compat: Added support for SRP on RHEL7.5
[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 #ifdef HAVE_REGISTER_NETDEVICE_NOTIFIER_RH
10 #define register_netdevice_notifier register_netdevice_notifier_rh
11 #define unregister_netdevice_notifier unregister_netdevice_notifier_rh
12 #endif
13
14 #if IS_ENABLED(CONFIG_VXLAN) && (defined(HAVE_NDO_ADD_VXLAN_PORT) || defined(HAVE_NDO_UDP_TUNNEL_ADD))
15 #define HAVE_KERNEL_WITH_VXLAN_SUPPORT_ON
16 #endif
17 #ifdef HAVE_NETDEV_XDP
18 #define HAVE_NETDEV_BPF 1
19 #define netdev_bpf      netdev_xdp
20 #define ndo_bpf         ndo_xdp
21 #endif
22
23 #ifndef HAVE_TC_SETUP_QDISC_MQPRIO
24 #define TC_SETUP_QDISC_MQPRIO TC_SETUP_MQPRIO
25 #endif
26
27 #ifndef netdev_WARN_ONCE
28 static inline const char *netdev_reg_state(const struct net_device *dev)
29 {
30         switch (dev->reg_state) {
31         case NETREG_UNINITIALIZED: return " (uninitialized)";
32         case NETREG_REGISTERED: return "";
33         case NETREG_UNREGISTERING: return " (unregistering)";
34         case NETREG_UNREGISTERED: return " (unregistered)";
35         case NETREG_RELEASED: return " (released)";
36         case NETREG_DUMMY: return " (dummy)";
37         }
38
39         WARN_ONCE(1, "%s: unknown reg_state %d\n", dev->name, dev->reg_state);
40         return " (unknown)";
41 }
42
43
44 #define netdev_level_once(level, dev, fmt, ...)                 \
45 do {                                                            \
46         static bool __print_once __read_mostly;                 \
47                                                                 \
48         if (!__print_once) {                                    \
49                 __print_once = true;                            \
50                 netdev_printk(level, dev, fmt, ##__VA_ARGS__);  \
51         }                                                       \
52 } while (0)
53
54 #define netdev_emerg_once(dev, fmt, ...) \
55         netdev_level_once(KERN_EMERG, dev, fmt, ##__VA_ARGS__)
56 #define netdev_alert_once(dev, fmt, ...) \
57         netdev_level_once(KERN_ALERT, dev, fmt, ##__VA_ARGS__)
58 #define netdev_crit_once(dev, fmt, ...) \
59         netdev_level_once(KERN_CRIT, dev, fmt, ##__VA_ARGS__)
60 #define netdev_err_once(dev, fmt, ...) \
61         netdev_level_once(KERN_ERR, dev, fmt, ##__VA_ARGS__)
62 #define netdev_warn_once(dev, fmt, ...) \
63         netdev_level_once(KERN_WARNING, dev, fmt, ##__VA_ARGS__)
64 #define netdev_notice_once(dev, fmt, ...) \
65         netdev_level_once(KERN_NOTICE, dev, fmt, ##__VA_ARGS__)
66 #define netdev_info_once(dev, fmt, ...) \
67         netdev_level_once(KERN_INFO, dev, fmt, ##__VA_ARGS__)
68
69
70 #define netdev_WARN_ONCE(dev, format, args...)                          \
71         WARN_ONCE(1, "netdevice: %s%s: " format, netdev_name(dev),      \
72                   netdev_reg_state(dev), ##args)
73
74 #endif /* netdev_WARN_ONCE */
75
76 #endif  /* _COMPAT_LINUX_NETDEVICE_H */