From nobody Tue May 21 18:49: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=1690114263; cv=none; d=zohomail.com; s=zohoarc; b=WklObguLkgYxUL/I52nhXQEwIggsZWCi3NMOaDPvK0GdkZ6f/65IJNad3M16Ia459zmcFUbC83gXtqoFIVZO1IkKLnk983Aik58xq1aC9iIQcuOv9tzDGL1gwFNj5pL2POY8odJAR0L+QRjZXeBIQo1iPDZ4z6GoXu4q0I8pIsY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690114263; 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=Mruzh5CY/l/MhA8f7XCTVPhhFsQd/B3p25trO/Qstzk=; b=i6CsE3k5OFwuki4GlcwMMl5p1I9RNGfaHvnWbzrWrDicPT59YGGDUD5X/4Lhh8wgAXRK7me++2Z8ba4rJINsnfu8fC3crY/zJPra7RR44iu0IvSOq00yVOSN0o0552IeNOdDaZ7Jo7T4ZceRZV327JlaSHSdPXX7SnFH3Lp3Gls= 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 1690114263390180.43527030052508; Sun, 23 Jul 2023 05:11:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNXuA-0006fj-9o; Sun, 23 Jul 2023 08:09:42 -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 1qNXu6-0006eg-Fd for qemu-devel@nongnu.org; Sun, 23 Jul 2023 08:09:38 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qNXu4-00084d-LA for qemu-devel@nongnu.org; Sun, 23 Jul 2023 08:09:38 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-666edfc50deso2193211b3a.0 for ; Sun, 23 Jul 2023 05:09:36 -0700 (PDT) Received: from localhost ([223.104.38.215]) by smtp.gmail.com with ESMTPSA id y13-20020a17090aca8d00b00263b4b1255esm6604457pjt.51.2023.07.23.05.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jul 2023 05:09:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690114175; x=1690718975; 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=Mruzh5CY/l/MhA8f7XCTVPhhFsQd/B3p25trO/Qstzk=; b=cFXpO5sQIHVGl7LQRzUxduh9UMuevktIYTKAMx5Xl86E+Jld16xqid5jJa22eN+iWa jajbmjtetVWPA3d8bmR+CwCS9eR7T7FbFgQQa6uIxQqMQ10W0w2PImk/51KH5LfJTI/K j1BXU+KhYAQJ+gavK0Sy8o8RlxeeHbGHY17tfFV8NvFlHLC3GH6Dd8+TUtytDs363NQ7 twMhJbcry6shluQU87AEoBaCCM5iy6P488TKBjRxRvYxNEdosh/RNPKHjOze+4dnVSFY moSQvamupgng/HPPYOeDgQa+juml/dOlSBJXstBlEWgwCn0azKBdqehiAGYuAHUhQ46F t1kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690114175; x=1690718975; 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=Mruzh5CY/l/MhA8f7XCTVPhhFsQd/B3p25trO/Qstzk=; b=RfnGIf7Ehk6+CnwZHKJRFGIKVNDjHq8+UX/drYb4mIB8BQthNYgbxafYksDF8YAwwL XgMg99FkHsQ5biSJ8d+M0b+kZYQzxuvH2STKPOA3YIIrs5/9HVxomTFzdxhZvtSA51Zy lDr13twP2xG+s0vlx3mxmIH/xGobj5BmmIxWl50b9qhfBHQ7nfL/0D8W9puFgVxUhcar GpPU5lSb7SII32q6YemLGkN0GNOi+N5HDNawDpyBhmreBNUIZsd1GzY1MASobr9buBJx gtvYf93LIdk0zf/70rpcG9t5uv7wRdPMPyVgaTlA12ZHtDZVTXJNBuOQnam8Ee90rSwO +G8w== X-Gm-Message-State: ABy/qLbWgiabMUXVpxQ4W4GEWpah2O4iqMlqURkrLGjldm+W9gmnnYfQ sJ3c5YzxouwCsABElXnBiEQ= X-Google-Smtp-Source: APBJJlFBNsd5Z8wqOwsQ3dcJdrl3U8YrX4JCsL0BBs+E9Gb4zMMleLRmH7Z95s2IzJoc/omRnIIZYQ== X-Received: by 2002:a17:90b:3b51:b0:263:f3d0:7ea2 with SMTP id ot17-20020a17090b3b5100b00263f3d07ea2mr10460565pjb.8.1690114174721; Sun, 23 Jul 2023 05:09: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 v3 1/4] virtio-net: do not reset vlan filtering at set_features Date: Sun, 23 Jul 2023 20:09:11 +0800 Message-Id: <95af0d013281282f48ad3f47f6ad1ac4ca9e52eb.1690106284.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::435; envelope-from=yin31149@gmail.com; helo=mail-pf1-x435.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: 1690114264797100010 This function is called after virtio_load, so all vlan configuration is lost in migration case. Just allow all the vlan-tagged packets if vlan is not configured, and trust device reset to clear all filtered vlans. Fixes: 0b1eaa8803 ("virtio-net: Do not filter VLANs without F_CTRL_VLAN") Signed-off-by: Eugenio P=C3=A9rez Reviewed-by: Hawkins Jiawei Signed-off-by: Hawkins Jiawei Tested-by: Lei Yang --- v3: - remove the extra "From" line v2: https://lore.kernel.org/all/95af0d013281282f48ad3f47f6ad1ac4ca9e52eb.16= 90100802.git.yin31149@gmail.com/ hw/net/virtio-net.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 7102ec4817..d20d5a63cd 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1006,9 +1006,7 @@ static void virtio_net_set_features(VirtIODevice *vde= v, uint64_t features) vhost_net_save_acked_features(nc->peer); } =20 - if (virtio_has_feature(features, VIRTIO_NET_F_CTRL_VLAN)) { - memset(n->vlans, 0, MAX_VLAN >> 3); - } else { + if (!virtio_has_feature(features, VIRTIO_NET_F_CTRL_VLAN)) { memset(n->vlans, 0xff, MAX_VLAN >> 3); } =20 --=20 2.25.1 From nobody Tue May 21 18:49: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=1690114263; cv=none; d=zohomail.com; s=zohoarc; b=aiXDUZQqh8HW/SZQajpqMS53BmBPEq/HFf6Ov6oNmIW8kCB14SJyHyffHPs0rAWyXeYoooTv3a/FZCz+avJ9mr5QSLrfajW5cQnlwMkGS1KnaKkswYJGpSkSuPJZ35kquDkauwCH4AI1lySVF+O7suXsvoiKzNVlbIJg3XY+DMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690114263; 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=OQXPMit78wxXOLwUXAdy/5EGNJNucIHi6SIpfnSqqAI=; b=hsLjIphJtPFNASgJnap3GnoDnZdCCSNus18X+sPhkMO3XIU2wn/hL9k4ypC26YY14PVIVXc/55jgJAvvrhL3UuPGoisy4iVdx6Td67SDaJVCuyV3Xi1pk/j45EjiLJGClsd9VP2HNTxdU1Xrw2REz/yvC91RB6aZOdrIqgkx72k= 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 1690114263435857.1024173220966; Sun, 23 Jul 2023 05:11:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNXuG-0006gD-B4; Sun, 23 Jul 2023 08:09:48 -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 1qNXuE-0006ft-8A for qemu-devel@nongnu.org; Sun, 23 Jul 2023 08:09:46 -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 1qNXuC-00089y-N9 for qemu-devel@nongnu.org; Sun, 23 Jul 2023 08:09:46 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1b852785a65so22626245ad.0 for ; Sun, 23 Jul 2023 05:09:44 -0700 (PDT) Received: from localhost ([223.104.38.215]) by smtp.gmail.com with ESMTPSA id j6-20020a170902690600b001b86e17ecacsm6730617plk.131.2023.07.23.05.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jul 2023 05:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690114182; x=1690718982; 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=OQXPMit78wxXOLwUXAdy/5EGNJNucIHi6SIpfnSqqAI=; b=MqsQKxcwpuSUr8ohfL5g+CRqiIme5kXIcr27cwvgTi/EfR96jA+kBv2rWuxTxjqAK9 9yyH9FFACjAQLqdi1v6AuJKPjqL8aySoWLZExQqiriCCLH2qe+AFsvoYGDiwAwD8JZcU bo0lycNZm3ltf3xBTx6aoJ7qc54sW5XIt00SJsasOhduYzZtfUwOYLsKNdjK3jJgZk4w BzjOmTfgcKgBoj+Uo/BzeSmdoVjL+c2bLdaZFg1jxI3pEMdDC4b553TpDgGijlgavm6D +2RtdU8M/OrM5CZf2tId2hqWwO3Dcv6302o16n8jx7L/pkMn6ZxrKl3xT2VyyiIzIHRq 9hIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690114182; x=1690718982; 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=OQXPMit78wxXOLwUXAdy/5EGNJNucIHi6SIpfnSqqAI=; b=CZ1MVY052aczjne5s441aSwlz6Kw0EIMH57t6D53gF2Wl+W9T/WdSU3Kv9fXziuYn2 OioJ5c91q9Ebut5m9d5aR4zMikvwPnzXSoPTdqbArvmMFAnIBX74O8/wujy/iJfW0WHG VWYnXIDyE9azU++L/s/4q5CKAmXTdQt4JmKw2dQ1KT0GEKugNreLRFirq0rS7EVRgirM G7ZLV21XHIEgzKFE1oJnS71cayFg+5KjabJzJLJGRtE8OW1QQNOEIHz4R2admWbmuT2z ZPELJLXWeO4G/qdCZq2LPWxS1Row3SWbT1iHOrGxHUuGLsK+Rl2FxkMryjWl8bNgbjEC isNg== X-Gm-Message-State: ABy/qLawpV0urlaHNLwIdLmr40YEXHqA6ft5yX/0CFHHFUlAjAknqmX7 y4WlzITtSnhmo5j7wnZz5mY= X-Google-Smtp-Source: APBJJlEjpcDCcNJTgNU6Nnqe/WF3xvqdSCv4HDFoiU8t1Z6XAOLLwtksU80qg907pDWnCj8xF9udVQ== X-Received: by 2002:a17:902:ea0a:b0:1b9:c61c:4c01 with SMTP id s10-20020a170902ea0a00b001b9c61c4c01mr10406876plg.9.1690114182233; Sun, 23 Jul 2023 05:09:42 -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/4] virtio-net: Expose MAX_VLAN Date: Sun, 23 Jul 2023 20:09:12 +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::62e; envelope-from=yin31149@gmail.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, 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: 1690114264791100009 vhost-vdpa shadowed CVQ needs to know the maximum number of vlans supported by the virtio-net device, so QEMU can restore the VLAN state in a migration. Co-developed-by: Eugenio P=C3=A9rez Signed-off-by: Eugenio P=C3=A9rez Signed-off-by: Hawkins Jiawei Tested-by: Lei Yang --- hw/net/virtio-net.c | 2 -- include/hw/virtio/virtio-net.h | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index d20d5a63cd..a32672039d 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -49,8 +49,6 @@ =20 #define VIRTIO_NET_VM_VERSION 11 =20 -#define MAX_VLAN (1 << 12) /* Per 802.1Q definition */ - /* previously fixed value */ #define VIRTIO_NET_RX_QUEUE_DEFAULT_SIZE 256 #define VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE 256 diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 5f5dcb4572..93f3bb5d97 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -38,6 +38,12 @@ OBJECT_DECLARE_SIMPLE_TYPE(VirtIONet, VIRTIO_NET) /* Maximum VIRTIO_NET_CTRL_MAC_TABLE_SET unicast + multicast entries. */ #define MAC_TABLE_ENTRIES 64 =20 +/* + * The maximum number of VLANs in the VLAN filter table + * added by VIRTIO_NET_CTRL_VLAN_ADD + */ +#define MAX_VLAN (1 << 12) /* Per 802.1Q definition */ + typedef struct virtio_net_conf { uint32_t txtimer; --=20 2.25.1 From nobody Tue May 21 18:49: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=1690114263; cv=none; d=zohomail.com; s=zohoarc; b=Xw1iEhNG0yrIYa+W0QU2l1kwisb8DLFZIEZX1OrAq6TVR5M1aqzn3qHHpkZ4YlqtYkcXYsbxuWDspKnEGdLMfkEAWyza8qnT1M2RXanBesAZvO6XT6dgyGKHcD9GUNuwl4zNW94i+kJL+g0Rs0Mzfw88ntysWMA8TqvTuOeyqdg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690114263; 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=j6MNpmpr0JlX5y+mb1RZNWk8OhHa3Y3TekRln1LZnlY=; b=B3q+pPAhpIVZjp6vQ4umPgsXs1RgAbR1YPCBo1Tb/i2fWPIo4m5tSvJWYmqMwkKrrQmI9IsbUVziVAcHaLzBsT+GVK6pFy0vAmU52vmmculXRrhRpmNo1YDKetSH0w1SwX9ncRkc3alLKjKXyGptwdXeuLJ+W3SJIeN0V+Nulkc= 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 1690114263600547.9161039504163; Sun, 23 Jul 2023 05:11:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNXuM-0006h2-H0; Sun, 23 Jul 2023 08:09:54 -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 1qNXuK-0006gT-Px for qemu-devel@nongnu.org; Sun, 23 Jul 2023 08:09:52 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qNXuJ-0008AC-3A for qemu-devel@nongnu.org; Sun, 23 Jul 2023 08:09:52 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-668704a5b5bso3268182b3a.0 for ; Sun, 23 Jul 2023 05:09:50 -0700 (PDT) Received: from localhost ([223.104.38.215]) by smtp.gmail.com with ESMTPSA id p6-20020aa78606000000b00640dbbd7830sm6095937pfn.18.2023.07.23.05.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jul 2023 05:09:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690114189; x=1690718989; 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=j6MNpmpr0JlX5y+mb1RZNWk8OhHa3Y3TekRln1LZnlY=; b=j2Ae9eIX2HvP5H6ZT4RwrclRcn0N4TkZ6oazKAJXeuZIvit4sPFUsSJCoI6720L4fs YaBACw28dCk7ik3HQaCzGi1BojkogLwFPe90GsKGvuRoajK7SpIJWEdKOqKVUVntkUzq cWh9VTZdsUcnCLwtNE83lfI+Jvbj9c7YbjzyhaGIlmAAazzun3gsaPdHCGz+nnxocoyE BbHBv699Q+Qy1hH1IJOj21T6inaXx9a+5JqdB42jsVcClfsJOI6R0AVa3Re+KEXRWVrw gOUVcRBTJJ5LJhMuxoNFc94CWDfN6oCZ5MmPIq11hQh+yLu90sfuUbtn3ShHDADGVQyf wBqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690114189; x=1690718989; 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=j6MNpmpr0JlX5y+mb1RZNWk8OhHa3Y3TekRln1LZnlY=; b=LsiI7vCddVKUyAVbKjzl6xCgx17+IdtRWUiOuVwO3lHYigkRZa+CJ+Uj03PjNZaSTR lbldxheBAReAMGSeEZLa+qP8xDHlv/jFS9vB1Q/VhbKqsEqu9EWzIc4J5PF72z9zcZB1 wn76uZYMbQu6RZC9gN/y8u3xnCSHkEh+QKe0ngjh9DGQ/pPydMc/g+ZJ90DXMYEJvHkn OHKokj62Yk1fXwxhUbQhwJ+148vAewvVLQEXuoA8ybGApLrXTRTLOrecDNP7bJLmJvK+ LMzilbo99pYOq5u8uRl/NJ01kAA7BShOs0/8Txou6fyGRKD8I4ANrNvpZMvOEnsTn1xX 6bVQ== X-Gm-Message-State: ABy/qLYpHhGgVHyV7+nRRWgAfFE2J94IlNisAgd9sBk7TPcce2daX+2K z8N4R9KT/4eJ+QlIZiYHORerSjar2bCLiEKcXqU= X-Google-Smtp-Source: APBJJlHAfcmTeeXWdn49nlBfySMjzPPORdHr50Pc4/RescHgFX/AQGiqp3hieM+16E+mMqFualdw1w== X-Received: by 2002:a05:6a00:844:b0:67b:8602:aa1e with SMTP id q4-20020a056a00084400b0067b8602aa1emr7852582pfk.28.1690114189403; Sun, 23 Jul 2023 05:09:49 -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 3/4] vdpa: Restore vlan filtering state Date: Sun, 23 Jul 2023 20:09:13 +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::434; envelope-from=yin31149@gmail.com; helo=mail-pf1-x434.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: 1690114265471100019 This patch introduces vhost_vdpa_net_load_single_vlan() and vhost_vdpa_net_load_vlan() to restore the vlan filtering state at device's startup. Co-developed-by: Eugenio P=C3=A9rez Signed-off-by: Eugenio P=C3=A9rez Signed-off-by: Hawkins Jiawei Tested-by: Lei Yang --- v2: - remove the extra line pointed out by Eugenio v1: https://lore.kernel.org/all/0a568cc8a8d2b750c2e09b2237e9f05cece07c3f.16= 89690854.git.yin31149@gmail.com/ net/vhost-vdpa.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 9795306742..347241796d 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -965,6 +965,50 @@ static int vhost_vdpa_net_load_rx(VhostVDPAState *s, return 0; } =20 +static int vhost_vdpa_net_load_single_vlan(VhostVDPAState *s, + const VirtIONet *n, + uint16_t vid) +{ + const struct iovec data =3D { + .iov_base =3D &vid, + .iov_len =3D sizeof(vid), + }; + ssize_t dev_written =3D vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_VLA= N, + VIRTIO_NET_CTRL_VLAN_ADD, + &data, 1); + if (unlikely(dev_written < 0)) { + return dev_written; + } + if (unlikely(*s->status !=3D VIRTIO_NET_OK)) { + return -EIO; + } + + return 0; +} + +static int vhost_vdpa_net_load_vlan(VhostVDPAState *s, + const VirtIONet *n) +{ + int r; + + if (!virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_CTRL_VLAN)) { + return 0; + } + + for (int i =3D 0; i < MAX_VLAN >> 5; i++) { + for (int j =3D 0; n->vlans[i] && j <=3D 0x1f; j++) { + if (n->vlans[i] & (1U << j)) { + r =3D vhost_vdpa_net_load_single_vlan(s, n, (i << 5) + j); + if (unlikely(r !=3D 0)) { + return r; + } + } + } + } + + return 0; +} + static int vhost_vdpa_net_load(NetClientState *nc) { VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); @@ -995,6 +1039,10 @@ static int vhost_vdpa_net_load(NetClientState *nc) if (unlikely(r)) { return r; } + r =3D vhost_vdpa_net_load_vlan(s, n); + if (unlikely(r)) { + return r; + } =20 return 0; } --=20 2.25.1 From nobody Tue May 21 18:49: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=1690114263; cv=none; d=zohomail.com; s=zohoarc; b=QGij36ACGoaqR8CMVR17c+X1wg5/i1rnsISeRJmudWLKyI0BsHfleD+S6t+yLVWtaYWZWvzsCWRR4VauSJkznhBkH7a+mtlhzzbvFz6zDm4YvUw3NGeBgvG5EJqkiYI7B50hQ3m+AZ9c46SN/8OYw9+ML2OdC0ohbmf9zPnbHTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690114263; 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=lqDYe0wtYfLpN2tqp42QO/VtGC9R8rwe6ys1M/nbgpg=; b=bVjVPwVKvAZPSdRGe+l/4Tu5q/JTW9eWN6N8Awy+XC7hHSCAsnHOS/hO3GEFxPSesh8N+uYdNvY53m9O2P+JimXLVZ8x0ljyTg9jA2Dg1IPrFP9F+UxUYoZa/qbRkV8Q4Un0i0LuqTUncKjHQMkO4aTMKTjXu/dSDEzpxUSXWLM= 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 1690114263373955.6561363826231; Sun, 23 Jul 2023 05:11:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNXuS-0006kN-Tg; Sun, 23 Jul 2023 08:10: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 1qNXuR-0006k9-C8 for qemu-devel@nongnu.org; Sun, 23 Jul 2023 08:09:59 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qNXuO-0008Ap-Sv for qemu-devel@nongnu.org; Sun, 23 Jul 2023 08:09:59 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-666e6541c98so3294369b3a.2 for ; Sun, 23 Jul 2023 05:09:56 -0700 (PDT) Received: from localhost ([223.104.38.215]) by smtp.gmail.com with ESMTPSA id k11-20020aa792cb000000b00682868714fdsm6083558pfa.95.2023.07.23.05.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jul 2023 05:09:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690114195; x=1690718995; 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=lqDYe0wtYfLpN2tqp42QO/VtGC9R8rwe6ys1M/nbgpg=; b=bp43bR8Odq8vREets1p2StaYvEkHSQbUrCTHlaTBzMak3SwvBp2BXOMigyeEqbvQ6t p9ej0OfkBrAj7Ckfqp7uWDG4UjY8gJAHOTZP+wLtU/75OKdkAHRZDzp8EqPpgejMY8F/ A3Km/RA21ByDKxeAcNKzwmZdEB2951mBtN1rpg6Fvx1BIPpjZln5yFWFXvJLSifzS0uM 4BLKVeGQV6DQSdLCnXe6WN1ybPFr5MAFFHtMX/JSp+lxxknsW3AKmv8vKF8PITLVIZtQ uhu9AFmP4PLl+Tck2Wys12OKZ8+xhqRK96l0N+Pml43KVJ/Wm7IXpqxEeKVdBenk2oQW miTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690114195; x=1690718995; 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=lqDYe0wtYfLpN2tqp42QO/VtGC9R8rwe6ys1M/nbgpg=; b=buTOJrmkoSIxge0E0ORpnBLyRkGit1GaPL8331amQXcf6kvD3CwyIrH7FIfBqhfgYk x0O5Tgmkz/4V67/sFjZyx1gh91LjhW1B0BYWbuUHt/ihV0Ol5Hw5rtzkMYNG33TYPAXE L4d6vePG5Q/gFfihd6bJQIQrUIEeR5Tg3BNXgpBjozbvILnQbSoMSqEN9qOCbpdgzMdK m47BYH+mh4RUyTFCHfeJNuuBGe00vJUdf33TuvMKgiarriDuPMOZ1UiFfS+X9LauPfJE AKXE2L9gjbl8tYCWUUBvpM2qzeY5AhfxSZwep7lJ8LWmuiTkDC0ocYst1qtiQuwCDxHP txkQ== X-Gm-Message-State: ABy/qLZJJCa2058vSv9iUU519uxEq9lrUbjRmsIGeYGI/qtcKssrtrqF aiLKToV5/vLfr4O6F40BBis= X-Google-Smtp-Source: APBJJlGMkDaoxr5DiAqqGU75+rhJKOoF9cOfjrUMm3oDLm7qA5yr44exIQ+xp+hAiAX1znHCAwQQYg== X-Received: by 2002:a05:6a00:2407:b0:668:9fb6:b311 with SMTP id z7-20020a056a00240700b006689fb6b311mr6835282pfh.32.1690114195349; Sun, 23 Jul 2023 05:09:55 -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 4/4] vdpa: Allow VIRTIO_NET_F_CTRL_VLAN in SVQ Date: Sun, 23 Jul 2023 20:09:14 +0800 Message-Id: <38dc63102a42c31c72fd293d0e6e2828fd54c86e.1690106284.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::42c; envelope-from=yin31149@gmail.com; helo=mail-pf1-x42c.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: 1690114264229100001 Enable SVQ with VIRTIO_NET_F_CTRL_VLAN feature. Co-developed-by: Eugenio P=C3=A9rez Signed-off-by: Eugenio P=C3=A9rez Signed-off-by: Hawkins Jiawei 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 347241796d..73e9063fa0 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -111,6 +111,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_VLAN) | BIT_ULL(VIRTIO_NET_F_CTRL_RX_EXTRA) | BIT_ULL(VIRTIO_NET_F_MQ) | BIT_ULL(VIRTIO_F_ANY_LAYOUT) | --=20 2.25.1