From nobody Wed May 15 09:59:34 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=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 From nobody Wed May 15 09:59:34 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=1688367691; cv=none; d=zohomail.com; s=zohoarc; b=Ath+xlMbmCA//jOMvourAxGcGnY1HCec1vIZTT9V6ONceNRCuCnV3KVVEFk7K4H9nKCAthp9hvV0Oc/FZvj8jKxBDLxJc9Sg7PSxCy9x6lgbmg6gHA9AvG0N5b5D36ynA8SFVszW9UeyZ23KXGtMzX3t6kdeHVYLmYtsR0wl40U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688367691; 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=Ha3IkVBd+fUFewyk5DQkD6w2X7LJOGWyyzCNhIUssA4=; b=W0BxSDWmy6FnsreEOg/3m0imzfpSC2Oy130eGvx4IDVXky3gtDhAJg3nx7EbRpGoqH95aj6qmAf5e/Dya30wcSyt6weDQt8NBVOdTSB+FdLvKUEb1TM7zc9Merg5FoYr6BAiOLtVpa+vUn+/fn7iRYGPi+FzHTTT8TUh4tdEf+w= 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 1688367691696816.4156343457535; Mon, 3 Jul 2023 00:01:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGDYU-0007Bg-Es; Mon, 03 Jul 2023 03:01:02 -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 1qGDYJ-00079D-J0 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 03:00:56 -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 1qGDYI-0007HO-2N for qemu-devel@nongnu.org; Mon, 03 Jul 2023 03:00:51 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1b7fb1a82c4so22482145ad.1 for ; Mon, 03 Jul 2023 00:00:49 -0700 (PDT) Received: from localhost ([159.226.94.115]) by smtp.gmail.com with ESMTPSA id ji5-20020a170903324500b001b895a9f681sm1204576plb.29.2023.07.03.00.00.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 00:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688367648; x=1690959648; 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=Ha3IkVBd+fUFewyk5DQkD6w2X7LJOGWyyzCNhIUssA4=; b=EhSM43kVWAddwl/5Io+M75awcNWxFxmuTPkhkBv9FGlvcES6DZbokYajmTOraqz9Tn rAsrZz0HhXliAARg7Bv70bSM7fDYqPwazAEI8pQ/qu1K1ckHsFv5vBs5e1Gh5ZzUov8q tenf7CoR+dm3ricrdNKMOzX3DUwhAQH66hzoqpq9F8rUlbTsRoDF0vxNwVIYLRQkeP7Z Hex6wtDURKnaOGTY5XCW22uVELq1cq3F+ws8kQhDjKMXnhndzj3KR5Ks/sY9hYwCy4+g /PTeynUVbAYMyhD3WT5FiTgzfkRl0i85vCZZHeAH8u7khNLtfwJ+LBwVTKKfdKVryM6Z ziGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688367648; x=1690959648; 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=Ha3IkVBd+fUFewyk5DQkD6w2X7LJOGWyyzCNhIUssA4=; b=dmc09NBPXdL0UpZS40FlSwI5ikSrwuFv9WWy9ukPEPBCPooiScfKIByy7Klmu9svST WznVUoMd3FcJ5LFg4GcvQk4jog4PimN8AT6/LPs4H2PF4ilTXzKfOviU5Xqh4V2SmU5i NCm5L/EG7iukUfAmJ54OslmvXM478bUaycgZ2Ee4il3PuvIH7SkOWBu/XfbK1dxYWBAQ lkfJ3H5/KpgjsXqZncwZndwKrbKPX8ASTDzKr7cy8esQyy4INzgY88jAhJxkbkWORoKl 5uBAkfzH9i5ar5SWAty8Xg7jqbaq7jM4FXora4PMPYbVVvj6jXDGTDWVuBioQKQcTI+V hRrw== X-Gm-Message-State: ABy/qLZ7LeEC7ky8ILCYDYAt1ep5uCYgoTp8AJoIplNHk3O6iE57FIms hBXChN0D2eUXSyZitsZG5ig= X-Google-Smtp-Source: APBJJlESW0//cl/sjhNNRYIGI8nuFDYpnniIGEuyDWNqO/VGxeoAzABNbeOWUPYt0+zUdCgy0CzzgQ== X-Received: by 2002:a17:903:244d:b0:1b8:9b1d:d7f1 with SMTP id l13-20020a170903244d00b001b89b1dd7f1mr1152614pls.47.1688367648123; Mon, 03 Jul 2023 00:00:48 -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 2/2] vdpa: Allow VIRTIO_NET_F_CTRL_RX_EXTRA in SVQ Date: Mon, 3 Jul 2023 14:59:53 +0800 Message-Id: <07f600faa258a0673c74854735d71a0a623c3721.1688365324.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: 1688367692660100001 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 4919e18208..e10a0128c3 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