All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/6] dpaa2-switch: offload bridge port flags to device
@ 2021-03-22 20:58 Ioana Ciornei
  2021-03-22 20:58 ` [PATCH net-next 1/6] dpaa2-switch: move the dpaa2_switch_fdb_set_egress_flood function Ioana Ciornei
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Ioana Ciornei @ 2021-03-22 20:58 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: andrew, f.fainelli, olteanv, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

Add support for offloading bridge port flags to the switch. With this
patch set, the learning, broadcast flooding and unknown ucast/mcast
flooding states will be user configurable.

Apart from that, the last patch is a small fix that configures the
offload_fwd_mark if the switch port is under a bridge or not.

Ioana Ciornei (6):
  dpaa2-switch: move the dpaa2_switch_fdb_set_egress_flood function
  dpaa2-switch: refactor the egress flooding domain setup
  dpaa2-switch: add support for configuring learning state per port
  dpaa2-switch: add support for configuring per port broadcast flooding
  dpaa2-switch: add support for configuring per port unknown flooding
  dpaa2-switch: mark skbs with offload_fwd_mark

 .../ethernet/freescale/dpaa2/dpaa2-switch.c   | 214 ++++++++++++++----
 .../ethernet/freescale/dpaa2/dpaa2-switch.h   |   3 +-
 .../net/ethernet/freescale/dpaa2/dpsw-cmd.h   |  10 +
 drivers/net/ethernet/freescale/dpaa2/dpsw.c   |  27 +++
 drivers/net/ethernet/freescale/dpaa2/dpsw.h   |  25 +-
 5 files changed, 225 insertions(+), 54 deletions(-)

-- 
2.30.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net-next 1/6] dpaa2-switch: move the dpaa2_switch_fdb_set_egress_flood function
  2021-03-22 20:58 [PATCH net-next 0/6] dpaa2-switch: offload bridge port flags to device Ioana Ciornei
@ 2021-03-22 20:58 ` Ioana Ciornei
  2021-03-22 20:58 ` [PATCH net-next 2/6] dpaa2-switch: refactor the egress flooding domain setup Ioana Ciornei
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Ioana Ciornei @ 2021-03-22 20:58 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: andrew, f.fainelli, olteanv, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

In order to avoid a forward declaration in the next patches, move the
dpaa2_switch_fdb_set_egress_flood() function to the top of the file.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 .../ethernet/freescale/dpaa2/dpaa2-switch.c   | 84 +++++++++----------
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 2fd05dd18d46..5254eae5c86a 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -110,6 +110,48 @@ static u16 dpaa2_switch_port_set_fdb(struct ethsw_port_priv *port_priv,
 	return 0;
 }
 
+static int dpaa2_switch_fdb_set_egress_flood(struct ethsw_core *ethsw, u16 fdb_id)
+{
+	struct dpsw_egress_flood_cfg flood_cfg;
+	int i = 0, j;
+	int err;
+
+	/* Add all the DPAA2 switch ports found in the same bridging domain to
+	 * the egress flooding domain
+	 */
+	for (j = 0; j < ethsw->sw_attr.num_ifs; j++)
+		if (ethsw->ports[j] && ethsw->ports[j]->fdb->fdb_id == fdb_id)
+			flood_cfg.if_id[i++] = ethsw->ports[j]->idx;
+
+	/* Add the CTRL interface to the egress flooding domain */
+	flood_cfg.if_id[i++] = ethsw->sw_attr.num_ifs;
+
+	/* Use the FDB of the first dpaa2 switch port added to the bridge */
+	flood_cfg.fdb_id = fdb_id;
+
+	/* Setup broadcast flooding domain */
+	flood_cfg.flood_type = DPSW_BROADCAST;
+	flood_cfg.num_ifs = i;
+	err = dpsw_set_egress_flood(ethsw->mc_io, 0, ethsw->dpsw_handle,
+				    &flood_cfg);
+	if (err) {
+		dev_err(ethsw->dev, "dpsw_set_egress_flood() = %d\n", err);
+		return err;
+	}
+
+	/* Setup unknown flooding domain */
+	flood_cfg.flood_type = DPSW_FLOODING;
+	flood_cfg.num_ifs = i;
+	err = dpsw_set_egress_flood(ethsw->mc_io, 0, ethsw->dpsw_handle,
+				    &flood_cfg);
+	if (err) {
+		dev_err(ethsw->dev, "dpsw_set_egress_flood() = %d\n", err);
+		return err;
+	}
+
+	return 0;
+}
+
 static void *dpaa2_iova_to_virt(struct iommu_domain *domain,
 				dma_addr_t iova_addr)
 {
@@ -1442,48 +1484,6 @@ static int dpaa2_switch_port_attr_set_event(struct net_device *netdev,
 	return notifier_from_errno(err);
 }
 
-static int dpaa2_switch_fdb_set_egress_flood(struct ethsw_core *ethsw, u16 fdb_id)
-{
-	struct dpsw_egress_flood_cfg flood_cfg;
-	int i = 0, j;
-	int err;
-
-	/* Add all the DPAA2 switch ports found in the same bridging domain to
-	 * the egress flooding domain
-	 */
-	for (j = 0; j < ethsw->sw_attr.num_ifs; j++)
-		if (ethsw->ports[j] && ethsw->ports[j]->fdb->fdb_id == fdb_id)
-			flood_cfg.if_id[i++] = ethsw->ports[j]->idx;
-
-	/* Add the CTRL interface to the egress flooding domain */
-	flood_cfg.if_id[i++] = ethsw->sw_attr.num_ifs;
-
-	/* Use the FDB of the first dpaa2 switch port added to the bridge */
-	flood_cfg.fdb_id = fdb_id;
-
-	/* Setup broadcast flooding domain */
-	flood_cfg.flood_type = DPSW_BROADCAST;
-	flood_cfg.num_ifs = i;
-	err = dpsw_set_egress_flood(ethsw->mc_io, 0, ethsw->dpsw_handle,
-				    &flood_cfg);
-	if (err) {
-		dev_err(ethsw->dev, "dpsw_set_egress_flood() = %d\n", err);
-		return err;
-	}
-
-	/* Setup unknown flooding domain */
-	flood_cfg.flood_type = DPSW_FLOODING;
-	flood_cfg.num_ifs = i;
-	err = dpsw_set_egress_flood(ethsw->mc_io, 0, ethsw->dpsw_handle,
-				    &flood_cfg);
-	if (err) {
-		dev_err(ethsw->dev, "dpsw_set_egress_flood() = %d\n", err);
-		return err;
-	}
-
-	return 0;
-}
-
 static int dpaa2_switch_port_bridge_join(struct net_device *netdev,
 					 struct net_device *upper_dev)
 {
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next 2/6] dpaa2-switch: refactor the egress flooding domain setup
  2021-03-22 20:58 [PATCH net-next 0/6] dpaa2-switch: offload bridge port flags to device Ioana Ciornei
  2021-03-22 20:58 ` [PATCH net-next 1/6] dpaa2-switch: move the dpaa2_switch_fdb_set_egress_flood function Ioana Ciornei
