Skip to content

Commit c657f86

Browse files
rohangt07kuba-moo
authored andcommitted
net: stmmac: vlan: Disable 802.1AD tag insertion offload
The DWMAC IP's VLAN tag insertion offload does not support inserting STAG (802.1AD) and CTAG (802.1Q) types in bytes 13 and 14 using the same MAC_VLAN_Incl and MAC_VLAN_Inner_Incl register configurations. Currently, MAC_VLAN_Incl is configured to offload only STAG type insertion. However, the DWMAC IP inserts a CTAG type when the inner VLAN ID field of the descriptor is not configured, and a STAG type when it is configured. This behavior is not documented and leads to inconsistent double VLAN tagging. Additionally, an unexpected CTAG with VLAN ID 0 is inserted, resulting in frames like: Frame 1: 110 bytes on wire (880 bits), 110 bytes captured (880 bits) Ethernet II, Src: <src> (<src>), Dst: <dst> (<dst>) IEEE 802.1ad, ID: 100 802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 0 (unexpected) 802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 200 Internet Protocol Version 4, Src: 192.168.4.10, Dst: 192.168.4.11 Internet Control Message Protocol To avoid this undocumented and incorrect behavior, disable 802.1AD tag insertion offload. Also, don't set CSVL bit. As per the data book, when this bit is set, S-VLAN type (0x88A8) is inserted in the 13th and 14th bytes of transmitted packets and when this bit is reset, C-VLAN type (0x8100) is inserted in the 13th and 14th bytes of transmitted packets. Fixes: 30d9322 ("net: stmmac: Add support for VLAN Insertion Offload") Fixes: e94e3f3 ("net: stmmac: Add support for VLAN Insertion Offload in GMAC4+") Fixes: 1d2c7a5 ("net: stmmac: Refactor VLAN implementation") Signed-off-by: Rohan G Thomas <[email protected]> Reviewed-by: Boon Khai Ng <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0dd1be4 commit c657f86

2 files changed

Lines changed: 5 additions & 15 deletions

File tree

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4089,18 +4089,11 @@ static int stmmac_release(struct net_device *dev)
40894089
static bool stmmac_vlan_insert(struct stmmac_priv *priv, struct sk_buff *skb,
40904090
struct stmmac_tx_queue *tx_q)
40914091
{
4092-
u16 tag = 0x0, inner_tag = 0x0;
4093-
u32 inner_type = 0x0;
40944092
struct dma_desc *p;
4093+
u16 tag = 0x0;
40954094

4096-
if (!priv->dma_cap.vlins)
4095+
if (!priv->dma_cap.vlins || !skb_vlan_tag_present(skb))
40974096
return false;
4098-
if (!skb_vlan_tag_present(skb))
4099-
return false;
4100-
if (skb->vlan_proto == htons(ETH_P_8021AD)) {
4101-
inner_tag = skb_vlan_tag_get(skb);
4102-
inner_type = STMMAC_VLAN_INSERT;
4103-
}
41044097

41054098
tag = skb_vlan_tag_get(skb);
41064099

@@ -4109,7 +4102,7 @@ static bool stmmac_vlan_insert(struct stmmac_priv *priv, struct sk_buff *skb,
41094102
else
41104103
p = &tx_q->dma_tx[tx_q->cur_tx];
41114104

4112-
if (stmmac_set_desc_vlan_tag(priv, p, tag, inner_tag, inner_type))
4105+
if (stmmac_set_desc_vlan_tag(priv, p, tag, 0x0, 0x0))
41134106
return false;
41144107

41154108
stmmac_set_tx_owner(priv, p);
@@ -7573,11 +7566,8 @@ int stmmac_dvr_probe(struct device *device,
75737566
ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
75747567
ndev->features |= NETIF_F_HW_VLAN_STAG_FILTER;
75757568
}
7576-
if (priv->dma_cap.vlins) {
7569+
if (priv->dma_cap.vlins)
75777570
ndev->features |= NETIF_F_HW_VLAN_CTAG_TX;
7578-
if (priv->dma_cap.dvlan)
7579-
ndev->features |= NETIF_F_HW_VLAN_STAG_TX;
7580-
}
75817571
#endif
75827572
priv->msg_enable = netif_msg_init(debug, default_msg_level);
75837573

drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ static void vlan_enable(struct mac_device_info *hw, u32 type)
212212

213213
value = readl(ioaddr + VLAN_INCL);
214214
value |= VLAN_VLTI;
215-
value |= VLAN_CSVL; /* Only use SVLAN */
215+
value &= ~VLAN_CSVL; /* Only use CVLAN */
216216
value &= ~VLAN_VLC;
217217
value |= (type << VLAN_VLC_SHIFT) & VLAN_VLC;
218218
writel(value, ioaddr + VLAN_INCL);

0 commit comments

Comments
 (0)