Re: [PATCH v2 3/4] net: dsa: hsr: Enable in KSZ9477 switch HW HSR offloading

From: Lukasz Majewski
Date: Mon Sep 04 2023 - 07:40:11 EST


Hi Andrew,

> > +int ksz9477_hsr_join(struct dsa_switch *ds, int port, struct
> > net_device *hsr,
> > + struct dsa_port *partner)
> > +{
> > + struct ksz_device *dev = ds->priv;
> > + struct net_device *slave;
> > + u8 i, data;
> > + int ret;
> > +
> > + /* Program which ports shall support HSR */
> > + dev->hsr_ports = BIT(port) | BIT(partner->index);
> > + ksz_write32(dev, REG_HSR_PORT_MAP__4, 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);
> > +
> > + /* Self MAC address filtering for HSR frames to avoid
> > + * traverse of the HSR ring more than once.
> > + *
> > + * The HSR port (i.e. hsr0) MAC address is used.
> > + */
> > + if (!is_valid_ether_addr(hsr->dev_addr)) {
> > + dev_err(dev->dev,
> > + "Set valid MAC address to %s for HSR
> > operation!",
> > + hsr->name);
> > + return -EINVAL;
> > + }
>
> This seems like something which should be done at a higher level, not
> per driver. Please check if there is an existing test, and if not, add
> one in the HSR core.

Yes, your are right. This is caught earlier in the net stack code.

Especially, I was afraid, that one can use:
local-mac-address = [00 00 00 00 00 00]

but in this case is caught as well.

I will remove this check. Thanks for pointing this out.

>
> Andrew




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