@ 2021-03-22 20:58 ` Ioana Ciornei
  2021-03-22 20:58 ` [PATCH net-next 3/6] dpaa2-switch: add support for configuring learning state per port Ioana Ciornei
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Ioana Ciornei @ 2021-03-22 20:58 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: andrew, f.fainelli, olteanv, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

Extract the code that determines the list of egress flood interfaces for
a specific flood type into a new function -
dpaa2_switch_fdb_get_flood_cfg().

This will help us to not duplicate code when the broadcast and
unknown ucast/mcast flooding domains will be individually configurable.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 .../ethernet/freescale/dpaa2/dpaa2-switch.c   | 38 ++++++++++++-------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 5254eae5c86a..2db9cd78201d 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -110,28 +110,41 @@ static u16 dpaa2_switch_port_set_fdb(struct ethsw_port_priv *port_priv,
 	return 0;
 }
 
-static int dpaa2_switch_fdb_set_egress_flood(struct ethsw_core *ethsw, u16 fdb_id)
+static void dpaa2_switch_fdb_get_flood_cfg(struct ethsw_core *ethsw, u16 fdb_id,
+					   enum dpsw_flood_type type,
+					   struct dpsw_egress_flood_cfg *cfg)
 {
-	struct dpsw_egress_flood_cfg flood_cfg;
 	int i = 0, j;
-	int err;
+
+	memset(cfg, 0, sizeof(*cfg));
 
 	/* Add all the DPAA2 switch ports found in the same bridging domain to
 	 * the egress flooding domain
 	 */
-	for (j = 0; j < ethsw->sw_attr.num_ifs; j++)
-		if (ethsw->ports[j] && ethsw->ports[j]->fdb->fdb_id == fdb_id)
-			flood_cfg.if_id[i++] = ethsw->ports[j]->idx;
+	for (j = 0; j < ethsw->sw_attr.num_ifs; j++) {
+		if (!ethsw->ports[j])
+			continue;
+		if (ethsw->ports[j]->fdb->fdb_id != fdb_id)
+			continue;
+
+		cfg->if_id[i++] = ethsw->ports[j]->idx;
+	}
 
 	/* Add the CTRL interface to the egress flooding domain */
-	flood_cfg.if_id[i++] = ethsw->sw_attr.num_ifs;
+	cfg->if_id[i++] = ethsw->sw_attr.num_ifs;
+
+	cfg->fdb_id = fdb_id;
+	cfg->flood_type = type;
+	cfg->num_ifs = i;
+}
 
