* [PATCH net 0/4] eth: fbnic: miscellaneous driver fixes
@ 2026-11-16 20:29 Dimitri Daskalakis
2026-11-16 20:29 ` [PATCH net 1/4] eth: fbnic: wait on the correct queues in fbnic_queue_stop() Dimitri Daskalakis
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Dimitri Daskalakis @ 2026-11-16 20:29 UTC (permalink / raw)
To: David S. Miller
Cc: Alexander Duyck, Jakub Kicinski, kernel-team, Andrew Lunn,
Eric Dumazet, Paolo Abeni, Shuah Khan, Mohsin Bashir,
Mike Marciniszyn (Meta), Stanislav Fomichev, Bobby Eshleman,
Björn Töpel, Breno Leitao, Simon Horman, Mina Almasry,
Vadim Fedorenko, Dimitri Daskalakis, netdev, Dimitri Daskalakis
From: Dimitri Daskalakis <daskald@meta.com>
AI identified several bugs while I was working on unrelated parts of the
driver. fbnic_queue_stop() always waits on queue 0 to idle for rx queues.
fbnic_get_ts_stats() dereferences a NULL pointer when the interface is down.
And fbnic_{set|reset}_netif_napi does not account for disabled rings.
All bugs were verified on HW, and a new stats selftest was added to identify
other drivers with the same timestamp stats mishandling.
Dimitri Daskalakis (4):
eth: fbnic: wait on the correct queues in fbnic_queue_stop()
eth: fbnic: skip disabled Tx rings when setting the queue NAPI
eth: fbnic: skip freed Tx rings in fbnic_get_ts_stats()
selftests: drv-net: stats: query timestamping stats while down
.../net/ethernet/meta/fbnic/fbnic_ethtool.c | 3 +++
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 20 ++++++++++++---
tools/testing/selftests/drivers/net/stats.py | 25 ++++++++++++++++++-
3 files changed, 43 insertions(+), 5 deletions(-)
--
2.52.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 1/4] eth: fbnic: wait on the correct queues in fbnic_queue_stop()
2026-11-16 20:29 [PATCH net 0/4] eth: fbnic: miscellaneous driver fixes Dimitri Daskalakis
@ 2026-11-16 20:29 ` Dimitri Daskalakis
2026-11-16 20:29 ` [PATCH net 2/4] eth: fbnic: skip disabled Tx rings when setting the queue NAPI Dimitri Daskalakis
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Dimitri Daskalakis @ 2026-11-16 20:29 UTC (permalink / raw)
To: David S. Miller
Cc: Alexander Duyck, Jakub Kicinski, kernel-team, Andrew Lunn,
Eric Dumazet, Paolo Abeni, Shuah Khan, Mohsin Bashir,
Mike Marciniszyn (Meta), Stanislav Fomichev, Bobby Eshleman,
Björn Töpel, Breno Leitao, Simon Horman, Mina Almasry,
Vadim Fedorenko, Dimitri Daskalakis, netdev, Dimitri Daskalakis
From: Dimitri Daskalakis <daskald@meta.com>
fbnic_queue_stop() waits for every queue of the NAPI vector to go idle
before tearing it down, using sub0.q_idx as the queue index. We set
q_idx on submission queues for Tx, and completion queues on Rx, so
this waits on queue 0 for every Rx queue.
For non-combined channels, stopping an Rx queue always stops/wakes
Tx queue 0.
Set the queue id on Tx completion rings so we don't have to distinguish
between ring types to get the correct queue id, and don't stop/wake
disabled rings.
This bug was found by AI and verified on HW.
Reproduced by binding a devmem dmabuf to one Rx queue (netdev bind-rx).
Added a printk to fbnic_wait_queue_idle(), and traced Tx queue stop/wake
with bpftrace.
combined 79, bind rxq 1:
before:
netif_stop_subqueue(1)
fbnic_wait_queue_idle(tx, 1)
fbnic_wait_queue_idle(rx, 0) <- wrong rxq
netif_wake_subqueue(1)
after:
netif_stop_subqueue(1)
fbnic_wait_queue_idle(tx, 1)
fbnic_wait_queue_idle(rx, 1)
netif_wake_subqueue(1)
rx 34 tx 34, bind rxq 5:
before:
netif_stop_subqueue(0)
fbnic_wait_queue_idle(tx, 0)
fbnic_wait_queue_idle(rx, 0)
netif_wake_subqueue(0)
after:
fbnic_wait_queue_idle(tx, 39)
fbnic_wait_queue_idle(rx, 5)
^ no more stop/wake of Tx queue 0
(tx 39 is the XDP Tx queue of rxq 5's vector,
rxq's alaways get a XDP Tx queue during init)
Fixes: da43127a8edc ("eth: fbnic: support queue ops / zero-copy Rx")
Signed-off-by: Dimitri Daskalakis <daskald@meta.com>
---
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
index 07d4b2e92362..5efed21e5932 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
@@ -1772,7 +1772,7 @@ static int fbnic_alloc_napi_vector(struct fbnic_dev *fbd, struct fbnic_net *fbn,
/* Configure Tx completion queue */
db = &uc_addr[FBNIC_QUEUE(txq_idx) + FBNIC_QUEUE_TCQ_HEAD];
- fbnic_ring_init(&qt->cmpl, db, 0, 0);
+ fbnic_ring_init(&qt->cmpl, db, txq_idx, 0);
/* Update Tx queue index */
txt_count--;
@@ -3047,8 +3047,11 @@ static void __fbnic_nv_restart(struct fbnic_net *fbn,
fbnic_wr32(fbd, FBNIC_INTR_SET(nv->v_idx / 32), BIT(nv->v_idx % 32));
fbnic_wrfl(fbd);
- for (i = 0; i < nv->txt_count; i++)
+ for (i = 0; i < nv->txt_count; i++) {
+ if (nv->qt[i].sub0.flags & FBNIC_RING_F_DISABLED)
+ continue;
netif_wake_subqueue(fbn->netdev, nv->qt[i].sub0.q_idx);
+ }
fbnic_dbg_nv_init(nv);
}
@@ -3089,13 +3092,16 @@ static int fbnic_queue_stop(struct net_device *dev, void *qmem, int idx)
napi_disable_locked(&nv->napi);
fbnic_nv_irq_disable(nv);
- for (i = 0; i < nv->txt_count; i++)
+ for (i = 0; i < nv->txt_count; i++) {
+ if (nv->qt[i].sub0.flags & FBNIC_RING_F_DISABLED)
+ continue;
netif_stop_subqueue(dev, nv->qt[i].sub0.q_idx);
+ }
fbnic_nv_disable(fbn, nv);
for (t = 0; t < nv->txt_count + nv->rxt_count; t++) {
err = fbnic_wait_queue_idle(fbn, t >= nv->txt_count,
- nv->qt[t].sub0.q_idx);
+ nv->qt[t].cmpl.q_idx);
if (err)
goto err_restart;
}
--
2.52.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 2/4] eth: fbnic: skip disabled Tx rings when setting the queue NAPI
2026-11-16 20:29 [PATCH net 0/4] eth: fbnic: miscellaneous driver fixes Dimitri Daskalakis
2026-11-16 20:29 ` [PATCH net 1/4] eth: fbnic: wait on the correct queues in fbnic_queue_stop() Dimitri Daskalakis
@ 2026-11-16 20:29 ` Dimitri Daskalakis
2026-11-16 20:29 ` [PATCH net 3/4] eth: fbnic: skip freed Tx rings in fbnic_get_ts_stats() Dimitri Daskalakis
2026-11-16 20:29 ` [PATCH net 4/4] selftests: drv-net: stats: query timestamping stats while down Dimitri Daskalakis
3 siblings, 0 replies; 5+ messages in thread
From: Dimitri Daskalakis @ 2026-11-16 20:29 UTC (permalink / raw)
To: David S. Miller
Cc: Alexander Duyck, Jakub Kicinski, kernel-team, Andrew Lunn,
Eric Dumazet, Paolo Abeni, Shuah Khan, Mohsin Bashir,
Mike Marciniszyn (Meta), Stanislav Fomichev, Bobby Eshleman,
Björn Töpel, Breno Leitao, Simon Horman, Mina Almasry,
Vadim Fedorenko, Dimitri Daskalakis, netdev, Dimitri Daskalakis
From: Dimitri Daskalakis <daskald@meta.com>
When Rx and Tx channels are not combined, each Rx vector gets a Tx
triad whose sub0 is disabled with a q_idx of 0. fbnic_set_netif_napi()
and fbnic_reset_netif_napi() don't skip it, so every Rx vector
associates Tx queue 0 with its own NAPI, and the netlink queue info
reports the wrong NAPI for Tx queue 0.
This bug was found by AI and verified on HW.
Reproduced with "ethtool -L eth0 combined 0 rx 34 tx 34", and reading
the NAPI IDs with "ynl --family netdev --dump queue-get":
before: tx 0 napi-id 580, tx 1 napi-id 514, rx 33 napi-id 580
^^^ rx 33's NAPI, not vector 0's
after: tx 0 napi-id 513, tx 1 napi-id 514, rx 33 napi-id 580
Fixes: cf4facfb132a ("eth: fbnic: Add support for XDP queues")
Signed-off-by: Dimitri Daskalakis <daskald@meta.com>
---
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
index 5efed21e5932..89e7b806363b 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
@@ -2184,6 +2184,9 @@ static void fbnic_set_netif_napi(struct fbnic_napi_vector *nv)
for (i = 0; i < nv->txt_count; i++) {
struct fbnic_q_triad *qt = &nv->qt[i];
+ if (qt->sub0.flags & FBNIC_RING_F_DISABLED)
+ continue;
+
netif_queue_set_napi(nv->napi.dev, qt->sub0.q_idx,
NETDEV_QUEUE_TYPE_TX, &nv->napi);
}
@@ -2205,6 +2208,9 @@ static void fbnic_reset_netif_napi(struct fbnic_napi_vector *nv)
for (i = 0; i < nv->txt_count; i++) {
struct fbnic_q_triad *qt = &nv->qt[i];
+ if (qt->sub0.flags & FBNIC_RING_F_DISABLED)
+ continue;
+
netif_queue_set_napi(nv->napi.dev, qt->sub0.q_idx,
NETDEV_QUEUE_TYPE_TX, NULL);
}
--
2.52.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 3/4] eth: fbnic: skip freed Tx rings in fbnic_get_ts_stats()
2026-11-16 20:29 [PATCH net 0/4] eth: fbnic: miscellaneous driver fixes Dimitri Daskalakis
2026-11-16 20:29 ` [PATCH net 1/4] eth: fbnic: wait on the correct queues in fbnic_queue_stop() Dimitri Daskalakis
2026-11-16 20:29 ` [PATCH net 2/4] eth: fbnic: skip disabled Tx rings when setting the queue NAPI Dimitri Daskalakis
@ 2026-11-16 20:29 ` Dimitri Daskalakis
2026-11-16 20:29 ` [PATCH net 4/4] selftests: drv-net: stats: query timestamping stats while down Dimitri Daskalakis
3 siblings, 0 replies; 5+ messages in thread
From: Dimitri Daskalakis @ 2026-11-16 20:29 UTC (permalink / raw)
To: David S. Miller
Cc: Alexander Duyck, Jakub Kicinski, kernel-team, Andrew Lunn,
Eric Dumazet, Paolo Abeni, Shuah Khan, Mohsin Bashir,
Mike Marciniszyn (Meta), Stanislav Fomichev, Bobby Eshleman,
Björn Töpel, Breno Leitao, Simon Horman, Mina Almasry,
Vadim Fedorenko, Dimitri Daskalakis, netdev, Dimitri Daskalakis
From: Dimitri Daskalakis <daskald@meta.com>
fbnic_stop() frees the NAPI vectors, which clears fbn->tx[] while
num_tx_queues is left unchanged. fbnic_get_ts_stats() walks fbn->tx[]
without checking for NULL, so asking for timestamping statistics while
the interface is down dereferences a NULL ring.
This was found by AI and reproduced on HW.
# ip link set dev eth0 down; ethtool -I -T eth0
BUG: kernel NULL pointer dereference, address: 0000000000000050
RIP: 0010:fbnic_get_ts_stats+0x38/0x60
Call Trace:
tsinfo_prepare_data+0x82/0xb0
ethnl_default_doit+0x213/0x470
genl_family_rcv_msg_doit+0xdd/0x110
...
Fixes: 96f358f75d1a ("eth: fbnic: add ethtool timestamping statistics")
Signed-off-by: Dimitri Daskalakis <daskald@meta.com>
---
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
index e774740fcb5d..0cd03cbf2713 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
@@ -1740,6 +1740,9 @@ static void fbnic_get_ts_stats(struct net_device *netdev,
ts_stats->lost = fbn->tx_stats.twq.ts_lost;
for (i = 0; i < fbn->num_tx_queues; i++) {
ring = fbn->tx[i];
+ if (!ring)
+ continue;
+
do {
start = u64_stats_fetch_begin(&ring->stats.syncp);
ts_packets = ring->stats.twq.ts_packets;
--
2.52.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 4/4] selftests: drv-net: stats: query timestamping stats while down
2026-11-16 20:29 [PATCH net 0/4] eth: fbnic: miscellaneous driver fixes Dimitri Daskalakis
` (2 preceding siblings ...)
2026-11-16 20:29 ` [PATCH net 3/4] eth: fbnic: skip freed Tx rings in fbnic_get_ts_stats() Dimitri Daskalakis
@ 2026-11-16 20:29 ` Dimitri Daskalakis
3 siblings, 0 replies; 5+ messages in thread
From: Dimitri Daskalakis @ 2026-11-16 20:29 UTC (permalink / raw)
To: David S. Miller
Cc: Alexander Duyck, Jakub Kicinski, kernel-team, Andrew Lunn,
Eric Dumazet, Paolo Abeni, Shuah Khan, Mohsin Bashir,
Mike Marciniszyn (Meta), Stanislav Fomichev, Bobby Eshleman,
Björn Töpel, Breno Leitao, Simon Horman, Mina Almasry,
Vadim Fedorenko, Dimitri Daskalakis, netdev, Dimitri Daskalakis
From: Dimitri Daskalakis <daskald@meta.com>
Read timestamping statistics before and after ifdown, to catch drivers
that crash or reset them while the interface is down.
Signed-off-by: Dimitri Daskalakis <daskald@meta.com>
---
tools/testing/selftests/drivers/net/stats.py | 25 +++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/drivers/net/stats.py b/tools/testing/selftests/drivers/net/stats.py
index b08e4d48b15c..e61db30b5181 100755
--- a/tools/testing/selftests/drivers/net/stats.py
+++ b/tools/testing/selftests/drivers/net/stats.py
@@ -220,6 +220,28 @@ def check_down(cfg) -> None:
netfam.qstats_get({"ifindex": cfg.ifindex, "scope": "queue"}, dump=True)
+@ksft_disruptive
+def check_down_ts_stats(cfg) -> None:
+ """Test timestamping stats are not impacted by ifdown"""
+
+ req = {"header": {"dev-index": cfg.ifindex, "flags": {"stats"}}}
+ try:
+ stats = ethnl.tsinfo_get(req).get("stats")
+ except NlError as e:
+ if e.error == errno.EOPNOTSUPP:
+ raise KsftSkipEx("timestamping not supported by the device") from e
+ raise
+ if not stats:
+ raise KsftSkipEx("timestamping stats not supported by the device")
+
+ ip(f"link set dev {cfg.dev['ifname']} down")
+ defer(ip, f"link set dev {cfg.dev['ifname']} up")
+
+ stats2 = ethnl.tsinfo_get(req).get("stats", {})
+ for k in stats:
+ ksft_ge(stats2[k], stats[k], comment=f"{k} went backwards on device down")
+
+
def __run_inf_loop(body):
body = body.strip()
if body[-1] != ';':
@@ -311,7 +333,8 @@ def main() -> None:
with NetDrvEnv(__file__, queue_count=100) as cfg:
ksft_run([check_pause, check_fec, check_fec_hist, pkt_byte_sum,
- qstat_by_ifindex, check_down, procfs_hammer,
+ qstat_by_ifindex, check_down, check_down_ts_stats,
+ procfs_hammer,
procfs_downup_hammer],
args=(cfg, ))
ksft_exit()
--
2.52.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-16 20:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 20:29 [PATCH net 0/4] eth: fbnic: miscellaneous driver fixes Dimitri Daskalakis
2026-11-16 20:29 ` [PATCH net 1/4] eth: fbnic: wait on the correct queues in fbnic_queue_stop() Dimitri Daskalakis
2026-11-16 20:29 ` [PATCH net 2/4] eth: fbnic: skip disabled Tx rings when setting the queue NAPI Dimitri Daskalakis
2026-11-16 20:29 ` [PATCH net 3/4] eth: fbnic: skip freed Tx rings in fbnic_get_ts_stats() Dimitri Daskalakis
2026-11-16 20:29 ` [PATCH net 4/4] selftests: drv-net: stats: query timestamping stats while down Dimitri Daskalakis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox