]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/net80211/_ieee80211.h
This commit was generated by cvs2svn to compensate for changes in r179191,
[FreeBSD/FreeBSD.git] / sys / net80211 / _ieee80211.h
1 /*-
2  * Copyright (c) 2001 Atsushi Onoe
3  * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28 #ifndef _NET80211__IEEE80211_H_
29 #define _NET80211__IEEE80211_H_
30
31 /*
32  * 802.11 implementation definitions.
33  *
34  * NB: this file is used by applications.
35  */
36
37 /*
38  * PHY type; mostly used to identify FH phys.
39  */
40 enum ieee80211_phytype {
41         IEEE80211_T_DS,                 /* direct sequence spread spectrum */
42         IEEE80211_T_FH,                 /* frequency hopping */
43         IEEE80211_T_OFDM,               /* frequency division multiplexing */
44         IEEE80211_T_TURBO,              /* high rate OFDM, aka turbo mode */
45         IEEE80211_T_HT,                 /* high throughput */
46 };
47 #define IEEE80211_T_CCK IEEE80211_T_DS  /* more common nomenclature */
48
49 /*
50  * PHY mode; this is not really a mode as multi-mode devices
51  * have multiple PHY's.  Mode is mostly used as a shorthand
52  * for constraining which channels to consider in setting up
53  * operation.  Modes used to be used more extensively when
54  * channels were identified as IEEE channel numbers.
55  */
56 enum ieee80211_phymode {
57         IEEE80211_MODE_AUTO     = 0,    /* autoselect */
58         IEEE80211_MODE_11A      = 1,    /* 5GHz, OFDM */
59         IEEE80211_MODE_11B      = 2,    /* 2GHz, CCK */
60         IEEE80211_MODE_11G      = 3,    /* 2GHz, OFDM */
61         IEEE80211_MODE_FH       = 4,    /* 2GHz, GFSK */
62         IEEE80211_MODE_TURBO_A  = 5,    /* 5GHz, OFDM, 2x clock */
63         IEEE80211_MODE_TURBO_G  = 6,    /* 2GHz, OFDM, 2x clock */
64         IEEE80211_MODE_STURBO_A = 7,    /* 5GHz, OFDM, 2x clock, static */
65         IEEE80211_MODE_11NA     = 8,    /* 5GHz, w/ HT */
66         IEEE80211_MODE_11NG     = 9,    /* 2GHz, w/ HT */
67 };
68 #define IEEE80211_MODE_MAX      (IEEE80211_MODE_11NG+1)
69
70 /*
71  * Operating mode.  Devices do not necessarily support
72  * all modes; they indicate which are supported in their
73  * capabilities.
74  */
75 enum ieee80211_opmode {
76         IEEE80211_M_IBSS        = 0,    /* IBSS (adhoc) station */
77         IEEE80211_M_STA         = 1,    /* infrastructure station */
78         IEEE80211_M_WDS         = 2,    /* WDS link */
79         IEEE80211_M_AHDEMO      = 3,    /* Old lucent compatible adhoc demo */
80         IEEE80211_M_HOSTAP      = 4,    /* Software Access Point */
81         IEEE80211_M_MONITOR     = 5,    /* Monitor mode */
82 };
83 #define IEEE80211_OPMODE_MAX    (IEEE80211_M_MONITOR+1)
84
85 /*
86  * 802.11g/802.11n protection mode.
87  */
88 enum ieee80211_protmode {
89         IEEE80211_PROT_NONE     = 0,    /* no protection */
90         IEEE80211_PROT_CTSONLY  = 1,    /* CTS to self */
91         IEEE80211_PROT_RTSCTS   = 2,    /* RTS-CTS */
92 };
93
94 /*
95  * Authentication mode.  The open and shared key authentication
96  * modes are implemented within the 802.11 layer.  802.1x and
97  * WPA/802.11i are implemented in user mode by setting the
98  * 802.11 layer into IEEE80211_AUTH_8021X and deferring
99  * authentication to user space programs.
100  */
101 enum ieee80211_authmode {
102         IEEE80211_AUTH_NONE     = 0,
103         IEEE80211_AUTH_OPEN     = 1,            /* open */
104         IEEE80211_AUTH_SHARED   = 2,            /* shared-key */
105         IEEE80211_AUTH_8021X    = 3,            /* 802.1x */
106         IEEE80211_AUTH_AUTO     = 4,            /* auto-select/accept */
107         /* NB: these are used only for ioctls */
108         IEEE80211_AUTH_WPA      = 5,            /* WPA/RSN w/ 802.1x/PSK */
109 };
110
111 /*
112  * Roaming mode is effectively who controls the operation
113  * of the 802.11 state machine when operating as a station.
114  * State transitions are controlled either by the driver
115  * (typically when management frames are processed by the
116  * hardware/firmware), the host (auto/normal operation of
117  * the 802.11 layer), or explicitly through ioctl requests
118  * when applications like wpa_supplicant want control.
119  */
120 enum ieee80211_roamingmode {
121         IEEE80211_ROAMING_DEVICE= 0,    /* driver/hardware control */
122         IEEE80211_ROAMING_AUTO  = 1,    /* 802.11 layer control */
123         IEEE80211_ROAMING_MANUAL= 2,    /* application control */
124 };
125
126 /*
127  * Channels are specified by frequency and attributes.
128  */
129 struct ieee80211_channel {
130         uint32_t        ic_flags;       /* see below */
131         uint16_t        ic_freq;        /* setting in Mhz */
132         uint8_t         ic_ieee;        /* IEEE channel number */
133         int8_t          ic_maxregpower; /* maximum regulatory tx power in dBm */
134         int8_t          ic_maxpower;    /* maximum tx power in .5 dBm */
135         int8_t          ic_minpower;    /* minimum tx power in .5 dBm */
136         uint8_t         ic_state;       /* dynamic state */
137         uint8_t         ic_extieee;     /* HT40 extension channel number */
138 };
139
140 #define IEEE80211_CHAN_MAX      255
141 #define IEEE80211_CHAN_BYTES    32      /* howmany(IEEE80211_CHAN_MAX, NBBY) */
142 #define IEEE80211_CHAN_ANY      0xffff  /* token for ``any channel'' */
143 #define IEEE80211_CHAN_ANYC \
144         ((struct ieee80211_channel *) IEEE80211_CHAN_ANY)
145
146 /* bits 0-3 are for private use by drivers */
147 /* channel attributes */
148 #define IEEE80211_CHAN_TURBO    0x00000010 /* Turbo channel */
149 #define IEEE80211_CHAN_CCK      0x00000020 /* CCK channel */
150 #define IEEE80211_CHAN_OFDM     0x00000040 /* OFDM channel */
151 #define IEEE80211_CHAN_2GHZ     0x00000080 /* 2 GHz spectrum channel. */
152 #define IEEE80211_CHAN_5GHZ     0x00000100 /* 5 GHz spectrum channel */
153 #define IEEE80211_CHAN_PASSIVE  0x00000200 /* Only passive scan allowed */
154 #define IEEE80211_CHAN_DYN      0x00000400 /* Dynamic CCK-OFDM channel */
155 #define IEEE80211_CHAN_GFSK     0x00000800 /* GFSK channel (FHSS PHY) */
156 #define IEEE80211_CHAN_GSM      0x00001000 /* 900 MHz spectrum channel */
157 #define IEEE80211_CHAN_STURBO   0x00002000 /* 11a static turbo channel only */
158 #define IEEE80211_CHAN_HALF     0x00004000 /* Half rate channel */
159 #define IEEE80211_CHAN_QUARTER  0x00008000 /* Quarter rate channel */
160 #define IEEE80211_CHAN_HT20     0x00010000 /* HT 20 channel */
161 #define IEEE80211_CHAN_HT40U    0x00020000 /* HT 40 channel w/ ext above */
162 #define IEEE80211_CHAN_HT40D    0x00040000 /* HT 40 channel w/ ext below */
163 #define IEEE80211_CHAN_DFS      0x00080000 /* DFS required */
164 #define IEEE80211_CHAN_4MSXMIT  0x00100000 /* 4ms limit on frame length */
165 #define IEEE80211_CHAN_NOADHOC  0x00200000 /* adhoc mode not allowed */
166 #define IEEE80211_CHAN_NOHOSTAP 0x00400000 /* hostap mode not allowed */
167 #define IEEE80211_CHAN_11D      0x00800000 /* 802.11d required */
168
169 #define IEEE80211_CHAN_HT40     (IEEE80211_CHAN_HT40U | IEEE80211_CHAN_HT40D)
170 #define IEEE80211_CHAN_HT       (IEEE80211_CHAN_HT20 | IEEE80211_CHAN_HT40)
171
172 /*
173  * Useful combinations of channel characteristics.
174  */
175 #define IEEE80211_CHAN_FHSS \
176         (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
177 #define IEEE80211_CHAN_A \
178         (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
179 #define IEEE80211_CHAN_B \
180         (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
181 #define IEEE80211_CHAN_PUREG \
182         (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
183 #define IEEE80211_CHAN_G \
184         (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
185 #define IEEE80211_CHAN_108A \
186         (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
187 #define IEEE80211_CHAN_108G \
188         (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
189 #define IEEE80211_CHAN_ST \
190         (IEEE80211_CHAN_108A | IEEE80211_CHAN_STURBO)
191
192 #define IEEE80211_CHAN_ALL \
193         (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_GFSK | \
194          IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_DYN | \
195          IEEE80211_CHAN_HT)
196 #define IEEE80211_CHAN_ALLTURBO \
197         (IEEE80211_CHAN_ALL | IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)
198
199 #define IEEE80211_IS_CHAN_FHSS(_c) \
200         (((_c)->ic_flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS)
201 #define IEEE80211_IS_CHAN_A(_c) \
202         (((_c)->ic_flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A)
203 #define IEEE80211_IS_CHAN_B(_c) \
204         (((_c)->ic_flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B)
205 #define IEEE80211_IS_CHAN_PUREG(_c) \
206         (((_c)->ic_flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG)
207 #define IEEE80211_IS_CHAN_G(_c) \
208         (((_c)->ic_flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G)
209 #define IEEE80211_IS_CHAN_ANYG(_c) \
210         (IEEE80211_IS_CHAN_PUREG(_c) || IEEE80211_IS_CHAN_G(_c))
211 #define IEEE80211_IS_CHAN_ST(_c) \
212         (((_c)->ic_flags & IEEE80211_CHAN_ST) == IEEE80211_CHAN_ST)
213 #define IEEE80211_IS_CHAN_108A(_c) \
214         (((_c)->ic_flags & IEEE80211_CHAN_108A) == IEEE80211_CHAN_108A)
215 #define IEEE80211_IS_CHAN_108G(_c) \
216         (((_c)->ic_flags & IEEE80211_CHAN_108G) == IEEE80211_CHAN_108G)
217
218 #define IEEE80211_IS_CHAN_2GHZ(_c) \
219         (((_c)->ic_flags & IEEE80211_CHAN_2GHZ) != 0)
220 #define IEEE80211_IS_CHAN_5GHZ(_c) \
221         (((_c)->ic_flags & IEEE80211_CHAN_5GHZ) != 0)
222 #define IEEE80211_IS_CHAN_PASSIVE(_c) \
223         (((_c)->ic_flags & IEEE80211_CHAN_PASSIVE) != 0)
224 #define IEEE80211_IS_CHAN_OFDM(_c) \
225         (((_c)->ic_flags & IEEE80211_CHAN_OFDM) != 0)
226 #define IEEE80211_IS_CHAN_CCK(_c) \
227         (((_c)->ic_flags & IEEE80211_CHAN_CCK) != 0)
228 #define IEEE80211_IS_CHAN_GFSK(_c) \
229         (((_c)->ic_flags & IEEE80211_CHAN_GFSK) != 0)
230 #define IEEE80211_IS_CHAN_TURBO(_c) \
231         (((_c)->ic_flags & IEEE80211_CHAN_TURBO) != 0)
232 #define IEEE80211_IS_CHAN_STURBO(_c) \
233         (((_c)->ic_flags & IEEE80211_CHAN_STURBO) != 0)
234 #define IEEE80211_IS_CHAN_DTURBO(_c) \
235         (((_c)->ic_flags & \
236         (IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)) == IEEE80211_CHAN_TURBO)
237 #define IEEE80211_IS_CHAN_HALF(_c) \
238         (((_c)->ic_flags & IEEE80211_CHAN_HALF) != 0)
239 #define IEEE80211_IS_CHAN_QUARTER(_c) \
240         (((_c)->ic_flags & IEEE80211_CHAN_QUARTER) != 0)
241 #define IEEE80211_IS_CHAN_FULL(_c) \
242         (((_c)->ic_flags & (IEEE80211_CHAN_QUARTER | IEEE80211_CHAN_HALF)) == 0)
243 #define IEEE80211_IS_CHAN_GSM(_c) \
244         (((_c)->ic_flags & IEEE80211_CHAN_GSM) != 0)
245 #define IEEE80211_IS_CHAN_HT(_c) \
246         (((_c)->ic_flags & IEEE80211_CHAN_HT) != 0)
247 #define IEEE80211_IS_CHAN_HT20(_c) \
248         (((_c)->ic_flags & IEEE80211_CHAN_HT20) != 0)
249 #define IEEE80211_IS_CHAN_HT40(_c) \
250         (((_c)->ic_flags & IEEE80211_CHAN_HT40) != 0)
251 #define IEEE80211_IS_CHAN_HT40U(_c) \
252         (((_c)->ic_flags & IEEE80211_CHAN_HT40U) != 0)
253 #define IEEE80211_IS_CHAN_HT40D(_c) \
254         (((_c)->ic_flags & IEEE80211_CHAN_HT40D) != 0)
255 #define IEEE80211_IS_CHAN_HTA(_c) \
256         (IEEE80211_IS_CHAN_5GHZ(_c) && \
257          ((_c)->ic_flags & IEEE80211_CHAN_HT) != 0)
258 #define IEEE80211_IS_CHAN_HTG(_c) \
259         (IEEE80211_IS_CHAN_2GHZ(_c) && \
260          ((_c)->ic_flags & IEEE80211_CHAN_HT) != 0)
261 #define IEEE80211_IS_CHAN_DFS(_c) \
262         (((_c)->ic_flags & IEEE80211_CHAN_DFS) != 0)
263 #define IEEE80211_IS_CHAN_NOADHOC(_c) \
264         (((_c)->ic_flags & IEEE80211_CHAN_NOADHOC) != 0)
265 #define IEEE80211_IS_CHAN_NOHOSTAP(_c) \
266         (((_c)->ic_flags & IEEE80211_CHAN_NOHOSTAP) != 0)
267 #define IEEE80211_IS_CHAN_11D(_c) \
268         (((_c)->ic_flags & IEEE80211_CHAN_11D) != 0)
269
270 #define IEEE80211_CHAN2IEEE(_c)         (_c)->ic_ieee
271
272 /* dynamic state */
273 #define IEEE80211_CHANSTATE_RADAR       0x01    /* radar detected */
274 #define IEEE80211_CHANSTATE_CACDONE     0x02    /* CAC completed */
275 #define IEEE80211_CHANSTATE_NORADAR     0x10    /* post notify on radar clear */
276
277 #define IEEE80211_IS_CHAN_RADAR(_c) \
278         (((_c)->ic_state & IEEE80211_CHANSTATE_RADAR) != 0)
279 #define IEEE80211_IS_CHAN_CACDONE(_c) \
280         (((_c)->ic_state & IEEE80211_CHANSTATE_CACDONE) != 0)
281
282 /* ni_chan encoding for FH phy */
283 #define IEEE80211_FH_CHANMOD    80
284 #define IEEE80211_FH_CHAN(set,pat)      (((set)-1)*IEEE80211_FH_CHANMOD+(pat))
285 #define IEEE80211_FH_CHANSET(chan)      ((chan)/IEEE80211_FH_CHANMOD+1)
286 #define IEEE80211_FH_CHANPAT(chan)      ((chan)%IEEE80211_FH_CHANMOD)
287
288 #define IEEE80211_TID_SIZE      (WME_NUM_TID+1) /* WME TID's +1 for non-QoS */
289 #define IEEE80211_NONQOS_TID    WME_NUM_TID     /* index for non-QoS sta */
290
291 /*
292  * The 802.11 spec says at most 2007 stations may be
293  * associated at once.  For most AP's this is way more
294  * than is feasible so we use a default of 128.  This
295  * number may be overridden by the driver and/or by
296  * user configuration but may not be less than IEEE80211_AID_MIN.
297  */
298 #define IEEE80211_AID_DEF               128
299 #define IEEE80211_AID_MIN               16
300
301 /*
302  * 802.11 rate set.
303  */
304 #define IEEE80211_RATE_SIZE     8               /* 802.11 standard */
305 #define IEEE80211_RATE_MAXSIZE  15              /* max rates we'll handle */
306
307 struct ieee80211_rateset {
308         uint8_t         rs_nrates;
309         uint8_t         rs_rates[IEEE80211_RATE_MAXSIZE];
310 };
311
312 /*
313  * 802.11n variant of ieee80211_rateset.  Instead of
314  * legacy rates the entries are MCS rates.  We define
315  * the structure such that it can be used interchangeably
316  * with an ieee80211_rateset (modulo structure size).
317  */
318 #define IEEE80211_HTRATE_MAXSIZE 127
319
320 struct ieee80211_htrateset {
321         uint8_t         rs_nrates;
322         uint8_t         rs_rates[IEEE80211_HTRATE_MAXSIZE];
323 };
324
325 #define IEEE80211_RATE_MCS      0x80
326
327 /*
328  * Per-mode transmit parameters/controls visible to user space.
329  * These can be used to set fixed transmit rate for all operating
330  * modes or on a per-client basis according to the capabilities
331  * of the client (e.g. an 11b client associated to an 11g ap).
332  *
333  * MCS are distinguished from legacy rates by or'ing in 0x80.
334  */
335 struct ieee80211_txparam {
336         uint8_t         ucastrate;      /* ucast data rate (legacy/MCS|0x80) */
337         uint8_t         mgmtrate;       /* mgmt frame rate (legacy/MCS|0x80) */
338         uint8_t         mcastrate;      /* multicast rate (legacy/MCS|0x80) */
339         uint8_t         maxretry;       /* max unicast data retry count */
340 };
341
342 /*
343  * Per-mode roaming state visible to user space.  There are two
344  * thresholds that control whether roaming is considered; when
345  * either is exceeded the 802.11 layer will check the scan cache
346  * for another AP.  If the cache is stale then a scan may be
347  * triggered.
348  */
349 struct ieee80211_roamparam {
350         int8_t          rssi;           /* rssi thresh (.5 dBm) */
351         uint8_t         rate;           /* tx rate thresh (.5 Mb/s or MCS) */
352         uint16_t        pad;            /* reserve */
353 };
354
355 /*
356  * Regulatory Information.
357  */
358 struct ieee80211_regdomain {
359         uint16_t        regdomain;      /* SKU */
360         uint16_t        country;        /* ISO country code */
361         uint8_t         location;       /* I (indoor), O (outdoor), other */
362         uint8_t         ecm;            /* Extended Channel Mode */
363         char            isocc[2];       /* country code string */
364         short           pad[2];
365 };
366
367 /*
368  * MIMO antenna/radio state.
369  */
370 struct ieee80211_mimo_info {
371         int8_t          rssi[3];        /* per-antenna rssi */
372         int8_t          noise[3];       /* per-antenna noise floor */
373         uint32_t        evm[3];         /* EVM data */
374 };
375 #endif /* _NET80211__IEEE80211_H_ */