update madwifi
[linux-2.6/zen-sources.git] / drivers / net / wireless / madwifi / net80211 / ieee80211_var.h
blob2f4801a82672c2521bcd9bde3736cab7f2f13908
1 /*-
2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
4 * All rights reserved.
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 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * Alternatively, this software may be distributed under the terms of the
18 * GNU General Public License ("GPL") version 2 as published by the Free
19 * Software Foundation.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * $Id: ieee80211_var.h 3849 2008-08-27 17:18:39Z proski $
35 #ifndef _NET80211_IEEE80211_VAR_H_
36 #define _NET80211_IEEE80211_VAR_H_
38 /* Definitions for IEEE 802.11 drivers. */
39 #include <net80211/ieee80211_linux.h>
41 #include <sys/queue.h>
43 #include <net80211/_ieee80211.h>
44 #include <net80211/ieee80211.h>
45 #include <net80211/ieee80211_crypto.h>
46 #include <net80211/ieee80211_ioctl.h> /* for ieee80211_stats */
47 #include <net80211/ieee80211_power.h>
48 #include <net80211/ieee80211_proto.h>
49 #include <net80211/ieee80211_scan.h>
51 /* NB:
52 * - Atheros chips use 6 bits when power is specified in whole dBm units, with
53 * a value range from 0 to 63.
54 * - Atheros chips use 7 bits when power is specified in half dBm units, with
55 * a value range from 0 to 127.
57 #define IEEE80211_TXPOWER_MAX 127 /* .5 dBm units */
58 #define IEEE80211_TXPOWER_MIN 0 /* kill radio */
60 #define IEEE80211_DTIM_MAX 15 /* max DTIM period */
61 #define IEEE80211_DTIM_MIN 1 /* min DTIM period */
62 #define IEEE80211_DTIM_DEFAULT 1 /* default DTIM period */
64 #define IEEE80211_BINTVAL_MAX 1000 /* max beacon interval (TUs) */
65 #define IEEE80211_BINTVAL_MIN 25 /* min beacon interval (TUs) */
66 #define IEEE80211_BINTVAL_DEFAULT 100 /* default beacon interval (TUs) */
67 #define IEEE80211_BINTVAL_VALID(_bi) \
68 ((IEEE80211_BINTVAL_MIN <= (_bi)) && \
69 ((_bi) <= IEEE80211_BINTVAL_MAX))
70 #define IEEE80211_BINTVAL_SANITISE(_bi) \
71 (IEEE80211_BINTVAL_VALID(_bi) ? \
72 (_bi) : IEEE80211_BINTVAL_DEFAULT)
74 #define IEEE80211_BMISSTHRESH_BMIN 2 /* min bmiss threshold (beacons) */
75 /* Default beacon miss threshold is set to roundup from 850ms
76 * This is halfway between the 10@100ms default from prior hardcoded setting for
77 * software beacon miss timers, and the 7@100ms default from prior hardcoded
78 * timer value for hardware beacon miss timer.
79 * Based upon emperical evidence and practices of commercial vendors, I believe
80 * this should really be 2500ms by default. */
81 #define IEEE80211_BMISSTHRESH_DEFAULT_MS 850
83 #define IEEE80211_BMISSTHRESH_VALID(_bmt) \
84 (IEEE80211_BMISSTHRESH_BMIN <= (_bmt))
85 #define IEEE80211_BMISSTHRESH_SANITISE(_bmt) \
86 ((IEEE80211_BMISSTHRESH_BMIN > (_bmt)) ? \
87 IEEE80211_BMISSTHRESH_BMIN : (_bmt))
89 #define IEEE80211_BGSCAN_INTVAL_MIN 15 /* min bg scan intvl (secs) */
90 #define IEEE80211_BGSCAN_INTVAL_DEFAULT (5 * 60) /* default BG scan int. */
92 #define IEEE80211_BGSCAN_IDLE_MIN 100 /* min idle time (ms) */
93 #define IEEE80211_BGSCAN_IDLE_DEFAULT 250 /* default idle time (ms) */
95 #define IEEE80211_COVERAGE_CLASS_MAX 31 /* max coverage class */
96 #define IEEE80211_REGCLASSIDS_MAX 10 /* max regclass id list */
98 #define IEEE80211_PS_SLEEP 0x1 /* STA is in power saving mode */
99 #define IEEE80211_PS_MAX_QUEUE 50 /* maximum saved packets */
101 #define IEEE80211_XR_BEACON_FACTOR 3 /* factor between xr Beacon interval and normal beacon interval */
102 #define IEEE80211_XR_DEFAULT_RATE_INDEX 0
103 #define IEEE80211_XR_FRAG_THRESHOLD 540
105 #define IEEE80211_FIXED_RATE_NONE -1
107 #define DEV_NAME(_d) \
108 ((NULL == _d || NULL == _d->name || 0 == strncmp(_d->name, "wifi%d", 6)) ? \
109 "MadWifi" : \
110 _d->name)
111 #define VAP_DEV_NAME(_v) \
112 ((NULL == _v) ? \
113 "MadWifi" : \
114 DEV_NAME(_v->iv_dev))
115 #define SC_DEV_NAME(_sc) \
116 ((NULL == _sc) ? \
117 "MadWifi" : \
118 DEV_NAME(_sc->sc_dev))
119 #define VAP_IC_DEV_NAME(_v) \
120 ((NULL == _v || NULL == _v->iv_ic) ? \
121 "MadWifi" : \
122 DEV_NAME(_v->iv_ic->ic_dev))
125 * TU conversions:
127 * TU is a 32bit value and defined by IEEE802.11 (page 6) as "A measurement of
128 * time equal to 1024 usec (microseconds)".
130 * TSF is a 64bit value in usec, therefore if we right shift it by 10 bit this
131 * will directly convert it to TU. The rest is truncated to fit into 32 bit.
133 #define IEEE80211_TSF_TO_TU(_tsf) ((u_int32_t)((_tsf) >> 10))
134 #define IEEE80211_MS_TO_TU(x) (((x) * 1000) / 1024)
135 #define IEEE80211_TU_TO_MS(x) (((x) * 1024) / 1000)
136 #define IEEE80211_TU_TO_JIFFIES(x) ((IEEE80211_TU_TO_MS(x) * HZ) / 1000)
137 #define IEEE80211_JIFFIES_TO_TU(x) IEEE80211_MS_TO_TU((x) * 1000 / HZ)
139 #define IEEE80211_APPIE_MAX 1024
141 #define IEEE80211_PWRCONSTRAINT_VAL(ic) \
142 (((ic)->ic_bsschan->ic_maxregpower > (ic)->ic_curchanmaxpwr) ? \
143 (ic)->ic_bsschan->ic_maxregpower - (ic)->ic_curchanmaxpwr : 0)
145 /* 802.11 control state is split into a common portion that maps
146 * 1-1 to a physical device and one or more "Virtual APs" (VAP)
147 * that are bound to an ieee80211com instance and share a single
148 * underlying device. Each VAP has a corresponding OS device
149 * entity through which traffic flows and that applications use
150 * for issuing ioctls, etc.
153 /* Data common to one or more virtual APs. State shared by
154 * the underlying device and the net80211 layer is exposed here;
155 * e.g. device-specific callbacks.
158 struct ieee80211com;
159 struct ieee80211_proc_entry;
160 struct vlan_group;
161 struct eapolcom;
162 struct ieee80211_aclator;
164 struct ieee80211_nsparams {
165 enum ieee80211_state newstate;
166 int arg;
167 int result;
170 #define IW_MAX_SPY 8
171 struct ieee80211_spy {
172 u_int8_t mac[IW_MAX_SPY * IEEE80211_ADDR_LEN];
173 u_int64_t ts_rssi[IW_MAX_SPY]; /* ts of rssi value from last read */
174 u_int8_t thr_low; /* 1 byte rssi value, 0 = threshold is off */
175 u_int8_t thr_high; /* 1 byte rssi value */
176 u_int8_t num;
179 struct ieee80211_app_ie {
180 u_int32_t length; /* buffer length */
181 struct ieee80211_ie *ie; /* buffer containing one or more IEs */
184 struct ieee80211vap {
185 struct net_device *iv_dev; /* associated device */
186 struct net_device_stats iv_devstats; /* interface statistics */
187 struct ifmedia iv_media; /* interface media config */
188 struct iw_statistics iv_iwstats; /* wireless statistics block */
189 struct ctl_table_header *iv_sysctl_header;
190 struct ctl_table *iv_sysctls;
191 struct proc_dir_entry *iv_proc;
192 struct ieee80211_proc_entry *iv_proc_entries;
193 struct vlan_group *iv_vlgrp; /* vlan group state */
195 TAILQ_ENTRY(ieee80211vap) iv_next; /* list of vap instances */
196 struct ieee80211com *iv_ic; /* back ptr to common state */
197 u_int32_t iv_debug; /* debug msg flags */
198 struct ieee80211_stats iv_stats; /* statistics */
200 int iv_monitor_nods_only; /* in monitor mode only nods traffic */
201 int iv_monitor_txf_len; /* in monitor mode, truncate tx packets */
202 int iv_monitor_phy_errors; /* in monitor mode, accept phy errors */
203 int iv_monitor_crc_errors; /* in monitor mode, accept crc errors */
205 int (*iv_newstate)(struct ieee80211vap *, enum ieee80211_state, int);
206 u_int8_t iv_myaddr[IEEE80211_ADDR_LEN];
207 u_int32_t iv_flags; /* state flags */
208 u_int32_t iv_flags_ext; /* extension of state flags */
209 u_int32_t iv_caps; /* capabilities */
210 u_int8_t iv_ath_cap; /* Atheros adv. capabilities */
211 enum ieee80211_opmode iv_opmode; /* operation mode */
212 enum ieee80211_state iv_state; /* state machine state */
213 struct timer_list iv_mgtsend; /* mgmt frame response timer */
214 /* inactivity timer settings */
215 int iv_inact_init; /* setting for new station */
216 int iv_inact_auth; /* auth but not assoc setting */
217 int iv_inact_run; /* authorized setting */
218 int iv_inact_probe; /* inactive probe time */
220 int iv_des_nssid; /* # desired ssids */
221 struct ieee80211_scan_ssid iv_des_ssid[1]; /* desired ssid table */
222 u_int8_t iv_des_bssid[IEEE80211_ADDR_LEN];
223 struct ieee80211_channel *iv_des_chan; /* desired channel */
224 u_int16_t iv_des_mode; /* desired mode */
225 int iv_nicknamelen; /* XXX junk */
226 u_int8_t iv_nickname[IEEE80211_NWID_LEN];
227 u_int iv_bgscanidle; /* bg scan idle threshold */
228 u_int iv_bgscanintvl; /* bg scan min interval */
229 u_int iv_scanvalid; /* scan cache valid threshold */
230 struct ieee80211_roam iv_roam; /* sta-mode roaming state */
232 unsigned long iv_csa_jiffies; /* last csa recv jiffies */
233 u_int8_t iv_csa_count; /* last csa count */
234 struct ieee80211_channel *iv_csa_chan; /* last csa channel */
235 u_int8_t iv_csa_mode; /* last csa mode */
236 struct timer_list iv_csa_timer; /* csa timer */
237 u_int32_t *iv_aid_bitmap; /* association id map */
238 u_int16_t iv_max_aid;
239 u_int16_t iv_sta_assoc; /* stations associated */
240 u_int16_t iv_ps_sta; /* stations in power save */
241 u_int16_t iv_ps_pending; /* PS STAs w/ pending frames */
242 u_int8_t *iv_tim_bitmap; /* power-save stations w/ data */
243 u_int16_t iv_tim_len; /* ic_tim_bitmap size (bytes) */
244 u_int8_t iv_dtim_period; /* DTIM period */
245 u_int8_t iv_dtim_count; /* DTIM count from last bcn */
246 /* set/unset aid pwrsav state */
247 void (*iv_set_tim)(struct ieee80211_node *, int);
248 u_int8_t iv_uapsdinfo; /* sta mode QoS Info flags */
249 struct ieee80211_node *iv_bss; /* information for this node */
251 u_int8_t iv_bssid[IEEE80211_ADDR_LEN];
253 int iv_fixed_rate; /* 802.11 rate or IEEE80211_FIXED_RATE_NONE */
254 u_int16_t iv_rtsthreshold;
255 u_int16_t iv_fragthreshold;
256 u_int16_t iv_txmin; /* min tx retry count */
257 u_int16_t iv_txmax; /* max tx retry count */
258 u_int16_t iv_txlifetime; /* tx lifetime */
259 int iv_inact_timer; /* inactivity timer wait */
260 void *iv_opt_ie; /* user-specified IEs */
261 u_int16_t iv_opt_ie_len; /* length of ni_opt_ie */
262 ieee80211_keyix_t iv_def_txkey; /* default/group TX key index */
263 struct ieee80211_key iv_nw_keys[IEEE80211_WEP_NKID];
264 ieee80211_keyix_t (*iv_key_alloc)(struct ieee80211vap *, const struct ieee80211_key *);
265 int (*iv_key_delete)(struct ieee80211vap *, const struct ieee80211_key *,
266 struct ieee80211_node *);
267 int (*iv_key_set)(struct ieee80211vap *, const struct ieee80211_key *,
268 const u_int8_t mac[IEEE80211_ADDR_LEN]);
269 void (*iv_key_update_begin)(struct ieee80211vap *);
270 void (*iv_key_update_end)(struct ieee80211vap *);
271 #ifdef ATH_SUPERG_COMP
272 void (*iv_comp_set)(struct ieee80211vap *, struct ieee80211_node *, int);
273 #endif
274 const struct ieee80211_authenticator *iv_auth; /* authenticator glue */
275 void *iv_ec; /* private auth state */
276 struct ieee80211vap *iv_xrvap; /* pointer to XR VAP , if XR is enabled */
277 u_int16_t iv_xrbcnwait; /* SWBA count incremented until it reaches XR_BECON_FACTOR */
278 struct timer_list iv_xrvapstart; /* timer to start xr */
279 u_int8_t iv_chanchange_count; /* 11h counter for channel change */
280 int iv_mcast_rate; /* Multicast rate (Kbps) */
282 const struct ieee80211_aclator *iv_acl; /* aclator glue */
283 void *iv_as; /* private aclator state */
285 struct timer_list iv_swbmiss; /* software beacon miss timer */
286 u_int16_t iv_swbmiss_period; /* software beacon miss timer period */
287 struct ieee80211_nsparams iv_nsparams; /* new state parameters for tasklet for stajoin1 */
288 struct IEEE80211_TQ_STRUCT iv_stajoin1tq; /* tasklet for newstate action called from stajoin1tq */
289 unsigned int iv_nsdone; /* Done with scheduled newstate tasklet */
290 uint8_t wds_mac[IEEE80211_ADDR_LEN];
291 struct ieee80211_spy iv_spy; /* IWSPY support */
292 struct ieee80211_app_ie app_ie[IEEE80211_APPIE_NUM_OF_FRAME]; /* app-specified IEs by frame type */
293 u_int32_t app_filter; /* filters which management frames are forwarded to app */
296 /* Debug functions need the definition of struct ieee80211vap because iv_debug
297 * is used at runtime to determine if we should log an event
299 #include <net80211/ieee80211_debug.h>
300 #include <net80211/ieee80211_node.h>
301 #include <net80211/ieee80211_skb.h>
303 struct ieee80211com {
304 struct net_device *ic_dev; /* associated device */
305 ieee80211com_lock_t ic_comlock; /* state update lock */
306 ieee80211com_lock_t ic_vapslock; /* vap state machine lock */
307 TAILQ_HEAD(ieee80211vap_headtype,
308 ieee80211vap) ic_vaps; /* list of vap instances */
309 enum ieee80211_phytype ic_phytype; /* XXX wrong for multi-mode */
310 enum ieee80211_opmode ic_opmode; /* operation mode */
311 struct ifmedia ic_media; /* interface media config */
312 u_int8_t ic_myaddr[IEEE80211_ADDR_LEN];
313 struct timer_list ic_inact; /* mgmt/inactivity timer */
315 u_int32_t ic_flags; /* state flags */
316 u_int32_t ic_flags_ext; /* extension of state flags */
317 u_int32_t ic_caps; /* capabilities */
318 u_int8_t ic_ath_cap; /* Atheros adv. capabilities */
319 u_int8_t ic_promisc; /* VAPs needing promisc mode */
320 u_int8_t ic_allmulti; /* VAPs needing all multicast */
321 u_int8_t ic_nopened; /* VAPs been opened */
322 struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX];
323 struct ieee80211_rateset ic_sup_xr_rates;
324 struct ieee80211_rateset ic_sup_half_rates;
325 struct ieee80211_rateset ic_sup_quarter_rates;
326 u_int16_t ic_modecaps; /* set of mode capabilities */
327 u_int16_t ic_curmode; /* current mode */
328 u_int16_t ic_lintval; /* beacon interval */
329 u_int16_t ic_holdover; /* PM hold over duration */
330 u_int16_t ic_bmissthreshold; /* beacon miss threshold (# beacons) */
331 unsigned long ic_bmiss_guard; /* when to cease ignoring bmiss (jiffies) */
332 u_int16_t ic_txpowlimit; /* global tx power limit (in 0.5 dBm) */
333 u_int16_t ic_newtxpowlimit; /* tx power limit to change to (in 0.5 dBm) */
334 u_int16_t ic_uapsdmaxtriggers; /* max triggers that could arrive */
335 u_int8_t ic_coverageclass; /* coverage class */
337 /* Channel state:
339 * ic_channels is the set of available channels for the device;
340 * it is setup by the driver
341 * ic_nchans is the number of valid entries in ic_channels
342 * ic_chan_avail is a bit vector of these channels used to check
343 * whether a channel is available w/o searching the channel table.
344 * ic_chan_active is a (potentially) constrained subset of
345 * ic_chan_avail that reflects any mode setting or user-specified
346 * limit on the set of channels to use/scan
347 * ic_curchan is the current channel the device is set to; it may
348 * be different from ic_bsschan when we are off-channel scanning
349 * or otherwise doing background work
350 * ic_bsschan is the channel selected for operation; it may
351 * be undefined (IEEE80211_CHAN_ANYC)
353 int ic_nchans; /* # entries in ic_channels */
354 struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX+1];
355 struct timeval ic_chan_non_occupy[IEEE80211_CHAN_MAX];
356 u_int8_t ic_chan_avail[IEEE80211_CHAN_BYTES];
357 u_int8_t ic_chan_active[IEEE80211_CHAN_BYTES];
358 struct ieee80211_channel *ic_curchan; /* current channel */
359 struct ieee80211_channel *ic_bsschan; /* bss channel */
360 int16_t ic_channoise; /* current channel noise in dBm */
361 struct timer_list ic_dfs_excl_timer;
363 * Spectrum management (IEEE 802.11h-2003):
365 * ic_chan_nodes is an array of numbers of nodes that provide
366 * ni_suppchans with the given channel reported as supported. Index
367 * of the array is an IEEE channel number (ic_ieee)
368 * ic_cn_total is the number of nodes counted in ic_chan_nodes
369 * (provided ni_suppchans and are associated)
370 * ic_sc_mincom is the desired minimum number of common channels, the
371 * parameter used by SC_TIGHT and SC_STRICT algorithms
372 * ic_sc_algorithm is the algorithm for (re)association based on
373 * supported channels
374 * ic_sc_slcg is the permil of Stations Lost per Channel Gained, the
375 * parameter used by SC_TIGHT and SC_STRICT algorithms. If due to
376 * association of the STA and disassociation of x other STAs (out of
377 * y associated STAs in total), the number of common channel
378 * increases by z, then such an action is performed if
379 * 1000 * x/y < z * ic_sc_slcg
380 * ic_sc_sldg is the permil of Stations Lost per rssi Db Gained, the
381 * parameter used by SC_LOOSE algorithm. If due to the switch,
382 * the maximum RSSI of received packets on the current channel would
383 * decrease by z decibels and x stations from the set of y stations
384 * would be lost, then such a switch will be performed if
385 * 1000 * x/y < z * ic_sc_sldg
386 * ic_sc_ie is the Supported Channels IE that is about to be sent along
387 * with (re)assoc requests (STA mode)
389 u_int16_t ic_chan_nodes[IEEE80211_CHAN_MAX+1];
390 u_int16_t ic_cn_total; /* # nodes counted in ic_chan nodes */
391 u_int16_t ic_sc_mincom; /* minimum number of common channels */
392 enum ieee80211_sc_algorithm ic_sc_algorithm;
393 u_int16_t ic_sc_slcg; /* permil of Stations Lost per Channel Gained */
394 u_int16_t ic_sc_sldg; /* permil of Stations Lost per rssi Db Gained */
395 struct ieee80211_ie_sc ic_sc_ie; /* Supported Channels IE */
397 /* Regulatory class ids */
398 u_int ic_nregclass; /* # entries in ic_regclassids */
399 u_int8_t ic_regclassids[IEEE80211_REGCLASSIDS_MAX];
401 /* Scan-related state */
402 struct ieee80211_scan_state *ic_scan; /* scan state */
403 enum ieee80211_roamingmode ic_roaming; /* roaming mode */
404 unsigned long ic_lastdata; /* time of last data frame */
405 unsigned long ic_lastscan; /* time last scan completed */
407 /* NB: this is the union of all vap stations/neighbors */
408 struct ieee80211_node_table ic_sta; /* stations/neighbors */
410 /* XXX Multi-BSS: split out common/VAP parts? */
411 struct ieee80211_wme_state ic_wme; /* WME/WMM state */
413 /* XXX Multi-BSS: can per-VAP be done/make sense? */
414 enum ieee80211_protmode ic_protmode; /* 802.11g protection mode */
415 int ic_rssi_ewma;
416 u_int16_t ic_nonerpsta; /* # non-ERP stations */
417 u_int16_t ic_longslotsta; /* # long slot time stations */
418 u_int16_t ic_sta_assoc; /* stations associated */
419 u_int16_t ic_dt_sta_assoc; /* dturbo capable stations */
420 u_int16_t ic_xr_sta_assoc; /* XR stations associated */
422 /* Spectrum management. */
423 u_int16_t ic_country_code;
424 int ic_country_outdoor;
425 struct ieee80211_ie_country ic_country_ie; /* country info element */
427 /* Current channel max. power, used to compute Power Constraint IE.
429 * NB: local power constraint depends on the channel, but assuming it must
430 * be detected dynamically, we cannot maintain a table (i.e., will not
431 * know value until change to channel and detect).
433 u_int8_t ic_curchanmaxpwr;
434 u_int8_t ic_chanchange_tbtt;
435 u_int8_t ic_chanchange_chan;
437 /* Global debug flags applicable to all VAPs */
438 int ic_debug;
439 /* used for reference tracking/counting. Nodes are shared between VAPs,
440 * so we put this here. */
441 atomic_t ic_node_counter;
442 /* Virtual AP create/delete */
443 struct ieee80211vap *(*ic_vap_create)(struct ieee80211com *,
444 const char *, int, int, struct net_device *);
445 void (*ic_vap_delete)(struct ieee80211vap *);
447 /* Send/recv 802.11 management frame */
448 int (*ic_send_mgmt)(struct ieee80211_node *, int, int);
449 int (*ic_recv_mgmt)(struct ieee80211vap *, struct ieee80211_node *,
450 struct sk_buff *, int, int, u_int64_t);
452 /* Send management frame to driver (like hardstart) */
453 int (*ic_mgtstart)(struct ieee80211com *, struct sk_buff *);
455 /* Reset device state after 802.11 parameter/state change */
456 int (*ic_init)(struct net_device *);
457 int (*ic_reset)(struct net_device *);
459 /* Update device state for 802.11 slot time change */
460 void (*ic_updateslot)(struct net_device *);
462 /* New station association callback/notification */
463 void (*ic_newassoc)(struct ieee80211_node *, int);
465 /* Node state management */
466 int32_t (*ic_node_count)(struct ieee80211com *);
467 struct ieee80211_node *(*ic_node_alloc)(struct ieee80211vap *);
468 void (*ic_node_cleanup)(struct ieee80211_node *);
469 void (*ic_node_free)(struct ieee80211_node *);
471 u_int8_t (*ic_node_getrssi)(const struct ieee80211_node *);
472 u_int8_t (*ic_node_move_data)(const struct ieee80211_node *);
474 /* Scanning support */
475 void (*ic_scan_start)(struct ieee80211com *);
476 void (*ic_scan_end)(struct ieee80211com *);
477 void (*ic_set_channel)(struct ieee80211com *);
479 /* U-APSD support */
480 void (*ic_uapsd_flush)(struct ieee80211_node *);
482 /* continuous transmission support */
483 void (*ic_set_txcont)(struct ieee80211com *, int);
484 int (*ic_get_txcont)(struct ieee80211com *);
485 void (*ic_set_txcont_power)(struct ieee80211com *, u_int);
486 int (*ic_get_txcont_power)(struct ieee80211com *);
487 void (*ic_set_txcont_rate)(struct ieee80211com *, u_int);
488 u_int (*ic_get_txcont_rate)(struct ieee80211com *);
490 /* DFS test mode prevents marking channel interference and channel
491 * switching during detection probability tests */
492 void (*ic_set_dfs_testmode)(struct ieee80211com *, int);
493 int (*ic_get_dfs_testmode)(struct ieee80211com *);
495 /* inject a fake radar signal -- used while on a 802.11h DFS channels */
496 unsigned int (*ic_test_radar)(struct ieee80211com *);
498 /* dump HAL */
499 unsigned int (*ic_dump_hal_map)(struct ieee80211com *);
501 /* DFS channel availability check time (in seconds) */
502 void (*ic_set_dfs_cac_time)(struct ieee80211com *, unsigned int);
503 unsigned int (*ic_get_dfs_cac_time)(struct ieee80211com *);
505 /* DFS non-occupancy period (in seconds) */
506 void (*ic_set_dfs_excl_period)(struct ieee80211com *, unsigned int);
507 unsigned int (*ic_get_dfs_excl_period)(struct ieee80211com *);
509 /* Set coverage class */
510 void (*ic_set_coverageclass)(struct ieee80211com *);
512 /* MHz to IEEE channel conversion */
513 u_int (*ic_mhz2ieee)(struct ieee80211com *, u_int, u_int);
515 #ifdef ATH_REVERSE_ENGINEERING
516 /* debug and reverse engineering hooks */
517 void (*ic_registers_dump)(struct ieee80211com *);
518 void (*ic_registers_mark)(struct ieee80211com *);
519 void (*ic_registers_dump_delta)(struct ieee80211com *);
520 unsigned int (*ic_write_register)(struct ieee80211com *, unsigned int, unsigned int);
521 unsigned int (*ic_read_register)(struct ieee80211com *, unsigned int, unsigned int*);
522 #endif /* #ifdef ATH_REVERSE_ENGINEERING */
523 int (*ic_debug_ath_iwpriv)(struct ieee80211com *, unsigned int param, unsigned int value);
526 #define MAX_PROC_IEEE80211_SIZE 16383
527 #define PROC_IEEE80211_PERM 0644
529 struct proc_ieee80211_priv {
530 int rlen;
531 int max_rlen;
532 char *rbuf;
534 int wlen;
535 int max_wlen;
536 char *wbuf;
539 struct ieee80211_proc_entry {
540 char *name;
541 struct file_operations *fileops;
542 struct proc_dir_entry *entry;
543 struct ieee80211_proc_entry *next;
546 MALLOC_DECLARE(M_80211_VAP);
548 #define IEEE80211_ADDR_NULL(a1) (memcmp(a1, "\x00\x00\x00\x00\x00\x00", \
549 IEEE80211_ADDR_LEN) == 0)
550 #define IEEE80211_ADDR_EQ(a1, a2) (memcmp(a1, a2, IEEE80211_ADDR_LEN) == 0)
551 #define IEEE80211_ADDR_COPY(dst, src) memcpy(dst, src, IEEE80211_ADDR_LEN)
552 #define IEEE80211_ADDR_SET_NULL(dst) memset(dst, 0, IEEE80211_ADDR_LEN)
554 /* ic_flags */
555 #define IEEE80211_F_FF 0x00000001 /* CONF: ATH FF enabled */
556 #define IEEE80211_F_TURBOP 0x00000002 /* CONF: ATH Turbo enabled*/
557 #define IEEE80211_F_PROMISC 0x00000004 /* STATUS: promiscuous mode */
558 #define IEEE80211_F_ALLMULTI 0x00000008 /* STATUS: all multicast mode */
559 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_PRIVACY */
560 #define IEEE80211_F_PRIVACY 0x00000010 /* CONF: privacy enabled */
561 #define IEEE80211_F_PUREG 0x00000020 /* CONF: 11g w/o 11b STAs */
562 #define IEEE80211_F_XRUPDATE 0x00000040 /* CONF: update beacon XR element*/
563 #define IEEE80211_F_SCAN 0x00000080 /* STATUS: scanning */
564 #define IEEE80211_F_XR 0x00000100 /* CONF: operate in XR mode */
565 #define IEEE80211_F_SIBSS 0x00000200 /* STATUS: start IBSS */
566 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_SHORT_SLOTTIME */
567 #define IEEE80211_F_SHSLOT 0x00000400 /* STATUS: use short slot time*/
568 #define IEEE80211_F_PMGTON 0x00000800 /* CONF: Power mgmt enable */
569 #define IEEE80211_F_DESBSSID 0x00001000 /* CONF: des_bssid is set */
570 #define IEEE80211_F_WME 0x00002000 /* CONF: enable WME use */
571 #define IEEE80211_F_BGSCAN 0x00004000 /* CONF: bg scan enabled */
572 #define IEEE80211_F_SWRETRY 0x00008000 /* CONF: sw tx retry enabled */
573 #define IEEE80211_F_TXPOW_FIXED 0x00010000 /* TX Power: fixed rate */
574 #define IEEE80211_F_IBSSON 0x00020000 /* CONF: IBSS creation enable */
575 #define IEEE80211_F_SHPREAMBLE 0x00040000 /* STATUS: use short preamble */
576 #define IEEE80211_F_DATAPAD 0x00080000 /* CONF: do alignment pad */
577 #define IEEE80211_F_USEPROT 0x00100000 /* STATUS: protection enabled */
578 #define IEEE80211_F_USEBARKER 0x00200000 /* STATUS: use barker preamble*/
579 #define IEEE80211_F_TIMUPDATE 0x00400000 /* STATUS: update beacon tim */
580 #define IEEE80211_F_WPA1 0x00800000 /* CONF: WPA enabled */
581 #define IEEE80211_F_WPA2 0x01000000 /* CONF: WPA2 enabled */
582 #define IEEE80211_F_WPA 0x01800000 /* CONF: WPA/WPA2 enabled */
583 #define IEEE80211_F_DROPUNENC 0x02000000 /* CONF: drop unencrypted */
584 #define IEEE80211_F_COUNTERM 0x04000000 /* CONF: TKIP countermeasures */
585 #define IEEE80211_F_HIDESSID 0x08000000 /* CONF: hide SSID in beacon */
586 #define IEEE80211_F_NOBRIDGE 0x10000000 /* CONF: disable internal bridge */
588 #define IEEE80211_F_WMEUPDATE 0x20000000 /* STATUS: update beacon wme */
589 #define IEEE80211_F_DOTH 0x40000000 /* CONF: enable 11.h (dot11SpectrumManagementRequired) */
590 #define IEEE80211_F_CHANSWITCH 0x80000000 /* force chanswitch */
592 /* ic_flags_ext */
593 #define IEEE80211_FEXT_WDS 0x00000001 /* CONF: 4 addr allowed */
594 #define IEEE80211_FEXT_COUNTRYIE 0x00000002 /* CONF: enable country IE */
595 #define IEEE80211_FEXT_SCAN_PENDING 0x00000004 /* STATE: scan pending */
596 #define IEEE80211_FEXT_BGSCAN 0x00000008 /* STATE: enable full bgscan completion */
597 #define IEEE80211_FEXT_UAPSD 0x00000010 /* CONF: enable U-APSD */
598 #define IEEE80211_FEXT_SLEEP 0x00000020 /* STATUS: sleeping */
599 #define IEEE80211_FEXT_EOSPDROP 0x00000040 /* drop uapsd EOSP frames for test */
600 #define IEEE80211_FEXT_MARKDFS 0x00000080 /* Enable marking of dfs interference */
601 #define IEEE80211_FEXT_REGCLASS 0x00000100 /* CONF: send regclassids in country ie */
602 #define IEEE80211_FEXT_ERPUPDATE 0x00000200 /* STATUS: update ERP element */
603 #define IEEE80211_FEXT_SWBMISS 0x00000400 /* CONF: use software beacon timer */
604 #define IEEE80211_FEXT_DROPUNENC_EAPOL 0x00000800 /* CONF: drop unencrypted eapol frames */
605 #define IEEE80211_FEXT_APPIE_UPDATE 0x00001000 /* STATE: beacon APP IE updated */
607 #define IEEE80211_COM_UAPSD_ENABLE(_ic) ((_ic)->ic_flags_ext |= IEEE80211_FEXT_UAPSD)
608 #define IEEE80211_COM_UAPSD_DISABLE(_ic) ((_ic)->ic_flags_ext &= ~IEEE80211_FEXT_UAPSD)
609 #define IEEE80211_COM_UAPSD_ENABLED(_ic) ((_ic)->ic_flags_ext & IEEE80211_FEXT_UAPSD)
610 #define IEEE80211_COM_GOTOSLEEP(_ic) ((_ic)->ic_flags_ext |= IEEE80211_FEXT_GOTOSLEEP)
611 #define IEEE80211_COM_WAKEUP(_ic) ((_ic)->ic_flags_ext &= ~IEEE80211_FEXT_SLEEP)
612 #define IEEE80211_COM_IS_SLEEPING(_ic) ((_ic)->ic_flags_ext & IEEE80211_FEXT_SLEEP)
614 #define IEEE80211_VAP_UAPSD_ENABLE(_v) ((_v)->iv_flags_ext |= IEEE80211_FEXT_UAPSD)
615 #define IEEE80211_VAP_UAPSD_DISABLE(_v) ((_v)->iv_flags_ext &= ~IEEE80211_FEXT_UAPSD)
616 #define IEEE80211_VAP_UAPSD_ENABLED(_v) ((_v)->iv_flags_ext & IEEE80211_FEXT_UAPSD)
617 #define IEEE80211_VAP_GOTOSLEEP(_v) ((_v)->iv_flags_ext |= IEEE80211_FEXT_SLEEP)
618 #define IEEE80211_VAP_WAKEUP(_v) ((_v)->iv_flags_ext &= ~IEEE80211_FEXT_SLEEP)
619 #define IEEE80211_VAP_IS_SLEEPING(_v) ((_v)->iv_flags_ext & IEEE80211_FEXT_SLEEP)
620 #define IEEE80211_VAP_EOSPDROP_ENABLE(_v) ((_v)->iv_flags_ext |= IEEE80211_FEXT_EOSPDROP)
621 #define IEEE80211_VAP_EOSPDROP_DISABLE(_v) ((_v)->iv_flags_ext &= ~IEEE80211_FEXT_EOSPDROP)
622 #define IEEE80211_VAP_EOSPDROP_ENABLED(_v) ((_v)->iv_flags_ext & IEEE80211_FEXT_EOSPDROP)
623 #define IEEE80211_VAP_DROPUNENC_EAPOL_ENABLE(_v) \
624 ((_v)->iv_flags_ext |= IEEE80211_FEXT_DROPUNENC_EAPOL)
625 #define IEEE80211_VAP_DROPUNENC_EAPOL_DISABLE(_v) \
626 ((_v)->iv_flags_ext &= ~IEEE80211_FEXT_DROPUNENC_EAPOL)
627 #define IEEE80211_VAP_DROPUNENC_EAPOL(_v) ((_v)->iv_flags_ext & IEEE80211_FEXT_DROPUNENC_EAPOL)
630 /* ic_caps */
631 #define IEEE80211_C_WEP 0x00000001 /* CAPABILITY: WEP available */
632 #define IEEE80211_C_TKIP 0x00000002 /* CAPABILITY: TKIP available */
633 #define IEEE80211_C_AES 0x00000004 /* CAPABILITY: AES OCB avail */
634 #define IEEE80211_C_AES_CCM 0x00000008 /* CAPABILITY: AES CCM avail */
635 #define IEEE80211_C_CKIP 0x00000020 /* CAPABILITY: CKIP available */
636 #define IEEE80211_C_FF 0x00000040 /* CAPABILITY: ATH FF avail */
637 #define IEEE80211_C_TURBOP 0x00000080 /* CAPABILITY: ATH Turbo avail*/
638 #define IEEE80211_C_IBSS 0x00000100 /* CAPABILITY: IBSS available */
639 #define IEEE80211_C_PMGT 0x00000200 /* CAPABILITY: Power mgmt */
640 #define IEEE80211_C_HOSTAP 0x00000400 /* CAPABILITY: HOSTAP avail */
641 #define IEEE80211_C_AHDEMO 0x00000800 /* CAPABILITY: Old Adhoc Demo */
642 #define IEEE80211_C_SWRETRY 0x00001000 /* CAPABILITY: sw tx retry */
643 #define IEEE80211_C_TXPMGT 0x00002000 /* CAPABILITY: tx power mgmt */
644 #define IEEE80211_C_SHSLOT 0x00004000 /* CAPABILITY: short slottime */
645 #define IEEE80211_C_SHPREAMBLE 0x00008000 /* CAPABILITY: short preamble */
646 #define IEEE80211_C_MONITOR 0x00010000 /* CAPABILITY: monitor mode */
647 #define IEEE80211_C_TKIPMIC 0x00020000 /* CAPABILITY: TKIP MIC avail */
648 #define IEEE80211_C_WPA1 0x00800000 /* CAPABILITY: WPA1 avail */
649 #define IEEE80211_C_WPA2 0x01000000 /* CAPABILITY: WPA2 avail */
650 #define IEEE80211_C_WPA 0x01800000 /* CAPABILITY: WPA1+WPA2 avail*/
651 #define IEEE80211_C_BURST 0x02000000 /* CAPABILITY: frame bursting */
652 #define IEEE80211_C_WME 0x04000000 /* CAPABILITY: WME avail */
653 #define IEEE80211_C_WDS 0x08000000 /* CAPABILITY: 4-addr support */
654 #define IEEE80211_C_WME_TKIPMIC 0x10000000 /* CAPABILITY: TKIP MIC for QoS frame */
655 #define IEEE80211_C_BGSCAN 0x20000000 /* CAPABILITY: bg scanning */
656 #define IEEE80211_C_UAPSD 0x40000000 /* CAPABILITY: UAPSD */
657 /* XXX protection/barker? */
659 #define IEEE80211_C_CRYPTO 0x0000002f /* CAPABILITY: crypto alg's */
661 /* Atheros ABOLT definitions */
662 #define IEEE80211_ABOLT_TURBO_G 0x01 /* Legacy Turbo G */
663 #define IEEE80211_ABOLT_TURBO_PRIME 0x02 /* Turbo Prime */
664 #define IEEE80211_ABOLT_COMPRESSION 0x04 /* Compression */
665 #define IEEE80211_ABOLT_FAST_FRAME 0x08 /* Fast Frames */
666 #define IEEE80211_ABOLT_BURST 0x10 /* Bursting */
667 #define IEEE80211_ABOLT_WME_ELE 0x20 /* WME based cwmin/max/burst tuning */
668 #define IEEE80211_ABOLT_XR 0x40 /* XR */
669 #define IEEE80211_ABOLT_AR 0x80 /* AR switches out based on adjaced non-turbo traffic */
671 /* Atheros Advanced Capabilities ABOLT definition */
672 #define IEEE80211_ABOLT_ADVCAP (IEEE80211_ABOLT_TURBO_PRIME | \
673 IEEE80211_ABOLT_COMPRESSION | \
674 IEEE80211_ABOLT_FAST_FRAME | \
675 IEEE80211_ABOLT_XR | \
676 IEEE80211_ABOLT_AR | \
677 IEEE80211_ABOLT_BURST | \
678 IEEE80211_ABOLT_WME_ELE)
680 /* check if a capability was negotiated for use */
681 #define IEEE80211_ATH_CAP(vap, ni, bit) \
682 ((ni)->ni_ath_flags & (vap)->iv_ath_cap & (bit))
684 /* flags to VAP create function */
685 #define IEEE80211_VAP_XR 0x10000 /* create a XR VAP without registering net device with OS */
687 int ieee80211_ifattach(struct ieee80211com *);
688 void ieee80211_ifdetach(struct ieee80211com *);
689 int ieee80211_vap_setup(struct ieee80211com *, struct net_device *,
690 const char *, int, int);
691 int ieee80211_vap_attach(struct ieee80211vap *, ifm_change_cb_t, ifm_stat_cb_t);
692 void ieee80211_vap_detach(struct ieee80211vap *);
693 void ieee80211_mark_dfs(struct ieee80211com *, struct ieee80211_channel *);
694 void ieee80211_announce(struct ieee80211com *);
695 void ieee80211_announce_channels(struct ieee80211com *);
696 int ieee80211_media_change(struct net_device *);
697 void ieee80211_media_status(struct net_device *, struct ifmediareq *);
698 int ieee80211_rate2media(struct ieee80211com*, int, enum ieee80211_phymode);
699 int ieee80211_media2rate(int);
700 u_int ieee80211_mhz2ieee(u_int, u_int);
701 u_int ieee80211_chan2ieee(struct ieee80211com *, const struct ieee80211_channel *);
702 u_int ieee80211_ieee2mhz(u_int, u_int);
703 struct ieee80211_channel *ieee80211_find_channel(struct ieee80211com *, int, int);
704 int ieee80211_setmode(struct ieee80211com *, enum ieee80211_phymode);
705 void ieee80211_reset_erp(struct ieee80211com *, enum ieee80211_phymode);
706 enum ieee80211_phymode ieee80211_chan2mode(const struct ieee80211_channel *);
707 void ieee80211_build_countryie(struct ieee80211com *);
708 int ieee80211_media_setup(struct ieee80211com *, struct ifmedia *, u_int32_t,
709 ifm_change_cb_t, ifm_stat_cb_t);
710 void ieee80211_build_sc_ie(struct ieee80211com *);
711 void ieee80211_dfs_action(struct ieee80211com *);
712 void ieee80211_expire_channel_excl_restrictions(struct ieee80211com *);
715 * Iterate through ic_channels to enumerate all distinct ic_ieee channel numbers.
716 * It relies on the assumption that ic_ieee cannot be 0 and that all the
717 * duplicates in ic_channels occur subsequently.
719 * _i and _prevchan are temporary variables
721 #define CHANNEL_FOREACH(_chan, _ic, _i, _prevchan) \
722 for ((_i) = 0, (_prevchan) = 0; \
723 (_i) < (_ic)->ic_nchans && ((_chan) = \
724 (_ic)->ic_channels[(_i)].ic_ieee); \
725 (_prevchan) = (_chan), (_i)++ \
726 ) if ((_chan) != (_prevchan))
728 /* Key update synchronization methods. XXX should not be visible. */
729 static __inline void
730 ieee80211_key_update_begin(struct ieee80211vap *vap)
732 vap->iv_key_update_begin(vap);
734 static __inline void
735 ieee80211_key_update_end(struct ieee80211vap *vap)
737 vap->iv_key_update_end(vap);
740 /* XXX these need to be here for IEEE80211_F_DATAPAD */
743 * Return the space occupied by the 802.11 header and any
744 * padding required by the driver. This works for a
745 * management or data frame.
747 static __inline int
748 ieee80211_hdrspace(struct ieee80211com *ic, const void *data)
750 int size = ieee80211_hdrsize(data);
751 if (ic->ic_flags & IEEE80211_F_DATAPAD)
752 size = roundup(size, sizeof(u_int32_t));
753 return size;
756 /* Like ieee80211_hdrspace, but handles any type of frame. */
757 static __inline int
758 ieee80211_anyhdrspace(struct ieee80211com *ic, const void *data)
760 int size = ieee80211_anyhdrsize(data);
761 if (ic->ic_flags & IEEE80211_F_DATAPAD)
762 size = roundup(size, sizeof(u_int32_t));
763 return size;
766 /* Macros to print MAC address used in 802.11 headers */
768 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
769 #define MAC_ADDR(addr) \
770 ((unsigned char *)(addr)) [0], \
771 ((unsigned char *)(addr)) [1], \
772 ((unsigned char *)(addr)) [2], \
773 ((unsigned char *)(addr)) [3], \
774 ((unsigned char *)(addr)) [4], \
775 ((unsigned char *)(addr)) [5]
777 #endif /* _NET80211_IEEE80211_VAR_H_ */