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