netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/8] dpaa2-switch: small improvements
@ 2023-12-13 12:14 Ioana Ciornei
  2023-12-13 12:14 ` [PATCH net-next v2 1/8] dpaa2-switch: set interface MAC address only on endpoint change Ioana Ciornei
                   ` (7 more replies)
  0 siblings, 8 replies; 19+ messages in thread
From: Ioana Ciornei @ 2023-12-13 12:14 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, netdev; +Cc: Ioana Ciornei

This patch set consists of a series of small improvements on the
dpaa2-switch driver ranging from adding some more verbosity when
encountering errors to reorganizing code to be easily extensible.

Changes in v2:
- No changes to the actual diff, only rephrased some commit messages and
  added more information.

Ioana Ciornei (8):
  dpaa2-switch: set interface MAC address only on endpoint change
  dpaa2-switch: declare the netdev as IFF_LIVE_ADDR_CHANGE capable
  dpaa2-switch: print an error when the vlan is already configured
  dpaa2-switch: add ENDPOINT_CHANGED to the irq_mask
  dpaa2-switch: do not clear any interrupts automatically
  dpaa2-switch: reorganize the [pre]changeupper events
  dpaa2-switch: move a check to the prechangeupper stage
  dpaa2-switch: cleanup the egress flood of an unused FDB

 .../ethernet/freescale/dpaa2/dpaa2-switch.c   | 131 +++++++++++-------
 1 file changed, 84 insertions(+), 47 deletions(-)

-- 
2.34.1


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

* [PATCH net-next v2 1/8] dpaa2-switch: set interface MAC address only on endpoint change
  2023-12-13 12:14 [PATCH net-next v2 0/8] dpaa2-switch: small improvements Ioana Ciornei
@ 2023-12-13 12:14 ` Ioana Ciornei
  2023-12-15 11:57   ` Simon Horman
  2023-12-13 12:14 ` [PATCH net-next v2 2/8] dpaa2-switch: declare the netdev as IFF_LIVE_ADDR_CHANGE capable Ioana Ciornei
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Ioana Ciornei @ 2023-12-13 12:14 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, netdev; +Cc: Ioana Ciornei

There is no point in updating the MAC address of a switch interface each
time the link state changes, this only needs to happen in case the
endpoint changes (the switch interface is [dis]connected from/to a MAC).

Just move the call to dpaa2_switch_port_set_mac_addr() under
DPSW_IRQ_EVENT_ENDPOINT_CHANGED.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
- none

 drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 97d3151076d5..08a4d64c1c7d 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -1523,12 +1523,11 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
 	if_id = (status & 0xFFFF0000) >> 16;
 	port_priv = ethsw->ports[if_id];
 
-	if (status & DPSW_IRQ_EVENT_LINK_CHANGED) {
+	if (status & DPSW_IRQ_EVENT_LINK_CHANGED)
 		dpaa2_switch_port_link_state_update(port_priv->netdev);
-		dpaa2_switch_port_set_mac_addr(port_priv);
-	}
 
 	if (status & DPSW_IRQ_EVENT_ENDPOINT_CHANGED) {
+		dpaa2_switch_port_set_mac_addr(port_priv);
 		/* We can avoid locking because the "endpoint changed" IRQ
 		 * handler is the only one who changes priv->mac at runtime,
 		 * so we are not racing with anyone.
-- 
2.34.1


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

* [PATCH net-next v2 2/8] dpaa2-switch: declare the netdev as IFF_LIVE_ADDR_CHANGE capable
  2023-12-13 12:14 [PATCH net-next v2 0/8] dpaa2-switch: small improvements Ioana Ciornei
  2023-12-13 12:14 ` [PATCH net-next v2 1/8] dpaa2-switch: set interface MAC address only on endpoint change Ioana Ciornei
@ 2023-12-13 12:14 ` Ioana Ciornei
  2023-12-15 11:57   ` Simon Horman
  2023-12-13 12:14 ` [PATCH net-next v2 3/8] dpaa2-switch: print an error when the vlan is already configured Ioana Ciornei
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Ioana Ciornei @ 2023-12-13 12:14 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, netdev; +Cc: Ioana Ciornei

There is no restriction around the change of the MAC address on the
switch ports, thus declare the interface netdevs IFF_LIVE_ADDR_CHANGE
capable.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
- none

 drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 08a4d64c1c7d..5b0ab06b40a7 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -3300,6 +3300,7 @@ static int dpaa2_switch_probe_port(struct ethsw_core *ethsw,
 	port_netdev->features = NETIF_F_HW_VLAN_CTAG_FILTER |
 				NETIF_F_HW_VLAN_STAG_FILTER |
 				NETIF_F_HW_TC;
+	port_netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
 
 	err = dpaa2_switch_port_init(port_priv, port_idx);
 	if (err)
-- 
2.34.1


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

* [PATCH net-next v2 3/8] dpaa2-switch: print an error when the vlan is already configured
  2023-12-13 12:14 [PATCH net-next v2 0/8] dpaa2-switch: small improvements Ioana Ciornei
  2023-12-13 12:14 ` [PATCH net-next v2 1/8] dpaa2-switch: set interface MAC address only on endpoint change Ioana Ciornei
  2023-12-13 12:14 ` [PATCH net-next v2 2/8] dpaa2-switch: declare the netdev as IFF_LIVE_ADDR_CHANGE capable Ioana Ciornei
@ 2023-12-13 12:14 ` Ioana Ciornei
  2023-12-15 11:58   ` Simon Horman
  2023-12-13 12:14 ` [PATCH net-next v2 4/8] dpaa2-switch: add ENDPOINT_CHANGED to the irq_mask Ioana Ciornei
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Ioana Ciornei @ 2023-12-13 12:14 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, netdev; +Cc: Ioana Ciornei

Print a netdev error when we hit a case in which a specific VLAN is
already configured on the port. While at it, change the already existing
netdev_warn into an _err for consistency purposes.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
- add a bit more info in the commit message

 drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 5b0ab06b40a7..654dd10df307 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -289,7 +289,7 @@ static int dpaa2_switch_port_add_vlan(struct ethsw_port_priv *port_priv,
 	int err;
 
 	if (port_priv->vlans[vid]) {
-		netdev_warn(netdev, "VLAN %d already configured\n", vid);
+		netdev_err(netdev, "VLAN %d already configured\n", vid);
 		return -EEXIST;
 	}
 
@@ -1774,8 +1774,10 @@ int dpaa2_switch_port_vlans_add(struct net_device *netdev,
 	/* Make sure that the VLAN is not already configured
 	 * on the switch port
 	 */
-	if (port_priv->vlans[vlan->vid] & ETHSW_VLAN_MEMBER)
+	if (port_priv->vlans[vlan->vid] & ETHSW_VLAN_MEMBER) {
+		netdev_err(netdev, "VLAN %d already configured\n", vlan->vid);
 		return -EEXIST;
+	}
 
 	/* Check if there is space for a new VLAN */
 	err = dpsw_get_attributes(ethsw->mc_io, 0, ethsw->dpsw_handle,
-- 
2.34.1


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

* [PATCH net-next v2 4/8] dpaa2-switch: add ENDPOINT_CHANGED to the irq_mask
  2023-12-13 12:14 [PATCH net-next v2 0/8] dpaa2-switch: small improvements Ioana Ciornei
                   ` (2 preceding siblings ...)
  2023-12-13 12:14 ` [PATCH net-next v2 3/8] dpaa2-switch: print an error when the vlan is already configured Ioana Ciornei
@ 2023-12-13 12:14 ` Ioana Ciornei
  2023-12-15 11:51   ` Simon Horman
  2023-12-13 12:14 ` [PATCH net-next v2 5/8] dpaa2-switch: do not clear any interrupts automatically Ioana Ciornei
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Ioana Ciornei @ 2023-12-13 12:14 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, netdev; +Cc: Ioana Ciornei

The blamed commit added support for MAC endpoints in the dpaa2-switch
driver but omitted to add the ENDPOINT_CHANGED irq to the list of
interrupt sources. Fix this by extending the list of events which can
raise an interrupt by extending the mask passed to the
dpsw_set_irq_mask() firmware API.

There is no user visible impact even without this patch since whenever a
switch interface is connected/disconnected from an endpoint both events
are set (LINK_CHANGED and ENDPOINT_CHANGED) and, luckily, the
LINK_CHANGED event could actually raise the interrupt and thus get the
MAC/PHY SW configuration started.

Even with this, it's better to just not rely on undocumented firmware
behavior which can change.

Fixes: 84cba72956fd ("dpaa2-switch: integrate the MAC endpoint support")
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
- add a bit more info in the commit message

 drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 654dd10df307..e91ade7c7c93 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -1550,9 +1550,9 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
 
 static int dpaa2_switch_setup_irqs(struct fsl_mc_device *sw_dev)
 {
+	u32 mask = DPSW_IRQ_EVENT_LINK_CHANGED | DPSW_IRQ_EVENT_ENDPOINT_CHANGED;
 	struct device *dev = &sw_dev->dev;
 	struct ethsw_core *ethsw = dev_get_drvdata(dev);
-	u32 mask = DPSW_IRQ_EVENT_LINK_CHANGED;
 	struct fsl_mc_device_irq *irq;
 	int err;
 
-- 
2.34.1


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

* [PATCH net-next v2 5/8] dpaa2-switch: do not clear any interrupts automatically
  2023-12-13 12:14 [PATCH net-next v2 0/8] dpaa2-switch: small improvements Ioana Ciornei
                   ` (3 preceding siblings ...)
  2023-12-13 12:14 ` [PATCH net-next v2 4/8] dpaa2-switch: add ENDPOINT_CHANGED to the irq_mask Ioana Ciornei
@ 2023-12-13 12:14 ` Ioana Ciornei
  2023-12-15 11:31   ` Simon Horman
  2023-12-13 12:14 ` [PATCH net-next v2 6/8] dpaa2-switch: reorganize the [pre]changeupper events Ioana Ciornei
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Ioana Ciornei @ 2023-12-13 12:14 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, netdev; +Cc: Ioana Ciornei

The DPSW object has multiple event sources multiplexed over the same
IRQ. The driver has the capability to configure only some of these
events to trigger the IRQ.

The dpsw_get_irq_status() can clear events automatically based on the
value stored in the 'status' variable passed to it. We don't want that
to happen because we could get into a situation when we are clearing
more events than we actually handled.
Just resort to manually clearing the events that we handled.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
- add a bit more info in the commit message

 drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index e91ade7c7c93..d9906573f71f 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -1509,7 +1509,7 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
 	struct device *dev = (struct device *)arg;
 	struct ethsw_core *ethsw = dev_get_drvdata(dev);
 	struct ethsw_port_priv *port_priv;
-	u32 status = ~0;
+	u32 status = 0;
 	int err, if_id;
 	bool had_mac;
 
@@ -1539,12 +1539,12 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
 			dpaa2_switch_port_connect_mac(port_priv);
 	}
 
-out:
 	err = dpsw_clear_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle,
 				    DPSW_IRQ_INDEX_IF, status);
 	if (err)
 		dev_err(dev, "Can't clear irq status (err %d)\n", err);
 
+out:
 	return IRQ_HANDLED;
 }
 
