netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: phylink: Update SFP selected interface on advertising changes
@ 2021-08-26  7:12 Nathan Rossi
  2021-08-26  9:25 ` Russell King (Oracle)
  2021-09-02  5:14 ` [PATCH v2] " Nathan Rossi
  0 siblings, 2 replies; 4+ messages in thread
From: Nathan Rossi @ 2021-08-26  7:12 UTC (permalink / raw)
  To: netdev
  Cc: Nathan Rossi, Nathan Rossi, Russell King, Andrew Lunn,
	Heiner Kallweit, David S. Miller, Jakub Kicinski

From: Nathan Rossi <nathan.rossi@digi.com>

Currently changes to the advertising state via ethtool do not cause any
reselection of the configured interface mode after the SFP is already
inserted and initially configured.

While it is not typical to change the advertised link modes for an
interface using an SFP in certain use cases it is desirable. In the case
of a SFP port that is capable of handling both SFP and SFP+ modules it
will automatically select between 1G and 10G modes depending on the
supported mode of the SFP. However if the SFP module is capable of
working in multiple modes (e.g. a SFP+ DAC that can operate at 1G or
10G), one end of the cable may be attached to a SFP 1000base-x port thus
the SFP+ end must be manually configured to the 1000base-x mode in order
for the link to be established.

This change causes the ethtool setting of advertised mode changes to
reselect the interface mode so that the link can be established.

Signed-off-by: Nathan Rossi <nathan.rossi@digi.com>
---
 drivers/net/phy/phylink.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 2cdf9f989d..8986c7a0c5 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1525,6 +1525,22 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
 	if (config.an_enabled && phylink_is_empty_linkmode(config.advertising))
 		return -EINVAL;
 
+	/* If this link is with an SFP, ensure that changes to advertised modes
+	 * also cause the associated interface to be selected such that the
+	 * link can be configured correctly.
+	 */
+	if (pl->sfp_port && pl->sfp_bus) {
+		config.interface = sfp_select_interface(pl->sfp_bus,
+							config.advertising);
+		if (config.interface == PHY_INTERFACE_MODE_NA) {
+			phylink_err(pl,
+				    "selection of interface failed, advertisement %*pb\n",
+				    __ETHTOOL_LINK_MODE_MASK_NBITS,
+				    config.advertising);
+			return -EINVAL;
+		}
+	}
+
 	mutex_lock(&pl->state_mutex);
 	pl->link_config.speed = config.speed;
 	pl->link_config.duplex = config.duplex;
---
2.33.0

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

end of thread, other threads:[~2021-09-02  5:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-26  7:12 [PATCH] net: phylink: Update SFP selected interface on advertising changes Nathan Rossi
2021-08-26  9:25 ` Russell King (Oracle)
2021-08-27  2:11   ` Nathan Rossi
2021-09-02  5:14 ` [PATCH v2] " Nathan Rossi

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).