Article View: linux.kernel.netdev
Article #24834[PATCH net-next] net: mana: add UDP segmentation offload support
From: Hamza Mahfooz
Date: Mon, 30 Nov 2026 23:14
Date: Mon, 30 Nov 2026 23:14
148 lines
14354 bytes
14354 bytes
The hardware segments both TCP and UDP. In LSO mode it takes the L4
protocol from the parsed header, rewrites the IP total/payload length,
the IPv4 ID and the UDP length of each segment, and computes the L4
checksum from scratch. However, it reports a non-fatal error if neither
the TCP nor the UDP checksum offload bit is set in the TX OOB.
Advertise NETIF_F_GSO_UDP_L4 and, for SKB_GSO_UDP_L4 skbs, set
comp_udp_csum instead of comp_tcp_csum and seed the UDP checksum
rather than the TCP one. Everything else, including the header size
calculation in mana_get_gso_hs(), is shared with TSO.
Advertise this change to the PF with the new driver capability flag
GDMA_DRV_CAP_FLAG_1_UDP_SEGMENTATION_OFFLOAD.
Tested between two Azure Standard_E372is_v7 VMs on different hosts,
where the MANA device is the VM's only network interface. The changes
below are relative to the same kernel with tx-udp-segmentation turned
off.
udpgso_bench_tx, one sender pinned to a CPU, 61600 byte sends split
into 1400 byte segments, median of three 10 second runs:
throughput CPU per byte
IPv4 +307% -84%
IPv6 +348% -84%
IPv4 zerocopy +498% -80%
IPv6 zerocopy +190% -79%
CPU is the user plus system time of the sending process. With USO a
single sender is no longer CPU bound. Its throughput varied widely,
both within and between runs, but its CPU time per byte did not.
With 8 IPv4 senders, each on its own core, the total throughput went
up by 432% while the senders' CPU usage went down by 51%. With the
default 212992 byte send buffer, a socket can only have about three
such sends in flight, so the rate also depends on TX completion
latency. With net.core.wmem_default raised to 4 MiB, 8, 16 and 32
senders all came close to the VMs' network limit, with 604% to 656%
more throughput than software GSO.
Uploads with msquic's secnetperf (which uses UDP_SEGMENT):
throughput CPU per byte
1 connection +39% -48%
8 connections +104% -56%
IPv6 results were similar. Sending without GSO is unaffected.
NOTE: netvsc does not advertise NETIF_F_GSO_UDP_L4. On VMs with
accelerated networking, where traffic goes through the netvsc device
and is then passed to the VF, UDP GSO packets are therefore still
segmented in software until netvsc supports USO as well. Where the
MANA device is the VM's network interface, as in the tests above,
this patch is enough.
Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
---
drivers/net/ethernet/microsoft/mana/mana_en.c | 26 ++++++++++++-------
include/net/mana/gdma.h | 6 ++++-
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index 95bf153c3e1a8..b8c21e26a2aeb 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -441,6 +441,9 @@ netdev_tx_t __mana_start_xmit(struct sk_buff *skb, struct net_device *ndev,
ipv6 = true;
if (skb_is_gso(skb)) {
+ bool is_uso = skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4;
+ u8 l4_proto = is_uso ? IPPROTO_UDP : IPPROTO_TCP;
+ __sum16 *l4_check;
int num_sge;
gso_hs = mana_get_gso_hs(skb);
@@ -465,7 +468,13 @@ netdev_tx_t __mana_start_xmit(struct sk_buff *skb, struct net_device *ndev,
pkg.tx_oob.s_oob.is_outer_ipv6 = ipv6;
pkg.tx_oob.s_oob.comp_iphdr_csum = 1;
- pkg.tx_oob.s_oob.comp_tcp_csum = 1;
+ if (is_uso) {
+ pkg.tx_oob.s_oob.comp_udp_csum = 1;
+ l4_check = &udp_hdr(skb)->check;
+ } else {
+ pkg.tx_oob.s_oob.comp_tcp_csum = 1;
+ l4_check = &tcp_hdr(skb)->check;
+ }
pkg.tx_oob.s_oob.trans_off = skb_transport_offset(skb);
pkg.wqe_req.client_data_unit = skb_shinfo(skb)->gso_size;
@@ -473,16 +482,14 @@ netdev_tx_t __mana_start_xmit(struct sk_buff *skb, struct net_device *ndev,
if (ipv4) {
ip_hdr(skb)->tot_len = 0;
ip_hdr(skb)->check = 0;
- tcp_hdr(skb)->check =
- ~csum_tcpudp_magic(ip_hdr(skb)->saddr,
- ip_hdr(skb)->daddr, 0,
- IPPROTO_TCP, 0);
+ *l4_check = ~csum_tcpudp_magic(ip_hdr(skb)->saddr,
+ ip_hdr(skb)->daddr, 0,
+ l4_proto, 0);
} else {
ipv6_hdr(skb)->payload_len = 0;
- tcp_hdr(skb)->check =
- ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
- &ipv6_hdr(skb)->daddr, 0,
- IPPROTO_TCP, 0);
+ *l4_check = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
+ &ipv6_hdr(skb)->daddr, 0,
+ l4_proto, 0);
}
} else if (skb->ip_summed == CHECKSUM_PARTIAL) {
csum_type = mana_checksum_info(skb);
@@ -4000,6 +4007,7 @@ static int mana_probe_port(struct mana_context *ac, int port_idx,
ndev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
ndev->hw_features |= NETIF_F_RXCSUM;
ndev->hw_features |= NETIF_F_TSO | NETIF_F_TSO6;
+ ndev->hw_features |= NETIF_F_GSO_UDP_L4;
ndev->hw_features |= NETIF_F_RXHASH;
ndev->features = ndev->hw_features | NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_CTAG_RX;
diff --git a/include/net/mana/gdma.h b/include/net/mana/gdma.h
index e17219a29fa5f..7d957241ee0c1 100644
--- a/include/net/mana/gdma.h
+++ b/include/net/mana/gdma.h
@@ -783,6 +783,9 @@ enum {
/* Enforce min 1 usec, 1 frames for Interrupt Moderation */
#define GDMA_DRV_CAP_FLAG_1_SET_MIN_INTR_MOD_VALUE BIT_ULL(33)
+/* Driver supports USO */
+#define GDMA_DRV_CAP_FLAG_1_UDP_SEGMENTATION_OFFLOAD BIT_ULL(35)
+
/* Capabilities in the PCI-only group below rely on dynamic MSI-X allocation
* and on the servicing and reset paths reached through
* mana_schedule_serv_work(). Transports that provide neither leave
@@ -809,7 +812,8 @@ enum {
GDMA_DRV_CAP_FLAG_1_DYN_INTERRUPT_MODERATION | \
GDMA_DRV_CAP_FLAG_1_NON_CONTIGUOUS_BUFFERS | \
GDMA_DRV_CAP_FLAG_1_THROTTLED_EVENT_QUEUE | \
- GDMA_DRV_CAP_FLAG_1_SET_MIN_INTR_MOD_VALUE)
+ GDMA_DRV_CAP_FLAG_1_SET_MIN_INTR_MOD_VALUE | \
+ GDMA_DRV_CAP_FLAG_1_UDP_SEGMENTATION_OFFLOAD)
#define GDMA_DRV_CAP_FLAGS2 0
--
2.56.1
Technical Details
Message-ID:
<20261130231409.2567518-1-hamzamahfooz@linux.microsoft.com>Path:
mbox-mo1.pugleaf.net!srv.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-374520-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.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-374520-linux-kernel-netdev=dewy.ru From: hamzamahfooz@linux.microsoft.com (Hamza Mahfooz) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next] net: mana: add UDP segmentation offload support Date: Mon, 30 Nov 2026 18:14:09 -0500 Organization: Usenet Network Message-ID: <20261130231409.2567518-1-hamzamahfooz@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1563878"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:2jlw0RSVkvv1pCS+nlbgpFTLw6Y= sha256:2hNsZ6eh5774VnOeLLQu1JgaxcvXhnGBbkCJcrL1j+M= sha1:LAS1xLrBv573+5I/xF0HZN9Q43E= sha256:VsTXQjzLIIMYhhjsdEnlJ3isNQOtAO1aB+jncgEo5vk= 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 97EA3126017; Tue, 1 Dec 2026 02:15:17 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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 (1024-bit key) header.d=linux.microsoft.com 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 eg6BQrbuXJlF; Tue, 1 Dec 2026 02:15:14 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374520-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.microsoft.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 2C8C6126013; Tue, 1 Dec 2026 02:15:05 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id DA0152B038; Mon, 30 Nov 2026 23:15:01 +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=1796080501; b=FGXPUA3aG4e/XuamBR8AxlyR4eOJ93PXGpy+dE+DOeA/Zq1fb3hPE0rGwUxJafXfN3Dn VT8PkLjaXVVWxtgxY75lz+IXliIWTzcnJd27gpCRJykDjQvBl0Wh8pTBAtVHfjXeGs2pG 9Wi/jwOaYGBP+6djAFf93D8VEsiiFW+qB4YvSYMWq/wdQkgiPXNetNX7tx1zQEZxxGIrd tH/9xTfYkilP0+/XieIDL3JsTlr/i3zPLafQZsfqT++iUKOB5/B82cf8K/JXjYhiNtVYK szLLOHPyIz3LZQzKkJgJ005EAm2SbcHAsAGxzGerdSxbxHbjzVveQ6Mlaf4jLT7OW9w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796080501; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Filter: DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=uSUqMSTec3NAgHCQe6EsIdq4k6wfzPEuEtWnqJlS0E4=; b=TNPeV5Sb1xI17WVwzgmcnx2HAJ+KE4APehqExLJgP6ZeoL6ZI61hlR8D/cfQ5b4Gwrz5 kyl/S41NLRbnZI89xsLt3tgi4kL+NvgHURpa68wiV5zbMTYhukdUBg7C1QP8hUcNFWD4F Fo54jORq7et5Ne/DFm9YGlMJ+pt5ZbPEQXd9gIiMqT/o2rX6iDh0UcjNJ+BjPUH+gw09C laC2w/+UeHzdZB/hn1uw1YoNlxSg6AF43CxLZhZ0oJKE8ynMhOb/g9a0KLBaPgrH97xSs PRNnexcXT/UhMJ0DzWRI4D9cPUcNnLlW6CdPkR6Y8txBEdp9zw0eE4TuMankW0ywBww== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=kukPTDc9; dmarc=pass header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; 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 B25BC606A320; Mon, 30 Nov 2026 23:15:01 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=kukPTDc9 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=13.77.154.182 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796080500; b=dc26UDV6YKSYgtFaTj1ucZSNoAvmjdINA6FVywzLsWPghoDsTS0CrMMRwBgqYqjTYyZB 1UzGAt8L1hHOsj+QQgoIJSrzr3pKR6t0vhl5FTzCt+MTNKoofi5+x4mMa6Y2EFZxO1dZW itO+NXFPXlUEtmHWMRRs5ZbNRPFnftGTqhfZd0QRWnXYIZQGBOLGCzSnvQburA/r1718Z BPALFJGzKlo+jgR7QRV9iBjSi2uYp81tB9AdQV9UB0fa8NU9CxNlm3yIztHwYEW2QEwcJ vltkDS011cTkeG2A2yn2CT7yiqKkhN3/QxO1iwuDcm8xdi6VqevLwEUg6dfwW1uPOwQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796080500; h=DMARC-Filter:Received:DKIM-Filter:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=uSUqMSTec3NAgHCQe6EsIdq4k6wfzPEuEtWnqJlS0E4=; b=LW8hdizPl2nPN0ea2CbaSFFz7zt0TTB7D+Gy+BEfPzPhmw0WfjGVV+0A63uk0epumOAL EJdltwsohhQgXaUgPfeSnCM1b0vWvApEBEpATDqMoG3iEpYeKolfyBEVy2ikPV3wH4aKd VKosCtsqdrFO/FKkeeXBp1TITZ1KoDpRo40Olb+7pcDoqwHGDKn9xzSt9Bon6nLPF3/JF 5lM/VidkFg+Onot9cuzF8GXR3z6JQbVCVYkpp2/WjILroFNb+V4BzYD1mOmzZIgfYYfZC Pw8AGSlGyLu/5nM5rEksauuglUiUxaK/JZNT866QUZuUxUs6l6LXJp0LeLeDZrn4W5g== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=kukPTDc9; arc=none smtp.remote-ip=13.77.154.182 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC542606A32A; Mon, 30 Nov 2026 23:14:59 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CC542606A32A X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com X-Received: by linux.microsoft.com (Postfix, from userid 1216) id D54C320B7166; Mon, 30 Nov 2026 15:14:51 -0800 (PST) X-DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D54C320B7166 X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1796080491; bh=uSUqMSTec3NAgHCQe6EsIdq4k6wfzPEuEtWnqJlS0E4=; h=From:To:Cc:Subject:Date:From; b=kukPTDc98d+CgE4MgBKRZEOvd6+vh9B1BJ/Qe74kqjb1cicQEc6UhanK6fmZPi+yM g3zNNvHTdeXSPYZzRyhN0hPbuAIgznABTMPS1l5R+LN04de15DLe1Gfn3KRCGp7xff 5QR7HWzvqKx2TbBxbVR97vqk6z0UBN5grzuk4mTY= X-Cc: Haiyang Zhang <haiyangz@microsoft.com>, Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>, Andrew Lunn <andrew+netdev@lunn.ch>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Wei Hu <weh@microsoft.com>, Konstantin Taranov <kotaranov@microsoft.com>, Willem de Bruijn <willemb@google.com>, Simon Horman <horms@kernel.org>, linux-hyperv@vger.kernel.org, linux-rdma@vger.kernel.org, Hamza Mahfooz <hamzamahfooz@linux.microsoft.com> X-Mailer: git-send-email 2.43.7 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