Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4188421pxj; Tue, 11 May 2021 23:12:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvUkH3liRprvifWBhPKgHEpxHRZ9PL0EL0cweBc5opEbRw7JBYZepUO1cPCRTsQ8sMv9cC X-Received: by 2002:a92:ad07:: with SMTP id w7mr28902442ilh.98.1620799937670; Tue, 11 May 2021 23:12:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620799937; cv=none; d=google.com; s=arc-20160816; b=mv+KVEhGfnEnbsKFoILueaLhCzqLCuTuYMbHjHLTFDBBnffTlvFsLPQCQSNUEj7vHW kchcIizYkvPb7j7LR0nFLJY5rdataPBC6wyKEMkxjQUynn6ZYtnxPVeTvPpauU4ks6iX tn4jQpFLY8KE4jPb5FcP8Mj4J5P23aPL9ZdnWPR33azt3/0xxH3VA13unOd5rDQVJ49Z QCTxvW4FkMhT1CYGOkh9Tn6lPW/xP+6kBgn00lTEKRszgOVIjksSTBhNOIoBpSNKVnBI M6CPr5Duh+IePrQ9qPvleYe1prDJ8yxXeGCgKR3ilYWmVc6e23UwvlkR/2ljNU1YHxhV 4vhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=NPvm8NafxYzbmgPT1/KnpbyytRpdTESXUP6H+J3SyAo=; b=oydb6jZfR9T+SFBNd3tMZSwpeUD613AgyrZTNmQtpxP7OF5a1Pf7TG6cRrFOTkWPpX Paw51TffGILWHYykOtOWgMQqWwbN6DQxxdx7CGhnp+XrkF7GPauOEX1Ixfxn4bhR4SHP RIsp/n7zxoWMcn3rZxQMy0pCpYTBRMKwRaf3UBm/5EwY3c9Da0WESvoGyvxXWfkV2cuq 3B4TpO+E/W9vrBW/RB5Y2haAruRB6E3YrRuD4/k9pINP+eXn7D+VZcs0CaKQiJdvrZx6 Tpey7gF24b4PSr0sgMNeJ1ieI20Y27m05PuzQdGexmX5e1D8WMEp1eJAgxrWUhtmsmVX LAFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@daynix-com.20150623.gappssmtp.com header.s=20150623 header.b="ggF7RmO/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l24si20156297ioh.105.2021.05.11.23.12.04; Tue, 11 May 2021 23:12:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@daynix-com.20150623.gappssmtp.com header.s=20150623 header.b="ggF7RmO/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230096AbhELGLA (ORCPT + 99 others); Wed, 12 May 2021 02:11:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230017AbhELGK5 (ORCPT ); Wed, 12 May 2021 02:10:57 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED8BDC06174A for ; Tue, 11 May 2021 23:09:48 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id d21so21282162oic.11 for ; Tue, 11 May 2021 23:09:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NPvm8NafxYzbmgPT1/KnpbyytRpdTESXUP6H+J3SyAo=; b=ggF7RmO/OPDJ7AQgIQ0iAERaZHJ5C488AblpYNQs+6RcXH8iQfaDsO9WAjqnEaNu3B vyg1bJF5Dd+pO6xB6zaGtHpjIxqB59k77WjABh4PU9nrp0kIwPHpeWegKXpB+6IUtixB kDmOjvtzodcTA+FiAE9bTJ6XPyGiZiwQRttA/ssbvAZQCu2t8r9O10j7y/V7kItmstEa BF1of08PkuFFYGp0Z4JEzekK26g65DCBOBDmsek68B00SsXAy6isjmx/FxnAp2BoSMz2 w5KdGBqWSWJ+RjIJ+OinIUCBsjjHwkvspW/xdGmKKO9dPL7//7vDRtvZdx0niDy2vHc8 sJJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NPvm8NafxYzbmgPT1/KnpbyytRpdTESXUP6H+J3SyAo=; b=KRppN19KvxAtqUO0M4w//hFxohdb5eT/0g/NTPLj6/ehC9cg8eOLz5aupfVfz1giJO fT2eoDAAn46UQI23aQPyGDio5RUcLB0L2pk81sVTilASJlXZzDg6Q5gCYgo8J9Nd+4Rt Yz8tLjfyWFjq/PkjH1f9lrsIbZ9nBHLWMA8WnIZeR3uFZiZa6dc0Gxq/KZrm0NZS51Yh CaA335uLBe8hXFH/n7tWybfZ02xWAPWy+3/im+oR/TjyXqlWG5kI/tAP/zaPq6/ZWc5W XuL3yATk2PkVk4hTSGiKOSACBeVLOBYA8/8XADaVL4xtKhsrBaz6zzknCVNe7Tu0yHTb YUOg== X-Gm-Message-State: AOAM530D1ikILE5Qix3ENR8CQmDHdgpFufl+R6Vbc1zaB8XZ0CXZ3t0f LIJSZoyFWtwGG83/5iwgwWVWyYNysj+hX1151apfHQ== X-Received: by 2002:aca:ad06:: with SMTP id w6mr6422169oie.54.1620799788219; Tue, 11 May 2021 23:09:48 -0700 (PDT) MIME-Version: 1.0 References: <20210511044253.469034-1-yuri.benditovich@daynix.com> <20210511044253.469034-3-yuri.benditovich@daynix.com> In-Reply-To: From: Yuri Benditovich Date: Wed, 12 May 2021 09:09:36 +0300 Message-ID: Subject: Re: [PATCH 2/4] virtio-net: add support of UDP segmentation (USO) on the host To: Willem de Bruijn Cc: David Miller , Jakub Kicinski , "Michael S. Tsirkin" , Jason Wang , Network Development , linux-kernel , virtualization , Yan Vugenfirer Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 11, 2021 at 8:48 PM Willem de Bruijn wrote: > > On Tue, May 11, 2021 at 12:43 AM Yuri Benditovich > wrote: > > > > Large UDP packet provided by the guest with GSO type set to > > VIRTIO_NET_HDR_GSO_UDP_L4 will be divided to several UDP > > packets according to the gso_size field. > > > > Signed-off-by: Yuri Benditovich > > --- > > include/linux/virtio_net.h | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h > > index b465f8f3e554..4ecf9a1ca912 100644 > > --- a/include/linux/virtio_net.h > > +++ b/include/linux/virtio_net.h > > @@ -51,6 +51,11 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb, > > ip_proto = IPPROTO_UDP; > > thlen = sizeof(struct udphdr); > > break; > > + case VIRTIO_NET_HDR_GSO_UDP_L4: > > + gso_type = SKB_GSO_UDP_L4; > > + ip_proto = IPPROTO_UDP; > > + thlen = sizeof(struct udphdr); > > + break; > > If adding a new VIRTIO_NET_HDR type I suggest adding separate IPv4 and > IPv6 variants, analogous to VIRTIO_NET_HDR_GSO_TCPV[46]. To avoid > having to infer protocol again, as for UDP fragmentation offload (the > retry case below this code). Thank you for denoting this important point of distinguishing between v4 and v6. Let's try to take a deeper look to see what is the correct thing to do and please correct me if I'm wrong: 1. For USO we do not need to guess the protocol as it is used with VIRTIO_NET_HDR_F_NEEDS_CSUM (unlike UFO) and the USO packets transmitted by the guest are under the same clause as both VIRTIO_NET_HDR_GSO_TCP, i.e. under if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { 2. If we even define VIRTIO_NET_HDR_GSO_UDPv4_L4 and VIRTIO_NET_HDR_GSO_UDPv6_L4 - both will be translated to SKB_GSO_UDP_L4, so this information is immediately lost (the code will look like: case VIRTIO_NET_HDR_GSO_UDP4_L4: case VIRTIO_NET_HDR_GSO_UDP6_L4 gso_type = SKB_GSO_UDP; 3. When we will define the respective guest features (like VIRTIO_NET_F_HOST_USO4 VIRTIO_NET_F_HOST_USO6) we will need to recreate the virtio_net header from the skb when both v4 and v6 have the same SKB_GSO_UDP_L4, (see virtio_net_hdr_from_skb) and I'm not sure whether somebody needs the exact v4 or v6 information on guest RX path. 4. What is completely correct is that when we will start working with the guest RX path we will need to define something like NETIF_F_USO4 and NETIF_F_USO6 and configure them according to exact guest offload capabilities. Do you agree?