Skip to content

Commit d4f73c8

Browse files
Francois RomieuJeff Garzik
authored andcommitted
via-velocity: fix vlan receipt
- vlans were using a single CAM register (see mac_set_vlan_cam) - setting the address filtering registers for vlans is not needed when there is no vlan The non-tagged interface is filtered out as soon as a tagged (!= 0) interface is created. Its traffic appears again when an zero-tagged interface is created. Tested on Via Epia SN (VT6130 chipset) with several vlans whose tag was above or beyond 255. Signed-off-by: Séguier Régis <rseguier@e-teleport.net> Acked-by: Francois Romieu <romieu@fr.zoreil.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
1 parent 9f3f791 commit d4f73c8

1 file changed

Lines changed: 28 additions & 18 deletions

File tree

‎drivers/net/via-velocity.c‎

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,6 @@ static void __devinit velocity_get_options(struct velocity_opt *opts, int index,
605605
static void velocity_init_cam_filter(struct velocity_info *vptr)
606606
{
607607
struct mac_regs __iomem * regs = vptr->mac_regs;
608-
unsigned short vid;
609608

610609
/* Turn on MCFG_PQEN, turn off MCFG_RTGOPT */
611610
WORD_REG_BITS_SET(MCFG_PQEN, MCFG_RTGOPT, &regs->MCFG);
@@ -617,29 +616,33 @@ static void velocity_init_cam_filter(struct velocity_info *vptr)
617616
mac_set_vlan_cam_mask(regs, vptr->vCAMmask);
618617
mac_set_cam_mask(regs, vptr->mCAMmask);
619618

620-
/* Enable first VCAM */
619+
/* Enable VCAMs */
621620
if (vptr->vlgrp) {
622-
for (vid = 0; vid < VLAN_VID_MASK; vid++) {
623-
if (vlan_group_get_device(vptr->vlgrp, vid)) {
624-
/* If Tagging option is enabled and
625-
VLAN ID is not zero, then
626-
turn on MCFG_RTGOPT also */
627-
if (vid != 0)
628-
WORD_REG_BITS_ON(MCFG_RTGOPT, &regs->MCFG);
621+
unsigned int vid, i = 0;
622+
623+
if (!vlan_group_get_device(vptr->vlgrp, 0))
624+
WORD_REG_BITS_ON(MCFG_RTGOPT, &regs->MCFG);
629625

630-
mac_set_vlan_cam(regs, 0, (u8 *) &vid);
626+
for (vid = 1; (vid < VLAN_VID_MASK); vid++) {
627+
if (vlan_group_get_device(vptr->vlgrp, vid)) {
628+
mac_set_vlan_cam(regs, i, (u8 *) &vid);
629+
vptr->vCAMmask[i / 8] |= 0x1 << (i % 8);
630+
if (++i >= VCAM_SIZE)
631+
break;
631632
}
632633
}
633-
vptr->vCAMmask[0] |= 1;
634634
mac_set_vlan_cam_mask(regs, vptr->vCAMmask);
635-
} else {
636-
u16 temp = 0;
637-
mac_set_vlan_cam(regs, 0, (u8 *) &temp);
638-
temp = 1;
639-
mac_set_vlan_cam_mask(regs, (u8 *) &temp);
640635
}
641636
}
642637

638+
static void velocity_vlan_rx_register(struct net_device *dev,
639+
struct vlan_group *grp)
640+
{
641+
struct velocity_info *vptr = netdev_priv(dev);
642+
643+
vptr->vlgrp = grp;
644+
}
645+
643646
static void velocity_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
644647
{
645648
struct velocity_info *vptr = netdev_priv(dev);
@@ -959,11 +962,13 @@ static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_devi
959962

960963
dev->vlan_rx_add_vid = velocity_vlan_rx_add_vid;
961964
dev->vlan_rx_kill_vid = velocity_vlan_rx_kill_vid;
965+
dev->vlan_rx_register = velocity_vlan_rx_register;
962966

963967
#ifdef VELOCITY_ZERO_COPY_SUPPORT
964968
dev->features |= NETIF_F_SG;
965969
#endif
966-
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_FILTER;
970+
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_FILTER |
971+
NETIF_F_HW_VLAN_RX;
967972

968973
if (vptr->flags & VELOCITY_FLAGS_TX_CSUM)
969974
dev->features |= NETIF_F_IP_CSUM;
@@ -1597,8 +1602,13 @@ static int velocity_receive_frame(struct velocity_info *vptr, int idx)
15971602
skb_put(skb, pkt_len - 4);
15981603
skb->protocol = eth_type_trans(skb, vptr->dev);
15991604

1605+
if (vptr->vlgrp && (rd->rdesc0.RSR & RSR_DETAG)) {
1606+
vlan_hwaccel_rx(skb, vptr->vlgrp,
1607+
swab16(le16_to_cpu(rd->rdesc1.PQTAG)));
1608+
} else
1609+
netif_rx(skb);
1610+
16001611
stats->rx_bytes += pkt_len;
1601-
netif_rx(skb);
16021612

16031613
return 0;
16041614
}

0 commit comments

Comments
 (0)