git: dfe2ff8fd33f - stable/15 - aq: Report partial initialization failures to iflib

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Mon, 12 Oct 2026 15:28:56 UTC
The branch stable/15 has been updated by emaste:

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

commit dfe2ff8fd33f0c8d7af9319d8bea11de2e3c92db
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-09-07 11:50:58 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2026-10-12 15:27:45 +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
    
    (cherry picked from commit 050683bb8e136981e4a1f66e845ab05c135630f4)
---
 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 edca88f34bba..04ce3a055aa0 100644
--- a/sys/dev/aq/aq_main.c
+++ b/sys/dev/aq/aq_main.c
@@ -775,9 +775,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;
@@ -800,11 +798,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++) {
@@ -814,19 +814,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)
@@ -855,6 +859,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);
 }