[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191028223236.31642-2-f.fainelli@gmail.com>
Date: Mon, 28 Oct 2019 15:32:35 -0700
From: Florian Fainelli <f.fainelli@...il.com>
To: netdev@...r.kernel.org
Cc: Florian Fainelli <f.fainelli@...il.com>, andrew@...n.ch,
vivien.didelot@...il.com, davem@...emloft.net,
Jakub Kicinski <jakub.kicinski@...ronome.com>
Subject: [PATCH net-next 1/2] net: dsa: Add ability to elect CPU port
In a configuration where multiple CPU ports are declared within the
platform configuration, it may be desirable to make sure that a
particular CPU port gets used. This is particularly true for Broadcom
switch that are fairly flexible to some extent in which port can be the
CPU port, yet will be more featureful if port 8 is elected.
Signed-off-by: Florian Fainelli <f.fainelli@...il.com>
---
include/net/dsa.h | 1 +
net/dsa/dsa2.c | 19 +++++++++++++++----
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index e3c14dc3bab9..f4f209576f8e 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -361,6 +361,7 @@ typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
struct dsa_switch_ops {
enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds,
int port);
+ int (*elect_cpu_port)(struct dsa_switch *ds, int port);
int (*setup)(struct dsa_switch *ds);
void (*teardown)(struct dsa_switch *ds);
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 214dd703b0cc..31c4b692bd19 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -184,14 +184,25 @@ static bool dsa_tree_setup_routing_table(struct dsa_switch_tree *dst)
return complete;
}
-static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst)
+static struct dsa_port *dsa_tree_find_cpu(struct dsa_switch_tree *dst)
{
+ struct dsa_switch *ds;
struct dsa_port *dp;
+ int err;
- list_for_each_entry(dp, &dst->ports, list)
- if (dsa_port_is_cpu(dp))
+ list_for_each_entry(dp, &dst->ports, list) {
+ ds = dp->ds;
+ if (!dsa_port_is_cpu(dp))
+ continue;
+
+ if (!ds->ops->elect_cpu_port)
return dp;
+ err = ds->ops->elect_cpu_port(ds, dp->index);
+ if (err == 0)
+ return dp;
+ }
+
return NULL;
}
@@ -199,7 +210,7 @@ static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst)
{
struct dsa_port *cpu_dp, *dp;
- cpu_dp = dsa_tree_find_first_cpu(dst);
+ cpu_dp = dsa_tree_find_cpu(dst);
if (!cpu_dp) {
pr_err("DSA: tree %d has no CPU port\n", dst->index);
return -EINVAL;
--
2.17.1
Powered by blists - more mailing lists