2
* Copyright (c) 2010 Broadcom Corporation
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.
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.
17
#ifndef _wl_cfg80211_h_
18
#define _wl_cfg80211_h_
20
#include <linux/wireless.h>
21
#include <linux/wireless.h>
22
#include <net/cfg80211.h>
32
#define WL_DBG_DBG (1 << 2)
33
#define WL_DBG_INFO (1 << 1)
34
#define WL_DBG_ERR (1 << 0)
35
#define WL_DBG_MASK ((WL_DBG_DBG | WL_DBG_INFO | WL_DBG_ERR) << 1)
37
#define WL_DBG_LEVEL 1 /* 0 invalidates all debug messages.
39
#define WL_ERR(fmt, args...) \
41
if (wl_dbg_level & WL_DBG_ERR) { \
42
if (net_ratelimit()) { \
43
printk(KERN_ERR "ERROR @%s : " fmt, \
49
#define WL_INFO(fmt, args...) \
51
if (wl_dbg_level & WL_DBG_INFO) { \
52
if (net_ratelimit()) { \
53
printk(KERN_ERR "INFO @%s : " fmt, \
59
#if (WL_DBG_LEVEL > 0)
60
#define WL_DBG(fmt, args...) \
62
if (wl_dbg_level & WL_DBG_DBG) { \
63
printk(KERN_ERR "DEBUG @%s :" fmt, \
67
#else /* !(WL_DBG_LEVEL > 0) */
68
#define WL_DBG(fmt, args...) noprintk(fmt, ##args)
69
#endif /* (WL_DBG_LEVEL > 0) */
71
#define WL_SCAN_RETRY_MAX 3 /* used for ibss scan */
72
#define WL_NUM_SCAN_MAX 1
73
#define WL_NUM_PMKIDS_MAX MAXPMKID /* will be used
77
#define WL_SCAN_BUF_MAX (1024 * 8)
78
#define WL_TLV_INFO_MAX 1024
79
#define WL_BSS_INFO_MAX 2048
80
#define WL_ASSOC_INFO_MAX 512 /*
81
* needs to grab assoc info from dongle to
82
* report it to cfg80211 through "connect"
85
#define WL_IOCTL_LEN_MAX 1024
86
#define WL_EXTRA_BUF_MAX 2048
87
#define WL_ISCAN_BUF_MAX 2048 /*
88
* the buf lengh can be WLC_IOCTL_MAXLEN (8K)
91
#define WL_ISCAN_TIMER_INTERVAL_MS 3000
92
#define WL_SCAN_ERSULTS_LAST (WL_SCAN_RESULTS_NO_MEM+1)
93
#define WL_AP_MAX 256 /* virtually unlimitted as long
94
* as kernel memory allows
96
#define WL_FILE_NAME_MAX 256
102
WL_STATUS_SCAN_ABORTING,
103
WL_STATUS_CONNECTING,
114
/* dongle profile list */
127
/* dongle iscan state */
128
enum wl_iscan_state {
130
WL_ISCAN_STATE_SCANING
133
/* fw downloading status */
136
WL_NVRAM_LOADING_DONE
139
/* beacon / probe_response */
140
struct beacon_proberesp {
145
} __attribute__ ((packed));
147
/* dongle configuration */
149
u32 mode; /* adhoc , infrastructure or ap */
155
struct ieee80211_channel channel;
158
/* cfg80211 main event loop */
159
struct wl_event_loop {
160
s32(*handler[WLC_E_LAST]) (struct wl_priv *wl,
161
struct net_device *ndev,
162
const wl_event_msg_t *e, void *data);
165
/* representing interface of cfg80211 plane */
171
void *driver_data; /* to store cfg80211 object information */
174
/* bss inform structure for cfg80211 interface */
175
struct wl_cfg80211_bss_info {
183
/* basic structure of scan request */
185
struct wlc_ssid ssid;
188
/* basic structure of information element */
191
u8 buf[WL_TLV_INFO_MAX];
194
/* event queue for cfg80211 main event */
196
struct list_head eq_list;
202
/* security information with currently associated ap */
211
/* ibss information for currently joined ibss network */
213
u8 beacon_interval; /* in millisecond */
214
u8 atim; /* in millisecond */
223
struct wlc_ssid ssid;
227
struct wl_security sec;
233
/* dongle iscan event loop */
234
struct wl_iscan_eloop {
235
s32(*handler[WL_SCAN_ERSULTS_LAST]) (struct wl_priv *wl);
238
/* dongle iscan controller */
239
struct wl_iscan_ctrl {
240
struct net_device *dev;
241
struct timer_list timer;
245
struct task_struct *tsk;
246
struct semaphore sync;
247
struct wl_iscan_eloop el;
249
s8 ioctl_buf[WLC_IOCTL_SMLEN];
250
s8 scan_buf[WL_ISCAN_BUF_MAX];
253
/* association inform */
254
struct wl_connect_info {
261
/* firmware /nvram downloading controller */
263
const struct firmware *fw_entry;
264
unsigned long status;
266
s8 fw_name[WL_FILE_NAME_MAX];
267
s8 nvram_name[WL_FILE_NAME_MAX];
270
/* assoc ie length */
271
struct wl_assoc_ielen {
279
pmkid_t foo[MAXPMKID - 1];
282
/* dongle private data of cfg80211 interface */
284
struct wireless_dev *wdev; /* representing wl cfg80211 device */
285
struct wl_conf *conf; /* dongle configuration */
286
struct cfg80211_scan_request *scan_request; /* scan request
288
struct wl_event_loop el; /* main event loop */
289
struct list_head eq_list; /* used for event queue */
290
spinlock_t eq_lock; /* for event queue synchronization */
291
struct mutex usr_sync; /* maily for dongle up/down synchronization */
292
struct wl_scan_results *bss_list; /* bss_list holding scanned
294
struct wl_scan_results *scan_results;
295
struct wl_scan_req *scan_req_int; /* scan request object for
297
struct wl_cfg80211_bss_info *bss_info; /* bss information for
299
struct wl_ie ie; /* information element object for
301
u8 bssid[ETH_ALEN]; /* bssid of currently engaged network */
302
struct semaphore event_sync; /* for synchronization of main event
304
struct wl_profile *profile; /* holding dongle profile */
305
struct wl_iscan_ctrl *iscan; /* iscan controller */
306
struct wl_connect_info conn_info; /* association information
308
struct wl_fw_ctrl *fw; /* control firwmare / nvram paramter
310
struct wl_pmk_list *pmk_list; /* wpa2 pmk list */
311
struct task_struct *event_tsk; /* task of main event handler thread */
312
unsigned long status; /* current dongle status */
314
u32 channel; /* current channel */
315
bool iscan_on; /* iscan on/off switch */
316
bool iscan_kickstart; /* indicate iscan already started */
317
bool active_scan; /* current scan mode */
318
bool ibss_starter; /* indicates this sta is ibss starter */
319
bool link_up; /* link/connection up flag */
320
bool pwr_save; /* indicate whether dongle to support
322
bool dongle_up; /* indicate whether dongle up or not */
323
bool roam_on; /* on/off switch for dongle self-roaming */
324
bool scan_tried; /* indicates if first scan attempted */
325
u8 *ioctl_buf; /* ioctl buffer */
326
u8 *extra_buf; /* maily to grab assoc information */
327
struct dentry *debugfsdir;
328
u8 ci[0] __attribute__ ((__aligned__(NETDEV_ALIGN)));
331
#define wl_to_dev(w) (wiphy_dev(wl->wdev->wiphy))
332
#define wl_to_wiphy(w) (w->wdev->wiphy)
333
#define wiphy_to_wl(w) ((struct wl_priv *)(wiphy_priv(w)))
334
#define wl_to_wdev(w) (w->wdev)
335
#define wdev_to_wl(w) ((struct wl_priv *)(wdev_priv(w)))
336
#define wl_to_ndev(w) (w->wdev->netdev)
337
#define ndev_to_wl(n) (wdev_to_wl(n->ieee80211_ptr))
338
#define ci_to_wl(c) (ci->wl)
339
#define wl_to_ci(w) (&w->ci)
340
#define wl_to_sr(w) (w->scan_req_int)
341
#define wl_to_ie(w) (&w->ie)
342
#define iscan_to_wl(i) ((struct wl_priv *)(i->data))
343
#define wl_to_iscan(w) (w->iscan)
344
#define wl_to_conn(w) (&w->conn_info)
346
static inline struct wl_bss_info *next_bss(struct wl_scan_results *list,
347
struct wl_bss_info *bss)
350
(struct wl_bss_info *)((unsigned long)bss +
351
le32_to_cpu(bss->length)) :
355
#define for_each_bss(list, bss, __i) \
356
for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, bss = next_bss(list, bss))
358
extern s32 wl_cfg80211_attach(struct net_device *ndev, void *data);
359
extern void wl_cfg80211_detach(void);
360
/* event handler from dongle */
361
extern void wl_cfg80211_event(struct net_device *ndev, const wl_event_msg_t *e,
363
extern void wl_cfg80211_sdio_func(void *func); /* set sdio function info */
364
extern struct sdio_func *wl_cfg80211_get_sdio_func(void); /* set sdio function info */
365
extern s32 wl_cfg80211_up(void); /* dongle up */
366
extern s32 wl_cfg80211_down(void); /* dongle down */
367
extern void wl_cfg80211_dbg_level(u32 level); /* set dongle
369
extern void *wl_cfg80211_request_fw(s8 *file_name); /* request fw /nvram
371
extern s32 wl_cfg80211_read_fw(s8 *buf, u32 size); /* read fw
373
extern void wl_cfg80211_release_fw(void); /* release fw */
374
extern s8 *wl_cfg80211_get_fwname(void); /* get firmware name for
376
extern s8 *wl_cfg80211_get_nvramname(void); /* get nvram name for
379
#endif /* _wl_cfg80211_h_ */