NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/38871 (vlans don't work on bge interface)



 Hi, all.

 This patch will fix the problem. Many drivers check ec_capenable
correctly (though if_vlan doesn't set it...), but some don't.


 if_vlan.c:
        Set ETHERCAP_VLAN_HWTAGGING into 
ec_capenable........................................

 if_bge.c:
        Set BGE_RX_MODE correctly.

 if_age.c:
        Check ec_capenable instead of ec_capabilities.

 if_ale.c:
        Check ec_capenable instead of if_capabilities. (Double fault)

 rtl8169.c:
        Check ec_capenable instead of if_capenable.
        


================
Index: net/if_vlan.c
===================================================================
RCS file: /cvsroot/src/sys/net/if_vlan.c,v
retrieving revision 1.66
diff -u -r1.66 if_vlan.c
--- net/if_vlan.c       5 Apr 2010 07:22:24 -0000       1.66
+++ net/if_vlan.c       29 Jun 2010 10:48:05 -0000
@@ -317,6 +317,7 @@
                 * offload.
                 */
                if (ec->ec_capabilities & ETHERCAP_VLAN_HWTAGGING)
+                       ec->ec_capenable |= ETHERCAP_VLAN_HWTAGGING;
                        ifp->if_capabilities = p->if_capabilities &
                            (IFCAP_TSOv4 | IFCAP_TSOv6 |
                             IFCAP_CSUM_IPv4_Tx|IFCAP_CSUM_IPv4_Rx|
Index: dev/pci/if_age.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_age.c,v
retrieving revision 1.38
diff -u -r1.38 if_age.c
--- dev/pci/if_age.c    5 Apr 2010 07:20:24 -0000       1.38
+++ dev/pci/if_age.c    29 Jun 2010 10:48:06 -0000
@@ -2235,7 +2235,7 @@
 
        reg = CSR_READ_4(sc, AGE_MAC_CFG);
        reg &= ~MAC_CFG_VLAN_TAG_STRIP;
-       if (sc->sc_ec.ec_capabilities & ETHERCAP_VLAN_HWTAGGING)
+       if (sc->sc_ec.ec_capenable & ETHERCAP_VLAN_HWTAGGING)
                reg |= MAC_CFG_VLAN_TAG_STRIP;
        CSR_WRITE_4(sc, AGE_MAC_CFG, reg);
 }
Index: dev/pci/if_ale.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_ale.c,v
retrieving revision 1.11
diff -u -r1.11 if_ale.c
--- dev/pci/if_ale.c    5 Apr 2010 07:20:25 -0000       1.11
+++ dev/pci/if_ale.c    29 Jun 2010 10:48:06 -0000
@@ -1973,12 +1973,12 @@
 static void
 ale_rxvlan(struct ale_softc *sc)
 {
-       struct ifnet *ifp = &sc->sc_ec.ec_if;
+       struct ethercom *ec = &sc->sc_ec;
        uint32_t reg;
 
        reg = CSR_READ_4(sc, ALE_MAC_CFG);
        reg &= ~MAC_CFG_VLAN_TAG_STRIP;
-       if (ifp->if_capabilities & ETHERCAP_VLAN_HWTAGGING)
+       if (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING)
                reg |= MAC_CFG_VLAN_TAG_STRIP;
        CSR_WRITE_4(sc, ALE_MAC_CFG, reg);
 }
Index: dev/pci/if_bge.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_bge.c,v
retrieving revision 1.185
diff -u -r1.185 if_bge.c
--- dev/pci/if_bge.c    3 Jun 2010 00:05:36 -0000       1.185
+++ dev/pci/if_bge.c    29 Jun 2010 10:48:07 -0000
@@ -221,6 +221,7 @@
 static uint8_t bge_eeprom_getbyte(struct bge_softc *, int, uint8_t *);
 static int bge_read_eeprom(struct bge_softc *, void *, int, int);
 static void bge_setmulti(struct bge_softc *);
+static void bge_setvlan(struct bge_softc *);
 
 static void bge_handle_events(struct bge_softc *);
 static int bge_alloc_jumbo_mem(struct bge_softc *);
@@ -1648,6 +1649,18 @@
 }
 
 static void
+bge_setvlan(struct bge_softc *sc)
+{
+       struct ethercom *ac = &sc->ethercom;
+
+       /* Enable or disable VLAN tag stripping as needed. */
+       if (ac->ec_capenable & ETHERCAP_VLAN_HWTAGGING)
+               BGE_CLRBIT(sc, BGE_RX_MODE, BGE_RXMODE_RX_KEEP_VLAN_DIAG);
+       else
+               BGE_SETBIT(sc, BGE_RX_MODE, BGE_RXMODE_RX_KEEP_VLAN_DIAG);
+}
+
+static void
 bge_sig_pre_reset(struct bge_softc *sc, int type)
 {
        /*
@@ -4315,6 +4328,9 @@
        /* Program multicast filter. */
        bge_setmulti(sc);
 
+       /* Program VLAN tag stripping. */
+       bge_setvlan(sc);
+
        /* Init RX ring. */
        bge_init_rx_ring_std(sc);
 
Index: dev/ic/rtl8169.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/rtl8169.c,v
retrieving revision 1.131
diff -u -r1.131 rtl8169.c
--- dev/ic/rtl8169.c    9 Apr 2010 10:40:59 -0000       1.131
+++ dev/ic/rtl8169.c    29 Jun 2010 10:48:07 -0000
@@ -1739,7 +1739,7 @@
        if ((sc->sc_quirk & RTKQ_8169NONS) != 0)
                cfg |= (0x1 << 14);
 
-       if ((ifp->if_capenable & ETHERCAP_VLAN_HWTAGGING) != 0)
+       if ((sc->ethercom.ec_capenable & ETHERCAP_VLAN_HWTAGGING) != 0)
                cfg |= RE_CPLUSCMD_VLANSTRIP;
        if ((ifp->if_capenable & (IFCAP_CSUM_IPv4_Rx |
             IFCAP_CSUM_TCPv4_Rx | IFCAP_CSUM_UDPv4_Rx)) != 0)
================




From: Mihai Chelaru <mihai.chelaru%NGNetworks.ro@localhost>
Subject: Re: kern/38871 (vlans don't work on bge interface)
Date: Mon, 21 Jun 2010 10:55:02 +0000 (UTC)

> The following reply was made to PR kern/38871; it has been noted by GNATS.
> 
> From: Mihai Chelaru <mihai.chelaru%NGNetworks.ro@localhost>
> To: gnats-bugs%NetBSD.org@localhost
> Cc: dholland%NetBSD.org@localhost, kern-bug-people%netbsd.org@localhost, 
>  netbsd-bugs%netbsd.org@localhost, gnats-admin%netbsd.org@localhost, 
> apb%cequrux.com@localhost
> Subject: Re: kern/38871 (vlans don't work on bge interface)
> Date: Mon, 21 Jun 2010 13:50:48 +0300
> 
>  On 06/21/10 06:00, dholland%NetBSD.org@localhost wrote:
>  > Synopsis: vlans don't work on bge interface
>  > 
>  > Responsible-Changed-From-To: port-i386-maintainer->kern-bug-people
>  > Responsible-Changed-By: dholland%NetBSD.org@localhost
>  > Responsible-Changed-When: Mon, 21 Jun 2010 03:00:44 +0000
>  > Responsible-Changed-Why:
>  > bring this to wider attention (doesn't appear to be i386-specific)
>  > 
>  > 
>  > State-Changed-From-To: feedback->open
>  > State-Changed-By: dholland%NetBSD.org@localhost
>  > State-Changed-When: Mon, 21 Jun 2010 03:00:44 +0000
>  > State-Changed-Why:
>  > submitter can't test.
>  > 
>  > Does anyone out there have a bge(4) and vlan environment?
>  > 
>  > 
>  > 
>  > 
>  
>  
>  # uname -r
>  5.99.29
>  # tcpdump -plnvvvex -i vlan0 port not ssh
>  tcpdump: listening on vlan0, link-type EN10MB (Ethernet), capture size
>  96 bytes
>  13:41:11.863747 00:22:15:80:ac:e8 > ff:ff:ff:ff:ff:ff, ethertype ARP
>  (0x0806), length 64: arp who-has 5.5.5.1 tell 5.5.5.2
>  ...



Home | Main Index | Thread Index | Old Index