From patchwork Tue Sep 28 14:41:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 12523015 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAD7BC433EF for ; Tue, 28 Sep 2021 14:44:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A984A611C3 for ; Tue, 28 Sep 2021 14:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241391AbhI1Oq3 (ORCPT ); Tue, 28 Sep 2021 10:46:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241294AbhI1Oq1 (ORCPT ); Tue, 28 Sep 2021 10:46:27 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED82EC06161C for ; Tue, 28 Sep 2021 07:44:47 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id y28so93047499lfb.0 for ; Tue, 28 Sep 2021 07:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mAwhGtRujnHTFUcceKkII8/F/aa8Tsch93j2q5uIZ6w=; b=yDxKT6Io0E53L7c14EAOL3Dglv7R8AOCEDvJYeIfYM1udipqObtf7iCxVjGPLeuZwq vz8DV7aSiGS6qdpoWznvEAwP/892JNl9+Bg++8JccP9+VmDmEtvQcNjVb72pRus/QHUz Lm46BoXzpHiMLit0/JAjEk6QKyRpeNNcyDnTDicacev3BGKd5jxdsuWcQlXlQwby/XWZ P9aOKPT65r8sjCZtROIrYY+ydj9vR73SBHpTRXIS11esDhw+04ob3U7KQE0yJ9TUmhIH QWHSK0Kovi6IzjSN0FP1bRMAje4oEVsnFqrMYs70ElwJzL1OLxLVtnXA1EX+wn38s3yv iT0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mAwhGtRujnHTFUcceKkII8/F/aa8Tsch93j2q5uIZ6w=; b=ODDcR9UYxuaa5ZwyrPvbH2UB/DEQGujl/N533n9rJt3/UTCj2Qi0v1txgtIx8e45Hw N8fkuKBT/of7x0uM1fqizTlajKdDymm0Xk/Y/QcLXy/oyXl6kjiq7kcuExX35tHbcCS7 ZtBBMZEkOjJlZx+AL9x7R3X+hMQgYjow52LMiTfK8TKeohrKqkAhBY0OxxQV1VQTU5gK rqBWsuIak4Yfa3IhZM2vRui+MY5xj9np+JeIecZjX1g+GhuBFRLQ90LiRek7YgbTTv4M nVe8sUv/rIFTw9JzbuZ8S5LTPejoTeVCU/nwDRuvWT+pHAbcrDxi9wlKerM3YDIVNcRS KCyg== X-Gm-Message-State: AOAM533R/AgmJ2TndvGxU98so71LRdpLM5tmqakpEuDoEn7tEGRzl4sv fF3JlTlN19bvVxVZfMKIe3h9Rw== X-Google-Smtp-Source: ABdhPJzt89cn4wTYEF+8jGeTcA1Tr/M+OC/q8p89StcNZTEO/aHGn/80wd29S6sMKmhDh2tY2tIiEA== X-Received: by 2002:ac2:4312:: with SMTP id l18mr6352608lfh.602.1632840282865; Tue, 28 Sep 2021 07:44:42 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id x23sm1933462lfd.136.2021.09.28.07.44.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 07:44:42 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, DENG Qingfang , Mauri Sandberg , =?utf-8?q?Alvin_=C5=A0ipraga?= , Linus Walleij Subject: [PATCH net-next 1/6 v8] net: dsa: rtl8366rb: Support bridge offloading Date: Tue, 28 Sep 2021 16:41:44 +0200 Message-Id: <20210928144149.84612-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928144149.84612-1-linus.walleij@linaro.org> References: <20210928144149.84612-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: DENG Qingfang Use port isolation registers to configure bridge offloading. Tested on the D-Link DIR-685, switching between ports and sniffing ports to make sure no packets leak. Cc: Vladimir Oltean Cc: Mauri Sandberg Reviewed-by: Vladimir Oltean Reviewed-by: Alvin Šipraga Reviewed-by: Florian Fainelli Signed-off-by: DENG Qingfang Signed-off-by: Linus Walleij --- ChangeLog v7->v8: - No changes just resending with the rest of the patches. ChangeLog v6->v7: - Collect Vladimir's review tag. ChangeLog v5->v6: - No changes just resending with the rest of the patches. ChangeLog v4->v5: - No changes just resending with the rest of the patches. ChangeLog v3->v4: - Fix a bug where I managed to mask off the CPU port from the ports we could access leading to numb bridge. - Reword some comments. ChangeLog v2->v3: - Parens around the (pmask) in the port isolation macro. - Do not exit join/leave functions on regmap failures, print an error and continue. - Clarify comments around the port in join/leave functions. ChangeLog v1->v2: - introduce RTL8366RB_PORT_ISO_PORTS() to shift the port mask into place so we are not confused by the enable bit. - Use this with dsa_user_ports() to isolate the CPU port from itself. --- drivers/net/dsa/rtl8366rb.c | 86 +++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index a89093bc6c6a..b930050cfd1b 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -300,6 +300,13 @@ #define RTL8366RB_INTERRUPT_STATUS_REG 0x0442 #define RTL8366RB_NUM_INTERRUPT 14 /* 0..13 */ +/* Port isolation registers */ +#define RTL8366RB_PORT_ISO_BASE 0x0F08 +#define RTL8366RB_PORT_ISO(pnum) (RTL8366RB_PORT_ISO_BASE + (pnum)) +#define RTL8366RB_PORT_ISO_EN BIT(0) +#define RTL8366RB_PORT_ISO_PORTS_MASK GENMASK(7, 1) +#define RTL8366RB_PORT_ISO_PORTS(pmask) ((pmask) << 1) + /* bits 0..5 enable force when cleared */ #define RTL8366RB_MAC_FORCE_CTRL_REG 0x0F11 @@ -835,6 +842,21 @@ static int rtl8366rb_setup(struct dsa_switch *ds) if (ret) return ret; + /* Isolate all user ports so they can only send packets to itself and the CPU port */ + for (i = 0; i < RTL8366RB_PORT_NUM_CPU; i++) { + ret = regmap_write(smi->map, RTL8366RB_PORT_ISO(i), + RTL8366RB_PORT_ISO_PORTS(BIT(RTL8366RB_PORT_NUM_CPU)) | + RTL8366RB_PORT_ISO_EN); + if (ret) + return ret; + } + /* CPU port can send packets to all ports */ + ret = regmap_write(smi->map, RTL8366RB_PORT_ISO(RTL8366RB_PORT_NUM_CPU), + RTL8366RB_PORT_ISO_PORTS(dsa_user_ports(ds)) | + RTL8366RB_PORT_ISO_EN); + if (ret) + return ret; + /* Set up the "green ethernet" feature */ ret = rtl8366rb_jam_table(rtl8366rb_green_jam, ARRAY_SIZE(rtl8366rb_green_jam), smi, false); @@ -1127,6 +1149,68 @@ rtl8366rb_port_disable(struct dsa_switch *ds, int port) rb8366rb_set_port_led(smi, port, false); } +static int +rtl8366rb_port_bridge_join(struct dsa_switch *ds, int port, + struct net_device *bridge) +{ + struct realtek_smi *smi = ds->priv; + unsigned int port_bitmap = 0; + int ret, i; + + /* Loop over all other ports than the current one */ + for (i = 0; i < RTL8366RB_PORT_NUM_CPU; i++) { + /* Current port handled last */ + if (i == port) + continue; + /* Not on this bridge */ + if (dsa_to_port(ds, i)->bridge_dev != bridge) + continue; + /* Join this port to each other port on the bridge */ + ret = regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(i), + RTL8366RB_PORT_ISO_PORTS(BIT(port)), + RTL8366RB_PORT_ISO_PORTS(BIT(port))); + if (ret) + dev_err(smi->dev, "failed to join port %d\n", port); + + port_bitmap |= BIT(i); + } + + /* Set the bits for the ports we can access */ + return regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(port), + RTL8366RB_PORT_ISO_PORTS(port_bitmap), + RTL8366RB_PORT_ISO_PORTS(port_bitmap)); +} + +static void +rtl8366rb_port_bridge_leave(struct dsa_switch *ds, int port, + struct net_device *bridge) +{ + struct realtek_smi *smi = ds->priv; + unsigned int port_bitmap = 0; + int ret, i; + + /* Loop over all other ports than this one */ + for (i = 0; i < RTL8366RB_PORT_NUM_CPU; i++) { + /* Current port handled last */ + if (i == port) + continue; + /* Not on this bridge */ + if (dsa_to_port(ds, i)->bridge_dev != bridge) + continue; + /* Remove this port from any other port on the bridge */ + ret = regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(i), + RTL8366RB_PORT_ISO_PORTS(BIT(port)), 0); + if (ret) + dev_err(smi->dev, "failed to leave port %d\n", port); + + port_bitmap |= BIT(i); + } + + /* Clear the bits for the ports we can not access, leave ourselves */ + regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(port), + RTL8366RB_PORT_ISO_PORTS(port_bitmap), 0); +} + static int rtl8366rb_change_mtu(struct dsa_switch *ds, int port, int new_mtu) { struct realtek_smi *smi = ds->priv; @@ -1510,6 +1594,8 @@ static const struct dsa_switch_ops rtl8366rb_switch_ops = { .get_strings = rtl8366_get_strings, .get_ethtool_stats = rtl8366_get_ethtool_stats, .get_sset_count = rtl8366_get_sset_count, + .port_bridge_join = rtl8366rb_port_bridge_join, + .port_bridge_leave = rtl8366rb_port_bridge_leave, .port_vlan_filtering = rtl8366_vlan_filtering, .port_vlan_add = rtl8366_vlan_add, .port_vlan_del = rtl8366_vlan_del, From patchwork Tue Sep 28 14:41:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 12523019 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E51C8C433F5 for ; Tue, 28 Sep 2021 14:44:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE8AC611C3 for ; Tue, 28 Sep 2021 14:44:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241399AbhI1Oqb (ORCPT ); Tue, 28 Sep 2021 10:46:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241311AbhI1Oq2 (ORCPT ); Tue, 28 Sep 2021 10:46:28 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 674EBC061745 for ; Tue, 28 Sep 2021 07:44:48 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id y26so54384038lfa.11 for ; Tue, 28 Sep 2021 07:44:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EGWUMoEsyjYiDRxtjWnqInO7daZnJ0Nzrr+qkb1K+Z4=; b=WqDL445es2OpXn1RHcgcJaDoy3VIc8cleNtTBTr4QiMpi7KX6IhU75UFjXogVobFqr g7UZDSXw7iBhMBHJWtgIcJVOerx5Z8gsuPbIRc19c69bgSeL+41rmUUDuhqQrICcJ573 47TX/WCR+cpnQ8kK1+LVp6fXkTelTcrYAv68alEEk6FVEZM/agNkmgXO0rdNwViEBbmY mbCHmIIeAl18hezdyjYKvjCAW3qQub73mX7mK6LYhH9MG0ZTjqtd3pNGTdkgYgHTXjDs dKQNKMZrtfuQXxRx+2ic9cXFPea0RS0zCQKAQSX4TGLvCf7q9lflD2F20I505li3/Qdn g4ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EGWUMoEsyjYiDRxtjWnqInO7daZnJ0Nzrr+qkb1K+Z4=; b=Kr2fkQvlm5lb0VwcJwvEcxBngFfMI8PnftYoL0nMwGRKM8mBhs9Q6lBtrOKkUbrBqw mSCSLM+GO5ty/AcLL4K1YiusPsEQl7cN/TI0cgYIZqwWGZ7WkjMKsMpdM8me4/mn1y4Q MAaey8EVLxYIyTe/oZoG/fGBfuQHE/zcc8Z/X+IfQdIokvw4B/he3pxBWoofFXNdVi+K nhJVk79MnlkOY9k/EIoEFPiTqnbXAxPTKNpMkfrwpKuuKdJ04Rs9Rz++Je1KXX0JrT/s t5+hKw8WOOMx4rDljP4BFqoZyBXpFx3nJfAyECnVCccxZdvK3rKjkA+ynsBjO2B9pAbU QioQ== X-Gm-Message-State: AOAM5306x8SzibAZNRXO18KHV0f/OEqTlrSKQFOvvIH+KCIv65X1lXFp euIlEmxTqWEoTzy9LtSbtGJI8Q== X-Google-Smtp-Source: ABdhPJw+3++WfC2VCTJuSeSCUy121lRjtLsCbaJTCDnWsulGKSA9/VnvvdBmb1Zo+5VzXmqeDa2iDA== X-Received: by 2002:ac2:5e75:: with SMTP id a21mr6016381lfr.557.1632840285560; Tue, 28 Sep 2021 07:44:45 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id x23sm1933462lfd.136.2021.09.28.07.44.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 07:44:44 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Linus Walleij , Mauri Sandberg , DENG Qingfang , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH net-next 2/6 v8] net: dsa: rtl8366: Drop custom VLAN set-up Date: Tue, 28 Sep 2021 16:41:45 +0200 Message-Id: <20210928144149.84612-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928144149.84612-1-linus.walleij@linaro.org> References: <20210928144149.84612-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This hacky default VLAN setup was done in order to direct packets to the right ports and provide port isolation, both which we now support properly using custom tags and proper bridge port isolation. We can drop the custom VLAN code and leave all VLAN handling alone, as users expect things to be. We can also drop ds->configure_vlan_while_not_filtering = false; and let the core deal with any VLANs it wants. Cc: Mauri Sandberg Cc: DENG Qingfang Reviewed-by: Vladimir Oltean Reviewed-by: Alvin Šipraga Reviewed-by: Florian Fainelli Signed-off-by: Linus Walleij --- ChangeLog v7->v8: - No changes just resending with the rest of the patches. ChangeLog v6->v7: - No changes just resending with the rest of the patches. ChangeLog v5->v6: - No changes just resending with the rest of the patches. ChangeLog v4->v5: - No changes just resending with the rest of the patches. ChangeLog v3->v4: - No changes ChangeLog v2->v3: - Collect a bunch of reviewed-by tags ChangeLog v1->v2: - No changes. --- drivers/net/dsa/realtek-smi-core.h | 1 - drivers/net/dsa/rtl8366.c | 48 ------------------------------ drivers/net/dsa/rtl8366rb.c | 4 +-- 3 files changed, 1 insertion(+), 52 deletions(-) diff --git a/drivers/net/dsa/realtek-smi-core.h b/drivers/net/dsa/realtek-smi-core.h index fcf465f7f922..c8fbd7b9fd0b 100644 --- a/drivers/net/dsa/realtek-smi-core.h +++ b/drivers/net/dsa/realtek-smi-core.h @@ -129,7 +129,6 @@ int rtl8366_set_pvid(struct realtek_smi *smi, unsigned int port, int rtl8366_enable_vlan4k(struct realtek_smi *smi, bool enable); int rtl8366_enable_vlan(struct realtek_smi *smi, bool enable); int rtl8366_reset_vlan(struct realtek_smi *smi); -int rtl8366_init_vlan(struct realtek_smi *smi); int rtl8366_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering, struct netlink_ext_ack *extack); int rtl8366_vlan_add(struct dsa_switch *ds, int port, diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 75897a369096..59c5bc4f7b71 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -292,54 +292,6 @@ int rtl8366_reset_vlan(struct realtek_smi *smi) } EXPORT_SYMBOL_GPL(rtl8366_reset_vlan); -int rtl8366_init_vlan(struct realtek_smi *smi) -{ - int port; - int ret; - - ret = rtl8366_reset_vlan(smi); - if (ret) - return ret; - - /* Loop over the available ports, for each port, associate - * it with the VLAN (port+1) - */ - for (port = 0; port < smi->num_ports; port++) { - u32 mask; - - if (port == smi->cpu_port) - /* For the CPU port, make all ports members of this - * VLAN. - */ - mask = GENMASK((int)smi->num_ports - 1, 0); - else - /* For all other ports, enable itself plus the - * CPU port. - */ - mask = BIT(port) | BIT(smi->cpu_port); - - /* For each port, set the port as member of VLAN (port+1) - * and untagged, except for the CPU port: the CPU port (5) is - * member of VLAN 6 and so are ALL the other ports as well. - * Use filter 0 (no filter). - */ - dev_info(smi->dev, "VLAN%d port mask for port %d, %08x\n", - (port + 1), port, mask); - ret = rtl8366_set_vlan(smi, (port + 1), mask, mask, 0); - if (ret) - return ret; - - dev_info(smi->dev, "VLAN%d port %d, PVID set to %d\n", - (port + 1), port, (port + 1)); - ret = rtl8366_set_pvid(smi, port, (port + 1)); - if (ret) - return ret; - } - - return rtl8366_enable_vlan(smi, true); -} -EXPORT_SYMBOL_GPL(rtl8366_init_vlan); - int rtl8366_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering, struct netlink_ext_ack *extack) { diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index b930050cfd1b..a5b7d7ff8884 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -985,7 +985,7 @@ static int rtl8366rb_setup(struct dsa_switch *ds) return ret; } - ret = rtl8366_init_vlan(smi); + ret = rtl8366_reset_vlan(smi); if (ret) return ret; @@ -999,8 +999,6 @@ static int rtl8366rb_setup(struct dsa_switch *ds) return -ENODEV; } - ds->configure_vlan_while_not_filtering = false; - return 0; } From patchwork Tue Sep 28 14:41:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 12523017 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF627C433EF for ; Tue, 28 Sep 2021 14:44:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD21D604D1 for ; Tue, 28 Sep 2021 14:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241400AbhI1Oqc (ORCPT ); Tue, 28 Sep 2021 10:46:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241398AbhI1Oqb (ORCPT ); Tue, 28 Sep 2021 10:46:31 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA028C06161C for ; Tue, 28 Sep 2021 07:44:51 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id y26so54384794lfa.11 for ; Tue, 28 Sep 2021 07:44:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RfMbMlQjSaKkpfo5xwj8gseBOZYY/BMF2dEl6C0fxC0=; b=sdQ0Qdhxilyfy10pym7nFr+vqT5EzQjH2dZLiQ4uCXPnHSrmkjDtwkSt4KoKijGoR3 fN+mAhOS4s1rGFr3LS4XMLUm3kI2t5C+5iwbA5bv3kq8zXnwhjKGNx5bRhGkdmyLp1WM VmeXiiR4iFoPnOUeRshe8B7f+3ZdA8uFi1h/dB0EKohoSfaChDJxm22DVVlsu7963EuK 8qpfJ89WuHA5EwuyQH+mlGSdQUYK80vxiQoWx05aHyb+MrPonqQMufu6N3ssgiQ1dX0C BgBllj7cdkrR30mCuOfP4F1EEZqNYUEDqERuycrT70IFD9/m2jcPBAhzIQd8jTVsjH2L XRhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RfMbMlQjSaKkpfo5xwj8gseBOZYY/BMF2dEl6C0fxC0=; b=Bg7uJoZbt1thZNQMyEqpGUkER2GV1Mge39fDhtQO2HtOS7Zrfki8HUVnDrZLcos59A saI0P5Oj506TcN/YUGyRwzaGboaaeDwMU5L6z8V9QtRR8uHn8z4ggbQZYbV8TKzMOq9q c9Um52b5sRfM84+XNSkNgGIK7U/1X5NYZKjQHFPPDRyxLL/Rk+3kneJEZ6sj4AHXaBXB ynG7u1yfLNkFL59NU7zT3GzSMoAPMIMIPt5m0yn019qgE+iwRzc/V490K9SdgRptwnQr hiDuhryyjaA77YjoZL2LFcXXNVfW1A2dGQj7drNf0/aKD88QCiUqs27EqTrxjc209/ZW atBA== X-Gm-Message-State: AOAM531FAUPfiiBzU+xdvGLvUHTrO+MyXJwhUfjBto2PC5uhXaGyVNP/ T3OJLvgVd5pp5Aur0FI1h6Gg1A== X-Google-Smtp-Source: ABdhPJwgalsB4e6Af4X1whhW0ybTdLqWPW/0FZYHYgj3/EK9ZhvlYnqLiWYshATdSp5NDDSyXpWGEA== X-Received: by 2002:a05:6512:2302:: with SMTP id o2mr6156471lfu.297.1632840288841; Tue, 28 Sep 2021 07:44:48 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id x23sm1933462lfd.136.2021.09.28.07.44.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 07:44:47 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Linus Walleij , Mauri Sandberg , DENG Qingfang , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH net-next 3/6 v8] net: dsa: rtl8366rb: Rewrite weird VLAN filering enablement Date: Tue, 28 Sep 2021 16:41:46 +0200 Message-Id: <20210928144149.84612-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928144149.84612-1-linus.walleij@linaro.org> References: <20210928144149.84612-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org While we were defining one VLAN per port for isolating the ports the port_vlan_filtering() callback was implemented to enable a VLAN on the port + 1. This function makes no sense, not only is it incomplete as it only enables the VLAN, it doesn't do what the callback is supposed to do, which is to selectively enable and disable filtering on a certain port. Implement the correct callback: we have two registers dealing with filtering on the RTL8366RB, so we implement an ASIC-specific callback and implement filering using the register bit that makes the switch drop frames if the port is not in the VLAN member set. The DSA documentation Documentation/networking/switchdev.rst states: When the bridge has VLAN filtering enabled and a PVID is not configured on the ingress port, untagged and 802.1p tagged packets must be dropped. When the bridge has VLAN filtering enabled and a PVID exists on the ingress port, untagged and priority-tagged packets must be accepted and forwarded according to the bridge's port membership of the PVID VLAN. When the bridge has VLAN filtering disabled, the presence/lack of a PVID should not influence the packet forwarding decision. To comply with this, we add two arrays of bool in the RTL8366RB state that keeps track of if filtering and PVID is enabled or not for each port. We then add code such that whenever filtering or PVID changes, we update the filter according to the specification. Cc: Vladimir Oltean Cc: Mauri Sandberg Cc: Florian Fainelli Cc: DENG Qingfang Reviewed-by: Alvin Šipraga Signed-off-by: Linus Walleij --- ChangeLog v7->v8: - Do not keep track of the filtering state in the driver but use the core dsa_port_is_vlan_filtering() to query the state instead. - Fix some spelling mistake. - Collect Alvin's Review tag ChangeLog v6->v7: - Add comments to the register definitions. - Rewrite the code to keep track on whether filtering and PVID is enabled on each port, and use this information to selectively drop untagged and C-tagged (802.1p) frames. - Add a hook in the PVID setup to always check the filtering of untagged and C-tagged frames when changing the PVID setting. ChangeLog v5->v6: - Drop unused leftover variable "ret" ChangeLog v4->v5: - Drop the code dropping frames without VID, after Florian described that this is not expected semantics for this callback. ChangeLog v1->v4: - New patch after discovering that this weirdness of mine is causing problems. --- drivers/net/dsa/realtek-smi-core.h | 2 - drivers/net/dsa/rtl8366.c | 35 ----------- drivers/net/dsa/rtl8366rb.c | 97 +++++++++++++++++++++++++++--- 3 files changed, 90 insertions(+), 44 deletions(-) diff --git a/drivers/net/dsa/realtek-smi-core.h b/drivers/net/dsa/realtek-smi-core.h index c8fbd7b9fd0b..214f710d7dd5 100644 --- a/drivers/net/dsa/realtek-smi-core.h +++ b/drivers/net/dsa/realtek-smi-core.h @@ -129,8 +129,6 @@ int rtl8366_set_pvid(struct realtek_smi *smi, unsigned int port, int rtl8366_enable_vlan4k(struct realtek_smi *smi, bool enable); int rtl8366_enable_vlan(struct realtek_smi *smi, bool enable); int rtl8366_reset_vlan(struct realtek_smi *smi); -int rtl8366_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering, - struct netlink_ext_ack *extack); int rtl8366_vlan_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan, struct netlink_ext_ack *extack); diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 59c5bc4f7b71..0672dd56c698 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -292,41 +292,6 @@ int rtl8366_reset_vlan(struct realtek_smi *smi) } EXPORT_SYMBOL_GPL(rtl8366_reset_vlan); -int rtl8366_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering, - struct netlink_ext_ack *extack) -{ - struct realtek_smi *smi = ds->priv; - struct rtl8366_vlan_4k vlan4k; - int ret; - - /* Use VLAN nr port + 1 since VLAN0 is not valid */ - if (!smi->ops->is_vlan_valid(smi, port + 1)) - return -EINVAL; - - dev_info(smi->dev, "%s filtering on port %d\n", - vlan_filtering ? "enable" : "disable", - port); - - /* TODO: - * The hardware support filter ID (FID) 0..7, I have no clue how to - * support this in the driver when the callback only says on/off. - */ - ret = smi->ops->get_vlan_4k(smi, port + 1, &vlan4k); - if (ret) - return ret; - - /* Just set the filter to FID 1 for now then */ - ret = rtl8366_set_vlan(smi, port + 1, - vlan4k.member, - vlan4k.untag, - 1); - if (ret) - return ret; - - return 0; -} -EXPORT_SYMBOL_GPL(rtl8366_vlan_filtering); - int rtl8366_vlan_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan, struct netlink_ext_ack *extack) diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index a5b7d7ff8884..b565074b0462 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -143,6 +143,21 @@ #define RTL8366RB_PHY_NO_OFFSET 9 #define RTL8366RB_PHY_NO_MASK (0x1f << 9) +/* VLAN Ingress Control Register 1, one bit per port. + * bit 0 .. 5 will make the switch drop ingress frames without + * VID such as untagged or priority-tagged frames for respective + * port. + * bit 6 .. 11 will make the switch drop ingress frames carrying + * a C-tag with VID != 0 for respective port. + */ +#define RTL8366RB_VLAN_INGRESS_CTRL1_REG 0x037E +#define RTL8366RB_VLAN_INGRESS_CTRL1_DROP(port) (BIT((port)) | BIT((port) + 6)) + +/* VLAN Ingress Control Register 2, one bit per port. + * bit0 .. bit5 will make the switch drop all ingress frames with + * a VLAN classification that does not include the port is in its + * member set. + */ #define RTL8366RB_VLAN_INGRESS_CTRL2_REG 0x037f /* LED control registers */ @@ -321,9 +336,11 @@ /** * struct rtl8366rb - RTL8366RB-specific data * @max_mtu: per-port max MTU setting + * @pvid_enabled: if PVID is set for respective port */ struct rtl8366rb { unsigned int max_mtu[RTL8366RB_NUM_PORTS]; + bool pvid_enabled[RTL8366RB_NUM_PORTS]; }; static struct rtl8366_mib_counter rtl8366rb_mib_counters[] = { @@ -933,11 +950,13 @@ static int rtl8366rb_setup(struct dsa_switch *ds) if (ret) return ret; - /* Discard VLAN tagged packets if the port is not a member of - * the VLAN with which the packets is associated. - */ + /* Accept all packets by default, we enable filtering on-demand */ + ret = regmap_write(smi->map, RTL8366RB_VLAN_INGRESS_CTRL1_REG, + 0); + if (ret) + return ret; ret = regmap_write(smi->map, RTL8366RB_VLAN_INGRESS_CTRL2_REG, - RTL8366RB_PORT_ALL); + 0); if (ret) return ret; @@ -1209,6 +1228,50 @@ rtl8366rb_port_bridge_leave(struct dsa_switch *ds, int port, RTL8366RB_PORT_ISO_PORTS(port_bitmap), 0); } +/** + * rtl8366rb_drop_untagged() - make the switch drop untagged and C-tagged frames + * @smi: SMI state container + * @port: the port to drop untagged and C-tagged frames on + * @drop: whether to drop or pass untagged and C-tagged frames + */ +static int rtl8366rb_drop_untagged(struct realtek_smi *smi, int port, bool drop) +{ + return regmap_update_bits(smi->map, RTL8366RB_VLAN_INGRESS_CTRL1_REG, + RTL8366RB_VLAN_INGRESS_CTRL1_DROP(port), + drop ? RTL8366RB_VLAN_INGRESS_CTRL1_DROP(port) : 0); +} + +static int rtl8366rb_vlan_filtering(struct dsa_switch *ds, int port, + bool vlan_filtering, + struct netlink_ext_ack *extack) +{ + struct realtek_smi *smi = ds->priv; + struct rtl8366rb *rb; + int ret; + + rb = smi->chip_data; + + dev_dbg(smi->dev, "port %d: %s VLAN filtering\n", port, + vlan_filtering ? "enable" : "disable"); + + /* If the port is not in the member set, the frame will be dropped */ + ret = regmap_update_bits(smi->map, RTL8366RB_VLAN_INGRESS_CTRL2_REG, + BIT(port), vlan_filtering ? BIT(port) : 0); + if (ret) + return ret; + + /* If VLAN filtering is enabled and PVID is also enabled, we must + * not drop any untagged or C-tagged frames. If we turn off VLAN + * filtering on a port, we need to accept any frames. + */ + if (vlan_filtering) + ret = rtl8366rb_drop_untagged(smi, port, !rb->pvid_enabled[port]); + else + ret = rtl8366rb_drop_untagged(smi, port, false); + + return ret; +} + static int rtl8366rb_change_mtu(struct dsa_switch *ds, int port, int new_mtu) { struct realtek_smi *smi = ds->priv; @@ -1420,14 +1483,34 @@ static int rtl8366rb_get_mc_index(struct realtek_smi *smi, int port, int *val) static int rtl8366rb_set_mc_index(struct realtek_smi *smi, int port, int index) { + struct rtl8366rb *rb; + bool pvid_enabled; + int ret; + + rb = smi->chip_data; + pvid_enabled = !!index; + if (port >= smi->num_ports || index >= RTL8366RB_NUM_VLANS) return -EINVAL; - return regmap_update_bits(smi->map, RTL8366RB_PORT_VLAN_CTRL_REG(port), + ret = regmap_update_bits(smi->map, RTL8366RB_PORT_VLAN_CTRL_REG(port), RTL8366RB_PORT_VLAN_CTRL_MASK << RTL8366RB_PORT_VLAN_CTRL_SHIFT(port), (index & RTL8366RB_PORT_VLAN_CTRL_MASK) << RTL8366RB_PORT_VLAN_CTRL_SHIFT(port)); + if (ret) + return ret; + + rb->pvid_enabled[port] = pvid_enabled; + + /* If VLAN filtering is enabled and PVID is also enabled, we must + * not drop any untagged or C-tagged frames. Make sure to update the + * filtering setting. + */ + if (dsa_port_is_vlan_filtering(dsa_to_port(smi->ds, port))) + ret = rtl8366rb_drop_untagged(smi, port, !pvid_enabled); + + return ret; } static bool rtl8366rb_is_vlan_valid(struct realtek_smi *smi, unsigned int vlan) @@ -1437,7 +1520,7 @@ static bool rtl8366rb_is_vlan_valid(struct realtek_smi *smi, unsigned int vlan) if (smi->vlan4k_enabled) max = RTL8366RB_NUM_VIDS - 1; - if (vlan == 0 || vlan > max) + if (vlan > max) return false; return true; @@ -1594,7 +1677,7 @@ static const struct dsa_switch_ops rtl8366rb_switch_ops = { .get_sset_count = rtl8366_get_sset_count, .port_bridge_join = rtl8366rb_port_bridge_join, .port_bridge_leave = rtl8366rb_port_bridge_leave, - .port_vlan_filtering = rtl8366_vlan_filtering, + .port_vlan_filtering = rtl8366rb_vlan_filtering, .port_vlan_add = rtl8366_vlan_add, .port_vlan_del = rtl8366_vlan_del, .port_enable = rtl8366rb_port_enable, From patchwork Tue Sep 28 14:41:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 12523025 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0E3CC433F5 for ; Tue, 28 Sep 2021 14:45:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5B37611CE for ; Tue, 28 Sep 2021 14:45:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241426AbhI1Oqo (ORCPT ); Tue, 28 Sep 2021 10:46:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241427AbhI1Oql (ORCPT ); Tue, 28 Sep 2021 10:46:41 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD339C061749 for ; Tue, 28 Sep 2021 07:45:01 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id u18so91950015lfd.12 for ; Tue, 28 Sep 2021 07:45:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PIgf3DsDMzPlEkL+3qloth/cat7utuH+OdIdrgmjoIs=; b=JLcmRMCcF7wdaVnVYrobu2efL0u0TCbuxotlva05T572L0moE+PORETze3VzZxLooH TrruhDuQ4+N/1YePqgvvhukM4t4/Db01LPiFYT23PQ7u9x7OSqysXRNk31sohcXslyGR Ib+ssGQVeev/zAYuEhr4GUEFM7h60kA86A+6+ttpB28Pj+PreFbwjw2NHMw/xa0y568Q skN6zgYU9RXn1wy5oGW6zEqaKN3VGY+vPPvzedyP9wMQq9MNAVxLxJWUMFkD6afHrEeR ELVpdZN+eqSeCDourf2YiW8KCvvANDxp7cUHHcpgif8ZDRr52XcFYuWEuh4Yq0PzU2hR I4KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PIgf3DsDMzPlEkL+3qloth/cat7utuH+OdIdrgmjoIs=; b=2PwEwn9HGSEmZZMTl/abET2G3uM3jSLsbPotk0fYq+olt/fmTZyny7Xspq+mt/B0uT d77TSWplPmMuoM0Y/PBL3BgksSy9gY+yfhEGZvrF6+eaQm4b7Am1SIdNj2Ds6QpbFffQ bOx3K4Tt7b1CP1y7TE+5QpRyvKmos01ZIFnOUYhoPpRrc/sw5Cgnd6RtCdKzL1XYzN7p xuPLWM+Jc6xoLY6iaUY4sJ/m1PFIjNkhGXT3rnCFcNWCx+lJ+1c1FVdV8CXiB+1tuhKl i6ktGS/yoz0LIKHZwiB1Nakan1NQF/+c8VPlBMnd9e/2zmJZXpewQnlrTLSFlR2FpTJR JMng== X-Gm-Message-State: AOAM5309Gx3SJxBXEHImFl3e3T9k9TC7/MhObwZmtCJFf846lA/1x3IC 5EYLZznRj3PHE0j++UktCoXy2Q== X-Google-Smtp-Source: ABdhPJznXyUDeS0Z/DhQhBouIFuMuam0TvcIHmo7WZLP8dRgPdQ7NsIONirVvli07OVOXOGBRLjv0Q== X-Received: by 2002:ac2:5387:: with SMTP id g7mr6011190lfh.541.1632840291460; Tue, 28 Sep 2021 07:44:51 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id x23sm1933462lfd.136.2021.09.28.07.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 07:44:50 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Linus Walleij , Mauri Sandberg , DENG Qingfang , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH net-next 4/6 v8] net: dsa: rtl8366rb: Fix off-by-one bug Date: Tue, 28 Sep 2021 16:41:47 +0200 Message-Id: <20210928144149.84612-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928144149.84612-1-linus.walleij@linaro.org> References: <20210928144149.84612-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The max VLAN number with non-4K VLAN activated is 15, and the range is 0..15. Not 16. The impact should be low since we by default have 4K VLAN and thus have 4095 VLANs to play with in this switch. There will not be a problem unless the code is rewritten to only use 16 VLANs. Fixes: d8652956cf37 ("net: dsa: realtek-smi: Add Realtek SMI driver") Cc: Mauri Sandberg Cc: DENG Qingfang Reviewed-by: Florian Fainelli Reviewed-by: Alvin Šipraga Reviewed-by: Vladimir Oltean Signed-off-by: Linus Walleij --- ChangeLog v7->v8: - Collect Florian's review tag. ChangeLog v6->v7: - Collect Alvin's and Vladimir's review tags. ChangeLog v5->v6: - No changes just resending with the rest of the patches. ChangeLog v4->v5: - Add some more text describing that this is not a critical bug. - Add Fixes tag ChangeLog v1->v4: - New patch for a bug discovered when fixing the other issues. --- drivers/net/dsa/rtl8366rb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index b565074b0462..bb9d017c2f9f 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -1515,7 +1515,7 @@ static int rtl8366rb_set_mc_index(struct realtek_smi *smi, int port, int index) static bool rtl8366rb_is_vlan_valid(struct realtek_smi *smi, unsigned int vlan) { - unsigned int max = RTL8366RB_NUM_VLANS; + unsigned int max = RTL8366RB_NUM_VLANS - 1; if (smi->vlan4k_enabled) max = RTL8366RB_NUM_VIDS - 1; From patchwork Tue Sep 28 14:41:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 12523023 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B1EFC433EF for ; Tue, 28 Sep 2021 14:45:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EEC23604D1 for ; Tue, 28 Sep 2021 14:45:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241420AbhI1Oqj (ORCPT ); Tue, 28 Sep 2021 10:46:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241411AbhI1Oqh (ORCPT ); Tue, 28 Sep 2021 10:46:37 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4AF3C06161C for ; Tue, 28 Sep 2021 07:44:57 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id y28so93049605lfb.0 for ; Tue, 28 Sep 2021 07:44:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SyJepoAP9gqp9xgp/GjgHi1fMuvyMC7LLl2uqf6Q+6k=; b=GVHGXwAsDT/eVNmLUaxXkb9bjMePwv2tWQbge/wagGCzMLSae4sqS0CySacAC3PTh4 285PCkzi699QZd4DIy7CG0iwk0WdVHDWs/Vp+i3qr24hGAVYAG62UBICdpXelLCT3Qik s0BhL7ULHKUPCGYNV4nCRDnJFSAztBNtP6vyI3ykMM6Fys3ssNSnq+GkVUUv0i26zEKQ bkyEchtrURiEcpMI/AdiegbCPy5UVV78n8IA3hTOlWggL5jkjmRNzTs3WsNT4lHPcDq2 cREOlrl1s/wETHpTW0Qq7D2z2MAcY1Ao3WVA0cSKjwGnyh+QWLHu2sJOakF16U3oepJb HhAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SyJepoAP9gqp9xgp/GjgHi1fMuvyMC7LLl2uqf6Q+6k=; b=3X5Vclnx/+ZQtZb7Oy3ZKmH/3kzIfTAwnpcKwrfpysqkWtHnvEY1loXemDZO8FDUN7 LK+bhgYNdWrT6kKhY+Qklvht+0L8ikfsMM8ePjB6tHK8FaknrpUqLP0WCZY3beyZoeXj gAO7HrieCmCnSR5HMurw0fvbYi0su6kwWqOFlzXjvSDFKK6Q5zd29YGVe8+zc61zzNPk WZ8zQW9UTDaSAKELvvSdi1+PIJy2K24PlxIVMsZYwOyWkCloz0eHxcPp/BMLfMdnfr5e OTcvmhhJjWdrRvLmLTyMfgaNPDhqwmdN9En7+LzpfABy5vjnqnJJioObo31EzQBDE1op HA7w== X-Gm-Message-State: AOAM532Ic6XBb0ze/c5emx3RACvLQX2pJfSfcL9HKxqtuG2sWk+LCyMO 7aGAqVB50CZ5o1XPU7Siy6Qibg== X-Google-Smtp-Source: ABdhPJz2ASAtwsAG1gh2UlbgkFrOEhSKwpIUUFKYNhCwpiWrrVZ+EIKe+ZQA2WlxHOECbdIAjus5Dg== X-Received: by 2002:a05:6512:1303:: with SMTP id x3mr6083260lfu.291.1632840293564; Tue, 28 Sep 2021 07:44:53 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id x23sm1933462lfd.136.2021.09.28.07.44.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 07:44:52 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Linus Walleij , Mauri Sandberg , DENG Qingfang , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH net-next 5/6 v8] net: dsa: rtl8366: Fix a bug in deleting VLANs Date: Tue, 28 Sep 2021 16:41:48 +0200 Message-Id: <20210928144149.84612-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928144149.84612-1-linus.walleij@linaro.org> References: <20210928144149.84612-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org We were checking that the MC (member config) was != 0 for some reason, all we need to check is that the config has no ports, i.e. no members. Then it can be recycled. This must be some misunderstanding. Fixes: 4ddcaf1ebb5e ("net: dsa: rtl8366: Properly clear member config") Cc: Mauri Sandberg Cc: DENG Qingfang Reviewed-by: Alvin Šipraga Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli Signed-off-by: Linus Walleij --- ChangeLog v7->v8: - No changes just resending with the rest of the patches. ChangeLog v6->v7: - Collect Alvin's and Vladimir's review tags. ChangeLog v5->v6: - No changes just resending with the rest of the patches. ChangeLog v4->v5: - Collect Florians review tag - Add Fixes tag ChangeLog v1->v4: - New patch for a bug found while fixing the other issues. --- drivers/net/dsa/rtl8366.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 0672dd56c698..f815cd16ad48 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -374,7 +374,7 @@ int rtl8366_vlan_del(struct dsa_switch *ds, int port, * anymore then clear the whole member * config so it can be reused. */ - if (!vlanmc.member && vlanmc.untag) { + if (!vlanmc.member) { vlanmc.vid = 0; vlanmc.priority = 0; vlanmc.fid = 0; From patchwork Tue Sep 28 14:41:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 12523021 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A787C433F5 for ; Tue, 28 Sep 2021 14:45:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0081C604D1 for ; Tue, 28 Sep 2021 14:44:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241417AbhI1Oqi (ORCPT ); Tue, 28 Sep 2021 10:46:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241398AbhI1Oqg (ORCPT ); Tue, 28 Sep 2021 10:46:36 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1088AC06161C for ; Tue, 28 Sep 2021 07:44:57 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id x27so93923253lfu.5 for ; Tue, 28 Sep 2021 07:44:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=62y0ANGEUm3ySLIVamKt9x6B4cOMDWlyE3Xypm+3cmw=; b=Kmea0YCMrSIDBm9cAWPXW2eLpoDtU99SaCnLhyXiotUFbVN6vk3+9NodecFOZqg0Xl Ahh6gDFdhu/KbuzeyWkcyN9EOjrqUAZXztHv4mtaUawfMQTFyoNTPSL4Q+g3bQf+S8vz V8NFr7dpirKWrdTHGMmd63r/l3UKQHOMqLB7+Ra3cup2tC2nqb7srh+h3Vz0mjE/E8pE rSPkvLvMvd4ZhDXMYIPSXbKux/Wcruw6ZsPpia2ZZddJmug+7E/bp7OlSd8M2fTZH6Ts VUwESTollrjDJqxqh1WdnlwLvu1r4sbyVlxxclELBVqeBFZkmKvy/bAk24PjHpixogjW T3dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=62y0ANGEUm3ySLIVamKt9x6B4cOMDWlyE3Xypm+3cmw=; b=psvWjdlOCfvAtNE6PJtmSrIvTwuCDo1ic5MuxII7V3OIdqBSTyqzomS5/GVIA/7LPT X1PSnMSMEg8hp0fbLLcOaCoS94ovrohRcbYn5uQbB4N0+9aSMgGBE3ddAkMgvfLzqQZA FfNi+QOhnnDR/2r9bRckREK6WLcwf8arPiQiEVmMvFglCDSqYE7jrrh32YNOsSnEIh78 Qxs+Fs+WErCLAuhD+UUxZZeLjOqv0Kp5EFZ8N6K7P+hnyDGDzv454WGVPlIPx87af14v jNoq1LUN6T/Ac1ho92zQWVGKoPfy0vAtqzrPyocyfxJJDp9pcIE4Ur7bZOkE0HL7odBa lSDg== X-Gm-Message-State: AOAM531m6DxdJoz8C9CI4QrOGwYWnJBCDB6Vij0ljKQKO7iAccTCN7VO CNL/d9eEJ0O6N/41pXbGRhsCIA== X-Google-Smtp-Source: ABdhPJz99AIJcxRi02OuZUTbnPmeGEHUZGQNzK6Lk8PfEfs5UocDHuhE9uL9LRCMGkZKhC2nhbspwQ== X-Received: by 2002:a2e:58c:: with SMTP id 134mr374947ljf.100.1632840295361; Tue, 28 Sep 2021 07:44:55 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id x23sm1933462lfd.136.2021.09.28.07.44.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 07:44:54 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Linus Walleij , Mauri Sandberg , DENG Qingfang , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH net-next 6/6 v8] net: dsa: rtl8366: Drop and depromote pointless prints Date: Tue, 28 Sep 2021 16:41:49 +0200 Message-Id: <20210928144149.84612-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928144149.84612-1-linus.walleij@linaro.org> References: <20210928144149.84612-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org We don't need a message for every VLAN association, dbg is fine. The message about adding the DSA or CPU port to a VLAN is directly misleading, this is perfectly fine. Cc: Vladimir Oltean Cc: Mauri Sandberg Cc: DENG Qingfang Reviewed-by: Alvin Šipraga Reviewed-by: Florian Fainelli Signed-off-by: Linus Walleij --- ChangeLog v7->v8: - No changes just resending with the rest of the patches. ChangeLog v6->v7: - Fix a small whitespace error in one of the debug messages. - Collect Alvin's review tag. ChangeLog v5->v6: - No changes just resending with the rest of the patches. ChangeLog v4->v5: - Collect Florians review tag. ChangeLog v1->v4: - New patch to deal with confusing messages and too talkative DSA bridge. --- drivers/net/dsa/rtl8366.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index f815cd16ad48..bdb8d8d34880 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -318,12 +318,9 @@ int rtl8366_vlan_add(struct dsa_switch *ds, int port, return ret; } - dev_info(smi->dev, "add VLAN %d on port %d, %s, %s\n", - vlan->vid, port, untagged ? "untagged" : "tagged", - pvid ? " PVID" : "no PVID"); - - if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) - dev_err(smi->dev, "port is DSA or CPU port\n"); + dev_dbg(smi->dev, "add VLAN %d on port %d, %s, %s\n", + vlan->vid, port, untagged ? "untagged" : "tagged", + pvid ? "PVID" : "no PVID"); member |= BIT(port); @@ -356,7 +353,7 @@ int rtl8366_vlan_del(struct dsa_switch *ds, int port, struct realtek_smi *smi = ds->priv; int ret, i; - dev_info(smi->dev, "del VLAN %04x on port %d\n", vlan->vid, port); + dev_dbg(smi->dev, "del VLAN %d on port %d\n", vlan->vid, port); for (i = 0; i < smi->num_vlan_mc; i++) { struct rtl8366_vlan_mc vlanmc;