-- 
2.34.1


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

* [PATCH net-next v2 6/8] dpaa2-switch: reorganize the [pre]changeupper events
  2023-12-13 12:14 [PATCH net-next v2 0/8] dpaa2-switch: small improvements Ioana Ciornei
                   ` (4 preceding siblings ...)
  2023-12-13 12:14 ` [PATCH net-next v2 5/8] dpaa2-switch: do not clear any interrupts automatically Ioana Ciornei
@ 2023-12-13 12:14 ` Ioana Ciornei
  2023-12-15 11:49   ` Simon Horman
  2023-12-13 12:14 ` [PATCH net-next v2 7/8] dpaa2-switch: move a check to the prechangeupper stage Ioana Ciornei
  2023-12-13 12:14 ` [PATCH net-next v2 8/8] dpaa2-switch: cleanup the egress flood of an unused FDB Ioana Ciornei
  7 siblings, 1 reply; 19+ messages in thread
From: Ioana Ciornei @ 2023-12-13 12:14 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, netdev; +Cc: Ioana Ciornei

Create separate functions, dpaa2_switch_port_prechangeupper and
dpaa2_switch_port_changeupper, to be called directly when a DPSW port
changes its upper device.

This way we are not open-coding everything in the main event callback
and we can easily extent when necessary.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
- none

 .../ethernet/freescale/dpaa2/dpaa2-switch.c   | 76 +++++++++++++------
 1 file changed, 52 insertions(+), 24 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index d9906573f71f..58c0baee2d61 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -2180,51 +2180,79 @@ dpaa2_switch_prechangeupper_sanity_checks(struct net_device *netdev,
 	return 0;
 }
 
