Skip to content

Commit 4ef8d85

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: tag_8021q: fix the VLAN IDs used for encoding sub-VLANs
When using sub-VLANs in the range of 1-7, the resulting value from: rx_vid = dsa_8021q_rx_vid_subvlan(ds, port, subvlan); is wrong according to the description from tag_8021q.c: | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +-----------+-----+-----------------+-----------+-----------------------+ | DIR | SVL | SWITCH_ID | SUBVLAN | PORT | +-----------+-----+-----------------+-----------+-----------------------+ For example, when ds->index == 0, port == 3 and subvlan == 1, dsa_8021q_rx_vid_subvlan() returns 1027, same as it returns for subvlan == 0, but it should have returned 1043. This is because the low portion of the subvlan bits are not masked properly when writing into the 12-bit VLAN value. They are masked into bits 4:3, but they should be masked into bits 5:4. Fixes: 3eaae1d ("net: dsa: tag_8021q: support up to 8 VLANs per port using sub-VLANs") Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4ac06a1 commit 4ef8d85

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/dsa/tag_8021q.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
#define DSA_8021Q_SUBVLAN_HI_SHIFT 9
6565
#define DSA_8021Q_SUBVLAN_HI_MASK GENMASK(9, 9)
6666
#define DSA_8021Q_SUBVLAN_LO_SHIFT 4
67-
#define DSA_8021Q_SUBVLAN_LO_MASK GENMASK(4, 3)
67+
#define DSA_8021Q_SUBVLAN_LO_MASK GENMASK(5, 4)
6868
#define DSA_8021Q_SUBVLAN_HI(x) (((x) & GENMASK(2, 2)) >> 2)
6969
#define DSA_8021Q_SUBVLAN_LO(x) ((x) & GENMASK(1, 0))
7070
#define DSA_8021Q_SUBVLAN(x) \

0 commit comments

Comments
 (0)