Linux-libre 3.17.4-gnu
[librecmc/linux-libre.git] / drivers / net / wireless / brcm80211 / brcmfmac / fwil_types.h
1 /*
2  * Copyright (c) 2012 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 #ifndef FWIL_TYPES_H_
19 #define FWIL_TYPES_H_
20
21 #include <linux/if_ether.h>
22
23
24 #define BRCMF_FIL_ACTION_FRAME_SIZE     1800
25
26 /* ARP Offload feature flags for arp_ol iovar */
27 #define BRCMF_ARP_OL_AGENT              0x00000001
28 #define BRCMF_ARP_OL_SNOOP              0x00000002
29 #define BRCMF_ARP_OL_HOST_AUTO_REPLY    0x00000004
30 #define BRCMF_ARP_OL_PEER_AUTO_REPLY    0x00000008
31
32 #define BRCMF_BSS_INFO_VERSION  109 /* curr ver of brcmf_bss_info_le struct */
33 #define BRCMF_BSS_RSSI_ON_CHANNEL       0x0002
34
35 #define BRCMF_STA_ASSOC                 0x10            /* Associated */
36
37 /* size of brcmf_scan_params not including variable length array */
38 #define BRCMF_SCAN_PARAMS_FIXED_SIZE    64
39
40 /* masks for channel and ssid count */
41 #define BRCMF_SCAN_PARAMS_COUNT_MASK    0x0000ffff
42 #define BRCMF_SCAN_PARAMS_NSSID_SHIFT   16
43
44 /* primary (ie tx) key */
45 #define BRCMF_PRIMARY_KEY               (1 << 1)
46 #define DOT11_BSSTYPE_ANY               2
47 #define BRCMF_ESCAN_REQ_VERSION         1
48
49 #define BRCMF_MAXRATES_IN_SET           16      /* max # of rates in rateset */
50
51 /* OBSS Coex Auto/On/Off */
52 #define BRCMF_OBSS_COEX_AUTO            (-1)
53 #define BRCMF_OBSS_COEX_OFF             0
54 #define BRCMF_OBSS_COEX_ON              1
55
56 /* join preference types for join_pref iovar */
57 enum brcmf_join_pref_types {
58         BRCMF_JOIN_PREF_RSSI = 1,
59         BRCMF_JOIN_PREF_WPA,
60         BRCMF_JOIN_PREF_BAND,
61         BRCMF_JOIN_PREF_RSSI_DELTA,
62 };
63
64 enum brcmf_fil_p2p_if_types {
65         BRCMF_FIL_P2P_IF_CLIENT,
66         BRCMF_FIL_P2P_IF_GO,
67         BRCMF_FIL_P2P_IF_DYNBCN_GO,
68         BRCMF_FIL_P2P_IF_DEV,
69 };
70
71 struct brcmf_fil_p2p_if_le {
72         u8 addr[ETH_ALEN];
73         __le16 type;
74         __le16 chspec;
75 };
76
77 struct brcmf_fil_chan_info_le {
78         __le32 hw_channel;
79         __le32 target_channel;
80         __le32 scan_channel;
81 };
82
83 struct brcmf_fil_action_frame_le {
84         u8      da[ETH_ALEN];
85         __le16  len;
86         __le32  packet_id;
87         u8      data[BRCMF_FIL_ACTION_FRAME_SIZE];
88 };
89
90 struct brcmf_fil_af_params_le {
91         __le32                                  channel;
92         __le32                                  dwell_time;
93         u8                                      bssid[ETH_ALEN];
94         u8                                      pad[2];
95         struct brcmf_fil_action_frame_le        action_frame;
96 };
97
98 struct brcmf_fil_bss_enable_le {
99         __le32 bsscfg_idx;
100         __le32 enable;
101 };
102
103 struct brcmf_fil_bwcap_le {
104         __le32 band;
105         __le32 bw_cap;
106 };
107
108 /**
109  * struct tdls_iovar - common structure for tdls iovars.
110  *
111  * @ea: ether address of peer station.
112  * @mode: mode value depending on specific tdls iovar.
113  * @chanspec: channel specification.
114  * @pad: unused (for future use).
115  */
116 struct brcmf_tdls_iovar_le {
117         u8 ea[ETH_ALEN];                /* Station address */
118         u8 mode;                        /* mode: depends on iovar */
119         __le16 chanspec;
120         __le32 pad;                     /* future */
121 };
122
123 enum brcmf_tdls_manual_ep_ops {
124         BRCMF_TDLS_MANUAL_EP_CREATE = 1,
125         BRCMF_TDLS_MANUAL_EP_DELETE = 3,
126         BRCMF_TDLS_MANUAL_EP_DISCOVERY = 6
127 };
128
129 /* Pattern matching filter. Specifies an offset within received packets to
130  * start matching, the pattern to match, the size of the pattern, and a bitmask
131  * that indicates which bits within the pattern should be matched.
132  */
133 struct brcmf_pkt_filter_pattern_le {
134         /*
135          * Offset within received packet to start pattern matching.
136          * Offset '0' is the first byte of the ethernet header.
137          */
138         __le32 offset;
139         /* Size of the pattern.  Bitmask must be the same size.*/
140         __le32 size_bytes;
141         /*
142          * Variable length mask and pattern data. mask starts at offset 0.
143          * Pattern immediately follows mask.
144          */
145         u8 mask_and_pattern[1];
146 };
147
148 /* IOVAR "pkt_filter_add" parameter. Used to install packet filters. */
149 struct brcmf_pkt_filter_le {
150         __le32 id;              /* Unique filter id, specified by app. */
151         __le32 type;            /* Filter type (WL_PKT_FILTER_TYPE_xxx). */
152         __le32 negate_match;    /* Negate the result of filter matches */
153         union {                 /* Filter definitions */
154                 struct brcmf_pkt_filter_pattern_le pattern; /* Filter pattern */
155         } u;
156 };
157
158 /* IOVAR "pkt_filter_enable" parameter. */
159 struct brcmf_pkt_filter_enable_le {
160         __le32 id;              /* Unique filter id */
161         __le32 enable;          /* Enable/disable bool */
162 };
163
164 /* BSS info structure
165  * Applications MUST CHECK ie_offset field and length field to access IEs and
166  * next bss_info structure in a vector (in struct brcmf_scan_results)
167  */
168 struct brcmf_bss_info_le {
169         __le32 version;         /* version field */
170         __le32 length;          /* byte length of data in this record,
171                                  * starting at version and including IEs
172                                  */
173         u8 BSSID[ETH_ALEN];
174         __le16 beacon_period;   /* units are Kusec */
175         __le16 capability;      /* Capability information */
176         u8 SSID_len;
177         u8 SSID[32];
178         struct {
179                 __le32 count;   /* # rates in this set */
180                 u8 rates[16]; /* rates in 500kbps units w/hi bit set if basic */
181         } rateset;              /* supported rates */
182         __le16 chanspec;        /* chanspec for bss */
183         __le16 atim_window;     /* units are Kusec */
184         u8 dtim_period; /* DTIM period */
185         __le16 RSSI;            /* receive signal strength (in dBm) */
186         s8 phy_noise;           /* noise (in dBm) */
187
188         u8 n_cap;               /* BSS is 802.11N Capable */
189         /* 802.11N BSS Capabilities (based on HT_CAP_*): */
190         __le32 nbss_cap;
191         u8 ctl_ch;              /* 802.11N BSS control channel number */
192         __le32 reserved32[1];   /* Reserved for expansion of BSS properties */
193         u8 flags;               /* flags */
194         u8 reserved[3]; /* Reserved for expansion of BSS properties */
195         u8 basic_mcs[MCSSET_LEN];       /* 802.11N BSS required MCS set */
196
197         __le16 ie_offset;       /* offset at which IEs start, from beginning */
198         __le32 ie_length;       /* byte length of Information Elements */
199         __le16 SNR;             /* average SNR of during frame reception */
200         /* Add new fields here */
201         /* variable length Information Elements */
202 };
203
204 struct brcm_rateset_le {
205         /* # rates in this set */
206         __le32 count;
207         /* rates in 500kbps units w/hi bit set if basic */
208         u8 rates[BRCMF_MAXRATES_IN_SET];
209 };
210
211 struct brcmf_ssid {
212         u32 SSID_len;
213         unsigned char SSID[32];
214 };
215
216 struct brcmf_ssid_le {
217         __le32 SSID_len;
218         unsigned char SSID[32];
219 };
220
221 struct brcmf_scan_params_le {
222         struct brcmf_ssid_le ssid_le;   /* default: {0, ""} */
223         u8 bssid[ETH_ALEN];     /* default: bcast */
224         s8 bss_type;            /* default: any,
225                                  * DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT
226                                  */
227         u8 scan_type;   /* flags, 0 use default */
228         __le32 nprobes;   /* -1 use default, number of probes per channel */
229         __le32 active_time;     /* -1 use default, dwell time per channel for
230                                  * active scanning
231                                  */
232         __le32 passive_time;    /* -1 use default, dwell time per channel
233                                  * for passive scanning
234                                  */
235         __le32 home_time;       /* -1 use default, dwell time for the
236                                  * home channel between channel scans
237                                  */
238         __le32 channel_num;     /* count of channels and ssids that follow
239                                  *
240                                  * low half is count of channels in
241                                  * channel_list, 0 means default (use all
242                                  * available channels)
243                                  *
244                                  * high half is entries in struct brcmf_ssid
245                                  * array that follows channel_list, aligned for
246                                  * s32 (4 bytes) meaning an odd channel count
247                                  * implies a 2-byte pad between end of
248                                  * channel_list and first ssid
249                                  *
250                                  * if ssid count is zero, single ssid in the
251                                  * fixed parameter portion is assumed, otherwise
252                                  * ssid in the fixed portion is ignored
253                                  */
254         __le16 channel_list[1]; /* list of chanspecs */
255 };
256
257 struct brcmf_scan_results {
258         u32 buflen;
259         u32 version;
260         u32 count;
261         struct brcmf_bss_info_le bss_info_le[];
262 };
263
264 struct brcmf_escan_params_le {
265         __le32 version;
266         __le16 action;
267         __le16 sync_id;
268         struct brcmf_scan_params_le params_le;
269 };
270
271 struct brcmf_escan_result_le {
272         __le32 buflen;
273         __le32 version;
274         __le16 sync_id;
275         __le16 bss_count;
276         struct brcmf_bss_info_le bss_info_le;
277 };
278
279 #define WL_ESCAN_RESULTS_FIXED_SIZE (sizeof(struct brcmf_escan_result_le) - \
280         sizeof(struct brcmf_bss_info_le))
281
282 /* used for association with a specific BSSID and chanspec list */
283 struct brcmf_assoc_params_le {
284         /* 00:00:00:00:00:00: broadcast scan */
285         u8 bssid[ETH_ALEN];
286         /* 0: all available channels, otherwise count of chanspecs in
287          * chanspec_list */
288         __le32 chanspec_num;
289         /* list of chanspecs */
290         __le16 chanspec_list[1];
291 };
292
293 /**
294  * struct join_pref params - parameters for preferred join selection.
295  *
296  * @type: preference type (see enum brcmf_join_pref_types).
297  * @len: length of bytes following (currently always 2).
298  * @rssi_gain: signal gain for selection (only when @type is RSSI_DELTA).
299  * @band: band to which selection preference applies.
300  *      This is used if @type is BAND or RSSI_DELTA.
301  */
302 struct brcmf_join_pref_params {
303         u8 type;
304         u8 len;
305         u8 rssi_gain;
306         u8 band;
307 };
308
309 /* used for join with or without a specific bssid and channel list */
310 struct brcmf_join_params {
311         struct brcmf_ssid_le ssid_le;
312         struct brcmf_assoc_params_le params_le;
313 };
314
315 /* scan params for extended join */
316 struct brcmf_join_scan_params_le {
317         u8 scan_type;           /* 0 use default, active or passive scan */
318         __le32 nprobes;         /* -1 use default, nr of probes per channel */
319         __le32 active_time;     /* -1 use default, dwell time per channel for
320                                  * active scanning
321                                  */
322         __le32 passive_time;    /* -1 use default, dwell time per channel
323                                  * for passive scanning
324                                  */
325         __le32 home_time;       /* -1 use default, dwell time for the home
326                                  * channel between channel scans
327                                  */
328 };
329
330 /* extended join params */
331 struct brcmf_ext_join_params_le {
332         struct brcmf_ssid_le ssid_le;   /* {0, ""}: wildcard scan */
333         struct brcmf_join_scan_params_le scan_le;
334         struct brcmf_assoc_params_le assoc_le;
335 };
336
337 struct brcmf_wsec_key {
338         u32 index;              /* key index */
339         u32 len;                /* key length */
340         u8 data[WLAN_MAX_KEY_LEN];      /* key data */
341         u32 pad_1[18];
342         u32 algo;       /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
343         u32 flags;      /* misc flags */
344         u32 pad_2[3];
345         u32 iv_initialized;     /* has IV been initialized already? */
346         u32 pad_3;
347         /* Rx IV */
348         struct {
349                 u32 hi; /* upper 32 bits of IV */
350                 u16 lo; /* lower 16 bits of IV */
351         } rxiv;
352         u32 pad_4[2];
353         u8 ea[ETH_ALEN];        /* per station */
354 };
355
356 /*
357  * dongle requires same struct as above but with fields in little endian order
358  */
359 struct brcmf_wsec_key_le {
360         __le32 index;           /* key index */
361         __le32 len;             /* key length */
362         u8 data[WLAN_MAX_KEY_LEN];      /* key data */
363         __le32 pad_1[18];
364         __le32 algo;    /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
365         __le32 flags;   /* misc flags */
366         __le32 pad_2[3];
367         __le32 iv_initialized;  /* has IV been initialized already? */
368         __le32 pad_3;
369         /* Rx IV */
370         struct {
371                 __le32 hi;      /* upper 32 bits of IV */
372                 __le16 lo;      /* lower 16 bits of IV */
373         } rxiv;
374         __le32 pad_4[2];
375         u8 ea[ETH_ALEN];        /* per station */
376 };
377
378 /* Used to get specific STA parameters */
379 struct brcmf_scb_val_le {
380         __le32 val;
381         u8 ea[ETH_ALEN];
382 };
383
384 /* channel encoding */
385 struct brcmf_channel_info_le {
386         __le32 hw_channel;
387         __le32 target_channel;
388         __le32 scan_channel;
389 };
390
391 struct brcmf_sta_info_le {
392         __le16  ver;            /* version of this struct */
393         __le16  len;            /* length in bytes of this structure */
394         __le16  cap;            /* sta's advertised capabilities */
395         __le32  flags;          /* flags defined below */
396         __le32  idle;           /* time since data pkt rx'd from sta */
397         u8      ea[ETH_ALEN];           /* Station address */
398         __le32  count;                  /* # rates in this set */
399         u8      rates[BRCMF_MAXRATES_IN_SET];   /* rates in 500kbps units */
400                                                 /* w/hi bit set if basic */
401         __le32  in;             /* seconds elapsed since associated */
402         __le32  listen_interval_inms; /* Min Listen interval in ms for STA */
403         __le32  tx_pkts;        /* # of packets transmitted */
404         __le32  tx_failures;    /* # of packets failed */
405         __le32  rx_ucast_pkts;  /* # of unicast packets received */
406         __le32  rx_mcast_pkts;  /* # of multicast packets received */
407         __le32  tx_rate;        /* Rate of last successful tx frame */
408         __le32  rx_rate;        /* Rate of last successful rx frame */
409         __le32  rx_decrypt_succeeds;    /* # of packet decrypted successfully */
410         __le32  rx_decrypt_failures;    /* # of packet decrypted failed */
411 };
412
413 struct brcmf_chanspec_list {
414         __le32  count;          /* # of entries */
415         __le32  element[1];     /* variable length uint32 list */
416 };
417
418 /*
419  * WLC_E_PROBRESP_MSG
420  * WLC_E_P2P_PROBREQ_MSG
421  * WLC_E_ACTION_FRAME_RX
422  */
423 struct brcmf_rx_mgmt_data {
424         __be16  version;
425         __be16  chanspec;
426         __be32  rssi;
427         __be32  mactime;
428         __be32  rate;
429 };
430
431 #endif /* FWIL_TYPES_H_ */