From patchwork Sun Jul 23 12:09:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hawkins Jiawei X-Patchwork-Id: 13323169 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 66B4DC41513 for ; Sun, 23 Jul 2023 12:11:03 +0000 (UTC) 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) 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) 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) 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 --- v3: - remove the extra "From" line v2: https://lore.kernel.org/all/95af0d013281282f48ad3f47f6ad1ac4ca9e52eb.1690100802.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 *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 12:09:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hawkins Jiawei X-Patchwork-Id: 13323168 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 740D7C3DA41 for ; Sun, 23 Jul 2023 12:11:03 +0000 (UTC) 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) 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) 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) 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 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+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 --- 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 12:09:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hawkins Jiawei X-Patchwork-Id: 13323167 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 8BD47C04A6A for ; Sun, 23 Jul 2023 12:11:03 +0000 (UTC) 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) 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) 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) 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 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 --- 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 12:09:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hawkins Jiawei X-Patchwork-Id: 13323166 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 71CBAC001DC for ; Sun, 23 Jul 2023 12:11:03 +0000 (UTC) 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) 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) 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) 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 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+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 --- 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) |