aboutsummaryrefslogtreecommitdiffstats
path: root/net/8021q/vlan.c
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 /net/8021q/vlan.c
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>
Diffstat (limited to 'net/8021q/vlan.c')
-rw-r--r--net/8021q/vlan.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 7a2625d2f9a0..68bdcf4a795c 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;