Introduce a dsa_is_upstream_port helper to check if a given switch port is directly or indirectly connected to a CPU port.
Signed-off-by: Vivien Didelot <vivien.dide...@gmail.com> --- include/net/dsa.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index 7b10a067b06d..c5b45bfeea01 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -347,6 +347,15 @@ static inline unsigned int dsa_upstream_port(struct dsa_switch *ds, int port) return dsa_towards_port(ds, cpu_dp->ds->index, cpu_dp->index); } +/* Return whether the port is a local upstream port */ +static inline bool dsa_is_upstream_port(struct dsa_switch *ds, int port) +{ + if (dsa_is_unused_port(ds, port)) + return false; + + return dsa_upstream_port(ds, port) == port; +} + static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp) { const struct dsa_switch *ds = dp->ds; -- 2.21.0