🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16816

[PATCH net v2] net: marvell: prestera: disable port before changing its MAC mode

#16816
From: Imre Kaloz
Date: Sun, 15 Nov 2026 23:08
72 lines
10254 bytes
prestera_pcs_config() writes a new mode, speed or inband setting to an
enabled port. The firmware can then report link down until the port is
disabled and enabled again.

Disable the port before such a write. 2500BASE-X and SGMII share one MAC
mode, so SGMII sets its own speed and the speed is compared as well.
Exercising this needs a link partner, so no in-tree test covers it.

Fixes: 52323ef75414 ("net: marvell: prestera: add phylink support")
Signed-off-by: Imre Kaloz <kaloz@kernel.org>
---
Changes in v2:
- Also disable the port on a speed change and set the SGMII speed, so
  that a switch between 2500BASE-X and SGMII, which share one MAC mode,
  is covered.
- Elad's Reviewed-by from v1 is not carried over, given the changes to the logic.
- Link to v1: https://lore.kernel.org/netdev/20261111101521.9878-1-kaloz@kernel.org/

 .../ethernet/marvell/prestera/prestera_main.c   | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
index a82e7a8029851..3173145573600 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
@@ -307,13 +307,14 @@ static int prestera_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
 			       bool permit_pause_to_mac)
 {
 	struct prestera_port *port = prestera_pcs_to_port(pcs);
-	struct prestera_port_mac_config cfg_mac;
+	struct prestera_port_mac_config cfg_mac, old;
 	int err;
 
 	err = prestera_port_cfg_mac_read(port, &cfg_mac);
 	if (err)
 		return err;
 
+	old = cfg_mac;
 	cfg_mac.admin = true;
 	cfg_mac.fec = PRESTERA_PORT_FEC_OFF;
 	cfg_mac.inband = neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED;
@@ -329,6 +330,7 @@ static int prestera_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
 		cfg_mac.mode = PRESTERA_MAC_MODE_SGMII;
 		break;
 	case PHY_INTERFACE_MODE_SGMII:
+		cfg_mac.speed = SPEED_1000;
 		cfg_mac.mode = PRESTERA_MAC_MODE_SGMII;
 		break;
 	case PHY_INTERFACE_MODE_1000BASEX:
@@ -339,6 +341,19 @@ static int prestera_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
 		break;
 	}
 
+	/* Firmware may not report link up after the mode, speed or inband
+	 * setting of an enabled port changes until the port is disabled and
+	 * re-enabled.
+	 */
+	if (old.admin && (old.mode != cfg_mac.mode ||
+			  old.speed != cfg_mac.speed ||
+			  old.inband != cfg_mac.inband)) {
+		old.admin = false;
+		err = prestera_port_cfg_mac_write(port, &old);
+		if (err)
+			return err;
+	}
+
 	err = prestera_port_cfg_mac_write(port, &cfg_mac);
 	if (err)
 		return err;
