cfg80211.h 12.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * Copyright (c) 2010 Broadcom Corporation
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

17 18
#ifndef BRCMFMAC_CFG80211_H
#define BRCMFMAC_CFG80211_H
19

F
Franky Lin 已提交
20 21 22
/* for brcmu_d11inf */
#include <brcmu_d11.h>

23
#include "core.h"
24 25 26
#include "fwil_types.h"
#include "p2p.h"

27
#define WL_NUM_SCAN_MAX			10
28 29
#define WL_TLV_INFO_MAX			1024
#define WL_BSS_INFO_MAX			2048
30 31
#define WL_ASSOC_INFO_MAX		512	/* assoc related fil max buf */
#define WL_EXTRA_BUF_MAX		2048
32 33 34
#define WL_ROAM_TRIGGER_LEVEL		-75
#define WL_ROAM_DELTA			20

35 36 37 38 39
/* Keep BRCMF_ESCAN_BUF_SIZE below 64K (65536). Allocing over 64K can be
 * problematic on some systems and should be avoided.
 */
#define BRCMF_ESCAN_BUF_SIZE		65000
#define BRCMF_ESCAN_TIMER_INTERVAL_MS	10000	/* E-Scan timeout */
H
Hante Meuleman 已提交
40 41 42 43 44

#define WL_ESCAN_ACTION_START		1
#define WL_ESCAN_ACTION_CONTINUE	2
#define WL_ESCAN_ACTION_ABORT		3

45
#define WL_AUTH_SHARED_KEY		1	/* d11 shared authentication */
H
Hante Meuleman 已提交
46
#define IE_MAX_LEN			512
47

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
/* IE TLV processing */
#define TLV_LEN_OFF			1	/* length offset */
#define TLV_HDR_LEN			2	/* header length */
#define TLV_BODY_OFF			2	/* body offset */
#define TLV_OUI_LEN			3	/* oui id length */

/* 802.11 Mgmt Packet flags */
#define BRCMF_VNDR_IE_BEACON_FLAG	0x1
#define BRCMF_VNDR_IE_PRBRSP_FLAG	0x2
#define BRCMF_VNDR_IE_ASSOCRSP_FLAG	0x4
#define BRCMF_VNDR_IE_AUTHRSP_FLAG	0x8
#define BRCMF_VNDR_IE_PRBREQ_FLAG	0x10
#define BRCMF_VNDR_IE_ASSOCREQ_FLAG	0x20
/* vendor IE in IW advertisement protocol ID field */
#define BRCMF_VNDR_IE_IWAPID_FLAG	0x40
/* allow custom IE id */
#define BRCMF_VNDR_IE_CUSTOM_FLAG	0x100

/* P2P Action Frames flags (spec ordered) */
#define BRCMF_VNDR_IE_GONREQ_FLAG     0x001000
#define BRCMF_VNDR_IE_GONRSP_FLAG     0x002000
#define BRCMF_VNDR_IE_GONCFM_FLAG     0x004000
#define BRCMF_VNDR_IE_INVREQ_FLAG     0x008000
#define BRCMF_VNDR_IE_INVRSP_FLAG     0x010000
#define BRCMF_VNDR_IE_DISREQ_FLAG     0x020000
#define BRCMF_VNDR_IE_DISRSP_FLAG     0x040000
#define BRCMF_VNDR_IE_PRDREQ_FLAG     0x080000
#define BRCMF_VNDR_IE_PRDRSP_FLAG     0x100000

#define BRCMF_VNDR_IE_P2PAF_SHIFT	12

79
#define BRCMF_MAX_DEFAULT_KEYS		6
80

81 82 83
/* beacon loss timeout defaults */
#define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_ON	2
#define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_OFF	4
84

85 86
#define BRCMF_VIF_EVENT_TIMEOUT		msecs_to_jiffies(1500)

87
/**
88
 * enum brcmf_scan_status - scan engine status
89 90 91
 *
 * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.
 * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.
92
 * @BRCMF_SCAN_STATUS_SUPPRESS: scanning is suppressed in driver.
93 94 95 96
 */
