From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=13.77.154.182 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== 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== 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 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) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CC542606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=kukPTDc9 Received: by linux.microsoft.com (Postfix, from userid 1216) id D54C320B7166; Mon, 30 Nov 2026 15:14:51 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D54C320B7166 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= From: Hamza Mahfooz To: netdev@vger.kernel.org Cc: Haiyang Zhang , Wei Liu , Dexuan Cui , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wei Hu , Konstantin Taranov , Willem de Bruijn , Simon Horman , linux-hyperv@vger.kernel.org, linux-rdma@vger.kernel.org, Hamza Mahfooz Subject: [PATCH net-next] net: mana: add UDP segmentation offload support Date: Mon, 30 Nov 2026 18:14:09 -0500 Message-ID: <20261130231409.2567518-1-hamzamahfooz@linux.microsoft.com> X-Mailer: git-send-email 2.43.7 X-Mailing-List: linux-hyperv@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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