Blame view

include/linux/if_macvlan.h 2.64 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
b863ceb7d   Patrick McHardy   [NET]: Add macvla...
2
3
  #ifndef _LINUX_IF_MACVLAN_H
  #define _LINUX_IF_MACVLAN_H
fc0663d6b   Arnd Bergmann   macvlan: allow mu...
4
  #include <linux/if_link.h>
cdf3e274c   Li RongQing   macvlan: unify ma...
5
  #include <linux/if_vlan.h>
fc0663d6b   Arnd Bergmann   macvlan: allow mu...
6
7
8
9
  #include <linux/list.h>
  #include <linux/netdevice.h>
  #include <linux/netlink.h>
  #include <net/netlink.h>
bc66154ef   Eric Dumazet   macvlan: 64 bit r...
10
  #include <linux/u64_stats_sync.h>
fc0663d6b   Arnd Bergmann   macvlan: allow mu...
11
12
  
  struct macvlan_port;
1565c7c1c   Krishna Kumar   macvtap: Implemen...
13

cd431e738   Eric Dumazet   macvlan: add mult...
14
15
  #define MACVLAN_MC_FILTER_BITS	8
  #define MACVLAN_MC_FILTER_SZ	(1 << MACVLAN_MC_FILTER_BITS)
fc0663d6b   Arnd Bergmann   macvlan: allow mu...
16
17
18
19
20
21
  struct macvlan_dev {
  	struct net_device	*dev;
  	struct list_head	list;
  	struct hlist_node	hlist;
  	struct macvlan_port	*port;
  	struct net_device	*lowerdev;
7d775f634   Alexander Duyck   macvlan: Rename f...
22
  	void			*accel_priv;
cdf3e274c   Li RongQing   macvlan: unify ma...
23
  	struct vlan_pcpu_stats __percpu *pcpu_stats;
cd431e738   Eric Dumazet   macvlan: add mult...
24
25
  
  	DECLARE_BITMAP(mc_filter, MACVLAN_MC_FILTER_SZ);
2be5c7679   Vlad Yasevich   macvtap: Let TUNS...
26
  	netdev_features_t	set_features;
fc0663d6b   Arnd Bergmann   macvlan: allow mu...
27
  	enum macvlan_mode	mode;
df8ef8f3a   John Fastabend   macvlan: add FDB ...
28
  	u16			flags;
5e54b3c12   Girish Moodalbail   macvlan: fix memo...
29
  	unsigned int		macaddr_count;
688cea83f   dingtianhong   macvlan: add netp...
30
31
32
  #ifdef CONFIG_NET_POLL_CONTROLLER
  	struct netpoll		*netpoll;
  #endif
fc0663d6b   Arnd Bergmann   macvlan: allow mu...
33
34
35
36
37
38
  };
  
  static inline void macvlan_count_rx(const struct macvlan_dev *vlan,
  				    unsigned int len, bool success,
  				    bool multicast)
  {
fc0663d6b   Arnd Bergmann   macvlan: allow mu...
39
  	if (likely(success)) {
cdf3e274c   Li RongQing   macvlan: unify ma...
40
  		struct vlan_pcpu_stats *pcpu_stats;
8ffab51b3   Eric Dumazet   macvlan: lockless...
41
42
43
44
45
  
  		pcpu_stats = this_cpu_ptr(vlan->pcpu_stats);
  		u64_stats_update_begin(&pcpu_stats->syncp);
  		pcpu_stats->rx_packets++;
  		pcpu_stats->rx_bytes += len;
fc0663d6b   Arnd Bergmann   macvlan: allow mu...
46
  		if (multicast)
8ffab51b3   Eric Dumazet   macvlan: lockless...
47
48
  			pcpu_stats->rx_multicast++;
  		u64_stats_update_end(&pcpu_stats->syncp);
fc0663d6b   Arnd Bergmann   macvlan: allow mu...
49
  	} else {
8ffab51b3   Eric Dumazet   macvlan: lockless...
50
  		this_cpu_inc(vlan->pcpu_stats->rx_errors);
fc0663d6b   Arnd Bergmann   macvlan: allow mu...
51
52
  	}
  }
8a35747a5   Herbert Xu   macvtap: Limit pa...
53
  extern void macvlan_common_setup(struct net_device *dev);
fc0663d6b   Arnd Bergmann   macvlan: allow mu...
54
  extern int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
42ab19ee9   David Ahern   net: Add extack t...
55
56
  				  struct nlattr *tb[], struct nlattr *data[],
  				  struct netlink_ext_ack *extack);
fc0663d6b   Arnd Bergmann   macvlan: allow mu...
57

fc0663d6b   Arnd Bergmann   macvlan: allow mu...
58
59
60
  extern void macvlan_dellink(struct net_device *dev, struct list_head *head);
  
  extern int macvlan_link_register(struct rtnl_link_ops *ops);
be9eac482   Michal Kubeček   macvlan: introduc...
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
  #if IS_ENABLED(CONFIG_MACVLAN)
  static inline struct net_device *
  macvlan_dev_real_dev(const struct net_device *dev)
  {
  	struct macvlan_dev *macvlan = netdev_priv(dev);
  
  	return macvlan->lowerdev;
  }
  #else
  static inline struct net_device *
  macvlan_dev_real_dev(const struct net_device *dev)
  {
  	BUG();
  	return NULL;
  }
  #endif
7d775f634   Alexander Duyck   macvlan: Rename f...
77
78
79
80
81
82
  static inline void *macvlan_accel_priv(struct net_device *dev)
  {
  	struct macvlan_dev *macvlan = netdev_priv(dev);
  
  	return macvlan->accel_priv;
  }
6cb1937d4   Alexander Duyck   macvlan: Add func...
83
84
85
86
87
88
89
90
91
  
  static inline bool macvlan_supports_dest_filter(struct net_device *dev)
  {
  	struct macvlan_dev *macvlan = netdev_priv(dev);
  
  	return macvlan->mode == MACVLAN_MODE_PRIVATE ||
  	       macvlan->mode == MACVLAN_MODE_VEPA ||
  	       macvlan->mode == MACVLAN_MODE_BRIDGE;
  }
53cd4d8e4   Alexander Duyck   macvlan: Provide ...
92
93
94
95
96
97
98
99
  
  static inline int macvlan_release_l2fw_offload(struct net_device *dev)
  {
  	struct macvlan_dev *macvlan = netdev_priv(dev);
  
  	macvlan->accel_priv = NULL;
  	return dev_uc_add(macvlan->lowerdev, dev->dev_addr);
  }
b863ceb7d   Patrick McHardy   [NET]: Add macvla...
100
  #endif /* _LINUX_IF_MACVLAN_H */