net: dsa: introduce the dsa_cpu_ports() helper

Similar to dsa_user_ports() which retrieves a port mask of all user
ports, introduce dsa_cpu_ports() which retrieves the mask of all CPU
ports of a switch.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Vladimir Oltean 2022-05-11 12:50:16 +03:00 committed by Jakub Kicinski
parent 910ee6cce9
commit 465c3de42b
1 changed files with 11 additions and 0 deletions

View File

@ -590,6 +590,17 @@ static inline u32 dsa_user_ports(struct dsa_switch *ds)
return mask;
}
static inline u32 dsa_cpu_ports(struct dsa_switch *ds)
{
struct dsa_port *cpu_dp;
u32 mask = 0;
dsa_switch_for_each_cpu_port(cpu_dp, ds)
mask |= BIT(cpu_dp->index);
return mask;
}
/* Return the local port used to reach an arbitrary switch device */
static inline unsigned int dsa_routing_port(struct dsa_switch *ds, int device)
{