From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9DD91F00A14; Fri, 4 Dec 2026 21:45:48 +0000 (UTC) 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== Subject: Re: [PATCH net-next V4 3/5] net/mlx5: nodnic: Add TX/RX statistics 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 Date: Fri, 04 Dec 2026 21:45:48 +0000 Message-ID: <179642074846.3146.277828236392822000@kernel.org> In-Reply-To: <20261203205721.4090361-4-tariqt@nvidia.com> References: <20261203205721.4090361-4-tariqt@nvidia.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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