summaryrefslogtreecommitdiffstats
path: root/include/net/dsa.h
diff options
context:
space:
mode:
authorVivien Didelot2017-12-05 21:34:13 +0100
committerDavid S. Miller2017-12-06 00:01:34 +0100
commit07073c79bf878988d8d0da94869fa5f9d1aa5005 (patch)
treead4d590c6c4bb4e58712ddb02e84d81426b48b02 /include/net/dsa.h
parentnet: dsa: assign a CPU port to DSA port (diff)
downloadkernel-qcow2-linux-07073c79bf878988d8d0da94869fa5f9d1aa5005.tar.gz
kernel-qcow2-linux-07073c79bf878988d8d0da94869fa5f9d1aa5005.tar.xz
kernel-qcow2-linux-07073c79bf878988d8d0da94869fa5f9d1aa5005.zip
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 <vivien.didelot@savoirfairelinux.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/dsa.h')
-rw-r--r--include/net/dsa.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 8198efcc8ced..d29feccaefab 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -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);
}