Linux 4.19.133
[linux/fpc-iii.git] / drivers / net / wireless / broadcom / brcm80211 / brcmfmac / cfg80211.h
blob9a6287f084a928324ebf04e663f0d309f0c42361
1 /*
2 * Copyright (c) 2010 Broadcom Corporation
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.
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.
17 #ifndef BRCMFMAC_CFG80211_H
18 #define BRCMFMAC_CFG80211_H
20 /* for brcmu_d11inf */
21 #include <brcmu_d11.h>
23 #include "core.h"
24 #include "fwil_types.h"
25 #include "p2p.h"
27 #define BRCMF_SCAN_IE_LEN_MAX 2048
29 #define WL_NUM_SCAN_MAX 10
30 #define WL_TLV_INFO_MAX 1024
31 #define WL_BSS_INFO_MAX 2048
32 #define WL_ASSOC_INFO_MAX 512 /* assoc related fil max buf */
33 #define WL_EXTRA_BUF_MAX 2048
34 #define WL_ROAM_TRIGGER_LEVEL -75
35 #define WL_ROAM_DELTA 20
37 /* Keep BRCMF_ESCAN_BUF_SIZE below 64K (65536). Allocing over 64K can be
38 * problematic on some systems and should be avoided.
40 #define BRCMF_ESCAN_BUF_SIZE 65000
41 #define BRCMF_ESCAN_TIMER_INTERVAL_MS 10000 /* E-Scan timeout */
43 #define WL_ESCAN_ACTION_START 1
44 #define WL_ESCAN_ACTION_CONTINUE 2
45 #define WL_ESCAN_ACTION_ABORT 3
47 #define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */
48 #define IE_MAX_LEN 512
50 /* IE TLV processing */
51 #define TLV_LEN_OFF 1 /* length offset */
52 #define TLV_HDR_LEN 2 /* header length */
53 #define TLV_BODY_OFF 2 /* body offset */
54 #define TLV_OUI_LEN 3 /* oui id length */
56 /* 802.11 Mgmt Packet flags */
57 #define BRCMF_VNDR_IE_BEACON_FLAG 0x1
58 #define BRCMF_VNDR_IE_PRBRSP_FLAG 0x2
59 #define BRCMF_VNDR_IE_ASSOCRSP_FLAG 0x4
60 #define BRCMF_VNDR_IE_AUTHRSP_FLAG 0x8
61 #define BRCMF_VNDR_IE_PRBREQ_FLAG 0x10
62 #define BRCMF_VNDR_IE_ASSOCREQ_FLAG 0x20
63 /* vendor IE in IW advertisement protocol ID field */
64 #define BRCMF_VNDR_IE_IWAPID_FLAG 0x40
65 /* allow custom IE id */
66 #define BRCMF_VNDR_IE_CUSTOM_FLAG 0x100
68 /* P2P Action Frames flags (spec ordered) */
69 #define BRCMF_VNDR_IE_GONREQ_FLAG 0x001000
70 #define BRCMF_VNDR_IE_GONRSP_FLAG 0x002000
71 #define BRCMF_VNDR_IE_GONCFM_FLAG 0x004000
72 #define BRCMF_VNDR_IE_INVREQ_FLAG 0x008000
73 #define BRCMF_VNDR_IE_INVRSP_FLAG 0x010000
74 #define BRCMF_VNDR_IE_DISREQ_FLAG 0x020000
75 #define BRCMF_VNDR_IE_DISRSP_FLAG 0x040000
76 #define BRCMF_VNDR_IE_PRDREQ_FLAG 0x080000
77 #define BRCMF_VNDR_IE_PRDRSP_FLAG 0x100000
79 #define BRCMF_VNDR_IE_P2PAF_SHIFT 12
81 #define BRCMF_MAX_DEFAULT_KEYS 6
83 /* beacon loss timeout defaults */
84 #define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_ON 2
85 #define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_OFF 4
87 #define BRCMF_VIF_EVENT_TIMEOUT msecs_to_jiffies(1500)
89 /**
90 * enum brcmf_scan_status - scan engine status
92 * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.
93 * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.
94 * @BRCMF_SCAN_STATUS_SUPPRESS: scanning is suppressed in driver.
96 enum brcmf_scan_status {
97 BRCMF_SCAN_STATUS_BUSY,
98 BRCMF_SCAN_STATUS_ABORT,
99 BRCMF_SCAN_STATUS_SUPPRESS,
102 /* dongle configuration */
103 struct brcmf_cfg80211_conf {
104 u32 frag_threshold;
105 u32 rts_threshold;
106 u32 retry_short;
107 u32 retry_long;
110 /* security information with currently associated ap */
111 struct brcmf_cfg80211_security {
112 u32 wpa_versions;
113 u32 auth_type;
114 u32 cipher_pairwise;
115 u32 cipher_group;
118 enum brcmf_profile_fwsup {
119 BRCMF_PROFILE_FWSUP_NONE,
120 BRCMF_PROFILE_FWSUP_PSK,
121 BRCMF_PROFILE_FWSUP_1X
125 * struct brcmf_cfg80211_profile - profile information.
127 * @bssid: bssid of joined/joining ibss.
128 * @sec: security information.
129 * @key: key information
131 struct brcmf_cfg80211_profile {
132 u8 bssid[ETH_ALEN];
133 struct brcmf_cfg80211_security sec;
134 struct brcmf_wsec_key key[BRCMF_MAX_DEFAULT_KEYS];
135 enum brcmf_profile_fwsup use_fwsup;
139 * enum brcmf_vif_status - bit indices for vif status.
141 * @BRCMF_VIF_STATUS_READY: ready for operation.
142 * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress.
143 * @BRCMF_VIF_STATUS_CONNECTED: connected/joined successfully.
144 * @BRCMF_VIF_STATUS_DISCONNECTING: disconnect/disable in progress.
145 * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started.
146 * @BRCMF_VIF_STATUS_EAP_SUCCUSS: EAPOL handshake successful.
147 * @BRCMF_VIF_STATUS_ASSOC_SUCCESS: successful SET_SSID received.
149 enum brcmf_vif_status {
150 BRCMF_VIF_STATUS_READY,
151 BRCMF_VIF_STATUS_CONNECTING,
152 BRCMF_VIF_STATUS_CONNECTED,
153 BRCMF_VIF_STATUS_DISCONNECTING,
154 BRCMF_VIF_STATUS_AP_CREATED,
155 BRCMF_VIF_STATUS_EAP_SUCCESS,
156 BRCMF_VIF_STATUS_ASSOC_SUCCESS,
160 * struct vif_saved_ie - holds saved IEs for a virtual interface.
162 * @probe_req_ie: IE info for probe request.
163 * @probe_res_ie: IE info for probe response.
164 * @beacon_ie: IE info for beacon frame.
165 * @probe_req_ie_len: IE info length for probe request.
166 * @probe_res_ie_len: IE info length for probe response.
167 * @beacon_ie_len: IE info length for beacon frame.
169 struct vif_saved_ie {
170 u8 probe_req_ie[IE_MAX_LEN];
171 u8 probe_res_ie[IE_MAX_LEN];
172 u8 beacon_ie[IE_MAX_LEN];
173 u8 assoc_req_ie[IE_MAX_LEN];
174 u32 probe_req_ie_len;
175 u32 probe_res_ie_len;
176 u32 beacon_ie_len;
177 u32 assoc_req_ie_len;
181 * struct brcmf_cfg80211_vif - virtual interface specific information.
183 * @ifp: lower layer interface pointer
184 * @wdev: wireless device.
185 * @profile: profile information.
186 * @sme_state: SME state using enum brcmf_vif_status bits.
187 * @list: linked list.
188 * @mgmt_rx_reg: registered rx mgmt frame types.
189 * @mbss: Multiple BSS type, set if not first AP (not relevant for P2P).
191 struct brcmf_cfg80211_vif {
192 struct brcmf_if *ifp;
193 struct wireless_dev wdev;
194 struct brcmf_cfg80211_profile profile;
195 unsigned long sme_state;
196 struct vif_saved_ie saved_ie;
197 struct list_head list;
198 u16 mgmt_rx_reg;
199 bool mbss;
200 int is_11d;
203 /* association inform */
204 struct brcmf_cfg80211_connect_info {
205 u8 *req_ie;
206 s32 req_ie_len;
207 u8 *resp_ie;
208 s32 resp_ie_len;
211 /* assoc ie length */
212 struct brcmf_cfg80211_assoc_ielen_le {
213 __le32 req_len;
214 __le32 resp_len;
217 /* dongle escan state */
218 enum wl_escan_state {
219 WL_ESCAN_STATE_IDLE,
220 WL_ESCAN_STATE_SCANNING
223 struct escan_info {
224 u32 escan_state;
225 u8 *escan_buf;
226 struct wiphy *wiphy;
227 struct brcmf_if *ifp;
228 s32 (*run)(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp,
229 struct cfg80211_scan_request *request);
233 * struct brcmf_cfg80211_vif_event - virtual interface event information.
235 * @vif_wq: waitqueue awaiting interface event from firmware.
236 * @vif_event_lock: protects other members in this structure.
237 * @vif_complete: completion for net attach.
238 * @action: either add, change, or delete.
239 * @vif: virtual interface object related to the event.
241 struct brcmf_cfg80211_vif_event {
242 wait_queue_head_t vif_wq;
243 spinlock_t vif_event_lock;
244 u8 action;
245 struct brcmf_cfg80211_vif *vif;
249 * struct brcmf_cfg80211_wowl - wowl related information.
251 * @active: set on suspend, cleared on resume.
252 * @pre_pmmode: firmware PM mode at entering suspend.
253 * @nd: net dectect data.
254 * @nd_info: helper struct to pass to cfg80211.
255 * @nd_data_wait: wait queue to sync net detect data.
256 * @nd_data_completed: completion for net detect data.
257 * @nd_enabled: net detect enabled.
259 struct brcmf_cfg80211_wowl {
260 bool active;
261 u32 pre_pmmode;
262 struct cfg80211_wowlan_nd_match *nd;
263 struct cfg80211_wowlan_nd_info *nd_info;
264 wait_queue_head_t nd_data_wait;
265 bool nd_data_completed;
266 bool nd_enabled;
270 * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface
272 * @wiphy: wiphy object for cfg80211 interface.
273 * @ops: pointer to copy of ops as registered with wiphy object.
274 * @conf: dongle configuration.
275 * @p2p: peer-to-peer specific information.
276 * @btcoex: Bluetooth coexistence information.
277 * @scan_request: cfg80211 scan request object.
278 * @usr_sync: mainly for dongle up/down synchronization.
279 * @bss_list: bss_list holding scanned ap information.
280 * @bss_info: bss information for cfg80211 layer.
281 * @conn_info: association info.
282 * @pmk_list: wpa2 pmk list.
283 * @scan_status: scan activity on the dongle.
284 * @pub: common driver information.
285 * @channel: current channel.
286 * @int_escan_map: bucket map for which internal e-scan is done.
287 * @ibss_starter: indicates this sta is ibss starter.
288 * @pwr_save: indicate whether dongle to support power save mode.
289 * @dongle_up: indicate whether dongle up or not.
290 * @roam_on: on/off switch for dongle self-roaming.
291 * @scan_tried: indicates if first scan attempted.
292 * @dcmd_buf: dcmd buffer.
293 * @extra_buf: mainly to grab assoc information.
294 * @debugfsdir: debugfs folder for this device.
295 * @escan_info: escan information.
296 * @escan_timeout: Timer for catch scan timeout.
297 * @escan_timeout_work: scan timeout worker.
298 * @vif_list: linked list of vif instances.
299 * @vif_cnt: number of vif instances.
300 * @vif_event: vif event signalling.
301 * @wowl: wowl related information.
302 * @pno: information of pno module.
304 struct brcmf_cfg80211_info {
305 struct wiphy *wiphy;
306 struct cfg80211_ops *ops;
307 struct brcmf_cfg80211_conf *conf;
308 struct brcmf_p2p_info p2p;
309 struct brcmf_btcoex_info *btcoex;
310 struct cfg80211_scan_request *scan_request;
311 struct mutex usr_sync;
312 struct wl_cfg80211_bss_info *bss_info;
313 struct brcmf_cfg80211_connect_info conn_info;
314 struct brcmf_pmk_list_le pmk_list;
315 unsigned long scan_status;
316 struct brcmf_pub *pub;
317 u32 channel;
318 u32 int_escan_map;
319 bool ibss_starter;
320 bool pwr_save;
321 bool dongle_up;
322 bool scan_tried;
323 u8 *dcmd_buf;
324 u8 *extra_buf;
325 struct dentry *debugfsdir;
326 struct escan_info escan_info;
327 struct timer_list escan_timeout;
328 struct work_struct escan_timeout_work;
329 struct list_head vif_list;
330 struct brcmf_cfg80211_vif_event vif_event;
331 struct completion vif_disabled;
332 struct brcmu_d11inf d11inf;
333 struct brcmf_assoclist_le assoclist;
334 struct brcmf_cfg80211_wowl wowl;
335 struct brcmf_pno_info *pno;
339 * struct brcmf_tlv - tag_ID/length/value_buffer tuple.
341 * @id: tag identifier.
342 * @len: number of bytes in value buffer.
343 * @data: value buffer.
345 struct brcmf_tlv {
346 u8 id;
347 u8 len;
348 u8 data[1];
351 static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
353 return cfg->wiphy;
356 static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
358 struct brcmf_pub *drvr = wiphy_priv(w);
359 return drvr->config;
362 static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
364 return wiphy_to_cfg(wd->wiphy);
367 static inline struct brcmf_cfg80211_vif *wdev_to_vif(struct wireless_dev *wdev)
369 return container_of(wdev, struct brcmf_cfg80211_vif, wdev);
372 static inline
373 struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
375 return brcmf_get_ifp(cfg->pub, 0)->ndev;
378 static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
380 return wdev_to_cfg(ndev->ieee80211_ptr);
383 static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
385 struct brcmf_if *ifp = netdev_priv(nd);
386 return &ifp->vif->profile;
389 static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
391 struct brcmf_if *ifp = netdev_priv(ndev);
392 return ifp->vif;
395 static inline struct
396 brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
398 return &cfg->conn_info;
401 struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
402 struct cfg80211_ops *ops,
403 bool p2pdev_forced);
404 void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
405 s32 brcmf_cfg80211_up(struct net_device *ndev);
406 s32 brcmf_cfg80211_down(struct net_device *ndev);
407 struct cfg80211_ops *brcmf_cfg80211_get_ops(struct brcmf_mp_device *settings);
408 enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp);
410 struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
411 enum nl80211_iftype type);
412 void brcmf_free_vif(struct brcmf_cfg80211_vif *vif);
414 s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag,
415 const u8 *vndr_ie_buf, u32 vndr_ie_len);
416 s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif);
417 u16 channel_to_chanspec(struct brcmu_d11inf *d11inf,
418 struct ieee80211_channel *ch);
419 bool brcmf_get_vif_state_any(struct brcmf_cfg80211_info *cfg,
420 unsigned long state);
421 void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg,
422 struct brcmf_cfg80211_vif *vif);
423 bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg);
424 int brcmf_cfg80211_wait_vif_event(struct brcmf_cfg80211_info *cfg,
425 u8 action, ulong timeout);
426 s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
427 struct brcmf_if *ifp, bool aborted,
428 bool fw_abort);
429 void brcmf_set_mpc(struct brcmf_if *ndev, int mpc);
430 void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg);
431 void brcmf_cfg80211_free_netdev(struct net_device *ndev);
433 #endif /* BRCMFMAC_CFG80211_H */