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