diff mbox series

[net-next,08/13] net: dsa: Add helper function to retrieve VLAN awareness setting

Message ID 20190428184554.9968-9-olteanv@gmail.com
State Accepted
Delegated to: David Miller
Headers show
Series Improvements to DSA core VLAN manipulation | expand

Commit Message

Vladimir Oltean April 28, 2019, 6:45 p.m. UTC
Since different types of hardware may or may not support this setting
per-port, DSA keeps it either in dsa_switch or in dsa_port.

While drivers may know the characteristics of their hardware and
retrieve it from the correct place without the need of helpers, it is
cumbersone to find out an unambigous answer from generic DSA code.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
---
 include/net/dsa.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Andrew Lunn April 29, 2019, 9:55 p.m. UTC | #1
On Sun, Apr 28, 2019 at 09:45:49PM +0300, Vladimir Oltean wrote:
> Since different types of hardware may or may not support this setting
> per-port, DSA keeps it either in dsa_switch or in dsa_port.
> 
> While drivers may know the characteristics of their hardware and
> retrieve it from the correct place without the need of helpers, it is
> cumbersone to find out an unambigous answer from generic DSA code.
> 
> Signed-off-by: Vladimir Oltean <olteanv@gmail.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
diff mbox series

Patch

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 4e0f7e9c5aa1..1e6b4efc80b9 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -305,6 +305,16 @@  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);
 }
 
+static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp)
+{
+	const struct dsa_switch *ds = dp->ds;
+
+	if (ds->vlan_filtering_is_global)
+		return ds->vlan_filtering;
+	else
+		return dp->vlan_filtering;
+}
+
 typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
 			      bool is_static, void *data);
 struct dsa_switch_ops {