Skip to content

Commit 1f66b0f

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: tag_8021q: introduce a vid_is_dsa_8021q helper
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 <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 54a0ed0 commit 1f66b0f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/linux/dsa/8021q.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ int dsa_8021q_rx_switch_id(u16 vid);
5050

5151
int dsa_8021q_rx_source_port(u16 vid);
5252

53+
bool vid_is_dsa_8021q(u16 vid);
54+
5355
#else
5456

5557
int dsa_port_setup_8021q_tagging(struct dsa_switch *ds, int index,
@@ -107,6 +109,11 @@ int dsa_8021q_rx_source_port(u16 vid)
107109
return 0;
108110
}
109111

112+
bool vid_is_dsa_8021q(u16 vid)
113+
{
114+
return false;
115+
}
116+
110117
#endif /* IS_ENABLED(CONFIG_NET_DSA_TAG_8021Q) */
111118

112119
#endif /* _NET_DSA_8021Q_H */

net/dsa/tag_8021q.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ int dsa_8021q_rx_source_port(u16 vid)
9393
}
9494
EXPORT_SYMBOL_GPL(dsa_8021q_rx_source_port);
9595

96+
bool vid_is_dsa_8021q(u16 vid)
97+
{
98+
return ((vid & DSA_8021Q_DIR_MASK) == DSA_8021Q_DIR_RX ||
99+
(vid & DSA_8021Q_DIR_MASK) == DSA_8021Q_DIR_TX);
100+
}
101+
EXPORT_SYMBOL_GPL(vid_is_dsa_8021q);
102+
96103
static int dsa_8021q_restore_pvid(struct dsa_switch *ds, int port)
97104
{
98105
struct bridge_vlan_info vinfo;

0 commit comments

Comments
 (0)