From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, andrew@lunn.ch,
vivien.didelot@savoirfairelinux.com, john@phrozen.org,
Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH v4 3/4] net: dsa: Associate slave network device with CPU port
Date: Tue, 13 Jun 2017 13:27:21 -0700 [thread overview]
Message-ID: <20170613202722.17598-4-f.fainelli@gmail.com> (raw)
In-Reply-To: <20170613202722.17598-1-f.fainelli@gmail.com>
In preparation for supporting multiple CPU ports with DSA, have the
dsa_port structure know which CPU it is associated with. This will be
important in order to make sure the correct CPU is used for transmission
of the frames. If not for functional reasons, for performance (e.g: load
balancing) and forwarding decisions.
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
include/net/dsa.h | 1 +
net/dsa/dsa2.c | 11 +++++++++++
net/dsa/dsa_priv.h | 2 +-
net/dsa/legacy.c | 1 +
net/dsa/slave.c | 4 +++-
5 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 7e93869819f9..58969b9a090c 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -171,6 +171,7 @@ struct dsa_port {
struct dsa_switch *ds;
unsigned int index;
const char *name;
+ struct dsa_port *cpu_dp;
struct net_device *netdev;
struct device_node *dn;
unsigned int ageing_time;
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index ab48c4f989da..52af8401af07 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -490,6 +490,8 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
enum dsa_tag_protocol tag_protocol;
struct net_device *ethernet_dev;
struct device_node *ethernet;
+ struct dsa_port *p;
+ unsigned int i;
if (port->dn) {
ethernet = of_parse_phandle(port->dn, "ethernet", 0);
@@ -507,6 +509,15 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
if (!dst->cpu_dp) {
dst->cpu_dp = port;
dst->cpu_dp->netdev = ethernet_dev;
+
+ for (i = 0; i < ds->num_ports; i++) {
+ p = &ds->ports[i];
+ if (!dsa_port_is_valid(p) ||
+ i == index)
+ continue;
+
+ p->cpu_dp = port;
+ }
}
tag_protocol = ds->ops->get_tag_protocol(ds);
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 5c510f4ba0ce..7c2326f3b538 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -185,7 +185,7 @@ extern const struct dsa_device_ops trailer_netdev_ops;
static inline struct net_device *dsa_master_netdev(struct dsa_slave_priv *p)
{
- return p->dp->ds->dst->cpu_dp->netdev;
+ return p->dp->cpu_dp->netdev;
}
#endif
diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c
index 5d4f6ffa3424..e60906125375 100644
--- a/net/dsa/legacy.c
+++ b/net/dsa/legacy.c
@@ -129,6 +129,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
ds->dsa_port_mask |= 1 << i;
} else {
ds->enabled_port_mask |= 1 << i;
+ ds->ports[i].cpu_dp = dst->cpu_dp;
}
valid_name_found = true;
}
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 9bf4c27f3393..a80b46777a04 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1140,9 +1140,11 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
struct net_device *master;
struct net_device *slave_dev;
struct dsa_slave_priv *p;
+ struct dsa_port *cpu_dp;
int ret;
- master = ds->dst->cpu_dp->netdev;
+ cpu_dp = ds->dst->cpu_dp;
+ master = cpu_dp->netdev;
slave_dev = alloc_netdev(sizeof(struct dsa_slave_priv), name,
NET_NAME_UNKNOWN, ether_setup);
--
2.9.3
next prev parent reply other threads:[~2017-06-13 20:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-13 20:27 [PATCH net-next v4 0/4] net: dsa: Multi-CPU ground work (v4) Florian Fainelli
2017-06-13 20:27 ` [PATCH v4 1/4] net: dsa: Remove master_netdev and use dst->cpu_dp->netdev Florian Fainelli
2017-06-13 20:27 ` [PATCH v4 2/4] net: dsa: Relocate master ethtool operations Florian Fainelli
2017-06-13 20:27 ` Florian Fainelli [this message]
2017-06-13 20:27 ` [PATCH v4 4/4] net: dsa: Introduce dsa_get_cpu_port() Florian Fainelli
2017-06-13 20:35 ` [PATCH net-next v4 0/4] net: dsa: Multi-CPU ground work (v4) 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=20170613202722.17598-4-f.fainelli@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=john@phrozen.org \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@savoirfairelinux.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).