Skip to content

Commit

Permalink
net: dsa: return per-port upstream port
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
vivien authored and davem330 committed Dec 5, 2017
1 parent 986d7cc commit 07073c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion drivers/net/dsa/mv88e6xxx/chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
int upstream_port;
int err;

upstream_port = dsa_upstream_port(ds);
upstream_port = dsa_upstream_port(ds, port);
if (chip->info->ops->port_set_upstream_port) {
err = chip->info->ops->port_set_upstream_port(chip, port,
upstream_port);
Expand Down
9 changes: 6 additions & 3 deletions include/net/dsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,13 @@ static inline unsigned int dsa_towards_port(struct dsa_switch *ds, int device,
}

/* Return the local port used to reach the dedicated CPU port */
static inline u8 dsa_upstream_port(struct dsa_switch *ds)
static inline unsigned int dsa_upstream_port(struct dsa_switch *ds, int port)
{
struct dsa_switch_tree *dst = ds->dst;
struct dsa_port *cpu_dp = dst->cpu_dp;
const struct dsa_port *dp = dsa_to_port(ds, port);
const struct dsa_port *cpu_dp = dp->cpu_dp;

if (!cpu_dp)
return port;

return dsa_towards_port(ds, cpu_dp->ds->index, cpu_dp->index);
}
Expand Down

0 comments on commit 07073c7

Please sign in to comment.