ethtool.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #include <linux/utsname.h>
  2. #include <net/cfg80211.h>
  3. #include "core.h"
  4. #include "ethtool.h"
  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. strlcpy(info->driver, wiphy_dev(wdev->wiphy)->driver->name,
  10. sizeof(info->driver));
  11. strlcpy(info->version, init_utsname()->release, sizeof(info->version));
  12. if (wdev->wiphy->fw_version[0])
  13. strncpy(info->fw_version, wdev->wiphy->fw_version,
  14. sizeof(info->fw_version));
  15. else
  16. strncpy(info->fw_version, "N/A", sizeof(info->fw_version));
  17. strlcpy(info->bus_info, dev_name(wiphy_dev(wdev->wiphy)),
  18. sizeof(info->bus_info));
  19. }
  20. static int cfg80211_get_regs_len(struct net_device *dev)
  21. {
  22. /* For now, return 0... */
  23. return 0;
  24. }
  25. static void cfg80211_get_regs(struct net_device *dev, struct ethtool_regs *regs,
  26. void *data)
  27. {
  28. struct wireless_dev *wdev = dev->ieee80211_ptr;
  29. regs->version = wdev->wiphy->hw_version;
  30. regs->len = 0;
  31. }
  32. static void cfg80211_get_ringparam(struct net_device *dev,
  33. struct ethtool_ringparam *rp)
  34. {
  35. struct wireless_dev *wdev = dev->ieee80211_ptr;
  36. struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
  37. memset(rp, 0, sizeof(*rp));
  38. if (rdev->ops->get_ringparam)
  39. rdev->ops->get_ringparam(wdev->wiphy,
  40. &rp->tx_pending, &rp->tx_max_pending,
  41. &rp->rx_pending, &rp->rx_max_pending);
  42. }
  43. static int cfg80211_set_ringparam(struct net_device *dev,
  44. struct ethtool_ringparam *rp)
  45. {
  46. struct wireless_dev *wdev = dev->ieee80211_ptr;
  47. struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
  48. if (rp->rx_mini_pending != 0 || rp->rx_jumbo_pending != 0)
  49. return -EINVAL;
  50. if (rdev->ops->set_ringparam)
  51. return rdev->ops->set_ringparam(wdev->wiphy,
  52. rp->tx_pending, rp->rx_pending);
  53. return -ENOTSUPP;
  54. }
  55. static int cfg80211_get_sset_count(struct net_device *dev, int sset)
  56. {
  57. struct wireless_dev *wdev = dev->ieee80211_ptr;
  58. struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
  59. if (rdev->ops->get_et_sset_count)
  60. return rdev->ops->get_et_sset_count(wdev->wiphy, dev, sset);
  61. return -EOPNOTSUPP;
  62. }
  63. static void cfg80211_get_stats(struct net_device *dev,
  64. struct ethtool_stats *stats, u64 *data)
  65. {
  66. struct wireless_dev *wdev = dev->ieee80211_ptr;
  67. struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
  68. if (rdev->ops->get_et_stats)
  69. rdev->ops->get_et_stats(wdev->wiphy, dev, stats, data);
  70. }
  71. static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data)
  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_strings)
  76. rdev->ops->get_et_strings(wdev->wiphy, dev, sset, data);
  77. }
  78. const struct ethtool_ops cfg80211_ethtool_ops = {
  79. .get_drvinfo = cfg80211_get_drvinfo,
  80. .get_regs_len = cfg80211_get_regs_len,
  81. .get_regs = cfg80211_get_regs,
  82. .get_link = ethtool_op_get_link,
  83. .get_ringparam = cfg80211_get_ringparam,
  84. .set_ringparam = cfg80211_set_ringparam,
  85. .get_strings = cfg80211_get_strings,
  86. .get_ethtool_stats = cfg80211_get_stats,
  87. .get_sset_count = cfg80211_get_sset_count,
  88. };