diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2017-11-06 16:11:45 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-11-08 19:26:49 -0500 |
commit | 17a22fcfc84a422d98a0f54e67d4ee8ee3875849 (patch) | |
tree | d8ebb6b8988e6f29b2c3fe048d2b93cad639ddcf /net/dsa/master.c | |
parent | f070464cf000131928b2c3fd592efd1946610eea (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/master.c')
-rw-r--r-- | net/dsa/master.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/net/dsa/master.c b/net/dsa/master.c index 5f3f57e372e0..00589147f042 100644 --- a/net/dsa/master.c +++ b/net/dsa/master.c | |||
@@ -85,7 +85,7 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset, | |||
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | int dsa_master_ethtool_setup(struct net_device *dev) | 88 | static int dsa_master_ethtool_setup(struct net_device *dev) |
89 | { | 89 | { |
90 | struct dsa_port *cpu_dp = dev->dsa_ptr; | 90 | struct dsa_port *cpu_dp = dev->dsa_ptr; |
91 | struct dsa_switch *ds = cpu_dp->ds; | 91 | struct dsa_switch *ds = cpu_dp->ds; |
@@ -108,10 +108,36 @@ int dsa_master_ethtool_setup(struct net_device *dev) | |||
108 | return 0; | 108 | return 0; |
109 | } | 109 | } |
110 | 110 | ||
111 | void dsa_master_ethtool_restore(struct net_device *dev) | 111 | static void dsa_master_ethtool_teardown(struct net_device *dev) |
112 | { | 112 | { |
113 | struct dsa_port *cpu_dp = dev->dsa_ptr; | 113 | struct dsa_port *cpu_dp = dev->dsa_ptr; |
114 | 114 | ||
115 | dev->ethtool_ops = cpu_dp->orig_ethtool_ops; | 115 | dev->ethtool_ops = cpu_dp->orig_ethtool_ops; |
116 | cpu_dp->orig_ethtool_ops = NULL; | 116 | cpu_dp->orig_ethtool_ops = NULL; |
117 | } | 117 | } |
118 | |||
119 | int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp) | ||
120 | { | ||
121 | /* If we use a tagging format that doesn't have an ethertype | ||
122 | * field, make sure that all packets from this point on get | ||
123 | * sent to the tag format's receive function. | ||
124 | */ | ||
125 | wmb(); | ||
126 | |||
127 | dev->dsa_ptr = cpu_dp; | ||
128 | |||
129 | return dsa_master_ethtool_setup(dev); | ||
130 | } | ||
131 | |||
132 | void dsa_master_teardown(struct net_device *dev) | ||
133 | { | ||
134 | dsa_master_ethtool_teardown(dev); | ||
135 | |||
136 | dev->dsa_ptr = NULL; | ||
137 | |||
138 | /* If we used a tagging format that doesn't have an ethertype | ||
139 | * field, make sure that all packets from this point get sent | ||
140 | * without the tag and go through the regular receive path. | ||
141 | */ | ||
142 | wmb(); | ||
143 | } | ||