-	/* Use the FDB of the first dpaa2 switch port added to the bridge */
-	flood_cfg.fdb_id = fdb_id;
+static int dpaa2_switch_fdb_set_egress_flood(struct ethsw_core *ethsw, u16 fdb_id)
+{
+	struct dpsw_egress_flood_cfg flood_cfg;
+	int err;
 
 	/* Setup broadcast flooding domain */
-	flood_cfg.flood_type = DPSW_BROADCAST;
-	flood_cfg.num_ifs = i;
+	dpaa2_switch_fdb_get_flood_cfg(ethsw, fdb_id, DPSW_BROADCAST, &flood_cfg);
 	err = dpsw_set_egress_flood(ethsw->mc_io, 0, ethsw->dpsw_handle,
 				    &flood_cfg);
 	if (err) {
@@ -140,8 +153,7 @@ static int dpaa2_switch_fdb_set_egress_flood(struct ethsw_core *ethsw, u16 fdb_i
 	}
 
 	/* Setup unknown flooding domain */
-	flood_cfg.flood_type = DPSW_FLOODING;
-	flood_cfg.num_ifs = i;
+	dpaa2_switch_fdb_get_flood_cfg(ethsw, fdb_id, DPSW_FLOODING, &flood_cfg);
 	err = dpsw_set_egress_flood(ethsw->mc_io, 0, ethsw->dpsw_handle,
 				    &flood_cfg);
 	if (err) {
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next 3/6] dpaa2-switch: add support for configuring learning state per port
  2021-03-22 20:58 [PATCH net-next 0/6] dpaa2-switch: offload bridge port flags to device Ioana Ciornei
  2021-03-22 20:58 ` [PATCH net-next 1/6] dpaa2-switch: move the dpaa2_switch_fdb_set_egress_flood function Ioana Ciornei
  2021-03-22 20:58 ` [PATCH net-next 2/6] dpaa2-switch: refactor the egress flooding domain setup Ioana Ciornei
@ 2021-03-22 20:58 ` Ioana Ciornei
  2021-03-22 20:58 ` [PATCH net-next 4/6] dpaa2-switch: add support for configuring per port broadcast flooding Ioana Ciornei
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Ioana Ciornei @ 2021-03-22 20:58 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: andrew, f.fainelli, olteanv, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

Add support for configuring the learning state of a switch port.
When the user requests the HW learning to be disabled, a fast-age
procedure on that specific port is run so that previously learnt
addresses do not linger.

At device probe as well as on a bridge leave action, the ports are
configured with HW learning disabled since they are basically a
standalone port.

At the same time, at bridge join we inherit the bridge port BR_LEARNING
flag state and configure it on the switch port.

There were already some MC firmware ABI functions for changing the
learning state, but those were per FDB (bridging domain) and not per
port so we need to adjust those to use the new MC fw command which is
per port.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 .../ethernet/freescale/dpaa2/dpaa2-switch.c   | 70 +++++++++++++++++++
 .../net/ethernet/freescale/dpaa2/dpsw-cmd.h   | 10 +++
 drivers/net/ethernet/freescale/dpaa2/dpsw.c   | 27 +++++++
 drivers/net/ethernet/freescale/dpaa2/dpsw.h   | 25 ++++---
 4 files changed, 121 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 2db9cd78201d..2ea3a4dac49d 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -1238,6 +1238,56 @@ static int dpaa2_switch_port_attr_stp_state_set(struct net_device *netdev,
 	return dpaa2_switch_port_set_stp_state(port_priv, state);
 }
 
+static int dpaa2_switch_port_set_learning(struct ethsw_port_priv *port_priv, bool enable)
+{
+	struct ethsw_core *ethsw = port_priv->ethsw_data;
+	enum dpsw_learning_mode learn_mode;
+	int err;
+
+	if (enable)
+		learn_mode = DPSW_LEARNING_MODE_HW;
+	else
+		learn_mode = DPSW_LEARNING_MODE_DIS;
+
+	err = dpsw_if_set_learning_mode(ethsw->mc_io, 0, ethsw->dpsw_handle,
+					port_priv->idx, learn_mode);
+	if (err)
+		netdev_err(port_priv->netdev, "dpsw_if_set_learning_mode err %d\n", err);
+
+	if (!enable)
+		dpaa2_switch_port_fast_age(port_priv);
+
+	return err;
+}
+
+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))
+		return -EINVAL;
+
+	return 0;
+}
+
+static int dpaa2_switch_port_bridge_flags(struct net_device *netdev,
+					  struct switchdev_brport_flags flags,
+					  struct netlink_ext_ack *extack)
+{
+	struct ethsw_port_priv *port_priv = netdev_priv(netdev);
+	int err;
+
+	if (flags.mask & BR_LEARNING) {
+		bool learn_ena = !!(flags.val & BR_LEARNING);
+
+		err = dpaa2_switch_port_set_learning(port_priv, learn_ena);
+		if (err)
+			return err;
+	}
+
+	return 0;
+}
+
 static int dpaa2_switch_port_attr_set(struct net_device *netdev,
 				      const struct switchdev_attr *attr,
 				      struct netlink_ext_ack *extack)
