[RFC PATCH 04/10] net: dsa: b53: fix IP_MULTICAST_CTRL on BCM5325

Álvaro Fernández Rojas posted 10 patches 6 months, 2 weeks ago
There is a newer version of this series
[RFC PATCH 04/10] net: dsa: b53: fix IP_MULTICAST_CTRL on BCM5325
Posted by Álvaro Fernández Rojas 6 months, 2 weeks ago
BCM5325 doesn't implement B53_UC_FWD_EN, B53_MC_FWD_EN or B53_IPMC_FWD_EN.

Fixes: 53568438e381 ("net: dsa: b53: Add support for port_egress_floods callback")
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 drivers/net/dsa/b53/b53_common.c | 13 +++++++++----
 drivers/net/dsa/b53/b53_regs.h   |  1 +
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index f314aeb81643..6b2ad82aa95f 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -367,11 +367,16 @@ static void b53_set_forwarding(struct b53_device *dev, int enable)
 		b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, mgmt);
 	}
 
-	/* Look at B53_UC_FWD_EN and B53_MC_FWD_EN to decide whether
-	 * frames should be flooded or not.
-	 */
 	b53_read8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, &mgmt);
-	mgmt |= B53_UC_FWD_EN | B53_MC_FWD_EN | B53_IPMC_FWD_EN;
+	if (is5325(dev)) {
+		/* Enable IP multicast address scheme. */
+		mgmt |= B53_IP_MCAST_25;
+	} else {
+		/* Look at B53_UC_FWD_EN and B53_MC_FWD_EN to decide whether
+		 * frames should be flooded or not.
+		 */
+		mgmt |= B53_UC_FWD_EN | B53_MC_FWD_EN | B53_IPMC_FWD_EN;
+	}
 	b53_write8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, mgmt);
 }
 
diff --git a/drivers/net/dsa/b53/b53_regs.h b/drivers/net/dsa/b53/b53_regs.h
index 1f15332fb2a7..896684d7f594 100644
--- a/drivers/net/dsa/b53/b53_regs.h
+++ b/drivers/net/dsa/b53/b53_regs.h
@@ -106,6 +106,7 @@
 
 /* IP Multicast control (8 bit) */
 #define B53_IP_MULTICAST_CTRL		0x21
+#define  B53_IP_MCAST_25		BIT(0)
 #define  B53_IPMC_FWD_EN		BIT(1)
 #define  B53_UC_FWD_EN			BIT(6)
 #define  B53_MC_FWD_EN			BIT(7)
-- 
2.39.5

Re: [RFC PATCH 04/10] net: dsa: b53: fix IP_MULTICAST_CTRL on BCM5325
Posted by Florian Fainelli 6 months, 2 weeks ago
On 5/31/25 03:13, Álvaro Fernández Rojas wrote:
> BCM5325 doesn't implement B53_UC_FWD_EN, B53_MC_FWD_EN or B53_IPMC_FWD_EN.
> 
> Fixes: 53568438e381 ("net: dsa: b53: Add support for port_egress_floods callback")
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>   drivers/net/dsa/b53/b53_common.c | 13 +++++++++----
>   drivers/net/dsa/b53/b53_regs.h   |  1 +
>   2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
> index f314aeb81643..6b2ad82aa95f 100644
> --- a/drivers/net/dsa/b53/b53_common.c
> +++ b/drivers/net/dsa/b53/b53_common.c
> @@ -367,11 +367,16 @@ static void b53_set_forwarding(struct b53_device *dev, int enable)
>   		b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, mgmt);
>   	}
>   
> -	/* Look at B53_UC_FWD_EN and B53_MC_FWD_EN to decide whether
> -	 * frames should be flooded or not.
> -	 */
>   	b53_read8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, &mgmt);
> -	mgmt |= B53_UC_FWD_EN | B53_MC_FWD_EN | B53_IPMC_FWD_EN;
> +	if (is5325(dev)) {
> +		/* Enable IP multicast address scheme. */
> +		mgmt |= B53_IP_MCAST_25;
> +	} else {
> +		/* Look at B53_UC_FWD_EN and B53_MC_FWD_EN to decide whether
> +		 * frames should be flooded or not.
> +		 */
> +		mgmt |= B53_UC_FWD_EN | B53_MC_FWD_EN | B53_IPMC_FWD_EN;
> +	}
>   	b53_write8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, mgmt);

