All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
To: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com,
	"David S. Miller" <davem@davemloft.net>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Subject: [PATCH net-next v2 5/7] net: dsa: prepare master receive hot path
Date: Fri, 29 Sep 2017 17:19:19 -0400	[thread overview]
Message-ID: <20170929211921.5571-6-vivien.didelot@savoirfairelinux.com> (raw)
In-Reply-To: <20170929211921.5571-1-vivien.didelot@savoirfairelinux.com>

In preparation to make DSA master devices point to their corresponding
CPU port instead of the whole tree, add copies of dst and rcv in the
dsa_port structure so that we keep fast access in the receive hot path.

Also keep the copies at the beginning of the dsa_port structure in order
to ensure they are available in cacheline 1.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 include/net/dsa.h | 5 +++++
 net/dsa/dsa2.c    | 4 ++++
 net/dsa/legacy.c  | 4 ++++
 3 files changed, 13 insertions(+)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 4d1df2f086e8..6bda01fa5747 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -178,6 +178,11 @@ struct dsa_port {
 	/* CPU port tagging operations used by master or slave devices */
 	const struct dsa_device_ops *tag_ops;
 
+	/* Copies for faster access in master receive hot path */
+	struct dsa_switch_tree *dst;
+	struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev,
+			       struct packet_type *pt);
+
 	struct dsa_switch	*ds;
 	unsigned int		index;
 	const char		*name;
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 9eac4726dc0c..b71e3bb478e4 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -524,7 +524,11 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
 
 	dst->cpu_dp->tag_ops = tag_ops;
 	dst->tag_ops = tag_ops;
+
+	/* Make a few copies for faster access in master receive hot path */
+	dst->cpu_dp->rcv = dst->cpu_dp->tag_ops->rcv;
 	dst->rcv = dst->tag_ops->rcv;
+	dst->cpu_dp->dst = dst;
 
 	return 0;
 }
diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c
index 4d374541815a..96c7e3f8b8bb 100644
--- a/net/dsa/legacy.c
+++ b/net/dsa/legacy.c
@@ -154,7 +154,11 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,
 
 		dst->cpu_dp->tag_ops = tag_ops;
 		dst->tag_ops = tag_ops;
+
+		/* Few copies for faster access in master receive hot path */
+		dst->cpu_dp->rcv = dst->cpu_dp->tag_ops->rcv;
 		dst->rcv = dst->tag_ops->rcv;
+		dst->cpu_dp->dst = dst;
 	}
 
 	memcpy(ds->rtable, cd->rtable, sizeof(ds->rtable));
-- 
2.14.1

  parent reply	other threads:[~2017-09-29 21:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-29 21:19 [PATCH net-next v2 0/7] net: dsa: change dsa_ptr for a dsa_port Vivien Didelot
2017-09-29 21:19 ` [PATCH net-next v2 1/7] net: dsa: add master helper to look up slaves Vivien Didelot
2017-09-30  1:14   ` Florian Fainelli
2017-09-29 21:19 ` [PATCH net-next v2 2/7] net: dsa: use cpu_dp in master code Vivien Didelot
2017-09-29 21:19 ` [PATCH net-next v2 3/7] net: dsa: use temporary dsa_device_ops variable Vivien Didelot
2017-09-29 21:19 ` [PATCH net-next v2 4/7] net: dsa: add tagging ops to port Vivien Didelot
2017-09-29 21:19 ` Vivien Didelot [this message]
2017-09-29 21:19 ` [PATCH net-next v2 6/7] net: dsa: change dsa_ptr for a dsa_port Vivien Didelot
2017-09-29 21:19 ` [PATCH net-next v2 7/7] net: dsa: remove tag ops from the switch tree Vivien Didelot
2017-10-01  3:15 ` [PATCH net-next v2 0/7] net: dsa: change dsa_ptr for a dsa_port David Miller

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=20170929211921.5571-6-vivien.didelot@savoirfairelinux.com \
    --to=vivien.didelot@savoirfairelinux.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kernel@savoirfairelinux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.