Commit 9dfebcc6479c55c001e4bb5fe7cc16b6799c43a7

Authored by Patrick McHardy
Committed by David S. Miller
1 parent af30151709

[VLAN]: Turn VLAN_DEV_INFO into inline function

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 7 changed files with 54 additions and 51 deletions Side-by-side Diff

drivers/net/cxgb3/l2t.c
... ... @@ -337,7 +337,7 @@
337 337 atomic_set(&e->refcnt, 1);
338 338 neigh_replace(e, neigh);
339 339 if (neigh->dev->priv_flags & IFF_802_1Q_VLAN)
340   - e->vlan = VLAN_DEV_INFO(neigh->dev)->vlan_id;
  340 + e->vlan = vlan_dev_info(neigh->dev)->vlan_id;
341 341 else
342 342 e->vlan = VLAN_NONE;
343 343 spin_unlock(&e->lock);
drivers/s390/net/qeth_main.c
... ... @@ -3890,7 +3890,7 @@
3890 3890 break;
3891 3891 }
3892 3892 }
3893   - if (rc && !(VLAN_DEV_INFO(dev)->real_dev->priv == (void *)card))
  3893 + if (rc && !(vlan_dev_info(dev)->real_dev->priv == (void *)card))
3894 3894 return 0;
3895 3895  
3896 3896 #endif
... ... @@ -3930,7 +3930,7 @@
3930 3930 card = (struct qeth_card *)dev->priv;
3931 3931 else if (rc == QETH_VLAN_CARD)
3932 3932 card = (struct qeth_card *)
3933   - VLAN_DEV_INFO(dev)->real_dev->priv;
  3933 + vlan_dev_info(dev)->real_dev->priv;
3934 3934  
3935 3935 QETH_DBF_TEXT_(trace, 4, "%d", rc);
3936 3936 return card ;
include/linux/if_vlan.h
... ... @@ -143,13 +143,16 @@
143 143 unsigned long cnt_encap_on_xmit; /* How many times did we have to encapsulate the skb on TX. */
144 144 };
145 145  
146   -#define VLAN_DEV_INFO(x) ((struct vlan_dev_info *)(x->priv))
  146 +static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
  147 +{
  148 + return netdev_priv(dev);
  149 +}
