Patrick McHardy | b863ceb | 2007-07-14 18:55:06 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_IF_MACVLAN_H |
| 2 | #define _LINUX_IF_MACVLAN_H |
| 3 | |
Arnd Bergmann | fc0663d | 2010-01-30 12:23:40 +0000 | [diff] [blame] | 4 | #include <linux/if_link.h> |
| 5 | #include <linux/list.h> |
| 6 | #include <linux/netdevice.h> |
| 7 | #include <linux/netlink.h> |
| 8 | #include <net/netlink.h> |
| 9 | |
Arnd Bergmann | 501c774 | 2010-02-18 05:46:50 +0000 | [diff] [blame] | 10 | #if defined(CONFIG_MACVTAP) || defined(CONFIG_MACVTAP_MODULE) |
| 11 | struct socket *macvtap_get_socket(struct file *); |
| 12 | #else |
| 13 | #include <linux/err.h> |
| 14 | #include <linux/errno.h> |
| 15 | struct file; |
| 16 | struct socket; |
| 17 | static inline struct socket *macvtap_get_socket(struct file *f) |
| 18 | { |
| 19 | return ERR_PTR(-EINVAL); |
| 20 | } |
| 21 | #endif /* CONFIG_MACVTAP */ |
| 22 | |
Arnd Bergmann | fc0663d | 2010-01-30 12:23:40 +0000 | [diff] [blame] | 23 | struct macvlan_port; |
| 24 | struct macvtap_queue; |
| 25 | |
| 26 | /** |
| 27 | * struct macvlan_rx_stats - MACVLAN percpu rx stats |
| 28 | * @rx_packets: number of received packets |
| 29 | * @rx_bytes: number of received bytes |
| 30 | * @multicast: number of received multicast packets |
| 31 | * @rx_errors: number of errors |
| 32 | */ |
| 33 | struct macvlan_rx_stats { |
| 34 | unsigned long rx_packets; |
| 35 | unsigned long rx_bytes; |
| 36 | unsigned long multicast; |
| 37 | unsigned long rx_errors; |
| 38 | }; |
| 39 | |
| 40 | struct macvlan_dev { |
| 41 | struct net_device *dev; |
| 42 | struct list_head list; |
| 43 | struct hlist_node hlist; |
| 44 | struct macvlan_port *port; |
| 45 | struct net_device *lowerdev; |
Tejun Heo | 47d7427 | 2010-02-16 15:21:08 +0000 | [diff] [blame] | 46 | struct macvlan_rx_stats __percpu *rx_stats; |
Arnd Bergmann | fc0663d | 2010-01-30 12:23:40 +0000 | [diff] [blame] | 47 | enum macvlan_mode mode; |
| 48 | int (*receive)(struct sk_buff *skb); |
| 49 | int (*forward)(struct net_device *dev, struct sk_buff *skb); |
Arnd Bergmann | 20d29d7 | 2010-01-30 12:24:26 +0000 | [diff] [blame] | 50 | struct macvtap_queue *tap; |
Arnd Bergmann | fc0663d | 2010-01-30 12:23:40 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | static inline void macvlan_count_rx(const struct macvlan_dev *vlan, |
| 54 | unsigned int len, bool success, |
| 55 | bool multicast) |
| 56 | { |
| 57 | struct macvlan_rx_stats *rx_stats; |
| 58 | |
| 59 | rx_stats = per_cpu_ptr(vlan->rx_stats, smp_processor_id()); |
| 60 | if (likely(success)) { |
| 61 | rx_stats->rx_packets++;; |
| 62 | rx_stats->rx_bytes += len; |
| 63 | if (multicast) |
| 64 | rx_stats->multicast++; |
| 65 | } else { |
| 66 | rx_stats->rx_errors++; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | extern int macvlan_common_newlink(struct net *src_net, struct net_device *dev, |
| 71 | struct nlattr *tb[], struct nlattr *data[], |
| 72 | int (*receive)(struct sk_buff *skb), |
| 73 | int (*forward)(struct net_device *dev, |
| 74 | struct sk_buff *skb)); |
| 75 | |
| 76 | extern void macvlan_count_rx(const struct macvlan_dev *vlan, |
| 77 | unsigned int len, bool success, |
| 78 | bool multicast); |
| 79 | |
| 80 | extern void macvlan_dellink(struct net_device *dev, struct list_head *head); |
| 81 | |
| 82 | extern int macvlan_link_register(struct rtnl_link_ops *ops); |
| 83 | |
| 84 | extern netdev_tx_t macvlan_start_xmit(struct sk_buff *skb, |
| 85 | struct net_device *dev); |
| 86 | |
| 87 | |
Patrick McHardy | b863ceb | 2007-07-14 18:55:06 -0700 | [diff] [blame] | 88 | extern struct sk_buff *(*macvlan_handle_frame_hook)(struct sk_buff *); |
| 89 | |
Patrick McHardy | b863ceb | 2007-07-14 18:55:06 -0700 | [diff] [blame] | 90 | #endif /* _LINUX_IF_MACVLAN_H */ |