1 #ifndef __LINUX_NETDEVICE_WRAPPER_H
2 #define __LINUX_NETDEVICE_WRAPPER_H 1
4 #include_next <linux/netdevice.h>
8 #include <linux/version.h>
9 /* Before 2.6.21, struct net_device has a "struct class_device" member named
10 * class_dev. Beginning with 2.6.21, struct net_device instead has a "struct
11 * device" member named dev. Otherwise the usage of these members is pretty
13 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
14 #define NETDEV_DEV_MEMBER class_dev
16 #define NETDEV_DEV_MEMBER dev
20 #define to_net_dev(class) container_of(class, struct net_device, NETDEV_DEV_MEMBER)
23 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
25 struct net *dev_net(const struct net_device *dev)
29 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
37 void dev_net_set(struct net_device *dev, const struct net *net)
43 #endif /* linux kernel < 2.6.26 */
45 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
46 #define NETIF_F_NETNS_LOCAL 0
49 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
50 #define proc_net init_net.proc_net
53 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
54 typedef int netdev_tx_t;
57 #ifndef for_each_netdev
58 /* Linux before 2.6.22 didn't have for_each_netdev at all. */
59 #define for_each_netdev(net, d) for (d = dev_base; d; d = d->next)
60 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
61 /* Linux 2.6.24 added a network namespace pointer to the macro. */
62 #undef for_each_netdev
63 #define for_each_netdev(net,d) list_for_each_entry(d, &dev_base_head, dev_list)
66 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
67 #define net_xmit_eval(e) ((e) == NET_XMIT_CN? 0 : (e))
70 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
71 extern void unregister_netdevice_queue(struct net_device *dev,
72 struct list_head *head);
73 extern void unregister_netdevice_many(struct list_head *head);
76 #ifndef HAVE_DEV_DISABLE_LRO
77 extern void dev_disable_lro(struct net_device *dev);
80 #ifndef HAVE_DEV_GET_STATS
81 static inline const struct net_device_stats *
82 dev_get_stats(struct net_device *dev)
84 return dev->get_stats(dev);
88 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
89 #define skb_checksum_help(skb) skb_checksum_help((skb), 0)
92 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
93 static inline int netdev_rx_handler_register(struct net_device *dev,
95 void *rx_handler_data)
99 rcu_assign_pointer(dev->br_port, rx_handler_data);
102 static inline void netdev_rx_handler_unregister(struct net_device *dev)
104 rcu_assign_pointer(dev->br_port, NULL);