Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3522075pxf; Mon, 15 Mar 2021 11:25:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyG+ZmcMOsiGFnSMzGi8z2KT+39423QU4tuydrkAZmgFJYg5UyxkZsRQpAJAyjP9QRYErgh X-Received: by 2002:a50:ee05:: with SMTP id g5mr31438135eds.164.1615832727830; Mon, 15 Mar 2021 11:25:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832727; cv=none; d=google.com; s=arc-20160816; b=PcvhBa3Lr/0OWxocH1t7C5Y9PScmY7O7iM1lQut2h/2HZ02oo0RY1AeQBmz5FCTsrO E3SX3qpS5hygZ+FWrLZ0HryMej4icweOH8QThb7ZXyhPhGY20CgEHTxgZKV0B7paxPc3 Ei4sds30FVTnTkGOM4QXEy/pUa2DeUhRpLj4paSNpY3cgJ9UHhZaPB8JV0EAuRuO2g6G b2xBUXJWveaYB0AWZP94wfbBpFEf9msb/WOl2+i3ZjUrPz2UUI1snTY5N4Jzguh8TePk lgh2LX97aVJ55cjtAc02CzxtiuMX6BINwYFKcUPpD9mYPyGSu8ENnu5JIOcTNcfejbpm VP2w== 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=TAqmD2yYkY1lYko60vefeOZhSesrlgX8lzNqk3H9cqg=; b=u4JTjQXN09ueWIKXywoBloiRIGNak/U8Gp4nYOSxvQpf3z82TWFkVOVdMWfubBP8vd V4rnvYFBCJS6R++APa8E7xSwFUqUEJeLaXKSSW5nCZe5PiDmPfaWyQ46+iExqI2/eo4T s0bhvmO5jc3FqXisZHqVQrKQPGijQKnM+RW8/PW2lDYy+Pb6U1SkNNoBNJAjJ/R22AqO I/KF1PE8eVI7QnuE9CP4lbijH5zbA4yDG0CPBN169ItOmDLHQgwI4vI4evTjFYxK9yit cROKQ6y2T3fAglgfMudSc/VGu2hhAFcuuXqWobMnxg8ERkxIm5etsU9yr8E+1XcgLM9a /Gfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="iu/WZryq"; 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 z17si11109428ejc.207.2021.03.15.11.25.05; Mon, 15 Mar 2021 11:25:27 -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="iu/WZryq"; 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 S234365AbhCOOZp (ORCPT + 99 others); Mon, 15 Mar 2021 10:25:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:35610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232986AbhCOOAa (ORCPT ); Mon, 15 Mar 2021 10:00:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 26F6361477; Mon, 15 Mar 2021 14:00:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816807; bh=dYe/vhAMgRIpAvvxIk9mqYIIilslTuXJDGQAk0+D5Ik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iu/WZryqO/vTkGtPkP94LHsILekZUEgM2nTSqEOfsiXxvTcj4MslwOIv1xr5KVdQK EIyWhzFGyAWcZV6U8F3MfAUrwwzbaGjVJZqMm5H7JOVt1L890Kds7lPdrzlKn2svTx b26BB45CaeksvuQdSSSI2ujrF4wWLXf2H/WtCqc0= 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" , Sasha Levin Subject: [PATCH 5.10 125/290] net: dsa: tag_mtk: fix 802.1ad VLAN egress Date: Mon, 15 Mar 2021 14:53:38 +0100 Message-Id: <20210315135546.138273417@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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 [ Upstream commit 9200f515c41f4cbaeffd8fdd1d8b6373a18b1b67 ] 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: Sasha Levin --- net/dsa/tag_mtk.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c index 38dcdded74c0..59748487664f 100644 --- 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(struct sk_buff *skb, 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(struct sk_buff *skb, * 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(struct sk_buff *skb, /* 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(struct sk_buff *skb, 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; } -- 2.30.1