Line 0
Link Here
|
|
|
1 |
/* ********************************************************** |
2 |
* Copyright 1998 VMware, Inc. All rights reserved. -- VMware Confidential |
3 |
* **********************************************************/ |
4 |
|
5 |
#ifndef __VMNETINT_H__ |
6 |
#define __VMNETINT_H__ |
7 |
|
8 |
|
9 |
#define INCLUDE_ALLOW_MODULE |
10 |
#include "includeCheck.h" |
11 |
#include "driver-config.h" |
12 |
|
13 |
|
14 |
/* |
15 |
* Hide all kernel compatibility stuff in those macros |
16 |
*/ |
17 |
|
18 |
/* All kernels above 2.6.23 have net namespaces. */ |
19 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) && !defined(VMW_NETDEV_HAS_NET) |
20 |
# define VMW_NETDEV_HAS_NET |
21 |
#endif |
22 |
|
23 |
/* All kernels above 2.6.23 have skb argument in nf_hookfn. */ |
24 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) && !defined(VMW_NFHOOK_USES_SKB) |
25 |
# define VMW_NFHOOK_USES_SKB |
26 |
#endif |
27 |
|
28 |
|
29 |
#ifdef KERNEL_2_4_0 |
30 |
# define compat_fop_set_owner(_pFop) do { \ |
31 |
(_pFop)->owner = THIS_MODULE; \ |
32 |
} while (0) |
33 |
# define compat_mod_inc_refcount |
34 |
# define compat_mod_dec_refcount |
35 |
#else |
36 |
# define compat_fop_set_owner(_pFop) |
37 |
# define compat_mod_inc_refcount do { \ |
38 |
MOD_INC_USE_COUNT; \ |
39 |
} while (0) |
40 |
# define compat_mod_dec_refcount do { \ |
41 |
MOD_DEC_USE_COUNT; \ |
42 |
} while (0) |
43 |
#endif |
44 |
|
45 |
|
46 |
#ifdef skb_shinfo |
47 |
# define SKB_IS_CLONE_OF(clone, skb) ( \ |
48 |
skb_shinfo(clone) == skb_shinfo(skb) \ |
49 |
) |
50 |
#else |
51 |
# define SKB_IS_CLONE_OF(clone, skb) ( \ |
52 |
skb_datarefp(clone) == skb_datarefp(skb) \ |
53 |
) |
54 |
#endif |
55 |
#define DEV_QUEUE_XMIT(skb, dev, pri) ( \ |
56 |
(skb)->dev = (dev), \ |
57 |
(skb)->priority = (pri), \ |
58 |
compat_skb_reset_mac_header(skb), \ |
59 |
compat_skb_set_network_header(skb, sizeof (struct ethhdr)), \ |
60 |
dev_queue_xmit(skb) \ |
61 |
) |
62 |
#ifdef KERNEL_2_3_15 |
63 |
# define dev_lock_list() read_lock(&dev_base_lock) |
64 |
# define dev_unlock_list() read_unlock(&dev_base_lock) |
65 |
# ifdef VMW_NETDEV_HAS_NET |
66 |
# define DEV_GET(x) __dev_get_by_name((x)->internalDev->nd_net, (x)->name) |
67 |
# else |
68 |
# define DEV_GET(x) __dev_get_by_name((x)->name) |
69 |
# endif |
70 |
#else |
71 |
# define DEV_GET(x) dev_get((x)->name) |
72 |
#endif |
73 |
|
74 |
|
75 |
/* |
76 |
* Various fields (including 'dead') of struct sock are replaced with the |
77 |
* 'flags' bitfield in 2.5.65 --hpreg |
78 |
*/ |
79 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 65) |
80 |
# define SET_SK_DEAD(_sk, _val) (_sk)->dead = (_val) |
81 |
#else |
82 |
# define SET_SK_DEAD(_sk, _val) sock_valbool_flag(_sk, SOCK_DEAD, _val) |
83 |
#endif |
84 |
|
85 |
|
86 |
#ifdef VMW_NETDEV_HAS_NET |
87 |
extern struct proto vmnet_proto; |
88 |
# define compat_sk_alloc(_bri, _pri) sk_alloc((_bri)->internalDev->nd_net, \ |
89 |
PF_NETLINK, _pri, &vmnet_proto) |
90 |
#elif defined(VMW_HAVE_SK_ALLOC_WITH_PROTO) |
91 |
extern struct proto vmnet_proto; |
92 |
# define compat_sk_alloc(_bri, _pri) sk_alloc(PF_NETLINK, _pri, &vmnet_proto, 1) |
93 |
#elif defined(KERNEL_2_5_5) |
94 |
# define compat_sk_alloc(_bri, _pri) sk_alloc(PF_NETLINK, _pri, 1, NULL) |
95 |
#else |
96 |
# define compat_sk_alloc(_bri, _pri) sk_alloc(0, _pri, 1) |
97 |
#endif |
98 |
|
99 |
|
100 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) |
101 |
# define fileTraversalLock(lock) spin_lock(lock) |
102 |
# define fileTraversalUnLock(lock) spin_unlock(lock) |
103 |
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) |
104 |
# define fileTraversalLock(lock) read_lock(lock) |
105 |
# define fileTraversalUnLock(lock) read_unlock(lock) |
106 |
#else //2.2 kernels |
107 |
# define fileTraversalLock(lock) lock_kernel() |
108 |
# define fileTraversalUnLock(lock) unlock_kernel() |
109 |
#endif |
110 |
|
111 |
|
112 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) |
113 |
# define taskLock(lock) task_lock(lock) |
114 |
# define taskUnLock(lock) task_unlock(lock) |
115 |
#else //2.2 kernels |
116 |
# define taskLock(lock) lock_kernel() |
117 |
# define taskUnLock(lock) unlock_kernel() |
118 |
#endif |
119 |
|
120 |
|
121 |
/* |
122 |
* Use CHECKSUM_HW for old kernels, if they have CHECKSUM_HW. Use CHECKSUM_PARTIAL for |
123 |
* new ones even if CHECKSUM_HW is defined. We do not do decision based on kernel version |
124 |
* only as CHECKSUM_PARTIAL was in mm tree for some time already, and we do not test |
125 |
* for CHECKSUM_PARTIAL existence as it may get converted to enum in future. |
126 |
*/ |
127 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) && defined(CHECKSUM_HW) |
128 |
# define VM_CHECKSUM_PARTIAL CHECKSUM_HW |
129 |
#else |
130 |
# define VM_CHECKSUM_PARTIAL CHECKSUM_PARTIAL |
131 |
#endif |
132 |
|
133 |
|
134 |
/* |
135 |
* The "owner" field in nf_hook_ops got added in 2.5.69 |
136 |
*/ |
137 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 69) |
138 |
# define compat_nf_hook_owner .owner = THIS_MODULE, |
139 |
#else |
140 |
# define compat_nf_hook_owner |
141 |
#endif |
142 |
|
143 |
|
144 |
#endif /* __VMNETINT_H__ */ |