wireless.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef __NET_WIRELESS_H
  2. #define __NET_WIRELESS_H
  3. /*
  4. * 802.11 device management
  5. *
  6. * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
  7. */
  8. #include <linux/netdevice.h>
  9. #include <linux/debugfs.h>
  10. #include <linux/list.h>
  11. #include <net/cfg80211.h>
  12. /**
  13. * struct wiphy - wireless hardware description
  14. * @idx: the wiphy index assigned to this item
  15. * @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name>
  16. */
  17. struct wiphy {
  18. /* assign these fields before you register the wiphy */
  19. /* permanent MAC address */
  20. u8 perm_addr[ETH_ALEN];
  21. /* If multiple wiphys are registered and you're handed e.g.
  22. * a regular netdev with assigned ieee80211_ptr, you won't
  23. * know whether it points to a wiphy your driver has registered
  24. * or not. Assign this to something global to your driver to
  25. * help determine whether you own this wiphy or not. */
  26. void *privid;
  27. /* fields below are read-only, assigned by cfg80211 */
  28. /* the item in /sys/class/ieee80211/ points to this,
  29. * you need use set_wiphy_dev() (see below) */
  30. struct device dev;
  31. /* dir in debugfs: ieee80211/<wiphyname> */
  32. struct dentry *debugfsdir;
  33. char priv[0] __attribute__((__aligned__(NETDEV_ALIGN)));
  34. };
  35. /** struct wireless_dev - wireless per-netdev state
  36. *
  37. * This structure must be allocated by the driver/stack
  38. * that uses the ieee80211_ptr field in struct net_device
  39. * (this is intentional so it can be allocated along with
  40. * the netdev.)
  41. *
  42. * @wiphy: pointer to hardware description
  43. */
  44. struct wireless_dev {
  45. struct wiphy *wiphy;
  46. /* private to the generic wireless code */
  47. struct list_head list;
  48. struct net_device *netdev;
  49. };
  50. /**
  51. * wiphy_priv - return priv from wiphy
  52. */
  53. static inline void *wiphy_priv(struct wiphy *wiphy)
  54. {
  55. BUG_ON(!wiphy);
  56. return &wiphy->priv;
  57. }
  58. /**
  59. * set_wiphy_dev - set device pointer for wiphy
  60. */
  61. static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
  62. {
  63. wiphy->dev.parent = dev;
  64. }
  65. /**
  66. * wiphy_dev - get wiphy dev pointer
  67. */
  68. static inline struct device *wiphy_dev(struct wiphy *wiphy)
  69. {
  70. return wiphy->dev.parent;
  71. }
  72. /**
  73. * wiphy_name - get wiphy name
  74. */
  75. static inline char *wiphy_name(struct wiphy *wiphy)
  76. {
  77. return wiphy->dev.bus_id;
  78. }
  79. /**
  80. * wdev_priv - return wiphy priv from wireless_dev
  81. */
  82. static inline void *wdev_priv(struct wireless_dev *wdev)
  83. {
  84. BUG_ON(!wdev);
  85. return wiphy_priv(wdev->wiphy);
  86. }
  87. /**
  88. * wiphy_new - create a new wiphy for use with cfg80211
  89. *
  90. * create a new wiphy and associate the given operations with it.
  91. * @sizeof_priv bytes are allocated for private use.
  92. *
  93. * the returned pointer must be assigned to each netdev's
  94. * ieee80211_ptr for proper operation.
  95. */
  96. struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv);
  97. /**
  98. * wiphy_register - register a wiphy with cfg80211
  99. *
  100. * register the given wiphy
  101. *
  102. * Returns a non-negative wiphy index or a negative error code.
  103. */
  104. extern int wiphy_register(struct wiphy *wiphy);
  105. /**
  106. * wiphy_unregister - deregister a wiphy from cfg80211
  107. *
  108. * unregister a device with the given priv pointer.
  109. * After this call, no more requests can be made with this priv
  110. * pointer, but the call may sleep to wait for an outstanding
  111. * request that is being handled.
  112. */
  113. extern void wiphy_unregister(struct wiphy *wiphy);
  114. /**
  115. * wiphy_free - free wiphy
  116. */
  117. extern void wiphy_free(struct wiphy *wiphy);
  118. #endif /* __NET_WIRELESS_H */