git: 873a495d2643 - main - aq: support a legacy INTx interrupt

From: Nick Price <nprice_at_FreeBSD.org>
Date: Tue, 24 Nov 2026 06:02:01 UTC
The branch main has been updated by nprice:

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

commit 873a495d2643dc3e103649e9817caa00ac776df3
Author:     Nick Price <nprice@FreeBSD.org>
AuthorDate: 2026-11-24 06:01:26 +0000
Commit:     Nick Price <nprice@FreeBSD.org>
CommitDate: 2026-11-24 06:01:29 +0000

    aq: support a legacy INTx interrupt
    
    aq(4) attached only with MSI-X.  Without an MSI controller iflib falls
    back to INTx, and attach failed with EOPNOTSUPP.
    
    Accept IFLIB_INTR_LEGACY, program the controller for INTx, and add a
    legacy filter.  INTx is level-triggered and nothing auto-masks, so the
    filter masks the vector before acknowledging it; iflib unmasks it via
    IFDI_INTR_ENABLE once the queues are drained.  All causes already map
    to vector 0 in this mode.  MSI stays unsupported: iflib never selects
    it here, since these controllers advertise 32 messages.
    
    Reviewed by:    adrian
    Differential Revision:  https://reviews.freebsd.org/D60461
    Signed-off-by:  Nick Price <nprice@FreeBSD.org>
---
 sys/dev/aq/aq_device.h |  1 +
 sys/dev/aq/aq_hw.c     |  2 +-
 sys/dev/aq/aq_irq.c    | 19 +++++++++++++++++++
 sys/dev/aq/aq_main.c   |  6 +-----
 sys/dev/aq/aq_ring.c   |  2 +-
 5 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/sys/dev/aq/aq_device.h b/sys/dev/aq/aq_device.h
index 1f71a410b9f0..553c1ed9d795 100644
--- a/sys/dev/aq/aq_device.h
+++ b/sys/dev/aq/aq_device.h
@@ -160,6 +160,7 @@ int aq_update_hw_stats(struct aq_dev *aq_dev);
 void aq_initmedia(struct aq_dev *aq_dev);
 int aq_linkstat_isr(void *arg);
 int aq_isr_rx(void *arg);
+int aq_isr_legacy(void *arg);
 void aq_mediastatus_update(struct aq_dev *aq_dev, uint32_t link_speed, const struct aq_hw_fc_info *fc_neg);
 void aq_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr);
 int aq_mediachange(struct ifnet *ifp);
diff --git a/sys/dev/aq/aq_hw.c b/sys/dev/aq/aq_hw.c
index 5c926f2ed960..d9850184e2da 100644
--- a/sys/dev/aq/aq_hw.c
+++ b/sys/dev/aq/aq_hw.c
@@ -871,7 +871,7 @@ aq_hw_init(struct aq_hw *hw, uint8_t *mac_addr, uint8_t adm_irq, bool msix)
 	if (msix)
 		itr_irq_mode_set(hw, 0x6); //MSIX + multi vector
 	else
-		itr_irq_mode_set(hw, 0x5); //MSI + multi vector
+		itr_irq_mode_set(hw, 0x0); //INTx, single vector
 
 	/* Route both hardware error causes (map reg 0) to the admin vector. */
 	reg_gen_irq_map_set(hw,
diff --git a/sys/dev/aq/aq_irq.c b/sys/dev/aq/aq_irq.c
index d3c1d5043969..33ef238f2d10 100644
--- a/sys/dev/aq/aq_irq.c
+++ b/sys/dev/aq/aq_irq.c
@@ -441,6 +441,25 @@ aq_isr_rx(void *arg)
 	return (FILTER_SCHEDULE_THREAD);
 }
 
+int
+aq_isr_legacy(void *arg)
+{
+	struct aq_dev	*aq_dev = arg;
+	struct aq_hw	*hw = &aq_dev->hw;
+	uint32_t	status;
+
+	status = itr_irq_statuslsw_get(hw);
+	if (status == 0)
+		return (FILTER_STRAY);
+
+	/* INTx is level-triggered: mask until iflib re-enables. */
+	itr_irq_msk_clearlsw_set(hw, status);
+	itr_irq_status_clearlsw_set(hw, status);
+	AQ_HW_FLUSH(hw);
+	counter_u64_add(aq_dev->rx_rings[0]->stats.irq, 1);
+	return (FILTER_SCHEDULE_THREAD);
+}
+
 /**************************************************************************/
 /* interrupt service routine  (Top half)                                  */
 /**************************************************************************/
diff --git a/sys/dev/aq/aq_main.c b/sys/dev/aq/aq_main.c
index c6396d6d9699..d54ab9931f9a 100644
--- a/sys/dev/aq/aq_main.c
+++ b/sys/dev/aq/aq_main.c
@@ -485,14 +485,10 @@ aq_if_attach_post(if_ctx_t ctx)
 
 
 	switch (softc->scctx->isc_intr) {
-	case IFLIB_INTR_LEGACY:
-		rc = EOPNOTSUPP;
-		goto exit;
-	goto exit;
-		break;
 	case IFLIB_INTR_MSI:
 		rc = EOPNOTSUPP;
 		goto exit;
+	case IFLIB_INTR_LEGACY:
 	case IFLIB_INTR_MSIX:
 		break;
 	default:
diff --git a/sys/dev/aq/aq_ring.c b/sys/dev/aq/aq_ring.c
index 8fef7ae7765d..185a52bfdbb4 100644
--- a/sys/dev/aq/aq_ring.c
+++ b/sys/dev/aq/aq_ring.c
@@ -68,7 +68,7 @@ struct if_txrx aq_txrx = {
 	.ift_rxd_pkt_get = aq_isc_rxd_pkt_get,
 	.ift_rxd_refill = aq_ring_rx_refill,
 	.ift_rxd_flush = aq_isc_rxd_flush,
-	.ift_legacy_intr = NULL
+	.ift_legacy_intr = aq_isr_legacy
 };