From patchwork Mon Aug 30 21:48:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 12466031 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 22116C432BE for ; Mon, 30 Aug 2021 21:52:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF37760FC0 for ; Mon, 30 Aug 2021 21:52:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238756AbhH3Vxq (ORCPT ); Mon, 30 Aug 2021 17:53:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237167AbhH3Vxp (ORCPT ); Mon, 30 Aug 2021 17:53:45 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19FB2C061575 for ; Mon, 30 Aug 2021 14:52:51 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id h1so28374451ljl.9 for ; Mon, 30 Aug 2021 14:52: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=OPOenaKE+1kJAT6buGCuFkpiFLC09mvc5Fh3pG+x+KQ=; b=qpdfyD3wu1+ur1vKEVugdvICyOGi4YVhNX6LAV8pzOd6WV6VgrduS28h7OehnnPjho vIspmJh5q/k1UwvXz4AJz9Vzq8XHE8Ty4FFDlC8h37kUEmIo2HAempVKODct8hiolTxL 6aEpDyGwrt8X+Xpw1SRWX/sAJ/qCf51lYOx7hMaI2V/NLDB8CtVhuweKQUUmawm4kbwz ix+A4PKpzRRWArie48YHLwEfTga9xtueUK1DOXSF+O81SVFRrZJhIeSVmfOHvHgt/VLU xPsy18Dy/R28GPoq1yGEFTcH/RkLYZjBD5xVLU+4oV963hB5GMGlmAxU9IUmggn+q6L0 rteA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=OPOenaKE+1kJAT6buGCuFkpiFLC09mvc5Fh3pG+x+KQ=; b=ppykYeNR0bVvsLgYhkhMht8bGyN7/IqrUkH11+3rTTN8VUCoYuzwFlsl1BSxhlGpIL CHyjbtZs36PINIXLpl3I9t2GbeY17Lsh/T4TvK+lTTHaqAZ9hnbKOACRO7OnGZEjX2uX kCpPagDi8RhvmMZIdZoKwpktSedL6aTFfAxKiHZ5J6gra8xj+LsxSPvXxC09CCFO44E7 05bEu9Sv9Mu4SXIybCiW5oo39gqxsvqCLCx1wZqKS2s/7Ym62/bl4GNAamFNgaT3NF3w cJ2MdUr+zZxfbc7b9CuOCniAT+Atuu6RzfHYI4TXdT9ow3Jy4QRcZ3quXAuOwnQrcVho mLZw== X-Gm-Message-State: AOAM531YQZbAEzwC8d3unrJNm3nJ/xSnv00r8giAQ745+wdvYhnRFm9y ymQZE03Fit6/Axb2h+A3U/9Bbg== X-Google-Smtp-Source: ABdhPJySM50kSzpCgI0XH4wT+JrWyti050taxnL5rdtMO7/FTxM+fuIkRM2sRNYfPsIPKMXpR8qENQ== X-Received: by 2002:a2e:804a:: with SMTP id p10mr22413906ljg.216.1630360369435; Mon, 30 Aug 2021 14:52:49 -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 h4sm1514049lft.184.2021.08.30.14.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 14:52:49 -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 , =?utf-8?q?Alvi?= =?utf-8?q?n_=C5=A0ipraga?= , Mauri Sandberg , Linus Walleij Subject: [PATCH net-next 1/5 v2] net: dsa: rtl8366rb: support bridge offloading Date: Mon, 30 Aug 2021 23:48:55 +0200 Message-Id: <20210830214859.403100-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210830214859.403100-1-linus.walleij@linaro.org> References: <20210830214859.403100-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: Alvin Šipraga Cc: Mauri Sandberg Signed-off-by: DENG Qingfang Signed-off-by: Linus Walleij Reviewed-by: Alvin Šipraga Reviewed-by: Florian Fainelli --- 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 | 87 +++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index a89093bc6c6a..50ee7cd62484 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,22 @@ static int rtl8366rb_setup(struct dsa_switch *ds) if (ret) return ret; + /* Isolate all user ports so only the CPU port can access them */ + for (i = 0; i < RTL8366RB_PORT_NUM_CPU; i++) { + ret = regmap_write(smi->map, RTL8366RB_PORT_ISO(i), + RTL8366RB_PORT_ISO_EN | + RTL8366RB_PORT_ISO_PORTS(BIT(RTL8366RB_PORT_NUM_CPU))); + if (ret) + return ret; + } + /* CPU port can access all ports */ + dev_info(smi->dev, "DSA user port mask: %08x\n", dsa_user_ports(ds)); + 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 +1150,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 this one */ + for (i = 0; i < RTL8366RB_PORT_NUM_CPU; i++) { + /* 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) + return ret; + + 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_MASK, + 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++) { + /* 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) + return; + + port_bitmap |= BIT(i); + } + + /* Clear the bits for the ports we can access */ + 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 +1595,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 Mon Aug 30 21:48:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 12466033 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 A7E54C4320E for ; Mon, 30 Aug 2021 21:52:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AAFD60FA0 for ; Mon, 30 Aug 2021 21:52:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238797AbhH3Vxu (ORCPT ); Mon, 30 Aug 2021 17:53:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237167AbhH3Vxq (ORCPT ); Mon, 30 Aug 2021 17:53:46 -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 93AF2C061575 for ; Mon, 30 Aug 2021 14:52:52 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id j4so34173673lfg.9 for ; Mon, 30 Aug 2021 14:52:52 -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=DZmYKsknRg8+p+PrSI/9VzJHFxsV1mevtKXxas2+qRE=; b=YCRhg/hFGWS3B+HgVZ6sJUt7m9xoZbqyJwbONPnxudagRD3tYL+Pu1YOtyseuoTtSQ p9Sk17R+4qFVveWaFQu6PxB5Jf0mnpGf4rfGWPC9Z/3KGgNaqoiw8MnMRSdd391cUv/u jHrm/L/jCEsTTG2P9WVLbmEDnfJac2I6TpWCeIf7iQX6Gpue8f/hBAoVrLRk3aH5kDxZ veJUk3Y6/2YseKAUFpKtgQqm5qKq/t7FqGJSlw2Ovvw9rZdTXECoCfNpNDzkMZbt4853 wKYiUYsfYuvvTE3GXV5+b8lgtTM5ZyeO6FgUJPL7ok5Iq1EjBwn07khtxHgq6eaIewKN Yj1A== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=DZmYKsknRg8+p+PrSI/9VzJHFxsV1mevtKXxas2+qRE=; b=qiSiNnm9Ik3N1EJm7b49vlR2hljxUSg7XcT4n8vt4O+Mz0d6uM55oUUQchEFjZASXD ZZ10hHaIrPhNvN+egBibmEpNYNFhVhueBAHpTPATMNhmIpkBccTQATgIOwzMKKcawrjt SM/qvkofsHKx9OkoTCaTCoFY2uLvitHKMxc9H3s+LsYWDDflrX6K+FiSqp2CUzNFbC8z /Ffe7UCr3IfRx1Tk/PT+YLSeFD+AacN6bLZtfNaOBIStLw4T3DMllsJgUekLpaGpJIEY z3Aa+k5Vj97niB+IgX1lOO3+Mx85b7QoHIW89KYgnMUhG5WWebCvIywMpHVBbO2bYkGd HCpg== X-Gm-Message-State: AOAM530VDCnm9HSn8yG5dPio6rYN3TyuzF3uJw4JTxRPWYqSXijN4C2a yOl9BwDBNhIU2WolL0MbtsWjMA== X-Google-Smtp-Source: ABdhPJy74PIXgkysXng3Q+gXmiwMtNUECeKI8GjJETyLjB4WD40REPYdoNnavLErMT0NzyIDik3RHg== X-Received: by 2002:a05:6512:15e:: with SMTP id m30mr6002331lfo.82.1630360370994; Mon, 30 Aug 2021 14:52:50 -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 h4sm1514049lft.184.2021.08.30.14.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 14:52: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 , =?utf-8?q?Alvin_=C5=A0ipraga?= , Mauri Sandberg , DENG Qingfang Subject: [PATCH net-next 2/5 v2] net: dsa: rtl8366: Drop custom VLAN set-up Date: Mon, 30 Aug 2021 23:48:56 +0200 Message-Id: <20210830214859.403100-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210830214859.403100-1-linus.walleij@linaro.org> References: <20210830214859.403100-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: Vladimir Oltean Cc: Alvin Šipraga Cc: Mauri Sandberg Cc: DENG Qingfang Signed-off-by: Linus Walleij Reviewed-by: Vladimir Oltean Reviewed-by: Alvin Šipraga Reviewed-by: Florian Fainelli --- 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 50ee7cd62484..8b040440d2d4 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -986,7 +986,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; @@ -1000,8 +1000,6 @@ static int rtl8366rb_setup(struct dsa_switch *ds) return -ENODEV; } - ds->configure_vlan_while_not_filtering = false; - return 0; } From patchwork Mon Aug 30 21:48:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 12466035 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 D62D9C432BE for ; Mon, 30 Aug 2021 21:52:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B417060FA0 for ; Mon, 30 Aug 2021 21:52:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238806AbhH3Vxv (ORCPT ); Mon, 30 Aug 2021 17:53:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238759AbhH3Vxs (ORCPT ); Mon, 30 Aug 2021 17:53:48 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E25DAC06175F for ; Mon, 30 Aug 2021 14:52:53 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id h1so28374615ljl.9 for ; Mon, 30 Aug 2021 14:52:53 -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=ygzbCZeLrFRK4C7lX1xuZX3+5YuPXt2lUz8XmLXuXb4=; b=ULJ1sAjl7WgYNynZYhc8h70jKLUpzlMxhdcWSidWDIKbW5KQqTpdUo2IHayNNXvq/H 1NGRu0qqchshbqau9yxck1obR50pJnieXHIII95VkoyJ+kr1VxwlXBdSxL/CQUZ/jgzQ +ubgyQOk7FfjnbWXo446+zIekEB5umSJXwI0Cy2nykoxSbXNMuNQhxUY0GVAn5o0l8QQ 6ABGRpQFVL/lnw+ibKbMI43bss4LdaWs6pI9/yLePRcSVco6MgFihF8JrGXlg5Wm90YV scxe982AxwJ3UyDv4Ndh2DL2PXZOhHEI2RxJf7iB6VMN1Rc76bw6bYyGllKiPhk326gu gXBg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ygzbCZeLrFRK4C7lX1xuZX3+5YuPXt2lUz8XmLXuXb4=; b=n7nw3pSpQ5tCqYE8kb9eLTym4hpr/zTpsU3wb6Vbcqj6EgzZ98vdHx6SrRZotxIN9y cKSJVxm61pRECepQVkeIwkNrdH0mWvQvvGJBeoQU+aEI4t3IG5S2qZvii5rIMs917IZy cySYyGLlsn+w43mFERFtmJMjJLnXukEC+x0KXoCgIdKCa4afkCiVrPE6DpnRlBljI6o/ zVR3FdDQN9b4AWQ+LBf+SKzPsekzdYJv3CfYaYIcUEvMJDGWnBDk9wLeH8/Xpy8XJrlS UwhWMWWPqydUXy5GhSCvNvDT9Rpl0umMuQf+GJbMfEqiXLBLaOAtJFb0pBRUBLsh6xaH RCaQ== X-Gm-Message-State: AOAM533ox9NHpH7WRmMgxxDPVAPoB/X30ln01TStb+K+mMsd7G3ucJUu 6h1hRZJXxEpGg1kXH4rtO3YSIg== X-Google-Smtp-Source: ABdhPJzug4J/BQ3GDv46urk1SWlbYbdveuPKBwcNTqyebvwCeMKlb9EhZYKcu9bOzIAUgdmPPEd+wQ== X-Received: by 2002:a2e:bf0d:: with SMTP id c13mr376437ljr.101.1630360372232; Mon, 30 Aug 2021 14:52:52 -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 h4sm1514049lft.184.2021.08.30.14.52.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 14:52:51 -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 , =?utf-8?q?Alvin_=C5=A0ipraga?= , Mauri Sandberg , DENG Qingfang Subject: [PATCH net-next 3/5 v2] net: dsa: rtl8366rb: Support disabling learning Date: Mon, 30 Aug 2021 23:48:57 +0200 Message-Id: <20210830214859.403100-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210830214859.403100-1-linus.walleij@linaro.org> References: <20210830214859.403100-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 RTL8366RB hardware supports disabling learning per-port so let's make use of this feature. Rename some unfortunately named registers in the process. Suggested-by: Vladimir Oltean Cc: Alvin Šipraga Cc: Mauri Sandberg Cc: DENG Qingfang Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - New patch suggested by Vladimir. --- drivers/net/dsa/rtl8366rb.c | 47 +++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index 8b040440d2d4..2cadd3e57e8b 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -42,9 +43,12 @@ /* Port Enable Control register */ #define RTL8366RB_PECR 0x0001 -/* Switch Security Control registers */ -#define RTL8366RB_SSCR0 0x0002 -#define RTL8366RB_SSCR1 0x0003 +/* Switch per-port learning disablement register */ +#define RTL8366RB_PORT_LEARNDIS_CTRL 0x0002 + +/* Security control, actually aging register */ +#define RTL8366RB_SECURITY_CTRL 0x0003 + #define RTL8366RB_SSCR2 0x0004 #define RTL8366RB_SSCR2_DROP_UNKNOWN_DA BIT(0) @@ -912,12 +916,12 @@ static int rtl8366rb_setup(struct dsa_switch *ds) rb->max_mtu[i] = 1532; /* Enable learning for all ports */ - ret = regmap_write(smi->map, RTL8366RB_SSCR0, 0); + ret = regmap_write(smi->map, RTL8366RB_PORT_LEARNDIS_CTRL, 0); if (ret) return ret; /* Enable auto ageing for all ports */ - ret = regmap_write(smi->map, RTL8366RB_SSCR1, 0); + ret = regmap_write(smi->map, RTL8366RB_SECURITY_CTRL, 0); if (ret) return ret; @@ -1148,6 +1152,37 @@ rtl8366rb_port_disable(struct dsa_switch *ds, int port) rb8366rb_set_port_led(smi, port, false); } +static int +rtl8366rb_port_pre_bridge_flags(struct dsa_switch *ds, int port, + struct switchdev_brport_flags flags, + struct netlink_ext_ack *extack) +{ + /* We support enabling/disabling learning */ + if (flags.mask & ~(BR_LEARNING)) + return -EINVAL; + + return 0; +} + +static int +rtl8366rb_port_bridge_flags(struct dsa_switch *ds, int port, + struct switchdev_brport_flags flags, + struct netlink_ext_ack *extack) +{ + struct realtek_smi *smi = ds->priv; + int ret; + + if (flags.mask & BR_LEARNING) { + ret = regmap_update_bits(smi->map, RTL8366RB_PORT_LEARNDIS_CTRL, + BIT(port), + (flags.val & BR_LEARNING) ? 0 : BIT(port)); + if (ret) + return ret; + } + + return 0; +} + static int rtl8366rb_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *bridge) @@ -1600,6 +1635,8 @@ static const struct dsa_switch_ops rtl8366rb_switch_ops = { .port_vlan_del = rtl8366_vlan_del, .port_enable = rtl8366rb_port_enable, .port_disable = rtl8366rb_port_disable, + .port_pre_bridge_flags = rtl8366rb_port_pre_bridge_flags, + .port_bridge_flags = rtl8366rb_port_bridge_flags, .port_change_mtu = rtl8366rb_change_mtu, .port_max_mtu = rtl8366rb_max_mtu, }; From patchwork Mon Aug 30 21:48:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 12466037 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 E711BC43214 for ; Mon, 30 Aug 2021 21:52:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C672560F42 for ; Mon, 30 Aug 2021 21:52:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238820AbhH3Vxw (ORCPT ); Mon, 30 Aug 2021 17:53:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238788AbhH3Vxt (ORCPT ); Mon, 30 Aug 2021 17:53:49 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43DDEC061764 for ; Mon, 30 Aug 2021 14:52:55 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id c8so21616720lfi.3 for ; Mon, 30 Aug 2021 14:52:55 -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=eSR/6/R7THpAwy4A0msHNf8bOj6o29f7fnPgnd1UmSA=; b=Q5CoBlQGxUdAsvYfNoHkrmajhg5mM9w5XCJpwllThzBGYrNFRvYtGCUEbGf9jv2ht+ QrkgMx1HHLuxPd7c0DOGSrHz8Z3eGBsBxHsGY4TzHQZ0wuc7faubhxO5AqTz70deVD5I V/1dBx5Gi14cZl99W9lLniM0Li76NKuErnTDdbJ3fN7MbalpVdzbNL3ePNgsDZCiV0cH VktoVeMZLQNeH98W2Im1njJWNPAQWYIKLcuJXIVU4sOeC7RHH+R5stXD6fUjVgQhkMCK 44EOuCFpEVQvPyL7v6S+qwNXsf8NthF50OJkh3wd48lh3a3arCycWWkn3UeaxZ5Fg3f/ TsJg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=eSR/6/R7THpAwy4A0msHNf8bOj6o29f7fnPgnd1UmSA=; b=HvGaPlLCYo0MOUtX7J+6fwpMZex32mwWyLP0njnE06OYWyC8ufXnFrvR6gpVojeONi 3Gj3NpzuZjLhHGgtWKv43zcRzr3CFAO2XX9b3X+V2c7YxaJiaDl2uqDq9KKRzUVcN+M4 JzaR7OQfk4ima9LRAhtAtoGRe3Mzmzg5xKm/cjUbYnoOcUZtixPBpnB6uPw/7GBbnpQT TAR62HfsGtgKHn/UmtEZ/QftRtNdfJ7QbIsBzCkHdd1uwFGfIgX5CtgiOKzep8YvCOME PnMABwWPzr1VJHhQpxSKhjykKt8gevRubwumORV0lcwhhM6QnHqWGphLYyV3ahRUQcjs SyPw== X-Gm-Message-State: AOAM5313PRrZu6uuC4hm+BEGofneNim7H7MeimannoV0XO0Iv/2NTWi2 nIDQeeBecZhsFCuK/In7HQkOqw== X-Google-Smtp-Source: ABdhPJx7BixVA946QLOaPULbqWzMOG7q6NLae45EG1vngjwnOzjXiwA/t5JBhbBKaSOTEt8PvtWHFg== X-Received: by 2002:a05:6512:318e:: with SMTP id i14mr6075790lfe.444.1630360373551; Mon, 30 Aug 2021 14:52: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 h4sm1514049lft.184.2021.08.30.14.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 14:52:53 -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 , =?utf-8?q?Alvin_=C5=A0ipraga?= , Mauri Sandberg , DENG Qingfang Subject: [PATCH net-next 4/5 v2] net: dsa: rtl8366rb: Support flood control Date: Mon, 30 Aug 2021 23:48:58 +0200 Message-Id: <20210830214859.403100-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210830214859.403100-1-linus.walleij@linaro.org> References: <20210830214859.403100-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 Now that we have implemented bridge flag handling we can easily support flood (storm) control as well so let's do it. Cc: Vladimir Oltean Cc: Alvin Šipraga Cc: Mauri Sandberg Cc: DENG Qingfang Signed-off-by: Linus Walleij Reviewed-by: Alvin Šipraga --- ChangeLog v1->v2: - New patch --- drivers/net/dsa/rtl8366rb.c | 38 ++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index 2cadd3e57e8b..4cb0e336ce6b 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -149,6 +149,11 @@ #define RTL8366RB_VLAN_INGRESS_CTRL2_REG 0x037f +#define RTL8366RB_STORM_BC_CTRL 0x03e0 +#define RTL8366RB_STORM_MC_CTRL 0x03e1 +#define RTL8366RB_STORM_UNDA_CTRL 0x03e2 +#define RTL8366RB_STORM_UNMC_CTRL 0x03e3 + /* LED control registers */ #define RTL8366RB_LED_BLINKRATE_REG 0x0430 #define RTL8366RB_LED_BLINKRATE_MASK 0x0007 @@ -1158,7 +1163,8 @@ rtl8366rb_port_pre_bridge_flags(struct dsa_switch *ds, int port, struct netlink_ext_ack *extack) { /* We support enabling/disabling learning */ - if (flags.mask & ~(BR_LEARNING)) + if (flags.mask & ~(BR_LEARNING | BR_BCAST_FLOOD | + BR_MCAST_FLOOD | BR_FLOOD)) return -EINVAL; return 0; @@ -1180,6 +1186,36 @@ rtl8366rb_port_bridge_flags(struct dsa_switch *ds, int port, return ret; } + if (flags.mask & BR_BCAST_FLOOD) { + ret = regmap_update_bits(smi->map, RTL8366RB_STORM_BC_CTRL, + BIT(port), + (flags.val & BR_BCAST_FLOOD) ? BIT(port) : 0); + if (ret) + return ret; + } + + if (flags.mask & BR_MCAST_FLOOD) { + ret = regmap_update_bits(smi->map, RTL8366RB_STORM_MC_CTRL, + BIT(port), + (flags.val & BR_MCAST_FLOOD) ? BIT(port) : 0); + if (ret) + return ret; + } + + /* Enable/disable both types of unicast floods */ + if (flags.mask & BR_FLOOD) { + ret = regmap_update_bits(smi->map, RTL8366RB_STORM_UNDA_CTRL, + BIT(port), + (flags.val & BR_FLOOD) ? BIT(port) : 0); + if (ret) + return ret; + ret = regmap_update_bits(smi->map, RTL8366RB_STORM_UNMC_CTRL, + BIT(port), + (flags.val & BR_FLOOD) ? BIT(port) : 0); + if (ret) + return ret; + } + return 0; } From patchwork Mon Aug 30 21:48:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 12466039 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 74302C432BE for ; Mon, 30 Aug 2021 21:53:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52A5C60ED8 for ; Mon, 30 Aug 2021 21:53:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238842AbhH3Vxz (ORCPT ); Mon, 30 Aug 2021 17:53:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237167AbhH3Vxv (ORCPT ); Mon, 30 Aug 2021 17:53:51 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBBA1C06175F for ; Mon, 30 Aug 2021 14:52:56 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id f2so28418607ljn.1 for ; Mon, 30 Aug 2021 14:52: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=90s4wpKUIcwIEvdTTZxL4JGPoTprkT4Ft/euRw6mn8k=; b=MHlrErK7NQ3Ky/kK8DzH2Px7FATj7UAsOrCRLH5vTGWa0V2LXb3UhFmH1dLEX+rLui Mk/RDykwIN4Ccv7AkL5GsZCcer4+Hyb3VEv+Zyiqb3awJrofWwFkehOl78NmuJEsQ4OJ gufmSopoedLkVhkY3mxB+WTt7GYKNUxSedxxJk2eX2kIreEonBBYXnb8OgJHi4QDov7n AeRfq4zhmuHdCX2N3VXqy8NDi8W9Dh2ks63DK6kCaAOt/5bBLPvDCkg1D2f3IPK+VcIf faUBZS4JppGIvKQe4BdhxXHE24idvqsogttT80Qxk0QjlAdRc1Xg7H8nVjtNGdTk6J42 4nzQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=90s4wpKUIcwIEvdTTZxL4JGPoTprkT4Ft/euRw6mn8k=; b=fGcUkS2mvy85rqVJ1IR6ig/mhLMB/j4OM4dIq+HnngUycr//SQtPyH9ka9kfjjBTna ZbmJeVemUiOkN81HQ8HpO9im/6s58pL0XfmVf603Cb8FAE2bHYjJJuH4icm3xxZdWUVx Mo52iU3eJgF/6jDMabGh0Fy1UvLtOWdao0d6C55Z49LXYcOXbTTsptJ9ttx+637C1VJt 7XFHnJdibSCD9Ygdy/e8OsseqM/vUtGLprFRher6XgEm5bNP2rkd4BnMlwivqtN8v5oi fV+Z7J7YgxOH70oUFP8QsnRiWdLGRnkbMJqQV7Kr5zRTXumsCB6s4DhQAe+QIBvF3asu eABg== X-Gm-Message-State: AOAM532uldLLYgUPPhzPXlwidrhop6T80ZsrhLrgnHIdRCXWGBDE2Y5I S7kGBMO1LahJIviisEN+AvexDg== X-Google-Smtp-Source: ABdhPJzPxORbmoU7WVlv4KC9wL2YIshT3p+5xKnZ/bx7GEKfXoofQesNnV/sAgd899mewd3L4YpUbQ== X-Received: by 2002:a2e:6808:: with SMTP id c8mr22729019lja.70.1630360375088; Mon, 30 Aug 2021 14:52: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 h4sm1514049lft.184.2021.08.30.14.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 14:52: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 , =?utf-8?q?Alvin_=C5=A0ipraga?= , Mauri Sandberg , DENG Qingfang Subject: [PATCH net-next 5/5 v2] net: dsa: rtl8366rb: Support fast aging Date: Mon, 30 Aug 2021 23:48:59 +0200 Message-Id: <20210830214859.403100-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210830214859.403100-1-linus.walleij@linaro.org> References: <20210830214859.403100-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 implements fast aging per-port using the special "security" register, which will flush any L2 LUTs on a port. Suggested-by: Vladimir Oltean Cc: Alvin Šipraga Cc: Mauri Sandberg Cc: DENG Qingfang Signed-off-by: Linus Walleij Reviewed-by: Alvin Šipraga --- ChangeLog v1->v2: - New patch suggested by Vladimir. --- drivers/net/dsa/rtl8366rb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index 4cb0e336ce6b..548282119cc4 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -1219,6 +1219,19 @@ rtl8366rb_port_bridge_flags(struct dsa_switch *ds, int port, return 0; } +static void +rtl8366rb_port_fast_age(struct dsa_switch *ds, int port) +{ + struct realtek_smi *smi = ds->priv; + + /* This will age out any L2 entries */ + regmap_update_bits(smi->map, RTL8366RB_SECURITY_CTRL, + BIT(port), BIT(port)); + /* Restore the normal state of things */ + regmap_update_bits(smi->map, RTL8366RB_SECURITY_CTRL, + BIT(port), 0); +} + static int rtl8366rb_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *bridge) @@ -1673,6 +1686,7 @@ static const struct dsa_switch_ops rtl8366rb_switch_ops = { .port_disable = rtl8366rb_port_disable, .port_pre_bridge_flags = rtl8366rb_port_pre_bridge_flags, .port_bridge_flags = rtl8366rb_port_bridge_flags, + .port_fast_age = rtl8366rb_port_fast_age, .port_change_mtu = rtl8366rb_change_mtu, .port_max_mtu = rtl8366rb_max_mtu, };