diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2017-11-30 12:56:42 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-12-02 21:20:59 -0500 |
commit | 3b8fac5d905ee15346ba2de1e2427ef43fbbd880 (patch) | |
tree | e7869942809937bd39cf27ab91c15e4cc9208b23 /include/net/dsa.h | |
parent | 5420683ae3d2b986f04efa99a7afd2d57e092004 (diff) |
net: dsa: introduce dsa_towards_port helper
Add a new helper returning the local port used to reach an arbitrary
switch port in the fabric.
Its only user at the moment is the dsa_upstream_port helper, which
returns the local port reaching the dedicated CPU port, but it will be
used in cross-chip FDB operations.
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.h | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h index 6700dff46a80..8198efcc8ced 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h | |||
@@ -296,20 +296,23 @@ static inline u32 dsa_user_ports(struct dsa_switch *ds) | |||
296 | return mask; | 296 | return mask; |
297 | } | 297 | } |
298 | 298 | ||
299 | /* Return the local port used to reach an arbitrary switch port */ | ||
300 | static inline unsigned int dsa_towards_port(struct dsa_switch *ds, int device, | ||
301 | int port) | ||
302 | { | ||
303 | if (device == ds->index) | ||
304 | return port; | ||
305 | else | ||
306 | return ds->rtable[device]; | ||
307 | } | ||
308 | |||
309 | /* Return the local port used to reach the dedicated CPU port */ | ||
299 | static inline u8 dsa_upstream_port(struct dsa_switch *ds) | 310 | static inline u8 dsa_upstream_port(struct dsa_switch *ds) |
300 | { | 311 | { |
301 | struct dsa_switch_tree *dst = ds->dst; | 312 | struct dsa_switch_tree *dst = ds->dst; |
313 | struct dsa_port *cpu_dp = dst->cpu_dp; | ||
302 | 314 | ||
303 | /* | 315 | return dsa_towards_port(ds, cpu_dp->ds->index, cpu_dp->index); |
304 | * If this is the root switch (i.e. the switch that connects | ||
305 | * to the CPU), return the cpu port number on this switch. | ||
306 | * Else return the (DSA) port number that connects to the | ||
307 | * switch that is one hop closer to the cpu. | ||
308 | */ | ||
309 | if (dst->cpu_dp->ds == ds) | ||
310 | return dst->cpu_dp->index; | ||
311 | else | ||
312 | return ds->rtable[dst->cpu_dp->ds->index]; | ||
313 | } | 316 | } |
314 | 317 | ||
315 | typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid, | 318 | typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid, |