diff options
author | Patrick McHardy <kaber@trash.net> | 2008-07-08 06:24:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-07-08 06:24:44 -0400 |
commit | 9bb8582efb555521c7eec595ebd34e835ddc34b8 (patch) | |
tree | 8eb6aae062bbd359e820a35d51fb16a32e7b828f /net/8021q/vlan_dev.c | |
parent | df6b6a0cf62afeacdeb4c1a35b8fba21fda54399 (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_dev.c')
-rw-r--r-- | net/8021q/vlan_dev.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 2aab294c5744..2ccac6bea57e 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 | ||
231 | static inline unsigned short | 230 | static inline u16 |
232 | vlan_dev_get_egress_qos_mask(struct net_device *dev, struct sk_buff *skb) | 231 | vlan_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 | ||
459 | void vlan_dev_set_ingress_priority(const struct net_device *dev, | 458 | void 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 | ||
472 | int vlan_dev_set_egress_priority(const struct net_device *dev, | 471 | int 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; |