diff options
author | Todd Fujinaka <todd.fujinaka@intel.com> | 2016-01-13 07:31:42 -0800 |
---|---|---|
committer | Todd Fujinaka <todd.fujinaka@intel.com> | 2016-01-13 07:31:42 -0800 |
commit | 72e0646dcfdcbc21950fa3b9861a019995681c40 (patch) | |
tree | 197ebde8663e15b919c3385bd61ac4c8bce81a0b | |
parent | 3fb708f1701097ab9ea7fb128ef3283f19c407fa (diff) | |
download | Open-AVB-72e0646dcfdcbc21950fa3b9861a019995681c40.tar.gz |
igb_avb: sync kcompat.[ch] with upstream
Sync kernel compatibility code for older kernel versions with upstream.
Signed-off-by: Todd Fujinaka <todd.fujinaka@intel.com>
-rw-r--r-- | kmod/igb/kcompat.c | 73 | ||||
-rw-r--r-- | kmod/igb/kcompat.h | 159 |
2 files changed, 196 insertions, 36 deletions
diff --git a/kmod/igb/kcompat.c b/kmod/igb/kcompat.c index 13bfda9e..c905fd3c 100644 --- a/kmod/igb/kcompat.c +++ b/kmod/igb/kcompat.c @@ -1059,21 +1059,19 @@ void _kc_netif_tx_start_all_queues(struct net_device *netdev) } #endif /* HAVE_TX_MQ */ -#ifndef __WARN_printf void __kc_warn_slowpath(const char *file, int line, const char *fmt, ...) { va_list args; printk(KERN_WARNING "------------[ cut here ]------------\n"); - printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file, line); + printk(KERN_WARNING "WARNING: at %s:%d \n", file, line); va_start(args, fmt); vprintk(fmt, args); va_end(args); dump_stack(); } -#endif /* __WARN_printf */ -#endif /* < 2.6.27 */ +#endif /* __VMKLNX__ */ /*****************************************************************************/ #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) ) @@ -1166,17 +1164,18 @@ int _kc_pci_num_vf(struct pci_dev __maybe_unused *dev) #ifdef HAVE_TX_MQ #if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0))) #ifndef CONFIG_NETDEVICES_MULTIQUEUE -void _kc_netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq) +int _kc_netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq) { unsigned int real_num = dev->real_num_tx_queues; struct Qdisc *qdisc; int i; - if (unlikely(txq > dev->num_tx_queues)) - ; + if (txq < 1 || txq > dev->num_tx_queues) + return -EINVAL; + else if (txq > real_num) dev->real_num_tx_queues = txq; - else if ( txq < real_num) { + else if (txq < real_num) { dev->real_num_tx_queues = txq; for (i = txq; i < dev->num_tx_queues; i++) { qdisc = netdev_get_tx_queue(dev, i)->qdisc; @@ -1187,6 +1186,8 @@ void _kc_netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq) } } } + + return 0; } #endif /* CONFIG_NETDEVICES_MULTIQUEUE */ #endif /* !(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0)) */ @@ -1544,6 +1545,62 @@ int __kc_pci_vfs_assigned(struct pci_dev __maybe_unused *dev) #endif /* CONFIG_PCI_IOV */ #endif /* 3.10.0 */ +/*****************************************************************************/ +#if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0) ) +const unsigned char pcie_link_speed[] = { + PCI_SPEED_UNKNOWN, /* 0 */ + PCIE_SPEED_2_5GT, /* 1 */ + PCIE_SPEED_5_0GT, /* 2 */ + PCIE_SPEED_8_0GT, /* 3 */ + PCI_SPEED_UNKNOWN, /* 4 */ + PCI_SPEED_UNKNOWN, /* 5 */ + PCI_SPEED_UNKNOWN, /* 6 */ + PCI_SPEED_UNKNOWN, /* 7 */ + PCI_SPEED_UNKNOWN, /* 8 */ + PCI_SPEED_UNKNOWN, /* 9 */ + PCI_SPEED_UNKNOWN, /* A */ + PCI_SPEED_UNKNOWN, /* B */ + PCI_SPEED_UNKNOWN, /* C */ + PCI_SPEED_UNKNOWN, /* D */ + PCI_SPEED_UNKNOWN, /* E */ + PCI_SPEED_UNKNOWN /* F */ +}; + +int __kc_pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed, + enum pcie_link_width *width) +{ + int ret; + + *speed = PCI_SPEED_UNKNOWN; + *width = PCIE_LNK_WIDTH_UNKNOWN; + + while (dev) { + u16 lnksta; + enum pci_bus_speed next_speed; + enum pcie_link_width next_width; + + ret = pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnksta); + if (ret) + return ret; + + next_speed = pcie_link_speed[lnksta & PCI_EXP_LNKSTA_CLS]; + next_width = (lnksta & PCI_EXP_LNKSTA_NLW) >> + PCI_EXP_LNKSTA_NLW_SHIFT; + + if (next_speed < *speed) + *speed = next_speed; + + if (next_width < *width) + *width = next_width; + + dev = dev->bus->self; + } + + return 0; +} + +#endif + #if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0) ) int __kc_dma_set_mask_and_coherent(struct device *dev, u64 mask) { diff --git a/kmod/igb/kcompat.h b/kmod/igb/kcompat.h index 845f5baa..ab9d8600 100644 --- a/kmod/igb/kcompat.h +++ b/kmod/igb/kcompat.h @@ -2021,12 +2021,6 @@ static inline int _kc_skb_padto(struct sk_buff *skb, unsigned int len) /*****************************************************************************/ #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) ) - -/* other values will be created as #defines later */ -enum pci_bus_speed { - PCI_SPEED_UNKNOWN = 0xff, -}; - enum pcie_link_width { PCIE_LNK_WIDTH_RESRV = 0x00, PCIE_LNK_X1 = 0x01, @@ -2743,6 +2737,13 @@ static inline void __kc_skb_queue_head_init(struct sk_buff_head *list) #define PCI_EXP_SLTSTA_PDS 0x0040 /* Presence Detect State */ +#ifndef PCI_EXP_LNKSTA_CLS +#define PCI_EXP_LNKSTA_CLS 0x000f /* Current Link Speed */ +#endif +#ifndef PCI_EXP_LNKSTA_NLW +#define PCI_EXP_LNKSTA_NLW 0x03f0 /* Negotiated Link Width */ +#endif + #ifndef pci_clear_master extern void _kc_pci_clear_master(struct pci_dev *dev); #define pci_clear_master(dev) _kc_pci_clear_master(dev) @@ -3204,9 +3205,20 @@ static inline bool _kc_pm_runtime_suspended(struct device __always_unused *dev) #endif #endif /* 2.6.0 => 2.6.34 */ -#define PCIE_SPEED_2_5GT 0x14 -#define PCIE_SPEED_5_0GT 0x15 -#define PCIE_SPEED_8_0GT 0x16 +#ifndef pci_bus_speed +/* override pci_bus_speed introduced in 2.6.19 with an expanded enum type */ +enum _kc_pci_bus_speed { + _KC_PCIE_SPEED_2_5GT = 0x14, + _KC_PCIE_SPEED_5_0GT = 0x15, + _KC_PCIE_SPEED_8_0GT = 0x16, + _KC_PCI_SPEED_UNKNOWN = 0xff, +}; +#define pci_bus_speed _kc_pci_bus_speed +#define PCIE_SPEED_2_5GT _KC_PCIE_SPEED_2_5GT +#define PCIE_SPEED_5_0GT _KC_PCIE_SPEED_5_0GT +#define PCIE_SPEED_8_0GT _KC_PCIE_SPEED_8_0GT +#define PCI_SPEED_UNKNOWN _KC_PCI_SPEED_UNKNOWN +#endif /* pci_bus_speed */ #else /* < 2.6.34 */ #define HAVE_SYSTEM_SLEEP_PM_OPS @@ -3232,22 +3244,29 @@ ssize_t _kc_simple_write_to_buffer(void *to, size_t available, loff_t *ppos, #ifndef numa_mem_id #define numa_mem_id numa_node_id #endif +#if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0))) #ifdef HAVE_TX_MQ #include <net/sch_generic.h> #ifndef CONFIG_NETDEVICES_MULTIQUEUE -#if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0))) -void _kc_netif_set_real_num_tx_queues(struct net_device *, unsigned int); -#define netif_set_real_num_tx_queues _kc_netif_set_real_num_tx_queues -#endif /* !(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0)) */ +int _kc_netif_set_real_num_tx_queues(struct net_device *, unsigned int); #else /* CONFIG_NETDEVICES_MULTI_QUEUE */ -#define netif_set_real_num_tx_queues(_netdev, _count) \ - do { \ - (_netdev)->egress_subqueue_count = _count; \ - } while (0) +static inline int _kc_netif_set_real_num_tx_queues(struct net_device *dev, + unsigned int txq) +{ + dev->egress_subqueue_count = txq; + return 0; +} #endif /* CONFIG_NETDEVICES_MULTI_QUEUE */ #else /* HAVE_TX_MQ */ -#define netif_set_real_num_tx_queues(_netdev, _count) do {} while(0) +static inline int _kc_netif_set_real_num_tx_queues(struct net_device __always_unused *dev, + unsigned int __always_unused txq) +{ + return 0; +} #endif /* HAVE_TX_MQ */ +#define netif_set_real_num_tx_queues(dev, txq) \ + _kc_netif_set_real_num_tx_queues(dev, txq) +#endif /* !(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0)) */ #ifndef ETH_FLAG_RXHASH #define ETH_FLAG_RXHASH (1<<28) #endif /* ETH_FLAG_RXHASH */ @@ -3341,6 +3360,16 @@ static inline void skb_tx_timestamp(struct sk_buff __always_unused *skb) /*****************************************************************************/ #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) ) +#ifndef netif_set_real_num_tx_queues +static inline int _kc_netif_set_real_num_tx_queues(struct net_device *dev, + unsigned int txq) +{ + netif_set_real_num_tx_queues(dev, txq); + return 0; +} +#define netif_set_real_num_tx_queues(dev, txq) \ + _kc_netif_set_real_num_tx_queues(dev, txq) +#endif #ifndef netif_set_real_num_rx_queues static inline int __kc_netif_set_real_num_rx_queues(struct net_device __always_unused *dev, unsigned int __always_unused rxq) @@ -4074,6 +4103,51 @@ static inline bool __kc_is_link_local_ether_addr(const u8 *addr) /*****************************************************************************/ #if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0) ) +#undef BUILD_BUG_ON +#ifdef __CHECKER__ +#define BUILD_BUG_ON(condition) (0) +#else /* __CHECKER__ */ +#ifndef __compiletime_warning +#if defined(__GNUC__) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40400) +#define __compiletime_warning(message) __attribute__((warning(message))) +#else /* __GNUC__ */ +#define __compiletime_warning(message) +#endif /* __GNUC__ */ +#endif /* __compiletime_warning */ +#ifndef __compiletime_error +#if defined(__GNUC__) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40400) +#define __compiletime_error(message) __attribute__((error(message))) +#define __compiletime_error_fallback(condition) do { } while (0) +#else /* __GNUC__ */ +#define __compiletime_error(message) +#define __compiletime_error_fallback(condition) \ + do { ((void)sizeof(char[1 - 2 * condition])); } while (0) +#endif /* __GNUC__ */ +#else /* __compiletime_error */ +#define __compiletime_error_fallback(condition) do { } while (0) +#endif /* __compiletime_error */ +#define __compiletime_assert(condition, msg, prefix, suffix) \ + do { \ + bool __cond = !(condition); \ + extern void prefix ## suffix(void) __compiletime_error(msg); \ + if (__cond) \ + prefix ## suffix(); \ + __compiletime_error_fallback(__cond); \ + } while (0) + +#define _compiletime_assert(condition, msg, prefix, suffix) \ + __compiletime_assert(condition, msg, prefix, suffix) +#define compiletime_assert(condition, msg) \ + _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) +#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) +#ifndef __OPTIMIZE__ +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) +#else /* __OPTIMIZE__ */ +#define BUILD_BUG_ON(condition) \ + BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) +#endif /* __OPTIMIZE__ */ +#endif /* __CHECKER__ */ + #undef hlist_entry #define hlist_entry(ptr, type, member) container_of(ptr,type,member) @@ -4178,6 +4252,10 @@ extern int __kc_ndo_dflt_fdb_del(struct ndmsg *ndm, struct net_device *dev, /*****************************************************************************/ #if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0) ) +#if ((RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,6)) ||\ + (SLE_VERSION_CODE && SLE_VERSION_CODE >= SLE_VERSION(11,4,0))) +#define HAVE_NDO_SET_VF_LINK_STATE +#endif #else /* >= 3.11.0 */ #define HAVE_NDO_SET_VF_LINK_STATE #define HAVE_SKB_INNER_PROTOCOL @@ -4259,11 +4337,7 @@ static inline void __kc_skb_set_hash(struct sk_buff __maybe_unused *skb, } #endif /* !skb_set_hash */ -#else - -#ifndef HAVE_ENCAP_TSO_OFFLOAD -#define HAVE_ENCAP_TSO_OFFLOAD -#endif /* HAVE_ENCAP_TSO_OFFLOAD */ +#else /* RHEL_RELEASE_CODE >= 7.0 || SLE_VERSION_CODE >= 12.0 */ #ifndef HAVE_VXLAN_RX_OFFLOAD #define HAVE_VXLAN_RX_OFFLOAD @@ -4272,7 +4346,7 @@ static inline void __kc_skb_set_hash(struct sk_buff __maybe_unused *skb, #ifndef HAVE_VXLAN_CHECKS #define HAVE_VXLAN_CHECKS #endif /* HAVE_VXLAN_CHECKS */ -#endif /* !(RHEL_RELEASE_CODE&&RHEL_RELEASE_CODE>=RHEL_RELEASE_VERSION(7,0)) */ +#endif /* !(RHEL_RELEASE_CODE >= 7.0 && SLE_VERSION_CODE >= 12.0) */ #ifndef pci_enable_msix_range extern int __kc_pci_enable_msix_range(struct pci_dev *dev, @@ -4474,6 +4548,12 @@ extern unsigned int __kc_eth_get_headlen(unsigned char *data, unsigned int max_l /* netdev_phys_port_id renamed to netdev_phys_item_id */ #define netdev_phys_item_id netdev_phys_port_id +static inline void _kc_napi_complete_done(struct napi_struct *napi, + int __always_unused work_done) { + napi_complete(napi); +} +#define napi_complete_done _kc_napi_complete_done + #ifndef NETDEV_RSS_KEY_LEN #define NETDEV_RSS_KEY_LEN (13 * 4) #endif @@ -4526,18 +4606,23 @@ static inline int __kc_eth_skb_pad(struct sk_buff *skb) #define eth_skb_pad(skb) __kc_eth_skb_pad(skb) #endif /* eth_skb_pad && skb_put_padto */ -#ifndef napi_alloc_skb +#ifndef SKB_ALLOC_NAPI +/* RHEL 7.2 backported napi_alloc_skb and friends */ static inline struct sk_buff *__kc_napi_alloc_skb(struct napi_struct *napi, unsigned int length) { return netdev_alloc_skb_ip_align(napi->dev, length); } #define napi_alloc_skb(napi,len) __kc_napi_alloc_skb(napi,len) -#endif /* napi_alloc_skb */ +#define __napi_alloc_skb(napi,len,mask) __kc_napi_alloc_skb(napi,len) +#endif /* SKB_ALLOC_NAPI */ #define HAVE_CONFIG_PM_RUNTIME #if RHEL_RELEASE_CODE && (RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(7,1)) #define NDO_DFLT_BRIDGE_GETLINK_HAS_BRFLAGS #define HAVE_RXFH_HASHFUNC #endif /* RHEL_RELEASE_CODE */ +#ifndef napi_schedule_irqoff +#define napi_schedule_irqoff napi_schedule +#endif #else /* 3.19.0 */ #define HAVE_NDO_FDB_ADD_VID #define HAVE_RXFH_HASHFUNC @@ -4576,9 +4661,10 @@ static inline void __kc_timecounter_adjtime(struct timecounter *tc, s64 delta) #else #define HAVE_PTP_CLOCK_INFO_GETTIME64 #define HAVE_NDO_BRIDGE_GETLINK_NLFLAGS +#define HAVE_PASSTHRU_FEATURES_CHECK #endif /* 4,1,0 */ -#if ( LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0) ) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,1,9)) #if (!(SLE_VERSION_CODE && SLE_VERSION_CODE >= SLE_VERSION(12,1,0))) static inline bool page_is_pfmemalloc(struct page __maybe_unused *page) { @@ -4589,10 +4675,27 @@ static inline bool page_is_pfmemalloc(struct page __maybe_unused *page) #endif } #endif /* !SLES12sp1 */ +#else +#undef HAVE_STRUCT_PAGE_PFMEMALLOC +#endif /* 4.1.9 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)) #else #define HAVE_NDO_DFLT_BRIDGE_GETLINK_VLAN_SUPPORT -#undef HAVE_STRUCT_PAGE_PFMEMALLOC #endif /* 4.2.0 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,4,0)) +#else +#define HAVE_NDO_SET_VF_TRUST +#endif /* 4.4.0 */ + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)) +/* protect against a likely backport */ +#ifndef NETIF_F_CSUM_MASK +#define NETIF_F_CSUM_MASK NETIF_F_ALL_CSUM +#endif /* NETIF_F_CSUM_MASK */ +#else +#define HAVE_GENEVE_RX_OFFLOAD +#endif /* 4.5.0 */ + #endif /* _KCOMPAT_H_ */ |