staging: brcm80211: removed occurrences of 'dhd'
[deliverable/linux.git] / drivers / staging / brcm80211 / brcmfmac / dhd.h
1 /*
2 * Copyright (c) 2010 Broadcom Corporation
3 *
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.
7 *
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.
15 */
16
17 /****************
18 * Common types *
19 */
20
21 #ifndef _BRCMF_H_
22 #define _BRCMF_H_
23
24 #define BRCMF_VERSION_STR "4.218.248.5"
25
26 #define BRCMF_C_IOCTL_SMLEN 256 /* "small" ioctl buffer required */
27 #define BRCMF_C_IOCTL_MEDLEN 1536 /* "med" ioctl buffer required */
28 #define BRCMF_C_IOCTL_MAXLEN 8192
29
30 #define BRCMF_C_UP 2
31 #define BRCMF_C_SET_PROMISC 10
32 #define BRCMF_C_GET_RATE 12
33 #define BRCMF_C_GET_INFRA 19
34 #define BRCMF_C_SET_INFRA 20
35 #define BRCMF_C_GET_AUTH 21
36 #define BRCMF_C_SET_AUTH 22
37 #define BRCMF_C_GET_BSSID 23
38 #define BRCMF_C_GET_SSID 25
39 #define BRCMF_C_SET_SSID 26
40 #define BRCMF_C_GET_CHANNEL 29
41 #define BRCMF_C_GET_SRL 31
42 #define BRCMF_C_GET_LRL 33
43 #define BRCMF_C_GET_RADIO 37
44 #define BRCMF_C_SET_RADIO 38
45 #define BRCMF_C_GET_PHYTYPE 39
46 #define BRCMF_C_SET_KEY 45
47 #define BRCMF_C_SET_PASSIVE_SCAN 49
48 #define BRCMF_C_SCAN 50
49 #define BRCMF_C_SCAN_RESULTS 51
50 #define BRCMF_C_DISASSOC 52
51 #define BRCMF_C_REASSOC 53
52 #define BRCMF_C_SET_ROAM_TRIGGER 55
53 #define BRCMF_C_SET_ROAM_DELTA 57
54 #define BRCMF_C_GET_DTIMPRD 77
55 #define BRCMF_C_SET_COUNTRY 84
56 #define BRCMF_C_GET_PM 85
57 #define BRCMF_C_SET_PM 86
58 #define BRCMF_C_GET_AP 117
59 #define BRCMF_C_SET_AP 118
60 #define BRCMF_C_GET_RSSI 127
61 #define BRCMF_C_GET_WSEC 133
62 #define BRCMF_C_SET_WSEC 134
63 #define BRCMF_C_GET_PHY_NOISE 135
64 #define BRCMF_C_GET_BSS_INFO 136
65 #define BRCMF_C_SET_SCAN_CHANNEL_TIME 185
66 #define BRCMF_C_SET_SCAN_UNASSOC_TIME 187
67 #define BRCMF_C_SCB_DEAUTHENTICATE_FOR_REASON 201
68 #define BRCMF_C_GET_VALID_CHANNELS 217
69 #define BRCMF_C_GET_KEY_PRIMARY 235
70 #define BRCMF_C_SET_KEY_PRIMARY 236
71 #define BRCMF_C_SET_SCAN_PASSIVE_TIME 258
72 #define BRCMF_C_GET_VAR 262
73 #define BRCMF_C_SET_VAR 263
74
75 /* phy types (returned by WLC_GET_PHYTPE) */
76 #define WLC_PHY_TYPE_A 0
77 #define WLC_PHY_TYPE_B 1
78 #define WLC_PHY_TYPE_G 2
79 #define WLC_PHY_TYPE_N 4
80 #define WLC_PHY_TYPE_LP 5
81 #define WLC_PHY_TYPE_SSN 6
82 #define WLC_PHY_TYPE_HT 7
83 #define WLC_PHY_TYPE_LCN 8
84 #define WLC_PHY_TYPE_NULL 0xf
85
86 #define BRCMF_PKT_FILTER_FIXED_LEN offsetof(struct brcmf_pkt_filter, u)
87 #define BRCMF_PKT_FILTER_PATTERN_FIXED_LEN \
88 offsetof(struct brcmf_pkt_filter_pattern, mask_and_pattern)
89
90 #define BRCMF_EVENTING_MASK_LEN 16
91
92 #define TOE_TX_CSUM_OL 0x00000001
93 #define TOE_RX_CSUM_OL 0x00000002
94
95 /* maximum channels returned by the get valid channels iovar */
96 #define WL_NUMCHANNELS 64
97
98 #define BRCMF_BSS_INFO_VERSION 108 /* current ver of brcmf_bss_info struct */
99
100 /* size of brcmf_scan_params not including variable length array */
101 #define BRCMF_SCAN_PARAMS_FIXED_SIZE 64
102
103 /* masks for channel and ssid count */
104 #define BRCMF_SCAN_PARAMS_COUNT_MASK 0x0000ffff
105 #define BRCMF_SCAN_PARAMS_NSSID_SHIFT 16
106
107 #define BRCMF_SCAN_ACTION_START 1
108 #define BRCMF_SCAN_ACTION_CONTINUE 2
109 #define WL_SCAN_ACTION_ABORT 3
110
111 #define BRCMF_ISCAN_REQ_VERSION 1
112
113 /* brcmf_iscan_results status values */
114 #define BRCMF_SCAN_RESULTS_SUCCESS 0
115 #define BRCMF_SCAN_RESULTS_PARTIAL 1
116 #define BRCMF_SCAN_RESULTS_PENDING 2
117 #define BRCMF_SCAN_RESULTS_ABORTED 3
118 #define BRCMF_SCAN_RESULTS_NO_MEM 4
119
120 #define WL_SOFT_KEY (1 << 0) /* Indicates this key is using soft encrypt */
121 #define BRCMF_PRIMARY_KEY (1 << 1) /* primary (ie tx) key */
122 #define WL_KF_RES_4 (1 << 4) /* Reserved for backward compat */
123 #define WL_KF_RES_5 (1 << 5) /* Reserved for backward compat */
124 #define WL_IBSS_PEER_GROUP_KEY (1 << 6) /* Indicates a group key for a IBSS PEER */
125
126 /* For supporting multiple interfaces */
127 #define BRCMF_MAX_IFS 16
128 #define BRCMF_DEL_IF -0xe
129 #define BRCMF_BAD_IF -0xf
130
131 #define DOT11_BSSTYPE_ANY 2
132 #define DOT11_MAX_DEFAULT_KEYS 4
133
134 #define BRCMF_EVENT_MSG_LINK 0x01
135 #define BRCMF_EVENT_MSG_FLUSHTXQ 0x02
136 #define BRCMF_EVENT_MSG_GROUP 0x04
137
138 struct brcmf_event_msg {
139 u16 version;
140 u16 flags;
141 u32 event_type;
142 u32 status;
143 u32 reason;
144 u32 auth_type;
145 u32 datalen;
146 u8 addr[ETH_ALEN];
147 char ifname[IFNAMSIZ];
148 } __packed;
149
150 struct brcm_ethhdr {
151 u16 subtype;
152 u16 length;
153 u8 version;
154 u8 oui[3];
155 u16 usr_subtype;
156 } __packed;
157
158 struct brcmf_event {
159 struct ethhdr eth;
160 struct brcm_ethhdr hdr;
161 struct brcmf_event_msg msg;
162 } __packed;
163
164 #define BRCMF_E_SET_SSID 0
165 #define BRCMF_E_JOIN 1
166 #define BRCMF_E_START 2
167 #define BRCMF_E_AUTH 3
168 #define BRCMF_E_AUTH_IND 4
169 #define BRCMF_E_DEAUTH 5
170 #define BRCMF_E_DEAUTH_IND 6
171 #define BRCMF_E_ASSOC 7
172 #define BRCMF_E_ASSOC_IND 8
173 #define BRCMF_E_REASSOC 9
174 #define BRCMF_E_REASSOC_IND 10
175 #define BRCMF_E_DISASSOC 11
176 #define BRCMF_E_DISASSOC_IND 12
177 #define BRCMF_E_QUIET_START 13
178 #define BRCMF_E_QUIET_END 14
179 #define BRCMF_E_BEACON_RX 15
180 #define BRCMF_E_LINK 16
181 #define BRCMF_E_MIC_ERROR 17
182 #define BRCMF_E_NDIS_LINK 18
183 #define BRCMF_E_ROAM 19
184 #define BRCMF_E_TXFAIL 20
185 #define BRCMF_E_PMKID_CACHE 21
186 #define BRCMF_E_RETROGRADE_TSF 22
187 #define BRCMF_E_PRUNE 23
188 #define BRCMF_E_AUTOAUTH 24
189 #define BRCMF_E_EAPOL_MSG 25
190 #define BRCMF_E_SCAN_COMPLETE 26
191 #define BRCMF_E_ADDTS_IND 27
192 #define BRCMF_E_DELTS_IND 28
193 #define BRCMF_E_BCNSENT_IND 29
194 #define BRCMF_E_BCNRX_MSG 30
195 #define BRCMF_E_BCNLOST_MSG 31
196 #define BRCMF_E_ROAM_PREP 32
197 #define BRCMF_E_PFN_NET_FOUND 33
198 #define BRCMF_E_PFN_NET_LOST 34
199 #define BRCMF_E_RESET_COMPLETE 35
200 #define BRCMF_E_JOIN_START 36
201 #define BRCMF_E_ROAM_START 37
202 #define BRCMF_E_ASSOC_START 38
203 #define BRCMF_E_IBSS_ASSOC 39
204 #define BRCMF_E_RADIO 40
205 #define BRCMF_E_PSM_WATCHDOG 41
206 #define BRCMF_E_PROBREQ_MSG 44
207 #define BRCMF_E_SCAN_CONFIRM_IND 45
208 #define BRCMF_E_PSK_SUP 46
209 #define BRCMF_E_COUNTRY_CODE_CHANGED 47
210 #define BRCMF_E_EXCEEDED_MEDIUM_TIME 48
211 #define BRCMF_E_ICV_ERROR 49
212 #define BRCMF_E_UNICAST_DECODE_ERROR 50
213 #define BRCMF_E_MULTICAST_DECODE_ERROR 51
214 #define BRCMF_E_TRACE 52
215 #define BRCMF_E_IF 54
216 #define BRCMF_E_RSSI 56
217 #define BRCMF_E_PFN_SCAN_COMPLETE 57
218 #define BRCMF_E_EXTLOG_MSG 58
219 #define BRCMF_E_ACTION_FRAME 59
220 #define BRCMF_E_ACTION_FRAME_COMPLETE 60
221 #define BRCMF_E_PRE_ASSOC_IND 61
222 #define BRCMF_E_PRE_REASSOC_IND 62
223 #define BRCMF_E_CHANNEL_ADOPTED 63
224 #define BRCMF_E_AP_STARTED 64
225 #define BRCMF_E_DFS_AP_STOP 65
226 #define BRCMF_E_DFS_AP_RESUME 66
227 #define BRCMF_E_RESERVED1 67
228 #define BRCMF_E_RESERVED2 68
229 #define BRCMF_E_ESCAN_RESULT 69
230 #define BRCMF_E_ACTION_FRAME_OFF_CHAN_COMPLETE 70
231 #define BRCMF_E_DCS_REQUEST 73
232
233 #define BRCMF_E_FIFO_CREDIT_MAP 74
234
235 #define BRCMF_E_LAST 75
236
237 #define BRCMF_E_STATUS_SUCCESS 0
238 #define BRCMF_E_STATUS_FAIL 1
239 #define BRCMF_E_STATUS_TIMEOUT 2
240 #define BRCMF_E_STATUS_NO_NETWORKS 3
241 #define BRCMF_E_STATUS_ABORT 4
242 #define BRCMF_E_STATUS_NO_ACK 5
243 #define BRCMF_E_STATUS_UNSOLICITED 6
244 #define BRCMF_E_STATUS_ATTEMPT 7
245 #define BRCMF_E_STATUS_PARTIAL 8
246 #define BRCMF_E_STATUS_NEWSCAN 9
247 #define BRCMF_E_STATUS_NEWASSOC 10
248 #define BRCMF_E_STATUS_11HQUIET 11
249 #define BRCMF_E_STATUS_SUPPRESS 12
250 #define BRCMF_E_STATUS_NOCHANS 13
251 #define BRCMF_E_STATUS_CS_ABORT 15
252 #define BRCMF_E_STATUS_ERROR 16
253
254 #define BRCMF_E_REASON_INITIAL_ASSOC 0
255 #define BRCMF_E_REASON_LOW_RSSI 1
256 #define BRCMF_E_REASON_DEAUTH 2
257 #define BRCMF_E_REASON_DISASSOC 3
258 #define BRCMF_E_REASON_BCNS_LOST 4
259 #define BRCMF_E_REASON_MINTXRATE 9
260 #define BRCMF_E_REASON_TXFAIL 10
261
262 #define BRCMF_E_REASON_FAST_ROAM_FAILED 5
263 #define BRCMF_E_REASON_DIRECTED_ROAM 6
264 #define BRCMF_E_REASON_TSPEC_REJECTED 7
265 #define BRCMF_E_REASON_BETTER_AP 8
266
267 #define BRCMF_E_PRUNE_ENCR_MISMATCH 1
268 #define BRCMF_E_PRUNE_BCAST_BSSID 2
269 #define BRCMF_E_PRUNE_MAC_DENY 3
270 #define BRCMF_E_PRUNE_MAC_NA 4
271 #define BRCMF_E_PRUNE_REG_PASSV 5
272 #define BRCMF_E_PRUNE_SPCT_MGMT 6
273 #define BRCMF_E_PRUNE_RADAR 7
274 #define BRCMF_E_RSN_MISMATCH 8
275 #define BRCMF_E_PRUNE_NO_COMMON_RATES 9
276 #define BRCMF_E_PRUNE_BASIC_RATES 10
277 #define BRCMF_E_PRUNE_CIPHER_NA 12
278 #define BRCMF_E_PRUNE_KNOWN_STA 13
279 #define BRCMF_E_PRUNE_WDS_PEER 15
280 #define BRCMF_E_PRUNE_QBSS_LOAD 16
281 #define BRCMF_E_PRUNE_HOME_AP 17
282
283 #define BRCMF_E_SUP_OTHER 0
284 #define BRCMF_E_SUP_DECRYPT_KEY_DATA 1
285 #define BRCMF_E_SUP_BAD_UCAST_WEP128 2
286 #define BRCMF_E_SUP_BAD_UCAST_WEP40 3
287 #define BRCMF_E_SUP_UNSUP_KEY_LEN 4
288 #define BRCMF_E_SUP_PW_KEY_CIPHER 5
289 #define BRCMF_E_SUP_MSG3_TOO_MANY_IE 6
290 #define BRCMF_E_SUP_MSG3_IE_MISMATCH 7
291 #define BRCMF_E_SUP_NO_INSTALL_FLAG 8
292 #define BRCMF_E_SUP_MSG3_NO_GTK 9
293 #define BRCMF_E_SUP_GRP_KEY_CIPHER 10
294 #define BRCMF_E_SUP_GRP_MSG1_NO_GTK 11
295 #define BRCMF_E_SUP_GTK_DECRYPT_FAIL 12
296 #define BRCMF_E_SUP_SEND_FAIL 13
297 #define BRCMF_E_SUP_DEAUTH 14
298
299 #define BRCMF_E_IF_ADD 1
300 #define BRCMF_E_IF_DEL 2
301 #define BRCMF_E_IF_CHANGE 3
302
303 #define BRCMF_E_IF_ROLE_STA 0
304 #define BRCMF_E_IF_ROLE_AP 1
305 #define BRCMF_E_IF_ROLE_WDS 2
306
307 #define BRCMF_E_LINK_BCN_LOSS 1
308 #define BRCMF_E_LINK_DISASSOC 2
309 #define BRCMF_E_LINK_ASSOC_REC 3
310 #define BRCMF_E_LINK_BSSCFG_DIS 4
311
312 /* The level of bus communication with the dongle */
313 enum brcmf_bus_state {
314 BRCMF_BUS_DOWN, /* Not ready for frame transfers */
315 BRCMF_BUS_LOAD, /* Download access only (CPU reset) */
316 BRCMF_BUS_DATA /* Ready for frame transfers */
317 };
318
319 /* Pattern matching filter. Specifies an offset within received packets to
320 * start matching, the pattern to match, the size of the pattern, and a bitmask
321 * that indicates which bits within the pattern should be matched.
322 */
323 struct brcmf_pkt_filter_pattern {
324 u32 offset; /* Offset within received packet to start pattern matching.
325 * Offset '0' is the first byte of the ethernet header.
326 */
327 u32 size_bytes; /* Size of the pattern. Bitmask must be the same size. */
328 u8 mask_and_pattern[1]; /* Variable length mask and pattern data. mask starts
329 * at offset 0. Pattern immediately follows mask.
330 */
331 };
332
333 /* IOVAR "pkt_filter_add" parameter. Used to install packet filters. */
334 struct brcmf_pkt_filter {
335 u32 id; /* Unique filter id, specified by app. */
336 u32 type; /* Filter type (WL_PKT_FILTER_TYPE_xxx). */
337 u32 negate_match; /* Negate the result of filter matches */
338 union { /* Filter definitions */
339 struct brcmf_pkt_filter_pattern pattern; /* Filter pattern */
340 } u;
341 };
342
343 /* IOVAR "pkt_filter_enable" parameter. */
344 struct brcmf_pkt_filter_enable {
345 u32 id; /* Unique filter id */
346 u32 enable; /* Enable/disable bool */
347 };
348
349 /* BSS info structure
350 * Applications MUST CHECK ie_offset field and length field to access IEs and
351 * next bss_info structure in a vector (in struct brcmf_scan_results)
352 */
353 struct brcmf_bss_info {
354 u32 version; /* version field */
355 u32 length; /* byte length of data in this record,
356 * starting at version and including IEs
357 */
358 u8 BSSID[ETH_ALEN];
359 u16 beacon_period; /* units are Kusec */
360 u16 capability; /* Capability information */
361 u8 SSID_len;
362 u8 SSID[32];
363 struct {
364 uint count; /* # rates in this set */
365 u8 rates[16]; /* rates in 500kbps units w/hi bit set if basic */
366 } rateset; /* supported rates */
367 chanspec_t chanspec; /* chanspec for bss */
368 u16 atim_window; /* units are Kusec */
369 u8 dtim_period; /* DTIM period */
370 s16 RSSI; /* receive signal strength (in dBm) */
371 s8 phy_noise; /* noise (in dBm) */
372
373 u8 n_cap; /* BSS is 802.11N Capable */
374 u32 nbss_cap; /* 802.11N BSS Capabilities (based on HT_CAP_*) */
375 u8 ctl_ch; /* 802.11N BSS control channel number */
376 u32 reserved32[1]; /* Reserved for expansion of BSS properties */
377 u8 flags; /* flags */
378 u8 reserved[3]; /* Reserved for expansion of BSS properties */
379 u8 basic_mcs[MCSSET_LEN]; /* 802.11N BSS required MCS set */
380
381 u16 ie_offset; /* offset at which IEs start, from beginning */
382 u32 ie_length; /* byte length of Information Elements */
383 s16 SNR; /* average SNR of during frame reception */
384 /* Add new fields here */
385 /* variable length Information Elements */
386 };
387
388 struct brcmf_ssid {
389 u32 SSID_len;
390 unsigned char SSID[32];
391 };
392
393 struct brcmf_scan_params {
394 struct brcmf_ssid ssid; /* default: {0, ""} */
395 u8 bssid[ETH_ALEN]; /* default: bcast */
396 s8 bss_type; /* default: any,
397 * DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT
398 */
399 u8 scan_type; /* flags, 0 use default */
400 s32 nprobes; /* -1 use default, number of probes per channel */
401 s32 active_time; /* -1 use default, dwell time per channel for
402 * active scanning
403 */
404 s32 passive_time; /* -1 use default, dwell time per channel
405 * for passive scanning
406 */
407 s32 home_time; /* -1 use default, dwell time for the home channel
408 * between channel scans
409 */
410 s32 channel_num; /* count of channels and ssids that follow
411 *
412 * low half is count of channels in
413 * channel_list, 0 means default (use all
414 * available channels)
415 *
416 * high half is entries in struct brcmf_ssid
417 * array that follows channel_list, aligned for
418 * s32 (4 bytes) meaning an odd channel count
419 * implies a 2-byte pad between end of
420 * channel_list and first ssid
421 *
422 * if ssid count is zero, single ssid in the
423 * fixed parameter portion is assumed, otherwise
424 * ssid in the fixed portion is ignored
425 */
426 u16 channel_list[1]; /* list of chanspecs */
427 };
428
429 /* incremental scan struct */
430 struct brcmf_iscan_params {
431 u32 version;
432 u16 action;
433 u16 scan_duration;
434 struct brcmf_scan_params params;
435 };
436
437 /* 3 fields + size of brcmf_scan_params, not including variable length array */
438 #define BRCMF_ISCAN_PARAMS_FIXED_SIZE \
439 (offsetof(struct brcmf_iscan_params, params) + \
440 sizeof(struct brcmf_ssid))
441
442 struct brcmf_scan_results {
443 u32 buflen;
444 u32 version;
445 u32 count;
446 struct brcmf_bss_info bss_info[1];
447 };
448
449 /* used for association with a specific BSSID and chanspec list */
450 struct brcmf_assoc_params {
451 u8 bssid[ETH_ALEN]; /* 00:00:00:00:00:00: broadcast scan */
452 s32 chanspec_num; /* 0: all available channels,
453 * otherwise count of chanspecs in chanspec_list
454 */
455 chanspec_t chanspec_list[1]; /* list of chanspecs */
456 };
457 #define BRCMF_ASSOC_PARAMS_FIXED_SIZE \
458 (sizeof(struct brcmf_assoc_params) - sizeof(chanspec_t))
459
460 /* used for join with or without a specific bssid and channel list */
461 struct brcmf_join_params {
462 struct brcmf_ssid ssid;
463 struct brcmf_assoc_params params;
464 };
465
466 /* size of brcmf_scan_results not including variable length array */
467 #define BRCMF_SCAN_RESULTS_FIXED_SIZE \
468 (sizeof(struct brcmf_scan_results) - sizeof(struct brcmf_bss_info))
469
470 /* incremental scan results struct */
471 struct brcmf_iscan_results {
472 u32 status;
473 struct brcmf_scan_results results;
474 };
475
476 /* size of brcmf_iscan_results not including variable length array */
477 #define BRCMF_ISCAN_RESULTS_FIXED_SIZE \
478 (BRCMF_SCAN_RESULTS_FIXED_SIZE + \
479 offsetof(struct brcmf_iscan_results, results))
480
481 struct brcmf_wsec_key {
482 u32 index; /* key index */
483 u32 len; /* key length */
484 u8 data[WLAN_MAX_KEY_LEN]; /* key data */
485 u32 pad_1[18];
486 u32 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
487 u32 flags; /* misc flags */
488 u32 pad_2[2];
489 int pad_3;
490 int iv_initialized; /* has IV been initialized already? */
491 int pad_4;
492 /* Rx IV */
493 struct {
494 u32 hi; /* upper 32 bits of IV */
495 u16 lo; /* lower 16 bits of IV */
496 } rxiv;
497 u32 pad_5[2];
498 u8 ea[ETH_ALEN]; /* per station */
499 };
500
501 /* Used to get specific STA parameters */
502 struct brcmf_scb_val {
503 u32 val;
504 u8 ea[ETH_ALEN];
505 };
506
507 /* channel encoding */
508 struct brcmf_channel_info {
509 int hw_channel;
510 int target_channel;
511 int scan_channel;
512 };
513
514 /* Linux network driver ioctl encoding */
515 struct brcmf_ioctl {
516 uint cmd; /* common ioctl definition */
517 void *buf; /* pointer to user buffer */
518 uint len; /* length of user buffer */
519 u8 set; /* get or set request (optional) */
520 uint used; /* bytes read or written (optional) */
521 uint needed; /* bytes needed (optional) */
522 };
523
524 /* Forward decls for struct brcmf_pub (see below) */
525 struct brcmf_bus; /* device bus info */
526 struct brcmf_proto; /* device communication protocol info */
527 struct brcmf_info; /* device driver info */
528
529 /* Common structure for module and instance linkage */
530 struct brcmf_pub {
531 /* Linkage ponters */
532 struct brcmf_bus *bus;
533 struct brcmf_proto *prot;
534 struct brcmf_info *info;
535
536 /* Internal brcmf items */
537 bool up; /* Driver up/down (to OS) */
538 bool txoff; /* Transmit flow-controlled */
539 bool dongle_reset; /* true = DEVRESET put dongle into reset */
540 enum brcmf_bus_state busstate;
541 uint hdrlen; /* Total BRCMF header length (proto + bus) */
542 uint maxctl; /* Max size rxctl request from proto to bus */
543 uint rxsz; /* Rx buffer size bus module should use */
544 u8 wme_dp; /* wme discard priority */
545
546 /* Dongle media info */
547 bool iswl; /* Dongle-resident driver is wl */
548 unsigned long drv_version; /* Version of dongle-resident driver */
549 u8 mac[ETH_ALEN]; /* MAC address obtained from dongle */
550 struct dngl_stats dstats; /* Stats for dongle-based data */
551
552 /* Additional stats for the bus level */
553 unsigned long tx_packets; /* Data packets sent to dongle */
554 unsigned long tx_multicast; /* Multicast data packets sent to dongle */
555 unsigned long tx_errors; /* Errors in sending data to dongle */
556 unsigned long tx_ctlpkts; /* Control packets sent to dongle */
557 unsigned long tx_ctlerrs; /* Errors sending control frames to dongle */
558 unsigned long rx_packets; /* Packets sent up the network interface */
559 unsigned long rx_multicast; /* Multicast packets sent up the network
560 interface */
561 unsigned long rx_errors; /* Errors processing rx data packets */
562 unsigned long rx_ctlpkts; /* Control frames processed from dongle */
563 unsigned long rx_ctlerrs; /* Errors in processing rx control frames */
564 unsigned long rx_dropped; /* Packets dropped locally (no memory) */
565 unsigned long rx_flushed; /* Packets flushed due to
566 unscheduled sendup thread */
567 unsigned long wd_dpc_sched; /* Number of times dpc scheduled by
568 watchdog timer */
569
570 unsigned long rx_readahead_cnt; /* Number of packets where header read-ahead
571 was used. */
572 unsigned long tx_realloc; /* Number of tx packets we had to realloc for
573 headroom */
574 unsigned long fc_packets; /* Number of flow control pkts recvd */
575
576 /* Last error return */
577 int bcmerror;
578 uint tickcnt;
579
580 /* Last error from dongle */
581 int dongle_error;
582
583 /* Suspend disable flag flag */
584 int suspend_disable_flag; /* "1" to disable all extra powersaving
585 during suspend */
586 int in_suspend; /* flag set to 1 when early suspend called */
587 int dtim_skip; /* dtim skip , default 0 means wake each dtim */
588
589 /* Pkt filter defination */
590 char *pktfilter[100];
591 int pktfilter_count;
592
593 u8 country_code[WLC_CNTRY_BUF_SZ];
594 char eventmask[BRCMF_EVENTING_MASK_LEN];
595
596 };
597
598 struct brcmf_if_event {
599 u8 ifidx;
600 u8 action;
601 u8 flags;
602 u8 bssidx;
603 };
604
605 struct brcmf_timeout {
606 u32 limit; /* Expiration time (usec) */
607 u32 increment; /* Current expiration increment (usec) */
608 u32 elapsed; /* Current elapsed time (usec) */
609 u32 tick; /* O/S tick time (usec) */
610 };
611
612 struct bcmevent_name {
613 uint event;
614 const char *name;
615 };
616
617 #if defined(CONFIG_PM_SLEEP)
618 extern atomic_t brcmf_mmc_suspend;
619 #define BRCMF_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
620 #define _BRCMF_PM_RESUME_WAIT(a, b) do { \
621 int retry = 0; \
622 while (atomic_read(&brcmf_mmc_suspend) && retry++ != b) { \
623 wait_event_timeout(a, false, HZ/100); \
624 } \
625 } while (0)
626 #define BRCMF_PM_RESUME_WAIT(a) _BRCMF_PM_RESUME_WAIT(a, 30)
627 #define BRCMF_PM_RESUME_RETURN_ERROR(a) \
628 do { if (atomic_read(&brcmf_mmc_suspend)) return a; } while (0)
629
630 #define BRCMF_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
631 #define BRCMF_SPINWAIT_SLEEP(a, exp, us) do { \
632 uint countdown = (us) + 9999; \
633 while ((exp) && (countdown >= 10000)) { \
634 wait_event_timeout(a, false, HZ/100); \
635 countdown -= 10000; \
636 } \
637 } while (0)
638
639 #else
640
641 #define BRCMF_PM_RESUME_WAIT_INIT(a)
642 #define BRCMF_PM_RESUME_WAIT(a)
643 #define BRCMF_PM_RESUME_RETURN_ERROR(a)
644
645 #define BRCMF_SPINWAIT_SLEEP_INIT(a)
646 #define BRCMF_SPINWAIT_SLEEP(a, exp, us) do { \
647 uint countdown = (us) + 9; \
648 while ((exp) && (countdown >= 10)) { \
649 udelay(10); \
650 countdown -= 10; \
651 } \
652 } while (0)
653
654 #endif /* defined(CONFIG_PM_SLEEP) */
655
656 /*
657 * Insmod parameters for debug/test
658 */
659
660 /* Use interrupts */
661 extern uint brcmf_intr;
662
663 /* Use polling */
664 extern uint brcmf_poll;
665
666 /* ARP offload agent mode */
667 extern uint brcmf_arp_mode;
668
669 /* ARP offload enable */
670 extern uint brcmf_arp_enable;
671
672 /* Pkt filte enable control */
673 extern uint brcmf_pkt_filter_enable;
674
675 /* Pkt filter init setup */
676 extern uint brcmf_pkt_filter_init;
677
678 /* Pkt filter mode control */
679 extern uint brcmf_master_mode;
680
681 /* Roaming mode control */
682 extern uint brcmf_roam;
683
684 /* Roaming mode control */
685 extern uint brcmf_radio_up;
686
687 /* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */
688 extern int brcmf_idletime;
689 #define BRCMF_IDLETIME_TICKS 1
690
691 /* SDIO Drive Strength */
692 extern uint brcmf_sdiod_drive_strength;
693
694 /* Override to force tx queueing all the time */
695 extern uint brcmf_force_tx_queueing;
696
697 #ifdef SDTEST
698 /* Echo packet generator (SDIO), pkts/s */
699 extern uint brcmf_pktgen;
700
701 /* Echo packet len (0 => sawtooth, max 1800) */
702 extern uint brcmf_pktgen_len;
703 #define BRCMF_MAX_PKTGEN_LEN 1800
704 #endif
705
706 extern u32 g_assert_type;
707 extern const struct bcmevent_name bcmevent_names[];
708 extern const int bcmevent_names_size;
709
710
711 static inline void MUTEX_LOCK_INIT(struct brcmf_pub *drvr)
712 {
713 }
714
715 static inline void MUTEX_LOCK(struct brcmf_pub *drvr)
716 {
717 }
718
719 static inline void MUTEX_UNLOCK(struct brcmf_pub *drvr)
720 {
721 }
722
723 static inline void MUTEX_LOCK_SOFTAP_SET_INIT(struct brcmf_pub *drvr)
724 {
725 }
726
727 static inline void MUTEX_LOCK_SOFTAP_SET(struct brcmf_pub *drvr)
728 {
729 }
730
731 static inline void MUTEX_UNLOCK_SOFTAP_SET(struct brcmf_pub *drvr)
732 {
733 }
734
735 static inline void MUTEX_LOCK_WL_SCAN_SET_INIT(void)
736 {
737 }
738
739 static inline void MUTEX_LOCK_WL_SCAN_SET(void)
740 {
741 }
742
743 static inline void MUTEX_UNLOCK_WL_SCAN_SET(void)
744 {
745 }
746
747 /* Indication from bus module regarding presence/insertion of dongle.
748 * Return struct brcmf_pub pointer, used as handle to OS module in later calls.
749 * Returned structure should have bus and prot pointers filled in.
750 * bus_hdrlen specifies required headroom for bus module header.
751 */
752 extern struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus,
753 uint bus_hdrlen);
754 extern int brcmf_net_attach(struct brcmf_pub *drvr, int idx);
755 extern int brcmf_netdev_wait_pend8021x(struct net_device *dev);
756
757 /* Indication from bus module regarding removal/absence of dongle */
758 extern void brcmf_detach(struct brcmf_pub *drvr);
759
760 /* Indication from bus module to change flow-control state */
761 extern void brcmf_txflowcontrol(struct brcmf_pub *drvr, int ifidx, bool on);
762
763 extern bool brcmf_c_prec_enq(struct brcmf_pub *drvr, struct pktq *q,
764 struct sk_buff *pkt, int prec);
765
766 /* Receive frame for delivery to OS. Callee disposes of rxp. */
767 extern void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx,
768 struct sk_buff *rxp, int numpkt);
769
770 /* Return pointer to interface name */
771 extern char *brcmf_ifname(struct brcmf_pub *drvr, int idx);
772
773 /* Notify tx completion */
774 extern void brcmf_txcomplete(struct brcmf_pub *drvr, struct sk_buff *txp,
775 bool success);
776
777 /* Query ioctl */
778 extern int brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx,
779 uint cmd, void *buf, uint len);
780
781 /* OS independent layer functions */
782 extern int brcmf_os_proto_block(struct brcmf_pub *drvr);
783 extern int brcmf_os_proto_unblock(struct brcmf_pub *drvr);
784 extern int brcmf_os_ioctl_resp_wait(struct brcmf_pub *drvr, uint *condition,
785 bool *pending);
786 extern int brcmf_os_ioctl_resp_wake(struct brcmf_pub *drvr);
787 extern unsigned int brcmf_os_get_ioctl_resp_timeout(void);
788 extern void brcmf_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
789 #ifdef BCMDBG
790 extern int brcmf_write_to_file(struct brcmf_pub *drvr, u8 *buf, int size);
791 #endif /* BCMDBG */
792
793 extern void brcmf_timeout_start(struct brcmf_timeout *tmo, uint usec);
794 extern int brcmf_timeout_expired(struct brcmf_timeout *tmo);
795
796 extern int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name);
797 extern int brcmf_c_host_event(struct brcmf_info *drvr_priv, int *idx,
798 void *pktdata, struct brcmf_event_msg *,
799 void **data_ptr);
800
801 extern void brcmf_c_init(void);
802
803 extern int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, void *handle,
804 char *name, u8 *mac_addr, u32 flags, u8 bssidx);
805 extern void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx);
806
807 /* Send packet to dongle via data channel */
808 extern int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx,\
809 struct sk_buff *pkt);
810
811 extern int brcmf_bus_devreset(struct brcmf_pub *drvr, u8 flag);
812 extern int brcmf_bus_start(struct brcmf_pub *drvr);
813
814 extern void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg);
815 extern void brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg,
816 int enable, int master_mode);
817
818 #ifdef BCMDBG
819 #define ASSERT(exp) \
820 do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0)
821 extern void osl_assert(char *exp, char *file, int line);
822 #else
823 #define ASSERT(exp) do {} while (0)
824 #endif /* defined(BCMDBG) */
825
826 /* Linux network driver ioctl encoding */
827 struct brcmf_c_ioctl {
828 uint cmd; /* common ioctl definition */
829 void *buf; /* pointer to user buffer */
830 uint len; /* length of user buffer */
831 bool set; /* get or set request (optional) */
832 uint used; /* bytes read or written (optional) */
833 uint needed; /* bytes needed (optional) */
834 uint driver; /* to identify target driver */
835 };
836
837 /* per-driver magic numbers */
838 #define BRCMF_IOCTL_MAGIC 0x00444944
839
840 /* bump this number if you change the ioctl interface */
841 #define BRCMF_IOCTL_VERSION 1
842 #define BRCMF_IOCTL_MAXLEN 8192 /* max length ioctl buffer required */
843
844 /* common ioctl definitions */
845 #define BRCMF_GET_MAGIC 0
846 #define BRCMF_GET_VERSION 1
847 #define BRCMF_GET_VAR 2
848 #define BRCMF_SET_VAR 3
849
850 /* message levels */
851 #define BRCMF_ERROR_VAL 0x0001
852 #define BRCMF_TRACE_VAL 0x0002
853 #define BRCMF_INFO_VAL 0x0004
854 #define BRCMF_DATA_VAL 0x0008
855 #define BRCMF_CTL_VAL 0x0010
856 #define BRCMF_TIMER_VAL 0x0020
857 #define BRCMF_HDRS_VAL 0x0040
858 #define BRCMF_BYTES_VAL 0x0080
859 #define BRCMF_INTR_VAL 0x0100
860 #define BRCMF_GLOM_VAL 0x0400
861 #define BRCMF_EVENT_VAL 0x0800
862 #define BRCMF_BTA_VAL 0x1000
863 #define BRCMF_ISCAN_VAL 0x2000
864
865 #ifdef SDTEST
866 /* For pktgen iovar */
867 struct brcmf_pktgen {
868 uint version; /* To allow structure change tracking */
869 uint freq; /* Max ticks between tx/rx attempts */
870 uint count; /* Test packets to send/rcv each attempt */
871 uint print; /* Print counts every <print> attempts */
872 uint total; /* Total packets (or bursts) */
873 uint minlen; /* Minimum length of packets to send */
874 uint maxlen; /* Maximum length of packets to send */
875 uint numsent; /* Count of test packets sent */
876 uint numrcvd; /* Count of test packets received */
877 uint numfail; /* Count of test send failures */
878 uint mode; /* Test mode (type of test packets) */
879 uint stop; /* Stop after this many tx failures */
880 };
881
882 /* Version in case structure changes */
883 #define BRCMF_PKTGEN_VERSION 2
884
885 /* Type of test packets to use */
886 #define BRCMF_PKTGEN_ECHO 1 /* Send echo requests */
887 #define BRCMF_PKTGEN_SEND 2 /* Send discard packets */
888 #define BRCMF_PKTGEN_RXBURST 3 /* Request dongle send N packets */
889 #define BRCMF_PKTGEN_RECV 4 /* Continuous rx from continuous
890 tx dongle */
891 #endif /* SDTEST */
892
893 /* Enter idle immediately (no timeout) */
894 #define BRCMF_IDLE_IMMEDIATE (-1)
895
896 /* Values for idleclock iovar: other values are the sd_divisor to use
897 when idle */
898 #define BRCMF_IDLE_ACTIVE 0 /* Do not request any SD clock change
899 when idle */
900
901 #endif /* _BRCMF_H_ */
This page took 0.071759 seconds and 5 git commands to generate.