]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
b863ceb7 PM |
2 | #ifndef _LINUX_IF_MACVLAN_H |
3 | #define _LINUX_IF_MACVLAN_H | |
4 | ||
fc0663d6 | 5 | #include <linux/if_link.h> |
cdf3e274 | 6 | #include <linux/if_vlan.h> |
fc0663d6 AB |
7 | #include <linux/list.h> |
8 | #include <linux/netdevice.h> | |
9 | #include <linux/netlink.h> | |
10 | #include <net/netlink.h> | |
bc66154e | 11 | #include <linux/u64_stats_sync.h> |
fc0663d6 AB |
12 | |
13 | struct macvlan_port; | |
1565c7c1 | 14 | |
cd431e73 ED |
15 | #define MACVLAN_MC_FILTER_BITS 8 |
16 | #define MACVLAN_MC_FILTER_SZ (1 << MACVLAN_MC_FILTER_BITS) | |
17 | ||
fc0663d6 AB |
18 | struct macvlan_dev { |
19 | struct net_device *dev; | |
20 | struct list_head list; | |
21 | struct hlist_node hlist; | |
22 | struct macvlan_port *port; | |
23 | struct net_device *lowerdev; | |
a6cc0cfa | 24 | void *fwd_priv; |
cdf3e274 | 25 | struct vlan_pcpu_stats __percpu *pcpu_stats; |
cd431e73 ED |
26 | |
27 | DECLARE_BITMAP(mc_filter, MACVLAN_MC_FILTER_SZ); | |
28 | ||
2be5c767 | 29 | netdev_features_t set_features; |
fc0663d6 | 30 | enum macvlan_mode mode; |
df8ef8f3 | 31 | u16 flags; |
c674ac30 | 32 | int nest_level; |
688cea83 | 33 | #ifdef CONFIG_NET_POLL_CONTROLLER |
34 | struct netpoll *netpoll; | |
35 | #endif | |
79cf79ab | 36 | unsigned int macaddr_count; |
fc0663d6 AB |
37 | }; |
38 | ||
39 | static inline void macvlan_count_rx(const struct macvlan_dev *vlan, | |
40 | unsigned int len, bool success, | |
41 | bool multicast) | |
42 | { | |
fc0663d6 | 43 | if (likely(success)) { |
cdf3e274 | 44 | struct vlan_pcpu_stats *pcpu_stats; |
8ffab51b ED |
45 | |
46 | pcpu_stats = this_cpu_ptr(vlan->pcpu_stats); | |
47 | u64_stats_update_begin(&pcpu_stats->syncp); | |
48 | pcpu_stats->rx_packets++; | |
49 | pcpu_stats->rx_bytes += len; | |
fc0663d6 | 50 | if (multicast) |
8ffab51b ED |
51 | pcpu_stats->rx_multicast++; |
52 | u64_stats_update_end(&pcpu_stats->syncp); | |
fc0663d6 | 53 | } else { |
8ffab51b | 54 | this_cpu_inc(vlan->pcpu_stats->rx_errors); |
fc0663d6 AB |
55 | } |
56 | } | |
57 | ||
8a35747a HX |
58 | extern void macvlan_common_setup(struct net_device *dev); |
59 | ||
fc0663d6 | 60 | extern int macvlan_common_newlink(struct net *src_net, struct net_device *dev, |
42ab19ee DA |
61 | struct nlattr *tb[], struct nlattr *data[], |
62 | struct netlink_ext_ack *extack); | |
fc0663d6 AB |
63 | |
64 | extern void macvlan_count_rx(const struct macvlan_dev *vlan, | |
65 | unsigned int len, bool success, | |
66 | bool multicast); | |
67 | ||
68 | extern void macvlan_dellink(struct net_device *dev, struct list_head *head); | |
69 | ||
70 | extern int macvlan_link_register(struct rtnl_link_ops *ops); | |
71 | ||
be9eac48 MK |
72 | #if IS_ENABLED(CONFIG_MACVLAN) |
73 | static inline struct net_device * | |
74 | macvlan_dev_real_dev(const struct net_device *dev) | |
75 | { | |
76 | struct macvlan_dev *macvlan = netdev_priv(dev); | |
77 | ||
78 | return macvlan->lowerdev; | |
79 | } | |
80 | #else | |
81 | static inline struct net_device * | |
82 | macvlan_dev_real_dev(const struct net_device *dev) | |
83 | { | |
84 | BUG(); | |
85 | return NULL; | |
86 | } | |
87 | #endif | |
88 | ||
b863ceb7 | 89 | #endif /* _LINUX_IF_MACVLAN_H */ |