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>
24 #include "fwil_types.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)
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 {
110 /* security information with currently associated ap */
111 struct brcmf_cfg80211_security {
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 {
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;
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;
203 /* association inform */
204 struct brcmf_cfg80211_connect_info {
211 /* assoc ie length */
212 struct brcmf_cfg80211_assoc_ielen_le {
217 /* dongle escan state */
218 enum wl_escan_state {
220 WL_ESCAN_STATE_SCANNING
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;
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 {
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;
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 * @active_scan: current scan mode.
287 * @int_escan_map: bucket map for which internal e-scan is done.
288 * @ibss_starter: indicates this sta is ibss starter.
289 * @pwr_save: indicate whether dongle to support power save mode.
290 * @dongle_up: indicate whether dongle up or not.
291 * @roam_on: on/off switch for dongle self-roaming.
292 * @scan_tried: indicates if first scan attempted.
293 * @dcmd_buf: dcmd buffer.
294 * @extra_buf: mainly to grab assoc information.
295 * @debugfsdir: debugfs folder for this device.
296 * @escan_info: escan information.
297 * @escan_timeout: Timer for catch scan timeout.
298 * @escan_timeout_work: scan timeout worker.
299 * @vif_list: linked list of vif instances.
300 * @vif_cnt: number of vif instances.
301 * @vif_event: vif event signalling.
302 * @wowl: wowl related information.
303 * @pno: information of pno module.
305 struct brcmf_cfg80211_info {
307 struct cfg80211_ops *ops;
308 struct brcmf_cfg80211_conf *conf;
309 struct brcmf_p2p_info p2p;
310 struct brcmf_btcoex_info *btcoex;
311 struct cfg80211_scan_request *scan_request;
312 struct mutex usr_sync;
313 struct wl_cfg80211_bss_info *bss_info;
314 struct brcmf_cfg80211_connect_info conn_info;
315 struct brcmf_pmk_list_le pmk_list;
316 unsigned long scan_status;
317 struct brcmf_pub *pub;
327 struct dentry *debugfsdir;
328 struct escan_info escan_info;
329 struct timer_list escan_timeout;
330 struct work_struct escan_timeout_work;
331 struct list_head vif_list;
332 struct brcmf_cfg80211_vif_event vif_event;
333 struct completion vif_disabled;
334 struct brcmu_d11inf d11inf;
335 struct brcmf_assoclist_le assoclist;
336 struct brcmf_cfg80211_wowl wowl;
337 struct brcmf_pno_info *pno;
341 * struct brcmf_tlv - tag_ID/length/value_buffer tuple.
343 * @id: tag identifier.
344 * @len: number of bytes in value buffer.
345 * @data: value buffer.
353 static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
358 static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
360 return (struct brcmf_cfg80211_info *)(wiphy_priv(w));
363 static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
365 return (struct brcmf_cfg80211_info *)(wdev_priv(wd));
369 struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
371 struct brcmf_cfg80211_vif *vif;
372 vif = list_first_entry(&cfg->vif_list, struct brcmf_cfg80211_vif, list);
373 return vif->wdev.netdev;
376 static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
378 return wdev_to_cfg(ndev->ieee80211_ptr);
381 static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
383 struct brcmf_if *ifp = netdev_priv(nd);
384 return &ifp->vif->profile;
387 static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
389 struct brcmf_if *ifp = netdev_priv(ndev);
394 brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
396 return &cfg->conn_info;
399 struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
400 struct device *busdev,
402 void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
403 s32 brcmf_cfg80211_up(struct net_device *ndev);
404 s32 brcmf_cfg80211_down(struct net_device *ndev);
405 enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp);
407 struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
408 enum nl80211_iftype type);
409 void brcmf_free_vif(struct brcmf_cfg80211_vif *vif);
411 s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag,
412 const u8 *vndr_ie_buf, u32 vndr_ie_len);
413 s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif);
414 u16 channel_to_chanspec(struct brcmu_d11inf *d11inf,
415 struct ieee80211_channel *ch);
416 bool brcmf_get_vif_state_any(struct brcmf_cfg80211_info *cfg,
417 unsigned long state);
418 void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg,
419 struct brcmf_cfg80211_vif *vif);
420 bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg);
421 int brcmf_cfg80211_wait_vif_event(struct brcmf_cfg80211_info *cfg,
422 u8 action, ulong timeout);
423 s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
424 struct brcmf_if *ifp, bool aborted,
426 void brcmf_set_mpc(struct brcmf_if *ndev, int mpc);
427 void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg);
428 void brcmf_cfg80211_free_netdev(struct net_device *ndev);
430 #endif /* BRCMFMAC_CFG80211_H */