Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: dsa: tag_mtk: fix 802.1ad VLAN egress

A different TPID bit is used for 802.1ad VLAN frames.

Reported-by: Ilario Gelmetti <iochesonome@gmail.com>
Fixes: f0af34317f4b ("net: dsa: mediatek: combine MediaTek tag with VLAN tag")
Signed-off-by: DENG Qingfang <dqfext@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

DENG Qingfang and committed by
David S. Miller
9200f515 b228c9b0

+13 -6
+13 -6
net/dsa/tag_mtk.c
··· 13 13 #define MTK_HDR_LEN 4 14 14 #define MTK_HDR_XMIT_UNTAGGED 0 15 15 #define MTK_HDR_XMIT_TAGGED_TPID_8100 1 16 + #define MTK_HDR_XMIT_TAGGED_TPID_88A8 2 16 17 #define MTK_HDR_RECV_SOURCE_PORT_MASK GENMASK(2, 0) 17 18 #define MTK_HDR_XMIT_DP_BIT_MASK GENMASK(5, 0) 18 19 #define MTK_HDR_XMIT_SA_DIS BIT(6) ··· 22 21 struct net_device *dev) 23 22 { 24 23 struct dsa_port *dp = dsa_slave_to_port(dev); 24 + u8 xmit_tpid; 25 25 u8 *mtk_tag; 26 - bool is_vlan_skb = true; 27 26 unsigned char *dest = eth_hdr(skb)->h_dest; 28 27 bool is_multicast_skb = is_multicast_ether_addr(dest) && 29 28 !is_broadcast_ether_addr(dest); ··· 34 33 * the both special and VLAN tag at the same time and then look up VLAN 35 34 * table with VID. 36 35 */ 37 - if (!skb_vlan_tagged(skb)) { 36 + switch (skb->protocol) { 37 + case htons(ETH_P_8021Q): 38 + xmit_tpid = MTK_HDR_XMIT_TAGGED_TPID_8100; 39 + break; 40 + case htons(ETH_P_8021AD): 41 + xmit_tpid = MTK_HDR_XMIT_TAGGED_TPID_88A8; 42 + break; 43 + default: 44 + xmit_tpid = MTK_HDR_XMIT_UNTAGGED; 38 45 skb_push(skb, MTK_HDR_LEN); 39 46 memmove(skb->data, skb->data + MTK_HDR_LEN, 2 * ETH_ALEN); 40 - is_vlan_skb = false; 41 47 } 42 48 43 49 mtk_tag = skb->data + 2 * ETH_ALEN; ··· 52 44 /* Mark tag attribute on special tag insertion to notify hardware 53 45 * whether that's a combined special tag with 802.1Q header. 54 46 */ 55 - mtk_tag[0] = is_vlan_skb ? MTK_HDR_XMIT_TAGGED_TPID_8100 : 56 - MTK_HDR_XMIT_UNTAGGED; 47 + mtk_tag[0] = xmit_tpid; 57 48 mtk_tag[1] = (1 << dp->index) & MTK_HDR_XMIT_DP_BIT_MASK; 58 49 59 50 /* Disable SA learning for multicast frames */ ··· 60 53 mtk_tag[1] |= MTK_HDR_XMIT_SA_DIS; 61 54 62 55 /* Tag control information is kept for 802.1Q */ 63 - if (!is_vlan_skb) { 56 + if (xmit_tpid == MTK_HDR_XMIT_UNTAGGED) { 64 57 mtk_tag[2] = 0; 65 58 mtk_tag[3] = 0; 66 59 }