๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #15041

Re: [PATCH net-next v2 1/6] eth: mpnic: Tx checksum offload

#15041
From: netdev-bot+sashiko
Date: Thu, 12 Nov 2026 10:08
102 lines
11292 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The new per-queue Tx counter `twq.csum_partial`, which reaches
  userspace as the qstats `tx-needs-csum` value, goes up too early.

--

eth: mpnic: Tx checksum offload

This adds generic Tx checksum offload (NETIF_F_HW_CSUM) to mpnic, including
for encapsulated skbs via hw_enc_features. It adds mpnic_features_check() to
make sure the skb header layout fits the Tx descriptor fields. CSO frames are
counted and reported through the netdev qstats needs_csum counter.

> diff --git a/drivers/net/ethernet/meta/mpnic/mpnic_txrx.c b/drivers/net/ethernet/meta/mpnic/mpnic_txrx.c
> index 93abdec44642f..65de6d999d548 100644
> --- a/drivers/net/ethernet/meta/mpnic/mpnic_txrx.c
> +++ b/drivers/net/ethernet/meta/mpnic/mpnic_txrx.c

[ ... ]

> +static void
> +mpnic_tx_offloads(struct mpnic_ring *ring, struct sk_buff *skb, __le64 *meta)
> +{
> +	struct mpnic_tx_hdrs hdrs = {};
> +
> +	if (skb->ip_summed != CHECKSUM_PARTIAL)
> +		return;
> +
> +	mpnic_tx_fill_hdrs(skb, &hdrs);
> +
> +	*meta |= cpu_to_le64(FIELD_PREP(MPNIC_TWD_CSUM_OFFSET,
> +					skb->csum_offset / 2) |
> +			     MPNIC_TWD_FLAG_REQ_CSO);
> +
> +	u64_stats_update_begin(&ring->stats.syncp);
> +	u64_stats_inc(&ring->stats.twq.csum_partial);
> +	u64_stats_update_end(&ring->stats.syncp);

[Severity: Low]
Should this counter be bumped only after the frame is actually queued to
the hardware?

mpnic_tx_offloads() increments twq.csum_partial for every CHECKSUM_PARTIAL
skb before mpnic_xmit_frame_ring() calls mpnic_tx_map():

> @@ -230,6 +263,8 @@ static netdev_tx_t mpnic_xmit_frame_ring(struct sk_buff *skb,
>  	MPNIC_XMIT_CB(skb)->bytecount = skb->len;
>  	MPNIC_XMIT_CB(skb)->desc_count = 0;
>  
> +	mpnic_tx_offloads(ring, skb, meta);
> +
>  	if (mpnic_tx_map(ring, skb, meta))
>  		goto err_free;

mpnic_tx_map() can fail in two ways. One is dma_map_single() or
skb_frag_dma_map() returning a mapping error. The other is the head or a
fragment being larger than FIELD_MAX(MPNIC_TWD_LEN). In either case the
error path frees the skb and counts it as dropped:

mpnic_xmit_frame_ring() {
    ...
err_free:
	dev_kfree_skb_any(skb);
	ring->tx_buf[tail] = NULL;
	ring->tail = tail;
err_drop:
	mpnic_tx_flush_doorbell(ring);

	u64_stats_update_begin(&ring->stats.syncp);
	u64_stats_inc(&ring->stats.twq.dropped);
	u64_stats_update_end(&ring->stats.syncp);
    ...
}

The csum_partial increment is never undone. mpnic_get_queue_stats_tx()
then reports it as tx->needs_csum, so the same packet shows up as both
dropped and checksummed by the device, even though it never reached the
hardware.

The same ordering is still there later in the series. mpnic_tx_offloads()
also bumps hw_gso_wire through mpnic_tx_lso() before mpnic_tx_map() runs.

One option is to have mpnic_tx_offloads() report which offload it used,
and update the stats only after mpnic_tx_map() succeeds. Note that fbnic
uses the same count-before-map pattern in fbnic_tx_offloads().

> +
> +	*meta |= cpu_to_le64(FIELD_PREP(MPNIC_TWD_L2_HLEN,
> +					skb_mac_header_len(skb) / 2) |
> +			     FIELD_PREP(MPNIC_TWD_L3_IHLEN, hdrs.i3len / 2));
> +}

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261110-mpnic-lso-v2-0-ccd37b051d08%40gmail.com
Technical Details
Message-ID: <179447813438.2199510.8203457737182862437@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361693-linux-kernel-netdev=dewy.ru
References: <20261110-mpnic-lso-v2-1-ccd37b051d08@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361693-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 1/6] eth: mpnic: Tx checksum offload
Date: Thu, 12 Nov 2026 10:08:54 +0000
Organization: Usenet Network
Message-ID: <179447813438.2199510.8203457737182862437@kernel.org>
References: <20261110-mpnic-lso-v2-1-ccd37b051d08@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1059977"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:kJOIrIUzXcBHonCAgVno55o1deY= sha256:HIkvKu9c4vPeE9wR+5PCvG6fg/jKSt5L06Eud16W4p8=
	sha1:3vvTdxGSjb5fBQEqXi0ltO4G4Do= sha256:ySgQLba+6hBYfVpvbMcNwCRoul3jfMvXACydG2PL2c4=
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 9FEA91141B7; Thu, 12 Nov 2026 13:25:47 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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] 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 Uv24bJfxaKtx;
	Thu, 12 Nov 2026 13:25:43 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-361693-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 4034A1141AD; Thu, 12 Nov 2026 13:25:34 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 837AB3D472; Thu, 12 Nov 2026 10:08:58 +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=1794478137;
	b=UeRVcBrWXW47FaY5egY8hxyKAF4We4JqzDvsQ0CPqu5Q75gfYkj61edhplkfDY+zOaP3
	 X/qNg74YP6I5KKwq2fwHge84ROvyx/mC0/EB0iowOLjmFNFvDNRB9FRGS06eacVFSTAGR
	 aq3SuPRQCXfLcLr/8D1kbWQC05JihkBbqJDVVfciDrmLnAvagoWYLyo++MyVt3wT2tjJ8
	 CdrJVW5lzCP0s4gwSHbgDrYGCCPHiDGOasrPhi2AKkjjfZO402/3zsZ5ISRnRb9mTwLne
	 p9ozq+pOtFM/hI53osr7c1yNl/W+/uzVlRvg726oTQtfzXGISy3YYJ8UHVvVJpXkQZg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794478137;
	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=GYZI2TbfNbB54zmF9fDhfS5KLR8hYBAK5ZU+ntDYVgU=;
	b=jnOQohC2AzB+0rAJsx2OqFyR05heayUL4wYUhRdyuexywWYt8xagMDM7kMb5aUJWrtIQ
	 7NJ6SgOLkO+yprH+msQ5xZ87WzN1g5BIs9ggU2amhdhXs1BpFNBsUa+Sl8cOXqDvtk4WO
	 lriAC43IpewbbHrCX6RFw8Ufu1/HinHjYTeWkCLsQm9i7Ym/j4z7QY/5l95vosauOd0jk
	 fR1Yc52k6j1uI0b3TMEjhJNDAJrzlVgYb//gm5DDVSX8TYCichmQPUW7L/se/irYPSr/l
	 4JQr36u5utmhopQV3KfLlVc0BESXe4X/tz+09OK3XdqYe3aQ2mScNGR5zmFHrRf8XlQ==
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=ilD9MwXC;
	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 E5067606A337;
	Thu, 12 Nov 2026 10:08:56 +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=ilD9MwXC
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=1794478136;
	b=ZZ99O8bNIlDBl/NNqeViTBC1MZskIqPjnOy3jTo9eSRt3t4LBZ/b87C9ChM7KCQEopwP
	 eV7JXfL5oOmZDt1GL4djQ3zRkfgoG4Af2KWn31i7YUQrEeSq41Hc8jZPPVQUQzG9uuT1U
	 pWcNOSB6mq3leUCX7Fl7BQwvDJrGLgb7doilfCrFZVGAgtS4IikSTsOvW5UmmZuWC9rgp
	 RJPQOToPviHcckjqKQ4/2MOSJJFOoYPQEEXB+c/RaWWw4BeRljC3voVj4uuc2dMgNvRSV
	 NosDRDXjCaIjvEsp2ZVuTSRY03xxhpeyFee/4Gk/FY5FnAWROhVqebrwzW+bkTeeYjA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794478136;
	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=GYZI2TbfNbB54zmF9fDhfS5KLR8hYBAK5ZU+ntDYVgU=;
	b=Q7tSaedzNfWUquZYBJGhiAUiJ8uKavLkwkK2uamNbZ8yfn6DRZ0Io575kHrLNXNHTeeW
	 1ZQPcGuEeNS80GMWbZh8+i3E4oYENoFhcI4RR31UnxDUBY3/HLoS8fOCR6kzb+qZCnkqS
	 9ob5E91QAe+HFdwEBG81MGmnz5GMaq+KjN4R2Ps2Cmjkffsga5tEkEVRVHA2mylKyHUsm
	 e0ccK3/MNtbGhKx70miUL7Cl/zj57UlDG/jh8tp4gz7aBfBM1L/KERuuE90qm2h9rLZBN
	 GXLRPCJKw2sdbS5mRHPdZKOFS6H0vtgubCuhT4FL33Hf32wCsU/c3FZWsS9RMbef4XQ==
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=ilD9MwXC;
	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 0E297606A321;
	Thu, 12 Nov 2026 10:08:55 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE9D21F00A05;
	Thu, 12 Nov 2026 10:08:54 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794478135;
	bh=GYZI2TbfNbB54zmF9fDhfS5KLR8hYBAK5ZU+ntDYVgU=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=ilD9MwXC5520N6YeS3vN2b1mHsCczauLN+nyrrr3AMQHF0l0WlxTlGo84+HMj6DMZ
	 RWOG9ZmfNQy08QesKrSx0GEsZC8oG+ors7gmYzDY1xdJQeUphUxFVW5QVuiO8vx+Mk
	 9jMBMqSjdAxP+hbUWgIG/KpgUe+fM5dvLJJMN8iacQ+lHNnkbPjojDci+GSFiUi5wg
	 Eysxtl/lQOEL3Ds0N4gQQsWkQsXFqZpu3FKu/wPDth3wWeftrRQpGYa0dmrcCmDWL/
	 jXGmECaG5F4xlKiclG1pFOQOfIGXw6BHG2q4i3axooSTYCSz5ooKmE+qB/7739G8hs
	 62BSxYn/kpiJw==
X-Cc: alexanderduyck@fb.com, kuba@kernel.org, kernel-team@meta.com,
 andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 pabeni@redhat.com, dimitri.daskalakis1@gmail.com, mohsin.bashr@gmail.com,
 netdev@vger.kernel.org, linux-kernel@vger.kernel.org
X-In-Reply-To: <20261110-mpnic-lso-v2-1-ccd37b051d08@gmail.com>
X-sashiko-severity: Low
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