Subject: Re: [PATCH net] net: dsa: microchip: fix initial port flush problem

From: Simon Horman <[email-masked]>
Date: Sat, 1 Jun 2024 13:05:45 +0100

On Fri, May 31, 2024 at 07:19:54PM +0000, [email-masked] wrote:
> > Subject: Re: [PATCH net] net: dsa: microchip: fix initial port flush problem
> > 
> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content
> > is safe
> > 
> > On Tue, May 28, 2024 at 02:35:45PM -0700, [email-masked] wrote:
> > > From: Tristram Ha <[email-masked]>
> > >
> > > The very first flush in any port will flush all learned addresses in all
> > > ports.  This can be observed by unplugging a cable from one port while
> > > additional ports are connected and dumping the fdb entries.
> > >
> > > This problem is caused by the initially wrong value programmed to the
> > > register.  After the first flush the value is reset back to the normal so
> > > the next port flush will not cause such problem again.
> > 
> > Hi Tristram,
> > 
> > I think it would be worth spelling out why it is correct to:
> > 1. Not set SW_FLUSH_STP_TABLE or SW_FLUSH_MSTP_TABLE; and
> > 2. Preserve the value of the other bits of REG_SW_LUE_CTRL_1
> 
> Setting SW_FLUSH_STP_TABLE and SW_FLUSH_MSTP_TABLE bits are wrong as they
> are action bits.  The bit should be set only when doing an action like
> flushing.

Understood, thanks. And I guess that only bits that are being configured
should be changed, thus the values other bits are preserved with this
change.

FWIIW, I do think it would be worth adding something about this to the
patch description.

> 
> > >
> > > Fixes: b987e98e50ab ("dsa: add DSA switch driver for Microchip KSZ9477")
> > > Signed-off-by: Tristram Ha <[email-masked]>
> > > ---
> > >  drivers/net/dsa/microchip/ksz9477.c | 3 +--
> > >  1 file changed, 1 insertion(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/net/dsa/microchip/ksz9477.c
> > b/drivers/net/dsa/microchip/ksz9477.c
> > > index f8ad7833f5d9..7cc92b90ffea 100644
> > > --- a/drivers/net/dsa/microchip/ksz9477.c
> > > +++ b/drivers/net/dsa/microchip/ksz9477.c
> > > @@ -356,8 +356,7 @@ int ksz9477_reset_switch(struct ksz_device *dev)
> > >
> > >       /* default configuration */
> > >       ksz_read8(dev, REG_SW_LUE_CTRL_1, &data8);
> > > -     data8 = SW_AGING_ENABLE | SW_LINK_AUTO_AGING |
> > > -           SW_SRC_ADDR_FILTER | SW_FLUSH_STP_TABLE | SW_FLUSH_MSTP_TABLE;
> > > +     data8 |= SW_AGING_ENABLE | SW_LINK_AUTO_AGING |
> > SW_SRC_ADDR_FILTER;
> > >       ksz_write8(dev, REG_SW_LUE_CTRL_1, data8);
> > >
> > >       /* disable interrupts */
> > > --
> > > 2.34.1
> > >
> > >
>