blob: e37862f1b1270d8e2056fb6289f01bf69b583720 [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"
Hila Gonene35e4d22012-06-27 17:19:42 +03005#include "rdev-ops.h"
John W. Linville4890e3b2009-09-30 14:50:17 -04006
7static void cfg80211_get_drvinfo(struct net_device *dev,
8 struct ethtool_drvinfo *info)
9{
10 struct wireless_dev *wdev = dev->ieee80211_ptr;
11
12 strlcpy(info->driver, wiphy_dev(wdev->wiphy)->driver->name,
13 sizeof(info->driver));
14
15 strlcpy(info->version, init_utsname()->release, sizeof(info->version));
16
Kalle Valodfce95f2009-09-24 11:02:42 -070017 if (wdev->wiphy->fw_version[0])
Jiri Pirko7826d432013-01-06 00:44:26 +000018 strlcpy(info->fw_version, wdev->wiphy->fw_version,
Kalle Valodfce95f2009-09-24 11:02:42 -070019 sizeof(info->fw_version));
20 else
Jiri Pirko7826d432013-01-06 00:44:26 +000021 strlcpy(info->fw_version, "N/A", sizeof(info->fw_version));
John W. Linville4890e3b2009-09-30 14:50:17 -040022
23 strlcpy(info->bus_info, dev_name(wiphy_dev(wdev->wiphy)),
24 sizeof(info->bus_info));
25}
26
Kalle Valodfce95f2009-09-24 11:02:42 -070027static int cfg80211_get_regs_len(struct net_device *dev)
28{
29 /* For now, return 0... */
30 return 0;
31}
32
33static void cfg80211_get_regs(struct net_device *dev, struct ethtool_regs *regs,
34 void *data)
35{
36 struct wireless_dev *wdev = dev->ieee80211_ptr;
37
38 regs->version = wdev->wiphy->hw_version;
39 regs->len = 0;
40}
41
John W. Linville36777132011-03-07 16:17:59 -050042static void cfg80211_get_ringparam(struct net_device *dev,
43 struct ethtool_ringparam *rp)
44{
45 struct wireless_dev *wdev = dev->ieee80211_ptr;
46 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
47
48 memset(rp, 0, sizeof(*rp));
49
50 if (rdev->ops->get_ringparam)
Hila Gonene35e4d22012-06-27 17:19:42 +030051 rdev_get_ringparam(rdev, &rp->tx_pending, &rp->tx_max_pending,
52 &rp->rx_pending, &rp->rx_max_pending);
John W. Linville36777132011-03-07 16:17:59 -050053}
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)
Hila Gonene35e4d22012-06-27 17:19:42 +030065 return rdev_set_ringparam(rdev, rp->tx_pending, rp->rx_pending);
John W. Linville36777132011-03-07 16:17:59 -050066
67 return -ENOTSUPP;
68}
69
Ben Greeard6199212012-04-23 12:50:29 -070070static int cfg80211_get_sset_count(struct net_device *dev, int sset)
71{
72 struct wireless_dev *wdev = dev->ieee80211_ptr;
73 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
74 if (rdev->ops->get_et_sset_count)
Hila Gonene35e4d22012-06-27 17:19:42 +030075 return rdev_get_et_sset_count(rdev, dev, sset);
Ben Greeard6199212012-04-23 12:50:29 -070076 return -EOPNOTSUPP;
77}
78
79static void cfg80211_get_stats(struct net_device *dev,
80 struct ethtool_stats *stats, u64 *data)
81{
82 struct wireless_dev *wdev = dev->ieee80211_ptr;
83 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
84 if (rdev->ops->get_et_stats)
Hila Gonene35e4d22012-06-27 17:19:42 +030085 rdev_get_et_stats(rdev, dev, stats, data);
Ben Greeard6199212012-04-23 12:50:29 -070086}
87
88static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data)
89{
90 struct wireless_dev *wdev = dev->ieee80211_ptr;
91 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
92 if (rdev->ops->get_et_strings)
Hila Gonene35e4d22012-06-27 17:19:42 +030093 rdev_get_et_strings(rdev, dev, sset, data);
Ben Greeard6199212012-04-23 12:50:29 -070094}
95
John W. Linville4890e3b2009-09-30 14:50:17 -040096const struct ethtool_ops cfg80211_ethtool_ops = {
97 .get_drvinfo = cfg80211_get_drvinfo,
Kalle Valodfce95f2009-09-24 11:02:42 -070098 .get_regs_len = cfg80211_get_regs_len,
99 .get_regs = cfg80211_get_regs,
John W. Linville4890e3b2009-09-30 14:50:17 -0400100 .get_link = ethtool_op_get_link,
John W. Linville36777132011-03-07 16:17:59 -0500101 .get_ringparam = cfg80211_get_ringparam,
102 .set_ringparam = cfg80211_set_ringparam,
Ben Greeard6199212012-04-23 12:50:29 -0700103 .get_strings = cfg80211_get_strings,
104 .get_ethtool_stats = cfg80211_get_stats,
105 .get_sset_count = cfg80211_get_sset_count,
John W. Linville4890e3b2009-09-30 14:50:17 -0400106};