Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: dimitri.daskalakis1@gmail.com
Cc: davem@davemloft.net, alexanderduyck@fb.com, kuba@kernel.org,
	kernel-team@meta.com, andrew+netdev@lunn.ch, edumazet@kernel.org,
	pabeni@redhat.com, shuah@kernel.org, hmohsin@meta.com,
	mike.marciniszyn@gmail.com, sdf@fomichev.me,
	bobbyeshleman@meta.com, bjorn@kernel.org, leitao@debian.org,
	horms@kernel.org, almasrymina@google.com,
	vadim.fedorenko@linux.dev, daskald@meta.com,
	netdev@vger.kernel.org
Subject: Re: [PATCH net 4/4] selftests: drv-net: stats: query timestamping stats while down
Date: Wed, 18 Nov 2026 14:32:15 +0000	[thread overview]
Message-ID: <179501233564.3136.8246592632106945254@kernel.org> (raw)
In-Reply-To: <20261116202957.3601684-5-dimitri.daskalakis1@gmail.com>

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

      parent reply	other threads:[~2026-11-18 14:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179501233564.3136.8246592632106945254@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alexanderduyck@fb.com \
    --cc=almasrymina@google.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bjorn@kernel.org \
    --cc=bobbyeshleman@meta.com \
    --cc=daskald@meta.com \
    --cc=davem@davemloft.net \
    --cc=dimitri.daskalakis1@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=hmohsin@meta.com \
    --cc=horms@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=mike.marciniszyn@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=vadim.fedorenko@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox