Re: [PATCH net-next v6 07/16] net: dsa: vsc73xx: Add vlan filtering

Paweł Dembicki
2024-03-25T20:42:21Z

pt., 8 mar 2024 o 14:09 Vladimir Oltean <olteanv@gmail.com> napisał(a):
>
> On Tue, Mar 05, 2024 at 03:51:11PM -0800, Florian Fainelli wrote:
> > On 3/1/24 14:16, Pawel Dembicki wrote:
> > > This patch implements VLAN filtering for the vsc73xx driver.
> > >
> > > After starting VLAN filtering, the switch is reconfigured from QinQ to
> > > a simple VLAN aware mode. This is required because VSC73XX chips do not
> > > support inner VLAN tag filtering.
> > >
> > > Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
> > > ---
> >
> > [snip]
> >
> > [snip]
> >
> > Have to admit the logic is a bit hard to follow, but that is also because of
> > my lack of understanding of the requirements surrounding the use of
> > tag_8021q.
>
> It's not only that. The code is also a bit hard on the brain for me.
>
> An alternative coding pattern would be to observe that certain hardware
> registers (the egress-untagged VLAN, the PVID) depend on a constellation
> of N input variables (the bridge VLAN filtering state, the tag_8021q
> active state, the bridge VLAN table). So, to make the code easier to
> follow and to ensure correctness, in theory a central function could be
> written, which embeds the same invariant logic of determining what to
> program the registers with, depending on the N inputs. This invariant
> function is called from every place that modifies any of the N inputs.
>
> What Paweł did here was to have slightly different code paths for
> modifying the hardware registers, each code path adjusted slightly on
> the state change transition of individual inputs.
>
> This was a design choice on which I commented very early on, stating
> that it's unusual but that I can go along with it. It is probably very
> ingrained with the choice of the untagged_storage[] and pvid_storage[]
> arrays, the logic of swapping the storage with the hardware at VLAN
> filtering state change, and thus very hard to change at this stage of
> development.

I have to admit that it wasn't an optimal implementation. I focused on
the wrong priorities, which led me astray. I prepared v7 and I tried
to maximize simplicity. I hope it will be more acceptable than the v6
version.