diff mbox series

[net-next,4/6] dpaa2-switch: add support for configuring per port broadcast flooding

Message ID 20210322205859.606704-5-ciorneiioana@gmail.com (mailing list archive)
State Accepted
Commit b54eb093f5ce784ca00170d4512c47cdc755397e
Delegated to: Netdev Maintainers
Headers show
Series dpaa2-switch: offload bridge port flags to device | expand

Checks

Context Check Description
netdev/apply success Patch already applied to net-next
netdev/tree_selection success Clearly marked for net-next

Commit Message

Ioana Ciornei March 22, 2021, 8:58 p.m. UTC
From: Ioana Ciornei <ioana.ciornei@nxp.com>

The BR_BCAST_FLOOD bridge port flag is now accepted by the driver and a
change in its state will determine a reconfiguration of the broadcast
egress flooding list on the FDB associated with the port.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 .../ethernet/freescale/dpaa2/dpaa2-switch.c   | 32 +++++++++++++++++--
 .../ethernet/freescale/dpaa2/dpaa2-switch.h   |  2 +-
 2 files changed, 31 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 2ea3a4dac49d..2ae4faf81b1f 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -127,7 +127,10 @@  static void dpaa2_switch_fdb_get_flood_cfg(struct ethsw_core *ethsw, u16 fdb_id,
 		if (ethsw->ports[j]->fdb->fdb_id != fdb_id)
 			continue;
 
-		cfg->if_id[i++] = ethsw->ports[j]->idx;
+		if (type == DPSW_BROADCAST && ethsw->ports[j]->bcast_flood)
+			cfg->if_id[i++] = ethsw->ports[j]->idx;
+		else if (type == DPSW_FLOODING)
+			cfg->if_id[i++] = ethsw->ports[j]->idx;
 	}
 
 	/* Add the CTRL interface to the egress flooding domain */
@@ -1260,11 +1263,22 @@  static int dpaa2_switch_port_set_learning(struct ethsw_port_priv *port_priv, boo
 	return err;
 }
 
+static int dpaa2_switch_port_flood(struct ethsw_port_priv *port_priv,
+				   struct switchdev_brport_flags flags)
+{
+	struct ethsw_core *ethsw = port_priv->ethsw_data;
+
+	if (flags.mask & BR_BCAST_FLOOD)
+		port_priv->bcast_flood = !!(flags.val & BR_BCAST_FLOOD);
+
+	return dpaa2_switch_fdb_set_egress_flood(ethsw, port_priv->fdb->fdb_id);
+}
+
 static int dpaa2_switch_port_pre_bridge_flags(struct net_device *netdev,
 					      struct switchdev_brport_flags flags,
 					      struct netlink_ext_ack *extack)
 {
-	if (flags.mask & ~(BR_LEARNING))
+	if (flags.mask & ~(BR_LEARNING | BR_BCAST_FLOOD))
 		return -EINVAL;
 
 	return 0;
@@ -1285,6 +1299,12 @@  static int dpaa2_switch_port_bridge_flags(struct net_device *netdev,
 			return err;
 	}
 
+	if (flags.mask & BR_BCAST_FLOOD) {
+		err = dpaa2_switch_port_flood(port_priv, flags);
+		if (err)
+			return err;
+	}
+
 	return 0;
 }
 
@@ -1643,6 +1663,12 @@  static int dpaa2_switch_port_bridge_leave(struct net_device *netdev)
 	if (err)
 		netdev_err(netdev, "Unable to restore RX VLANs to the new FDB, err (%d)\n", err);
 
+	/* Reset the flooding state to denote that this port can send any
+	 * packet in standalone mode. With this, we are also ensuring that any
+	 * later bridge join will have the flooding flag on.
+	 */
+	port_priv->bcast_flood = true;
+
 	/* Setup the egress flood policy (broadcast, unknown unicast).
 	 * When the port is not under a bridge, only the CTRL interface is part
 	 * of the flooding domain besides the actual port
@@ -2728,6 +2754,8 @@  static int dpaa2_switch_probe_port(struct ethsw_core *ethsw,
 
 	port_netdev->needed_headroom = DPAA2_SWITCH_NEEDED_HEADROOM;
 
+	port_priv->bcast_flood = true;
+
 	/* Set MTU limits */
 	port_netdev->min_mtu = ETH_MIN_MTU;
 	port_netdev->max_mtu = ETHSW_MAX_FRAME_LENGTH;
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h
index 933563064015..65ede6036870 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h
@@ -105,13 +105,13 @@  struct ethsw_port_priv {
 	struct ethsw_core	*ethsw_data;
 	u8			link_state;
 	u8			stp_state;
-	bool			flood;
 
 	u8			vlans[VLAN_VID_MASK + 1];
 	u16			pvid;
 	u16			tx_qdid;
 
 	struct dpaa2_switch_fdb	*fdb;
+	bool			bcast_flood;
 };
 
 /* Switch data */