From 4bf50fd71803c27cf181c3b5fcea53a664d0887f Mon Sep 17 00:00:00 2001 From: Vladimir Sokolovsky Date: Wed, 28 Aug 2019 16:24:20 -0500 Subject: [PATCH] Added support for mlx4_en on RHEL7.6 Signed-off-by: Vladimir Sokolovsky --- compat/bitmap.c | 60 +++++++++++ config/rdma.m4 | 219 +++++++++++++++++++++++++++++++++++++- include/linux/bitmap.h | 39 +++++++ include/linux/netdevice.h | 4 + 4 files changed, 321 insertions(+), 1 deletion(-) create mode 100644 compat/bitmap.c create mode 100644 include/linux/bitmap.h diff --git a/compat/bitmap.c b/compat/bitmap.c new file mode 100644 index 0000000..86263d3 --- /dev/null +++ b/compat/bitmap.c @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifndef HAVE_BITMAP_KZALLOC +unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags) +{ + return kmalloc_array(BITS_TO_LONGS(nbits), sizeof(unsigned long), + flags); +} +EXPORT_SYMBOL(bitmap_alloc); + +unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags) +{ + return bitmap_alloc(nbits, flags | __GFP_ZERO); +} +EXPORT_SYMBOL(bitmap_zalloc); +#endif + +#ifndef HAVE_BITMAP_FREE +#define bitmap_free LINUX_BACKPORT(bitmap_free) +void bitmap_free(const unsigned long *bitmap) +{ + kfree(bitmap); +} +EXPORT_SYMBOL(bitmap_free); +#endif + +#ifndef HAVE_BITMAP_FROM_ARR32 +#if BITS_PER_LONG == 64 +void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, + unsigned int nbits) +{ + unsigned int i, halfwords; + + halfwords = DIV_ROUND_UP(nbits, 32); + for (i = 0; i < halfwords; i++) { + bitmap[i/2] = (unsigned long) buf[i]; + if (++i < halfwords) + bitmap[i/2] |= ((unsigned long) buf[i]) << 32; + } + + /* Clear tail bits in last word beyond nbits. */ + if (nbits % BITS_PER_LONG) + bitmap[(halfwords - 1) / 2] &= BITMAP_LAST_WORD_MASK(nbits); +} +EXPORT_SYMBOL(bitmap_from_arr32); +#endif +#endif diff --git a/config/rdma.m4 b/config/rdma.m4 index f917ad0..ff5148d 100644 --- a/config/rdma.m4 +++ b/config/rdma.m4 @@ -4307,7 +4307,7 @@ AC_DEFUN([LINUX_CONFIG_COMPAT], AC_MSG_CHECKING([if iscsi_transport.h has iscsit_set_unsolicited_dataout]) LB_LINUX_TRY_COMPILE([ #include - + ],[ iscsit_set_unsolicited_dataout(NULL); return 0; @@ -9691,6 +9691,223 @@ AC_DEFUN([LINUX_CONFIG_COMPAT], AC_MSG_RESULT(no) ]) + AC_MSG_CHECKING([if bitmap.h has bitmap_free]) + LB_LINUX_TRY_COMPILE([ + #include + #include + ],[ + unsigned long *bmap; + + bmap = kcalloc(BITS_TO_LONGS(1), sizeof(unsigned long), 0); + bitmap_free(bmap); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BITMAP_FREE, 1, + [bitmap_free is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if bitmap.h has bitmap_from_arr32]) + LB_LINUX_TRY_COMPILE([ + #include + #include + ],[ + unsigned long *bmap; + u32 *word; + + bmap = kcalloc(BITS_TO_LONGS(1), sizeof(unsigned long), 0); + bitmap_from_arr32(bmap, word, 1); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BITMAP_FROM_ARR32, 1, + [bitmap_from_arr32 is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if bitmap.h has bitmap_kzalloc]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + unsigned long *bmap; + + bmap = bitmap_zalloc(1, 0); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BITMAP_KZALLOC, 1, + [bitmap_kzalloc is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if cpumask.h has cpumask_available]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + cpumask_available(NULL); + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_CPUMASK_AVAILABLE, 1, + [cpumask_available is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if gfp.h has __GFP_DIRECT_RECLAIM]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + gfp_t gfp_mask = __GFP_DIRECT_RECLAIM; + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GFP_DIRECT_RECLAIM, 1, + [__GFP_DIRECT_RECLAIM is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if devlink has devlink_param_driverinit_value_get]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + devlink_param_driverinit_value_get(NULL, 0, NULL); + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DEVLINK_DRIVERINIT_VAL, 1, + [devlink_param_driverinit_value_get exist]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if struct devlink_param exist in net/devlink.h]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + struct devlink_param soso; + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DEVLINK_PARAM, 1, + [struct devlink_param exist]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if devlink enum has DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + int i = DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT; + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT, 1, + [struct devlink_param exist]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if netdevice.h has __netdev_tx_sent_queue]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + __netdev_tx_sent_queue(NULL, 0, 0); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_NETDEV_TX_SEND_QUEUE, 1, + [__netdev_tx_sent_queue is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + AC_MSG_CHECKING([if select_queue_fallback_t has third parameter]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + extern select_queue_fallback_t fallback; + fallback(NULL, NULL, NULL); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SELECT_QUEUE_FALLBACK_T_3_PARAMS, 1, + [select_queue_fallback_t has third parameter]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if ndo_select_queue has 3 parameters]) + LB_LINUX_TRY_COMPILE([ + #include + + u16 select_queue(struct net_device *dev, struct sk_buff *skb, + struct net_device *sb_dev) + { + return 0; + } + ],[ + struct net_device_ops ndops = { + .ndo_select_queue = select_queue, + }; + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_3_PARAMS_FOR_NDO_SELECT_QUEUE, 1, + [.ndo_select_queue has 3 parameters]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if ndo_select_queue has a second net_device parameter]) + LB_LINUX_TRY_COMPILE([ + #include + + static u16 select_queue(struct net_device *dev, struct sk_buff *skb, + struct net_device *sb_dev, + select_queue_fallback_t fallback) + { + return 0; + } + ],[ + struct net_device_ops ndops = { + .ndo_select_queue = select_queue, + }; + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SELECT_QUEUE_NET_DEVICE, 1, + [ndo_select_queue has a second net_device parameter]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if if_vlan.h has __vlan_hwaccel_clear_tag]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + __vlan_hwaccel_clear_tag(NULL); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE__VLAN_HWACCEL_CLEAR_TAG, 1, + [__vlan_hwaccel_clear_tag defined]) + ],[ + AC_MSG_RESULT(no) + ]) + ]) # # COMPAT_CONFIG_HEADERS diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h new file mode 100644 index 0000000..da46d3f --- /dev/null +++ b/include/linux/bitmap.h @@ -0,0 +1,39 @@ +#ifndef _COMPAT_LINUX_BITMAP_H +#define _COMPAT_LINUX_BITMAP_H + +#include "../../compat/config.h" + +#include_next + + +#ifndef HAVE_BITMAP_KZALLOC +extern unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags); +extern unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags); +#endif + +#ifndef HAVE_BITMAP_FREE +#define bitmap_free LINUX_BACKPORT(bitmap_free) +extern void bitmap_free(const unsigned long *bitmap); +#endif + +#ifndef HAVE_BITMAP_FROM_ARR32 +#if BITS_PER_LONG == 64 +extern void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, + unsigned int nbits); +#else + +static inline void bitmap_copy_clear_tail(unsigned long *dst, + const unsigned long *src, unsigned int nbits) +{ + bitmap_copy(dst, src, nbits); + if (nbits % BITS_PER_LONG) + dst[nbits / BITS_PER_LONG] &= BITMAP_LAST_WORD_MASK(nbits); +} + +#define bitmap_from_arr32(bitmap, buf, nbits) \ + bitmap_copy_clear_tail((unsigned long *) (bitmap), \ + (const unsigned long *) (buf), (nbits)) +#endif +#endif + +#endif /* _COMPAT_LINUX_BITMAP_H */ diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 255f3b7..eb02142 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -57,6 +57,10 @@ static inline int netdev_set_master(struct net_device *dev, alloc_netdev_mq(sizeof_priv, name, setup, \ max_t(unsigned int, txqs, rxqs)) #endif + +#ifndef HAVE_SELECT_QUEUE_FALLBACK_T +#define fallback(dev, skb) __netdev_pick_tx(dev, skb) +#endif #ifdef HAVE_REGISTER_NETDEVICE_NOTIFIER_RH #define register_netdevice_notifier register_netdevice_notifier_rh #define unregister_netdevice_notifier unregister_netdevice_notifier_rh -- 2.46.0