From nobody Wed May 15 23:01:20 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=1688808413; cv=none; d=zohomail.com; s=zohoarc; b=J0Piw66Mc2eJ7hZoJctVB+ii4gAAZFVLlFxn/O7pGzetHTIOeY/n0lUdfsZOhI/kMqEHE0GzxINR8eqNHONJkLOB4JkyRBBt7cQMypAIK237KQh8i0NjI19xSJAH77op4fm3yzhR2yrvKRGPQjs0X+j8VGFKNSjlkj45FfvXWqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688808413; 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=YS54aOZ4UTlUbA4dn/Pd1uNd43qqED1ZdNbpnBRTruw=; b=ONXKSG7kGLCRx0VLC7iE/ESCaqlvfmq4iV78ZGcOAwBnb8glJCRimHx8uKjdfvwIShA4GyRKRAWgGLikjeRNS625wlD2pCETzJy4TGcxhp2lSAEnE9Yoc+Ap86XoejoMmcgvJ1DMuK8rOhO5IKr8/QMXSFKAiCEfIin0DjBIVHM= 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 1688808413555574.5509065484891; Sat, 8 Jul 2023 02:26:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qI4Cc-0002QG-7J; Sat, 08 Jul 2023 05:26:06 -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 1qI4Ca-0002Nn-D5 for qemu-devel@nongnu.org; Sat, 08 Jul 2023 05:26:04 -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 1qI4CY-0001AK-Hs for qemu-devel@nongnu.org; Sat, 08 Jul 2023 05:26:04 -0400 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-55b66ca1c80so1436994a12.0 for ; Sat, 08 Jul 2023 02:26:02 -0700 (PDT) Received: from localhost ([159.226.94.115]) by smtp.gmail.com with ESMTPSA id jj21-20020a170903049500b001b891259eddsm4513519plb.197.2023.07.08.02.26.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jul 2023 02:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688808361; x=1691400361; 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=YS54aOZ4UTlUbA4dn/Pd1uNd43qqED1ZdNbpnBRTruw=; b=f36P/e2zyNBEUUWy1iGnZvy/7Dmtv7VTpvpkm20TxF9Vuci/lJP0zJeXT271nRdd7N UqTjpEVEzHjWPO2p2v+ddLXBLGixVX4wZlQUW36ys8nSrV61mShvmWpvK3AYefuHV4Nv HrHr5IEu6sk0tOUfuYz2/O/TX5Dg7ypgVaWSxc9PZ3MvQSc+Ejh7TVq0YOvsHvj9P/C8 M/Niti5H8if9T0BdC3+7RkDOgNeiJP/mborbpAFgARr/zGoQiiC837uuJHEKmkUA4ito T7PDMBJvA7J+flfR1Azcw2HKFQJTUBq4yfq8D0ZNaEoEFPt2nvWcPb6jd+F03XnE8XgW 2Uhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688808361; x=1691400361; 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=YS54aOZ4UTlUbA4dn/Pd1uNd43qqED1ZdNbpnBRTruw=; b=XSOGZeqDl4IPsCN7gJFb4UCda4eECdy8oDYrPNSuAYHWzUb3u8wE2uXjPrD/l0nM5U zYhWhamT7w+BE5LBMLfzf2q1jkSP77yObll4IGjSqjgIg4CY2G2qWw0eWo2oHnQxayBw dRZpPvasasjJ/T/ZVxhnLpnVTqtT7lsObDM8+v4IxmAcTEWJ/x2yxFTayfdQp8mgAVUO ppidK9bgRJ0Qp/m5EzKH9sKUIb92wWmw+TnyP9cRgjPe0ZhQDn9EetYRo9Nfyyfx5U+G JF2ZoiQOHyCvdMBoSZGj6xfz7l0Ejdy/tQbDl/G8tbnPeon4CzA5mKLqmwXMfGAu8+06 cisw== X-Gm-Message-State: ABy/qLbUuldZnxwG3flETLICMd/beOyE9LAoPeglZo01rYtGH03LOxCB VRJKji0J06nJ6Ktyn6VAbu8= X-Google-Smtp-Source: APBJJlGLI1hlxndyuKXkT2XPeAUP7YPIFABaKofOI95K7zGqP9XHYKo57UVxHz4buxadsu/i+AaS9A== X-Received: by 2002:a17:903:230e:b0:1b5:47fc:5864 with SMTP id d14-20020a170903230e00b001b547fc5864mr6271285plh.56.1688808361089; Sat, 08 Jul 2023 02:26:01 -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 v3 1/2] vdpa: Restore packet receive filtering state relative with _F_CTRL_RX_EXTRA feature Date: Sat, 8 Jul 2023 17:24:51 +0800 Message-Id: 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::532; envelope-from=yin31149@gmail.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, 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: 1688808414132100002 Content-Type: text/plain; charset="utf-8" This patch refactors vhost_vdpa_net_load_rx() to restore the packet receive filtering state in relation to VIRTIO_NET_F_CTRL_RX_EXTRA feature at device's startup. Signed-off-by: Hawkins Jiawei --- v3: - return early if mismatch the condition suggested by Eugenio - remove the `on` variable suggested by Eugenio v2: https://lore.kernel.org/all/66ec4d7e3a680de645043d0331ab65940154f2b8.16= 88365324.git.yin31149@gmail.com/ - avoid sending CVQ command in default state suggested by Eugenio v1: https://lists.nongnu.org/archive/html/qemu-devel/2023-06/msg04957.html net/vhost-vdpa.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 0994836f8c..9a1905fddd 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -867,6 +867,94 @@ static int vhost_vdpa_net_load_rx(VhostVDPAState *s, } } =20 + if (!virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_CTRL_RX_EXTR= A)) { + return 0; + } + + /* + * According to virtio_net_reset(), device turns all-unicast mode + * off by default. + * + * Therefore, QEMU should only send this CVQ command if the driver + * sets all-unicast mode on, different from the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + if (n->alluni) { + dev_written =3D vhost_vdpa_net_load_rx_mode(s, + VIRTIO_NET_CTRL_RX_ALLUNI, 1); + if (dev_written < 0) { + return dev_written; + } + if (*s->status !=3D VIRTIO_NET_OK) { + return -EIO; + } + } + + /* + * According to virtio_net_reset(), device turns non-multicast mode + * off by default. + * + * Therefore, QEMU should only send this CVQ command if the driver + * sets non-multicast mode on, different from the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + if (n->nomulti) { + dev_written =3D vhost_vdpa_net_load_rx_mode(s, + VIRTIO_NET_CTRL_RX_NOMULTI, 1); + if (dev_written < 0) { + return dev_written; + } + if (*s->status !=3D VIRTIO_NET_OK) { + return -EIO; + } + } + + /* + * According to virtio_net_reset(), device turns non-unicast mode + * off by default. + * + * Therefore, QEMU should only send this CVQ command if the driver + * sets non-unicast mode on, different from the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + if (n->nouni) { + dev_written =3D vhost_vdpa_net_load_rx_mode(s, + VIRTIO_NET_CTRL_RX_NOUNI, 1); + if (dev_written < 0) { + return dev_written; + } + if (*s->status !=3D VIRTIO_NET_OK) { + return -EIO; + } + } + + /* + * According to virtio_net_reset(), device turns non-broadcast mode + * off by default. + * + * Therefore, QEMU should only send this CVQ command if the driver + * sets non-broadcast mode on, different from the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + if (n->nobcast) { + dev_written =3D vhost_vdpa_net_load_rx_mode(s, + VIRTIO_NET_CTRL_RX_NOBCAST, 1); + if (dev_written < 0) { + return dev_written; + } + if (*s->status !=3D VIRTIO_NET_OK) { + return -EIO; + } + } + return 0; } =20 --=20 2.25.1 From nobody Wed May 15 23:01:20 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=1688808420; cv=none; d=zohomail.com; s=zohoarc; b=ZiqgOVAZgrfHor8g/i+kPDBZFcB0XadCn2d/3KilGOce5Az/06pnCUSFU78V927Dwl9Yrx3x/51yeiba2nGjC2ld4F3TUpvzrMaszwEth3NL67JMqW/HEfyghHOkvhiVuclFUNQwVb0c7Zg53DGAAD2DJ/wz5bEwXOXxgF/d7xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688808420; 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=DxeNtWgJRVe83GCQvocRBXCW9Y/2jczfQBIZF/TMV5Q=; b=P3A6HrNCFVFSBry2zx/CU1bXt2mGMuAJzayO2nxvm8yEpkgXLzEq2YoDw5iRXnFc34xS3UTxWeSfQ/81Xqv3rUohB+PpGtBaP0xbA1eit20Hop5AdrMkXjR6tnLI8Anxz8OIQXdUB7PBBy/1hFR+2I6KZamMGRqcpkUfwGq2kYc= 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 1688808420335261.53622931392454; Sat, 8 Jul 2023 02:27:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qI4Cg-0002R2-4U; Sat, 08 Jul 2023 05:26:10 -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 1qI4Cd-0002QV-P5 for qemu-devel@nongnu.org; Sat, 08 Jul 2023 05:26:07 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qI4Cc-0001Ay-D4 for qemu-devel@nongnu.org; Sat, 08 Jul 2023 05:26:07 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1b89114266dso19472975ad.0 for ; Sat, 08 Jul 2023 02:26:05 -0700 (PDT) Received: from localhost ([159.226.94.115]) by smtp.gmail.com with ESMTPSA id p8-20020a170902e74800b001b8a8154f3fsm4508908plf.270.2023.07.08.02.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jul 2023 02:26:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688808364; x=1691400364; 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=DxeNtWgJRVe83GCQvocRBXCW9Y/2jczfQBIZF/TMV5Q=; b=S5TGBSjyVPL1dhFceufp+XqynCEQZf4gSlggFMoOGcEJMJTYBdBS7DJspEC6sF72oB mip9ZSKapug2azAVafBk5Ny61n1DhFslS1WLg+/5mM2nQvkWXV0l8FPUTGZHbNdxiQLH uG9WqodicxYrADFO34Fi2CCHQ52Nu3cESyTrZ5p7dgbNtwtLWaCBgrPShVf/GAnAarEZ IN+UaTSuq7FPe9XIKcdAHxnhhl/wnRIlRsha/oQBAQ5wx5c3O0Hm0Xxu1yq1Y6k2oDf/ c1jShSz0CvadgKOQqtCtiK9IOzF7wYg0QTKL4fc9EVP/ReregVgOJSRUGxR6JHOZZhXS KBMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688808364; x=1691400364; 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=DxeNtWgJRVe83GCQvocRBXCW9Y/2jczfQBIZF/TMV5Q=; b=UK/RuXZdlFt9HqMokYDrDs7y79FsxnGrbS6uhqnke3Mxs+uCkWRYHID+6ajjj515Kb /aOXeH8FF2NCvWb1b5u6zShIZii7mbgMRckwllzZ4g4vAJnPrSR1wdv7HqgtbKiTX1HD O2Rp5SgxD6702tA2JCZ8U5ZPXr4CO2OTpphskFJVGXFD3rWF5WKAtAO+pEHNK2cltHon 43SD8IJ3hC/Y5QiDzuYvXZ9sizKTJWjBnUlrvw0hnSEXtVQUzYJM+qlR+6eVWy11VyD+ Q3jssjSxAalaBsUY2WIZKI2MOfWLRxPbIdWbFqP1Y04qoJghsJcfk0wh6QXYV7dMypBt dArA== X-Gm-Message-State: ABy/qLYQQi6Jvzmjc2AMh+2kKAypmpF1d96uaSO0TdQqxlIK/Vjkdo1n l57Ew66nhtc0zg/cLWftzi0= X-Google-Smtp-Source: APBJJlH4sB+TNTFTAo+3UAD14T+eCct/TvtpGvx8Q52oY1se0j77Sz3z8e9TqU7vCmZ+ugbfwTk/mw== X-Received: by 2002:a17:903:1208:b0:1b8:e41:f43f with SMTP id l8-20020a170903120800b001b80e41f43fmr9046205plh.27.1688808363572; Sat, 08 Jul 2023 02:26:03 -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 v3 2/2] vdpa: Allow VIRTIO_NET_F_CTRL_RX_EXTRA in SVQ Date: Sat, 8 Jul 2023 17:24:52 +0800 Message-Id: <15ecc49975f9b8d1316ed4296879564a18abf31e.1688797728.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::629; envelope-from=yin31149@gmail.com; helo=mail-pl1-x629.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: 1688808420671100001 Enable SVQ with VIRTIO_NET_F_CTRL_RX_EXTRA feature. Signed-off-by: Hawkins Jiawei Acked-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 9a1905fddd..1df82636c9 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -105,6 +105,7 @@ static const uint64_t vdpa_svq_device_features =3D BIT_ULL(VIRTIO_NET_F_STATUS) | BIT_ULL(VIRTIO_NET_F_CTRL_VQ) | BIT_ULL(VIRTIO_NET_F_CTRL_RX) | + BIT_ULL(VIRTIO_NET_F_CTRL_RX_EXTRA) | BIT_ULL(VIRTIO_NET_F_MQ) | BIT_ULL(VIRTIO_F_ANY_LAYOUT) | BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) | --=20 2.25.1