Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3511204pxf; Mon, 15 Mar 2021 11:09:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSNjzAPfgzEqq4V5C8GyxVE3ad9tc981xAXVceBchs99tdzo51hhLETQLRH9249jaA5S1c X-Received: by 2002:a05:6402:520b:: with SMTP id s11mr31873948edd.212.1615831761556; Mon, 15 Mar 2021 11:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615831761; cv=none; d=google.com; s=arc-20160816; b=0UejldpsKQ8Yf0Yy9YRZZwL/bLx6o6zeTrgZPO1TH+0m9ouZkLC8r6QFBbn4fqRTYz oaL0rrd9Rukr1sTOk/DIHp7j3b4g+cfsu47Jl6hmFkGrltVIDtJlfjcJ3OUbQphd7DQQ AYOcMG4sC4S6LfeDb1V1Hk/4PyvJi/SQcCos04Ev/myjWp0dIfdRWJOc6m7FCw2Hj/4+ WMbHxTfc9b2gzWRSCdzsvNQiV/v4KHBgPg+Lr1U3WVP1ZDZcLbOLkr12k8s04HTcR+7h AJCjrFg2yHPFpJqd1tiSXBp+UZKIYHBrRFNvlXUn6SF2I86Yi7xEEPWdQndIzvSCNCCK sRkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AHI8vR7HqDTlfAb/uivcatS2Z0OxDaKM3WhAUA0Xijo=; b=NXTGWA5PfWixxA7StNidRyiMF6/W2yNZDoz3/HaaQl/+XV6FXdDH8NCn77WEcQrBKb TBBB3QwgHVjpfwAS0aO9pjxJbTvfT/29tmUFanVbBwzeGEgpgW16a4suDoJBedvLNe/W mghg9s/tCB5tLAC3zxx7xEPXv3IOLINJgXJEEK3K6Wy+VXz7Y/sdEwYjZ7VBc4riBAl1 R2bdnBe3REa7ioNt1PZrH302PROzpYZ8ESPDy7aFMvtlxtMLk3rFHdwAZin7+ztPZfnU 3zddGybvHORBYahV15E3PwaRjvI0c0hFOf+9s6dagn0qDnoUSdwToAplGBlu8M/eY+1G F80Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EdD3jP7l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 24si12148927edv.533.2021.03.15.11.08.54; Mon, 15 Mar 2021 11:09:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EdD3jP7l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231963AbhCOOJh (ORCPT + 99 others); Mon, 15 Mar 2021 10:09:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:35462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232133AbhCON5v (ORCPT ); Mon, 15 Mar 2021 09:57:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6EB2B64F36; Mon, 15 Mar 2021 13:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816670; bh=ULs0xDulZgZXrcyaRZxcqEYrIgBFhRxxjSfiS3yuAN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EdD3jP7lEF/qbA/U4ie3NJkWeR5oj+UFmTaBVeRjefRRW0/ZPZJ4AyxwtlWeG83+G lRtTvbF1/sJ1tzPLtCLhiV4IvI5nl2i0yVZb6KBFLMBwmQbPQ+io15b+RaELcF9rJH TZh8ewC3qGCCCDWbS1GfFdFX3wwuPiUQvT94McYo= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilario Gelmetti , DENG Qingfang , "David S. Miller" Subject: [PATCH 5.11 054/306] net: dsa: tag_mtk: fix 802.1ad VLAN egress Date: Mon, 15 Mar 2021 14:51:57 +0100 Message-Id: <20210315135509.481199421@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: DENG Qingfang commit 9200f515c41f4cbaeffd8fdd1d8b6373a18b1b67 upstream. A different TPID bit is used for 802.1ad VLAN frames. Reported-by: Ilario Gelmetti Fixes: f0af34317f4b ("net: dsa: mediatek: combine MediaTek tag with VLAN tag") Signed-off-by: DENG Qingfang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/dsa/tag_mtk.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) --- a/net/dsa/tag_mtk.c +++ b/net/dsa/tag_mtk.c @@ -13,6 +13,7 @@ #define MTK_HDR_LEN 4 #define MTK_HDR_XMIT_UNTAGGED 0 #define MTK_HDR_XMIT_TAGGED_TPID_8100 1 +#define MTK_HDR_XMIT_TAGGED_TPID_88A8 2 #define MTK_HDR_RECV_SOURCE_PORT_MASK GENMASK(2, 0) #define MTK_HDR_XMIT_DP_BIT_MASK GENMASK(5, 0) #define MTK_HDR_XMIT_SA_DIS BIT(6) @@ -21,8 +22,8 @@ static struct sk_buff *mtk_tag_xmit(stru struct net_device *dev) { struct dsa_port *dp = dsa_slave_to_port(dev); + u8 xmit_tpid; u8 *mtk_tag; - bool is_vlan_skb = true; unsigned char *dest = eth_hdr(skb)->h_dest; bool is_multicast_skb = is_multicast_ether_addr(dest) && !is_broadcast_ether_addr(dest); @@ -33,10 +34,17 @@ static struct sk_buff *mtk_tag_xmit(stru * the both special and VLAN tag at the same time and then look up VLAN * table with VID. */ - if (!skb_vlan_tagged(skb)) { + switch (skb->protocol) { + case htons(ETH_P_8021Q): + xmit_tpid = MTK_HDR_XMIT_TAGGED_TPID_8100; + break; + case htons(ETH_P_8021AD): + xmit_tpid = MTK_HDR_XMIT_TAGGED_TPID_88A8; + break; + default: + xmit_tpid = MTK_HDR_XMIT_UNTAGGED; skb_push(skb, MTK_HDR_LEN); memmove(skb->data, skb->data + MTK_HDR_LEN, 2 * ETH_ALEN); - is_vlan_skb = false; } mtk_tag = skb->data + 2 * ETH_ALEN; @@ -44,8 +52,7 @@ static struct sk_buff *mtk_tag_xmit(stru /* Mark tag attribute on special tag insertion to notify hardware * whether that's a combined special tag with 802.1Q header. */ - mtk_tag[0] = is_vlan_skb ? MTK_HDR_XMIT_TAGGED_TPID_8100 : - MTK_HDR_XMIT_UNTAGGED; + mtk_tag[0] = xmit_tpid; mtk_tag[1] = (1 << dp->index) & MTK_HDR_XMIT_DP_BIT_MASK; /* Disable SA learning for multicast frames */ @@ -53,7 +60,7 @@ static struct sk_buff *mtk_tag_xmit(stru mtk_tag[1] |= MTK_HDR_XMIT_SA_DIS; /* Tag control information is kept for 802.1Q */ - if (!is_vlan_skb) { + if (xmit_tpid == MTK_HDR_XMIT_UNTAGGED) { mtk_tag[2] = 0; mtk_tag[3] = 0; }