From a35b51a1a1197efc33aae2031afe3aafdf1468b3 Mon Sep 17 00:00:00 2001 From: Vladimir Sokolovsky Date: Mon, 19 Sep 2016 16:28:18 +0300 Subject: [PATCH] compat: Added support for ib_core from kernel 4.8 on RHEL7.2 Signed-off-by: Vladimir Sokolovsky --- config/rdma.m4 | 389 +++++++++++++++++++++++++++++++++++- include/linux/compat-2.6.h | 2 + include/linux/compat-3.12.h | 7 +- include/linux/compat-3.17.h | 27 +++ include/linux/irq_poll.h | 10 + include/linux/mm.h | 16 ++ include/linux/printk.h | 66 +++++- include/linux/timekeeping.h | 15 ++ include/net/addrconf.h | 41 ++++ include/net/bonding.h | 24 +++ include/net/devlink.h | 10 + 11 files changed, 601 insertions(+), 6 deletions(-) create mode 100644 include/linux/compat-3.17.h create mode 100644 include/linux/irq_poll.h create mode 100644 include/linux/mm.h create mode 100644 include/linux/timekeeping.h create mode 100644 include/net/addrconf.h create mode 100644 include/net/bonding.h create mode 100644 include/net/devlink.h diff --git a/config/rdma.m4 b/config/rdma.m4 index 7e100fa..50555da 100644 --- a/config/rdma.m4 +++ b/config/rdma.m4 @@ -187,6 +187,38 @@ AC_DEFUN([LINUX_CONFIG_COMPAT], AC_MSG_RESULT(no) ]) + AC_MSG_CHECKING([if kernel has ktime_get_boot_ns]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + unsigned long long ns; + + ns = ktime_get_boot_ns(); + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_KTIME_GET_BOOT_NS, 1, + [ktime_get_boot_ns defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if timekeeping.h has ktime_get_real_ns]) + LB_LINUX_TRY_COMPILE([ + #include + #include + ],[ + ktime_get_real_ns(); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_KTIME_GET_REAL_NS, 1, + [ktime_get_real_ns is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + AC_MSG_CHECKING([if svc_xprt_class has xcl_ident]) LB_LINUX_TRY_COMPILE([ #include @@ -754,7 +786,7 @@ AC_DEFUN([LINUX_CONFIG_COMPAT], ],[ enum pci_bus_speed speed = PCI_SPEED_UNKNOWN; - return 0; + return speed; ],[ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_PCI_BUS_SPEED, 1, @@ -2327,6 +2359,361 @@ AC_DEFUN([LINUX_CONFIG_COMPAT], ],[ AC_MSG_RESULT(no) ]) + + AC_MSG_CHECKING([if include/linux/irq_poll.h exists]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_IRQ_POLL_H, 1, + [include/linux/irq_poll.h exists]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if linux/dma-mapping.h has struct dma_attrs]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + struct dma_attrs *attrs; + int ret; + + ret = dma_get_attr(DMA_ATTR_WRITE_BARRIER, attrs); + + return ret; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_STRUCT_DMA_ATTRS, 1, + [struct dma_attrs is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if pci.h has pcie_get_minimum_link]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + int ret; + ret = pcie_get_minimum_link(NULL, NULL, NULL); + + return ret; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_PCIE_GET_MINIMUM_LINK, 1, + [pcie_get_minimum_link is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if netdevice.h has netdev_for_each_all_upper_dev_rcu]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + struct net_device *dev; + struct net_device *upper; + struct list_head *list; + + netdev_for_each_all_upper_dev_rcu(dev, upper, list); + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_NETDEV_FOR_EACH_ALL_UPPER_DEV_RCU, 1, + [netdev_master_upper_dev_get_rcu is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if netdevice.h has netdev_has_upper_dev]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + struct net_device *dev; + struct net_device *upper; + netdev_has_upper_dev(dev, upper); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_NETDEV_HAS_UPPER_DEV, 1, + [netdev_has_upper_dev is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if ethtool.h has __ethtool_get_link_ksettings]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + __ethtool_get_link_ksettings(NULL, NULL); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE___ETHTOOL_GET_LINK_KSETTINGS, 1, + [__ethtool_get_link_ksettings is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if addrconf.h has addrconf_ifid_eui48]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + int x = addrconf_ifid_eui48(NULL, NULL); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_ADDRCONF_IFID_EUI48, 1, + [addrconf_ifid_eui48 is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if mm.h get_user_pages has 6 params]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + get_user_pages(0, 0, 0, 0, NULL, NULL); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GET_USER_PAGES_6_PARAMS, 1, + [get_user_pages has 6 params]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if mm.h get_user_pages_remote]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + get_user_pages_remote(NULL, NULL, 0, 0, 0, 0, NULL, NULL); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GET_USER_PAGES_REMOTE, 1, + [get_user_pages_remote exist]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if ip_fib.h fib_lookup has 4 params]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + fib_lookup(NULL, NULL, NULL, 0); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_FIB_LOOKUP_4_PARAMS, 1, + [fib_lookup has 4 params]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if include/net/devlink.h exists]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_NET_DEVLINK_H, 1, + [include/net/devlink.h exists]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if io_mapping_map_wc has 3 params]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + io_mapping_map_wc(NULL, 0, 0); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_IO_MAPPING_MAP_WC_3_PARAMS, 1, + [io_mapping_map_wc has 3 params]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if include/net/dcbnl.h struct dcbnl_rtnl_ops has *ieee_getqcn]) + LB_LINUX_TRY_COMPILE([ + #include + #include + ],[ + struct dcbnl_rtnl_ops x = { + .ieee_getqcn = NULL, + }; + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_IEEE_GETQCN, 1, + [ieee_getqcn is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if dcbnl.h has struct ieee_qcn]) + LB_LINUX_TRY_COMPILE([ + #include + #include + ],[ + struct ieee_qcn x; + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_STRUCT_IEEE_QCN, 1, + [ieee_qcn is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if netdevice.h has napi_consume_skb]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + napi_consume_skb(NULL, 0); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_NAPI_CONSUME_SKB, 1, + [napi_consume_skb is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if include/linux/bpf.h exists]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_LINUX_BPF_H, 1, + [include/linux/bpf.h exists]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if mm_types.h struct page has _count]) + LB_LINUX_TRY_COMPILE([ + #include + #include + ],[ + struct page p; + p._count.counter = 0; + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_MM_PAGE__COUNT, 1, + [struct page has _count]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if include/linux/page_ref.h exists]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_LINUX_PAGE_REF_H, 1, + [include/linux/page_ref.h exists]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if linux/ethtool.h has ETHTOOL_xLINKSETTINGS API]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + enum ethtool_link_mode_bit_indices x = ETHTOOL_LINK_MODE_TP_BIT; + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_ETHTOOL_xLINKSETTINGS, 1, + [ETHTOOL_xLINKSETTINGS API is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if linux/printk.h exists]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_LINUX_PRINTK_H, 1, + [linux/printk.h is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if printk.h has struct va_format]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + struct va_format x; + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_VA_FORMAT, 1, + [va_format is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if irq.h irq_data has member affinity]) + LB_LINUX_TRY_COMPILE([ + #include + #include + ],[ + cpumask_var_t x; + struct irq_data y = { + .affinity = x, + }; + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_IRQ_DATA_AFFINITY, 1, + [irq_data member affinity is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if irq.h irq_data_get_affinity_mask]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + irq_data_get_affinity_mask(NULL); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_IRQ_DATA_GET_AFFINITY_MASK, 1, + [irq_data_get_affinity_mask exist]) + ],[ + AC_MSG_RESULT(no) + ]) + ]) # # COMPAT_CONFIG_HEADERS diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index e172a84..62b4e31 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -19,6 +19,7 @@ #endif #include #include +#include #include /* @@ -73,5 +74,6 @@ void backport_dependency_symbol(void); #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ diff --git a/include/linux/compat-3.12.h b/include/linux/compat-3.12.h index 7f06dfd..007d4a6 100644 --- a/include/linux/compat-3.12.h +++ b/include/linux/compat-3.12.h @@ -2,10 +2,9 @@ #define LINUX_3_12_COMPAT_H #include +#include <../../compat/config.h> #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0)) -#include -#include #ifndef PTR_ERR_OR_ZERO #define PTR_ERR_OR_ZERO(p) PTR_RET(p) @@ -19,6 +18,8 @@ static inline struct inode *file_inode(struct file *f) return f->f_dentry->d_inode; } +#include + #ifndef HAVE_PCIE_LINK_WIDTH /* These values come from the PCI Express Spec */ enum pcie_link_width { @@ -36,8 +37,10 @@ enum pcie_link_width { extern const unsigned char pcie_link_speed[]; +#ifndef HAVE_PCIE_GET_MINIMUM_LINK #define pcie_get_minimum_link LINUX_BACKPORT(pcie_get_minimum_link) int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed, enum pcie_link_width *width); +#endif #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0)) */ #endif /* LINUX_3_12_COMPAT_H */ diff --git a/include/linux/compat-3.17.h b/include/linux/compat-3.17.h new file mode 100644 index 0000000..0e5e424 --- /dev/null +++ b/include/linux/compat-3.17.h @@ -0,0 +1,27 @@ +#ifndef LINUX_3_17_COMPAT_H +#define LINUX_3_17_COMPAT_H + +#include +#include "../../compat/config.h" + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)) + +#ifndef HAVE_KTIME_GET_REAL_NS +#include +#include +static inline u64 ktime_get_real_ns(void) { + return ktime_to_ns(ktime_get_real()); +} +#endif /* HAVE_KTIME_GET_REAL_NS */ + +#ifndef HAVE_KTIME_GET_BOOT_NS +#include +static inline u64 ktime_get_boot_ns(void) +{ + return ktime_to_ns(ktime_get_boottime()); +} +#endif /* HAVE_KTIME_GET_BOOT_NS */ + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)) */ + +#endif /* LINUX_3_17_COMPAT_H */ diff --git a/include/linux/irq_poll.h b/include/linux/irq_poll.h new file mode 100644 index 0000000..bf3fe72 --- /dev/null +++ b/include/linux/irq_poll.h @@ -0,0 +1,10 @@ +#ifndef _COMPAT_LINUX_IRQ_POLL_H +#define _COMPAT_LINUX_IRQ_POLL_H 1 + +#include "../../compat/config.h" + +#ifdef HAVE_IRQ_POLL_H +#include_next +#endif + +#endif /* _COMPAT_LINUX_IRQ_POLL_H */ diff --git a/include/linux/mm.h b/include/linux/mm.h new file mode 100644 index 0000000..9aae7bb --- /dev/null +++ b/include/linux/mm.h @@ -0,0 +1,16 @@ +#ifndef _COMPAT_LINUX_MM_H +#define _COMPAT_LINUX_MM_H 1 + +#include "../../compat/config.h" +#include_next + +#ifdef HAVE_GET_USER_PAGES_6_PARAMS +#define get_user_pages(p1, p2, p3, p4, p5, p6, p7, p8) \ + get_user_pages(p3, p4, p5, p6, p7, p8) +#endif + +#ifndef HAVE_GET_USER_PAGES_REMOTE +#define get_user_pages_remote get_user_pages +#endif + +#endif /* _COMPAT_LINUX_MM_H */ diff --git a/include/linux/printk.h b/include/linux/printk.h index c0822ac..dc8f99e 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -2,11 +2,71 @@ #define _COMPAT_LINUX_PRINTK_H 1 #include +#include "../../compat/config.h" -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36)) +#ifdef HAVE_LINUX_PRINTK_H #include_next -#else +#else /* HAVE_LINUX_PRINTK_H */ #include -#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,35)) */ + +#define pr_emerg_once(fmt, ...) \ + printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) +#define pr_alert_once(fmt, ...) \ + printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) +#define pr_crit_once(fmt, ...) \ + printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) +#define pr_err_once(fmt, ...) \ + printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) +#define pr_warn_once(fmt, ...) \ + printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) +#define pr_warn pr_warning +#define pr_notice_once(fmt, ...) \ + printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) +#define pr_info_once(fmt, ...) \ + printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) +#define pr_cont_once(fmt, ...) \ + printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__) +#if defined(DEBUG) +#define pr_debug_once(fmt, ...) \ + printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) +#else +#define pr_debug_once(fmt, ...) \ + no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) +#endif + +/* + * ratelimited messages with local ratelimit_state, + * no local ratelimit_state used in the !PRINTK case + */ +#ifndef printk_ratelimited +#ifdef CONFIG_PRINTK +#define printk_ratelimited(fmt, ...) \ +({ \ + static DEFINE_RATELIMIT_STATE(_rs, \ + DEFAULT_RATELIMIT_INTERVAL, \ + DEFAULT_RATELIMIT_BURST); \ + \ + if (__ratelimit(&_rs)) \ + printk(fmt, ##__VA_ARGS__); \ +}) +#else +#define printk_ratelimited(fmt, ...) \ + no_printk(fmt, ##__VA_ARGS__) +#endif +#endif /* ifndef printk_ratelimited */ + +#ifndef printk_once +#define printk_once(fmt, ...) \ +({ \ + static bool __print_once; \ + \ + if (!__print_once) { \ + __print_once = true; \ + printk(fmt, ##__VA_ARGS__); \ + } \ +}) +#endif + +#endif /* HAVE_LINUX_PRINTK_H */ #endif /* _COMPAT_LINUX_PRINTK_H */ diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h new file mode 100644 index 0000000..98ba9c5 --- /dev/null +++ b/include/linux/timekeeping.h @@ -0,0 +1,15 @@ +#ifndef COMPAT_LINUX_TIMEKEEPING_H +#define COMPAT_LINUX_TIMEKEEPING_H + +#include "../../compat/config.h" + +#include_next + +#ifndef HAVE_KTIME_GET_NS +static inline u64 ktime_get_ns(void) +{ + return ktime_to_ns(ktime_get()); +} +#endif /* HAVE_KTIME_TO_NS */ + +#endif /* COMPAT_LINUX_TIMEKEEPING_H */ diff --git a/include/net/addrconf.h b/include/net/addrconf.h new file mode 100644 index 0000000..2e9b110 --- /dev/null +++ b/include/net/addrconf.h @@ -0,0 +1,41 @@ +#ifndef LINUX_ADDRCONF_H +#define LINUX_ADDRCONF_H + +#include "../../compat/config.h" + +#include_next + +#ifndef HAVE_ADDRCONF_IFID_EUI48 +static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev) +{ + if (dev->addr_len != ETH_ALEN) + return -1; + memcpy(eui, dev->dev_addr, 3); + memcpy(eui + 5, dev->dev_addr + 3, 3); + + /* + * The zSeries OSA network cards can be shared among various + * OS instances, but the OSA cards have only one MAC address. + * This leads to duplicate address conflicts in conjunction + * with IPv6 if more than one instance uses the same card. + * + * The driver for these cards can deliver a unique 16-bit + * identifier for each instance sharing the same card. It is + * placed instead of 0xFFFE in the interface identifier. The + * "u" bit of the interface identifier is not inverted in this + * case. Hence the resulting interface identifier has local + * scope according to RFC2373. + */ + if (dev->dev_id) { + eui[3] = (dev->dev_id >> 8) & 0xFF; + eui[4] = dev->dev_id & 0xFF; + } else { + eui[3] = 0xFF; + eui[4] = 0xFE; + eui[0] ^= 2; + } + return 0; +} +#endif + +#endif /* LINUX_ADDRCONF_H */ diff --git a/include/net/bonding.h b/include/net/bonding.h new file mode 100644 index 0000000..08ee8c9 --- /dev/null +++ b/include/net/bonding.h @@ -0,0 +1,24 @@ +#ifndef LINUX_BONDING_H +#define LINUX_BONDING_H + +#include "../../compat/config.h" + +#ifdef HAVE_BONDING_H +#include_next + +#define MLX_USES_PRIMARY(mode) \ + (((mode) == BOND_MODE_ACTIVEBACKUP) || \ + ((mode) == BOND_MODE_TLB) || \ + ((mode) == BOND_MODE_ALB)) + +#define bond_option_active_slave_get_rcu LINUX_BACKPORT(bond_option_active_slave_get_rcu) +static inline struct net_device *bond_option_active_slave_get_rcu(struct bonding + *bond) +{ + struct slave *slave = rcu_dereference(bond->curr_active_slave); + + return MLX_USES_PRIMARY(bond->params.mode) && slave ? slave->dev : NULL; +} +#endif /* HAVE_BONDING_H */ + +#endif /* LINUX_BONDING_H */ diff --git a/include/net/devlink.h b/include/net/devlink.h new file mode 100644 index 0000000..164737d --- /dev/null +++ b/include/net/devlink.h @@ -0,0 +1,10 @@ +#ifndef _COMPAT_NET_DEVLINK_H +#define _COMPAT_NET_DEVLINK_H 1 + +#include "../../compat/config.h" + +#ifdef HAVE_NET_DEVLINK_H +#include_next +#endif + +#endif /* _COMPAT_NET_DEVLINK_H */ -- 2.46.0