Netdev List
 help / color / mirror / Atom feed
* [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; 9+ 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] 9+ 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-18 14:32   ` netdev-bot+sashiko
  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, 1 reply; 9+ 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] 9+ 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; 9+ 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] 9+ 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; 9+ 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] 9+ 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
  2026-11-16 22:51   ` Jakub Kicinski
  2026-11-18 14:32   ` netdev-bot+sashiko
  3 siblings, 2 replies; 9+ 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] 9+ messages in thread

* Re: [PATCH net 4/4] selftests: drv-net: stats: query timestamping stats while down
  2026-11-16 20:29 ` [PATCH net 4/4] selftests: drv-net: stats: query timestamping stats while down Dimitri Daskalakis
@ 2026-11-16 22:51   ` Jakub Kicinski
  2026-11-16 23:12     ` Dimitri Daskalakis
  2026-11-18 14:32   ` netdev-bot+sashiko
  1 sibling, 1 reply; 9+ messages in thread
From: Jakub Kicinski @ 2026-11-16 22:51 UTC (permalink / raw)
  To: Dimitri Daskalakis
  Cc: David S. Miller, Alexander Duyck, 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

On Mon, 16 Nov 2026 12:29:57 -0800 Dimitri Daskalakis wrote:
> +def check_down_ts_stats(cfg) -> None:

This is skipping on netdevsim, you need to add a fake callback 
to netdevsim as well. drivers/net tests can't skip on netdevsim
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net 4/4] selftests: drv-net: stats: query timestamping stats while down
  2026-11-16 22:51   ` Jakub Kicinski
@ 2026-11-16 23:12     ` Dimitri Daskalakis
  0 siblings, 0 replies; 9+ messages in thread
From: Dimitri Daskalakis @ 2026-11-16 23:12 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: David S. Miller, Alexander Duyck, 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

On 11/16/26 2:51 PM, Jakub Kicinski wrote:
> On Mon, 16 Nov 2026 12:29:57 -0800 Dimitri Daskalakis wrote:
>> +def check_down_ts_stats(cfg) -> None:
> 
> This is skipping on netdevsim, you need to add a fake callback 
> to netdevsim as well. drivers/net tests can't skip on netdevsim

Ack, will add netdevsim support in v2.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net 1/4] eth: fbnic: wait on the correct queues in fbnic_queue_stop()
  2026-11-16 20:29 ` [PATCH net 1/4] eth: fbnic: wait on the correct queues in fbnic_queue_stop() Dimitri Daskalakis
@ 2026-11-18 14:32   ` netdev-bot+sashiko
  0 siblings, 0 replies; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-11-18 14:32 UTC (permalink / raw)
  To: dimitri.daskalakis1
  Cc: davem, alexanderduyck, kuba, kernel-team, andrew+netdev, edumazet,
	pabeni, shuah, hmohsin, mike.marciniszyn, sdf, bobbyeshleman,
	bjorn, leitao, horms, almasrymina, vadim.fedorenko, daskald,
	netdev

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] eth: fbnic: fbnic_wait_queue_idle() only polls 128 bits of
  256-bit Tx idle regs
- [Low] This patch changes what `struct fbnic_ring::q_idx` holds for Tx
  completion rings, but the field's comment still describes the old…

--

eth: fbnic: wait on the correct queues in fbnic_queue_stop()

fbnic_queue_stop() now passes cmpl.q_idx to fbnic_wait_queue_idle(), so
each queue triad is checked against its own hardware queue. Before this,
sub0.q_idx was used and every Rx triad was checked against queue 0. The
patch also sets q_idx on Tx completion rings, and the stop/wake loops now
skip disabled Tx rings.

> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
> index 07d4b2e923627..5efed21e59329 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);

[Severity: Low]
This isn't a bug, but should the comment on struct fbnic_ring::q_idx in
fbnic_txrx.h be updated along with this change? It still says:

	u8 q_idx;			/* Logical netdev ring index */

With this patch, the Tx completion ring's q_idx holds the hardware TCQ
number. fbnic_queue_stop() now relies on that, because
fbnic_wait_queue_idle() uses idx only as a bit position in the QM idle
registers:

	off = idx / 32;
	mask = BIT(idx % 32);

On XDP-only Tx triads (txq_count == 0 in fbnic_alloc_napi_vector(), with
sub0 marked FBNIC_RING_F_DISABLED), no netdev Tx queue has this index. In
the "rx 34 tx 34" example from the commit message the value is 39, but
the netdev has only 34 Tx queues.

Future code that trusts the comment, for example
netdev_get_tx_queue(dev, qt->cmpl.q_idx) or fbn->tx[qt->cmpl.q_idx] on a
Tx triad, would get the wrong queue or none at all. Could the comment say
that q_idx on completion rings is the hardware queue index?

[ ... ]

> @@ -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;
>  	}

[Severity: Medium]
Does fbnic_wait_queue_idle() actually wait on the XDP Tx ring here?

The commit message says that in the "rx 34 tx 34" case the vector now
waits on tx 39, the XDP Tx queue of rxq 5's vector. That ring is
qt->sub1, which is TWQ1 of hardware queue 39. qt->sub0 (TWQ0) on the
same triad is marked FBNIC_RING_F_DISABLED. The first Tx triad of every
vector with Rx queues has the same XDP sub1 ring, combined or not.

In fbnic_csr.h, FBNIC_QM_TWQ_IDLE, FBNIC_QM_TQS_IDLE and
FBNIC_QM_TDE_IDLE each have 8 registers. That is 256 bits, enough for
TWQ0 and TWQ1 of all 128 queues. FBNIC_QM_TCQ_IDLE has only 4.
fbnic_wait_queue_idle() derives a single offset and mask from idx:

	off = idx / 32;
	mask = BIT(idx % 32);

It applies those to every Tx register base, so it only reads registers
0..3 of the 256-bit arrays.

If the upper half holds the TWQ1 bits, TWQ1 is never polled.
fbnic_queue_stop() can then go on to fbnic_nv_flush() and clean up the
XDP Tx ring and its buffers while the hardware may still be processing
it. If the bits are interleaved per queue instead, the bit polled for
idx > 0 is not the TWQ0 bit of that queue at all, and we would either
miss the real queue or hit spurious idle timeouts.

The register handling predates this patch. Until now, though, every Rx
triad was checked against queue 0, and this patch makes the XDP-only
triads depend on this wait. How are the TWQ1 idle bits laid out? Should
fbnic_wait_queue_idle() also poll the TWQ1 bit for the TWQ, TQS and
TDE registers, perhaps only when sub1 is not FBNIC_RING_F_DISABLED?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116202957.3601684-1-dimitri.daskalakis1%40gmail.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net 4/4] selftests: drv-net: stats: query timestamping stats while down
  2026-11-16 20:29 ` [PATCH net 4/4] selftests: drv-net: stats: query timestamping stats while down Dimitri Daskalakis
  2026-11-16 22:51   ` Jakub Kicinski
@ 2026-11-18 14:32   ` netdev-bot+sashiko
  1 sibling, 0 replies; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-11-18 14:32 UTC (permalink / raw)
  To: dimitri.daskalakis1
  Cc: davem, alexanderduyck, kuba, kernel-team, andrew+netdev, edumazet,
	pabeni, shuah, hmohsin, mike.marciniszyn, sdf, bobbyeshleman,
	bjorn, leitao, horms, almasrymina, vadim.fedorenko, daskald,
	netdev

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The commit message says check_down_ts_stats() should "catch
  drivers that crash or reset [timestamping stats] while the interface…
