Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2221421rdb; Tue, 3 Oct 2023 14:15:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvVR5cfQ8rBkkSpPDI6rDwLbgQlLqWOG8zzkYo9IIZtarqoYswt/zgOFtsTMrYkxdvVeQK X-Received: by 2002:a05:6a20:dd87:b0:15c:c381:f65e with SMTP id kw7-20020a056a20dd8700b0015cc381f65emr515056pzb.34.1696367751502; Tue, 03 Oct 2023 14:15:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696367751; cv=none; d=google.com; s=arc-20160816; b=qyWkjF3XczPEx4A1Q+Rk5JUiG1PuGqFG5lrM98hbx80Ico6h6cRnk9USpvT0/rricn l++JYdAiXSdIOLe2hvp61lytmF2qZjdpLDm9MHNzWcwiJRDzT5c+5m9neE0apdlgKf9f ctmlt5/Vckt2Wv3AGQQLz605yY+ktQC8fNS6BRd9x/jj0L4ftfdk8RHYIA6jALgtf8H/ istkMW0TflYu3s+vVMTK0UET4oE9nRvPvjlBxiUaOMsmJNLBjjyD1vxMk9RyTlHCibfM 5ZqrRk3rC2QUkEddyykU1ilbMYPeypSVHE0vntltTarvkayjmqYQ0g5SUBNyc9DTPFsD CUtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=t66igBKn3unZXjiFNkV7Rwej4hjUxsXRg77hR2hMt8g=; fh=O3AgTU6vjY5mXnBzjF+nG9PoaQXkTDb+dhRBh28lgMg=; b=nClklaIN6SoOaMjlJN74/lLKRBQq9vRnq74kY4fsbn8E7SQKmBukZtuQwmDeFXI7gZ CGE2oZYKJ+voyXw2DNrOhY+FnE1sn03czpnJtR1GumLdK2GwK0KgDUYcNOAyjzNwRwgK lrfRJFv8FPRyyEZ0QX70q0CxTbFcuAoaG9J7ejUF52cuA9T7+uZG6QUKYreaMzn6UJlI 1MByp+8eRv7aYuHhhxkbEP11/E3PZYQGaYD4Z/xTjL4hCwa2M86Swl/Aa90pnAXxtxOh cWDjb36e+XV/VqDzJf/ZAVia4dJ4d1UkTlq9Txe/0y0dUwia2LmvGi1LmAIA4Nk0zj7b WuHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=F6FtSrhk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id c22-20020a056a000ad600b0069347c30c78si2406240pfl.230.2023.10.03.14.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 14:15:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=F6FtSrhk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 4EB2F8090E8D; Tue, 3 Oct 2023 14:15:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241172AbjJCVPL (ORCPT + 99 others); Tue, 3 Oct 2023 17:15:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241171AbjJCVPK (ORCPT ); Tue, 3 Oct 2023 17:15:10 -0400 Received: from mail-vs1-xe2e.google.com (mail-vs1-xe2e.google.com [IPv6:2607:f8b0:4864:20::e2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D6B3D8; Tue, 3 Oct 2023 14:15:07 -0700 (PDT) Received: by mail-vs1-xe2e.google.com with SMTP id ada2fe7eead31-4526b9078b2so654437137.0; Tue, 03 Oct 2023 14:15:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696367706; x=1696972506; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=t66igBKn3unZXjiFNkV7Rwej4hjUxsXRg77hR2hMt8g=; b=F6FtSrhkKbEAbrbgaRYiWexw4Z5Ka9Ao+WBZD8jAoFRwYyGD/9fn5V17nhCQlRU8rz nKA1DerouRjKH4RSr5ORaCoQ8WKMvX0k1Iyrx0iWX4qc16XlKpYmGJobtnWYtnN/oP51 cZi1m1ncpBcyOwjaS9F/aArLEFcBz15VnpsY/io8u/agSBeQzrnMthmpzwXH21emXSRp ltEU+r+BuSwoyzcV4gPeVcf5MRxNGQEWL34DqUEc4/UJ1bzgrHhZMYz50y0SqnpSZLpX nszRVMM8UOpoBxRgzy7nuUdRScIxUvrr4+yF4mT+xkpUfl4Xnfgd594w4waXqMmP9jyM mJ6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696367706; x=1696972506; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t66igBKn3unZXjiFNkV7Rwej4hjUxsXRg77hR2hMt8g=; b=W5HPZAAqyhbRfve3H1/9Sy3hfJWMgV4A6dSZh9ynLCoZjJtmg52B9DrmtfnvO/O+lA z9BJXceJEt2qrn0BhsRDfVWhQ1V52H0KEprosBp/Hfy1XhCYA89xgreP/9sHWdJIc2Kv GHp4HvscVcTBorb1NfJhXi0hE2Dkz7aCaKFMC/Re70Gj/dSHi7cxAn6SgIG4XFUlVT+Y ep3hkeQ01fnKglgn98gYkTUjz8OGOI3UADVgWKmXd7J16EfMireemIINW065mif2DzUb /70Rsso6CMe1AKf72NcVyHdIe9l89amPhkyHfk3Et3b0wmqTBb16lOOGtPDUWmRMb42n FvKw== X-Gm-Message-State: AOJu0YzoeVPcrAHu3Dv7RbXj0yHde57Rm8ZIj4J8xRg0xWhRE0lRRrcd 5AnQJd62Mp/OgnvNDePKmMvCjH/ULWmXqv6iLMk= X-Received: by 2002:a05:6102:7c2:b0:44e:96aa:e445 with SMTP id y2-20020a05610207c200b0044e96aae445mr525026vsg.29.1696367706115; Tue, 03 Oct 2023 14:15:06 -0700 (PDT) MIME-Version: 1.0 References: <20230912122201.3752918-1-paweldembicki@gmail.com> <20230912122201.3752918-6-paweldembicki@gmail.com> <20230912161709.g34slexfaop6xp7w@skbuf> <20230926235848.3uftpkj7m24qsord@skbuf> In-Reply-To: <20230926235848.3uftpkj7m24qsord@skbuf> From: =?UTF-8?Q?Pawe=C5=82_Dembicki?= Date: Tue, 3 Oct 2023 23:14:55 +0200 Message-ID: Subject: Re: [PATCH net-next v3 5/8] net: dsa: vsc73xx: Add vlan filtering To: Vladimir Oltean Cc: netdev@vger.kernel.org, Dan Carpenter , Simon Horman , Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 03 Oct 2023 14:15:21 -0700 (PDT) =C5=9Br., 27 wrz 2023 o 01:58 Vladimir Oltean napisa=C5= =82(a): > > On Fri, Sep 22, 2023 at 04:26:00PM +0200, Pawe=C5=82 Dembicki wrote: > > > > + if (vsc->untagged_storage[port] < VLAN_N_VID && > > > > + !vid_is_dsa_8021q(vsc->untagged_storage[port]) && > > > > + !vid_is_dsa_8021q(vid) && > > > > > > The problem here which led to these vid_is_dsa_8021q() checks is that > > > dsa_switch_tag_8021q_vlan_add() sets all flags on user ports to > > > BRIDGE_VLAN_INFO_UNTAGGED | BRIDGE_VLAN_INFO_PVID, and you can't offl= oad > > > those, correct? > > > > In my case, the major problem with tag8021q vlans is > > "dsa_tag_8021q_bridge_join" function: > > "dsa_port_tag_8021q_vlan_add" is called before "dsa_port_tag_8021q_vlan= _del". > > I must disable pvid/untagged checking, because it will always fail. I > > let kernel do the job, > > it keeps only one untagged/pvid per port after "dsa_tag_8021q_bridge_jo= in". > > I'm not sure that you described the problem in a way that I can understan= d, here. > > After dsa_tag_8021q_bridge_join(): > -> dsa_port_tag_8021q_vlan_add(dp, bridge_vid) > -> dsa_port_tag_8021q_vlan_del(dp, standalone_vid) > > it's *expected* that there should be only one untagged/pvid per port: the= bridge_vid. > > For context, consider the fact that you can run the following commands: > > bridge vlan add dev eth0 vid 10 pvid > bridge vlan add dev eth0 vid 11 pvid > > and after the second command, vid 10 stops being a pvid. > > So I think that the "Port %d can have only one pvid! Now is: %d.\n" behav= ior > is not correct. You need to implement the pvid overwriting behavior, sinc= e > there's always only 1 pvid. > Yes, overwriting pvid is the only proper way. Kernel mechanism will take care about the number of pvids. I will fixit in v4. > So that leaves the "untagged" flag as being problematic, correct? Could > you comment... > > > > > > But when the port is VSC73XX_VLAN_IGNORE mode (and > > > tag_8021q is active), VSC73XX_TXUPDCFG_TX_INSERT_TAG is 0, and thus, > > > *all* VLANs are egress-untagged VLANs, correct? > > > > > > If that is the case, why do you call vsc73xx_vlan_set_untagged() in t= he > > > first place, for tag_8021q VLANs, if you don't rely on the port's nat= ive > > > VLAN for egress untagging? > > ... on this? Here I'm pointing out that "all VLANs have the egress-untagg= ed flag" > is a configuration that can actually be supported by vsc73xx. You just > need to ensure that VSC73XX_TXUPDCFG_TX_INSERT_TAG is 0. And tag_8021q > basically requests exactly that configuration on user ports (both the > bridge_vid and the standalone_vid are egress-untagged). So your check is > too restrictive, you are denying a configuration that would work. > The problem only appears when you mix egress-tagged with egress-untagged > VLANs on a port. Only then there can be at most 1 egress-untagged VID, > because you need to enable VSC73XX_TXUPDCFG_TX_INSERT_TAG for the > egress-tagged VIDs to work. Should I make a local copy of the quantity of egress untagged and tagged vlans per port to resolve this issue, shouldn't I? And then I check how many vlans are egress tagged or untagged for a properly restricted solution? I see another problem. Even if I return an error value, the untagged will be marked in 'bridge vlan' listing. I'm not sure how it should work in this case. > > > > A comment would be good which states that the flipping between the > > > hardware and the storage values relies on the fact that vsc73xx_port_= vlan_filtering() > > > only gets called on actual changes to vlan_filtering, and thus, to > > > vsc73xx_tag_8021q_active(). So, we know for sure that what is in stor= age > > > needs to go to hardware, and what is in hardware needs to go to stora= ge. > > > > > > It's an interesting implementation for sure. > > > > > > > Thank you. > > I'm not sure if that was a compliment :) Touch=C3=A9. :) >At least in this form, it's > certainly non-trivial to determine by looking at the code if it is > correct or not, and it uses different patterns than the other VLAN > implementations in DSA drivers. Generally, boring and obvious is > preferable. But after I took the time to understand, it seems plausible > that the approach might work. > > Let's see how the same idea looks, cleaned up a bit but not redesigned, > in v4. I try to at least clean pvid and untagged issues before v4.