From patchwork Thu Dec 1 22:33:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Melnichenko X-Patchwork-Id: 13061885 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E77A0C4321E for ; Thu, 1 Dec 2022 22:49:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231626AbiLAWtL (ORCPT ); Thu, 1 Dec 2022 17:49:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231587AbiLAWs6 (ORCPT ); Thu, 1 Dec 2022 17:48:58 -0500 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C472A5578 for ; Thu, 1 Dec 2022 14:48:57 -0800 (PST) Received: by mail-lj1-x22b.google.com with SMTP id x11so3550618ljh.7 for ; Thu, 01 Dec 2022 14:48:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XMtP14B7qgPGyencUQ441983HC3jgMwtJjN+dpKWwyo=; b=QIQ9QFt6qMwp9XgTopg2JzMbaT24wt3HeYg+fxh2eIY25LpQKv/Bg1KkBosQnkMkAk 1g6BLnAuxPG9e2PzRQufKdjdVlLeRsoUlCXoUwG8rQJZny/8lnZJwZarl54c/e2Rk3DM foc/e2m89DqxnydMwjnRTE4EZkN4LgASPDWndvyxzduxDuIeYQYXrYNvShkB/fD3euQL uyKLR84Hw0zsbK1mSf5R861QlHqUGw8cw8TSBuiczlmLHglE2C5EewwBws0xnaf837SH hrzCf2Z9MSQmbOlDlHcbNMftRtZ5BRS+P/nhsGycDTHSzKbIQMi9G9NFZAx9iAlWBBTn 717A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XMtP14B7qgPGyencUQ441983HC3jgMwtJjN+dpKWwyo=; b=xa3zcieDCzhVbaz+rsGfRVp2fyzg3LoXAEjXKPwlSeo+/09KFzCTEm0EQG5qbnIeNL 9Op0sGS0KDSx2JC+umTaTV1NjVWKCqO0HWWYLOIj0X7vB6+mZf2jWJQanF/uFRASfFrQ zsoghozksjXB6GsmrFa/aLIzpwB8sQD3XkoakkHBJcR3KsuHNuUggCsaf9FwadqW0oLV 7dLS/Y7Nsu9xYR2eSvMLG8MKCfVLis6NtmPpC3IBymvj5tVL5k9XG19xjigtKgWgXSWN DnWKlr3a0skjMKNIXkPEmNI7P6U0Unu9eJt2G5aSxBZq2LvrLjvmyIYNkWUjDwUcxHHm 6qDw== X-Gm-Message-State: ANoB5pnI6LAgMrdxwfts0ujUcPR4lMULF+5opTodNG+mqJHzwzLQJHYd QJHrCSvss0p1zu257+4vmM0RpA== X-Google-Smtp-Source: AA0mqf7iH4qKDrkzG9+Shl2zZSzIdLZslzUZoaguiNHYTQH5G1+QmGOuuQK8t7+Hz26D8DQgTqiZ6A== X-Received: by 2002:a05:651c:12c5:b0:279:a905:b547 with SMTP id 5-20020a05651c12c500b00279a905b547mr6590583lje.295.1669934936605; Thu, 01 Dec 2022 14:48:56 -0800 (PST) Received: from localhost.localdomain ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id g7-20020a056512118700b00497ab34bf5asm797573lfr.20.2022.12.01.14.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 14:48:56 -0800 (PST) From: Andrew Melnychenko To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mst@redhat.com, jasowang@redhat.com, yoshfuji@linux-ipv6.org, dsahern@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: devel@daynix.com Subject: [PATCH v4 6/6] drivers/net/virtio_net.c: Added USO support. Date: Fri, 2 Dec 2022 00:33:32 +0200 Message-Id: <20221201223332.249441-6-andrew@daynix.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221201223332.249441-1-andrew@daynix.com> References: <20221201223332.249441-1-andrew@daynix.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Now, it possible to enable GSO_UDP_L4("tx-udp-segmentation") for VirtioNet. Signed-off-by: Andrew Melnychenko --- drivers/net/virtio_net.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 86e52454b5b5..97d63c819c7b 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -60,13 +60,17 @@ static const unsigned long guest_offloads[] = { VIRTIO_NET_F_GUEST_TSO6, VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO, - VIRTIO_NET_F_GUEST_CSUM + VIRTIO_NET_F_GUEST_CSUM, + VIRTIO_NET_F_GUEST_USO4, + VIRTIO_NET_F_GUEST_USO6 }; #define GUEST_OFFLOAD_GRO_HW_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \ (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \ (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ - (1ULL << VIRTIO_NET_F_GUEST_UFO)) + (1ULL << VIRTIO_NET_F_GUEST_UFO) | \ + (1ULL << VIRTIO_NET_F_GUEST_USO4) | \ + (1ULL << VIRTIO_NET_F_GUEST_USO6)) struct virtnet_stat_desc { char desc[ETH_GSTRING_LEN]; @@ -3085,7 +3089,9 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog, virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6) || virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) || virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO) || - virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM))) { + virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM) || + virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_USO4) || + virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_USO6))) { NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing GRO_HW/CSUM, disable GRO_HW/CSUM first"); return -EOPNOTSUPP; } @@ -3690,7 +3696,9 @@ static bool virtnet_check_guest_gso(const struct virtnet_info *vi) return virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO4) || virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6) || virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) || - virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO); + virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO) || + (virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_USO4) && + virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_USO6)); } static void virtnet_set_big_packets(struct virtnet_info *vi, const int mtu) @@ -3759,6 +3767,8 @@ static int virtnet_probe(struct virtio_device *vdev) dev->hw_features |= NETIF_F_TSO6; if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN)) dev->hw_features |= NETIF_F_TSO_ECN; + if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_USO)) + dev->hw_features |= NETIF_F_GSO_UDP_L4; dev->features |= NETIF_F_GSO_ROBUST; @@ -4036,6 +4046,7 @@ static struct virtio_device_id id_table[] = { VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6, \ VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, \ VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO, \ + VIRTIO_NET_F_HOST_USO, VIRTIO_NET_F_GUEST_USO4, VIRTIO_NET_F_GUEST_USO6, \ VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ, \ VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN, \ VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ, \