| From 0f2e84b06686745694f276c4aae6cf9d132a56af Mon Sep 17 00:00:00 2001 |
| From: Sam Shih <sam.shih@mediatek.com> |
| Date: Fri, 2 Jun 2023 13:06:30 +0800 |
| Subject: [PATCH] |
| [networking][999-2712-net-ethernet-mtk_eth_soc-add-mtk-dsa-tag-rx-offload.patch] |
| |
| --- |
| net/dsa/tag_mtk.c | 32 +++++++++++++++++++------------- |
| 1 file changed, 19 insertions(+), 13 deletions(-) |
| |
| diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c |
| index edc505e07..c386fdc90 100644 |
| --- a/net/dsa/tag_mtk.c |
| +++ b/net/dsa/tag_mtk.c |
| @@ -80,22 +80,28 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev, |
| bool is_multicast_skb = is_multicast_ether_addr(dest) && |
| !is_broadcast_ether_addr(dest); |
| |
| - if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN))) |
| - return NULL; |
| + if (dev->features & NETIF_F_HW_VLAN_CTAG_RX) { |
| + hdr = ntohs(skb->vlan_proto); |
| + skb->vlan_proto = 0; |
| + skb->vlan_tci = 0; |
| + } else { |
| + if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN))) |
| + return NULL; |
| |
| - /* The MTK header is added by the switch between src addr |
| - * and ethertype at this point, skb->data points to 2 bytes |
| - * after src addr so header should be 2 bytes right before. |
| - */ |
| - phdr = (__be16 *)(skb->data - 2); |
| - hdr = ntohs(*phdr); |
| + /* The MTK header is added by the switch between src addr |
| + * and ethertype at this point, skb->data points to 2 bytes |
| + * after src addr so header should be 2 bytes right before. |
| + */ |
| + phdr = (__be16 *)(skb->data - 2); |
| + hdr = ntohs(*phdr); |
| |
| - /* Remove MTK tag and recalculate checksum. */ |
| - skb_pull_rcsum(skb, MTK_HDR_LEN); |
| + /* Remove MTK tag and recalculate checksum. */ |
| + skb_pull_rcsum(skb, MTK_HDR_LEN); |
| |
| - memmove(skb->data - ETH_HLEN, |
| - skb->data - ETH_HLEN - MTK_HDR_LEN, |
| - 2 * ETH_ALEN); |
| + memmove(skb->data - ETH_HLEN, |
| + skb->data - ETH_HLEN - MTK_HDR_LEN, |
| + 2 * ETH_ALEN); |
| + } |
| |
| /* Get source port information */ |
| port = (hdr & MTK_HDR_RECV_SOURCE_PORT_MASK); |
| -- |
| 2.34.1 |
| |