git: 050683bb8e13 - main - aq: Report partial initialization failures to iflib

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Fri, 25 Sep 2026 05:13:12 UTC
The branch main has been updated by kbowling:

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

commit 050683bb8e136981e4a1f66e845ab05c135630f4
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-09-07 11:50:58 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-09-25 05:12:32 +0000

    aq: Report partial initialization failures to iflib
    
    Stop initialization when hardware setup, ring initialization/start, or
    datapath start fails. Run the existing best-effort stop/cache/reset
    cleanup and report the failure through iflib_init_failed(). Do not keep
    configuring later rings or publish the interface as running.
    
    Reviewed by:    nprice
    MFC after:      2 weeks
    Sponsored by:   BBOX.io
    Differential Revision:  https://reviews.freebsd.org/D59853
---
 sys/dev/aq/aq_main.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/sys/dev/aq/aq_main.c b/sys/dev/aq/aq_main.c
index 5aa162e096b0..c6396d6d9699 100644
--- a/sys/dev/aq/aq_main.c
+++ b/sys/dev/aq/aq_main.c
@@ -770,9 +770,7 @@ aq_if_init(if_ctx_t ctx)
 	    softc->scctx->isc_intr == IFLIB_INTR_MSIX);
 	if (err != 0) {
 		device_printf(softc->dev, "aq_hw_init: %d\n", err);
-		softc->init_failed = true;
-		AQ_DBG_EXIT(err);
-		return;
+		goto fail;
 	}
 	softc->init_failed = false;
 	softc->init_retries = 0;
@@ -787,11 +785,13 @@ aq_if_init(if_ctx_t ctx)
 		if (err) {
 			device_printf(softc->dev,
 			    "aq_ring_tx_init: %d\n", err);
+			goto fail;
 		}
 		err = aq_ring_tx_start(hw, ring);
 		if (err != 0) {
 			device_printf(softc->dev,
 			    "aq_ring_tx_start: %d\n", err);
+			goto fail;
 		}
 	}
 	for (i = 0; i < softc->rx_rings_count; i++) {
@@ -801,19 +801,23 @@ aq_if_init(if_ctx_t ctx)
 		if (err) {
 			device_printf(softc->dev,
 			    "aq_ring_rx_init: %d\n", err);
+			goto fail;
 		}
 		err = aq_ring_rx_start(hw, ring);
 		if (err != 0) {
 			device_printf(softc->dev,
 			    "aq_ring_rx_start: %d\n", err);
+			goto fail;
 		}
 		aq_if_rx_queue_intr_enable(ctx, i);
 	}
 
 	err = aq_hw_start(hw);
-	if (err != 0)
+	if (err != 0) {
 		device_printf(softc->dev, "could not start the datapath: %d\n",
 		    err);
+		goto fail;
+	}
 	aq_if_enable_intr(ctx);
 	err = aq_hw_rss_hash_set(&softc->hw, softc->rss_key);
 	if (err != 0)
@@ -842,6 +846,13 @@ aq_if_init(if_ctx_t ctx)
 		device_printf(softc->dev, "could not restore promiscuous mode\n");
 
 	AQ_DBG_EXIT(0);
+	return;
+
+fail:
+	aq_if_stop(ctx);
+	softc->init_failed = true;
+	iflib_init_failed(ctx);
+	AQ_DBG_EXIT(err);
 }