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 #define WL_NUM_SCAN_MAX 10
24 #define WL_TLV_INFO_MAX 1024
25 #define WL_BSS_INFO_MAX 2048
26 #define WL_ASSOC_INFO_MAX 512 /* assoc related fil max buf */
27 #define WL_EXTRA_BUF_MAX 2048
28 #define WL_ROAM_TRIGGER_LEVEL -75
29 #define WL_ROAM_DELTA 20
31 #define WL_ESCAN_BUF_SIZE (1024 * 64)
32 #define WL_ESCAN_TIMER_INTERVAL_MS 10000 /* E-Scan timeout */
34 #define WL_ESCAN_ACTION_START 1
35 #define WL_ESCAN_ACTION_CONTINUE 2
36 #define WL_ESCAN_ACTION_ABORT 3
38 #define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */
39 #define IE_MAX_LEN 512
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 */
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
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
70 #define BRCMF_VNDR_IE_P2PAF_SHIFT 12
72 #define BRCMF_MAX_DEFAULT_KEYS 4
74 /* beacon loss timeout defaults */
75 #define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_ON 2
76 #define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_OFF 4
78 #define BRCMF_VIF_EVENT_TIMEOUT msecs_to_jiffies(1500)
81 * enum brcmf_scan_status - scan engine status
83 * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.
84 * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.
85 * @BRCMF_SCAN_STATUS_SUPPRESS: scanning is suppressed in driver.
87 enum brcmf_scan_status {
88 BRCMF_SCAN_STATUS_BUSY,
89 BRCMF_SCAN_STATUS_ABORT,
90 BRCMF_SCAN_STATUS_SUPPRESS,
93 /* dongle configuration */
94 struct brcmf_cfg80211_conf {
101 /* security information with currently associated ap */
102 struct brcmf_cfg80211_security {
111 * struct brcmf_cfg80211_profile - profile information.
113 * @bssid: bssid of joined/joining ibss.
114 * @sec: security information.
115 * @key: key information
117 struct brcmf_cfg80211_profile {
119 struct brcmf_cfg80211_security sec;
120 struct brcmf_wsec_key key[BRCMF_MAX_DEFAULT_KEYS];
124 * enum brcmf_vif_status - bit indices for vif status.
126 * @BRCMF_VIF_STATUS_READY: ready for operation.
127 * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress.
128 * @BRCMF_VIF_STATUS_CONNECTED: connected/joined succesfully.
129 * @BRCMF_VIF_STATUS_DISCONNECTING: disconnect/disable in progress.
130 * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started.
132 enum brcmf_vif_status {
133 BRCMF_VIF_STATUS_READY,
134 BRCMF_VIF_STATUS_CONNECTING,
135 BRCMF_VIF_STATUS_CONNECTED,
136 BRCMF_VIF_STATUS_DISCONNECTING,
137 BRCMF_VIF_STATUS_AP_CREATED
141 * struct vif_saved_ie - holds saved IEs for a virtual interface.
143 * @probe_req_ie: IE info for probe request.
144 * @probe_res_ie: IE info for probe response.
145 * @beacon_ie: IE info for beacon frame.
146 * @probe_req_ie_len: IE info length for probe request.
147 * @probe_res_ie_len: IE info length for probe response.
148 * @beacon_ie_len: IE info length for beacon frame.
150 struct vif_saved_ie {
151 u8 probe_req_ie[IE_MAX_LEN];
152 u8 probe_res_ie[IE_MAX_LEN];
153 u8 beacon_ie[IE_MAX_LEN];
154 u8 assoc_req_ie[IE_MAX_LEN];
155 u32 probe_req_ie_len;
156 u32 probe_res_ie_len;
158 u32 assoc_req_ie_len;
162 * struct brcmf_cfg80211_vif - virtual interface specific information.
164 * @ifp: lower layer interface pointer
165 * @wdev: wireless device.
166 * @profile: profile information.
167 * @sme_state: SME state using enum brcmf_vif_status bits.
168 * @pm_block: power-management blocked.
169 * @list: linked list.
170 * @mgmt_rx_reg: registered rx mgmt frame types.
171 * @mbss: Multiple BSS type, set if not first AP (not relevant for P2P).
173 struct brcmf_cfg80211_vif {
174 struct brcmf_if *ifp;
175 struct wireless_dev wdev;
176 struct brcmf_cfg80211_profile profile;
177 unsigned long sme_state;
179 struct vif_saved_ie saved_ie;
180 struct list_head list;
186 /* association inform */
187 struct brcmf_cfg80211_connect_info {
194 /* assoc ie length */
195 struct brcmf_cfg80211_assoc_ielen_le {
200 /* dongle escan state */
201 enum wl_escan_state {
203 WL_ESCAN_STATE_SCANNING
208 u8 escan_buf[WL_ESCAN_BUF_SIZE];
210 struct brcmf_if *ifp;
211 s32 (*run)(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp,
212 struct cfg80211_scan_request *request);
216 * struct brcmf_cfg80211_vif_event - virtual interface event information.
218 * @vif_wq: waitqueue awaiting interface event from firmware.
219 * @vif_event_lock: protects other members in this structure.
220 * @vif_complete: completion for net attach.
221 * @action: either add, change, or delete.
222 * @vif: virtual interface object related to the event.
224 struct brcmf_cfg80211_vif_event {
225 wait_queue_head_t vif_wq;
226 struct mutex vif_event_lock;
228 struct brcmf_cfg80211_vif *vif;
232 * struct brcmf_cfg80211_wowl - wowl related information.
234 * @active: set on suspend, cleared on resume.
235 * @pre_pmmode: firmware PM mode at entering suspend.
236 * @nd: net dectect data.
237 * @nd_info: helper struct to pass to cfg80211.
238 * @nd_data_wait: wait queue to sync net detect data.
239 * @nd_data_completed: completion for net detect data.
240 * @nd_enabled: net detect enabled.
242 struct brcmf_cfg80211_wowl {
245 struct cfg80211_wowlan_nd_match *nd;
246 struct cfg80211_wowlan_nd_info *nd_info;
247 wait_queue_head_t nd_data_wait;
248 bool nd_data_completed;
253 * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface
255 * @wiphy: wiphy object for cfg80211 interface.
256 * @conf: dongle configuration.
257 * @p2p: peer-to-peer specific information.
258 * @btcoex: Bluetooth coexistence information.
259 * @scan_request: cfg80211 scan request object.
260 * @usr_sync: mainly for dongle up/down synchronization.
261 * @bss_list: bss_list holding scanned ap information.
262 * @bss_info: bss information for cfg80211 layer.
263 * @conn_info: association info.
264 * @pmk_list: wpa2 pmk list.
265 * @scan_status: scan activity on the dongle.
266 * @pub: common driver information.
267 * @channel: current channel.
268 * @active_scan: current scan mode.
269 * @sched_escan: e-scan for scheduled scan support running.
270 * @ibss_starter: indicates this sta is ibss starter.
271 * @pwr_save: indicate whether dongle to support power save mode.
272 * @dongle_up: indicate whether dongle up or not.
273 * @roam_on: on/off switch for dongle self-roaming.
274 * @scan_tried: indicates if first scan attempted.
275 * @dcmd_buf: dcmd buffer.
276 * @extra_buf: mainly to grab assoc information.
277 * @debugfsdir: debugfs folder for this device.
278 * @escan_info: escan information.
279 * @escan_timeout: Timer for catch scan timeout.
280 * @escan_timeout_work: scan timeout worker.
281 * @escan_ioctl_buf: dongle command buffer for escan commands.
282 * @vif_list: linked list of vif instances.
283 * @vif_cnt: number of vif instances.
284 * @vif_event: vif event signalling.
285 * @wowl: wowl related information.
287 struct brcmf_cfg80211_info {
289 struct brcmf_cfg80211_conf *conf;
290 struct brcmf_p2p_info p2p;
291 struct brcmf_btcoex_info *btcoex;
292 struct cfg80211_scan_request *scan_request;
293 struct mutex usr_sync;
294 struct wl_cfg80211_bss_info *bss_info;
295 struct brcmf_cfg80211_connect_info conn_info;
296 struct brcmf_pmk_list_le pmk_list;
297 unsigned long scan_status;
298 struct brcmf_pub *pub;
308 struct dentry *debugfsdir;
309 struct escan_info escan_info;
310 struct timer_list escan_timeout;
311 struct work_struct escan_timeout_work;
313 struct list_head vif_list;
314 struct brcmf_cfg80211_vif_event vif_event;
315 struct completion vif_disabled;
316 struct brcmu_d11inf d11inf;
317 struct brcmf_assoclist_le assoclist;
318 struct brcmf_cfg80211_wowl wowl;
322 * struct brcmf_tlv - tag_ID/length/value_buffer tuple.
324 * @id: tag identifier.
325 * @len: number of bytes in value buffer.
326 * @data: value buffer.
334 static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
339 static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
341 return (struct brcmf_cfg80211_info *)(wiphy_priv(w));
344 static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
346 return (struct brcmf_cfg80211_info *)(wdev_priv(wd));
350 struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
352 struct brcmf_cfg80211_vif *vif;
353 vif = list_first_entry(&cfg->vif_list, struct brcmf_cfg80211_vif, list);
354 return vif->wdev.netdev;
357 static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
359 return wdev_to_cfg(ndev->ieee80211_ptr);
362 static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
364 struct brcmf_if *ifp = netdev_priv(nd);
365 return &ifp->vif->profile;
368 static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
370 struct brcmf_if *ifp = netdev_priv(ndev);
375 brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
377 return &cfg->conn_info;
380 struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
381 struct device *busdev,
383 void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
384 s32 brcmf_cfg80211_up(struct net_device *ndev);
385 s32 brcmf_cfg80211_down(struct net_device *ndev);
386 enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp);
388 struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
389 enum nl80211_iftype type,
391 void brcmf_free_vif(struct brcmf_cfg80211_vif *vif);
393 s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag,
394 const u8 *vndr_ie_buf, u32 vndr_ie_len);
395 s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif);
396 const struct brcmf_tlv *
397 brcmf_parse_tlvs(const void *buf, int buflen, uint key);
398 u16 channel_to_chanspec(struct brcmu_d11inf *d11inf,
399 struct ieee80211_channel *ch);
400 bool brcmf_get_vif_state_any(struct brcmf_cfg80211_info *cfg,
401 unsigned long state);
402 void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg,
403 struct brcmf_cfg80211_vif *vif);
404 bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg);
405 int brcmf_cfg80211_wait_vif_event_timeout(struct brcmf_cfg80211_info *cfg,
406 u8 action, ulong timeout);
407 s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
408 struct brcmf_if *ifp, bool aborted,
410 void brcmf_set_mpc(struct brcmf_if *ndev, int mpc);
411 void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg);
412 void brcmf_cfg80211_free_netdev(struct net_device *ndev);
414 #endif /* BRCMFMAC_CFG80211_H */