git: 2b6479e5b5c7 - stable/15 - ice(4): Fix link bringup on driver load

From: Krzysztof Galazka <kgalazka_at_FreeBSD.org>
Date: Fri, 23 Oct 2026 18:15:42 UTC
The branch stable/15 has been updated by kgalazka:

URL: https://cgit.FreeBSD.org/src/commit/?id=2b6479e5b5c7a3fec63ec995c952d5d8387481bf

commit 2b6479e5b5c7a3fec63ec995c952d5d8387481bf
Author:     Krzysztof Galazka <kgalazka@FreeBSD.org>
AuthorDate: 2026-09-28 11:47:43 +0000
Commit:     Krzysztof Galazka <kgalazka@FreeBSD.org>
CommitDate: 2026-10-23 18:15:07 +0000

    ice(4): Fix link bringup on driver load
    
    Patch adding Total Port Shutdown support incorrectly
    handled a case when this feature was not enabled in the NVM.
    When TPS bit is not set driver should apply link configuration
    according to user settings and update the status. Those steps
    were mistakenly omitted, while the state flag was still set
    to prevent link renegotation and status update on first
    attempt to bring interface up with ifconfig.
    
    Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
    
    Reported by:    kbowling
    Reviewed by:    kbowling
    Fixes:          0011cd9f8863 ("ice(4): Support Total Port Shutdown on E830 devices")
    Sponsored by:   Intel Corporation
    Differential Revision:  https://reviews.freebsd.org/D59578
    
    (cherry picked from commit dcb84ddcfe89d358a66cffb45196e6b45b45502c)
---
 sys/dev/ice/ice_lib.c      | 26 ++++++++++++++++++++++----
 sys/dev/ice/if_ice_iflib.c |  6 ++----
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/sys/dev/ice/ice_lib.c b/sys/dev/ice/ice_lib.c
index 6fcf6772ed0e..3965196f728d 100644
--- a/sys/dev/ice/ice_lib.c
+++ b/sys/dev/ice/ice_lib.c
@@ -9552,15 +9552,33 @@ retry:
 		}
 		return;
 	}
+	ice_debug(hw, ICE_DBG_LINK,
+	    "%s IFF_UP: %d, media: %d, TPS: %d, link_active_on_if_down: %d\n",
+	    __func__,
+	    (if_getflags(sc->ifp) & IFF_UP) != 0,
+	    (pi->phy.link_info.link_info & ICE_AQ_MEDIA_AVAILABLE) != 0,
+	    ice_test_state(&sc->state, ICE_STATE_TOTAL_PORT_SHUTDOWN),
+	    ice_test_state(&sc->state, ICE_STATE_LINK_ACTIVE_ON_DOWN));
 
 	if (pi->phy.link_info.link_info & ICE_AQ_MEDIA_AVAILABLE) {
 		ice_clear_state(&sc->state, ICE_STATE_NO_MEDIA);
-		/* Apply default link settings */
-		if (!ice_test_state(&sc->state, ICE_STATE_LINK_ACTIVE_ON_DOWN)) {
+		if ((if_getflags(sc->ifp) & IFF_UP) != 0 ||
+		    ice_test_state(&sc->state, ICE_STATE_LINK_ACTIVE_ON_DOWN)) {
+			/* Apply default link settings if link was administratively
+			 * brought up or link_active_on_if_down flag is enabled */
+			ice_debug(hw, ICE_DBG_LINK,
+			    "%s: applying saved phy cfg\n",
+			    __func__);
+			ice_apply_saved_phy_cfg(sc, ICE_APPLY_LS_FEC_FC);
+		} else {
+			/* Either link_active_on_if_down is disabled or
+			 * Total Port Shutdown is enabled in NVM */
+			ice_debug(hw, ICE_DBG_LINK,
+			    "%s: bringing link down\n",
+			    __func__);
 			ice_set_link(sc, false);
 			ice_set_state(&sc->state, ICE_STATE_LINK_STATUS_REPORTED);
-		} else
-			ice_apply_saved_phy_cfg(sc, ICE_APPLY_LS_FEC_FC);
+		}
 	} else {
 		 /* Set link down, and poll for media available in timer. This prevents the
 		  * driver from receiving spurious link-related events.
diff --git a/sys/dev/ice/if_ice_iflib.c b/sys/dev/ice/if_ice_iflib.c
index 5a267671e87d..d72bce8b5468 100644
--- a/sys/dev/ice/if_ice_iflib.c
+++ b/sys/dev/ice/if_ice_iflib.c
@@ -3465,10 +3465,8 @@ ice_init_link(struct ice_softc *sc)
 	} else {
 		ice_clear_state(&sc->state, ICE_STATE_PHY_FW_INIT_PENDING);
 
-		if (ice_is_e830(hw)) {
-			if (!(sc->ldo_tlv.options & ICE_LINK_OVERRIDE_PORT_DIS))
-				return;
-
+		if (ice_is_e830(hw) &&
+		    (sc->ldo_tlv.options & ICE_LINK_OVERRIDE_PORT_DIS) != 0) {
 			ice_set_state(&sc->state, ICE_STATE_TOTAL_PORT_SHUTDOWN);
 			ice_clear_state(&sc->state, ICE_STATE_LINK_ACTIVE_ON_DOWN);
 		}