@@ -1256,6 +1306,12 @@ static int dpaa2_switch_port_attr_set(struct net_device *netdev,
 			return -EOPNOTSUPP;
 		}
 		break;
+	case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS:
+		err = dpaa2_switch_port_pre_bridge_flags(netdev, attr->u.brport_flags, extack);
+		break;
+	case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
+		err = dpaa2_switch_port_bridge_flags(netdev, attr->u.brport_flags, extack);
+		break;
 	default:
 		err = -EOPNOTSUPP;
 		break;
@@ -1504,6 +1560,7 @@ static int dpaa2_switch_port_bridge_join(struct net_device *netdev,
 	struct ethsw_port_priv *other_port_priv;
 	struct net_device *other_dev;
 	struct list_head *iter;
+	bool learn_ena;
 	int err;
 
 	netdev_for_each_lower_dev(upper_dev, other_dev, iter) {
@@ -1525,6 +1582,10 @@ static int dpaa2_switch_port_bridge_join(struct net_device *netdev,
 
 	dpaa2_switch_port_set_fdb(port_priv, upper_dev);
 
+	/* Inherit the initial bridge port learning state */
+	learn_ena = br_port_flag_is_set(netdev, BR_LEARNING);
+	err = dpaa2_switch_port_set_learning(port_priv, learn_ena);
+
 	/* Setup the egress flood policy (broadcast, unknown unicast) */
 	err = dpaa2_switch_fdb_set_egress_flood(ethsw, port_priv->fdb->fdb_id);
 	if (err)
@@ -1595,6 +1656,11 @@ static int dpaa2_switch_port_bridge_leave(struct net_device *netdev)
 	if (err)
 		return err;
 
+	/* No HW learning when not under a bridge */
+	err = dpaa2_switch_port_set_learning(port_priv, false);
+	if (err)
+		return err;
+
 	/* Add the VLAN 1 as PVID when not under a bridge. We need this since
 	 * the dpaa2 switch interfaces are not capable to be VLAN unaware
 	 */
@@ -2684,6 +2750,10 @@ static int dpaa2_switch_probe_port(struct ethsw_core *ethsw,
 	if (err)
 		goto err_port_probe;
 
+	err = dpaa2_switch_port_set_learning(port_priv, false);
+	if (err)
+		goto err_port_probe;
+
 	return 0;
 
 err_port_probe:
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpsw-cmd.h b/drivers/net/ethernet/freescale/dpaa2/dpsw-cmd.h
index 996a59dcd01d..24b17d6e09af 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpsw-cmd.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpsw-cmd.h
@@ -83,6 +83,7 @@
 #define DPSW_CMDID_CTRL_IF_SET_QUEUE        DPSW_CMD_ID(0x0A6)
 
 #define DPSW_CMDID_SET_EGRESS_FLOOD         DPSW_CMD_ID(0x0AC)
+#define DPSW_CMDID_IF_SET_LEARNING_MODE     DPSW_CMD_ID(0x0AD)
 
 /* Macros for accessing command fields smaller than 1byte */
 #define DPSW_MASK(field)        \
@@ -447,5 +448,14 @@ struct dpsw_cmd_set_egress_flood {
 	u8 pad[5];
 	__le64 if_id;
 };
+
+#define DPSW_LEARNING_MODE_SHIFT	0
+#define DPSW_LEARNING_MODE_SIZE		4
+
+struct dpsw_cmd_if_set_learning_mode {
+	__le16 if_id;
+	/* only the first 4 bits from LSB */
+	u8 mode;
+};
 #pragma pack(pop)
 #endif /* __FSL_DPSW_CMD_H */
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpsw.c b/drivers/net/ethernet/freescale/dpaa2/dpsw.c
index 56f3c23fce07..6c787d4b85f9 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpsw.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpsw.c
@@ -1327,3 +1327,30 @@ int dpsw_set_egress_flood(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
 
 	return mc_send_command(mc_io, &cmd);
 }
+
+/**
+ * dpsw_if_set_learning_mode() - Configure the learning mode on an interface.
+ * If this API is used, it will take precedence over the FDB configuration.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPSW object
+ * @if_id:	InterfaceID
+ * @mode:	Learning mode
+ *
+ * Return:	Completion status. '0' on Success; Error code otherwise.
+ */
+int dpsw_if_set_learning_mode(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
+			      u16 if_id, enum dpsw_learning_mode mode)
+{
+	struct dpsw_cmd_if_set_learning_mode *cmd_params;
+	struct fsl_mc_command cmd = { 0 };
+
+	cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_LEARNING_MODE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpsw_cmd_if_set_learning_mode *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	dpsw_set_field(cmd_params->mode, LEARNING_MODE, mode);
+
+	return mc_send_command(mc_io, &cmd);
+}
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpsw.h b/drivers/net/ethernet/freescale/dpaa2/dpsw.h
index f108cc61bb27..96837b10cc94 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpsw.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpsw.h
@@ -532,11 +532,11 @@ int dpsw_fdb_remove_multicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
 			      u16 fdb_id, const struct dpsw_fdb_multicast_cfg *cfg);
 
 /**
- * enum dpsw_fdb_learning_mode - Auto-learning modes
- * @DPSW_FDB_LEARNING_MODE_DIS: Disable Auto-learning
- * @DPSW_FDB_LEARNING_MODE_HW: Enable HW auto-Learning
- * @DPSW_FDB_LEARNING_MODE_NON_SECURE: Enable None secure learning by CPU
- * @DPSW_FDB_LEARNING_MODE_SECURE: Enable secure learning by CPU
+ * enum dpsw_learning_mode - Auto-learning modes
+ * @DPSW_LEARNING_MODE_DIS: Disable Auto-learning
+ * @DPSW_LEARNING_MODE_HW: Enable HW auto-Learning
+ * @DPSW_LEARNING_MODE_NON_SECURE: Enable None secure learning by CPU
+ * @DPSW_LEARNING_MODE_SECURE: Enable secure learning by CPU
  *
  *	NONE - SECURE LEARNING
  *	SMAC found	DMAC found	CTLU Action
@@ -561,11 +561,11 @@ int dpsw_fdb_remove_multicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
  *	-		-		Forward frame to
  *						1.  Control interface
  */
-enum dpsw_fdb_learning_mode {
-	DPSW_FDB_LEARNING_MODE_DIS = 0,
-	DPSW_FDB_LEARNING_MODE_HW = 1,
-	DPSW_FDB_LEARNING_MODE_NON_SECURE = 2,
-	DPSW_FDB_LEARNING_MODE_SECURE = 3
+enum dpsw_learning_mode {
+	DPSW_LEARNING_MODE_DIS = 0,
+	DPSW_LEARNING_MODE_HW = 1,
+	DPSW_LEARNING_MODE_NON_SECURE = 2,
+	DPSW_LEARNING_MODE_SECURE = 3
 };
 
 /**
@@ -579,7 +579,7 @@ enum dpsw_fdb_learning_mode {
 struct dpsw_fdb_attr {
 	u16 max_fdb_entries;
 	u16 fdb_ageing_time;
-	enum dpsw_fdb_learning_mode learning_mode;
+	enum dpsw_learning_mode learning_mode;
 	u16 num_fdb_mc_groups;
 	u16 max_fdb_mc_groups;
 };
@@ -625,4 +625,7 @@ struct dpsw_egress_flood_cfg {
 int dpsw_set_egress_flood(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
 			  const struct dpsw_egress_flood_cfg *cfg);
 
+int dpsw_if_set_learning_mode(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
+			      u16 if_id, enum dpsw_learning_mode mode);
+
 #endif /* __FSL_DPSW_H */
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next 4/6] dpaa2-switch: add support for configuring per port broadcast flooding
  2021-03-22 20:58 [PATCH net-next 0/6] dpaa2-switch: offload bridge port flags to device Ioana Ciornei
                   ` (2 preceding siblings ...)
  2021-03-22 20:58 ` [PATCH net-next 3/6] dpaa2-switch: add support for configuring learning state per port Ioana Ciornei
@ 2021-03-22 20:58 ` Ioana Ciornei
  2021-03-22 20:58 ` [PATCH net-next 5/6] dpaa2-switch: add support for configuring per port unknown flooding Ioana Ciornei
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Ioana Ciornei @ 2021-03-22 20:58 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: andrew, f.fainelli, olteanv, Ioana Ciornei

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 --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 */
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next 5/6] dpaa2-switch: add support for configuring per port unknown flooding
  2021-03-22 20:58 [PATCH net-next 0/6] dpaa2-switch: offload bridge port flags to device Ioana Ciornei
                   ` (3 preceding siblings ...)
  2021-03-22 20:58 ` [PATCH net-next 4/6] dpaa2-switch: add support for configuring per port broadcast flooding Ioana Ciornei
@ 2021-03-22 20:58 ` Ioana Ciornei
  2021-03-22 20:58 ` [PATCH net-next 6/6] dpaa2-switch: mark skbs with offload_fwd_mark Ioana Ciornei
  2021-03-22 23:50 ` [PATCH net-next 0/6] dpaa2-switch: offload bridge port flags to device patchwork-bot+netdevbpf
  6 siblings, 0 replies; 8+ messages in thread
From: Ioana Ciornei @ 2021-03-22 20:58 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: andrew, f.fainelli, olteanv, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

Add support for configuring per port unknown flooding by accepting both
BR_FLOOD and BR_MCAST_FLOOD as offloadable bridge port flags.

The DPAA2 switch does not support at the moment configuration of unknown
multicast flooding independently of unknown unicast flooding, therefore
check that both BR_FLOOD and BR_MCAST_FLOOD have the same state.

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

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 2ae4faf81b1f..9f1a59219435 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -129,7 +129,7 @@ static void dpaa2_switch_fdb_get_flood_cfg(struct ethsw_core *ethsw, u16 fdb_id,
 
 		if (type == DPSW_BROADCAST && ethsw->ports[j]->bcast_flood)
 			cfg->if_id[i++] = ethsw->ports[j]->idx;
-		else if (type == DPSW_FLOODING)
+		else if (type == DPSW_FLOODING && ethsw->ports[j]->ucast_flood)
 			cfg->if_id[i++] = ethsw->ports[j]->idx;
 	}
 
@@ -1271,6 +1271,9 @@ static int dpaa2_switch_port_flood(struct ethsw_port_priv *port_priv,
 	if (flags.mask & BR_BCAST_FLOOD)
 		port_priv->bcast_flood = !!(flags.val & BR_BCAST_FLOOD);
 
+	if (flags.mask & BR_FLOOD)
+		port_priv->ucast_flood = !!(flags.val & BR_FLOOD);
+
 	return dpaa2_switch_fdb_set_egress_flood(ethsw, port_priv->fdb->fdb_id);
 }
 
@@ -1278,9 +1281,21 @@ 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 | BR_BCAST_FLOOD))
+	if (flags.mask & ~(BR_LEARNING | BR_BCAST_FLOOD | BR_FLOOD |
+			   BR_MCAST_FLOOD))
 		return -EINVAL;
 
+	if (flags.mask & (BR_FLOOD | BR_MCAST_FLOOD)) {
+		bool multicast = !!(flags.val & BR_MCAST_FLOOD);
+		bool unicast = !!(flags.val & BR_FLOOD);
+
+		if (unicast != multicast) {
+			NL_SET_ERR_MSG_MOD(extack,
+					   "Cannot configure multicast flooding independently of unicast");
+			return -EINVAL;
+		}
+	}
+
 	return 0;
 }
 
@@ -1299,7 +1314,7 @@ static int dpaa2_switch_port_bridge_flags(struct net_device *netdev,
 			return err;
 	}
 
-	if (flags.mask & BR_BCAST_FLOOD) {
+	if (flags.mask & (BR_BCAST_FLOOD | BR_FLOOD | BR_MCAST_FLOOD)) {
 		err = dpaa2_switch_port_flood(port_priv, flags);
 		if (err)
 			return err;
@@ -1668,6 +1683,7 @@ static int dpaa2_switch_port_bridge_leave(struct net_device *netdev)
 	 * later bridge join will have the flooding flag on.
 	 */
 	port_priv->bcast_flood = true;
+	port_priv->ucast_flood = true;
 
 	/* Setup the egress flood policy (broadcast, unknown unicast).
 	 * When the port is not under a bridge, only the CTRL interface is part
@@ -2755,6 +2771,7 @@ static int dpaa2_switch_probe_port(struct ethsw_core *ethsw,
 	port_netdev->needed_headroom = DPAA2_SWITCH_NEEDED_HEADROOM;
 
 	port_priv->bcast_flood = true;
+	port_priv->ucast_flood = true;
 
 	/* Set MTU limits */
 	port_netdev->min_mtu = ETH_MIN_MTU;
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h
index 65ede6036870..549218994243 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h
@@ -112,6 +112,7 @@ struct ethsw_port_priv {
 
 	struct dpaa2_switch_fdb	*fdb;
 	bool			bcast_flood;
+	bool			ucast_flood;
 };
 
 /* Switch data */
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next 6/6] dpaa2-switch: mark skbs with offload_fwd_mark
  2021-03-22 20:58 [PATCH net-next 0/6] dpaa2-switch: offload bridge port flags to device Ioana Ciornei
                   ` (4 preceding siblings ...)
  2021-03-22 20:58 ` [PATCH net-next 5/6] dpaa2-switch: add support for configuring per port unknown flooding Ioana Ciornei
@ 2021-03-22 20:58 ` Ioana Ciornei
  2021-03-22 23:50 ` [PATCH net-next 0/6] dpaa2-switch: offload bridge port flags to device patchwork-bot+netdevbpf
  6 siblings, 0 replies; 8+ messages in thread
From: Ioana Ciornei @ 2021-03-22 20:58 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: andrew, f.fainelli, olteanv, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

If a switch port is under a bridge, the offload_fwd_mark should be setup
before sending the skb towards the stack so that the bridge does not try
to flood the packet on the other switch ports.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 9f1a59219435..a9b30a72ddad 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -2005,6 +2005,9 @@ static void dpaa2_switch_rx(struct dpaa2_switch_fq *fq,
 	skb->dev = netdev;
 	skb->protocol = eth_type_trans(skb, skb->dev);
 
+	/* Setup the offload_fwd_mark only if the port is under a bridge */
+	skb->offload_fwd_mark = !!(port_priv->fdb->bridge_dev);
+
 	netif_receive_skb(skb);
 
 	return;
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 0/6] dpaa2-switch: offload bridge port flags to device
  2021-03-22 20:58 [PATCH net-next 0/6] dpaa2-switch: offload bridge port flags to device Ioana Ciornei
                   ` (5 preceding siblings ...)
  2021-03-22 20:58 ` [PATCH net-next 6/6] dpaa2-switch: mark skbs with offload_fwd_mark Ioana Ciornei
@ 2021-03-22 23:50 ` patchwork-bot+netdevbpf
  6 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-22 23:50 UTC (permalink / raw)
  To: Ioana Ciornei
  Cc: davem, kuba, netdev, andrew, f.fainelli, olteanv, ioana.ciornei

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Mon, 22 Mar 2021 22:58:53 +0200 you wrote:
> From: Ioana Ciornei <ioana.ciornei@nxp.com>
> 
> Add support for offloading bridge port flags to the switch. With this
> patch set, the learning, broadcast flooding and unknown ucast/mcast
> flooding states will be user configurable.
> 
> Apart from that, the last patch is a small fix that configures the
> offload_fwd_mark if the switch port is under a bridge or not.
> 
> [...]

Here is the summary with links:
  - [net-next,1/6] dpaa2-switch: move the dpaa2_switch_fdb_set_egress_flood function
    https://git.kernel.org/netdev/net-next/c/c7e856c85981
  - [net-next,2/6] dpaa2-switch: refactor the egress flooding domain setup
    https://git.kernel.org/netdev/net-next/c/f054e3e217e4
  - [net-next,3/6] dpaa2-switch: add support for configuring learning state per port
    https://git.kernel.org/netdev/net-next/c/1e7cbabfdb12
  - [net-next,4/6] dpaa2-switch: add support for configuring per port broadcast flooding
    https://git.kernel.org/netdev/net-next/c/b54eb093f5ce
  - [net-next,5/6] dpaa2-switch: add support for configuring per port unknown flooding
    https://git.kernel.org/netdev/net-next/c/6253d5e39ce2
  - [net-next,6/6] dpaa2-switch: mark skbs with offload_fwd_mark
    https://git.kernel.org/netdev/net-next/c/b175dfd7e691

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-22 23:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22 20:58 [PATCH net-next 0/6] dpaa2-switch: offload bridge port flags to device Ioana Ciornei
2021-03-22 20:58 ` [PATCH net-next 1/6] dpaa2-switch: move the dpaa2_switch_fdb_set_egress_flood function Ioana Ciornei
2021-03-22 20:58 ` [PATCH net-next 2/6] dpaa2-switch: refactor the egress flooding domain setup Ioana Ciornei
2021-03-22 20:58 ` [PATCH net-next 3/6] dpaa2-switch: add support for configuring learning state per port Ioana Ciornei
2021-03-22 20:58 ` [PATCH net-next 4/6] dpaa2-switch: add support for configuring per port broadcast flooding Ioana Ciornei
2021-03-22 20:58 ` [PATCH net-next 5/6] dpaa2-switch: add support for configuring per port unknown flooding Ioana Ciornei
2021-03-22 20:58 ` [PATCH net-next 6/6] dpaa2-switch: mark skbs with offload_fwd_mark Ioana Ciornei
2021-03-22 23:50 ` [PATCH net-next 0/6] dpaa2-switch: offload bridge port flags to device patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.