Skip to content

Commit ab188e8

Browse files
Elad Nachmandavem330
authored andcommitted
stmmac: added support for 802.1ad vlan stripping
stmmac reception handler calls stmmac_rx_vlan() to strip the vlan before calling napi_gro_receive(). The function assumes VLAN tagged frames are always tagged with 802.1Q protocol, and assigns ETH_P_8021Q to the skb by hard-coding the parameter on call to __vlan_hwaccel_put_tag() . This causes packets not to be passed to the VLAN slave if it was created with 802.1AD protocol (ip link add link eth0 eth0.100 type vlan proto 802.1ad id 100). This fix passes the protocol from the VLAN header into __vlan_hwaccel_put_tag() instead of using the hard-coded value of ETH_P_8021Q. NETIF_F_HW_VLAN_STAG_RX check was added and the strip action is now dependent on the correct combination of features and the detected vlan tag. NETIF_F_HW_VLAN_STAG_RX feature was added to be in line with the driver actual abilities. Signed-off-by: Elad Nachman <[email protected]> Reviewed-by: Toshiaki Makita <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 06bdf28 commit ab188e8

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,17 +3182,22 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
31823182

31833183
static void stmmac_rx_vlan(struct net_device *dev, struct sk_buff *skb)
31843184
{
3185-
struct ethhdr *ehdr;
3185+
struct vlan_ethhdr *veth;
3186+
__be16 vlan_proto;
31863187
u16 vlanid;
31873188

3188-
if ((dev->features & NETIF_F_HW_VLAN_CTAG_RX) ==
3189-
NETIF_F_HW_VLAN_CTAG_RX &&
3190-
!__vlan_get_tag(skb, &vlanid)) {
3189+
veth = (struct vlan_ethhdr *)skb->data;
3190+
vlan_proto = veth->h_vlan_proto;
3191+
3192+
if ((vlan_proto == htons(ETH_P_8021Q) &&
3193+
dev->features & NETIF_F_HW_VLAN_CTAG_RX) ||
3194+
(vlan_proto == htons(ETH_P_8021AD) &&
3195+
dev->features & NETIF_F_HW_VLAN_STAG_RX)) {
31913196
/* pop the vlan tag */
3192-
ehdr = (struct ethhdr *)skb->data;
3193-
memmove(skb->data + VLAN_HLEN, ehdr, ETH_ALEN * 2);
3197+
vlanid = ntohs(veth->h_vlan_TCI);
3198+
memmove(skb->data + VLAN_HLEN, veth, ETH_ALEN * 2);
31943199
skb_pull(skb, VLAN_HLEN);
3195-
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlanid);
3200+
__vlan_hwaccel_put_tag(skb, vlan_proto, vlanid);
31963201
}
31973202
}
31983203

@@ -4235,7 +4240,7 @@ int stmmac_dvr_probe(struct device *device,
42354240
ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
42364241
#ifdef STMMAC_VLAN_TAG_USED
42374242
/* Both mac100 and gmac support receive VLAN tag detection */
4238-
ndev->features |= NETIF_F_HW_VLAN_CTAG_RX;
4243+
ndev->features |= NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX;
42394244
#endif
42404245
priv->msg_enable = netif_msg_init(debug, default_msg_level);
42414246

0 commit comments

Comments
 (0)