aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2018-11-28 16:40:04 -0500
committerDavid S. Miller <davem@davemloft.net>2018-11-30 20:17:39 -0500
commita3d7e01da06013dc580641a1da57c3b482d58157 (patch)
treed70f2b58060b47d2e5608d381209a985016ede8f /net/dsa
parentfd6d433865a2ad1f7e018ef80408cb3dc3be1ab3 (diff)
net: dsa: Fix tagging attribute location
While introducing the DSA tagging protocol attribute, it was added to the DSA slave network devices, but those actually see untagged traffic (that is their whole purpose). Correct this mistake by putting the tagging sysfs attribute under the DSA master network device where this is the information that we need. While at it, also correct the sysfs documentation mistake that missed the "dsa/" directory component of the attribute. Fixes: 98cdb4807123 ("net: dsa: Expose tagging protocol to user-space") Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/master.c34
-rw-r--r--net/dsa/slave.c28
2 files changed, 33 insertions, 29 deletions
diff --git a/net/dsa/master.c b/net/dsa/master.c
index c90ee3227dea..5e8c9bef78bd 100644
--- a/net/dsa/master.c
+++ b/net/dsa/master.c
@@ -158,8 +158,31 @@ static void dsa_master_ethtool_teardown(struct net_device *dev)
158 cpu_dp->orig_ethtool_ops = NULL; 158 cpu_dp->orig_ethtool_ops = NULL;
159} 159}
160 160
161static ssize_t tagging_show(struct device *d, struct device_attribute *attr,
162 char *buf)
163{
164 struct net_device *dev = to_net_dev(d);
165 struct dsa_port *cpu_dp = dev->dsa_ptr;
166
167 return sprintf(buf, "%s\n",
168 dsa_tag_protocol_to_str(cpu_dp->tag_ops));
169}
170static DEVICE_ATTR_RO(tagging);
171
172static struct attribute *dsa_slave_attrs[] = {
173 &dev_attr_tagging.attr,
174 NULL
175};
176
177static const struct attribute_group dsa_group = {
178 .name = "dsa",
179 .attrs = dsa_slave_attrs,
180};
181
161int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp) 182int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
162{ 183{
184 int ret;
185
163 /* If we use a tagging format that doesn't have an ethertype 186 /* If we use a tagging format that doesn't have an ethertype
164 * field, make sure that all packets from this point on get 187 * field, make sure that all packets from this point on get
165 * sent to the tag format's receive function. 188 * sent to the tag format's receive function.
@@ -168,11 +191,20 @@ int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
168 191
169 dev->dsa_ptr = cpu_dp; 192 dev->dsa_ptr = cpu_dp;
170 193
171 return dsa_master_ethtool_setup(dev); 194 ret = dsa_master_ethtool_setup(dev);
195 if (ret)
196 return ret;
197
198 ret = sysfs_create_group(&dev->dev.kobj, &dsa_group);
199 if (ret)
200 dsa_master_ethtool_teardown(dev);
201
202 return ret;
172} 203}
173 204
174void dsa_master_teardown(struct net_device *dev) 205void dsa_master_teardown(struct net_device *dev)
175{ 206{
207 sysfs_remove_group(&dev->dev.kobj, &dsa_group);
176 dsa_master_ethtool_teardown(dev); 208 dsa_master_ethtool_teardown(dev);
177 209
178 dev->dsa_ptr = NULL; 210 dev->dsa_ptr = NULL;
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 7d0c19e7edcf..aec78f5aca72 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1058,27 +1058,6 @@ static struct device_type dsa_type = {
1058 .name = "dsa", 1058 .name = "dsa",
1059}; 1059};
1060 1060
1061static ssize_t tagging_show(struct device *d, struct device_attribute *attr,
1062 char *buf)
1063{
1064 struct net_device *dev = to_net_dev(d);
1065 struct dsa_port *dp = dsa_slave_to_port(dev);
1066
1067 return sprintf(buf, "%s\n",
1068 dsa_tag_protocol_to_str(dp->cpu_dp->tag_ops));
1069}
1070static DEVICE_ATTR_RO(tagging);
1071
1072static struct attribute *dsa_slave_attrs[] = {
1073 &dev_attr_tagging.attr,
1074 NULL
1075};
1076
1077static const struct attribute_group dsa_group = {
1078 .name = "dsa",
1079 .attrs = dsa_slave_attrs,
1080};
1081
1082static void dsa_slave_phylink_validate(struct net_device *dev, 1061static void dsa_slave_phylink_validate(struct net_device *dev,
1083 unsigned long *supported, 1062 unsigned long *supported,
1084 struct phylink_link_state *state) 1063 struct phylink_link_state *state)
@@ -1374,14 +1353,8 @@ int dsa_slave_create(struct dsa_port *port)
1374 goto out_phy; 1353 goto out_phy;
1375 } 1354 }
1376 1355
1377 ret = sysfs_create_group(&slave_dev->dev.kobj, &dsa_group);
1378 if (ret)
1379 goto out_unreg;
1380
1381 return 0; 1356 return 0;
1382 1357
1383out_unreg:
1384 unregister_netdev(slave_dev);
1385out_phy: 1358out_phy:
1386 rtnl_lock(); 1359 rtnl_lock();
1387 phylink_disconnect_phy(p->dp->pl); 1360 phylink_disconnect_phy(p->dp->pl);
@@ -1405,7 +1378,6 @@ void dsa_slave_destroy(struct net_device *slave_dev)
1405 rtnl_unlock(); 1378 rtnl_unlock();
1406 1379
1407 dsa_slave_notify(slave_dev, DSA_PORT_UNREGISTER); 1380 dsa_slave_notify(slave_dev, DSA_PORT_UNREGISTER);
1408 sysfs_remove_group(&slave_dev->dev.kobj, &dsa_group);
1409 unregister_netdev(slave_dev); 1381 unregister_netdev(slave_dev);
1410 phylink_destroy(dp->pl); 1382 phylink_destroy(dp->pl);
1411 free_percpu(p->stats64); 1383 free_percpu(p->stats64);