-static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb,
-					     unsigned long event, void *ptr)
+static int dpaa2_switch_port_prechangeupper(struct net_device *netdev,
+					    struct netdev_notifier_changeupper_info *info)
 {
-	struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
-	struct netdev_notifier_changeupper_info *info = ptr;
 	struct netlink_ext_ack *extack;
 	struct net_device *upper_dev;
 	int err = 0;
 
 	if (!dpaa2_switch_port_dev_check(netdev))
-		return NOTIFY_DONE;
+		return 0;
 
 	extack = netdev_notifier_info_to_extack(&info->info);
-
-	switch (event) {
-	case NETDEV_PRECHANGEUPPER:
-		upper_dev = info->upper_dev;
-		if (!netif_is_bridge_master(upper_dev))
-			break;
-
+	upper_dev = info->upper_dev;
+	if (netif_is_bridge_master(upper_dev)) {
 		err = dpaa2_switch_prechangeupper_sanity_checks(netdev,
 								upper_dev,
 								extack);
 		if (err)
-			goto out;
+			return err;
 
 		if (!info->linking)
 			dpaa2_switch_port_pre_bridge_leave(netdev);
+	}
+
+	return 0;
+}
+
+static int dpaa2_switch_port_changeupper(struct net_device *netdev,
+					 struct netdev_notifier_changeupper_info *info)
+{
+	struct netlink_ext_ack *extack;
+	struct net_device *upper_dev;
+	int err = 0;
+
+	if (!dpaa2_switch_port_dev_check(netdev))
+		return 0;
+
+	extack = netdev_notifier_info_to_extack(&info->info);
+
+	upper_dev = info->upper_dev;
+	if (netif_is_bridge_master(upper_dev)) {
+		if (info->linking)
+			return dpaa2_switch_port_bridge_join(netdev,
+							     upper_dev,
+							     extack);
+		else
+			return dpaa2_switch_port_bridge_leave(netdev);
+	}
+
+	return err;
+}
+
+static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb,
+					     unsigned long event, void *ptr)
+{
+	struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
+	int err = 0;
+
+	switch (event) {
+	case NETDEV_PRECHANGEUPPER:
+		err = dpaa2_switch_port_prechangeupper(netdev, ptr);
+		if (err)
+			return notifier_from_errno(err);
 
 		break;
 	case NETDEV_CHANGEUPPER:
-		upper_dev = info->upper_dev;
-		if (netif_is_bridge_master(upper_dev)) {
-			if (info->linking)
-				err = dpaa2_switch_port_bridge_join(netdev,
-								    upper_dev,
-								    extack);
-			else
-				err = dpaa2_switch_port_bridge_leave(netdev);
-		}
+		err = dpaa2_switch_port_changeupper(netdev, ptr);
+		if (err)
+			return notifier_from_errno(err);
+
 		break;
 	}
 
-out:
-	return notifier_from_errno(err);
+	return NOTIFY_DONE;
 }
 
 struct ethsw_switchdev_event_work {
-- 
2.34.1


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

* [PATCH net-next v2 7/8] dpaa2-switch: move a check to the prechangeupper stage
  2023-12-13 12:14 [PATCH net-next v2 0/8] dpaa2-switch: small improvements Ioana Ciornei
                   ` (5 preceding siblings ...)
  2023-12-13 12:14 ` [PATCH net-next v2 6/8] dpaa2-switch: reorganize the [pre]changeupper events Ioana Ciornei
@ 2023-12-13 12:14 ` Ioana Ciornei
  2023-12-15 11:58   ` Simon Horman
  2023-12-13 12:14 ` [PATCH net-next v2 8/8] dpaa2-switch: cleanup the egress flood of an unused FDB Ioana Ciornei
  7 siblings, 1 reply; 19+ messages in thread
From: Ioana Ciornei @ 2023-12-13 12:14 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, netdev; +Cc: Ioana Ciornei

Two different DPAA2 switch ports from two different DPSW instances
cannot be under the same bridge. Instead of checking for this
unsupported configuration in the CHANGEUPPER event, check it as early as
possible in the PRECHANGEUPPER one.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
- none

 .../ethernet/freescale/dpaa2/dpaa2-switch.c   | 31 ++++++++++---------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 58c0baee2d61..dd878e87eef1 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -2008,24 +2008,9 @@ static int dpaa2_switch_port_bridge_join(struct net_device *netdev,
 {
 	struct ethsw_port_priv *port_priv = netdev_priv(netdev);
 	struct ethsw_core *ethsw = port_priv->ethsw_data;
-	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) {
-		if (!dpaa2_switch_port_dev_check(other_dev))
-			continue;
-
-		other_port_priv = netdev_priv(other_dev);
-		if (other_port_priv->ethsw_data != port_priv->ethsw_data) {
-			NL_SET_ERR_MSG_MOD(extack,
-					   "Interface from a different DPSW is in the bridge already");
-			return -EINVAL;
-		}
-	}
-
 	/* Delete the previously manually installed VLAN 1 */
 	err = dpaa2_switch_port_del_vlan(port_priv, 1);
 	if (err)
@@ -2163,6 +2148,10 @@ dpaa2_switch_prechangeupper_sanity_checks(struct net_device *netdev,
 					  struct net_device *upper_dev,
 					  struct netlink_ext_ack *extack)
 {
+	struct ethsw_port_priv *port_priv = netdev_priv(netdev);
+	struct ethsw_port_priv *other_port_priv;
+	struct net_device *other_dev;
+	struct list_head *iter;
 	int err;
 
 	if (!br_vlan_enabled(upper_dev)) {
@@ -2177,6 +2166,18 @@ dpaa2_switch_prechangeupper_sanity_checks(struct net_device *netdev,
 		return 0;
 	}
 
+	netdev_for_each_lower_dev(upper_dev, other_dev, iter) {
+		if (!dpaa2_switch_port_dev_check(other_dev))
+			continue;
+
+		other_port_priv = netdev_priv(other_dev);
+		if (other_port_priv->ethsw_data != port_priv->ethsw_data) {
+			NL_SET_ERR_MSG_MOD(extack,
+					   "Interface from a different DPSW is in the bridge already");
+			return -EINVAL;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.34.1


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

* [PATCH net-next v2 8/8] dpaa2-switch: cleanup the egress flood of an unused FDB
  2023-12-13 12:14 [PATCH net-next v2 0/8] dpaa2-switch: small improvements Ioana Ciornei
                   ` (6 preceding siblings ...)
  2023-12-13 12:14 ` [PATCH net-next v2 7/8] dpaa2-switch: move a check to the prechangeupper stage Ioana Ciornei
@ 2023-12-13 12:14 ` Ioana Ciornei
  2023-12-15 11:58   ` Simon Horman
  7 siblings, 1 reply; 19+ messages in thread
From: Ioana Ciornei @ 2023-12-13 12:14 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, netdev; +Cc: Ioana Ciornei

In case a DPAA2 switch interface joins a bridge, the FDB used on the
port will be changed to the one associated with the bridge. What this
means exactly is that any VLAN installed on the port will need to be
removed and then installed back so that it points to the new FDB.

Once this is done, the previous FDB will become unused (no VLAN to
point to it). Even though no traffic will reach this FDB, it's best to
just cleanup the state of the FDB by zeroing its egress flood domain.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
- add a bit more info in the commit message

 drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index dd878e87eef1..7ff678c759e4 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -2007,6 +2007,7 @@ static int dpaa2_switch_port_bridge_join(struct net_device *netdev,
 					 struct netlink_ext_ack *extack)
 {
 	struct ethsw_port_priv *port_priv = netdev_priv(netdev);
+	struct dpaa2_switch_fdb *old_fdb = port_priv->fdb;
 	struct ethsw_core *ethsw = port_priv->ethsw_data;
 	bool learn_ena;
 	int err;
@@ -2028,6 +2029,11 @@ static int dpaa2_switch_port_bridge_join(struct net_device *netdev,
 	if (err)
 		goto err_egress_flood;
 
+	/* Recreate the egress flood domain of the FDB that we just left. */
+	err = dpaa2_switch_fdb_set_egress_flood(ethsw, old_fdb->fdb_id);
+	if (err)
+		goto err_egress_flood;
+
 	err = switchdev_bridge_port_offload(netdev, netdev, NULL,
 					    &dpaa2_switch_port_switchdev_nb,
 					    &dpaa2_switch_port_switchdev_blocking_nb,
-- 
2.34.1


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

* Re: [PATCH net-next v2 5/8] dpaa2-switch: do not clear any interrupts automatically
  2023-12-13 12:14 ` [PATCH net-next v2 5/8] dpaa2-switch: do not clear any interrupts automatically Ioana Ciornei
@ 2023-12-15 11:31   ` Simon Horman
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Horman @ 2023-12-15 11:31 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, edumazet, kuba, pabeni, netdev

On Wed, Dec 13, 2023 at 02:14:08PM +0200, Ioana Ciornei wrote:
> The DPSW object has multiple event sources multiplexed over the same
> IRQ. The driver has the capability to configure only some of these
> events to trigger the IRQ.
> 
> The dpsw_get_irq_status() can clear events automatically based on the
> value stored in the 'status' variable passed to it. We don't want that
> to happen because we could get into a situation when we are clearing
> more events than we actually handled.
> Just resort to manually clearing the events that we handled.

Hi Ioana,

Continuing the theme of Jakub's review of v1,
I think it would be useful to state that
there is no user-visible effect of this change.
And, ideally, explain why that is so.

> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---
> Changes in v2:
> - add a bit more info in the commit message
> 
>  drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> index e91ade7c7c93..d9906573f71f 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> @@ -1509,7 +1509,7 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
>  	struct device *dev = (struct device *)arg;
>  	struct ethsw_core *ethsw = dev_get_drvdata(dev);
>  	struct ethsw_port_priv *port_priv;
> -	u32 status = ~0;
> +	u32 status = 0;
>  	int err, if_id;
>  	bool had_mac;

As status is no longer used in the 'out' unwind path,
I don't think the initialisation above is needed any more.

	...
	int err, if_id;
	bool had_mac;
	u32 status;

>  
> @@ -1539,12 +1539,12 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
>  			dpaa2_switch_port_connect_mac(port_priv);
>  	}
>  
> -out:
>  	err = dpsw_clear_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle,
>  				    DPSW_IRQ_INDEX_IF, status);
>  	if (err)
>  		dev_err(dev, "Can't clear irq status (err %d)\n", err);
>  
> +out:
>  	return IRQ_HANDLED;
>  }
>  
> -- 
> 2.34.1
> 

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

* Re: [PATCH net-next v2 6/8] dpaa2-switch: reorganize the [pre]changeupper events
  2023-12-13 12:14 ` [PATCH net-next v2 6/8] dpaa2-switch: reorganize the [pre]changeupper events Ioana Ciornei
@ 2023-12-15 11:49   ` Simon Horman
  2023-12-15 12:08     ` Ioana Ciornei
  0 siblings, 1 reply; 19+ messages in thread
From: Simon Horman @ 2023-12-15 11:49 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, edumazet, kuba, pabeni, netdev

On Wed, Dec 13, 2023 at 02:14:09PM +0200, Ioana Ciornei wrote:
> Create separate functions, dpaa2_switch_port_prechangeupper and
> dpaa2_switch_port_changeupper, to be called directly when a DPSW port
> changes its upper device.
> 
> This way we are not open-coding everything in the main event callback
> and we can easily extent when necessary.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---
> Changes in v2:
> - none
> 
>  .../ethernet/freescale/dpaa2/dpaa2-switch.c   | 76 +++++++++++++------
>  1 file changed, 52 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> index d9906573f71f..58c0baee2d61 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> @@ -2180,51 +2180,79 @@ dpaa2_switch_prechangeupper_sanity_checks(struct net_device *netdev,
>  	return 0;
>  }
>  
> -static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb,
> -					     unsigned long event, void *ptr)
> +static int dpaa2_switch_port_prechangeupper(struct net_device *netdev,
> +					    struct netdev_notifier_changeupper_info *info)
>  {
> -	struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
> -	struct netdev_notifier_changeupper_info *info = ptr;
>  	struct netlink_ext_ack *extack;
>  	struct net_device *upper_dev;
>  	int err = 0;

nit: I don't think that err needs to be initialised here.

>  
>  	if (!dpaa2_switch_port_dev_check(netdev))
> -		return NOTIFY_DONE;
> +		return 0;
>  
>  	extack = netdev_notifier_info_to_extack(&info->info);
> -
> -	switch (event) {
> -	case NETDEV_PRECHANGEUPPER:
> -		upper_dev = info->upper_dev;
> -		if (!netif_is_bridge_master(upper_dev))
> -			break;
> -
> +	upper_dev = info->upper_dev;
> +	if (netif_is_bridge_master(upper_dev)) {
>  		err = dpaa2_switch_prechangeupper_sanity_checks(netdev,
>  								upper_dev,
>  								extack);
>  		if (err)
> -			goto out;
> +			return err;
>  
>  		if (!info->linking)
>  			dpaa2_switch_port_pre_bridge_leave(netdev);
> +	}

FWIIW, I think that a more idomatic flow would be to return if
netif_is_bridge_master() is false. Something like this (completely untested!):

	if (!netif_is_bridge_master(upper_dev))
		return 0;

	err = dpaa2_switch_prechangeupper_sanity_checks(netdev, upper_dev,
							extack);
	if (err)
		return err;

	if (!info->linking)
		dpaa2_switch_port_pre_bridge_leave(netdev);

> +
> +	return 0;
> +}
> +
> +static int dpaa2_switch_port_changeupper(struct net_device *netdev,
> +					 struct netdev_notifier_changeupper_info *info)
> +{
> +	struct netlink_ext_ack *extack;
> +	struct net_device *upper_dev;
> +	int err = 0;

nit: I don't think err is needed in this function it's value never changes.

> +
> +	if (!dpaa2_switch_port_dev_check(netdev))
> +		return 0;
> +
> +	extack = netdev_notifier_info_to_extack(&info->info);
> +
> +	upper_dev = info->upper_dev;
> +	if (netif_is_bridge_master(upper_dev)) {
> +		if (info->linking)
> +			return dpaa2_switch_port_bridge_join(netdev,
> +							     upper_dev,
> +							     extack);
> +		else
> +			return dpaa2_switch_port_bridge_leave(netdev);
> +	}
> +
> +	return err;
> +}

In a similar vein to my comment above, FWIIW, I would have
gone for something more like this (completely untested!).

	if (!netif_is_bridge_master(upper_dev))
		return 0;

	if (info->linking)
		return dpaa2_switch_port_bridge_join(netdev, upper_dev,
						     extack);

	return dpaa2_switch_port_bridge_leave(netdev);

> +
> +static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb,
> +					     unsigned long event, void *ptr)
> +{
> +	struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
> +	int err = 0;
> +
> +	switch (event) {
> +	case NETDEV_PRECHANGEUPPER:
> +		err = dpaa2_switch_port_prechangeupper(netdev, ptr);
> +		if (err)
> +			return notifier_from_errno(err);
>  
>  		break;
>  	case NETDEV_CHANGEUPPER:
> -		upper_dev = info->upper_dev;
> -		if (netif_is_bridge_master(upper_dev)) {
> -			if (info->linking)
> -				err = dpaa2_switch_port_bridge_join(netdev,
> -								    upper_dev,
> -								    extack);
> -			else
> -				err = dpaa2_switch_port_bridge_leave(netdev);
> -		}
> +		err = dpaa2_switch_port_changeupper(netdev, ptr);
> +		if (err)
> +			return notifier_from_errno(err);
> +
>  		break;
>  	}
>  
> -out:
> -	return notifier_from_errno(err);
> +	return NOTIFY_DONE;
>  }
>  
>  struct ethsw_switchdev_event_work {
> -- 
> 2.34.1
> 

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

* Re: [PATCH net-next v2 4/8] dpaa2-switch: add ENDPOINT_CHANGED to the irq_mask
  2023-12-13 12:14 ` [PATCH net-next v2 4/8] dpaa2-switch: add ENDPOINT_CHANGED to the irq_mask Ioana Ciornei
@ 2023-12-15 11:51   ` Simon Horman
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Horman @ 2023-12-15 11:51 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, edumazet, kuba, pabeni, netdev

On Wed, Dec 13, 2023 at 02:14:07PM +0200, Ioana Ciornei wrote:
> The blamed commit added support for MAC endpoints in the dpaa2-switch
> driver but omitted to add the ENDPOINT_CHANGED irq to the list of
> interrupt sources. Fix this by extending the list of events which can
> raise an interrupt by extending the mask passed to the
> dpsw_set_irq_mask() firmware API.
> 
> There is no user visible impact even without this patch since whenever a
> switch interface is connected/disconnected from an endpoint both events
> are set (LINK_CHANGED and ENDPOINT_CHANGED) and, luckily, the
> LINK_CHANGED event could actually raise the interrupt and thus get the
> MAC/PHY SW configuration started.
> 
> Even with this, it's better to just not rely on undocumented firmware
> behavior which can change.
> 
> Fixes: 84cba72956fd ("dpaa2-switch: integrate the MAC endpoint support")

Hi Ioana,

As there is no user-visible bug, I think it is better to drop the Fixes tag.

If you want to mention the commit, which is probably a good idea,
then perhaps you can use something like:

   Introduced by commit ...

> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---
> Changes in v2:
> - add a bit more info in the commit message
> 
>  drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> index 654dd10df307..e91ade7c7c93 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> @@ -1550,9 +1550,9 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
>  
>  static int dpaa2_switch_setup_irqs(struct fsl_mc_device *sw_dev)
>  {
> +	u32 mask = DPSW_IRQ_EVENT_LINK_CHANGED | DPSW_IRQ_EVENT_ENDPOINT_CHANGED;
>  	struct device *dev = &sw_dev->dev;
>  	struct ethsw_core *ethsw = dev_get_drvdata(dev);
> -	u32 mask = DPSW_IRQ_EVENT_LINK_CHANGED;
>  	struct fsl_mc_device_irq *irq;
>  	int err;
>  
> -- 
> 2.34.1
> 

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

* Re: [PATCH net-next v2 1/8] dpaa2-switch: set interface MAC address only on endpoint change
  2023-12-13 12:14 ` [PATCH net-next v2 1/8] dpaa2-switch: set interface MAC address only on endpoint change Ioana Ciornei
@ 2023-12-15 11:57   ` Simon Horman
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Horman @ 2023-12-15 11:57 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, edumazet, kuba, pabeni, netdev

On Wed, Dec 13, 2023 at 02:14:04PM +0200, Ioana Ciornei wrote:
> There is no point in updating the MAC address of a switch interface each
> time the link state changes, this only needs to happen in case the
> endpoint changes (the switch interface is [dis]connected from/to a MAC).
> 
> Just move the call to dpaa2_switch_port_set_mac_addr() under
> DPSW_IRQ_EVENT_ENDPOINT_CHANGED.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net-next v2 2/8] dpaa2-switch: declare the netdev as IFF_LIVE_ADDR_CHANGE capable
  2023-12-13 12:14 ` [PATCH net-next v2 2/8] dpaa2-switch: declare the netdev as IFF_LIVE_ADDR_CHANGE capable Ioana Ciornei
@ 2023-12-15 11:57   ` Simon Horman
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Horman @ 2023-12-15 11:57 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, edumazet, kuba, pabeni, netdev

On Wed, Dec 13, 2023 at 02:14:05PM +0200, Ioana Ciornei wrote:
> There is no restriction around the change of the MAC address on the
> switch ports, thus declare the interface netdevs IFF_LIVE_ADDR_CHANGE
> capable.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net-next v2 3/8] dpaa2-switch: print an error when the vlan is already configured
  2023-12-13 12:14 ` [PATCH net-next v2 3/8] dpaa2-switch: print an error when the vlan is already configured Ioana Ciornei
@ 2023-12-15 11:58   ` Simon Horman
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Horman @ 2023-12-15 11:58 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, edumazet, kuba, pabeni, netdev