enum brcmf_scan_status {
	BRCMF_SCAN_STATUS_BUSY,
	BRCMF_SCAN_STATUS_ABORT,
97
	BRCMF_SCAN_STATUS_SUPPRESS,
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
};

/* dongle configuration */
struct brcmf_cfg80211_conf {
	u32 frag_threshold;
	u32 rts_threshold;
	u32 retry_short;
	u32 retry_long;
};

/* security information with currently associated ap */
struct brcmf_cfg80211_security {
	u32 wpa_versions;
	u32 auth_type;
	u32 cipher_pairwise;
	u32 cipher_group;
};

116 117 118 119 120
/**
 * struct brcmf_cfg80211_profile - profile information.
 *
 * @bssid: bssid of joined/joining ibss.
 * @sec: security information.
121
 * @key: key information
122
 */
123 124 125
struct brcmf_cfg80211_profile {
	u8 bssid[ETH_ALEN];
	struct brcmf_cfg80211_security sec;
126
	struct brcmf_wsec_key key[BRCMF_MAX_DEFAULT_KEYS];
127 128
};

129 130 131 132 133 134
/**
 * enum brcmf_vif_status - bit indices for vif status.
 *
 * @BRCMF_VIF_STATUS_READY: ready for operation.
 * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress.
 * @BRCMF_VIF_STATUS_CONNECTED: connected/joined succesfully.
135
 * @BRCMF_VIF_STATUS_DISCONNECTING: disconnect/disable in progress.
136 137 138 139 140 141
 * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started.
 */
enum brcmf_vif_status {
	BRCMF_VIF_STATUS_READY,
	BRCMF_VIF_STATUS_CONNECTING,
	BRCMF_VIF_STATUS_CONNECTED,
142
	BRCMF_VIF_STATUS_DISCONNECTING,
143 144 145
	BRCMF_VIF_STATUS_AP_CREATED
};

146 147 148
/**
 * struct vif_saved_ie - holds saved IEs for a virtual interface.
 *
149
 * @probe_req_ie: IE info for probe request.
150 151
 * @probe_res_ie: IE info for probe response.
 * @beacon_ie: IE info for beacon frame.
152
 * @probe_req_ie_len: IE info length for probe request.
153 154 155 156
 * @probe_res_ie_len: IE info length for probe response.
 * @beacon_ie_len: IE info length for beacon frame.
 */
struct vif_saved_ie {
157
	u8  probe_req_ie[IE_MAX_LEN];
158 159
	u8  probe_res_ie[IE_MAX_LEN];
	u8  beacon_ie[IE_MAX_LEN];
160
	u8  assoc_req_ie[IE_MAX_LEN];
161
	u32 probe_req_ie_len;
162 163
	u32 probe_res_ie_len;
	u32 beacon_ie_len;
164
	u32 assoc_req_ie_len;
165 166
};

167 168 169 170 171
/**
 * struct brcmf_cfg80211_vif - virtual interface specific information.
 *
 * @ifp: lower layer interface pointer
 * @wdev: wireless device.
172
 * @profile: profile information.
173
 * @sme_state: SME state using enum brcmf_vif_status bits.
174
 * @list: linked list.
175
 * @mgmt_rx_reg: registered rx mgmt frame types.
176
 * @mbss: Multiple BSS type, set if not first AP (not relevant for P2P).
177 178 179 180
 */
struct brcmf_cfg80211_vif {
	struct brcmf_if *ifp;
	struct wireless_dev wdev;
181
	struct brcmf_cfg80211_profile profile;
182
	unsigned long sme_state;
183
	struct vif_saved_ie saved_ie;
184
	struct list_head list;
185
	u16 mgmt_rx_reg;
186
	bool mbss;
187
	int is_11d;
188 189
};

190 191 192 193 194 195 196 197 198
/* association inform */
struct brcmf_cfg80211_connect_info {
	u8 *req_ie;
	s32 req_ie_len;
	u8 *resp_ie;
	s32 resp_ie_len;
};

/* assoc ie length */
199 200 201
struct brcmf_cfg80211_assoc_ielen_le {
	__le32 req_len;
	__le32 resp_len;
202 203
};

