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_CONN (1 << 5)
33 #define WL_DBG_SCAN (1 << 4)
34 #define WL_DBG_TRACE (1 << 3)
35 #define WL_DBG_INFO (1 << 1)
36 #define WL_DBG_ERR (1 << 0)
37 #define WL_DBG_MASK ((WL_DBG_INFO | WL_DBG_ERR | WL_DBG_TRACE) | \
38 (WL_DBG_SCAN) | (WL_DBG_CONN))
40 #define WL_ERR(fmt, args...) \
42 if (wl_dbg_level & WL_DBG_ERR) { \
43 if (net_ratelimit()) { \
44 printk(KERN_ERR "ERROR @%s : " fmt, \
51 #define WL_INFO(fmt, args...) \
53 if (wl_dbg_level & WL_DBG_INFO) { \
54 if (net_ratelimit()) { \
55 printk(KERN_ERR "INFO @%s : " fmt, \
61 #define WL_TRACE(fmt, args...) \
63 if (wl_dbg_level & WL_DBG_TRACE) { \
64 if (net_ratelimit()) { \
65 printk(KERN_ERR "TRACE @%s : " fmt, \
71 #define WL_SCAN(fmt, args...) \
73 if (wl_dbg_level & WL_DBG_SCAN) { \
74 if (net_ratelimit()) { \
75 printk(KERN_ERR "SCAN @%s : " fmt, \
81 #define WL_CONN(fmt, args...) \
83 if (wl_dbg_level & WL_DBG_CONN) { \
84 if (net_ratelimit()) { \
85 printk(KERN_ERR "CONN @%s : " fmt, \
91 #else /* (defined BCMDBG) */
92 #define WL_INFO(fmt, args...)
93 #define WL_TRACE(fmt, args...)
94 #define WL_SCAN(fmt, args...)
95 #define WL_CONN(fmt, args...)
96 #endif /* (defined BCMDBG) */
99 #define WL_SCAN_RETRY_MAX 3 /* used for ibss scan */
100 #define WL_NUM_SCAN_MAX 1
101 #define WL_NUM_PMKIDS_MAX MAXPMKID /* will be used
105 #define WL_SCAN_BUF_MAX (1024 * 8)
106 #define WL_TLV_INFO_MAX 1024
107 #define WL_BSS_INFO_MAX 2048
108 #define WL_ASSOC_INFO_MAX 512 /*
109 * needs to grab assoc info from dongle to
110 * report it to cfg80211 through "connect"
113 #define WL_IOCTL_LEN_MAX 1024
114 #define WL_EXTRA_BUF_MAX 2048
115 #define WL_ISCAN_BUF_MAX 2048 /*
116 * the buf lengh can be WLC_IOCTL_MAXLEN (8K)
117 * to reduce iteration
119 #define WL_ISCAN_TIMER_INTERVAL_MS 3000
120 #define WL_SCAN_ERSULTS_LAST (WL_SCAN_RESULTS_NO_MEM+1)
121 #define WL_AP_MAX 256 /* virtually unlimitted as long
122 * as kernel memory allows
124 #define WL_FILE_NAME_MAX 256
126 #define WL_ROAM_TRIGGER_LEVEL -75
127 #define WL_ROAM_DELTA 20
128 #define WL_BEACON_TIMEOUT 3
130 #define WL_SCAN_CHANNEL_TIME 40
131 #define WL_SCAN_UNASSOC_TIME 40
132 #define WL_SCAN_PASSIVE_TIME 120
138 WL_STATUS_SCAN_ABORTING,
139 WL_STATUS_CONNECTING,
150 /* dongle profile list */
163 /* dongle iscan state */
164 enum wl_iscan_state {
166 WL_ISCAN_STATE_SCANING
169 /* fw downloading status */
172 WL_NVRAM_LOADING_DONE
175 /* beacon / probe_response */
176 struct beacon_proberesp {
181 } __attribute__ ((packed));
183 /* dongle configuration */
185 u32 mode; /* adhoc , infrastructure or ap */
191 struct ieee80211_channel channel;
194 /* cfg80211 main event loop */
195 struct wl_event_loop {
196 s32(*handler[WLC_E_LAST]) (struct wl_priv *wl,
197 struct net_device *ndev,
198 const wl_event_msg_t *e, void *data);
201 /* representing interface of cfg80211 plane */
207 void *driver_data; /* to store cfg80211 object information */
210 /* bss inform structure for cfg80211 interface */
211 struct wl_cfg80211_bss_info {
219 /* basic structure of scan request */
221 struct wlc_ssid ssid;
224 /* basic structure of information element */
227 u8 buf[WL_TLV_INFO_MAX];
230 /* event queue for cfg80211 main event */
232 struct list_head eq_list;
238 /* security information with currently associated ap */
247 /* ibss information for currently joined ibss network */
249 u8 beacon_interval; /* in millisecond */
250 u8 atim; /* in millisecond */
259 struct wlc_ssid ssid;
263 struct wl_security sec;
268 /* dongle iscan event loop */
269 struct wl_iscan_eloop {
270 s32(*handler[WL_SCAN_ERSULTS_LAST]) (struct wl_priv *wl);
273 /* dongle iscan controller */
274 struct wl_iscan_ctrl {
275 struct net_device *dev;
276 struct timer_list timer;
280 struct task_struct *tsk;
281 struct semaphore sync;
282 struct wl_iscan_eloop el;
284 s8 ioctl_buf[WLC_IOCTL_SMLEN];
285 s8 scan_buf[WL_ISCAN_BUF_MAX];
288 /* association inform */
289 struct wl_connect_info {
296 /* firmware /nvram downloading controller */
298 const struct firmware *fw_entry;
299 unsigned long status;
301 s8 fw_name[WL_FILE_NAME_MAX];
302 s8 nvram_name[WL_FILE_NAME_MAX];
305 /* assoc ie length */
306 struct wl_assoc_ielen {
314 pmkid_t foo[MAXPMKID - 1];
317 /* dongle private data of cfg80211 interface */
319 struct wireless_dev *wdev; /* representing wl cfg80211 device */
320 struct wl_conf *conf; /* dongle configuration */
321 struct cfg80211_scan_request *scan_request; /* scan request
323 struct wl_event_loop el; /* main event loop */
324 struct list_head eq_list; /* used for event queue */
325 spinlock_t eq_lock; /* for event queue synchronization */
326 struct mutex usr_sync; /* maily for dongle up/down synchronization */
327 struct wl_scan_results *bss_list; /* bss_list holding scanned
329 struct wl_scan_results *scan_results;
330 struct wl_scan_req *scan_req_int; /* scan request object for
332 struct wl_cfg80211_bss_info *bss_info; /* bss information for
334 struct wl_ie ie; /* information element object for
336 struct semaphore event_sync; /* for synchronization of main event
338 struct wl_profile *profile; /* holding dongle profile */
339 struct wl_iscan_ctrl *iscan; /* iscan controller */
340 struct wl_connect_info conn_info; /* association information
342 struct wl_fw_ctrl *fw; /* control firwmare / nvram paramter
344 struct wl_pmk_list *pmk_list; /* wpa2 pmk list */
345 struct task_struct *event_tsk; /* task of main event handler thread */
346 unsigned long status; /* current dongle status */
348 u32 channel; /* current channel */
349 bool iscan_on; /* iscan on/off switch */
350 bool iscan_kickstart; /* indicate iscan already started */
351 bool active_scan; /* current scan mode */
352 bool ibss_starter; /* indicates this sta is ibss starter */
353 bool link_up; /* link/connection up flag */
354 bool pwr_save; /* indicate whether dongle to support
356 bool dongle_up; /* indicate whether dongle up or not */
357 bool roam_on; /* on/off switch for dongle self-roaming */
358 bool scan_tried; /* indicates if first scan attempted */
359 u8 *ioctl_buf; /* ioctl buffer */
360 u8 *extra_buf; /* maily to grab assoc information */
361 struct dentry *debugfsdir;
362 u8 ci[0] __attribute__ ((__aligned__(NETDEV_ALIGN)));
365 #define wl_to_dev(w) (wiphy_dev(wl->wdev->wiphy))
366 #define wl_to_wiphy(w) (w->wdev->wiphy)
367 #define wiphy_to_wl(w) ((struct wl_priv *)(wiphy_priv(w)))
368 #define wl_to_wdev(w) (w->wdev)
369 #define wdev_to_wl(w) ((struct wl_priv *)(wdev_priv(w)))
370 #define wl_to_ndev(w) (w->wdev->netdev)
371 #define ndev_to_wl(n) (wdev_to_wl(n->ieee80211_ptr))
372 #define ci_to_wl(c) (ci->wl)
373 #define wl_to_ci(w) (&w->ci)
374 #define wl_to_sr(w) (w->scan_req_int)
375 #define wl_to_ie(w) (&w->ie)
376 #define iscan_to_wl(i) ((struct wl_priv *)(i->data))
377 #define wl_to_iscan(w) (w->iscan)
378 #define wl_to_conn(w) (&w->conn_info)
380 static inline struct wl_bss_info *next_bss(struct wl_scan_results *list,
381 struct wl_bss_info *bss)
384 (struct wl_bss_info *)((unsigned long)bss +
385 le32_to_cpu(bss->length)) :
389 #define for_each_bss(list, bss, __i) \
390 for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, bss = next_bss(list, bss))
392 extern s32 wl_cfg80211_attach(struct net_device *ndev, void *data);
393 extern void wl_cfg80211_detach(void);
394 /* event handler from dongle */
395 extern void wl_cfg80211_event(struct net_device *ndev, const wl_event_msg_t *e,
397 extern void wl_cfg80211_sdio_func(void *func); /* set sdio function info */
398 extern struct sdio_func *wl_cfg80211_get_sdio_func(void); /* set sdio function info */
399 extern s32 wl_cfg80211_up(void); /* dongle up */
400 extern s32 wl_cfg80211_down(void); /* dongle down */
401 extern void wl_cfg80211_dbg_level(u32 level); /* set dongle
403 extern void *wl_cfg80211_request_fw(s8 *file_name); /* request fw /nvram
405 extern s32 wl_cfg80211_read_fw(s8 *buf, u32 size); /* read fw
407 extern void wl_cfg80211_release_fw(void); /* release fw */
408 extern s8 *wl_cfg80211_get_fwname(void); /* get firmware name for
410 extern s8 *wl_cfg80211_get_nvramname(void); /* get nvram name for
412 extern void wl_os_wd_timer(struct net_device *ndev, uint wdtick);
414 #endif /* _wl_cfg80211_h_ */