summaryrefslogtreecommitdiff
path: root/net/dsa/dsa2.c
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>2017-11-06 16:11:45 -0500
committerDavid S. Miller <davem@davemloft.net>2017-11-09 09:26:49 +0900
commit17a22fcfc84a422d98a0f54e67d4ee8ee3875849 (patch)
treed8ebb6b8988e6f29b2c3fe048d2b93cad639ddcf /net/dsa/dsa2.c
parentf070464cf000131928b2c3fd592efd1946610eea (diff)
net: dsa: setup and teardown master device
Add DSA helpers to setup and teardown a master net device wired to its CPU port. This centralizes the dsa_ptr assignment. This also makes the master ethtool helpers static at the same time. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/dsa2.c')
-rw-r--r--net/dsa/dsa2.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 0a63a2119cd0..c9b50339fcac 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -469,6 +469,23 @@ static void dsa_ds_unapply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
}
+static int dsa_tree_setup_master(struct dsa_switch_tree *dst)
+{
+ struct dsa_port *cpu_dp = dst->cpu_dp;
+ struct net_device *master = cpu_dp->master;
+
+ /* DSA currently supports a single pair of CPU port and master device */
+ return dsa_master_setup(master, cpu_dp);
+}
+
+static void dsa_tree_teardown_master(struct dsa_switch_tree *dst)
+{
+ struct dsa_port *cpu_dp = dst->cpu_dp;
+ struct net_device *master = cpu_dp->master;
+
+ return dsa_master_teardown(master);
+}
+
static int dsa_dst_apply(struct dsa_switch_tree *dst)
{
struct dsa_switch *ds;
@@ -489,14 +506,7 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)
return err;
}
- /* If we use a tagging format that doesn't have an ethertype
- * field, make sure that all packets from this point on get
- * sent to the tag format's receive function.
- */
- wmb();
- dst->cpu_dp->master->dsa_ptr = dst->cpu_dp;
-
- err = dsa_master_ethtool_setup(dst->cpu_dp->master);
+ err = dsa_tree_setup_master(dst);
if (err)
return err;
@@ -513,15 +523,7 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)
if (!dst->applied)
return;
- dsa_master_ethtool_restore(dst->cpu_dp->master);
-
- dst->cpu_dp->master->dsa_ptr = NULL;
-
- /* If we used a tagging format that doesn't have an ethertype
- * field, make sure that all packets from this point get sent
- * without the tag and go through the regular receive path.
- */
- wmb();
+ dsa_tree_teardown_master(dst);
for (index = 0; index < DSA_MAX_SWITCHES; index++) {
ds = dst->ds[index];