Re: [PATCH v2 3/4] net: dsa: hsr: Enable in KSZ9477 switch HW HSR offloading
From: Andrew Lunn <andrew@lunn.ch>
Date: 2023-09-03 17:17:49
Also in:
lkml
From: Andrew Lunn <andrew@lunn.ch>
Date: 2023-09-03 17:17:49
Also in:
lkml
+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.
Andrew