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 _wl_cfg80211_h_
18 #define _wl_cfg80211_h_
20 #define WL_NUM_SCAN_MAX 10
21 #define WL_NUM_PMKIDS_MAX MAXPMKID
22 #define WL_TLV_INFO_MAX 1024
23 #define WL_BSS_INFO_MAX 2048
24 #define WL_ASSOC_INFO_MAX 512 /* assoc related fil max buf */
25 #define WL_EXTRA_BUF_MAX 2048
26 #define WL_ROAM_TRIGGER_LEVEL -75
27 #define WL_ROAM_DELTA 20
28 #define WL_BEACON_TIMEOUT 3
30 #define WL_SCAN_CHANNEL_TIME 40
31 #define WL_SCAN_UNASSOC_TIME 40
32 #define WL_SCAN_PASSIVE_TIME 120
34 #define WL_ESCAN_BUF_SIZE (1024 * 64)
35 #define WL_ESCAN_TIMER_INTERVAL_MS 8000 /* E-Scan timeout */
37 #define WL_ESCAN_ACTION_START 1
38 #define WL_ESCAN_ACTION_CONTINUE 2
39 #define WL_ESCAN_ACTION_ABORT 3
41 #define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */
42 #define IE_MAX_LEN 512
44 /* IE TLV processing */
45 #define TLV_LEN_OFF 1 /* length offset */
46 #define TLV_HDR_LEN 2 /* header length */
47 #define TLV_BODY_OFF 2 /* body offset */
48 #define TLV_OUI_LEN 3 /* oui id length */
50 /* 802.11 Mgmt Packet flags */
51 #define BRCMF_VNDR_IE_BEACON_FLAG 0x1
52 #define BRCMF_VNDR_IE_PRBRSP_FLAG 0x2
53 #define BRCMF_VNDR_IE_ASSOCRSP_FLAG 0x4
54 #define BRCMF_VNDR_IE_AUTHRSP_FLAG 0x8
55 #define BRCMF_VNDR_IE_PRBREQ_FLAG 0x10
56 #define BRCMF_VNDR_IE_ASSOCREQ_FLAG 0x20
57 /* vendor IE in IW advertisement protocol ID field */
58 #define BRCMF_VNDR_IE_IWAPID_FLAG 0x40
59 /* allow custom IE id */
60 #define BRCMF_VNDR_IE_CUSTOM_FLAG 0x100
62 /* P2P Action Frames flags (spec ordered) */
63 #define BRCMF_VNDR_IE_GONREQ_FLAG 0x001000
64 #define BRCMF_VNDR_IE_GONRSP_FLAG 0x002000
65 #define BRCMF_VNDR_IE_GONCFM_FLAG 0x004000
66 #define BRCMF_VNDR_IE_INVREQ_FLAG 0x008000
67 #define BRCMF_VNDR_IE_INVRSP_FLAG 0x010000
68 #define BRCMF_VNDR_IE_DISREQ_FLAG 0x020000
69 #define BRCMF_VNDR_IE_DISRSP_FLAG 0x040000
70 #define BRCMF_VNDR_IE_PRDREQ_FLAG 0x080000
71 #define BRCMF_VNDR_IE_PRDRSP_FLAG 0x100000
73 #define BRCMF_VNDR_IE_P2PAF_SHIFT 12
77 * enum brcmf_scan_status - dongle scan status
79 * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.
80 * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.
82 enum brcmf_scan_status {
83 BRCMF_SCAN_STATUS_BUSY,
84 BRCMF_SCAN_STATUS_ABORT,
88 * enum wl_mode - driver mode of virtual interface.
90 * @WL_MODE_BSS: connects to BSS.
91 * @WL_MODE_IBSS: operate as ad-hoc.
92 * @WL_MODE_AP: operate as access-point.
93 * @WL_MODE_P2P: provide P2P discovery.
102 /* dongle configuration */
103 struct brcmf_cfg80211_conf {
109 struct ieee80211_channel channel;
112 /* basic structure of scan request */
113 struct brcmf_cfg80211_scan_req {
114 struct brcmf_ssid_le ssid_le;
117 /* basic structure of information element */
118 struct brcmf_cfg80211_ie {
120 u8 buf[WL_TLV_INFO_MAX];
123 /* security information with currently associated ap */
124 struct brcmf_cfg80211_security {
133 * struct brcmf_cfg80211_profile - profile information.
135 * @ssid: ssid of associated/associating ap.
136 * @bssid: bssid of joined/joining ibss.
137 * @sec: security information.
139 struct brcmf_cfg80211_profile {
140 struct brcmf_ssid ssid;
142 struct brcmf_cfg80211_security sec;
146 * enum brcmf_vif_status - bit indices for vif status.
148 * @BRCMF_VIF_STATUS_READY: ready for operation.
149 * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress.
150 * @BRCMF_VIF_STATUS_CONNECTED: connected/joined succesfully.
151 * @BRCMF_VIF_STATUS_DISCONNECTING: disconnect/disable in progress.
152 * @BRCMF_VIF_STATUS_AP_CREATING: interface configured for AP operation.
153 * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started.
155 enum brcmf_vif_status {
156 BRCMF_VIF_STATUS_READY,
157 BRCMF_VIF_STATUS_CONNECTING,
158 BRCMF_VIF_STATUS_CONNECTED,
159 BRCMF_VIF_STATUS_DISCONNECTING,
160 BRCMF_VIF_STATUS_AP_CREATING,
161 BRCMF_VIF_STATUS_AP_CREATED
165 * struct vif_saved_ie - holds saved IEs for a virtual interface.
167 * @probe_req_ie: IE info for probe request.
168 * @probe_res_ie: IE info for probe response.
169 * @beacon_ie: IE info for beacon frame.
170 * @probe_req_ie_len: IE info length for probe request.
171 * @probe_res_ie_len: IE info length for probe response.
172 * @beacon_ie_len: IE info length for beacon frame.
174 struct vif_saved_ie {
175 u8 probe_req_ie[IE_MAX_LEN];
176 u8 probe_res_ie[IE_MAX_LEN];
177 u8 beacon_ie[IE_MAX_LEN];
178 u8 assoc_req_ie[IE_MAX_LEN];
179 u32 probe_req_ie_len;
180 u32 probe_res_ie_len;
182 u32 assoc_req_ie_len;
186 * struct brcmf_cfg80211_vif - virtual interface specific information.
188 * @ifp: lower layer interface pointer
189 * @wdev: wireless device.
190 * @profile: profile information.
191 * @mode: operating mode.
192 * @roam_off: roaming state.
193 * @sme_state: SME state using enum brcmf_vif_status bits.
194 * @pm_block: power-management blocked.
195 * @list: linked list.
196 * @mgmt_rx_reg: registered rx mgmt frame types.
198 struct brcmf_cfg80211_vif {
199 struct brcmf_if *ifp;
200 struct wireless_dev wdev;
201 struct brcmf_cfg80211_profile profile;
204 unsigned long sme_state;
206 struct vif_saved_ie saved_ie;
207 struct list_head list;
211 /* association inform */
212 struct brcmf_cfg80211_connect_info {
219 /* assoc ie length */
220 struct brcmf_cfg80211_assoc_ielen_le {
226 struct brcmf_cfg80211_pmk_list {
227 struct pmkid_list pmkids;
228 struct pmkid foo[MAXPMKID - 1];
231 /* dongle escan state */
232 enum wl_escan_state {
234 WL_ESCAN_STATE_SCANNING
239 u8 escan_buf[WL_ESCAN_BUF_SIZE];
241 struct net_device *ndev;
242 s32 (*run)(struct brcmf_cfg80211_info *cfg,
243 struct net_device *ndev,
244 struct cfg80211_scan_request *request, u16 action);
248 * struct brcmf_pno_param_le - PNO scan configuration parameters
250 * @version: PNO parameters version.
251 * @scan_freq: scan frequency.
252 * @lost_network_timeout: #sec. to declare discovered network as lost.
253 * @flags: Bit field to control features of PFN such as sort criteria auto
254 * enable switch and background scan.
255 * @rssi_margin: Margin to avoid jitter for choosing a PFN based on RSSI sort
257 * @bestn: number of best networks in each scan.
258 * @mscan: number of scans recorded.
259 * @repeat: minimum number of scan intervals before scan frequency changes
261 * @exp: exponent of 2 for maximum scan interval.
262 * @slow_freq: slow scan period.
264 struct brcmf_pno_param_le {
267 __le32 lost_network_timeout;
278 * struct brcmf_pno_net_param_le - scan parameters per preferred network.
280 * @ssid: ssid name and its length.
281 * @flags: bit2: hidden.
282 * @infra: BSS vs IBSS.
283 * @auth: Open vs Closed.
284 * @wpa_auth: WPA type.
287 struct brcmf_pno_net_param_le {
288 struct brcmf_ssid_le ssid;
297 * struct brcmf_pno_net_info_le - information per found network.
299 * @bssid: BSS network identifier.
300 * @channel: channel number only.
301 * @SSID_len: length of ssid.
302 * @SSID: ssid characters.
303 * @RSSI: receive signal strength (in dBm).
304 * @timestamp: age in seconds.
306 struct brcmf_pno_net_info_le {
316 * struct brcmf_pno_scanresults_le - result returned in PNO NET FOUND event.
318 * @version: PNO version identifier.
319 * @status: indicates completion status of PNO scan.
320 * @count: amount of brcmf_pno_net_info_le entries appended.
322 struct brcmf_pno_scanresults_le {
329 * struct brcmf_cfg80211_vif_event - virtual interface event information.
331 * @vif_wq: waitqueue awaiting interface event from firmware.
332 * @vif_event_lock: protects other members in this structure.
333 * @vif_complete: completion for net attach.
334 * @action: either add, change, or delete.
335 * @vif: virtual interface object related to the event.
337 struct brcmf_cfg80211_vif_event {
338 wait_queue_head_t vif_wq;
339 struct mutex vif_event_lock;
341 struct brcmf_cfg80211_vif *vif;
345 * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface
347 * @wiphy: wiphy object for cfg80211 interface.
348 * @conf: dongle configuration.
349 * @p2p: peer-to-peer specific information.
350 * @scan_request: cfg80211 scan request object.
351 * @usr_sync: mainly for dongle up/down synchronization.
352 * @bss_list: bss_list holding scanned ap information.
353 * @scan_req_int: internal scan request object.
354 * @bss_info: bss information for cfg80211 layer.
355 * @ie: information element object for internal purpose.
356 * @conn_info: association info.
357 * @pmk_list: wpa2 pmk list.
358 * @scan_status: scan activity on the dongle.
359 * @pub: common driver information.
360 * @channel: current channel.
361 * @active_scan: current scan mode.
362 * @sched_escan: e-scan for scheduled scan support running.
363 * @ibss_starter: indicates this sta is ibss starter.
364 * @pwr_save: indicate whether dongle to support power save mode.
365 * @dongle_up: indicate whether dongle up or not.
366 * @roam_on: on/off switch for dongle self-roaming.
367 * @scan_tried: indicates if first scan attempted.
368 * @dcmd_buf: dcmd buffer.
369 * @extra_buf: mainly to grab assoc information.
370 * @debugfsdir: debugfs folder for this device.
371 * @escan_info: escan information.
372 * @escan_timeout: Timer for catch scan timeout.
373 * @escan_timeout_work: scan timeout worker.
374 * @escan_ioctl_buf: dongle command buffer for escan commands.
375 * @vif_list: linked list of vif instances.
376 * @vif_cnt: number of vif instances.
377 * @vif_event: vif event signalling.
379 struct brcmf_cfg80211_info {
381 struct brcmf_cfg80211_conf *conf;
382 struct brcmf_p2p_info p2p;
383 struct cfg80211_scan_request *scan_request;
384 struct mutex usr_sync;
385 struct brcmf_scan_results *bss_list;
386 struct brcmf_cfg80211_scan_req scan_req_int;
387 struct wl_cfg80211_bss_info *bss_info;
388 struct brcmf_cfg80211_ie ie;
389 struct brcmf_cfg80211_connect_info conn_info;
390 struct brcmf_cfg80211_pmk_list *pmk_list;
391 unsigned long scan_status;
392 struct brcmf_pub *pub;
403 struct dentry *debugfsdir;
404 struct escan_info escan_info;
405 struct timer_list escan_timeout;
406 struct work_struct escan_timeout_work;
408 struct list_head vif_list;
410 struct brcmf_cfg80211_vif_event vif_event;
411 struct completion vif_disabled;
415 * struct brcmf_tlv - tag_ID/length/value_buffer tuple.
417 * @id: tag identifier.
418 * @len: number of bytes in value buffer.
419 * @data: value buffer.
427 static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
432 static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
434 return (struct brcmf_cfg80211_info *)(wiphy_priv(w));
437 static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
439 return (struct brcmf_cfg80211_info *)(wdev_priv(wd));
443 struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
445 struct brcmf_cfg80211_vif *vif;
446 vif = list_first_entry(&cfg->vif_list, struct brcmf_cfg80211_vif, list);
447 return vif->wdev.netdev;
450 static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
452 return wdev_to_cfg(ndev->ieee80211_ptr);
455 static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
457 struct brcmf_if *ifp = netdev_priv(nd);
458 return &ifp->vif->profile;
461 static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
463 struct brcmf_if *ifp = netdev_priv(ndev);
468 brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
470 return &cfg->conn_info;
473 struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
474 struct device *busdev);
475 void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
476 s32 brcmf_cfg80211_up(struct net_device *ndev);
477 s32 brcmf_cfg80211_down(struct net_device *ndev);
479 struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
480 enum nl80211_iftype type,
482 void brcmf_free_vif(struct brcmf_cfg80211_vif *vif);
484 s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag,
485 const u8 *vndr_ie_buf, u32 vndr_ie_len);
486 s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif);
487 struct brcmf_tlv *brcmf_parse_tlvs(void *buf, int buflen, uint key);
488 u16 channel_to_chanspec(struct ieee80211_channel *ch);
489 u32 wl_get_vif_state_all(struct brcmf_cfg80211_info *cfg, unsigned long state);
490 void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg,
491 struct brcmf_cfg80211_vif *vif);
492 bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg);
493 int brcmf_cfg80211_wait_vif_event_timeout(struct brcmf_cfg80211_info *cfg,
494 u8 action, ulong timeout);
495 s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
496 struct net_device *ndev,
497 bool aborted, bool fw_abort);
498 void brcmf_set_mpc(struct net_device *ndev, int mpc);
499 void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg);
501 #endif /* _wl_cfg80211_h_ */