linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Lobakin <alobakin@dlink.ru>
To: "David S. Miller" <davem@davemloft.net>
Cc: Edward Cree <ecree@solarflare.com>, Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Hauke Mehrtens <hauke@hauke-m.de>,
	Sean Wang <sean.wang@mediatek.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Jiri Pirko <jiri@mellanox.com>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Jakub Kicinski <jakub.kicinski@netronome.com>,
	Alexander Lobakin <alobakin@dlink.ru>,
	Taehee Yoo <ap420073@gmail.com>,
	Stephen Hemminger <stephen@networkplumber.org>,
	Stanislav Fomichev <sdf@google.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Song Liu <songliubraving@fb.com>,
	Matteo Croce <mcroce@redhat.com>,
	Jakub Sitnicki <jakub@cloudflare.com>,
	Paul Blakey <paulb@mellanox.com>,
	Yoshiki Komachi <komachi.yoshiki@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: [PATCH RFC net-next 02/19] net: dsa: add GRO support infrastructure
Date: Mon, 30 Dec 2019 17:30:10 +0300	[thread overview]
Message-ID: <20191230143028.27313-3-alobakin@dlink.ru> (raw)
In-Reply-To: <20191230143028.27313-1-alobakin@dlink.ru>

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 <alobakin@dlink.ru>
---
 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;
-- 
2.24.1


  parent reply	other threads:[~2019-12-30 14:31 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-30 14:30 [PATCH RFC net-next 00/20] net: dsa: add GRO support Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 01/19] net: dsa: make .flow_dissect() callback returning void Alexander Lobakin
2019-12-30 18:11   ` Florian Fainelli
2019-12-30 14:30 ` Alexander Lobakin [this message]
2019-12-30 14:30 ` [PATCH RFC net-next 03/19] net: dsa: tag_ar9331: add .flow_dissect() callback Alexander Lobakin
2019-12-30 18:22   ` Florian Fainelli
2019-12-30 14:30 ` [PATCH RFC net-next 04/19] net: dsa: tag_ar9331: split out common tag accessors Alexander Lobakin
2019-12-30 17:18   ` Andrew Lunn
2019-12-30 14:30 ` [PATCH RFC net-next 05/19] net: dsa: tag_ar9331: add GRO callbacks Alexander Lobakin
2019-12-30 18:20   ` Florian Fainelli
2019-12-30 20:36     ` Andrew Lunn
2020-01-13  9:21     ` Alexander Lobakin
2020-01-13  9:42       ` Vladimir Oltean
2020-01-13  9:46         ` Alexander Lobakin
2020-01-13 10:28           ` Vladimir Oltean
2020-01-14 21:56             ` Florian Fainelli
2020-01-15  7:38               ` Alexander Lobakin
2020-01-15 11:29                 ` Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 06/19] net: dsa: tag_gswip: fix typo in tag name Alexander Lobakin
2019-12-30 17:22   ` Andrew Lunn
2020-01-14 21:57     ` Florian Fainelli
2020-01-15  7:24       ` Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 07/19] net: dsa: tag_gswip: switch to bitfield helpers Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 08/19] net: dsa: tag_gswip: add .flow_dissect() callback Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 09/19] net: dsa: tag_gswip: split out common tag accessors Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 10/19] net: dsa: tag_gswip: add GRO callbacks Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 11/19] net: dsa: tag_lan9303: add .flow_dissect() callback Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 12/19] net: dsa: tag_lan9303: split out common tag accessors Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 13/19] net: dsa: tag_lan9303: add GRO callbacks Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 14/19] net: dsa: tag_mtk: split out common tag accessors Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 15/19] net: dsa: tag_mtk: add GRO callbacks Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 16/19] net: dsa: tag_qca: fix doubled Tx statistics Alexander Lobakin
2019-12-30 17:23   ` Andrew Lunn
2020-01-14 21:57     ` Florian Fainelli
2019-12-30 14:30 ` [PATCH RFC net-next 17/19] net: dsa: tag_qca: switch to bitfield helpers Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 18/19] net: dsa: tag_qca: split out common tag accessors Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 19/19] net: dsa: tag_qca: add GRO callbacks Alexander Lobakin
2019-12-30 14:30 ` [PATCH RFC net-next 20/20] net: core: add (unlikely) DSA support in napi_gro_frags() Alexander Lobakin
2019-12-30 17:12 ` [PATCH RFC net-next 00/20] net: dsa: add GRO support Andrew Lunn
2020-01-13  9:25   ` Alexander Lobakin
2019-12-31 15:32 ` Vladimir Oltean
2020-01-13  9:30   ` Alexander Lobakin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191230143028.27313-3-alobakin@dlink.ru \
    --to=alobakin@dlink.ru \
    --cc=andrew@lunn.ch \
    --cc=ap420073@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=ecree@solarflare.com \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=hauke@hauke-m.de \
    --cc=jakub.kicinski@netronome.com \
    --cc=jakub@cloudflare.com \
    --cc=jiri@mellanox.com \
    --cc=komachi.yoshiki@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mcroce@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=paulb@mellanox.com \
    --cc=sdf@google.com \
    --cc=sean.wang@mediatek.com \
    --cc=songliubraving@fb.com \
    --cc=stephen@networkplumber.org \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).