Skip to contentSkip to conversation

net: show stopped status in sysfs

PATCH In review Michael S. Tsirkin 3 participants 4 messages May 3, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: show stopped status in sysfs

When debugging faulty hardware (in case of virt, faulty emulation) I found it helpful to be able to examine stopped status of the interface. The following patch makes this visible in sysfs.

---
 net/core/net-sysfs.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
net/core/net-sysfs.c +11 -0
index c57c4b2..e1f80c0 100644
@@ -132,6 +132,16 @@ static ssize_t show_carrier(struct device *dev,
 	return -EINVAL;
 }
 
+static ssize_t show_stopped(struct device *dev,
+			    struct device_attribute *attr, char *buf)
+{
+	struct net_device *netdev = to_net_dev(dev);
+	if (netif_running(netdev)) {
+		return sprintf(buf, fmt_dec, !!netif_queue_stopped(netdev));
+	}
+	return -EINVAL;
+}
+
 static ssize_t show_speed(struct device *dev,
 			  struct device_attribute *attr, char *buf)
 {
@@ -303,6 +313,7 @@ static struct device_attribute net_class_attributes[] = {
 	__ATTR(address, S_IRUGO, show_address, NULL),
 	__ATTR(broadcast, S_IRUGO, show_broadcast, NULL),
 	__ATTR(carrier, S_IRUGO, show_carrier, NULL),
+	__ATTR(carrier, S_IRUGO, show_stopped, NULL),
 	__ATTR(speed, S_IRUGO, show_speed, NULL),
 	__ATTR(duplex, S_IRUGO, show_duplex, NULL),
 	__ATTR(dormant, S_IRUGO, show_dormant, NULL),
Signature · 1 line
1.7.1.rc1.22.g3163
#1 lore raw
Quoted 4 lines · Michael S. Tsirkin

When debugging faulty hardware (in case of virt, faulty emulation) I found it helpful to be able to examine stopped status of the interface. The following patch makes this visible in sysfs.

[...]

This is a per-queue attribute and should not be associated directly with the netdev.

Ben.

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
maintainer
#2 lore raw

From: Ben Hutchings <[email protected]>
Date: Mon, 03 May 2010 22:44:53 +0100

Quoted 9 lines · Michael S. Tsirkin
Quoted 4 lines

When debugging faulty hardware (in case of virt, faulty emulation) I found it helpful to be able to examine stopped status of the interface. The following patch makes this visible in sysfs.

[...]

This is a per-queue attribute and should not be associated directly with the netdev.

Right.

maintainer
#3 lore raw
In reply to Michael S. Tsirkin

From: "Michael S. Tsirkin" <[email protected]>
Date: Tue, 4 May 2010 00:24:25 +0300

net/core/net-sysfs.c static struct device_attribute net_class_attributes[] = { · line 316

Quoted 5 lines
net/core/net-sysfs.c +1 -0
@@ -303,6 +313,7 @@ static struct device_attribute net_class_attributes[] = {
 	__ATTR(address, S_IRUGO, show_address, NULL),
 	__ATTR(broadcast, S_IRUGO, show_broadcast, NULL),
 	__ATTR(carrier, S_IRUGO, show_carrier, NULL),
+	__ATTR(carrier, S_IRUGO, show_stopped, NULL),

Besides the fact that you have to publish this as a per-queue attribute, you're also erroneously naming it 'carrier' here.