From nobody Sat Nov 15 17:45:26 2025 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=1748579720; cv=none; d=zohomail.com; s=zohoarc; b=Lo+h29SOF+bvFY/pbH78U+CnBFx33/QBhJIkBlDyJuHXx2J8earPAGZ6YkyLdzB17dbrDWeXlYbUxgXgciaDA9LHFdPyWoKy+EQR5R0zVsCwlVFzk//xuCIebDXWGc3/hrTiSns+QdoJ2yAqt6XVJfY0z1/5CdtdfcBro5xdUK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748579720; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=pr5XbKXLi2V3KwlJ9cBsFoT8dIWtqHqQMkw/uTu+ycI=; b=Wu+opPLR9Xj7t1Ui6B6wYMuDNd7Dvx2qbIMlvYViulayKj4y4RGS8pX7C8R10g4WRJhzYkVriUkJthgBuUkWr7HaDNM7f2PtmF+30HaUyLVATkUv8cEjaS1zpD4y8bEk2nPFCQ/MsHWr37qQHlDEF1TVtwZ9ky/1M4vpAmWnG34= 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 1748579720761403.3254430249185; Thu, 29 May 2025 21:35:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKrRg-0001j6-Lb; Fri, 30 May 2025 00:34:16 -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 1uKrRK-0001MO-CV for qemu-devel@nongnu.org; Fri, 30 May 2025 00:33:55 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uKrQx-0005Gx-LK for qemu-devel@nongnu.org; Fri, 30 May 2025 00:33:54 -0400 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-b170c99aa49so1025599a12.1 for ; Thu, 29 May 2025 21:33:29 -0700 (PDT) Received: from localhost ([157.82.128.1]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-b2eceb0288fsm763078a12.9.2025.05.29.21.33.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 May 2025 21:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1748579608; x=1749184408; darn=nongnu.org; h=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=pr5XbKXLi2V3KwlJ9cBsFoT8dIWtqHqQMkw/uTu+ycI=; b=UD+E13pfs6uFkSc/MUFDVqNWerCpDtIYo3I2f2MyO92gnq50rpsr8Lr9+ASVCS2waQ RWUH3bsiWoGcKCQ6mAgGCO3HJqOFg4MNooHHI81w6Frp/vFmmWHS9kaYjkkTFxlsDuNC beSw/yKsOiCJk/10+prJSNqoshQ2NHxEsC3AfibPVnkt3pd3I695qZ4DEHG/s7Tii4th Hk9vwpze0tru739fkejOCS3GCBnNC2jFnBzUj+710BoQPY49HzsJyytKbrg97dTIVfa7 wX51AXPhFH6O8S6gq6UPoJZEglYfaWz47nnd7UI4AB32cw/63RACp4xYijri+k5ma8al FYwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748579608; x=1749184408; h=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=pr5XbKXLi2V3KwlJ9cBsFoT8dIWtqHqQMkw/uTu+ycI=; b=kyohglIjeT87AZ5xgTDwCmXeeMu250Yb3F4p+Mn9bNvoHonfa5Y0roLyReEE4HT5la W3SfGQnZ0KWU1Ok/HcqylCbZSS4Y+q8r1yxEpd9SO5giUBBlleVvUG+OlzEgKQn7MZ1y UPJpQoXq4iYwiN0kMLzLk43ydSNKifeYl9Fo1+f4h5O7YWrbc4LiZnGMvqrTeWmNeOYf wPHK7Lto6iHsp0NrWI+6gkHQNG232mm81dV7LEBH+y084qRFgfTqJb/p8OxLUblgxHY+ gkvi988AesM+DJlBvTCouBuIIA309N1U+GP0b295qy+NVu2xNre3aSKAdWVlaMkeeIYD b8aQ== X-Gm-Message-State: AOJu0YyU4zSG6mkW3EXmfxUeENHNeSpxJJeIpOKTUr+wc3GJUClSiKEP pSIDtNkP9VCsJ1/xM8Ffvx+/3U2xRwvHbs5Ce3G33ngu/lpW4wCx9K5YUN8FHYmg+/6YU0EspHH yHBvy X-Gm-Gg: ASbGncuTy6c+/BIib7PK/q/VOP+VRJ1u1+Rn1+oP+EdPz2jUf3NXFLhQj67RSjW4aU+ FVGG/ujVR7n5ZxHpCIzLvTDlAY/dRWQpMf7DQ5g+sv2TyAiSTPGr7nRgEQGwb1IKNZLkNk3ZFdW NHdqDOhEekHFOGN+jnL28YFdEosXGDkl+WSe8+0TdbhoRG7uVe8uFe6/pEQ8wmtix0YgEU/zCg9 QgpOP+hTCaryxKHG/x7ElGJM7o1tEx5SIT+1PUtkGAxCLJzl1Vxx3ADGbHI5VfKWOy/2hRhxR9F stDieQ7+MUXE2h0tg9WLAHi4AjyXdPnu+pLgV0KYO2sLp6U5Cj2y X-Google-Smtp-Source: AGHT+IEDnw6rAjoTTSpcdEGLAwTRg4WtJABskwOWq5rR/2oJZuGLio/NTkPa1Q8j6sMtlbflvmegpQ== X-Received: by 2002:a17:902:c952:b0:232:1daf:6f06 with SMTP id d9443c01a7336-23529a0a258mr31201755ad.47.1748579608319; Thu, 29 May 2025 21:33:28 -0700 (PDT) From: Akihiko Odaki Date: Fri, 30 May 2025 13:33:16 +0900 Subject: [PATCH 1/6] qdev-properties: Add DEFINE_PROP_ON_OFF_AUTO_BIT64() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250530-vdpa-v1-1-5af4109b1c19@daynix.com> References: <20250530-vdpa-v1-0-5af4109b1c19@daynix.com> In-Reply-To: <20250530-vdpa-v1-0-5af4109b1c19@daynix.com> To: qemu-devel@nongnu.org, Yuri Benditovich , Andrew Melnychenko , "Michael S . Tsirkin" , Jason Wang , Paolo Abeni , devel@daynix.com, Akihiko Odaki X-Mailer: b4 0.15-dev-edae6 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: pass client-ip=2607:f8b0:4864:20::532; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x532.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_PASS=-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: 1748579721607116600 DEFINE_PROP_ON_OFF_AUTO_BIT64() corresponds to DEFINE_PROP_ON_OFF_AUTO() as DEFINE_PROP_BIT64() corresponds to DEFINE_PROP_BOOL(). The difference is that DEFINE_PROP_ON_OFF_AUTO_BIT64() exposes OnOffAuto instead of bool. Signed-off-by: Akihiko Odaki --- include/hw/qdev-properties.h | 18 ++++++++++++ hw/core/qdev-properties.c | 67 ++++++++++++++++++++++++++++++++++++++++= +++- 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 2c99856caacb..0197aa4995e6 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -43,11 +43,22 @@ struct PropertyInfo { ObjectPropertyRelease *release; }; =20 +/** + * struct OnOffAutoBit64 - OnOffAuto storage with 64 elements. + * @on_bits: Bitmap of elements with "on". + * @auto_bits: Bitmap of elements with "auto". + */ +typedef struct OnOffAutoBit64 { + uint64_t on_bits; + uint64_t auto_bits; +} OnOffAutoBit64; + =20 /*** qdev-properties.c ***/ =20 extern const PropertyInfo qdev_prop_bit; extern const PropertyInfo qdev_prop_bit64; +extern const PropertyInfo qdev_prop_on_off_auto_bit64; extern const PropertyInfo qdev_prop_bool; extern const PropertyInfo qdev_prop_uint8; extern const PropertyInfo qdev_prop_uint16; @@ -100,6 +111,13 @@ extern const PropertyInfo qdev_prop_link; .set_default =3D true, \ .defval.u =3D (bool)_defval) =20 +#define DEFINE_PROP_ON_OFF_AUTO_BIT64(_name, _state, _field, _bit, _defval= ) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_on_off_auto_bit64, = \ + OnOffAutoBit64, = \ + .bitnr =3D (_bit), = \ + .set_default =3D true, = \ + .defval.i =3D (OnOffAuto)_defval) + #define DEFINE_PROP_BOOL(_name, _state, _field, _defval) \ DEFINE_PROP(_name, _state, _field, qdev_prop_bool, bool, \ .set_default =3D true, \ diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 147b3ffd16e2..b7e8a89ba5cd 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -2,6 +2,7 @@ #include "hw/qdev-properties.h" #include "qapi/error.h" #include "qapi/qapi-types-misc.h" +#include "qapi/qapi-visit-common.h" #include "qobject/qlist.h" #include "qemu/ctype.h" #include "qemu/error-report.h" @@ -180,7 +181,8 @@ const PropertyInfo qdev_prop_bit =3D { =20 static uint64_t qdev_get_prop_mask64(const Property *prop) { - assert(prop->info =3D=3D &qdev_prop_bit64); + assert(prop->info =3D=3D &qdev_prop_bit64 || + prop->info =3D=3D &qdev_prop_on_off_auto_bit64); return 0x1ull << prop->bitnr; } =20 @@ -225,6 +227,69 @@ const PropertyInfo qdev_prop_bit64 =3D { .set_default_value =3D set_default_value_bool, }; =20 +static void prop_get_on_off_auto_bit64(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + Property *prop =3D opaque; + OnOffAutoBit64 *p =3D object_field_prop_ptr(obj, prop); + OnOffAuto value; + uint64_t mask =3D qdev_get_prop_mask64(prop); + + if (p->auto_bits & mask) { + value =3D ON_OFF_AUTO_AUTO; + } else if (p->on_bits & mask) { + value =3D ON_OFF_AUTO_ON; + } else { + value =3D ON_OFF_AUTO_OFF; + } + + visit_type_OnOffAuto(v, name, &value, errp); +} + +static void prop_set_on_off_auto_bit64(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + Property *prop =3D opaque; + OnOffAutoBit64 *p =3D object_field_prop_ptr(obj, prop); + OnOffAuto value; + uint64_t mask =3D qdev_get_prop_mask64(prop); + + if (!visit_type_OnOffAuto(v, name, &value, errp)) { + return; + } + + switch (value) { + case ON_OFF_AUTO_AUTO: + p->on_bits &=3D ~mask; + p->auto_bits |=3D mask; + break; + + case ON_OFF_AUTO_ON: + p->on_bits |=3D mask; + p->auto_bits &=3D ~mask; + break; + + case ON_OFF_AUTO_OFF: + p->on_bits &=3D ~mask; + p->auto_bits &=3D ~mask; + break; + + case ON_OFF_AUTO__MAX: + g_assert_not_reached(); + } +} + +const PropertyInfo qdev_prop_on_off_auto_bit64 =3D { + .type =3D "OnOffAuto", + .description =3D "on/off/auto", + .enum_table =3D &OnOffAuto_lookup, + .get =3D prop_get_on_off_auto_bit64, + .set =3D prop_set_on_off_auto_bit64, + .set_default_value =3D qdev_propinfo_set_default_value_enum, +}; + /* --- bool --- */ =20 static void get_bool(Object *obj, Visitor *v, const char *name, void *opaq= ue, --=20 2.49.0 From nobody Sat Nov 15 17:45:26 2025 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=1748579695; cv=none; d=zohomail.com; s=zohoarc; b=Qte17vVJ3VVQEOt1pAfA4H1+K69RhcCpD2VhB6zfDExEjxeFF5p72PyxUQIdN6RaHtv7r/qWAqcsqagwxkKujYggk06MeR77k/nv+Dj+PjWs/ZMhTabsWkUYSHR7gQ0BGzW41+Q2W9m86MVzuuvx25EYVI2kczSVcb52sc++EfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748579695; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=OejkH4zRsERXHTFoa8W8lm+ekIjzJaKY4aOmv4SvKCA=; b=aLMAspzzmesq/wPvip8+5EcfkPAKM42pLjBEsVr4D/nhIXs9Byh0OFtRuuf4S5MREp3nZ4MbDyfM2g+iYCuuRjUmW1jkyJfgsz8tb9nK/pzIUjSUNcjSs8vG9/VZWst/erZ3ubF59iqYoW65tkwKZ5gG7bAL10J9/aF0erQJ63I= 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 17485796949113.9686728208160957; Thu, 29 May 2025 21:34:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKrRk-0001nP-9h; Fri, 30 May 2025 00:34:20 -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 1uKrRM-0001NB-Ai for qemu-devel@nongnu.org; Fri, 30 May 2025 00:33:59 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uKrQz-0005Hz-An for qemu-devel@nongnu.org; Fri, 30 May 2025 00:33:54 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-23035b3edf1so16088985ad.3 for ; Thu, 29 May 2025 21:33:32 -0700 (PDT) Received: from localhost ([157.82.128.1]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-23506cf9116sm19924305ad.200.2025.05.29.21.33.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 May 2025 21:33:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1748579611; x=1749184411; darn=nongnu.org; h=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=OejkH4zRsERXHTFoa8W8lm+ekIjzJaKY4aOmv4SvKCA=; b=ScmfHSDlTdMZGLOURTAlCq41s2h/KsV6CBqKHoTvy+Yl2CD2ktt2TWxR+debaz9hJb g07ExsSiNjvf9k104uoW31HcsGq8PBXEsLaCkw9SB8Uf2VCYCb8YIvSWFWShogm+UgNi M+NMV4SfsnBWj7GZdI6eC1f9+V+mHBIgYgYGe+WYaMsblCFWQh8DxzqeMRyppu3wWn5d eOXh1op7K3GMRAa2eNINo/lE8nIUe+scv8UhjVJiurClOGb95djhOd/7jab4fTnilc7d SXW+AP42J/dTozKPTuuW158wzSnbzqBVJ7hd/n9BSK/IeYVlyCFUYf7AD7ocf9X8U8im k7Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748579611; x=1749184411; h=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=OejkH4zRsERXHTFoa8W8lm+ekIjzJaKY4aOmv4SvKCA=; b=ZzxQPDfIdw0fC+xl7YLCS1Wa2ofrKh+WXvgqQ+REnh2GrxQbwgrXCpaj5iB+BgkPfg UQcoUtUreiOOSRsVOkqYCK9tVwiE16NZMTq8LcjypvSPHD0b6SaNRjj7Lq4CF7vRkqEC tiMMAsaEDMlAPva4faQ45w3lpmCGjzcowwhu0VKCa9JXIeBRSUYkjpIQO006zYmMu3DA /50L0ryxRqzDDPY4jIJbox7zwBQAZdTz2S/BeXWD0FaxfsH5TS4dmKFzdcTQCqF6EAQv iYPNwiINTrz/UxrO65LvENgso2ExnpHlhc6trq3YRhiAWGUqDI2jzPaCw14/7Ipxqo7X 9DKA== X-Gm-Message-State: AOJu0Yx/aA8+OknkZ8Up76vVKIAYbswWxnR5ko42JspqW/fcMjDaWRrC mkwPeDOL32gOm/Ke0HNcXCfw/dK4QeMBBWQbpXUviR4wssETUakH4p7w6ovpaXhPfKIKTFKViQb XokMo X-Gm-Gg: ASbGncvdDhpAOVdvyyAwV2B4zEd7BFq0fF6wP26KHrdRgCMMEyGoMC3ywZ5MPeN9Duv wqPThYeBz0ltizCxfqrlcITNXajco8Ui7CV/Bh9bAJa1Ub2g0YLN/sLz0PnfQE8Bau3JHNk9bc0 w03j7x1xrfnDh6oualnT8+K+IsQB6SnZNDoI99G05s+LOcpdb5F6UyOrqaNNFD7vdpkWryTrnz0 ss8ISggVRykCh/MdYTrH3P1wxWpwBHyI9shGuiQQSVc4RFwN0AvW18nu10DBsauYbASd9GexlXF K/srKIKGUTJ9Ek0rghqW0fSn7OrUaynQRKG1lnPHZIWvqef6cK1E X-Google-Smtp-Source: AGHT+IGcsB1XpRme+lQzDk65V0HsCC2NkakQ5KhP2BwnX8y3umu5tVknouE340pBjn/GHnqbeM63bg== X-Received: by 2002:a17:902:cf43:b0:223:7006:4db2 with SMTP id d9443c01a7336-23529517b67mr30012375ad.31.1748579611025; Thu, 29 May 2025 21:33:31 -0700 (PDT) From: Akihiko Odaki Date: Fri, 30 May 2025 13:33:17 +0900 Subject: [PATCH 2/6] net/vhost-vdpa: Report hashing capability MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250530-vdpa-v1-2-5af4109b1c19@daynix.com> References: <20250530-vdpa-v1-0-5af4109b1c19@daynix.com> In-Reply-To: <20250530-vdpa-v1-0-5af4109b1c19@daynix.com> To: qemu-devel@nongnu.org, Yuri Benditovich , Andrew Melnychenko , "Michael S . Tsirkin" , Jason Wang , Paolo Abeni , devel@daynix.com, Akihiko Odaki X-Mailer: b4 0.15-dev-edae6 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: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62e.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_PASS=-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: 1748579697256116600 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 cdd5b109b0d2..545f4339cec8 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; @@ -189,6 +191,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 39d6f28158a3..d0ae3db0d864 100644 --- a/net/net.c +++ b/net/net.c @@ -573,6 +573,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 7ca8b46eee77..1493b08792ea 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -251,6 +251,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); @@ -440,6 +466,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, .set_vnet_le =3D vhost_vdpa_set_vnet_le, .check_peer_type =3D vhost_vdpa_check_peer_type, @@ -1314,6 +1341,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.49.0 From nobody Sat Nov 15 17:45:26 2025 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=1748579695; cv=none; d=zohomail.com; s=zohoarc; b=dwIgfsnaIGVFBuNaROR8EmribrUOItPyuNQzbFEMrrGd+RhbzHEyxokN1IRqmdF8M+DzHM/RqBeKIOcTjAjA07wK2oKtPicVt+2Dr6cvGTnv5S9MlVNoOitXxbXmXsqj0S39IqbAqlLJ1VT8lMi95YmlWHS6y5O2NBSYCrBGFwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748579695; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=/Zxy0RFU8N4trMrRBRmAFZjrhHTvZ0aptypNMIJeX1M=; b=aX87lRjJO2cOjJwlV8yjLK9oRdxQXHtyiSCJjzrD9B9HWGeEbCpqafkTwUbg0cQxqrI/m+NWBt6WCzQshsgXgSvwCgz6aK9kZWn8201eCS8xjfgczMDQ2CIvMDDradoTFYuUw6Fpkujn1f4MnusPNU+953NzvNb5VAIPwUTitBU= 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 1748579694899728.9852334635842; Thu, 29 May 2025 21:34:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKrRi-0001l9-Mh; Fri, 30 May 2025 00:34:19 -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 1uKrRM-0001N8-9F for qemu-devel@nongnu.org; Fri, 30 May 2025 00:33:59 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uKrR1-0005KN-34 for qemu-devel@nongnu.org; Fri, 30 May 2025 00:33:55 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-742af848148so1027174b3a.1 for ; Thu, 29 May 2025 21:33:34 -0700 (PDT) Received: from localhost ([157.82.128.1]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-b2eceb048dcsm766608a12.12.2025.05.29.21.33.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 May 2025 21:33:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1748579613; x=1749184413; darn=nongnu.org; h=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=/Zxy0RFU8N4trMrRBRmAFZjrhHTvZ0aptypNMIJeX1M=; b=p3zymd+cv1sE7swfsyoSZpG1X16lHTzaiP5nYwLuFvPzNOejHqiQBNBrdizc7kxgwo mIEv+ENcS5y6PkK4z/NhZzP1IG0N8lSlCGPPJKE4oQ7EThMEmq+HcICZvcUDy+SrA7r0 zfVWLaRlKiUrF1WGsWe37b8Jnp0NLLYswTHtE1Fv5lZXSv4hkqKY1w7NVfC6BIZOttL+ iKBw019VhEWHOflC/ozjcMNKSPSPZMwZVVAg7sAd7uxerEnSnnybDxkFkFprH5LkPmd1 4SSPME3gZbhbLE1eJKrYpJUhB8nS/TrDtU4qGpOhEoUa99sdSFM3LQXXEW31FGdSdJ/m SIGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748579613; x=1749184413; h=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=/Zxy0RFU8N4trMrRBRmAFZjrhHTvZ0aptypNMIJeX1M=; b=bwGhVHystKM4372fy9uma+z5RJoNts7tMU87I7hLjWvrG6rrwPC9S/aIoPr75D+MTR tNjgPd2b2yGJk+LtkvzNILB6rCYfARgkHeba+FavBQ36u1fGsmCwfr3SR6ex0TGv20ob GOVmXkOUtrOYq87s6w2hEat9QJdnX+MC5kyHVArfH2aEIhknN6l765F2rQOXMzLjAJ+/ ngu3IGE91pcvWOV41gZ8b5f/zrhYNoFxqCWm3F+17Kho0zfMqwrV37vcleIEr9skOhjQ zVknOwcyAYmUqz+ozYXynLv6M7mc7p7KpqKGfjwKXXs2MwLweGkj/2M2dDB5ZRpeCDy/ x4xw== X-Gm-Message-State: AOJu0Yz5TmE8/RDeQEbR5h9sJr2RbzUCurUDgBHBXoDch/BMElt1f6oC jgeyuvMAjhthovpiGcSrmUWqZKxnTwdINPq/oIfAAL0SyFQoE4cNy6sPW9F4GVSN+IY9tH87Mcr AQbXu X-Gm-Gg: ASbGncvtu7lJLhAiSHEcfVepWJBEiM3xBmRYoBExgSmqWkK5XWrqpUhf4YCjg94KKNq ZinssJ2nE6s1nUlIAbIckxD9QsS6uhcWius5/nfeQe5PUKZowwmdSyXLAozqgioUtn0NIkTF7bT H9b8es2VOd0OFyvbiaUrycl5JhUu2iKDHgUDp9Tze53Km6zAaE1xTAGQGP0jgvDU48RvOzNdx0m S+8hPLNZSa2dVioxcKbuYiPPh6lg/Y5HO7JNREK/e3UZriTcqgHH5guRiaHpCgwMis0VDGuCrHK Fg+2Sg4okX8goUBM/oE9Ievu1V81QA/2DQvdcg5LtA6Lrxzaq8Qx X-Google-Smtp-Source: AGHT+IH8J2ctCk1Nf99Bkb/RlH65K7izPe+rVX2Ae7kQadke9xuZ8vxvZDvwrS4MaV5F17e9VU++iA== X-Received: by 2002:a05:6a20:d045:b0:21a:b9d4:ad73 with SMTP id adf61e73a8af0-21ad98f00b2mr3764881637.40.1748579613575; Thu, 29 May 2025 21:33:33 -0700 (PDT) From: Akihiko Odaki Date: Fri, 30 May 2025 13:33:18 +0900 Subject: [PATCH 3/6] virtio-net: Move virtio_net_get_features() down MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250530-vdpa-v1-3-5af4109b1c19@daynix.com> References: <20250530-vdpa-v1-0-5af4109b1c19@daynix.com> In-Reply-To: <20250530-vdpa-v1-0-5af4109b1c19@daynix.com> To: qemu-devel@nongnu.org, Yuri Benditovich , Andrew Melnychenko , "Michael S . Tsirkin" , Jason Wang , Paolo Abeni , devel@daynix.com, Akihiko Odaki X-Mailer: b4 0.15-dev-edae6 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: pass client-ip=2607:f8b0:4864:20::433; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x433.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_PASS=-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: 1748579697258116600 Move virtio_net_get_features() to the later part of the file so that it can call other functions. Signed-off-by: Akihiko Odaki --- hw/net/virtio-net.c | 146 ++++++++++++++++++++++++++----------------------= ---- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 221252e00a50..4ebe7f93f5c3 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -752,79 +752,6 @@ static void virtio_net_set_queue_pairs(VirtIONet *n) =20 static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue); =20 -static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t featu= res, - Error **errp) -{ - VirtIONet *n =3D VIRTIO_NET(vdev); - NetClientState *nc =3D qemu_get_queue(n->nic); - - /* Firstly sync all virtio-net possible supported features */ - features |=3D n->host_features; - - virtio_add_feature(&features, VIRTIO_NET_F_MAC); - - if (!peer_has_vnet_hdr(n)) { - virtio_clear_feature(&features, VIRTIO_NET_F_CSUM); - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_TSO4); - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_TSO6); - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_ECN); - - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_CSUM); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_TSO4); - 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); - } - - if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) { - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_UFO); - 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; - } - - if (!ebpf_rss_is_loaded(&n->ebpf_rss)) { - virtio_clear_feature(&features, VIRTIO_NET_F_RSS); - } - features =3D vhost_net_get_features(get_vhost_net(nc->peer), features); - vdev->backend_features =3D features; - - if (n->mtu_bypass_backend && - (n->host_features & 1ULL << VIRTIO_NET_F_MTU)) { - features |=3D (1ULL << VIRTIO_NET_F_MTU); - } - - /* - * Since GUEST_ANNOUNCE is emulated the feature bit could be set witho= ut - * enabled. This happens in the vDPA case. - * - * Make sure the feature set is not incoherent, as the driver could re= fuse - * to start. - * - * TODO: QEMU is able to emulate a CVQ just for guest_announce purpose= s, - * helping guest to notify the new location with vDPA devices that doe= s not - * support it. - */ - if (!virtio_has_feature(vdev->backend_features, VIRTIO_NET_F_CTRL_VQ))= { - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE); - } - - return features; -} - static uint64_t virtio_net_bad_features(VirtIODevice *vdev) { uint64_t features =3D 0; @@ -3076,6 +3003,79 @@ static int virtio_net_pre_load_queues(VirtIODevice *= vdev) return 0; } =20 +static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t featu= res, + Error **errp) +{ + VirtIONet *n =3D VIRTIO_NET(vdev); + NetClientState *nc =3D qemu_get_queue(n->nic); + + /* Firstly sync all virtio-net possible supported features */ + features |=3D n->host_features; + + virtio_add_feature(&features, VIRTIO_NET_F_MAC); + + if (!peer_has_vnet_hdr(n)) { + virtio_clear_feature(&features, VIRTIO_NET_F_CSUM); + virtio_clear_feature(&features, VIRTIO_NET_F_HOST_TSO4); + virtio_clear_feature(&features, VIRTIO_NET_F_HOST_TSO6); + virtio_clear_feature(&features, VIRTIO_NET_F_HOST_ECN); + + virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_CSUM); + virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_TSO4); + 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); + } + + if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) { + virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_UFO); + 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; + } + + if (!ebpf_rss_is_loaded(&n->ebpf_rss)) { + virtio_clear_feature(&features, VIRTIO_NET_F_RSS); + } + features =3D vhost_net_get_features(get_vhost_net(nc->peer), features); + vdev->backend_features =3D features; + + if (n->mtu_bypass_backend && + (n->host_features & 1ULL << VIRTIO_NET_F_MTU)) { + features |=3D (1ULL << VIRTIO_NET_F_MTU); + } + + /* + * Since GUEST_ANNOUNCE is emulated the feature bit could be set witho= ut + * enabled. This happens in the vDPA case. + * + * Make sure the feature set is not incoherent, as the driver could re= fuse + * to start. + * + * TODO: QEMU is able to emulate a CVQ just for guest_announce purpose= s, + * helping guest to notify the new location with vDPA devices that doe= s not + * support it. + */ + if (!virtio_has_feature(vdev->backend_features, VIRTIO_NET_F_CTRL_VQ))= { + virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE); + } + + return features; +} + static int virtio_net_post_load_device(void *opaque, int version_id) { VirtIONet *n =3D opaque; --=20 2.49.0 From nobody Sat Nov 15 17:45:26 2025 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=1748579739; cv=none; d=zohomail.com; s=zohoarc; b=L9oH5NeFH0qMPp4O8PaQS3nOY+vvu0agSjeTuFWEKxVWQDOeK0XgPGhanqGKmsNZvXM0W7SFJD/PT7d7As95q7kzGd+7bH+P/WkRu8iiDAK0Ia9ogG7eVoXr8SWz4j++E0VtUjWWgnjVAlBa6VNhXXpuYuIXKp4U0G5ft4DMLrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748579739; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=3xHxQ8PrI5HPaGnznbShFoLmh2PFnUcEB2+6G2u3KrQ=; b=ZmfFKINVcQxn6zxIOjfaY9CA1dPPXINeiDN7rBnuTHxh5AOgYhtbSgL/BmDOBwIzOPLqYTk/+3HDkT2tdCJcI/MdpPgs3cae5IuWPABZ+3x6jrNvLM4p4+gp8SkMWU2ALmOi0l2Nrx5lK2tTbdxCJkOceQhEXHs9VlAUi9UMtoo= 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 1748579739360113.10486500336481; Thu, 29 May 2025 21:35:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKrRg-0001id-E4; Fri, 30 May 2025 00:34:16 -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 1uKrRM-0001N7-8l for qemu-devel@nongnu.org; Fri, 30 May 2025 00:33:59 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uKrR4-0005Lf-0B for qemu-devel@nongnu.org; Fri, 30 May 2025 00:33:55 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-231e98e46c0so16112645ad.3 for ; Thu, 29 May 2025 21:33:37 -0700 (PDT) Received: from localhost ([157.82.128.1]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-23506cf504asm19894115ad.178.2025.05.29.21.33.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 May 2025 21:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1748579616; x=1749184416; darn=nongnu.org; h=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=3xHxQ8PrI5HPaGnznbShFoLmh2PFnUcEB2+6G2u3KrQ=; b=w2dluSkPKMkTvY27rPFWJmB+hFhtw3+qwNHpED0obd5qSxY0S2WI6/uQzRjhDdXcD1 DntU9oo5KGnDhTXZ6heEmIyY2nYC0WJULFSdCBXsShPmRw4xVjJ+qpwEgHRTIm99zZeh AtDGr/SiByiEc3lsOBpPTTXLBnMhAaBjUJvBsmGP6qc7t26wNglhQH7UN7I+K/tsi1sr PwIodCHEPnl/cFfdQnSxSxsJuna44FHx+RCbRLeF+PmE4dbAsSRSP++5vb1VTv9vCUj9 f3k8LFx0yme5/XW3P/LjfoQUn781BH7uZC+rXSYvoK3FkZa5o8MzFxcaRs01Rm+WbpUE P1Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748579616; x=1749184416; h=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=3xHxQ8PrI5HPaGnznbShFoLmh2PFnUcEB2+6G2u3KrQ=; b=oq4amcFnhl7iZAWhsdxZWqvLTKC3qimKL8aeu3zORLdDnf1pYfSpZKlTabgPVUOcws cA934e0CqML3x6rkAH2i0ewFp18vEL0dWpvpI1xO4CzfhdAA1P5zegE49v3FDFxmBfsl rH7kZ0p2anBW4BIgdikgMGR8MuY2ZxwoOyESJ+kt2bkPiCXK5vBf1mW50nSrABNzCssy kTrhtBnt9B88JFc3LH8qzkKsHfJePuNqxeFcUCi/zciiYfM1h/4wPGHjgkzFokiw//rF /9H1Csbi+QVnqivtal3rpBm0Fwi04wQKlrGn+BRiitPHXIxYLZ8Ti+BE6mv93+fmUvCa bGaQ== X-Gm-Message-State: AOJu0YzEetpCmo6cFunMjrw1lcZ09/aqo5WZfELtlbX/Qy3LKj2ZRjm0 jQtSAsl1wMo9iKEpFoDcwn+XJ4KDJmtmtQulSmnomU0A5rqGz/hxuQf1jqebRulESrDrv272BSE bgGwf X-Gm-Gg: ASbGnctxPvU7l9lVu9fGNN6fbJNqQpOOMP3pOn5Q/m6BKRBaQYMoA9iwbMJnPVSKJek QxgvpAMKmhsGA3edPJdLdQxXWxQ6A30FA4rah1wCs/vB54WeZT+AoUOxicE6VADRVF5YbqFU651 ZqYFtsHaFEFhDnkopo8FCc/DeEJj/Ncno8gmq79/8Wl0qV7iRhhtRpQAuN2F0WCvv6zSKBFcQgB ngtoH19TVAy4jsdGAuadZi7QARqOFlQ95rfOMMSXqDAGDpglwTS19NtCkJ4sEOXJCIuhmm+DWlm 6cDde/VAIZi40n7DwYtxpvXyFTcclu6ITEs6C+fTFIEJEP0/unsP X-Google-Smtp-Source: AGHT+IE0LgEBlSD21Yq+GwnN2FRZs9DppQqyrHpYUer3CZWWarfp5Ol/MJpmp2xKpPih6YNuO/imVg== X-Received: by 2002:a17:902:ec84:b0:235:1b3e:c01c with SMTP id d9443c01a7336-23529903758mr30471275ad.39.1748579616234; Thu, 29 May 2025 21:33:36 -0700 (PDT) From: Akihiko Odaki Date: Fri, 30 May 2025 13:33:19 +0900 Subject: [PATCH 4/6] virtio-net: Retrieve peer hashing capability MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250530-vdpa-v1-4-5af4109b1c19@daynix.com> References: <20250530-vdpa-v1-0-5af4109b1c19@daynix.com> In-Reply-To: <20250530-vdpa-v1-0-5af4109b1c19@daynix.com> To: qemu-devel@nongnu.org, Yuri Benditovich , Andrew Melnychenko , "Michael S . Tsirkin" , Jason Wang , Paolo Abeni , devel@daynix.com, Akihiko Odaki X-Mailer: b4 0.15-dev-edae6 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: pass client-ip=2607:f8b0:4864:20::631; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x631.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_PASS=-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: 1748579739828116600 Retrieve peer hashing capability instead of hardcoding. Signed-off-by: Akihiko Odaki --- include/hw/virtio/virtio-net.h | 5 ++- hw/net/virtio-net.c | 71 ++++++++++++++++++++++++++++++++++----= ---- net/vhost-vdpa.c | 4 +-- 3 files changed, 64 insertions(+), 16 deletions(-) diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index b9ea9e824e3c..c4957c44c06e 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -144,7 +144,10 @@ typedef struct VirtioNetRssData { bool enabled_software_rss; bool redirect; bool populate_hash; - uint32_t hash_types; + bool peer_hash_available; + uint32_t runtime_hash_types; + uint32_t supported_hash_types; + uint32_t peer_hash_types; uint8_t key[VIRTIO_NET_RSS_MAX_KEY_SIZE]; uint16_t indirections_len; uint16_t *indirections_table; diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 4ebe7f93f5c3..cd5a632596b1 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -158,7 +158,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, u= int8_t *config) virtio_host_has_feature(vdev, VIRTIO_NET_F_RSS) ? VIRTIO_NET_RSS_MAX_TABLE_LEN : 1); virtio_stl_p(vdev, &netcfg.supported_hash_types, - VIRTIO_NET_RSS_SUPPORTED_HASHES); + n->rss_data.supported_hash_types); memcpy(config, &netcfg, n->config_size); =20 /* @@ -1178,7 +1178,7 @@ static void rss_data_to_rss_config(struct VirtioNetRs= sData *data, { config->redirect =3D data->redirect; config->populate_hash =3D data->populate_hash; - config->hash_types =3D data->hash_types; + config->hash_types =3D data->runtime_hash_types; config->indirections_len =3D data->indirections_len; config->default_queue =3D data->default_queue; } @@ -1213,6 +1213,10 @@ static void virtio_net_detach_ebpf_rss(VirtIONet *n) =20 static void virtio_net_commit_rss_config(VirtIONet *n) { + if (n->rss_data.peer_hash_available) { + return; + } + if (n->rss_data.enabled) { n->rss_data.enabled_software_rss =3D n->rss_data.populate_hash; if (n->rss_data.populate_hash) { @@ -1227,7 +1231,7 @@ static void virtio_net_commit_rss_config(VirtIONet *n) } =20 trace_virtio_net_rss_enable(n, - n->rss_data.hash_types, + n->rss_data.runtime_hash_types, n->rss_data.indirections_len, sizeof(n->rss_data.key)); } else { @@ -1338,7 +1342,7 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, err_value =3D (uint32_t)s; goto error; } - n->rss_data.hash_types =3D virtio_ldl_p(vdev, &cfg.hash_types); + n->rss_data.runtime_hash_types =3D virtio_ldl_p(vdev, &cfg.hash_types); n->rss_data.indirections_len =3D virtio_lduw_p(vdev, &cfg.indirection_table_mask); if (!do_rss) { @@ -1401,12 +1405,12 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, err_value =3D temp.b; goto error; } - if (!temp.b && n->rss_data.hash_types) { + if (!temp.b && n->rss_data.runtime_hash_types) { err_msg =3D "No key provided"; err_value =3D 0; goto error; } - if (!temp.b && !n->rss_data.hash_types) { + if (!temp.b && !n->rss_data.runtime_hash_types) { virtio_net_disable_rss(n); return queue_pairs; } @@ -1808,7 +1812,7 @@ static int virtio_net_process_rss(NetClientState *nc,= const uint8_t *buf, net_rx_pkt_set_protocols(pkt, &iov, 1, n->host_hdr_len); net_rx_pkt_get_protocols(pkt, &hasip4, &hasip6, &l4hdr_proto); net_hash_type =3D virtio_net_get_hash_type(hasip4, hasip6, l4hdr_proto, - n->rss_data.hash_types); + n->rss_data.runtime_hash_type= s); if (net_hash_type > NetPktRssIpV6UdpEx) { if (n->rss_data.populate_hash) { hdr->hash_value =3D VIRTIO_NET_HASH_REPORT_NONE; @@ -3008,6 +3012,14 @@ static uint64_t virtio_net_get_features(VirtIODevice= *vdev, uint64_t features, { VirtIONet *n =3D VIRTIO_NET(vdev); NetClientState *nc =3D qemu_get_queue(n->nic); + uint32_t supported_hash_types =3D n->rss_data.supported_hash_types; + uint32_t peer_hash_types =3D n->rss_data.peer_hash_types; + bool use_own_hash =3D + (supported_hash_types & VIRTIO_NET_RSS_SUPPORTED_HASHES) =3D=3D + supported_hash_types; + bool use_peer_hash =3D + n->rss_data.peer_hash_available && + (supported_hash_types & peer_hash_types) =3D=3D supported_hash_typ= es; =20 /* Firstly sync all virtio-net possible supported features */ features |=3D n->host_features; @@ -3044,12 +3056,28 @@ static uint64_t virtio_net_get_features(VirtIODevic= e *vdev, uint64_t features, } =20 if (!get_vhost_net(nc->peer)) { + if (!use_own_hash) { + virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT); + virtio_clear_feature(&features, VIRTIO_NET_F_RSS); + } else if (virtio_has_feature(features, VIRTIO_NET_F_RSS)) { + virtio_net_load_ebpf(n, errp); + } + return features; } =20 - if (!ebpf_rss_is_loaded(&n->ebpf_rss)) { - virtio_clear_feature(&features, VIRTIO_NET_F_RSS); + if (!use_peer_hash) { + virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT); + + if (!use_own_hash || !virtio_net_attach_ebpf_to_backend(n->nic, -1= )) { + if (!virtio_net_load_ebpf(n, errp)) { + return features; + } + + virtio_clear_feature(&features, VIRTIO_NET_F_RSS); + } } + features =3D vhost_net_get_features(get_vhost_net(nc->peer), features); vdev->backend_features =3D features; =20 @@ -3314,6 +3342,17 @@ static const VMStateDescription vmstate_virtio_net_h= as_vnet =3D { }, }; =20 +static int virtio_net_rss_post_load(void *opaque, int version_id) +{ + VirtIONet *n =3D VIRTIO_NET(opaque); + + if (version_id =3D=3D 1) { + n->rss_data.supported_hash_types =3D VIRTIO_NET_RSS_SUPPORTED_HASH= ES; + } + + return 0; +} + static bool virtio_net_rss_needed(void *opaque) { return VIRTIO_NET(opaque)->rss_data.enabled; @@ -3321,14 +3360,16 @@ static bool virtio_net_rss_needed(void *opaque) =20 static const VMStateDescription vmstate_virtio_net_rss =3D { .name =3D "virtio-net-device/rss", - .version_id =3D 1, + .version_id =3D 2, .minimum_version_id =3D 1, + .post_load =3D virtio_net_rss_post_load, .needed =3D virtio_net_rss_needed, .fields =3D (const VMStateField[]) { VMSTATE_BOOL(rss_data.enabled, VirtIONet), VMSTATE_BOOL(rss_data.redirect, VirtIONet), VMSTATE_BOOL(rss_data.populate_hash, VirtIONet), - VMSTATE_UINT32(rss_data.hash_types, VirtIONet), + VMSTATE_UINT32(rss_data.runtime_hash_types, VirtIONet), + VMSTATE_UINT32_V(rss_data.supported_hash_types, VirtIONet, 2), VMSTATE_UINT16(rss_data.indirections_len, VirtIONet), VMSTATE_UINT16(rss_data.default_queue, VirtIONet), VMSTATE_UINT8_ARRAY(rss_data.key, VirtIONet, @@ -3915,8 +3956,12 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) =20 net_rx_pkt_init(&n->rx_pkt); =20 - if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) { - virtio_net_load_ebpf(n, errp); + if (qemu_get_vnet_hash_supported_types(qemu_get_queue(n->nic)->peer, + &n->rss_data.peer_hash_types)) { + n->rss_data.peer_hash_available =3D true; + n->rss_data.supported_hash_types =3D n->rss_data.peer_hash_types; + } else { + n->rss_data.supported_hash_types =3D VIRTIO_NET_RSS_SUPPORTED_HASH= ES; } } =20 diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1493b08792ea..4f63ded40d47 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -895,13 +895,13 @@ static int vhost_vdpa_net_load_rss(VhostVDPAState *s,= const VirtIONet *n, * configuration only at live migration. */ if (!n->rss_data.enabled || - n->rss_data.hash_types =3D=3D VIRTIO_NET_HASH_REPORT_NONE) { + n->rss_data.runtime_hash_types =3D=3D VIRTIO_NET_HASH_REPORT_NONE)= { return 0; } =20 table =3D g_malloc_n(n->rss_data.indirections_len, sizeof(n->rss_data.indirections_table[0])); - cfg.hash_types =3D cpu_to_le32(n->rss_data.hash_types); + cfg.hash_types =3D cpu_to_le32(n->rss_data.runtime_hash_types); =20 if (do_rss) { /* --=20 2.49.0 From nobody Sat Nov 15 17:45:26 2025 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=1748579705; cv=none; d=zohomail.com; s=zohoarc; b=IxkoJ4rUtE6bHQC3V2CqwNRt4urhPysetup9s6JZkBlfqNwBnWIyx4Msm6B5bNt2TmesPCwaTRy/zIFYOm2qt4PYXjuj/oZczyTVkWaPMNekoF7vkqfDEBdypvTLwc500pO3jatTCWM0upiFfq/dj7tefh1YV1Ha7zJ6o4F0kS4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748579705; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=AZ7GhEwjBgkQdcPHsHCxJ1Vfs4exel6ROH4bH1WKn9M=; b=IhygV7PQNQyKEUrND8TIHxyxcx1Y6u1EcS4gpsvUE7w7n2VXpIh9bP5jKwWZ/C6tDEyGQf0kqNmeprAObjhWoq3jZUV64pRRSTHiHIuQpwkGduSJ2bDwyoJQld7eFVYJ4OzqkU2BHSIAyJSmAGdy/XU08dnM5zcZ8Haq0pnuEvA= 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 1748579704882821.2040004056638; Thu, 29 May 2025 21:35:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKrRf-0001hL-83; Fri, 30 May 2025 00:34:15 -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 1uKrRM-0001NA-A5 for qemu-devel@nongnu.org; Fri, 30 May 2025 00:33:59 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uKrR6-0005NV-I1 for qemu-devel@nongnu.org; Fri, 30 May 2025 00:33:55 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-23228b9d684so18509865ad.1 for ; Thu, 29 May 2025 21:33:40 -0700 (PDT) Received: from localhost ([157.82.128.1]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-3124e3c13ffsm342528a91.41.2025.05.29.21.33.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 May 2025 21:33:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1748579619; x=1749184419; darn=nongnu.org; h=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=AZ7GhEwjBgkQdcPHsHCxJ1Vfs4exel6ROH4bH1WKn9M=; b=IOk9nMN/tyCo6EdzPkjWL/OsSJWzf6i1lBsbBEzeSM3C8t7UhiOCdyS3Ha84VeV2TD Tj5DUMIl4QMCd7n/Lj5EHHbqkK2eEgEoRI+Qo6gmkOinvXsYh2X9O8j0zsdxD5QRUJej JrJ67FBoz2n0VUEgDiVIA/sC4vZs91R2aUdrEZrB1iis5KKfgHjRvbP/Z7pRm9RWGcI1 gKs1KPyocw9T+eEXR0JXqwF/c6M63w6mZcp7hymTAScb8D0JYDcPbmyk0kjOhKcznrPX Yh3aD5n4i7XI4QdqY7YAEWCaDb5IuBSd9ZU85YWNTJ+qSdYmL/kgkpUr2lKWEnTc36W1 watQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748579619; x=1749184419; h=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=AZ7GhEwjBgkQdcPHsHCxJ1Vfs4exel6ROH4bH1WKn9M=; b=GGfzagkGp+D2A1gX5sP0hKoWFxOoVkckRAGCnjOE/21QPsNNDvWROTDzx9QlTnx7zk CJRTD2onctN6+/ff1arUwdzyvpr13p3/4BVNN6zqGiGz2zqi9gRmzDuafc8MaLn+y7ly BvvcLTd+6FuTUclhGAxqlwaEYJcd7W1c8P78i186ZVm+K+iEajKqf1fAOaRlTlomC93w W56VJwGGVC+J5T6PdpBa8odP0W4zVABvzq3weJOXo28y3BDCvtROmhJgK2B1q3eCzVgX tizrXRBHU2pn8kETymPHAbzSmQHsEmxpVA+GYUx4EMXMgt1RF0cGjRamYbILk7/SCNf9 S93w== X-Gm-Message-State: AOJu0YwCt+imf35XbU2vML/QbTEGT0ucA94gFi6uwXe1M7Rk+pnkPVrb ouaqOeCR475/Q2xJlh7/v44AcG1L1x+Z8G+QVRF6TMXAU04r3HyhsdPnAAwHxME7FxGxuMyBWDM ZxLYj X-Gm-Gg: ASbGncvwd2XGR5vrD0iXT+OvXCoPOzHT5LWbRWJm05ISHHpSXiz+mvA8WGv6CnWDLMw gc0qdbqx9TbZ/wQpavo0akuDmYUH6qNBBKG/KPMHHEHPy1j2zhJ5h5rfRrwrxf6QuqsXv3WRiTR +hepb5bSNCrLkh458AazkW9IsfUseb9Me7uKMzem+89+eoCmyAyMim04j21JRd0qMtPx9/T/teG EsKPUBbVanCHuiUQctvwWbHPhWgE8Aefx/cYGTY5aVIKJRZSo5TEUD7dEYmWddM5DUqcDiC+LOC zYCjj4ENoOTSSpJweaHPpdEhNIL9MLBO7oXvIyzDkUWV2htweS/iXv8XBNz9FZk= X-Google-Smtp-Source: AGHT+IH9RBdYB7c8M93CuIwdStKvJKfkFSqu05PwiIw/KD8onNVHw0gHlgy4IR/W3oexgq7yle2YhA== X-Received: by 2002:a17:903:2381:b0:235:a9b:21e0 with SMTP id d9443c01a7336-2353855c95emr13673435ad.0.1748579618903; Thu, 29 May 2025 21:33:38 -0700 (PDT) From: Akihiko Odaki Date: Fri, 30 May 2025 13:33:20 +0900 Subject: [PATCH 5/6] net/vhost-vdpa: Remove dummy SetSteeringEBPF MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250530-vdpa-v1-5-5af4109b1c19@daynix.com> References: <20250530-vdpa-v1-0-5af4109b1c19@daynix.com> In-Reply-To: <20250530-vdpa-v1-0-5af4109b1c19@daynix.com> To: qemu-devel@nongnu.org, Yuri Benditovich , Andrew Melnychenko , "Michael S . Tsirkin" , Jason Wang , Paolo Abeni , devel@daynix.com, Akihiko Odaki X-Mailer: b4 0.15-dev-edae6 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: pass client-ip=2607:f8b0:4864:20::634; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x634.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_PASS=-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: 1748579707224116600 It is no longer used. Signed-off-by: Akihiko Odaki --- net/vhost-vdpa.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 4f63ded40d47..149c0f7f1766 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -238,12 +238,6 @@ static void vhost_vdpa_cleanup(NetClientState *nc) g_free(s->vhost_vdpa.shared); } =20 -/** Dummy SetSteeringEBPF to support RSS for vhost-vdpa backend */ -static bool vhost_vdpa_set_steering_ebpf(NetClientState *nc, int prog_fd) -{ - return true; -} - static bool vhost_vdpa_has_vnet_hdr(NetClientState *nc) { assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); @@ -470,7 +464,6 @@ static NetClientInfo net_vhost_vdpa_info =3D { .has_ufo =3D vhost_vdpa_has_ufo, .set_vnet_le =3D vhost_vdpa_set_vnet_le, .check_peer_type =3D vhost_vdpa_check_peer_type, - .set_steering_ebpf =3D vhost_vdpa_set_steering_ebpf, }; =20 static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index, @@ -1344,7 +1337,6 @@ static NetClientInfo net_vhost_vdpa_cvq_info =3D { .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 /* --=20 2.49.0 From nobody Sat Nov 15 17:45:26 2025 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=1748579726; cv=none; d=zohomail.com; s=zohoarc; b=n/h639auz7iNlSO6RmYj00YZvH29bjFjN4hlqD/SYLwbBMYiPyEUaS+g//kt+oJj/xR8KRrp9zZzjp4L4YaMiEr61a9lUrbFvXw5FECfmWays3JQrQi3it7hkdIElduAa333CIgTtvkkkmIRObnlG1ZVRPlfhzoInj9PLiH9Ij0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748579726; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=PzspMOXBN18eh+XrNUrzXep8Qjkld4nXnkxOhOiGHWE=; b=EdR90Q60TyxTV5Bq6Rf808iUJ3wG14cZZUdyHr+dXUoYGDDCbP1t+Yx3JZPCuA2TvZejYD7WNrrONXF9va2GFYOPgclOHCXYTweFwXoJVaBYez6Ww6PgmVTBwJht7i2B8i0/EES5UlPoJk18wMm71XHjWu+sJ/9wO7/Sf0ZYHvc= 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 1748579726120155.28366045160465; Thu, 29 May 2025 21:35:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKrRh-0001jv-6s; Fri, 30 May 2025 00:34:17 -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 1uKrRM-0001NG-V1 for qemu-devel@nongnu.org; Fri, 30 May 2025 00:33:59 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uKrR9-0005Oz-3X for qemu-devel@nongnu.org; Fri, 30 May 2025 00:33:56 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-23526264386so6825985ad.2 for ; Thu, 29 May 2025 21:33:42 -0700 (PDT) Received: from localhost ([157.82.128.1]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-23506d14702sm19809485ad.214.2025.05.29.21.33.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 May 2025 21:33:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1748579621; x=1749184421; darn=nongnu.org; h=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=PzspMOXBN18eh+XrNUrzXep8Qjkld4nXnkxOhOiGHWE=; b=tinI5KiEdDNc/fHo2hoELeRoqUk8vU1ejVkhQPceGhk1VUOZUXpcB62qdwWS0PzEzy LGlgSc9iRKf9v8h20zaXq6yB7oPVPFK6ZfLDV5ivg6TzITSQEkuVv0hZLkvnMibZi9b3 QIWo1uQS5O67tkGMk/asDVctiDS32sBM0ekmi3KnftANq61wWbOwL6zg+sYcmKqoGO7Y 2dxzERzOnLWU9I0qiMpmgy2LERGvnyozYOZdkQ0KRPMqgjlQzM5lkSqYlzmbOrvKGsR1 5bv9dMIMfRlPzf1UphJFotkjDEQ4wqQmq/Qfo6uURLU7Tl73MJbu3/hIw5QZfzmS/CSP +CVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748579621; x=1749184421; h=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=PzspMOXBN18eh+XrNUrzXep8Qjkld4nXnkxOhOiGHWE=; b=V9X/jJNzemsQ7LstpewSVdLGAg2om1vVrO4E9zS2nryXm1/JX2eNBJT+1IR1Jm+AGb 8a4cGbHE5j2DLaO4hbf3CD4d2qlPQqNd+QOx1nbU1YMhwOIWrL45ckg/Hs9NzDtJ4G9t lKfSaKMnDB3LzsE2sZ9K27zA54x0m+HaQckbILWqe6YyW0XJEoJw8/XLiuGdJ5BtFzQu 7n8+dVscjf+N7J564DrjAeuWICv7Ig/BAF80nh9Ri6uzyzK4BjEOjdKF+dCxgV68pN7H D7GWi51e3fb+pL962I/uS8U2av9wiu+c2bbhuMGwS2sm/BDzDmcha7UoqPjPmBk49inj rogA== X-Gm-Message-State: AOJu0YzTjsLWa+Iir+vu4PigwOd0+BVB2wAkQr3PGPfHyeib3Hw2df51 a7o1nAgtrY7PTva8fmf83GdmSaFcekEE6CmbfBOGvcfFivzdKKdguwBeSyzsvUjwG2wXlhLEh8E uLfrN X-Gm-Gg: ASbGncv2Vo6hO7BP5GoLLGGEUOk2HStWeTDiHIhP1EYT68KPLAUP358zuQjIHmiJH4R 5z/rbZzTkfCA6PLdlsasMApa1iRO09UmStP3CVDcqNSclelqOLT/r2707RTYx4Ug5oyp26x8T4+ liJzNhVuO10HQC+n0qzDlxZ5XsQMT6rOMVnNynIPJYT+oFljj9RZKsxA/g10arrq99Od7ww/z3E LYGH4U5ktfF7/JIOrpoq/P6y1FJI1F2DYRrySx2w8Q9Rersn68hKSqRUCl9ZQ/0HNRTZSaWOZIh 2/6nLfOO3iXz1sff7rPnqjmdSkIySSb7bv8gQ4bT0COmwbWPwDI8qNbkNmt1yDo= X-Google-Smtp-Source: AGHT+IEaxA8Lq0B1laCaHcOAnqBoXnkQajj1gzeNhidp1lDH2ysWr3Z4JGktRcIikctO2CosWX5uMw== X-Received: by 2002:a17:903:2f90:b0:234:f580:a15 with SMTP id d9443c01a7336-23529203bdfmr34360395ad.14.1748579621512; Thu, 29 May 2025 21:33:41 -0700 (PDT) From: Akihiko Odaki Date: Fri, 30 May 2025 13:33:21 +0900 Subject: [PATCH 6/6] virtio-net: Add hash type options MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250530-vdpa-v1-6-5af4109b1c19@daynix.com> References: <20250530-vdpa-v1-0-5af4109b1c19@daynix.com> In-Reply-To: <20250530-vdpa-v1-0-5af4109b1c19@daynix.com> To: qemu-devel@nongnu.org, Yuri Benditovich , Andrew Melnychenko , "Michael S . Tsirkin" , Jason Wang , Paolo Abeni , devel@daynix.com, Akihiko Odaki X-Mailer: b4 0.15-dev-edae6 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: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62d.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_PASS=-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: 1748579727806116600 By default, virtio-net limits the hash types that will be advertised to the guest so that all hash types are covered by the offloading capability the client provides. This change allows to override this behavior and to advertise hash types that require user-space hash calculation by specifying "on" for the corresponding properties. Signed-off-by: Akihiko Odaki --- include/hw/virtio/virtio-net.h | 1 + hw/net/virtio-net.c | 45 ++++++++++++++++++++++++++++++++++++++= ++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index c4957c44c06e..73fdefc0dcb8 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -148,6 +148,7 @@ typedef struct VirtioNetRssData { uint32_t runtime_hash_types; uint32_t supported_hash_types; uint32_t peer_hash_types; + OnOffAutoBit64 specified_hash_types; uint8_t key[VIRTIO_NET_RSS_MAX_KEY_SIZE]; uint16_t indirections_len; uint16_t *indirections_table; diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index cd5a632596b1..52fe404b3431 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3959,9 +3959,14 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) if (qemu_get_vnet_hash_supported_types(qemu_get_queue(n->nic)->peer, &n->rss_data.peer_hash_types)) { n->rss_data.peer_hash_available =3D true; - n->rss_data.supported_hash_types =3D n->rss_data.peer_hash_types; + n->rss_data.supported_hash_types =3D + n->rss_data.specified_hash_types.on_bits | + (n->rss_data.specified_hash_types.auto_bits & + n->rss_data.peer_hash_types); } else { - n->rss_data.supported_hash_types =3D VIRTIO_NET_RSS_SUPPORTED_HASH= ES; + n->rss_data.supported_hash_types =3D + n->rss_data.specified_hash_types.on_bits | + n->rss_data.specified_hash_types.auto_bits; } } =20 @@ -4178,6 +4183,42 @@ static const Property virtio_net_properties[] =3D { VIRTIO_NET_F_GUEST_USO6, true), DEFINE_PROP_BIT64("host_uso", VirtIONet, host_features, VIRTIO_NET_F_HOST_USO, true), + DEFINE_PROP_ON_OFF_AUTO_BIT64("hash-ipv4", VirtIONet, + rss_data.specified_hash_types, + VIRTIO_NET_HASH_REPORT_IPv4 - 1, + ON_OFF_AUTO_AUTO), + DEFINE_PROP_ON_OFF_AUTO_BIT64("hash-tcp4", VirtIONet, + rss_data.specified_hash_types, + VIRTIO_NET_HASH_REPORT_TCPv4 - 1, + ON_OFF_AUTO_AUTO), + DEFINE_PROP_ON_OFF_AUTO_BIT64("hash-udp4", VirtIONet, + rss_data.specified_hash_types, + VIRTIO_NET_HASH_REPORT_UDPv4 - 1, + ON_OFF_AUTO_AUTO), + DEFINE_PROP_ON_OFF_AUTO_BIT64("hash-ipv6", VirtIONet, + rss_data.specified_hash_types, + VIRTIO_NET_HASH_REPORT_IPv6 - 1, + ON_OFF_AUTO_AUTO), + DEFINE_PROP_ON_OFF_AUTO_BIT64("hash-tcp6", VirtIONet, + rss_data.specified_hash_types, + VIRTIO_NET_HASH_REPORT_TCPv6 - 1, + ON_OFF_AUTO_AUTO), + DEFINE_PROP_ON_OFF_AUTO_BIT64("hash-udp6", VirtIONet, + rss_data.specified_hash_types, + VIRTIO_NET_HASH_REPORT_UDPv6 - 1, + ON_OFF_AUTO_AUTO), + DEFINE_PROP_ON_OFF_AUTO_BIT64("hash-ipv6ex", VirtIONet, + rss_data.specified_hash_types, + VIRTIO_NET_HASH_REPORT_IPv6_EX - 1, + ON_OFF_AUTO_AUTO), + DEFINE_PROP_ON_OFF_AUTO_BIT64("hash-tcp6ex", VirtIONet, + rss_data.specified_hash_types, + VIRTIO_NET_HASH_REPORT_TCPv6_EX - 1, + ON_OFF_AUTO_AUTO), + DEFINE_PROP_ON_OFF_AUTO_BIT64("hash-udp6ex", VirtIONet, + rss_data.specified_hash_types, + VIRTIO_NET_HASH_REPORT_UDPv6_EX - 1, + ON_OFF_AUTO_AUTO), }; =20 static void virtio_net_class_init(ObjectClass *klass, const void *data) --=20 2.49.0