From patchwork Mon Nov 7 18:54:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2235154wru; Mon, 7 Nov 2022 11:04:02 -0800 (PST) X-Google-Smtp-Source: AMsMyM7xlCXhp0ZQHKhDT9S1+g6ZlSjDUctcoTqgBfyNh1NLJwEvWad5vAhwZC14XRFfKZBvEtn9 X-Received: by 2002:a17:90b:1b01:b0:213:ccc6:87ea with SMTP id nu1-20020a17090b1b0100b00213ccc687eamr47667663pjb.135.1667847842167; Mon, 07 Nov 2022 11:04:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667847842; cv=none; d=google.com; s=arc-20160816; b=kWageNXTW5ch+Ivl5Z2E72OQctSGBtyjpVhpxlnHWdrXEcf3gib0MUAsoOW7JzGzGA M4B+/aTQeSdfQOUkfaJsMQ4cV55d9K1Y7EC8C9fn0G5hGorfyGiOH0AiYlyzLL6BAw42 uaVdfXOvNpxooAZ1T+QD8BnLwPDJQ1hmXljLHSpVkE53D5MbxfGWcvIDMwAm4Gmh8P91 IBvkEHWOIC4WQGEDvDCtTUA3qKfRpDkOq9bH3KhZjlUSE3KjmtwYs5GQd5t1cA7ouNmb oO2wKmJ7KRP2UW1dBZ1ByRNoXsT30hBl+tprrvrPQSlSeRTMl5USFJLntvaUvhQML9gL 8BkQ== 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 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.03.47; Mon, 07 Nov 2022 11:04:02 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748865218844356356?= X-GMAIL-MSGID: =?utf-8?q?1748865218844356356?= 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, };