Commit | Line | Data |
---|---|---|
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 | ||
bfe81975 HM |
17 | #ifndef BRCMFMAC_CFG80211_H |
18 | #define BRCMFMAC_CFG80211_H | |
5b435de0 | 19 | |
83cf17aa FL |
20 | /* for brcmu_d11inf */ |
21 | #include <brcmu_d11.h> | |
22 | ||
f0799895 | 23 | #define WL_NUM_SCAN_MAX 10 |
5b435de0 AS |
24 | #define WL_TLV_INFO_MAX 1024 |
25 | #define WL_BSS_INFO_MAX 2048 | |
f0799895 HM |
26 | #define WL_ASSOC_INFO_MAX 512 /* assoc related fil max buf */ |
27 | #define WL_EXTRA_BUF_MAX 2048 | |
5b435de0 AS |
28 | #define WL_ROAM_TRIGGER_LEVEL -75 |
29 | #define WL_ROAM_DELTA 20 | |
5b435de0 | 30 | |
e756af5b | 31 | #define WL_ESCAN_BUF_SIZE (1024 * 64) |
ef8596e1 | 32 | #define WL_ESCAN_TIMER_INTERVAL_MS 10000 /* E-Scan timeout */ |
e756af5b HM |
33 | |
34 | #define WL_ESCAN_ACTION_START 1 | |
35 | #define WL_ESCAN_ACTION_CONTINUE 2 | |
36 | #define WL_ESCAN_ACTION_ABORT 3 | |
37 | ||
f09d0c02 | 38 | #define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */ |
1a873342 | 39 | #define IE_MAX_LEN 512 |
f09d0c02 | 40 | |
9f440b7b AS |
41 | /* IE TLV processing */ |
42 | #define TLV_LEN_OFF 1 /* length offset */ | |
43 | #define TLV_HDR_LEN 2 /* header length */ | |
44 | #define TLV_BODY_OFF 2 /* body offset */ | |
45 | #define TLV_OUI_LEN 3 /* oui id length */ | |
46 | ||
47 | /* 802.11 Mgmt Packet flags */ | |
48 | #define BRCMF_VNDR_IE_BEACON_FLAG 0x1 | |
49 | #define BRCMF_VNDR_IE_PRBRSP_FLAG 0x2 | |
50 | #define BRCMF_VNDR_IE_ASSOCRSP_FLAG 0x4 | |
51 | #define BRCMF_VNDR_IE_AUTHRSP_FLAG 0x8 | |
52 | #define BRCMF_VNDR_IE_PRBREQ_FLAG 0x10 | |
53 | #define BRCMF_VNDR_IE_ASSOCREQ_FLAG 0x20 | |
54 | /* vendor IE in IW advertisement protocol ID field */ | |
55 | #define BRCMF_VNDR_IE_IWAPID_FLAG 0x40 | |
56 | /* allow custom IE id */ | |
57 | #define BRCMF_VNDR_IE_CUSTOM_FLAG 0x100 | |
58 | ||
59 | /* P2P Action Frames flags (spec ordered) */ | |
60 | #define BRCMF_VNDR_IE_GONREQ_FLAG 0x001000 | |
61 | #define BRCMF_VNDR_IE_GONRSP_FLAG 0x002000 | |
62 | #define BRCMF_VNDR_IE_GONCFM_FLAG 0x004000 | |
63 | #define BRCMF_VNDR_IE_INVREQ_FLAG 0x008000 | |
64 | #define BRCMF_VNDR_IE_INVRSP_FLAG 0x010000 | |
65 | #define BRCMF_VNDR_IE_DISREQ_FLAG 0x020000 | |
66 | #define BRCMF_VNDR_IE_DISRSP_FLAG 0x040000 | |
67 | #define BRCMF_VNDR_IE_PRDREQ_FLAG 0x080000 | |
68 | #define BRCMF_VNDR_IE_PRDRSP_FLAG 0x100000 | |
69 | ||
70 | #define BRCMF_VNDR_IE_P2PAF_SHIFT 12 | |
71 | ||
118eb304 HM |
72 | #define BRCMF_MAX_DEFAULT_KEYS 4 |
73 | ||
1119e23e HM |
74 | /* beacon loss timeout defaults */ |
75 | #define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_ON 2 | |
76 | #define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_OFF 4 | |
9f440b7b | 77 | |
c1179033 | 78 | /** |
1687eee2 | 79 | * enum brcmf_scan_status - scan engine status |
c1179033 AS |
80 | * |
81 | * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle. | |
82 | * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle. | |
1687eee2 | 83 | * @BRCMF_SCAN_STATUS_SUPPRESS: scanning is suppressed in driver. |
c1179033 AS |
84 | */ |
85 | enum brcmf_scan_status { | |
86 | BRCMF_SCAN_STATUS_BUSY, | |
87 | BRCMF_SCAN_STATUS_ABORT, | |
1687eee2 | 88 | BRCMF_SCAN_STATUS_SUPPRESS, |
5b435de0 AS |
89 | }; |
90 | ||
5b435de0 AS |
91 | /* dongle configuration */ |
92 | struct brcmf_cfg80211_conf { | |
5b435de0 AS |
93 | u32 frag_threshold; |
94 | u32 rts_threshold; | |
95 | u32 retry_short; | |
96 | u32 retry_long; | |
5b435de0 AS |
97 | }; |
98 | ||
5b435de0 AS |
99 | /* security information with currently associated ap */ |
100 | struct brcmf_cfg80211_security { | |
101 | u32 wpa_versions; | |
102 | u32 auth_type; | |
103 | u32 cipher_pairwise; | |
104 | u32 cipher_group; | |
105 | u32 wpa_auth; | |
106 | }; | |
107 | ||
3bc0a96c AS |
108 | /** |
109 | * struct brcmf_cfg80211_profile - profile information. | |
110 | * | |
3bc0a96c AS |
111 | * @bssid: bssid of joined/joining ibss. |
112 | * @sec: security information. | |
118eb304 | 113 | * @key: key information |
3bc0a96c | 114 | */ |
5b435de0 | 115 | struct brcmf_cfg80211_profile { |
5b435de0 | 116 | u8 bssid[ETH_ALEN]; |
5b435de0 | 117 | struct brcmf_cfg80211_security sec; |
118eb304 | 118 | struct brcmf_wsec_key key[BRCMF_MAX_DEFAULT_KEYS]; |
5b435de0 AS |
119 | }; |
120 | ||
c1179033 AS |
121 | /** |
122 | * enum brcmf_vif_status - bit indices for vif status. | |
123 | * | |
124 | * @BRCMF_VIF_STATUS_READY: ready for operation. | |
125 | * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress. | |
126 | * @BRCMF_VIF_STATUS_CONNECTED: connected/joined succesfully. | |
5f4f9f11 | 127 | * @BRCMF_VIF_STATUS_DISCONNECTING: disconnect/disable in progress. |
c1179033 AS |
128 | * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started. |
129 | */ | |
130 | enum brcmf_vif_status { | |
131 | BRCMF_VIF_STATUS_READY, | |
132 | BRCMF_VIF_STATUS_CONNECTING, | |
133 | BRCMF_VIF_STATUS_CONNECTED, | |
5f4f9f11 | 134 | BRCMF_VIF_STATUS_DISCONNECTING, |
c1179033 AS |
135 | BRCMF_VIF_STATUS_AP_CREATED |
136 | }; | |
137 | ||
8ff5dc92 AS |
138 | /** |
139 | * struct vif_saved_ie - holds saved IEs for a virtual interface. | |
140 | * | |
9f440b7b | 141 | * @probe_req_ie: IE info for probe request. |
8ff5dc92 AS |
142 | * @probe_res_ie: IE info for probe response. |
143 | * @beacon_ie: IE info for beacon frame. | |
9f440b7b | 144 | * @probe_req_ie_len: IE info length for probe request. |
8ff5dc92 AS |
145 | * @probe_res_ie_len: IE info length for probe response. |
146 | * @beacon_ie_len: IE info length for beacon frame. | |
147 | */ | |
148 | struct vif_saved_ie { | |
dae3a273 | 149 | u8 probe_req_ie[IE_MAX_LEN]; |
8ff5dc92 AS |
150 | u8 probe_res_ie[IE_MAX_LEN]; |
151 | u8 beacon_ie[IE_MAX_LEN]; | |
89286dc9 | 152 | u8 assoc_req_ie[IE_MAX_LEN]; |
9f440b7b | 153 | u32 probe_req_ie_len; |
8ff5dc92 AS |
154 | u32 probe_res_ie_len; |
155 | u32 beacon_ie_len; | |
89286dc9 | 156 | u32 assoc_req_ie_len; |
8ff5dc92 AS |
157 | }; |
158 | ||
3eacf866 AS |
159 | /** |
160 | * struct brcmf_cfg80211_vif - virtual interface specific information. | |
161 | * | |
162 | * @ifp: lower layer interface pointer | |
163 | * @wdev: wireless device. | |
6ac4f4ed | 164 | * @profile: profile information. |
c1179033 | 165 | * @sme_state: SME state using enum brcmf_vif_status bits. |
3eacf866 AS |
166 | * @pm_block: power-management blocked. |
167 | * @list: linked list. | |
0de8aace | 168 | * @mgmt_rx_reg: registered rx mgmt frame types. |
a44aa400 | 169 | * @mbss: Multiple BSS type, set if not first AP (not relevant for P2P). |
3eacf866 AS |
170 | */ |
171 | struct brcmf_cfg80211_vif { | |
172 | struct brcmf_if *ifp; | |
173 | struct wireless_dev wdev; | |
6ac4f4ed | 174 | struct brcmf_cfg80211_profile profile; |
c1179033 | 175 | unsigned long sme_state; |
3eacf866 | 176 | bool pm_block; |
8ff5dc92 | 177 | struct vif_saved_ie saved_ie; |
3eacf866 | 178 | struct list_head list; |
0de8aace | 179 | u16 mgmt_rx_reg; |
a44aa400 | 180 | bool mbss; |
98027769 | 181 | int is_11d; |
3eacf866 AS |
182 | }; |
183 | ||
5b435de0 AS |
184 | /* association inform */ |
185 | struct brcmf_cfg80211_connect_info { | |
186 | u8 *req_ie; | |
187 | s32 req_ie_len; | |
188 | u8 *resp_ie; | |
189 | s32 resp_ie_len; | |
190 | }; | |
191 | ||
192 | /* assoc ie length */ | |
c4e382d2 AS |
193 | struct brcmf_cfg80211_assoc_ielen_le { |
194 | __le32 req_len; | |
195 | __le32 resp_len; | |
5b435de0 AS |
196 | }; |
197 | ||
e756af5b HM |
198 | /* dongle escan state */ |
199 | enum wl_escan_state { | |
200 | WL_ESCAN_STATE_IDLE, | |
201 | WL_ESCAN_STATE_SCANNING | |
202 | }; | |
203 | ||
204 | struct escan_info { | |
205 | u32 escan_state; | |
206 | u8 escan_buf[WL_ESCAN_BUF_SIZE]; | |
207 | struct wiphy *wiphy; | |
a0f472ac AS |
208 | struct brcmf_if *ifp; |
209 | s32 (*run)(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp, | |
c4958106 | 210 | struct cfg80211_scan_request *request); |
e756af5b HM |
211 | }; |
212 | ||
d3c0b633 AS |
213 | /** |
214 | * struct brcmf_cfg80211_vif_event - virtual interface event information. | |
215 | * | |
216 | * @vif_wq: waitqueue awaiting interface event from firmware. | |
217 | * @vif_event_lock: protects other members in this structure. | |
218 | * @vif_complete: completion for net attach. | |
219 | * @action: either add, change, or delete. | |
220 | * @vif: virtual interface object related to the event. | |
221 | */ | |
222 | struct brcmf_cfg80211_vif_event { | |
223 | wait_queue_head_t vif_wq; | |
224 | struct mutex vif_event_lock; | |
d3c0b633 AS |
225 | u8 action; |
226 | struct brcmf_cfg80211_vif *vif; | |
227 | }; | |
228 | ||
02030eb6 | 229 | /** |
27a68fe3 | 230 | * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface |
02030eb6 | 231 | * |
3eacf866 | 232 | * @wiphy: wiphy object for cfg80211 interface. |
02030eb6 | 233 | * @conf: dongle configuration. |
9f440b7b | 234 | * @p2p: peer-to-peer specific information. |
61730d4d | 235 | * @btcoex: Bluetooth coexistence information. |
02030eb6 | 236 | * @scan_request: cfg80211 scan request object. |
02030eb6 AS |
237 | * @usr_sync: mainly for dongle up/down synchronization. |
238 | * @bss_list: bss_list holding scanned ap information. | |
02030eb6 | 239 | * @bss_info: bss information for cfg80211 layer. |
02030eb6 AS |
240 | * @conn_info: association info. |
241 | * @pmk_list: wpa2 pmk list. | |
c1179033 | 242 | * @scan_status: scan activity on the dongle. |
02030eb6 AS |
243 | * @pub: common driver information. |
244 | * @channel: current channel. | |
02030eb6 AS |
245 | * @active_scan: current scan mode. |
246 | * @sched_escan: e-scan for scheduled scan support running. | |
247 | * @ibss_starter: indicates this sta is ibss starter. | |
02030eb6 AS |
248 | * @pwr_save: indicate whether dongle to support power save mode. |
249 | * @dongle_up: indicate whether dongle up or not. | |
250 | * @roam_on: on/off switch for dongle self-roaming. | |
251 | * @scan_tried: indicates if first scan attempted. | |
252 | * @dcmd_buf: dcmd buffer. | |
253 | * @extra_buf: mainly to grab assoc information. | |
254 | * @debugfsdir: debugfs folder for this device. | |
02030eb6 AS |
255 | * @escan_info: escan information. |
256 | * @escan_timeout: Timer for catch scan timeout. | |
257 | * @escan_timeout_work: scan timeout worker. | |
258 | * @escan_ioctl_buf: dongle command buffer for escan commands. | |
3eacf866 AS |
259 | * @vif_list: linked list of vif instances. |
260 | * @vif_cnt: number of vif instances. | |
d3c0b633 | 261 | * @vif_event: vif event signalling. |
4eb3af7c HM |
262 | * @wowl_enabled; set during suspend, is wowl used. |
263 | * @pre_wowl_pmmode: intermediate storage of pm mode during wowl. | |
02030eb6 | 264 | */ |
27a68fe3 | 265 | struct brcmf_cfg80211_info { |
3eacf866 | 266 | struct wiphy *wiphy; |
02030eb6 | 267 | struct brcmf_cfg80211_conf *conf; |
9f440b7b | 268 | struct brcmf_p2p_info p2p; |
61730d4d | 269 | struct brcmf_btcoex_info *btcoex; |
02030eb6 | 270 | struct cfg80211_scan_request *scan_request; |
02030eb6 | 271 | struct mutex usr_sync; |
02030eb6 | 272 | struct wl_cfg80211_bss_info *bss_info; |
02030eb6 | 273 | struct brcmf_cfg80211_connect_info conn_info; |
6c404f34 | 274 | struct brcmf_pmk_list_le pmk_list; |
c1179033 | 275 | unsigned long scan_status; |
ee928381 | 276 | struct brcmf_pub *pub; |
02030eb6 | 277 | u32 channel; |
02030eb6 AS |
278 | bool active_scan; |
279 | bool sched_escan; | |
280 | bool ibss_starter; | |
02030eb6 AS |
281 | bool pwr_save; |
282 | bool dongle_up; | |
02030eb6 AS |
283 | bool scan_tried; |
284 | u8 *dcmd_buf; | |
285 | u8 *extra_buf; | |
5b435de0 | 286 | struct dentry *debugfsdir; |
02030eb6 AS |
287 | struct escan_info escan_info; |
288 | struct timer_list escan_timeout; | |
289 | struct work_struct escan_timeout_work; | |
e756af5b | 290 | u8 *escan_ioctl_buf; |
3eacf866 | 291 | struct list_head vif_list; |
d3c0b633 | 292 | struct brcmf_cfg80211_vif_event vif_event; |
5f4f9f11 | 293 | struct completion vif_disabled; |
83cf17aa | 294 | struct brcmu_d11inf d11inf; |
4eb3af7c HM |
295 | bool wowl_enabled; |
296 | u32 pre_wowl_pmmode; | |
bf2a7e04 | 297 | struct brcmf_assoclist_le assoclist; |
5b435de0 AS |
298 | }; |
299 | ||
9f440b7b AS |
300 | /** |
301 | * struct brcmf_tlv - tag_ID/length/value_buffer tuple. | |
302 | * | |
303 | * @id: tag identifier. | |
304 | * @len: number of bytes in value buffer. | |
305 | * @data: value buffer. | |
306 | */ | |
307 | struct brcmf_tlv { | |
308 | u8 id; | |
309 | u8 len; | |
310 | u8 data[1]; | |
311 | }; | |
312 | ||
3eacf866 | 313 | static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg) |
5b435de0 | 314 | { |
3eacf866 | 315 | return cfg->wiphy; |
5b435de0 AS |
316 | } |
317 | ||
27a68fe3 | 318 | static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w) |
5b435de0 | 319 | { |
27a68fe3 | 320 | return (struct brcmf_cfg80211_info *)(wiphy_priv(w)); |
5b435de0 AS |
321 | } |
322 | ||
27a68fe3 | 323 | static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd) |
5b435de0 | 324 | { |
27a68fe3 | 325 | return (struct brcmf_cfg80211_info *)(wdev_priv(wd)); |
5b435de0 AS |
326 | } |
327 | ||
3eacf866 AS |
328 | static inline |
329 | struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg) | |
5b435de0 | 330 | { |
3eacf866 AS |
331 | struct brcmf_cfg80211_vif *vif; |
332 | vif = list_first_entry(&cfg->vif_list, struct brcmf_cfg80211_vif, list); | |
333 | return vif->wdev.netdev; | |
5b435de0 AS |
334 | } |
335 | ||
27a68fe3 | 336 | static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev) |
5b435de0 AS |
337 | { |
338 | return wdev_to_cfg(ndev->ieee80211_ptr); | |
339 | } | |
340 | ||
6ac4f4ed AS |
341 | static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd) |
342 | { | |
343 | struct brcmf_if *ifp = netdev_priv(nd); | |
344 | return &ifp->vif->profile; | |
345 | } | |
346 | ||
1332e26e AS |
347 | static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev) |
348 | { | |
349 | struct brcmf_if *ifp = netdev_priv(ndev); | |
350 | return ifp->vif; | |
351 | } | |
352 | ||
5b435de0 | 353 | static inline struct |
27a68fe3 | 354 | brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg) |
5b435de0 AS |
355 | { |
356 | return &cfg->conn_info; | |
357 | } | |
358 | ||
d9cb2596 | 359 | struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr, |
ae7c03f6 HM |
360 | struct device *busdev, |
361 | bool p2pdev_forced); | |
27a68fe3 | 362 | void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg); |
bdf5ff51 AS |
363 | s32 brcmf_cfg80211_up(struct net_device *ndev); |
364 | s32 brcmf_cfg80211_down(struct net_device *ndev); | |
a7965fbb | 365 | enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp); |
5b435de0 | 366 | |
9f440b7b | 367 | struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg, |
9f440b7b AS |
368 | enum nl80211_iftype type, |
369 | bool pm_block); | |
427dec5f | 370 | void brcmf_free_vif(struct brcmf_cfg80211_vif *vif); |
9f440b7b AS |
371 | |
372 | s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag, | |
373 | const u8 *vndr_ie_buf, u32 vndr_ie_len); | |
5f4f9f11 | 374 | s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif); |
4b5800fe JB |
375 | const struct brcmf_tlv * |
376 | brcmf_parse_tlvs(const void *buf, int buflen, uint key); | |
83cf17aa FL |
377 | u16 channel_to_chanspec(struct brcmu_d11inf *d11inf, |
378 | struct ieee80211_channel *ch); | |
bfe81975 HM |
379 | bool brcmf_get_vif_state_any(struct brcmf_cfg80211_info *cfg, |
380 | unsigned long state); | |
d3c0b633 AS |
381 | void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg, |
382 | struct brcmf_cfg80211_vif *vif); | |
383 | bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg); | |
384 | int brcmf_cfg80211_wait_vif_event_timeout(struct brcmf_cfg80211_info *cfg, | |
385 | u8 action, ulong timeout); | |
7a5c1f64 | 386 | s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg, |
a0f472ac AS |
387 | struct brcmf_if *ifp, bool aborted, |
388 | bool fw_abort); | |
f96aa07e | 389 | void brcmf_set_mpc(struct brcmf_if *ndev, int mpc); |
18e2f61d | 390 | void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg); |
9df4d542 | 391 | void brcmf_cfg80211_free_netdev(struct net_device *ndev); |
9f440b7b | 392 | |
bfe81975 | 393 | #endif /* BRCMFMAC_CFG80211_H */ |