From patchwork Tue Jun 8 21:19:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12308135 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DDC4C47082 for ; Tue, 8 Jun 2021 21:20:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73E9161375 for ; Tue, 8 Jun 2021 21:20:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232404AbhFHVWT (ORCPT ); Tue, 8 Jun 2021 17:22:19 -0400 Received: from mail-pg1-f171.google.com ([209.85.215.171]:46640 "EHLO mail-pg1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230297AbhFHVWS (ORCPT ); Tue, 8 Jun 2021 17:22:18 -0400 Received: by mail-pg1-f171.google.com with SMTP id n12so17559406pgs.13; Tue, 08 Jun 2021 14:20:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GQwh626zfM0U1fcFtkvnbbFBBL2HeKYCTc8Ov3QqP4A=; b=SS7DicXMMBMKZ7ie6EtJkLEw0evfTPyAuOuXZnrnG7Ptwpe0XEnIwfvSQSIKrcTwr7 FF3oEG28yFCs8gdj2qKbIUbAy6HtCEgocfWSMIN0KZb6IC6sDXpjWToBqRyZohl/0GjG Gi28AxNyxKedpAzj7dz/xCRVOKGe+w9y6FTZcGgNnSRyORDaDV3LIj+eS+H1wKPuov/1 m/iCikpcC0m9Ny2PYgYt7Sm4+aEeKG/rhVy/Czgt992bBEPc73rRFLSMSrqv7OUoy0uv sR2q/VhZa+z9sEdANtNC5Vw/vexju96qoEudw2NKwJ27IcNj6+2Fhw/Q1boF/NP0W+S6 3NfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GQwh626zfM0U1fcFtkvnbbFBBL2HeKYCTc8Ov3QqP4A=; b=n5AYtwIVcnmlqZFBCUlSX1NLF32gelTSuSbpb7nOVRM0iFpAS08vLMYMFDX3gj1no0 g3TtmhsNRZmqrcCAurWmt3QoQOD1eiw/Y5KkyqlKbyfcWp6x1s7ZoiqVUStKWZP9D7xh DyYPFaCGOoh0EwrGL34jXxns9B66dz3MnuhiWPELYu9mZnMZMmvhB0k0Rw0HmitRao2Y yQSVVD/QjyaNoWysghA3wmRdt6AK91Mim5rdnfLk2+2nWSMxATMFAF+ZJIYgzKe6oxg2 8dTqGcVAijzEna04H8uodt7hy3vfvRHLe9MlXbaMiRhU6ZQezip/Y1cw3CRDr12EbyU0 rPNg== X-Gm-Message-State: AOAM5314r4/QnvQN82Fb1GPYgrON3jqcedyP3gndcr4uqFswm03lMfk8 TB3wGn7kh+C7VGcahVb89kdg6XE1p7w= X-Google-Smtp-Source: ABdhPJygWFsMb/NOsKZoaO9oP0XFGhfudCSBTF1S3GtJKoosdbqaixIbEv27pInfwAtVYPE7Kxax2w== X-Received: by 2002:a63:5756:: with SMTP id h22mr168526pgm.377.1623187164943; Tue, 08 Jun 2021 14:19:24 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id r24sm3120205pjz.11.2021.06.08.14.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 14:19:24 -0700 (PDT) From: Florian Fainelli To: netev@vger.kernel.org Cc: mnhagan88@gmail.com, Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org (open list:BROADCOM B53 ETHERNET SWITCH DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v2] net: dsa: b53: Do not force CPU to be always tagged Date: Tue, 8 Jun 2021 14:19:15 -0700 Message-Id: <20210608211915.3978509-1-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Commit ca8931948344 ("net: dsa: b53: Keep CPU port as tagged in all VLANs") forced the CPU port to be always tagged in any VLAN membership. This was necessary back then because we did not support Broadcom tags for all configurations so the only way to differentiate tagged and untagged traffic while DSA_TAG_PROTO_NONE was used was to force the CPU port into being always tagged. With most configurations enabling Broadcom tags, especially after 8fab459e69ab ("net: dsa: b53: Enable Broadcom tags for 531x5/539x families") we do not need to apply this unconditional force tagging of the CPU port in all VLANs. A helper function is introduced to faciliate the encapsulation of the specific condition requiring the CPU port to be tagged in all VLANs and the dsa_switch_ops::untag_bridge_pvid boolean is moved to when dsa_switch_ops::setup is called when we have already determined the tagging protocol we will be using. Reported-by: Matthew Hagan Signed-off-by: Florian Fainelli --- Changes in v2: - properly deal with DSA_TAG_PROTO_NONE so we continue to support that mode on older chips like 5325 and 5365 until they gain Broadcom tag support drivers/net/dsa/b53/b53_common.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 3ca6b394dd5f..6e199454e41d 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -1084,6 +1084,11 @@ static int b53_setup(struct dsa_switch *ds) unsigned int port; int ret; + /* Request bridge PVID untagged when DSA_TAG_PROTO_NONE is set + * which forces the CPU port to be tagged in all VLANs. + */ + ds->untag_bridge_pvid = dev->tag_protocol == DSA_TAG_PROTO_NONE; + ret = b53_reset_switch(dev); if (ret) { dev_err(ds->dev, "failed to reset switch\n"); @@ -1455,6 +1460,13 @@ static int b53_vlan_prepare(struct dsa_switch *ds, int port, return 0; } +static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port) +{ + struct b53_device *dev = ds->priv; + + return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port); +} + int b53_vlan_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan, struct netlink_ext_ack *extack) @@ -1477,7 +1489,7 @@ int b53_vlan_add(struct dsa_switch *ds, int port, untagged = true; vl->members |= BIT(port); - if (untagged && !dsa_is_cpu_port(ds, port)) + if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port)) vl->untag |= BIT(port); else vl->untag &= ~BIT(port); @@ -1514,7 +1526,7 @@ int b53_vlan_del(struct dsa_switch *ds, int port, if (pvid == vlan->vid) pvid = b53_default_pvid(dev); - if (untagged && !dsa_is_cpu_port(ds, port)) + if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port)) vl->untag &= ~(BIT(port)); b53_set_vlan_entry(dev, vlan->vid, vl); @@ -2660,7 +2672,6 @@ struct b53_device *b53_switch_alloc(struct device *base, dev->priv = priv; dev->ops = ops; ds->ops = &b53_switch_ops; - ds->untag_bridge_pvid = true; dev->vlan_enabled = true; /* Let DSA handle the case were multiple bridges span the same switch * device and different VLAN awareness settings are requested, which