staging: brcm80211: cleaned up macros in 802.11.h
[firefly-linux-kernel-4.4.55.git] / drivers / staging / brcm80211 / include / proto / 802.11.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 #ifndef _802_11_H_
18 #define _802_11_H_
19
20 #include <linux/if_ether.h>
21
22 #define DOT11_A3_HDR_LEN                24
23 #define DOT11_A4_HDR_LEN                30
24 #define DOT11_MAC_HDR_LEN               DOT11_A3_HDR_LEN
25 #define DOT11_ICV_AES_LEN               8
26 #define DOT11_QOS_LEN                   2
27
28 #define DOT11_IV_MAX_LEN                8
29
30 #define DOT11_DEFAULT_RTS_LEN           2347
31
32 #define DOT11_MIN_FRAG_LEN              256
33 #define DOT11_MAX_FRAG_LEN              2346
34 #define DOT11_DEFAULT_FRAG_LEN          2346
35
36 #define DOT11_MIN_BEACON_PERIOD         1
37 #define DOT11_MAX_BEACON_PERIOD         0xFFFF
38
39 #define DOT11_MIN_DTIM_PERIOD           1
40 #define DOT11_MAX_DTIM_PERIOD           0xFF
41
42 #define DOT11_OUI_LEN                   3
43
44 #define DOT11_RTS_LEN           16
45 #define DOT11_CTS_LEN           10
46 #define DOT11_ACK_LEN           10
47
48 #define DOT11_BA_BITMAP_LEN             128
49 #define DOT11_BA_LEN            4
50
51 #define DOT11_MGMT_HDR_LEN      24
52
53 struct dot11_bcn_prb {
54         u32 timestamp[2];
55         u16 beacon_interval;
56         u16 capability;
57 } __attribute__((packed));
58 #define DOT11_BCN_PRB_LEN       12
59
60 #define WME_OUI                 "\x00\x50\xf2"
61 #define WME_VER                 1
62 #define WME_TYPE                2
63 #define WME_SUBTYPE_PARAM_IE    1
64
65 #define AC_BE                   0
66 #define AC_BK                   1
67 #define AC_VI                   2
68 #define AC_VO                   3
69 #define AC_COUNT                4
70
71 typedef u8 ac_bitmap_t;
72
73 #define AC_BITMAP_ALL           0xf
74 #define AC_BITMAP_TST(ab, ac)   (((ab) & (1 << (ac))) != 0)
75
76 struct edcf_acparam {
77         u8 ACI;
78         u8 ECW;
79         u16 TXOP;
80 } __attribute__((packed));
81 typedef struct edcf_acparam edcf_acparam_t;
82
83 struct wme_param_ie {
84         u8 oui[3];
85         u8 type;
86         u8 subtype;
87         u8 version;
88         u8 qosinfo;
89         u8 rsvd;
90         edcf_acparam_t acparam[AC_COUNT];
91 } __attribute__((packed));
92 typedef struct wme_param_ie wme_param_ie_t;
93 #define WME_PARAM_IE_LEN            24
94
95 #define EDCF_AIFSN_MIN               1
96 #define EDCF_AIFSN_MAX               15
97 #define EDCF_AIFSN_MASK              0x0f
98 #define EDCF_ACM_MASK                0x10
99 #define EDCF_ACI_MASK                0x60
100 #define EDCF_ACI_SHIFT               5
101
102 #define EDCF_ECW2CW(exp)             ((1 << (exp)) - 1)
103 #define EDCF_ECWMIN_MASK             0x0f
104 #define EDCF_ECWMAX_MASK             0xf0
105 #define EDCF_ECWMAX_SHIFT            4
106
107 #define EDCF_TXOP2USEC(txop)         ((txop) << 5)
108
109 #define EDCF_AC_BE_ACI_STA           0x03
110 #define EDCF_AC_BE_ECW_STA           0xA4
111 #define EDCF_AC_BE_TXOP_STA          0x0000
112 #define EDCF_AC_BK_ACI_STA           0x27
113 #define EDCF_AC_BK_ECW_STA           0xA4
114 #define EDCF_AC_BK_TXOP_STA          0x0000
115 #define EDCF_AC_VI_ACI_STA           0x42
116 #define EDCF_AC_VI_ECW_STA           0x43
117 #define EDCF_AC_VI_TXOP_STA          0x005e
118 #define EDCF_AC_VO_ACI_STA           0x62
119 #define EDCF_AC_VO_ECW_STA           0x32
120 #define EDCF_AC_VO_TXOP_STA          0x002f
121
122 #define EDCF_AC_VO_TXOP_AP           0x002f
123
124 #define DOT11_OPEN_SYSTEM       0
125 #define DOT11_SHARED_KEY        1
126
127 #define SEQNUM_SHIFT            4
128 #define SEQNUM_MAX              0x1000
129 #define FRAGNUM_MASK            0xF
130
131 #define FC_SUBTYPE_ANY_QOS(s)   ((((fc) & IEEE80211_FCTL_STYPE & (1<<7))) != 0)
132
133 #define FC_KIND_MASK            (IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)
134
135 #define FC_PROBE_REQ    (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ)
136 #define FC_PROBE_RESP   (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP)
137 #define FC_BEACON       (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON)
138 #define FC_PS_POLL      (IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL)
139 #define FC_RTS          (IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS)
140 #define FC_CTS          (IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS)
141
142 #define TLV_LEN_OFF             1
143 #define TLV_HDR_LEN             2
144 #define TLV_BODY_OFF            2
145
146 #define DOT11_MNG_RSN_ID                        48
147 #define DOT11_MNG_WPA_ID                        221
148 #define DOT11_MNG_VS_ID                         221
149
150 #define DOT11_BSSTYPE_INFRASTRUCTURE            0
151 #define DOT11_BSSTYPE_ANY                       2
152 #define DOT11_SCANTYPE_ACTIVE                   0
153
154 #define PREN_PREAMBLE           24
155 #define PREN_MM_EXT             12
156 #define PREN_PREAMBLE_EXT       4
157
158 #define RIFS_11N_TIME           2
159
160 #define APHY_SLOT_TIME          9
161 #define APHY_SIFS_TIME          16
162 #define APHY_PREAMBLE_TIME      16
163 #define APHY_SIGNAL_TIME        4
164 #define APHY_SYMBOL_TIME        4
165 #define APHY_SERVICE_NBITS      16
166 #define APHY_TAIL_NBITS         6
167 #define APHY_CWMIN              15
168
169 #define BPHY_SLOT_TIME          20
170 #define BPHY_SIFS_TIME          10
171 #define BPHY_PLCP_TIME          192
172 #define BPHY_PLCP_SHORT_TIME    96
173
174 #define DOT11_OFDM_SIGNAL_EXTENSION     6
175
176 #define PHY_CWMAX               1023
177
178 #define DOT11_MAXNUMFRAGS       16
179
180 typedef struct d11cnt {
181         u32 txfrag;
182         u32 txmulti;
183         u32 txfail;
184         u32 txretry;
185         u32 txretrie;
186         u32 rxdup;
187         u32 txrts;
188         u32 txnocts;
189         u32 txnoack;
190         u32 rxfrag;
191         u32 rxmulti;
192         u32 rxcrc;
193         u32 txfrmsnt;
194         u32 rxundec;
195 } d11cnt_t;
196
197 #define MCSSET_LEN      16
198
199 struct ht_cap_ie {
200         u16 cap;
201         u8 params;
202         u8 supp_mcs[MCSSET_LEN];
203         u16 ext_htcap;
204         u32 txbf_cap;
205         u8 as_cap;
206 } __attribute__((packed));
207 typedef struct ht_cap_ie ht_cap_ie_t;
208
209 #define HT_CAP_IE_LEN           26
210
211 #define HT_CAP_MIMO_PS_MASK     0x000C
212 #define HT_CAP_MIMO_PS_OFF      0x0003
213 #define HT_CAP_MIMO_PS_ON       0x0000
214 #define HT_CAP_RX_STBC_MASK     0x0300
215 #define HT_CAP_RX_STBC_SHIFT    8
216 #define HT_CAP_MAX_AMSDU        0x0800
217
218 #define HT_CAP_RX_STBC_NO               0x0
219 #define HT_CAP_RX_STBC_ONE_STREAM       0x1
220
221 #define HT_PARAMS_RX_FACTOR_MASK        0x03
222
223 #define AMPDU_MAX_MPDU_DENSITY  7
224 #define AMPDU_RX_FACTOR_16K     1
225 #define AMPDU_RX_FACTOR_32K     2
226 #define AMPDU_RX_FACTOR_64K     3
227
228 #define AMPDU_DELIMITER_LEN     4
229
230 #define DOT11N_TXBURST          0x0008
231
232 #define WPA_VERSION             1
233 #define WPA_OUI                 "\x00\x50\xF2"
234
235 #define WFA_OUI                 "\x00\x50\xF2"
236 #define WFA_OUI_LEN     3
237
238 #define WFA_OUI_TYPE_WPA        1
239
240 #define RSN_AKM_NONE            0
241 #define RSN_AKM_UNSPECIFIED     1
242 #define RSN_AKM_PSK             2
243
244 #define DOT11_MAX_DEFAULT_KEYS  4
245 #define DOT11_MAX_KEY_SIZE      32
246 #define DOT11_WPA_KEY_RSC_LEN   8
247
248 #define BRCM_OUI                "\x00\x10\x18"
249
250 #endif                          /* _802_11_H_ */