From nobody Mon May 6 20:26:44 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1685706828; cv=none; d=zohomail.com; s=zohoarc; b=kDJFeNcZdWfxwXBxuLVowTT9vtJ/ce1TX2syEMgSkJvjX67UGYIjo+h1j2Ng/v8+VyYp2JTqIIXoXdVCCIuMhJRfLzkLTiqVOJSKuN/hwfWNsCrkDtGCVUb5wQY03RZwWdUR6rP6F9m8Pb6tTLwLDMryInVygZAmkB9cwvNIe9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685706828; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Tfdwdo9EGbsNiJTfLy+KhuY6lhHyln8G6IJjnc2Afnw=; b=dg17huKSkBFsI/GA8wEG+ic0mExjlqMgHjNyldbcYKTwYfWSTawo3nmBe2C+RD4Lr/aj6th9RS3v0MVMvLhGllN84yyCo21tFVCVb2cdc4GLV9kSmtIo1B8f3sHgQ63QBCD4EA83j6mFDAegy7LF6vTGLNxySg0vrOozNI/6U0Q= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685706828294867.2144560873099; Fri, 2 Jun 2023 04:53:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q53KZ-00087i-90; Fri, 02 Jun 2023 07:52:31 -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 1q53KY-00085O-5L for qemu-devel@nongnu.org; Fri, 02 Jun 2023 07:52:30 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q53KW-0007Et-IP for qemu-devel@nongnu.org; Fri, 02 Jun 2023 07:52:29 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1b04782fe07so10669195ad.3 for ; Fri, 02 Jun 2023 04:52:28 -0700 (PDT) Received: from localhost ([159.226.94.115]) by smtp.gmail.com with ESMTPSA id ju11-20020a170903428b00b001a9b29b6759sm1181585plb.183.2023.06.02.04.52.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jun 2023 04:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685706747; x=1688298747; 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=Tfdwdo9EGbsNiJTfLy+KhuY6lhHyln8G6IJjnc2Afnw=; b=cWfXOQU2YhIGZsMj82/COrOTmeBBd6U6GlyzADl8OUu7PZqtF7NrIpQnPd1LLZTd+q k2ZVVaKoN8n4GtVzqy0/UIzCB+qUI9yE0NkD700SJH3taVyUuhk2lgIfMdxxCGeH654X 6rdoVFjB9nFufcNBR+dxWgr6U2mLULwz+xNtjr2s/5lv3ocTLMCyYiZxsY1t9bJ6VBUf B2gKtjH/uAlbWg7MbCxlW5EapL/IpBnOoy8YTQwA5JhQaaDoBpgt7ngDP9p61pttE72X 5HpPS1h1NhKjuKu/B/k3Xu3z+USYebQKchXW7RZTeFXozX+8M5teOMbZXPxLVArsvXZG SPMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685706747; x=1688298747; 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=Tfdwdo9EGbsNiJTfLy+KhuY6lhHyln8G6IJjnc2Afnw=; b=J5iZoKsPoF25AF+H3TC7gvVIvkrlz354R1nOeDvyLzjipPmSedHzejfHiK92qxT28k ris4Rfwdls+bFt/VLhtz08WxdFcQxZKe7Q+Qy6XboazDaG/CC1dbsR+xzfHTr9Vs/XaC wh6M9sD4TwXl23eGT/UMjRuzjqmQJkPUV0nRd9cjhmGHS6fwNBYO1gaSybKcB05Uii4T KAEnKZaiZ/cDoq0Mf3CQ0U/Nf/2ECMN4092Qmcx9MdeLYTlmkQanjKtzN9bPRC1yxEn5 tG7G0i/O5Puhsv2VFzPaux5YYix4bEJ4PZLc4vUwckcs/A/U9q6bv0nA7jo6/pPkvOND sJ1w== X-Gm-Message-State: AC+VfDznofFOwFe9c9J972FzrUDuxHIUuiz44rbMm8qMQ8RrAjQAEKzL H9MWl/w9c0rEDL/BRxa6zBI= X-Google-Smtp-Source: ACHHUZ4HRSpWSlwD9a3iktO23cNwRfTQD0RhdhkKT7hmDRNv6e0jXpfRDDHkOUjAxTcj0FVzxcGwZg== X-Received: by 2002:a17:902:d894:b0:1ab:eee:c5d7 with SMTP id b20-20020a170902d89400b001ab0eeec5d7mr1181610plz.48.1685706746864; Fri, 02 Jun 2023 04:52:26 -0700 (PDT) From: Hawkins Jiawei To: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com Cc: qemu-devel@nongnu.org, yin31149@gmail.com, 18801353760@163.com Subject: [PATCH v4 1/6] include/hw/virtio: make some VirtIODevice const Date: Fri, 2 Jun 2023 19:52:13 +0800 Message-Id: <16c0561b921310a32c240a4fb6e8cee3ffee16fe.1685704856.git.yin31149@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::62c; envelope-from=yin31149@gmail.com; helo=mail-pl1-x62c.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, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1685706829598100007 The VirtIODevice structure is not modified in virtio_vdev_has_feature(). Therefore, make it const to allow this function to accept const variables. Signed-off-by: Hawkins Jiawei Reviewed-by: Eugenio P=C3=A9rez Martin Reviewed-by: Eugenio P=C3=A9rez Tested-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- include/hw/virtio/virtio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index af86ed7249..0492d26900 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -402,7 +402,7 @@ static inline bool virtio_has_feature(uint64_t features= , unsigned int fbit) return !!(features & (1ULL << fbit)); } =20 -static inline bool virtio_vdev_has_feature(VirtIODevice *vdev, +static inline bool virtio_vdev_has_feature(const VirtIODevice *vdev, unsigned int fbit) { return virtio_has_feature(vdev->guest_features, fbit); --=20 2.25.1 From nobody Mon May 6 20:26:44 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1685706792; cv=none; d=zohomail.com; s=zohoarc; b=Zu7AvFoB4r5jliF+wL+ffOAj5/RpP053kYj3qFBpZooiy6gMOurDhT0/PVp/JqAUTE+0ugpekRaqtlIMYAOtVjCo7PuvGpsS41XroA2mOppIfErvREwuVS90FWmHKzHJj5es2ahumlvXizzKf1l560n8HIuvfjoQls7lVaAuhX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685706792; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PdZEvGS5pKAdDP2r/hDEuoCh9mnMaQgfKyqI6O8cGcY=; b=iPEvhBBXDswfmZFhP7Ylof8k3yzPt2+fFbMyCyJqoleODxmmT7dan1GoTE7lFlLsRZ5J4vXzOsHfNEM5zvtM6jGtrMk31ggQ1cA1k7VaGpWtzDTPy+vWECMAtE1mvHQjNEEjmS3ISDt3Llve1mDtuQVkew1Ix4GaIBHEjUOydhI= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685706792259632.7243646716711; Fri, 2 Jun 2023 04:53:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q53Kc-0008I6-Ss; Fri, 02 Jun 2023 07:52:34 -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 1q53Ka-0008AK-Vw for qemu-devel@nongnu.org; Fri, 02 Jun 2023 07:52:33 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q53KZ-0007FV-3d for qemu-devel@nongnu.org; Fri, 02 Jun 2023 07:52:32 -0400 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-2562cc85d3dso1527260a91.1 for ; Fri, 02 Jun 2023 04:52:30 -0700 (PDT) Received: from localhost ([159.226.94.115]) by smtp.gmail.com with ESMTPSA id 27-20020a17090a031b00b002567501040csm3112275pje.42.2023.06.02.04.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jun 2023 04:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685706750; x=1688298750; 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=PdZEvGS5pKAdDP2r/hDEuoCh9mnMaQgfKyqI6O8cGcY=; b=p8LJ9BDno+yEuj5xP028CMjuuna28eKkdocFl1RLW18K95ELqDpPyytuxtnoCpKeSv P75U36//icEGoFnZwB01gVh7HrUIBWLxHEzfl0HB/iTVLMutEEmQXgrN+FhG4n96KbuG urTGsJ7cetA0SkIy0Tv7eP+Actmg2+HpDA/8htlFei2SC7j9E6J95OvV8GjpvRU7s+Y2 khQB8sehnCgzn6testzH+VtT1F0C3SizbgO6RPjUAOYgrccuoZVa4+U/chnWToIbuk85 46y+CuydHaK3OUyGrK9y0dMzDYSMqu7bMAv0Q3mrRRK8rsRZmaYj71hI2RfmVsHVjLsC XGNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685706750; x=1688298750; 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=PdZEvGS5pKAdDP2r/hDEuoCh9mnMaQgfKyqI6O8cGcY=; b=fDIUn+CppJFzVicN3Tpd4lssRZu30ebbmAZ02nIwZwKHTYd5XH0VyF92kna0zzBYSJ iK8uWkV2GozEM4HFgoynbSESnbJwg2yGVRcjj4/PUmHI5AlOSGtzCFdKCfxR0nW2OZnG C9COoB0BNQM1De/w6bcHBsviYTZV2COm6xi0s4iWSExz25DGw9w7dFzqc/yNdnBLIlD2 gyYs8AROfRDKJfyXG6ebSvx04HOow42+wj2sFrj22BLxwlcU8alZ4QUW56lLmHWHoXUJ lzI/xMiDFvxo0kXExKuv+BYM2sqPUk3u2AQ5Et9YSRc/ZsUUS3XoRo88nkn4uijXhoTV 8l8A== X-Gm-Message-State: AC+VfDxuZn13TMkd85XZ7t4rGIr9VG7pf+zHxQo2Lo8VTTq1zwVta/L0 KEZMOTWZy1teZkgStQLABoo= X-Google-Smtp-Source: ACHHUZ5DbV/YPQ279tFs5KMUnqA5JgQy43eEChxP5EkaS1sjIXYBQMHjZ0IzwuaXvQj8grFFnhLT6A== X-Received: by 2002:a17:90b:f0a:b0:255:afdd:2e7 with SMTP id br10-20020a17090b0f0a00b00255afdd02e7mr2215045pjb.7.1685706749628; Fri, 02 Jun 2023 04:52:29 -0700 (PDT) From: Hawkins Jiawei To: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com Cc: qemu-devel@nongnu.org, yin31149@gmail.com, 18801353760@163.com Subject: [PATCH v4 2/6] vdpa: reuse virtio_vdev_has_feature() Date: Fri, 2 Jun 2023 19:52:14 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::102d; envelope-from=yin31149@gmail.com; helo=mail-pj1-x102d.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, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1685706793514100007 We can use virtio_vdev_has_feature() instead of manually accessing the features. Signed-off-by: Hawkins Jiawei Acked-by: Eugenio P=C3=A9rez Reviewed-by: Eugenio P=C3=A9rez Tested-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- net/vhost-vdpa.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 37cdc84562..e907a3c792 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -643,8 +643,7 @@ static ssize_t vhost_vdpa_net_load_cmd(VhostVDPAState *= s, uint8_t class, =20 static int vhost_vdpa_net_load_mac(VhostVDPAState *s, const VirtIONet *n) { - uint64_t features =3D n->parent_obj.guest_features; - if (features & BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR)) { + if (virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_CTRL_MAC_ADDR= )) { ssize_t dev_written =3D vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL= _MAC, VIRTIO_NET_CTRL_MAC_ADDR= _SET, n->mac, sizeof(n->mac)); @@ -662,10 +661,9 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s, const VirtIONet *n) { struct virtio_net_ctrl_mq mq; - uint64_t features =3D n->parent_obj.guest_features; ssize_t dev_written; =20 - if (!(features & BIT_ULL(VIRTIO_NET_F_MQ))) { + if (!virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_MQ)) { return 0; } =20 --=20 2.25.1 From nobody Mon May 6 20:26:44 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1685706839; cv=none; d=zohomail.com; s=zohoarc; b=UeozlnoAxQauicSZo8zTnYOugZ8rt1FsS5bQoT4XF0+pT1CO94b+2N7dYdhqnFWHcgNUzxI/geuE2KCSIyeB+s/WvBML2f7fYKsfomG3TOlAoWsCGl3O6fH1CoqaMq4vBmMGU7Z9NUkB2yEXnRej9breNE5MrHXdGHhX3sImrqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685706839; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PR8gVp6AayIwlrOZ5rFXSJfbCB9/dT2f8XhiwNsNRww=; b=GUQ0rG8+I1W7Y+6ZcccQL01rT2KdgJIT0SjoaQW2kjLchTqkmSbxyXm54278WvWGhh61zIFK1h8GgcAyVEZsW3UAaxc+w7w83N7+z7CDzfMdQma3AdxDhpDbngO1w1rNX+k5g6WmAYQY1OJY+39e8HAdseGKH0A2OIN8khRMYn8= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685706839818366.06296065981724; Fri, 2 Jun 2023 04:53:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q53Ke-0008JV-SD; Fri, 02 Jun 2023 07:52:36 -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 1q53Kd-0008IJ-4j for qemu-devel@nongnu.org; Fri, 02 Jun 2023 07:52:35 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q53Kb-0007G9-L9 for qemu-devel@nongnu.org; Fri, 02 Jun 2023 07:52:34 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-64f47448aeaso1307804b3a.0 for ; Fri, 02 Jun 2023 04:52:33 -0700 (PDT) Received: from localhost ([159.226.94.115]) by smtp.gmail.com with ESMTPSA id e21-20020a170902d39500b001aaf2172418sm1190659pld.95.2023.06.02.04.52.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jun 2023 04:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685706752; x=1688298752; 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=PR8gVp6AayIwlrOZ5rFXSJfbCB9/dT2f8XhiwNsNRww=; b=ixUqMJq7lMbyHcVcQtZZhKMPlD67/eSpqX+oz7WNXEl1ci5foffYb7ukeDa3ot2TLI mjiS9hujPhekZTmwQp2YC4RsKiubvGvqAzoGkNOAwp/sq/0ayr9WiSKak/LsEvFvQYsi 2Xh6kiFWni2gqkFt7QfkRoU1NyZuFJVwbHw3b7zI3qLXAaIFyoMOujoZaqMLFoIh2TBv kBMLUjLtJFhtecyJv/WRTLsC9rHiLSqMDELSwdq9tmrZf9GgW2hIS0XWdC7khgpnHk54 UF7QC5E7KiN/LxVUFSAsIDUEzE3YpQEEwIL9HvLlpIcEOUjkOZUSWIw9IzXjZQ0U7W+r B5YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685706752; x=1688298752; 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=PR8gVp6AayIwlrOZ5rFXSJfbCB9/dT2f8XhiwNsNRww=; b=Ca4TtTeyamN4Icqp67Zf3atEAjzxrdaPiVWOWiKg89Rb06OBrpma42oJ0lQcHfMB3Q nkxvpSqTk0nK6ooZFX0Ceo9K6TUQdGmu9ICX76eHIiw/YM0B/3RdXp66DUHnU11Axj5F taPKD0y7hF0yFM+WUkIYue2GVGos1uY4onBdl044MJBda9fmHDjdhMYBD0U4BYwGJYaf fpbIQ2nWUJgBSrAkJroLznN5hZp6VtRapHUyCnUGl3Off5j7yTrAMu7MUUiZrfFu8mOU Wpt5k4Td0yqk+kGVXsjylJMpHsqWqXvf8PMcdYYrY5t59GaqFu05eBCsiN8y66TuThK2 hoOg== X-Gm-Message-State: AC+VfDxd8Ve6POFIglElzvm3ZQr3EvaphhZpPRg0Wi5UreF8eRZ4AgOF 6FJgDcqs7n5HRPsoLck6/cY= X-Google-Smtp-Source: ACHHUZ5OaLaJXDakvssJWFlAYaAPFK7vdEzWRQGMD/p+4D0n8oSzyJmupi0GDZWZEYqGLkGNRxd70A== X-Received: by 2002:a05:6a20:a5a9:b0:10c:67c9:e5ea with SMTP id bc41-20020a056a20a5a900b0010c67c9e5eamr8467201pzb.31.1685706751932; Fri, 02 Jun 2023 04:52:31 -0700 (PDT) From: Hawkins Jiawei To: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com Cc: qemu-devel@nongnu.org, yin31149@gmail.com, 18801353760@163.com Subject: [PATCH v4 3/6] hw/net/virtio-net: make some VirtIONet const Date: Fri, 2 Jun 2023 19:52:15 +0800 Message-Id: <489b09c3998ac09b9135e57a7dd8c56a4be8cdf9.1685704856.git.yin31149@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::42d; envelope-from=yin31149@gmail.com; helo=mail-pf1-x42d.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, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1685706841094100003 The VirtIONet structure is not modified in virtio_net_supported_guest_offloads(). Therefore, make it const to allow this function to accept const variables. Signed-off-by: Hawkins Jiawei Reviewed-by: Eugenio P=C3=A9rez Tested-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- hw/net/virtio-net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 6df6b7329d..7b27dad6c4 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -874,7 +874,7 @@ static uint64_t virtio_net_guest_offloads_by_features(u= int32_t features) return guest_offloads_mask & features; } =20 -static inline uint64_t virtio_net_supported_guest_offloads(VirtIONet *n) +static inline uint64_t virtio_net_supported_guest_offloads(const VirtIONet= *n) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); return virtio_net_guest_offloads_by_features(vdev->guest_features); --=20 2.25.1 From nobody Mon May 6 20:26:44 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1685706792; cv=none; d=zohomail.com; s=zohoarc; b=bYqFraurUSBCXVMrbfeO2R/8suAOIG4r9ab77yc1C6O9nyl3kAACgeKJt+8MBAXTjMKv1WwgSXfFUJfqcyBuvygScYS10THDDUljN58Kj0d0sJlo1i6BbaUiPXgCwSgvLALDwcaOlDU2RHmRgntSx1pE6/VR4t0LPjYfTJC7q9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685706792; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VAms4dm3KCeYAKXoZpA5YggmskcWUP006Xt8FZqxidk=; b=KRPhZIqMJ9IMB3I2zo0cv5qM47nDmzsE7QnjeN3ilzM5JluIxzfan4MtmzgYRNwU2uVAhTBfooUbylJTuua5ilhYOc34KLVEWUC3QU3RJTPMSAi4nStZlLAINLqjgFvgHL60ZLFAs0khW205Fd6wOWR5vwbKPlLdbTcZlqwFpEE= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685706792258319.9579971537938; Fri, 2 Jun 2023 04:53:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q53Kg-0008Jy-Bg; Fri, 02 Jun 2023 07:52:38 -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 1q53Kf-0008Jn-7D for qemu-devel@nongnu.org; Fri, 02 Jun 2023 07:52:37 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q53Kd-0007GX-ME for qemu-devel@nongnu.org; Fri, 02 Jun 2023 07:52:36 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1b026657a6fso17264905ad.0 for ; Fri, 02 Jun 2023 04:52:35 -0700 (PDT) Received: from localhost ([159.226.94.115]) by smtp.gmail.com with ESMTPSA id n13-20020a170902e54d00b001ae4d4d2676sm1163536plf.269.2023.06.02.04.52.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jun 2023 04:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685706754; x=1688298754; 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=VAms4dm3KCeYAKXoZpA5YggmskcWUP006Xt8FZqxidk=; b=S/qkFZYC2wSNSt+GCcqvwdxlG8IA+7ME0ZRyaJ5cNN4nTdniALxHFilkPiiQHaXCPg 6j2KRa+LQdCgh+kFVRf3Ny8j2HDKgrBxZD0FxeeQzbhxQPed80Q03BhaJWrIVEcDlHlE cYvrrMV6tk0KCVKQZsXbyAJIcb2w2TliZy50qZWpY1IA8la7xVKRB52LsytX85QnYoBD Cg1mPzDamleiEiC3hXl+a1q9jNPwAUQiawzlw6M+uYbGvzHYZfEzkYBHMMjN887Zg6Ze X0PdGcfpUhpv09SZDMSQy1kgb9DRWR/X5xHxFhy+Lr1kCoS2v7duQE5pWVNSVUNpOa64 QIaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685706754; x=1688298754; 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=VAms4dm3KCeYAKXoZpA5YggmskcWUP006Xt8FZqxidk=; b=DGCmpmLC3tpEVbkAFE7MiE4wtJr55QxPK00oSUgaKNq782iUCXmNiMm+4X/700Dx79 l1idD53wjxzZCnQ9tHacyu78sZeoSOumW7JxvW0wp3I+IswdgbeUKQ192kv0HGWPoWLz Zu7ATT3u+oWmYAX5t91aPRoMmuyuU+nNLswIBlg7v/oz6jYp6H9Fi21Fa2CieOh3uyOO Eu7iG7eYFplIt59RcAekuGaRpC7snDPGcdprUhbYvKxt/Jcw0uMvuLRPI7bir+X+KCLF Ue1XTFuhsttKVmT4NaF9QL+lw28Q2PlIIxvioRbzka7P6p7LnsGOIqeOXDx6qIRK6IEK nmww== X-Gm-Message-State: AC+VfDzsu7pL2oxbWa+r5U5DbnW6ZMPA8PkOPtX4z5ll75DXQJQ2fboT Eu2kDJvSQDyNh/kN9upk7kU= X-Google-Smtp-Source: ACHHUZ4eLUD4sr+T1pioYM4U0o4IYg4bJfsIArHF3+eFF8gN1qvX/RF4qjqbsj+RRC+/kvD4IDAvPw== X-Received: by 2002:a17:902:f7d4:b0:1b0:2f15:e0b3 with SMTP id h20-20020a170902f7d400b001b02f15e0b3mr2096535plw.50.1685706754276; Fri, 02 Jun 2023 04:52:34 -0700 (PDT) From: Hawkins Jiawei To: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com Cc: qemu-devel@nongnu.org, yin31149@gmail.com, 18801353760@163.com Subject: [PATCH v4 4/6] virtio-net: expose virtio_net_supported_guest_offloads() Date: Fri, 2 Jun 2023 19:52:16 +0800 Message-Id: <43679506f3f039a7aa2bdd5b49785107b5dfd7d4.1685704856.git.yin31149@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::636; envelope-from=yin31149@gmail.com; helo=mail-pl1-x636.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, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1685706793244100002 Content-Type: text/plain; charset="utf-8" To support restoring offloads state in vdpa, it is necessary to expose the function virtio_net_supported_guest_offloads(). According to VirtIO standard, "Upon feature negotiation corresponding offload gets enabled to preserve backward compatibility.". Therefore, QEMU uses this function to get the device supported offloads. This allows QEMU to know the device's defaults and skip the control message sending if these defaults align with the driver's configuration. Note that the device's defaults can mismatch the driver's configuration only at live migration. Signed-off-by: Hawkins Jiawei Reviewed-by: Eugenio P=C3=A9rez Tested-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- hw/net/virtio-net.c | 2 +- include/hw/virtio/virtio-net.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 7b27dad6c4..7e8897a8bc 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -874,7 +874,7 @@ static uint64_t virtio_net_guest_offloads_by_features(u= int32_t features) return guest_offloads_mask & features; } =20 -static inline uint64_t virtio_net_supported_guest_offloads(const VirtIONet= *n) +uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); return virtio_net_guest_offloads_by_features(vdev->guest_features); diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index ef234ffe7e..5f5dcb4572 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -227,5 +227,6 @@ size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev, unsigned out_num); void virtio_net_set_netclient_name(VirtIONet *n, const char *name, const char *type); +uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n); =20 #endif --=20 2.25.1 From nobody Mon May 6 20:26:44 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1685706796; cv=none; d=zohomail.com; s=zohoarc; b=TX1BBnq+IMhcxij2LX2x9d71h/8IlNqs0Tf28rlZ33RPq5hm2qDrR47MEuvqRMRuMdCn1QMfxXTXkWkRTj42kIivqHQPCQPOcY3iVUHkaIrv/sQond1VHXgLSoEX4LTZW+t6Fq4ZrLSO4KvTbCk5V0wI50mAfYHAJaaE+99F0hs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685706796; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0qcxgCXtqBx5DBEK6YoQwk5QCMI9bRJjdZFLaUSr1gU=; b=Z5fGKJreDLwPayi4wHOuTpAOoK1DBmsALr1bPxOD85zijmFA1M+5MykCyDaigvWFjz3fvB4HVwyzTKmRfXHZsy0dY2QK4OZpGb4iGdO6Th2T2P/Trvue6NLgt1zdUVxrLK5nXt6K6ewQ6n/Hscexpxbk4DWraZzwgtXCMM9Bx40= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685706796187570.4632233129632; Fri, 2 Jun 2023 04:53:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q53Kj-0008L0-Ta; Fri, 02 Jun 2023 07:52:41 -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 1q53Ki-0008KU-5Y for qemu-devel@nongnu.org; Fri, 02 Jun 2023 07:52:40 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q53Kg-0007Gy-Is for qemu-devel@nongnu.org; Fri, 02 Jun 2023 07:52:39 -0400 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2565a896d07so872618a91.2 for ; Fri, 02 Jun 2023 04:52:38 -0700 (PDT) Received: from localhost ([159.226.94.115]) by smtp.gmail.com with ESMTPSA id g13-20020a17090a290d00b00256799877ffsm1123319pjd.47.2023.06.02.04.52.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jun 2023 04:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685706757; x=1688298757; 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=0qcxgCXtqBx5DBEK6YoQwk5QCMI9bRJjdZFLaUSr1gU=; b=Nxr2+7qVUpB5uF7RnTyKkmmC94rXebELBQKlIfU5AyiBxdEXE2neKFJcvqaJlfrDzw lqglVSI9APADRVlkMK79V3+MUC3FmghqaB5IB5BY6LmzwkRE3xzQHyV7HkT14zDjPLPJ XGlwe1Rcohux46KiATwMOQJxrqnBF6vB/16hZv/OF05Yuo4jAqBJHvq/MUkDuaSbx+hF 4DK7qEfxGqjI0dqXHn+WqdRMwS0tyxDWppEyX7UVfGQRkmCcabLTSDayzL+2Vre4DgjW T/Hf+3yTqRbL87DhIPVfra6ZuJr6TAIrH7jUolumTv3qOEX3YZWUkZH0LH6rSHF2bUrl UBHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685706757; x=1688298757; 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=0qcxgCXtqBx5DBEK6YoQwk5QCMI9bRJjdZFLaUSr1gU=; b=bepoclif0lAfxhTW1VBg7NGZBeZweLm2gLOnDAUd+xivK1Krobzr0GmtTlzrbtAMLD /2lpm+1pj3+xIzoTMyJOpjCJWydUphOmL9uRmaFozmHXv47zcSL55kLX1DiT6S7wa3nd vciX8lonk7RC7sJ7VhQA2uPRB3SwJL+Y2FKgpeRu3GIGOU5Mi2cBcpBAJhPsX10Yy5Fy YVKC8kBBW7JdT785IR/tpcW+qgLvT71pTzg+R/mS9SRSbfhcrtRC8yD75l4o+M1sAr3d z0MQzJJH72VjsDuYLwGHI7kFnoY5a4bxcOjmz/CNy3kqcoECP3KGckP9CcMPhLHAUUw2 qXDw== X-Gm-Message-State: AC+VfDzBHMY//9XG7Elns8mxVpDSWRJcjYN2DVLbA/GS0JBfZPc1HU9k c60rCfD7zQG+qk5AjeULmN0= X-Google-Smtp-Source: ACHHUZ5BCxtdpuzf5wM99YT0OO+7im0id+W2mxzMcX4PZm+Xyh3Ln2pWeORzikcA/T2xZm0uJgT+cg== X-Received: by 2002:a17:90a:3b0b:b0:256:4246:d94d with SMTP id d11-20020a17090a3b0b00b002564246d94dmr1161051pjc.3.1685706757026; Fri, 02 Jun 2023 04:52:37 -0700 (PDT) From: Hawkins Jiawei To: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com Cc: qemu-devel@nongnu.org, yin31149@gmail.com, 18801353760@163.com Subject: [PATCH v4 5/6] vdpa: Add vhost_vdpa_net_load_offloads() Date: Fri, 2 Jun 2023 19:52:17 +0800 Message-Id: <7e2b5cad9c48c917df53d80dec27dbfeb513e1a3.1685704856.git.yin31149@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::1036; envelope-from=yin31149@gmail.com; helo=mail-pj1-x1036.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, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1685706797433100002 Content-Type: text/plain; charset="utf-8" This patch introduces vhost_vdpa_net_load_offloads() to restore offloads state at device's startup. Signed-off-by: Hawkins Jiawei Reviewed-by: Eugenio P=C3=A9rez Tested-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- net/vhost-vdpa.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index e907a3c792..1a295af51d 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -678,6 +678,44 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s, return *s->status !=3D VIRTIO_NET_OK; } =20 +static int vhost_vdpa_net_load_offloads(VhostVDPAState *s, + const VirtIONet *n) +{ + uint64_t offloads; + ssize_t dev_written; + + if (!virtio_vdev_has_feature(&n->parent_obj, + VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { + return 0; + } + + if (n->curr_guest_offloads =3D=3D virtio_net_supported_guest_offloads(= n)) { + /* + * According to VirtIO standard, "Upon feature negotiation + * corresponding offload gets enabled to preserve + * backward compatibility.". + * + * Therefore, there is no need to send this CVQ command if the + * driver also enables all supported offloads, which aligns with + * the device's defaults. + * + * Note that the device's defaults can mismatch the driver's confi= guration + * only at live migration. + */ + return 0; + } + + offloads =3D cpu_to_le64(n->curr_guest_offloads); + dev_written =3D vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_GUEST_OFFLO= ADS, + VIRTIO_NET_CTRL_GUEST_OFFLOADS_S= ET, + &offloads, sizeof(offloads)); + if (unlikely(dev_written < 0)) { + return dev_written; + } + + return *s->status !=3D VIRTIO_NET_OK; +} + static int vhost_vdpa_net_load(NetClientState *nc) { VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); @@ -700,6 +738,10 @@ static int vhost_vdpa_net_load(NetClientState *nc) if (unlikely(r)) { return r; } + r =3D vhost_vdpa_net_load_offloads(s, n); + if (unlikely(r)) { + return r; + } =20 return 0; } --=20 2.25.1 From nobody Mon May 6 20:26:44 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1685706826; cv=none; d=zohomail.com; s=zohoarc; b=Nb2hKOWIpo/qHDGV/IFKMLqWPRVTrF3uPnegRCbtXhm2myvZ7UkdPQOEgVyTL5sB/o+S9sRg1JkZoOFYbUWjCz1XYgw5zSaue6n9YXlcMdPLzlwz3GPLn+5RuzSv+xGr2SDOYNKCfFxYmXOtSIYFHWadG/qZgD/OlV2tsRUX3PM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685706826; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iSlNPZFePKdQEbEASdUB2CHWXuLAoQ8iKDnQOm/+zKI=; b=HGcZ+ktlzno+zyTJ77wk0DeR4+/y2zBxacWO1eBBCTq6jvXtsnI8MR/0FfSbNXXrVnZVBIKVaLqxRC/BQ/4tc8IwRz8NdlIDd6TXhWGMitp437dqjNSuqXe7agxTXeQ7ZWQCUF6/5t1l5DjN612JCvidtUL46lDo98BRyimI2a8= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685706826505488.5070000518725; Fri, 2 Jun 2023 04:53:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q53Kl-0008LU-Ev; Fri, 02 Jun 2023 07:52: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 1q53Kk-0008L9-EC for qemu-devel@nongnu.org; Fri, 02 Jun 2023 07:52: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 1q53Ki-0007HE-TL for qemu-devel@nongnu.org; Fri, 02 Jun 2023 07:52:42 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-652328c18d5so814504b3a.1 for ; Fri, 02 Jun 2023 04:52:40 -0700 (PDT) Received: from localhost ([159.226.94.115]) by smtp.gmail.com with ESMTPSA id l17-20020a170902f69100b001a96d295f15sm1155751plg.284.2023.06.02.04.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jun 2023 04:52:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685706759; x=1688298759; 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=iSlNPZFePKdQEbEASdUB2CHWXuLAoQ8iKDnQOm/+zKI=; b=V/aLzWX9C3sGodHjt03sHEQDYuEqp9b9/rALEjN9AldjvsKQsj3/fPtQxqdqPppk3r N6D2Hje2wGx9BtuPItvJvXlTsKYTYNOM7ZmiIeNImz/IH3QAezUNOTor7AN9s7vETZXk yhnqRH+13sjKiZIP6pXKNO0vRqveanN/ZuQTVBgZmk2wFK1GS8qj9mG5+KOqE1JVAvhe PnTzdfMrc48dUtX9j9dBeUMKUC50L1fTU+PxOXnLQTxAz9iNhie9SqTbjEm7tY42XqGN IHp6xnCWoWES6cNEKb5dNKNS1ubDfhuuFN5HRksphTAUVFFERrUZ2CmFj+/AoiHmYzv3 p2XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685706759; x=1688298759; 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=iSlNPZFePKdQEbEASdUB2CHWXuLAoQ8iKDnQOm/+zKI=; b=aLEzF0klcfeHwvu4oZEv5toAn4hWOscqzN04+nMk35a+uxcGe0nJConaQInvxxYtMi jyxr0cqnEMObsbxBUjhx17XlW9jjIs35IDU64Xus3veLtbwQ3fvnimPK6PBlj9Y3rCBS E4jQR/R+hVYibdlviyhKce6xGmqXoqPr6sGll+M9Vb83MXb33NSTZIAg/eMgio34hqgh iHoX2Xzv46p5dJFX8EWlpt+kZUxA8bLOKlTML3e8y7PwzG6TwyBScEuSvpCIJ1teMk3m A+aMYI1pKH8wUHVKx0YGi469WgI91/kvdEZh30FdhY5JcEBcFu6gyYEFpe2EsQ4YuIPn nvrg== X-Gm-Message-State: AC+VfDzkKt4YskIj+U+6UpZa2QxT/slXvl6NxjfecivhnYQu3L6BbBs3 MtxJEbvPajUpTGgYAJBidq4= X-Google-Smtp-Source: ACHHUZ5SZQB3siTx5GSYGp3q6o7bdm5wiPddcQvhZIyvUXPQXi64GNNtLcc22zkCTdasUCvN8A0yCQ== X-Received: by 2002:a05:6a20:9389:b0:10f:1d52:93c2 with SMTP id x9-20020a056a20938900b0010f1d5293c2mr9384958pzh.28.1685706759415; Fri, 02 Jun 2023 04:52:39 -0700 (PDT) From: Hawkins Jiawei To: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com Cc: qemu-devel@nongnu.org, yin31149@gmail.com, 18801353760@163.com Subject: [PATCH v4 6/6] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ Date: Fri, 2 Jun 2023 19:52:18 +0800 Message-Id: <778d642ecae6deed8a218b0e6232e4d7bb96b439.1685704856.git.yin31149@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::42f; envelope-from=yin31149@gmail.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, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1685706827598100001 Enable SVQ with VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature. Signed-off-by: Hawkins Jiawei Acked-by: Jason Wang Acked-by: Eugenio P=C3=A9rez Reviewed-by: Eugenio P=C3=A9rez Tested-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- net/vhost-vdpa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1a295af51d..5a72204899 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -85,6 +85,7 @@ const int vdpa_feature_bits[] =3D { static const uint64_t vdpa_svq_device_features =3D BIT_ULL(VIRTIO_NET_F_CSUM) | BIT_ULL(VIRTIO_NET_F_GUEST_CSUM) | + BIT_ULL(VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) | BIT_ULL(VIRTIO_NET_F_MTU) | BIT_ULL(VIRTIO_NET_F_MAC) | BIT_ULL(VIRTIO_NET_F_GUEST_TSO4) | --=20 2.25.1