net: dsa: tag_8021q: introduce a vid_is_dsa_8021q helper
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 12 May 2020 17:20:26 +0000 (20:20 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 12 May 2020 20:08:07 +0000 (13:08 -0700)
This function returns a boolean denoting whether the VLAN passed as
argument is part of the 1024-3071 range that the dsa_8021q tagging
scheme uses.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/dsa/8021q.h
net/dsa/tag_8021q.c

index b8daaec0896eef787424f7ba27dff4171702c372..ebc245ff838a6060102cca6cb3e17e6921156690 100644 (file)
@@ -50,6 +50,8 @@ int dsa_8021q_rx_switch_id(u16 vid);
 
 int dsa_8021q_rx_source_port(u16 vid);
 
+bool vid_is_dsa_8021q(u16 vid);
+
 #else
 
 int dsa_port_setup_8021q_tagging(struct dsa_switch *ds, int index,
@@ -107,6 +109,11 @@ int dsa_8021q_rx_source_port(u16 vid)
        return 0;
 }
 
+bool vid_is_dsa_8021q(u16 vid)
+{
+       return false;
+}
+
 #endif /* IS_ENABLED(CONFIG_NET_DSA_TAG_8021Q) */
 
 #endif /* _NET_DSA_8021Q_H */
index ff9c5bf64bda829b1d67b4dc98da9d494aa2ba0b..4774ecd1f8fca9cd2ae8a84b8f83c1125dbe5784 100644 (file)
@@ -93,6 +93,13 @@ int dsa_8021q_rx_source_port(u16 vid)
 }
 EXPORT_SYMBOL_GPL(dsa_8021q_rx_source_port);
 
+bool vid_is_dsa_8021q(u16 vid)
+{
+       return ((vid & DSA_8021Q_DIR_MASK) == DSA_8021Q_DIR_RX ||
+               (vid & DSA_8021Q_DIR_MASK) == DSA_8021Q_DIR_TX);
+}
+EXPORT_SYMBOL_GPL(vid_is_dsa_8021q);
+
 static int dsa_8021q_restore_pvid(struct dsa_switch *ds, int port)
 {
        struct bridge_vlan_info vinfo;