aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/net-sysfs.c
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2019-02-06 12:45:35 -0500
committerDavid S. Miller <davem@davemloft.net>2019-02-06 17:16:11 -0500
commitd6abc5969463359c366d459247b90366fcd6f5c5 (patch)
treeb957d030e5c687e689f0da32c9585c81a7f6efbd /net/core/net-sysfs.c
parent47b98039fb6e1b3fc7b04a86a9c8ed5bbf604103 (diff)
net: Introduce ndo_get_port_parent_id()
In preparation for getting rid of switchdev_ops, create a dedicated NDO operation for getting the port's parent identifier. There are essentially two classes of drivers that need to implement getting the port's parent ID which are VF/PF drivers with a built-in switch, and pure switchdev drivers such as mlxsw, ocelot, dsa etc. We introduce a helper function: dev_get_port_parent_id() which supports recursion into the lower devices to obtain the first port's parent ID. Convert the bridge, core and ipv4 multicast routing code to check for such ndo_get_port_parent_id() and call the helper function when valid before falling back to switchdev_port_attr_get(). This will allow us to convert all relevant drivers in one go instead of having to implement both switchdev_port_attr_get() and ndo_get_port_parent_id() operations, then get rid of switchdev_port_attr_get(). Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/net-sysfs.c')
-rw-r--r--net/core/net-sysfs.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index ff9fd2bb4ce4..4eace9f1dcf9 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -495,6 +495,7 @@ static ssize_t phys_switch_id_show(struct device *dev,
495 struct device_attribute *attr, char *buf) 495 struct device_attribute *attr, char *buf)
496{ 496{
497 struct net_device *netdev = to_net_dev(dev); 497 struct net_device *netdev = to_net_dev(dev);
498 const struct net_device_ops *ops = netdev->netdev_ops;
498 ssize_t ret = -EINVAL; 499 ssize_t ret = -EINVAL;
499 500
500 if (!rtnl_trylock()) 501 if (!rtnl_trylock())
@@ -507,7 +508,11 @@ static ssize_t phys_switch_id_show(struct device *dev,
507 .flags = SWITCHDEV_F_NO_RECURSE, 508 .flags = SWITCHDEV_F_NO_RECURSE,
508 }; 509 };
509 510
510 ret = switchdev_port_attr_get(netdev, &attr); 511 if (ops->ndo_get_port_parent_id)
512 ret = dev_get_port_parent_id(netdev, &attr.u.ppid,
513 false);
514 else
515 ret = switchdev_port_attr_get(netdev, &attr);
511 if (!ret) 516 if (!ret)
512 ret = sprintf(buf, "%*phN\n", attr.u.ppid.id_len, 517 ret = sprintf(buf, "%*phN\n", attr.u.ppid.id_len,
513 attr.u.ppid.id); 518 attr.u.ppid.id);