xref: /openbmc/linux/net/ieee802154/core.h (revision a26c5fd7)
1a5dd1d72SAlexander Aring #ifndef __IEEE802154_CORE_H
2a5dd1d72SAlexander Aring #define __IEEE802154_CORE_H
3a5dd1d72SAlexander Aring 
4a5dd1d72SAlexander Aring #include <net/cfg802154.h>
5a5dd1d72SAlexander Aring 
6a5dd1d72SAlexander Aring struct cfg802154_registered_device {
7a5dd1d72SAlexander Aring 	const struct cfg802154_ops *ops;
8f3ada640SAlexander Aring 	struct list_head list;
9a5dd1d72SAlexander Aring 
1053f9ee61SAlexander Aring 	/* wpan_phy index, internal only */
1153f9ee61SAlexander Aring 	int wpan_phy_idx;
1253f9ee61SAlexander Aring 
13fcf39e6eSAlexander Aring 	/* also protected by devlist_mtx */
14fcf39e6eSAlexander Aring 	int opencount;
15fcf39e6eSAlexander Aring 	wait_queue_head_t dev_wait;
16fcf39e6eSAlexander Aring 
17fcf39e6eSAlexander Aring 	/* protected by RTNL only */
18fcf39e6eSAlexander Aring 	int num_running_ifaces;
19fcf39e6eSAlexander Aring 
20fcf39e6eSAlexander Aring 	/* associated wpan interfaces, protected by rtnl or RCU */
21fcf39e6eSAlexander Aring 	struct list_head wpan_dev_list;
22fcf39e6eSAlexander Aring 	int devlist_generation, wpan_dev_id;
23fcf39e6eSAlexander Aring 
24a5dd1d72SAlexander Aring 	/* must be last because of the way we do wpan_phy_priv(),
25a5dd1d72SAlexander Aring 	 * and it should at least be aligned to NETDEV_ALIGN
26a5dd1d72SAlexander Aring 	 */
27a5dd1d72SAlexander Aring 	struct wpan_phy wpan_phy __aligned(NETDEV_ALIGN);
28a5dd1d72SAlexander Aring };
29a5dd1d72SAlexander Aring 
30ea4dcd32SAlexander Aring static inline struct cfg802154_registered_device *
31ea4dcd32SAlexander Aring wpan_phy_to_rdev(struct wpan_phy *wpan_phy)
32ea4dcd32SAlexander Aring {
33ea4dcd32SAlexander Aring 	BUG_ON(!wpan_phy);
34ea4dcd32SAlexander Aring 	return container_of(wpan_phy, struct cfg802154_registered_device,
35ea4dcd32SAlexander Aring 			    wpan_phy);
36ea4dcd32SAlexander Aring }
37ea4dcd32SAlexander Aring 
3879fe1a2aSAlexander Aring extern struct list_head cfg802154_rdev_list;
39ca20ce20SAlexander Aring extern int cfg802154_rdev_list_generation;
4079fe1a2aSAlexander Aring 
41a5dd1d72SAlexander Aring /* free object */
42a5dd1d72SAlexander Aring void cfg802154_dev_free(struct cfg802154_registered_device *rdev);
4379fe1a2aSAlexander Aring struct cfg802154_registered_device *
4479fe1a2aSAlexander Aring cfg802154_rdev_by_wpan_phy_idx(int wpan_phy_idx);
45a26c5fd7SAlexander Aring struct wpan_phy *wpan_phy_idx_to_wpan_phy(int wpan_phy_idx);
46a5dd1d72SAlexander Aring 
47a5dd1d72SAlexander Aring #endif /* __IEEE802154_CORE_H */
48