compat: Added macros and headers to support RHEL7.1
authorVladimir Sokolovsky <vlad@mellanox.com>
Mon, 12 Dec 2016 08:25:19 +0000 (10:25 +0200)
committerVladimir Sokolovsky <vlad@mellanox.com>
Mon, 12 Dec 2016 10:01:59 +0000 (12:01 +0200)
Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
compat/Makefile
compat/compat-4.1.c [new file with mode: 0644]
config/rdma.m4
include/linux/clocksource.h [new file with mode: 0644]
include/linux/compat-2.6.h
include/linux/compat-4.1.h [new file with mode: 0644]
include/linux/skbuff.h [new file with mode: 0644]

index 4de8583..51b7fa6 100644 (file)
@@ -57,6 +57,7 @@ compat-$(CONFIG_COMPAT_KERNEL_3_15) += compat-3.15.o
 compat-$(CONFIG_COMPAT_KERNEL_3_16) += compat-3.16.o
 compat-$(CONFIG_COMPAT_KERNEL_3_18) += compat-3.18.o
 compat-$(CONFIG_COMPAT_KERNEL_4_0) += compat-4.0.o
+compat-$(CONFIG_COMPAT_KERNEL_4_1) += compat-4.1.o
 
 compat-$(CONFIG_COMPAT_CORDIC) += cordic.o
 compat-$(CONFIG_COMPAT_CRC8) += crc8.o
diff --git a/compat/compat-4.1.c b/compat/compat-4.1.c
new file mode 100644 (file)
index 0000000..936cb0c
--- /dev/null
@@ -0,0 +1,48 @@
+#include <linux/slab.h>
+#include <linux/kernel.h>
+#include <linux/bitops.h>
+#include <linux/cpumask.h>
+#include <linux/export.h>
+#include <linux/bootmem.h>
+
+/**
+ * cpumask_local_spread - select the i'th cpu with local numa cpu's first
+ * @i: index number
+ * @node: local numa_node
+ *
+ * This function selects an online CPU according to a numa aware policy;
+ * local cpus are returned first, followed by non-local ones, then it
+ * wraps around.
+ *
+ * It's not very efficient, but useful for setup.
+ */
+#define cpumask_local_spread LINUX_BACKPORT(cpumask_local_spread)
+unsigned int cpumask_local_spread(unsigned int i, int node)
+{
+       int cpu;
+
+       /* Wrap: we always want a cpu. */
+       i %= num_online_cpus();
+
+       if (node == -1) {
+               for_each_cpu(cpu, cpu_online_mask)
+                       if (i-- == 0)
+                               return cpu;
+       } else {
+               /* NUMA first. */
+               for_each_cpu_and(cpu, cpumask_of_node(node), cpu_online_mask)
+                       if (i-- == 0)
+                               return cpu;
+
+               for_each_cpu(cpu, cpu_online_mask) {
+                       /* Skip NUMA nodes, done above. */
+                       if (cpumask_test_cpu(cpu, cpumask_of_node(node)))
+                               continue;
+
+                       if (i-- == 0)
+                               return cpu;
+               }
+       }
+       BUG();
+}
+EXPORT_SYMBOL(cpumask_local_spread);
index fc5f474..2ad9607 100644 (file)
@@ -2257,6 +2257,23 @@ AC_DEFUN([LINUX_CONFIG_COMPAT],
        ])
 
        # timecounter_adjtime can be in timecounter.h or clocksource.h
