Re: [PATCH v1 net-next] net: dsa: Allow only up to two HSR HW offloaded ports for KSZ9477

From: Lukasz Majewski
Date: Tue Jun 18 2024 - 10:08:22 EST


Hi Dan,

> On Tue, Jun 18, 2024 at 03:04:33PM +0200, Lukasz Majewski wrote:
> > The KSZ9477 allows HSR in-HW offloading for any of two selected
> > ports. This patch adds check if one tries to use more than two
> > ports with HSR offloading enabled.
> >
> > Signed-off-by: Lukasz Majewski <lukma@xxxxxxx>
>
> Is this a bug fix?

This seems to be fixing stuff, which was added earlier to next-next.


> What is the impact for the user?

Impact is that this board with this particular setup can just
malfunction.

> Fixes tag?

Ok.

> Add
> this information to the commit message when you resend.

I will wait a few days for input and then send v2.

Thanks for the input.

>
> > ---
> > drivers/net/dsa/microchip/ksz_common.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/net/dsa/microchip/ksz_common.c
> > b/drivers/net/dsa/microchip/ksz_common.c index
> > 2818e24e2a51..0d68f0a5bf19 100644 ---
> > a/drivers/net/dsa/microchip/ksz_common.c +++
> > b/drivers/net/dsa/microchip/ksz_common.c @@ -3913,6 +3913,9 @@
> > static int ksz_hsr_join(struct dsa_switch *ds, int port, struct
> > net_device *hsr, if (ret) return ret;
> >
> > + if (dev->chip_id == KSZ9477_CHIP_ID &&
> > hweight8(dev->hsr_ports) > 1)
> > + return -EOPNOTSUPP;
>
> Put this condition before the ksz_switch_macaddr_get(). Otherwise
> we'd need to do a ksz_switch_macaddr_put().
>
> If dev->chip_id != KSZ9477_CHIP_ID then we would have already
> returned. Really, that should be the first check in this function.
> The hsr_get_version() should be moved to right before we use the
> version. (But that's a separate issue, not related to this patch so
> ignore it).
>
> So do something like this but write a better error message.
>
> regards,
> dan carpenter
>
> diff --git a/drivers/net/dsa/microchip/ksz_common.c
> b/drivers/net/dsa/microchip/ksz_common.c index
> 2818e24e2a51..181e81af3a78 100644 ---
> a/drivers/net/dsa/microchip/ksz_common.c +++
> b/drivers/net/dsa/microchip/ksz_common.c @@ -3906,6 +3906,11 @@
> static int ksz_hsr_join(struct dsa_switch *ds, int port, struct
> net_device *hsr, return -EOPNOTSUPP; }
>
> + if (hweight8(dev->hsr_ports) > 1) {
> + NL_SET_ERR_MSG_MOD(extack, "Cannot offload more than
> two ports (in use=0x%x)", dev->hsr_ports);
> + return -EOPNOTSUPP;
> + }
> +
> /* Self MAC address filtering, to avoid frames traversing
> * the HSR ring more than once.
> */
>
>




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@xxxxxxx

Attachment: pgpjDhrIO82ar.pgp
Description: OpenPGP digital signature