Skip to content

Commit

Permalink
dpaa2-switch: setup learning state on STP state change
Browse files Browse the repository at this point in the history
Depending on what STP state a port is in, the learning on that port
should be enabled or disabled.

When the STP state is DISABLED, BLOCKING or LISTENING no learning should
be happening irrespective of what the bridge previously requested. The
learning state is changed to be the one setup by the bridge when the STP
state is LEARNING or FORWARDING.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ioana Ciornei authored and David S. Miller committed Mar 31, 2021
1 parent 1a64ed1 commit bc96781
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1250,14 +1250,6 @@ static void dpaa2_switch_teardown_irqs(struct fsl_mc_device *sw_dev)
fsl_mc_free_irqs(sw_dev);
}

static int dpaa2_switch_port_attr_stp_state_set(struct net_device *netdev,
u8 state)
{
struct ethsw_port_priv *port_priv = netdev_priv(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;
Expand All @@ -1280,6 +1272,32 @@ static int dpaa2_switch_port_set_learning(struct ethsw_port_priv *port_priv, boo
return err;
}

static int dpaa2_switch_port_attr_stp_state_set(struct net_device *netdev,
u8 state)
{
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
int err;

err = dpaa2_switch_port_set_stp_state(port_priv, state);
if (err)
return err;

switch (state) {
case BR_STATE_DISABLED:
case BR_STATE_BLOCKING:
case BR_STATE_LISTENING:
err = dpaa2_switch_port_set_learning(port_priv, false);
break;
case BR_STATE_LEARNING:
case BR_STATE_FORWARDING:
err = dpaa2_switch_port_set_learning(port_priv,
port_priv->learn_ena);
break;
}

return err;
}

static int dpaa2_switch_port_flood(struct ethsw_port_priv *port_priv,
struct switchdev_brport_flags flags)
{
Expand Down

0 comments on commit bc96781

Please sign in to comment.