Re: [PATCH v5 net-next 5/5] net: dsa: microchip: Enable HSR offloading for KSZ9477

From: Lukasz Majewski
Date: Fri Sep 22 2023 - 07:29:19 EST


Hi Vladimir,

> On Wed, Sep 20, 2023 at 01:43:43PM +0200, Lukasz Majewski wrote:
> > +void ksz9477_hsr_join(struct dsa_switch *ds, int port, struct
> > net_device *hsr) +{
> > + struct ksz_device *dev = ds->priv;
> > + struct net_device *slave;
> > + u8 data;
> > +
> > + /* Program which port(s) shall support HSR */
> > + ksz_rmw32(dev, REG_HSR_PORT_MAP__4, BIT(port), BIT(port));
> > +
> > + /* Forward frames between HSR ports (i.e. bridge together
> > HSR ports) */
> > + ksz9477_cfg_port_member(dev, port,
> > + BIT(dsa_upstream_port(ds, port)) |
> > BIT(port));
>
> Isn't this supposed to be
>
> ksz9477_cfg_port_member(dev, port,
> BIT(dsa_upstream_port(ds, port)) |
> BIT(pair));
>
> where "pair" is not even passed as an argument to ksz9477_hsr_join(),
> but represents the *other* port in the HSR ring, not this one?

Unfortunately, yes...

The code as it is now -> would set for port lan1 0x21 and lan2 0x22.

However the setup shall be 0x23 for both ports.

More info here:
https://github.com/Microchip-Ethernet/EVB-KSZ9477/issues/98#issuecomment-1701557449

I will setup this register from dev->hsr_ports when both HSR ports are
known.


>
> > +
> > + if (!dev->hsr_ports) {
> > + /* Enable discarding of received HSR frames */
> > + ksz_read8(dev, REG_HSR_ALU_CTRL_0__1, &data);
> > + data |= HSR_DUPLICATE_DISCARD;
> > + data &= ~HSR_NODE_UNICAST;
> > + ksz_write8(dev, REG_HSR_ALU_CTRL_0__1, data);
> > + }
> > +
> > + /* Enable per port self-address filtering.
> > + * The global self-address filtering has already been
> > enabled in the
> > + * ksz9477_reset_switch() function.
> > + */
> > + ksz_port_cfg(dev, port, REG_PORT_LUE_CTRL,
> > PORT_SRC_ADDR_FILTER, true); +
> > + /* Setup HW supported features for lan HSR ports */
> > + slave = dsa_to_port(ds, port)->slave;
> > + slave->features |= KSZ9477_SUPPORTED_HSR_FEATURES;
> > +}
> > diff --git a/drivers/net/dsa/microchip/ksz_common.h
> > b/drivers/net/dsa/microchip/ksz_common.h index
> > 1f3fb6c23f36..1f447a34f555 100644 ---
> > a/drivers/net/dsa/microchip/ksz_common.h +++
> > b/drivers/net/dsa/microchip/ksz_common.h @@ -101,6 +101,11 @@
> > struct ksz_ptp_irq { int num;
> > };
> >
> > +struct ksz_switch_macaddr {
> > + unsigned char addr[ETH_ALEN];
> > + refcount_t refcount;
> > +};
> > +
> > struct ksz_port {
> > bool remove_tag; /* Remove Tag flag set,
> > for ksz8795 only */ bool learning;
> > @@ -169,6 +174,10 @@ struct ksz_device {
> > struct mutex lock_irq; /* IRQ Access */
> > struct ksz_irq girq;
> > struct ksz_ptp_data ptp_data;
> > +
> > + struct ksz_switch_macaddr *switch_macaddr;
> > + struct net_device *hsr_dev; /* HSR */
>
> Please be consistent with the lines above, and use tabs to align the
> "/* HSR */" comment.
>
> > + u8 hsr_ports;
> > };
> >
> > /* List of supported models */
> > --
> > 2.20.1
> >
>




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: pgpuTo8z5yhPT.pgp
Description: OpenPGP digital signature