From patchwork Wed Jun 19 13:42:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 13703844 X-Patchwork-Delegate: kuba@kernel.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFC941E492; Wed, 19 Jun 2024 13:43:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=85.214.62.61 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718804607; cv=none; b=nY6owUUYBCJ6UdynjMvFWxYGGuvPPS1gj1hQEFqWFUn5cv7G+cR8S/U1V8bAz2bJ7vNwmWIpzR38+K9sM6YtetPSj/kN/sKMylMu8kd6LrH4i2EF78oAkY3x+Z7kJZOfII81A8NOp6/Oh8elTD4Z8gHnEarU0tCGY7sUcsSLMxY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718804607; c=relaxed/simple; bh=dUSlc6Lg5vWg8y4LNfZgdjLzNa2vJIlTrGtGI9EZzdM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=BjZt/iJGTwg6+GNJ/Sh957cdAEiaMU2qwt3Y/V/w0ccuCKaaQZX4nRUC9sr35ukNyPu7an8kJ7n2t6LhG9gKB+5pWMiqAhcx2BajR6BKCbm7TEJteHm0nGHOSacLAyofUgo2jmvqapEWWg89O32xgSTi/EfeeritHiU6SXv0NwE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=denx.de; spf=pass smtp.mailfrom=denx.de; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b=W/lMsG15; arc=none smtp.client-ip=85.214.62.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=denx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=denx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="W/lMsG15" Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 4722E8839C; Wed, 19 Jun 2024 15:43:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1718804595; bh=LxutYi9m1J9PLpwUyDonpTyGQDOBfl75a2yDTGQqVDY=; h=From:To:Cc:Subject:Date:From; b=W/lMsG15BMmpqQYBrjjOOXHzK/ljzRuZaZV9LWCpGOWLSA6MRLHyMAwN2yRoaZx8p 8SlcIVuLfTHY1cSZwsqIMALmsDWmgM5dV3W3go7qtYuA1tf/FxSA3pZPvuMzjOc4s3 P9dBD/s218dI9X70EcgOkzZeG8czoRI6GxXY8wCSKozKKsXQy5d0PfYLCk2kFdZ1DK kJhScT7v5Mr4l6jgbVEk21g9wdkfpGH20xD+5YcFI7CrMB54WWe0EzfQ8TvUc1eZla ovnl6pqzC9j6FLfS04dn2JNlAwsBYr04V7VGvoLkX+F5ZjeNYB/Ov0H5aHrdv3uyD9 ywTVU78zkMYfw== From: Lukasz Majewski To: Vladimir Oltean , Jakub Kicinski , netdev@vger.kernel.org, Paolo Abeni Cc: Eric Dumazet , "David S. Miller" , Oleksij Rempel , Tristram.Ha@microchip.com, Sebastian Andrzej Siewior , Simon Horman , Dan Carpenter , "Ricardo B. Marliere" , Casper Andersson , linux-kernel@vger.kernel.org, Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Lukasz Majewski Subject: [PATCH v2 net-next] net: dsa: Allow only up to two HSR HW offloaded ports for KSZ9477 Date: Wed, 19 Jun 2024 15:42:48 +0200 Message-Id: <20240619134248.1228443-1-lukma@denx.de> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Dan Carpenter Reviewed-by: Andrew Lunn --- 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 --- 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..72bb419e34b0 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 - use software HSR"); + return -EOPNOTSUPP; + } + /* Self MAC address filtering, to avoid frames traversing * the HSR ring more than once. */