Patch "net: phylink: Update SFP selected interface on advertising changes" has been added to the 5.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: phylink: Update SFP selected interface on advertising changes

to the 5.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-phylink-update-sfp-selected-interface-on-adverti.patch
and it can be found in the queue-5.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 163a52593772e305436711522d5fa513bfaaf7f5
Author: Nathan Rossi <nathan.rossi@xxxxxxxx>
Date:   Thu Sep 2 05:14:49 2021 +0000

    net: phylink: Update SFP selected interface on advertising changes
    
    [ Upstream commit ea269a6f720782ed94171fb962b14ce07c372138 ]
    
    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.
    Additionally when a module is inserted the advertising mode is reset to
    match the supported modes of the module.
    
    Signed-off-by: Nathan Rossi <nathan.rossi@xxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 42e5a681183f..0d3d9c3ee83c 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1604,6 +1604,32 @@ 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;
+		}
+
+		/* Revalidate with the selected interface */
+		linkmode_copy(support, pl->supported);
+		if (phylink_validate(pl, support, &config)) {
+			phylink_err(pl, "validation of %s/%s with support %*pb failed\n",
+				    phylink_an_mode_str(pl->cur_link_an_mode),
+				    phy_modes(config.interface),
+				    __ETHTOOL_LINK_MODE_MASK_NBITS, support);
+			return -EINVAL;
+		}
+	}
+
 	mutex_lock(&pl->state_mutex);
 	pl->link_config.speed = config.speed;
 	pl->link_config.duplex = config.duplex;
@@ -2183,7 +2209,9 @@ static int phylink_sfp_config(struct phylink *pl, u8 mode,
 	if (phy_interface_mode_is_8023z(iface) && pl->phydev)
 		return -EINVAL;
 
-	changed = !linkmode_equal(pl->supported, support);
+	changed = !linkmode_equal(pl->supported, support) ||
+		  !linkmode_equal(pl->link_config.advertising,
+				  config.advertising);
 	if (changed) {
 		linkmode_copy(pl->supported, support);
 		linkmode_copy(pl->link_config.advertising, config.advertising);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux