NetBSD Problem Report #38871

From apb@cequrux.com  Thu Jun  5 15:05:52 2008
Return-Path: <apb@cequrux.com>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 300B063BA89
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  5 Jun 2008 15:05:52 +0000 (UTC)
Message-Id: <20080605150529.00FE9E93312@apb-laptoy.apb.alt.za>
Date: Thu,  5 Jun 2008 15:05:28 +0000 (UTC)
From: apb@cequrux.com
Reply-To: apb@cequrux.com
To: gnats-bugs@gnats.NetBSD.org
Subject: vlans don't work on bge interface
X-Send-Pr-Version: 3.95

>Number:         38871
>Category:       kern
>Synopsis:       vlans don't work on bge interface
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 05 15:10:00 +0000 2008
>Closed-Date:    Mon Nov 26 14:38:25 +0000 2018
>Last-Modified:  Mon Nov 26 14:38:25 +0000 2018
>Originator:     Alan Barrett
>Release:        NetBSD 4.99.63
>Organization:
Not much
>Environment:

>Description:
	802.1q vlans do not work properly on bge inetrfaces on NetBSD/i386

>How-To-Repeat:
	Configure multiple vlans on a suitable ethernet switch.
	Have some of the switch ports configured to use 802.1q tags.

        Connect the "bge0" interface on a NetBSD/i386 host to a
        switch port that is configured as a trunk containing multiple
        vlans with 802.1q tags.

        Cause non-NetBSD hosts to send broadcast packets inside the
        vlans.

	Run "tcpdump -i bge0 -lenvv" on the NetBSD host.  Observe that
	the packets that should have vlan tags do not have vlan tags.

	Run "tcpdump -i bge0 -lenvv vlan" on the NetBSD host.  Observe that
	no packets pass the filter.

	Configure a vlan interface on the NetBSD host, via "ifconfig vlan42
	create; ifconfig vlan42 vlan 42 vlanif bge0".  Run "tcpdump -i vlan42
	-lenvv".  Observe that no packets apear.

>Fix:
	Unknown.

        One theory is that the hardware is removing the VLAN tag headers
        before the OS can see them.  It is possible that the hardware
        can be configured not to do this.

>Release-Note:

>Audit-Trail:
From: Michael van Elst <mlelstv@serpens.de>
To: gnats-bugs@netbsd.org, apb@cequrux.com
Cc: 
Subject: Re: kern/38871: vlans don't work on bge interface
Date: Tue, 17 Jun 2008 09:26:15 +0200

 Hi Alan,

 can you try this patch?

 Index: if_bge.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/pci/if_bge.c,v
 retrieving revision 1.148
 diff -u -r1.148 if_bge.c
 --- if_bge.c	17 Jun 2008 06:08:46 -0000	1.148
 +++ if_bge.c	17 Jun 2008 07:21:28 -0000
 @@ -3985,6 +3985,9 @@
  		BGE_CLRBIT(sc, BGE_RX_MODE, BGE_RXMODE_RX_PROMISC);
  	}

 +	/* Disable VLAN tag stripping */
 +	BGE_CLRBIT(sc, BGE_RX_MODE, BGE_RXMODE_RX_KEEP_VLAN_DIAG);
 +
  	/* Program multicast filter. */
  	bge_setmulti(sc);



 -- 
                                 Michael van Elst
 Internet: mlelstv@serpens.de
                                 "A potential Snark may lurk in every tree."

State-Changed-From-To: open->feedback
State-Changed-By: riz@NetBSD.org
State-Changed-When: Thu, 17 Jun 2010 00:34:24 +0000
State-Changed-Why:
Can you try the patch provided and/or a newer kernel?  Does the problem
persist?


