brcmfmac: change struct brcmf_cfg80211_priv comments to kernel-doc
[deliverable/linux.git] / drivers / net / wireless / brcm80211 / brcmfmac / wl_cfg80211.h
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 struct brcmf_cfg80211_conf;
21 struct brcmf_cfg80211_iface;
22 struct brcmf_cfg80211_priv;
23 struct brcmf_cfg80211_security;
24 struct brcmf_cfg80211_ibss;
25
26 #define WL_DBG_NONE 0
27 #define WL_DBG_CONN (1 << 5)
28 #define WL_DBG_SCAN (1 << 4)
29 #define WL_DBG_TRACE (1 << 3)
30 #define WL_DBG_INFO (1 << 1)
31 #define WL_DBG_ERR (1 << 0)
32 #define WL_DBG_MASK ((WL_DBG_INFO | WL_DBG_ERR | WL_DBG_TRACE) | \
33 (WL_DBG_SCAN) | (WL_DBG_CONN))
34
35 #define WL_ERR(fmt, ...) \
36 do { \
37 if (brcmf_dbg_level & WL_DBG_ERR) { \
38 if (net_ratelimit()) { \
39 pr_err("ERROR @%s : " fmt, \
40 __func__, ##__VA_ARGS__); \
41 } \
42 } \
43 } while (0)
44
45 #if (defined DEBUG)
46 #define WL_INFO(fmt, ...) \
47 do { \
48 if (brcmf_dbg_level & WL_DBG_INFO) { \
49 if (net_ratelimit()) { \
50 pr_err("INFO @%s : " fmt, \
51 __func__, ##__VA_ARGS__); \
52 } \
53 } \
54 } while (0)
55
56 #define WL_TRACE(fmt, ...) \
57 do { \
58 if (brcmf_dbg_level & WL_DBG_TRACE) { \
59 if (net_ratelimit()) { \
60 pr_err("TRACE @%s : " fmt, \
61 __func__, ##__VA_ARGS__); \
62 } \
63 } \
64 } while (0)
65
66 #define WL_SCAN(fmt, ...) \
67 do { \
68 if (brcmf_dbg_level & WL_DBG_SCAN) { \
69 if (net_ratelimit()) { \
70 pr_err("SCAN @%s : " fmt, \
71 __func__, ##__VA_ARGS__); \
72 } \
73 } \
74 } while (0)
75
76 #define WL_CONN(fmt, ...) \
77 do { \
78 if (brcmf_dbg_level & WL_DBG_CONN) { \
79 if (net_ratelimit()) { \
80 pr_err("CONN @%s : " fmt, \
81 __func__, ##__VA_ARGS__); \
82 } \
83 } \
84 } while (0)
85
86 #else /* (defined DEBUG) */
87 #define WL_INFO(fmt, args...)
88 #define WL_TRACE(fmt, args...)
89 #define WL_SCAN(fmt, args...)
90 #define WL_CONN(fmt, args...)
91 #endif /* (defined DEBUG) */
92
93 #define WL_NUM_SCAN_MAX 1
94 #define WL_NUM_PMKIDS_MAX MAXPMKID /* will be used
95 * for 2.6.33 kernel
96 * or later
97 */
98 #define WL_SCAN_BUF_MAX (1024 * 8)
99 #define WL_TLV_INFO_MAX 1024
100 #define WL_BSS_INFO_MAX 2048
101 #define WL_ASSOC_INFO_MAX 512 /*
102 * needs to grab assoc info from dongle to
103 * report it to cfg80211 through "connect"
104 * event
105 */
106 #define WL_DCMD_LEN_MAX 1024
107 #define WL_EXTRA_BUF_MAX 2048
108 #define WL_ISCAN_BUF_MAX 2048 /*
109 * the buf length can be BRCMF_DCMD_MAXLEN
110 * to reduce iteration
111 */
112 #define WL_ISCAN_TIMER_INTERVAL_MS 3000
113 #define WL_SCAN_ERSULTS_LAST (BRCMF_SCAN_RESULTS_NO_MEM+1)
114 #define WL_AP_MAX 256 /* virtually unlimitted as long
115 * as kernel memory allows
116 */
117
118 #define WL_ROAM_TRIGGER_LEVEL -75
119 #define WL_ROAM_DELTA 20
120 #define WL_BEACON_TIMEOUT 3
121
122 #define WL_SCAN_CHANNEL_TIME 40
123 #define WL_SCAN_UNASSOC_TIME 40
124 #define WL_SCAN_PASSIVE_TIME 120
125
126 #define WL_ESCAN_BUF_SIZE (1024 * 64)
127 #define WL_ESCAN_TIMER_INTERVAL_MS 8000 /* E-Scan timeout */
128
129 #define WL_ESCAN_ACTION_START 1
130 #define WL_ESCAN_ACTION_CONTINUE 2
131 #define WL_ESCAN_ACTION_ABORT 3
132
133 /* dongle status */
134 enum wl_status {
135 WL_STATUS_READY,
136 WL_STATUS_SCANNING,
137 WL_STATUS_SCAN_ABORTING,
138 WL_STATUS_CONNECTING,
139 WL_STATUS_CONNECTED
140 };
141
142 /* wi-fi mode */
143 enum wl_mode {
144 WL_MODE_BSS,
145 WL_MODE_IBSS,
146 WL_MODE_AP
147 };
148
149 /* dongle profile list */
150 enum wl_prof_list {
151 WL_PROF_MODE,
152 WL_PROF_SSID,
153 WL_PROF_SEC,
154 WL_PROF_IBSS,
155 WL_PROF_BAND,
156 WL_PROF_BSSID,
157 WL_PROF_ACT,
158 WL_PROF_BEACONINT,
159 WL_PROF_DTIMPERIOD
160 };
161
162 /* dongle iscan state */
163 enum wl_iscan_state {
164 WL_ISCAN_STATE_IDLE,
165 WL_ISCAN_STATE_SCANING
166 };
167
168 /* dongle configuration */
169 struct brcmf_cfg80211_conf {
170 u32 mode; /* adhoc , infrastructure or ap */
171 u32 frag_threshold;
172 u32 rts_threshold;
173 u32 retry_short;
174 u32 retry_long;
175 s32 tx_power;
176 struct ieee80211_channel channel;
177 };
178
179 /* cfg80211 main event loop */
180 struct brcmf_cfg80211_event_loop {
181 s32(*handler[BRCMF_E_LAST]) (struct brcmf_cfg80211_priv *cfg_priv,
182 struct net_device *ndev,
183 const struct brcmf_event_msg *e,
184 void *data);
185 };
186
187 /* representing interface of cfg80211 plane */
188 struct brcmf_cfg80211_iface {
189 struct brcmf_cfg80211_priv *cfg_priv;
190 };
191
192 struct brcmf_cfg80211_dev {
193 void *driver_data; /* to store cfg80211 object information */
194 };
195
196 /* basic structure of scan request */
197 struct brcmf_cfg80211_scan_req {
198 struct brcmf_ssid_le ssid_le;
199 };
200
201 /* basic structure of information element */
202 struct brcmf_cfg80211_ie {
203 u16 offset;
204 u8 buf[WL_TLV_INFO_MAX];
205 };
206
207 /* event queue for cfg80211 main event */
208 struct brcmf_cfg80211_event_q {
209 struct list_head evt_q_list;
210 u32 etype;
211 struct brcmf_event_msg emsg;
212 s8 edata[1];
213 };
214
215 /* security information with currently associated ap */
216 struct brcmf_cfg80211_security {
217 u32 wpa_versions;
218 u32 auth_type;
219 u32 cipher_pairwise;
220 u32 cipher_group;
221 u32 wpa_auth;
222 };
223
224 /* ibss information for currently joined ibss network */
225 struct brcmf_cfg80211_ibss {
226 u8 beacon_interval; /* in millisecond */
227 u8 atim; /* in millisecond */
228 s8 join_only;
229 u8 band;
230 u8 channel;
231 };
232
233 /* dongle profile */
234 struct brcmf_cfg80211_profile {
235 u32 mode;
236 struct brcmf_ssid ssid;
237 u8 bssid[ETH_ALEN];
238 u16 beacon_interval;
239 u8 dtim_period;
240 struct brcmf_cfg80211_security sec;
241 struct brcmf_cfg80211_ibss ibss;
242 s32 band;
243 };
244
245 /* dongle iscan event loop */
246 struct brcmf_cfg80211_iscan_eloop {
247 s32 (*handler[WL_SCAN_ERSULTS_LAST])
248 (struct brcmf_cfg80211_priv *cfg_priv);
249 };
250
251 /* dongle iscan controller */
252 struct brcmf_cfg80211_iscan_ctrl {
253 struct net_device *ndev;
254 struct timer_list timer;
255 u32 timer_ms;
256 u32 timer_on;
257 s32 state;
258 struct work_struct work;
259 struct brcmf_cfg80211_iscan_eloop el;
260 void *data;
261 s8 dcmd_buf[BRCMF_DCMD_SMLEN];
262 s8 scan_buf[WL_ISCAN_BUF_MAX];
263 };
264
265 /* association inform */
266 struct brcmf_cfg80211_connect_info {
267 u8 *req_ie;
268 s32 req_ie_len;
269 u8 *resp_ie;
270 s32 resp_ie_len;
271 };
272
273 /* assoc ie length */
274 struct brcmf_cfg80211_assoc_ielen_le {
275 __le32 req_len;
276 __le32 resp_len;
277 };
278
279 /* wpa2 pmk list */
280 struct brcmf_cfg80211_pmk_list {
281 struct pmkid_list pmkids;
282 struct pmkid foo[MAXPMKID - 1];
283 };
284
285 /* dongle escan state */
286 enum wl_escan_state {
287 WL_ESCAN_STATE_IDLE,
288 WL_ESCAN_STATE_SCANNING
289 };
290
291 struct escan_info {
292 u32 escan_state;
293 u8 escan_buf[WL_ESCAN_BUF_SIZE];
294 struct wiphy *wiphy;
295 struct net_device *ndev;
296 };
297
298 /**
299 * struct brcmf_pno_param_le - PNO scan configuration parameters
300 *
301 * @version: PNO parameters version.
302 * @scan_freq: scan frequency.
303 * @lost_network_timeout: #sec. to declare discovered network as lost.
304 * @flags: Bit field to control features of PFN such as sort criteria auto
305 * enable switch and background scan.
306 * @rssi_margin: Margin to avoid jitter for choosing a PFN based on RSSI sort
307 * criteria.
308 * @bestn: number of best networks in each scan.
309 * @mscan: number of scans recorded.
310 * @repeat: minimum number of scan intervals before scan frequency changes
311 * in adaptive scan.
312 * @exp: exponent of 2 for maximum scan interval.
313 * @slow_freq: slow scan period.
314 */
315 struct brcmf_pno_param_le {
316 __le32 version;
317 __le32 scan_freq;
318 __le32 lost_network_timeout;
319 __le16 flags;
320 __le16 rssi_margin;
321 u8 bestn;
322 u8 mscan;
323 u8 repeat;
324 u8 exp;
325 __le32 slow_freq;
326 };
327
328 /**
329 * struct brcmf_pno_net_param_le - scan parameters per preferred network.
330 *
331 * @ssid: ssid name and its length.
332 * @flags: bit2: hidden.
333 * @infra: BSS vs IBSS.
334 * @auth: Open vs Closed.
335 * @wpa_auth: WPA type.
336 * @wsec: wsec value.
337 */
338 struct brcmf_pno_net_param_le {
339 struct brcmf_ssid_le ssid;
340 __le32 flags;
341 __le32 infra;
342 __le32 auth;
343 __le32 wpa_auth;
344 __le32 wsec;
345 };
346
347 /**
348 * struct brcmf_pno_net_info_le - information per found network.
349 *
350 * @bssid: BSS network identifier.
351 * @channel: channel number only.
352 * @SSID_len: length of ssid.
353 * @SSID: ssid characters.
354 * @RSSI: receive signal strength (in dBm).
355 * @timestamp: age in seconds.
356 */
357 struct brcmf_pno_net_info_le {
358 u8 bssid[ETH_ALEN];
359 u8 channel;
360 u8 SSID_len;
361 u8 SSID[32];
362 __le16 RSSI;
363 __le16 timestamp;
364 };
365
366 /**
367 * struct brcmf_pno_scanresults_le - result returned in PNO NET FOUND event.
368 *
369 * @version: PNO version identifier.
370 * @status: indicates completion status of PNO scan.
371 * @count: amount of brcmf_pno_net_info_le entries appended.
372 */
373 struct brcmf_pno_scanresults_le {
374 __le32 version;
375 __le32 status;
376 __le32 count;
377 };
378
379 /**
380 * struct brcmf_cfg80211_priv - dongle private data of cfg80211 interface
381 *
382 * @wdev: representing wl cfg80211 device.
383 * @conf: dongle configuration.
384 * @scan_request: cfg80211 scan request object.
385 * @el: main event loop.
386 * @evt_q_list: used for event queue.
387 * @evt_q_lock: for event queue synchronization.
388 * @usr_sync: mainly for dongle up/down synchronization.
389 * @bss_list: bss_list holding scanned ap information.
390 * @scan_results: results of the last scan.
391 * @scan_req_int: internal scan request object.
392 * @bss_info: bss information for cfg80211 layer.
393 * @ie: information element object for internal purpose.
394 * @profile: holding dongle profile.
395 * @iscan: iscan controller information.
396 * @conn_info: association info.
397 * @pmk_list: wpa2 pmk list.
398 * @event_work: event handler work struct.
399 * @status: current dongle status.
400 * @pub: common driver information.
401 * @channel: current channel.
402 * @iscan_on: iscan on/off switch.
403 * @iscan_kickstart: indicate iscan already started.
404 * @active_scan: current scan mode.
405 * @sched_escan: e-scan for scheduled scan support running.
406 * @ibss_starter: indicates this sta is ibss starter.
407 * @link_up: link/connection up flag.
408 * @pwr_save: indicate whether dongle to support power save mode.
409 * @dongle_up: indicate whether dongle up or not.
410 * @roam_on: on/off switch for dongle self-roaming.
411 * @scan_tried: indicates if first scan attempted.
412 * @dcmd_buf: dcmd buffer.
413 * @extra_buf: mainly to grab assoc information.
414 * @debugfsdir: debugfs folder for this device.
415 * @escan_on: escan on/off switch.
416 * @escan_info: escan information.
417 * @escan_timeout: Timer for catch scan timeout.
418 * @escan_timeout_work: scan timeout worker.
419 * @escan_ioctl_buf: dongle command buffer for escan commands.
420 * @ci: used to link this structure to netdev private data.
421 */
422 struct brcmf_cfg80211_priv {
423 struct wireless_dev *wdev;
424 struct brcmf_cfg80211_conf *conf;
425 struct cfg80211_scan_request *scan_request;
426 struct brcmf_cfg80211_event_loop el;
427 struct list_head evt_q_list;
428 spinlock_t evt_q_lock;
429 struct mutex usr_sync;
430 struct brcmf_scan_results *bss_list;
431 struct brcmf_scan_results *scan_results;
432 struct brcmf_cfg80211_scan_req *scan_req_int;
433 struct wl_cfg80211_bss_info *bss_info;
434 struct brcmf_cfg80211_ie ie;
435 struct brcmf_cfg80211_profile *profile;
436 struct brcmf_cfg80211_iscan_ctrl *iscan;
437 struct brcmf_cfg80211_connect_info conn_info;
438 struct brcmf_cfg80211_pmk_list *pmk_list;
439 struct work_struct event_work;
440 unsigned long status;
441 void *pub;
442 u32 channel;
443 bool iscan_on;
444 bool iscan_kickstart;
445 bool active_scan;
446 bool sched_escan;
447 bool ibss_starter;
448 bool link_up;
449 bool pwr_save;
450 bool dongle_up;
451 bool roam_on;
452 bool scan_tried;
453 u8 *dcmd_buf;
454 u8 *extra_buf;
455 struct dentry *debugfsdir;
456 bool escan_on;
457 struct escan_info escan_info;
458 struct timer_list escan_timeout;
459 struct work_struct escan_timeout_work;
460 u8 *escan_ioctl_buf;
461 u8 ci[0] __aligned(NETDEV_ALIGN);
462 };
463
464 static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_priv *w)
465 {
466 return w->wdev->wiphy;
467 }
468
469 static inline struct brcmf_cfg80211_priv *wiphy_to_cfg(struct wiphy *w)
470 {
471 return (struct brcmf_cfg80211_priv *)(wiphy_priv(w));
472 }
473
474 static inline struct brcmf_cfg80211_priv *wdev_to_cfg(struct wireless_dev *wd)
475 {
476 return (struct brcmf_cfg80211_priv *)(wdev_priv(wd));
477 }
478
479 static inline struct net_device *cfg_to_ndev(struct brcmf_cfg80211_priv *cfg)
480 {
481 return cfg->wdev->netdev;
482 }
483
484 static inline struct brcmf_cfg80211_priv *ndev_to_cfg(struct net_device *ndev)
485 {
486 return wdev_to_cfg(ndev->ieee80211_ptr);
487 }
488
489 #define iscan_to_cfg(i) ((struct brcmf_cfg80211_priv *)(i->data))
490 #define cfg_to_iscan(w) (w->iscan)
491
492 static inline struct
493 brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_priv *cfg)
494 {
495 return &cfg->conn_info;
496 }
497
498 extern struct brcmf_cfg80211_dev *brcmf_cfg80211_attach(struct net_device *ndev,
499 struct device *busdev,
500 void *data);
501 extern void brcmf_cfg80211_detach(struct brcmf_cfg80211_dev *cfg);
502
503 /* event handler from dongle */
504 extern void brcmf_cfg80211_event(struct net_device *ndev,
505 const struct brcmf_event_msg *e, void *data);
506 extern s32 brcmf_cfg80211_up(struct brcmf_cfg80211_dev *cfg_dev);
507 extern s32 brcmf_cfg80211_down(struct brcmf_cfg80211_dev *cfg_dev);
508
509 #endif /* _wl_cfg80211_h_ */
This page took 0.733112 seconds and 5 git commands to generate.