git: f008b582c9f1 - main - ixl: Report PF initialization failures to iflib

Kevin Bowling <[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 kbowling:

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

commit f008b582c9f1e1a636e88a5f330ff3a167094440
Author:     Kevin Bowling <[email protected]>
AuthorDate: 2026-08-10 03:41:08 +0000
Commit:     Kevin Bowling <[email protected]>
CommitDate: 2026-08-10 10:03:43 +0000

    ixl: Report PF initialization failures to iflib
    
    ixl_if_init() returned early after AdminQ reconstruction, LAA, or
    VSI initialization failures.  Since IFDI_INIT has no return value,
    iflib then marked the interface RUNNING and enabled its interrupts
    and timers despite the incomplete hardware state.
    
    Use iflib_init_failed() on each incomplete path.  Also stop at the
    first ring-enable error and tear down any partially enabled rings
    before reporting failure.  This keeps the interface stopped and
    makes a later initialization attempt start from a bounded state.
    
    MFC after:      2 weeks
---
 sys/dev/ixl/if_ixl.c       | 29 ++++++++++++++++++++---------
 sys/dev/ixl/ixl_pf_iflib.c | 14 ++++++++++----
 2 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/sys/dev/ixl/if_ixl.c b/sys/dev/ixl/if_ixl.c
index 0c95838ce3ed..b7234cf89bef 100644
--- a/sys/dev/ixl/if_ixl.c
+++ b/sys/dev/ixl/if_ixl.c
@@ -961,7 +961,7 @@ ixl_if_init(if_ctx_t ctx)
 	int		ret;
 
 	if (IXL_PF_IN_RECOVERY_MODE(pf))
-		return;
+		goto fail;
 	/*
 	 * If the aq is dead here, it probably means something outside of the driver
 	 * did something to the adapter, like a PF reset.
@@ -969,23 +969,25 @@ ixl_if_init(if_ctx_t ctx)
 	 */
 	if (!i40e_check_asq_alive(&pf->hw)) {
 		device_printf(dev, "Admin Queue is down; resetting...\n");
-		ixl_teardown_hw_structs(pf);
-		ixl_rebuild_hw_structs_after_reset(pf, false);
+		(void)ixl_teardown_hw_structs(pf);
+		ret = ixl_rebuild_hw_structs_after_reset(pf, false);
+		if (ret != 0)
+			goto fail;
 	}
 
 	/* Get the latest mac address... User might use a LAA */
 	bcopy(if_getlladdr(vsi->ifp), tmpaddr, ETH_ALEN);
 	if (!ixl_ether_is_equal(hw->mac.addr, tmpaddr) &&
 	    (i40e_validate_mac_addr(tmpaddr) == I40E_SUCCESS)) {
-		ixl_del_all_vlan_filters(vsi, hw->mac.addr);
-		bcopy(tmpaddr, hw->mac.addr, ETH_ALEN);
 		ret = i40e_aq_mac_address_write(hw,
 		    I40E_AQC_WRITE_TYPE_LAA_ONLY,
-		    hw->mac.addr, NULL);
+		    tmpaddr, NULL);
 		if (ret) {
 			device_printf(dev, "LLA address change failed!!\n");
-			return;
+			goto fail;
 		}
+		ixl_del_all_vlan_filters(vsi, hw->mac.addr);
+		bcopy(tmpaddr, hw->mac.addr, ETH_ALEN);
 		/*
 		 * New filters are configured by ixl_reconfigure_filters
 		 * at the end of ixl_init_locked.
@@ -997,7 +999,7 @@ ixl_if_init(if_ctx_t ctx)
 	/* Prepare the VSI: rings, hmc contexts, etc... */
 	if (ixl_initialize_vsi(vsi)) {
 		device_printf(dev, "initialize vsi failed!!\n");
-		return;
+		goto fail;
 	}
 
 	ixl_set_link(pf, true);
@@ -1020,7 +1022,12 @@ ixl_if_init(if_ctx_t ctx)
 	else
 		ixl_init_tx_rsqs(vsi);
 
-	ixl_enable_rings(vsi);
+	ret = ixl_enable_rings(vsi);
+	if (ret != 0) {
+		device_printf(dev, "enable rings failed: %d\n", ret);
+		ixl_disable_rings(pf, vsi, &pf->qtag);
+		goto fail;
+	}
 
 	i40e_aq_set_default_vsi(hw, vsi->seid, NULL);
 
@@ -1038,6 +1045,10 @@ ixl_if_init(if_ctx_t ctx)
 			    "initialize iwarp failed, code %d\n", ret);
 	}
 #endif
+	return;
+
+fail:
+	iflib_init_failed(ctx);
 }
 
 void
diff --git a/sys/dev/ixl/ixl_pf_iflib.c b/sys/dev/ixl/ixl_pf_iflib.c
index 8289cc72bc64..1f48519344f7 100644
--- a/sys/dev/ixl/ixl_pf_iflib.c
+++ b/sys/dev/ixl/ixl_pf_iflib.c
@@ -875,15 +875,21 @@ int
 ixl_enable_rings(struct ixl_vsi *vsi)
 {
 	struct ixl_pf	*pf = vsi->back;
-	int		error = 0;
+	int		error;
 
-	for (int i = 0; i < vsi->num_tx_queues; i++)
+	for (int i = 0; i < vsi->num_tx_queues; i++) {
 		error = ixl_enable_tx_ring(pf, &pf->qtag, i);
+		if (error != 0)
+			return (error);
+	}
 
-	for (int i = 0; i < vsi->num_rx_queues; i++)
+	for (int i = 0; i < vsi->num_rx_queues; i++) {
 		error = ixl_enable_rx_ring(pf, &pf->qtag, i);
+		if (error != 0)
+			return (error);
+	}
 
-	return (error);
+	return (0);
 }
 
 int
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.