From: Vladimir Sokolovsky Date: Mon, 12 Dec 2016 08:25:19 +0000 (+0200) Subject: compat: Added macros and headers to support RHEL7.1 X-Git-Tag: vofed-4.8-rc4~13 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=d6c834df904f268f2ed616ae2af68b5b2382a2bd;p=compat-rdma%2Fcompat.git compat: Added macros and headers to support RHEL7.1 Signed-off-by: Vladimir Sokolovsky --- diff --git a/compat/Makefile b/compat/Makefile index 4de8583..51b7fa6 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -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 index 0000000..936cb0c --- /dev/null +++ b/compat/compat-4.1.c @@ -0,0 +1,48 @@ +#include +#include +#include +#include +#include +#include + +/** + * 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); diff --git a/config/rdma.m4 b/config/rdma.m4 index fc5f474..2ad9607 100644 --- a/config/rdma.m4 +++ b/config/rdma.m4 @@ -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 + ],[ + 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 @@ -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 + ],[ + 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 + ],[ + 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 + ],[ + 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 index 0000000..d17cc03 --- /dev/null +++ b/include/linux/clocksource.h @@ -0,0 +1,20 @@ +#ifndef LINUX_CLOCKSOURCE_H +#define LINUX_CLOCKSOURCE_H + +#include +#include "../../compat/config.h" + +#include_next + +#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 */ diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index ef8ccf5..4c9714a 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -76,6 +76,7 @@ void backport_dependency_symbol(void); #include #include #include +#include #include #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 index 0000000..e04eca9 --- /dev/null +++ b/include/linux/compat-4.1.h @@ -0,0 +1,33 @@ +#ifndef LINUX_4_1_COMPAT_H +#define LINUX_4_1_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)) +#include "../../compat/config.h" +#include + +#ifndef dma_rmb +#define dma_rmb() rmb() +#endif + +#ifndef dma_wmb +#define dma_wmb() wmb() +#endif + +#include + +#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 index 0000000..c35dea1 --- /dev/null +++ b/include/linux/skbuff.h @@ -0,0 +1,21 @@ +#ifndef _COMPAT_LINUX_SKBUFF_H +#define _COMPAT_LINUX_SKBUFF_H + +#include +#include "../../compat/config.h" + +#include_next + +#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 */