[kernel] r15551 - in dists/sid/linux-2.6/debian: . patches/features/all patches/series

Maximilian Attems maks at alioth.debian.org
Sat Apr 24 01:43:34 UTC 2010


Author: maks
Date: Sat Apr 24 01:43:32 2010
New Revision: 15551

Log:
net: export device speed and duplex via sysfs

sent to stable, but not sure if accepted, anyway nice to have.

Added:
   dists/sid/linux-2.6/debian/patches/features/all/net-export-device-speed-and-duplex-via-sysfs.patch
Modified:
   dists/sid/linux-2.6/debian/changelog
   dists/sid/linux-2.6/debian/patches/series/12

Modified: dists/sid/linux-2.6/debian/changelog
==============================================================================
--- dists/sid/linux-2.6/debian/changelog	Sat Apr 24 01:14:43 2010	(r15550)
+++ dists/sid/linux-2.6/debian/changelog	Sat Apr 24 01:43:32 2010	(r15551)
@@ -46,6 +46,7 @@
   * Backport radeon r800 modesetting support.
   * drm/radeon/kms: further spread spectrum fixes.
   * Backport p54 fixes.
+  * net: export device speed and duplex via sysfs.
 
   [ dann frazier ]
   * Add DRBD backport

Added: dists/sid/linux-2.6/debian/patches/features/all/net-export-device-speed-and-duplex-via-sysfs.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/sid/linux-2.6/debian/patches/features/all/net-export-device-speed-and-duplex-via-sysfs.patch	Sat Apr 24 01:43:32 2010	(r15551)
@@ -0,0 +1,106 @@
+From d519e17e2d01a0ee9abe083019532061b4438065 Mon Sep 17 00:00:00 2001
+From: Andy Gospodarek <andy at greyhouse.net>
+Date: Fri, 2 Oct 2009 09:26:12 +0000
+Subject: [PATCH] net: export device speed and duplex via sysfs
+
+This patch exports the link-speed (in Mbps) and duplex of an interface
+via sysfs.  This eliminates the need to use ethtool just to check the
+link-speed.  Not requiring 'ethtool' and not relying on the SIOCETHTOOL
+ioctl should be helpful in an embedded environment where space is at a
+premium as well.
+
+NOTE: This patch also intentionally allows non-root users to check the link
+speed and duplex -- something not possible with ethtool.
+
+Here's some sample output:
+
+# cat /sys/class/net/eth0/speed
+100
+# cat /sys/class/net/eth0/duplex
+half
+# ethtool eth0
+Settings for eth0:
+        Supported ports: [ TP ]
+        Supported link modes:   10baseT/Half 10baseT/Full
+                                100baseT/Half 100baseT/Full
+                                1000baseT/Half 1000baseT/Full
+        Supports auto-negotiation: Yes
+        Advertised link modes:  Not reported
+        Advertised auto-negotiation: No
+        Speed: 100Mb/s
+        Duplex: Half
+        Port: Twisted Pair
+        PHYAD: 1
+        Transceiver: internal
+        Auto-negotiation: off
+        Supports Wake-on: g
+        Wake-on: g
+        Current message level: 0x000000ff (255)
+        Link detected: yes
+
+Signed-off-by: David S. Miller <davem at davemloft.net>
+---
+ net/core/net-sysfs.c |   40 ++++++++++++++++++++++++++++++++++++++++
+ 1 files changed, 40 insertions(+), 0 deletions(-)
+
+diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
+index 821d309..effb784 100644
+--- a/net/core/net-sysfs.c
++++ b/net/core/net-sysfs.c
+@@ -130,6 +130,44 @@ static ssize_t show_carrier(struct device *dev,
+ 	return -EINVAL;
+ }
+ 
++static ssize_t show_speed(struct device *dev,
++			  struct device_attribute *attr, char *buf)
++{
++	struct net_device *netdev = to_net_dev(dev);
++	int ret = -EINVAL;
++
++	if (!rtnl_trylock())
++		return restart_syscall();
++
++	if (netif_running(netdev) && netdev->ethtool_ops->get_settings) {
++		struct ethtool_cmd cmd = { ETHTOOL_GSET };
++
++		if (!netdev->ethtool_ops->get_settings(netdev, &cmd))
++			ret = sprintf(buf, fmt_dec, ethtool_cmd_speed(&cmd));
++	}
++	rtnl_unlock();
++	return ret;
++}
++
++static ssize_t show_duplex(struct device *dev,
++			   struct device_attribute *attr, char *buf)
++{
++	struct net_device *netdev = to_net_dev(dev);
++	int ret = -EINVAL;
++
++	if (!rtnl_trylock())
++		return restart_syscall();
++
++	if (netif_running(netdev) && netdev->ethtool_ops->get_settings) {
++		struct ethtool_cmd cmd = { ETHTOOL_GSET };
++
++		if (!netdev->ethtool_ops->get_settings(netdev, &cmd))
++			ret = sprintf(buf, "%s\n", cmd.duplex ? "full" : "half");
++	}
++	rtnl_unlock();
++	return ret;
++}
++
+ static ssize_t show_dormant(struct device *dev,
+ 			    struct device_attribute *attr, char *buf)
+ {
+@@ -259,6 +297,8 @@ 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(speed, S_IRUGO, show_speed, NULL),
++	__ATTR(duplex, S_IRUGO, show_duplex, NULL),
+ 	__ATTR(dormant, S_IRUGO, show_dormant, NULL),
+ 	__ATTR(operstate, S_IRUGO, show_operstate, NULL),
+ 	__ATTR(mtu, S_IRUGO | S_IWUSR, show_mtu, store_mtu),
+-- 
+1.6.5
+

Modified: dists/sid/linux-2.6/debian/patches/series/12
==============================================================================
--- dists/sid/linux-2.6/debian/patches/series/12	Sat Apr 24 01:14:43 2010	(r15550)
+++ dists/sid/linux-2.6/debian/patches/series/12	Sat Apr 24 01:43:32 2010	(r15551)
@@ -48,3 +48,4 @@
 + bugfix/all/p54pci-fix-serious-sparse-warning.patch
 + bugfix/all/p54pci-fix-bugs-in-p54p_check_tx_ring.patch
 + bugfix/all/p54pci-fix-regression.patch
++ features/all/net-export-device-speed-and-duplex-via-sysfs.patch



More information about the Kernel-svn-changes mailing list