datapath: Add sysfs support for all (otherwise supported) Linux versions.
[sliver-openvswitch.git] / datapath / linux-2.6 / compat-2.6 / include / linux / netdevice.h
1 #ifndef __LINUX_NETDEVICE_WRAPPER_H
2 #define __LINUX_NETDEVICE_WRAPPER_H 1
3
4 #include_next <linux/netdevice.h>
5
6 struct net;
7
8 /* Before 2.6.21, struct net_device has a "struct class_device" member named
9  * class_dev.  Beginning with 2.6.21, struct net_device instead has a "struct
10  * device" member named dev.  Otherwise the usage of these members is pretty
11  * much the same. */
12 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
13 #define NETDEV_DEV_MEMBER class_dev
14 #else
15 #define NETDEV_DEV_MEMBER dev
16 #endif
17
18 #ifndef to_net_dev
19 #define to_net_dev(class) \
20         container_of(class, struct net_device, NETDEV_DEV_MEMBER)
21 #endif
22
23 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
24 static inline
25 struct net *dev_net(const struct net_device *dev)
26 {
27         return NULL;
28 }
29 #endif /* linux kernel < 2.6.26 */
30
31 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
32 #define proc_net init_net.proc_net
33 #endif
34
35 #ifndef for_each_netdev
36 /* Linux before 2.6.22 didn't have for_each_netdev at all. */
37 #define for_each_netdev(net, d) for (d = dev_base; d; d = d->next)
38 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
39 /* Linux 2.6.24 added a network namespace pointer to the macro. */
40 #undef for_each_netdev
41 #define for_each_netdev(net,d) list_for_each_entry(d, &dev_base_head, dev_list)
42 #endif
43
44
45
46 #endif