On Wed, Dec 13, 2023 at 02:14:06PM +0200, Ioana Ciornei wrote:
> Print a netdev error when we hit a case in which a specific VLAN is
> already configured on the port. While at it, change the already existing
> netdev_warn into an _err for consistency purposes.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net-next v2 7/8] dpaa2-switch: move a check to the prechangeupper stage
  2023-12-13 12:14 ` [PATCH net-next v2 7/8] dpaa2-switch: move a check to the prechangeupper stage Ioana Ciornei
@ 2023-12-15 11:58   ` Simon Horman
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Horman @ 2023-12-15 11:58 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, edumazet, kuba, pabeni, netdev

On Wed, Dec 13, 2023 at 02:14:10PM +0200, Ioana Ciornei wrote:
> Two different DPAA2 switch ports from two different DPSW instances
> cannot be under the same bridge. Instead of checking for this
> unsupported configuration in the CHANGEUPPER event, check it as early as
> possible in the PRECHANGEUPPER one.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net-next v2 8/8] dpaa2-switch: cleanup the egress flood of an unused FDB
  2023-12-13 12:14 ` [PATCH net-next v2 8/8] dpaa2-switch: cleanup the egress flood of an unused FDB Ioana Ciornei
@ 2023-12-15 11:58   ` Simon Horman
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Horman @ 2023-12-15 11:58 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, edumazet, kuba, pabeni, netdev

