Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
wl_cfg80211.h
Go to the documentation of this file.
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 #define WL_DBG_NONE 0
21 #define WL_DBG_CONN (1 << 5)
22 #define WL_DBG_SCAN (1 << 4)
23 #define WL_DBG_TRACE (1 << 3)
24 #define WL_DBG_INFO (1 << 1)
25 #define WL_DBG_ERR (1 << 0)
26 #define WL_DBG_MASK ((WL_DBG_INFO | WL_DBG_ERR | WL_DBG_TRACE) | \
27  (WL_DBG_SCAN) | (WL_DBG_CONN))
28 
29 #define WL_ERR(fmt, ...) \
30 do { \
31  if (brcmf_dbg_level & WL_DBG_ERR) { \
32  if (net_ratelimit()) { \
33  pr_err("ERROR @%s : " fmt, \
34  __func__, ##__VA_ARGS__); \
35  } \
36  } \
37 } while (0)
38 
39 #if (defined DEBUG)
40 #define WL_INFO(fmt, ...) \
41 do { \
42  if (brcmf_dbg_level & WL_DBG_INFO) { \
43  if (net_ratelimit()) { \
44  pr_err("INFO @%s : " fmt, \
45  __func__, ##__VA_ARGS__); \
46  } \
47  } \
48 } while (0)
49 
50 #define WL_TRACE(fmt, ...) \
51 do { \
52  if (brcmf_dbg_level & WL_DBG_TRACE) { \
53  if (net_ratelimit()) { \
54  pr_err("TRACE @%s : " fmt, \
55  __func__, ##__VA_ARGS__); \
56  } \
57  } \
58 } while (0)
59 
60 #define WL_SCAN(fmt, ...) \
61 do { \
62  if (brcmf_dbg_level & WL_DBG_SCAN) { \
63  if (net_ratelimit()) { \
64  pr_err("SCAN @%s : " fmt, \
65  __func__, ##__VA_ARGS__); \
66  } \
67  } \
68 } while (0)
69 
70 #define WL_CONN(fmt, ...) \
71 do { \
72  if (brcmf_dbg_level & WL_DBG_CONN) { \
73  if (net_ratelimit()) { \
74  pr_err("CONN @%s : " fmt, \
75  __func__, ##__VA_ARGS__); \
76  } \
77  } \
78 } while (0)
79 
80 #else /* (defined DEBUG) */
81 #define WL_INFO(fmt, args...)
82 #define WL_TRACE(fmt, args...)
83 #define WL_SCAN(fmt, args...)
84 #define WL_CONN(fmt, args...)
85 #endif /* (defined DEBUG) */
86 
87 #define WL_NUM_SCAN_MAX 1
88 #define WL_NUM_PMKIDS_MAX MAXPMKID /* will be used
89  * for 2.6.33 kernel
90  * or later
91  */
92 #define WL_SCAN_BUF_MAX (1024 * 8)
93 #define WL_TLV_INFO_MAX 1024
94 #define WL_BSS_INFO_MAX 2048
95 #define WL_ASSOC_INFO_MAX 512 /*
96  * needs to grab assoc info from dongle to
97  * report it to cfg80211 through "connect"
98  * event
99  */
100 #define WL_DCMD_LEN_MAX 1024
101 #define WL_EXTRA_BUF_MAX 2048
102 #define WL_ISCAN_BUF_MAX 2048 /*
103  * the buf length can be BRCMF_DCMD_MAXLEN
104  * to reduce iteration
105  */
106 #define WL_ISCAN_TIMER_INTERVAL_MS 3000
107 #define WL_SCAN_ERSULTS_LAST (BRCMF_SCAN_RESULTS_NO_MEM+1)
108 #define WL_AP_MAX 256 /* virtually unlimitted as long
109  * as kernel memory allows
110  */
112 #define WL_ROAM_TRIGGER_LEVEL -75
113 #define WL_ROAM_DELTA 20
114 #define WL_BEACON_TIMEOUT 3
116 #define WL_SCAN_CHANNEL_TIME 40
117 #define WL_SCAN_UNASSOC_TIME 40
118 #define WL_SCAN_PASSIVE_TIME 120
120 #define WL_ESCAN_BUF_SIZE (1024 * 64)
121 #define WL_ESCAN_TIMER_INTERVAL_MS 8000 /* E-Scan timeout */
123 #define WL_ESCAN_ACTION_START 1
124 #define WL_ESCAN_ACTION_CONTINUE 2
125 #define WL_ESCAN_ACTION_ABORT 3
127 #define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */
128 #define IE_MAX_LEN 512
129 
130 /* dongle status */
131 enum wl_status {
139 };
141 /* wi-fi mode */
142 enum wl_mode {
146 };
147 
148 /* dongle profile list */
149 enum wl_prof_list {
153  WL_PROF_IBSS,
154  WL_PROF_BAND,
159 };
161 /* dongle iscan state */
165 };
166 
167 /* dongle configuration */
168 struct brcmf_cfg80211_conf {
169  u32 mode; /* adhoc , infrastructure or ap */
173  u32 retry_long;
174  s32 tx_power;
175  struct ieee80211_channel channel;
176 };
177 
178 /* forward declaration */
180 
181 /* cfg80211 main event loop */
184  struct net_device *ndev,
185  const struct brcmf_event_msg *e,
186  void *data);
187 };
188 
189 /* basic structure of scan request */
192 };
194 /* basic structure of information element */
195 struct brcmf_cfg80211_ie {
196  u16 offset;
198 };
200 /* event queue for cfg80211 main event */
203  u32 etype;
204  struct brcmf_event_msg emsg;
205  s8 edata[1];
206 };
208 /* security information with currently associated ap */
214  u32 wpa_auth;
215 };
217 /* ibss information for currently joined ibss network */
219  u8 beacon_interval; /* in millisecond */
220  u8 atim; /* in millisecond */
224 };
225 
226 /* dongle profile */
228  u32 mode;
229  struct brcmf_ssid ssid;
230  u8 bssid[ETH_ALEN];
232  u8 dtim_period;
236 };
238 /* dongle iscan event loop */
242 };
244 /* dongle iscan controller */
246  struct net_device *ndev;
253  void *data;
256 };
258 /* association inform */
260  u8 *req_ie;
264 };
265 
266 /* assoc ie length */
270 };
271 
272 /* wpa2 pmk list */
275  struct pmkid foo[MAXPMKID - 1];
276 };
277 
278 /* dongle escan state */
279 enum wl_escan_state {
282 };
284 struct escan_info {
287  struct wiphy *wiphy;
288  struct net_device *ndev;
289 };
290 
291 /* Structure to hold WPS, WPA IEs for a AP */
292 struct ap_info {
297  u8 *wpa_ie;
298  u8 *rsn_ie;
299  bool security_mode;
300 };
301 
319 struct brcmf_pno_param_le {
320  __le32 version;
323  __le16 flags;
325  u8 bestn;
326  u8 mscan;
327  u8 repeat;
328  u8 exp;
330 };
342 struct brcmf_pno_net_param_le {
343  struct brcmf_ssid_le ssid;
344  __le32 flags;
345  __le32 infra;
346  __le32 auth;
348  __le32 wsec;
349 };
361 struct brcmf_pno_net_info_le {
362  u8 bssid[ETH_ALEN];
363  u8 channel;
364  u8 SSID_len;
365  u8 SSID[32];
368 };
369 
378  __le32 version;
379  __le32 status;
380  __le32 count;
381 };
382 
434  struct mutex usr_sync;
438  struct wl_cfg80211_bss_info *bss_info;
445  unsigned long status;
446  struct brcmf_pub *pub;
448  bool iscan_on;
453  bool link_up;
454  bool pwr_save;
455  bool dongle_up;
456  bool roam_on;
457  bool scan_tried;
458  u8 *dcmd_buf;
459  u8 *extra_buf;
460  struct dentry *debugfsdir;
461  bool escan_on;
462  struct escan_info escan_info;
463  struct timer_list escan_timeout;
466  struct ap_info *ap_info;
467 };
468 
469 static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *w)
470 {
471  return w->wdev->wiphy;
472 }
473 
474 static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
475 {
476  return (struct brcmf_cfg80211_info *)(wiphy_priv(w));
477 }
478 
479 static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
480 {
481  return (struct brcmf_cfg80211_info *)(wdev_priv(wd));
482 }
484 static inline struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
485 {
486  return cfg->wdev->netdev;
487 }
488 
489 static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
490 {
491  return wdev_to_cfg(ndev->ieee80211_ptr);
492 }
493 
494 #define iscan_to_cfg(i) ((struct brcmf_cfg80211_info *)(i->data))
495 #define cfg_to_iscan(w) (w->iscan)
496 
497 static inline struct
499 {
500  return &cfg->conn_info;
501 }
502 
504  struct device *busdev,
505  struct brcmf_pub *drvr);
507 
508 /* event handler from dongle */
510  const struct brcmf_event_msg *e, void *data);
513 
514 #endif /* _wl_cfg80211_h_ */