aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorScott Feldman <sfeldma@gmail.com>2015-05-10 12:47:49 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-12 18:43:53 -0400
commitf8e20a9f87d33865cc1d67f13da0db8d457fc3c9 (patch)
tree0072db71330af1215e78c1def9033d62156a4183 /net/dsa
parent3094333d9089d43e8b8f0418676fa6ae06c27b51 (diff)
switchdev: convert parent_id_get to switchdev attr get
Switch ID is just a gettable port attribute. Convert switchdev op switchdev_parent_id_get to a switchdev attr. Note: for sysfs and netlink interfaces, SWITCHDEV_ATTR_PORT_PARENT_ID is called with SWITCHDEV_F_NO_RECUSE to limit switch ID user-visiblity to only port netdevs. So when a port is stacked under bond/bridge, the user can only query switch id via the switch ports, but not via the upper devices Signed-off-by: Scott Feldman <sfeldma@gmail.com> Acked-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/slave.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 1546acf6ebd3..de705b674ac9 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -382,14 +382,20 @@ static int dsa_slave_bridge_port_leave(struct net_device *dev)
382 return ret; 382 return ret;
383} 383}
384 384
385static int dsa_slave_parent_id_get(struct net_device *dev, 385static int dsa_slave_port_attr_get(struct net_device *dev,
386 struct netdev_phys_item_id *psid) 386 struct switchdev_attr *attr)
387{ 387{
388 struct dsa_slave_priv *p = netdev_priv(dev); 388 struct dsa_slave_priv *p = netdev_priv(dev);
389 struct dsa_switch *ds = p->parent; 389 struct dsa_switch *ds = p->parent;
390 390
391 psid->id_len = sizeof(ds->index); 391 switch (attr->id) {
392 memcpy(&psid->id, &ds->index, psid->id_len); 392 case SWITCHDEV_ATTR_PORT_PARENT_ID:
393 attr->ppid.id_len = sizeof(ds->index);
394 memcpy(&attr->ppid.id, &ds->index, attr->ppid.id_len);
395 break;
396 default:
397 return -EOPNOTSUPP;
398 }
393 399
394 return 0; 400 return 0;
395} 401}
@@ -676,7 +682,7 @@ static const struct net_device_ops dsa_slave_netdev_ops = {
676}; 682};
677 683
678static const struct switchdev_ops dsa_slave_switchdev_ops = { 684static const struct switchdev_ops dsa_slave_switchdev_ops = {
679 .switchdev_parent_id_get = dsa_slave_parent_id_get, 685 .switchdev_port_attr_get = dsa_slave_port_attr_get,
680 .switchdev_port_stp_update = dsa_slave_stp_update, 686 .switchdev_port_stp_update = dsa_slave_stp_update,
681}; 687};
682 688