]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: introduce the dsa_cpu_ports() helper
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 11 May 2022 09:50:16 +0000 (12:50 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 12 May 2022 23:38:54 +0000 (16:38 -0700)
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>
include/net/dsa.h

index efd33956df371ade8a657e730951513b0e43adfe..76257a9f0e1bdbec1eda3fcebdccc8998609f803 100644 (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)
 {