From: netdev-bot+sashiko@kernel.org
To: tariqt@nvidia.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com,
willemb@google.com, cjubran@nvidia.com, gal@nvidia.com,
linux-kernel@vger.kernel.org, shshitrit@nvidia.com
Subject: Re: [PATCH net-next V4 3/5] net/mlx5: nodnic: Add TX/RX statistics
Date: Fri, 04 Dec 2026 21:45:48 +0000 [thread overview]
Message-ID: <179642074846.3146.277828236392822000@kernel.org> (raw)
In-Reply-To: <20261203205721.4090361-4-tariqt@nvidia.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 (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] When the device reports a send error,
`mlx5_nodnic_handle_err_cqe()`…
- [Low] RX accounting is incomplete.
Pre-existing issues:
- [Medium] This problem wasn't introduced by this patch, but
`mlx5_nodnic_handle_recv_cqe()` (rx.c) takes `byte_count` straight…
--
net/mlx5: nodnic: Add TX/RX statistics
This commit adds u64_stats based TX and RX packet and byte counters and a
TX drop counter to the nodnic driver. The counters are updated from the
NAPI completion paths and from ndo_start_xmit, and are exposed through
ndo_get_stats64.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/nodnic/en.c b/drivers/net/ethernet/mellanox/mlx5/nodnic/en.c
> index 6cbdfaf7cc01d..a8f5ce5507d54 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/nodnic/en.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/nodnic/en.c
> @@ -85,10 +85,15 @@ static void mlx5_nodnic_handle_err_cqe(struct mlx5_nodnic_cq *cq,
>
> if (opcode == OPCODE_CQ_SEND_ERR) {
> struct mlx5_nodnic_sq *sq = &priv->sq;
> - u16 sq_pi = mlx5_nodnic_sq_get_pi(sq, wqe_counter);
> + struct mlx5_nodnic_tx_wqe_info *wi;
> + u16 sq_pi;
>
> - mlx5_nodnic_complete_send_wqe(sq, &sq->wqe_info[sq_pi],
> - napi_budget);
> + sq_pi = mlx5_nodnic_sq_get_pi(sq, wqe_counter);
> + wi = &sq->wqe_info[sq_pi];
> +
> + mlx5_nodnic_sq_stats_inc(&priv->sq_stats, wi);
[Severity: Medium]
Should an error completion count as a successfully transmitted packet here?
mlx5_nodnic_sq_stats_inc() always increments the same packets and bytes
counters that mlx5_nodnic_handle_send_cqe() uses for a good OPCODE_CQ_SEND
completion. mlx5_nodnic_update_sq_stats() then reports them as tx_packets
and tx_bytes.
Every TX WQE is posted with CE_ALWAYS in mlx5_nodnic_tx_build_wqe_ctrl():
ctrl->fm_ce_se = cpu_to_be32(MLX5_NODNIC_CE_ALWAYS << 2);
So each WQE produces either a SEND or a SEND_ERR CQE. Errors such as
LOCAL_PROT_ERR or LOCAL_LENGTH_ERR land here. Once the SQ enters the error
state, every outstanding WQE is flushed with WR_FLUSH_ERR. That could add up
to ring.num_entries (1024) failed packets and their bytes to tx_packets and
tx_bytes, while tx_errors and tx_dropped stay at zero.
The rtnl_link_stats64 kernel-doc in include/uapi/linux/if_link.h describes
tx_packets as packets successfully transmitted. It says transmit problems
belong in tx_errors. For comparison, mlx5e counts MLX5_CQE_REQ_ERR in a
separate cqe_err counter.
Could this path skip mlx5_nodnic_sq_stats_inc()? It could instead increment
an error counter under the NAPI syncp, reported as tx_errors (or
tx_dropped). It would still need to call mlx5_nodnic_complete_send_wqe() for
the unmap and free.
> +
> + mlx5_nodnic_complete_send_wqe(sq, wi, napi_budget);
> } else {
> struct mlx5_nodnic_rq *rq = &priv->rq;
> u16 ci = wqe_counter & (rq->ring.num_entries - 1);
[ ... ]
> diff --git a/drivers/net/ethernet/mellanox/mlx5/nodnic/rx.c b/drivers/net/ethernet/mellanox/mlx5/nodnic/rx.c
> index 7736a1f24ea5b..58d6b033f5f67 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/nodnic/rx.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/nodnic/rx.c
> @@ -140,6 +140,11 @@ void mlx5_nodnic_handle_recv_cqe(struct mlx5_nodnic_cq *cq,
>
> page_pool_dma_sync_for_cpu(rq->page_pool, page, 0, byte_count);
>
> + u64_stats_update_begin(&priv->rq_stats.syncp);
> + u64_stats_inc(&priv->rq_stats.packets);
> + u64_stats_add(&priv->rq_stats.bytes, byte_count);
[Severity: Medium]
This isn't a bug introduced by this patch, but byte_count comes straight
from the device-written CQE and is never checked against the posted buffer
size:
u32 byte_count = be32_to_cpu(cqe->byte_cnt);
mlx5_nodnic_rq_post_one() posts each RX buffer with:
wqe->byte_count = cpu_to_be32(MLX5_NODNIC_HW_MTU);
Later in mlx5_nodnic_handle_recv_cqe() the value is used directly:
skb_reserve(skb, MLX5_NODNIC_SKB_HEADROOM_BYTES);
skb_put(skb, byte_count);
If faulty firmware reports a byte_cnt larger than the remaining tailroom,
could skb_put() hit skb_over_panic()? For values between
MLX5_NODNIC_HW_MTU and the tailroom, could stale page_pool contents end up
in the skb?
A correctly working device should not report more than the posted length.
The unchecked skb_put() came from the earlier commit "net/mlx5: nodnic:
Implement data path". This patch only adds rx_bytes as another consumer of
the value.
Would it be worth checking byte_count against MLX5_NODNIC_HW_MTU?
> + u64_stats_update_end(&priv->rq_stats.syncp);
> +
> skb = napi_build_skb(page_address(page), PAGE_SIZE);
> if (unlikely(!skb))
> goto err_recycle;
[Severity: Low]
This isn't really a bug, but should RX drops and errors be counted as well?
Counting rx_packets before napi_build_skb() is fine. The if_link.h
kernel-doc allows rx_packets to include packets the driver dropped. But
when napi_build_skb() fails, the frame is recycled through err_recycle and
mlx5_nodnic_release_rx_wqe(), and no drop counter is incremented.
The same goes for OPCODE_CQ_RECV_ERR completions. They take the else branch
of mlx5_nodnic_handle_err_cqe(), which only calls
mlx5_nodnic_release_rx_wqe().
struct mlx5_nodnic_rq_stats has no dropped or errors field, so
mlx5_nodnic_get_stats64() never fills rx_dropped or rx_errors.
Would it make sense to add these alongside the new TX drop counter?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203205721.4090361-1-tariqt%40nvidia.com
next prev parent reply other threads:[~2026-12-04 21:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 20:57 [PATCH net-next V4 0/5] net/mlx5: Introduce mlx5_nodnic, a driver for DRAM-less NVIDIA Mellanox NIC functions Tariq Toukan
2026-12-03 20:57 ` [PATCH net-next V4 1/5] net/mlx5: nodnic: Introduce the mlx5_nodnic driver Tariq Toukan
2026-12-04 21:45 ` netdev-bot+sashiko
2026-12-03 20:57 ` [PATCH net-next V4 2/5] net/mlx5: nodnic: Implement data path Tariq Toukan
2026-12-04 21:45 ` netdev-bot+sashiko
2026-12-03 20:57 ` [PATCH net-next V4 3/5] net/mlx5: nodnic: Add TX/RX statistics Tariq Toukan
2026-12-04 21:45 ` netdev-bot+sashiko [this message]
2026-12-03 20:57 ` [PATCH net-next V4 4/5] net/mlx5: nodnic: Add ethtool driver info Tariq Toukan
2026-12-03 20:57 ` [PATCH net-next V4 5/5] net/mlx5: nodnic: Add health monitoring Tariq Toukan
2026-12-04 21:45 ` netdev-bot+sashiko
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=179642074846.3146.277828236392822000@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=cjubran@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=gal@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shshitrit@nvidia.com \
--cc=tariqt@nvidia.com \
--cc=willemb@google.com \
/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