147 150  
148 151 /* inline functions */
149 152 static inline __u32 vlan_get_ingress_priority(struct net_device *dev,
150 153 unsigned short vlan_tag)
151 154 {
152   - struct vlan_dev_info *vip = VLAN_DEV_INFO(dev);
  155 + struct vlan_dev_info *vip = vlan_dev_info(dev);
153 156  
154 157 return vip->ingress_priority_map[(vlan_tag >> 13) & 0x7];
155 158 }
... ... @@ -134,7 +134,7 @@
134 134  
135 135 void unregister_vlan_dev(struct net_device *dev)
136 136 {
137   - struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
  137 + struct vlan_dev_info *vlan = vlan_dev_info(dev);
138 138 struct net_device *real_dev = vlan->real_dev;
139 139 struct vlan_group *grp;
140 140 unsigned short vlan_id = vlan->vlan_id;
... ... @@ -229,7 +229,7 @@
229 229  
230 230 int register_vlan_dev(struct net_device *dev)
231 231 {
232   - struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
  232 + struct vlan_dev_info *vlan = vlan_dev_info(dev);
233 233 struct net_device *real_dev = vlan->real_dev;
234 234 unsigned short vlan_id = vlan->vlan_id;
235 235 struct vlan_group *grp, *ngrp = NULL;
... ... @@ -328,10 +328,10 @@
328 328 */
329 329 new_dev->mtu = real_dev->mtu;
330 330  
331   - VLAN_DEV_INFO(new_dev)->vlan_id = VLAN_ID; /* 1 through VLAN_VID_MASK */
332   - VLAN_DEV_INFO(new_dev)->real_dev = real_dev;
333   - VLAN_DEV_INFO(new_dev)->dent = NULL;
334   - VLAN_DEV_INFO(new_dev)->flags = VLAN_FLAG_REORDER_HDR;
  331 + vlan_dev_info(new_dev)->vlan_id = VLAN_ID; /* 1 through VLAN_VID_MASK */
  332 + vlan_dev_info(new_dev)->real_dev = real_dev;
  333 + vlan_dev_info(new_dev)->dent = NULL;
  334 + vlan_dev_info(new_dev)->flags = VLAN_FLAG_REORDER_HDR;
335 335  
336 336 new_dev->rtnl_link_ops = &vlan_link_ops;
337 337 err = register_vlan_dev(new_dev);
... ... @@ -348,7 +348,7 @@
348 348 static void vlan_sync_address(struct net_device *dev,
349 349 struct net_device *vlandev)
350 350 {
351   - struct vlan_dev_info *vlan = VLAN_DEV_INFO(vlandev);
  351 + struct vlan_dev_info *vlan = vlan_dev_info(vlandev);
352 352  
353 353 /* May be called without an actual change */
354 354 if (!compare_ether_addr(vlan->real_dev_addr, dev->dev_addr))
net/8021q/vlan_dev.c
... ... @@ -72,7 +72,7 @@
72 72  
73 73 static inline struct sk_buff *vlan_check_reorder_header(struct sk_buff *skb)
74 74 {
75   - if (VLAN_DEV_INFO(skb->dev)->flags & VLAN_FLAG_REORDER_HDR) {
  75 + if (vlan_dev_info(skb->dev)->flags & VLAN_FLAG_REORDER_HDR) {
76 76 if (skb_shared(skb) || skb_cloned(skb)) {
77 77 struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC);
78 78 kfree_skb(skb);
... ... @@ -290,7 +290,7 @@
290 290 struct sk_buff* skb)
291 291 {
292 292 struct vlan_priority_tci_mapping *mp =
293   - VLAN_DEV_INFO(dev)->egress_priority_map[(skb->priority & 0xF)];
  293 + vlan_dev_info(dev)->egress_priority_map[(skb->priority & 0xF)];
294 294  
295 295 while (mp) {
296 296 if (mp->priority == skb->priority) {
... ... @@ -324,7 +324,7 @@
324 324 struct net_device *vdev = dev; /* save this for the bottom of the method */
325 325  
326 326 pr_debug("%s: skb: %p type: %hx len: %u vlan_id: %hx, daddr: %p\n",
327   - __FUNCTION__, skb, type, len, VLAN_DEV_INFO(dev)->vlan_id, daddr);
  327 + __FUNCTION__, skb, type, len, vlan_dev_info(dev)->vlan_id, daddr);
328 328  
329 329 /* build vlan header only if re_order_header flag is NOT set. This
330 330 * fixes some programs that get confused when they see a VLAN device
... ... @@ -334,7 +334,7 @@
334 334 * header shuffling in the hard_start_xmit. Users can turn off this
335 335 * REORDER behaviour with the vconfig tool.
336 336 */
337   - if (!(VLAN_DEV_INFO(dev)->flags & VLAN_FLAG_REORDER_HDR))
  337 + if (!(vlan_dev_info(dev)->flags & VLAN_FLAG_REORDER_HDR))
338 338 build_vlan_header = 1;
339 339  
340 340 if (build_vlan_header) {
... ... @@ -349,7 +349,7 @@
349 349 * VLAN ID 12 bits (low bits)
350 350 *
351 351 */
352   - veth_TCI = VLAN_DEV_INFO(dev)->vlan_id;
  352 + veth_TCI = vlan_dev_info(dev)->vlan_id;
353 353 veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb);
354 354  
355 355 vhdr->h_vlan_TCI = htons(veth_TCI);
... ... @@ -374,7 +374,7 @@
374 374 if (saddr == NULL)
375 375 saddr = dev->dev_addr;
376 376  
377   - dev = VLAN_DEV_INFO(dev)->real_dev;
  377 + dev = vlan_dev_info(dev)->real_dev;
378 378  
379 379 /* MPLS can send us skbuffs w/out enough space. This check will grow the
380 380 * skb if it doesn't have enough headroom. Not a beautiful solution, so
... ... @@ -395,7 +395,7 @@
395 395 stats->tx_dropped++;
396 396 return -ENOMEM;
397 397 }
398   - VLAN_DEV_INFO(vdev)->cnt_inc_headroom_on_tx++;
  398 + vlan_dev_info(vdev)->cnt_inc_headroom_on_tx++;
399 399 pr_debug("%s: %s: had to grow skb.\n", __FUNCTION__, vdev->name);
400 400 }
401 401  
402 402  
... ... @@ -430,12 +430,12 @@
430 430 */
431 431  
432 432 if (veth->h_vlan_proto != htons(ETH_P_8021Q) ||
433   - VLAN_DEV_INFO(dev)->flags & VLAN_FLAG_REORDER_HDR) {
  433 + vlan_dev_info(dev)->flags & VLAN_FLAG_REORDER_HDR) {
434 434 int orig_headroom = skb_headroom(skb);
435 435 unsigned short veth_TCI;
436 436  
437 437 /* This is not a VLAN frame...but we can fix that! */
438   - VLAN_DEV_INFO(dev)->cnt_encap_on_xmit++;
  438 + vlan_dev_info(dev)->cnt_encap_on_xmit++;
439 439  
440 440 pr_debug("%s: proto to encap: 0x%hx\n",
441 441 __FUNCTION__, htons(veth->h_vlan_proto));
... ... @@ -445,7 +445,7 @@
445 445 * CFI 1 bit
446 446 * VLAN ID 12 bits (low bits)
447 447 */
448   - veth_TCI = VLAN_DEV_INFO(dev)->vlan_id;
  448 + veth_TCI = vlan_dev_info(dev)->vlan_id;
449 449 veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb);
450 450  
451 451 skb = __vlan_put_tag(skb, veth_TCI);
... ... @@ -455,7 +455,7 @@
455 455 }
456 456  
457 457 if (orig_headroom < VLAN_HLEN) {
458   - VLAN_DEV_INFO(dev)->cnt_inc_headroom_on_tx++;
  458 + vlan_dev_info(dev)->cnt_inc_headroom_on_tx++;
459 459 }
460 460 }
461 461  
... ... @@ -472,7 +472,7 @@
472 472 stats->tx_packets++; /* for statics only */
473 473 stats->tx_bytes += skb->len;
474 474  
475   - skb->dev = VLAN_DEV_INFO(dev)->real_dev;
  475 + skb->dev = vlan_dev_info(dev)->real_dev;
476 476 dev_queue_xmit(skb);
477 477  
478 478 return 0;
479 479  
... ... @@ -490,14 +490,14 @@
490 490 * CFI 1 bit
491 491 * VLAN ID 12 bits (low bits)
492 492 */
493   - veth_TCI = VLAN_DEV_INFO(dev)->vlan_id;
  493 + veth_TCI = vlan_dev_info(dev)->vlan_id;
494 494 veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb);
495 495 skb = __vlan_hwaccel_put_tag(skb, veth_TCI);
496 496  
497 497 stats->tx_packets++;
498 498 stats->tx_bytes += skb->len;
499 499  
500   - skb->dev = VLAN_DEV_INFO(dev)->real_dev;
  500 + skb->dev = vlan_dev_info(dev)->real_dev;
501 501 dev_queue_xmit(skb);
502 502  
503 503 return 0;
... ... @@ -508,7 +508,7 @@
508 508 /* TODO: gotta make sure the underlying layer can handle it,
509 509 * maybe an IFF_VLAN_CAPABLE flag for devices?
510 510 */
511   - if (VLAN_DEV_INFO(dev)->real_dev->mtu < new_mtu)
  511 + if (vlan_dev_info(dev)->real_dev->mtu < new_mtu)
512 512 return -ERANGE;
513 513  
514 514 dev->mtu = new_mtu;
... ... @@ -519,7 +519,7 @@
519 519 void vlan_dev_set_ingress_priority(const struct net_device *dev,
520 520 u32 skb_prio, short vlan_prio)
521 521 {
522   - struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
  522 + struct vlan_dev_info *vlan = vlan_dev_info(dev);
523 523  
524 524 if (vlan->ingress_priority_map[vlan_prio & 0x7] && !skb_prio)
525 525 vlan->nr_ingress_mappings--;
... ... @@ -532,7 +532,7 @@
532 532 int vlan_dev_set_egress_priority(const struct net_device *dev,
533 533 u32 skb_prio, short vlan_prio)
534 534 {
535   - struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
  535 + struct vlan_dev_info *vlan = vlan_dev_info(dev);
536 536 struct vlan_priority_tci_mapping *mp = NULL;
537 537 struct vlan_priority_tci_mapping *np;
538 538 u32 vlan_qos = (vlan_prio << 13) & 0xE000;
539 539  
... ... @@ -573,9 +573,9 @@
573 573 /* verify flag is supported */
574 574 if (flag == VLAN_FLAG_REORDER_HDR) {
575 575 if (flag_val) {
576   - VLAN_DEV_INFO(dev)->flags |= VLAN_FLAG_REORDER_HDR;
  576 + vlan_dev_info(dev)->flags |= VLAN_FLAG_REORDER_HDR;
577 577 } else {
578   - VLAN_DEV_INFO(dev)->flags &= ~VLAN_FLAG_REORDER_HDR;
  578 + vlan_dev_info(dev)->flags &= ~VLAN_FLAG_REORDER_HDR;
579 579 }
580 580 return 0;
581 581 }
582 582  
583 583  
... ... @@ -584,17 +584,17 @@
584 584  
585 585 void vlan_dev_get_realdev_name(const struct net_device *dev, char *result)
586 586 {
587   - strncpy(result, VLAN_DEV_INFO(dev)->real_dev->name, 23);
  587 + strncpy(result, vlan_dev_info(dev)->real_dev->name, 23);
588 588 }
589 589  
590 590 void vlan_dev_get_vid(const struct net_device *dev, unsigned short *result)
591 591 {
592   - *result = VLAN_DEV_INFO(dev)->vlan_id;
  592 + *result = vlan_dev_info(dev)->vlan_id;
593 593 }
594 594  
595 595 static int vlan_dev_open(struct net_device *dev)
596 596 {
597   - struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
  597 + struct vlan_dev_info *vlan = vlan_dev_info(dev);
598 598 struct net_device *real_dev = vlan->real_dev;
599 599 int err;
600 600  
... ... @@ -618,7 +618,7 @@
618 618  
619 619 static int vlan_dev_stop(struct net_device *dev)
620 620 {
621   - struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
  621 + struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
622 622  
623 623 dev_mc_unsync(real_dev, dev);
624 624 if (dev->flags & IFF_ALLMULTI)
... ... @@ -634,7 +634,7 @@
634 634  
635 635 static int vlan_dev_set_mac_address(struct net_device *dev, void *p)
636 636 {
637   - struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
  637 + struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
638 638 struct sockaddr *addr = p;
639 639 int err;
640 640  
... ... @@ -660,7 +660,7 @@
660 660  
661 661 static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
662 662 {
663   - struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
  663 + struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
664 664 struct ifreq ifrr;
665 665 int err = -EOPNOTSUPP;
666 666  
... ... @@ -684,7 +684,7 @@
684 684  
685 685 static void vlan_dev_change_rx_flags(struct net_device *dev, int change)
686 686 {
687   - struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
  687 + struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
688 688  
689 689 if (change & IFF_ALLMULTI)
690 690 dev_set_allmulti(real_dev, dev->flags & IFF_ALLMULTI ? 1 : -1);
... ... @@ -694,7 +694,7 @@
694 694  
695 695 static void vlan_dev_set_multicast_list(struct net_device *vlan_dev)
696 696 {
697   - dev_mc_sync(VLAN_DEV_INFO(vlan_dev)->real_dev, vlan_dev);
  697 + dev_mc_sync(vlan_dev_info(vlan_dev)->real_dev, vlan_dev);
698 698 }
699 699  
700 700 /*
... ... @@ -712,7 +712,7 @@
712 712  
713 713 static int vlan_dev_init(struct net_device *dev)
714 714 {
715   - struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
  715 + struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
716 716 int subclass = 0;
717 717  
718 718 /* IFF_BROADCAST|IFF_MULTICAST; ??? */
net/8021q/vlan_netlink.c
... ... @@ -75,7 +75,7 @@
75 75 static int vlan_changelink(struct net_device *dev,
76 76 struct nlattr *tb[], struct nlattr *data[])
77 77 {
78   - struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
  78 + struct vlan_dev_info *vlan = vlan_dev_info(dev);
79 79 struct ifla_vlan_flags *flags;
80 80 struct ifla_vlan_qos_mapping *m;
81 81 struct nlattr *attr;
... ... @@ -104,7 +104,7 @@
104 104 static int vlan_newlink(struct net_device *dev,
105 105 struct nlattr *tb[], struct nlattr *data[])
106 106 {
107   - struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
  107 + struct vlan_dev_info *vlan = vlan_dev_info(dev);
108 108 struct net_device *real_dev;
109 109 int err;
110 110  
... ... @@ -148,7 +148,7 @@
148 148  
149 149 static size_t vlan_get_size(const struct net_device *dev)
150 150 {
151   - struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
  151 + struct vlan_dev_info *vlan = vlan_dev_info(dev);
152 152  
153 153 return nla_total_size(2) + /* IFLA_VLAN_ID */
154 154 vlan_qos_map_size(vlan->nr_ingress_mappings) +
155 155  
... ... @@ -157,14 +157,14 @@
157 157  
158 158 static int vlan_fill_info(struct sk_buff *skb, const struct net_device *dev)
159 159 {
160   - struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
  160 + struct vlan_dev_info *vlan = vlan_dev_info(dev);
161 161 struct vlan_priority_tci_mapping *pm;
162 162 struct ifla_vlan_flags f;
163 163 struct ifla_vlan_qos_mapping m;
164 164 struct nlattr *nest;
165 165 unsigned int i;
166 166  
167   - NLA_PUT_U16(skb, IFLA_VLAN_ID, VLAN_DEV_INFO(dev)->vlan_id);
  167 + NLA_PUT_U16(skb, IFLA_VLAN_ID, vlan_dev_info(dev)->vlan_id);
168 168 if (vlan->flags) {
169 169 f.flags = vlan->flags;
170 170 f.mask = ~0;
net/8021q/vlanproc.c
... ... @@ -180,7 +180,7 @@
180 180  
181 181 int vlan_proc_add_dev (struct net_device *vlandev)
182 182 {
183   - struct vlan_dev_info *dev_info = VLAN_DEV_INFO(vlandev);
  183 + struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
184 184  
185 185 dev_info->dent = create_proc_entry(vlandev->name,
186 186 S_IFREG|S_IRUSR|S_IWUSR,
... ... @@ -199,9 +199,9 @@
199 199 int vlan_proc_rem_dev(struct net_device *vlandev)
200 200 {
201 201 /** NOTE: This will consume the memory pointed to by dent, it seems. */
202   - if (VLAN_DEV_INFO(vlandev)->dent) {
203   - remove_proc_entry(VLAN_DEV_INFO(vlandev)->dent->name, proc_vlan_dir);
204   - VLAN_DEV_INFO(vlandev)->dent = NULL;
  202 + if (vlan_dev_info(vlandev)->dent) {
  203 + remove_proc_entry(vlan_dev_info(vlandev)->dent->name, proc_vlan_dir);
  204 + vlan_dev_info(vlandev)->dent = NULL;
205 205 }
206 206 return 0;
207 207 }
... ... @@ -278,7 +278,7 @@
278 278 nmtype ? nmtype : "UNKNOWN" );
279 279 } else {
280 280 const struct net_device *vlandev = v;
281   - const struct vlan_dev_info *dev_info = VLAN_DEV_INFO(vlandev);
  281 + const struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
282 282  
283 283 seq_printf(seq, "%-15s| %d | %s\n", vlandev->name,
284 284 dev_info->vlan_id, dev_info->real_dev->name);
... ... @@ -289,7 +289,7 @@
289 289 static int vlandev_seq_show(struct seq_file *seq, void *offset)
290 290 {
291 291 struct net_device *vlandev = (struct net_device *) seq->private;
292   - const struct vlan_dev_info *dev_info = VLAN_DEV_INFO(vlandev);
  292 + const struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
293 293 struct net_device_stats *stats = &vlandev->stats;
294 294 static const char fmt[] = "%30s %12lu\n";
295 295 int i;