diff options
author | Jiri Pirko <jpirko@redhat.com> | 2011-07-20 00:54:31 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-07-21 16:47:56 -0400 |
commit | 5da96be53a16a62488316810d0c7c5d58ce3ee4f (patch) | |
tree | f2628fc1e2db9ac0b36b4c17f744c5e18a74e554 /drivers/net | |
parent | 73b54688815f76bdccb8b94b5d1fd2dd0af3ea70 (diff) |
starfire: do vlan cleanup
- unify vlan and nonvlan rx path
- kill np->vlgrp and netdev_vlan_rx_register
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/starfire.c | 89 |
1 files changed, 39 insertions, 50 deletions
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c index 860a50815f84..7ae1f990a98e 100644 --- a/drivers/net/starfire.c +++ b/drivers/net/starfire.c | |||
@@ -561,7 +561,7 @@ struct netdev_private { | |||
561 | struct net_device *dev; | 561 | struct net_device *dev; |
562 | struct pci_dev *pci_dev; | 562 | struct pci_dev *pci_dev; |
563 | #ifdef VLAN_SUPPORT | 563 | #ifdef VLAN_SUPPORT |
564 | struct vlan_group *vlgrp; | 564 | unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; |
565 | #endif | 565 | #endif |
566 | void *queue_mem; | 566 | void *queue_mem; |
567 | dma_addr_t queue_mem_dma; | 567 | dma_addr_t queue_mem_dma; |
@@ -607,18 +607,6 @@ static const struct ethtool_ops ethtool_ops; | |||
607 | 607 | ||
608 | 608 | ||
609 | #ifdef VLAN_SUPPORT | 609 | #ifdef VLAN_SUPPORT |
610 | static void netdev_vlan_rx_register(struct net_device *dev, struct vlan_group *grp) | ||
611 | { | ||
612 | struct netdev_private *np = netdev_priv(dev); | ||
613 | |||
614 | spin_lock(&np->lock); | ||
615 | if (debug > 2) | ||
616 | printk("%s: Setting vlgrp to %p\n", dev->name, grp); | ||
617 | np->vlgrp = grp; | ||
618 | set_rx_mode(dev); | ||
619 | spin_unlock(&np->lock); | ||
620 | } | ||
621 | |||
622 | static void netdev_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) | 610 | static void netdev_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) |
623 | { | 611 | { |
624 | struct netdev_private *np = netdev_priv(dev); | 612 | struct netdev_private *np = netdev_priv(dev); |
@@ -626,6 +614,7 @@ static void netdev_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) | |||
626 | spin_lock(&np->lock); | 614 | spin_lock(&np->lock); |
627 | if (debug > 1) | 615 | if (debug > 1) |
628 | printk("%s: Adding vlanid %d to vlan filter\n", dev->name, vid); | 616 | printk("%s: Adding vlanid %d to vlan filter\n", dev->name, vid); |
617 | set_bit(vid, np->active_vlans); | ||
629 | set_rx_mode(dev); | 618 | set_rx_mode(dev); |
630 | spin_unlock(&np->lock); | 619 | spin_unlock(&np->lock); |
631 | } | 620 | } |
@@ -637,7 +626,7 @@ static void netdev_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) | |||
637 | spin_lock(&np->lock); | 626 | spin_lock(&np->lock); |
638 | if (debug > 1) | 627 | if (debug > 1) |
639 | printk("%s: removing vlanid %d from vlan filter\n", dev->name, vid); | 628 | printk("%s: removing vlanid %d from vlan filter\n", dev->name, vid); |
640 | vlan_group_set_device(np->vlgrp, vid, NULL); | 629 | clear_bit(vid, np->active_vlans); |
641 | set_rx_mode(dev); | 630 | set_rx_mode(dev); |
642 | spin_unlock(&np->lock); | 631 | spin_unlock(&np->lock); |
643 | } | 632 | } |
@@ -648,15 +637,14 @@ static const struct net_device_ops netdev_ops = { | |||
648 | .ndo_open = netdev_open, | 637 | .ndo_open = netdev_open, |
649 | .ndo_stop = netdev_close, | 638 | .ndo_stop = netdev_close, |
650 | .ndo_start_xmit = start_tx, | 639 | .ndo_start_xmit = start_tx, |
651 | .ndo_tx_timeout = tx_timeout, | 640 | .ndo_tx_timeout = tx_timeout, |
652 | .ndo_get_stats = get_stats, | 641 | .ndo_get_stats = get_stats, |
653 | .ndo_set_multicast_list = &set_rx_mode, | 642 | .ndo_set_multicast_list = &set_rx_mode, |
654 | .ndo_do_ioctl = netdev_ioctl, | 643 | .ndo_do_ioctl = netdev_ioctl, |
655 | .ndo_change_mtu = eth_change_mtu, | 644 | .ndo_change_mtu = eth_change_mtu, |
656 | .ndo_set_mac_address = eth_mac_addr, | 645 | .ndo_set_mac_address = eth_mac_addr, |
657 | .ndo_validate_addr = eth_validate_addr, | 646 | .ndo_validate_addr = eth_validate_addr, |
658 | #ifdef VLAN_SUPPORT | 647 | #ifdef VLAN_SUPPORT |
659 | .ndo_vlan_rx_register = netdev_vlan_rx_register, | ||
660 | .ndo_vlan_rx_add_vid = netdev_vlan_rx_add_vid, | 648 | .ndo_vlan_rx_add_vid = netdev_vlan_rx_add_vid, |
661 | .ndo_vlan_rx_kill_vid = netdev_vlan_rx_kill_vid, | 649 | .ndo_vlan_rx_kill_vid = netdev_vlan_rx_kill_vid, |
662 | #endif | 650 | #endif |
@@ -1528,21 +1516,17 @@ static int __netdev_rx(struct net_device *dev, int *quota) | |||
1528 | printk(KERN_DEBUG "%s: checksum_hw, status2 = %#x\n", dev->name, le16_to_cpu(desc->status2)); | 1516 | printk(KERN_DEBUG "%s: checksum_hw, status2 = %#x\n", dev->name, le16_to_cpu(desc->status2)); |
1529 | } | 1517 | } |
1530 | #ifdef VLAN_SUPPORT | 1518 | #ifdef VLAN_SUPPORT |
1531 | if (np->vlgrp && le16_to_cpu(desc->status2) & 0x0200) { | 1519 | if (le16_to_cpu(desc->status2) & 0x0200) { |
1532 | u16 vlid = le16_to_cpu(desc->vlanid); | 1520 | u16 vlid = le16_to_cpu(desc->vlanid); |
1533 | 1521 | ||
1534 | if (debug > 4) { | 1522 | if (debug > 4) { |
1535 | printk(KERN_DEBUG " netdev_rx() vlanid = %d\n", | 1523 | printk(KERN_DEBUG " netdev_rx() vlanid = %d\n", |
1536 | vlid); | 1524 | vlid); |
1537 | } | 1525 | } |
1538 | /* | 1526 | __vlan_hwaccel_put_tag(skb, vlid); |
1539 | * vlan_hwaccel_rx expects a packet with the VLAN tag | 1527 | } |
1540 | * stripped out. | ||
1541 | */ | ||
1542 | vlan_hwaccel_rx(skb, np->vlgrp, vlid); | ||
1543 | } else | ||
1544 | #endif /* VLAN_SUPPORT */ | 1528 | #endif /* VLAN_SUPPORT */ |
1545 | netif_receive_skb(skb); | 1529 | netif_receive_skb(skb); |
1546 | dev->stats.rx_packets++; | 1530 | dev->stats.rx_packets++; |
1547 | 1531 | ||
1548 | next_rx: | 1532 | next_rx: |
@@ -1752,6 +1736,32 @@ static struct net_device_stats *get_stats(struct net_device *dev) | |||
1752 | return &dev->stats; | 1736 | return &dev->stats; |
1753 | } | 1737 | } |
1754 | 1738 | ||
1739 | #ifdef VLAN_SUPPORT | ||
1740 | static u32 set_vlan_mode(struct netdev_private *np) | ||
1741 | { | ||
1742 | u32 ret = VlanMode; | ||
1743 | u16 vid; | ||
1744 | void __iomem *filter_addr = np->base + HashTable + 8; | ||
1745 | int vlan_count = 0; | ||
1746 | |||
1747 | for_each_set_bit(vid, np->active_vlans, VLAN_N_VID) { | ||
1748 | if (vlan_count == 32) | ||
1749 | break; | ||
1750 | writew(vid, filter_addr); | ||
1751 | filter_addr += 16; | ||
1752 | vlan_count++; | ||
1753 | } | ||
1754 | if (vlan_count == 32) { | ||
1755 | ret |= PerfectFilterVlan; | ||
1756 | while (vlan_count < 32) { | ||
1757 | writew(0, filter_addr); | ||
1758 | filter_addr += 16; | ||
1759 | vlan_count++; | ||
1760 | } | ||
1761 | } | ||
1762 | return ret; | ||
1763 | } | ||
1764 | #endif /* VLAN_SUPPORT */ | ||
1755 | 1765 | ||
1756 | static void set_rx_mode(struct net_device *dev) | 1766 | static void set_rx_mode(struct net_device *dev) |
1757 | { | 1767 | { |
@@ -1760,30 +1770,9 @@ static void set_rx_mode(struct net_device *dev) | |||
1760 | u32 rx_mode = MinVLANPrio; | 1770 | u32 rx_mode = MinVLANPrio; |
1761 | struct netdev_hw_addr *ha; | 1771 | struct netdev_hw_addr *ha; |
1762 | int i; | 1772 | int i; |
1763 | #ifdef VLAN_SUPPORT | ||
1764 | 1773 | ||
1765 | rx_mode |= VlanMode; | 1774 | #ifdef VLAN_SUPPORT |
1766 | if (np->vlgrp) { | 1775 | rx_mode |= set_vlan_mode(np); |
1767 | int vlan_count = 0; | ||
1768 | void __iomem *filter_addr = ioaddr + HashTable + 8; | ||
1769 | for (i = 0; i < VLAN_VID_MASK; i++) { | ||
1770 | if (vlan_group_get_device(np->vlgrp, i)) { | ||
1771 | if (vlan_count >= 32) | ||
1772 | break; | ||
1773 | writew(i, filter_addr); | ||
1774 | filter_addr += 16; | ||
1775 | vlan_count++; | ||
1776 | } | ||
1777 | } | ||
1778 | if (i == VLAN_VID_MASK) { | ||
1779 | rx_mode |= PerfectFilterVlan; | ||
1780 | while (vlan_count < 32) { | ||
1781 | writew(0, filter_addr); | ||
1782 | filter_addr += 16; | ||
1783 | vlan_count++; | ||
1784 | } | ||
1785 | } | ||
1786 | } | ||
1787 | #endif /* VLAN_SUPPORT */ | 1776 | #endif /* VLAN_SUPPORT */ |
1788 | 1777 | ||
1789 | if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ | 1778 | if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ |