blob: 1c19f575d574d051784ac6070c6b9e651c57f4cd [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Alexander Aringa5dd1d72014-11-02 04:18:35 +01002#ifndef __IEEE802154_CORE_H
3#define __IEEE802154_CORE_H
4
5#include <net/cfg802154.h>
6
7struct cfg802154_registered_device {
8 const struct cfg802154_ops *ops;
Alexander Aringf3ada642014-11-09 08:36:48 +01009 struct list_head list;
Alexander Aringa5dd1d72014-11-02 04:18:35 +010010
Alexander Aring53f9ee612014-11-05 20:51:12 +010011 /* wpan_phy index, internal only */
12 int wpan_phy_idx;
13
Alexander Aringfcf39e62014-11-09 08:36:50 +010014 /* also protected by devlist_mtx */
15 int opencount;
16 wait_queue_head_t dev_wait;
17
18 /* protected by RTNL only */
19 int num_running_ifaces;
20
21 /* associated wpan interfaces, protected by rtnl or RCU */
22 struct list_head wpan_dev_list;
23 int devlist_generation, wpan_dev_id;
24
Alexander Aringa5dd1d72014-11-02 04:18:35 +010025 /* must be last because of the way we do wpan_phy_priv(),
26 * and it should at least be aligned to NETDEV_ALIGN
27 */
28 struct wpan_phy wpan_phy __aligned(NETDEV_ALIGN);
29};
30
Alexander Aringea4dcd32014-11-02 04:18:37 +010031static inline struct cfg802154_registered_device *
32wpan_phy_to_rdev(struct wpan_phy *wpan_phy)
33{
34 BUG_ON(!wpan_phy);
35 return container_of(wpan_phy, struct cfg802154_registered_device,
36 wpan_phy);
37}
38
Alexander Aring79fe1a22014-11-09 08:36:53 +010039extern struct list_head cfg802154_rdev_list;
Alexander Aringca20ce202014-11-09 08:36:54 +010040extern int cfg802154_rdev_list_generation;
Alexander Aring79fe1a22014-11-09 08:36:53 +010041
Alexander Aring66e5c262016-06-18 10:45:34 +020042int cfg802154_switch_netns(struct cfg802154_registered_device *rdev,
43 struct net *net);
Alexander Aringa5dd1d72014-11-02 04:18:35 +010044/* free object */
45void cfg802154_dev_free(struct cfg802154_registered_device *rdev);
Alexander Aring79fe1a22014-11-09 08:36:53 +010046struct cfg802154_registered_device *
47cfg802154_rdev_by_wpan_phy_idx(int wpan_phy_idx);
Alexander Aringa26c5fd2015-09-28 09:00:25 +020048struct wpan_phy *wpan_phy_idx_to_wpan_phy(int wpan_phy_idx);
Alexander Aringa5dd1d72014-11-02 04:18:35 +010049
50#endif /* __IEEE802154_CORE_H */