blob: f3e95580caee0e96ada8bee0bb2a2e72aa21eda3 [file] [log] [blame]
Alexander Aringa5dd1d72014-11-02 04:18:35 +01001#ifndef __IEEE802154_CORE_H
2#define __IEEE802154_CORE_H
3
4#include <net/cfg802154.h>
5
6struct cfg802154_registered_device {
7 const struct cfg802154_ops *ops;
Alexander Aringf3ada642014-11-09 08:36:48 +01008 struct list_head list;
Alexander Aringa5dd1d72014-11-02 04:18:35 +01009
Alexander Aring53f9ee612014-11-05 20:51:12 +010010 /* wpan_phy index, internal only */
11 int wpan_phy_idx;
12
Alexander Aringfcf39e62014-11-09 08:36:50 +010013 /* also protected by devlist_mtx */
14 int opencount;
15 wait_queue_head_t dev_wait;
16
17 /* protected by RTNL only */
18 int num_running_ifaces;
19
20 /* associated wpan interfaces, protected by rtnl or RCU */
21 struct list_head wpan_dev_list;
22 int devlist_generation, wpan_dev_id;
23
Alexander Aringa5dd1d72014-11-02 04:18:35 +010024 /* must be last because of the way we do wpan_phy_priv(),
25 * and it should at least be aligned to NETDEV_ALIGN
26 */
27 struct wpan_phy wpan_phy __aligned(NETDEV_ALIGN);
28};
29
Alexander Aringea4dcd32014-11-02 04:18:37 +010030static inline struct cfg802154_registered_device *
31wpan_phy_to_rdev(struct wpan_phy *wpan_phy)
32{
33 BUG_ON(!wpan_phy);
34 return container_of(wpan_phy, struct cfg802154_registered_device,
35 wpan_phy);
36}
37
Alexander Aring79fe1a22014-11-09 08:36:53 +010038extern struct list_head cfg802154_rdev_list;
Alexander Aringca20ce202014-11-09 08:36:54 +010039extern int cfg802154_rdev_list_generation;
Alexander Aring79fe1a22014-11-09 08:36:53 +010040
Alexander Aringa5dd1d72014-11-02 04:18:35 +010041/* free object */
42void cfg802154_dev_free(struct cfg802154_registered_device *rdev);
Alexander Aring79fe1a22014-11-09 08:36:53 +010043struct cfg802154_registered_device *
44cfg802154_rdev_by_wpan_phy_idx(int wpan_phy_idx);
Alexander Aringa5dd1d72014-11-02 04:18:35 +010045
46#endif /* __IEEE802154_CORE_H */