diff options
author | Jiri Pirko <jiri@resnulli.us> | 2013-07-29 12:16:51 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-07-30 20:31:25 -0400 |
commit | ff80e519ab1b3a6abb2c6bbf684b98be07111879 (patch) | |
tree | 35c295ad35956c5e92916b2b9dc0d80514fe0f09 /net/core/net-sysfs.c | |
parent | 66cae9ed6bc46b8cc57a9693f99f69926f3cc7ef (diff) |
net: export physical port id via sysfs
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Acked-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Narendra K <narendra_k@dell.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.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 981fed397d1d..8826b0d1e0cc 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
@@ -334,6 +334,27 @@ static ssize_t store_group(struct device *dev, struct device_attribute *attr, | |||
334 | return netdev_store(dev, attr, buf, len, change_group); | 334 | return netdev_store(dev, attr, buf, len, change_group); |
335 | } | 335 | } |
336 | 336 | ||
337 | static ssize_t show_phys_port_id(struct device *dev, | ||
338 | struct device_attribute *attr, char *buf) | ||
339 | { | ||
340 | struct net_device *netdev = to_net_dev(dev); | ||
341 | ssize_t ret = -EINVAL; | ||
342 | |||
343 | if (!rtnl_trylock()) | ||
344 | return restart_syscall(); | ||
345 | |||
346 | if (dev_isalive(netdev)) { | ||
347 | struct netdev_phys_port_id ppid; | ||
348 | |||
349 | ret = dev_get_phys_port_id(netdev, &ppid); | ||
350 | if (!ret) | ||
351 | ret = sprintf(buf, "%*phN\n", ppid.id_len, ppid.id); | ||
352 | } | ||
353 | rtnl_unlock(); | ||
354 | |||
355 | return ret; | ||
356 | } | ||
357 | |||
337 | static struct device_attribute net_class_attributes[] = { | 358 | static struct device_attribute net_class_attributes[] = { |
338 | __ATTR(addr_assign_type, S_IRUGO, show_addr_assign_type, NULL), | 359 | __ATTR(addr_assign_type, S_IRUGO, show_addr_assign_type, NULL), |
339 | __ATTR(addr_len, S_IRUGO, show_addr_len, NULL), | 360 | __ATTR(addr_len, S_IRUGO, show_addr_len, NULL), |
@@ -355,6 +376,7 @@ static struct device_attribute net_class_attributes[] = { | |||
355 | __ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len, | 376 | __ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len, |
356 | store_tx_queue_len), | 377 | store_tx_queue_len), |
357 | __ATTR(netdev_group, S_IRUGO | S_IWUSR, show_group, store_group), | 378 | __ATTR(netdev_group, S_IRUGO | S_IWUSR, show_group, store_group), |
379 | __ATTR(phys_port_id, S_IRUGO, show_phys_port_id, NULL), | ||
358 | {} | 380 | {} |
359 | }; | 381 | }; |
360 | 382 | ||