staging: brcm80211: Convert ETHER_IS<FOO> to is_<foo>_ether_addr
[deliverable/linux.git] / drivers / staging / brcm80211 / brcmfmac / wl_cfg80211.h
CommitLineData
cf2b4488
HP
1/*
2 * Copyright (c) 2010 Broadcom Corporation
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef _wl_cfg80211_h_
18#define _wl_cfg80211_h_
19
20#include <linux/wireless.h>
cf2b4488
HP
21#include <linux/wireless.h>
22#include <net/cfg80211.h>
a1c16ed2
GKH
23#include <proto/ethernet.h>
24#include <wlioctl.h>
cf2b4488
HP
25
26struct wl_conf;
27struct wl_iface;
28struct wl_priv;
29struct wl_security;
30struct wl_ibss;
31
32#if defined(IL_BIGENDIAN)
33#include <bcmendian.h>
34#define htod32(i) (bcmswap32(i))
35#define htod16(i) (bcmswap16(i))
36#define dtoh32(i) (bcmswap32(i))
37#define dtoh16(i) (bcmswap16(i))
38#define htodchanspec(i) htod16(i)
39#define dtohchanspec(i) dtoh16(i)
40#else
41#define htod32(i) i
42#define htod16(i) i
43#define dtoh32(i) i
44#define dtoh16(i) i
45#define htodchanspec(i) i
46#define dtohchanspec(i) i
47#endif
48
49#define WL_DBG_NONE 0
50#define WL_DBG_DBG (1 << 2)
51#define WL_DBG_INFO (1 << 1)
52#define WL_DBG_ERR (1 << 0)
53#define WL_DBG_MASK ((WL_DBG_DBG | WL_DBG_INFO | WL_DBG_ERR) << 1)
54
55#define WL_DBG_LEVEL 1 /* 0 invalidates all debug messages.
56 default is 1 */
57#define WL_ERR(args) \
58do { \
59 if (wl_dbg_level & WL_DBG_ERR) { \
60 if (net_ratelimit()) { \
61 printk(KERN_ERR "ERROR @%s : ", __func__); \
62 printk args; \
63 } \
64 } \
65} while (0)
66#define WL_INFO(args) \
67do { \
68 if (wl_dbg_level & WL_DBG_INFO) { \
69 if (net_ratelimit()) { \
70 printk(KERN_ERR "INFO @%s : ", __func__); \
71 printk args; \
72 } \
73 } \
74} while (0)
75#if (WL_DBG_LEVEL > 0)
76#define WL_DBG(args) \
77do { \
78 if (wl_dbg_level & WL_DBG_DBG) { \
79 printk(KERN_ERR "DEBUG @%s :", __func__); \
80 printk args; \
81 } \
82} while (0)
83#else /* !(WL_DBG_LEVEL > 0) */
84#define WL_DBG(args)
85#endif /* (WL_DBG_LEVEL > 0) */
86
87#define WL_SCAN_RETRY_MAX 3 /* used for ibss scan */
88#define WL_NUM_SCAN_MAX 1
89#define WL_NUM_PMKIDS_MAX MAXPMKID /* will be used
90 * for 2.6.33 kernel
91 * or later
92 */
93#define WL_SCAN_BUF_MAX (1024 * 8)
94#define WL_TLV_INFO_MAX 1024
95#define WL_BSS_INFO_MAX 2048
96#define WL_ASSOC_INFO_MAX 512 /*
97 * needs to grab assoc info from dongle to
98 * report it to cfg80211 through "connect"
99 * event
100 */
101#define WL_IOCTL_LEN_MAX 1024
102#define WL_EXTRA_BUF_MAX 2048
103#define WL_ISCAN_BUF_MAX 2048 /*
104 * the buf lengh can be WLC_IOCTL_MAXLEN (8K)
105 * to reduce iteration
106 */
107#define WL_ISCAN_TIMER_INTERVAL_MS 3000
108#define WL_SCAN_ERSULTS_LAST (WL_SCAN_RESULTS_NO_MEM+1)
109#define WL_AP_MAX 256 /* virtually unlimitted as long
110 * as kernel memory allows
111 */
112#define WL_FILE_NAME_MAX 256
113
114/* dongle status */
115enum wl_status {
116 WL_STATUS_READY,
117 WL_STATUS_SCANNING,
118 WL_STATUS_SCAN_ABORTING,
119 WL_STATUS_CONNECTING,
120 WL_STATUS_CONNECTED
121};
122
123/* wi-fi mode */
124enum wl_mode {
125 WL_MODE_BSS,
126 WL_MODE_IBSS,
127 WL_MODE_AP
128};
129
130/* dongle profile list */
131enum wl_prof_list {
132 WL_PROF_MODE,
133 WL_PROF_SSID,
134 WL_PROF_SEC,
135 WL_PROF_IBSS,
136 WL_PROF_BAND,
137 WL_PROF_BSSID,
1e0645c3 138 WL_PROF_ACT,
139 WL_PROF_BEACONINT,
140 WL_PROF_DTIMPERIOD
cf2b4488
HP
141};
142
143/* dongle iscan state */
144enum wl_iscan_state {
145 WL_ISCAN_STATE_IDLE,
146 WL_ISCAN_STATE_SCANING
147};
148
149/* fw downloading status */
150enum wl_fw_status {
151 WL_FW_LOADING_DONE,
152 WL_NVRAM_LOADING_DONE
153};
154
c5ca038f 155/* beacon / probe_response */
156struct beacon_proberesp {
157 __le64 timestamp;
158 __le16 beacon_int;
159 __le16 capab_info;
160 u8 variable[0];
161} __attribute__ ((packed));
162
cf2b4488
HP
163/* dongle configuration */
164struct wl_conf {
66cbd3ab
GKH
165 u32 mode; /* adhoc , infrastructure or ap */
166 u32 frag_threshold;
167 u32 rts_threshold;
168 u32 retry_short;
169 u32 retry_long;
3e26416e 170 s32 tx_power;
cf2b4488
HP
171 struct ieee80211_channel channel;
172};
173
174/* cfg80211 main event loop */
175struct wl_event_loop {
3e26416e 176 s32(*handler[WLC_E_LAST]) (struct wl_priv *wl,
cf2b4488
HP
177 struct net_device *ndev,
178 const wl_event_msg_t *e, void *data);
179};
180
181/* representing interface of cfg80211 plane */
182struct wl_iface {
183 struct wl_priv *wl;
184};
185
186struct wl_dev {
187 void *driver_data; /* to store cfg80211 object information */
188};
189
190/* bss inform structure for cfg80211 interface */
191struct wl_cfg80211_bss_info {
7d4df48e
GKH
192 u16 band;
193 u16 channel;
e59fe083 194 s16 rssi;
7d4df48e 195 u16 frame_len;
3fd79f7c 196 u8 frame_buf[1];
cf2b4488
HP
197};
198
199/* basic structure of scan request */
200struct wl_scan_req {
201 struct wlc_ssid ssid;
202};
203
204/* basic structure of information element */
205struct wl_ie {
7d4df48e 206 u16 offset;
3fd79f7c 207 u8 buf[WL_TLV_INFO_MAX];
cf2b4488
HP
208};
209
210/* event queue for cfg80211 main event */
211struct wl_event_q {
212 struct list_head eq_list;
66cbd3ab 213 u32 etype;
cf2b4488 214 wl_event_msg_t emsg;
562c8850 215 s8 edata[1];
cf2b4488
HP
216};
217
218/* security information with currently associated ap */
219struct wl_security {
66cbd3ab
GKH
220 u32 wpa_versions;
221 u32 auth_type;
222 u32 cipher_pairwise;
223 u32 cipher_group;
224 u32 wpa_auth;
cf2b4488
HP
225};
226
227/* ibss information for currently joined ibss network */
228struct wl_ibss {
3fd79f7c
GKH
229 u8 beacon_interval; /* in millisecond */
230 u8 atim; /* in millisecond */
562c8850 231 s8 join_only;
3fd79f7c
GKH
232 u8 band;
233 u8 channel;
cf2b4488
HP
234};
235
236/* dongle profile */
237struct wl_profile {
66cbd3ab 238 u32 mode;
cf2b4488 239 struct wlc_ssid ssid;
3fd79f7c 240 u8 bssid[ETHER_ADDR_LEN];
1e0645c3 241 u16 beacon_interval;
242 u8 dtim_period;
cf2b4488
HP
243 struct wl_security sec;
244 struct wl_ibss ibss;
3e26416e 245 s32 band;
cf2b4488
HP
246 bool active;
247};
248
249/* dongle iscan event loop */
250struct wl_iscan_eloop {
3e26416e 251 s32(*handler[WL_SCAN_ERSULTS_LAST]) (struct wl_priv *wl);
cf2b4488
HP
252};
253
254/* dongle iscan controller */
255struct wl_iscan_ctrl {
256 struct net_device *dev;
257 struct timer_list timer;
66cbd3ab
GKH
258 u32 timer_ms;
259 u32 timer_on;
3e26416e 260 s32 state;
7716314b 261 struct task_struct *tsk;
cf2b4488 262 struct semaphore sync;
cf2b4488
HP
263 struct wl_iscan_eloop el;
264 void *data;
562c8850
GKH
265 s8 ioctl_buf[WLC_IOCTL_SMLEN];
266 s8 scan_buf[WL_ISCAN_BUF_MAX];
cf2b4488
HP
267};
268
269/* association inform */
270struct wl_connect_info {
3fd79f7c 271 u8 *req_ie;
3e26416e 272 s32 req_ie_len;
3fd79f7c 273 u8 *resp_ie;
3e26416e 274 s32 resp_ie_len;
cf2b4488
HP
275};
276
277/* firmware /nvram downloading controller */
278struct wl_fw_ctrl {
279 const struct firmware *fw_entry;
3deea904 280 unsigned long status;
66cbd3ab 281 u32 ptr;
562c8850
GKH
282 s8 fw_name[WL_FILE_NAME_MAX];
283 s8 nvram_name[WL_FILE_NAME_MAX];
cf2b4488
HP
284};
285
286/* assoc ie length */
287struct wl_assoc_ielen {
66cbd3ab
GKH
288 u32 req_len;
289 u32 resp_len;
cf2b4488
HP
290};
291
292/* wpa2 pmk list */
293struct wl_pmk_list {
294 pmkid_list_t pmkids;
295 pmkid_t foo[MAXPMKID - 1];
296};
297
298/* dongle private data of cfg80211 interface */
299struct wl_priv {
300 struct wireless_dev *wdev; /* representing wl cfg80211 device */
301 struct wl_conf *conf; /* dongle configuration */
302 struct cfg80211_scan_request *scan_request; /* scan request
303 object */
304 struct wl_event_loop el; /* main event loop */
305 struct list_head eq_list; /* used for event queue */
306 spinlock_t eq_lock; /* for event queue synchronization */
307 struct mutex usr_sync; /* maily for dongle up/down synchronization */
308 struct wl_scan_results *bss_list; /* bss_list holding scanned
309 ap information */
310 struct wl_scan_results *scan_results;
311 struct wl_scan_req *scan_req_int; /* scan request object for
312 internal purpose */
313 struct wl_cfg80211_bss_info *bss_info; /* bss information for
314 cfg80211 layer */
315 struct wl_ie ie; /* information element object for
316 internal purpose */
317 struct ether_addr bssid; /* bssid of currently engaged network */
318 struct semaphore event_sync; /* for synchronization of main event
319 thread */
cf2b4488
HP
320 struct wl_profile *profile; /* holding dongle profile */
321 struct wl_iscan_ctrl *iscan; /* iscan controller */
322 struct wl_connect_info conn_info; /* association information
323 container */
324 struct wl_fw_ctrl *fw; /* control firwmare / nvram paramter
325 downloading */
326 struct wl_pmk_list *pmk_list; /* wpa2 pmk list */
7716314b 327 struct task_struct *event_tsk; /* task of main event handler thread */
3deea904 328 unsigned long status; /* current dongle status */
cf2b4488 329 void *pub;
66cbd3ab 330 u32 channel; /* current channel */
cf2b4488
HP
331 bool iscan_on; /* iscan on/off switch */
332 bool iscan_kickstart; /* indicate iscan already started */
333 bool active_scan; /* current scan mode */
334 bool ibss_starter; /* indicates this sta is ibss starter */
335 bool link_up; /* link/connection up flag */
336 bool pwr_save; /* indicate whether dongle to support
337 power save mode */
338 bool dongle_up; /* indicate whether dongle up or not */
339 bool roam_on; /* on/off switch for dongle self-roaming */
340 bool scan_tried; /* indicates if first scan attempted */
3fd79f7c
GKH
341 u8 *ioctl_buf; /* ioctl buffer */
342 u8 *extra_buf; /* maily to grab assoc information */
cd389a34 343 struct dentry *debugfsdir;
3fd79f7c 344 u8 ci[0] __attribute__ ((__aligned__(NETDEV_ALIGN)));
cf2b4488
HP
345};
346
347#define wl_to_dev(w) (wiphy_dev(wl->wdev->wiphy))
348#define wl_to_wiphy(w) (w->wdev->wiphy)
349#define wiphy_to_wl(w) ((struct wl_priv *)(wiphy_priv(w)))
350#define wl_to_wdev(w) (w->wdev)
351#define wdev_to_wl(w) ((struct wl_priv *)(wdev_priv(w)))
352#define wl_to_ndev(w) (w->wdev->netdev)
353#define ndev_to_wl(n) (wdev_to_wl(n->ieee80211_ptr))
354#define ci_to_wl(c) (ci->wl)
355#define wl_to_ci(w) (&w->ci)
356#define wl_to_sr(w) (w->scan_req_int)
357#define wl_to_ie(w) (&w->ie)
358#define iscan_to_wl(i) ((struct wl_priv *)(i->data))
359#define wl_to_iscan(w) (w->iscan)
360#define wl_to_conn(w) (&w->conn_info)
361
362static inline struct wl_bss_info *next_bss(struct wl_scan_results *list,
363 struct wl_bss_info *bss)
364{
365 return bss = bss ?
f024c48a 366 (struct wl_bss_info *)((unsigned long)bss +
cf2b4488
HP
367 dtoh32(bss->length)) : list->bss_info;
368}
369
370#define for_each_bss(list, bss, __i) \
371 for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, bss = next_bss(list, bss))
372
3e26416e 373extern s32 wl_cfg80211_attach(struct net_device *ndev, void *data);
cf2b4488
HP
374extern void wl_cfg80211_detach(void);
375/* event handler from dongle */
376extern void wl_cfg80211_event(struct net_device *ndev, const wl_event_msg_t *e,
377 void *data);
378extern void wl_cfg80211_sdio_func(void *func); /* set sdio function info */
93ad12cf 379extern struct sdio_func *wl_cfg80211_get_sdio_func(void); /* set sdio function info */
3e26416e
GKH
380extern s32 wl_cfg80211_up(void); /* dongle up */
381extern s32 wl_cfg80211_down(void); /* dongle down */
66cbd3ab 382extern void wl_cfg80211_dbg_level(u32 level); /* set dongle
cf2b4488 383 debugging level */
562c8850 384extern void *wl_cfg80211_request_fw(s8 *file_name); /* request fw /nvram
cf2b4488 385 downloading */
3e26416e 386extern s32 wl_cfg80211_read_fw(s8 *buf, u32 size); /* read fw
cf2b4488
HP
387 image */
388extern void wl_cfg80211_release_fw(void); /* release fw */
562c8850 389extern s8 *wl_cfg80211_get_fwname(void); /* get firmware name for
cf2b4488 390 the dongle */
562c8850 391extern s8 *wl_cfg80211_get_nvramname(void); /* get nvram name for
cf2b4488
HP
392 the dongle */
393
394#endif /* _wl_cfg80211_h_ */
This page took 0.120637 seconds and 5 git commands to generate.