Re: [PATCH net-next V3 3/5] net/mlx5: nodnic: Add TX/RX statistics

From: Shahar Shitrit

Date: Sun Nov 29 2026 - 09:46:23 EST




On 27/11/2026 21:03, netdev-bot+sashiko@xxxxxxxxxx wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> 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] mlx5_nodnic_handle_err_cqe() in
> drivers/net/ethernet/mellanox/mlx5/nodnic/en.c counts failed send…
>
> --
>
> net/mlx5: nodnic: Add TX/RX statistics
>
> This commit adds TX and RX packet and byte counters to the nodnic
> driver, plus a TX drop counter. The counters are updated from the xmit,
> send completion, error completion and receive paths. They 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 6400e100bcb10..38dd7498568e2 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 successful transmit here?
>
> The normal path in mlx5_nodnic_handle_send_cqe() uses the same helper,
> mlx5_nodnic_sq_stats_inc(). It increments sq_stats.packets and adds
> wi->num_bytes to sq_stats.bytes. mlx5_nodnic_get_stats64() then reports
> those values as tx_packets and tx_bytes.
>
> An OPCODE_CQ_SEND_ERR CQE means the device did not complete the WQE,
> for example LOCAL_LENGTH_ERR, LOCAL_PROT_ERR or WR_FLUSH_ERR. After the
> SQ enters the error state, every outstanding WQE completes with
> WR_FLUSH_ERR, and each of those would be counted as transmitted.
>
> The rtnl_link_stats64 kernel-doc in include/uapi/linux/if_link.h defines
> tx_packets as packets the device "acknowledged it copied them out of
> host memory". Flushed or rejected WQEs don't meet that definition.
>
> These failures are also not reported anywhere else.
> mlx5_nodnic_update_sq_stats() never sets tx_errors, and tx_dropped only
> counts WQE build failures in mlx5_nodnic_xmit():
>
> do {
> start = u64_stats_fetch_begin(&sq->xmit_syncp);
> s->tx_dropped = u64_stats_read(&sq->dropped);
> } while (u64_stats_fetch_retry(&sq->xmit_syncp, start));
>
> As a result, after an SQ error, ip -s link would show every flushed
> packet and byte as transmitted, with zero errors.
>
> The slot still has to be released through
> mlx5_nodnic_complete_send_wqe(). Could this branch increment a separate
> error counter instead, and report it as tx_errors (or tx_dropped)?
>
>> +
>> + 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);
>
> [ ... ]
>
TX error CQEs should be counted for tx_packets and bytes, like mlx5
count them. The doc says "Number of packets successfully transmitted.
For hardware interfaces counts packets which host was able to
successfully hand over to the device, whichdoes not necessarily mean
that packets had been successfully transmitted out of the device…".