On Wed, Dec 13, 2023 at 02:14:11PM +0200, Ioana Ciornei wrote:
> In case a DPAA2 switch interface joins a bridge, the FDB used on the
> port will be changed to the one associated with the bridge. What this
> means exactly is that any VLAN installed on the port will need to be
> removed and then installed back so that it points to the new FDB.
> 
> Once this is done, the previous FDB will become unused (no VLAN to
> point to it). Even though no traffic will reach this FDB, it's best to
> just cleanup the state of the FDB by zeroing its egress flood domain.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net-next v2 6/8] dpaa2-switch: reorganize the [pre]changeupper events
  2023-12-15 11:49   ` Simon Horman
@ 2023-12-15 12:08     ` Ioana Ciornei
  2023-12-18  8:33       ` Simon Horman
  0 siblings, 1 reply; 19+ messages in thread
From: Ioana Ciornei @ 2023-12-15 12:08 UTC (permalink / raw)
  To: Simon Horman; +Cc: davem, edumazet, kuba, pabeni, netdev

On Fri, Dec 15, 2023 at 11:49:39AM +0000, Simon Horman wrote:
> On Wed, Dec 13, 2023 at 02:14:09PM +0200, Ioana Ciornei wrote:
> > Create separate functions, dpaa2_switch_port_prechangeupper and
> > dpaa2_switch_port_changeupper, to be called directly when a DPSW port
> > changes its upper device.
> > 
> > This way we are not open-coding everything in the main event callback
> > and we can easily extent when necessary.
> > 
> > Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> > ---
> > Changes in v2:
> > - none
> > 
> >  .../ethernet/freescale/dpaa2/dpaa2-switch.c   | 76 +++++++++++++------
> >  1 file changed, 52 insertions(+), 24 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> > index d9906573f71f..58c0baee2d61 100644
> > --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> > +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> > @@ -2180,51 +2180,79 @@ dpaa2_switch_prechangeupper_sanity_checks(struct net_device *netdev,
> >  	return 0;
> >  }
> >  
> > -static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb,
> > -					     unsigned long event, void *ptr)
> > +static int dpaa2_switch_port_prechangeupper(struct net_device *netdev,
> > +					    struct netdev_notifier_changeupper_info *info)
> >  {
> > -	struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
> > -	struct netdev_notifier_changeupper_info *info = ptr;
> >  	struct netlink_ext_ack *extack;
> >  	struct net_device *upper_dev;
> >  	int err = 0;
> 
> nit: I don't think that err needs to be initialised here.
> 

Ok.

> >  
> >  	if (!dpaa2_switch_port_dev_check(netdev))
> > -		return NOTIFY_DONE;
> > +		return 0;
> >  
> >  	extack = netdev_notifier_info_to_extack(&info->info);
> > -
> > -	switch (event) {
> > -	case NETDEV_PRECHANGEUPPER:
> > -		upper_dev = info->upper_dev;
> > -		if (!netif_is_bridge_master(upper_dev))
> > -			break;
> > -
> > +	upper_dev = info->upper_dev;
> > +	if (netif_is_bridge_master(upper_dev)) {
> >  		err = dpaa2_switch_prechangeupper_sanity_checks(netdev,
> >  								upper_dev,
> >  								extack);
> >  		if (err)
> > -			goto out;
> > +			return err;
> >  
> >  		if (!info->linking)
> >  			dpaa2_switch_port_pre_bridge_leave(netdev);
> > +	}
> 
> FWIIW, I think that a more idomatic flow would be to return if
> netif_is_bridge_master() is false. Something like this (completely untested!):
> 
> 	if (!netif_is_bridge_master(upper_dev))
> 		return 0;
> 
> 	err = dpaa2_switch_prechangeupper_sanity_checks(netdev, upper_dev,
> 							extack);
> 	if (err)
> 		return err;
> 
> 	if (!info->linking)
> 		dpaa2_switch_port_pre_bridge_leave(netdev);
> 

It looks better but I don't think this it's easily extensible.

I am planning to add support for LAG offloading which would mean that I
would have to revert to the initial flow and extend it to something
like:

	if (netif_is_bridge_master(upper_dev)) {
		...
	} else if (netif_is_lag_master(upper_dev)) {
		...
	}

The same thing applies to the dpaa2_switch_port_changeupper() function
below.

> > +
> > +	return 0;
> > +}
> > +
> > +static int dpaa2_switch_port_changeupper(struct net_device *netdev,
> > +					 struct netdev_notifier_changeupper_info *info)
> > +{
> > +	struct netlink_ext_ack *extack;
> > +	struct net_device *upper_dev;
> > +	int err = 0;
> 
> nit: I don't think err is needed in this function it's value never changes.
> 

Yes, indeed. I'll remove it.

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

* Re: [PATCH net-next v2 6/8] dpaa2-switch: reorganize the [pre]changeupper events
  2023-12-15 12:08     ` Ioana Ciornei
@ 2023-12-18  8:33       ` Simon Horman
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Horman @ 2023-12-18  8:33 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, edumazet, kuba, pabeni, netdev

On Fri, Dec 15, 2023 at 02:08:51PM +0200, Ioana Ciornei wrote:
> On Fri, Dec 15, 2023 at 11:49:39AM +0000, Simon Horman wrote:
> > On Wed, Dec 13, 2023 at 02:14:09PM +0200, Ioana Ciornei wrote:

...

> > >  	if (!dpaa2_switch_port_dev_check(netdev))
> > > -		return NOTIFY_DONE;
> > > +		return 0;
> > >  
> > >  	extack = netdev_notifier_info_to_extack(&info->info);
> > > -
> > > -	switch (event) {
> > > -	case NETDEV_PRECHANGEUPPER:
> > > -		upper_dev = info->upper_dev;
> > > -		if (!netif_is_bridge_master(upper_dev))
> > > -			break;
> > > -
> > > +	upper_dev = info->upper_dev;
> > > +	if (netif_is_bridge_master(upper_dev)) {
> > >  		err = dpaa2_switch_prechangeupper_sanity_checks(netdev,
> > >  								upper_dev,
> > >  								extack);
> > >  		if (err)
> > > -			goto out;
> > > +			return err;
> > >  
> > >  		if (!info->linking)
> > >  			dpaa2_switch_port_pre_bridge_leave(netdev);
> > > +	}
> > 
> > FWIIW, I think that a more idomatic flow would be to return if
> > netif_is_bridge_master() is false. Something like this (completely untested!):
> > 
> > 	if (!netif_is_bridge_master(upper_dev))
> > 		return 0;
> > 
> > 	err = dpaa2_switch_prechangeupper_sanity_checks(netdev, upper_dev,
> > 							extack);
> > 	if (err)
> > 		return err;
> > 
> > 	if (!info->linking)
> > 		dpaa2_switch_port_pre_bridge_leave(netdev);
> > 
> 
> It looks better but I don't think this it's easily extensible.
> 
> I am planning to add support for LAG offloading which would mean that I
> would have to revert to the initial flow and extend it to something
> like:
> 
> 	if (netif_is_bridge_master(upper_dev)) {
> 		...
> 	} else if (netif_is_lag_master(upper_dev)) {
> 		...
> 	}
> 
> The same thing applies to the dpaa2_switch_port_changeupper() function
> below.

Understood. If this is going somewhere then don't let me derail it.

,,,

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

end of thread, other threads:[~2023-12-18  8:33 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-13 12:14 [PATCH net-next v2 0/8] dpaa2-switch: small improvements Ioana Ciornei
2023-12-13 12:14 ` [PATCH net-next v2 1/8] dpaa2-switch: set interface MAC address only on endpoint change Ioana Ciornei
2023-12-15 11:57   ` Simon Horman
2023-12-13 12:14 ` [PATCH net-next v2 2/8] dpaa2-switch: declare the netdev as IFF_LIVE_ADDR_CHANGE capable Ioana Ciornei
2023-12-15 11:57   ` Simon Horman
2023-12-13 12:14 ` [PATCH net-next v2 3/8] dpaa2-switch: print an error when the vlan is already configured Ioana Ciornei
2023-12-15 11:58   ` Simon Horman
2023-12-13 12:14 ` [PATCH net-next v2 4/8] dpaa2-switch: add ENDPOINT_CHANGED to the irq_mask Ioana Ciornei
2023-12-15 11:51   ` Simon Horman
2023-12-13 12:14 ` [PATCH net-next v2 5/8] dpaa2-switch: do not clear any interrupts automatically Ioana Ciornei
2023-12-15 11:31   ` Simon Horman
2023-12-13 12:14 ` [PATCH net-next v2 6/8] dpaa2-switch: reorganize the [pre]changeupper events Ioana Ciornei
2023-12-15 11:49   ` Simon Horman
2023-12-15 12:08     ` Ioana Ciornei
2023-12-18  8:33       ` Simon Horman
2023-12-13 12:14 ` [PATCH net-next v2 7/8] dpaa2-switch: move a check to the prechangeupper stage Ioana Ciornei
2023-12-15 11:58   ` Simon Horman
2023-12-13 12:14 ` [PATCH net-next v2 8/8] dpaa2-switch: cleanup the egress flood of an unused FDB Ioana Ciornei
2023-12-15 11:58   ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).