John W. Linville | 4890e3b | 2009-09-30 14:50:17 -0400 | [diff] [blame] | 1 | #include <linux/utsname.h> |
| 2 | #include <net/cfg80211.h> |
John W. Linville | 3677713 | 2011-03-07 16:17:59 -0500 | [diff] [blame] | 3 | #include "core.h" |
John W. Linville | 4890e3b | 2009-09-30 14:50:17 -0400 | [diff] [blame] | 4 | #include "ethtool.h" |
Hila Gonen | e35e4d2 | 2012-06-27 17:19:42 +0300 | [diff] [blame^] | 5 | #include "rdev-ops.h" |
John W. Linville | 4890e3b | 2009-09-30 14:50:17 -0400 | [diff] [blame] | 6 | |
| 7 | static 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 Valo | dfce95f | 2009-09-24 11:02:42 -0700 | [diff] [blame] | 17 | if (wdev->wiphy->fw_version[0]) |
| 18 | strncpy(info->fw_version, wdev->wiphy->fw_version, |
| 19 | sizeof(info->fw_version)); |
| 20 | else |
| 21 | strncpy(info->fw_version, "N/A", sizeof(info->fw_version)); |
John W. Linville | 4890e3b | 2009-09-30 14:50:17 -0400 | [diff] [blame] | 22 | |
| 23 | strlcpy(info->bus_info, dev_name(wiphy_dev(wdev->wiphy)), |
| 24 | sizeof(info->bus_info)); |
| 25 | } |
| 26 | |
Kalle Valo | dfce95f | 2009-09-24 11:02:42 -0700 | [diff] [blame] | 27 | static int cfg80211_get_regs_len(struct net_device *dev) |
| 28 | { |
| 29 | /* For now, return 0... */ |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | static 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. Linville | 3677713 | 2011-03-07 16:17:59 -0500 | [diff] [blame] | 42 | static 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 Gonen | e35e4d2 | 2012-06-27 17:19:42 +0300 | [diff] [blame^] | 51 | rdev_get_ringparam(rdev, &rp->tx_pending, &rp->tx_max_pending, |
| 52 | &rp->rx_pending, &rp->rx_max_pending); |
John W. Linville | 3677713 | 2011-03-07 16:17:59 -0500 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | static 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 Gonen | e35e4d2 | 2012-06-27 17:19:42 +0300 | [diff] [blame^] | 65 | return rdev_set_ringparam(rdev, rp->tx_pending, rp->rx_pending); |
John W. Linville | 3677713 | 2011-03-07 16:17:59 -0500 | [diff] [blame] | 66 | |
| 67 | return -ENOTSUPP; |
| 68 | } |
| 69 | |
Ben Greear | d619921 | 2012-04-23 12:50:29 -0700 | [diff] [blame] | 70 | static 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 Gonen | e35e4d2 | 2012-06-27 17:19:42 +0300 | [diff] [blame^] | 75 | return rdev_get_et_sset_count(rdev, dev, sset); |
Ben Greear | d619921 | 2012-04-23 12:50:29 -0700 | [diff] [blame] | 76 | return -EOPNOTSUPP; |
| 77 | } |
| 78 | |
| 79 | static 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 Gonen | e35e4d2 | 2012-06-27 17:19:42 +0300 | [diff] [blame^] | 85 | rdev_get_et_stats(rdev, dev, stats, data); |
Ben Greear | d619921 | 2012-04-23 12:50:29 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | static 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 Gonen | e35e4d2 | 2012-06-27 17:19:42 +0300 | [diff] [blame^] | 93 | rdev_get_et_strings(rdev, dev, sset, data); |
Ben Greear | d619921 | 2012-04-23 12:50:29 -0700 | [diff] [blame] | 94 | } |
| 95 | |
John W. Linville | 4890e3b | 2009-09-30 14:50:17 -0400 | [diff] [blame] | 96 | const struct ethtool_ops cfg80211_ethtool_ops = { |
| 97 | .get_drvinfo = cfg80211_get_drvinfo, |
Kalle Valo | dfce95f | 2009-09-24 11:02:42 -0700 | [diff] [blame] | 98 | .get_regs_len = cfg80211_get_regs_len, |
| 99 | .get_regs = cfg80211_get_regs, |
John W. Linville | 4890e3b | 2009-09-30 14:50:17 -0400 | [diff] [blame] | 100 | .get_link = ethtool_op_get_link, |
John W. Linville | 3677713 | 2011-03-07 16:17:59 -0500 | [diff] [blame] | 101 | .get_ringparam = cfg80211_get_ringparam, |
| 102 | .set_ringparam = cfg80211_set_ringparam, |
Ben Greear | d619921 | 2012-04-23 12:50:29 -0700 | [diff] [blame] | 103 | .get_strings = cfg80211_get_strings, |
| 104 | .get_ethtool_stats = cfg80211_get_stats, |
| 105 | .get_sset_count = cfg80211_get_sset_count, |
John W. Linville | 4890e3b | 2009-09-30 14:50:17 -0400 | [diff] [blame] | 106 | }; |