Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2260310rwb; Mon, 7 Nov 2022 11:04:44 -0800 (PST) X-Google-Smtp-Source: AMsMyM5EjF/wR+rJR2y6nkwB2uy9j4VWs0BJh+cI/+rs/HPTN9I30mLyReEW/gTpT3nJa0fShke8 X-Received: by 2002:a63:ed13:0:b0:46f:b030:565c with SMTP id d19-20020a63ed13000000b0046fb030565cmr36921139pgi.380.1667847883754; Mon, 07 Nov 2022 11:04:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667847883; cv=none; d=google.com; s=arc-20160816; b=NlkAZPzXr4x6jQ7IaNnkMuPxNlZBX5GFekVOw8+wE/ETiPZineJJpWjnS01GWIn2jg /pSPqOWFfJbsKiQ71vpGTfXXPqQMGamiTnlmDhIqqkGTX2PqO6NflUHApSc7JA6tVtxW 0CcftTs62P0VBvp8OxQHyk+vWe/dcJlTVJA5ZNi6hbWzuNizhvptFsXcDKeym8w56ZEy qWhztaw6vePVsXSbreKFJmghUhNsV8tu4D8K5KH1Rd8GtSOKHzlzgnDfKXXnp0XY5q42 fNe/Ly2lWcmFH9KgJVOI8R8TlZfzMOWA3FFO4JdQuLwN0s2S3OAzHhGelA2rk2PRdK35 2kkg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Qys05PG22fbxdWm5s8ByJ0wPdOueN+diTukAKqcYoqA=; b=zYlg/suJ732te3Q1aRaOUHAjIsI4Lyz5vFV2ej55mByOOAK8eJrSkd/tdTSmbYX8K/ 48PvNtIUW1xgWoqs15OS0J2jN8g8MBMquEEqP7hbOBnKyGYtLIHCoGPe4eCPk50aupZ7 nOCx3l4y5k/K0Bp4AdlF3TOsh624FwWKo86Y0SKxf96zcrd41HcpDAY3sHHTub1tjb5b eLxEUQZ108EN+o1nNzjMmLzZ6DU9MfWSL5nY9jYRZbCORGQy+iMJy+cugGupTdjKOkuR zHJlFBufEiGOZAx60dPuiwNLrnx+nVRjMmFXtOBk/banKdAd3Ev4cPhJsO8Q834yo0jj mceA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=FxYpLAUU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a63b304000000b0043ab83b731asi12189471pgf.689.2022.11.07.11.04.31; Mon, 07 Nov 2022 11:04:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=FxYpLAUU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232630AbiKGS4I (ORCPT + 92 others); Mon, 7 Nov 2022 13:56:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232105AbiKGSzh (ORCPT ); Mon, 7 Nov 2022 13:55:37 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 508BF25E96; Mon, 7 Nov 2022 10:55:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Qys05PG22fbxdWm5s8ByJ0wPdOueN+diTukAKqcYoqA=; b=FxYpLAUUzZ0MezR3P4pPCvkz2p /RYuPhe0ELtcVlsyntSnLU/zmxETClklGmsfqVpQIdY0+hM+lS07kJrd/7+XniM7QNEyUlKZGFC+N 6wKJjv6SCdI4vdLSRQfStoVeLpLj4cpnvQk6E9QmauVKZ+Uy2JAPOi0HZU51jBVmFT+k=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7HF-000LCc-A1; Mon, 07 Nov 2022 19:55:21 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, Sean Wang , Landen Chao , DENG Qingfang , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/14] net: dsa: tag_mtk: parse hwaccel VLAN tags Date: Mon, 7 Nov 2022 19:54:48 +0100 Message-Id: <20221107185452.90711-10-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221107185452.90711-1-nbd@nbd.name> References: <20221107185452.90711-1-nbd@nbd.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pull the port information from the VLAN protocol ID field Signed-off-by: Felix Fietkau --- net/dsa/tag_mtk.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c index 445d6113227f..0dfa2354f77d 100644 --- a/net/dsa/tag_mtk.c +++ b/net/dsa/tag_mtk.c @@ -73,13 +73,18 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev) if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN))) return NULL; - phdr = dsa_etype_header_pos_rx(skb); - hdr = ntohs(*phdr); + if (skb_vlan_tag_present(skb)) { + hdr = ntohs(skb->vlan_proto); + __vlan_hwaccel_clear_tag(skb); + } else { + phdr = dsa_etype_header_pos_rx(skb); + 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); - dsa_strip_etype_header(skb, MTK_HDR_LEN); + dsa_strip_etype_header(skb, MTK_HDR_LEN); + } /* Get source port information */ port = (hdr & MTK_HDR_RECV_SOURCE_PORT_MASK); @@ -93,11 +98,22 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev) return skb; } +static void mtk_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, + int *offset) +{ + if (!skb_vlan_tag_present(skb)) + return dsa_tag_generic_flow_dissect(skb, proto, offset); + + *offset = 0; + *proto = ((__be16 *)skb->data)[-1]; +} + static const struct dsa_device_ops mtk_netdev_ops = { .name = "mtk", .proto = DSA_TAG_PROTO_MTK, .xmit = mtk_tag_xmit, .rcv = mtk_tag_rcv, + .flow_dissect = mtk_tag_flow_dissect, .needed_headroom = MTK_HDR_LEN, }; -- 2.38.1