H
Hante Meuleman 已提交
204 205 206 207 208 209 210 211
/* dongle escan state */
enum wl_escan_state {
	WL_ESCAN_STATE_IDLE,
	WL_ESCAN_STATE_SCANNING
};

struct escan_info {
	u32 escan_state;
212
	u8 *escan_buf;
H
Hante Meuleman 已提交
213
	struct wiphy *wiphy;
214 215
	struct brcmf_if *ifp;
	s32 (*run)(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp,
216
		   struct cfg80211_scan_request *request);
H
Hante Meuleman 已提交
217 218
};

219 220 221 222 223 224 225 226 227 228 229
/**
 * struct brcmf_cfg80211_vif_event - virtual interface event information.
 *
 * @vif_wq: waitqueue awaiting interface event from firmware.
 * @vif_event_lock: protects other members in this structure.
 * @vif_complete: completion for net attach.
 * @action: either add, change, or delete.
 * @vif: virtual interface object related to the event.
 */
struct brcmf_cfg80211_vif_event {
	wait_queue_head_t vif_wq;
230
	spinlock_t vif_event_lock;
231 232 233 234
	u8 action;
	struct brcmf_cfg80211_vif *vif;
};

235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
/**
 * struct brcmf_cfg80211_wowl - wowl related information.
 *
 * @active: set on suspend, cleared on resume.
 * @pre_pmmode: firmware PM mode at entering suspend.
 * @nd: net dectect data.
 * @nd_info: helper struct to pass to cfg80211.
 * @nd_data_wait: wait queue to sync net detect data.
 * @nd_data_completed: completion for net detect data.
 * @nd_enabled: net detect enabled.
 */
struct brcmf_cfg80211_wowl {
	bool active;
	u32 pre_pmmode;
	struct cfg80211_wowlan_nd_match *nd;
	struct cfg80211_wowlan_nd_info *nd_info;
	wait_queue_head_t nd_data_wait;
	bool nd_data_completed;
	bool nd_enabled;
};

256
/**
257
 * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface
258
 *
259
 * @wiphy: wiphy object for cfg80211 interface.
260
 * @ops: pointer to copy of ops as registered with wiphy object.
261
 * @conf: dongle configuration.
262
 * @p2p: peer-to-peer specific information.
263
 * @btcoex: Bluetooth coexistence information.
264 265 266 267 268 269
 * @scan_request: cfg80211 scan request object.
 * @usr_sync: mainly for dongle up/down synchronization.
 * @bss_list: bss_list holding scanned ap information.
 * @bss_info: bss information for cfg80211 layer.
 * @conn_info: association info.
 * @pmk_list: wpa2 pmk list.
270
 * @scan_status: scan activity on the dongle.
271 272 273
 * @pub: common driver information.
 * @channel: current channel.
 * @active_scan: current scan mode.
274
 * @internal_escan: indicates internally initiated e-scan is running.
275 276 277 278 279 280 281 282 283 284 285
 * @ibss_starter: indicates this sta is ibss starter.
 * @pwr_save: indicate whether dongle to support power save mode.
 * @dongle_up: indicate whether dongle up or not.
 * @roam_on: on/off switch for dongle self-roaming.
 * @scan_tried: indicates if first scan attempted.
 * @dcmd_buf: dcmd buffer.
 * @extra_buf: mainly to grab assoc information.
 * @debugfsdir: debugfs folder for this device.
 * @escan_info: escan information.
 * @escan_timeout: Timer for catch scan timeout.
 * @escan_timeout_work: scan timeout worker.
286 287
 * @vif_list: linked list of vif instances.
 * @vif_cnt: number of vif instances.
288
 * @vif_event: vif event signalling.
289
 * @wowl: wowl related information.
290
 */
