[PATCH net-next v4 0/5] bnge: Make NQ0 persistent across open/close

From: Bhargava Marreddy

Date: Wed Nov 11 2026 - 14:04:23 EST


Hi,

This series ensures the bnge driver's Notification Queue 0 (NQ0) remains
persistent across interface close/open cycles rather than being destroyed
and recreated on each cycle.

Currently, NQ0 exists only between ndo_open() and ndo_stop(), so firmware
async events (e.g., link changes) and HWRM completions are not received
while the interface is down.

NQ0 and its MSI-X vector are now allocated at probe and retained until
remove. To conserve MSI-X vectors for Rx/Tx queues, vector 0 is shared.
NQ0's NAPI exists only between ndo_open() and ndo_stop(), like every other
NQ. While the interface is up, NQ0 runs via NAPI; while down, an
IRQ-triggered work item processes non-datapath events.

Patches 1-4: Preparatory refactoring (alloc/free helpers, logging
fallbacks, NQ iterator, irq_tbl layout). No functional
change apart from the items noted in their commit messages.
Patch 5 : Create NQ0 at probe, free it at remove, and add the worker
fallback.

irq_tbl layout after this series:
Vector 0 : NQ0 (probe to remove)
Vectors 1..A : RoCE (auxiliary driver)
Vectors A+1..N : Main L2 NQs (open/close only)

v4:
Addressed feedback from Jakub Kicinski on v3:
- NQ0's NAPI no longer outlives the open state: it is added in
ndo_open() and deleted in ndo_stop(), like every other NQ.
- While down, the NQ0 IRQ handler queues a work item for async and
HWRM events instead. The mode switches only in open/stop, so one
context consumes NQ0 at a time.
https://lore.kernel.org/all/20261022181639.1815c338@xxxxxxxxxx/

v3:
Addressed feedback from Simon Horman:
- Extracted the failure-path NULL dereference fix in bnge_alloc_core() and
submitted it as a standalone patch to 'net'.
- Dropped unnecessary defensive NULL checks (!bn->rx_ring and !bn->tx_ring)
from bnge_free_tpa_info(), bnge_free_rx_rings(), and bnge_free_tx_rings().

Addressed comments from Sashiko:
https://sashiko.dev/#/patchset/20260922052904.59237-1-bhargava.marreddy%40broadcom.com
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260922052904.59237-1-bhargava.marreddy%40broadcom.com

Other changes:
- Renamed series from "bnge: Support async events while down" to "bnge:
Make NQ0 persistent across open/close" to accurately reflect the
streamlined focus on NQ0 persistence.
- Completely reorganized and streamlined the series from 6 patches down to 5.
- Redesigned and shifted the MSI-X vector/offset mapping layout:
Vector 0 (IRQ0) : Permanently dedicated to NQ0 at probe
(no longer recreated on RoCE load/unload or open/close)
Vectors 1..A : RoCE (aux) queues
Vectors A..N : Main L2 queues
- Added a new patch introducing bnge_err()/bnge_warn()/bnge_dbg() logging
helper macros to fall back to PCI dev-level logging before netdev
registration during probe (Patch 2).
- Switched to the bnge_for_each_open_nq() loop iterator to clarify which
loops are open-only versus those that cover all NQs (Patch 3).
- Enhanced safety in bnge_napi_poll() to skip CQ notification processing
on NQ0 when completion rings are unallocated while the interface is down,
preventing invalid dereferences of cp_ring_arr (Patch 5).

v2:
https://lore.kernel.org/all/20260922052904.59237-1-bhargava.marreddy@xxxxxxxxxxxx/

Addressed comments from Sashiko
https://sashiko.dev/#/patchset/20260901191728.643212-1-bhargava.marreddy%40broadcom.com
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260901191728.643212-1-bhargava.marreddy%40broadcom.com
- Dropped patch 7/7 ("bnge: Process async events while administratively down"):
- Link events while down are unnecessary to process since bnge_open() already
queries and updates PHY settings via bnge_update_phy_setting().
- Keeps the series focused strictly on the NQ0/NAPI lifecycle refactoring.
- Corrected the order of operations in bnge_quiesce_nq0() to disable NAPI
first, synchronize IRQ, and then ring the doorbell to prevent NAPI
rescheduling race conditions.
- Added support for dynamic MSI-X vector reallocation by introducing
bnge_reinit_nq0() during interface open.
- Fixed potential NULL pointer dereferences in core ring cleanups (e.g. bn->rx_ring,
bn->tx_ring, and bn->grp_info) on allocation failure paths and failed opens.
- Fixed a resource leak in bnge_init_nic() where RX ring pair buffers
were leaked if chip initialization failed.
- Corrected the MSI-X vector demand check in bnge_resc.c to ensure
sufficient vectors are allocated for both NQ0/aux and main rings.
- Changed CPU affinity hint failure from a fatal error to a warning.
- Added robust NULL pointer and safety checks in ring allocation and
cleanup paths to prevent potential kernel crashes on allocation failures.

v1: https://lore.kernel.org/all/20260901191728.643212-1-bhargava.marreddy@xxxxxxxxxxxx/

Bhargava Marreddy (5):
bnge: factor out per-NQ alloc/free helpers
bnge: add bnge_err()/bnge_warn()/bnge_dbg() logging helpers
bnge: add bnge_for_each_open_nq() iterator
bnge: make irq_tbl layout depend on BNGE_FIRST_OPEN_NQ
bnge: create NQ0 during probe and keep it active across open/close

drivers/net/ethernet/broadcom/bnge/bnge.h | 47 ++
.../net/ethernet/broadcom/bnge/bnge_auxr.c | 4 +-
.../ethernet/broadcom/bnge/bnge_hwrm_lib.c | 8 +-
.../net/ethernet/broadcom/bnge/bnge_netdev.c | 518 +++++++++++++-----
.../net/ethernet/broadcom/bnge/bnge_netdev.h | 5 +
.../net/ethernet/broadcom/bnge/bnge_rmem.c | 10 -
.../net/ethernet/broadcom/bnge/bnge_txrx.c | 57 +-
.../net/ethernet/broadcom/bnge/bnge_txrx.h | 3 +
8 files changed, 493 insertions(+), 159 deletions(-)

--
2.47.3