aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/bcmdhd/wl_cfg80211.h
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-22 10:38:37 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-22 10:38:37 -0500
commitfcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch)
treea57612d1888735a2ec7972891b68c1ac5ec8faea /drivers/net/wireless/bcmdhd/wl_cfg80211.h
parent8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff)
Added missing tegra files.HEADmaster
Diffstat (limited to 'drivers/net/wireless/bcmdhd/wl_cfg80211.h')
-rw-r--r--drivers/net/wireless/bcmdhd/wl_cfg80211.h558
1 files changed, 558 insertions, 0 deletions
diff --git a/drivers/net/wireless/bcmdhd/wl_cfg80211.h b/drivers/net/wireless/bcmdhd/wl_cfg80211.h
new file mode 100644
index 00000000000..262335ef99c
--- /dev/null
+++ b/drivers/net/wireless/bcmdhd/wl_cfg80211.h
@@ -0,0 +1,558 @@
1/*
2 * Linux cfg80211 driver
3 *
4 * Copyright (C) 1999-2011, Broadcom Corporation
5 *
6 * Unless you and Broadcom execute a separate written software license
7 * agreement governing use of this software, this software is licensed to you
8 * under the terms of the GNU General Public License version 2 (the "GPL"),
9 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10 * following added to such license:
11 *
12 * As a special exception, the copyright holders of this software give you
13 * permission to link this software with independent modules, and to copy and
14 * distribute the resulting executable under terms of your choice, provided that
15 * you also meet, for each linked independent module, the terms and conditions of
16 * the license of that module. An independent module is a module which is not
17 * derived from this software. The special exception does not apply to any
18 * modifications of the software.
19 *
20 * Notwithstanding the above, under no circumstances may you combine this
21 * software in any way with any other Broadcom software provided under a license
22 * other than the GPL, without Broadcom's express prior written consent.
23 *
24 * $Id: wl_cfg80211.h,v 1.1.4.1.2.8 2011/02/09 01:37:52 Exp $
25 */
26
27#ifndef _wl_cfg80211_h_
28#define _wl_cfg80211_h_
29
30#include <linux/wireless.h>
31#include <typedefs.h>
32#include <proto/ethernet.h>
33#include <wlioctl.h>
34#include <linux/wireless.h>
35#include <net/cfg80211.h>
36#include <linux/rfkill.h>
37
38#include <wl_cfgp2p.h>
39
40struct wl_conf;
41struct wl_iface;
42struct wl_priv;
43struct wl_security;
44struct wl_ibss;
45
46
47#define htod32(i) i
48#define htod16(i) i
49#define dtoh32(i) i
50#define dtoh16(i) i
51#define htodchanspec(i) i
52#define dtohchanspec(i) i
53
54#define WL_DBG_NONE 0
55#define WL_DBG_TRACE (1 << 4)
56#define WL_DBG_SCAN (1 << 3)
57#define WL_DBG_DBG (1 << 2)
58#define WL_DBG_INFO (1 << 1)
59#define WL_DBG_ERR (1 << 0)
60
61/* 0 invalidates all debug messages. default is 1 */
62#define WL_DBG_LEVEL 0xFF
63
64#define WL_ERR(args) \
65do { \
66 if (wl_dbg_level & WL_DBG_ERR) { \
67 printk(KERN_ERR "CFG80211-ERROR) %s : ", __func__); \
68 printk args; \
69 } \
70} while (0)
71#define WL_INFO(args) \
72do { \
73 if (wl_dbg_level & WL_DBG_INFO) { \
74 printk(KERN_ERR "CFG80211-INFO) %s : ", __func__); \
75 printk args; \
76 } \
77} while (0)
78#define WL_SCAN(args) \
79do { \
80 if (wl_dbg_level & WL_DBG_SCAN) { \
81 printk(KERN_ERR "CFG80211-SCAN) %s :", __func__); \
82 printk args; \
83 } \
84} while (0)
85#define WL_TRACE(args) \
86do { \
87 if (wl_dbg_level & WL_DBG_TRACE) { \
88 printk(KERN_ERR "CFG80211-TRACE) %s :", __func__); \
89 printk args; \
90 } \
91} while (0)
92#if (WL_DBG_LEVEL > 0)
93#define WL_DBG(args) \
94do { \
95 if (wl_dbg_level & WL_DBG_DBG) { \
96 printk(KERN_ERR "CFG80211-DEBUG) %s :", __func__); \
97 printk args; \
98 } \
99} while (0)
100#else /* !(WL_DBG_LEVEL > 0) */
101#define WL_DBG(args)
102#endif /* (WL_DBG_LEVEL > 0) */
103
104
105#define WL_SCAN_RETRY_MAX 3 /* used for ibss scan */
106#define WL_NUM_PMKIDS_MAX MAXPMKID /* will be used
107 * for 2.6.33 kernel
108 * or later
109 */
110#define WL_SCAN_BUF_MAX (1024 * 8)
111#define WL_TLV_INFO_MAX 1024
112#define WL_SCAN_IE_LEN_MAX 2048
113#define WL_BSS_INFO_MAX 2048
114#define WL_ASSOC_INFO_MAX 512 /*
115 * needs to grab assoc info from dongle to
116 * report it to cfg80211 through "connect"
117 * event
118 */
119#define WL_IOCTL_LEN_MAX 1024
120#define WL_EXTRA_BUF_MAX 2048
121#define WL_ISCAN_BUF_MAX 2048 /*
122 * the buf lengh can be WLC_IOCTL_MAXLEN (8K)
123 * to reduce iteration
124 */
125#define WL_ISCAN_TIMER_INTERVAL_MS 3000
126#define WL_SCAN_ERSULTS_LAST (WL_SCAN_RESULTS_NO_MEM+1)
127#define WL_AP_MAX 256 /* virtually unlimitted as long
128 * as kernel memory allows
129 */
130#define WL_FILE_NAME_MAX 256
131#define WL_DWELL_TIME 200
132#define WL_LONG_DWELL_TIME 1000
133#define VWDEV_CNT 3
134
135#define WL_SCAN_TIMER_INTERVAL_MS 8000 /* Scan timeout */
136
137/* dongle status */
138enum wl_status {
139 WL_STATUS_READY = 0,
140 WL_STATUS_SCANNING,
141 WL_STATUS_SCAN_ABORTING,
142 WL_STATUS_CONNECTING,
143 WL_STATUS_CONNECTED,
144 WL_STATUS_DISCONNECTING,
145 WL_STATUS_AP_CREATING,
146 WL_STATUS_AP_CREATED
147};
148
149/* wi-fi mode */
150enum wl_mode {
151 WL_MODE_BSS,
152 WL_MODE_IBSS,
153 WL_MODE_AP
154};
155
156/* dongle profile list */
157enum wl_prof_list {
158 WL_PROF_MODE,
159 WL_PROF_SSID,
160 WL_PROF_SEC,
161 WL_PROF_IBSS,
162 WL_PROF_BAND,
163 WL_PROF_BSSID,
164 WL_PROF_ACT,
165 WL_PROF_BEACONINT,
166 WL_PROF_DTIMPERIOD
167};
168
169/* dongle iscan state */
170enum wl_iscan_state {
171 WL_ISCAN_STATE_IDLE,
172 WL_ISCAN_STATE_SCANING
173};
174
175/* donlge escan state */
176enum wl_escan_state {
177 WL_ESCAN_STATE_IDLE,
178 WL_ESCAN_STATE_SCANING
179};
180/* fw downloading status */
181enum wl_fw_status {
182 WL_FW_LOADING_DONE,
183 WL_NVRAM_LOADING_DONE
184};
185
186enum wl_management_type {
187 WL_BEACON = 0x1,
188 WL_PROBE_RESP = 0x2,
189 WL_ASSOC_RESP = 0x4
190};
191/* beacon / probe_response */
192struct beacon_proberesp {
193 __le64 timestamp;
194 __le16 beacon_int;
195 __le16 capab_info;
196 u8 variable[0];
197} __attribute__ ((packed));
198
199/* dongle configuration */
200struct wl_conf {
201 struct net_mode {
202 struct net_device *ndev;
203 s32 type;
204 } mode [VWDEV_CNT + 1]; /* adhoc , infrastructure or ap */
205 u32 frag_threshold;
206 u32 rts_threshold;
207 u32 retry_short;
208 u32 retry_long;
209 s32 tx_power;
210 struct ieee80211_channel channel;
211};
212
213typedef s32(*EVENT_HANDLER) (struct wl_priv *wl,
214 struct net_device *ndev, const wl_event_msg_t *e, void *data);
215
216/* bss inform structure for cfg80211 interface */
217struct wl_cfg80211_bss_info {
218 u16 band;
219 u16 channel;
220 s16 rssi;
221 u16 frame_len;
222 u8 frame_buf[1];
223};
224
225/* basic structure of scan request */
226struct wl_scan_req {
227 struct wlc_ssid ssid;
228};
229
230/* basic structure of information element */
231struct wl_ie {
232 u16 offset;
233 u8 buf[WL_TLV_INFO_MAX];
234};
235
236/* event queue for cfg80211 main event */
237struct wl_event_q {
238 struct list_head eq_list;
239 u32 etype;
240 wl_event_msg_t emsg;
241 s8 edata[1];
242};
243
244/* security information with currently associated ap */
245struct wl_security {
246 u32 wpa_versions;
247 u32 auth_type;
248 u32 cipher_pairwise;
249 u32 cipher_group;
250 u32 wpa_auth;
251};
252
253/* ibss information for currently joined ibss network */
254struct wl_ibss {
255 u8 beacon_interval; /* in millisecond */
256 u8 atim; /* in millisecond */
257 s8 join_only;
258 u8 band;
259 u8 channel;
260};
261
262/* dongle profile */
263struct wl_profile {
264 u32 mode;
265 struct wlc_ssid ssid;
266 u8 bssid[ETHER_ADDR_LEN];
267 u16 beacon_interval;
268 u8 dtim_period;
269 struct wl_security sec;
270 struct wl_ibss ibss;
271 s32 band;
272 bool active;
273};
274
275typedef s32(*ISCAN_HANDLER) (struct wl_priv *wl);
276
277/* dongle iscan controller */
278struct wl_iscan_ctrl {
279 struct net_device *dev;
280 struct timer_list timer;
281 u32 timer_ms;
282 u32 timer_on;
283 s32 state;
284 struct task_struct *tsk;
285 struct semaphore sync;
286 ISCAN_HANDLER iscan_handler[WL_SCAN_ERSULTS_LAST];
287 void *data;
288 s8 ioctl_buf[WLC_IOCTL_SMLEN];
289 s8 scan_buf[WL_ISCAN_BUF_MAX];
290};
291
292/* association inform */
293#define MAX_REQ_LINE 1024
294struct wl_connect_info {
295 u8 req_ie[MAX_REQ_LINE];
296 s32 req_ie_len;
297 u8 resp_ie[MAX_REQ_LINE];
298 s32 resp_ie_len;
299};
300
301/* firmware /nvram downloading controller */
302struct wl_fw_ctrl {
303 const struct firmware *fw_entry;
304 unsigned long status;
305 u32 ptr;
306 s8 fw_name[WL_FILE_NAME_MAX];
307 s8 nvram_name[WL_FILE_NAME_MAX];
308};
309
310/* assoc ie length */
311struct wl_assoc_ielen {
312 u32 req_len;
313 u32 resp_len;
314};
315
316/* wpa2 pmk list */
317struct wl_pmk_list {
318 pmkid_list_t pmkids;
319 pmkid_t foo[MAXPMKID - 1];
320};
321
322
323#define ESCAN_BUF_SIZE (64 * 1024)
324
325struct escan_info {
326 u32 escan_state;
327 u8 escan_buf[ESCAN_BUF_SIZE];
328 struct wiphy *wiphy;
329};
330
331struct ap_info {
332/* Structure to hold WPS, WPA IEs for a AP */
333 u8 probe_res_ie[IE_MAX_LEN];
334 u8 beacon_ie[IE_MAX_LEN];
335 u32 probe_res_ie_len;
336 u32 beacon_ie_len;
337 u8 *wpa_ie;
338 u8 *rsn_ie;
339 u8 *wps_ie;
340 bool security_mode;
341};
342struct btcoex_info {
343 struct timer_list timer;
344 uint32 timer_ms;
345 uint32 timer_on;
346 uint32 ts_dhcp_start; /* ms ts ecord time stats */
347 uint32 ts_dhcp_ok; /* ms ts ecord time stats */
348 bool dhcp_done; /* flag, indicates that host done with
349 * dhcp before t1/t2 expiration
350 */
351 int bt_state;
352 struct work_struct work;
353 struct net_device *dev;
354};
355
356struct sta_info {
357 /* Structure to hold WPS IE for a STA */
358 u8 probe_req_ie[IE_MAX_LEN];
359 u8 assoc_req_ie[IE_MAX_LEN];
360 u32 probe_req_ie_len;
361 u32 assoc_req_ie_len;
362};
363/* dongle private data of cfg80211 interface */
364struct wl_priv {
365 struct wireless_dev *wdev; /* representing wl cfg80211 device */
366 struct wireless_dev *vwdev[VWDEV_CNT];
367 struct wl_conf *conf; /* dongle configuration */
368 struct cfg80211_scan_request *scan_request; /* scan request object */
369 EVENT_HANDLER evt_handler[WLC_E_LAST];
370 struct list_head eq_list; /* used for event queue */
371 spinlock_t eq_lock; /* for event queue synchronization */
372 struct mutex usr_sync; /* maily for dongle up/down synchronization */
373 struct wl_scan_results *bss_list;
374 struct wl_scan_results *scan_results;
375
376 /* scan request object for internal purpose */
377 struct wl_scan_req *scan_req_int;
378
379 /* bss information for cfg80211 layer */
380 struct wl_cfg80211_bss_info *bss_info;
381 /* information element object for internal purpose */
382 struct wl_ie ie;
383
384 /* for synchronization of main event thread */
385 struct wl_profile *profile; /* holding dongle profile */
386 struct wl_iscan_ctrl *iscan; /* iscan controller */
387
388 /* association information container */
389 struct wl_connect_info conn_info;
390
391 /* control firwmare and nvram paramter downloading */
392 struct wl_fw_ctrl *fw;
393 struct wl_pmk_list *pmk_list; /* wpa2 pmk list */
394 tsk_ctl_t event_tsk; /* task of main event handler thread */
395 unsigned long status; /* current dongle status */
396 void *pub;
397 u32 channel; /* current channel */
398 bool iscan_on; /* iscan on/off switch */
399 bool iscan_kickstart; /* indicate iscan already started */
400 bool escan_on; /* escan on/off switch */
401 struct escan_info escan_info; /* escan information */
402 bool active_scan; /* current scan mode */
403 bool ibss_starter; /* indicates this sta is ibss starter */
404 bool link_up; /* link/connection up flag */
405
406 /* indicate whether dongle to support power save mode */
407 bool pwr_save;
408 bool dongle_up; /* indicate whether dongle up or not */
409 bool roam_on; /* on/off switch for dongle self-roaming */
410 bool scan_tried; /* indicates if first scan attempted */
411 u8 *ioctl_buf; /* ioctl buffer */
412 u8 *escan_ioctl_buf;
413 u8 *extra_buf; /* maily to grab assoc information */
414 struct dentry *debugfsdir;
415 struct rfkill *rfkill;
416 bool rf_blocked;
417 struct ieee80211_channel remain_on_chan;
418 enum nl80211_channel_type remain_on_chan_type;
419 u64 cache_cookie;
420 wait_queue_head_t dongle_event_wait;
421 struct ap_info *ap_info;
422 struct sta_info *sta_info;
423 struct p2p_info *p2p;
424 bool p2p_supported;
425 struct btcoex_info *btcoex_info;
426 struct timer_list scan_timeout; /* Timer for catch scan event timeout */
427};
428
429#define wl_to_wiphy(w) (w->wdev->wiphy)
430#define wl_to_prmry_ndev(w) (w->wdev->netdev)
431#define ndev_to_wl(n) (wdev_to_wl(n->ieee80211_ptr))
432#define wl_to_sr(w) (w->scan_req_int)
433#define wl_to_ie(w) (&w->ie)
434#define iscan_to_wl(i) ((struct wl_priv *)(i->data))
435#define wl_to_iscan(w) (w->iscan)
436#define wl_to_conn(w) (&w->conn_info)
437#define wiphy_from_scan(w) (w->escan_info.wiphy)
438#define wl_get_drv_status(wl, stat) (test_bit(WL_STATUS_ ## stat, &(wl)->status))
439#define wl_set_drv_status(wl, stat) (set_bit(WL_STATUS_ ## stat, &(wl)->status))
440#define wl_clr_drv_status(wl, stat) (clear_bit(WL_STATUS_ ## stat, &(wl)->status))
441#define wl_chg_drv_status(wl, stat) (change_bit(WL_STATUS_ ## stat, &(wl)->status))
442
443static inline struct wl_bss_info *next_bss(struct wl_scan_results *list, struct wl_bss_info *bss)
444{
445 return bss = bss ?
446 (struct wl_bss_info *)((uintptr) bss + dtoh32(bss->length)) : list->bss_info;
447}
448static inline s32 alloc_idx_vwdev(struct wl_priv *wl)
449{
450 s32 i = 0;
451 for (i = 0; i < VWDEV_CNT; i++) {
452 if (wl->vwdev[i] == NULL)
453 return i;
454 }
455 return -1;
456}
457
458static inline s32 get_idx_vwdev_by_netdev(struct wl_priv *wl, struct net_device *ndev)
459{
460 s32 i = 0;
461 for (i = 0; i < VWDEV_CNT; i++) {
462 if ((wl->vwdev[i] != NULL) && (wl->vwdev[i]->netdev == ndev))
463 return i;
464 }
465 return -1;
466}
467
468static inline s32 get_mode_by_netdev(struct wl_priv *wl, struct net_device *ndev)
469{
470 s32 i = 0;
471 for (i = 0; i <= VWDEV_CNT; i++) {
472 if (wl->conf->mode[i].ndev != NULL && (wl->conf->mode[i].ndev == ndev))
473 return wl->conf->mode[i].type;
474 }
475 return -1;
476}
477static inline void set_mode_by_netdev(struct wl_priv *wl, struct net_device *ndev, s32 type)
478{
479 s32 i = 0;
480 for (i = 0; i <= VWDEV_CNT; i++) {
481 if (type == -1) {
482 /* free the info of netdev */
483 if (wl->conf->mode[i].ndev == ndev) {
484 wl->conf->mode[i].ndev = NULL;
485 wl->conf->mode[i].type = -1;
486 break;
487 }
488
489 } else {
490 if ((wl->conf->mode[i].ndev != NULL)&&
491 (wl->conf->mode[i].ndev == ndev)) {
492 /* update type of ndev */
493 wl->conf->mode[i].type = type;
494 break;
495 }
496 else if ((wl->conf->mode[i].ndev == NULL)&&
497 (wl->conf->mode[i].type == -1)) {
498 wl->conf->mode[i].ndev = ndev;
499 wl->conf->mode[i].type = type;
500 break;
501 }
502 }
503 }
504}
505#define free_vwdev_by_index(wl, __i) do { \
506 if (wl->vwdev[__i] != NULL) \
507 kfree(wl->vwdev[__i]); \
508 wl->vwdev[__i] = NULL; \
509 } while (0)
510
511#define for_each_bss(list, bss, __i) \
512 for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, bss = next_bss(list, bss))
513
514/* In case of WPS from wpa_supplicant, pairwise siute and group suite is 0.
515 * In addtion to that, wpa_version is WPA_VERSION_1
516 */
517#define is_wps_conn(_sme) \
518 ((_sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) && \
519 (!_sme->crypto.n_ciphers_pairwise) && \
520 (!_sme->crypto.cipher_group))
521extern s32 wl_cfg80211_attach(struct net_device *ndev, void *data);
522extern s32 wl_cfg80211_attach_post(struct net_device *ndev);
523extern void wl_cfg80211_detach(void);
524/* event handler from dongle */
525extern void wl_cfg80211_event(struct net_device *ndev, const wl_event_msg_t *e,
526 void *data);
527extern void wl_cfg80211_set_sdio_func(void *func); /* set sdio function info */
528extern struct sdio_func *wl_cfg80211_get_sdio_func(void); /* set sdio function info */
529extern s32 wl_cfg80211_up(void); /* dongle up */
530extern s32 wl_cfg80211_down(void); /* dongle down */
531extern s32 wl_cfg80211_notify_ifadd(struct net_device *net, s32 idx, s32 bssidx,
532int (*_net_attach)(dhd_pub_t *dhdp, int ifidx));
533extern s32 wl_cfg80211_notify_ifdel(struct net_device *ndev);
534extern s32 wl_cfg80211_is_progress_ifadd(void);
535extern s32 wl_cfg80211_is_progress_ifchange(void);
536extern s32 wl_cfg80211_is_progress_ifadd(void);
537extern s32 wl_cfg80211_notify_ifchange(void);
538extern void wl_cfg80211_dbg_level(u32 level);
539extern void *wl_cfg80211_request_fw(s8 *file_name);
540extern s32 wl_cfg80211_read_fw(s8 *buf, u32 size);
541extern void wl_cfg80211_release_fw(void);
542extern s8 *wl_cfg80211_get_fwname(void);
543extern s8 *wl_cfg80211_get_nvramname(void);
544extern s32 wl_cfg80211_get_p2p_dev_addr(struct net_device *net, struct ether_addr *p2pdev_addr);
545extern s32 wl_cfg80211_set_p2p_noa(struct net_device *net, char* buf, int len);
546extern s32 wl_cfg80211_get_p2p_noa(struct net_device *net, char* buf, int len);
547extern s32 wl_cfg80211_set_wps_p2p_ie(struct net_device *net, char *buf, int len,
548 enum wl_management_type type);
549extern s32 wl_cfg80211_set_p2p_ps(struct net_device *net, char* buf, int len);
550extern int wl_cfg80211_hang(struct net_device *dev, u16 reason);
551
552/* do scan abort */
553extern s32
554wl_cfg80211_scan_abort(struct wl_priv *wl, struct net_device *ndev);
555
556extern s32
557wl_cfg80211_if_is_group_owner(void);
558#endif /* _wl_cfg80211_h_ */