1 #include <linux/utsname.h>
2 #include <net/cfg80211.h>
7 static void cfg80211_get_drvinfo(struct net_device *dev,
8 struct ethtool_drvinfo *info)
10 struct wireless_dev *wdev = dev->ieee80211_ptr;
12 strlcpy(info->driver, wiphy_dev(wdev->wiphy)->driver->name,
13 sizeof(info->driver));
15 strlcpy(info->version, init_utsname()->release, sizeof(info->version));
17 if (wdev->wiphy->fw_version[0])
18 strlcpy(info->fw_version, wdev->wiphy->fw_version,
19 sizeof(info->fw_version));
21 strlcpy(info->fw_version, "N/A", sizeof(info->fw_version));
23 strlcpy(info->bus_info, dev_name(wiphy_dev(wdev->wiphy)),
24 sizeof(info->bus_info));
27 static int cfg80211_get_regs_len(struct net_device *dev)
29 /* For now, return 0... */
33 static void cfg80211_get_regs(struct net_device *dev, struct ethtool_regs *regs,
36 struct wireless_dev *wdev = dev->ieee80211_ptr;
38 regs->version = wdev->wiphy->hw_version;
42 static void cfg80211_get_ringparam(struct net_device *dev,
43 struct ethtool_ringparam *rp)
45 struct wireless_dev *wdev = dev->ieee80211_ptr;
46 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
48 memset(rp, 0, sizeof(*rp));
50 if (rdev->ops->get_ringparam)
51 rdev_get_ringparam(rdev, &rp->tx_pending, &rp->tx_max_pending,
52 &rp->rx_pending, &rp->rx_max_pending);
55 static int cfg80211_set_ringparam(struct net_device *dev,
56 struct ethtool_ringparam *rp)
58 struct wireless_dev *wdev = dev->ieee80211_ptr;
59 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
61 if (rp->rx_mini_pending != 0 || rp->rx_jumbo_pending != 0)
64 if (rdev->ops->set_ringparam)
65 return rdev_set_ringparam(rdev, rp->tx_pending, rp->rx_pending);
70 static int cfg80211_get_sset_count(struct net_device *dev, int sset)
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)
75 return rdev_get_et_sset_count(rdev, dev, sset);
79 static void cfg80211_get_stats(struct net_device *dev,
80 struct ethtool_stats *stats, u64 *data)
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)
85 rdev_get_et_stats(rdev, dev, stats, data);
88 static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data)
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)
93 rdev_get_et_strings(rdev, dev, sset, data);
96 const struct ethtool_ops cfg80211_ethtool_ops = {
97 .get_drvinfo = cfg80211_get_drvinfo,
98 .get_regs_len = cfg80211_get_regs_len,
99 .get_regs = cfg80211_get_regs,
100 .get_link = ethtool_op_get_link,
101 .get_ringparam = cfg80211_get_ringparam,
102 .set_ringparam = cfg80211_set_ringparam,
103 .get_strings = cfg80211_get_strings,
104 .get_ethtool_stats = cfg80211_get_stats,
105 .get_sset_count = cfg80211_get_sset_count,