From patchwork Sun Jul 23 09:26:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hawkins Jiawei X-Patchwork-Id: 13323121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D797C001DE for ; Sun, 23 Jul 2023 09:28:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNVNM-0001et-1L; Sun, 23 Jul 2023 05:27:40 -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 1qNVNK-0001ek-Gh for qemu-devel@nongnu.org; Sun, 23 Jul 2023 05:27:38 -0400 Received: from mail-oa1-x35.google.com ([2001:4860:4864:20::35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qNVNJ-0001VX-1M for qemu-devel@nongnu.org; Sun, 23 Jul 2023 05:27:38 -0400 Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-1ba5cda3530so2678506fac.3 for ; Sun, 23 Jul 2023 02:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690104455; x=1690709255; 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=749c16VfFqHXoK3rBi9xwn3HY6BMtdWqslVMXDL704I=; b=fggoczcXHpDtLbhIZ1PrJqmn8Qbzaw2iEtGGoD+DExbqVwCsUDpeZpqSdS+5ByjPxB 7SLudd4+A4XwWWgfsD6DgM/xTWC8r1pzqm/je05TVy5jvZ2Ey39+wgY6/gaWBULAFYXB UPe55c2pRDjbWQ8tmjSFI6xYJcmfRenUtIb5u9eYnIIF+8hMaK8tqvhv0Evi1F81+cHo C53LxxLRCawdDa1v+pXIXsKWDqqyo1fRNVv+peISJ7m1RR7xmQsOvLb/mV47w56Kz60P TPiIIWKE1Q4Uw5TAfL5CYvhW9h+pZCRZT+dpnHIFkDcqErZpIfvl3KHS7fOavPE6Hl/k 0SQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690104455; x=1690709255; 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=749c16VfFqHXoK3rBi9xwn3HY6BMtdWqslVMXDL704I=; b=FmMKwsK/0DIvn8K0j7zpW8MN4Z5QBecjL/X8FiznHD+PBMYcSI/aAXwkKjxsVf+SNQ yIZkYJMH2xd05QKDT0vz+yRq/825zBNt98PJmgy0qQOrZDFiSdWWbPa3nLQAM7GX7W3B bq3M909D7HLyu8C8j2nh7advyxKY+msU27bt9aqejHYeV18CtKMXDGSjJRmBtFY4SL95 uvV6i3PVdGcQVBkMA9u0RXRuLednM0qpsvSSMBQV9Fd/b4EKPJWPaTDVbmUlwdUKxOPs 65GuE/L01PGbO0SsWx/GSS3YlwkElbC2AFR6QCQz83K3fU25ql+B0ZeP3oBq2E0hqB3W sofg== X-Gm-Message-State: ABy/qLbQSr5jBkcT+6UsfO+qLulZ66PGOO2KaNlAk4WExX2PVqkFVnmW iMjEWrvgi5SsqtlO6E7hLh8= X-Google-Smtp-Source: APBJJlEjOP3VIBtYInrCKzVRrnFX9JQSIM1zm8DqrSQ3N4j9U5i/9sIid7ZcHvPgsAl+4+gKpylOdA== X-Received: by 2002:a05:6870:5493:b0:1ba:d044:8a4 with SMTP id f19-20020a056870549300b001bad04408a4mr7364851oan.18.1690104455419; Sun, 23 Jul 2023 02:27:35 -0700 (PDT) Received: from localhost ([123.117.183.65]) by smtp.gmail.com with ESMTPSA id c3-20020a62e803000000b0067b384d5955sm5696949pfi.26.2023.07.23.02.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jul 2023 02:27:35 -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 v2 1/4] virtio-net: do not reset vlan filtering at set_features Date: Sun, 23 Jul 2023 17:26:34 +0800 Message-Id: <95af0d013281282f48ad3f47f6ad1ac4ca9e52eb.1690100802.git.yin31149@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::35; envelope-from=yin31149@gmail.com; helo=mail-oa1-x35.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Eugenio Pérez 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érez Reviewed-by: Hawkins Jiawei Signed-off-by: Hawkins Jiawei Acked-by: Jason Wang --- 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 *vdev, uint64_t features) vhost_net_save_acked_features(nc->peer); } - 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); } From patchwork Sun Jul 23 09:26:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hawkins Jiawei X-Patchwork-Id: 13323122 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 10D5FC001B0 for ; Sun, 23 Jul 2023 09:28:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNVNS-0001gM-JQ; Sun, 23 Jul 2023 05:27:46 -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 1qNVNR-0001fv-Cs for qemu-devel@nongnu.org; Sun, 23 Jul 2023 05:27:45 -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 1qNVNP-0001W9-RZ for qemu-devel@nongnu.org; Sun, 23 Jul 2023 05:27:45 -0400 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-268128a0105so118433a91.3 for ; Sun, 23 Jul 2023 02:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690104461; x=1690709261; 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=fmsVIb/LLMqQcE65C4gdI7s+e/Eo6sNFzRCuqQsXsy5bTogLvOatSaKCY4eaDd0F5O 26tQOatnwXaR76fKpUX10DxhUzNqJivo1hagcQWSIKrhxk7vC/nF0px8RXxRLjCwwiZE 3wZuAjXU50c0SZvILXKhxPgI4spd7f+znlgfogpK8BMnYNEjqrJiNFgYfOeJNO6dQWEr /hPdaXAegTjmXeiHHgKFy7cz+bvB/l1GV/V7f1nViVO+Xja0g/TnDwtEUCiy2GSBaxnX PhvZuO7suZ6Bxs32bCqJTXfhcTwejyAt0JBctCW8+oQBFwW0ptoZcVYjAFGYZbTl5B4X Xcnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690104461; x=1690709261; 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=N856XWQNkgQgMVWwmBNLEr4kTnrc6o/usGxD/ubwypCDJVSKXEwYwCB1rzKDoc8Mja uwXIUc0SB5EruqOp0RRMHiG+rVcPgdx2M7gx1IErlr1Vt0bvJXqRX2BhG06zCjcnqhYd 8BvK9kzFhkgPxQgumgBy2zxET7EXmEgHMvbJhS4RoqEAbnpkdtSv6dXTtn5/G2fZJ7Q4 Jmo3o0/TUuI1L77ghce5NPf+va8aDcEKkfJwkEfvlGrCCQ0suhhMp0AwpsNa8xusPDHo 7hHoWVCF7TcMHZ+/smw2qf5H5/FA+4wbBs8pSb9QKFPagTsBdcot/423aZorWrBj5bEf d7JA== X-Gm-Message-State: ABy/qLbllOcBvWHQiS+of+a4we30nVXqBxZLqIt2VSmTqgmwnMZtnwU5 Cp5a4je79nwkrH4mXvHFplg= X-Google-Smtp-Source: APBJJlHtoGaxTKWHTyVEgE0gTN5eCCPwFRiT19gibR4kPLThh7sefQHsbY0Wrv3lzkZiXIUGK9G9fw== X-Received: by 2002:a17:90b:4c11:b0:263:bc7b:a76d with SMTP id na17-20020a17090b4c1100b00263bc7ba76dmr7129705pjb.4.1690104461430; Sun, 23 Jul 2023 02:27:41 -0700 (PDT) Received: from localhost ([123.117.183.65]) by smtp.gmail.com with ESMTPSA id m8-20020a17090a4d8800b00267c49d74e8sm5610345pjh.42.2023.07.23.02.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jul 2023 02:27:41 -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 v2 2/4] virtio-net: Expose MAX_VLAN Date: Sun, 23 Jul 2023 17:26:35 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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érez Signed-off-by: Eugenio Pérez Signed-off-by: Hawkins Jiawei Acked-by: Jason Wang --- 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 @@ #define VIRTIO_NET_VM_VERSION 11 -#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 +/* + * 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; From patchwork Sun Jul 23 09:26:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hawkins Jiawei X-Patchwork-Id: 13323123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7FE50C001DE for ; Sun, 23 Jul 2023 09:28:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNVNY-0001gj-2g; Sun, 23 Jul 2023 05:27:52 -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 1qNVNW-0001gZ-7R for qemu-devel@nongnu.org; Sun, 23 Jul 2023 05:27:50 -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 1qNVNU-0001WV-LD for qemu-devel@nongnu.org; Sun, 23 Jul 2023 05:27:49 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-666eec46206so3217959b3a.3 for ; Sun, 23 Jul 2023 02:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690104467; x=1690709267; 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=bQhbdbFV1iCTYj41SXJoA2LJ9blIhXO4jJ3bKnuV0g8EtsBJsNy4IFVBQFi5XuF97v dYkaEPr1SQEkajFBJiUlvsyQBOF+FlUDgDqRZfGCABOOWcTyLPCHjAIceAvp0Xz2Apk0 F5ZJYliZUf9ALMGacUgLec4dZ/YArW/GnrKRSIZNfE0F8KnYq0h0WGm5U52dUhGoKieP nOY+8W50uXSiDlO5r4HrJZep0x3pGDQV+l1pYp68ycb+mUaTWGdcNGrF+FvJFOvQL+vY dHY6YoBhjSJbdD7bn8zUeMM0nAjkQ5jIKWkfXA8FymDe65An7aH/muTQyTKkqHe1zPu4 DTVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690104467; x=1690709267; 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=D4srzvXcRNod20sARmv001WtOgBqjuYGB4jV8GqQ2hIZBAlelnmW+aCVq6hOvUVBl9 pD3co80yn7ZmMzfWJLXni6U3DN6QT9saZLfbwuYz5SgTSUlcMscEzcjH2W7ad1OXoDBW ZN5FPvHhrOyEvxFhrlVrfvv79EoBlZMoVhkWyjLs6d15x3Ttty7M+rpNXhnFRqW/kY2E B2TMlSsCKh3KtlHtw+cFeA2wV01cMxZ44xUcs8je5ER+bphfX1ZiMRVcQkDzROvcxltH bsT/xPix3cCOYHl5OfOtidsUO8p7R5PXojNI778cqNiuUv+XkndGxXZ1QYJ0LCKHzpy+ pD6w== X-Gm-Message-State: ABy/qLZ9uLhqRSX8uZHp+aFOucwKFRTbYqzMPRmLUh62/KRzczdabgtm jY3X5QrUTBJiuHWwx7jvgeY= X-Google-Smtp-Source: APBJJlGiITRtHHRWgb1EnSVoPaf03qBuz4xy3Wu27lts0o3Vm9+pY25UJnIN1sUXt9ejqzVCLVOCZQ== X-Received: by 2002:a05:6a00:84c:b0:67a:b045:e290 with SMTP id q12-20020a056a00084c00b0067ab045e290mr7006332pfk.4.1690104466992; Sun, 23 Jul 2023 02:27:46 -0700 (PDT) Received: from localhost ([123.117.183.65]) by smtp.gmail.com with ESMTPSA id e21-20020aa78255000000b0065da94fe917sm5706154pfn.36.2023.07.23.02.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jul 2023 02:27:46 -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 v2 3/4] vdpa: Restore vlan filtering state Date: Sun, 23 Jul 2023 17:26:36 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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érez Signed-off-by: Eugenio Pérez Signed-off-by: Hawkins Jiawei Acked-by: Jason Wang --- v2: - remove the extra line pointed out by Eugenio v1: https://lore.kernel.org/all/0a568cc8a8d2b750c2e09b2237e9f05cece07c3f.1689690854.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; } +static int vhost_vdpa_net_load_single_vlan(VhostVDPAState *s, + const VirtIONet *n, + uint16_t vid) +{ + const struct iovec data = { + .iov_base = &vid, + .iov_len = sizeof(vid), + }; + ssize_t dev_written = vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_VLAN, + VIRTIO_NET_CTRL_VLAN_ADD, + &data, 1); + if (unlikely(dev_written < 0)) { + return dev_written; + } + if (unlikely(*s->status != 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 = 0; i < MAX_VLAN >> 5; i++) { + for (int j = 0; n->vlans[i] && j <= 0x1f; j++) { + if (n->vlans[i] & (1U << j)) { + r = vhost_vdpa_net_load_single_vlan(s, n, (i << 5) + j); + if (unlikely(r != 0)) { + return r; + } + } + } + } + + return 0; +} + static int vhost_vdpa_net_load(NetClientState *nc) { VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); @@ -995,6 +1039,10 @@ static int vhost_vdpa_net_load(NetClientState *nc) if (unlikely(r)) { return r; } + r = vhost_vdpa_net_load_vlan(s, n); + if (unlikely(r)) { + return r; + } return 0; } From patchwork Sun Jul 23 09:26:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hawkins Jiawei X-Patchwork-Id: 13323124 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 82761C001B0 for ; Sun, 23 Jul 2023 09:28:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNVNf-0001hQ-5x; Sun, 23 Jul 2023 05:27:59 -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 1qNVNe-0001hH-5J for qemu-devel@nongnu.org; Sun, 23 Jul 2023 05:27:58 -0400 Received: from mail-oa1-x34.google.com ([2001:4860:4864:20::34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qNVNa-0001X4-Co for qemu-devel@nongnu.org; Sun, 23 Jul 2023 05:27:57 -0400 Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-1bb5f78b30dso91625fac.1 for ; Sun, 23 Jul 2023 02:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690104473; x=1690709273; 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=fULkiA3qFelc4c5X8wZOSnw7GrJzc8129ArM2M5dYiBcWdBXRodnnr0YvQZFeVUYPj ib/fykJJuJZo/m//jYbLC+MCq3XsuRjAti8czPrefmbMULmXRMijeBh2BHvCxZOkUGYh MoOCynN7hyFwqulQ4O7bVu0C1tt2lqnM/T+xqWJKWyy6uB8bFUWl4loICv6GadAlYA7t BJvgojOspq/SpxQ8loxNBSEtAKUjy9TNEmPEditmPszs/PjnuExn4wO3kIWcSinYJcIz JO5gYf4yMRyiwEo0WEFWpby5GACL8c6qu22C1knQHoAOnv+MHeu+It8z89QKkJMICw8g dD0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690104473; x=1690709273; 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=GPg4yzwVSxFSYEBWOi3eSa/CCQvkl7tbyC9Mb5ZWkx4Hx7OB4W6R4ovKl8Ouuitydb xrLg2MSC1+/39WOUCi+mrn3VPt4Idk4fdd4mvehTsyDLCoxRCaP5dgOnjRcOkTTUgDv4 8Pt3DTmfxFJ04lJNDtqdpaR2BE7BV44ztqg2RqM7Ya8mCKcL9l3oAWIvNV0bVd0k6TYN 4qX+T+P6bvGbD8ltbOa+tPkTs0dMSWfmkVova0fCQaJF/Gb30gAzFxf8ckiQ66CYN/Hf vJynsvcNX5ExJC1wjP0kvQx2XSiGSWLVZnWWnBguxjiytrWpyNOuL+bpLVgNrWEppDNA kpSA== X-Gm-Message-State: ABy/qLaMAfOBLDM1Vq69e8w/aTBSQ7CE/g/smGTwAmEcBOqqxtzMif1k ubxvTV0etuRByNX5GG+5AKQ= X-Google-Smtp-Source: APBJJlFgR7zSjLZJnFfT85js8lc2AkclerUTOd4L0vSRp9agwotZKJCFlDXArfR/jRV0WzKiP8nj9g== X-Received: by 2002:a05:6871:112:b0:1a0:85d3:3d70 with SMTP id y18-20020a056871011200b001a085d33d70mr7788428oab.28.1690104472723; Sun, 23 Jul 2023 02:27:52 -0700 (PDT) Received: from localhost ([123.117.183.65]) by smtp.gmail.com with ESMTPSA id z129-20020a633387000000b005633c9493d0sm6179518pgz.21.2023.07.23.02.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jul 2023 02:27:52 -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 v2 4/4] vdpa: Allow VIRTIO_NET_F_CTRL_VLAN in SVQ Date: Sun, 23 Jul 2023 17:26:37 +0800 Message-Id: <38dc63102a42c31c72fd293d0e6e2828fd54c86e.1690100802.git.yin31149@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::34; envelope-from=yin31149@gmail.com; helo=mail-oa1-x34.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Enable SVQ with VIRTIO_NET_F_CTRL_VLAN feature. Co-developed-by: Eugenio Pérez Signed-off-by: Eugenio Pérez Signed-off-by: Hawkins Jiawei Acked-by: Jason Wang --- 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 = 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) |