From patchwork Mon Dec 30 14:30:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313129 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ACEC313A4 for ; Mon, 30 Dec 2019 14:38:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8ADAA20663 for ; Mon, 30 Dec 2019 14:38:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NFwwMyu1"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="G/ZMx01H" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8ADAA20663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zYWghzwCaJgIjdBCvq6Ns63Q2CyzekRzOBVvzLSPBic=; b=NFwwMyu1s78a+c qaamPTzY9mLJFAtUT6IgwFFpFVwIks9HGxlX31zeOTbPcnchf/X1ZnEwwaTLHUWzaeyHW8dVOYUoT h8qk0sKglFoSs8g5wR2Y8+/rCoa3++ouRRF5kPzikQ0DSb1NmmMTGaRqKn6LRBrKL+GkWKY2cvnYH AltD5EXt8uVMuQh1qLOAbvSfbY7Frc5byedBqGfp6TvG0TxUbnyNsafK/dPQP4s+6+ilmnhn0w+Y+ KhBkG+gEPlw2raV3Em6D+rG+mmXKeyIbSfEpYYQsvH1jYEkWxHnByMaaFBTASuLNaP2xCVnxGHNLV 79NEwMhpe49ziunGVT0w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwBC-0001Ok-RW; Mon, 30 Dec 2019 14:37:58 +0000 Received: from fd.dlink.ru ([178.170.168.18]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwAj-0000xN-QJ; Mon, 30 Dec 2019 14:37:31 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id 0913D1B210C1; Mon, 30 Dec 2019 17:31:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 0913D1B210C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716289; bh=L55d4XdjAtvKL0l9HxmdxPvldFzgURGS4JiXQm8SXdA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=G/ZMx01H4wK1kGPSkQ5hXbnB1LPCUOYawurey2dYWrN4V+lsdHzGjsnCQ6usv61m7 44kBKmAJmJc/E6klpfzq/IvUguB+Lc+5bL44gy4VTg7gfUFwCiqRxK+J5mtgEuR5mQ gXtLyqlqRUqXEIUgU0sImBKvY9rQZEEicFJ/jegs= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id 83F871B20206; Mon, 30 Dec 2019 17:31:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 83F871B20206 Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id C95A91B229D0; Mon, 30 Dec 2019 17:31:03 +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:03 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 01/19] net: dsa: make .flow_dissect() callback returning void Date: Mon, 30 Dec 2019 17:30:09 +0300 Message-Id: <20191230143028.27313-2-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_063730_221672_6392FF0C X-CRM114-Status: GOOD ( 10.52 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org There are no tag protocols which return non-zero values from flow_dissect() callback. Remove it to simplify code and save some object size. If a particular tagger can't calculate offset and proto for some reason, it can simply leave the original values untouched. Signed-off-by: Alexander Lobakin Reviewed-by: Florian Fainelli --- include/net/dsa.h | 5 ++--- net/core/flow_dissector.c | 8 ++++---- net/dsa/tag_dsa.c | 5 ++--- net/dsa/tag_edsa.c | 5 ++--- net/dsa/tag_mtk.c | 6 ++---- net/dsa/tag_qca.c | 6 ++---- 6 files changed, 14 insertions(+), 21 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index da5578db228e..633d9894ab87 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -72,8 +72,8 @@ struct dsa_device_ops { struct sk_buff *(*xmit)(struct sk_buff *skb, struct net_device *dev); struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt); - int (*flow_dissect)(const struct sk_buff *skb, __be16 *proto, - int *offset); + void (*flow_dissect)(const struct sk_buff *skb, __be16 *proto, + int *offset); /* Used to determine which traffic should match the DSA filter in * eth_type_trans, and which, if any, should bypass it and be processed * as regular on the master net device. @@ -774,4 +774,3 @@ static struct dsa_tag_driver *dsa_tag_driver_array[] = { \ }; \ module_dsa_tag_drivers(dsa_tag_driver_array) #endif - diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 2dbbb030fbed..2c9d8c7c76b3 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -971,12 +971,12 @@ bool __skb_flow_dissect(const struct net *net, #if IS_ENABLED(CONFIG_NET_DSA) if (unlikely(skb->dev && netdev_uses_dsa(skb->dev) && proto == htons(ETH_P_XDSA))) { - const struct dsa_device_ops *ops; + typeof_member(struct dsa_device_ops, flow_dissect) fd; int offset = 0; - ops = skb->dev->dsa_ptr->tag_ops; - if (ops->flow_dissect && - !ops->flow_dissect(skb, &proto, &offset)) { + fd = skb->dev->dsa_ptr->tag_ops->flow_dissect; + if (fd) { + fd(skb, &proto, &offset); hlen -= offset; nhoff += offset; } diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c index 7ddec9794477..ef15aee58dfc 100644 --- a/net/dsa/tag_dsa.c +++ b/net/dsa/tag_dsa.c @@ -142,12 +142,11 @@ static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev, return skb; } -static int dsa_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, - int *offset) +static void dsa_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, + int *offset) { *offset = 4; *proto = ((__be16 *)skb->data)[1]; - return 0; } static const struct dsa_device_ops dsa_netdev_ops = { diff --git a/net/dsa/tag_edsa.c b/net/dsa/tag_edsa.c index e8eaa804ccb9..37a99254b411 100644 --- a/net/dsa/tag_edsa.c +++ b/net/dsa/tag_edsa.c @@ -161,12 +161,11 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev, return skb; } -static int edsa_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, - int *offset) +static void edsa_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, + int *offset) { *offset = 8; *proto = ((__be16 *)skb->data)[3]; - return 0; } static const struct dsa_device_ops edsa_netdev_ops = { diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c index b5705cba8318..c3ad7b7b142a 100644 --- a/net/dsa/tag_mtk.c +++ b/net/dsa/tag_mtk.c @@ -89,13 +89,11 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev, return skb; } -static int mtk_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, - int *offset) +static void mtk_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, + int *offset) { *offset = 4; *proto = ((__be16 *)skb->data)[1]; - - return 0; } static const struct dsa_device_ops mtk_netdev_ops = { diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c index c95885215525..8e2dbaaffe59 100644 --- a/net/dsa/tag_qca.c +++ b/net/dsa/tag_qca.c @@ -90,13 +90,11 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev, return skb; } -static int qca_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, - int *offset) +static void qca_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, + int *offset) { *offset = QCA_HDR_LEN; *proto = ((__be16 *)skb->data)[0]; - - return 0; } static const struct dsa_device_ops qca_netdev_ops = { From patchwork Mon Dec 30 14:30:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313267 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ABC9813A4 for ; Mon, 30 Dec 2019 14:49:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5FE0920663 for ; Mon, 30 Dec 2019 14:49:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jOMfjTqC"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="GmdgPLyp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5FE0920663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZLHZO9v+5BTG0K84byWuo4I4hBclK2YAqlT/2M7sUu0=; b=jOMfjTqCwx6+0H eaRWdVFEPbNzLy0nAXB5KplwBE7bthMWN7FJ9/+QiKC64V3LAdb9KjpscH6B5o3RsWikt2NPyh/Ns iYzVx9ICBb+lKPRdkq8+bO+tUnsIf3AUK0CRSStfy9V3Pd+y3nr0RUuBum62ApAnxP7SmqlB1gdIn RNpltU7+jzBfw4vkHUX+E0+nG+GTa16ryskLrEPLe1Lz787E4nQQePkcM1FfUrbwhpZ7kqbXO/lBj +41KHF8InM9hpKvAuKgHlIiOnIlNVh/r0pvXsVUpjKunMJrU7vvk8f+a7a0RWLsBUsZZ5LzE/GEtG Rw9lHZTFr+rvuU5H5JNw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwMA-0002FC-C5; Mon, 30 Dec 2019 14:49:18 +0000 Received: from fd.dlink.ru ([178.170.168.18]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFc-0003ys-Rj; Mon, 30 Dec 2019 14:42:37 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id 61AAE1B21813; Mon, 30 Dec 2019 17:31:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 61AAE1B21813 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716299; bh=GSv5uxS8JB5ZFL1df4FA5xdldqWieg3v4SkX8gUq2MY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GmdgPLypb3SV0iTI0fTBl5C5KPZy9g8Fo+WJRuNUIrilumWA0Ajkw/p1QT/Vlr4Lw p8BGiv6bFOeStHPIQlHTfSEeTRMN728HSw8rIqE9Bb+01W4yJbC7CArszuDDwFiElk rA4R+drt1I1vxSvz6qCHp/1L6GB3iyPT5DS1P78k= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id 286831B20805; Mon, 30 Dec 2019 17:31:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 286831B20805 Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id 71F111B229CB; Mon, 30 Dec 2019 17:31:05 +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:05 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 02/19] net: dsa: add GRO support infrastructure Date: Mon, 30 Dec 2019 17:30:10 +0300 Message-Id: <20191230143028.27313-3-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064233_289751_8E4D050E X-CRM114-Status: GOOD ( 13.27 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Add .gro_receive() (with shortcut) and .gro_complete() callbacks to tagger ops and basic ETH_P_XDSA packet_offload with wrappers around them, so DSA-tagged frames can now be processed within GRO layer if the particular tagger implements this (will be added in subsequent patches). Note: no need to take RCU read locks in dsa_gro_receive() and dsa_gro_complete() as dev->cpu_dp is not RCU-protected, at least for now. The corresponding locks must be taken in the actual tagger callbacks. Signed-off-by: Alexander Lobakin --- include/net/dsa.h | 5 +++++ net/dsa/dsa.c | 43 +++++++++++++++++++++++++++++++++++++++++-- net/dsa/dsa2.c | 1 + 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index 633d9894ab87..8a7f80709d51 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -79,6 +79,9 @@ struct dsa_device_ops { * as regular on the master net device. */ bool (*filter)(const struct sk_buff *skb, struct net_device *dev); + struct sk_buff *(*gro_receive)(struct list_head *head, + struct sk_buff *skb); + int (*gro_complete)(struct sk_buff *skb, int nhoff); unsigned int overhead; const char *name; enum dsa_tag_protocol proto; @@ -170,6 +173,8 @@ struct dsa_port { struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt); bool (*filter)(const struct sk_buff *skb, struct net_device *dev); + struct sk_buff *(*gro_receive)(struct list_head *head, + struct sk_buff *skb); enum { DSA_PORT_TYPE_UNUSED = 0, diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 17281fec710c..9a8d8ce7473c 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -243,6 +243,34 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev, return 0; } +static struct sk_buff *dsa_gro_receive(struct list_head *head, + struct sk_buff *skb) +{ + const struct dsa_port *cpu_dp = skb->dev->dsa_ptr; + struct sk_buff *pp = NULL; + int flush = 1; + + if (unlikely(!cpu_dp) || !cpu_dp->gro_receive) + goto flush; + + pp = cpu_dp->gro_receive(head, skb); + flush = 0; + +flush: + skb_gro_flush_final(skb, pp, flush); + return pp; +} + +static int dsa_gro_complete(struct sk_buff *skb, int nhoff) +{ + const struct dsa_port *cpu_dp = skb->dev->dsa_ptr; + + if (likely(cpu_dp) && cpu_dp->tag_ops->gro_complete) + return cpu_dp->tag_ops->gro_complete(skb, nhoff); + + return -ENOENT; +} + #ifdef CONFIG_PM_SLEEP static bool dsa_is_port_initialized(struct dsa_switch *ds, int p) { @@ -298,8 +326,17 @@ EXPORT_SYMBOL_GPL(dsa_switch_resume); #endif static struct packet_type dsa_pack_type __read_mostly = { - .type = cpu_to_be16(ETH_P_XDSA), - .func = dsa_switch_rcv, + .type = htons(ETH_P_XDSA), + .func = dsa_switch_rcv, +}; + +static struct packet_offload dsa_pack_offload __read_mostly = { + .type = htons(ETH_P_XDSA), + .priority = 10, + .callbacks = { + .gro_receive = dsa_gro_receive, + .gro_complete = dsa_gro_complete, + }, }; static struct workqueue_struct *dsa_owq; @@ -430,6 +467,7 @@ static int __init dsa_init_module(void) goto register_notifier_fail; dev_add_pack(&dsa_pack_type); + dev_add_offload(&dsa_pack_offload); dsa_tag_driver_register(&DSA_TAG_DRIVER_NAME(none_ops), THIS_MODULE); @@ -448,6 +486,7 @@ static void __exit dsa_cleanup_module(void) dsa_tag_driver_unregister(&DSA_TAG_DRIVER_NAME(none_ops)); dsa_slave_unregister_notifier(); + dev_remove_offload(&dsa_pack_offload); dev_remove_pack(&dsa_pack_type); destroy_workqueue(dsa_owq); } diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index c66abbed4daf..5f66e0280e8e 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -631,6 +631,7 @@ static int dsa_port_parse_cpu(struct dsa_port *dp, struct net_device *master) } dp->type = DSA_PORT_TYPE_CPU; + dp->gro_receive = tag_ops->gro_receive; dp->filter = tag_ops->filter; dp->rcv = tag_ops->rcv; dp->tag_ops = tag_ops; From patchwork Mon Dec 30 14:30:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313229 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0A8113A4 for ; Mon, 30 Dec 2019 14:46:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96CBA20663 for ; Mon, 30 Dec 2019 14:46:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tR//jxhA"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="TgfnbWI9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96CBA20663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WjxM5yKzAzipHpW4aXyopb3fjQXnb/nrehU3wZkBLak=; b=tR//jxhA/Eu4/o cyvN7H5zpmozCsxlJDsGJYVddDw4DPskm0iNwmm52928zpW31TgX9jD+RZKKgnCtRC9QBoiVw+9u3 bs87NXXF5lcSL6vC1XYg2hElk4Vz8iSUlxmF7DwL3VhRe+LGZw/cqfHRchkrxuWL/Q+a0hCAKUUhP Ya5QgJgCT8q95lWlhV3g8YrClV0uUrhNFFXPOEwA83dngzOMPP6dJbZM4HTFEcjnbsGAVcK+b+ITR +ydKY+PK84guwxokaBLcTEv/ccU2kQC90p5NGkgltFaNLryVcwHMuwFm17BViw6Er7czmxrt1KEn/ duzlKhHpOEbF1V4fzTsg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwJQ-0007zE-0S; Mon, 30 Dec 2019 14:46:28 +0000 Received: from mail.dlink.ru ([178.170.168.18] helo=fd.dlink.ru) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFb-0003xY-2A; Mon, 30 Dec 2019 14:42:32 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id 12FCC1B205E4; Mon, 30 Dec 2019 17:31:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 12FCC1B205E4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716308; bh=18voDyGBMtcwId3z4bi4wS1wyOebnKJGhqqk04an6a0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TgfnbWI9TBc3yVVN1K2QdM7eEbyAyE00CNl4wigySu3iFcTjAtP01FSXGw5+R0Cn7 fwRFXsTjaNiqN6JS+c/zW1l6fC5qvX+S2LJHDvKfn5eKcwTuRczYazS+ki0EwQYXIv L5UPgTwDGkc1/OsNzAt1hGc6Zn063tb+VbM8Ubo8= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id D7C7E1B205DF; Mon, 30 Dec 2019 17:31:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru D7C7E1B205DF Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id 1E48A1B229D1; Mon, 30 Dec 2019 17:31:07 +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:07 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 03/19] net: dsa: tag_ar9331: add .flow_dissect() callback Date: Mon, 30 Dec 2019 17:30:11 +0300 Message-Id: <20191230143028.27313-4-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064231_280780_E37306E3 X-CRM114-Status: UNSURE ( 9.19 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org ...to make RPS work correctly if user would like to configure it. Misc: fix identation of ar9331_netdev_ops structure. Signed-off-by: Alexander Lobakin --- net/dsa/tag_ar9331.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/net/dsa/tag_ar9331.c b/net/dsa/tag_ar9331.c index 466ffa92a474..399ca21ec03b 100644 --- a/net/dsa/tag_ar9331.c +++ b/net/dsa/tag_ar9331.c @@ -83,12 +83,20 @@ static struct sk_buff *ar9331_tag_rcv(struct sk_buff *skb, return skb; } +static void ar9331_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, + int *offset) +{ + *offset = AR9331_HDR_LEN; + *proto = *(__be16 *)skb->data; +} + static const struct dsa_device_ops ar9331_netdev_ops = { - .name = "ar9331", - .proto = DSA_TAG_PROTO_AR9331, - .xmit = ar9331_tag_xmit, - .rcv = ar9331_tag_rcv, - .overhead = AR9331_HDR_LEN, + .name = "ar9331", + .proto = DSA_TAG_PROTO_AR9331, + .xmit = ar9331_tag_xmit, + .rcv = ar9331_tag_rcv, + .flow_dissect = ar9331_tag_flow_dissect, + .overhead = AR9331_HDR_LEN, }; MODULE_LICENSE("GPL v2"); From patchwork Mon Dec 30 14:30:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313127 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 53A2813A4 for ; Mon, 30 Dec 2019 14:38:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 236AD20663 for ; Mon, 30 Dec 2019 14:38:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ieq7y2W4"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="PFAfL5sW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 236AD20663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8FKpP+A+eeJYC6iUPLrxuj4u8rP8Ln/6yKW3YtxZQ2M=; b=Ieq7y2W4Ah4wVC y4chd4858v2va0bxvgiIkP9bs6yeUJShttlgG673Q6dJSaeEi0sIIZDkXFkN7Ah0ukI9c4mnsvD2U nxrEWKTAgzDh8KKrEwYxfA5liM6LxrXr+ydvMYbnCv1QCu1pb/3EYrCHLs86+9sBuJgI+QBgUNDQ8 SxVqtTB1GbsTkUvAfiQRlonqbYohbKwLGkd+EtVsp/fdBjp9U5+ViACrAaVESHi/FpAmboz73jGd4 +tEuPEIlwSGOIyk8Dd8X+r1qfDG0FF2pIF1yTdLp4V7RdAa6sPdHiJTpFdqdaeGzqeylM50doFKjs 0S+HbZCTo+MHBqDUG//g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwBB-0001NO-UG; Mon, 30 Dec 2019 14:37:57 +0000 Received: from fd.dlink.ru ([178.170.168.18]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwAk-0000xR-1X; Mon, 30 Dec 2019 14:37:31 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id 1D35C1B20759; Mon, 30 Dec 2019 17:31:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 1D35C1B20759 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716317; bh=MElnUAXdbAsEzuA8MGuhZyEpxZHkJL0ydPnsBAYspiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PFAfL5sWrlbjw5bOBVaCSHG9T9Lz+DIXQnZ4J2oydzJ8/nGsMPjkU3wcslu2m0Mi5 8NbvC/5iXl35VH4MvCP84/Zj9rgur1fdwyEakbJ95RGtdax+msw0N6Zl6VgEz5wyXb mXrmGNG7/aXIYQ19IgnLoyvkS1qQzubGY2OxKSCM= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id 0C2421B207EB; Mon, 30 Dec 2019 17:31:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 0C2421B207EB Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id C6D2A1B229CB; Mon, 30 Dec 2019 17:31:08 +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:08 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 04/19] net: dsa: tag_ar9331: split out common tag accessors Date: Mon, 30 Dec 2019 17:30:12 +0300 Message-Id: <20191230143028.27313-5-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_063730_442130_A7F6DA68 X-CRM114-Status: GOOD ( 11.75 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org They will be reused in upcoming GRO callbacks. (Almost) no functional changes except less informative error string. Signed-off-by: Alexander Lobakin --- net/dsa/tag_ar9331.c | 46 +++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/net/dsa/tag_ar9331.c b/net/dsa/tag_ar9331.c index 399ca21ec03b..c22c1b515e02 100644 --- a/net/dsa/tag_ar9331.c +++ b/net/dsa/tag_ar9331.c @@ -24,6 +24,25 @@ #define AR9331_HDR_RESERVED_MASK GENMASK(5, 4) #define AR9331_HDR_PORT_NUM_MASK GENMASK(3, 0) +static inline bool ar9331_tag_sanity_check(const u8 *data) +{ + u16 hdr = le16_to_cpup((__le16 *)(data - ETH_HLEN)); + + return FIELD_GET(AR9331_HDR_VERSION_MASK, hdr) == AR9331_HDR_VERSION && + !(hdr & AR9331_HDR_FROM_CPU); +} + +static inline int ar9331_tag_source_port(const u8 *data) +{ + /* hdr comes in LE byte order, so srcport field is in the first byte */ + return FIELD_GET(AR9331_HDR_PORT_NUM_MASK, *(data - ETH_HLEN)); +} + +static inline __be16 ar9331_tag_encap_proto(const u8 *data) +{ + return *(__be16 *)data; +} + static struct sk_buff *ar9331_tag_xmit(struct sk_buff *skb, struct net_device *dev) { @@ -50,36 +69,27 @@ static struct sk_buff *ar9331_tag_rcv(struct sk_buff *skb, struct net_device *ndev, struct packet_type *pt) { - u8 ver, port; - u16 hdr; + int port; if (unlikely(!pskb_may_pull(skb, AR9331_HDR_LEN))) return NULL; - hdr = le16_to_cpu(*(__le16 *)skb_mac_header(skb)); - - ver = FIELD_GET(AR9331_HDR_VERSION_MASK, hdr); - if (unlikely(ver != AR9331_HDR_VERSION)) { - netdev_warn_once(ndev, "%s:%i wrong header version 0x%2x\n", - __func__, __LINE__, hdr); - return NULL; - } - - if (unlikely(hdr & AR9331_HDR_FROM_CPU)) { - netdev_warn_once(ndev, "%s:%i packet should not be from cpu 0x%2x\n", - __func__, __LINE__, hdr); + if (unlikely(!ar9331_tag_sanity_check(skb->data))) { + netdev_warn_once(ndev, + "%s:%i wrong header version or source port\n", + __func__, __LINE__); return NULL; } - skb_pull_rcsum(skb, AR9331_HDR_LEN); - /* Get source port information */ - port = FIELD_GET(AR9331_HDR_PORT_NUM_MASK, hdr); + port = ar9331_tag_source_port(skb->data); skb->dev = dsa_master_find_slave(ndev, 0, port); if (!skb->dev) return NULL; + skb_pull_rcsum(skb, AR9331_HDR_LEN); + return skb; } @@ -87,7 +97,7 @@ static void ar9331_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, int *offset) { *offset = AR9331_HDR_LEN; - *proto = *(__be16 *)skb->data; + *proto = ar9331_tag_encap_proto(skb->data); } static const struct dsa_device_ops ar9331_netdev_ops = { From patchwork Mon Dec 30 14:30:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313259 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E46714E3 for ; Mon, 30 Dec 2019 14:49:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E0BAA20663 for ; Mon, 30 Dec 2019 14:49:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oivlaSSA"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="WEUab1cB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0BAA20663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Of/LDPfbFb/AdUXmhtTYEjNIybuKq/S7J26QxoUfN9Q=; b=oivlaSSAIoNnDj wAKpDiBrrQre7i+7Kdkn6tLou+aPKRK0wpdveTF6AWqxg3ljjvTnpAhP4nH/DkFbPr7QQXGxj3QSb 73Y6gMO2IN8N91r+DoFgjVgkxnFYZExJOzjEabj+y75JKgl4z1f/FvEEUBejY3nOg8KWzHFdxfzks 3moAamjze5lg8dkUDsMmor/VUgjZkh7czgou+DbdHJR3Uq8NYixYqSZKUGPDZps/ZE6AjbPPmT3OF Zc4SzbTlv+BnITFizcYFQ5uLVhV6fYOxORBSmWrm8p6Yc3U8hubn2I9vvOwBw9YOl9V4oxMDBpfzL AYBkyvHfwKc5WkFIuhyA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwM1-00023z-Lm; Mon, 30 Dec 2019 14:49:09 +0000 Received: from fd.dlink.ru ([178.170.168.18]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFc-0003yr-Rs; Mon, 30 Dec 2019 14:42:36 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id 631DA1B205DF; Mon, 30 Dec 2019 17:32:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 631DA1B205DF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716329; bh=n2vYVzB39mJzBIUNOizuSzaLB2BB0ciDP2ax+76PUW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WEUab1cBnDDhdofGowRffq6sVSz1KrGZ8L+hGjnd6F1cW/SvyukpK2dFwGyzM9fZR o4lu4MS6p7AaWB9KoOoGq+mBqWH3V8QDsAESoCOF+RgY4FJqSMsRkVWlRF/gW/4e0s aFEChcMZ2MarNFOa93eVXP+6Apa7gyRrkU3zQhds= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id 113301B20B5F; Mon, 30 Dec 2019 17:31:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 113301B20B5F Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id E5D7D1B229D0; Mon, 30 Dec 2019 17:31:10 +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:10 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 05/19] net: dsa: tag_ar9331: add GRO callbacks Date: Mon, 30 Dec 2019 17:30:13 +0300 Message-Id: <20191230143028.27313-6-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064233_301425_9EEF0AA2 X-CRM114-Status: GOOD ( 12.50 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Add GRO callbacks to the AR9331 tagger so GRO layer can now process such frames. Signed-off-by: Alexander Lobakin --- net/dsa/tag_ar9331.c | 77 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/net/dsa/tag_ar9331.c b/net/dsa/tag_ar9331.c index c22c1b515e02..99cc7fd92d8e 100644 --- a/net/dsa/tag_ar9331.c +++ b/net/dsa/tag_ar9331.c @@ -100,12 +100,89 @@ static void ar9331_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, *proto = ar9331_tag_encap_proto(skb->data); } +static struct sk_buff *ar9331_tag_gro_receive(struct list_head *head, + struct sk_buff *skb) +{ + const struct packet_offload *ptype; + struct sk_buff *p, *pp = NULL; + u32 data_off, data_end; + const u8 *data; + int flush = 1; + + data_off = skb_gro_offset(skb); + data_end = data_off + AR9331_HDR_LEN; + + data = skb_gro_header_fast(skb, data_off); + if (skb_gro_header_hard(skb, data_end)) { + data = skb_gro_header_slow(skb, data_end, data_off); + if (unlikely(!data)) + goto out; + } + + /* Data that is to the left from the current position is already + * pulled to the head + */ + if (unlikely(!ar9331_tag_sanity_check(skb->data + data_off))) + goto out; + + rcu_read_lock(); + + ptype = gro_find_receive_by_type(ar9331_tag_encap_proto(data)); + if (!ptype) + goto out_unlock; + + flush = 0; + + list_for_each_entry(p, head, list) { + if (!NAPI_GRO_CB(p)->same_flow) + continue; + + if (ar9331_tag_source_port(skb->data + data_off) ^ + ar9331_tag_source_port(p->data + data_off)) + NAPI_GRO_CB(p)->same_flow = 0; + } + + skb_gro_pull(skb, AR9331_HDR_LEN); + skb_gro_postpull_rcsum(skb, data, AR9331_HDR_LEN); + + pp = call_gro_receive(ptype->callbacks.gro_receive, head, skb); + +out_unlock: + rcu_read_unlock(); +out: + skb_gro_flush_final(skb, pp, flush); + + return pp; +} + +static int ar9331_tag_gro_complete(struct sk_buff *skb, int nhoff) +{ + const struct packet_offload *ptype; + int err = -ENOENT; + __be16 proto; + + proto = ar9331_tag_encap_proto(skb->data + nhoff); + nhoff += AR9331_HDR_LEN; + + rcu_read_lock(); + + ptype = gro_find_complete_by_type(proto); + if (ptype) + err = ptype->callbacks.gro_complete(skb, nhoff); + + rcu_read_unlock(); + + return err; +} + static const struct dsa_device_ops ar9331_netdev_ops = { .name = "ar9331", .proto = DSA_TAG_PROTO_AR9331, .xmit = ar9331_tag_xmit, .rcv = ar9331_tag_rcv, .flow_dissect = ar9331_tag_flow_dissect, + .gro_receive = ar9331_tag_gro_receive, + .gro_complete = ar9331_tag_gro_complete, .overhead = AR9331_HDR_LEN, }; From patchwork Mon Dec 30 14:30:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313235 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6548814E3 for ; Mon, 30 Dec 2019 14:46:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 24F8E20663 for ; Mon, 30 Dec 2019 14:46:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hc/wYolJ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="bTfUYnEb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 24F8E20663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vMAXhO0atorXDKgwnO2dtRBvbqYBj185o6Y7XaEVsZI=; b=hc/wYolJAF2GWV W6xqqYxlSizFSr3EG5HQIBtFrvVl68J6g864TuRUIBRgElGzUGkjsahPBP66iWgBO+6fIE2L20K3V sA+g5Ks80OKy9ONs+9vvGxUBLs/CASj/ZBgC7KyELnbcD5ifJS+JNhNKxQul1LyPJZi5XxK/hfmHO h2lIweun9btM4BarnvSNUs//qeUE5ZKteKQiuOqHVDUiZNGbiWV7+zOe2UvYv2sKIlJ1UmV1cmJ6c uC+M8aCtk9eL1Bnq4p58j0yx0kQ3tEqrIHvVKXlEmFauxrhZW6Q/8C7MsFSxsxFwbA/fvVCVA8Pmw kiVZw9oSp3NXrGeI0ttQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwJc-00086i-TB; Mon, 30 Dec 2019 14:46:40 +0000 Received: from fd.dlink.ru ([178.170.168.18]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFc-0003yn-Td; Mon, 30 Dec 2019 14:42:35 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id AB3131B2195D; Mon, 30 Dec 2019 17:32:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru AB3131B2195D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716335; bh=7OSwCRil5bvUGDc9SU5jjL6pENQDuKNpW1Evf4I2LJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bTfUYnEbwx9UKdlFqoxFUlqG4FBl2tw4lNIFQ5wUqpO7HNbGor4glHL54EJzHI64q vndN/zPoL87nn28z1uVpu9eqS5zmzWbpejIjFxRjSoi1HQXqa2n9Lk/EIa29waoIK/ W7B6ZRubDFo0UDdMzeHBFuV+ZSyRK2mBvprOT3rU= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id CE9171B2085D; Mon, 30 Dec 2019 17:31:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru CE9171B2085D Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id 02BE81B229D1; Mon, 30 Dec 2019 17:31:13 +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:12 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 06/19] net: dsa: tag_gswip: fix typo in tag name Date: Mon, 30 Dec 2019 17:30:14 +0300 Message-Id: <20191230143028.27313-7-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064233_163003_6722FDC0 X-CRM114-Status: UNSURE ( 9.91 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org "gwsip" -> "gswip". Signed-off-by: Alexander Lobakin Reviewed-by: Andrew Lunn --- net/dsa/tag_gswip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/dsa/tag_gswip.c b/net/dsa/tag_gswip.c index b678160bbd66..408d4af390a0 100644 --- a/net/dsa/tag_gswip.c +++ b/net/dsa/tag_gswip.c @@ -104,7 +104,7 @@ static struct sk_buff *gswip_tag_rcv(struct sk_buff *skb, } static const struct dsa_device_ops gswip_netdev_ops = { - .name = "gwsip", + .name = "gswip", .proto = DSA_TAG_PROTO_GSWIP, .xmit = gswip_tag_xmit, .rcv = gswip_tag_rcv, From patchwork Mon Dec 30 14:30:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313217 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F7C313A4 for ; Mon, 30 Dec 2019 14:44:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5A8B720663 for ; Mon, 30 Dec 2019 14:44:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="n5GIfZcb"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="W+81RZh7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5A8B720663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p3PSQQY3KnjTBA7EsCXNPxuv6dYUjyraZ0t0mv2LeLk=; b=n5GIfZcb1qqmBx QESaD3u/Z90JuiNvlY6+Y9N0nlbcv4lcZvgQDHAbOqnK0g6SplpHRgn4Qia38OljAWLmvF0Qz9bnM mwqkRS+L825LN7VIWuGDC0kVB63PG568Ms9bUAyvEO3MNc6PbM0aUc+D8fBnX4kmDYtlLOatxhwYF tYm9EeuCYxh5S0iFK+fvbronv3lWxgauXB/wVjUw6YmXL34hTxyxNXHsg891Z1KoWo50KWPbbioZn M32C3gtNgHRlUmSTH78/0k/ajGdTB9RuHKZ5xSH2neQRUDbafi3wJ337mdf2qLy9QPyDSzm/m3/jp E3u/x+SqBErBmVCWCtTg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwHc-0005TE-01; Mon, 30 Dec 2019 14:44:36 +0000 Received: from fd.dlink.ru ([178.170.168.18]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFY-0003vx-Gh; Mon, 30 Dec 2019 14:42:31 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id 03CEF1B218C1; Mon, 30 Dec 2019 17:32:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 03CEF1B218C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716365; bh=oevogiD6ZZjPjhds8OttybiSWL3W+YH+lNJv5xktFv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W+81RZh70xRv2YQ9Uh/40TpcbYlXCM7cscSdVj2AQL+6x/LphC0er7cU2TZNb6wzW 8gtpweVg6mCswv3aiRHrQoVZdXzhGJDWT/M7REGe9bDjiITIsizcSal/sfUmPoi1cK FKyfrqTEEud4FrqpG4Qydzr8qitHV/q3Tofw3AWQ= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id 0E58B1B2176F; Mon, 30 Dec 2019 17:31:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 0E58B1B2176F Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id D02B21B229CB; Mon, 30 Dec 2019 17:31:14 +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:14 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 07/19] net: dsa: tag_gswip: switch to bitfield helpers Date: Mon, 30 Dec 2019 17:30:15 +0300 Message-Id: <20191230143028.27313-8-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064228_911362_3C0940DB X-CRM114-Status: GOOD ( 10.08 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Make code look cleaner and more readable by using bitfield macros instead of open-coding masks and shifts. Misc: remove redundant variable in gswip_tag_xmit(), make dsa_port const. Signed-off-by: Alexander Lobakin --- net/dsa/tag_gswip.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/net/dsa/tag_gswip.c b/net/dsa/tag_gswip.c index 408d4af390a0..de920f6aac5b 100644 --- a/net/dsa/tag_gswip.c +++ b/net/dsa/tag_gswip.c @@ -5,6 +5,7 @@ * Copyright (C) 2017 - 2018 Hauke Mehrtens */ +#include #include #include #include @@ -45,26 +46,22 @@ #define GSWIP_TX_CLASS_MASK GENMASK(3, 0) /* Byte 3 */ +#define GSWIP_TX_PORT_MAP(port) FIELD_PREP(GENMASK(6, 1), BIT(port)) #define GSWIP_TX_DPID_EN BIT(0) -#define GSWIP_TX_PORT_MAP_SHIFT 1 -#define GSWIP_TX_PORT_MAP_MASK GENMASK(6, 1) -#define GSWIP_RX_HEADER_LEN 8 +#define GSWIP_RX_HEADER_LEN 8 /* special tag in RX path header */ /* Byte 7 */ -#define GSWIP_RX_SPPID_SHIFT 4 -#define GSWIP_RX_SPPID_MASK GENMASK(6, 4) +#define GSWIP_RX_SPPID(byte_7) FIELD_GET(GENMASK(6, 4), byte_7) static struct sk_buff *gswip_tag_xmit(struct sk_buff *skb, struct net_device *dev) { - struct dsa_port *dp = dsa_slave_to_port(dev); - int err; + const struct dsa_port *dp = dsa_slave_to_port(dev); u8 *gswip_tag; - err = skb_cow_head(skb, GSWIP_TX_HEADER_LEN); - if (err) + if (skb_cow_head(skb, GSWIP_TX_HEADER_LEN)) return NULL; skb_push(skb, GSWIP_TX_HEADER_LEN); @@ -73,8 +70,7 @@ static struct sk_buff *gswip_tag_xmit(struct sk_buff *skb, gswip_tag[0] = GSWIP_TX_SLPID_CPU; gswip_tag[1] = GSWIP_TX_DPID_ELAN; gswip_tag[2] = GSWIP_TX_PORT_MAP_EN | GSWIP_TX_PORT_MAP_SEL; - gswip_tag[3] = BIT(dp->index + GSWIP_TX_PORT_MAP_SHIFT) & GSWIP_TX_PORT_MAP_MASK; - gswip_tag[3] |= GSWIP_TX_DPID_EN; + gswip_tag[3] = GSWIP_TX_PORT_MAP(dp->index) | GSWIP_TX_DPID_EN; return skb; } @@ -84,15 +80,13 @@ static struct sk_buff *gswip_tag_rcv(struct sk_buff *skb, struct packet_type *pt) { int port; - u8 *gswip_tag; if (unlikely(!pskb_may_pull(skb, GSWIP_RX_HEADER_LEN))) return NULL; - gswip_tag = skb->data - ETH_HLEN; - /* Get source port information */ - port = (gswip_tag[7] & GSWIP_RX_SPPID_MASK) >> GSWIP_RX_SPPID_SHIFT; + port = GSWIP_RX_SPPID(*(skb->data - ETH_HLEN + 7)); + skb->dev = dsa_master_find_slave(dev, 0, port); if (!skb->dev) return NULL; From patchwork Mon Dec 30 14:30:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313269 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A517013A4 for ; Mon, 30 Dec 2019 14:49:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8351620663 for ; Mon, 30 Dec 2019 14:49:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eSV9DGRk"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="sGO8qxyG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8351620663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HOFhD3ncRjqbCpGERTalAxElMeJRq2FSd/vnGMp6AyE=; b=eSV9DGRkZqlk1+ m0v/1jJwqHZuohBrHFALLe9V81x1CiosAEBBTxqQh5Wx57+6MVkMg3lhzyIlXmHMkKnl5CshsRm/l AxYRJHS7mUaPrnn+oEG7GXNhMR0aavuox2Y0th1eM2BOBpvGeWvKXRDYQiHT6ZvpmRT5RkvcQ3rV3 o11cJvuffh5ICjmZUDIcQADDzgk7L9CSPGI7WFuhlXaI2DVrZupiIuBTLhvlso+dYjG2A5KeJ9D1e FpkxXF9UV8MYfELiWCZXKXZbSMNxumFJ3HJfqLOQC1Fklh5Xi55mUHkW6/rQkGbFUQ335px2nr7sf VF+gtQtgiQaLrONQslyA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwMB-0002H7-HA; Mon, 30 Dec 2019 14:49:19 +0000 Received: from mail.dlink.ru ([178.170.168.18] helo=fd.dlink.ru) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFe-0003xV-9G; Mon, 30 Dec 2019 14:42:38 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id 31CC51B218DB; Mon, 30 Dec 2019 17:32:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 31CC51B218DB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716369; bh=NXl5VU/NmF4XHV2zVViXhu4aInL/BB6UJlu0+qQYx4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sGO8qxyGYybn/Po1WmhPp1sGjgBeQTnyzxajt/66jqkR93107HgRiCDRncWOJ2xlH 9i+loa1yrvFE4FNXlgrOJD7tI2hsgb57/2uZejcAO8VOYrNMBKPtvdAX+exBfg3fPl Nrkzx5bxiaEhjgRf7SsEiDsGwaLCnrtK0tkXmJmE= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id 1C4DF1B217AA; Mon, 30 Dec 2019 17:31:19 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 1C4DF1B217AA Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id DF39D1B229D0; Mon, 30 Dec 2019 17:31:16 +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:16 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 08/19] net: dsa: tag_gswip: add .flow_dissect() callback Date: Mon, 30 Dec 2019 17:30:16 +0300 Message-Id: <20191230143028.27313-9-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064235_362451_671B0EA2 X-CRM114-Status: UNSURE ( 9.20 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org In case user would like to configure RPS on such systems. Misc: fix identation of gswip_netdev_ops structure. Signed-off-by: Alexander Lobakin --- net/dsa/tag_gswip.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/net/dsa/tag_gswip.c b/net/dsa/tag_gswip.c index de920f6aac5b..d37289540ef3 100644 --- a/net/dsa/tag_gswip.c +++ b/net/dsa/tag_gswip.c @@ -97,12 +97,20 @@ static struct sk_buff *gswip_tag_rcv(struct sk_buff *skb, return skb; } +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); +} + static const struct dsa_device_ops gswip_netdev_ops = { - .name = "gswip", - .proto = DSA_TAG_PROTO_GSWIP, - .xmit = gswip_tag_xmit, - .rcv = gswip_tag_rcv, - .overhead = GSWIP_RX_HEADER_LEN, + .name = "gswip", + .proto = DSA_TAG_PROTO_GSWIP, + .xmit = gswip_tag_xmit, + .rcv = gswip_tag_rcv, + .flow_dissect = gswip_tag_flow_dissect, + .overhead = GSWIP_RX_HEADER_LEN, }; MODULE_LICENSE("GPL"); From patchwork Mon Dec 30 14:30:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313257 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A448F14E3 for ; Mon, 30 Dec 2019 14:49:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8017120663 for ; Mon, 30 Dec 2019 14:49:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HywTvMTj"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="ifBh0oM5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8017120663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sijzIpDAPDLqB2NWt111Xigdd8U0R9aO+23O2Y8/93g=; b=HywTvMTjCq9VyY pGi63AAO49x261CCJL3CV+09WoirEXoVjL6f4wwvufFXBvSDEtNVWr1f9I2cd78qTTNEdMFWRSNof EsYUOtRr7IVxv23TckCC7x9wHzwvehtK//zDxMQ5GBORLIFarHyLiUP0RmHYB+0FIRRuQWFZ887Mg PMMqVDy2wksBIjI8Yfmkt29wfen3oxDZKXf5lr/KZo/6pvKRwsR7UbgYqT5VsHMSn1majzIe/VYlN ToJtCw/kv7IwY8EC8q8RjMyBza18ZXPY2iBjUsveAqBugNnvfBvk4QWOk1XBhagCWO3iypgg2uEty 9+SMHLWLT3hTys5tuMhg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwLy-00021y-Nb; Mon, 30 Dec 2019 14:49:06 +0000 Received: from mail.dlink.ru ([178.170.168.18] helo=fd.dlink.ru) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFc-0003yk-MR; Mon, 30 Dec 2019 14:42:34 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id 8DC4D1B219A9; Mon, 30 Dec 2019 17:33:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 8DC4D1B219A9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716397; bh=Erjvba4dIKrPISREjV3SM+2wcBTCz6oIK+5iwW6Xun4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ifBh0oM5RjN1pJshxUJUxApGaPZXJAsSdc+JnKIY1A+up2KDhgQw6uZlU3OLZHSa0 ayaubqSP83ACs2fBOlRmtYIkjxO+cRl+qYeuyGgPtIlsyBqh7nWL+2tlB8MNjp9/6T y+d0jFxDU9kQdZnzGiPKwRi66NsWfSl4/uZMqZqE= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 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" 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064233_128284_41A26389 X-CRM114-Status: UNSURE ( 9.53 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.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 = { From patchwork Mon Dec 30 14:30:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313233 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5329714E3 for ; Mon, 30 Dec 2019 14:46:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 197AB20663 for ; Mon, 30 Dec 2019 14:46:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IpdwgOrq"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="mf6GRk88" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 197AB20663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8MDEcCJ9LmJlHPUfNkZN+zpBPeGfHmzYKbISFX6lr8I=; b=IpdwgOrqgEH7hz oz/yzaxYFa5kZ+DV1rjIbMUb5iqT/TSq8ENdXAjwuaniLfkQA35C80xyROxwMc8fVNqtDEf1fMeyA Ms+YNY64iH9SVg4iQ2/s+FQNbC2pEyvvI0ueo5KUSWffe0sDA9QOcU2v1CV+aDeqVtEAhVW23C4oZ PdgzkoSnLaaJuSlYiwtPL90iBLjOdwyU5DeC0WMpfdJHdV0rrLQWtrYhDNBNYaPGJTHbaJ6b/4UBT cad3wLGoA8H2GeE0reXYbYV2PTqDkrqtl0woGwOLZ2hkYDKwyYDU27qNKW8v11WI0j1GH3QhDOuNy YqbPAbXlSFW1F7SxTnIg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwJY-000845-0P; Mon, 30 Dec 2019 14:46:36 +0000 Received: from mail.dlink.ru ([178.170.168.18] helo=fd.dlink.ru) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFb-0003xW-0n; Mon, 30 Dec 2019 14:42:34 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id E10151B218BD; Mon, 30 Dec 2019 17:33:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru E10151B218BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716397; bh=q7IufE7HIiHvycVJgjMYvuW6fyhlbqwjI/W5rJkX8G8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mf6GRk88E1XfIfsnXAFdJgb76JNyC8VZruLzcc8i9vhYiuIBuiP8k1vMmOAz4Frcr QFGoBSK8vV42BzYmmt43dnEUuagjawjBucnhJ225rqsR72hcCGzJ3cFPuzXGQ925xT s3I94OATlkcN8/YEbe7QwLRlApxsfqR6dY2xUy6U= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id 5AEF91B20B7B; Mon, 30 Dec 2019 17:31:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 5AEF91B20B7B Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id 3BD431B229CB; Mon, 30 Dec 2019 17:31:21 +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:21 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 10/19] net: dsa: tag_gswip: add GRO callbacks Date: Mon, 30 Dec 2019 17:30:18 +0300 Message-Id: <20191230143028.27313-11-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064231_442965_2A6DF371 X-CRM114-Status: GOOD ( 11.94 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org ...so that GRO layer can now correctly process GSWIP-tagged frames. Signed-off-by: Alexander Lobakin --- net/dsa/tag_gswip.c | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/net/dsa/tag_gswip.c b/net/dsa/tag_gswip.c index e7b36de27fd8..56e754bd434a 100644 --- a/net/dsa/tag_gswip.c +++ b/net/dsa/tag_gswip.c @@ -114,12 +114,86 @@ static void gswip_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, *proto = gswip_tag_encap_proto(skb->data); } +static struct sk_buff *gswip_tag_gro_receive(struct list_head *head, + struct sk_buff *skb) +{ + const struct packet_offload *ptype; + struct sk_buff *p, *pp = NULL; + u32 data_off, data_end; + const u8 *data; + int flush = 1; + + data_off = skb_gro_offset(skb); + data_end = data_off + GSWIP_RX_HEADER_LEN; + + data = skb_gro_header_fast(skb, data_off); + if (skb_gro_header_hard(skb, data_end)) { + data = skb_gro_header_slow(skb, data_end, data_off); + if (unlikely(!data)) + goto out; + } + + rcu_read_lock(); + + ptype = gro_find_receive_by_type(gswip_tag_encap_proto(data)); + if (!ptype) + goto out_unlock; + + flush = 0; + + list_for_each_entry(p, head, list) { + if (!NAPI_GRO_CB(p)->same_flow) + continue; + + /* Data that is to the left to the current position is already + * pulled to the head + */ + if (gswip_tag_source_port(skb->data + data_off) ^ + gswip_tag_source_port(p->data + data_off)) + NAPI_GRO_CB(p)->same_flow = 0; + } + + skb_gro_pull(skb, GSWIP_RX_HEADER_LEN); + skb_gro_postpull_rcsum(skb, data, GSWIP_RX_HEADER_LEN); + + pp = call_gro_receive(ptype->callbacks.gro_receive, head, skb); + +out_unlock: + rcu_read_unlock(); +out: + skb_gro_flush_final(skb, pp, flush); + + return pp; +} + +static int gswip_tag_gro_complete(struct sk_buff *skb, int nhoff) +{ + const struct packet_offload *ptype; + int err = -ENOENT; + __be16 proto; + + proto = gswip_tag_encap_proto(skb->data + nhoff); + nhoff += GSWIP_RX_HEADER_LEN; + + rcu_read_lock(); + + ptype = gro_find_complete_by_type(proto); + if (ptype) + err = ptype->callbacks.gro_complete(skb, nhoff); + + rcu_read_unlock(); + + return err; +} + static const struct dsa_device_ops gswip_netdev_ops = { .name = "gswip", .proto = DSA_TAG_PROTO_GSWIP, .xmit = gswip_tag_xmit, .rcv = gswip_tag_rcv, .flow_dissect = gswip_tag_flow_dissect, + .gro_receive = gswip_tag_gro_receive, + .gro_complete = gswip_tag_gro_complete, .overhead = GSWIP_RX_HEADER_LEN, }; From patchwork Mon Dec 30 14:30:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313261 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8877913A4 for ; Mon, 30 Dec 2019 14:49:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 30DC42071E for ; Mon, 30 Dec 2019 14:49:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gayG/d4e"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="O/FVi7pI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30DC42071E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qhhVG2TOZQnq3YtepuPPMwdPvls3kHP3gj/tV82AFOc=; b=gayG/d4eoq2Rhb VGzS9oxEEkoKGEYf41Tm8nESk4aowke56auCTMK/fPzfG1YmhopWPzInQiYe77Z2G1KlXB/TeagNk Uusx8mQ0dIeWftv0xXoTgl8OKCy8voarjZQ2vZzNCw7XDBZOOH5HlyNWE9nfz4ohyhx4q6+pqwmE0 Um81fARZ4DtkoxdM0TZlrYlyJiiVT/aRKtcfS0SRDBCB7G0i2fqZXYQDY44nePNYE6aEwwiYICi5R OkV8kyo65ssv0091JtuSOuoId6j7COqdrBMtwdFxg04Mrt5A8l8TSpY46fWd4R3GKTzeAxr+fosy/ 6FP/P7mLfdoSvCHQF4Sw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwM3-00025j-CP; Mon, 30 Dec 2019 14:49:11 +0000 Received: from mail.dlink.ru ([178.170.168.18] helo=fd.dlink.ru) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFd-0003xY-4w; Mon, 30 Dec 2019 14:42:37 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id B08931B2196B; Mon, 30 Dec 2019 17:33:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru B08931B2196B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716416; bh=YK6u2SeWu80P0OI5Ey+MvrHZ5A/LDUTcrFuPYPEXrWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=O/FVi7pIJ19rPaWCeIhTGpgbnXWL0lK2fz6ou6mmBXE83LNYfFlRUR0bTHJKoDHLq gR90XmpWWhvD08FNbpaRXTtKoavvbnXGNo8BfZq+9EnZlel3XBHMys+j5pzEsM2C8J QAqWQvI9U3pRSE7a3XATiBSuqAf6tQJOfjkcAIsM= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id 5C4301B2181E; Mon, 30 Dec 2019 17:31:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 5C4301B2181E Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id 5FCF01B229D0; Mon, 30 Dec 2019 17:31:23 +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:23 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 11/19] net: dsa: tag_lan9303: add .flow_dissect() callback Date: Mon, 30 Dec 2019 17:30:19 +0300 Message-Id: <20191230143028.27313-12-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064233_442396_C51EC539 X-CRM114-Status: UNSURE ( 8.78 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org This fixes Rx packet hashing on RPS-enabled systems. Misc: fix lan9303_netdev_ops identation. Signed-off-by: Alexander Lobakin --- net/dsa/tag_lan9303.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/net/dsa/tag_lan9303.c b/net/dsa/tag_lan9303.c index eb0e7a32e53d..d328a44381a9 100644 --- a/net/dsa/tag_lan9303.c +++ b/net/dsa/tag_lan9303.c @@ -128,12 +128,20 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev, return skb; } +static void lan9303_flow_dissect(const struct sk_buff *skb, __be16 *proto, + int *offset) +{ + *offset = LAN9303_TAG_LEN; + *proto = *(__be16 *)(skb->data + 2); +} + static const struct dsa_device_ops lan9303_netdev_ops = { - .name = "lan9303", - .proto = DSA_TAG_PROTO_LAN9303, - .xmit = lan9303_xmit, - .rcv = lan9303_rcv, - .overhead = LAN9303_TAG_LEN, + .name = "lan9303", + .proto = DSA_TAG_PROTO_LAN9303, + .xmit = lan9303_xmit, + .rcv = lan9303_rcv, + .flow_dissect = lan9303_flow_dissect, + .overhead = LAN9303_TAG_LEN, }; MODULE_LICENSE("GPL"); From patchwork Mon Dec 30 14:30:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313245 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 994DB13A4 for ; Mon, 30 Dec 2019 14:48:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5368220663 for ; Mon, 30 Dec 2019 14:48:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fAiVixNK"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="AEmV+Pzo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5368220663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TwPF+TxucSeqofQj3+q3AHoVHkdj+kkmELkSLypXazk=; b=fAiVixNK2gebn2 ASsufAah/Zx6TymSxJFAnMA8tO71Qis5yXYUD7BllmJ7ovF/O/5uinG+tNaFRUAjFngUlHpAhEQnK zwXVhPbnB55nuQo8/Mxj605KYncQTa+FXfEz8nyId18HlLz31JYX/UC+arSXLryMySnYv6oFYpjpn whT8mtDO1OezdZs9GDk712N8wl0PyqrgkIZ8C3MMGMwSsr1wx8NIl2KT6lTgfppSFlwsSfl+QLZJQ EF03J/dw38dWqDJ5PPjLsFWOlJx9ONtYAnSmS2IU/gi+ztqRfzHqGniFhqwAwK36SdGKDRK3XAV4z OPV2rmAydQT5EYaU1Mpg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwKs-0000f3-1i; Mon, 30 Dec 2019 14:47:58 +0000 Received: from mail.dlink.ru ([178.170.168.18] helo=fd.dlink.ru) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFb-0003xV-0X; Mon, 30 Dec 2019 14:42:33 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id C7A1F1B218EC; Mon, 30 Dec 2019 17:32:02 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru C7A1F1B218EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716322; bh=K9IglDMfo6fAz8oDQ8Cy06HvYvmttudvu1VgNCQnFXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AEmV+PzosTQy+ffRHWc7q8N5rnnRC5TmOT5+nRzFPZZCQzN1B4i0WyBid1CGiUZqp eY1GlsWriOtgr+G7r8uRuYqqKSqbqP0QQZTjdHP2ed/kYjiurHwwmfUIrulHo900+6 k3ovWwWBOoNzTwWZwsfNRyP9/4AAVIfiiO6uCwpc= Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id 615FD1B21809; Mon, 30 Dec 2019 17:31:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 615FD1B21809 Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id 5C76B1B229CB; Mon, 30 Dec 2019 17:31:25 +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:25 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 12/19] net: dsa: tag_lan9303: split out common tag accessors Date: Mon, 30 Dec 2019 17:30:20 +0300 Message-Id: <20191230143028.27313-13-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064231_439621_322992FC X-CRM114-Status: GOOD ( 13.43 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org ...as they will be needed in the upcoming GRO callbacks. Signed-off-by: Alexander Lobakin --- net/dsa/tag_lan9303.c | 46 +++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/net/dsa/tag_lan9303.c b/net/dsa/tag_lan9303.c index d328a44381a9..ba03502986a4 100644 --- a/net/dsa/tag_lan9303.c +++ b/net/dsa/tag_lan9303.c @@ -38,6 +38,32 @@ # define LAN9303_TAG_RX_TRAPPED_TO_CPU (LAN9303_TAG_RX_IGMP | \ LAN9303_TAG_RX_STP) +static inline bool lan9303_sanity_check(const u8 *data) +{ + /* '->data' points into the middle of our special VLAN tag information: + * + * ~ MAC src | 0x81 | 0x00 | 0xyy | 0xzz | ether type + * ^ + * ->data + */ + return *(__be16 *)(data - 2) == htons(ETH_P_8021Q); +} + +static inline bool lan9303_trapped_to_cpu(const u8 *data) +{ + return *(data + 1) & LAN9303_TAG_RX_TRAPPED_TO_CPU; +} + +static inline int lan9303_source_port(const u8 *data) +{ + return *(data + 1) & GENMASK(1, 0); +} + +static inline __be16 lan9303_encap_proto(const u8 *data) +{ + return *(__be16 *)(data + 2); +} + /* Decide whether to transmit using ALR lookup, or transmit directly to * port using tag. ALR learning is performed only when using ALR lookup. * If the two external ports are bridged and the frame is unicast, @@ -85,8 +111,6 @@ static struct sk_buff *lan9303_xmit(struct sk_buff *skb, struct net_device *dev) static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) { - u16 *lan9303_tag; - u16 lan9303_tag1; unsigned int source_port; if (unlikely(!pskb_may_pull(skb, LAN9303_TAG_LEN))) { @@ -95,21 +119,12 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev, return NULL; } - /* '->data' points into the middle of our special VLAN tag information: - * - * ~ MAC src | 0x81 | 0x00 | 0xyy | 0xzz | ether type - * ^ - * ->data - */ - lan9303_tag = (u16 *)(skb->data - 2); - - if (lan9303_tag[0] != htons(ETH_P_8021Q)) { + if (!lan9303_sanity_check(skb->data)) { dev_warn_ratelimited(&dev->dev, "Dropping packet due to invalid VLAN marker\n"); return NULL; } - lan9303_tag1 = ntohs(lan9303_tag[1]); - source_port = lan9303_tag1 & 0x3; + source_port = lan9303_source_port(skb->data); skb->dev = dsa_master_find_slave(dev, 0, source_port); if (!skb->dev) { @@ -117,13 +132,14 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev, return NULL; } + skb->offload_fwd_mark = !lan9303_trapped_to_cpu(skb->data); + /* remove the special VLAN tag between the MAC addresses * and the current ethertype field. */ skb_pull_rcsum(skb, 2 + 2); memmove(skb->data - ETH_HLEN, skb->data - (ETH_HLEN + LAN9303_TAG_LEN), 2 * ETH_ALEN); - skb->offload_fwd_mark = !(lan9303_tag1 & LAN9303_TAG_RX_TRAPPED_TO_CPU); return skb; } @@ -132,7 +148,7 @@ static void lan9303_flow_dissect(const struct sk_buff *skb, __be16 *proto, int *offset) { *offset = LAN9303_TAG_LEN; - *proto = *(__be16 *)(skb->data + 2); + *proto = lan9303_encap_proto(skb->data); } static const struct dsa_device_ops lan9303_netdev_ops = { From patchwork Mon Dec 30 14:30:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313265 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 47C2714E3 for ; Mon, 30 Dec 2019 14:49:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 258B320663 for ; Mon, 30 Dec 2019 14:49:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gLsS8QHu"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="qWSynPqa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 258B320663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6FBq8SKBtrgOOYptgYcZaLVv/vKjtGmiq3Pw34NSoOI=; b=gLsS8QHuGBnZ4F ZydO6BbqMdbtQ7XcXNP851K7sYSrWJO2xuDdDkkPUt0XeTr1Dt+0HE9bvyneIQDdktGJLRUJak5P2 AQnGx2zbLkQCuMMtftyqj6udLerTmHt0PtuKnoSVNwNP3gxR0+9ykonBObhwsHF6PhvIjYcQb6gTN TdPjACZpsLwd7HWvj7KtTN9NvwT4P+ZFJSfwRQCU3zbhpsXXmkYr4K01sLvodMyTqG8nczevgWTlb 5qGC8iCPHgJhsbmyTLPqT9IICjc4i+6VmGjOTFf1DhCRTsYWfn/DvlTWJWNYOAnytDgW6al/X/IRb 1CwKiHSb0xb3bIr53Hyg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwM9-0002Co-4F; Mon, 30 Dec 2019 14:49:17 +0000 Received: from mail.dlink.ru ([178.170.168.18] helo=fd.dlink.ru) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFc-0003yj-PU; Mon, 30 Dec 2019 14:42:37 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id A32B11B2191E; Mon, 30 Dec 2019 17:32:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru A32B11B2191E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716330; bh=SYnifMPQP4kzdSLpDkUORDps+aCxCuIpXYmwM1fEL9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qWSynPqamq2vu3rHWp6/Ys3pxIrOTkLRx3ZezonYii1EquqP08soQTNpX1WjtfEs4 yz8JzEUB2EzofaWNraN5P31GJonoOytZ/1zxAFeyZBKKLcaHo75Z2jU3DNShyScBch lOCVovbzltnCE/K86L53IARuxB6GqHBPxqlI4xOA= Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id 3C8BB1B21825; Mon, 30 Dec 2019 17:31:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 3C8BB1B21825 Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id 678DC1B229D0; Mon, 30 Dec 2019 17:31:27 +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:27 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 13/19] net: dsa: tag_lan9303: add GRO callbacks Date: Mon, 30 Dec 2019 17:30:21 +0300 Message-Id: <20191230143028.27313-14-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064233_295036_836447C8 X-CRM114-Status: GOOD ( 12.07 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Add GRO callbacks for LAN9303 tagger to make GRO available for frames tagged with it. Signed-off-by: Alexander Lobakin --- net/dsa/tag_lan9303.c | 77 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/net/dsa/tag_lan9303.c b/net/dsa/tag_lan9303.c index ba03502986a4..77aba4311f2d 100644 --- a/net/dsa/tag_lan9303.c +++ b/net/dsa/tag_lan9303.c @@ -151,12 +151,89 @@ static void lan9303_flow_dissect(const struct sk_buff *skb, __be16 *proto, *proto = lan9303_encap_proto(skb->data); } +static struct sk_buff *lan9303_gro_receive(struct list_head *head, + struct sk_buff *skb) +{ + const struct packet_offload *ptype; + struct sk_buff *p, *pp = NULL; + const u8 *data, *data_p; + u32 data_off, data_end; + int flush = 1; + + data_off = skb_gro_offset(skb); + data_end = data_off + LAN9303_TAG_LEN; + + data = skb_gro_header_fast(skb, data_off); + if (skb_gro_header_hard(skb, data_end)) { + data = skb_gro_header_slow(skb, data_end, data_off); + if (unlikely(!data)) + goto out; + } + + /* Data that is to the left to the current position is already + * pulled to the head + */ + if (!lan9303_sanity_check(skb->data + data_off)) + goto out; + + rcu_read_lock(); + + ptype = gro_find_receive_by_type(lan9303_encap_proto(data)); + if (!ptype) + goto out_unlock; + + flush = 0; + + list_for_each_entry(p, head, list) { + if (!NAPI_GRO_CB(p)->same_flow) + continue; + + data_p = p->data + data_off; + if (lan9303_source_port(data) ^ lan9303_source_port(data_p)) + NAPI_GRO_CB(p)->same_flow = 0; + } + + skb_gro_pull(skb, LAN9303_TAG_LEN); + skb_gro_postpull_rcsum(skb, data, LAN9303_TAG_LEN); + + pp = call_gro_receive(ptype->callbacks.gro_receive, head, skb); + +out_unlock: + rcu_read_unlock(); +out: + skb_gro_flush_final(skb, pp, flush); + + return pp; +} + +static int lan9303_gro_complete(struct sk_buff *skb, int nhoff) +{ + const struct packet_offload *ptype; + int err = -ENOENT; + __be16 proto; + + proto = lan9303_encap_proto(skb->data + nhoff); + nhoff += LAN9303_TAG_LEN; + + rcu_read_lock(); + + ptype = gro_find_complete_by_type(proto); + if (ptype) + err = ptype->callbacks.gro_complete(skb, nhoff); + + rcu_read_unlock(); + + return err; +} + static const struct dsa_device_ops lan9303_netdev_ops = { .name = "lan9303", .proto = DSA_TAG_PROTO_LAN9303, .xmit = lan9303_xmit, .rcv = lan9303_rcv, .flow_dissect = lan9303_flow_dissect, + .gro_receive = lan9303_gro_receive, + .gro_complete = lan9303_gro_complete, .overhead = LAN9303_TAG_LEN, }; From patchwork Mon Dec 30 14:30:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313139 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C6F8109A for ; Mon, 30 Dec 2019 14:43:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB96A20663 for ; Mon, 30 Dec 2019 14:43:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NvT6O7lo"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="pVeNl+Pv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB96A20663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HqDxjmcjMa2ySoBSO/X6nqbMFBZUY6EKjVkiF/9/DDU=; b=NvT6O7lo7bOzWC BbAPbOeFhfi6CIo8imU4gpdoLJtvQAESmCxSzoYHkfMLJgUuR2RYtqilDWfgZtUlFcVLGSzBFGhXF W000xrYK9CQxYU/WXBxYxY2KnEKFh5z9tWl6nq3T4b5GBx14x7i2w+oMpGyizrcazj/1DSe88usOa XD2gyAnMtcuYIHYi2kFFOYJqRu2LxQ4INzYSruawJdcXd7ErcaIUcfsfs0uqWhfAzfpqU8deXqFip RVh8hmm9/t4QYwUwUMNuBDJMBq52Uy4y6BvCjvbapHVvtk9OnG9qAlcVAO18JJIE2tnPjB9MMEOPe RMcSR+HAcyJO/YhbP/Cg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwGE-0004RH-Lx; Mon, 30 Dec 2019 14:43:10 +0000 Received: from mail.dlink.ru ([178.170.168.18] helo=fd.dlink.ru) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFY-0003vp-EY; Mon, 30 Dec 2019 14:42:30 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id 027DC1B219A8; Mon, 30 Dec 2019 17:33:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 027DC1B219A8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716428; bh=omc8QrcNvP8pME1zDqBdaSM8dT/TdIR/78ZE/IJu6BE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pVeNl+Pvn4Yrzl89PReZ1MU+3rtkWE6p2QPhpzLcOjHUrlJ5bR93xJjnPnsswJH+1 KdGgHRB0aNYEe98P84mc/T2kDlJ0XlRXUDKaumqX2OeUp31bMrDUvJY5ZONyQthfnB wMevs+aXuuptlgPhHYlCDzymqq3mrta5FiPoVCrE= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id 041281B21829; Mon, 30 Dec 2019 17:31:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 041281B21829 Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id 3A52F1B229CB; Mon, 30 Dec 2019 17:31:29 +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:29 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 14/19] net: dsa: tag_mtk: split out common tag accessors Date: Mon, 30 Dec 2019 17:30:22 +0300 Message-Id: <20191230143028.27313-15-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064228_852051_57D57C81 X-CRM114-Status: GOOD ( 11.16 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Misc: fix identation of MTK_HDR_LEN and make use of it in mtk_tag_flow_dissect() instead of open-coded value. Signed-off-by: Alexander Lobakin --- net/dsa/tag_mtk.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c index c3ad7b7b142a..b926ffdf5fb5 100644 --- a/net/dsa/tag_mtk.c +++ b/net/dsa/tag_mtk.c @@ -10,12 +10,27 @@ #include "dsa_priv.h" -#define MTK_HDR_LEN 4 +#define MTK_HDR_LEN 4 #define MTK_HDR_XMIT_UNTAGGED 0 #define MTK_HDR_XMIT_TAGGED_TPID_8100 1 #define MTK_HDR_RECV_SOURCE_PORT_MASK GENMASK(2, 0) #define MTK_HDR_XMIT_DP_BIT_MASK GENMASK(5, 0) +static inline int mtk_tag_source_port(const u8 *data) +{ + /* The MTK header is added by the switch between src addr + * and ethertype at this point, skb->data points to 2 bytes + * after src addr so header should be 2 bytes right before. + * The source port field is in the second byte of the tag. + */ + return *(data - 1) & MTK_HDR_RECV_SOURCE_PORT_MASK; +} + +static inline __be16 mtk_tag_encap_proto(const u8 *data) +{ + return *(__be16 *)(data + 2); +} + static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb, struct net_device *dev) { @@ -60,17 +75,15 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) { int port; - __be16 *phdr, hdr; if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN))) return NULL; - /* The MTK header is added by the switch between src addr - * and ethertype at this point, skb->data points to 2 bytes - * after src addr so header should be 2 bytes right before. - */ - phdr = (__be16 *)(skb->data - 2); - hdr = ntohs(*phdr); + port = mtk_tag_source_port(skb->data); + + skb->dev = dsa_master_find_slave(dev, 0, port); + if (!skb->dev) + return NULL; /* Remove MTK tag and recalculate checksum. */ skb_pull_rcsum(skb, MTK_HDR_LEN); @@ -79,21 +92,14 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev, skb->data - ETH_HLEN - MTK_HDR_LEN, 2 * ETH_ALEN); - /* Get source port information */ - port = (hdr & MTK_HDR_RECV_SOURCE_PORT_MASK); - - skb->dev = dsa_master_find_slave(dev, 0, port); - if (!skb->dev) - return NULL; - return skb; } static void mtk_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, int *offset) { - *offset = 4; - *proto = ((__be16 *)skb->data)[1]; + *offset = MTK_HDR_LEN; + *proto = mtk_tag_encap_proto(skb->data); } static const struct dsa_device_ops mtk_netdev_ops = { From patchwork Mon Dec 30 14:30:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313263 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C63A114E3 for ; Mon, 30 Dec 2019 14:49:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A4C1F20663 for ; Mon, 30 Dec 2019 14:49:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZYnfQOpF"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="oU3O3MJ2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4C1F20663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JOxyu48M6cB40Zjh5seUh2kKdQwlxVBng8Q97eF8O+A=; b=ZYnfQOpF3vLPhp ud1m65R9mPPl8JgvU9RJ4aWpddEGVMaq37VsENQv/vryXukA6YbSSyIyZ4Sx5lg8JloqXcvRoJpCB 0MziHz09OxlQ8Tf4H5efHN3O5ZFLQsHnHAFhNRGobRbu2xx2XejP/GTVPvyDezYh+6k0ZzsCKrYu1 Mcm0YLTBIPBbNBV+U+BO5e1P1mkG6hzQfRukRVHF+Bzp+lgybpRvScvJipQhDBAwxrLsZiqERhrBN m8bJAlG6kWX9/oupZms7rszufZq04YP8gocfxLnveg26fM8H/16t2B+uoHYlf9iK0LirMI92VzKzB lGC7xpSS1aGkv/N5h5qA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwM5-00027p-KA; Mon, 30 Dec 2019 14:49:13 +0000 Received: from fd.dlink.ru ([178.170.168.18]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFd-0003zb-Kb; Mon, 30 Dec 2019 14:42:37 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id 694331B21829; Mon, 30 Dec 2019 17:33:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 694331B21829 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716431; bh=5GU07UvxnF6CEe2vyJnNhi1kO3JmRqioFhLZDpggQ5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oU3O3MJ2vbvpM7PeGVFatSWJSsQVT8AuWoWEyQUjkD1UgHkBZdIOng1qBpCt1cs9m rkg8YzOLlTKJ4eaWBCq2ND9lH2B5t4fGTkAU/gkjhNdjZ11TCYPCMeUUlpBL5ncAre VCH4YTb8bPhBsoGpVrq/6IypLadPePkNDJOCuvmY= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id 11B8D1B2184B; Mon, 30 Dec 2019 17:31:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 11B8D1B2184B Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id 24C671B229D0; Mon, 30 Dec 2019 17:31:31 +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:31 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 15/19] net: dsa: tag_mtk: add GRO callbacks Date: Mon, 30 Dec 2019 17:30:23 +0300 Message-Id: <20191230143028.27313-16-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064234_069745_44EFF50B X-CRM114-Status: GOOD ( 11.72 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Make GRO available for frames with MTK tag by adding the corresponding callbacks to MTK tagger. Signed-off-by: Alexander Lobakin --- net/dsa/tag_mtk.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c index b926ffdf5fb5..13d929160283 100644 --- a/net/dsa/tag_mtk.c +++ b/net/dsa/tag_mtk.c @@ -102,12 +102,85 @@ static void mtk_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, *proto = mtk_tag_encap_proto(skb->data); } +static struct sk_buff *mtk_tag_gro_receive(struct list_head *head, + struct sk_buff *skb) +{ + const struct packet_offload *ptype; + struct sk_buff *p, *pp = NULL; + u32 data_off, data_end; + const u8 *data; + int flush = 1; + + data_off = skb_gro_offset(skb); + data_end = data_off + MTK_HDR_LEN; + + data = skb_gro_header_fast(skb, data_off); + if (skb_gro_header_hard(skb, data_end)) { + data = skb_gro_header_slow(skb, data_end, data_off); + if (unlikely(!data)) + goto out; + } + + rcu_read_lock(); + + ptype = gro_find_receive_by_type(mtk_tag_encap_proto(data)); + if (!ptype) + goto out_unlock; + + flush = 0; + + list_for_each_entry(p, head, list) { + if (!NAPI_GRO_CB(p)->same_flow) + continue; + + /* Data that is to the left to the current position is already + * pulled to the head + */ + if (mtk_tag_source_port(skb->data + data_off) ^ + mtk_tag_source_port(p->data + data_off)) + NAPI_GRO_CB(p)->same_flow = 0; + } + + skb_gro_pull(skb, MTK_HDR_LEN); + skb_gro_postpull_rcsum(skb, data, MTK_HDR_LEN); + + pp = call_gro_receive(ptype->callbacks.gro_receive, head, skb); + +out_unlock: + rcu_read_unlock(); +out: + skb_gro_flush_final(skb, pp, flush); + + return pp; +} + +static int mtk_tag_gro_complete(struct sk_buff *skb, int nhoff) +{ + const struct packet_offload *ptype; + int err = -ENOENT; + __be16 proto; + + proto = mtk_tag_encap_proto(skb->data + nhoff); + + rcu_read_lock(); + + ptype = gro_find_complete_by_type(proto); + if (ptype) + err = ptype->callbacks.gro_complete(skb, nhoff + MTK_HDR_LEN); + + rcu_read_unlock(); + + return err; +} + 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, + .gro_receive = mtk_tag_gro_receive, + .gro_complete = mtk_tag_gro_complete, .overhead = MTK_HDR_LEN, }; From patchwork Mon Dec 30 14:30:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313255 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6CCC13A4 for ; Mon, 30 Dec 2019 14:49:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 98F2020663 for ; Mon, 30 Dec 2019 14:49:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="aRLRDy3T"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="GqolDMyh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 98F2020663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CprjZz0L/O/5KE/jbaSlVSeAkwjEr/CeQX9i4imaeGo=; b=aRLRDy3TIdbzca DuYCYCnQ3aj/6syjnUn/16/GFkJpbIeAeyY0hfhDMyiPmvvSai7QhMrbussLKZ1jx4UXBm7V6Y9r2 HxMfeAP/HgnGcjXrC2vZyodlJLeXITN/TedGV1xbqOx7TlxsgZMv/CjXZwCGHBUb1BLZgUqKA+Fax D82F+M/8XPa4XjI+r7YO4IDhiTDcH68DYkrAreWlwxEbxHwCs/WspPaCnxxWqIoWo5VZuGfHzz7j3 1+Xx5tcZYLt8dOH+aE/khlt7XRuTAYaiGrwESZP1FGKaDMNs6vFq6alPFODCpX7TgWIlGg3C6VM5w uil2OnQF7IhqEonVy36g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwLt-0001xt-V9; Mon, 30 Dec 2019 14:49:02 +0000 Received: from fd.dlink.ru ([178.170.168.18]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFc-0003ym-Mf; Mon, 30 Dec 2019 14:42:34 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id A3CB61B218D4; Mon, 30 Dec 2019 17:32:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru A3CB61B218D4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716346; bh=MfsRtMSNQGcDzXA0voG56kxHlja09vUFQDB8lQPVTx0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GqolDMyhWdfp2oPVt3KZkKSzRI8kQNhp+IKHEkgsLfNxet6OldUTt5teo7ftvp0wg +PBZC6mOz2QJnq67XFPb7omttc1Tfz6mcLrc4URSHwDXHhfERuuAkf9Du9uK9mxusV Gn8nAAajfQcA5NJY6XhNKp9SgmrOZL5O7Jtf01NQ= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id DFEF81B2182A; Mon, 30 Dec 2019 17:31:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru DFEF81B2182A Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id 174551B229CB; Mon, 30 Dec 2019 17:31:33 +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:33 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 16/19] net: dsa: tag_qca: fix doubled Tx statistics Date: Mon, 30 Dec 2019 17:30:24 +0300 Message-Id: <20191230143028.27313-17-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064232_949938_FC663C05 X-CRM114-Status: UNSURE ( 7.63 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DSA core updates Tx stats for slaves in dsa_slave_xmit(), no need to do it manually in .xmit() tagger callback. Signed-off-by: Alexander Lobakin Reviewed-by: Andrew Lunn --- net/dsa/tag_qca.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c index 8e2dbaaffe59..e1c4dd04734a 100644 --- a/net/dsa/tag_qca.c +++ b/net/dsa/tag_qca.c @@ -33,9 +33,6 @@ static struct sk_buff *qca_tag_xmit(struct sk_buff *skb, struct net_device *dev) struct dsa_port *dp = dsa_slave_to_port(dev); u16 *phdr, hdr; - dev->stats.tx_packets++; - dev->stats.tx_bytes += skb->len; - if (skb_cow_head(skb, 0) < 0) return NULL; From patchwork Mon Dec 30 14:30:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313231 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3271C13A4 for ; Mon, 30 Dec 2019 14:46:35 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1094920663 for ; Mon, 30 Dec 2019 14:46:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="RFyRIENo"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="IVVHVnaM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1094920663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BmZFKrXphRaD99iqG4GTjw5zJooWmHESQzHLVVWZdzA=; b=RFyRIENoy5JNTg onys0CmeI/m59xjObC7AqjHwAFn3FIzK2oDBu8N2wk6fe/P8XFgXAxCaspPFKcLcotIEkM6CsnV/q myzMqOIUUoTjHm7EccfcCpLr5hm8Gumpsv73u49WxnwcjvJg2iE/fRWXZLF6OCuMBq1bn0IKGuoye BPQlUXe1VheXIAQmR4sBD3FfEGjdAPsqyPUQpgq+ndyIogeNt40Q0Z6EEDZpzvW9fIl2E45ZSHXTk ianPlHiY7ltcQ+FhEGryz5IR4qhf3n3gQ/TG/lTraQZ2wqcrxLRZjrLc33JMfTSk6/xUSveozN4Ho 5BTcMLfC/dw5vOeMmEog==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwJT-00081N-Ka; Mon, 30 Dec 2019 14:46:31 +0000 Received: from mail.dlink.ru ([178.170.168.18] helo=fd.dlink.ru) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFb-0003xX-1a; Mon, 30 Dec 2019 14:42:34 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id 1004F1B218DD; Mon, 30 Dec 2019 17:32:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 1004F1B218DD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716367; bh=E3wS4CWwlylImJof0eomCAHaPV4aLBnqVAQ7xnSqdyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IVVHVnaM/RM+UDv2UYa/dQtQ/GFA+1urOJh+VXrWV/uPNbowe6Rt8I20pPuEXrap7 jcLdLQhThhhNiI6Y4YNa/SkZSscpCdqfuECR6wfrGmlcyzKINgSQ2ZkDCWae8ZBJmc 7MgLJuXdK6F1c+t21rbp5crN4fJC1WbW5PFw5aKo= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id 70CB51B21845; Mon, 30 Dec 2019 17:31:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 70CB51B21845 Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id 4683B1B229D0; Mon, 30 Dec 2019 17:31:35 +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:35 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 17/19] net: dsa: tag_qca: switch to bitfield helpers Date: Mon, 30 Dec 2019 17:30:25 +0300 Message-Id: <20191230143028.27313-18-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064231_456137_E394F5E0 X-CRM114-Status: GOOD ( 11.09 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Make code look cleaner and more readable by using bitfield macros. Misc: fix several macro identation and phdr type in qca_tag_xmit(). Signed-off-by: Alexander Lobakin --- net/dsa/tag_qca.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c index e1c4dd04734a..8939abce36d7 100644 --- a/net/dsa/tag_qca.c +++ b/net/dsa/tag_qca.c @@ -3,15 +3,15 @@ * Copyright (c) 2015, The Linux Foundation. All rights reserved. */ +#include #include #include "dsa_priv.h" -#define QCA_HDR_LEN 2 -#define QCA_HDR_VERSION 0x2 +#define QCA_HDR_LEN 2 +#define QCA_HDR_VERSION 0x2 -#define QCA_HDR_RECV_VERSION_MASK GENMASK(15, 14) -#define QCA_HDR_RECV_VERSION_S 14 +#define QCA_HDR_RECV_VERSION(tag) FIELD_GET(GENMASK(15, 14), tag) #define QCA_HDR_RECV_PRIORITY_MASK GENMASK(13, 11) #define QCA_HDR_RECV_PRIORITY_S 11 #define QCA_HDR_RECV_TYPE_MASK GENMASK(10, 6) @@ -19,19 +19,20 @@ #define QCA_HDR_RECV_FRAME_IS_TAGGED BIT(3) #define QCA_HDR_RECV_SOURCE_PORT_MASK GENMASK(2, 0) -#define QCA_HDR_XMIT_VERSION_MASK GENMASK(15, 14) -#define QCA_HDR_XMIT_VERSION_S 14 +#define QCA_HDR_XMIT_VERSION FIELD_PREP(GENMASK(15, 14), \ + QCA_HDR_VERSION) #define QCA_HDR_XMIT_PRIORITY_MASK GENMASK(13, 11) #define QCA_HDR_XMIT_PRIORITY_S 11 #define QCA_HDR_XMIT_CONTROL_MASK GENMASK(10, 8) #define QCA_HDR_XMIT_CONTROL_S 8 #define QCA_HDR_XMIT_FROM_CPU BIT(7) -#define QCA_HDR_XMIT_DP_BIT_MASK GENMASK(6, 0) +#define QCA_HDR_XMIT_DP(port) FIELD_PREP(GENMASK(6, 0), BIT(port)) static struct sk_buff *qca_tag_xmit(struct sk_buff *skb, struct net_device *dev) { - struct dsa_port *dp = dsa_slave_to_port(dev); - u16 *phdr, hdr; + const struct dsa_port *dp = dsa_slave_to_port(dev); + __be16 *phdr; + u16 hdr; if (skb_cow_head(skb, 0) < 0) return NULL; @@ -39,11 +40,11 @@ static struct sk_buff *qca_tag_xmit(struct sk_buff *skb, struct net_device *dev) skb_push(skb, QCA_HDR_LEN); memmove(skb->data, skb->data + QCA_HDR_LEN, 2 * ETH_ALEN); - phdr = (u16 *)(skb->data + 2 * ETH_ALEN); + phdr = (__be16 *)(skb->data + 2 * ETH_ALEN); /* Set the version field, and set destination port information */ - hdr = QCA_HDR_VERSION << QCA_HDR_XMIT_VERSION_S | - QCA_HDR_XMIT_FROM_CPU | BIT(dp->index); + hdr = QCA_HDR_XMIT_VERSION | QCA_HDR_XMIT_FROM_CPU | + QCA_HDR_XMIT_DP(dp->index); *phdr = htons(hdr); @@ -53,7 +54,6 @@ static struct sk_buff *qca_tag_xmit(struct sk_buff *skb, struct net_device *dev) static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) { - u8 ver; int port; __be16 *phdr, hdr; @@ -68,8 +68,7 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev, hdr = ntohs(*phdr); /* Make sure the version is correct */ - ver = (hdr & QCA_HDR_RECV_VERSION_MASK) >> QCA_HDR_RECV_VERSION_S; - if (unlikely(ver != QCA_HDR_VERSION)) + if (unlikely(QCA_HDR_RECV_VERSION(hdr) != QCA_HDR_VERSION)) return NULL; /* Remove QCA tag and recalculate checksum */ From patchwork Mon Dec 30 14:30:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313141 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 251D213A4 for ; Mon, 30 Dec 2019 14:43:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 036AB20663 for ; Mon, 30 Dec 2019 14:43:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MrvY8g6E"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="C4PUPT5a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 036AB20663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8CSAPOd+1scB/ASognPvZPuXpIPOkuvFu8FfMDO3kjA=; b=MrvY8g6EQt0wLU UK6Fb4f+2OXEKrETaVvymny767mhUCvZIcLlrMoiKU70rYFUoRE4RZlkWFwnkdRZJIMN5FXQDzX6A MY2HWl+CnUwSAENl30LvGLhVJ3wqJVld8V9kMdsiLs2c6JnUJOgwdcOW6WZFB7JvGADCLH4j0hB9I XyinIKSCaW9SfZVL5S+QFSUjPub9JqFxsKZXwshTYqRUMkSzfwO7QCWv8F17CGOGkoF/Iuz3Zkqvl avfwJj5rmLes8HBQgEnE966zR0DW6ciM4XX7SS7IN4sMJyh8Q/sSi3dI2H2rJrx0VZABUw1PlUWcD hafvypqNis+n9ILdYVnw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwGH-0004TH-Kk; Mon, 30 Dec 2019 14:43:13 +0000 Received: from mail.dlink.ru ([178.170.168.18] helo=fd.dlink.ru) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFY-0003vw-GW; Mon, 30 Dec 2019 14:42:30 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id 596BE1B21812; Mon, 30 Dec 2019 17:32:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 596BE1B21812 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716363; bh=vMMdZPRhhDCtnbuTLqLyjTW+Dv/ebEhvjE+SEn3R/dc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=C4PUPT5aZfqEy+kMGpyrZc5ufQXKbyCgxM7U9mAmBzS8gDrxUVI19cHu+u6DxK4SF ejToayX02+FTnft8J8lMXgehX4n9JP1J/GUGg6Ms13QzXNvWeRgEY1xh2sQkpGEgIy a3T3fWwmwDRKya9tWVewHt8NCB/ALfqPS/rxGCJ4= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id DD1001B21836; Mon, 30 Dec 2019 17:31:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru DD1001B21836 Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id 6D13F1B229CB; Mon, 30 Dec 2019 17:31:37 +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:37 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 18/19] net: dsa: tag_qca: split out common tag accessors Date: Mon, 30 Dec 2019 17:30:26 +0300 Message-Id: <20191230143028.27313-19-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064228_906483_4AF08DCF X-CRM114-Status: GOOD ( 11.86 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org ...to make them available for the upcoming GRO callbacks. Signed-off-by: Alexander Lobakin --- net/dsa/tag_qca.c | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c index 8939abce36d7..bee2788e034d 100644 --- a/net/dsa/tag_qca.c +++ b/net/dsa/tag_qca.c @@ -28,6 +28,27 @@ #define QCA_HDR_XMIT_FROM_CPU BIT(7) #define QCA_HDR_XMIT_DP(port) FIELD_PREP(GENMASK(6, 0), BIT(port)) +static inline bool qca_tag_sanity_check(const u8 *data) +{ + /* The QCA header is added by the switch between src addr and Ethertype + * At this point, skb->data points to ethertype so header should be + * right before + */ + u16 hdr = ntohs(*(__be16 *)(data - 2)); + + return QCA_HDR_RECV_VERSION(hdr) == QCA_HDR_VERSION; +} + +static inline int qca_tag_source_port(const u8 *data) +{ + return *(data - 1) & QCA_HDR_RECV_SOURCE_PORT_MASK; +} + +static inline __be16 qca_tag_encap_proto(const u8 *data) +{ + return *(__be16 *)data; +} + static struct sk_buff *qca_tag_xmit(struct sk_buff *skb, struct net_device *dev) { const struct dsa_port *dp = dsa_slave_to_port(dev); @@ -55,34 +76,26 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) { int port; - __be16 *phdr, hdr; if (unlikely(!pskb_may_pull(skb, QCA_HDR_LEN))) return NULL; - /* The QCA header is added by the switch between src addr and Ethertype - * At this point, skb->data points to ethertype so header should be - * right before - */ - phdr = (__be16 *)(skb->data - 2); - hdr = ntohs(*phdr); - /* Make sure the version is correct */ - if (unlikely(QCA_HDR_RECV_VERSION(hdr) != QCA_HDR_VERSION)) + if (unlikely(!qca_tag_sanity_check(skb->data))) return NULL; - /* Remove QCA tag and recalculate checksum */ - skb_pull_rcsum(skb, QCA_HDR_LEN); - memmove(skb->data - ETH_HLEN, skb->data - ETH_HLEN - QCA_HDR_LEN, - ETH_HLEN - QCA_HDR_LEN); - /* Get source port information */ - port = (hdr & QCA_HDR_RECV_SOURCE_PORT_MASK); + port = qca_tag_source_port(skb->data); skb->dev = dsa_master_find_slave(dev, 0, port); if (!skb->dev) return NULL; + /* Remove QCA tag and recalculate checksum */ + skb_pull_rcsum(skb, QCA_HDR_LEN); + memmove(skb->data - ETH_HLEN, skb->data - ETH_HLEN - QCA_HDR_LEN, + ETH_HLEN - QCA_HDR_LEN); + return skb; } @@ -90,7 +103,7 @@ static void qca_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, int *offset) { *offset = QCA_HDR_LEN; - *proto = ((__be16 *)skb->data)[0]; + *proto = qca_tag_encap_proto(skb->data); } static const struct dsa_device_ops qca_netdev_ops = { From patchwork Mon Dec 30 14:30:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313211 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB719109A for ; Mon, 30 Dec 2019 14:44:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7691A208C3 for ; Mon, 30 Dec 2019 14:44:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="m3YU+TcN"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="LOUIsUq7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7691A208C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=e8SQwDC02APzlDpFYpUHM9hNi4WQjBRIggOCRemOKNU=; b=m3YU+TcNk/NLn/ XMR9FRVVYGSYsYU889e39RlQqzUGTMM0OKKfA2mTHqo5pJ9kvjHteKaCZt3a81GNzFQO8t2dw2Ai7 YvGms3Xy7ZkWpZLUxOabrmjUhRXp35dSsBtBd/3/O9D0Tf/DM66i0Wt/Zvau9pFHhSuTiMJS9lr58 MPHAhATih8rlMXhNssaCAHjUMzLW3LL5JRxaHmwhxxHpDEzW+0bKSJre1Sc0BIPXyQhcYevg66yO/ 3be9JZPRuEmoxWbkMsHAjrg8f1Ld/6x+L8X+lxJBZHd1qAh5GxMdq3BXyzWi5xC1u/rhsfcZEfTKy mfeqGgcxGO0YlnukfbyA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwHX-0005Pd-1K; Mon, 30 Dec 2019 14:44:31 +0000 Received: from mail.dlink.ru ([178.170.168.18] helo=fd.dlink.ru) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFY-0003w1-Ju; Mon, 30 Dec 2019 14:42:31 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id 5FD9C1B21990; Mon, 30 Dec 2019 17:32:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru 5FD9C1B21990 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716377; bh=4XferhwJ+noZjvLLF7PDu0hDkxQ/WpPucldtTtVh1Bc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LOUIsUq7DpP0fdqTXl/cEoFtg6XNKAEYorBY7I8u4A/94vJm9VZb5B+ec7Uy+I6l/ gpzckHhwSNoOWx8wim4ItsUqPXpxBnNt5KLsvk4SrnUYbGQqypMnPdcc7stSD3QIyT N3nkfuGBs5et62erZPnYwOn414kCfgrjYccnxeVc= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id C096F1B20954; Mon, 30 Dec 2019 17:31:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru C096F1B20954 Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id D81481B229D0; Mon, 30 Dec 2019 17:31:39 +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:39 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 19/19] net: dsa: tag_qca: add GRO callbacks Date: Mon, 30 Dec 2019 17:30:27 +0300 Message-Id: <20191230143028.27313-20-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064229_022565_D6BFAAE6 X-CRM114-Status: GOOD ( 13.09 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org ...so that frames tagged with this CPU tag type can be correctly processed by the GRO layer. Misc: fix qca_netdev_ops structure identation. Signed-off-by: Alexander Lobakin --- net/dsa/tag_qca.c | 88 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 6 deletions(-) diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c index bee2788e034d..d0cb2299cbe9 100644 --- a/net/dsa/tag_qca.c +++ b/net/dsa/tag_qca.c @@ -106,13 +106,89 @@ static void qca_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, *proto = qca_tag_encap_proto(skb->data); } +static struct sk_buff *qca_tag_gro_receive(struct list_head *head, + struct sk_buff *skb) +{ + const struct packet_offload *ptype; + struct sk_buff *p, *pp = NULL; + u32 data_off, data_end; + const u8 *data; + int flush = 1; + + data_off = skb_gro_offset(skb); + data_end = data_off + QCA_HDR_LEN; + + data = skb_gro_header_fast(skb, data_off); + if (skb_gro_header_hard(skb, data_end)) { + data = skb_gro_header_slow(skb, data_end, data_off); + if (unlikely(!data)) + goto out; + } + + /* Data that is to the left to the current position is already + * pulled to the head + */ + if (unlikely(!qca_tag_sanity_check(skb->data + data_off))) + goto out; + + rcu_read_lock(); + + ptype = gro_find_receive_by_type(qca_tag_encap_proto(data)); + if (!ptype) + goto out_unlock; + + flush = 0; + + list_for_each_entry(p, head, list) { + if (!NAPI_GRO_CB(p)->same_flow) + continue; + + if (qca_tag_source_port(skb->data + data_off) ^ + qca_tag_source_port(p->data + data_off)) + NAPI_GRO_CB(p)->same_flow = 0; + } + + skb_gro_pull(skb, QCA_HDR_LEN); + skb_gro_postpull_rcsum(skb, data, QCA_HDR_LEN); + + pp = call_gro_receive(ptype->callbacks.gro_receive, head, skb); + +out_unlock: + rcu_read_unlock(); +out: + skb_gro_flush_final(skb, pp, flush); + + return pp; +} + +static int qca_tag_gro_complete(struct sk_buff *skb, int nhoff) +{ + const struct packet_offload *ptype; + int err = -ENOENT; + __be16 proto; + + proto = qca_tag_encap_proto(skb->data + nhoff); + + rcu_read_lock(); + + ptype = gro_find_complete_by_type(proto); + if (ptype) + err = ptype->callbacks.gro_complete(skb, nhoff + QCA_HDR_LEN); + + rcu_read_unlock(); + + return err; +} + static const struct dsa_device_ops qca_netdev_ops = { - .name = "qca", - .proto = DSA_TAG_PROTO_QCA, - .xmit = qca_tag_xmit, - .rcv = qca_tag_rcv, - .flow_dissect = qca_tag_flow_dissect, - .overhead = QCA_HDR_LEN, + .name = "qca", + .proto = DSA_TAG_PROTO_QCA, + .xmit = qca_tag_xmit, + .rcv = qca_tag_rcv, + .flow_dissect = qca_tag_flow_dissect, + .gro_receive = qca_tag_gro_receive, + .gro_complete = qca_tag_gro_complete, + .overhead = QCA_HDR_LEN, }; MODULE_LICENSE("GPL"); From patchwork Mon Dec 30 14:30:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 11313197 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 23B8E109A for ; Mon, 30 Dec 2019 14:44:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 022EA20722 for ; Mon, 30 Dec 2019 14:44:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MfNVyJl0"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=dlink.ru header.i=@dlink.ru header.b="a4b0eZmu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 022EA20722 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dlink.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=G4/3AkiBWumnEbwZcmpLj/linooB0ziUrrCHDkdBvg4=; b=MfNVyJl0crA8WN 5LF59f4/77Z635ub/cKnKICz3muXGh3/mA/JaVak9ApniZeHzUmTEHu1fSKbCYply1qWZLALwjIaR kJPztwczOI9vSTwkeTPl9O0CzVrSaJ72Hku4IWDtNPvX8gA1XFoNYXOSUQRFFv8YWnXXklxUqZ5FZ 13ctJRoMd0JJ9dqrDlDILVg0UxXAeMCnkSVdkK7vLuyXLI8xCf/YaxmzLoJDhlKWizebwRaNT08cD yUGYy0cHoa9falNpOvZvkT7Js0/6lN3zr7airQzt3/O9xg/6/PNuUQ4Z6iNAT8RKAATkM3hMpfM94 mL/joKAHpoMg4AVrOqQg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwHT-0005Mw-1z; Mon, 30 Dec 2019 14:44:27 +0000 Received: from mail.dlink.ru ([178.170.168.18] helo=fd.dlink.ru) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilwFY-0003w2-Ko; Mon, 30 Dec 2019 14:42:31 +0000 Received: by fd.dlink.ru (Postfix, from userid 5000) id C199F1B2199E; Mon, 30 Dec 2019 17:32:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru C199F1B2199E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dlink.ru; s=mail; t=1577716377; bh=oIQhxpQSU+of0GS4enDiLZVDRRd/vUUBvg7EXVnvZnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=a4b0eZmu5mab4I8iqprKXq5h0rJ/gLc/GnAzwQywCZXr1Xn2xW+y2N1lDhn0RyRDP Xli11vUEXMFk9GPxGejxvvXsM+K/iuylazAuLfropKpvK3FPlydE8tLg8iHrhD1c67 WDv80KecztONQM+ifd7jndk2n/kae8EOmwaKiQus= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dlink.ru X-Spam-Level: X-Spam-Status: No, score=-99.2 required=7.5 tests=BAYES_50,URIBL_BLOCKED, USER_IN_WHITELIST autolearn=disabled version=3.4.2 Received: from mail.rzn.dlink.ru (mail.rzn.dlink.ru [178.170.168.13]) by fd.dlink.ru (Postfix) with ESMTP id AD2C11B20206; Mon, 30 Dec 2019 17:31:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 fd.dlink.ru AD2C11B20206 Received: from mail.rzn.dlink.ru (localhost [127.0.0.1]) by mail.rzn.dlink.ru (Postfix) with ESMTP id BE9641B229CB; Mon, 30 Dec 2019 17:31:41 +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:41 +0300 (MSK) From: Alexander Lobakin To: "David S. Miller" Subject: [PATCH RFC net-next 20/20] net: core: add (unlikely) DSA support in napi_gro_frags() Date: Mon, 30 Dec 2019 17:30:28 +0300 Message-Id: <20191230143028.27313-21-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191230_064229_041870_751F8D93 X-CRM114-Status: GOOD ( 10.99 ) X-Spam-Score: 2.4 (++) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.170.168.18 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [196.196.203.126 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Jakub Kicinski , Alexander Lobakin , Yoshiki Komachi , linux-kernel@vger.kernel.org, Eric Dumazet , Stanislav Fomichev , Matteo Croce , Edward Cree , Florian Fainelli , Jakub Sitnicki , Daniel Borkmann , Paolo Abeni , Vivien Didelot , Hauke Mehrtens , Sean Wang , Jiri Pirko , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Paul Blakey , Stephen Hemminger , Taehee Yoo Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Make napi_gro_frags() available for DSA-enabled device drivers by adding the same condition for them as the one in eth_type_trans(). Signed-off-by: Alexander Lobakin --- net/core/dev.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index f1b8afcfbc0f..923b930a4506 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -142,6 +142,7 @@ #include #include #include +#include #include "net-sysfs.h" @@ -5951,6 +5952,7 @@ static gro_result_t napi_frags_finish(struct napi_struct *napi, */ static struct sk_buff *napi_frags_skb(struct napi_struct *napi) { + struct net_device *dev = napi->dev; struct sk_buff *skb = napi->skb; const struct ethhdr *eth; unsigned int hlen = sizeof(*eth); @@ -5964,7 +5966,7 @@ static struct sk_buff *napi_frags_skb(struct napi_struct *napi) eth = skb_gro_header_slow(skb, hlen, 0); if (unlikely(!eth)) { net_warn_ratelimited("%s: dropping impossible skb from %s\n", - __func__, napi->dev->name); + __func__, dev->name); napi_reuse_skb(napi, skb); return NULL; } @@ -5978,10 +5980,13 @@ static struct sk_buff *napi_frags_skb(struct napi_struct *napi) /* * This works because the only protocols we care about don't require - * special handling. + * special handling... except for DSA. * We'll fix it up properly in napi_frags_finish() */ - skb->protocol = eth->h_proto; + if (unlikely(netdev_uses_dsa(dev)) && dsa_can_decode(skb, dev)) + skb->protocol = htons(ETH_P_XDSA); + else + skb->protocol = eth->h_proto; return skb; }