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 | |
| 10 | struct macvlan_port; |
| 11 | struct macvtap_queue; |
| 12 | |
| 13 | /** |
| 14 | * struct macvlan_rx_stats - MACVLAN percpu rx stats |
| 15 | * @rx_packets: number of received packets |
| 16 | * @rx_bytes: number of received bytes |
| 17 | * @multicast: number of received multicast packets |
| 18 | * @rx_errors: number of errors |
| 19 | */ |
| 20 | struct macvlan_rx_stats { |
| 21 | unsigned long rx_packets; |
| 22 | unsigned long rx_bytes; |
| 23 | unsigned long multicast; |
| 24 | unsigned long rx_errors; |
| 25 | }; |
| 26 | |
| 27 | struct macvlan_dev { |
| 28 | struct net_device *dev; |
| 29 | struct list_head list; |
| 30 | struct hlist_node hlist; |
| 31 | struct macvlan_port *port; |
| 32 | struct net_device *lowerdev; |
| 33 | struct macvlan_rx_stats *rx_stats; |
| 34 | enum macvlan_mode mode; |
| 35 | int (*receive)(struct sk_buff *skb); |
| 36 | int (*forward)(struct net_device *dev, struct sk_buff *skb); |
Arnd Bergmann | 20d29d7 | 2010-01-30 12:24:26 +0000 | [diff] [blame] | 37 | struct macvtap_queue *tap; |
Arnd Bergmann | fc0663d | 2010-01-30 12:23:40 +0000 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | static inline void macvlan_count_rx(const struct macvlan_dev *vlan, |
| 41 | unsigned int len, bool success, |
| 42 | bool multicast) |
| 43 | { |
| 44 | struct macvlan_rx_stats *rx_stats; |
| 45 | |
| 46 | rx_stats = per_cpu_ptr(vlan->rx_stats, smp_processor_id()); |
| 47 | if (likely(success)) { |
| 48 | rx_stats->rx_packets++;; |
| 49 | rx_stats->rx_bytes += len; |
| 50 | if (multicast) |
| 51 | rx_stats->multicast++; |
| 52 | } else { |
| 53 | rx_stats->rx_errors++; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | extern int macvlan_common_newlink(struct net *src_net, struct net_device *dev, |
| 58 | struct nlattr *tb[], struct nlattr *data[], |
| 59 | int (*receive)(struct sk_buff *skb), |
| 60 | int (*forward)(struct net_device *dev, |
| 61 | struct sk_buff *skb)); |
| 62 | |
| 63 | extern void macvlan_count_rx(const struct macvlan_dev *vlan, |
| 64 | unsigned int len, bool success, |
| 65 | bool multicast); |
| 66 | |
| 67 | extern void macvlan_dellink(struct net_device *dev, struct list_head *head); |
| 68 | |
| 69 | extern int macvlan_link_register(struct rtnl_link_ops *ops); |
| 70 | |
| 71 | extern netdev_tx_t macvlan_start_xmit(struct sk_buff *skb, |
| 72 | struct net_device *dev); |
| 73 | |
| 74 | |
Patrick McHardy | b863ceb | 2007-07-14 18:55:06 -0700 | [diff] [blame] | 75 | extern struct sk_buff *(*macvlan_handle_frame_hook)(struct sk_buff *); |
| 76 | |
Patrick McHardy | b863ceb | 2007-07-14 18:55:06 -0700 | [diff] [blame] | 77 | #endif /* _LINUX_IF_MACVLAN_H */ |