From nobody Mon Feb 9 06:07:51 2026 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=1688367696; cv=none; d=zohomail.com; s=zohoarc; b=YqKHjFahxoZ63yOEj82AicgPeGTYXaYSGWab6zb7JwvcbTenoFXsJlYlh+Ult0xEoFuo+3CGV9sHJXHM8Orhh9j9/QUGGc3S1aurMgqcxToHsB/A0CZY8q2Hj5GsCPbrFRdIj+f5HuFY/XcWmsuuXEcGPAapvpRIL6RNc+lYLGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688367696; 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=E/z6RpcImb1+2EgwzyD3jgXXi1S5FfTucd+yIKYsBng=; b=VZjuj5Wvfo/V5+ubEqDejZetfadukhj9WuTB18rpgL+P/v/kIifrELpjqp84lnYyXLtxuG+7caC5osRK4ZyqqY0xoxVzueJXKnTtSoKnI7uOfd1ZObyVqqn9xl5XomiivjYtV8WHjIrNOLA04sGyocyRGWofwg3e+eby5ijbIac= 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 1688367696585217.62647143981894; Mon, 3 Jul 2023 00:01:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGDYS-00079l-HI; Mon, 03 Jul 2023 03:01:00 -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 1qGDYH-00079A-HS for qemu-devel@nongnu.org; Mon, 03 Jul 2023 03:00:56 -0400 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGDYE-0007Gw-Go for qemu-devel@nongnu.org; Mon, 03 Jul 2023 03:00:49 -0400 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-1b0605d4d11so3417440fac.1 for ; Mon, 03 Jul 2023 00:00:46 -0700 (PDT) Received: from localhost ([159.226.94.115]) by smtp.gmail.com with ESMTPSA id sk15-20020a17090b2dcf00b0025eb5aafd3csm14548932pjb.32.2023.07.03.00.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 00:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688367645; x=1690959645; 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=E/z6RpcImb1+2EgwzyD3jgXXi1S5FfTucd+yIKYsBng=; b=UpQhWiPA5PFkBzl64jmhvcYc8QuKVguY0odijNr1XXLYWCwlt/T7CSfyf5EGtQezlm 8fTvJTEej4oq9HUJziT04nueALuVJq6C2Uqf8J3kHncaTLmPiuHhsOEcuHXTrd+WoXvi vvPncqC7Vt2kdPHbtPg4owXHl7wKj0xiw9Ql/Few76xctAI98PfNvwNfIN4VugwzxGBv TO/TCQ3UKOt+WplnP9vaeMOGVnrTRH6qE/mNTxjAhELy2cTqLOwWn5170eCVNAIBQdvR R8qgmJ+c/7oYom9P36R0U3qPX4ij5eYTa+hmFMrpBS4NvhfsJYNxPDal5kEs0K/EN2HV 4VkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688367645; x=1690959645; 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=E/z6RpcImb1+2EgwzyD3jgXXi1S5FfTucd+yIKYsBng=; b=avFwuGJsh+718gaEtsvjiIiQB7N46N0jGDjkUVHw5KTMvQklu5h4yfm2FUJALQDZAD tTnzcLorC98aiWF9RLUZeqweRYhSdQDieNW0COMd2l3TETRQJhbQhVEQ96TrUkt7JKpQ qROWysCDBe3ExKi+8qHyL+StvYJ8nXqO/eaNeIex+Rs/610ykahN/Jz5Afpi390qK+dX lmmjmWcJ9eafEB9PJ9mRJWaSIpP2MOircLwnuWZvDMBAnbZJodcNlcSc4E86kPPRjG9Y XnAtACnjoRCewNRAcw9fC9AOR/Kpp75IEeWWeyMUE8xU1Go7z98ywHkw/R6tMuKBO8SN kASg== X-Gm-Message-State: AC+VfDyLDEWQTU3C27RJa+wdxZLZG8e7IKUyLmhsod8Z81we8/RgpHQv 8zH1i8PiMBEEs2D8K8SNdtk= X-Google-Smtp-Source: ACHHUZ45y/hASFeJwQDhIdFEs7v5WYkkFTjMg961WEQE1FnvUpJ+105kKxRi8tdSNdfmOGaid2uTog== X-Received: by 2002:a05:6870:fba9:b0:1a6:5403:eaae with SMTP id kv41-20020a056870fba900b001a65403eaaemr11159703oab.5.1688367644999; Mon, 03 Jul 2023 00:00:44 -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 RFC v2 1/2] vdpa: Restore packet receive filtering state relative with _F_CTRL_RX_EXTRA feature Date: Mon, 3 Jul 2023 14:59:52 +0800 Message-Id: <66ec4d7e3a680de645043d0331ab65940154f2b8.1688365324.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=2001:4860:4864:20::31; envelope-from=yin31149@gmail.com; helo=mail-oa1-x31.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: 1688367698648100001 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 --- v2: - 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 | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 0410a52043..4919e18208 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -890,6 +890,88 @@ static int vhost_vdpa_net_load_rx(VhostVDPAState *s, } } =20 + if (virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_CTRL_RX_EXTRA= )) { + /* Load the all-unicast mode */ + on =3D n->alluni; + if (on !=3D 0) { + /* + * According to virtio_net_reset(), device turns all-unicast m= ode + * off by default. + * + * Therefore, there is no need to send this CVQ command if the + * driver also sets all-unicast mode off, which aligns with + * the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + r =3D vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_ALLUNI= , on); + if (r < 0) { + return r; + } + } + + /* Load the non-multicast mode */ + on =3D n->nomulti; + if (on !=3D 0) { + /* + * According to virtio_net_reset(), device turns non-multicast= mode + * off by default. + * + * Therefore, there is no need to send this CVQ command if the + * driver also sets non-multicast mode off, which aligns with + * the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + r =3D vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOMULT= I, on); + if (r < 0) { + return r; + } + } + + /* Load the non-unicast mode */ + on =3D n->nouni; + if (on !=3D 0) { + /* + * According to virtio_net_reset(), device turns non-unicast m= ode + * off by default. + * + * Therefore, there is no need to send this CVQ command if the + * driver also sets non-unicast mode off, which aligns with + * the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + r =3D vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOUNI,= on); + if (r < 0) { + return r; + } + } + + /* Load the non-broadcast mode */ + on =3D n->nobcast; + if (on !=3D 0) { + /* + * According to virtio_net_reset(), device turns non-broadcast= mode + * off by default. + * + * Therefore, there is no need to send this CVQ command if the + * driver also sets non-broadcast mode off, which aligns with + * the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + r =3D vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOBCAS= T, on); + if (r < 0) { + return r; + } + } + } + return 0; } =20 --=20 2.25.1