batman-adv: upgrade package to latest release 2016.3
[lede-routing/.git] / batman-adv / files / compat-hacks.h
1 /* Please avoid adding hacks here - instead add it to mac80211/backports.git */
2
3 #undef CONFIG_MODULE_STRIPPED
4
5 #include <linux/version.h>      /* LINUX_VERSION_CODE */
6 #include <linux/types.h>
7
8 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
9
10 #define dev_get_iflink(_net_dev) ((_net_dev)->iflink)
11
12 #endif /* < KERNEL_VERSION(4, 1, 0) */
13
14 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)
15
16 #include <linux/netdevice.h>
17
18 #define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info) ({\
19         BUILD_BUG_ON(upper_priv != NULL); \
20         BUILD_BUG_ON(upper_info != NULL); \
21         netdev_set_master(dev, upper_dev); \
22 })
23
24 #elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
25
26 #include <linux/netdevice.h>
27
28 #define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info) ({\
29         BUILD_BUG_ON(upper_priv != NULL); \
30         BUILD_BUG_ON(upper_info != NULL); \
31         netdev_master_upper_dev_link(dev, upper_dev); \
32 })
33
34 #endif /* < KERNEL_VERSION(4, 5, 0) */
35
36 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)
37
38 struct sk_buff *skb_checksum_trimmed(struct sk_buff *skb,
39                                      unsigned int transport_len,
40                                      __sum16(*skb_chkf)(struct sk_buff *skb));
41
42 int ip_mc_check_igmp(struct sk_buff *skb, struct sk_buff **skb_trimmed);
43
44 int ipv6_mc_check_mld(struct sk_buff *skb, struct sk_buff **skb_trimmed);
45
46 #endif /* < KERNEL_VERSION(4, 2, 0) */
47
48 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
49
50 #define IFF_NO_QUEUE    0; dev->tx_queue_len = 0
51
52 #endif /* < KERNEL_VERSION(4, 3, 0) */
53
54 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
55
56 #include <linux/ethtool.h>
57
58 #define ethtool_link_ksettings batadv_ethtool_link_ksettings
59
60 struct batadv_ethtool_link_ksettings {
61         struct {
62                 __u32   speed;
63                 __u8    duplex;
64         } base;
65 };
66
67 #define __ethtool_get_link_ksettings(__dev, __link_settings) \
68         batadv_ethtool_get_link_ksettings(__dev, __link_settings)
69
70 static inline int
71 batadv_ethtool_get_link_ksettings(struct net_device *dev,
72                                   struct ethtool_link_ksettings *link_ksettings)
73 {
74         struct ethtool_cmd cmd;
75         int ret;
76
77         memset(&cmd, 0, sizeof(cmd));
78         ret = __ethtool_get_settings(dev, &cmd);
79
80         if (ret != 0)
81                 return ret;
82
83         link_ksettings->base.duplex = cmd.duplex;
84         link_ksettings->base.speed = ethtool_cmd_speed(&cmd);
85
86         return 0;
87 }
88
89 #endif /* < KERNEL_VERSION(4, 6, 0) */
90
91 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)
92
93 #define netif_trans_update batadv_netif_trans_update
94 static inline void batadv_netif_trans_update(struct net_device *dev)
95 {
96         dev->trans_start = jiffies;
97 }
98
99 #endif /* < KERNEL_VERSION(4, 7, 0) */