Skip to content

Commit

Permalink
net: dsa: tag_8021q: introduce a vid_is_dsa_8021q helper
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
vladimiroltean authored and davem330 committed May 12, 2020
1 parent 54a0ed0 commit 1f66b0f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/linux/dsa/8021q.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 */
7 changes: 7 additions & 0 deletions net/dsa/tag_8021q.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1f66b0f

Please sign in to comment.