-- 
2.47.3
Technical Details
Message-ID: <20261115230812.29644-1-kaloz@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363902-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363902-linux-kernel-netdev=dewy.ru
From: kaloz@kernel.org (Imre Kaloz)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2] net: marvell: prestera: disable port before changing its MAC mode
Date: Mon, 16 Nov 2026 00:08:12 +0100
Organization: Usenet Network
Message-ID: <20261115230812.29644-1-kaloz@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1924259"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:TiMgxy6uD5ouiew/dmeL440vJWg= sha256:XDnHQ5sqYKqtAQollCJVOsDCQMEdaevOLOfCDyuMXh4=
	sha1:vpCBmjmg/7xoA8Y/ml2OlsPJ/aY= sha256:E91tLyn9wWL4WEY7PvOLaWol4IstasYbO406TChgRIs=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 3A9DB114A97; Mon, 16 Nov 2026 02:09:56 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id kAa11nCUBJVz;
	Mon, 16 Nov 2026 02:09:48 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-363902-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 4EA8B114A7B; Mon, 16 Nov 2026 02:09:40 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id E5C8460499E; Sun, 15 Nov 2026 23:09:39 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794784177;
	b=sNoswjA0Wzq2rwucxaFxX4pUH71E6scYIkm0N4Eym/MpYgxCalrUzqhaxTJBzuJmG7HX
	 nZItitbbPxRezMVh7vHyOxkOP2LunpdqEf+7WAatIztGlm3kFvoOyPL32wsxz00anWvfz
	 tf846N6IDkNMqzWw4YaNU+1M+8rBb3hG1I+2bNwDpKjEN0k55Z5NlnCgXy7cfdy9C0e4e
	 be8PfNziwZ2qr0O/c7xltVoi5v0WJx3CfKecb0iYYjr9gDAzNX5wa9+g75d/KsRlvQTFY
	 bECg97mggCG9hS/vWB1b+lSQIkfwvtePVg7pca14oiO2BVhlRWZipt5GI7+/Gg/N08A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794784177;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=fcySjAgXRv1Omeu2uLTfEyvofesTjl/NbY/HSOVg4ec=;
	b=XVpB1E2Jveu4mA59UugLp6ceQRnac6rOe5qLbPe0MWmEQp7pjZZEMg84h/JvsJs4oQwL
	 +DDVcQ355z9AX9yb2jCnZovuVRU+Iqp6W/9lvC7m0HXuEkJSgJtA4TTsB1A5YE2m65Yst
	 b/pcVyHJug1B5YH8KgZPkp6ea51cB9HKFlc4y7BC9ZvDpSTv100Vj2TXUFwtP4OmfPUSf
	 TSPFwViVX+kDxE3xcz1Q9n53xfU2xt4vSwLKSbr1C1NLQPU0GAO2F2UenAMr5PvJChrVM
	 L3vxi+3y4OZ/ioJGHVrvRmBaFJ/hY4EyRX51MJ56vdXeOZFshG5JmkMEUNwN+l94YIw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iMyHLiEA;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D8C7606A334;
	Sun, 15 Nov 2026 23:09:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iMyHLiEA
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794784176;
	b=V5UyaAQ0Mqqimps2r5Gy7m29JvqJRFgbqnMRMmVgwRfUCjv/bEJiqfNve7r4CBuVzX+J
	 o7XqSh+0+vOKPQ0u+K7PcnpPGMZZMsw4bZstTHc0HOx8mAsyKmAwWulhOLLUgJ7mY7yuu
	 nBFU8bO+5SY8KYeMqA8d+PE5OQDrDCZK8HT4uBTZmo+ZqzIL4o2aME0IIvVh/PEb9TIhX
	 1GmahuJ5mMLTC8Qeuva7dw/PpU6i7vdSohmxoU1bl5OVXDZw3PZYnc6zu6KdUC37nwr5W
	 YyaTXNA/rZ9Jmih4rh6iWX38+pwEwkGe/unwEUBzYr7Xfzm+Xs/sBBqlwR9tyWR3eLA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794784176;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 MIME-Version:Content-Transfer-Encoding;
	bh=fcySjAgXRv1Omeu2uLTfEyvofesTjl/NbY/HSOVg4ec=;
	b=aSG9D6UqcFcrymuTlkFEkft1AXX2FCFUKeNhGAZp87kkeFCCiyc7aWHFD9L2Ir2r8FTV
	 Ly12SIiM603T/JkDfqF9/p/79Ptv5kDSofejEynq7kzUZQLo8BDV8Zg1UZXOGNijb59n3
	 RqJiLUXDMlCDiUZj0flckmet1jbBdajplVtli9o61trkxS7Iyne56fjE/hpDdbcmk9RoT
	 1FFLVGGjUYeV8ePln2VkjsZUV9qrWq9LkwfCJvIS6OHvOlY821nfcHdvppaXDlR6AbtEf
	 aCpCenwYEqGyA6Xy5uidEjl8Zy4VLRFqX6wIkUOj6fXNVu+S0vagyeGLFPFdHhiU7+w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iMyHLiEA;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4940C606A323
	for <netdev@vger.kernel.org>; Sun, 15 Nov 2026 23:09:36 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDAA91F000C4;
	Sun, 15 Nov 2026 23:09:33 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794784175;
	bh=fcySjAgXRv1Omeu2uLTfEyvofesTjl/NbY/HSOVg4ec=;
	h=From:To:Cc:Subject:Date;
	b=iMyHLiEABx76W2qPYcp0ne+sEnp5KPMJy5xjquofbvVyKJQWSukK2XnTkD4Lvvn1r
	 P6p1bFEMleM9RA9sp7i10x70XNa/43rnF2EP5pGa+lfKYsKK/0RyPHl96zu9yxmMWs
	 WEeEobMW1mKfgJaR91GUpKPQ6tjGkd+xtsG5Dju9+UH31QwnaqF2lswUNHJRWgeUzT
	 BtuMCV1l9ziMKT9ix6zMP74QqtH1a+rXMJhCLBYdU82GpBmqALpKiL6Miq/wljefrn
	 zr1X1y/YPjseLcpihooW0cZ5GvC5BdoqAlTVNe8utzm/g7UKSpIgemIau7H0L2m5zT
	 TnDN01xU0y+eQ==
X-Cc: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Elad Nachman <enachman@marvell.com>,
	Oleksandr Mazur <oleksandr.mazur@plvision.eu>
X-Mailer: git-send-email 2.47.3
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list