Commit 4a5b85ff authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller

net: dsa: use dsa_is_user_port everywhere

Most of the DSA code still check ds->enabled_port_mask directly to
inspect a given port type instead of using the provided dsa_is_user_port
helper. Change this.
Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2b3e9891
...@@ -652,8 +652,7 @@ static int bcm_sf2_sw_suspend(struct dsa_switch *ds) ...@@ -652,8 +652,7 @@ static int bcm_sf2_sw_suspend(struct dsa_switch *ds)
* bcm_sf2_sw_setup * bcm_sf2_sw_setup
*/ */
for (port = 0; port < DSA_MAX_PORTS; port++) { for (port = 0; port < DSA_MAX_PORTS; port++) {
if ((1 << port) & ds->enabled_port_mask || if (dsa_is_user_port(ds, port) || dsa_is_cpu_port(ds, port))
dsa_is_cpu_port(ds, port))
bcm_sf2_port_disable(ds, port, NULL); bcm_sf2_port_disable(ds, port, NULL);
} }
...@@ -676,7 +675,7 @@ static int bcm_sf2_sw_resume(struct dsa_switch *ds) ...@@ -676,7 +675,7 @@ static int bcm_sf2_sw_resume(struct dsa_switch *ds)
bcm_sf2_gphy_enable_set(ds, true); bcm_sf2_gphy_enable_set(ds, true);
for (port = 0; port < DSA_MAX_PORTS; port++) { for (port = 0; port < DSA_MAX_PORTS; port++) {
if ((1 << port) & ds->enabled_port_mask) if (dsa_is_user_port(ds, port))
bcm_sf2_port_setup(ds, port, NULL); bcm_sf2_port_setup(ds, port, NULL);
else if (dsa_is_cpu_port(ds, port)) else if (dsa_is_cpu_port(ds, port))
bcm_sf2_imp_setup(ds, port); bcm_sf2_imp_setup(ds, port);
...@@ -771,7 +770,7 @@ static void bcm_sf2_sw_configure_vlan(struct dsa_switch *ds) ...@@ -771,7 +770,7 @@ static void bcm_sf2_sw_configure_vlan(struct dsa_switch *ds)
bcm_sf2_vlan_op(priv, ARLA_VTBL_CMD_CLEAR); bcm_sf2_vlan_op(priv, ARLA_VTBL_CMD_CLEAR);
for (port = 0; port < priv->hw_params.num_ports; port++) { for (port = 0; port < priv->hw_params.num_ports; port++) {
if (!((1 << port) & ds->enabled_port_mask)) if (!dsa_is_user_port(ds, port))
continue; continue;
core_writel(priv, 1, CORE_DEFAULT_1Q_TAG_P(port)); core_writel(priv, 1, CORE_DEFAULT_1Q_TAG_P(port));
...@@ -786,7 +785,7 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds) ...@@ -786,7 +785,7 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
/* Enable all valid ports and disable those unused */ /* Enable all valid ports and disable those unused */
for (port = 0; port < priv->hw_params.num_ports; port++) { for (port = 0; port < priv->hw_params.num_ports; port++) {
/* IMP port receives special treatment */ /* IMP port receives special treatment */
if ((1 << port) & ds->enabled_port_mask) if (dsa_is_user_port(ds, port))
bcm_sf2_port_setup(ds, port, NULL); bcm_sf2_port_setup(ds, port, NULL);
else if (dsa_is_cpu_port(ds, port)) else if (dsa_is_cpu_port(ds, port))
bcm_sf2_imp_setup(ds, port); bcm_sf2_imp_setup(ds, port);
......
...@@ -750,7 +750,7 @@ static int bcm_sf2_cfp_rule_set(struct dsa_switch *ds, int port, ...@@ -750,7 +750,7 @@ static int bcm_sf2_cfp_rule_set(struct dsa_switch *ds, int port,
port_num = fs->ring_cookie / SF2_NUM_EGRESS_QUEUES; port_num = fs->ring_cookie / SF2_NUM_EGRESS_QUEUES;
if (fs->ring_cookie == RX_CLS_FLOW_DISC || if (fs->ring_cookie == RX_CLS_FLOW_DISC ||
!(BIT(port_num) & ds->enabled_port_mask) || !dsa_is_user_port(ds, port_num) ||
port_num >= priv->hw_params.num_ports) port_num >= priv->hw_params.num_ports)
return -EINVAL; return -EINVAL;
/* /*
......
...@@ -781,7 +781,7 @@ mt7530_port_bridge_join(struct dsa_switch *ds, int port, ...@@ -781,7 +781,7 @@ mt7530_port_bridge_join(struct dsa_switch *ds, int port,
* same bridge. If the port is disabled, port matrix is kept * same bridge. If the port is disabled, port matrix is kept
* and not being setup until the port becomes enabled. * and not being setup until the port becomes enabled.
*/ */
if (ds->enabled_port_mask & BIT(i) && i != port) { if (dsa_is_user_port(ds, i) && i != port) {
if (dsa_to_port(ds, i)->bridge_dev != bridge) if (dsa_to_port(ds, i)->bridge_dev != bridge)
continue; continue;
if (priv->ports[i].enable) if (priv->ports[i].enable)
...@@ -818,7 +818,7 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port, ...@@ -818,7 +818,7 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port,
* in the same bridge. If the port is disabled, port matrix * in the same bridge. If the port is disabled, port matrix
* is kept and not being setup until the port becomes enabled. * is kept and not being setup until the port becomes enabled.
*/ */
if (ds->enabled_port_mask & BIT(i) && i != port) { if (dsa_is_user_port(ds, i) && i != port) {
if (dsa_to_port(ds, i)->bridge_dev != bridge) if (dsa_to_port(ds, i)->bridge_dev != bridge)
continue; continue;
if (priv->ports[i].enable) if (priv->ports[i].enable)
......
...@@ -536,7 +536,7 @@ qca8k_setup(struct dsa_switch *ds) ...@@ -536,7 +536,7 @@ qca8k_setup(struct dsa_switch *ds)
/* Disable MAC by default on all user ports */ /* Disable MAC by default on all user ports */
for (i = 1; i < QCA8K_NUM_PORTS; i++) for (i = 1; i < QCA8K_NUM_PORTS; i++)
if (ds->enabled_port_mask & BIT(i)) if (dsa_is_user_port(ds, i))
qca8k_port_set_status(priv, i, 0); qca8k_port_set_status(priv, i, 0);
/* Forward all unknown frames to CPU port for Linux processing */ /* Forward all unknown frames to CPU port for Linux processing */
...@@ -556,7 +556,7 @@ qca8k_setup(struct dsa_switch *ds) ...@@ -556,7 +556,7 @@ qca8k_setup(struct dsa_switch *ds)
} }
/* Invividual user ports get connected to CPU port only */ /* Invividual user ports get connected to CPU port only */
if (ds->enabled_port_mask & BIT(i)) { if (dsa_is_user_port(ds, i)) {
int shift = 16 * (i % 2); int shift = 16 * (i % 2);
qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(i), qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(i),
......
...@@ -201,7 +201,7 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -201,7 +201,7 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static bool dsa_is_port_initialized(struct dsa_switch *ds, int p) static bool dsa_is_port_initialized(struct dsa_switch *ds, int p)
{ {
return ds->enabled_port_mask & (1 << p) && ds->ports[p].slave; return dsa_is_user_port(ds, p) && ds->ports[p].slave;
} }
int dsa_switch_suspend(struct dsa_switch *ds) int dsa_switch_suspend(struct dsa_switch *ds)
......
...@@ -190,7 +190,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, ...@@ -190,7 +190,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,
ds->ports[i].dn = cd->port_dn[i]; ds->ports[i].dn = cd->port_dn[i];
ds->ports[i].cpu_dp = dst->cpu_dp; ds->ports[i].cpu_dp = dst->cpu_dp;
if (!(ds->enabled_port_mask & (1 << i))) if (dsa_is_user_port(ds, i))
continue; continue;
ret = dsa_slave_create(&ds->ports[i], cd->port_names[i]); ret = dsa_slave_create(&ds->ports[i], cd->port_names[i]);
...@@ -258,7 +258,7 @@ static void dsa_switch_destroy(struct dsa_switch *ds) ...@@ -258,7 +258,7 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
/* Destroy network devices for physical switch ports. */ /* Destroy network devices for physical switch ports. */
for (port = 0; port < ds->num_ports; port++) { for (port = 0; port < ds->num_ports; port++) {
if (!(ds->enabled_port_mask & (1 << port))) if (!dsa_is_user_port(ds, port))
continue; continue;
if (!ds->ports[port].slave) if (!ds->ports[port].slave)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment