blob: 7eecdf40cf80b3420b745ff044896948c7492201 [file] [log] [blame]
John W. Linville4890e3b2009-09-30 14:50:17 -04001#include <linux/utsname.h>
2#include <net/cfg80211.h>
John W. Linville36777132011-03-07 16:17:59 -05003#include "core.h"
John W. Linville4890e3b2009-09-30 14:50:17 -04004#include "ethtool.h"
5
6static void cfg80211_get_drvinfo(struct net_device *dev,
7 struct ethtool_drvinfo *info)
8{
9 struct wireless_dev *wdev = dev->ieee80211_ptr;
10
11 strlcpy(info->driver, wiphy_dev(wdev->wiphy)->driver->name,
12 sizeof(info->driver));
13
14 strlcpy(info->version, init_utsname()->release, sizeof(info->version));
15
Kalle Valodfce95f2009-09-24 11:02:42 -070016 if (wdev->wiphy->fw_version[0])
17 strncpy(info->fw_version, wdev->wiphy->fw_version,
18 sizeof(info->fw_version));
19 else
20 strncpy(info->fw_version, "N/A", sizeof(info->fw_version));
John W. Linville4890e3b2009-09-30 14:50:17 -040021
22 strlcpy(info->bus_info, dev_name(wiphy_dev(wdev->wiphy)),
23 sizeof(info->bus_info));
24}
25
Kalle Valodfce95f2009-09-24 11:02:42 -070026static int cfg80211_get_regs_len(struct net_device *dev)
27{
28 /* For now, return 0... */
29 return 0;
30}
31
32static void cfg80211_get_regs(struct net_device *dev, struct ethtool_regs *regs,
33 void *data)
34{
35 struct wireless_dev *wdev = dev->ieee80211_ptr;
36
37 regs->version = wdev->wiphy->hw_version;
38 regs->len = 0;
39}
40
John W. Linville36777132011-03-07 16:17:59 -050041static void cfg80211_get_ringparam(struct net_device *dev,
42 struct ethtool_ringparam *rp)
43{
44 struct wireless_dev *wdev = dev->ieee80211_ptr;
45 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
46
47 memset(rp, 0, sizeof(*rp));
48
49 if (rdev->ops->get_ringparam)
50 rdev->ops->get_ringparam(wdev->wiphy,
51 &rp->tx_pending, &rp->tx_max_pending,
52 &rp->rx_pending, &rp->rx_max_pending);
53}
54
55static int cfg80211_set_ringparam(struct net_device *dev,
56 struct ethtool_ringparam *rp)
57{
58 struct wireless_dev *wdev = dev->ieee80211_ptr;
59 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
60
61 if (rp->rx_mini_pending != 0 || rp->rx_jumbo_pending != 0)
62 return -EINVAL;
63
64 if (rdev->ops->set_ringparam)
65 return rdev->ops->set_ringparam(wdev->wiphy,
66 rp->tx_pending, rp->rx_pending);
67
68 return -ENOTSUPP;
69}
70
Ben Greeard6199212012-04-23 12:50:29 -070071static int cfg80211_get_sset_count(struct net_device *dev, int sset)
72{
73 struct wireless_dev *wdev = dev->ieee80211_ptr;
74 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
75 if (rdev->ops->get_et_sset_count)
76 return rdev->ops->get_et_sset_count(wdev->wiphy, dev, sset);
77 return -EOPNOTSUPP;
78}
79
80static void cfg80211_get_stats(struct net_device *dev,
81 struct ethtool_stats *stats, u64 *data)
82{
83 struct wireless_dev *wdev = dev->ieee80211_ptr;
84 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
85 if (rdev->ops->get_et_stats)
86 rdev->ops->get_et_stats(wdev->wiphy, dev, stats, data);
87}
88
89static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data)
90{
91 struct wireless_dev *wdev = dev->ieee80211_ptr;
92 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
93 if (rdev->ops->get_et_strings)
94 rdev->ops->get_et_strings(wdev->wiphy, dev, sset, data);
95}
96
John W. Linville4890e3b2009-09-30 14:50:17 -040097const struct ethtool_ops cfg80211_ethtool_ops = {
98 .get_drvinfo = cfg80211_get_drvinfo,
Kalle Valodfce95f2009-09-24 11:02:42 -070099 .get_regs_len = cfg80211_get_regs_len,
100 .get_regs = cfg80211_get_regs,
John W. Linville4890e3b2009-09-30 14:50:17 -0400101 .get_link = ethtool_op_get_link,
John W. Linville36777132011-03-07 16:17:59 -0500102 .get_ringparam = cfg80211_get_ringparam,
103 .set_ringparam = cfg80211_set_ringparam,
Ben Greeard6199212012-04-23 12:50:29 -0700104 .get_strings = cfg80211_get_strings,
105 .get_ethtool_stats = cfg80211_get_stats,
106 .get_sset_count = cfg80211_get_sset_count,
John W. Linville4890e3b2009-09-30 14:50:17 -0400107};