From: Luiz Angelo Daros de Luca <luizluca@gmail.com>
To: "Andrew Lunn" <andrew@lunn.ch>,
"Vladimir Oltean" <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Simon Horman" <horms@kernel.org>,
"Linus Walleij" <linusw@kernel.org>,
"Alvin Šipraga" <alsi@bang-olufsen.dk>,
"Yury Norov" <yury.norov@gmail.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Russell King" <linux@armlinux.org.uk>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Luiz Angelo Daros de Luca <luizluca@gmail.com>
Subject: [net-next PATCH 09/10] net: dsa: realtek: rtl8365mb: add bridge port flags
Date: Tue, 31 Mar 2026 20:00:09 -0300 [thread overview]
Message-ID: <20260331-realtek_forward-v1-9-44fb63033b7e@gmail.com> (raw)
In-Reply-To: <20260331-realtek_forward-v1-0-44fb63033b7e@gmail.com>
From: Alvin Šipraga <alsi@bang-olufsen.dk>
Add bridge port flags for:
- BR_LEARNING
- BR_FLOOD
- BR_MCAST_FLOOD
- BR_BCAST_FLOOD
Co-developed-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
---
drivers/net/dsa/realtek/rtl8365mb_main.c | 125 +++++++++++++++++++++++++++++++
1 file changed, 125 insertions(+)
diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
index 0767b2704ad7..b26335c5b27e 100644
--- a/drivers/net/dsa/realtek/rtl8365mb_main.c
+++ b/drivers/net/dsa/realtek/rtl8365mb_main.c
@@ -302,6 +302,21 @@
#define RTL8365MB_MSTI_CTRL_PORT_STATE_MASK(_physport) \
(0x3 << RTL8365MB_MSTI_CTRL_PORT_STATE_OFFSET((_physport)))
+/* Unknown unicast DA flooding port mask */
+#define RTL8365MB_UNKNOWN_UNICAST_FLOODING_PMASK_REG 0x0890
+#define RTL8365MB_UNKNOWN_UNICAST_FLOODING_PMASK_MASK 0x07FF
+
+/* Unknown multicast DA flooding port mask */
+#define RTL8365MB_UNKNOWN_MULTICAST_FLOODING_PMASK_REG 0x0891
+#define RTL8365MB_UNKNOWN_MULTICAST_FLOODING_PMASK_MASK 0x07FF
+
+/* Broadcast flooding port mask */
+#define RTL8365MB_UNKNOWN_BROADCAST_FLOODING_PMASK_REG 0x0892
+#define RTL8365MB_UNKNOWN_BROADCAST_FLOODING_PMASK_MASK 0x07FF
+
+#define RTL8365MB_SUPPORTED_BRIDGE_FLAGS \
+ (BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD)
+
/* Miscellaneous port configuration register, incl. VLAN egress mode */
#define RTL8365MB_PORT_MISC_CFG_REG_BASE 0x000E
#define RTL8365MB_PORT_MISC_CFG_REG(_p) \
@@ -1641,6 +1656,97 @@ static int rtl8365mb_port_set_learning(struct realtek_priv *priv, int port,
enable ? RTL8365MB_LEARN_LIMIT_MAX : 0);
}
+static int rtl8365mb_port_set_ucast_flood(struct realtek_priv *priv, int port,
+ bool enable)
+{
+ /* Frames with unknown unicast DA will be flooded to a programmable
+ * port mask that by default includes all ports. Add or remove
+ * the specified port from this port mask accordingly.
+ */
+ return regmap_update_bits(priv->map,
+ RTL8365MB_UNKNOWN_UNICAST_FLOODING_PMASK_REG,
+ BIT(port), enable ? BIT(port) : 0);
+}
+
+static int rtl8365mb_port_set_mcast_flood(struct realtek_priv *priv, int port,
+ bool enable)
+{
+ return regmap_update_bits(priv->map,
+ RTL8365MB_UNKNOWN_MULTICAST_FLOODING_PMASK_REG,
+ BIT(port), enable ? BIT(port) : 0);
+}
+
+static int rtl8365mb_port_set_bcast_flood(struct realtek_priv *priv, int port,
+ bool enable)
+{
+ return regmap_update_bits(priv->map,
+ RTL8365MB_UNKNOWN_BROADCAST_FLOODING_PMASK_REG,
+ BIT(port), enable ? BIT(port) : 0);
+}
+
+static int rtl8365mb_port_pre_bridge_flags(struct dsa_switch *ds, int port,
+ struct switchdev_brport_flags flags,
+ struct netlink_ext_ack *extack)
+{
+ struct realtek_priv *priv = ds->priv;
+
+ dev_dbg(priv->dev, "pre_bridge_flags port:%d flags:%lx supported:%lx",
+ port, flags.mask, RTL8365MB_SUPPORTED_BRIDGE_FLAGS);
+
+ if (flags.mask & ~RTL8365MB_SUPPORTED_BRIDGE_FLAGS)
+ return -EINVAL;
+
+ return 0;
+}
+
+static int rtl8365mb_port_bridge_flags(struct dsa_switch *ds, int port,
+ struct switchdev_brport_flags flags,
+ struct netlink_ext_ack *exack)
+{
+ struct realtek_priv *priv = ds->priv;
+ int ret;
+
+ dev_dbg(priv->dev, "port_bridge_flags port:%d flags:%lx supported:%lx",
+ port, flags.mask, RTL8365MB_SUPPORTED_BRIDGE_FLAGS);
+
+ if (flags.mask & BR_LEARNING) {
+ bool learning_en = !!(flags.val & BR_LEARNING);
+
+ ret = rtl8365mb_port_set_learning(priv, port, learning_en);
+ if (ret)
+ return ret;
+ }
+
+ if (flags.mask & BR_FLOOD) {
+ bool ucast_flood_en = !!(flags.val & BR_FLOOD);
+
+ ret = rtl8365mb_port_set_ucast_flood(priv, port,
+ ucast_flood_en);
+ if (ret)
+ return ret;
+ }
+
+ if (flags.mask & BR_MCAST_FLOOD) {
+ bool mcast_flood_en = !!(flags.val & BR_MCAST_FLOOD);
+
+ ret = rtl8365mb_port_set_mcast_flood(priv, port,
+ mcast_flood_en);
+ if (ret)
+ return ret;
+ }
+
+ if (flags.mask & BR_BCAST_FLOOD) {
+ bool bcast_flood_en = !!(flags.val & BR_BCAST_FLOOD);
+
+ ret = rtl8365mb_port_set_bcast_flood(priv, port,
+ bcast_flood_en);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
static int rtl8365mb_port_set_efid(struct realtek_priv *priv, int port,
u32 efid)
{
@@ -1691,6 +1797,8 @@ static int rtl8365mb_port_bridge_join(struct dsa_switch *ds, int port,
int ret;
int i;
+ dev_dbg(priv->dev, "bridge %d join port %d\n", port, bridge.num);
+
/* Add this port to the isolation group of every other port
* offloading this bridge.
*/
@@ -1730,6 +1838,8 @@ static void rtl8365mb_port_bridge_leave(struct dsa_switch *ds, int port,
u32 mask = 0;
int i;
+ dev_dbg(priv->dev, "bridge %d leave port %d\n", port, bridge.num);
+
/* Remove this port from the isolation group of every other
* port offloading this bridge.
*/
@@ -2547,6 +2657,19 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
if (ret)
goto out_teardown_irq;
+ /* Enable all types of flooding */
+ ret = rtl8365mb_port_set_ucast_flood(priv, i, true);
+ if (ret)
+ goto out_teardown_irq;
+
+ ret = rtl8365mb_port_set_mcast_flood(priv, i, true);
+ if (ret)
+ goto out_teardown_irq;
+
+ ret = rtl8365mb_port_set_bcast_flood(priv, i, true);
+ if (ret)
+ goto out_teardown_irq;
+
/* Set up per-port private data */
p->priv = priv;
p->index = i;
@@ -2686,6 +2809,8 @@ static const struct dsa_switch_ops rtl8365mb_switch_ops = {
.phylink_get_caps = rtl8365mb_phylink_get_caps,
.port_bridge_join = rtl8365mb_port_bridge_join,
.port_bridge_leave = rtl8365mb_port_bridge_leave,
+ .port_pre_bridge_flags = rtl8365mb_port_pre_bridge_flags,
+ .port_bridge_flags = rtl8365mb_port_bridge_flags,
.port_stp_state_set = rtl8365mb_port_stp_state_set,
.port_fast_age = rtl8365mb_port_fast_age,
.port_fdb_add = rtl8365mb_port_fdb_add,
--
2.53.0
next prev parent reply other threads:[~2026-03-31 23:01 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 23:00 [net-next PATCH 00/10] net: dsa: realtek: rtl8365mb: bridge offloading and VLAN support Luiz Angelo Daros de Luca
2026-03-31 23:00 ` [net-next PATCH 01/10] net: dsa: tag_rtl8_4: update format description Luiz Angelo Daros de Luca
2026-03-31 23:00 ` [net-next PATCH 02/10] net: dsa: realtek: rtl8365mb: set STP state to disabled early Luiz Angelo Daros de Luca
2026-03-31 23:00 ` [net-next PATCH 03/10] net: dsa: realtek: rtl8365mb: prepare for multiple source files Luiz Angelo Daros de Luca
2026-03-31 23:00 ` [net-next PATCH 04/10] bitfield.h: add FIELD_WIDTH() Luiz Angelo Daros de Luca
2026-04-01 2:15 ` Yury Norov
2026-04-02 4:00 ` Luiz Angelo Daros de Luca
2026-04-02 9:27 ` David Laight
2026-04-02 13:52 ` Yury Norov
2026-04-02 22:21 ` David Laight
2026-04-03 14:09 ` Luiz Angelo Daros de Luca
2026-04-03 16:18 ` Yury Norov
2026-04-04 14:54 ` David Laight
2026-04-04 15:12 ` David Laight
2026-04-02 13:45 ` Yury Norov
2026-03-31 23:00 ` [net-next PATCH 05/10] net: dsa: realtek: rtl8365mb: add table lookup interface Luiz Angelo Daros de Luca
2026-03-31 23:00 ` [net-next PATCH 06/10] net: dsa: realtek: rtl8365mb: add VLAN support Luiz Angelo Daros de Luca
2026-04-01 2:27 ` Yury Norov
2026-04-02 2:45 ` Luiz Angelo Daros de Luca
2026-04-02 14:22 ` Yury Norov
2026-03-31 23:00 ` [net-next PATCH 07/10] net: dsa: realtek: rtl8365mb: add port_bridge_{join,leave} Luiz Angelo Daros de Luca
2026-03-31 23:00 ` [net-next PATCH 08/10] net: dsa: realtek: rtl8365mb: add FDB support Luiz Angelo Daros de Luca
2026-03-31 23:00 ` Luiz Angelo Daros de Luca [this message]
2026-03-31 23:00 ` [net-next PATCH 10/10] net: dsa: tag_rtl8_4: set KEEP flag Luiz Angelo Daros de Luca
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260331-realtek_forward-v1-9-44fb63033b7e@gmail.com \
--to=luizluca@gmail.com \
--cc=alsi@bang-olufsen.dk \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linux@rasmusvillemoes.dk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox