Re: [PATCH net-next 2/3] net: dsa: qca8k: factor out bridge join/leave logic

From: Vladimir Oltean
Date: Fri Jun 21 2024 - 12:48:23 EST


On Thu, Jun 20, 2024 at 07:25:49PM +0200, Matthias Schiffer wrote:
> diff --git a/drivers/net/dsa/qca/qca8k-common.c b/drivers/net/dsa/qca/qca8k-common.c
> index b33df84070d3..09108fa99dbe 100644
> --- a/drivers/net/dsa/qca/qca8k-common.c
> +++ b/drivers/net/dsa/qca/qca8k-common.c
> @@ -614,6 +614,49 @@ void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)
> qca8k_port_configure_learning(ds, port, learning);
> }
>
> +static int qca8k_update_port_member(struct qca8k_priv *priv, int port,
> + const struct net_device *bridge_dev,
> + bool join)
> +{
> + struct dsa_port *dp = dsa_to_port(priv->ds, port), *other_dp;
> + u32 port_mask = BIT(dp->cpu_dp->index);
> + int i, ret;
> +
> + for (i = 0; i < QCA8K_NUM_PORTS; i++) {
> + if (i == port)
> + continue;
> + if (dsa_is_cpu_port(priv->ds, i))
> + continue;
> +
> + other_dp = dsa_to_port(priv->ds, i);

I would have liked to see less of the "dsa_to_port() in a loop"
antipattern.
https://lore.kernel.org/netdev/20211018152136.2595220-7-vladimir.oltean@xxxxxxx/T/

I'll send a patch which refactors the new function to use
dsa_switch_for_each_user_port().