git: 15ef9ad2f5f4 - stable/14 - ice(4): Fix link speed after changing cable type

From: Krzysztof Galazka <kgalazka_at_FreeBSD.org>
Date: Fri, 10 Jul 2026 19:15:52 UTC
The branch stable/14 has been updated by kgalazka:

URL: https://cgit.FreeBSD.org/src/commit/?id=15ef9ad2f5f46c4172121f22ba9d051c08365814

commit 15ef9ad2f5f46c4172121f22ba9d051c08365814
Author:     Krzysztof Galazka <kgalazka@FreeBSD.org>
AuthorDate: 2026-06-12 11:56:15 +0000
Commit:     Krzysztof Galazka <kgalazka@FreeBSD.org>
CommitDate: 2026-07-10 19:15:18 +0000

    ice(4): Fix link speed after changing cable type
    
    When interface was connected to a link partner with a cable
    type limitting maximum supported speed, e.g. SFP+ cable
    in 25G port, driver incorrectly saved a supported speed
    as the user configured speed. This prevented interface
    from using all supported speeds after switching cable to SFP28.
    Link was established at 10G as supported by previously used
    SFP+ cable. Don't set user requested speed unless actually
    configured by an user, to allow automatic selection of highest
    available speed. Only when user sets custom config
    using advertise_speed sysctl save it and try
    to apply after cable is changed.
    
    Also don't save initial supported speeds if FW supports
    reporting default PHY config.
    
    Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
    
    Reviewed by:    kbowling, erj, mateusz.moga_intel.com
    Sponsored by:   Intel Corporation
    Differential Revision:  https://reviews.freebsd.org/D53611
    
    (cherry picked from commit 310145642312e1c5fb3d8efa8321cf905d0354c4)
---
 sys/dev/ice/ice_lib.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/sys/dev/ice/ice_lib.c b/sys/dev/ice/ice_lib.c
index fd7189130c25..54267d25941e 100644
--- a/sys/dev/ice/ice_lib.c
+++ b/sys/dev/ice/ice_lib.c
@@ -9652,8 +9652,7 @@ ice_apply_saved_phy_req_to_cfg(struct ice_softc *sc,
 
 finalize_link_speed:
 
-	/* Cache new user settings for speeds */
-	pi->phy.curr_user_speed_req = phy_data.user_speeds_intr;
+	/* Update phy types in config */
 	cfg->phy_type_low = htole64(phy_low);
 	cfg->phy_type_high = htole64(phy_high);
 
@@ -9959,16 +9958,21 @@ ice_init_saved_phy_cfg(struct ice_softc *sc)
 	device_t dev = sc->dev;
 	int status;
 	u64 phy_low, phy_high;
-	u8 report_mode = ICE_AQC_REPORT_TOPO_CAP_MEDIA;
 
+	/*
+	 * If the FW supports Link Management V2 we don't need
+	 * to save initial PHY configuration as it can be always
+	 * read from FW.
+	 */
 	if (ice_is_bit_set(sc->feat_en, ICE_FEATURE_LINK_MGMT_VER_2))
-		report_mode = ICE_AQC_REPORT_DFLT_CFG;
-	status = ice_aq_get_phy_caps(pi, false, report_mode, &pcaps, NULL);
+		return;
+
+	status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_TOPO_CAP_MEDIA,
+	    &pcaps, NULL);
 	if (status) {
 		device_printf(dev,
-		    "%s: ice_aq_get_phy_caps (%s) failed; status %s, aq_err %s\n",
+		    "%s: ice_aq_get_phy_caps failed; status %s, aq_err %s\n",
 		    __func__,
-		    report_mode == ICE_AQC_REPORT_DFLT_CFG ? "DFLT" : "w/MEDIA",
 		    ice_status_str(status),
 		    ice_aq_str(hw->adminq.sq_last_status));
 		return;