Added support for mlx4_en on RHEL7.6
[compat-rdma/compat.git] / include / linux / netdevice.h
1 #ifndef _COMPAT_LINUX_NETDEVICE_H
2 #define _COMPAT_LINUX_NETDEVICE_H 1
3
4 #include "../../compat/config.h"
5 #include <linux/kconfig.h>
6
7 #include_next <linux/netdevice.h>
8
9 #ifndef SET_ETHTOOL_OPS
10 #define SET_ETHTOOL_OPS(netdev,ops) \
11     ( (netdev)->ethtool_ops = (ops) )
12 #endif
13
14 #if !defined(HAVE_NETDEV_EXTENDED_HW_FEATURES)     && \
15     !defined(HAVE_NETDEV_OPS_EXT_NDO_FIX_FEATURES) && \
16     !defined(HAVE_NETDEV_OPS_EXT_NDO_SET_FEATURES) && \
17     !defined(HAVE_NDO_SET_FEATURES)
18 #define LEGACY_ETHTOOL_OPS
19 #endif
20
21 #ifndef NETDEV_BONDING_INFO
22 #define NETDEV_BONDING_INFO     0x0019
23 #endif
24
25
26 #ifndef HAVE_NETDEV_MASTER_UPPER_DEV_GET_RCU
27 #define netdev_master_upper_dev_get_rcu(x) (x)->master
28 #define netdev_master_upper_dev_get(x) \
29         netdev_master_upper_dev_get_rcu(x)
30 #else
31 static inline int netdev_set_master(struct net_device *dev,
32                                     struct net_device *master)
33 {
34         int rc = 0;
35
36         if (master) {
37 #if defined(NETDEV_MASTER_UPPER_DEV_LINK_4_PARAMS)
38                 rc = netdev_master_upper_dev_link(dev, master, NULL, NULL);
39 #elif defined(NETDEV_MASTER_UPPER_DEV_LINK_5_PARAMS)
40                 rc = netdev_master_upper_dev_link(dev, master,
41                                                   NULL, NULL, NULL);
42 #else
43                 rc = netdev_master_upper_dev_link(dev, master);
44 #endif
45         } else {
46                 master = netdev_master_upper_dev_get_rcu(dev);
47                 netdev_upper_dev_unlink(dev, master);
48         }
49         return rc;
50 }
51 #endif
52
53 #ifdef HAVE_ALLOC_NETDEV_MQS_5_PARAMS
54 #define alloc_netdev_mqs(p1, p2, p3, p4, p5, p6) alloc_netdev_mqs(p1, p2, p4, p5, p6)
55 #elif defined(HAVE_ALLOC_NETDEV_MQ_4_PARAMS)
56 #define alloc_netdev_mqs(sizeof_priv, name, name_assign_type, setup, txqs, rxqs)        \
57         alloc_netdev_mq(sizeof_priv, name, setup,                                       \
58                         max_t(unsigned int, txqs, rxqs))
59 #endif
60
61 #ifndef HAVE_SELECT_QUEUE_FALLBACK_T
62 #define fallback(dev, skb) __netdev_pick_tx(dev, skb)
63 #endif
64 #ifdef HAVE_REGISTER_NETDEVICE_NOTIFIER_RH
65 #define register_netdevice_notifier register_netdevice_notifier_rh
66 #define unregister_netdevice_notifier unregister_netdevice_notifier_rh
67 #endif
68
69 #if IS_ENABLED(CONFIG_VXLAN) && (defined(HAVE_NDO_ADD_VXLAN_PORT) || defined(HAVE_NDO_UDP_TUNNEL_ADD))
70 #define HAVE_KERNEL_WITH_VXLAN_SUPPORT_ON
71 #endif
72 #ifdef HAVE_NETDEV_XDP
73 #define HAVE_NETDEV_BPF 1
74 #define netdev_bpf      netdev_xdp
75 #define ndo_bpf         ndo_xdp
76 #endif
77
78 #ifndef HAVE_TC_SETUP_QDISC_MQPRIO
79 #define TC_SETUP_QDISC_MQPRIO TC_SETUP_MQPRIO
80 #endif
81
82 #ifndef netdev_WARN_ONCE
83
84 #ifndef HAVE_NETDEV_REG_STATE
85 static inline const char *netdev_reg_state(const struct net_device *dev)
86 {
87         switch (dev->reg_state) {
88         case NETREG_UNINITIALIZED: return " (uninitialized)";
89         case NETREG_REGISTERED: return "";
90         case NETREG_UNREGISTERING: return " (unregistering)";
91         case NETREG_UNREGISTERED: return " (unregistered)";
92         case NETREG_RELEASED: return " (released)";
93         case NETREG_DUMMY: return " (dummy)";
94         }
95
96         WARN_ONCE(1, "%s: unknown reg_state %d\n", dev->name, dev->reg_state);
97         return " (unknown)";
98 }
99 #endif
100
101
102 #define netdev_level_once(level, dev, fmt, ...)                 \
103 do {                                                            \
104         static bool __print_once __read_mostly;                 \
105                                                                 \
106         if (!__print_once) {                                    \
107                 __print_once = true;                            \
108                 netdev_printk(level, dev, fmt, ##__VA_ARGS__);  \
109         }                                                       \
110 } while (0)
111
112 #define netdev_emerg_once(dev, fmt, ...) \
113         netdev_level_once(KERN_EMERG, dev, fmt, ##__VA_ARGS__)
114 #define netdev_alert_once(dev, fmt, ...) \
115         netdev_level_once(KERN_ALERT, dev, fmt, ##__VA_ARGS__)
116 #define netdev_crit_once(dev, fmt, ...) \
117         netdev_level_once(KERN_CRIT, dev, fmt, ##__VA_ARGS__)
118 #define netdev_err_once(dev, fmt, ...) \
119         netdev_level_once(KERN_ERR, dev, fmt, ##__VA_ARGS__)
120 #define netdev_warn_once(dev, fmt, ...) \
121         netdev_level_once(KERN_WARNING, dev, fmt, ##__VA_ARGS__)
122 #define netdev_notice_once(dev, fmt, ...) \
123         netdev_level_once(KERN_NOTICE, dev, fmt, ##__VA_ARGS__)
124 #define netdev_info_once(dev, fmt, ...) \
125         netdev_level_once(KERN_INFO, dev, fmt, ##__VA_ARGS__)
126
127
128 #define netdev_WARN_ONCE(dev, format, args...)                          \
129         WARN_ONCE(1, "netdevice: %s%s: " format, netdev_name(dev),      \
130                   netdev_reg_state(dev), ##args)
131
132 #endif /* netdev_WARN_ONCE */
133
134 #endif  /* _COMPAT_LINUX_NETDEVICE_H */