git: 33be59b660be - main - ice: Use the mirror interface softc in PF callbacks

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Fri, 11 Sep 2026 21:07:54 UTC
The branch main has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=33be59b660befb13cdcc38e52b1c9b4119a6a069

commit 33be59b660befb13cdcc38e52b1c9b4119a6a069
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-09-07 13:43:20 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-09-11 20:58:35 +0000

    ice: Use the mirror interface softc in PF callbacks
    
    PF iflib callbacks receive struct ice_softc, not struct ice_mirr_if.
    Resolve the mirror interface through sc->mirr_if before checking or
    resetting subinterface state.
    
    Use the same mirror softc when rebuilding its VSI.  This records the
    required subinterface reset in the state consumed by the PF callback,
    rather than overlaying the PF softc and leaving rebuilt queues stopped.
    
    MFC after:      2 weeks
    Sponsored by:   BBOX.io
---
 sys/dev/ice/if_ice_iflib.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/sys/dev/ice/if_ice_iflib.c b/sys/dev/ice/if_ice_iflib.c
index 2214be71f4de..41c34bcfc1e4 100644
--- a/sys/dev/ice/if_ice_iflib.c
+++ b/sys/dev/ice/if_ice_iflib.c
@@ -2069,12 +2069,13 @@ ice_update_rx_mbuf_sz(struct ice_softc *sc)
 static void
 ice_if_init(if_ctx_t ctx)
 {
-	struct ice_mirr_if *mif = (struct ice_mirr_if *)iflib_get_softc(ctx);
+	struct ice_mirr_if *mif;
 	struct ice_softc *sc = (struct ice_softc *)iflib_get_softc(ctx);
 	device_t dev = sc->dev;
 	int err;
 
 	ASSERT_CTX_LOCKED(sc);
+	mif = sc->mirr_if;
 
 	/*
 	 * We've seen an issue with 11.3/12.1 where sideband routines are
@@ -2163,10 +2164,11 @@ ice_if_init(if_ctx_t ctx)
 
 	ice_set_state(&sc->state, ICE_STATE_DRIVER_INITIALIZED);
 
-	if (sc->mirr_if && ice_testandclear_state(&mif->state, ICE_STATE_SUBIF_NEEDS_REINIT)) {
+	if (mif != NULL && ice_testandclear_state(&mif->state,
+	    ICE_STATE_SUBIF_NEEDS_REINIT)) {
 		ice_clear_state(&mif->state, ICE_STATE_DRIVER_INITIALIZED);
-		iflib_request_reset(sc->mirr_if->subctx);
-		iflib_admin_intr_deferred(sc->mirr_if->subctx);
+		iflib_request_reset(mif->subctx);
+		iflib_admin_intr_deferred(mif->subctx);
 	}
 
 	return;
@@ -3144,10 +3146,11 @@ ice_if_vlan_unregister(if_ctx_t ctx, u16 vtag)
 static void
 ice_if_stop(if_ctx_t ctx)
 {
-	struct ice_mirr_if *mif = (struct ice_mirr_if *)iflib_get_softc(ctx);
+	struct ice_mirr_if *mif;
 	struct ice_softc *sc = (struct ice_softc *)iflib_get_softc(ctx);
 
 	ASSERT_CTX_LOCKED(sc);
+	mif = sc->mirr_if;
 	ice_led_restore(sc);
 
 	/*
@@ -3196,8 +3199,9 @@ ice_if_stop(if_ctx_t ctx)
 		 !(if_getflags(sc->ifp) & IFF_UP) && sc->link_up)
 		ice_set_link(sc, false);
 
-	if (sc->mirr_if && ice_test_state(&mif->state, ICE_STATE_SUBIF_NEEDS_REINIT)) {
-		ice_subif_if_stop(sc->mirr_if->subctx);
+	if (mif != NULL && ice_test_state(&mif->state,
+	    ICE_STATE_SUBIF_NEEDS_REINIT)) {
+		ice_subif_if_stop(mif->subctx);
 		device_printf(sc->dev, "The subinterface also comes down and up after reset\n");
 	}
 }
@@ -4038,7 +4042,7 @@ fail:
 static int
 ice_subif_rebuild(struct ice_softc *sc)
 {
-	struct ice_mirr_if *mif = (struct ice_mirr_if *)iflib_get_softc(sc->ctx);
+	struct ice_mirr_if *mif = sc->mirr_if;
 	struct ice_vsi *vsi = sc->mirr_if->vsi;
 	int err;