ethtool.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. const struct ethtool_ops cfg80211_ethtool_ops = {
  56. .get_drvinfo = cfg80211_get_drvinfo,
  57. .get_regs_len = cfg80211_get_regs_len,
  58. .get_regs = cfg80211_get_regs,
  59. .get_link = ethtool_op_get_link,
  60. .get_ringparam = cfg80211_get_ringparam,
  61. .set_ringparam = cfg80211_set_ringparam,
  62. };