[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1374840596-5748-4-git-send-email-jiri@resnulli.us>
Date: Fri, 26 Jul 2013 14:09:55 +0200
From: Jiri Pirko <jiri@...nulli.us>
To: netdev@...r.kernel.org
Cc: davem@...emloft.net, stephen@...workplumber.org,
Narendra_K@...l.com, bhutchings@...arflare.com,
john.r.fastabend@...el.com, or.gerlitz@...il.com,
jeffrey.t.kirsher@...el.com, jesse.brandeburg@...el.com,
bruce.w.allan@...el.com, carolyn.wyborny@...el.com,
donald.c.skidmore@...el.com, gregory.v.rose@...el.com,
peter.p.waskiewicz.jr@...el.com, alexander.h.duyck@...el.com,
john.ronciak@...el.com, tushar.n.dave@...el.com,
matthew.vick@...el.com, mitch.a.williams@...el.com,
vyasevic@...hat.com, amwang@...hat.com, johannes@...solutions.net,
Narendra K <narendra_k@...l.com>
Subject: [patch net-next v5 3/4] net: export physical port id via sysfs
Signed-off-by: Jiri Pirko <jiri@...nulli.us>
Acked-by: Ben Hutchings <bhutchings@...arflare.com>
Signed-off-by: Narendra K <narendra_k@...l.com>
---
net/core/net-sysfs.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 981fed3..8826b0d 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,
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[] = {
__ATTR(addr_assign_type, S_IRUGO, show_addr_assign_type, NULL),
__ATTR(addr_len, S_IRUGO, show_addr_len, NULL),
@@ -355,6 +376,7 @@ static struct device_attribute net_class_attributes[] = {
__ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len,
store_tx_queue_len),
__ATTR(netdev_group, S_IRUGO | S_IWUSR, show_group, store_group),
+ __ATTR(phys_port_id, S_IRUGO, show_phys_port_id, NULL),
{}
};
--
1.8.1.4
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists