Skip to content

Commit 07073c7

Browse files
viviendavem330
authored andcommitted
net: dsa: return per-port upstream port
The current dsa_upstream_port() helper still assumes a unique CPU port in the whole switch fabric. This is becoming wrong, as every port in the fabric has its dedicated CPU port, thus every port has an upstream port. Add a port argument to the dsa_upstream_port() helper and fetch its CPU port instead of the deprecated unique fabric CPU port. A CPU or unused port has no dedicated CPU port, so return itself in this case. At the same time, change the return value from u8 to unsigned int since there is no need to limit the size here. Signed-off-by: Vivien Didelot <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 986d7cc commit 07073c7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,7 @@ static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
17501750
int upstream_port;
17511751
int err;
17521752

1753-
upstream_port = dsa_upstream_port(ds);
1753+
upstream_port = dsa_upstream_port(ds, port);
17541754
if (chip->info->ops->port_set_upstream_port) {
17551755
err = chip->info->ops->port_set_upstream_port(chip, port,
17561756
upstream_port);

include/net/dsa.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,13 @@ static inline unsigned int dsa_towards_port(struct dsa_switch *ds, int device,
307307
}
308308

309309
/* Return the local port used to reach the dedicated CPU port */
310-
static inline u8 dsa_upstream_port(struct dsa_switch *ds)
310+
static inline unsigned int dsa_upstream_port(struct dsa_switch *ds, int port)
311311
{
312-
struct dsa_switch_tree *dst = ds->dst;
313-
struct dsa_port *cpu_dp = dst->cpu_dp;
312+
const struct dsa_port *dp = dsa_to_port(ds, port);
313+
const struct dsa_port *cpu_dp = dp->cpu_dp;
314+
315+
if (!cpu_dp)
316+
return port;
314317

315318
return dsa_towards_port(ds, cpu_dp->ds->index, cpu_dp->index);
316319
}

0 commit comments

Comments
 (0)