Subject: Re: [PATCH net-next 08/12] net: dsa: rzn1-a5psw: add FDB support

From: Clément Léger <[email-masked]>
Date: Wed, 20 Apr 2022 10:16:48 +0200

Le Thu, 14 Apr 2022 20:51:40 +0300,
Vladimir Oltean <[email-masked]> a écrit :

> > +
> > +static int a5psw_port_fdb_add(struct dsa_switch *ds, int port,
> > +			      const unsigned char *addr, u16 vid,
> > +			      struct dsa_db db)  
> 
> This isn't something that is documented because I haven't had time to
> update that, but new drivers should comply to the requirements for FDB
> isolation (not ignore the passed "db" here) and eventually set
> ds->fdb_isolation = true. Doing so would allow your switch to behave
> correctly when
> - there is more than one bridge spanning its ports,
> - some ports are standalone and some ports are bridged
> - standalone ports are looped back via an external cable with bridged
>   ports
> - unrecognized upper interfaces (bond, team) are used, and those are
>   bridged directly with some other switch ports
> 
> The most basic thing you need to do to satisfy the requirements is to
> figure out what mechanism for FDB partitioning does your hardware have.
> If the answer is "none", then we'll have to use VLANs for that: all
> standalone ports to share a VLAN, each VLAN-unaware bridge to share a
> VLAN across all member ports, each VLAN of a VLAN-aware bridge to
> reserve its own VLAN. Up to a total of 32 VLANs, since I notice that's
> what the limit for your hardware is.

Ok, I see the idea. In the mean time, could we make a first step with a
single bridge and without VLAN support ? This is expected to come later
anyway.

> 
> But I see this patch set doesn't include VLAN functionality (and also
> ignores the "vid" from FDB entries), so I can't really say more right now.
> But if you could provide more information about the hardware
> capabilities we can discuss implementation options.

That's indeed the problem. The FDB table does not seems to have
partitionning at all (except for ports) and entries (such as seen below)
do not contain any VLAN information.

> > diff --git a/drivers/net/dsa/rzn1_a5psw.h b/drivers/net/dsa/rzn1_a5psw.h
> > index b34ea549e936..37aa89383e70 100644
> > --- a/drivers/net/dsa/rzn1_a5psw.h
> > +++ b/drivers/net/dsa/rzn1_a5psw.h
> > @@ -167,6 +167,22 @@
> >  #define A5PSW_CTRL_TIMEOUT		1000
> >  #define A5PSW_TABLE_ENTRIES		8192
> >  
> > +struct fdb_entry {  
> 
> Shouldn't this contain something along the lines of a VID, FID, something?

This is extracted directly from the datasheet [1]. The switch FDB table
does not seems to store the VID with the entries (See page 300).

[1]
https://www.renesas.com/us/en/document/mah/rzn1d-group-rzn1s-group-rzn1l-group-users-manual-r-engine-and-ethernet-peripherals
> 
> > +	u8 mac[ETH_ALEN];
> > +	u8 valid:1;
> > +	u8 is_static:1;
> > +	u8 prio:3;
> > +	u8 port_mask:5;
> > +} __packed;
> > +
> > +union lk_data {
> > +	struct {
> > +		u32 lo;
> > +		u32 hi;
> > +	};
> > +	struct fdb_entry entry;
> > +};
> > +
> >  /**
> >   * struct a5psw - switch struct
> >   * @base: Base address of the switch
> > -- 
> > 2.34.1
> >   
> 

-- 
Clément Léger,
Embedded Linux and Kernel engineer at Bootlin
https://bootlin.com