From nobody Tue Nov 5 10:44:49 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=1726363589; cv=none; d=zohomail.com; s=zohoarc; b=bJ6804Q5y4Hgo+HYQiY4WXzMD/XL20kMIEwsaldxuscolNxu/0MsQN3QVSVVs9Yb/V3IkHvpcXyKsv5MwR1Nu2EN5pmfpoe1o+M6/oi2No4GZuTEAsxemIuatG0aotuoMtlqkgsftATFKhzG1/nKyMnLe7me9AwhAvCz3M2aTxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726363589; 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=yTKMLrThNs3dDMSlreK+ICpdf6za+wNhj1qJUdDtbIo=; b=LLVN2vTtaL5hPvjPaBe13Qeea774RajncO/1IX8HGo6SG4GusWrORbLA/QA4q4rBIzzBAEhwVR//2qfMUleFBpUdsl4MVYAZyxK0hBTNOrGEXjkXEW7qSZWrhby/6x35Zjap9TEoDuYzpitcuzi9kBgm+2p5F4XbrvQ37hANHWs= 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 1726363589482269.39818039320323; Sat, 14 Sep 2024 18:26:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1spe0K-0002pj-Lx; Sat, 14 Sep 2024 21:24:44 -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 1spe0H-0002p9-9m for qemu-devel@nongnu.org; Sat, 14 Sep 2024 21:24:42 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1spe0F-0005RF-NS for qemu-devel@nongnu.org; Sat, 14 Sep 2024 21:24:41 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-71788bfe60eso2466693b3a.1 for ; Sat, 14 Sep 2024 18:24:38 -0700 (PDT) Received: from localhost ([210.160.217.68]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-719449b370fsm1529648b3a.0.2024.09.14.18.24.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 14 Sep 2024 18:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1726363477; x=1726968277; 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=yTKMLrThNs3dDMSlreK+ICpdf6za+wNhj1qJUdDtbIo=; b=lNbT4h0Pw575LN5xrvKA2delDYklaum3sStyH4Mk+yySyu8xaqq2IA3qge8ucgDVBb FdWYrKHbSMXgRnLmB1xG8kfFh7FtC9DYr6ky6ocyz38Ex10p2HTzE+z8t7cB8hBumkBD 7Or2w1HEBMjwXOJhBOU77zi7TC3AwmlxercdfeVlBdD/xlVHM8twi4IWH7fRhwE7b+jg yjddGoJQWOoEhZxwTGD8WbG/DC9CR/KnDvFrA7MfiQU+9ZJEOPKJEDi39tm5JW8Jt9em 67uR2/PUDhm3eRIQhIG1zd9cW/LEi/j3oKLGic1EjuW+EvkfBywdFeGCK/oRoeWmK9eu 9A6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726363477; x=1726968277; 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=yTKMLrThNs3dDMSlreK+ICpdf6za+wNhj1qJUdDtbIo=; b=Uuls1QR7sZ5B0IJYChg3kKX395Pa5d2Ni38ruRypx9YFfJm6qEFpVdDfit0w0l6q2I 96T/YPWyTKO5xidkGjkvS8aevLKt23Nx9+DtbCwGYeDMH0RPSphqr+iHucqtcUDwvohu afyS6ZgYTGnnJiumASxC/mvNu/Y1Zjz4j0N+XJj+Ew8dSRo3sb4C3hBf/XHoPiwLPiMx fK6b0o5KBeY2rt2g5L1bxAMR5eYEBksOkIUy1+80MoCBkjUq9epo0ZCayxhkZFvzakeI Ga/mA1NcDwz4ZvoNscdzY+PnRmWVT4pU8E9O/S4k5UuocE7yVw+MHyHS/Dl4HqqmYusb 4eIw== X-Gm-Message-State: AOJu0YwM76K+7jZGMS2jDc1O+5o01zx+rJWIjV8XZzHC5IIg73xMK7Js 9PTbnObDW41or3qNFInE4ueMz3seRAIUjFBI61CdS8hvJ11tygTmJP0KZC9l027JbDJ7TeBO2Ad LXOM= X-Google-Smtp-Source: AGHT+IF51Z3E1n81FIknv+NP7KqLvmXf1UHAyU8TlecPRkU/WdUhRauCD08sHwMOYE+RCQvvAvtGKg== X-Received: by 2002:a05:6a21:1190:b0:1cf:6baf:61c0 with SMTP id adf61e73a8af0-1cf764c29e6mr17117920637.44.1726363477574; Sat, 14 Sep 2024 18:24:37 -0700 (PDT) From: Akihiko Odaki Date: Sun, 15 Sep 2024 10:23:43 +0900 Subject: [PATCH RFC v3 02/11] net/vhost-vdpa: Report hashing capability MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240915-hash-v3-2-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::42f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42f.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: 1726363589984116600 Report hashing capability so that virtio-net can deliver the correct capability information to the guest. Signed-off-by: Akihiko Odaki --- include/net/net.h | 3 +++ net/net.c | 9 +++++++++ net/vhost-vdpa.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index c8f679761bf9..099616c8cbe3 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -60,6 +60,7 @@ typedef bool (HasVnetHdrLen)(NetClientState *, int); typedef void (SetOffload)(NetClientState *, int, int, int, int, int, int, = int); typedef int (GetVnetHdrLen)(NetClientState *); typedef void (SetVnetHdrLen)(NetClientState *, int); +typedef bool (GetVnetHashSupportedTypes)(NetClientState *, uint32_t *); typedef int (SetVnetLE)(NetClientState *, bool); typedef int (SetVnetBE)(NetClientState *, bool); typedef struct SocketReadState SocketReadState; @@ -89,6 +90,7 @@ typedef struct NetClientInfo { SetVnetHdrLen *set_vnet_hdr_len; SetVnetLE *set_vnet_le; SetVnetBE *set_vnet_be; + GetVnetHashSupportedTypes *get_vnet_hash_supported_types; NetAnnounce *announce; SetSteeringEBPF *set_steering_ebpf; NetCheckPeerType *check_peer_type; @@ -192,6 +194,7 @@ void qemu_set_offload(NetClientState *nc, int csum, int= tso4, int tso6, 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); +bool qemu_get_vnet_hash_supported_types(NetClientState *nc, uint32_t *type= s); int qemu_set_vnet_le(NetClientState *nc, bool is_le); int qemu_set_vnet_be(NetClientState *nc, bool is_be); void qemu_macaddr_default_if_unset(MACAddr *macaddr); diff --git a/net/net.c b/net/net.c index 6938da05e077..3b04f8fe5d6b 100644 --- a/net/net.c +++ b/net/net.c @@ -559,6 +559,15 @@ void qemu_set_vnet_hdr_len(NetClientState *nc, int len) nc->info->set_vnet_hdr_len(nc, len); } =20 +bool qemu_get_vnet_hash_supported_types(NetClientState *nc, uint32_t *type= s) +{ + if (!nc || !nc->info->get_vnet_hash_supported_types) { + return false; + } + + return nc->info->get_vnet_hash_supported_types(nc, types); +} + int qemu_set_vnet_le(NetClientState *nc, bool is_le) { #if HOST_BIG_ENDIAN diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 03457ead663a..af0c3c448c1f 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -258,6 +258,32 @@ static bool vhost_vdpa_has_vnet_hdr(NetClientState *nc) return true; } =20 +static bool vhost_vdpa_get_vnet_hash_supported_types(NetClientState *nc, + uint32_t *types) +{ + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + uint64_t features =3D s->vhost_vdpa.dev->features; + int fd =3D s->vhost_vdpa.shared->device_fd; + struct { + struct vhost_vdpa_config hdr; + uint32_t supported_hash_types; + } config; + + if (!virtio_has_feature(features, VIRTIO_NET_F_HASH_REPORT) && + !virtio_has_feature(features, VIRTIO_NET_F_RSS)) { + return false; + } + + config.hdr.off =3D offsetof(struct virtio_net_config, supported_hash_t= ypes); + config.hdr.len =3D sizeof(config.supported_hash_types); + + assert(!ioctl(fd, VHOST_VDPA_GET_CONFIG, &config)); + *types =3D le32_to_cpu(config.supported_hash_types); + + return true; +} + static bool vhost_vdpa_has_ufo(NetClientState *nc) { assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); @@ -436,6 +462,7 @@ static NetClientInfo net_vhost_vdpa_info =3D { .stop =3D vhost_vdpa_net_client_stop, .cleanup =3D vhost_vdpa_cleanup, .has_vnet_hdr =3D vhost_vdpa_has_vnet_hdr, + .get_vnet_hash_supported_types =3D vhost_vdpa_get_vnet_hash_suppor= ted_types, .has_ufo =3D vhost_vdpa_has_ufo, .check_peer_type =3D vhost_vdpa_check_peer_type, .set_steering_ebpf =3D vhost_vdpa_set_steering_ebpf, @@ -1303,6 +1330,7 @@ static NetClientInfo net_vhost_vdpa_cvq_info =3D { .stop =3D vhost_vdpa_net_cvq_stop, .cleanup =3D vhost_vdpa_cleanup, .has_vnet_hdr =3D vhost_vdpa_has_vnet_hdr, + .get_vnet_hash_supported_types =3D vhost_vdpa_get_vnet_hash_supported_= types, .has_ufo =3D vhost_vdpa_has_ufo, .check_peer_type =3D vhost_vdpa_check_peer_type, .set_steering_ebpf =3D vhost_vdpa_set_steering_ebpf, --=20 2.46.0