From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-i386/38871 (vlans don't work on bge interface)
Date: Thu, 17 Jun 2010 13:33:34 +0200

 On Thu, 17 Jun 2010, riz@NetBSD.org wrote:
 > Can you try the patch provided and/or a newer kernel?  Does the problem
 > persist?

 Sorry, I no longer have an environment in which I can test that.

 --apb (Alan Barrett)

Responsible-Changed-From-To: port-i386-maintainer->kern-bug-people
Responsible-Changed-By: dholland@NetBSD.org
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
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?


From: Mihai Chelaru <mihai.chelaru@NGNetworks.ro>
To: gnats-bugs@NetBSD.org
Cc: dholland@NetBSD.org, kern-bug-people@netbsd.org, 
 netbsd-bugs@netbsd.org, gnats-admin@netbsd.org, apb@cequrux.com
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 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
 > 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
 > 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
 ...

From: masanobu@iij.ad.jp
To: gnats-bugs@NetBSD.org, mihai.chelaru@NGNetworks.ro
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
        apb@cequrux.com
Subject: Re: kern/38871 (vlans don't work on bge interface)
Date: Tue, 29 Jun 2010 19:58:49 +0900 (JST)

  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>
 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>
 > To: gnats-bugs@NetBSD.org
 > Cc: dholland@NetBSD.org, kern-bug-people@netbsd.org, 
 >  netbsd-bugs@netbsd.org, gnats-admin@netbsd.org, apb@cequrux.com
 > 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 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
 >  > 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
 >  > 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
 >  ...

From: Christoph Egger <cegger@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/38871 CVS commit: src/sys/dev/pci
Date: Tue, 20 Jul 2010 09:17:25 +0000

 Module Name:	src
 Committed By:	cegger
 Date:		Tue Jul 20 09:17:24 UTC 2010

 Modified Files:
 	src/sys/dev/pci: if_age.c if_ale.c

 Log Message:
 PR kern/38871: Fix VLAN


 To generate a diff of this commit:
 cvs rdiff -u -r1.38 -r1.39 src/sys/dev/pci/if_age.c
 cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/if_ale.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Stephen Borrill" <sborrill@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/38871 CVS commit: src/sys
Date: Fri, 8 Apr 2011 13:56:52 +0000

 Module Name:	src
 Committed By:	sborrill
 Date:		Fri Apr  8 13:56:51 UTC 2011

 Modified Files:
 	src/sys/dev/pci: if_alc.c if_bge.c
 	src/sys/net: if_vlan.c

 Log Message:
 PR kern/38871

 Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
 card drivers.


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/if_alc.c
 cvs rdiff -u -r1.190 -r1.191 src/sys/dev/pci/if_bge.c
 cvs rdiff -u -r1.66 -r1.67 src/sys/net/if_vlan.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Jeff Rizzo <riz@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/38871
Date: Tue, 03 Apr 2012 08:50:00 -0700

 Just a note that bge(4) still does not work properly in a VLAN setup.  
 What's not seen in this PR is that sborrill@ backed out his changes of a 
 year ago shortly after he made them, as they do not actually fix the 
 problem.


 Interestingly enough, while vlans in general do not work properly, as I 
 was testing various combinations of patches and stuff, there was a 
 period of several days during which vlans *were* working on a stock 
 6.0_BETA kernel.  This persisted until I had to power-cycle the machine; 
 now they don't work again. (They don't work with the backed-out patches, 
 either - I've tried)  This leads me to believe there is some setup I 
 accidentally did that's missing from our driver, and might be enough to 
 get vlan support going.

 If anyone has any ideas, I'd love to try them.

State-Changed-From-To: open->closed
State-Changed-By: bouyer@NetBSD.org
State-Changed-When: Mon, 26 Nov 2018 14:38:25 +0000
State-Changed-Why:
On a
bge0 at pci4 dev 0 function 0: Broadcom BCM5720 Gigabit Ethernet
bge0: APE firmware NCSI 1.4.22.0
bge0: interrupting at msi1 vec 0
bge0: HW config 002b1194, 00006014, 0002aa38, 00000000 0000000c
bge0: ASIC BCM5720 A0 (0x5720000), Ethernet address d0:94:66:8b:9c:18
bge0: setting short Tx thresholds
brgphy0 at bge0 phy 1: BCM5720C 1000BASE-T media interface, rev. 0

I can do HW vlan tagging at full gigabit speed. Assume fixed.


>Unformatted:
 System: NetBSD 4.99.63 i386
 Architecture: i386
 Machine: i386

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.