core.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Wireless configuration interface internals.
  3. *
  4. * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net>
  5. */
  6. #ifndef __NET_WIRELESS_CORE_H
  7. #define __NET_WIRELESS_CORE_H
  8. #include <linux/mutex.h>
  9. #include <linux/list.h>
  10. #include <linux/netdevice.h>
  11. #include <net/genetlink.h>
  12. #include <net/wireless.h>
  13. #include <net/cfg80211.h>
  14. struct cfg80211_registered_device {
  15. struct cfg80211_ops *ops;
  16. struct list_head list;
  17. /* we hold this mutex during any call so that
  18. * we cannot do multiple calls at once, and also
  19. * to avoid the deregister call to proceed while
  20. * any call is in progress */
  21. struct mutex mtx;
  22. /* wiphy index, internal only */
  23. int idx;
  24. /* associate netdev list */
  25. struct mutex devlist_mtx;
  26. struct list_head netdev_list;
  27. /* must be last because of the way we do wiphy_priv(),
  28. * and it should at least be aligned to NETDEV_ALIGN */
  29. struct wiphy wiphy __attribute__((__aligned__(NETDEV_ALIGN)));
  30. };
  31. static inline
  32. struct cfg80211_registered_device *wiphy_to_dev(struct wiphy *wiphy)
  33. {
  34. BUG_ON(!wiphy);
  35. return container_of(wiphy, struct cfg80211_registered_device, wiphy);
  36. }
  37. extern struct mutex cfg80211_drv_mutex;
  38. extern struct list_head cfg80211_drv_list;
  39. /*
  40. * This function returns a pointer to the driver
  41. * that the genl_info item that is passed refers to.
  42. * If successful, it returns non-NULL and also locks
  43. * the driver's mutex!
  44. *
  45. * This means that you need to call cfg80211_put_dev()
  46. * before being allowed to acquire &cfg80211_drv_mutex!
  47. *
  48. * This is necessary because we need to lock the global
  49. * mutex to get an item off the list safely, and then
  50. * we lock the drv mutex so it doesn't go away under us.
  51. *
  52. * We don't want to keep cfg80211_drv_mutex locked
  53. * for all the time in order to allow requests on
  54. * other interfaces to go through at the same time.
  55. *
  56. * The result of this can be a PTR_ERR and hence must
  57. * be checked with IS_ERR() for errors.
  58. */
  59. extern struct cfg80211_registered_device *
  60. cfg80211_get_dev_from_info(struct genl_info *info);
  61. /* identical to cfg80211_get_dev_from_info but only operate on ifindex */
  62. extern struct cfg80211_registered_device *
  63. cfg80211_get_dev_from_ifindex(int ifindex);
  64. extern void cfg80211_put_dev(struct cfg80211_registered_device *drv);
  65. /* free object */
  66. extern void cfg80211_dev_free(struct cfg80211_registered_device *drv);
  67. extern int cfg80211_dev_rename(struct cfg80211_registered_device *drv,
  68. char *newname);
  69. #endif /* __NET_WIRELESS_CORE_H */