From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796389018; b=pEdIDXCvZsVOQT8l8GJMFN7mdlzPC885wMTWYUy9Zk2PLcjBYWurfQ7WX8GOoDhInNlc /AVrcJFIJmb29KKh1ZFNOFu4GMf2fSPoFmY/pkBaz89BYJBJVEAF2y7rci2qedsb0kf4a 1CQqOQukCaWmrzRWUM2UNqp15e0LaaHlvmSVVuYpqjA+WsbHSWXgn3k6nLevlw9CL7FFY 79HzEevGbVM3wL+BgNro+shcwpPF1AZA7S2PeWvXH2F2eIwSfbbKBP5Mc+opJi7MO+YO8 6N2XHXCMxbLQBq9EpE04eglTfCLpzR8s/QsNWWIGBPtuUa+7gOYGH3wWTGuc7s/raIA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389018; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=iK+xAmxt58E3tA2NhPp5RFAa9ztd700YjxO9L5mQGSU=; b=JzO0Ko4s3ajrHKPBCHD8tuIJY1HUKVy8cLqCBWwoyXpxJM+F6IzpZ9JjE7PUX4j6TvYa iO86Q6FyNbMGmRTWSqIsYsujDHfTyzMB727EIoNavY0WvONutCdGh/hFcSAFZLlZJ1vl5 L+sivXpMPun2eDjwTmkjYsj2/7asNkZUg2Kqfx+3J6KcgODulkVZsYT2ChAgs4Mam9dq1 IgFQWuyqIvvGTYAFJ8L+1qRHpZ+lVsnSW22OdPQDaqaed607XLi8QBfcnSY25Nfok8Fku h1o+I/gVzQ/No4sj8G+n9z+LN3RFCIoG5wX5mUw6RJITy+sT6/wwUMaHHkGzjWMDfqA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=sfTvMS3A; arc=none smtp.remote-ip=100.103.45.18 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 83AD0606A32F; Fri, 4 Dec 2026 12:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=sfTvMS3A Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC4C41F00935; Fri, 4 Dec 2026 12:56:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389018; bh=iK+xAmxt58E3tA2NhPp5RFAa9ztd700YjxO9L5mQGSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sfTvMS3ABqFBsHd67b1Ie7D7X3INxQ9QVwroUtL9TY/1ABCibGMhuKWG9NGqIGaqQ 7jIUPTHpmDHgGDMiHkL3A7euiLBTjrqTh+VHjFoB0uCvs9T9G+UkaXYEYxkmFqLXXF k6LeI2Oe8SPhPL7ZkDb3tcTIroCHBugaW42vDY9M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Simon Horman , "Russell King (Oracle)" , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 0835/1059] net: sfp: add support for setting signalling rate Date: Fri, 4 Dec 2026 19:06:06 +0900 Message-ID: <20261204100705.658189922@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Russell King (Oracle) [ Upstream commit dc18582211b34bce8250ddf3cac2a2230e192120 ] Add support to the SFP layer to allow phylink to set the signalling rate for a SFP module. The rate given will be in units of kilo-baud (1000 baud). Reviewed-by: Simon Horman Signed-off-by: Russell King (Oracle) Signed-off-by: Jakub Kicinski Stable-dep-of: fdb6fcabdbb8 ("net: marvell: prestera: disable port before changing its MAC mode") Signed-off-by: Sasha Levin --- drivers/net/phy/phylink.c | 24 ++++++++++++++++++++++++ drivers/net/phy/sfp-bus.c | 20 ++++++++++++++++++++ drivers/net/phy/sfp.c | 5 +++++ drivers/net/phy/sfp.h | 1 + include/linux/sfp.h | 6 ++++++ 5 files changed, 56 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 8109a049a74e4..d1463f9cbd711 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -156,6 +156,23 @@ static const char *phylink_an_mode_str(unsigned int mode) return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown"; } +static unsigned int phylink_interface_signal_rate(phy_interface_t interface) +{ + switch (interface) { + case PHY_INTERFACE_MODE_SGMII: + case PHY_INTERFACE_MODE_1000BASEX: /* 1.25Mbd */ + return 1250; + case PHY_INTERFACE_MODE_2500BASEX: /* 3.125Mbd */ + return 3125; + case PHY_INTERFACE_MODE_5GBASER: /* 5.15625Mbd */ + return 5156; + case PHY_INTERFACE_MODE_10GBASER: /* 10.3125Mbd */ + return 10313; + default: + return 0; + } +} + /** * phylink_interface_max_speed() - get the maximum speed of a phy interface * @interface: phy interface mode defined by &typedef phy_interface_t @@ -992,6 +1009,7 @@ static void phylink_major_config(struct phylink *pl, bool restart, { struct phylink_pcs *pcs = NULL; bool pcs_changed = false; + unsigned int rate_kbd; int err; phylink_dbg(pl, "major config %s\n", phy_modes(state->interface)); @@ -1051,6 +1069,12 @@ static void phylink_major_config(struct phylink *pl, bool restart, ERR_PTR(err)); } + if (pl->sfp_bus) { + rate_kbd = phylink_interface_signal_rate(state->interface); + if (rate_kbd) + sfp_upstream_set_signal_rate(pl->sfp_bus, rate_kbd); + } + phylink_pcs_poll_start(pl); } diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c index 1865e3dbdfad0..c4363500e0971 100644 --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c @@ -585,6 +585,26 @@ static void sfp_upstream_clear(struct sfp_bus *bus) bus->upstream = NULL; } +/** + * sfp_upstream_set_signal_rate() - set data signalling rate + * @bus: a pointer to the &struct sfp_bus structure for the sfp module + * @rate_kbd: signalling rate in units of 1000 baud + * + * Configure the rate select settings on the SFP module for the signalling + * rate (not the same as the data rate). + * + * Locks that may be held: + * Phylink's state_mutex + * rtnl lock + * SFP's sm_mutex + */ +void sfp_upstream_set_signal_rate(struct sfp_bus *bus, unsigned int rate_kbd) +{ + if (bus->registered) + bus->socket_ops->set_signal_rate(bus->sfp, rate_kbd); +} +EXPORT_SYMBOL_GPL(sfp_upstream_set_signal_rate); + /** * sfp_bus_find_fwnode() - parse and locate the SFP bus from fwnode * @fwnode: firmware node for the parent device (MAC or PHY) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 907d4005a1cf5..7f1d751b87b35 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -2472,6 +2472,10 @@ static void sfp_stop(struct sfp *sfp) sfp_sm_event(sfp, SFP_E_DEV_DOWN); } +static void sfp_set_signal_rate(struct sfp *sfp, unsigned int rate_kbd) +{ +} + static int sfp_module_info(struct sfp *sfp, struct ethtool_modinfo *modinfo) { /* locking... and check module is present */ @@ -2550,6 +2554,7 @@ static const struct sfp_socket_ops sfp_module_ops = { .detach = sfp_detach, .start = sfp_start, .stop = sfp_stop, + .set_signal_rate = sfp_set_signal_rate, .module_info = sfp_module_info, .module_eeprom = sfp_module_eeprom, .module_eeprom_by_page = sfp_module_eeprom_by_page, diff --git a/drivers/net/phy/sfp.h b/drivers/net/phy/sfp.h index 6cf1643214d3e..c7cb50d100999 100644 --- a/drivers/net/phy/sfp.h +++ b/drivers/net/phy/sfp.h @@ -19,6 +19,7 @@ struct sfp_socket_ops { void (*detach)(struct sfp *sfp); void (*start)(struct sfp *sfp); void (*stop)(struct sfp *sfp); + void (*set_signal_rate)(struct sfp *sfp, unsigned int rate_kbd); int (*module_info)(struct sfp *sfp, struct ethtool_modinfo *modinfo); int (*module_eeprom)(struct sfp *sfp, struct ethtool_eeprom *ee, u8 *data); diff --git a/include/linux/sfp.h b/include/linux/sfp.h index d1f343853b6c7..a5179be7f7df5 100644 --- a/include/linux/sfp.h +++ b/include/linux/sfp.h @@ -547,6 +547,7 @@ int sfp_get_module_eeprom_by_page(struct sfp_bus *bus, struct netlink_ext_ack *extack); void sfp_upstream_start(struct sfp_bus *bus); void sfp_upstream_stop(struct sfp_bus *bus); +void sfp_upstream_set_signal_rate(struct sfp_bus *bus, unsigned int rate_kbd); void sfp_bus_put(struct sfp_bus *bus); struct sfp_bus *sfp_bus_find_fwnode(struct fwnode_handle *fwnode); int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, @@ -606,6 +607,11 @@ static inline void sfp_upstream_stop(struct sfp_bus *bus) { } +static inline void sfp_upstream_set_signal_rate(struct sfp_bus *bus, + unsigned int rate_kbd) +{ +} + static inline void sfp_bus_put(struct sfp_bus *bus) { } -- 2.53.0