aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/if_vlan.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/if_vlan.h')
-rw-r--r--include/linux/if_vlan.h67
1 files changed, 36 insertions, 31 deletions
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 976d4b1067d1..34f40efc7607 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -16,11 +16,6 @@
16#ifdef __KERNEL__ 16#ifdef __KERNEL__
17 17
18/* externally defined structs */ 18/* externally defined structs */
19struct vlan_group;
20struct net_device;
21struct packet_type;
22struct vlan_collection;
23struct vlan_dev_info;
24struct hlist_node; 19struct hlist_node;
25 20
26#include <linux/netdevice.h> 21#include <linux/netdevice.h>
@@ -39,12 +34,30 @@ struct hlist_node;
39#define VLAN_ETH_DATA_LEN 1500 /* Max. octets in payload */ 34#define VLAN_ETH_DATA_LEN 1500 /* Max. octets in payload */
40#define VLAN_ETH_FRAME_LEN 1518 /* Max. octets in frame sans FCS */ 35#define VLAN_ETH_FRAME_LEN 1518 /* Max. octets in frame sans FCS */
41 36
37/*
38 * struct vlan_hdr - vlan header
39 * @h_vlan_TCI: priority and VLAN ID
40 * @h_vlan_encapsulated_proto: packet type ID or len
41 */
42struct vlan_hdr {
43 __be16 h_vlan_TCI;
44 __be16 h_vlan_encapsulated_proto;
45};
46
47/**
48 * struct vlan_ethhdr - vlan ethernet header (ethhdr + vlan_hdr)
49 * @h_dest: destination ethernet address
50 * @h_source: source ethernet address
51 * @h_vlan_proto: ethernet protocol (always 0x8100)
52 * @h_vlan_TCI: priority and VLAN ID
53 * @h_vlan_encapsulated_proto: packet type ID or len
54 */
42struct vlan_ethhdr { 55struct vlan_ethhdr {
43 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ 56 unsigned char h_dest[ETH_ALEN];
44 unsigned char h_source[ETH_ALEN]; /* source ether addr */ 57 unsigned char h_source[ETH_ALEN];
45 __be16 h_vlan_proto; /* Should always be 0x8100 */ 58 __be16 h_vlan_proto;
46 __be16 h_vlan_TCI; /* Encapsulates priority and VLAN ID */ 59 __be16 h_vlan_TCI;
47 __be16 h_vlan_encapsulated_proto; /* packet type ID field (or len) */ 60 __be16 h_vlan_encapsulated_proto;
48}; 61};
49 62
50#include <linux/skbuff.h> 63#include <linux/skbuff.h>
@@ -54,18 +67,11 @@ static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb)
54 return (struct vlan_ethhdr *)skb_mac_header(skb); 67 return (struct vlan_ethhdr *)skb_mac_header(skb);
55} 68}
56 69
57struct vlan_hdr {
58 __be16 h_vlan_TCI; /* Encapsulates priority and VLAN ID */
59 __be16 h_vlan_encapsulated_proto; /* packet type ID field (or len) */
60};
61
62#define VLAN_VID_MASK 0xfff 70#define VLAN_VID_MASK 0xfff
63 71
64/* found in socket.c */ 72/* found in socket.c */
65extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *)); 73extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
66 74
67#define VLAN_NAME "vlan"
68
69/* if this changes, algorithm will have to be reworked because this 75/* if this changes, algorithm will have to be reworked because this
70 * depends on completely exhausting the VLAN identifier space. Thus 76 * depends on completely exhausting the VLAN identifier space. Thus
71 * it gives constant time look-up, but in many cases it wastes memory. 77 * it gives constant time look-up, but in many cases it wastes memory.
@@ -76,19 +82,22 @@ extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
76 82
77struct vlan_group { 83struct vlan_group {
78 int real_dev_ifindex; /* The ifindex of the ethernet(like) device the vlan is attached to. */ 84 int real_dev_ifindex; /* The ifindex of the ethernet(like) device the vlan is attached to. */
85 unsigned int nr_vlans;
79 struct hlist_node hlist; /* linked list */ 86 struct hlist_node hlist; /* linked list */
80 struct net_device **vlan_devices_arrays[VLAN_GROUP_ARRAY_SPLIT_PARTS]; 87 struct net_device **vlan_devices_arrays[VLAN_GROUP_ARRAY_SPLIT_PARTS];
81 struct rcu_head rcu; 88 struct rcu_head rcu;
82}; 89};
83 90
84static inline struct net_device *vlan_group_get_device(struct vlan_group *vg, int vlan_id) 91static inline struct net_device *vlan_group_get_device(struct vlan_group *vg,
92 unsigned int vlan_id)
85{ 93{
86 struct net_device **array; 94 struct net_device **array;
87 array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN]; 95 array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
88 return array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN]; 96 return array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN];
89} 97}
90 98
91static inline void vlan_group_set_device(struct vlan_group *vg, int vlan_id, 99static inline void vlan_group_set_device(struct vlan_group *vg,
100 unsigned int vlan_id,
92 struct net_device *dev) 101 struct net_device *dev)
93{ 102{
94 struct net_device **array; 103 struct net_device **array;
@@ -132,22 +141,18 @@ struct vlan_dev_info {
132 struct proc_dir_entry *dent; /* Holds the proc data */ 141 struct proc_dir_entry *dent; /* Holds the proc data */
133 unsigned long cnt_inc_headroom_on_tx; /* How many times did we have to grow the skb on TX. */ 142 unsigned long cnt_inc_headroom_on_tx; /* How many times did we have to grow the skb on TX. */
134 unsigned long cnt_encap_on_xmit; /* How many times did we have to encapsulate the skb on TX. */ 143 unsigned long cnt_encap_on_xmit; /* How many times did we have to encapsulate the skb on TX. */
135 struct net_device_stats dev_stats; /* Device stats (rx-bytes, tx-pkts, etc...) */
136}; 144};
137 145
138#define VLAN_DEV_INFO(x) ((struct vlan_dev_info *)(x->priv)) 146static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
139
140/* inline functions */
141
142static inline struct net_device_stats *vlan_dev_get_stats(struct net_device *dev)
143{ 147{
144 return &(VLAN_DEV_INFO(dev)->dev_stats); 148 return netdev_priv(dev);
145} 149}
146 150
151/* inline functions */
147static inline __u32 vlan_get_ingress_priority(struct net_device *dev, 152static inline __u32 vlan_get_ingress_priority(struct net_device *dev,
148 unsigned short vlan_tag) 153 unsigned short vlan_tag)
149{ 154{
150 struct vlan_dev_info *vip = VLAN_DEV_INFO(dev); 155 struct vlan_dev_info *vip = vlan_dev_info(dev);
151 156
152 return vip->ingress_priority_map[(vlan_tag >> 13) & 0x7]; 157 return vip->ingress_priority_map[(vlan_tag >> 13) & 0x7];
153} 158}
@@ -188,7 +193,7 @@ static inline int __vlan_hwaccel_rx(struct sk_buff *skb,
188 193
189 skb->dev->last_rx = jiffies; 194 skb->dev->last_rx = jiffies;
190 195
191 stats = vlan_dev_get_stats(skb->dev); 196 stats = &skb->dev->stats;
192 stats->rx_packets++; 197 stats->rx_packets++;
193 stats->rx_bytes += skb->len; 198 stats->rx_bytes += skb->len;
194 199
@@ -266,12 +271,12 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short
266 memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN); 271 memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN);
267 272
268 /* first, the ethernet type */ 273 /* first, the ethernet type */
269 veth->h_vlan_proto = __constant_htons(ETH_P_8021Q); 274 veth->h_vlan_proto = htons(ETH_P_8021Q);
270 275
271 /* now, the tag */ 276 /* now, the tag */
272 veth->h_vlan_TCI = htons(tag); 277 veth->h_vlan_TCI = htons(tag);
273 278
274 skb->protocol = __constant_htons(ETH_P_8021Q); 279 skb->protocol = htons(ETH_P_8021Q);
275 skb->mac_header -= VLAN_HLEN; 280 skb->mac_header -= VLAN_HLEN;
276 skb->network_header -= VLAN_HLEN; 281 skb->network_header -= VLAN_HLEN;
277 282
@@ -326,7 +331,7 @@ static inline int __vlan_get_tag(struct sk_buff *skb, unsigned short *tag)
326{ 331{
327 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data; 332 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data;
328 333
329 if (veth->h_vlan_proto != __constant_htons(ETH_P_8021Q)) { 334 if (veth->h_vlan_proto != htons(ETH_P_8021Q)) {
330 return -EINVAL; 335 return -EINVAL;
331 } 336 }
332 337