summaryrefslogtreecommitdiffstats
path: root/net/core/net-sysfs.c
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2020-04-20 00:11:51 +0200
committerDavid S. Miller <davem@davemloft.net>2020-04-20 12:43:24 -0700
commitdb30a57779b18b7cef092c21887ed2d23ad2bd35 (patch)
treec8687e48259178fb2a7f2d23abe5a8eee9ee73bc /net/core/net-sysfs.c
parenteec517cdb4810b3843eb7707971de3164088bff1 (diff)
downloadlinux-db30a57779b18b7cef092c21887ed2d23ad2bd35.tar.gz
linux-db30a57779b18b7cef092c21887ed2d23ad2bd35.tar.bz2
linux-db30a57779b18b7cef092c21887ed2d23ad2bd35.zip
net: Add testing sysfs attribute
Similar to speed, duplex and dorment, report the testing status in sysfs. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.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.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 4773ad6ec111..0d9e46de205e 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -243,6 +243,18 @@ static ssize_t duplex_show(struct device *dev,
}
static DEVICE_ATTR_RO(duplex);
+static ssize_t testing_show(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_testing(netdev));
+
+ return -EINVAL;
+}
+static DEVICE_ATTR_RO(testing);
+
static ssize_t dormant_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -260,7 +272,7 @@ static const char *const operstates[] = {
"notpresent", /* currently unused */
"down",
"lowerlayerdown",
- "testing", /* currently unused */
+ "testing",
"dormant",
"up"
};
@@ -524,6 +536,7 @@ static struct attribute *net_class_attrs[] __ro_after_init = {
&dev_attr_speed.attr,
&dev_attr_duplex.attr,
&dev_attr_dormant.attr,
+ &dev_attr_testing.attr,
&dev_attr_operstate.attr,
&dev_attr_carrier_changes.attr,
&dev_attr_ifalias.attr,