Commit | Line | Data |
---|---|---|
b863ceb7 PM |
1 | #ifndef _LINUX_IF_MACVLAN_H |
2 | #define _LINUX_IF_MACVLAN_H | |
3 | ||
fc0663d6 | 4 | #include <linux/if_link.h> |
cdf3e274 | 5 | #include <linux/if_vlan.h> |
fc0663d6 AB |
6 | #include <linux/list.h> |
7 | #include <linux/netdevice.h> | |
8 | #include <linux/netlink.h> | |
9 | #include <net/netlink.h> | |
bc66154e | 10 | #include <linux/u64_stats_sync.h> |
fc0663d6 AB |
11 | |
12 | struct macvlan_port; | |
13 | struct macvtap_queue; | |
14 | ||
1565c7c1 KK |
15 | /* |
16 | * Maximum times a macvtap device can be opened. This can be used to | |
17 | * configure the number of receive queue, e.g. for multiqueue virtio. | |
18 | */ | |
635b8c8e | 19 | #define MAX_TAP_QUEUES 256 |
1565c7c1 | 20 | |
cd431e73 ED |
21 | #define MACVLAN_MC_FILTER_BITS 8 |
22 | #define MACVLAN_MC_FILTER_SZ (1 << MACVLAN_MC_FILTER_BITS) | |
23 | ||
fc0663d6 AB |
24 | struct macvlan_dev { |
25 | struct net_device *dev; | |
26 | struct list_head list; | |
27 | struct hlist_node hlist; | |
28 | struct macvlan_port *port; | |
29 | struct net_device *lowerdev; | |
a6cc0cfa | 30 | void *fwd_priv; |
cdf3e274 | 31 | struct vlan_pcpu_stats __percpu *pcpu_stats; |
cd431e73 ED |
32 | |
33 | DECLARE_BITMAP(mc_filter, MACVLAN_MC_FILTER_SZ); | |
34 | ||
2be5c767 | 35 | netdev_features_t set_features; |
fc0663d6 | 36 | enum macvlan_mode mode; |
df8ef8f3 | 37 | u16 flags; |
815f236d | 38 | /* This array tracks active taps. */ |
635b8c8e | 39 | struct tap_queue __rcu *taps[MAX_TAP_QUEUES]; |
815f236d JW |
40 | /* This list tracks all taps (both enabled and disabled) */ |
41 | struct list_head queue_list; | |
1565c7c1 | 42 | int numvtaps; |
815f236d | 43 | int numqueues; |
2be5c767 | 44 | netdev_features_t tap_features; |
e09eff7f | 45 | int minor; |
c674ac30 | 46 | int nest_level; |
688cea83 | 47 | #ifdef CONFIG_NET_POLL_CONTROLLER |
48 | struct netpoll *netpoll; | |
49 | #endif | |
79cf79ab | 50 | unsigned int macaddr_count; |
fc0663d6 AB |
51 | }; |
52 | ||
53 | static inline void macvlan_count_rx(const struct macvlan_dev *vlan, | |
54 | unsigned int len, bool success, | |
55 | bool multicast) | |
56 | { | |
fc0663d6 | 57 | if (likely(success)) { |
cdf3e274 | 58 | struct vlan_pcpu_stats *pcpu_stats; |
8ffab51b ED |
59 | |
60 | pcpu_stats = this_cpu_ptr(vlan->pcpu_stats); | |
61 | u64_stats_update_begin(&pcpu_stats->syncp); | |
62 | pcpu_stats->rx_packets++; | |
63 | pcpu_stats->rx_bytes += len; | |
fc0663d6 | 64 | if (multicast) |
8ffab51b ED |
65 | pcpu_stats->rx_multicast++; |
66 | u64_stats_update_end(&pcpu_stats->syncp); | |
fc0663d6 | 67 | } else { |
8ffab51b | 68 | this_cpu_inc(vlan->pcpu_stats->rx_errors); |
fc0663d6 AB |
69 | } |
70 | } | |
71 | ||
8a35747a HX |
72 | extern void macvlan_common_setup(struct net_device *dev); |
73 | ||
fc0663d6 | 74 | extern int macvlan_common_newlink(struct net *src_net, struct net_device *dev, |
2f6a1b66 | 75 | struct nlattr *tb[], struct nlattr *data[]); |
fc0663d6 AB |
76 | |
77 | extern void macvlan_count_rx(const struct macvlan_dev *vlan, | |
78 | unsigned int len, bool success, | |
79 | bool multicast); | |
80 | ||
81 | extern void macvlan_dellink(struct net_device *dev, struct list_head *head); | |
82 | ||
83 | extern int macvlan_link_register(struct rtnl_link_ops *ops); | |
84 | ||
be9eac48 MK |
85 | #if IS_ENABLED(CONFIG_MACVLAN) |
86 | static inline struct net_device * | |
87 | macvlan_dev_real_dev(const struct net_device *dev) | |
88 | { | |
89 | struct macvlan_dev *macvlan = netdev_priv(dev); | |
90 | ||
91 | return macvlan->lowerdev; | |
92 | } | |
93 | #else | |
94 | static inline struct net_device * | |
95 | macvlan_dev_real_dev(const struct net_device *dev) | |
96 | { | |
97 | BUG(); | |
98 | return NULL; | |
99 | } | |
100 | #endif | |
101 | ||
b863ceb7 | 102 | #endif /* _LINUX_IF_MACVLAN_H */ |