From patchwork Mon Jul 31 22:31:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuri Benditovich X-Patchwork-Id: 1815281 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20221208.gappssmtp.com header.i=@daynix-com.20221208.gappssmtp.com header.a=rsa-sha256 header.s=20221208 header.b=lV0S2XvK; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RFChF6KZPz1yfG for ; Tue, 1 Aug 2023 08:33:48 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQbRT-00012J-Cw; Mon, 31 Jul 2023 18:32:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQbRR-00011u-He for qemu-devel@nongnu.org; Mon, 31 Jul 2023 18:32:41 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQbRP-0002U9-FB for qemu-devel@nongnu.org; Mon, 31 Jul 2023 18:32:41 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4fe0e23a4b1so7940933e87.3 for ; Mon, 31 Jul 2023 15:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690842757; x=1691447557; 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=PAmE1DyeqznznZSq0BolvkMuK+QiqpygZmLnWgYS8ik=; b=lV0S2XvKanSEyHLsjTijWV16Tjh1utSJlsjrcmz55Se87FiBPxfCfzjSVo/8e5LRgq MbdE3Tp6KK9MKpscFZ14eYw1VSmB2wMBBRP2uGn/K+6fK1sB03UHjZ492FRH8DA5Gb+w ipXiUCgJP/YBKIlR8whCrUSH3n5lajz0TQLz3GgTgMVkMBbS3d9uiHHUwtpOCQM9U8Ya oc+jxAKgU4GW11/siMqxm2Lup5DqzbBJC3g2jntGoWvK4w7YL9A/etuzGneQs2mijCEb VLJYOPZbUMck9kdXe4p2e145ayvPfisHZT63YpYYQxmmH9w/iTEaWL/UpFdwzs1uxAHH zuVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690842757; x=1691447557; 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=PAmE1DyeqznznZSq0BolvkMuK+QiqpygZmLnWgYS8ik=; b=NIvH819q9NfcRhNnJOLjWeSArU259EAoD9wA3PXdtwtpU/iumu8uG0ZGxb6hNRMeYj 2LqI1cwa7i5d4NWh7ybGVR8RX8UbVmapkKS4HyBWUwdJa+r97LwqzeN6hPrnYL7/yCgN Ui4MioE5guySwtIVwC8Pl0Dnk2OWZdRmsuDWkoh+sSnVCUG/g/9QSbo1sIrw9Azic/tN v+EmG3WI+9AtPZ3ZD6ZmMm9Q0oFEm8h++7Ds4vtbOj/SM2NFrWAYz+KAniE2Y4H7YXzb CGALDX+/tYvJRnhRS2oLJCqWnoAdlqBwsnkTqApVrx3rjIJwN8JzzFBSnD4M9MxFj/E6 ecgQ== X-Gm-Message-State: ABy/qLYipzZj38x95ujNtjTCVIlnmyOLVXVKLlgwnGsN+HFFblssvqMn EAVp6/zQKQcdK4d73o54rngT2g== X-Google-Smtp-Source: APBJJlEzRsZZ7nDGNa64eDpWkmO/NZf5YDrPqY1Fb754kaLwphEXs4efNDxaeHITkTrecifp3chP4w== X-Received: by 2002:a05:6512:224a:b0:4fb:7772:7bae with SMTP id i10-20020a056512224a00b004fb77727baemr813684lfu.6.1690842757009; Mon, 31 Jul 2023 15:32:37 -0700 (PDT) Received: from localhost.localdomain ([2a06:c701:46e5:f400:91e1:5f50:afab:4c79]) by smtp.gmail.com with ESMTPSA id x5-20020aa7dac5000000b005223c34259fsm5915088eds.57.2023.07.31.15.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 15:32:36 -0700 (PDT) From: Yuri Benditovich To: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, dmitry.fleytman@gmail.com, akihiko.odaki@daynix.com, jasowang@redhat.com, sriram.yagnaraman@est.tech, mst@redhat.com, sw@weilnetz.de, qemu-devel@nongnu.org Cc: yan@daynix.com Subject: [PATCH v2 1/4] tap: Add USO support to tap device. Date: Tue, 1 Aug 2023 01:31:45 +0300 Message-Id: <20230731223148.1002258-2-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20230731223148.1002258-1-yuri.benditovich@daynix.com> References: <20230731223148.1002258-1-yuri.benditovich@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2a00:1450:4864:20::132; envelope-from=yuri.benditovich@daynix.com; helo=mail-lf1-x132.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Andrew Melnychenko Passing additional parameters (USOv4 and USOv6 offloads) when setting TAP offloads Signed-off-by: Yuri Benditovich Signed-off-by: Andrew Melnychenko --- hw/net/e1000e_core.c | 2 +- hw/net/igb_core.c | 2 +- hw/net/virtio-net.c | 4 +++- hw/net/vmxnet3.c | 2 ++ include/net/net.h | 4 ++-- net/net.c | 4 ++-- net/tap-bsd.c | 2 +- net/tap-linux.c | 15 ++++++++++++--- net/tap-linux.h | 2 ++ net/tap-solaris.c | 2 +- net/tap-stub.c | 2 +- net/tap-win32.c | 2 +- net/tap.c | 6 +++--- net/tap_int.h | 3 ++- 14 files changed, 34 insertions(+), 18 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index f8aeafa16b..d4055956ad 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -2852,7 +2852,7 @@ e1000e_update_rx_offloads(E1000ECore *core) if (core->has_vnet) { qemu_set_offload(qemu_get_queue(core->owner_nic)->peer, - cso_state, 0, 0, 0, 0); + cso_state, 0, 0, 0, 0, 0, 0); } } diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 8b6b75c522..389eef1549 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -2753,7 +2753,7 @@ igb_update_rx_offloads(IGBCore *core) if (core->has_vnet) { qemu_set_offload(qemu_get_queue(core->owner_nic)->peer, - cso_state, 0, 0, 0, 0); + cso_state, 0, 0, 0, 0, 0, 0); } } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 7102ec4817..d2311e7d6e 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -859,7 +859,9 @@ static void virtio_net_apply_guest_offloads(VirtIONet *n) !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_TSO4)), !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_TSO6)), !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_ECN)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_UFO))); + !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_UFO)), + !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_USO4)), + !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_USO6))); } static uint64_t virtio_net_guest_offloads_by_features(uint32_t features) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 5dfacb1098..886adae42b 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -1341,6 +1341,8 @@ static void vmxnet3_update_features(VMXNET3State *s) s->lro_supported, s->lro_supported, 0, + 0, + 0, 0); } } diff --git a/include/net/net.h b/include/net/net.h index 1448d00afb..b5ccfbbffb 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -58,7 +58,7 @@ typedef bool (HasVnetHdr)(NetClientState *); typedef bool (HasVnetHdrLen)(NetClientState *, int); typedef bool (GetUsingVnetHdr)(NetClientState *); typedef void (UsingVnetHdr)(NetClientState *, bool); -typedef void (SetOffload)(NetClientState *, int, int, int, int, int); +typedef void (SetOffload)(NetClientState *, int, int, int, int, int, int, int); typedef int (GetVnetHdrLen)(NetClientState *); typedef void (SetVnetHdrLen)(NetClientState *, int); typedef int (SetVnetLE)(NetClientState *, bool); @@ -192,7 +192,7 @@ bool qemu_has_vnet_hdr_len(NetClientState *nc, int len); bool qemu_get_using_vnet_hdr(NetClientState *nc); void qemu_using_vnet_hdr(NetClientState *nc, bool enable); void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6, - int ecn, int ufo); + int ecn, int ufo, int uso4, int uso6); int qemu_get_vnet_hdr_len(NetClientState *nc); void qemu_set_vnet_hdr_len(NetClientState *nc, int len); int qemu_set_vnet_le(NetClientState *nc, bool is_le); diff --git a/net/net.c b/net/net.c index 6492ad530e..543e6dec43 100644 --- a/net/net.c +++ b/net/net.c @@ -532,13 +532,13 @@ void qemu_using_vnet_hdr(NetClientState *nc, bool enable) } void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6, - int ecn, int ufo) + int ecn, int ufo, int uso4, int uso6) { if (!nc || !nc->info->set_offload) { return; } - nc->info->set_offload(nc, csum, tso4, tso6, ecn, ufo); + nc->info->set_offload(nc, csum, tso4, tso6, ecn, ufo, uso4, uso6); } int qemu_get_vnet_hdr_len(NetClientState *nc) diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 4c98fdd337..abd16a2ad2 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -232,7 +232,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) } void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo) + int tso6, int ecn, int ufo, int uso4, int uso6) { } diff --git a/net/tap-linux.c b/net/tap-linux.c index f54f308d35..30fcca1bc2 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -237,7 +237,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) } void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo) + int tso6, int ecn, int ufo, int uso4, int uso6) { unsigned int offload = 0; @@ -256,13 +256,22 @@ void tap_fd_set_offload(int fd, int csum, int tso4, offload |= TUN_F_TSO_ECN; if (ufo) offload |= TUN_F_UFO; + if (uso4) { + offload |= TUN_F_USO4; + } + if (uso6) { + offload |= TUN_F_USO6; + } } if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) { - offload &= ~TUN_F_UFO; + offload &= ~(TUN_F_USO4 | TUN_F_USO6); if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) { - fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n", + offload &= ~TUN_F_UFO; + if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) { + fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n", strerror(errno)); + } } } } diff --git a/net/tap-linux.h b/net/tap-linux.h index bbbb62c2a7..9a58cecb7f 100644 --- a/net/tap-linux.h +++ b/net/tap-linux.h @@ -50,5 +50,7 @@ #define TUN_F_TSO6 0x04 /* I can handle TSO for IPv6 packets */ #define TUN_F_TSO_ECN 0x08 /* I can handle TSO with ECN bits. */ #define TUN_F_UFO 0x10 /* I can handle UFO packets */ +#define TUN_F_USO4 0x20 /* I can handle USO for IPv4 packets */ +#define TUN_F_USO6 0x40 /* I can handle USO for IPv6 packets */ #endif /* QEMU_TAP_LINUX_H */ diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 38e15028bf..a617a10e5c 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -236,7 +236,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) } void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo) + int tso6, int ecn, int ufo, int uso4, int uso6) { } diff --git a/net/tap-stub.c b/net/tap-stub.c index a0fa25804b..ac8dfc03b4 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -67,7 +67,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) } void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo) + int tso6, int ecn, int ufo, int uso4, int uso6) { } diff --git a/net/tap-win32.c b/net/tap-win32.c index f327d62ab0..7b8b4be02c 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -741,7 +741,7 @@ static void tap_using_vnet_hdr(NetClientState *nc, bool using_vnet_hdr) } static void tap_set_offload(NetClientState *nc, int csum, int tso4, - int tso6, int ecn, int ufo) + int tso6, int ecn, int ufo, int uso4, int uso6) { } diff --git a/net/tap.c b/net/tap.c index 1bf085d422..14ea4ef26f 100644 --- a/net/tap.c +++ b/net/tap.c @@ -307,14 +307,14 @@ static int tap_set_vnet_be(NetClientState *nc, bool is_be) } static void tap_set_offload(NetClientState *nc, int csum, int tso4, - int tso6, int ecn, int ufo) + int tso6, int ecn, int ufo, int uso4, int uso6) { TAPState *s = DO_UPCAST(TAPState, nc, nc); if (s->fd < 0) { return; } - tap_fd_set_offload(s->fd, csum, tso4, tso6, ecn, ufo); + tap_fd_set_offload(s->fd, csum, tso4, tso6, ecn, ufo, uso4, uso6); } static void tap_exit_notify(Notifier *notifier, void *data) @@ -414,7 +414,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer, s->using_vnet_hdr = false; s->has_ufo = tap_probe_has_ufo(s->fd); s->enabled = true; - tap_set_offload(&s->nc, 0, 0, 0, 0, 0); + tap_set_offload(&s->nc, 0, 0, 0, 0, 0, 0, 0); /* * Make sure host header length is set correctly in tap: * it might have been modified by another instance of qemu. diff --git a/net/tap_int.h b/net/tap_int.h index 547f8a5a28..d8861d81ba 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -37,7 +37,8 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp); int tap_probe_vnet_hdr(int fd, Error **errp); int tap_probe_vnet_hdr_len(int fd, int len); int tap_probe_has_ufo(int fd); -void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo); +void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo, + int uso4, int uso6); void tap_fd_set_vnet_hdr_len(int fd, int len); int tap_fd_set_vnet_le(int fd, int vnet_is_le); int tap_fd_set_vnet_be(int fd, int vnet_is_be); From patchwork Mon Jul 31 22:31:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuri Benditovich X-Patchwork-Id: 1815280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20221208.gappssmtp.com header.i=@daynix-com.20221208.gappssmtp.com header.a=rsa-sha256 header.s=20221208 header.b=PSNYho2O; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RFChG2JW0z20G3 for ; Tue, 1 Aug 2023 08:33:48 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQbRT-00012Q-P9; Mon, 31 Jul 2023 18:32:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQbRS-000124-9j for qemu-devel@nongnu.org; Mon, 31 Jul 2023 18:32:42 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQbRQ-0002UT-Gg for qemu-devel@nongnu.org; Mon, 31 Jul 2023 18:32:42 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-31763b2c5a4so5153097f8f.3 for ; Mon, 31 Jul 2023 15:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690842759; x=1691447559; 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=/C3GsHFScwRvNPkmYfHnFJs052Dw/j4Lwl+ku+3sy6M=; b=PSNYho2OYlUhimrOLaOQbIXNLCEMAmLAy96urojX34mPawSjXMSlE5Zj4T78PNKwZW 33DBaj9Je5yb0GI/U66XmV+97ApKLK7bvFrDc0qfla4nE/wTFS6vPqLIlJXEClEAKkls tFrbUsHOII4V326FWXRGCK+EkzfirSpAsGdlrKFWbdM9dzzQPcCWLzYbOhe+xCvD+3jm +OLijRm/Qd8C4X82TK3dQyLbf46FcEOl+X686EmkAnu+8W2kLu9ZMtBYn2BH0lz1wPWy 49xodUEWqCsfJlwPJFFrE+Zy7cH3ThqjgthfhmF0BllSos4UfjhMySGhavfP5TijxNBt lYfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690842759; x=1691447559; 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=/C3GsHFScwRvNPkmYfHnFJs052Dw/j4Lwl+ku+3sy6M=; b=hyl4SYIWRpKTXK4ViZsD4fuMBCbWsLWHlEwMsXNGpgrkG/IBb1zm1k1rSZOHnxPVxv qOnlc/x5PnPDMI1XYwXKCXaQ2wUDyytZ1UghK3kEKaU3vsWNyCbfqdmwt5H6cQ6g8Bt/ dT+bD0MNs0BaOz/uHC7aMYccB9mupY17BtnLCDHkqvyPN8fLOBODl2sOYU5yDb7rXAzu yBB4mcWYbCHFhW9Ec2QbPPWmIyY1rPCACe2Puw8nbxi8eUwTMVcCzSrKFtVzL8rl0Zcv uxT/Wmn6aD6fwVewLkIR+xYRAKz8KHMMsHEhF6sFuN4SFbLW//9w7TbGNm1LrQSx7Zkg VvlQ== X-Gm-Message-State: ABy/qLa0hiGBm+Redp2qXNz6+Y7EpGMeGkkRKEEn8g8V/20AhKX9fVUt rIYgC1P3WVa04+FkP5BJOmppEQ== X-Google-Smtp-Source: APBJJlE5QFQJXkviQwWvh6+tR3URsj2x60lEciuUv+lXdgwa8Cumus5S19F8+86TD9Biuqpk4rxO1Q== X-Received: by 2002:a5d:50d0:0:b0:317:3c89:7f03 with SMTP id f16-20020a5d50d0000000b003173c897f03mr969491wrt.5.1690842758525; Mon, 31 Jul 2023 15:32:38 -0700 (PDT) Received: from localhost.localdomain ([2a06:c701:46e5:f400:91e1:5f50:afab:4c79]) by smtp.gmail.com with ESMTPSA id x5-20020aa7dac5000000b005223c34259fsm5915088eds.57.2023.07.31.15.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 15:32:38 -0700 (PDT) From: Yuri Benditovich To: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, dmitry.fleytman@gmail.com, akihiko.odaki@daynix.com, jasowang@redhat.com, sriram.yagnaraman@est.tech, mst@redhat.com, sw@weilnetz.de, qemu-devel@nongnu.org Cc: yan@daynix.com Subject: [PATCH v2 2/4] tap: Add check for USO features Date: Tue, 1 Aug 2023 01:31:46 +0300 Message-Id: <20230731223148.1002258-3-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20230731223148.1002258-1-yuri.benditovich@daynix.com> References: <20230731223148.1002258-1-yuri.benditovich@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2a00:1450:4864:20::430; envelope-from=yuri.benditovich@daynix.com; helo=mail-wr1-x430.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Tap indicates support for USO features according to capabilities of current kernel module. Signed-off-by: Yuri Benditovich Signed-off-by: Andrew Melnychecnko --- include/net/net.h | 3 +++ net/net.c | 9 +++++++++ net/tap-bsd.c | 5 +++++ net/tap-linux.c | 12 ++++++++++++ net/tap-solaris.c | 5 +++++ net/tap-stub.c | 5 +++++ net/tap.c | 12 ++++++++++++ net/tap_int.h | 1 + 8 files changed, 52 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index b5ccfbbffb..330d285930 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -54,6 +54,7 @@ typedef void (LinkStatusChanged)(NetClientState *); typedef void (NetClientDestructor)(NetClientState *); typedef RxFilterInfo *(QueryRxFilter)(NetClientState *); typedef bool (HasUfo)(NetClientState *); +typedef bool (HasUso)(NetClientState *); typedef bool (HasVnetHdr)(NetClientState *); typedef bool (HasVnetHdrLen)(NetClientState *, int); typedef bool (GetUsingVnetHdr)(NetClientState *); @@ -84,6 +85,7 @@ typedef struct NetClientInfo { QueryRxFilter *query_rx_filter; NetPoll *poll; HasUfo *has_ufo; + HasUso *has_uso; HasVnetHdr *has_vnet_hdr; HasVnetHdrLen *has_vnet_hdr_len; GetUsingVnetHdr *get_using_vnet_hdr; @@ -187,6 +189,7 @@ void qemu_set_info_str(NetClientState *nc, const char *fmt, ...) G_GNUC_PRINTF(2, 3); void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]); bool qemu_has_ufo(NetClientState *nc); +bool qemu_has_uso(NetClientState *nc); bool qemu_has_vnet_hdr(NetClientState *nc); bool qemu_has_vnet_hdr_len(NetClientState *nc, int len); bool qemu_get_using_vnet_hdr(NetClientState *nc); diff --git a/net/net.c b/net/net.c index 543e6dec43..b110e61f66 100644 --- a/net/net.c +++ b/net/net.c @@ -495,6 +495,15 @@ bool qemu_has_ufo(NetClientState *nc) return nc->info->has_ufo(nc); } +bool qemu_has_uso(NetClientState *nc) +{ + if (!nc || !nc->info->has_uso) { + return false; + } + + return nc->info->has_uso(nc); +} + bool qemu_has_vnet_hdr(NetClientState *nc) { if (!nc || !nc->info->has_vnet_hdr) { diff --git a/net/tap-bsd.c b/net/tap-bsd.c index abd16a2ad2..274ea7bd2c 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -212,6 +212,11 @@ int tap_probe_has_ufo(int fd) return 0; } +int tap_probe_has_uso(int fd) +{ + return 0; +} + int tap_probe_vnet_hdr_len(int fd, int len) { return 0; diff --git a/net/tap-linux.c b/net/tap-linux.c index 30fcca1bc2..c7e514ecb0 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -173,6 +173,18 @@ int tap_probe_has_ufo(int fd) return 1; } +int tap_probe_has_uso(int fd) +{ + unsigned offload; + + offload = TUN_F_CSUM | TUN_F_USO4 | TUN_F_USO6; + + if (ioctl(fd, TUNSETOFFLOAD, offload) < 0) { + return 0; + } + return 1; +} + /* Verify that we can assign given length */ int tap_probe_vnet_hdr_len(int fd, int len) { diff --git a/net/tap-solaris.c b/net/tap-solaris.c index a617a10e5c..08b13af512 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -216,6 +216,11 @@ int tap_probe_has_ufo(int fd) return 0; } +int tap_probe_has_uso(int fd) +{ + return 0; +} + int tap_probe_vnet_hdr_len(int fd, int len) { return 0; diff --git a/net/tap-stub.c b/net/tap-stub.c index ac8dfc03b4..4b24f61e3a 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -47,6 +47,11 @@ int tap_probe_has_ufo(int fd) return 0; } +int tap_probe_has_uso(int fd) +{ + return 0; +} + int tap_probe_vnet_hdr_len(int fd, int len) { return 0; diff --git a/net/tap.c b/net/tap.c index 14ea4ef26f..bcea8d03f9 100644 --- a/net/tap.c +++ b/net/tap.c @@ -57,6 +57,7 @@ typedef struct TAPState { bool write_poll; bool using_vnet_hdr; bool has_ufo; + bool has_uso; bool enabled; VHostNetState *vhost_net; unsigned host_vnet_hdr_len; @@ -237,6 +238,15 @@ static bool tap_has_ufo(NetClientState *nc) return s->has_ufo; } +static bool tap_has_uso(NetClientState *nc) +{ + TAPState *s = DO_UPCAST(TAPState, nc, nc); + + assert(nc->info->type == NET_CLIENT_DRIVER_TAP); + + return s->has_uso; +} + static bool tap_has_vnet_hdr(NetClientState *nc) { TAPState *s = DO_UPCAST(TAPState, nc, nc); @@ -384,6 +394,7 @@ static NetClientInfo net_tap_info = { .poll = tap_poll, .cleanup = tap_cleanup, .has_ufo = tap_has_ufo, + .has_uso = tap_has_uso, .has_vnet_hdr = tap_has_vnet_hdr, .has_vnet_hdr_len = tap_has_vnet_hdr_len, .get_using_vnet_hdr = tap_get_using_vnet_hdr, @@ -413,6 +424,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer, s->host_vnet_hdr_len = vnet_hdr ? sizeof(struct virtio_net_hdr) : 0; s->using_vnet_hdr = false; s->has_ufo = tap_probe_has_ufo(s->fd); + s->has_uso = tap_probe_has_uso(s->fd); s->enabled = true; tap_set_offload(&s->nc, 0, 0, 0, 0, 0, 0, 0); /* diff --git a/net/tap_int.h b/net/tap_int.h index d8861d81ba..9a2175655b 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -37,6 +37,7 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp); int tap_probe_vnet_hdr(int fd, Error **errp); int tap_probe_vnet_hdr_len(int fd, int len); int tap_probe_has_ufo(int fd); +int tap_probe_has_uso(int fd); void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo, int uso4, int uso6); void tap_fd_set_vnet_hdr_len(int fd, int len); From patchwork Mon Jul 31 22:31:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuri Benditovich X-Patchwork-Id: 1815284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20221208.gappssmtp.com header.i=@daynix-com.20221208.gappssmtp.com header.a=rsa-sha256 header.s=20221208 header.b=Jmu/m+om; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RFChW07DYz20G3 for ; Tue, 1 Aug 2023 08:34:02 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQbRW-00013S-9U; Mon, 31 Jul 2023 18:32:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQbRT-00012C-2j for qemu-devel@nongnu.org; Mon, 31 Jul 2023 18:32:43 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQbRR-0002Ug-EK for qemu-devel@nongnu.org; Mon, 31 Jul 2023 18:32:42 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-31783d02093so4600069f8f.0 for ; Mon, 31 Jul 2023 15:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690842760; x=1691447560; 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=Iu/VH6iMKuUxxyQPM1EhE4e/T9vxFBVOqC59TnKMtyQ=; b=Jmu/m+omskc2AbleBTZ48SoHvBO55LzYQHghrlBuvp0tHmKs1W0BSQNBO/HttM0sky phPmZ/opIH4ONfpV0nZXPtAkmHkygyy2UhFi87rVMQ6bhkVxmgXDBjtzlAyXsBEOcAEm Iy5e2T32QRTUFC5B2xVXRJXZOpzUy/bixDMFAgADg2HOE3sRk5RpiJNBAPnAH50HTvdN d0rv+10LsXom9PQoglHgat7pFsh1aAARhFhrTp+ZJGXLjsAE59Vhz/x2PGDNwTuEoO7P k3eXeqwqVi1WyZUiropUQqC2mXyVYcR6I8giK1+DBvdAk9WTpJG7F3aZod2uox8Lc0dk hnBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690842760; x=1691447560; 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=Iu/VH6iMKuUxxyQPM1EhE4e/T9vxFBVOqC59TnKMtyQ=; b=RxfAO5Dy0ACz3KHzRmoeEYfN93DU7gdsUfXNk4cgTM7mHIYqY0r7G3VjmrpcMPMshz CxRWcuEdRmVssap4QHGOVIM1yLZaTSK6X8Og5AXhBT9jJkN0vJEFV/BvHr/Luqcnf4VN 6Z8R2RWvxQAwg2GimABKVFLXcS2K5HR8QLIuZUnRlj9DpBI73LC9xjQdA20A6Nz75Cjm ShmQrhHdW6EKD3U+lEjdv79Y6TqB7URIOY6u8QyA8dT9BWloBsP3NnPvjfaiJArnEmv4 XwXjD7rpz/kGKiZuh1hTqUJKpiACJGHvMpMMmDpP0fH3Ftg4oayUMG7GW7aj/SRlFW64 CaoQ== X-Gm-Message-State: ABy/qLZEl4kLBzQPDz/XEr16yjeuvyfjRAT4WecqrOQvUavI4h6eAWBO bLJKrxJM0g6yu8Sfsdh9yWycMg== X-Google-Smtp-Source: APBJJlFfaNWID1x7cwHA3j2FAiofWytmWlbV1wTNbuasG+lJuvUHSBZ6aYi4f4Lsqc0/355rgUPrkA== X-Received: by 2002:a5d:43c3:0:b0:317:734e:3614 with SMTP id v3-20020a5d43c3000000b00317734e3614mr774350wrr.39.1690842760009; Mon, 31 Jul 2023 15:32:40 -0700 (PDT) Received: from localhost.localdomain ([2a06:c701:46e5:f400:91e1:5f50:afab:4c79]) by smtp.gmail.com with ESMTPSA id x5-20020aa7dac5000000b005223c34259fsm5915088eds.57.2023.07.31.15.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 15:32:39 -0700 (PDT) From: Yuri Benditovich To: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, dmitry.fleytman@gmail.com, akihiko.odaki@daynix.com, jasowang@redhat.com, sriram.yagnaraman@est.tech, mst@redhat.com, sw@weilnetz.de, qemu-devel@nongnu.org Cc: yan@daynix.com Subject: [PATCH v2 3/4] virtio-net: Add USO flags to vhost support. Date: Tue, 1 Aug 2023 01:31:47 +0300 Message-Id: <20230731223148.1002258-4-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20230731223148.1002258-1-yuri.benditovich@daynix.com> References: <20230731223148.1002258-1-yuri.benditovich@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2a00:1450:4864:20::434; envelope-from=yuri.benditovich@daynix.com; helo=mail-wr1-x434.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Andrew Melnychenko New features are subject to check with vhost-user and vdpa. Signed-off-by: Yuri Benditovich Signed-off-by: Andrew Melnychenko --- hw/net/vhost_net.c | 3 +++ net/vhost-vdpa.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 6b958d6363..57427a3997 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -78,6 +78,9 @@ static const int user_feature_bits[] = { VIRTIO_F_RING_RESET, VIRTIO_NET_F_RSS, VIRTIO_NET_F_HASH_REPORT, + VIRTIO_NET_F_GUEST_USO4, + VIRTIO_NET_F_GUEST_USO6, + VIRTIO_NET_F_HOST_USO, /* This bit implies RARP isn't sent by QEMU out of band */ VIRTIO_NET_F_GUEST_ANNOUNCE, diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 9795306742..1dca37aae2 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -75,11 +75,14 @@ const int vdpa_feature_bits[] = { VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, VIRTIO_NET_F_GUEST_UFO, + VIRTIO_NET_F_GUEST_USO4, + VIRTIO_NET_F_GUEST_USO6, VIRTIO_NET_F_HASH_REPORT, VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6, VIRTIO_NET_F_HOST_UFO, + VIRTIO_NET_F_HOST_USO, VIRTIO_NET_F_MQ, VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_MTU, From patchwork Mon Jul 31 22:31:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuri Benditovich X-Patchwork-Id: 1815283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20221208.gappssmtp.com header.i=@daynix-com.20221208.gappssmtp.com header.a=rsa-sha256 header.s=20221208 header.b=aeTXkq0t; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RFChV0wjfz1yfG for ; Tue, 1 Aug 2023 08:34:02 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQbRW-00013T-C6; Mon, 31 Jul 2023 18:32:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQbRU-00012w-G0 for qemu-devel@nongnu.org; Mon, 31 Jul 2023 18:32:44 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQbRS-0002Uy-Sb for qemu-devel@nongnu.org; Mon, 31 Jul 2023 18:32:44 -0400 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-522462d8416so6937670a12.1 for ; Mon, 31 Jul 2023 15:32:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690842761; x=1691447561; 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=kZEWQmnQQOwrf5Z+6mr58v42rgmvWm2TczTVPz1HEYc=; b=aeTXkq0tKcmnxsu12eJLQ5JQZIWH/PFZ6To49Q2eQLiq0H6LH1pEl1WCYVtnK/Fl7D cBkTH16pjdK40mx6KwxFdGyzrv1TcvATgYDVz0LzdirtxpUzdsHQMY/M2d7lJkn95b/f ekVfwr23aTEEK+Bi/uixEK10KnxcHVeVSAxkjSXdX1Fxpnik27hYBJLBNfo+1u3jyU9m EF3d9gCYCmAfhQuEdqWNOisOe5bxO/itFijWeSxT3wdzAPDIPdlXvnFfRZjC6kFf1bNC by9ppV90Sbonfthu1KD3KT1Q5phSeS+MTLMK9o2uNfQDzrOorhxCCMYLDWQhpvfofd1A h7Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690842761; x=1691447561; 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=kZEWQmnQQOwrf5Z+6mr58v42rgmvWm2TczTVPz1HEYc=; b=XC7UsBUII6/dX9TuCAogPJxqPrQ5zz4mA0K4QJuLH6jxd+oWGNtc+XPvGRPJOjQEUz /IUJSUcczHaZ9wRBYyL6n/gAhPTSBl18Jbdbmeh7sHlO8x3A3+7EzzLqM8IiiwVATnDQ kl7MlxE2Jt48LrCvJ3QEXYv4aEXtn7Zg6z29OZuuvDjLKfq9dpAWmZ0nTifvdC/nKQ8L PSillW2rvtcJCiaETggyDfhtT3eZq8fCjGq6XP8zrgUH+/MrVwS4Zl9jgKonG4EfoQ53 25dQTox6VQnmorPJndeW4z13dMHOHZRRGs+/IT4VN21zFHcLis9wydUpcwrSaN2TrIP0 GgcQ== X-Gm-Message-State: ABy/qLYZaAq7hI8fKrTxzpumR4WJ5p2MnwfefqIQ1RVCL9DafA9OpIHM CT6wKGaUbHUxM163Fv8H84KZnw== X-Google-Smtp-Source: APBJJlGR5UIMJO/w/eGqXMZYNOvtGi09nG0ABA+coGinDCenDbgp1/lQ5itSXtipDwBOhVLzYARG3w== X-Received: by 2002:aa7:c70c:0:b0:522:1d1d:1de8 with SMTP id i12-20020aa7c70c000000b005221d1d1de8mr834765edq.2.1690842761468; Mon, 31 Jul 2023 15:32:41 -0700 (PDT) Received: from localhost.localdomain ([2a06:c701:46e5:f400:91e1:5f50:afab:4c79]) by smtp.gmail.com with ESMTPSA id x5-20020aa7dac5000000b005223c34259fsm5915088eds.57.2023.07.31.15.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 15:32:41 -0700 (PDT) From: Yuri Benditovich To: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, dmitry.fleytman@gmail.com, akihiko.odaki@daynix.com, jasowang@redhat.com, sriram.yagnaraman@est.tech, mst@redhat.com, sw@weilnetz.de, qemu-devel@nongnu.org Cc: yan@daynix.com Subject: [PATCH v2 4/4] virtio-net: Add support for USO features Date: Tue, 1 Aug 2023 01:31:48 +0300 Message-Id: <20230731223148.1002258-5-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20230731223148.1002258-1-yuri.benditovich@daynix.com> References: <20230731223148.1002258-1-yuri.benditovich@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2a00:1450:4864:20::536; envelope-from=yuri.benditovich@daynix.com; helo=mail-ed1-x536.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org USO features of virtio-net device depend on kernel ability to support them, for backward compatibility by default the features are disabled on 8.0 and earlier. Signed-off-by: Yuri Benditovich Signed-off-by: Andrew Melnychecnko --- hw/core/machine.c | 4 ++++ hw/net/virtio-net.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index f0d35c6401..a725e76738 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -38,10 +38,14 @@ #include "exec/confidential-guest-support.h" #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-pci.h" +#include "hw/virtio/virtio-net.h" GlobalProperty hw_compat_8_0[] = { { "migration", "multifd-flush-after-each-section", "on"}, { TYPE_PCI_DEVICE, "x-pcie-ari-nextfn-1", "on" }, + { TYPE_VIRTIO_NET, "host_uso", "off"}, + { TYPE_VIRTIO_NET, "guest_uso4", "off"}, + { TYPE_VIRTIO_NET, "guest_uso6", "off"}, }; const size_t hw_compat_8_0_len = G_N_ELEMENTS(hw_compat_8_0); diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index d2311e7d6e..bd0ead94fe 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -659,6 +659,15 @@ static int peer_has_ufo(VirtIONet *n) return n->has_ufo; } +static int peer_has_uso(VirtIONet *n) +{ + if (!peer_has_vnet_hdr(n)) { + return 0; + } + + return qemu_has_uso(qemu_get_queue(n->nic)->peer); +} + static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs, int version_1, int hash_report) { @@ -796,6 +805,10 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features, virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_TSO6); virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ECN); + virtio_clear_feature(&features, VIRTIO_NET_F_HOST_USO); + virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO4); + virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO6); + virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT); } @@ -804,6 +817,12 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features, virtio_clear_feature(&features, VIRTIO_NET_F_HOST_UFO); } + if (!peer_has_uso(n)) { + virtio_clear_feature(&features, VIRTIO_NET_F_HOST_USO); + virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO4); + virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO6); + } + if (!get_vhost_net(nc->peer)) { return features; } @@ -864,14 +883,16 @@ static void virtio_net_apply_guest_offloads(VirtIONet *n) !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_USO6))); } -static uint64_t virtio_net_guest_offloads_by_features(uint32_t features) +static uint64_t virtio_net_guest_offloads_by_features(uint64_t features) { static const uint64_t guest_offloads_mask = (1ULL << VIRTIO_NET_F_GUEST_CSUM) | (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); return guest_offloads_mask & features; } @@ -3924,6 +3945,12 @@ static Property virtio_net_properties[] = { DEFINE_PROP_INT32("speed", VirtIONet, net_conf.speed, SPEED_UNKNOWN), DEFINE_PROP_STRING("duplex", VirtIONet, net_conf.duplex_str), DEFINE_PROP_BOOL("failover", VirtIONet, failover, false), + DEFINE_PROP_BIT64("guest_uso4", VirtIONet, host_features, + VIRTIO_NET_F_GUEST_USO4, true), + DEFINE_PROP_BIT64("guest_uso6", VirtIONet, host_features, + VIRTIO_NET_F_GUEST_USO6, true), + DEFINE_PROP_BIT64("host_uso", VirtIONet, host_features, + VIRTIO_NET_F_HOST_USO, true), DEFINE_PROP_END_OF_LIST(), };