Added support for mlx4_en on RHEL7.6
authorVladimir Sokolovsky <vlad@mellanox.com>
Wed, 28 Aug 2019 21:24:20 +0000 (16:24 -0500)
committerVladimir Sokolovsky <vlad@mellanox.com>
Wed, 28 Aug 2019 21:24:20 +0000 (16:24 -0500)
Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
compat/bitmap.c [new file with mode: 0644]
config/rdma.m4
include/linux/bitmap.h [new file with mode: 0644]
include/linux/netdevice.h

diff --git a/compat/bitmap.c b/compat/bitmap.c
new file mode 100644 (file)
index 0000000..86263d3
--- /dev/null
@@ -0,0 +1,60 @@
+#include <linux/export.h>
+#include <linux/thread_info.h>
+#include <linux/ctype.h>
+#include <linux/errno.h>
+#include <linux/bitmap.h>
+#include <linux/bitops.h>
+#include <linux/bug.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/uaccess.h>
+
+#include <asm/page.h>
+
+#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
index f917ad0..ff5148d 100644 (file)
@@ -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 <target/iscsi/iscsi_transport.h>
-
+       ],[
                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 <linux/bitmap.h>
+               #include <linux/slab.h>
+       ],[
+               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 <linux/bitmap.h>
+               #include <linux/slab.h>
+       ],[
+               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 <linux/bitmap.h>
+       ],[
+               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 <linux/cpumask.h>
+       ],[
+                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 <linux/gfp.h>
+       ],[
+               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 <net/devlink.h>
+       ],[
+               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 <net/devlink.h>
+       ],[
+               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 <net/devlink.h>
+       ],[
+               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 <linux/netdevice.h>
+       ],[
+               __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 <linux/netdevice.h>
+       ],[
+               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 <linux/netdevice.h>
+
+               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 <linux/netdevice.h>
+
+               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 <linux/if_vlan.h>
+       ],[
+               __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 (file)
index 0000000..da46d3f
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef _COMPAT_LINUX_BITMAP_H
+#define _COMPAT_LINUX_BITMAP_H
+
+#include "../../compat/config.h"
+
+#include_next <linux/bitmap.h>
+
+
+#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 */
index 255f3b7..eb02142 100644 (file)
@@ -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