2021-06-15 17:56:58

by George McCollister

[permalink] [raw]
Subject: [PATCH net-next] net: dsa: xrs700x: forward HSR supervision frames

Forward supervision frames between redunant HSR ports. This was broken
in the last commit.

Fixes: 1a42624aecba ("net: dsa: xrs700x: allow HSR/PRP supervision dupes
for node_table")
Signed-off-by: George McCollister <[email protected]>
---
drivers/net/dsa/xrs700x/xrs700x.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/drivers/net/dsa/xrs700x/xrs700x.c b/drivers/net/dsa/xrs700x/xrs700x.c
index a79066174a77..130abb0f1438 100644
--- a/drivers/net/dsa/xrs700x/xrs700x.c
+++ b/drivers/net/dsa/xrs700x/xrs700x.c
@@ -337,7 +337,8 @@ static int xrs700x_port_add_bpdu_ipf(struct dsa_switch *ds, int port)
* This is required to correctly populate the HSR/PRP node_table.
* Leave the policy disabled, it will be enabled as needed.
*/
-static int xrs700x_port_add_hsrsup_ipf(struct dsa_switch *ds, int port)
+static int xrs700x_port_add_hsrsup_ipf(struct dsa_switch *ds, int port,
+ int fwdport)
{
struct xrs700x *priv = ds->priv;
unsigned int val = 0;
@@ -368,6 +369,9 @@ static int xrs700x_port_add_hsrsup_ipf(struct dsa_switch *ds, int port)
if (ret)
return ret;

+ if (fwdport >= 0)
+ val |= BIT(fwdport);
+
/* Allow must be set prevent duplicate discard */
ret = regmap_write(priv->regmap, XRS_ETH_ADDR_FWD_ALLOW(port, 1), val);
if (ret)
@@ -405,10 +409,6 @@ static int xrs700x_port_setup(struct dsa_switch *ds, int port)
ret = xrs700x_port_add_bpdu_ipf(ds, port);
if (ret)
return ret;
-
- ret = xrs700x_port_add_hsrsup_ipf(ds, port);
- if (ret)
- return ret;
}

return 0;
@@ -562,6 +562,7 @@ static int xrs700x_hsr_join(struct dsa_switch *ds, int port,
struct net_device *slave;
int ret, i, hsr_pair[2];
enum hsr_version ver;
+ bool fwd = false;

ret = hsr_get_version(hsr, &ver);
if (ret)
@@ -607,6 +608,7 @@ static int xrs700x_hsr_join(struct dsa_switch *ds, int port,
if (ver == HSR_V1) {
val &= ~BIT(partner->index);
val &= ~BIT(port);
+ fwd = true;
}
val &= ~BIT(dsa_upstream_port(ds, port));
regmap_write(priv->regmap, XRS_PORT_FWD_MASK(partner->index), val);
@@ -616,10 +618,19 @@ static int xrs700x_hsr_join(struct dsa_switch *ds, int port,
XRS_PORT_FORWARDING);
regmap_fields_write(priv->ps_forward, port, XRS_PORT_FORWARDING);

- /* Enable inbound policy added by xrs700x_port_add_hsrsup_ipf()
- * which allows HSR/PRP supervision forwarding to the CPU port without
- * discarding duplicates.
+ /* Enable inbound policy which allows HSR/PRP supervision forwarding
+ * to the CPU port without discarding duplicates. Continue to
+ * forward to redundant ports when in HSR mode while discarding
+ * duplicates.
*/
+ ret = xrs700x_port_add_hsrsup_ipf(ds, partner->index, fwd ? port : -1);
+ if (ret)
+ return ret;
+
+ ret = xrs700x_port_add_hsrsup_ipf(ds, port, fwd ? partner->index : -1);
+ if (ret)
+ return ret;
+
regmap_update_bits(priv->regmap,
XRS_ETH_ADDR_CFG(partner->index, 1), 1, 1);
regmap_update_bits(priv->regmap, XRS_ETH_ADDR_CFG(port, 1), 1, 1);
--
2.11.0


2021-06-15 23:23:31

by Vladimir Oltean

[permalink] [raw]
Subject: Re: [PATCH net-next] net: dsa: xrs700x: forward HSR supervision frames

On Tue, Jun 15, 2021 at 12:55:26PM -0500, George McCollister wrote:
> Forward supervision frames between redunant HSR ports. This was broken
> in the last commit.
>
> Fixes: 1a42624aecba ("net: dsa: xrs700x: allow HSR/PRP supervision dupes
> for node_table")

It would be good if you could resend with the Fixes: line not wrapped
around. There are several scripts around which won't parse that.

> Signed-off-by: George McCollister <[email protected]>
> ---

Otherwise the change looks reasonably clean, and it agrees with what IEC
62439-3:2018 does seem to imply in "5.3.4 DANH forwarding rules" that
HSR_Supervision frames should be forwarded and without discarding
duplicates. For PRP, of course the DANP does not forward packets between
the redundant ports, so it does not forward PRP_Supervision packets
either.

Reviewed-by: Vladimir Oltean <[email protected]>

2021-06-16 01:33:53

by George McCollister

[permalink] [raw]
Subject: Re: [PATCH net-next] net: dsa: xrs700x: forward HSR supervision frames

On Tue, Jun 15, 2021 at 6:22 PM Vladimir Oltean <[email protected]> wrote:
>
> On Tue, Jun 15, 2021 at 12:55:26PM -0500, George McCollister wrote:
> > Forward supervision frames between redunant HSR ports. This was broken
> > in the last commit.
> >
> > Fixes: 1a42624aecba ("net: dsa: xrs700x: allow HSR/PRP supervision dupes
> > for node_table")
>
> It would be good if you could resend with the Fixes: line not wrapped
> around. There are several scripts around which won't parse that.

WIll do. I was wondering which way was correct and figured scripts
should be smart enough to parse it especially since all it should
really need is Fixes: $HASH. Oh well.

>
> > Signed-off-by: George McCollister <[email protected]>
> > ---
>
> Otherwise the change looks reasonably clean, and it agrees with what IEC
> 62439-3:2018 does seem to imply in "5.3.4 DANH forwarding rules" that
> HSR_Supervision frames should be forwarded and without discarding
> duplicates. For PRP, of course the DANP does not forward packets between
> the redundant ports, so it does not forward PRP_Supervision packets
> either.

Yeah the tricky part with HSR supervision frames is you must forward
if the other port has received the duplicate frame but not if the
frame has been sent out the port you're about to send from already. At
first I set the mirror bit in addition to the allow bit and activity
was on completely solid as supervision frames looped around.

>
> Reviewed-by: Vladimir Oltean <[email protected]>

Thanks