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