core.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __IEEE802154_CORE_H
  3. #define __IEEE802154_CORE_H
  4. #include <net/cfg802154.h>
  5. struct cfg802154_registered_device {
  6. const struct cfg802154_ops *ops;
  7. struct list_head list;
  8. /* wpan_phy index, internal only */
  9. int wpan_phy_idx;
  10. /* also protected by devlist_mtx */
  11. int opencount;
  12. wait_queue_head_t dev_wait;
  13. /* protected by RTNL only */
  14. int num_running_ifaces;
  15. /* associated wpan interfaces, protected by rtnl or RCU */
  16. struct list_head wpan_dev_list;
  17. int devlist_generation, wpan_dev_id;
  18. /* must be last because of the way we do wpan_phy_priv(),
  19. * and it should at least be aligned to NETDEV_ALIGN
  20. */
  21. struct wpan_phy wpan_phy __aligned(NETDEV_ALIGN);
  22. };
  23. static inline struct cfg802154_registered_device *
  24. wpan_phy_to_rdev(struct wpan_phy *wpan_phy)
  25. {
  26. BUG_ON(!wpan_phy);
  27. return container_of(wpan_phy, struct cfg802154_registered_device,
  28. wpan_phy);
  29. }
  30. extern struct list_head cfg802154_rdev_list;
  31. extern int cfg802154_rdev_list_generation;
  32. int cfg802154_switch_netns(struct cfg802154_registered_device *rdev,
  33. struct net *net);
  34. /* free object */
  35. void cfg802154_dev_free(struct cfg802154_registered_device *rdev);
  36. struct cfg802154_registered_device *
  37. cfg802154_rdev_by_wpan_phy_idx(int wpan_phy_idx);
  38. struct wpan_phy *wpan_phy_idx_to_wpan_phy(int wpan_phy_idx);
  39. #endif /* __IEEE802154_CORE_H */