Skip to content

Commit 4890e3b

Browse files
committed
wireless: implement basic ethtool support for cfg80211 devices
Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent f41bb89 commit 4890e3b

4 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎net/wireless/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ obj-$(CONFIG_WEXT_SPY) += wext-spy.o
1010
obj-$(CONFIG_WEXT_PRIV) += wext-priv.o
1111

1212
cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o
13-
cfg80211-y += mlme.o ibss.o sme.o chan.o
13+
cfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o
1414
cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o
1515
cfg80211-$(CONFIG_CFG80211_WEXT) += wext-compat.o wext-sme.o
1616

‎net/wireless/core.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "sysfs.h"
2222
#include "debugfs.h"
2323
#include "wext-compat.h"
24+
#include "ethtool.h"
2425

2526
/* name for sysfs, %d is appended */
2627
#define PHY_NAME "phy"
@@ -690,6 +691,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
690691
wdev->wext.ps = false;
691692
}
692693
#endif
694+
if (!dev->ethtool_ops)
695+
dev->ethtool_ops = &cfg80211_ethtool_ops;
693696
break;
694697
case NETDEV_GOING_DOWN:
695698
switch (wdev->iftype) {

‎net/wireless/ethtool.c‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <linux/utsname.h>
2+
#include <net/cfg80211.h>
3+
#include "ethtool.h"
4+
5+
static void cfg80211_get_drvinfo(struct net_device *dev,
6+
struct ethtool_drvinfo *info)
7+
{
8+
struct wireless_dev *wdev = dev->ieee80211_ptr;
9+
10+
strlcpy(info->driver, wiphy_dev(wdev->wiphy)->driver->name,
11+
sizeof(info->driver));
12+
13+
strlcpy(info->version, init_utsname()->release, sizeof(info->version));
14+
15+
strlcpy(info->fw_version, "N/A", sizeof(info->fw_version));
16+
17+
strlcpy(info->bus_info, dev_name(wiphy_dev(wdev->wiphy)),
18+
sizeof(info->bus_info));
19+
}
20+
21+
const struct ethtool_ops cfg80211_ethtool_ops = {
22+
.get_drvinfo = cfg80211_get_drvinfo,
23+
.get_link = ethtool_op_get_link,
24+
};

‎net/wireless/ethtool.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef __CFG80211_ETHTOOL__
2+
#define __CFG80211_ETHTOOL__
3+
4+
#include <linux/ethtool.h>
5+
6+
extern const struct ethtool_ops cfg80211_ethtool_ops;
7+
8+
#endif /* __CFG80211_ETHTOOL__ */

0 commit comments

Comments
 (0)