- [Low] In check_down_ts_stats()
  (tools/testing/selftests/drivers/net/stats.py), a timestamping counter…

--

selftests: drv-net: stats: query timestamping stats while down

This adds check_down_ts_stats() to the drv-net stats.py selftest. The test
reads the ethtool tsinfo timestamping statistics, brings the interface
down, reads them again, and checks that no counter went backwards.

> diff --git a/tools/testing/selftests/drivers/net/stats.py b/tools/testing/selftests/drivers/net/stats.py
> index b08e4d48b15ce..e61db30b51817 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")

[Severity: Medium]
Can this test actually detect the reset case that the commit message
describes?

  "to catch drivers that crash or reset them while the interface is down"

The baseline is read without first enabling hardware TX timestamping, and
without sending any packets that request a hardware timestamp. The only
source of these counters is the driver's get_ts_stats():

net/ethtool/tsinfo.c:tsinfo_prepare_data() {
    ...
	if (req_base->flags & ETHTOOL_FLAG_STATS) {
		ethtool_stats_init((u64 *)&data->stats,
				   sizeof(data->stats) / sizeof(u64));
		if (dev->ethtool_ops->get_ts_stats)
			dev->ethtool_ops->get_ts_stats(dev, &data->stats);
	}
    ...
}

In fbnic, ice, idpf, bnxt, wangxun and mlx5, tx-pkts, tx-lost and tx-err
only count TX packets that asked for a hardware timestamp. In a typical
selftest environment the baseline will probably be all zeros.

If the baseline is zero, the ksft_ge(stats2[k], stats[k]) check below
still passes when a driver zeroes its counters in ndo_stop. check_down()
does not have this problem with the same >= pattern, because the qstats
already contain non-zero traffic counts.

The crash-on-query-while-down part does get exercised. Should the test
send some hardware-timestamped TX traffic before reading the baseline, so
that the reset part is covered too?

> +
> +    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")

[Severity: Low]
What happens here if a counter is in the baseline but missing from the
reply after ifdown?

The {} default only helps when the whole nest is missing. That never
happens here, because tsinfo_fill_reply() always emits the stats nest when
the stats flag is set. What can go missing is individual counters, since
tsinfo_put_stat() leaves out unset values:

net/ethtool/tsinfo.c:tsinfo_put_stat() {
	if (val == ETHTOOL_STAT_NOT_SET)
		return 0;
    ...
}

On wangxun ngbe/txgbe, ndo_stop calls wx_ptp_stop(), which sets
wx->ptp_clock to NULL. After that, wx_get_ptp_stats() fills in nothing:

drivers/net/ethernet/wangxun/libwx/wx_ethtool.c:wx_get_ptp_stats() {
    ...
	if (wx->ptp_clock) {
		ts_stats->pkts = wx->tx_hwtstamp_pkts;
		...
	}
}

So stats2 comes back empty and stats2[k] raises KeyError.

ksft_run() still counts this as a failure, and the deferred link up still
runs. However, the output is a Python traceback instead of the "went
backwards on device down" message, and the remaining keys are never
compared.

Would checking k in stats2 (or using stats2.get(k)) with ksft_true() or
ksft_ge() give a clearer failure? The neighbouring check_down() uses the
same qstat2[k] pattern.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116202957.3601684-1-dimitri.daskalakis1%40gmail.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-11-18 14:32 UTC | newest]

Thread overview: 9+ 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-18 14:32   ` netdev-bot+sashiko
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
2026-11-16 22:51   ` Jakub Kicinski
2026-11-16 23:12     ` Dimitri Daskalakis
2026-11-18 14:32   ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox