xref: /openbmc/linux/net/ieee802154/core.h (revision b2441318)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2a5dd1d72SAlexander Aring #ifndef __IEEE802154_CORE_H
3a5dd1d72SAlexander Aring #define __IEEE802154_CORE_H
4a5dd1d72SAlexander Aring 
5a5dd1d72SAlexander Aring #include <net/cfg802154.h>
6a5dd1d72SAlexander Aring 
7a5dd1d72SAlexander Aring struct cfg802154_registered_device {
8a5dd1d72SAlexander Aring 	const struct cfg802154_ops *ops;
9f3ada640SAlexander Aring 	struct list_head list;
10a5dd1d72SAlexander Aring 
1153f9ee61SAlexander Aring 	/* wpan_phy index, internal only */
1253f9ee61SAlexander Aring 	int wpan_phy_idx;
1353f9ee61SAlexander Aring 
14fcf39e6eSAlexander Aring 	/* also protected by devlist_mtx */
15fcf39e6eSAlexander Aring 	int opencount;
16fcf39e6eSAlexander Aring 	wait_queue_head_t dev_wait;
17fcf39e6eSAlexander Aring 
18fcf39e6eSAlexander Aring 	/* protected by RTNL only */
19fcf39e6eSAlexander Aring 	int num_running_ifaces;
20fcf39e6eSAlexander Aring 
21fcf39e6eSAlexander Aring 	/* associated wpan interfaces, protected by rtnl or RCU */
22fcf39e6eSAlexander Aring 	struct list_head wpan_dev_list;
23fcf39e6eSAlexander Aring 	int devlist_generation, wpan_dev_id;
24fcf39e6eSAlexander Aring 
25a5dd1d72SAlexander Aring 	/* must be last because of the way we do wpan_phy_priv(),
26a5dd1d72SAlexander Aring 	 * and it should at least be aligned to NETDEV_ALIGN
27a5dd1d72SAlexander Aring 	 */
28a5dd1d72SAlexander Aring 	struct wpan_phy wpan_phy __aligned(NETDEV_ALIGN);
29a5dd1d72SAlexander Aring };
30a5dd1d72SAlexander Aring 
31ea4dcd32SAlexander Aring static inline struct cfg802154_registered_device *
wpan_phy_to_rdev(struct wpan_phy * wpan_phy)32ea4dcd32SAlexander Aring wpan_phy_to_rdev(struct wpan_phy *wpan_phy)
33ea4dcd32SAlexander Aring {
34ea4dcd32SAlexander Aring 	BUG_ON(!wpan_phy);
35ea4dcd32SAlexander Aring 	return container_of(wpan_phy, struct cfg802154_registered_device,
36ea4dcd32SAlexander Aring 			    wpan_phy);
37ea4dcd32SAlexander Aring }
38ea4dcd32SAlexander Aring 
3979fe1a2aSAlexander Aring extern struct list_head cfg802154_rdev_list;
40ca20ce20SAlexander Aring extern int cfg802154_rdev_list_generation;
4179fe1a2aSAlexander Aring 
4266e5c267SAlexander Aring int cfg802154_switch_netns(struct cfg802154_registered_device *rdev,
4366e5c267SAlexander Aring 			   struct net *net);
44a5dd1d72SAlexander Aring /* free object */
45a5dd1d72SAlexander Aring void cfg802154_dev_free(struct cfg802154_registered_device *rdev);
4679fe1a2aSAlexander Aring struct cfg802154_registered_device *
4779fe1a2aSAlexander Aring cfg802154_rdev_by_wpan_phy_idx(int wpan_phy_idx);
48a26c5fd7SAlexander Aring struct wpan_phy *wpan_phy_idx_to_wpan_phy(int wpan_phy_idx);
49a5dd1d72SAlexander Aring 
50a5dd1d72SAlexander Aring #endif /* __IEEE802154_CORE_H */
51