d96275af96c5884f498f2fc57a3080b9debf7fc8
[deb_dpdk.git] / lib / librte_eal / linuxapp / kni / compat.h
1 /*
2  * Minimal wrappers to allow compiling kni on older kernels.
3  */
4
5 #include <linux/version.h>
6
7 #ifndef RHEL_RELEASE_VERSION
8 #define RHEL_RELEASE_VERSION(a, b) (((a) << 8) + (b))
9 #endif
10
11 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && \
12         (!(defined(RHEL_RELEASE_CODE) && \
13            RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 4)))
14
15 #define kstrtoul strict_strtoul
16
17 #endif /* < 2.6.39 */
18
19 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
20 #define HAVE_SIMPLIFIED_PERNET_OPERATIONS
21 #endif
22
23 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
24 #define sk_sleep(s) ((s)->sk_sleep)
25 #else
26 #define HAVE_SOCKET_WQ
27 #endif
28
29 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
30 #define HAVE_STATIC_SOCK_MAP_FD
31 #else
32 #define kni_sock_map_fd(s) sock_map_fd(s, 0)
33 #endif
34
35 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
36 #define HAVE_CHANGE_CARRIER_CB
37 #endif
38
39 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
40 #define ether_addr_copy(dst, src) memcpy(dst, src, ETH_ALEN)
41 #endif
42
43 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
44 #define HAVE_IOV_ITER_MSGHDR
45 #endif
46
47 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
48 #define HAVE_KIOCB_MSG_PARAM
49 #define HAVE_REBUILD_HEADER
50 #endif
51
52 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
53 #define HAVE_SK_ALLOC_KERN_PARAM
54 #endif
55
56 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
57 #define HAVE_TRANS_START_HELPER
58 #endif
59
60 /*
61  * KNI uses NET_NAME_UNKNOWN macro to select correct version of alloc_netdev()
62  * For old kernels just backported the commit that enables the macro
63  * (685343fc3ba6) but still uses old API, it is required to undefine macro to
64  * select correct version of API, this is safe since KNI doesn't use the value.
65  * This fix is specific to RedHat/CentOS kernels.
66  */
67 #if (defined(RHEL_RELEASE_CODE) && \
68         (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 8)) && \
69         (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)))
70 #undef NET_NAME_UNKNOWN
71 #endif
72
73 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
74 #define HAVE_SIGNAL_FUNCTIONS_OWN_HEADER
75 #endif