From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 795D2C2D0D3 for ; Mon, 30 Dec 2019 14:33:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 50C752071E for ; Mon, 30 Dec 2019 14:33:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="W9DiqZJ5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727842AbfL3Odc (ORCPT ); Mon, 30 Dec 2019 09:33:32 -0500 Received: from mail.dlink.ru ([178.170.168.18]:42232 "EHLO fd.dlink.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727576AbfL3Oda (ORCPT ); Mon, 30 Dec 2019 09:33:30 -0500 Received: by fd.dlink.ru (Postfix, from userid 5000) id 05BD91B20B7B; Mon, 30 Dec 2019 17:33:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 05BD91B20B7B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716407; bh=Erjvba4dIKrPISREjV3SM+2wcBTCz6oIK+5iwW6Xun4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W9DiqZJ515jMwhKOig4girjPYcE4uMTlFxCaeERSRbste6vzrQDxtUSlDa8PpmCBh clMjplrv8rpBd4MatbcgS7tVbCQ5seWlVj+vfyXWG/PTL+efemYwc2uau4PMh+OSfp Oeu6BJjraKKEtpwG5m+q97Nr9IwiwbgYACDxQFP8= Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id 6FBF51B2180E; Mon, 30 Dec 2019 17:31:21 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 6FBF51B2180E Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id 266F41B229D1; Mon, 30 Dec 2019 17:31:19 +0300 (MSK) Received: from localhost.localdomain (unknown [196.196.203.126]) by mail.rzn.dlink.ru (Postfix) with ESMTPA; Mon, 30 Dec 2019 17:31:19 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Cc: Edward Cree , Andrew Lunn , Vivien Didelot , Florian Fainelli , Hauke Mehrtens , Sean Wang , Matthias Brugger , Jiri Pirko , Eric Dumazet , Paolo Abeni , Jakub Kicinski , Alexander Lobakin , Taehee Yoo , Stephen Hemminger , Stanislav Fomichev , Daniel Borkmann , Song Liu , Matteo Croce , Jakub Sitnicki , Paul Blakey , Yoshiki Komachi , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH RFC net-next 09/19] net: dsa: tag_gswip: split out common tag accessors Date: Mon, 30 Dec 2019 17:30:17 +0300 Message-Id: <20191230143028.27313-10-alobakin@dlink.ru> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191230143028.27313-1-alobakin@dlink.ru> References: <20191230143028.27313-1-alobakin@dlink.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ...to reuse them in GRO callbacks. Signed-off-by: Alexander Lobakin --- net/dsa/tag_gswip.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/net/dsa/tag_gswip.c b/net/dsa/tag_gswip.c index d37289540ef3..e7b36de27fd8 100644 --- a/net/dsa/tag_gswip.c +++ b/net/dsa/tag_gswip.c @@ -55,6 +55,16 @@ /* Byte 7 */ #define GSWIP_RX_SPPID(byte_7) FIELD_GET(GENMASK(6, 4), byte_7) +static inline int gswip_tag_source_port(const u8 *data) +{ + return GSWIP_RX_SPPID(*(data - ETH_HLEN + 7)); +} + +static inline __be16 gswip_tag_encap_proto(const u8 *data) +{ + return *(__be16 *)(data + 6); +} + static struct sk_buff *gswip_tag_xmit(struct sk_buff *skb, struct net_device *dev) { @@ -85,7 +95,7 @@ static struct sk_buff *gswip_tag_rcv(struct sk_buff *skb, return NULL; /* Get source port information */ - port = GSWIP_RX_SPPID(*(skb->data - ETH_HLEN + 7)); + port = gswip_tag_source_port(skb->data); skb->dev = dsa_master_find_slave(dev, 0, port); if (!skb->dev) @@ -101,7 +111,7 @@ static void gswip_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, int *offset) { *offset = GSWIP_RX_HEADER_LEN; - *proto = *(__be16 *)(skb->data + 6); + *proto = gswip_tag_encap_proto(skb->data); } static const struct dsa_device_ops gswip_netdev_ops = { -- 2.24.1