[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190816150834.26939-3-marek.behun@nic.cz>
Date: Fri, 16 Aug 2019 17:08:33 +0200
From: Marek Behún <marek.behun@....cz>
To: netdev@...r.kernel.org
Cc: Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...il.com>,
Vladimir Oltean <olteanv@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
Marek Behún <marek.behun@....cz>
Subject: [PATCH RFC net-next 2/3] net: dsa: add port_setup/port_teardown methods to DSA ops
Add two new methods into the DSA operations structure:
- port_setup(), called from dsa_port_setup() after the DSA port
already registered
- port_teardown(), called from dsa_port_teardown() before the port is
unregistered
Signed-off-by: Marek Behún <marek.behun@....cz>
Cc: Andrew Lunn <andrew@...n.ch>
Cc: Florian Fainelli <f.fainelli@...il.com>
Cc: Vladimir Oltean <olteanv@...il.com>
Cc: Vivien Didelot <vivien.didelot@...il.com>
---
include/net/dsa.h | 2 ++
net/dsa/dsa2.c | 10 +++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 147b757ef8ea..848898e5d7c5 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -360,6 +360,8 @@ struct dsa_switch_ops {
int (*setup)(struct dsa_switch *ds);
void (*teardown)(struct dsa_switch *ds);
+ int (*port_setup)(struct dsa_switch *ds, int port);
+ void (*port_teardown)(struct dsa_switch *ds, int port);
u32 (*get_phy_flags)(struct dsa_switch *ds, int port);
/*
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 3abd173ebacb..c891300a6d2c 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -315,6 +315,9 @@ static int dsa_port_setup(struct dsa_port *dp)
break;
}
+ if (!err && ds->ops->port_setup)
+ err = ds->ops->port_setup(ds, dp->index);
+
if (err)
devlink_port_unregister(&dp->devlink_port);
@@ -323,8 +326,13 @@ static int dsa_port_setup(struct dsa_port *dp)
static void dsa_port_teardown(struct dsa_port *dp)
{
- if (dp->type != DSA_PORT_TYPE_UNUSED)
+ struct dsa_switch *ds = dp->ds;
+
+ if (dp->type != DSA_PORT_TYPE_UNUSED) {
devlink_port_unregister(&dp->devlink_port);
+ if (ds->ops->port_teardown)
+ ds->ops->port_teardown(ds, dp->index);
+ }
switch (dp->type) {
case DSA_PORT_TYPE_UNUSED:
--
2.21.0
Powered by blists - more mailing lists