Commit 5da96be5 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

starfire: do vlan cleanup

- unify vlan and nonvlan rx path
- kill np->vlgrp and netdev_vlan_rx_register
Signed-off-by: default avatarJiri Pirko <jpirko@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 73b54688
...@@ -561,7 +561,7 @@ struct netdev_private { ...@@ -561,7 +561,7 @@ struct netdev_private {
struct net_device *dev; struct net_device *dev;
struct pci_dev *pci_dev; struct pci_dev *pci_dev;
#ifdef VLAN_SUPPORT #ifdef VLAN_SUPPORT
struct vlan_group *vlgrp; unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
#endif #endif
void *queue_mem; void *queue_mem;
dma_addr_t queue_mem_dma; dma_addr_t queue_mem_dma;
...@@ -607,18 +607,6 @@ static const struct ethtool_ops ethtool_ops; ...@@ -607,18 +607,6 @@ static const struct ethtool_ops ethtool_ops;
#ifdef VLAN_SUPPORT #ifdef VLAN_SUPPORT
static void netdev_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
{
struct netdev_private *np = netdev_priv(dev);
spin_lock(&np->lock);
if (debug > 2)
printk("%s: Setting vlgrp to %p\n", dev->name, grp);
np->vlgrp = grp;
set_rx_mode(dev);
spin_unlock(&np->lock);
}
static void netdev_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) static void netdev_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
{ {
struct netdev_private *np = netdev_priv(dev); 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,6 +614,7 @@ static void netdev_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
spin_lock(&np->lock); spin_lock(&np->lock);
if (debug > 1) if (debug > 1)
printk("%s: Adding vlanid %d to vlan filter\n", dev->name, vid); printk("%s: Adding vlanid %d to vlan filter\n", dev->name, vid);
set_bit(vid, np->active_vlans);
set_rx_mode(dev); set_rx_mode(dev);
spin_unlock(&np->lock); spin_unlock(&np->lock);
} }
...@@ -637,7 +626,7 @@ static void netdev_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) ...@@ -637,7 +626,7 @@ static void netdev_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
spin_lock(&np->lock); spin_lock(&np->lock);
if (debug > 1) if (debug > 1)
printk("%s: removing vlanid %d from vlan filter\n", dev->name, vid); printk("%s: removing vlanid %d from vlan filter\n", dev->name, vid);
vlan_group_set_device(np->vlgrp, vid, NULL); clear_bit(vid, np->active_vlans);
set_rx_mode(dev); set_rx_mode(dev);
spin_unlock(&np->lock); spin_unlock(&np->lock);
} }
...@@ -656,7 +645,6 @@ static const struct net_device_ops netdev_ops = { ...@@ -656,7 +645,6 @@ static const struct net_device_ops netdev_ops = {
.ndo_set_mac_address = eth_mac_addr, .ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
#ifdef VLAN_SUPPORT #ifdef VLAN_SUPPORT
.ndo_vlan_rx_register = netdev_vlan_rx_register,
.ndo_vlan_rx_add_vid = netdev_vlan_rx_add_vid, .ndo_vlan_rx_add_vid = netdev_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = netdev_vlan_rx_kill_vid, .ndo_vlan_rx_kill_vid = netdev_vlan_rx_kill_vid,
#endif #endif
...@@ -1528,19 +1516,15 @@ static int __netdev_rx(struct net_device *dev, int *quota) ...@@ -1528,19 +1516,15 @@ static int __netdev_rx(struct net_device *dev, int *quota)
printk(KERN_DEBUG "%s: checksum_hw, status2 = %#x\n", dev->name, le16_to_cpu(desc->status2)); printk(KERN_DEBUG "%s: checksum_hw, status2 = %#x\n", dev->name, le16_to_cpu(desc->status2));
} }
#ifdef VLAN_SUPPORT #ifdef VLAN_SUPPORT
if (np->vlgrp && le16_to_cpu(desc->status2) & 0x0200) { if (le16_to_cpu(desc->status2) & 0x0200) {
u16 vlid = le16_to_cpu(desc->vlanid); u16 vlid = le16_to_cpu(desc->vlanid);
if (debug > 4) { if (debug > 4) {
printk(KERN_DEBUG " netdev_rx() vlanid = %d\n", printk(KERN_DEBUG " netdev_rx() vlanid = %d\n",
vlid); vlid);
} }
/* __vlan_hwaccel_put_tag(skb, vlid);
* vlan_hwaccel_rx expects a packet with the VLAN tag }
* stripped out.
*/
vlan_hwaccel_rx(skb, np->vlgrp, vlid);
} else
#endif /* VLAN_SUPPORT */ #endif /* VLAN_SUPPORT */
netif_receive_skb(skb); netif_receive_skb(skb);
dev->stats.rx_packets++; dev->stats.rx_packets++;
...@@ -1752,38 +1736,43 @@ static struct net_device_stats *get_stats(struct net_device *dev) ...@@ -1752,38 +1736,43 @@ static struct net_device_stats *get_stats(struct net_device *dev)
return &dev->stats; return &dev->stats;
} }
static void set_rx_mode(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->base;
u32 rx_mode = MinVLANPrio;
struct netdev_hw_addr *ha;
int i;
#ifdef VLAN_SUPPORT #ifdef VLAN_SUPPORT
static u32 set_vlan_mode(struct netdev_private *np)
rx_mode |= VlanMode; {
if (np->vlgrp) { u32 ret = VlanMode;
u16 vid;
void __iomem *filter_addr = np->base + HashTable + 8;
int vlan_count = 0; int vlan_count = 0;
void __iomem *filter_addr = ioaddr + HashTable + 8;
for (i = 0; i < VLAN_VID_MASK; i++) { for_each_set_bit(vid, np->active_vlans, VLAN_N_VID) {
if (vlan_group_get_device(np->vlgrp, i)) { if (vlan_count == 32)
if (vlan_count >= 32)
break; break;
writew(i, filter_addr); writew(vid, filter_addr);
filter_addr += 16; filter_addr += 16;
vlan_count++; vlan_count++;
} }
} if (vlan_count == 32) {
if (i == VLAN_VID_MASK) { ret |= PerfectFilterVlan;
rx_mode |= PerfectFilterVlan;
while (vlan_count < 32) { while (vlan_count < 32) {
writew(0, filter_addr); writew(0, filter_addr);
filter_addr += 16; filter_addr += 16;
vlan_count++; vlan_count++;
} }
} }
} return ret;
}
#endif /* VLAN_SUPPORT */
static void set_rx_mode(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->base;
u32 rx_mode = MinVLANPrio;
struct netdev_hw_addr *ha;
int i;
#ifdef VLAN_SUPPORT
rx_mode |= set_vlan_mode(np);
#endif /* VLAN_SUPPORT */ #endif /* VLAN_SUPPORT */
if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment