diff options
-rw-r--r-- | 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 821d30918cfc..effb78410eb2 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, | |||
130 | return -EINVAL; | 130 | return -EINVAL; |
131 | } | 131 | } |
132 | 132 | ||
133 | static ssize_t show_speed(struct device *dev, | ||
134 | struct device_attribute *attr, char *buf) | ||
135 | { | ||
136 | struct net_device *netdev = to_net_dev(dev); | ||
137 | int ret = -EINVAL; | ||
138 | |||
139 | if (!rtnl_trylock()) | ||
140 | return restart_syscall(); | ||
141 | |||
142 | if (netif_running(netdev) && netdev->ethtool_ops->get_settings) { | ||
143 | struct ethtool_cmd cmd = { ETHTOOL_GSET }; | ||
144 | |||
145 | if (!netdev->ethtool_ops->get_settings(netdev, &cmd)) | ||
146 | ret = sprintf(buf, fmt_dec, ethtool_cmd_speed(&cmd)); | ||
147 | } | ||
148 | rtnl_unlock(); | ||
149 | return ret; | ||
150 | } | ||
151 | |||
152 | static ssize_t show_duplex(struct device *dev, | ||
153 | struct device_attribute *attr, char *buf) | ||
154 | { | ||
155 | struct net_device *netdev = to_net_dev(dev); | ||
156 | int ret = -EINVAL; | ||
157 | |||
158 | if (!rtnl_trylock()) | ||
159 | return restart_syscall(); | ||
160 | |||
161 | if (netif_running(netdev) && netdev->ethtool_ops->get_settings) { | ||
162 | struct ethtool_cmd cmd = { ETHTOOL_GSET }; | ||
163 | |||
164 | if (!netdev->ethtool_ops->get_settings(netdev, &cmd)) | ||
165 | ret = sprintf(buf, "%s\n", cmd.duplex ? "full" : "half"); | ||
166 | } | ||
167 | rtnl_unlock(); | ||
168 | return ret; | ||
169 | } | ||
170 | |||
133 | static ssize_t show_dormant(struct device *dev, | 171 | static ssize_t show_dormant(struct device *dev, |
134 | struct device_attribute *attr, char *buf) | 172 | struct device_attribute *attr, char *buf) |
135 | { | 173 | { |
@@ -259,6 +297,8 @@ static struct device_attribute net_class_attributes[] = { | |||
259 | __ATTR(address, S_IRUGO, show_address, NULL), | 297 | __ATTR(address, S_IRUGO, show_address, NULL), |
260 | __ATTR(broadcast, S_IRUGO, show_broadcast, NULL), | 298 | __ATTR(broadcast, S_IRUGO, show_broadcast, NULL), |
261 | __ATTR(carrier, S_IRUGO, show_carrier, NULL), | 299 | __ATTR(carrier, S_IRUGO, show_carrier, NULL), |
300 | __ATTR(speed, S_IRUGO, show_speed, NULL), | ||
301 | __ATTR(duplex, S_IRUGO, show_duplex, NULL), | ||
262 | __ATTR(dormant, S_IRUGO, show_dormant, NULL), | 302 | __ATTR(dormant, S_IRUGO, show_dormant, NULL), |
263 | __ATTR(operstate, S_IRUGO, show_operstate, NULL), | 303 | __ATTR(operstate, S_IRUGO, show_operstate, NULL), |
264 | __ATTR(mtu, S_IRUGO | S_IWUSR, show_mtu, store_mtu), | 304 | __ATTR(mtu, S_IRUGO | S_IWUSR, show_mtu, store_mtu), |