🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27158

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

#27158
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 21:45
151 lines
13869 bytes
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
Technical Details
Message-ID: <179642074846.3146.277828236392822000@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377662-linux-kernel-netdev=dewy.ru
References: <20261203205721.4090361-4-tariqt@nvidia.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377662-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next V4 3/5] net/mlx5: nodnic: Add TX/RX statistics
Date: Fri, 04 Dec 2026 21:45:48 +0000
Organization: Usenet Network
Message-ID: <179642074846.3146.277828236392822000@kernel.org>
References: <20261203205721.4090361-4-tariqt@nvidia.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2879071"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:hlcGHeMKeSo/GOgZNvzTrlhJNtk= sha256:WSI8V3cgFwRCphLf/B0hU4fAYi3nn4ece+mgl3cycS4=
	sha1:1f0ckMfcf1VVu7RhkWZOi5Jkclo= sha256:tAv7ZM1pICRBYg+nNu8bHggs5QY0+e9qJiLGppXOpLE=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 4DE79117CFC; Sat,  5 Dec 2026 00:46:08 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.641
X-Spam-Status: No, score=-3.641 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id vWPt-SFB0ZDY;
	Sat,  5 Dec 2026 00:46:05 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377662-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id EA638117CFD; Sat,  5 Dec 2026 00:45:56 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 1C6E527D20; Fri,  4 Dec 2026 21:45:54 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796420750;
	b=3BOH9neiQN/yzLcz9YMFSbE440+RXh2dsYF+JDVaD/OSwJq7QXado8C5e3R73neaU/dY
	 Fu47t/GEHv7sATn7qNclEXI3eaKwylGFal2nztrzKPMvy1MJ8bjvp5cQY58+WoJJuLnxC
	 jzGxJL2fs7qT4/c6lJuxNXpy1+z25b9CNJxlD0dgkA90BuyfNfcg+/LS9FuDgChkJc8QP
	 xvaD12JWunoukFXn0sTz0xkrHi17gb+WY3kTiQg0ZOL8MlL4N1j1WF2IKTCC0wJMnNxei
	 IKELsn3fcHLnyphHYgnWSdG5U1nPpZrCYzxOSFRWEPBLR6WsAyz4NEVUG1ICPVa6g+w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796420750;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=7Aq13CP/T0RBVE2jOHV1/qRXMCyQ2zh2OgptYlyFmHo=;
	b=be8p3ePJyKg+W1+5QuPtFvuF7BtioqfkEIn1sHPhmZOhzI/rW27/pxOdaLGRr+DdFwsH
	 cQRLCse69LDINotWlgjh3/NvpfT8foIPM3Ehx0PHpZvYrCPz7DDskNeMsYNiIBtJqZgtf
	 0HuaPHTlgLF+WekAz4dl1GRpsd/WG4I1ZdSK0+M2nOWd33i6gosoLylCbXwL9GV7dcw3p
	 m6aiV0TqhVkFWqkzNRlFTSqw4+4E76uhOscyOBex17IVy8QAPyiHB2wRg7VnXaFIAyswM
	 NW7D0XlAyJLFfCdnGLUfuqhZ/mWwDyxFSVlwgzO12Sh7rz1vwQHTPCRPdi3zHZ8/29g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FVAho2yr;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 7E20A606A33F;
	Fri,  4 Dec 2026 21:45:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FVAho2yr
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796420749;
	b=Y+Y3an/7al3jI/pNkq6xEJinzHgbcmZ1QksCiYAw1OfwpebVsd1XON7ulL8MIxAumGWT
	 +TrdCZgQWWYUBxi77tw9rEPoLSzeE3JLTGY6q9KDJnK2bAvFCoQwiDaS/OBum5T6F21GK
	 PWBgczjqILVPUOhGehLkVWEeTfzbPIu8TAWbawXMrQ0hVu+MFZWLuCKSJps2JTqd4S2Y9
	 LyhP5JTVDUyDdefaCxzR5DHncqRjSxcEIaUkDtfeHXOWs1Xe+vi2IgoVv+4ExrYBdcM0z
	 +9045Qzsyd7lCmhob3TEzKkbPvIgBgpUp5KAU6XI6s7fMBNnaH6E0WyqW3cMvTk7w8A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796420749;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=7Aq13CP/T0RBVE2jOHV1/qRXMCyQ2zh2OgptYlyFmHo=;
	b=DdJhwVhCz5/z0vd5pjkMp2aBTD/PcR2Ry7u3oFYa1x/1XnfkkTXmpPij0vbH9HSaPacp
	 w2fP41DO12iICzn8lQMfuRgFOEsRkTb51rAzeiFcmGkQX425i+1onadprJAxiTm/3qlCn
	 Edcoj/ZxB/ctmGjl1YK7DfP1LyS6kasZAT0WePgLPNGRHWJ5jDY5Ga/3xCoJBdQ+COKRd
	 7gLkbKbBX1OKxNbFmNCUGPdSpGW526GkV9DtVFxKHV/m76QDl+fz1eoOdZ06Bob+yRmrZ
	 d+CmQVfE1Z2SssPwfX+tNaXOurTlWJXYw0avFHLvn+rRcv8dO8Fyp90w1TP86/2StRw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FVAho2yr;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id A05F1606A690;
	Fri,  4 Dec 2026 21:45:49 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9DD91F00A14;
	Fri,  4 Dec 2026 21:45:48 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796420749;
	bh=7Aq13CP/T0RBVE2jOHV1/qRXMCyQ2zh2OgptYlyFmHo=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=FVAho2yrr/YJYj3qSmy0Q4LTS+4K4vHFtYFl7Tia//J1OgfXGAcXcCJgtTLgBRgZB
	 FJcBavwW58/s7iGdxVA/S4EUamYaBPaZZHwDz3qCjUWqzlImclKwurTxZBgLZJM9zP
	 OYz0v/IasTYz0o4SARK0l8enRSiG4vIpoB/+h9SPCjg5o4cXcIhOXv/gRFzktonB9g
	 eUZtReR4S9kzIA/X6RjPLG/8IPT6Pm9JzR+p9ckKLWcbGbjnA7mSaZQHa25NoKVlmt
	 SoS36RVC/UlMAWDR0pfYJnIhXqD/RqPRsxI/j3L4gYh16q5tS9BNq2tOCaCvG7h5sq
	 ECQHQ2dcPxcwA==
X-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
X-In-Reply-To: <20261203205721.4090361-4-tariqt@nvidia.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list