aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-07-08 06:24:44 -0400
committerDavid S. Miller <davem@davemloft.net>2008-07-08 06:24:44 -0400
commit9bb8582efb555521c7eec595ebd34e835ddc34b8 (patch)
tree8eb6aae062bbd359e820a35d51fb16a32e7b828f
parentdf6b6a0cf62afeacdeb4c1a35b8fba21fda54399 (diff)
vlan: TCI related type and naming cleanups
The VLAN code contains multiple spots that use tag, id and tci as identifiers for arguments and variables incorrectly and they actually contain or are expected to contain something different. Additionally types are used inconsistently (unsigned short vs u16) and identifiers are sometimes capitalized. - consistently use u16 for storing TCI, ID or QoS values - consistently use vlan_id and vlan_tci for storing the respective values - remove capitalization - add kdoc comment to netif_hwaccel_{rx,receive_skb} Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/if_vlan.h84
-rw-r--r--net/8021q/vlan.c34
-rw-r--r--net/8021q/vlan.h19
-rw-r--r--net/8021q/vlan_core.c6
-rw-r--r--net/8021q/vlan_dev.c47
-rw-r--r--net/8021q/vlan_gvrp.c8
6 files changed, 103 insertions, 95 deletions
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 8e68b05b13d..d36515dae62 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -87,7 +87,7 @@ struct vlan_group {
87}; 87};
88 88
89static inline struct net_device *vlan_group_get_device(struct vlan_group *vg, 89static inline struct net_device *vlan_group_get_device(struct vlan_group *vg,
90 unsigned int vlan_id) 90 u16 vlan_id)
91{ 91{
92 struct net_device **array; 92 struct net_device **array;
93 array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN]; 93 array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
@@ -95,7 +95,7 @@ static inline struct net_device *vlan_group_get_device(struct vlan_group *vg,
95} 95}
96 96
97static inline void vlan_group_set_device(struct vlan_group *vg, 97static inline void vlan_group_set_device(struct vlan_group *vg,
98 unsigned int vlan_id, 98 u16 vlan_id,
99 struct net_device *dev) 99 struct net_device *dev)
100{ 100{
101 struct net_device **array; 101 struct net_device **array;
@@ -122,7 +122,7 @@ extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
122extern u16 vlan_dev_vlan_id(const struct net_device *dev); 122extern u16 vlan_dev_vlan_id(const struct net_device *dev);
123 123
124extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, 124extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
125 unsigned short vlan_tag, int polling); 125 u16 vlan_tci, int polling);
126#else 126#else
127static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev) 127static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev)
128{ 128{
@@ -137,39 +137,51 @@ static inline u16 vlan_dev_vlan_id(const struct net_device *dev)
137} 137}
138 138
139static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, 139static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
140 unsigned short vlan_tag, int polling) 140 u16 vlan_tci, int polling)
141{ 141{
142 BUG(); 142 BUG();
143 return NET_XMIT_SUCCESS; 143 return NET_XMIT_SUCCESS;
144} 144}
145#endif 145#endif
146 146
147/**
148 * vlan_hwaccel_rx - netif_rx wrapper for VLAN RX acceleration
149 * @skb: buffer
150 * @grp: vlan group
151 * @vlan_tci: VLAN TCI as received from the card
152 */
147static inline int vlan_hwaccel_rx(struct sk_buff *skb, 153static inline int vlan_hwaccel_rx(struct sk_buff *skb,
148 struct vlan_group *grp, 154 struct vlan_group *grp,
149 unsigned short vlan_tag) 155 u16 vlan_tci)
150{ 156{
151 return __vlan_hwaccel_rx(skb, grp, vlan_tag, 0); 157 return __vlan_hwaccel_rx(skb, grp, vlan_tci, 0);
152} 158}
153 159
160/**
161 * vlan_hwaccel_receive_skb - netif_receive_skb wrapper for VLAN RX acceleration
162 * @skb: buffer
163 * @grp: vlan group
164 * @vlan_tci: VLAN TCI as received from the card
165 */
154static inline int vlan_hwaccel_receive_skb(struct sk_buff *skb, 166static inline int vlan_hwaccel_receive_skb(struct sk_buff *skb,
155 struct vlan_group *grp, 167 struct vlan_group *grp,
156 unsigned short vlan_tag) 168 u16 vlan_tci)
157{ 169{
158 return __vlan_hwaccel_rx(skb, grp, vlan_tag, 1); 170 return __vlan_hwaccel_rx(skb, grp, vlan_tci, 1);
159} 171}
160 172
161/** 173/**
162 * __vlan_put_tag - regular VLAN tag inserting 174 * __vlan_put_tag - regular VLAN tag inserting
163 * @skb: skbuff to tag 175 * @skb: skbuff to tag
164 * @tag: VLAN tag to insert 176 * @vlan_tci: VLAN TCI to insert
165 * 177 *
166 * Inserts the VLAN tag into @skb as part of the payload 178 * Inserts the VLAN tag into @skb as part of the payload
167 * Returns a VLAN tagged skb. If a new skb is created, @skb is freed. 179 * Returns a VLAN tagged skb. If a new skb is created, @skb is freed.
168 * 180 *
169 * Following the skb_unshare() example, in case of error, the calling function 181 * Following the skb_unshare() example, in case of error, the calling function
170 * doesn't have to worry about freeing the original skb. 182 * doesn't have to worry about freeing the original skb.
171 */ 183 */
172static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag) 184static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
173{ 185{
174 struct vlan_ethhdr *veth; 186 struct vlan_ethhdr *veth;
175 187
@@ -197,8 +209,8 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short
197 /* first, the ethernet type */ 209 /* first, the ethernet type */
198 veth->h_vlan_proto = htons(ETH_P_8021Q); 210 veth->h_vlan_proto = htons(ETH_P_8021Q);
199 211
200 /* now, the tag */ 212 /* now, the TCI */
201 veth->h_vlan_TCI = htons(tag); 213 veth->h_vlan_TCI = htons(vlan_tci);
202 214
203 skb->protocol = htons(ETH_P_8021Q); 215 skb->protocol = htons(ETH_P_8021Q);
204 216
@@ -208,17 +220,18 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short
208/** 220/**
209 * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting 221 * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting
210 * @skb: skbuff to tag 222 * @skb: skbuff to tag
211 * @tag: VLAN tag to insert 223 * @vlan_tci: VLAN TCI to insert
212 * 224 *
213 * Puts the VLAN tag in @skb->cb[] and lets the device do the rest 225 * Puts the VLAN TCI in @skb->cb[] and lets the device do the rest
214 */ 226 */
215static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, unsigned short tag) 227static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb,
228 u16 vlan_tci)
216{ 229{
217 struct vlan_skb_tx_cookie *cookie; 230 struct vlan_skb_tx_cookie *cookie;
218 231
219 cookie = VLAN_TX_SKB_CB(skb); 232 cookie = VLAN_TX_SKB_CB(skb);
220 cookie->magic = VLAN_TX_COOKIE_MAGIC; 233 cookie->magic = VLAN_TX_COOKIE_MAGIC;
221 cookie->vlan_tag = tag; 234 cookie->vlan_tag = vlan_tci;
222 235
223 return skb; 236 return skb;
224} 237}
@@ -228,28 +241,28 @@ static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, unsign
228/** 241/**
229 * vlan_put_tag - inserts VLAN tag according to device features 242 * vlan_put_tag - inserts VLAN tag according to device features
230 * @skb: skbuff to tag 243 * @skb: skbuff to tag
231 * @tag: VLAN tag to insert 244 * @vlan_tci: VLAN TCI to insert
232 * 245 *
233 * Assumes skb->dev is the target that will xmit this frame. 246 * Assumes skb->dev is the target that will xmit this frame.
234 * Returns a VLAN tagged skb. 247 * Returns a VLAN tagged skb.
235 */ 248 */
236static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, unsigned short tag) 249static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
237{ 250{
238 if (skb->dev->features & NETIF_F_HW_VLAN_TX) { 251 if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
239 return __vlan_hwaccel_put_tag(skb, tag); 252 return __vlan_hwaccel_put_tag(skb, vlan_tci);
240 } else { 253 } else {
241 return __vlan_put_tag(skb, tag); 254 return __vlan_put_tag(skb, vlan_tci);
242 } 255 }
243} 256}
244 257
245/** 258/**
246 * __vlan_get_tag - get the VLAN ID that is part of the payload 259 * __vlan_get_tag - get the VLAN ID that is part of the payload
247 * @skb: skbuff to query 260 * @skb: skbuff to query
248 * @tag: buffer to store vlaue 261 * @vlan_tci: buffer to store vlaue
249 * 262 *
250 * Returns error if the skb is not of VLAN type 263 * Returns error if the skb is not of VLAN type
251 */ 264 */
252static inline int __vlan_get_tag(const struct sk_buff *skb, unsigned short *tag) 265static inline int __vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
253{ 266{
254 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data; 267 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data;
255 268
@@ -257,29 +270,28 @@ static inline int __vlan_get_tag(const struct sk_buff *skb, unsigned short *tag)
257 return -EINVAL; 270 return -EINVAL;
258 } 271 }
259 272
260 *tag = ntohs(veth->h_vlan_TCI); 273 *vlan_tci = ntohs(veth->h_vlan_TCI);
261
262 return 0; 274 return 0;
263} 275}
264 276
265/** 277/**
266 * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[] 278 * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[]
267 * @skb: skbuff to query 279 * @skb: skbuff to query
268 * @tag: buffer to store vlaue 280 * @vlan_tci: buffer to store vlaue
269 * 281 *
270 * Returns error if @skb->cb[] is not set correctly 282 * Returns error if @skb->cb[] is not set correctly
271 */ 283 */
272static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb, 284static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb,
273 unsigned short *tag) 285 u16 *vlan_tci)
274{ 286{
275 struct vlan_skb_tx_cookie *cookie; 287 struct vlan_skb_tx_cookie *cookie;
276 288
277 cookie = VLAN_TX_SKB_CB(skb); 289 cookie = VLAN_TX_SKB_CB(skb);
278 if (cookie->magic == VLAN_TX_COOKIE_MAGIC) { 290 if (cookie->magic == VLAN_TX_COOKIE_MAGIC) {
279 *tag = cookie->vlan_tag; 291 *vlan_tci = cookie->vlan_tag;
280 return 0; 292 return 0;
281 } else { 293 } else {
282 *tag = 0; 294 *vlan_tci = 0;
283 return -EINVAL; 295 return -EINVAL;
284 } 296 }
285} 297}
@@ -289,16 +301,16 @@ static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb,
289/** 301/**
290 * vlan_get_tag - get the VLAN ID from the skb 302 * vlan_get_tag - get the VLAN ID from the skb
291 * @skb: skbuff to query 303 * @skb: skbuff to query
292 * @tag: buffer to store vlaue 304 * @vlan_tci: buffer to store vlaue
293 * 305 *
294 * Returns error if the skb is not VLAN tagged 306 * Returns error if the skb is not VLAN tagged
295 */ 307 */
296static inline int vlan_get_tag(const struct sk_buff *skb, unsigned short *tag) 308static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
297{ 309{
298 if (skb->dev->features & NETIF_F_HW_VLAN_TX) { 310 if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
299 return __vlan_hwaccel_get_tag(skb, tag); 311 return __vlan_hwaccel_get_tag(skb, vlan_tci);
300 } else { 312 } else {
301 return __vlan_get_tag(skb, tag); 313 return __vlan_get_tag(skb, vlan_tci);
302 } 314 }
303} 315}
304 316
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 7a2625d2f9a..68bdcf4a795 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -83,13 +83,12 @@ static struct vlan_group *__vlan_find_group(struct net_device *real_dev)
83 * 83 *
84 * Must be invoked with RCU read lock (no preempt) 84 * Must be invoked with RCU read lock (no preempt)
85 */ 85 */
86struct net_device *__find_vlan_dev(struct net_device *real_dev, 86struct net_device *__find_vlan_dev(struct net_device *real_dev, u16 vlan_id)
87 unsigned short VID)
88{ 87{
89 struct vlan_group *grp = __vlan_find_group(real_dev); 88 struct vlan_group *grp = __vlan_find_group(real_dev);
90 89
91 if (grp) 90 if (grp)
92 return vlan_group_get_device(grp, VID); 91 return vlan_group_get_device(grp, vlan_id);
93 92
94 return NULL; 93 return NULL;
95} 94}
@@ -117,14 +116,14 @@ static struct vlan_group *vlan_group_alloc(struct net_device *real_dev)
117 return grp; 116 return grp;
118} 117}
119 118
120static int vlan_group_prealloc_vid(struct vlan_group *vg, int vid) 119static int vlan_group_prealloc_vid(struct vlan_group *vg, u16 vlan_id)
121{ 120{
122 struct net_device **array; 121 struct net_device **array;
123 unsigned int size; 122 unsigned int size;
124 123
125 ASSERT_RTNL(); 124 ASSERT_RTNL();
126 125
127 array = vg->vlan_devices_arrays[vid / VLAN_GROUP_ARRAY_PART_LEN]; 126 array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
128 if (array != NULL) 127 if (array != NULL)
129 return 0; 128 return 0;
130 129
@@ -133,7 +132,7 @@ static int vlan_group_prealloc_vid(struct vlan_group *vg, int vid)
133 if (array == NULL) 132 if (array == NULL)
134 return -ENOBUFS; 133 return -ENOBUFS;
135 134
136 vg->vlan_devices_arrays[vid / VLAN_GROUP_ARRAY_PART_LEN] = array; 135 vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN] = array;
137 return 0; 136 return 0;
138} 137}
139 138
@@ -147,7 +146,7 @@ void unregister_vlan_dev(struct net_device *dev)
147 struct vlan_dev_info *vlan = vlan_dev_info(dev); 146 struct vlan_dev_info *vlan = vlan_dev_info(dev);
148 struct net_device *real_dev = vlan->real_dev; 147 struct net_device *real_dev = vlan->real_dev;
149 struct vlan_group *grp; 148 struct vlan_group *grp;
150 unsigned short vlan_id = vlan->vlan_id; 149 u16 vlan_id = vlan->vlan_id;
151 150
152 ASSERT_RTNL(); 151 ASSERT_RTNL();
153 152
@@ -205,7 +204,7 @@ static void vlan_transfer_operstate(const struct net_device *dev,
205 } 204 }
206} 205}
207 206
208int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id) 207int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id)
209{ 208{
210 char *name = real_dev->name; 209 char *name = real_dev->name;
211 210
@@ -242,7 +241,7 @@ int register_vlan_dev(struct net_device *dev)
242{ 241{
243 struct vlan_dev_info *vlan = vlan_dev_info(dev); 242 struct vlan_dev_info *vlan = vlan_dev_info(dev);
244 struct net_device *real_dev = vlan->real_dev; 243 struct net_device *real_dev = vlan->real_dev;
245 unsigned short vlan_id = vlan->vlan_id; 244 u16 vlan_id = vlan->vlan_id;
246 struct vlan_group *grp, *ngrp = NULL; 245 struct vlan_group *grp, *ngrp = NULL;
247 int err; 246 int err;
248 247
@@ -295,8 +294,7 @@ out_free_group:
295/* Attach a VLAN device to a mac address (ie Ethernet Card). 294/* Attach a VLAN device to a mac address (ie Ethernet Card).
296 * Returns 0 if the device was created or a negative error code otherwise. 295 * Returns 0 if the device was created or a negative error code otherwise.
297 */ 296 */
298static int register_vlan_device(struct net_device *real_dev, 297static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
299 unsigned short VLAN_ID)
300{ 298{
301 struct net_device *new_dev; 299 struct net_device *new_dev;
302 struct net *net = dev_net(real_dev); 300 struct net *net = dev_net(real_dev);
@@ -304,10 +302,10 @@ static int register_vlan_device(struct net_device *real_dev,
304 char name[IFNAMSIZ]; 302 char name[IFNAMSIZ];
305 int err; 303 int err;
306 304
307 if (VLAN_ID >= VLAN_VID_MASK) 305 if (vlan_id >= VLAN_VID_MASK)
308 return -ERANGE; 306 return -ERANGE;
309 307
310 err = vlan_check_real_dev(real_dev, VLAN_ID); 308 err = vlan_check_real_dev(real_dev, vlan_id);
311 if (err < 0) 309 if (err < 0)
312 return err; 310 return err;
313 311
@@ -315,26 +313,26 @@ static int register_vlan_device(struct net_device *real_dev,
315 switch (vn->name_type) { 313 switch (vn->name_type) {
316 case VLAN_NAME_TYPE_RAW_PLUS_VID: 314 case VLAN_NAME_TYPE_RAW_PLUS_VID:
317 /* name will look like: eth1.0005 */ 315 /* name will look like: eth1.0005 */
318 snprintf(name, IFNAMSIZ, "%s.%.4i", real_dev->name, VLAN_ID); 316 snprintf(name, IFNAMSIZ, "%s.%.4i", real_dev->name, vlan_id);
319 break; 317 break;
320 case VLAN_NAME_TYPE_PLUS_VID_NO_PAD: 318 case VLAN_NAME_TYPE_PLUS_VID_NO_PAD:
321 /* Put our vlan.VID in the name. 319 /* Put our vlan.VID in the name.
322 * Name will look like: vlan5 320 * Name will look like: vlan5
323 */ 321 */
324 snprintf(name, IFNAMSIZ, "vlan%i", VLAN_ID); 322 snprintf(name, IFNAMSIZ, "vlan%i", vlan_id);
325 break; 323 break;
326 case VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD: 324 case VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD:
327 /* Put our vlan.VID in the name. 325 /* Put our vlan.VID in the name.
328 * Name will look like: eth0.5 326 * Name will look like: eth0.5
329 */ 327 */
330 snprintf(name, IFNAMSIZ, "%s.%i", real_dev->name, VLAN_ID); 328 snprintf(name, IFNAMSIZ, "%s.%i", real_dev->name, vlan_id);
331 break; 329 break;
332 case VLAN_NAME_TYPE_PLUS_VID: 330 case VLAN_NAME_TYPE_PLUS_VID:
333 /* Put our vlan.VID in the name. 331 /* Put our vlan.VID in the name.
334 * Name will look like: vlan0005 332 * Name will look like: vlan0005
335 */ 333 */
336 default: 334 default:
337 snprintf(name, IFNAMSIZ, "vlan%.4i", VLAN_ID); 335 snprintf(name, IFNAMSIZ, "vlan%.4i", vlan_id);
338 } 336 }
339 337
340 new_dev = alloc_netdev(sizeof(struct vlan_dev_info), name, 338 new_dev = alloc_netdev(sizeof(struct vlan_dev_info), name,
@@ -349,7 +347,7 @@ static int register_vlan_device(struct net_device *real_dev,
349 */ 347 */
350 new_dev->mtu = real_dev->mtu; 348 new_dev->mtu = real_dev->mtu;
351 349
352 vlan_dev_info(new_dev)->vlan_id = VLAN_ID; /* 1 through VLAN_VID_MASK */ 350 vlan_dev_info(new_dev)->vlan_id = vlan_id;
353 vlan_dev_info(new_dev)->real_dev = real_dev; 351 vlan_dev_info(new_dev)->real_dev = real_dev;
354 vlan_dev_info(new_dev)->dent = NULL; 352 vlan_dev_info(new_dev)->dent = NULL;
355 vlan_dev_info(new_dev)->flags = VLAN_FLAG_REORDER_HDR; 353 vlan_dev_info(new_dev)->flags = VLAN_FLAG_REORDER_HDR;
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 14c421e033f..a6603a4d917 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -12,7 +12,7 @@
12 */ 12 */
13struct vlan_priority_tci_mapping { 13struct vlan_priority_tci_mapping {
14 u32 priority; 14 u32 priority;
15 unsigned short vlan_qos; 15 u16 vlan_qos;
16 struct vlan_priority_tci_mapping *next; 16 struct vlan_priority_tci_mapping *next;
17}; 17};
18 18
@@ -36,8 +36,8 @@ struct vlan_dev_info {
36 unsigned int nr_egress_mappings; 36 unsigned int nr_egress_mappings;
37 struct vlan_priority_tci_mapping *egress_priority_map[16]; 37 struct vlan_priority_tci_mapping *egress_priority_map[16];
38 38
39 unsigned short vlan_id; 39 u16 vlan_id;
40 unsigned short flags; 40 u16 flags;
41 41
42 struct net_device *real_dev; 42 struct net_device *real_dev;
43 unsigned char real_dev_addr[ETH_ALEN]; 43 unsigned char real_dev_addr[ETH_ALEN];
@@ -67,30 +67,29 @@ static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
67 * Must be invoked with rcu_read_lock (ie preempt disabled) 67 * Must be invoked with rcu_read_lock (ie preempt disabled)
68 * or with RTNL. 68 * or with RTNL.
69 */ 69 */
70struct net_device *__find_vlan_dev(struct net_device *real_dev, 70struct net_device *__find_vlan_dev(struct net_device *real_dev, u16 vlan_id);
71 unsigned short VID); /* vlan.c */
72 71
73/* found in vlan_dev.c */ 72/* found in vlan_dev.c */
74int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, 73int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
75 struct packet_type *ptype, struct net_device *orig_dev); 74 struct packet_type *ptype, struct net_device *orig_dev);
76void vlan_dev_set_ingress_priority(const struct net_device *dev, 75void vlan_dev_set_ingress_priority(const struct net_device *dev,
77 u32 skb_prio, short vlan_prio); 76 u32 skb_prio, u16 vlan_prio);
78int vlan_dev_set_egress_priority(const struct net_device *dev, 77int vlan_dev_set_egress_priority(const struct net_device *dev,
79 u32 skb_prio, short vlan_prio); 78 u32 skb_prio, u16 vlan_prio);
80int vlan_dev_change_flags(const struct net_device *dev, u32 flag, u32 mask); 79int vlan_dev_change_flags(const struct net_device *dev, u32 flag, u32 mask);
81void vlan_dev_get_realdev_name(const struct net_device *dev, char *result); 80void vlan_dev_get_realdev_name(const struct net_device *dev, char *result);
82 81
83int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id); 82int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id);
84void vlan_setup(struct net_device *dev); 83void vlan_setup(struct net_device *dev);
85int register_vlan_dev(struct net_device *dev); 84int register_vlan_dev(struct net_device *dev);
86void unregister_vlan_dev(struct net_device *dev); 85void unregister_vlan_dev(struct net_device *dev);
87 86
88static inline u32 vlan_get_ingress_priority(struct net_device *dev, 87static inline u32 vlan_get_ingress_priority(struct net_device *dev,
89 unsigned short vlan_tag) 88 u16 vlan_tci)
90{ 89{
91 struct vlan_dev_info *vip = vlan_dev_info(dev); 90 struct vlan_dev_info *vip = vlan_dev_info(dev);
92 91
93 return vip->ingress_priority_map[(vlan_tag >> 13) & 0x7]; 92 return vip->ingress_priority_map[(vlan_tci >> 13) & 0x7];
94} 93}
95 94
96#ifdef CONFIG_VLAN_8021Q_GVRP 95#ifdef CONFIG_VLAN_8021Q_GVRP
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index f980b9154cc..68df12d3664 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -5,7 +5,7 @@
5 5
6/* VLAN rx hw acceleration helper. This acts like netif_{rx,receive_skb}(). */ 6/* VLAN rx hw acceleration helper. This acts like netif_{rx,receive_skb}(). */
7int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, 7int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
8 unsigned short vlan_tag, int polling) 8 u16 vlan_tci, int polling)
9{ 9{
10 struct net_device_stats *stats; 10 struct net_device_stats *stats;
11 11
@@ -14,7 +14,7 @@ int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
14 return NET_RX_DROP; 14 return NET_RX_DROP;
15 } 15 }
16 16
17 skb->dev = vlan_group_get_device(grp, vlan_tag & VLAN_VID_MASK); 17 skb->dev = vlan_group_get_device(grp, vlan_tci & VLAN_VID_MASK);
18 if (skb->dev == NULL) { 18 if (skb->dev == NULL) {
19 dev_kfree_skb_any(skb); 19 dev_kfree_skb_any(skb);
20 /* Not NET_RX_DROP, this is not being dropped 20 /* Not NET_RX_DROP, this is not being dropped
@@ -27,7 +27,7 @@ int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
27 stats->rx_packets++; 27 stats->rx_packets++;
28 stats->rx_bytes += skb->len; 28 stats->rx_bytes += skb->len;
29 29
30 skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tag); 30 skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tci);
31 switch (skb->pkt_type) { 31 switch (skb->pkt_type) {
32 case PACKET_BROADCAST: 32 case PACKET_BROADCAST:
33 break; 33 break;
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 2aab294c574..2ccac6bea57 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -150,9 +150,9 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
150 struct packet_type *ptype, struct net_device *orig_dev) 150 struct packet_type *ptype, struct net_device *orig_dev)
151{ 151{
152 struct vlan_hdr *vhdr; 152 struct vlan_hdr *vhdr;
153 unsigned short vid;
154 struct net_device_stats *stats; 153 struct net_device_stats *stats;
155 unsigned short vlan_TCI; 154 u16 vlan_id;
155 u16 vlan_tci;
156 156
157 skb = skb_share_check(skb, GFP_ATOMIC); 157 skb = skb_share_check(skb, GFP_ATOMIC);
158 if (skb == NULL) 158 if (skb == NULL)
@@ -162,14 +162,14 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
162 goto err_free; 162 goto err_free;
163 163
164 vhdr = (struct vlan_hdr *)skb->data; 164 vhdr = (struct vlan_hdr *)skb->data;
165 vlan_TCI = ntohs(vhdr->h_vlan_TCI); 165 vlan_tci = ntohs(vhdr->h_vlan_TCI);
166 vid = (vlan_TCI & VLAN_VID_MASK); 166 vlan_id = vlan_tci & VLAN_VID_MASK;
167 167
168 rcu_read_lock(); 168 rcu_read_lock();
169 skb->dev = __find_vlan_dev(dev, vid); 169 skb->dev = __find_vlan_dev(dev, vlan_id);
170 if (!skb->dev) { 170 if (!skb->dev) {
171 pr_debug("%s: ERROR: No net_device for VID: %u on dev: %s\n", 171 pr_debug("%s: ERROR: No net_device for VID: %u on dev: %s\n",
172 __func__, (unsigned int)vid, dev->name); 172 __func__, vlan_id, dev->name);
173 goto err_unlock; 173 goto err_unlock;
174 } 174 }
175 175
@@ -181,11 +181,10 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
181 181
182 skb_pull_rcsum(skb, VLAN_HLEN); 182 skb_pull_rcsum(skb, VLAN_HLEN);
183 183
184 skb->priority = vlan_get_ingress_priority(skb->dev, 184 skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tci);
185 ntohs(vhdr->h_vlan_TCI));
186 185
187 pr_debug("%s: priority: %u for TCI: %hu\n", 186 pr_debug("%s: priority: %u for TCI: %hu\n",
188 __func__, skb->priority, ntohs(vhdr->h_vlan_TCI)); 187 __func__, skb->priority, vlan_tci);
189 188
190 switch (skb->pkt_type) { 189 switch (skb->pkt_type) {
191 case PACKET_BROADCAST: /* Yeah, stats collect these together.. */ 190 case PACKET_BROADCAST: /* Yeah, stats collect these together.. */
@@ -228,7 +227,7 @@ err_free:
228 return NET_RX_DROP; 227 return NET_RX_DROP;
229} 228}
230 229
231static inline unsigned short 230static inline u16
232vlan_dev_get_egress_qos_mask(struct net_device *dev, struct sk_buff *skb) 231vlan_dev_get_egress_qos_mask(struct net_device *dev, struct sk_buff *skb)
233{ 232{
234 struct vlan_priority_tci_mapping *mp; 233 struct vlan_priority_tci_mapping *mp;
@@ -260,7 +259,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
260 unsigned int len) 259 unsigned int len)
261{ 260{
262 struct vlan_hdr *vhdr; 261 struct vlan_hdr *vhdr;
263 unsigned short veth_TCI = 0; 262 u16 vlan_tci = 0;
264 int rc = 0; 263 int rc = 0;
265 int build_vlan_header = 0; 264 int build_vlan_header = 0;
266 struct net_device *vdev = dev; 265 struct net_device *vdev = dev;
@@ -292,10 +291,10 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
292 * VLAN ID 12 bits (low bits) 291 * VLAN ID 12 bits (low bits)
293 * 292 *
294 */ 293 */
295 veth_TCI = vlan_dev_info(dev)->vlan_id; 294 vlan_tci = vlan_dev_info(dev)->vlan_id;
296 veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb); 295 vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
297 296
298 vhdr->h_vlan_TCI = htons(veth_TCI); 297 vhdr->h_vlan_TCI = htons(vlan_tci);
299 298
300 /* 299 /*
301 * Set the protocol type. For a packet of type ETH_P_802_3 we 300 * Set the protocol type. For a packet of type ETH_P_802_3 we
@@ -373,7 +372,7 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
373 if (veth->h_vlan_proto != htons(ETH_P_8021Q) || 372 if (veth->h_vlan_proto != htons(ETH_P_8021Q) ||
374 vlan_dev_info(dev)->flags & VLAN_FLAG_REORDER_HDR) { 373 vlan_dev_info(dev)->flags & VLAN_FLAG_REORDER_HDR) {
375 int orig_headroom = skb_headroom(skb); 374 int orig_headroom = skb_headroom(skb);
376 unsigned short veth_TCI; 375 u16 vlan_tci;
377 376
378 /* This is not a VLAN frame...but we can fix that! */ 377 /* This is not a VLAN frame...but we can fix that! */
379 vlan_dev_info(dev)->cnt_encap_on_xmit++; 378 vlan_dev_info(dev)->cnt_encap_on_xmit++;
@@ -386,10 +385,10 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
386 * CFI 1 bit 385 * CFI 1 bit
387 * VLAN ID 12 bits (low bits) 386 * VLAN ID 12 bits (low bits)
388 */ 387 */
389 veth_TCI = vlan_dev_info(dev)->vlan_id; 388 vlan_tci = vlan_dev_info(dev)->vlan_id;
390 veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb); 389 vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
391 390
392 skb = __vlan_put_tag(skb, veth_TCI); 391 skb = __vlan_put_tag(skb, vlan_tci);
393 if (!skb) { 392 if (!skb) {
394 stats->tx_dropped++; 393 stats->tx_dropped++;
395 return 0; 394 return 0;
@@ -422,7 +421,7 @@ static int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb,
422 struct net_device *dev) 421 struct net_device *dev)
423{ 422{
424 struct net_device_stats *stats = &dev->stats; 423 struct net_device_stats *stats = &dev->stats;
425 unsigned short veth_TCI; 424 u16 vlan_tci;
426 425
427 /* Construct the second two bytes. This field looks something 426 /* Construct the second two bytes. This field looks something
428 * like: 427 * like:
@@ -430,9 +429,9 @@ static int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb,
430 * CFI 1 bit 429 * CFI 1 bit
431 * VLAN ID 12 bits (low bits) 430 * VLAN ID 12 bits (low bits)
432 */ 431 */
433 veth_TCI = vlan_dev_info(dev)->vlan_id; 432 vlan_tci = vlan_dev_info(dev)->vlan_id;
434 veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb); 433 vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
435 skb = __vlan_hwaccel_put_tag(skb, veth_TCI); 434 skb = __vlan_hwaccel_put_tag(skb, vlan_tci);
436 435
437 stats->tx_packets++; 436 stats->tx_packets++;
438 stats->tx_bytes += skb->len; 437 stats->tx_bytes += skb->len;
@@ -457,7 +456,7 @@ static int vlan_dev_change_mtu(struct net_device *dev, int new_mtu)
457} 456}
458 457
459void vlan_dev_set_ingress_priority(const struct net_device *dev, 458void vlan_dev_set_ingress_priority(const struct net_device *dev,
460 u32 skb_prio, short vlan_prio) 459 u32 skb_prio, u16 vlan_prio)
461{ 460{
462 struct vlan_dev_info *vlan = vlan_dev_info(dev); 461 struct vlan_dev_info *vlan = vlan_dev_info(dev);
463 462
@@ -470,7 +469,7 @@ void vlan_dev_set_ingress_priority(const struct net_device *dev,
470} 469}
471 470
472int vlan_dev_set_egress_priority(const struct net_device *dev, 471int vlan_dev_set_egress_priority(const struct net_device *dev,
473 u32 skb_prio, short vlan_prio) 472 u32 skb_prio, u16 vlan_prio)
474{ 473{
475 struct vlan_dev_info *vlan = vlan_dev_info(dev); 474 struct vlan_dev_info *vlan = vlan_dev_info(dev);
476 struct vlan_priority_tci_mapping *mp = NULL; 475 struct vlan_priority_tci_mapping *mp = NULL;
diff --git a/net/8021q/vlan_gvrp.c b/net/8021q/vlan_gvrp.c
index db978160836..061ceceeef1 100644
--- a/net/8021q/vlan_gvrp.c
+++ b/net/8021q/vlan_gvrp.c
@@ -30,19 +30,19 @@ static struct garp_application vlan_gvrp_app __read_mostly = {
30int vlan_gvrp_request_join(const struct net_device *dev) 30int vlan_gvrp_request_join(const struct net_device *dev)
31{ 31{
32 const struct vlan_dev_info *vlan = vlan_dev_info(dev); 32 const struct vlan_dev_info *vlan = vlan_dev_info(dev);
33 __be16 vid = htons(vlan->vlan_id); 33 __be16 vlan_id = htons(vlan->vlan_id);
34 34
35 return garp_request_join(vlan->real_dev, &vlan_gvrp_app, 35 return garp_request_join(vlan->real_dev, &vlan_gvrp_app,
36 &vid, sizeof(vid), GVRP_ATTR_VID); 36 &vlan_id, sizeof(vlan_id), GVRP_ATTR_VID);
37} 37}
38 38
39void vlan_gvrp_request_leave(const struct net_device *dev) 39void vlan_gvrp_request_leave(const struct net_device *dev)
40{ 40{
41 const struct vlan_dev_info *vlan = vlan_dev_info(dev); 41 const struct vlan_dev_info *vlan = vlan_dev_info(dev);
42 __be16 vid = htons(vlan->vlan_id); 42 __be16 vlan_id = htons(vlan->vlan_id);
43 43
44 garp_request_leave(vlan->real_dev, &vlan_gvrp_app, 44 garp_request_leave(vlan->real_dev, &vlan_gvrp_app,
45 &vid, sizeof(vid), GVRP_ATTR_VID); 45 &vlan_id, sizeof(vlan_id), GVRP_ATTR_VID);
46} 46}
47 47
48int vlan_gvrp_init_applicant(struct net_device *dev) 48int vlan_gvrp_init_applicant(struct net_device *dev)