I don't think B53_IPM_MULTICAST_CTRL is a valid register offset within 
B53_CTRL_PAGE, or elsewhere for that matter, do you have a datasheet 
that says this exists?
-- 
Florian
Re: [RFC PATCH 04/10] net: dsa: b53: fix IP_MULTICAST_CTRL on BCM5325
Posted by Jonas Gorski 6 months, 2 weeks ago
On Mon, Jun 2, 2025 at 8:06 PM Florian Fainelli
<florian.fainelli@broadcom.com> wrote:
>
> On 5/31/25 03:13, Álvaro Fernández Rojas wrote:
> > BCM5325 doesn't implement B53_UC_FWD_EN, B53_MC_FWD_EN or B53_IPMC_FWD_EN.
> >
> > Fixes: 53568438e381 ("net: dsa: b53: Add support for port_egress_floods callback")
> > Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> > ---
> >   drivers/net/dsa/b53/b53_common.c | 13 +++++++++----
> >   drivers/net/dsa/b53/b53_regs.h   |  1 +
> >   2 files changed, 10 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
> > index f314aeb81643..6b2ad82aa95f 100644
> > --- a/drivers/net/dsa/b53/b53_common.c
> > +++ b/drivers/net/dsa/b53/b53_common.c
> > @@ -367,11 +367,16 @@ static void b53_set_forwarding(struct b53_device *dev, int enable)
> >               b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, mgmt);
> >       }
> >
> > -     /* Look at B53_UC_FWD_EN and B53_MC_FWD_EN to decide whether
> > -      * frames should be flooded or not.
> > -      */
> >       b53_read8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, &mgmt);
> > -     mgmt |= B53_UC_FWD_EN | B53_MC_FWD_EN | B53_IPMC_FWD_EN;
> > +     if (is5325(dev)) {
> > +             /* Enable IP multicast address scheme. */
> > +             mgmt |= B53_IP_MCAST_25;
> > +     } else {
> > +             /* Look at B53_UC_FWD_EN and B53_MC_FWD_EN to decide whether
> > +              * frames should be flooded or not.
> > +              */
> > +             mgmt |= B53_UC_FWD_EN | B53_MC_FWD_EN | B53_IPMC_FWD_EN;
> > +     }
> >       b53_write8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, mgmt);

Since the only common thing is the register name, maybe it would make
more sense to have the flow here

if (is5325) {
    enable IP_MULTICAST
}  else {
    enable DUMB_FWD_EN
    enable {UC,MC,IPMC}_FWD_EN
}

>
> I don't think B53_IPM_MULTICAST_CTRL is a valid register offset within
> B53_CTRL_PAGE, or elsewhere for that matter, do you have a datasheet
> that says this exists?

5325E-DS14-R, page 83 (or 105 in pdf paging) on the top.

Regards,
Jonas
Re: [RFC PATCH 04/10] net: dsa: b53: fix IP_MULTICAST_CTRL on BCM5325
Posted by Álvaro Fernández Rojas 6 months, 2 weeks ago
Hi Jonas,

El lun, 2 jun 2025 a las 21:59, Jonas Gorski
(<jonas.gorski@gmail.com>) escribió:
>
> On Mon, Jun 2, 2025 at 8:06 PM Florian Fainelli
> <florian.fainelli@broadcom.com> wrote:
> >
> > On 5/31/25 03:13, Álvaro Fernández Rojas wrote:
> > > BCM5325 doesn't implement B53_UC_FWD_EN, B53_MC_FWD_EN or B53_IPMC_FWD_EN.
> > >
> > > Fixes: 53568438e381 ("net: dsa: b53: Add support for port_egress_floods callback")
> > > Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> > > ---
> > >   drivers/net/dsa/b53/b53_common.c | 13 +++++++++----
> > >   drivers/net/dsa/b53/b53_regs.h   |  1 +
> > >   2 files changed, 10 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
> > > index f314aeb81643..6b2ad82aa95f 100644
> > > --- a/drivers/net/dsa/b53/b53_common.c
> > > +++ b/drivers/net/dsa/b53/b53_common.c
> > > @@ -367,11 +367,16 @@ static void b53_set_forwarding(struct b53_device *dev, int enable)
> > >               b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, mgmt);
> > >       }
> > >
> > > -     /* Look at B53_UC_FWD_EN and B53_MC_FWD_EN to decide whether
> > > -      * frames should be flooded or not.
> > > -      */
> > >       b53_read8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, &mgmt);
> > > -     mgmt |= B53_UC_FWD_EN | B53_MC_FWD_EN | B53_IPMC_FWD_EN;
> > > +     if (is5325(dev)) {
> > > +             /* Enable IP multicast address scheme. */
> > > +             mgmt |= B53_IP_MCAST_25;
> > > +     } else {
> > > +             /* Look at B53_UC_FWD_EN and B53_MC_FWD_EN to decide whether
> > > +              * frames should be flooded or not.
> > > +              */
> > > +             mgmt |= B53_UC_FWD_EN | B53_MC_FWD_EN | B53_IPMC_FWD_EN;
> > > +     }
> > >       b53_write8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, mgmt);
>
> Since the only common thing is the register name, maybe it would make
> more sense to have the flow here
>
> if (is5325) {
>     enable IP_MULTICAST
> }  else {
>     enable DUMB_FWD_EN
>     enable {UC,MC,IPMC}_FWD_EN
> }

OK, then I will do that by merging this patch with #3.

>
> >
> > I don't think B53_IPM_MULTICAST_CTRL is a valid register offset within
> > B53_CTRL_PAGE, or elsewhere for that matter, do you have a datasheet
> > that says this exists?
>
> 5325E-DS14-R, page 83 (or 105 in pdf paging) on the top.
>
> Regards,
> Jonas

Best regards,
Álvaro.