diff options
author | Arnd Bergmann <arnd@arndb.de> | 2010-01-30 07:23:40 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-03 23:20:33 -0500 |
commit | fc0663d6b5e6d8e9b57f872a644c0aafd82361b7 (patch) | |
tree | 133f8fb33482f58cd9adcb7747cd51a81856436d /include/linux/if_macvlan.h | |
parent | 8a83a00b0735190384a348156837918271034144 (diff) |
macvlan: allow multiple driver backends
This makes it possible to hook into the macvlan driver
from another kernel module. In particular, the goal is
to extend it with the macvtap backend that provides
a tun/tap compatible interface directly on the macvlan
device.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/if_macvlan.h')
-rw-r--r-- | include/linux/if_macvlan.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h index 5f200bac3749..9a11544bb0b1 100644 --- a/include/linux/if_macvlan.h +++ b/include/linux/if_macvlan.h | |||
@@ -1,6 +1,76 @@ | |||
1 | #ifndef _LINUX_IF_MACVLAN_H | 1 | #ifndef _LINUX_IF_MACVLAN_H |
2 | #define _LINUX_IF_MACVLAN_H | 2 | #define _LINUX_IF_MACVLAN_H |
3 | 3 | ||
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); | ||
37 | }; | ||
38 | |||
39 | static inline void macvlan_count_rx(const struct macvlan_dev *vlan, | ||
40 | unsigned int len, bool success, | ||
41 | bool multicast) | ||
42 | { | ||
43 | struct macvlan_rx_stats *rx_stats; | ||
44 | |||
45 | rx_stats = per_cpu_ptr(vlan->rx_stats, smp_processor_id()); | ||
46 | if (likely(success)) { | ||
47 | rx_stats->rx_packets++;; | ||
48 | rx_stats->rx_bytes += len; | ||
49 | if (multicast) | ||
50 | rx_stats->multicast++; | ||
51 | } else { | ||
52 | rx_stats->rx_errors++; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | extern int macvlan_common_newlink(struct net *src_net, struct net_device *dev, | ||
57 | struct nlattr *tb[], struct nlattr *data[], | ||
58 | int (*receive)(struct sk_buff *skb), | ||
59 | int (*forward)(struct net_device *dev, | ||
60 | struct sk_buff *skb)); | ||
61 | |||
62 | extern void macvlan_count_rx(const struct macvlan_dev *vlan, | ||
63 | unsigned int len, bool success, | ||
64 | bool multicast); | ||
65 | |||
66 | extern void macvlan_dellink(struct net_device *dev, struct list_head *head); | ||
67 | |||
68 | extern int macvlan_link_register(struct rtnl_link_ops *ops); | ||
69 | |||
70 | extern netdev_tx_t macvlan_start_xmit(struct sk_buff *skb, | ||
71 | struct net_device *dev); | ||
72 | |||
73 | |||
4 | extern struct sk_buff *(*macvlan_handle_frame_hook)(struct sk_buff *); | 74 | extern struct sk_buff *(*macvlan_handle_frame_hook)(struct sk_buff *); |
5 | 75 | ||
6 | #endif /* _LINUX_IF_MACVLAN_H */ | 76 | #endif /* _LINUX_IF_MACVLAN_H */ |