Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

via-velocity: do vlan cleanup

- unify vlan and nonvlan rx path
- kill vptr->vlgrp and velocity_vlan_rx_register

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jiri Pirko and committed by
David S. Miller
73b54688 08dddfc3

+20 -29
+19 -28
drivers/net/via-velocity.c
··· 45 45 46 46 #include <linux/module.h> 47 47 #include <linux/types.h> 48 + #include <linux/bitops.h> 48 49 #include <linux/init.h> 49 50 #include <linux/mm.h> 50 51 #include <linux/errno.h> ··· 77 76 #include <linux/udp.h> 78 77 #include <linux/crc-ccitt.h> 79 78 #include <linux/crc32.h> 79 + #include <linux/if_vlan.h> 80 80 81 81 #include "via-velocity.h" 82 82 ··· 503 501 static void velocity_init_cam_filter(struct velocity_info *vptr) 504 502 { 505 503 struct mac_regs __iomem *regs = vptr->mac_regs; 504 + unsigned int vid, i = 0; 506 505 507 506 /* Turn on MCFG_PQEN, turn off MCFG_RTGOPT */ 508 507 WORD_REG_BITS_SET(MCFG_PQEN, MCFG_RTGOPT, &regs->MCFG); ··· 516 513 mac_set_cam_mask(regs, vptr->mCAMmask); 517 514 518 515 /* Enable VCAMs */ 519 - if (vptr->vlgrp) { 520 - unsigned int vid, i = 0; 521 516 522 - if (!vlan_group_get_device(vptr->vlgrp, 0)) 523 - WORD_REG_BITS_ON(MCFG_RTGOPT, &regs->MCFG); 517 + if (test_bit(0, vptr->active_vlans)) 518 + WORD_REG_BITS_ON(MCFG_RTGOPT, &regs->MCFG); 524 519 525 - for (vid = 1; (vid < VLAN_VID_MASK); vid++) { 526 - if (vlan_group_get_device(vptr->vlgrp, vid)) { 527 - mac_set_vlan_cam(regs, i, (u8 *) &vid); 528 - vptr->vCAMmask[i / 8] |= 0x1 << (i % 8); 529 - if (++i >= VCAM_SIZE) 530 - break; 531 - } 532 - } 533 - mac_set_vlan_cam_mask(regs, vptr->vCAMmask); 520 + for_each_set_bit(vid, vptr->active_vlans, VLAN_N_VID) { 521 + mac_set_vlan_cam(regs, i, (u8 *) &vid); 522 + vptr->vCAMmask[i / 8] |= 0x1 << (i % 8); 523 + if (++i >= VCAM_SIZE) 524 + break; 534 525 } 535 - } 536 - 537 - static void velocity_vlan_rx_register(struct net_device *dev, 538 - struct vlan_group *grp) 539 - { 540 - struct velocity_info *vptr = netdev_priv(dev); 541 - 542 - vptr->vlgrp = grp; 526 + mac_set_vlan_cam_mask(regs, vptr->vCAMmask); 543 527 } 544 528 545 529 static void velocity_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) ··· 534 544 struct velocity_info *vptr = netdev_priv(dev); 535 545 536 546 spin_lock_irq(&vptr->lock); 547 + set_bit(vid, vptr->active_vlans); 537 548 velocity_init_cam_filter(vptr); 538 549 spin_unlock_irq(&vptr->lock); 539 550 } ··· 544 553 struct velocity_info *vptr = netdev_priv(dev); 545 554 546 555 spin_lock_irq(&vptr->lock); 547 - vlan_group_set_device(vptr->vlgrp, vid, NULL); 556 + clear_bit(vid, vptr->active_vlans); 548 557 velocity_init_cam_filter(vptr); 549 558 spin_unlock_irq(&vptr->lock); 550 559 } ··· 2085 2094 skb_put(skb, pkt_len - 4); 2086 2095 skb->protocol = eth_type_trans(skb, vptr->dev); 2087 2096 2088 - if (vptr->vlgrp && (rd->rdesc0.RSR & RSR_DETAG)) { 2089 - vlan_hwaccel_rx(skb, vptr->vlgrp, 2090 - swab16(le16_to_cpu(rd->rdesc1.PQTAG))); 2091 - } else 2092 - netif_rx(skb); 2097 + if (rd->rdesc0.RSR & RSR_DETAG) { 2098 + u16 vid = swab16(le16_to_cpu(rd->rdesc1.PQTAG)); 2099 + 2100 + __vlan_hwaccel_put_tag(skb, vid); 2101 + } 2102 + netif_rx(skb); 2093 2103 2094 2104 stats->rx_bytes += pkt_len; 2095 2105 ··· 2633 2641 .ndo_do_ioctl = velocity_ioctl, 2634 2642 .ndo_vlan_rx_add_vid = velocity_vlan_rx_add_vid, 2635 2643 .ndo_vlan_rx_kill_vid = velocity_vlan_rx_kill_vid, 2636 - .ndo_vlan_rx_register = velocity_vlan_rx_register, 2637 2644 }; 2638 2645 2639 2646 /**
+1 -1
drivers/net/via-velocity.h
··· 1437 1437 struct pci_dev *pdev; 1438 1438 struct net_device *dev; 1439 1439 1440 - struct vlan_group *vlgrp; 1440 + unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 1441 1441 u8 ip_addr[4]; 1442 1442 enum chip_type chip_id; 1443 1443