git: 0011cd9f8863 - main - ice(4): Support Total Port Shutdown on E830 devices

Krzysztof Galazka <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src,gmane.os.freebsd.current.scm
Message-ID <[email protected]>
The branch main has been updated by kgalazka:

URL: https://cgit.FreeBSD.org/src/commit/?id=0011cd9f8863fce3743bfd9920b7924162bb6410

commit 0011cd9f8863fce3743bfd9920b7924162bb6410
Author:     Sobczyk, Pawel <[email protected]>
AuthorDate: 2026-08-20 16:35:12 +0000
Commit:     Krzysztof Galazka <[email protected]>
CommitDate: 2026-08-20 16:35:27 +0000

    ice(4): Support Total Port Shutdown on E830 devices
    
    When 'Permit Total Port Shutdown' feature in BIOS is enabled then Port
    Disable bit is set in the Link Default Override Mask TLV PFA module
    in the NVM. In this mode, the driver acts as if the link_active_on_if_down
    flag is always disabled and disallow any change to that flag.
    This feature applies for E830 and E835 NIC series.
    
    Signed-off-by: Pawel Sobczyk <[email protected]>
    
    Tested by:      Mateusz Moga <[email protected]>
    MFC after:      2 weeks
    Sponsored by:   Intel Corporation
    Differential Revision:  https://reviews.freebsd.org/D58149
---
 sys/dev/ice/ice_lib.c      | 15 ++++++++++-----
 sys/dev/ice/ice_lib.h      |  1 +
 sys/dev/ice/ice_strings.c  |  2 ++
 sys/dev/ice/if_ice_iflib.c |  9 +++++++++
 4 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/sys/dev/ice/ice_lib.c b/sys/dev/ice/ice_lib.c
index 25e189823072..b14f63de4069 100644
--- a/sys/dev/ice/ice_lib.c
+++ b/sys/dev/ice/ice_lib.c
@@ -4545,6 +4545,11 @@ ice_sysctl_set_link_active(SYSCTL_HANDLER_ARGS)
 	if ((ret) || (req->newptr == NULL))
 		return (ret);
 
+	if (ice_test_state(&sc->state, ICE_STATE_TOTAL_PORT_SHUTDOWN)) {
+		device_printf(sc->dev,
+			"Setting link_active_on_if_down not supported on this port\n");
+		return (EPERM);
+	}
 	if (mode)
 		ice_set_state(&sc->state, ICE_STATE_LINK_ACTIVE_ON_DOWN);
 	else
@@ -9872,6 +9877,11 @@ ice_set_link_management_mode(struct ice_softc *sc)
 	if (sc->hw.debug_mask & ICE_DBG_LINK)
 		ice_print_ldo_tlv(sc, &tlv);
 
+	/* Cache the LDO TLV structure in the driver, since it
+	 * won't change during the driver's lifetime.
+	 */
+	sc->ldo_tlv = tlv;
+
 	/* Set lenient link mode */
 	if (ice_is_bit_set(sc->feat_cap, ICE_FEATURE_LENIENT_LINK_MODE) &&
 	    (!(tlv.options & ICE_LINK_OVERRIDE_STRICT_MODE)))
@@ -9893,11 +9903,6 @@ ice_set_link_management_mode(struct ice_softc *sc)
 	    ice_is_bit_set(sc->feat_en, ICE_FEATURE_LENIENT_LINK_MODE) &&
 	    (tlv.options & ICE_LINK_OVERRIDE_EN))
 		ice_set_bit(ICE_FEATURE_LINK_MGMT_VER_1, sc->feat_en);
-
-	/* Cache the LDO TLV structure in the driver, since it
-	 * won't change during the driver's lifetime.
-	 */
-	sc->ldo_tlv = tlv;
 }
 
 /**
diff --git a/sys/dev/ice/ice_lib.h b/sys/dev/ice/ice_lib.h
index 640bdf8fed7b..be4cc674556b 100644
--- a/sys/dev/ice/ice_lib.h
+++ b/sys/dev/ice/ice_lib.h
@@ -712,6 +712,7 @@ enum ice_state {
 	ICE_STATE_MULTIPLE_TCS,
 	ICE_STATE_DO_FW_DEBUG_DUMP,
 	ICE_STATE_LINK_ACTIVE_ON_DOWN,
+	ICE_STATE_TOTAL_PORT_SHUTDOWN,
 	ICE_STATE_FIRST_INIT_LINK,
 	ICE_STATE_DO_CREATE_MIRR_INTFC,
 	ICE_STATE_DO_DESTROY_MIRR_INTFC,
diff --git a/sys/dev/ice/ice_strings.c b/sys/dev/ice/ice_strings.c
index 1b377a1bf518..09adf47a33f2 100644
--- a/sys/dev/ice/ice_strings.c
+++ b/sys/dev/ice/ice_strings.c
@@ -1046,6 +1046,8 @@ ice_state_to_str(enum ice_state state)
 		return "DO_FW_DEBUG_DUMP";
 	case ICE_STATE_LINK_ACTIVE_ON_DOWN:
 		return "LINK_ACTIVE_ON_DOWN";
+	case ICE_STATE_TOTAL_PORT_SHUTDOWN:
+		return "TOTAL_PORT_SHUTDOWN";
 	case ICE_STATE_FIRST_INIT_LINK:
 		return "FIRST_INIT_LINK";
 	case ICE_STATE_DO_CREATE_MIRR_INTFC:
diff --git a/sys/dev/ice/if_ice_iflib.c b/sys/dev/ice/if_ice_iflib.c
index 41324cc6779a..5a267671e87d 100644
--- a/sys/dev/ice/if_ice_iflib.c
+++ b/sys/dev/ice/if_ice_iflib.c
@@ -3464,6 +3464,15 @@ ice_init_link(struct ice_softc *sc)
 		/* Do not access PHY config while PHY FW is busy initializing */
 	} 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;
+
+			ice_set_state(&sc->state, ICE_STATE_TOTAL_PORT_SHUTDOWN);
+			ice_clear_state(&sc->state, ICE_STATE_LINK_ACTIVE_ON_DOWN);
+		}
+
 		ice_init_link_configuration(sc);
 		ice_update_link_status(sc, true);
 	}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.