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: 504342 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp2191565jai; Mon, 30 Aug 2021 14:53:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznQwoS3V5zVpBiW/bMOoaVDLlFMe+TAOZ7gRowKLfoLgkc0+R+koONYoEY/UTHtvXugPkp X-Received: by 2002:a5e:8349:: with SMTP id y9mr14594913iom.34.1630360379982; Mon, 30 Aug 2021 14:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630360379; cv=none; d=google.com; s=arc-20160816; b=NLltIJDVQVFW9Xpd9eAIG/sqQCMYvaTEhg1/kx76JbdXxMI28MEeWMqFY5itGhkyi0 qJDbvuKAGB4WR/iLr5kdnFPVoyjqVZFuNcbPtNwRPVL/HDxL1gagyE/IYOnqDWQXk6Bi R0osar+MzpscfbWZKBgI00k3dJ0WSXadDk1PUldkAP5AE//lL/5d3xFD8YjOaGWP8vnL QIflmKZH5yyGS+Ho6ZfmvmhCr1u0eiKeXhsOJTy8aS9ip53SXZC1rdK0f6IPt4Yx8d4J 3OjDrpK0wI1z9ZQftM82+SyjZXRqnZDXoYxrBxu/6/AlSPmnHlSJqZmUgstbj2Z/tAga +OBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eSR/6/R7THpAwy4A0msHNf8bOj6o29f7fnPgnd1UmSA=; b=WKizE+H/erFddD9E5LCu5GfI6V5r1DE1emRiXAxBmxmfzEpq/NS5jE42GfQzRDzlRg Vps81LuHV4jmQhKfcsqhZ2rT7rNpOlqf914mToW+f3yJ3+/O2j2BTbKDrt3H90skugUJ hFBY6iNN94ka6ijNhOHS6e/Lvib0fUbV0FQzGZwFDFPFzbaAAOAqgz0wRvdg0/09Co45 9sNH7Y5mCTuQMatphnFDcGZK2j27ZHVUBP/+k+T19HK3tJ+JBoIXEhC+oJMM/VlGY4sp 4F7PeLQRecpn2RKSq9SFdI6gQyTk6jl38BmGwIQo0bfhfab/iXcUAibMEKalxq83roiy 479A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q5CoBlQG; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h10si15195253ioe.21.2021.08.30.14.52.59; Mon, 30 Aug 2021 14:52:59 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q5CoBlQG; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238820AbhH3Vxw (ORCPT + 8 others); 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-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 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 --- ChangeLog v1->v2: - New patch --- drivers/net/dsa/rtl8366rb.c | 38 ++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) -- 2.31.1 Reviewed-by: Alvin Šipraga 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; }