From nobody Tue Nov 5 10:51:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1726363599; cv=none; d=zohomail.com; s=zohoarc; b=VclHI4vQGAxgYM4sGr8K7UHKJN0QWO0+outDw9qqOalszqJVM/f+xPgYEyBHxNrZKOYNdDyQaeEWfrHd0mUq4SVWAqFDb295lkkI2cv1zFzLXthIWWqyZzbGHl7DGB9pVvs7+pAC4HNPCzVVVQJRG6T7wCwiBiAyVttf0Cy4zMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726363599; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mCu6mvOatJtGAfDwhnsDWwsDctuJ051UjuOLN4ujdpw=; b=Q1p60sqRM64ulmzZK/oMRhkQmCxJOjVOCQQuRbxUgAImKd1qf3J0bMSyW+p4G0CmALjtWx1p7eXk9BlpUtTBOVvd9Hw/52kp0Iusgsd+mala46iePWxAnmcUxJbcwVSH95XFW6kCPboSc/+/5CFMNFQkAkXCL5OUPZs2w8SWKls= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726363599736985.2893958912293; Sat, 14 Sep 2024 18:26:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1spe0v-0004Yz-AB; Sat, 14 Sep 2024 21:25:21 -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 1spe0s-0004G4-1G for qemu-devel@nongnu.org; Sat, 14 Sep 2024 21:25:18 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1spe0q-0005eM-5p for qemu-devel@nongnu.org; Sat, 14 Sep 2024 21:25:17 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-7d916b6a73aso2007253a12.1 for ; Sat, 14 Sep 2024 18:25:15 -0700 (PDT) Received: from localhost ([210.160.217.68]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7db4998b773sm1760892a12.57.2024.09.14.18.25.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 14 Sep 2024 18:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1726363514; x=1726968314; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=mCu6mvOatJtGAfDwhnsDWwsDctuJ051UjuOLN4ujdpw=; b=mFWFcqPDgh+WOy90CwYEQlYq+JtksSvMfq+99kIz9mtVa+F8wV9x9KkEFl0yl0lb7o Yz6JvXnseMwhlYL8S8t8jzlEcokrf8wBB3c4/ETtXINWa9ONUA7E4llJY1tZD91XOqgN r6BCFQuhrRTkVx6a3rNSrje5iqJI7paYWjJerDt8LLVuF+143TuehflbLC+SvP3Otshc XYS2K3k1cqmotzEeYqlt/ZCJZ9Sg+KuxJf8LPUjAPNkczj5jFx0mj1X9evGZ6CMU2sQz Mn9IMUNwXW8zLTk+UcasiRZROp2s76+1pMTyo44TFtIO92EomGTVO9mwSUQDNVzyPqRL KTFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726363514; x=1726968314; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mCu6mvOatJtGAfDwhnsDWwsDctuJ051UjuOLN4ujdpw=; b=EBDMxaQt0PnMF1SyGU4RSE7qCBVHLVyROYAJB54gEAUk/BM8/HQCmtD7f7rrafqenF dkSM98gXQ/h9g3aw507JM9p4HyZrq3Zt7qNihuLeXQLcx1YlmUdaGYluZF9kzbmziPaV gEfJbfSgQYoUbmsPpmhMgUsXgueSvAJ0cmgY6kETUmo/sRMWwmptyGfeCFTecN9aLWuN iLeeAREg7js/bFYtYr/5OdEJHHt9ev/JuiU4DPMJM7zYDgjeldhUi18FDKkCFRhTGLQT VrT4rGivkfUVzghz3O4WV+GSeZwJi7jXWZiBD57UCaShcK4cfvB4fGleoq+gb8rrRewH 9GGA== X-Gm-Message-State: AOJu0YyNnW/47xlHdTcU5OXVD/Xb+y7DLSvM5vjK7boP8xWcxTO/+Zlw MbwbAB8x+FkZxywH31Ies+3LDJZg8CO3+6V6lGu99RekkBjZzU/3lmm0llyHKV6mGpvdNzLxk16 +Xdw= X-Google-Smtp-Source: AGHT+IHfSNLfVM5uZbgj+f8joU/AHheFTp5H/z7qAU+HCi1JJSSFicx8EO6oW/VsKjIyJDCXlG32Hw== X-Received: by 2002:a05:6a21:3981:b0:1d1:13de:68c6 with SMTP id adf61e73a8af0-1d113de68camr12429962637.29.1726363514157; Sat, 14 Sep 2024 18:25:14 -0700 (PDT) From: Akihiko Odaki Date: Sun, 15 Sep 2024 10:23:51 +0900 Subject: [PATCH RFC v3 10/11] tap: Report virtio-net hashing support on Linux MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240915-hash-v3-10-79cb08d28647@daynix.com> References: <20240915-hash-v3-0-79cb08d28647@daynix.com> In-Reply-To: <20240915-hash-v3-0-79cb08d28647@daynix.com> To: qemu-devel@nongnu.org, Yuri Benditovich , Andrew Melnychenko , "Michael S . Tsirkin" , Jason Wang Cc: Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::52d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x52d.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1726363600227116600 This allows offloading virtio-net hashing to tap on Linux. Signed-off-by: Akihiko Odaki --- net/tap-linux.h | 1 + net/tap_int.h | 1 + net/tap-bsd.c | 5 +++++ net/tap-linux.c | 13 +++++++++++++ net/tap-solaris.c | 5 +++++ net/tap-stub.c | 5 +++++ net/tap.c | 8 ++++++++ 7 files changed, 38 insertions(+) diff --git a/net/tap-linux.h b/net/tap-linux.h index 5fac64c24f99..c773609c799e 100644 --- a/net/tap-linux.h +++ b/net/tap-linux.h @@ -32,6 +32,7 @@ #define TUNSETVNETLE _IOW('T', 220, int) #define TUNSETVNETBE _IOW('T', 222, int) #define TUNSETSTEERINGEBPF _IOR('T', 224, int) +#define TUNGETVNETHASHCAP _IOR('T', 228, NetVnetHash) #define TUNSETVNETHASH _IOW('T', 229, NetVnetHash) =20 #endif diff --git a/net/tap_int.h b/net/tap_int.h index e1b53e343397..84a88841b720 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -36,6 +36,7 @@ ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxl= en); =20 void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp); int tap_probe_vnet_hdr(int fd, Error **errp); +bool tap_probe_vnet_hash_supported_types(int fd, uint32_t *types); 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, diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 2eee0c0a0ec5..142e1abe0420 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -217,6 +217,11 @@ int tap_probe_has_uso(int fd) return 0; } =20 +bool tap_probe_vnet_hash_supported_types(int fd, uint32_t *types) +{ + return false; +} + void tap_fd_set_vnet_hdr_len(int fd, int len) { } diff --git a/net/tap-linux.c b/net/tap-linux.c index e96d38eec922..a601cb1ed2d9 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -185,6 +185,19 @@ int tap_probe_has_uso(int fd) return 1; } =20 +bool tap_probe_vnet_hash_supported_types(int fd, uint32_t *types) +{ + NetVnetHash hash; + + if (ioctl(fd, TUNGETVNETHASHCAP, &hash)) { + return false; + } + + *types =3D hash.types; + + return true; +} + void tap_fd_set_vnet_hdr_len(int fd, int len) { if (ioctl(fd, TUNSETVNETHDRSZ, &len) =3D=3D -1) { diff --git a/net/tap-solaris.c b/net/tap-solaris.c index c65104b84e93..00d1c850680d 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -221,6 +221,11 @@ int tap_probe_has_uso(int fd) return 0; } =20 +bool tap_probe_vnet_hash_supported_types(int fd, uint32_t *types) +{ + return false; +} + void tap_fd_set_vnet_hdr_len(int fd, int len) { } diff --git a/net/tap-stub.c b/net/tap-stub.c index 5bdc76216b7f..a4718654fbeb 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -52,6 +52,11 @@ int tap_probe_has_uso(int fd) return 0; } =20 +bool tap_probe_vnet_hash_supported_types(int fd, uint32_t *types) +{ + return false; +} + void tap_fd_set_vnet_hdr_len(int fd, int len) { } diff --git a/net/tap.c b/net/tap.c index 8d451c745d70..e17565c2ac3c 100644 --- a/net/tap.c +++ b/net/tap.c @@ -248,6 +248,13 @@ static void tap_set_vnet_hdr_len(NetClientState *nc, i= nt len) s->using_vnet_hdr =3D true; } =20 +static bool tap_get_vnet_hash_supported_types(NetClientState *nc, + uint32_t *types) +{ + TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + return tap_probe_vnet_hash_supported_types(s->fd, types); +} + static void tap_set_vnet_hash(NetClientState *nc, const NetVnetHash *hash) { TAPState *s =3D DO_UPCAST(TAPState, nc, nc); @@ -350,6 +357,7 @@ static NetClientInfo net_tap_info =3D { .has_vnet_hdr_len =3D tap_has_vnet_hdr_len, .set_offload =3D tap_set_offload, .set_vnet_hdr_len =3D tap_set_vnet_hdr_len, + .get_vnet_hash_supported_types =3D tap_get_vnet_hash_supported_types, .set_vnet_hash =3D tap_set_vnet_hash, .set_vnet_le =3D tap_set_vnet_le, .set_vnet_be =3D tap_set_vnet_be, --=20 2.46.0