From: Vladimir Oltean <olteanv@gmail.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: davem@davemloft.net, vivien.didelot@gmail.com, andrew@lunn.ch,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next 4/4] net: dsa: set configure_vlan_while_not_filtering to true by default
Date: Wed, 9 Sep 2020 19:31:05 +0300 [thread overview]
Message-ID: <20200909163105.nynkw5jvwqapzx2z@skbuf> (raw)
In-Reply-To: <f0217ae5-7897-17e2-a807-fc0ba0246c74@gmail.com>
On Tue, Sep 08, 2020 at 05:02:06PM -0700, Florian Fainelli wrote:
> Found the problem, we do not allow the CPU port to be configured as
> untagged, and when we toggle vlan_filtering we actually incorrectly "move"
> the PVID from 1 to 0,
pvid 1 must be coming from the default_pvid of the bridge, I assume.
Where is pvid 0 (aka dev->ports[port].pvid) coming from? Is it simply
the cached value from B53_VLAN_PORT_DEF_TAG, from a previous
b53_vlan_filtering() call? Strange.
> which is incorrect, but since the CPU is also untagged in VID 0 this
> is why it "works" or rather two mistakes canceling it each other.
How does the CPU end up untagged in VLAN 0?
> I still need to confirm this, but the bridge in VLAN filtering mode seems to
> support receiving frames with the default_pvid as tagged, and it will untag
> it for the bridge master device transparently.
So it seems.
> The reason for not allowing the CPU port to be untagged
> (ca8931948344c485569b04821d1f6bcebccd376b) was because the CPU port could be
> added as untagged in several VLANs, e.g.: when port0-3 are PVID 1 untagged,
> and port 4 is PVID 2 untagged. Back then there was no support for Broadcom
> tags, so the only way to differentiate traffic properly was to also add a
> pair of tagged VIDs to the DSA master.
> I am still trying to remember whether there were other concerns that
> prompted me to make that change and would appreciate some thoughts on that.
I think it makes some sense to always configure the VLANs on the CPU
port as tagged either way. I did the same in Felix and it's ok. But that
was due to a hardware limitation. On sja1105 I'm keeping the same flags
as on the user port, and that is ok too.
> Tangentially, maybe we should finally add support for programming the CPU
> port's VLAN membership independently from the other ports.
How?
> The following appears to work nicely now and allows us to get rid of the
> b53_vlan_filtering() logic, which would no longer work now because it
> assumed that toggling vlan_filtering implied that there would be no VLAN
> configuration when filtering was off.
>
> diff --git a/drivers/net/dsa/b53/b53_common.c
> b/drivers/net/dsa/b53/b53_common.c
> index 26fcff85d881..fac033730f4a 100644
> --- a/drivers/net/dsa/b53/b53_common.c
> +++ b/drivers/net/dsa/b53/b53_common.c
> @@ -1322,23 +1322,6 @@ EXPORT_SYMBOL(b53_phylink_mac_link_up);
> int b53_vlan_filtering(struct dsa_switch *ds, int port, bool
> vlan_filtering)
> {
> struct b53_device *dev = ds->priv;
> - u16 pvid, new_pvid;
> -
> - b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), &pvid);
> - if (!vlan_filtering) {
> - /* Filtering is currently enabled, use the default PVID
> since
> - * the bridge does not expect tagging anymore
> - */
> - dev->ports[port].pvid = pvid;
> - new_pvid = b53_default_pvid(dev);
> - } else {
> - /* Filtering is currently disabled, restore the previous
> PVID */
> - new_pvid = dev->ports[port].pvid;
> - }
> -
> - if (pvid != new_pvid)
> - b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port),
> - new_pvid);
Yes, much simpler.
>
> b53_enable_vlan(dev, dev->vlan_enabled, vlan_filtering);
>
> @@ -1389,7 +1372,7 @@ void b53_vlan_add(struct dsa_switch *ds, int port,
> untagged = true;
>
> vl->members |= BIT(port);
> - if (untagged && !dsa_is_cpu_port(ds, port))
> + if (untagged)
> vl->untag |= BIT(port);
> else
> vl->untag &= ~BIT(port);
> @@ -1427,7 +1410,7 @@ int b53_vlan_del(struct dsa_switch *ds, int port,
> if (pvid == vid)
> pvid = b53_default_pvid(dev);
>
> - if (untagged && !dsa_is_cpu_port(ds, port))
> + if (untagged)
Ok, so you're removing this workaround now. A welcome simplification.
> vl->untag &= ~(BIT(port));
>
> b53_set_vlan_entry(dev, vid, vl);
> @@ -2563,6 +2546,8 @@ struct b53_device *b53_switch_alloc(struct device
> *base,
> dev->priv = priv;
> dev->ops = ops;
> ds->ops = &b53_switch_ops;
> + ds->configure_vlan_while_not_filtering = true;
> + dev->vlan_enabled = ds->configure_vlan_while_not_filtering;
> mutex_init(&dev->reg_mutex);
> mutex_init(&dev->stats_mutex);
>
>
> --
> Florian
Looks good!
I'm going to hold off with my configure_vlan_while_not_filtering patch.
You can send this one before me.
Thanks,
-Vladimir
next prev parent reply other threads:[~2020-09-09 16:31 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-07 18:29 [PATCH net-next 0/4] Some VLAN handling cleanup in DSA Vladimir Oltean
2020-09-07 18:29 ` [PATCH net-next 1/4] net: dsa: tag_8021q: include missing refcount.h Vladimir Oltean
2020-09-08 4:07 ` Florian Fainelli
2020-09-07 18:29 ` [PATCH net-next 2/4] net: dsa: tag_8021q: add a context structure Vladimir Oltean
2020-09-07 18:29 ` [PATCH net-next 3/4] Revert "net: dsa: Add more convenient functions for installing port VLANs" Vladimir Oltean
2020-09-07 18:29 ` [PATCH net-next 4/4] net: dsa: set configure_vlan_while_not_filtering to true by default Vladimir Oltean
2020-09-08 4:07 ` Florian Fainelli
2020-09-08 10:33 ` Vladimir Oltean
2020-09-08 22:28 ` Florian Fainelli
2020-09-09 0:02 ` Florian Fainelli
2020-09-09 16:31 ` Vladimir Oltean [this message]
2020-09-09 17:22 ` Florian Fainelli
2020-09-09 17:53 ` Vladimir Oltean
2020-09-09 18:34 ` Florian Fainelli
2020-09-10 21:58 ` Florian Fainelli
2020-09-11 0:03 ` Vladimir Oltean
2020-09-11 3:09 ` Florian Fainelli
2020-09-11 15:43 ` Vladimir Oltean
2020-09-11 18:23 ` Florian Fainelli
2020-09-11 18:35 ` Vladimir Oltean
2020-09-11 19:39 ` Florian Fainelli
2020-09-11 19:48 ` Florian Fainelli
2020-09-11 22:30 ` Vladimir Oltean
2020-09-08 10:14 ` Kurt Kanzenbach
2020-09-08 10:29 ` Vladimir Oltean
2020-10-02 8:06 ` Kurt Kanzenbach
2020-10-02 8:15 ` Vladimir Oltean
2020-10-03 7:52 ` Vladimir Oltean
2020-10-03 9:45 ` Kurt Kanzenbach
2020-10-04 10:56 ` Vladimir Oltean
2020-10-05 12:34 ` Vladimir Oltean
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=20200909163105.nynkw5jvwqapzx2z@skbuf \
--to=olteanv@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
--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