Merge branch 'rc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / net / wireless / brcm80211 / brcmfmac / wl_cfg80211.h
CommitLineData
5b435de0
AS
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
83cf17aa
FL
20/* for brcmu_d11inf */
21#include <brcmu_d11.h>
22
f0799895
HM
23#define WL_NUM_SCAN_MAX 10
24#define WL_NUM_PMKIDS_MAX MAXPMKID
5b435de0
AS
25#define WL_TLV_INFO_MAX 1024
26#define WL_BSS_INFO_MAX 2048
f0799895
HM
27#define WL_ASSOC_INFO_MAX 512 /* assoc related fil max buf */
28#define WL_EXTRA_BUF_MAX 2048
5b435de0
AS
29#define WL_ROAM_TRIGGER_LEVEL -75
30#define WL_ROAM_DELTA 20
31#define WL_BEACON_TIMEOUT 3
32
33#define WL_SCAN_CHANNEL_TIME 40
34#define WL_SCAN_UNASSOC_TIME 40
35#define WL_SCAN_PASSIVE_TIME 120
36
e756af5b
HM
37#define WL_ESCAN_BUF_SIZE (1024 * 64)
38#define WL_ESCAN_TIMER_INTERVAL_MS 8000 /* E-Scan timeout */
39
40#define WL_ESCAN_ACTION_START 1
41#define WL_ESCAN_ACTION_CONTINUE 2
42#define WL_ESCAN_ACTION_ABORT 3
43
f09d0c02 44#define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */
1a873342 45#define IE_MAX_LEN 512
f09d0c02 46
9f440b7b
AS
47/* IE TLV processing */
48#define TLV_LEN_OFF 1 /* length offset */
49#define TLV_HDR_LEN 2 /* header length */
50#define TLV_BODY_OFF 2 /* body offset */
51#define TLV_OUI_LEN 3 /* oui id length */
52
53/* 802.11 Mgmt Packet flags */
54#define BRCMF_VNDR_IE_BEACON_FLAG 0x1
55#define BRCMF_VNDR_IE_PRBRSP_FLAG 0x2
56#define BRCMF_VNDR_IE_ASSOCRSP_FLAG 0x4
57#define BRCMF_VNDR_IE_AUTHRSP_FLAG 0x8
58#define BRCMF_VNDR_IE_PRBREQ_FLAG 0x10
59#define BRCMF_VNDR_IE_ASSOCREQ_FLAG 0x20
60/* vendor IE in IW advertisement protocol ID field */
61#define BRCMF_VNDR_IE_IWAPID_FLAG 0x40
62/* allow custom IE id */
63#define BRCMF_VNDR_IE_CUSTOM_FLAG 0x100
64
65/* P2P Action Frames flags (spec ordered) */
66#define BRCMF_VNDR_IE_GONREQ_FLAG 0x001000
67#define BRCMF_VNDR_IE_GONRSP_FLAG 0x002000
68#define BRCMF_VNDR_IE_GONCFM_FLAG 0x004000
69#define BRCMF_VNDR_IE_INVREQ_FLAG 0x008000
70#define BRCMF_VNDR_IE_INVRSP_FLAG 0x010000
71#define BRCMF_VNDR_IE_DISREQ_FLAG 0x020000
72#define BRCMF_VNDR_IE_DISRSP_FLAG 0x040000
73#define BRCMF_VNDR_IE_PRDREQ_FLAG 0x080000
74#define BRCMF_VNDR_IE_PRDRSP_FLAG 0x100000
75
76#define BRCMF_VNDR_IE_P2PAF_SHIFT 12
77
78
c1179033 79/**
1687eee2 80 * enum brcmf_scan_status - scan engine status
c1179033
AS
81 *
82 * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.
83 * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.
1687eee2 84 * @BRCMF_SCAN_STATUS_SUPPRESS: scanning is suppressed in driver.
c1179033
AS
85 */
86enum brcmf_scan_status {
87 BRCMF_SCAN_STATUS_BUSY,
88 BRCMF_SCAN_STATUS_ABORT,
1687eee2 89 BRCMF_SCAN_STATUS_SUPPRESS,
5b435de0
AS
90};
91
9f440b7b
AS
92/**
93 * enum wl_mode - driver mode of virtual interface.
94 *
95 * @WL_MODE_BSS: connects to BSS.
96 * @WL_MODE_IBSS: operate as ad-hoc.
97 * @WL_MODE_AP: operate as access-point.
98 * @WL_MODE_P2P: provide P2P discovery.
99 */
5b435de0
AS
100enum wl_mode {
101 WL_MODE_BSS,
102 WL_MODE_IBSS,
9f440b7b
AS
103 WL_MODE_AP,
104 WL_MODE_P2P
5b435de0
AS
105};
106
5b435de0
AS
107/* dongle configuration */
108struct brcmf_cfg80211_conf {
5b435de0
AS
109 u32 frag_threshold;
110 u32 rts_threshold;
111 u32 retry_short;
112 u32 retry_long;
113 s32 tx_power;
114 struct ieee80211_channel channel;
115};
116
5b435de0
AS
117/* basic structure of scan request */
118struct brcmf_cfg80211_scan_req {
119 struct brcmf_ssid_le ssid_le;
120};
121
122/* basic structure of information element */
123struct brcmf_cfg80211_ie {
124 u16 offset;
125 u8 buf[WL_TLV_INFO_MAX];
126};
127
5b435de0
AS
128/* security information with currently associated ap */
129struct brcmf_cfg80211_security {
130 u32 wpa_versions;
131 u32 auth_type;
132 u32 cipher_pairwise;
133 u32 cipher_group;
134 u32 wpa_auth;
135};
136
3bc0a96c
AS
137/**
138 * struct brcmf_cfg80211_profile - profile information.
139 *
140 * @ssid: ssid of associated/associating ap.
141 * @bssid: bssid of joined/joining ibss.
142 * @sec: security information.
143 */
5b435de0 144struct brcmf_cfg80211_profile {
5b435de0
AS
145 struct brcmf_ssid ssid;
146 u8 bssid[ETH_ALEN];
5b435de0 147 struct brcmf_cfg80211_security sec;
5b435de0
AS
148};
149
c1179033
AS
150/**
151 * enum brcmf_vif_status - bit indices for vif status.
152 *
153 * @BRCMF_VIF_STATUS_READY: ready for operation.
154 * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress.
155 * @BRCMF_VIF_STATUS_CONNECTED: connected/joined succesfully.
5f4f9f11 156 * @BRCMF_VIF_STATUS_DISCONNECTING: disconnect/disable in progress.
c1179033
AS
157 * @BRCMF_VIF_STATUS_AP_CREATING: interface configured for AP operation.
158 * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started.
159 */
160enum brcmf_vif_status {
161 BRCMF_VIF_STATUS_READY,
162 BRCMF_VIF_STATUS_CONNECTING,
163 BRCMF_VIF_STATUS_CONNECTED,
5f4f9f11 164 BRCMF_VIF_STATUS_DISCONNECTING,
c1179033
AS
165 BRCMF_VIF_STATUS_AP_CREATING,
166 BRCMF_VIF_STATUS_AP_CREATED
167};
168
8ff5dc92
AS
169/**
170 * struct vif_saved_ie - holds saved IEs for a virtual interface.
171 *
9f440b7b 172 * @probe_req_ie: IE info for probe request.
8ff5dc92
AS
173 * @probe_res_ie: IE info for probe response.
174 * @beacon_ie: IE info for beacon frame.
9f440b7b 175 * @probe_req_ie_len: IE info length for probe request.
8ff5dc92
AS
176 * @probe_res_ie_len: IE info length for probe response.
177 * @beacon_ie_len: IE info length for beacon frame.
178 */
179struct vif_saved_ie {
dae3a273 180 u8 probe_req_ie[IE_MAX_LEN];
8ff5dc92
AS
181 u8 probe_res_ie[IE_MAX_LEN];
182 u8 beacon_ie[IE_MAX_LEN];
89286dc9 183 u8 assoc_req_ie[IE_MAX_LEN];
9f440b7b 184 u32 probe_req_ie_len;
8ff5dc92
AS
185 u32 probe_res_ie_len;
186 u32 beacon_ie_len;
89286dc9 187 u32 assoc_req_ie_len;
8ff5dc92
AS
188};
189
3eacf866
AS
190/**
191 * struct brcmf_cfg80211_vif - virtual interface specific information.
192 *
193 * @ifp: lower layer interface pointer
194 * @wdev: wireless device.
6ac4f4ed 195 * @profile: profile information.
3eacf866
AS
196 * @mode: operating mode.
197 * @roam_off: roaming state.
c1179033 198 * @sme_state: SME state using enum brcmf_vif_status bits.
3eacf866
AS
199 * @pm_block: power-management blocked.
200 * @list: linked list.
0de8aace 201 * @mgmt_rx_reg: registered rx mgmt frame types.
3eacf866
AS
202 */
203struct brcmf_cfg80211_vif {
204 struct brcmf_if *ifp;
205 struct wireless_dev wdev;
6ac4f4ed 206 struct brcmf_cfg80211_profile profile;
3eacf866
AS
207 s32 mode;
208 s32 roam_off;
c1179033 209 unsigned long sme_state;
3eacf866 210 bool pm_block;
8ff5dc92 211 struct vif_saved_ie saved_ie;
3eacf866 212 struct list_head list;
0de8aace 213 u16 mgmt_rx_reg;
3eacf866
AS
214};
215
5b435de0
AS
216/* association inform */
217struct brcmf_cfg80211_connect_info {
218 u8 *req_ie;
219 s32 req_ie_len;
220 u8 *resp_ie;
221 s32 resp_ie_len;
222};
223
224/* assoc ie length */
c4e382d2
AS
225struct brcmf_cfg80211_assoc_ielen_le {
226 __le32 req_len;
227 __le32 resp_len;
5b435de0
AS
228};
229
230/* wpa2 pmk list */
231struct brcmf_cfg80211_pmk_list {
232 struct pmkid_list pmkids;
233 struct pmkid foo[MAXPMKID - 1];
234};
235
e756af5b
HM
236/* dongle escan state */
237enum wl_escan_state {
238 WL_ESCAN_STATE_IDLE,
239 WL_ESCAN_STATE_SCANNING
240};
241
242struct escan_info {
243 u32 escan_state;
244 u8 escan_buf[WL_ESCAN_BUF_SIZE];
245 struct wiphy *wiphy;
a0f472ac
AS
246 struct brcmf_if *ifp;
247 s32 (*run)(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp,
9f440b7b 248 struct cfg80211_scan_request *request, u16 action);
e756af5b
HM
249};
250
e5806072
AS
251/**
252 * struct brcmf_pno_param_le - PNO scan configuration parameters
253 *
254 * @version: PNO parameters version.
255 * @scan_freq: scan frequency.
256 * @lost_network_timeout: #sec. to declare discovered network as lost.
257 * @flags: Bit field to control features of PFN such as sort criteria auto
258 * enable switch and background scan.
259 * @rssi_margin: Margin to avoid jitter for choosing a PFN based on RSSI sort
260 * criteria.
261 * @bestn: number of best networks in each scan.
262 * @mscan: number of scans recorded.
263 * @repeat: minimum number of scan intervals before scan frequency changes
264 * in adaptive scan.
265 * @exp: exponent of 2 for maximum scan interval.
266 * @slow_freq: slow scan period.
267 */
268struct brcmf_pno_param_le {
269 __le32 version;
270 __le32 scan_freq;
271 __le32 lost_network_timeout;
272 __le16 flags;
273 __le16 rssi_margin;
274 u8 bestn;
275 u8 mscan;
276 u8 repeat;
277 u8 exp;
278 __le32 slow_freq;
279};
280
281/**
282 * struct brcmf_pno_net_param_le - scan parameters per preferred network.
283 *
284 * @ssid: ssid name and its length.
285 * @flags: bit2: hidden.
286 * @infra: BSS vs IBSS.
287 * @auth: Open vs Closed.
288 * @wpa_auth: WPA type.
289 * @wsec: wsec value.
290 */
291struct brcmf_pno_net_param_le {
292 struct brcmf_ssid_le ssid;
293 __le32 flags;
294 __le32 infra;
295 __le32 auth;
296 __le32 wpa_auth;
297 __le32 wsec;
298};
299
300/**
301 * struct brcmf_pno_net_info_le - information per found network.
302 *
303 * @bssid: BSS network identifier.
304 * @channel: channel number only.
305 * @SSID_len: length of ssid.
306 * @SSID: ssid characters.
307 * @RSSI: receive signal strength (in dBm).
308 * @timestamp: age in seconds.
309 */
310struct brcmf_pno_net_info_le {
311 u8 bssid[ETH_ALEN];
312 u8 channel;
313 u8 SSID_len;
314 u8 SSID[32];
315 __le16 RSSI;
316 __le16 timestamp;
317};
318
319/**
320 * struct brcmf_pno_scanresults_le - result returned in PNO NET FOUND event.
321 *
322 * @version: PNO version identifier.
323 * @status: indicates completion status of PNO scan.
324 * @count: amount of brcmf_pno_net_info_le entries appended.
325 */
326struct brcmf_pno_scanresults_le {
327 __le32 version;
328 __le32 status;
329 __le32 count;
330};
331
d3c0b633
AS
332/**
333 * struct brcmf_cfg80211_vif_event - virtual interface event information.
334 *
335 * @vif_wq: waitqueue awaiting interface event from firmware.
336 * @vif_event_lock: protects other members in this structure.
337 * @vif_complete: completion for net attach.
338 * @action: either add, change, or delete.
339 * @vif: virtual interface object related to the event.
340 */
341struct brcmf_cfg80211_vif_event {
342 wait_queue_head_t vif_wq;
343 struct mutex vif_event_lock;
d3c0b633
AS
344 u8 action;
345 struct brcmf_cfg80211_vif *vif;
346};
347
02030eb6 348/**
27a68fe3 349 * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface
02030eb6 350 *
3eacf866 351 * @wiphy: wiphy object for cfg80211 interface.
02030eb6 352 * @conf: dongle configuration.
9f440b7b 353 * @p2p: peer-to-peer specific information.
61730d4d 354 * @btcoex: Bluetooth coexistence information.
02030eb6 355 * @scan_request: cfg80211 scan request object.
02030eb6
AS
356 * @usr_sync: mainly for dongle up/down synchronization.
357 * @bss_list: bss_list holding scanned ap information.
02030eb6
AS
358 * @scan_req_int: internal scan request object.
359 * @bss_info: bss information for cfg80211 layer.
360 * @ie: information element object for internal purpose.
02030eb6
AS
361 * @conn_info: association info.
362 * @pmk_list: wpa2 pmk list.
c1179033 363 * @scan_status: scan activity on the dongle.
02030eb6
AS
364 * @pub: common driver information.
365 * @channel: current channel.
02030eb6
AS
366 * @active_scan: current scan mode.
367 * @sched_escan: e-scan for scheduled scan support running.
368 * @ibss_starter: indicates this sta is ibss starter.
02030eb6
AS
369 * @pwr_save: indicate whether dongle to support power save mode.
370 * @dongle_up: indicate whether dongle up or not.
371 * @roam_on: on/off switch for dongle self-roaming.
372 * @scan_tried: indicates if first scan attempted.
373 * @dcmd_buf: dcmd buffer.
374 * @extra_buf: mainly to grab assoc information.
375 * @debugfsdir: debugfs folder for this device.
02030eb6
AS
376 * @escan_info: escan information.
377 * @escan_timeout: Timer for catch scan timeout.
378 * @escan_timeout_work: scan timeout worker.
379 * @escan_ioctl_buf: dongle command buffer for escan commands.
3eacf866
AS
380 * @vif_list: linked list of vif instances.
381 * @vif_cnt: number of vif instances.
d3c0b633 382 * @vif_event: vif event signalling.
02030eb6 383 */
27a68fe3 384struct brcmf_cfg80211_info {
3eacf866 385 struct wiphy *wiphy;
02030eb6 386 struct brcmf_cfg80211_conf *conf;
9f440b7b 387 struct brcmf_p2p_info p2p;
61730d4d 388 struct brcmf_btcoex_info *btcoex;
02030eb6 389 struct cfg80211_scan_request *scan_request;
02030eb6
AS
390 struct mutex usr_sync;
391 struct brcmf_scan_results *bss_list;
f0799895 392 struct brcmf_cfg80211_scan_req scan_req_int;
02030eb6
AS
393 struct wl_cfg80211_bss_info *bss_info;
394 struct brcmf_cfg80211_ie ie;
02030eb6
AS
395 struct brcmf_cfg80211_connect_info conn_info;
396 struct brcmf_cfg80211_pmk_list *pmk_list;
c1179033 397 unsigned long scan_status;
ee928381 398 struct brcmf_pub *pub;
02030eb6 399 u32 channel;
02030eb6
AS
400 bool active_scan;
401 bool sched_escan;
402 bool ibss_starter;
02030eb6
AS
403 bool pwr_save;
404 bool dongle_up;
405 bool roam_on;
406 bool scan_tried;
407 u8 *dcmd_buf;
408 u8 *extra_buf;
5b435de0 409 struct dentry *debugfsdir;
02030eb6
AS
410 struct escan_info escan_info;
411 struct timer_list escan_timeout;
412 struct work_struct escan_timeout_work;
e756af5b 413 u8 *escan_ioctl_buf;
3eacf866
AS
414 struct list_head vif_list;
415 u8 vif_cnt;
d3c0b633 416 struct brcmf_cfg80211_vif_event vif_event;
5f4f9f11 417 struct completion vif_disabled;
83cf17aa 418 struct brcmu_d11inf d11inf;
5b435de0
AS
419};
420
9f440b7b
AS
421/**
422 * struct brcmf_tlv - tag_ID/length/value_buffer tuple.
423 *
424 * @id: tag identifier.
425 * @len: number of bytes in value buffer.
426 * @data: value buffer.
427 */
428struct brcmf_tlv {
429 u8 id;
430 u8 len;
431 u8 data[1];
432};
433
3eacf866 434static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
5b435de0 435{
3eacf866 436 return cfg->wiphy;
5b435de0
AS
437}
438
27a68fe3 439static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
5b435de0 440{
27a68fe3 441 return (struct brcmf_cfg80211_info *)(wiphy_priv(w));
5b435de0
AS
442}
443
27a68fe3 444static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
5b435de0 445{
27a68fe3 446 return (struct brcmf_cfg80211_info *)(wdev_priv(wd));
5b435de0
AS
447}
448
3eacf866
AS
449static inline
450struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
5b435de0 451{
3eacf866
AS
452 struct brcmf_cfg80211_vif *vif;
453 vif = list_first_entry(&cfg->vif_list, struct brcmf_cfg80211_vif, list);
454 return vif->wdev.netdev;
5b435de0
AS
455}
456
27a68fe3 457static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
5b435de0
AS
458{
459 return wdev_to_cfg(ndev->ieee80211_ptr);
460}
461
6ac4f4ed
AS
462static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
463{
464 struct brcmf_if *ifp = netdev_priv(nd);
465 return &ifp->vif->profile;
466}
467
1332e26e
AS
468static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
469{
470 struct brcmf_if *ifp = netdev_priv(ndev);
471 return ifp->vif;
472}
473
5b435de0 474static inline struct
27a68fe3 475brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
5b435de0
AS
476{
477 return &cfg->conn_info;
478}
479
d9cb2596
AS
480struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
481 struct device *busdev);
27a68fe3 482void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
bdf5ff51
AS
483s32 brcmf_cfg80211_up(struct net_device *ndev);
484s32 brcmf_cfg80211_down(struct net_device *ndev);
a7965fbb 485enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp);
5b435de0 486
9f440b7b 487struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
9f440b7b
AS
488 enum nl80211_iftype type,
489 bool pm_block);
24e28bee
AS
490void brcmf_free_vif(struct brcmf_cfg80211_info *cfg,
491 struct brcmf_cfg80211_vif *vif);
9f440b7b
AS
492
493s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag,
494 const u8 *vndr_ie_buf, u32 vndr_ie_len);
5f4f9f11 495s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif);
9f440b7b 496struct brcmf_tlv *brcmf_parse_tlvs(void *buf, int buflen, uint key);
83cf17aa
FL
497u16 channel_to_chanspec(struct brcmu_d11inf *d11inf,
498 struct ieee80211_channel *ch);
9f440b7b 499u32 wl_get_vif_state_all(struct brcmf_cfg80211_info *cfg, unsigned long state);
d3c0b633
AS
500void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg,
501 struct brcmf_cfg80211_vif *vif);
502bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg);
503int brcmf_cfg80211_wait_vif_event_timeout(struct brcmf_cfg80211_info *cfg,
504 u8 action, ulong timeout);
7a5c1f64 505s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
a0f472ac
AS
506 struct brcmf_if *ifp, bool aborted,
507 bool fw_abort);
f96aa07e 508void brcmf_set_mpc(struct brcmf_if *ndev, int mpc);
18e2f61d 509void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg);
9f440b7b 510
5b435de0 511#endif /* _wl_cfg80211_h_ */