+       AC_MSG_CHECKING([if linux/clocksource.h has timecounter_adjtime])
+       LB_LINUX_TRY_COMPILE([
+               #include <linux/timecounter.h>
+       ],[
+               struct timecounter x;
+               s64 y = 0;
+               timecounter_adjtime(&x, y);
+
+               return 0;
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_TIMECOUNTER_ADJTIME, 1,
+                         [timecounter_adjtime is defined])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+
        AC_MSG_CHECKING([if linux/clocksource.h has timecounter_adjtime])
        LB_LINUX_TRY_COMPILE([
                #include <linux/clocksource.h>
@@ -3902,6 +3919,51 @@ AC_DEFUN([LINUX_CONFIG_COMPAT],
                AC_MSG_RESULT(no)
        ])
 
+       AC_MSG_CHECKING([if netdevice.h has napi_schedule_irqoff])
+       LB_LINUX_TRY_COMPILE([
+               #include <linux/netdevice.h>
+       ],[
+               napi_schedule_irqoff(NULL);
+
+               return 0;
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_NAPI_SCHEDULE_IRQOFF, 1,
+                         [napi_schedule_irqoff is defined])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+
+       AC_MSG_CHECKING([if skbuff.h has dev_alloc_pages])
+       LB_LINUX_TRY_COMPILE([
+               #include <linux/skbuff.h>
+       ],[
+               dev_alloc_pages(0);
+
+               return 0;
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_DEV_ALLOC_PAGES, 1,
+                         [dev_alloc_pages is defined])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+
+       AC_MSG_CHECKING([if skbuff.h has napi_alloc_skb])
+       LB_LINUX_TRY_COMPILE([
+               #include <linux/skbuff.h>
+       ],[
+               napi_alloc_skb(NULL, 0);
+
+               return 0;
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_NAPI_ALLOC_SKB, 1,
+                         [napi_alloc_skb is defined])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+
 ])
 #
 # COMPAT_CONFIG_HEADERS
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
new file mode 100644 (file)
index 0000000..d17cc03
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef LINUX_CLOCKSOURCE_H
+#define LINUX_CLOCKSOURCE_H
+
+#include <linux/version.h>
+#include "../../compat/config.h"
+
+#include_next <linux/clocksource.h>
+
+#ifndef HAVE_TIMECOUNTER_ADJTIME
+/**
+* timecounter_adjtime - Shifts the time of the clock.
+* @delta:     Desired change in nanoseconds.
+*/
+static inline void timecounter_adjtime(struct timecounter *tc, s64 delta)
+{
+       tc->nsec += delta;
+}
+#endif /* HAVE_TIMECOUNTER_H */
+
+#endif /* LINUX_CLOCKSOURCE_H */
index ef8ccf5..4c9714a 100644 (file)
@@ -76,6 +76,7 @@ void backport_dependency_symbol(void);
 #include <linux/compat-3.16.h>
 #include <linux/compat-3.17.h>
 #include <linux/compat-4.0.h>
+#include <linux/compat-4.1.h>
 #include <linux/compat-4.5.h>
 
 #endif /* LINUX_26_COMPAT_H */
diff --git a/include/linux/compat-4.1.h b/include/linux/compat-4.1.h
new file mode 100644 (file)
index 0000000..e04eca9
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef LINUX_4_1_COMPAT_H
+#define LINUX_4_1_COMPAT_H
+
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0))
+#include "../../compat/config.h"
+#include <linux/dma-mapping.h>
+
+#ifndef dma_rmb
+#define dma_rmb()       rmb()
+#endif
+
+#ifndef dma_wmb
+#define dma_wmb()       wmb()
+#endif
+
+#include <linux/cpumask.h>
+
+#define cpumask_local_spread LINUX_BACKPORT(cpumask_local_spread)
+
+#if NR_CPUS == 1
+static inline unsigned int cpumask_local_spread(unsigned int i, int node)
+{
+       return 0;
+}
+#else
+unsigned int cpumask_local_spread(unsigned int i, int node);
+#endif
+
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)) */
+
+#endif /* LINUX_4_1_COMPAT_H */
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
new file mode 100644 (file)
index 0000000..c35dea1
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef _COMPAT_LINUX_SKBUFF_H
+#define _COMPAT_LINUX_SKBUFF_H
+
+#include <linux/version.h>
+#include "../../compat/config.h"
+
+#include_next <linux/skbuff.h>
+
+#ifndef HAVE_DEV_ALLOC_PAGES
+static inline struct page *dev_alloc_pages(unsigned int order)
+{
+       gfp_t gfp_mask = GFP_ATOMIC | __GFP_NOWARN | __GFP_COLD | __GFP_COMP | __GFP_MEMALLOC;
+       return alloc_pages_node(NUMA_NO_NODE, gfp_mask, order);
+}
+
+static inline struct page *dev_alloc_page(void)
+{
+       return dev_alloc_pages(0);
+}
+#endif
+#endif /* _COMPAT_LINUX_SKBUFF_H */