1 #ifndef __NET_WIRELESS_H
2 #define __NET_WIRELESS_H
5 * 802.11 device management
7 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
10 #include <linux/netdevice.h>
11 #include <linux/debugfs.h>
12 #include <linux/list.h>
13 #include <net/cfg80211.h>
16 * struct wiphy - wireless hardware description
17 * @idx: the wiphy index assigned to this item
18 * @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name>
21 /* assign these fields before you register the wiphy */
23 /* permanent MAC address */
24 u8 perm_addr
[ETH_ALEN
];
26 /* If multiple wiphys are registered and you're handed e.g.
27 * a regular netdev with assigned ieee80211_ptr, you won't
28 * know whether it points to a wiphy your driver has registered
29 * or not. Assign this to something global to your driver to
30 * help determine whether you own this wiphy or not. */
33 /* fields below are read-only, assigned by cfg80211 */
35 /* the item in /sys/class/ieee80211/ points to this,
36 * you need use set_wiphy_dev() (see below) */
39 /* dir in debugfs: ieee80211/<wiphyname> */
40 struct dentry
*debugfsdir
;
42 char priv
[0] __attribute__((__aligned__(NETDEV_ALIGN
)));
45 /** struct wireless_dev - wireless per-netdev state
47 * This structure must be allocated by the driver/stack
48 * that uses the ieee80211_ptr field in struct net_device
49 * (this is intentional so it can be allocated along with
52 * @wiphy: pointer to hardware description
57 /* private to the generic wireless code */
58 struct list_head list
;
59 struct net_device
*netdev
;
63 * wiphy_priv - return priv from wiphy
65 static inline void *wiphy_priv(struct wiphy
*wiphy
)
72 * set_wiphy_dev - set device pointer for wiphy
74 static inline void set_wiphy_dev(struct wiphy
*wiphy
, struct device
*dev
)
76 wiphy
->dev
.parent
= dev
;
80 * wiphy_dev - get wiphy dev pointer
82 static inline struct device
*wiphy_dev(struct wiphy
*wiphy
)
84 return wiphy
->dev
.parent
;
88 * wiphy_name - get wiphy name
90 static inline char *wiphy_name(struct wiphy
*wiphy
)
92 return wiphy
->dev
.bus_id
;
96 * wdev_priv - return wiphy priv from wireless_dev
98 static inline void *wdev_priv(struct wireless_dev
*wdev
)
101 return wiphy_priv(wdev
->wiphy
);
105 * wiphy_new - create a new wiphy for use with cfg80211
107 * create a new wiphy and associate the given operations with it.
108 * @sizeof_priv bytes are allocated for private use.
110 * the returned pointer must be assigned to each netdev's
111 * ieee80211_ptr for proper operation.
113 struct wiphy
*wiphy_new(struct cfg80211_ops
*ops
, int sizeof_priv
);
116 * wiphy_register - register a wiphy with cfg80211
118 * register the given wiphy
120 * Returns a non-negative wiphy index or a negative error code.
122 extern int wiphy_register(struct wiphy
*wiphy
);
125 * wiphy_unregister - deregister a wiphy from cfg80211
127 * unregister a device with the given priv pointer.
128 * After this call, no more requests can be made with this priv
129 * pointer, but the call may sleep to wait for an outstanding
130 * request that is being handled.
132 extern void wiphy_unregister(struct wiphy
*wiphy
);
135 * wiphy_free - free wiphy
137 extern void wiphy_free(struct wiphy
*wiphy
);
139 #endif /* __NET_WIRELESS_H */