291
struct brcmf_cfg80211_info {
292
	struct wiphy *wiphy;
293
	struct cfg80211_ops *ops;
294
	struct brcmf_cfg80211_conf *conf;
295
	struct brcmf_p2p_info p2p;
296
	struct brcmf_btcoex_info *btcoex;
297 298 299 300
	struct cfg80211_scan_request *scan_request;
	struct mutex usr_sync;
	struct wl_cfg80211_bss_info *bss_info;
	struct brcmf_cfg80211_connect_info conn_info;
301
	struct brcmf_pmk_list_le pmk_list;
302
	unsigned long scan_status;
303
	struct brcmf_pub *pub;
304 305
	u32 channel;
	bool active_scan;
306
	bool internal_escan;
307 308 309 310 311 312
	bool ibss_starter;
	bool pwr_save;
	bool dongle_up;
	bool scan_tried;
	u8 *dcmd_buf;
	u8 *extra_buf;
313
	struct dentry *debugfsdir;
314 315 316
	struct escan_info escan_info;
	struct timer_list escan_timeout;
	struct work_struct escan_timeout_work;
317
	struct list_head vif_list;
318
	struct brcmf_cfg80211_vif_event vif_event;
319
	struct completion vif_disabled;
F
Franky Lin 已提交
320
	struct brcmu_d11inf d11inf;
321
	struct brcmf_assoclist_le assoclist;
322
	struct brcmf_cfg80211_wowl wowl;
323 324
};

325 326 327 328 329 330 331 332 333 334 335 336 337
/**
 * struct brcmf_tlv - tag_ID/length/value_buffer tuple.
 *
 * @id: tag identifier.
 * @len: number of bytes in value buffer.
 * @data: value buffer.
 */
struct brcmf_tlv {
	u8 id;
	u8 len;
	u8 data[1];
};

338
static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
339
{
340
	return cfg->wiphy;
341 342
}

343
static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
344
{
345
	return (struct brcmf_cfg80211_info *)(wiphy_priv(w));
346 347
}

348
static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
349
{
350
	return (struct brcmf_cfg80211_info *)(wdev_priv(wd));
351 352
}

353 354
static inline
struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
355
{
356 357 358
	struct brcmf_cfg80211_vif *vif;
	vif = list_first_entry(&cfg->vif_list, struct brcmf_cfg80211_vif, list);
	return vif->wdev.netdev;
359 360
}

361
static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
362 363 364 365
{
	return wdev_to_cfg(ndev->ieee80211_ptr);
}

366 367 368 369 370 371
static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
{
	struct brcmf_if *ifp = netdev_priv(nd);
	return &ifp->vif->profile;
}

372 373 374 375 376 377
static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
{
	struct brcmf_if *ifp = netdev_priv(ndev);
	return ifp->vif;
}

378
static inline struct
379
brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
380 381 382 383
{
	return &cfg->conn_info;
}

A
Arend van Spriel 已提交
384
struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
385 386
						  struct device *busdev,
						  bool p2pdev_forced);
387
void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
388 389
s32 brcmf_cfg80211_up(struct net_device *ndev);
s32 brcmf_cfg80211_down(struct net_device *ndev);
390
enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp);
391

392
struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
393
					   enum nl80211_iftype type);
394
void brcmf_free_vif(struct brcmf_cfg80211_vif *vif);
395 396 397

s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag,
			  const u8 *vndr_ie_buf, u32 vndr_ie_len);
398
s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif);
F
Franky Lin 已提交
399 400
u16 channel_to_chanspec(struct brcmu_d11inf *d11inf,
			struct ieee80211_channel *ch);
401 402
bool brcmf_get_vif_state_any(struct brcmf_cfg80211_info *cfg,
			     unsigned long state);
403 404 405
void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg,
				  struct brcmf_cfg80211_vif *vif);
bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg);
406 407
int brcmf_cfg80211_wait_vif_event(struct brcmf_cfg80211_info *cfg,
				  u8 action, ulong timeout);
408
s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
409 410
				struct brcmf_if *ifp, bool aborted,
				bool fw_abort);
411
void brcmf_set_mpc(struct brcmf_if *ndev, int mpc);
H
Hante Meuleman 已提交
412
void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg);
413
void brcmf_cfg80211_free_netdev(struct net_device *ndev);
414

415
#endif /* BRCMFMAC_CFG80211_H */