diff mbox series

include: net: add dsa_cpu_ports function

Message ID 20210406034903.14329-1-ansuelsmth@gmail.com
State New
Headers show
Series include: net: add dsa_cpu_ports function | expand

Commit Message

Christian Marangi April 6, 2021, 3:49 a.m. UTC
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.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 include/net/dsa.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Andrew Lunn April 7, 2021, 12:16 a.m. UTC | #1
On Tue, Apr 06, 2021 at 05:49:03AM +0200, Ansuel Smith wrote:
> 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.
> 
> Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> ---
>  include/net/dsa.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index 83a933e563fe..d71b1acd9c3e 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -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;
> +}

Hi Ansuel

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

   Andrew
diff mbox series

Patch

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 83a933e563fe..d71b1acd9c3e 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -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)
 {