Netdev List
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>,
	DENG Qingfang <dqfext@gmail.com>,
	Mauri Sandberg <sandberg@mailfence.com>
Subject: Re: [net-next PATCH 4/5 v4] net: dsa: rtl8366: VLAN 0 as disable tagging
Date: Tue, 7 Jul 2020 10:20:32 +0300	[thread overview]
Message-ID: <20200707072032.tfwfip5lvck4cg6z@skbuf> (raw)
In-Reply-To: <9a87a847-05e9-0de8-bdf1-d56eab15f2a9@gmail.com>

Hi Linus,

On Mon, Jul 06, 2020 at 02:23:11PM -0700, Florian Fainelli wrote:
> 
> 
> On 7/6/2020 1:52 PM, Linus Walleij wrote:
> > The code in net/8021q/vlan.c, vlan_device_event() sets
> > VLAN 0 for a VLAN-capable ethernet device when it
> > comes up.
> > 
> > Since the RTL8366 DSA switches must have a VLAN and
> > PVID set up for any packets to come through we have
> > already set up default VLAN for each port as part of
> > bringing the switch online.
> > 
> > Make sure that setting VLAN 0 has the same effect
> > and does not try to actually tell the hardware to use
> > VLAN 0 on the port because that will not work.
> > 
> > Cc: DENG Qingfang <dqfext@gmail.com>
> > Cc: Mauri Sandberg <sandberg@mailfence.com>
> > Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> > ---
> > ChangeLog v3->v4:
> > - Resend with the rest
> > ChangeLog v2->v3:
> > - Collected Andrew's review tag.
> > ChangeLog v1->v2:
> > - Rebased on v5.8-rc1 and other changes.
> > ---
> >  drivers/net/dsa/rtl8366.c | 65 +++++++++++++++++++++++++++++++--------
> >  1 file changed, 52 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c
> > index b907c0ed9697..a000d458d121 100644
> > --- a/drivers/net/dsa/rtl8366.c
> > +++ b/drivers/net/dsa/rtl8366.c
> > @@ -355,15 +355,25 @@ int rtl8366_vlan_prepare(struct dsa_switch *ds, int port,
> >  			 const struct switchdev_obj_port_vlan *vlan)
> >  {
> >  	struct realtek_smi *smi = ds->priv;
> > +	u16 vid_begin = vlan->vid_begin;
> > +	u16 vid_end = vlan->vid_end;
> >  	u16 vid;
> >  	int ret;
> >  
> > -	for (vid = vlan->vid_begin; vid < vlan->vid_end; vid++)
> > +	if (vid_begin == 0) {
> > +		dev_info(smi->dev, "prepare VLAN 0 - ignored\n");
> > +		if (vid_end == 0)
> > +			return 0;
> > +		/* Skip VLAN 0 and start with VLAN 1 */
> > +		vid_begin = 1;
> > +	}
> 
> Humm I still don't understand why you are doing that. Upon DSA network
> device creation, VID 0 will be pushed because we advertise support for
> NETIF_F_HW_VLAN_CTAG_FILTER, so if nothing else, we will be getting the
> "prepare VLAN 0 -ignored" message which is not relevant nor a good idea
> to print.
> 
> You can force this VLAN to be programmed as untagged, in fact you should
> be doing that per the 802.1Q specification.
> 
> There are no other cases other than the initial network device creation
> that will lead to programming this VLAN ID. The bridge will always
> specify a VID range within 1 through 4094 and the VLAN RX filter offload
> will not add or remove VID 0 other than at creation/destruction.
> 
> As mentioned before, if you need VLAN awareness into the switch from the
> get go, you need to set configure_vlan_while_not_filtering and that
> would ensure that all ports belong to a VID at startup. Later on, when
> the bridge gets set-up, it will be requesting the ports added as bridge
> ports to be programmed into VID 1 as PVID untagged. And this should
> still be fine.
> -- 
> Florian

To add to what Florian said, you should basically try to enable and test
"ds->configure_vlan_while_not_filtering = true" regardless, while you're
at it. The whole reason why it's there is because we didn't want to
introduce breakage when changing behavior of the DSA core. But ideally,
all drivers would use this setting, and then it could get deleted and so
would the old behavior of DSA.

Thanks,
-Vladimir

  reply	other threads:[~2020-07-07  7:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06 20:52 [net-next PATCH 0/5 v4] RTL8366RB DSA tagging and fixes Linus Walleij
2020-07-06 20:52 ` [net-next PATCH 1/5 v4] net: dsa: tag_rtl4_a: Implement Realtek 4 byte A tag Linus Walleij
2020-07-06 20:52 ` [net-next PATCH 2/5 v4] net: dsa: rtl8366rb: Support the CPU DSA tag Linus Walleij
2020-07-06 20:52 ` [net-next PATCH 3/5 v4] net: dsa: rtl8366: Split out default VLAN config Linus Walleij
2020-07-06 20:52 ` [net-next PATCH 4/5 v4] net: dsa: rtl8366: VLAN 0 as disable tagging Linus Walleij
2020-07-06 21:23   ` Florian Fainelli
2020-07-07  7:20     ` Vladimir Oltean [this message]
2020-07-08 13:34     ` Linus Walleij
2020-07-06 20:52 ` [net-next PATCH 5/5 v4] net: dsa: rtl8366: Use top VLANs for default Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200707072032.tfwfip5lvck4cg6z@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dqfext@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=netdev@vger.kernel.org \
    --cc=sandberg@mailfence.com \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox