netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 net-next] net: dsa: ksz_common: Allow only up to two HSR HW offloaded ports for KSZ9477
@ 2024-06-19 14:58 Lukasz Majewski
  2024-06-19 15:25 ` Florian Fainelli
  2024-06-21  9:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Lukasz Majewski @ 2024-06-19 14:58 UTC (permalink / raw)
  To: Vladimir Oltean, Jakub Kicinski, netdev, Paolo Abeni
  Cc: Eric Dumazet, David S. Miller, Oleksij Rempel, Tristram.Ha,
	Sebastian Andrzej Siewior, Simon Horman, Dan Carpenter,
	Ricardo B. Marliere, Casper Andersson, linux-kernel, Woojung Huh,
	UNGLinuxDriver, Andrew Lunn, Lukasz Majewski

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.

The problem is with RedBox configuration (HSR-SAN) - when configuring:
ip link add name hsr0 type hsr slave1 lan1 slave2 lan2 interlink lan3 \
	supervision 45 version 1

The lan1 (port0) and lan2 (port1) are correctly configured as ports, which
can use HSR offloading on ksz9477.

However, when we do already have two bits set in hsr_ports, we need to
return (-ENOTSUPP), so the interlink port (lan3) would be used with
SW based HSR RedBox support.

Otherwise, I do see some strange network behavior, as some HSR frames are
visible on non-HSR network and vice versa.

This causes the switch connected to interlink port (lan3) to drop frames
and no communication is possible.

Moreover, conceptually - the interlink (i.e. HSR-SAN port - lan3/port2)
shall be only supported in software as it is also possible to use ksz9477
with only SW based HSR (i.e. port0/1 -> hsr0 with offloading, port2 ->
HSR-SAN/interlink, port4/5 -> hsr1 with SW based HSR).

Fixes: 5055cccfc2d1 ("net: hsr: Provide RedBox support (HSR-SAN)")
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>

---
Changes for v2:
- Add more verbose description with Fixes: tag
- Check the condition earlier and remove extra check if SoC is ksz9477
- Add comment in the source code file

Changes for v3:
- Change 'use' to 'using'
- Adjust commit subject prefix
---
 drivers/net/dsa/microchip/ksz_common.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 2818e24e2a51..debb554b60ed 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -3906,6 +3906,13 @@ static int ksz_hsr_join(struct dsa_switch *ds, int port, struct net_device *hsr,
 		return -EOPNOTSUPP;
 	}
 
+	/* KSZ9477 can only perform HSR offloading for up to two ports */
+	if (hweight8(dev->hsr_ports) >= 2) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "Cannot offload more than two ports - using software HSR");
+		return -EOPNOTSUPP;
+	}
+
 	/* Self MAC address filtering, to avoid frames traversing
 	 * the HSR ring more than once.
 	 */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 net-next] net: dsa: ksz_common: Allow only up to two HSR HW offloaded ports for KSZ9477
  2024-06-19 14:58 [PATCH v3 net-next] net: dsa: ksz_common: Allow only up to two HSR HW offloaded ports for KSZ9477 Lukasz Majewski
@ 2024-06-19 15:25 ` Florian Fainelli
  2024-06-21  9:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2024-06-19 15:25 UTC (permalink / raw)
  To: Lukasz Majewski, Vladimir Oltean, Jakub Kicinski, netdev,
	Paolo Abeni
  Cc: Eric Dumazet, David S. Miller, Oleksij Rempel, Tristram.Ha,
	Sebastian Andrzej Siewior, Simon Horman, Dan Carpenter,
	Ricardo B. Marliere, Casper Andersson, linux-kernel, Woojung Huh,
	UNGLinuxDriver, Andrew Lunn



On 6/19/2024 3:58 PM, 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.
> 
> The problem is with RedBox configuration (HSR-SAN) - when configuring:
> ip link add name hsr0 type hsr slave1 lan1 slave2 lan2 interlink lan3 \
> 	supervision 45 version 1
> 
> The lan1 (port0) and lan2 (port1) are correctly configured as ports, which
> can use HSR offloading on ksz9477.
> 
> However, when we do already have two bits set in hsr_ports, we need to
> return (-ENOTSUPP), so the interlink port (lan3) would be used with
> SW based HSR RedBox support.
> 
> Otherwise, I do see some strange network behavior, as some HSR frames are
> visible on non-HSR network and vice versa.
> 
> This causes the switch connected to interlink port (lan3) to drop frames
> and no communication is possible.
> 
> Moreover, conceptually - the interlink (i.e. HSR-SAN port - lan3/port2)
> shall be only supported in software as it is also possible to use ksz9477
> with only SW based HSR (i.e. port0/1 -> hsr0 with offloading, port2 ->
> HSR-SAN/interlink, port4/5 -> hsr1 with SW based HSR).
> 
> Fixes: 5055cccfc2d1 ("net: hsr: Provide RedBox support (HSR-SAN)")
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 net-next] net: dsa: ksz_common: Allow only up to two HSR HW offloaded ports for KSZ9477
  2024-06-19 14:58 [PATCH v3 net-next] net: dsa: ksz_common: Allow only up to two HSR HW offloaded ports for KSZ9477 Lukasz Majewski
  2024-06-19 15:25 ` Florian Fainelli
@ 2024-06-21  9:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-06-21  9:20 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: olteanv, kuba, netdev, pabeni, edumazet, davem, o.rempel,
	Tristram.Ha, bigeasy, horms, dan.carpenter, ricardo, casper.casan,
	linux-kernel, woojung.huh, UNGLinuxDriver, andrew

Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Wed, 19 Jun 2024 16:58:09 +0200 you 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.
> 
> The problem is with RedBox configuration (HSR-SAN) - when configuring:
> ip link add name hsr0 type hsr slave1 lan1 slave2 lan2 interlink lan3 \
> 	supervision 45 version 1
> 
> [...]

Here is the summary with links:
  - [v3,net-next] net: dsa: ksz_common: Allow only up to two HSR HW offloaded ports for KSZ9477
    https://git.kernel.org/netdev/net-next/c/dcec8d291da8

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-21  9:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19 14:58 [PATCH v3 net-next] net: dsa: ksz_common: Allow only up to two HSR HW offloaded ports for KSZ9477 Lukasz Majewski
2024-06-19 15:25 ` Florian Fainelli
2024-06-21  9:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).