* [PATCH net-next v3 0/2] net: dsa: port enabling
@ 2017-09-22 23:01 Vivien Didelot
2017-09-22 23:01 ` [PATCH net-next v3 1/2] net: dsa: make slave close symmetrical to open Vivien Didelot
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Vivien Didelot @ 2017-09-22 23:01 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
This patchset makes slave open and close symmetrical and provides
helpers for enabling or disabling a given DSA port.
Changes in v3:
- save the phy_device change for a future patchset
Changes in v2:
- do not remove the phy argument from port enable/disable
Vivien Didelot (2):
net: dsa: make slave close symmetrical to open
net: dsa: add port enable and disable helpers
net/dsa/dsa_priv.h | 3 ++-
net/dsa/port.c | 31 ++++++++++++++++++++++++++++++-
net/dsa/slave.c | 21 ++++++---------------
3 files changed, 38 insertions(+), 17 deletions(-)
--
2.14.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v3 1/2] net: dsa: make slave close symmetrical to open
2017-09-22 23:01 [PATCH net-next v3 0/2] net: dsa: port enabling Vivien Didelot
@ 2017-09-22 23:01 ` Vivien Didelot
2017-09-22 23:01 ` [PATCH net-next v3 2/2] net: dsa: add port enable and disable helpers Vivien Didelot
2017-09-26 3:23 ` [PATCH net-next v3 0/2] net: dsa: port enabling David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Vivien Didelot @ 2017-09-22 23:01 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
The DSA slave open function configures the unicast MAC addresses on the
master device, enable the switch port, change its STP state, then start
the PHY device.
Make the close function symmetric, by first stopping the PHY device,
then changing the STP state, disabling the switch port and restore the
master device.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
net/dsa/slave.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 02ace7d462c4..c2bb48579032 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -133,6 +133,11 @@ static int dsa_slave_close(struct net_device *dev)
if (p->phy)
phy_stop(p->phy);
+ dsa_port_set_state_now(p->dp, BR_STATE_DISABLED);
+
+ if (ds->ops->port_disable)
+ ds->ops->port_disable(ds, p->dp->index, p->phy);
+
dev_mc_unsync(master, dev);
dev_uc_unsync(master, dev);
if (dev->flags & IFF_ALLMULTI)
@@ -143,11 +148,6 @@ static int dsa_slave_close(struct net_device *dev)
if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
dev_uc_del(master, dev->dev_addr);
- if (ds->ops->port_disable)
- ds->ops->port_disable(ds, p->dp->index, p->phy);
-
- dsa_port_set_state_now(p->dp, BR_STATE_DISABLED);
-
return 0;
}
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net-next v3 2/2] net: dsa: add port enable and disable helpers
2017-09-22 23:01 [PATCH net-next v3 0/2] net: dsa: port enabling Vivien Didelot
2017-09-22 23:01 ` [PATCH net-next v3 1/2] net: dsa: make slave close symmetrical to open Vivien Didelot
@ 2017-09-22 23:01 ` Vivien Didelot
2017-09-26 3:23 ` [PATCH net-next v3 0/2] net: dsa: port enabling David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Vivien Didelot @ 2017-09-22 23:01 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
Provide dsa_port_enable and dsa_port_disable helpers to respectively
enable and disable a switch port. This makes the dsa_port_set_state_now
helper static.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
net/dsa/dsa_priv.h | 3 ++-
net/dsa/port.c | 31 ++++++++++++++++++++++++++++++-
net/dsa/slave.c | 19 +++++--------------
3 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 9803952a5b40..0298a0f6a349 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -117,7 +117,8 @@ void dsa_master_ethtool_restore(struct net_device *dev);
/* port.c */
int dsa_port_set_state(struct dsa_port *dp, u8 state,
struct switchdev_trans *trans);
-void dsa_port_set_state_now(struct dsa_port *dp, u8 state);
+int dsa_port_enable(struct dsa_port *dp, struct phy_device *phy);
+void dsa_port_disable(struct dsa_port *dp, struct phy_device *phy);
int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br);
void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br);
int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering,
diff --git a/net/dsa/port.c b/net/dsa/port.c
index 76d43a82d397..72c8dbd3d3f2 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -56,7 +56,7 @@ int dsa_port_set_state(struct dsa_port *dp, u8 state,
return 0;
}
-void dsa_port_set_state_now(struct dsa_port *dp, u8 state)
+static void dsa_port_set_state_now(struct dsa_port *dp, u8 state)
{
int err;
@@ -65,6 +65,35 @@ void dsa_port_set_state_now(struct dsa_port *dp, u8 state)
pr_err("DSA: failed to set STP state %u (%d)\n", state, err);
}
+int dsa_port_enable(struct dsa_port *dp, struct phy_device *phy)
+{
+ u8 stp_state = dp->bridge_dev ? BR_STATE_BLOCKING : BR_STATE_FORWARDING;
+ struct dsa_switch *ds = dp->ds;
+ int port = dp->index;
+ int err;
+
+ if (ds->ops->port_enable) {
+ err = ds->ops->port_enable(ds, port, phy);
+ if (err)
+ return err;
+ }
+
+ dsa_port_set_state_now(dp, stp_state);
+
+ return 0;
+}
+
+void dsa_port_disable(struct dsa_port *dp, struct phy_device *phy)
+{
+ struct dsa_switch *ds = dp->ds;
+ int port = dp->index;
+
+ dsa_port_set_state_now(dp, BR_STATE_DISABLED);
+
+ if (ds->ops->port_disable)
+ ds->ops->port_disable(ds, port, phy);
+}
+
int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br)
{
struct dsa_notifier_bridge_info info = {
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index c2bb48579032..bd51ef56ec5b 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -73,9 +73,7 @@ static int dsa_slave_open(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp;
- struct dsa_switch *ds = dp->ds;
struct net_device *master = dsa_master_netdev(p);
- u8 stp_state = dp->bridge_dev ? BR_STATE_BLOCKING : BR_STATE_FORWARDING;
int err;
if (!(master->flags & IFF_UP))
@@ -98,13 +96,9 @@ static int dsa_slave_open(struct net_device *dev)
goto clear_allmulti;
}
- if (ds->ops->port_enable) {
- err = ds->ops->port_enable(ds, p->dp->index, p->phy);
- if (err)
- goto clear_promisc;
- }
-
- dsa_port_set_state_now(p->dp, stp_state);
+ err = dsa_port_enable(dp, p->phy);
+ if (err)
+ goto clear_promisc;
if (p->phy)
phy_start(p->phy);
@@ -128,15 +122,12 @@ static int dsa_slave_close(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct net_device *master = dsa_master_netdev(p);
- struct dsa_switch *ds = p->dp->ds;
+ struct dsa_port *dp = p->dp;
if (p->phy)
phy_stop(p->phy);
- dsa_port_set_state_now(p->dp, BR_STATE_DISABLED);
-
- if (ds->ops->port_disable)
- ds->ops->port_disable(ds, p->dp->index, p->phy);
+ dsa_port_disable(dp, p->phy);
dev_mc_unsync(master, dev);
dev_uc_unsync(master, dev);
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v3 0/2] net: dsa: port enabling
2017-09-22 23:01 [PATCH net-next v3 0/2] net: dsa: port enabling Vivien Didelot
2017-09-22 23:01 ` [PATCH net-next v3 1/2] net: dsa: make slave close symmetrical to open Vivien Didelot
2017-09-22 23:01 ` [PATCH net-next v3 2/2] net: dsa: add port enable and disable helpers Vivien Didelot
@ 2017-09-26 3:23 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-09-26 3:23 UTC (permalink / raw)
To: vivien.didelot; +Cc: netdev, linux-kernel, kernel, f.fainelli, andrew
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Date: Fri, 22 Sep 2017 19:01:54 -0400
> This patchset makes slave open and close symmetrical and provides
> helpers for enabling or disabling a given DSA port.
>
> Changes in v3:
> - save the phy_device change for a future patchset
>
> Changes in v2:
> - do not remove the phy argument from port enable/disable
Series applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-09-26 3:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-22 23:01 [PATCH net-next v3 0/2] net: dsa: port enabling Vivien Didelot
2017-09-22 23:01 ` [PATCH net-next v3 1/2] net: dsa: make slave close symmetrical to open Vivien Didelot
2017-09-22 23:01 ` [PATCH net-next v3 2/2] net: dsa: add port enable and disable helpers Vivien Didelot
2017-09-26 3:23 ` [PATCH net-next v3 0/2] net: dsa: port enabling David Miller
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).