Skip to contentSkip to conversation

include: net: add dsa_cpu_ports function

PATCH Superseded Ansuel Smith 2 participants 2 messages Apr 6, 2021 – Apr 7, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 include: net: add dsa_cpu_ports function

In preparation for the future when dsa will support multi cpu port, dsa_cpu_ports can be useful for switch that has multiple cpu port to retrieve the cpu mask for ACL and bridge table.

---
 include/net/dsa.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/net/dsa.h +12 -0
index 83a933e563fe..d71b1acd9c3e 100644
@@ -446,6 +446,18 @@ static inline u32 dsa_user_ports(struct dsa_switch *ds)
 	return mask;
 }
 
+static inline u32 dsa_cpu_ports(struct dsa_switch *ds)
+{
+	u32 mask = 0;
+	int p;
+
+	for (p = 0; p < ds->num_ports; p++)
+		if (dsa_is_cpu_port(ds, p))
+			mask |= BIT(p);
+
+	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)
 {
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 18 lines · Ansuel Smith

In preparation for the future when dsa will support multi cpu port, dsa_cpu_ports can be useful for switch that has multiple cpu port to retrieve the cpu mask for ACL and bridge table.

---
 include/net/dsa.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/net/dsa.h +1 -0
index 83a933e563fe..d71b1acd9c3e 100644
@@ -446,6 +446,18 @@ static inline u32 dsa_user_ports(struct dsa_switch *ds)
 	return mask;
 }
 
+static inline u32 dsa_cpu_ports(struct dsa_switch *ds)

include/net/dsa.h static inline u32 dsa_user_ports(struct dsa_switch *ds) · line 459

Quoted 10 lines
include/net/dsa.h +10 -0
+{
+	u32 mask = 0;
+	int p;
+
+	for (p = 0; p < ds->num_ports; p++)
+		if (dsa_is_cpu_port(ds, p))
+			mask |= BIT(p);
+
+	return mask;
+}

Hi Ansuel

We don't add a function unless it has a user. Please call it from somewhere.

Andrew