Commit ff80e519 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

net: export physical port id via sysfs

Signed-off-by: default avatarJiri Pirko <jiri@resnulli.us>
Acked-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarNarendra K <narendra_k@dell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 66cae9ed
...@@ -334,6 +334,27 @@ static ssize_t store_group(struct device *dev, struct device_attribute *attr, ...@@ -334,6 +334,27 @@ static ssize_t store_group(struct device *dev, struct device_attribute *attr,
return netdev_store(dev, attr, buf, len, change_group); return netdev_store(dev, attr, buf, len, change_group);
} }
static ssize_t show_phys_port_id(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct net_device *netdev = to_net_dev(dev);
ssize_t ret = -EINVAL;
if (!rtnl_trylock())
return restart_syscall();
if (dev_isalive(netdev)) {
struct netdev_phys_port_id ppid;
ret = dev_get_phys_port_id(netdev, &ppid);
if (!ret)
ret = sprintf(buf, "%*phN\n", ppid.id_len, ppid.id);
}
rtnl_unlock();
return ret;
}
static struct device_attribute net_class_attributes[] = { static struct device_attribute net_class_attributes[] = {
__ATTR(addr_assign_type, S_IRUGO, show_addr_assign_type, NULL), __ATTR(addr_assign_type, S_IRUGO, show_addr_assign_type, NULL),
__ATTR(addr_len, S_IRUGO, show_addr_len, NULL), __ATTR(addr_len, S_IRUGO, show_addr_len, NULL),
...@@ -355,6 +376,7 @@ static struct device_attribute net_class_attributes[] = { ...@@ -355,6 +376,7 @@ static struct device_attribute net_class_attributes[] = {
__ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len, __ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len,
store_tx_queue_len), store_tx_queue_len),
__ATTR(netdev_group, S_IRUGO | S_IWUSR, show_group, store_group), __ATTR(netdev_group, S_IRUGO | S_IWUSR, show_group, store_group),
__ATTR(phys_port_id, S_IRUGO, show_phys_port_id, NULL),
{} {}
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment