xref: /dflybsd-src/sys/netproto/802_11/ieee80211_var.h (revision 805c8e8e4093ceca2e27510ad3a66d4de8060a55)
132176cfdSRui Paulo /*-
2f186073cSJoerg Sonnenberger  * Copyright (c) 2001 Atsushi Onoe
332176cfdSRui Paulo  * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
4f186073cSJoerg Sonnenberger  * All rights reserved.
5f186073cSJoerg Sonnenberger  *
6f186073cSJoerg Sonnenberger  * Redistribution and use in source and binary forms, with or without
7f186073cSJoerg Sonnenberger  * modification, are permitted provided that the following conditions
8f186073cSJoerg Sonnenberger  * are met:
9f186073cSJoerg Sonnenberger  * 1. Redistributions of source code must retain the above copyright
10f186073cSJoerg Sonnenberger  *    notice, this list of conditions and the following disclaimer.
11f186073cSJoerg Sonnenberger  * 2. Redistributions in binary form must reproduce the above copyright
12f186073cSJoerg Sonnenberger  *    notice, this list of conditions and the following disclaimer in the
13f186073cSJoerg Sonnenberger  *    documentation and/or other materials provided with the distribution.
14f186073cSJoerg Sonnenberger  *
15f186073cSJoerg Sonnenberger  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16f186073cSJoerg Sonnenberger  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17f186073cSJoerg Sonnenberger  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18f186073cSJoerg Sonnenberger  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19f186073cSJoerg Sonnenberger  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20f186073cSJoerg Sonnenberger  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21f186073cSJoerg Sonnenberger  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22f186073cSJoerg Sonnenberger  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23f186073cSJoerg Sonnenberger  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24f186073cSJoerg Sonnenberger  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25f186073cSJoerg Sonnenberger  *
26085ff963SMatthew Dillon  * $FreeBSD$
27f186073cSJoerg Sonnenberger  */
28841ab66cSSepherosa Ziehau #ifndef _NET80211_IEEE80211_VAR_H_
29841ab66cSSepherosa Ziehau #define _NET80211_IEEE80211_VAR_H_
30f186073cSJoerg Sonnenberger 
31f186073cSJoerg Sonnenberger /*
32f186073cSJoerg Sonnenberger  * Definitions for IEEE 802.11 drivers.
33f186073cSJoerg Sonnenberger  */
34841ab66cSSepherosa Ziehau /* NB: portability glue must go first */
3532176cfdSRui Paulo #if defined(__NetBSD__)
36085ff963SMatthew Dillon #include <netproto/802_11/ieee80211_netbsd.h>
3732176cfdSRui Paulo #elif defined(__FreeBSD__)
38085ff963SMatthew Dillon #include <netproto/802_11/ieee80211_freebsd.h>
3932176cfdSRui Paulo #elif defined(__DragonFly__)
40841ab66cSSepherosa Ziehau #include <netproto/802_11/ieee80211_dragonfly.h>
41085ff963SMatthew Dillon #elif defined(__linux__)
42085ff963SMatthew Dillon #include <netproto/802_11/ieee80211_linux.h>
43841ab66cSSepherosa Ziehau #else
44841ab66cSSepherosa Ziehau #error	"No support for your operating system!"
45841ab66cSSepherosa Ziehau #endif
46841ab66cSSepherosa Ziehau 
47841ab66cSSepherosa Ziehau #include <netproto/802_11/_ieee80211.h>
48f186073cSJoerg Sonnenberger #include <netproto/802_11/ieee80211.h>
4932176cfdSRui Paulo #include <netproto/802_11/ieee80211_ageq.h>
50f186073cSJoerg Sonnenberger #include <netproto/802_11/ieee80211_crypto.h>
5132176cfdSRui Paulo #include <netproto/802_11/ieee80211_dfs.h>
52f186073cSJoerg Sonnenberger #include <netproto/802_11/ieee80211_ioctl.h>		/* for ieee80211_stats */
5332176cfdSRui Paulo #include <netproto/802_11/ieee80211_phy.h>
5432176cfdSRui Paulo #include <netproto/802_11/ieee80211_power.h>
55f186073cSJoerg Sonnenberger #include <netproto/802_11/ieee80211_node.h>
56f186073cSJoerg Sonnenberger #include <netproto/802_11/ieee80211_proto.h>
5732176cfdSRui Paulo #include <netproto/802_11/ieee80211_radiotap.h>
5832176cfdSRui Paulo #include <netproto/802_11/ieee80211_scan.h>
59f186073cSJoerg Sonnenberger 
60085ff963SMatthew Dillon #define	IEEE80211_TXPOWER_MAX	100	/* .5 dBm (XXX units?) */
61841ab66cSSepherosa Ziehau #define	IEEE80211_TXPOWER_MIN	0	/* kill radio */
62f186073cSJoerg Sonnenberger 
63841ab66cSSepherosa Ziehau #define	IEEE80211_DTIM_DEFAULT	1	/* default DTIM period */
64841ab66cSSepherosa Ziehau #define	IEEE80211_BINTVAL_DEFAULT 100	/* default beacon interval (TU's) */
65f186073cSJoerg Sonnenberger 
66841ab66cSSepherosa Ziehau #define	IEEE80211_BMISS_MAX	2	/* maximum consecutive bmiss allowed */
67841ab66cSSepherosa Ziehau #define	IEEE80211_HWBMISS_DEFAULT 7	/* h/w bmiss threshold (beacons) */
68f186073cSJoerg Sonnenberger 
6932176cfdSRui Paulo #define	IEEE80211_BGSCAN_INTVAL_MIN	15	/* min bg scan intvl (secs) */
7032176cfdSRui Paulo #define	IEEE80211_BGSCAN_INTVAL_DEFAULT	(5*60)	/* default bg scan intvl */
7132176cfdSRui Paulo 
7232176cfdSRui Paulo #define	IEEE80211_BGSCAN_IDLE_MIN	100	/* min idle time (ms) */
7332176cfdSRui Paulo #define	IEEE80211_BGSCAN_IDLE_DEFAULT	250	/* default idle time (ms) */
7432176cfdSRui Paulo 
7532176cfdSRui Paulo #define	IEEE80211_SCAN_VALID_MIN	10	/* min scan valid time (secs) */
7632176cfdSRui Paulo #define	IEEE80211_SCAN_VALID_DEFAULT	60	/* default scan valid time */
7732176cfdSRui Paulo 
78841ab66cSSepherosa Ziehau #define	IEEE80211_PS_SLEEP	0x1	/* STA is in power saving mode */
79841ab66cSSepherosa Ziehau #define	IEEE80211_PS_MAX_QUEUE	50	/* maximum saved packets */
80f186073cSJoerg Sonnenberger 
8132176cfdSRui Paulo #define	IEEE80211_FIXED_RATE_NONE	0xff
8232176cfdSRui Paulo #define	IEEE80211_TXMAX_DEFAULT		6	/* default ucast max retries */
83f186073cSJoerg Sonnenberger 
84841ab66cSSepherosa Ziehau #define	IEEE80211_RTS_DEFAULT		IEEE80211_RTS_MAX
85841ab66cSSepherosa Ziehau #define	IEEE80211_FRAG_DEFAULT		IEEE80211_FRAG_MAX
86f186073cSJoerg Sonnenberger 
8734b861deSSepherosa Ziehau #define	IEEE80211_MS_TO_TU(x)	(((x) * 1000) / 1024)
8834b861deSSepherosa Ziehau #define	IEEE80211_TU_TO_MS(x)	(((x) * 1024) / 1000)
894f655ef5SMatthew Dillon /* XXX TODO: cap this at 1, in case hz is not 1000 */
904f655ef5SMatthew Dillon #define	IEEE80211_TU_TO_TICKS(x)(((uint64_t)(x) * 1024 * hz) / (1000 * 1000))
91f186073cSJoerg Sonnenberger 
9232176cfdSRui Paulo /*
9332176cfdSRui Paulo  * 802.11 control state is split into a common portion that maps
9432176cfdSRui Paulo  * 1-1 to a physical device and one or more "Virtual AP's" (VAP)
9532176cfdSRui Paulo  * that are bound to an ieee80211com instance and share a single
9632176cfdSRui Paulo  * underlying device.  Each VAP has a corresponding OS device
9732176cfdSRui Paulo  * entity through which traffic flows and that applications use
9832176cfdSRui Paulo  * for issuing ioctls, etc.
9932176cfdSRui Paulo  */
10032176cfdSRui Paulo 
10132176cfdSRui Paulo /*
10232176cfdSRui Paulo  * Data common to one or more virtual AP's.  State shared by
10332176cfdSRui Paulo  * the underlying device and the net80211 layer is exposed here;
10432176cfdSRui Paulo  * e.g. device-specific callbacks.
10532176cfdSRui Paulo  */
10632176cfdSRui Paulo struct ieee80211vap;
10732176cfdSRui Paulo typedef void (*ieee80211vap_attach)(struct ieee80211vap *);
10832176cfdSRui Paulo 
10932176cfdSRui Paulo struct ieee80211_appie {
11032176cfdSRui Paulo 	uint16_t		ie_len;		/* size of ie_data */
11132176cfdSRui Paulo 	uint8_t			ie_data[];	/* user-specified IE's */
11232176cfdSRui Paulo };
11332176cfdSRui Paulo 
11432176cfdSRui Paulo struct ieee80211_tdma_param;
11532176cfdSRui Paulo struct ieee80211_rate_table;
11632176cfdSRui Paulo struct ieee80211_tx_ampdu;
11732176cfdSRui Paulo struct ieee80211_rx_ampdu;
11832176cfdSRui Paulo struct ieee80211_superg;
11932176cfdSRui Paulo struct ieee80211_frame;
120f186073cSJoerg Sonnenberger 
121f186073cSJoerg Sonnenberger struct ieee80211com {
1224f898719SImre Vadász 	void			*ic_softc;	/* driver softc */
1234f898719SImre Vadász 	const char		*ic_name;	/* usually device name */
124085ff963SMatthew Dillon 	ieee80211_com_lock_t	ic_comlock;	/* state update lock */
125085ff963SMatthew Dillon 	ieee80211_tx_lock_t	ic_txlock;	/* ic/vap TX lock */
1264f655ef5SMatthew Dillon 	LIST_ENTRY(ieee80211com)   ic_next;	/* on global list */
12732176cfdSRui Paulo 	TAILQ_HEAD(, ieee80211vap) ic_vaps;	/* list of vap instances */
1284ac84526SSepherosa Ziehau 	int			ic_headroom;	/* driver tx headroom needs */
12932176cfdSRui Paulo 	enum ieee80211_phytype	ic_phytype;	/* XXX wrong for multi-mode */
13032176cfdSRui Paulo 	enum ieee80211_opmode	ic_opmode;	/* operation mode */
13132176cfdSRui Paulo 	struct callout		ic_inact;	/* inactivity processing */
13232176cfdSRui Paulo 	struct taskqueue	*ic_tq;		/* deferred state thread */
13332176cfdSRui Paulo 	struct task		ic_parent_task;	/* deferred parent processing */
13432176cfdSRui Paulo 	struct task		ic_promisc_task;/* deferred promisc update */
13532176cfdSRui Paulo 	struct task		ic_mcast_task;	/* deferred mcast update */
13632176cfdSRui Paulo 	struct task		ic_chan_task;	/* deferred channel change */
13732176cfdSRui Paulo 	struct task		ic_bmiss_task;	/* deferred beacon miss hndlr */
138085ff963SMatthew Dillon 	struct task		ic_chw_task;	/* deferred HT CHW update */
1394f655ef5SMatthew Dillon 	struct task		ic_wme_task;	/* deferred WME update */
1404f655ef5SMatthew Dillon 	struct task		ic_restart_task; /* deferred device restart */
1414f655ef5SMatthew Dillon 
1424f655ef5SMatthew Dillon #if defined(__DragonFly__)
1434f655ef5SMatthew Dillon 	uint64_t		ic_ierrors;	/* input errors */
1444f655ef5SMatthew Dillon 	uint64_t		ic_oerrors;	/* output errors */
1454f655ef5SMatthew Dillon #else
1464f655ef5SMatthew Dillon 	counter_u64_t		ic_ierrors;	/* input errors */
1474f655ef5SMatthew Dillon 	counter_u64_t		ic_oerrors;	/* output errors */
1484f655ef5SMatthew Dillon #endif
149841ab66cSSepherosa Ziehau 
15032176cfdSRui Paulo 	uint32_t		ic_flags;	/* state flags */
15132176cfdSRui Paulo 	uint32_t		ic_flags_ext;	/* extended state flags */
15232176cfdSRui Paulo 	uint32_t		ic_flags_ht;	/* HT state flags */
15332176cfdSRui Paulo 	uint32_t		ic_flags_ven;	/* vendor state flags */
15432176cfdSRui Paulo 	uint32_t		ic_caps;	/* capabilities */
15532176cfdSRui Paulo 	uint32_t		ic_htcaps;	/* HT capabilities */
1564028af95SRui Paulo 	uint32_t		ic_htextcaps;	/* HT extended capabilities */
15732176cfdSRui Paulo 	uint32_t		ic_cryptocaps;	/* crypto capabilities */
1584f655ef5SMatthew Dillon 						/* set of mode capabilities */
1594f655ef5SMatthew Dillon 	uint8_t			ic_modecaps[IEEE80211_MODE_BYTES];
16032176cfdSRui Paulo 	uint8_t			ic_promisc;	/* vap's needing promisc mode */
16132176cfdSRui Paulo 	uint8_t			ic_allmulti;	/* vap's needing all multicast*/
16232176cfdSRui Paulo 	uint8_t			ic_nrunning;	/* vap's marked running */
16332176cfdSRui Paulo 	uint8_t			ic_curmode;	/* current mode */
1644f655ef5SMatthew Dillon 	uint8_t			ic_macaddr[IEEE80211_ADDR_LEN];
16532176cfdSRui Paulo 	uint16_t		ic_bintval;	/* beacon interval */
16632176cfdSRui Paulo 	uint16_t		ic_lintval;	/* listen interval */
16732176cfdSRui Paulo 	uint16_t		ic_holdover;	/* PM hold over duration */
16832176cfdSRui Paulo 	uint16_t		ic_txpowlimit;	/* global tx power limit */
169f186073cSJoerg Sonnenberger 	struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX];
17032176cfdSRui Paulo 
17132176cfdSRui Paulo 	/*
17232176cfdSRui Paulo 	 * Channel state:
17332176cfdSRui Paulo 	 *
17432176cfdSRui Paulo 	 * ic_channels is the set of available channels for the device;
17532176cfdSRui Paulo 	 *    it is setup by the driver
17632176cfdSRui Paulo 	 * ic_nchans is the number of valid entries in ic_channels
17732176cfdSRui Paulo 	 * ic_chan_avail is a bit vector of these channels used to check
17832176cfdSRui Paulo 	 *    whether a channel is available w/o searching the channel table.
17932176cfdSRui Paulo 	 * ic_chan_active is a (potentially) constrained subset of
18032176cfdSRui Paulo 	 *    ic_chan_avail that reflects any mode setting or user-specified
18132176cfdSRui Paulo 	 *    limit on the set of channels to use/scan
18232176cfdSRui Paulo 	 * ic_curchan is the current channel the device is set to; it may
18332176cfdSRui Paulo 	 *    be different from ic_bsschan when we are off-channel scanning
18432176cfdSRui Paulo 	 *    or otherwise doing background work
18532176cfdSRui Paulo 	 * ic_bsschan is the channel selected for operation; it may
18632176cfdSRui Paulo 	 *    be undefined (IEEE80211_CHAN_ANYC)
18732176cfdSRui Paulo 	 * ic_prevchan is a cached ``previous channel'' used to optimize
18832176cfdSRui Paulo 	 *    lookups when switching back+forth between two channels
18932176cfdSRui Paulo 	 *    (e.g. for dynamic turbo)
19032176cfdSRui Paulo 	 */
19132176cfdSRui Paulo 	int			ic_nchans;	/* # entries in ic_channels */
19232176cfdSRui Paulo 	struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX];
193841ab66cSSepherosa Ziehau 	uint8_t			ic_chan_avail[IEEE80211_CHAN_BYTES];
194841ab66cSSepherosa Ziehau 	uint8_t			ic_chan_active[IEEE80211_CHAN_BYTES];
195841ab66cSSepherosa Ziehau 	uint8_t			ic_chan_scan[IEEE80211_CHAN_BYTES];
196841ab66cSSepherosa Ziehau 	struct ieee80211_channel *ic_curchan;	/* current channel */
19732176cfdSRui Paulo 	const struct ieee80211_rate_table *ic_rt; /* table for ic_curchan */
19832176cfdSRui Paulo 	struct ieee80211_channel *ic_bsschan;	/* bss channel */
19932176cfdSRui Paulo 	struct ieee80211_channel *ic_prevchan;	/* previous channel */
20032176cfdSRui Paulo 	struct ieee80211_regdomain ic_regdomain;/* regulatory data */
20132176cfdSRui Paulo 	struct ieee80211_appie	*ic_countryie;	/* calculated country ie */
20232176cfdSRui Paulo 	struct ieee80211_channel *ic_countryie_chan;
20332176cfdSRui Paulo 
20432176cfdSRui Paulo 	/* 802.11h/DFS state */
20532176cfdSRui Paulo 	struct ieee80211_channel *ic_csa_newchan;/* channel for doing CSA */
20632176cfdSRui Paulo 	short			ic_csa_mode;	/* mode for doing CSA */
20732176cfdSRui Paulo 	short			ic_csa_count;	/* count for doing CSA */
20832176cfdSRui Paulo 	struct ieee80211_dfs_state ic_dfs;	/* DFS state */
20932176cfdSRui Paulo 
21032176cfdSRui Paulo 	struct ieee80211_scan_state *ic_scan;	/* scan state */
2114f898719SImre Vadász 	struct ieee80211_scan_methods *ic_scan_methods; /* scan methods */
21232176cfdSRui Paulo 	int			ic_lastdata;	/* time of last data frame */
21332176cfdSRui Paulo 	int			ic_lastscan;	/* time last scan completed */
21432176cfdSRui Paulo 
21532176cfdSRui Paulo 	/* NB: this is the union of all vap stations/neighbors */
21632176cfdSRui Paulo 	int			ic_max_keyix;	/* max h/w key index */
21732176cfdSRui Paulo 	struct ieee80211_node_table ic_sta;	/* stations/neighbors */
21832176cfdSRui Paulo 	struct ieee80211_ageq	ic_stageq;	/* frame staging queue */
21932176cfdSRui Paulo 	uint32_t		ic_hash_key;	/* random key for mac hash */
22032176cfdSRui Paulo 
22132176cfdSRui Paulo 	/* XXX multi-bss: split out common/vap parts */
22232176cfdSRui Paulo 	struct ieee80211_wme_state ic_wme;	/* WME/WMM state */
22332176cfdSRui Paulo 
22432176cfdSRui Paulo 	/* XXX multi-bss: can per-vap be done/make sense? */
22532176cfdSRui Paulo 	enum ieee80211_protmode	ic_protmode;	/* 802.11g protection mode */
226841ab66cSSepherosa Ziehau 	uint16_t		ic_nonerpsta;	/* # non-ERP stations */
227841ab66cSSepherosa Ziehau 	uint16_t		ic_longslotsta;	/* # long slot time stations */
22832176cfdSRui Paulo 	uint16_t		ic_sta_assoc;	/* stations associated */
22932176cfdSRui Paulo 	uint16_t		ic_ht_sta_assoc;/* HT stations associated */
23032176cfdSRui Paulo 	uint16_t		ic_ht40_sta_assoc;/* HT40 stations associated */
23132176cfdSRui Paulo 	uint8_t			ic_curhtprotmode;/* HTINFO bss state */
23232176cfdSRui Paulo 	enum ieee80211_protmode	ic_htprotmode;	/* HT protection mode */
23332176cfdSRui Paulo 	int			ic_lastnonerp;	/* last time non-ERP sta noted*/
23432176cfdSRui Paulo 	int			ic_lastnonht;	/* last time non-HT sta noted */
235085ff963SMatthew Dillon 	uint8_t			ic_rxstream;    /* # RX streams */
236085ff963SMatthew Dillon 	uint8_t			ic_txstream;    /* # TX streams */
23732176cfdSRui Paulo 
23832176cfdSRui Paulo 	/* optional state for Atheros SuperG protocol extensions */
23932176cfdSRui Paulo 	struct ieee80211_superg	*ic_superg;
24032176cfdSRui Paulo 
24132176cfdSRui Paulo 	/* radiotap handling */
24232176cfdSRui Paulo 	struct ieee80211_radiotap_header *ic_th;/* tx radiotap headers */
24332176cfdSRui Paulo 	void			*ic_txchan;	/* channel state in ic_th */
24432176cfdSRui Paulo 	struct ieee80211_radiotap_header *ic_rh;/* rx radiotap headers */
24532176cfdSRui Paulo 	void			*ic_rxchan;	/* channel state in ic_rh */
24632176cfdSRui Paulo 	int			ic_montaps;	/* active monitor mode taps */
24732176cfdSRui Paulo 
24832176cfdSRui Paulo 	/* virtual ap create/delete */
24932176cfdSRui Paulo 	struct ieee80211vap*	(*ic_vap_create)(struct ieee80211com *,
250085ff963SMatthew Dillon 				    const char [IFNAMSIZ], int,
251085ff963SMatthew Dillon 				    enum ieee80211_opmode, int,
252085ff963SMatthew Dillon 				    const uint8_t [IEEE80211_ADDR_LEN],
253085ff963SMatthew Dillon 				    const uint8_t [IEEE80211_ADDR_LEN]);
25432176cfdSRui Paulo 	void			(*ic_vap_delete)(struct ieee80211vap *);
2554f655ef5SMatthew Dillon 	/* device specific ioctls */
2564f655ef5SMatthew Dillon 	int			(*ic_ioctl)(struct ieee80211com *,
2574f655ef5SMatthew Dillon 				    u_long, void *);
2584f655ef5SMatthew Dillon 	/* start/stop device */
2594f655ef5SMatthew Dillon 	void			(*ic_parent)(struct ieee80211com *);
26032176cfdSRui Paulo 	/* operating mode attachment */
26132176cfdSRui Paulo 	ieee80211vap_attach	ic_vattach[IEEE80211_OPMODE_MAX];
26232176cfdSRui Paulo 	/* return hardware/radio capabilities */
26332176cfdSRui Paulo 	void			(*ic_getradiocaps)(struct ieee80211com *,
26432176cfdSRui Paulo 				    int, int *, struct ieee80211_channel []);
26532176cfdSRui Paulo 	/* check and/or prepare regdomain state change */
26632176cfdSRui Paulo 	int			(*ic_setregdomain)(struct ieee80211com *,
26732176cfdSRui Paulo 				    struct ieee80211_regdomain *,
26832176cfdSRui Paulo 				    int, struct ieee80211_channel []);
269085ff963SMatthew Dillon 
270085ff963SMatthew Dillon 	int			(*ic_set_quiet)(struct ieee80211_node *,
271085ff963SMatthew Dillon 				    u_int8_t *quiet_elm);
272085ff963SMatthew Dillon 
2734f655ef5SMatthew Dillon 	/* regular transmit */
2744f655ef5SMatthew Dillon 	int			(*ic_transmit)(struct ieee80211com *,
2754f655ef5SMatthew Dillon 				    struct mbuf *);
27632176cfdSRui Paulo 	/* send/recv 802.11 management frame */
27732176cfdSRui Paulo 	int			(*ic_send_mgmt)(struct ieee80211_node *,
27832176cfdSRui Paulo 				     int, int);
27932176cfdSRui Paulo 	/* send raw 802.11 frame */
28032176cfdSRui Paulo 	int			(*ic_raw_xmit)(struct ieee80211_node *,
28132176cfdSRui Paulo 				    struct mbuf *,
28232176cfdSRui Paulo 				    const struct ieee80211_bpf_params *);
28332176cfdSRui Paulo 	/* update device state for 802.11 slot time change */
2844f898719SImre Vadász 	void			(*ic_updateslot)(struct ieee80211com *);
28532176cfdSRui Paulo 	/* handle multicast state changes */
2864f898719SImre Vadász 	void			(*ic_update_mcast)(struct ieee80211com *);
28732176cfdSRui Paulo 	/* handle promiscuous mode changes */
2884f898719SImre Vadász 	void			(*ic_update_promisc)(struct ieee80211com *);
28932176cfdSRui Paulo 	/* new station association callback/notification */
29032176cfdSRui Paulo 	void			(*ic_newassoc)(struct ieee80211_node *, int);
29132176cfdSRui Paulo 	/* TDMA update notification */
29232176cfdSRui Paulo 	void			(*ic_tdma_update)(struct ieee80211_node *,
29332176cfdSRui Paulo 				    const struct ieee80211_tdma_param *, int);
29432176cfdSRui Paulo 	/* node state management */
29532176cfdSRui Paulo 	struct ieee80211_node*	(*ic_node_alloc)(struct ieee80211vap *,
29632176cfdSRui Paulo 				    const uint8_t [IEEE80211_ADDR_LEN]);
29732176cfdSRui Paulo 	void			(*ic_node_free)(struct ieee80211_node *);
29832176cfdSRui Paulo 	void			(*ic_node_cleanup)(struct ieee80211_node *);
29932176cfdSRui Paulo 	void			(*ic_node_age)(struct ieee80211_node *);
30032176cfdSRui Paulo 	void			(*ic_node_drain)(struct ieee80211_node *);
30132176cfdSRui Paulo 	int8_t			(*ic_node_getrssi)(const struct ieee80211_node*);
30232176cfdSRui Paulo 	void			(*ic_node_getsignal)(const struct ieee80211_node*,
30332176cfdSRui Paulo 				    int8_t *, int8_t *);
30432176cfdSRui Paulo 	void			(*ic_node_getmimoinfo)(
30532176cfdSRui Paulo 				    const struct ieee80211_node*,
30632176cfdSRui Paulo 				    struct ieee80211_mimo_info *);
30732176cfdSRui Paulo 	/* scanning support */
30832176cfdSRui Paulo 	void			(*ic_scan_start)(struct ieee80211com *);
30932176cfdSRui Paulo 	void			(*ic_scan_end)(struct ieee80211com *);
31032176cfdSRui Paulo 	void			(*ic_set_channel)(struct ieee80211com *);
31132176cfdSRui Paulo 	void			(*ic_scan_curchan)(struct ieee80211_scan_state *,
31232176cfdSRui Paulo 				    unsigned long);
31332176cfdSRui Paulo 	void			(*ic_scan_mindwell)(struct ieee80211_scan_state *);
314841ab66cSSepherosa Ziehau 
315841ab66cSSepherosa Ziehau 	/*
31632176cfdSRui Paulo 	 * 802.11n ADDBA support.  A simple/generic implementation
31732176cfdSRui Paulo 	 * of A-MPDU tx aggregation is provided; the driver may
31832176cfdSRui Paulo 	 * override these methods to provide their own support.
31932176cfdSRui Paulo 	 * A-MPDU rx re-ordering happens automatically if the
32032176cfdSRui Paulo 	 * driver passes out-of-order frames to ieee80211_input
32132176cfdSRui Paulo 	 * from an assocated HT station.
322841ab66cSSepherosa Ziehau 	 */
32332176cfdSRui Paulo 	int			(*ic_recv_action)(struct ieee80211_node *,
32432176cfdSRui Paulo 				    const struct ieee80211_frame *,
32532176cfdSRui Paulo 				    const uint8_t *frm, const uint8_t *efrm);
32632176cfdSRui Paulo 	int			(*ic_send_action)(struct ieee80211_node *,
32732176cfdSRui Paulo 				    int category, int action, void *);
32832176cfdSRui Paulo 	/* check if A-MPDU should be enabled this station+ac */
32932176cfdSRui Paulo 	int			(*ic_ampdu_enable)(struct ieee80211_node *,
33032176cfdSRui Paulo 				    struct ieee80211_tx_ampdu *);
33132176cfdSRui Paulo 	/* start/stop doing A-MPDU tx aggregation for a station */
33232176cfdSRui Paulo 	int			(*ic_addba_request)(struct ieee80211_node *,
33332176cfdSRui Paulo 				    struct ieee80211_tx_ampdu *,
33432176cfdSRui Paulo 				    int dialogtoken, int baparamset,
33532176cfdSRui Paulo 				    int batimeout);
33632176cfdSRui Paulo 	int			(*ic_addba_response)(struct ieee80211_node *,
33732176cfdSRui Paulo 				    struct ieee80211_tx_ampdu *,
33832176cfdSRui Paulo 				    int status, int baparamset, int batimeout);
33932176cfdSRui Paulo 	void			(*ic_addba_stop)(struct ieee80211_node *,
34032176cfdSRui Paulo 				    struct ieee80211_tx_ampdu *);
341085ff963SMatthew Dillon 	void			(*ic_addba_response_timeout)(struct ieee80211_node *,
342085ff963SMatthew Dillon 				    struct ieee80211_tx_ampdu *);
34332176cfdSRui Paulo 	/* BAR response received */
34432176cfdSRui Paulo 	void			(*ic_bar_response)(struct ieee80211_node *,
34532176cfdSRui Paulo 				    struct ieee80211_tx_ampdu *, int status);
34632176cfdSRui Paulo 	/* start/stop doing A-MPDU rx processing for a station */
34732176cfdSRui Paulo 	int			(*ic_ampdu_rx_start)(struct ieee80211_node *,
34832176cfdSRui Paulo 				    struct ieee80211_rx_ampdu *, int baparamset,
34932176cfdSRui Paulo 				    int batimeout, int baseqctl);
35032176cfdSRui Paulo 	void			(*ic_ampdu_rx_stop)(struct ieee80211_node *,
35132176cfdSRui Paulo 				    struct ieee80211_rx_ampdu *);
352085ff963SMatthew Dillon 
353085ff963SMatthew Dillon 	/* The channel width has changed (20<->2040) */
354085ff963SMatthew Dillon 	void			(*ic_update_chw)(struct ieee80211com *);
355085ff963SMatthew Dillon 
3564028af95SRui Paulo 	uint64_t		ic_spare[7];
357f186073cSJoerg Sonnenberger };
358f186073cSJoerg Sonnenberger 
35932176cfdSRui Paulo struct ieee80211_aclator;
36032176cfdSRui Paulo struct ieee80211_tdma_state;
36132176cfdSRui Paulo struct ieee80211_mesh_state;
36232176cfdSRui Paulo struct ieee80211_hwmp_state;
36332176cfdSRui Paulo 
36432176cfdSRui Paulo struct ieee80211vap {
36532176cfdSRui Paulo 	struct ifmedia		iv_media;	/* interface media config */
36632176cfdSRui Paulo 	struct ifnet		*iv_ifp;	/* associated device */
36732176cfdSRui Paulo 	struct bpf_if		*iv_rawbpf;	/* packet filter structure */
36832176cfdSRui Paulo 	struct sysctl_ctx_list	*iv_sysctl;	/* dynamic sysctl context */
36932176cfdSRui Paulo 	struct sysctl_oid	*iv_oid;	/* net.wlan.X sysctl oid */
37032176cfdSRui Paulo 
37132176cfdSRui Paulo 	TAILQ_ENTRY(ieee80211vap) iv_next;	/* list of vap instances */
37232176cfdSRui Paulo 	struct ieee80211com	*iv_ic;		/* back ptr to common state */
3734f655ef5SMatthew Dillon 	/* MAC address: ifp or ic */
3744f655ef5SMatthew Dillon 	uint8_t			iv_myaddr[IEEE80211_ADDR_LEN];
37532176cfdSRui Paulo 	uint32_t		iv_debug;	/* debug msg flags */
37632176cfdSRui Paulo 	struct ieee80211_stats	iv_stats;	/* statistics */
37732176cfdSRui Paulo 
37832176cfdSRui Paulo 	uint32_t		iv_flags;	/* state flags */
37932176cfdSRui Paulo 	uint32_t		iv_flags_ext;	/* extended state flags */
38032176cfdSRui Paulo 	uint32_t		iv_flags_ht;	/* HT state flags */
38132176cfdSRui Paulo 	uint32_t		iv_flags_ven;	/* vendor state flags */
3824f655ef5SMatthew Dillon 	uint32_t		iv_ifflags;	/* ifnet flags */
38332176cfdSRui Paulo 	uint32_t		iv_caps;	/* capabilities */
38432176cfdSRui Paulo 	uint32_t		iv_htcaps;	/* HT capabilities */
3854028af95SRui Paulo 	uint32_t		iv_htextcaps;	/* HT extended capabilities */
38632176cfdSRui Paulo 	enum ieee80211_opmode	iv_opmode;	/* operation mode */
38732176cfdSRui Paulo 	enum ieee80211_state	iv_state;	/* state machine state */
38832176cfdSRui Paulo 	enum ieee80211_state	iv_nstate;	/* pending state */
38932176cfdSRui Paulo 	int			iv_nstate_arg;	/* pending state arg */
39032176cfdSRui Paulo 	struct task		iv_nstate_task;	/* deferred state processing */
39132176cfdSRui Paulo 	struct task		iv_swbmiss_task;/* deferred iv_bmiss call */
39232176cfdSRui Paulo 	struct callout		iv_mgtsend;	/* mgmt frame response timer */
39332176cfdSRui Paulo 						/* inactivity timer settings */
39432176cfdSRui Paulo 	int			iv_inact_init;	/* setting for new station */
39532176cfdSRui Paulo 	int			iv_inact_auth;	/* auth but not assoc setting */
39632176cfdSRui Paulo 	int			iv_inact_run;	/* authorized setting */
39732176cfdSRui Paulo 	int			iv_inact_probe;	/* inactive probe time */
39832176cfdSRui Paulo 
39932176cfdSRui Paulo 	int			iv_des_nssid;	/* # desired ssids */
40032176cfdSRui Paulo 	struct ieee80211_scan_ssid iv_des_ssid[1];/* desired ssid table */
40132176cfdSRui Paulo 	uint8_t			iv_des_bssid[IEEE80211_ADDR_LEN];
40232176cfdSRui Paulo 	struct ieee80211_channel *iv_des_chan;	/* desired channel */
40332176cfdSRui Paulo 	uint16_t		iv_des_mode;	/* desired mode */
40432176cfdSRui Paulo 	int			iv_nicknamelen;	/* XXX junk */
40532176cfdSRui Paulo 	uint8_t			iv_nickname[IEEE80211_NWID_LEN];
40632176cfdSRui Paulo 	u_int			iv_bgscanidle;	/* bg scan idle threshold */
40732176cfdSRui Paulo 	u_int			iv_bgscanintvl;	/* bg scan min interval */
40832176cfdSRui Paulo 	u_int			iv_scanvalid;	/* scan cache valid threshold */
40932176cfdSRui Paulo 	u_int			iv_scanreq_duration;
41032176cfdSRui Paulo 	u_int			iv_scanreq_mindwell;
41132176cfdSRui Paulo 	u_int			iv_scanreq_maxdwell;
41232176cfdSRui Paulo 	uint16_t		iv_scanreq_flags;/* held scan request params */
41332176cfdSRui Paulo 	uint8_t			iv_scanreq_nssid;
41432176cfdSRui Paulo 	struct ieee80211_scan_ssid iv_scanreq_ssid[IEEE80211_SCAN_MAX_SSID];
41532176cfdSRui Paulo 	/* sta-mode roaming state */
41632176cfdSRui Paulo 	enum ieee80211_roamingmode iv_roaming;	/* roaming mode */
41732176cfdSRui Paulo 	struct ieee80211_roamparam iv_roamparms[IEEE80211_MODE_MAX];
41832176cfdSRui Paulo 
41932176cfdSRui Paulo 	uint8_t			iv_bmissthreshold;
42032176cfdSRui Paulo 	uint8_t			iv_bmiss_count;	/* current beacon miss count */
42132176cfdSRui Paulo 	int			iv_bmiss_max;	/* max bmiss before scan */
42232176cfdSRui Paulo 	uint16_t		iv_swbmiss_count;/* beacons in last period */
42332176cfdSRui Paulo 	uint16_t		iv_swbmiss_period;/* s/w bmiss period */
42432176cfdSRui Paulo 	struct callout		iv_swbmiss;	/* s/w beacon miss timer */
42532176cfdSRui Paulo 
42632176cfdSRui Paulo 	int			iv_ampdu_rxmax;	/* A-MPDU rx limit (bytes) */
42732176cfdSRui Paulo 	int			iv_ampdu_density;/* A-MPDU density */
42832176cfdSRui Paulo 	int			iv_ampdu_limit;	/* A-MPDU tx limit (bytes) */
42932176cfdSRui Paulo 	int			iv_amsdu_limit;	/* A-MSDU tx limit (bytes) */
43032176cfdSRui Paulo 	u_int			iv_ampdu_mintraffic[WME_NUM_AC];
43132176cfdSRui Paulo 
4324f655ef5SMatthew Dillon 	struct ieee80211_beacon_offsets iv_bcn_off;
43332176cfdSRui Paulo 	uint32_t		*iv_aid_bitmap;	/* association id map */
43432176cfdSRui Paulo 	uint16_t		iv_max_aid;
43532176cfdSRui Paulo 	uint16_t		iv_sta_assoc;	/* stations associated */
43632176cfdSRui Paulo 	uint16_t		iv_ps_sta;	/* stations in power save */
43732176cfdSRui Paulo 	uint16_t		iv_ps_pending;	/* ps sta's w/ pending frames */
43832176cfdSRui Paulo 	uint16_t		iv_txseq;	/* mcast xmit seq# space */
43932176cfdSRui Paulo 	uint16_t		iv_tim_len;	/* ic_tim_bitmap size (bytes) */
44032176cfdSRui Paulo 	uint8_t			*iv_tim_bitmap;	/* power-save stations w/ data*/
44132176cfdSRui Paulo 	uint8_t			iv_dtim_period;	/* DTIM period */
44232176cfdSRui Paulo 	uint8_t			iv_dtim_count;	/* DTIM count from last bcn */
44332176cfdSRui Paulo 						/* set/unset aid pwrsav state */
444085ff963SMatthew Dillon 	uint8_t			iv_quiet;	/* Quiet Element */
445085ff963SMatthew Dillon 	uint8_t			iv_quiet_count;	/* constant count for Quiet Element */
446085ff963SMatthew Dillon 	uint8_t			iv_quiet_count_value;	/* variable count for Quiet Element */
447085ff963SMatthew Dillon 	uint8_t			iv_quiet_period;	/* period for Quiet Element */
448085ff963SMatthew Dillon 	uint16_t		iv_quiet_duration;	/* duration for Quiet Element */
449085ff963SMatthew Dillon 	uint16_t		iv_quiet_offset;	/* offset for Quiet Element */
45032176cfdSRui Paulo 	int			iv_csa_count;	/* count for doing CSA */
45132176cfdSRui Paulo 
45232176cfdSRui Paulo 	struct ieee80211_node	*iv_bss;	/* information for this node */
45332176cfdSRui Paulo 	struct ieee80211_txparam iv_txparms[IEEE80211_MODE_MAX];
45432176cfdSRui Paulo 	uint16_t		iv_rtsthreshold;
45532176cfdSRui Paulo 	uint16_t		iv_fragthreshold;
45632176cfdSRui Paulo 	int			iv_inact_timer;	/* inactivity timer wait */
45732176cfdSRui Paulo 	/* application-specified IE's to attach to mgt frames */
45832176cfdSRui Paulo 	struct ieee80211_appie	*iv_appie_beacon;
45932176cfdSRui Paulo 	struct ieee80211_appie	*iv_appie_probereq;
46032176cfdSRui Paulo 	struct ieee80211_appie	*iv_appie_proberesp;
46132176cfdSRui Paulo 	struct ieee80211_appie	*iv_appie_assocreq;
46232176cfdSRui Paulo 	struct ieee80211_appie	*iv_appie_assocresp;
46332176cfdSRui Paulo 	struct ieee80211_appie	*iv_appie_wpa;
46432176cfdSRui Paulo 	uint8_t			*iv_wpa_ie;
46532176cfdSRui Paulo 	uint8_t			*iv_rsn_ie;
46632176cfdSRui Paulo 	uint16_t		iv_max_keyix;	/* max h/w key index */
46732176cfdSRui Paulo 	ieee80211_keyix		iv_def_txkey;	/* default/group tx key index */
46832176cfdSRui Paulo 	struct ieee80211_key	iv_nw_keys[IEEE80211_WEP_NKID];
46932176cfdSRui Paulo 	int			(*iv_key_alloc)(struct ieee80211vap *,
47032176cfdSRui Paulo 				    struct ieee80211_key *,
47132176cfdSRui Paulo 				    ieee80211_keyix *, ieee80211_keyix *);
47232176cfdSRui Paulo 	int			(*iv_key_delete)(struct ieee80211vap *,
47332176cfdSRui Paulo 				    const struct ieee80211_key *);
47432176cfdSRui Paulo 	int			(*iv_key_set)(struct ieee80211vap *,
4754f655ef5SMatthew Dillon 				    const struct ieee80211_key *);
47632176cfdSRui Paulo 	void			(*iv_key_update_begin)(struct ieee80211vap *);
47732176cfdSRui Paulo 	void			(*iv_key_update_end)(struct ieee80211vap *);
47832176cfdSRui Paulo 
47932176cfdSRui Paulo 	const struct ieee80211_authenticator *iv_auth; /* authenticator glue */
48032176cfdSRui Paulo 	void			*iv_ec;		/* private auth state */
48132176cfdSRui Paulo 
48232176cfdSRui Paulo 	const struct ieee80211_aclator *iv_acl;	/* acl glue */
48332176cfdSRui Paulo 	void			*iv_as;		/* private aclator state */
48432176cfdSRui Paulo 
4854028af95SRui Paulo 	const struct ieee80211_ratectl *iv_rate;
4864028af95SRui Paulo 	void			*iv_rs;		/* private ratectl state */
4874028af95SRui Paulo 
48832176cfdSRui Paulo 	struct ieee80211_tdma_state *iv_tdma;	/* tdma state */
48932176cfdSRui Paulo 	struct ieee80211_mesh_state *iv_mesh;	/* MBSS state */
49032176cfdSRui Paulo 	struct ieee80211_hwmp_state *iv_hwmp;	/* HWMP state */
49132176cfdSRui Paulo 
49232176cfdSRui Paulo 	/* operate-mode detach hook */
49332176cfdSRui Paulo 	void			(*iv_opdetach)(struct ieee80211vap *);
49432176cfdSRui Paulo 	/* receive processing */
49532176cfdSRui Paulo 	int			(*iv_input)(struct ieee80211_node *,
4964f898719SImre Vadász 				    struct mbuf *,
4974f898719SImre Vadász 				    const struct ieee80211_rx_stats *,
4984f898719SImre Vadász 				    int, int);
49932176cfdSRui Paulo 	void			(*iv_recv_mgmt)(struct ieee80211_node *,
5004f898719SImre Vadász 				    struct mbuf *, int,
5014f898719SImre Vadász 				    const struct ieee80211_rx_stats *,
5024f898719SImre Vadász 				    int, int);
50332176cfdSRui Paulo 	void			(*iv_recv_ctl)(struct ieee80211_node *,
50432176cfdSRui Paulo 				    struct mbuf *, int);
50532176cfdSRui Paulo 	void			(*iv_deliver_data)(struct ieee80211vap *,
50632176cfdSRui Paulo 				    struct ieee80211_node *, struct mbuf *);
50732176cfdSRui Paulo #if 0
50832176cfdSRui Paulo 	/* send processing */
50932176cfdSRui Paulo 	int			(*iv_send_mgmt)(struct ieee80211_node *,
51032176cfdSRui Paulo 				     int, int);
51132176cfdSRui Paulo #endif
51232176cfdSRui Paulo 	/* beacon miss processing */
51332176cfdSRui Paulo 	void			(*iv_bmiss)(struct ieee80211vap *);
51432176cfdSRui Paulo 	/* reset device state after 802.11 parameter/state change */
51532176cfdSRui Paulo 	int			(*iv_reset)(struct ieee80211vap *, u_long);
51632176cfdSRui Paulo 	/* [schedule] beacon frame update */
51732176cfdSRui Paulo 	void			(*iv_update_beacon)(struct ieee80211vap *, int);
51832176cfdSRui Paulo 	/* power save handling */
51932176cfdSRui Paulo 	void			(*iv_update_ps)(struct ieee80211vap *, int);
52032176cfdSRui Paulo 	int			(*iv_set_tim)(struct ieee80211_node *, int);
521d98a0bcfSMatthew Dillon 	void			(*iv_node_ps)(struct ieee80211_node *, int);
522d98a0bcfSMatthew Dillon 	void			(*iv_sta_ps)(struct ieee80211vap *, int);
523085ff963SMatthew Dillon 	void			(*iv_recv_pspoll)(struct ieee80211_node *,
524085ff963SMatthew Dillon 				    struct mbuf *);
525085ff963SMatthew Dillon 
52632176cfdSRui Paulo 	/* state machine processing */
52732176cfdSRui Paulo 	int			(*iv_newstate)(struct ieee80211vap *,
52832176cfdSRui Paulo 				    enum ieee80211_state, int);
52932176cfdSRui Paulo 	/* 802.3 output method for raw frame xmit */
530085ff963SMatthew Dillon #if defined(__DragonFly__)
53132176cfdSRui Paulo 	int			(*iv_output)(struct ifnet *, struct mbuf *,
53234a60cf6SRui Paulo 				    struct sockaddr *, struct rtentry *);
533085ff963SMatthew Dillon #else
534085ff963SMatthew Dillon 	int			(*iv_output)(struct ifnet *, struct mbuf *,
535294727bfSImre Vadász 				    const struct sockaddr *, struct route *);
536085ff963SMatthew Dillon #endif
5374028af95SRui Paulo 	uint64_t		iv_spare[6];
53832176cfdSRui Paulo };
539*805c8e8eSzrj #ifdef MALLOC_DECLARE
54032176cfdSRui Paulo MALLOC_DECLARE(M_80211_VAP);
541*805c8e8eSzrj #endif
54232176cfdSRui Paulo 
543f186073cSJoerg Sonnenberger #define	IEEE80211_ADDR_EQ(a1,a2)	(memcmp(a1,a2,IEEE80211_ADDR_LEN) == 0)
544f186073cSJoerg Sonnenberger #define	IEEE80211_ADDR_COPY(dst,src)	memcpy(dst,src,IEEE80211_ADDR_LEN)
545f186073cSJoerg Sonnenberger 
54632176cfdSRui Paulo /* ic_flags/iv_flags */
54732176cfdSRui Paulo #define	IEEE80211_F_TURBOP	0x00000001	/* CONF: ATH Turbo enabled*/
54832176cfdSRui Paulo #define	IEEE80211_F_COMP	0x00000002	/* CONF: ATH comp enabled */
54932176cfdSRui Paulo #define	IEEE80211_F_FF		0x00000004	/* CONF: ATH FF enabled */
55032176cfdSRui Paulo #define	IEEE80211_F_BURST	0x00000008	/* CONF: bursting enabled */
551841ab66cSSepherosa Ziehau /* NB: this is intentionally setup to be IEEE80211_CAPINFO_PRIVACY */
552841ab66cSSepherosa Ziehau #define	IEEE80211_F_PRIVACY	0x00000010	/* CONF: privacy enabled */
553841ab66cSSepherosa Ziehau #define	IEEE80211_F_PUREG	0x00000020	/* CONF: 11g w/o 11b sta's */
554841ab66cSSepherosa Ziehau #define	IEEE80211_F_SCAN	0x00000080	/* STATUS: scanning */
555841ab66cSSepherosa Ziehau #define	IEEE80211_F_ASCAN	0x00000100	/* STATUS: active scan */
556841ab66cSSepherosa Ziehau #define	IEEE80211_F_SIBSS	0x00000200	/* STATUS: start IBSS */
557841ab66cSSepherosa Ziehau /* NB: this is intentionally setup to be IEEE80211_CAPINFO_SHORT_SLOTTIME */
558841ab66cSSepherosa Ziehau #define	IEEE80211_F_SHSLOT	0x00000400	/* STATUS: use short slot time*/
559841ab66cSSepherosa Ziehau #define	IEEE80211_F_PMGTON	0x00000800	/* CONF: Power mgmt enable */
560841ab66cSSepherosa Ziehau #define	IEEE80211_F_DESBSSID	0x00001000	/* CONF: des_bssid is set */
561841ab66cSSepherosa Ziehau #define	IEEE80211_F_WME		0x00002000	/* CONF: enable WME use */
562841ab66cSSepherosa Ziehau #define	IEEE80211_F_BGSCAN	0x00004000	/* CONF: bg scan enabled (???)*/
563841ab66cSSepherosa Ziehau #define	IEEE80211_F_SWRETRY	0x00008000	/* CONF: sw tx retry enabled */
564841ab66cSSepherosa Ziehau #define IEEE80211_F_TXPOW_FIXED	0x00010000	/* TX Power: fixed rate */
565841ab66cSSepherosa Ziehau #define	IEEE80211_F_IBSSON	0x00020000	/* CONF: IBSS creation enable */
566841ab66cSSepherosa Ziehau #define	IEEE80211_F_SHPREAMBLE	0x00040000	/* STATUS: use short preamble */
567841ab66cSSepherosa Ziehau #define	IEEE80211_F_DATAPAD	0x00080000	/* CONF: do alignment pad */
568f186073cSJoerg Sonnenberger #define	IEEE80211_F_USEPROT	0x00100000	/* STATUS: protection enabled */
569f186073cSJoerg Sonnenberger #define	IEEE80211_F_USEBARKER	0x00200000	/* STATUS: use barker preamble*/
57032176cfdSRui Paulo #define	IEEE80211_F_CSAPENDING	0x00400000	/* STATUS: chan switch pending*/
571841ab66cSSepherosa Ziehau #define	IEEE80211_F_WPA1	0x00800000	/* CONF: WPA enabled */
572841ab66cSSepherosa Ziehau #define	IEEE80211_F_WPA2	0x01000000	/* CONF: WPA2 enabled */
573841ab66cSSepherosa Ziehau #define	IEEE80211_F_WPA		0x01800000	/* CONF: WPA/WPA2 enabled */
574841ab66cSSepherosa Ziehau #define	IEEE80211_F_DROPUNENC	0x02000000	/* CONF: drop unencrypted */
575841ab66cSSepherosa Ziehau #define	IEEE80211_F_COUNTERM	0x04000000	/* CONF: TKIP countermeasures */
576841ab66cSSepherosa Ziehau #define	IEEE80211_F_HIDESSID	0x08000000	/* CONF: hide SSID in beacon */
577841ab66cSSepherosa Ziehau #define	IEEE80211_F_NOBRIDGE	0x10000000	/* CONF: dis. internal bridge */
57832176cfdSRui Paulo #define	IEEE80211_F_PCF		0x20000000	/* CONF: PCF enabled */
57932176cfdSRui Paulo #define	IEEE80211_F_DOTH	0x40000000	/* CONF: 11h enabled */
58032176cfdSRui Paulo #define	IEEE80211_F_DWDS	0x80000000	/* CONF: Dynamic WDS enabled */
581841ab66cSSepherosa Ziehau 
58232176cfdSRui Paulo #define	IEEE80211_F_BITS \
58332176cfdSRui Paulo 	"\20\1TURBOP\2COMP\3FF\4BURST\5PRIVACY\6PUREG\10SCAN\11ASCAN\12SIBSS" \
58432176cfdSRui Paulo 	"\13SHSLOT\14PMGTON\15DESBSSID\16WME\17BGSCAN\20SWRETRY\21TXPOW_FIXED" \
58532176cfdSRui Paulo 	"\22IBSSON\23SHPREAMBLE\24DATAPAD\25USEPROT\26USERBARKER\27CSAPENDING" \
58632176cfdSRui Paulo 	"\30WPA1\31WPA2\32DROPUNENC\33COUNTERM\34HIDESSID\35NOBRIDG\36PCF" \
58732176cfdSRui Paulo 	"\37DOTH\40DWDS"
58832176cfdSRui Paulo 
58932176cfdSRui Paulo /* Atheros protocol-specific flags */
59032176cfdSRui Paulo #define	IEEE80211_F_ATHEROS \
59132176cfdSRui Paulo 	(IEEE80211_F_FF | IEEE80211_F_COMP | IEEE80211_F_TURBOP)
59232176cfdSRui Paulo /* Check if an Atheros capability was negotiated for use */
59332176cfdSRui Paulo #define	IEEE80211_ATH_CAP(vap, ni, bit) \
59432176cfdSRui Paulo 	((vap)->iv_flags & (ni)->ni_ath_flags & (bit))
59532176cfdSRui Paulo 
59632176cfdSRui Paulo /* ic_flags_ext/iv_flags_ext */
59732176cfdSRui Paulo #define	IEEE80211_FEXT_INACT	 0x00000002	/* CONF: sta inact handling */
59832176cfdSRui Paulo #define	IEEE80211_FEXT_SCANWAIT	 0x00000004	/* STATUS: awaiting scan */
599841ab66cSSepherosa Ziehau /* 0x00000006 reserved */
60032176cfdSRui Paulo #define	IEEE80211_FEXT_BGSCAN	 0x00000008	/* STATUS: complete bgscan */
60132176cfdSRui Paulo #define	IEEE80211_FEXT_WPS	 0x00000010	/* CONF: WPS enabled */
60232176cfdSRui Paulo #define	IEEE80211_FEXT_TSN 	 0x00000020	/* CONF: TSN enabled */
60332176cfdSRui Paulo #define	IEEE80211_FEXT_SCANREQ	 0x00000040	/* STATUS: scan req params */
60432176cfdSRui Paulo #define	IEEE80211_FEXT_RESUME	 0x00000080	/* STATUS: start on resume */
60532176cfdSRui Paulo #define	IEEE80211_FEXT_4ADDR	 0x00000100	/* CONF: apply 4-addr encap */
60632176cfdSRui Paulo #define	IEEE80211_FEXT_NONERP_PR 0x00000200	/* STATUS: non-ERP sta present*/
607841ab66cSSepherosa Ziehau #define	IEEE80211_FEXT_SWBMISS	 0x00000400	/* CONF: do bmiss in s/w */
60832176cfdSRui Paulo #define	IEEE80211_FEXT_DFS	 0x00000800	/* CONF: DFS enabled */
60932176cfdSRui Paulo #define	IEEE80211_FEXT_DOTD	 0x00001000	/* CONF: 11d enabled */
61032176cfdSRui Paulo #define	IEEE80211_FEXT_STATEWAIT 0x00002000	/* STATUS: awaiting state chg */
61132176cfdSRui Paulo #define	IEEE80211_FEXT_REINIT	 0x00004000	/* STATUS: INIT state first */
61232176cfdSRui Paulo #define	IEEE80211_FEXT_BPF	 0x00008000	/* STATUS: BPF tap present */
61332176cfdSRui Paulo /* NB: immutable: should be set only when creating a vap */
61432176cfdSRui Paulo #define	IEEE80211_FEXT_WDSLEGACY 0x00010000	/* CONF: legacy WDS operation */
615841ab66cSSepherosa Ziehau #define	IEEE80211_FEXT_PROBECHAN 0x00020000	/* CONF: probe passive channel*/
61632176cfdSRui Paulo #define	IEEE80211_FEXT_UNIQMAC	 0x00040000	/* CONF: user or computed mac */
61784bcb7f7SImre Vadász #define	IEEE80211_FEXT_SCAN_OFFLOAD	0x00080000	/* CONF: scan is fully offloaded */
618f186073cSJoerg Sonnenberger 
61932176cfdSRui Paulo #define	IEEE80211_FEXT_BITS \
62032176cfdSRui Paulo 	"\20\2INACT\3SCANWAIT\4BGSCAN\5WPS\6TSN\7SCANREQ\10RESUME" \
62132176cfdSRui Paulo 	"\0114ADDR\12NONEPR_PR\13SWBMISS\14DFS\15DOTD\16STATEWAIT\17REINIT" \
62284bcb7f7SImre Vadász 	"\20BPF\21WDSLEGACY\22PROBECHAN\23UNIQMAC\24SCAN_OFFLOAD"
62332176cfdSRui Paulo 
62432176cfdSRui Paulo /* ic_flags_ht/iv_flags_ht */
62532176cfdSRui Paulo #define	IEEE80211_FHT_NONHT_PR	 0x00000001	/* STATUS: non-HT sta present */
62632176cfdSRui Paulo #define	IEEE80211_FHT_GF  	 0x00040000	/* CONF: Greenfield enabled */
62732176cfdSRui Paulo #define	IEEE80211_FHT_HT	 0x00080000	/* CONF: HT supported */
62832176cfdSRui Paulo #define	IEEE80211_FHT_AMPDU_TX	 0x00100000	/* CONF: A-MPDU tx supported */
62932176cfdSRui Paulo #define	IEEE80211_FHT_AMPDU_RX	 0x00200000	/* CONF: A-MPDU rx supported */
63032176cfdSRui Paulo #define	IEEE80211_FHT_AMSDU_TX	 0x00400000	/* CONF: A-MSDU tx supported */
63132176cfdSRui Paulo #define	IEEE80211_FHT_AMSDU_RX	 0x00800000	/* CONF: A-MSDU rx supported */
63232176cfdSRui Paulo #define	IEEE80211_FHT_USEHT40	 0x01000000	/* CONF: 20/40 use enabled */
63332176cfdSRui Paulo #define	IEEE80211_FHT_PUREN	 0x02000000	/* CONF: 11n w/o legacy sta's */
63432176cfdSRui Paulo #define	IEEE80211_FHT_SHORTGI20	 0x04000000	/* CONF: short GI in HT20 */
63532176cfdSRui Paulo #define	IEEE80211_FHT_SHORTGI40	 0x08000000	/* CONF: short GI in HT40 */
63632176cfdSRui Paulo #define	IEEE80211_FHT_HTCOMPAT 	 0x10000000	/* CONF: HT vendor OUI's */
63732176cfdSRui Paulo #define	IEEE80211_FHT_RIFS  	 0x20000000	/* CONF: RIFS enabled */
63832176cfdSRui Paulo #define	IEEE80211_FHT_STBC_TX 	 0x40000000	/* CONF: STBC tx enabled */
63932176cfdSRui Paulo #define	IEEE80211_FHT_STBC_RX 	 0x80000000	/* CONF: STBC rx enabled */
64032176cfdSRui Paulo 
64132176cfdSRui Paulo #define	IEEE80211_FHT_BITS \
64232176cfdSRui Paulo 	"\20\1NONHT_PR" \
643085ff963SMatthew Dillon 	"\23GF\24HT\25AMPDU_TX\26AMPDU_TX" \
64432176cfdSRui Paulo 	"\27AMSDU_TX\30AMSDU_RX\31USEHT40\32PUREN\33SHORTGI20\34SHORTGI40" \
64532176cfdSRui Paulo 	"\35HTCOMPAT\36RIFS\37STBC_TX\40STBC_RX"
64632176cfdSRui Paulo 
64732176cfdSRui Paulo #define	IEEE80211_FVEN_BITS	"\20"
64832176cfdSRui Paulo 
64932176cfdSRui Paulo /* ic_caps/iv_caps: device driver capabilities */
65032176cfdSRui Paulo /* 0x2e available */
65132176cfdSRui Paulo #define	IEEE80211_C_STA		0x00000001	/* CAPABILITY: STA available */
65232176cfdSRui Paulo #define	IEEE80211_C_8023ENCAP	0x00000002	/* CAPABILITY: 802.3 encap */
653841ab66cSSepherosa Ziehau #define	IEEE80211_C_FF		0x00000040	/* CAPABILITY: ATH FF avail */
654841ab66cSSepherosa Ziehau #define	IEEE80211_C_TURBOP	0x00000080	/* CAPABILITY: ATH Turbo avail*/
655841ab66cSSepherosa Ziehau #define	IEEE80211_C_IBSS	0x00000100	/* CAPABILITY: IBSS available */
656841ab66cSSepherosa Ziehau #define	IEEE80211_C_PMGT	0x00000200	/* CAPABILITY: Power mgmt */
657841ab66cSSepherosa Ziehau #define	IEEE80211_C_HOSTAP	0x00000400	/* CAPABILITY: HOSTAP avail */
658841ab66cSSepherosa Ziehau #define	IEEE80211_C_AHDEMO	0x00000800	/* CAPABILITY: Old Adhoc Demo */
659841ab66cSSepherosa Ziehau #define	IEEE80211_C_SWRETRY	0x00001000	/* CAPABILITY: sw tx retry */
660841ab66cSSepherosa Ziehau #define	IEEE80211_C_TXPMGT	0x00002000	/* CAPABILITY: tx power mgmt */
661841ab66cSSepherosa Ziehau #define	IEEE80211_C_SHSLOT	0x00004000	/* CAPABILITY: short slottime */
662841ab66cSSepherosa Ziehau #define	IEEE80211_C_SHPREAMBLE	0x00008000	/* CAPABILITY: short preamble */
663841ab66cSSepherosa Ziehau #define	IEEE80211_C_MONITOR	0x00010000	/* CAPABILITY: monitor mode */
66432176cfdSRui Paulo #define	IEEE80211_C_DFS		0x00020000	/* CAPABILITY: DFS/radar avail*/
66532176cfdSRui Paulo #define	IEEE80211_C_MBSS	0x00040000	/* CAPABILITY: MBSS available */
666d98a0bcfSMatthew Dillon #define	IEEE80211_C_SWSLEEP	0x00080000	/* CAPABILITY: do sleep here */
6674f655ef5SMatthew Dillon #define	IEEE80211_C_SWAMSDUTX	0x00100000	/* CAPABILITY: software A-MSDU TX */
66832176cfdSRui Paulo /* 0x7c0000 available */
669841ab66cSSepherosa Ziehau #define	IEEE80211_C_WPA1	0x00800000	/* CAPABILITY: WPA1 avail */
670841ab66cSSepherosa Ziehau #define	IEEE80211_C_WPA2	0x01000000	/* CAPABILITY: WPA2 avail */
671841ab66cSSepherosa Ziehau #define	IEEE80211_C_WPA		0x01800000	/* CAPABILITY: WPA1+WPA2 avail*/
672841ab66cSSepherosa Ziehau #define	IEEE80211_C_BURST	0x02000000	/* CAPABILITY: frame bursting */
673841ab66cSSepherosa Ziehau #define	IEEE80211_C_WME		0x04000000	/* CAPABILITY: WME avail */
674841ab66cSSepherosa Ziehau #define	IEEE80211_C_WDS		0x08000000	/* CAPABILITY: 4-addr support */
675841ab66cSSepherosa Ziehau /* 0x10000000 reserved */
676841ab66cSSepherosa Ziehau #define	IEEE80211_C_BGSCAN	0x20000000	/* CAPABILITY: bg scanning */
677841ab66cSSepherosa Ziehau #define	IEEE80211_C_TXFRAG	0x40000000	/* CAPABILITY: tx fragments */
67832176cfdSRui Paulo #define	IEEE80211_C_TDMA	0x80000000	/* CAPABILITY: TDMA avail */
679841ab66cSSepherosa Ziehau /* XXX protection/barker? */
680f186073cSJoerg Sonnenberger 
68132176cfdSRui Paulo #define	IEEE80211_C_OPMODE \
68232176cfdSRui Paulo 	(IEEE80211_C_STA | IEEE80211_C_IBSS | IEEE80211_C_HOSTAP | \
68332176cfdSRui Paulo 	 IEEE80211_C_AHDEMO | IEEE80211_C_MONITOR | IEEE80211_C_WDS | \
68432176cfdSRui Paulo 	 IEEE80211_C_TDMA | IEEE80211_C_MBSS)
685f186073cSJoerg Sonnenberger 
68632176cfdSRui Paulo #define	IEEE80211_C_BITS \
68732176cfdSRui Paulo 	"\20\1STA\002803ENCAP\7FF\10TURBOP\11IBSS\12PMGT" \
68832176cfdSRui Paulo 	"\13HOSTAP\14AHDEMO\15SWRETRY\16TXPMGT\17SHSLOT\20SHPREAMBLE" \
68932176cfdSRui Paulo 	"\21MONITOR\22DFS\23MBSS\30WPA1\31WPA2\32BURST\33WME\34WDS\36BGSCAN" \
69032176cfdSRui Paulo 	"\37TXFRAG\40TDMA"
69121152d39SSepherosa Ziehau 
69232176cfdSRui Paulo /*
69332176cfdSRui Paulo  * ic_htcaps/iv_htcaps: HT-specific device/driver capabilities
69432176cfdSRui Paulo  *
69532176cfdSRui Paulo  * NB: the low 16-bits are the 802.11 definitions, the upper
69632176cfdSRui Paulo  *     16-bits are used to define s/w/driver capabilities.
69732176cfdSRui Paulo  */
69832176cfdSRui Paulo #define	IEEE80211_HTC_AMPDU	0x00010000	/* CAPABILITY: A-MPDU tx */
69932176cfdSRui Paulo #define	IEEE80211_HTC_AMSDU	0x00020000	/* CAPABILITY: A-MSDU tx */
70032176cfdSRui Paulo /* NB: HT40 is implied by IEEE80211_HTCAP_CHWIDTH40 */
70132176cfdSRui Paulo #define	IEEE80211_HTC_HT	0x00040000	/* CAPABILITY: HT operation */
70232176cfdSRui Paulo #define	IEEE80211_HTC_SMPS	0x00080000	/* CAPABILITY: MIMO power save*/
70332176cfdSRui Paulo #define	IEEE80211_HTC_RIFS	0x00100000	/* CAPABILITY: RIFS support */
704085ff963SMatthew Dillon #define	IEEE80211_HTC_RXUNEQUAL	0x00200000	/* CAPABILITY: RX unequal MCS */
705085ff963SMatthew Dillon #define	IEEE80211_HTC_RXMCS32	0x00400000	/* CAPABILITY: MCS32 support */
706085ff963SMatthew Dillon #define	IEEE80211_HTC_TXUNEQUAL	0x00800000	/* CAPABILITY: TX unequal MCS */
707085ff963SMatthew Dillon #define	IEEE80211_HTC_TXMCS32	0x01000000	/* CAPABILITY: MCS32 suport */
70832176cfdSRui Paulo 
70932176cfdSRui Paulo #define	IEEE80211_C_HTCAP_BITS \
71032176cfdSRui Paulo 	"\20\1LDPC\2CHWIDTH40\5GREENFIELD\6SHORTGI20\7SHORTGI40\10TXSTBC" \
71132176cfdSRui Paulo 	"\21AMPDU\22AMSDU\23HT\24SMPS\25RIFS"
71232176cfdSRui Paulo 
7134f898719SImre Vadász int	ic_printf(struct ieee80211com *, const char *, ...) __printflike(2, 3);
7144f655ef5SMatthew Dillon void	ieee80211_ifattach(struct ieee80211com *);
715841ab66cSSepherosa Ziehau void	ieee80211_ifdetach(struct ieee80211com *);
71632176cfdSRui Paulo int	ieee80211_vap_setup(struct ieee80211com *, struct ieee80211vap *,
717085ff963SMatthew Dillon 		const char name[IFNAMSIZ], int unit,
718085ff963SMatthew Dillon 		enum ieee80211_opmode opmode, int flags,
7194f655ef5SMatthew Dillon 		const uint8_t bssid[IEEE80211_ADDR_LEN]);
72032176cfdSRui Paulo int	ieee80211_vap_attach(struct ieee80211vap *,
7214f655ef5SMatthew Dillon 		ifm_change_cb_t, ifm_stat_cb_t,
7224f655ef5SMatthew Dillon 		const uint8_t macaddr[IEEE80211_ADDR_LEN]);
72332176cfdSRui Paulo void	ieee80211_vap_detach(struct ieee80211vap *);
72432176cfdSRui Paulo const struct ieee80211_rateset *ieee80211_get_suprates(struct ieee80211com *ic,
72532176cfdSRui Paulo 		const struct ieee80211_channel *);
72632176cfdSRui Paulo void	ieee80211_announce(struct ieee80211com *);
72732176cfdSRui Paulo void	ieee80211_announce_channels(struct ieee80211com *);
72832176cfdSRui Paulo void	ieee80211_drain(struct ieee80211com *);
7294f655ef5SMatthew Dillon void	ieee80211_chan_init(struct ieee80211com *);
730841ab66cSSepherosa Ziehau struct ieee80211com *ieee80211_find_vap(const uint8_t mac[IEEE80211_ADDR_LEN]);
7314f655ef5SMatthew Dillon struct ieee80211com *ieee80211_find_com(const char *name);
732f186073cSJoerg Sonnenberger int	ieee80211_media_change(struct ifnet *);
733f186073cSJoerg Sonnenberger void	ieee80211_media_status(struct ifnet *, struct ifmediareq *);
734085ff963SMatthew Dillon #if defined(__DragonFly__)
73534a60cf6SRui Paulo int	ieee80211_ioctl(struct ifnet *, u_long, caddr_t, struct ucred *);
736085ff963SMatthew Dillon #else
737085ff963SMatthew Dillon int	ieee80211_ioctl(struct ifnet *, u_long, caddr_t);
738085ff963SMatthew Dillon #endif
739f186073cSJoerg Sonnenberger int	ieee80211_rate2media(struct ieee80211com *, int,
740f186073cSJoerg Sonnenberger 		enum ieee80211_phymode);
741f186073cSJoerg Sonnenberger int	ieee80211_media2rate(int);
74232176cfdSRui Paulo int	ieee80211_mhz2ieee(u_int, u_int);
74332176cfdSRui Paulo int	ieee80211_chan2ieee(struct ieee80211com *,
74447f525a7SSepherosa Ziehau 		const struct ieee80211_channel *);
745f186073cSJoerg Sonnenberger u_int	ieee80211_ieee2mhz(u_int, u_int);
7464f655ef5SMatthew Dillon int	ieee80211_add_channel(struct ieee80211_channel[], int, int *,
7474f655ef5SMatthew Dillon 	    uint8_t, uint16_t, int8_t, uint32_t, const uint8_t[]);
7484f655ef5SMatthew Dillon int	ieee80211_add_channel_ht40(struct ieee80211_channel[], int, int *,
7494f655ef5SMatthew Dillon 	    uint8_t, int8_t, uint32_t);
7504f655ef5SMatthew Dillon int	ieee80211_add_channel_list_2ghz(struct ieee80211_channel[], int, int *,
7514f655ef5SMatthew Dillon 	    const uint8_t[], int, const uint8_t[], int);
7524f655ef5SMatthew Dillon int	ieee80211_add_channel_list_5ghz(struct ieee80211_channel[], int, int *,
7534f655ef5SMatthew Dillon 	    const uint8_t[], int, const uint8_t[], int);
75432176cfdSRui Paulo struct ieee80211_channel *ieee80211_find_channel(struct ieee80211com *,
75532176cfdSRui Paulo 		int freq, int flags);
75632176cfdSRui Paulo struct ieee80211_channel *ieee80211_find_channel_byieee(struct ieee80211com *,
75732176cfdSRui Paulo 		int ieee, int flags);
7584f898719SImre Vadász struct ieee80211_channel *ieee80211_lookup_channel_rxstatus(struct ieee80211vap *,
7594f898719SImre Vadász 		const struct ieee80211_rx_stats *);
760f186073cSJoerg Sonnenberger int	ieee80211_setmode(struct ieee80211com *, enum ieee80211_phymode);
76132176cfdSRui Paulo enum ieee80211_phymode ieee80211_chan2mode(const struct ieee80211_channel *);
76232176cfdSRui Paulo uint32_t ieee80211_mac_hash(const struct ieee80211com *,
76332176cfdSRui Paulo 		const uint8_t addr[IEEE80211_ADDR_LEN]);
7644f898719SImre Vadász char	ieee80211_channel_type_char(const struct ieee80211_channel *c);
765f186073cSJoerg Sonnenberger 
76632176cfdSRui Paulo void	ieee80211_radiotap_attach(struct ieee80211com *,
76732176cfdSRui Paulo 	    struct ieee80211_radiotap_header *th, int tlen,
76832176cfdSRui Paulo 		uint32_t tx_radiotap,
76932176cfdSRui Paulo 	    struct ieee80211_radiotap_header *rh, int rlen,
77032176cfdSRui Paulo 		uint32_t rx_radiotap);
771085ff963SMatthew Dillon void	ieee80211_radiotap_attachv(struct ieee80211com *,
772085ff963SMatthew Dillon 	    struct ieee80211_radiotap_header *th,
773085ff963SMatthew Dillon 	    int tlen, int n_tx_v, uint32_t tx_radiotap,
774085ff963SMatthew Dillon 	    struct ieee80211_radiotap_header *rh,
775085ff963SMatthew Dillon 	    int rlen, int n_rx_v, uint32_t rx_radiotap);
77632176cfdSRui Paulo void	ieee80211_radiotap_detach(struct ieee80211com *);
77732176cfdSRui Paulo void	ieee80211_radiotap_vattach(struct ieee80211vap *);
77832176cfdSRui Paulo void	ieee80211_radiotap_vdetach(struct ieee80211vap *);
77932176cfdSRui Paulo void	ieee80211_radiotap_chan_change(struct ieee80211com *);
78032176cfdSRui Paulo void	ieee80211_radiotap_tx(struct ieee80211vap *, struct mbuf *);
78132176cfdSRui Paulo void	ieee80211_radiotap_rx(struct ieee80211vap *, struct mbuf *);
78232176cfdSRui Paulo void	ieee80211_radiotap_rx_all(struct ieee80211com *, struct mbuf *);
78332176cfdSRui Paulo 
78432176cfdSRui Paulo static __inline int
ieee80211_radiotap_active(const struct ieee80211com * ic)78532176cfdSRui Paulo ieee80211_radiotap_active(const struct ieee80211com *ic)
78632176cfdSRui Paulo {
78732176cfdSRui Paulo 	return (ic->ic_flags_ext & IEEE80211_FEXT_BPF) != 0;
78832176cfdSRui Paulo }
78932176cfdSRui Paulo 
79032176cfdSRui Paulo static __inline int
ieee80211_radiotap_active_vap(const struct ieee80211vap * vap)79132176cfdSRui Paulo ieee80211_radiotap_active_vap(const struct ieee80211vap *vap)
79232176cfdSRui Paulo {
79332176cfdSRui Paulo 	return (vap->iv_flags_ext & IEEE80211_FEXT_BPF) ||
79432176cfdSRui Paulo 	    vap->iv_ic->ic_montaps != 0;
79532176cfdSRui Paulo }
79632176cfdSRui Paulo 
79732176cfdSRui Paulo /*
79832176cfdSRui Paulo  * Enqueue a task on the state thread.
79932176cfdSRui Paulo  */
80032176cfdSRui Paulo static __inline void
ieee80211_runtask(struct ieee80211com * ic,struct task * task)80132176cfdSRui Paulo ieee80211_runtask(struct ieee80211com *ic, struct task *task)
80232176cfdSRui Paulo {
80332176cfdSRui Paulo 	taskqueue_enqueue(ic->ic_tq, task);
80432176cfdSRui Paulo }
80532176cfdSRui Paulo 
80632176cfdSRui Paulo /*
80732176cfdSRui Paulo  * Wait for a queued task to complete.
80832176cfdSRui Paulo  */
80932176cfdSRui Paulo static __inline void
ieee80211_draintask(struct ieee80211com * ic,struct task * task)81032176cfdSRui Paulo ieee80211_draintask(struct ieee80211com *ic, struct task *task)
81132176cfdSRui Paulo {
81232176cfdSRui Paulo 	taskqueue_drain(ic->ic_tq, task);
81332176cfdSRui Paulo }
814841ab66cSSepherosa Ziehau 
815841ab66cSSepherosa Ziehau /*
816841ab66cSSepherosa Ziehau  * Key update synchronization methods.  XXX should not be visible.
817841ab66cSSepherosa Ziehau  */
818841ab66cSSepherosa Ziehau static __inline void
ieee80211_key_update_begin(struct ieee80211vap * vap)81932176cfdSRui Paulo ieee80211_key_update_begin(struct ieee80211vap *vap)
820841ab66cSSepherosa Ziehau {
82132176cfdSRui Paulo 	vap->iv_key_update_begin(vap);
822841ab66cSSepherosa Ziehau }
823841ab66cSSepherosa Ziehau static __inline void
ieee80211_key_update_end(struct ieee80211vap * vap)82432176cfdSRui Paulo ieee80211_key_update_end(struct ieee80211vap *vap)
825841ab66cSSepherosa Ziehau {
82632176cfdSRui Paulo 	vap->iv_key_update_end(vap);
827841ab66cSSepherosa Ziehau }
828841ab66cSSepherosa Ziehau 
829841ab66cSSepherosa Ziehau /*
830841ab66cSSepherosa Ziehau  * XXX these need to be here for IEEE80211_F_DATAPAD
831841ab66cSSepherosa Ziehau  */
832841ab66cSSepherosa Ziehau 
833841ab66cSSepherosa Ziehau /*
834841ab66cSSepherosa Ziehau  * Return the space occupied by the 802.11 header and any
835841ab66cSSepherosa Ziehau  * padding required by the driver.  This works for a
836841ab66cSSepherosa Ziehau  * management or data frame.
837841ab66cSSepherosa Ziehau  */
838841ab66cSSepherosa Ziehau static __inline int
ieee80211_hdrspace(struct ieee80211com * ic,const void * data)839841ab66cSSepherosa Ziehau ieee80211_hdrspace(struct ieee80211com *ic, const void *data)
840841ab66cSSepherosa Ziehau {
841841ab66cSSepherosa Ziehau 	int size = ieee80211_hdrsize(data);
842841ab66cSSepherosa Ziehau 	if (ic->ic_flags & IEEE80211_F_DATAPAD)
843841ab66cSSepherosa Ziehau 		size = roundup(size, sizeof(uint32_t));
844841ab66cSSepherosa Ziehau 	return size;
845841ab66cSSepherosa Ziehau }
846841ab66cSSepherosa Ziehau 
847841ab66cSSepherosa Ziehau /*
848841ab66cSSepherosa Ziehau  * Like ieee80211_hdrspace, but handles any type of frame.
849841ab66cSSepherosa Ziehau  */
850841ab66cSSepherosa Ziehau static __inline int
ieee80211_anyhdrspace(struct ieee80211com * ic,const void * data)851841ab66cSSepherosa Ziehau ieee80211_anyhdrspace(struct ieee80211com *ic, const void *data)
852841ab66cSSepherosa Ziehau {
853841ab66cSSepherosa Ziehau 	int size = ieee80211_anyhdrsize(data);
854841ab66cSSepherosa Ziehau 	if (ic->ic_flags & IEEE80211_F_DATAPAD)
855841ab66cSSepherosa Ziehau 		size = roundup(size, sizeof(uint32_t));
856841ab66cSSepherosa Ziehau 	return size;
857841ab66cSSepherosa Ziehau }
858841ab66cSSepherosa Ziehau 
85932176cfdSRui Paulo /*
86032176cfdSRui Paulo  * Notify a vap that beacon state has been updated.
86132176cfdSRui Paulo  */
86232176cfdSRui Paulo static __inline void
ieee80211_beacon_notify(struct ieee80211vap * vap,int what)86332176cfdSRui Paulo ieee80211_beacon_notify(struct ieee80211vap *vap, int what)
86432176cfdSRui Paulo {
86532176cfdSRui Paulo 	if (vap->iv_state == IEEE80211_S_RUN)
86632176cfdSRui Paulo 		vap->iv_update_beacon(vap, what);
86732176cfdSRui Paulo }
868820cef05SSepherosa Ziehau 
86932176cfdSRui Paulo /*
87032176cfdSRui Paulo  * Calculate HT channel promotion flags for a channel.
87132176cfdSRui Paulo  * XXX belongs in ieee80211_ht.h but needs IEEE80211_FHT_*
87232176cfdSRui Paulo  */
87332176cfdSRui Paulo static __inline int
ieee80211_htchanflags(const struct ieee80211_channel * c)87432176cfdSRui Paulo ieee80211_htchanflags(const struct ieee80211_channel *c)
87532176cfdSRui Paulo {
87632176cfdSRui Paulo 	return IEEE80211_IS_CHAN_HT40(c) ?
87732176cfdSRui Paulo 	    IEEE80211_FHT_HT | IEEE80211_FHT_USEHT40 :
87832176cfdSRui Paulo 	    IEEE80211_IS_CHAN_HT(c) ?  IEEE80211_FHT_HT : 0;
87932176cfdSRui Paulo }
88032176cfdSRui Paulo 
88132176cfdSRui Paulo /*
882f501b47dSMatthew Dillon  * Fetch the current TX power (cap) for the given node.
883f501b47dSMatthew Dillon  *
884f501b47dSMatthew Dillon  * This includes the node and ic/vap TX power limit as needed,
885f501b47dSMatthew Dillon  * but it doesn't take into account any per-rate limit.
886f501b47dSMatthew Dillon  */
887f501b47dSMatthew Dillon static __inline uint16_t
ieee80211_get_node_txpower(struct ieee80211_node * ni)888f501b47dSMatthew Dillon ieee80211_get_node_txpower(struct ieee80211_node *ni)
889f501b47dSMatthew Dillon {
890f501b47dSMatthew Dillon 	struct ieee80211com *ic = ni->ni_ic;
891f501b47dSMatthew Dillon 	uint16_t txpower;
892f501b47dSMatthew Dillon 
893f501b47dSMatthew Dillon 	txpower = ni->ni_txpower;
894f501b47dSMatthew Dillon 	txpower = MIN(txpower, ic->ic_txpowlimit);
895f501b47dSMatthew Dillon 	if (ic->ic_curchan != NULL) {
896f501b47dSMatthew Dillon 		txpower = MIN(txpower, 2 * ic->ic_curchan->ic_maxregpower);
897f501b47dSMatthew Dillon 		txpower = MIN(txpower, ic->ic_curchan->ic_maxpower);
898f501b47dSMatthew Dillon 	}
899f501b47dSMatthew Dillon 
900f501b47dSMatthew Dillon 	return (txpower);
901f501b47dSMatthew Dillon }
902f501b47dSMatthew Dillon 
903f501b47dSMatthew Dillon /*
90432176cfdSRui Paulo  * Debugging facilities compiled in when IEEE80211_DEBUG is defined.
90532176cfdSRui Paulo  *
90632176cfdSRui Paulo  * The intent is that any problem in the net80211 layer can be
90732176cfdSRui Paulo  * diagnosed by inspecting the statistics (dumped by the wlanstats
90832176cfdSRui Paulo  * program) and/or the msgs generated by net80211.  Messages are
90932176cfdSRui Paulo  * broken into functional classes and can be controlled with the
91032176cfdSRui Paulo  * wlandebug program.  Certain of these msg groups are for facilities
91132176cfdSRui Paulo  * that are no longer part of net80211 (e.g. IEEE80211_MSG_DOT1XSM).
91232176cfdSRui Paulo  */
91332176cfdSRui Paulo #define	IEEE80211_MSG_11N	0x80000000	/* 11n mode debug */
914841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_DEBUG	0x40000000	/* IFF_DEBUG equivalent */
915841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_DUMPPKTS	0x20000000	/* IFF_LINK2 equivalant */
916841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_CRYPTO	0x10000000	/* crypto work */
917841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_INPUT	0x08000000	/* input handling */
918841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_XRATE	0x04000000	/* rate set handling */
919841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_ELEMID	0x02000000	/* element id parsing */
920841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_NODE	0x01000000	/* node handling */
921841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_ASSOC	0x00800000	/* association handling */
922841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_AUTH	0x00400000	/* authentication handling */
923841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_SCAN	0x00200000	/* scanning */
924841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_OUTPUT	0x00100000	/* output handling */
925841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_STATE	0x00080000	/* state machine */
926841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_POWER	0x00040000	/* power save handling */
92732176cfdSRui Paulo #define	IEEE80211_MSG_HWMP	0x00020000	/* hybrid mesh protocol */
928841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_DOT1XSM	0x00010000	/* 802.1x state machine */
929841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_RADIUS	0x00008000	/* 802.1x radius client */
930841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_RADDUMP	0x00004000	/* dump 802.1x radius packets */
93132176cfdSRui Paulo #define	IEEE80211_MSG_MESH	0x00002000	/* mesh networking */
932841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_WPA	0x00001000	/* WPA/RSN protocol */
933841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_ACL	0x00000800	/* ACL handling */
934841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_WME	0x00000400	/* WME protocol */
935841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_SUPERG	0x00000200	/* Atheros SuperG protocol */
936841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_DOTH	0x00000100	/* 802.11h support */
937841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_INACT	0x00000080	/* inactivity handling */
938841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_ROAM	0x00000040	/* sta-mode roaming */
93932176cfdSRui Paulo #define	IEEE80211_MSG_RATECTL	0x00000020	/* tx rate control */
94032176cfdSRui Paulo #define	IEEE80211_MSG_ACTION	0x00000010	/* action frame handling */
94132176cfdSRui Paulo #define	IEEE80211_MSG_WDS	0x00000008	/* WDS handling */
94232176cfdSRui Paulo #define	IEEE80211_MSG_IOCTL	0x00000004	/* ioctl handling */
94332176cfdSRui Paulo #define	IEEE80211_MSG_TDMA	0x00000002	/* TDMA handling */
944841ab66cSSepherosa Ziehau 
945841ab66cSSepherosa Ziehau #define	IEEE80211_MSG_ANY	0xffffffff	/* anything */
946841ab66cSSepherosa Ziehau 
94732176cfdSRui Paulo #define	IEEE80211_MSG_BITS \
94832176cfdSRui Paulo 	"\20\2TDMA\3IOCTL\4WDS\5ACTION\6RATECTL\7ROAM\10INACT\11DOTH\12SUPERG" \
94932176cfdSRui Paulo 	"\13WME\14ACL\15WPA\16RADKEYS\17RADDUMP\20RADIUS\21DOT1XSM\22HWMP" \
95032176cfdSRui Paulo 	"\23POWER\24STATE\25OUTPUT\26SCAN\27AUTH\30ASSOC\31NODE\32ELEMID" \
95132176cfdSRui Paulo 	"\33XRATE\34INPUT\35CRYPTO\36DUPMPKTS\37DEBUG\04011N"
952820cef05SSepherosa Ziehau 
953f186073cSJoerg Sonnenberger #ifdef IEEE80211_DEBUG
95432176cfdSRui Paulo #define	ieee80211_msg(_vap, _m)	((_vap)->iv_debug & (_m))
95532176cfdSRui Paulo #define	IEEE80211_DPRINTF(_vap, _m, _fmt, ...) do {			\
95632176cfdSRui Paulo 	if (ieee80211_msg(_vap, _m))					\
95732176cfdSRui Paulo 		ieee80211_note(_vap, _fmt, __VA_ARGS__);		\
958841ab66cSSepherosa Ziehau } while (0)
95932176cfdSRui Paulo #define	IEEE80211_NOTE(_vap, _m, _ni, _fmt, ...) do {			\
96032176cfdSRui Paulo 	if (ieee80211_msg(_vap, _m))					\
96132176cfdSRui Paulo 		ieee80211_note_mac(_vap, (_ni)->ni_macaddr, _fmt, __VA_ARGS__);\
962476d885dSSepherosa Ziehau } while (0)
96332176cfdSRui Paulo #define	IEEE80211_NOTE_MAC(_vap, _m, _mac, _fmt, ...) do {		\
96432176cfdSRui Paulo 	if (ieee80211_msg(_vap, _m))					\
96532176cfdSRui Paulo 		ieee80211_note_mac(_vap, _mac, _fmt, __VA_ARGS__);	\
966841ab66cSSepherosa Ziehau } while (0)
96732176cfdSRui Paulo #define	IEEE80211_NOTE_FRAME(_vap, _m, _wh, _fmt, ...) do {		\
96832176cfdSRui Paulo 	if (ieee80211_msg(_vap, _m))					\
96932176cfdSRui Paulo 		ieee80211_note_frame(_vap, _wh, _fmt, __VA_ARGS__);	\
970841ab66cSSepherosa Ziehau } while (0)
971f92fae3fSSascha Wildner void	ieee80211_note(const struct ieee80211vap *, const char *, ...)
972f92fae3fSSascha Wildner 		__printflike(2, 3);
973085ff963SMatthew Dillon void	ieee80211_note_mac(const struct ieee80211vap *,
974f92fae3fSSascha Wildner 		const uint8_t mac[IEEE80211_ADDR_LEN], const char *, ...)
975f92fae3fSSascha Wildner 		__printflike(3, 4);
976085ff963SMatthew Dillon void	ieee80211_note_frame(const struct ieee80211vap *,
977f92fae3fSSascha Wildner 		const struct ieee80211_frame *, const char *, ...)
978f92fae3fSSascha Wildner 		__printflike(3, 4);
97932176cfdSRui Paulo #define	ieee80211_msg_debug(_vap) \
98032176cfdSRui Paulo 	((_vap)->iv_debug & IEEE80211_MSG_DEBUG)
98132176cfdSRui Paulo #define	ieee80211_msg_dumppkts(_vap) \
98232176cfdSRui Paulo 	((_vap)->iv_debug & IEEE80211_MSG_DUMPPKTS)
98332176cfdSRui Paulo #define	ieee80211_msg_input(_vap) \
98432176cfdSRui Paulo 	((_vap)->iv_debug & IEEE80211_MSG_INPUT)
98532176cfdSRui Paulo #define	ieee80211_msg_radius(_vap) \
98632176cfdSRui Paulo 	((_vap)->iv_debug & IEEE80211_MSG_RADIUS)
98732176cfdSRui Paulo #define	ieee80211_msg_dumpradius(_vap) \
98832176cfdSRui Paulo 	((_vap)->iv_debug & IEEE80211_MSG_RADDUMP)
98932176cfdSRui Paulo #define	ieee80211_msg_dumpradkeys(_vap) \
99032176cfdSRui Paulo 	((_vap)->iv_debug & IEEE80211_MSG_RADKEYS)
99132176cfdSRui Paulo #define	ieee80211_msg_scan(_vap) \
99232176cfdSRui Paulo 	((_vap)->iv_debug & IEEE80211_MSG_SCAN)
99332176cfdSRui Paulo #define	ieee80211_msg_assoc(_vap) \
99432176cfdSRui Paulo 	((_vap)->iv_debug & IEEE80211_MSG_ASSOC)
995f186073cSJoerg Sonnenberger 
99632176cfdSRui Paulo /*
99732176cfdSRui Paulo  * Emit a debug message about discarding a frame or information
99832176cfdSRui Paulo  * element.  One format is for extracting the mac address from
99932176cfdSRui Paulo  * the frame header; the other is for when a header is not
100032176cfdSRui Paulo  * available or otherwise appropriate.
100132176cfdSRui Paulo  */
100232176cfdSRui Paulo #define	IEEE80211_DISCARD(_vap, _m, _wh, _type, _fmt, ...) do {		\
100332176cfdSRui Paulo 	if ((_vap)->iv_debug & (_m))					\
100432176cfdSRui Paulo 		ieee80211_discard_frame(_vap, _wh, _type, _fmt, __VA_ARGS__);\
100532176cfdSRui Paulo } while (0)
100632176cfdSRui Paulo #define	IEEE80211_DISCARD_IE(_vap, _m, _wh, _type, _fmt, ...) do {	\
100732176cfdSRui Paulo 	if ((_vap)->iv_debug & (_m))					\
100832176cfdSRui Paulo 		ieee80211_discard_ie(_vap, _wh, _type, _fmt, __VA_ARGS__);\
100932176cfdSRui Paulo } while (0)
101032176cfdSRui Paulo #define	IEEE80211_DISCARD_MAC(_vap, _m, _mac, _type, _fmt, ...) do {	\
101132176cfdSRui Paulo 	if ((_vap)->iv_debug & (_m))					\
101232176cfdSRui Paulo 		ieee80211_discard_mac(_vap, _mac, _type, _fmt, __VA_ARGS__);\
101332176cfdSRui Paulo } while (0)
101432176cfdSRui Paulo 
1015085ff963SMatthew Dillon void ieee80211_discard_frame(const struct ieee80211vap *,
1016f92fae3fSSascha Wildner 	const struct ieee80211_frame *, const char *type, const char *fmt, ...)
1017f92fae3fSSascha Wildner 	__printflike(4, 5);
1018085ff963SMatthew Dillon void ieee80211_discard_ie(const struct ieee80211vap *,
1019f92fae3fSSascha Wildner 	const struct ieee80211_frame *, const char *type, const char *fmt, ...)
1020f92fae3fSSascha Wildner 	__printflike(4, 5);
1021085ff963SMatthew Dillon void ieee80211_discard_mac(const struct ieee80211vap *,
1022085ff963SMatthew Dillon 	const uint8_t mac[IEEE80211_ADDR_LEN], const char *type,
1023f92fae3fSSascha Wildner 	const char *fmt, ...)
1024f92fae3fSSascha Wildner 	__printflike(4, 5);
102532176cfdSRui Paulo #else
1026097e9486Szrj #define	IEEE80211_DPRINTF(_vap, _m, _fmt, ...)		do { } while (0)
1027097e9486Szrj #define	IEEE80211_NOTE(_vap, _m, _ni, _fmt, ...)	do { } while (0)
1028097e9486Szrj #define	IEEE80211_NOTE_FRAME(_vap, _m, _wh, _fmt, ...)	do { } while (0)
1029097e9486Szrj #define	IEEE80211_NOTE_MAC(_vap, _m, _mac, _fmt, ...)	do { } while (0)
103032176cfdSRui Paulo #define	ieee80211_msg_dumppkts(_vap)	0
103132176cfdSRui Paulo #define	ieee80211_msg(_vap, _m)		0
103232176cfdSRui Paulo 
1033097e9486Szrj #define	IEEE80211_DISCARD(_vap, _m, _wh, _type, _fmt, ...) do { } while (0)
1034097e9486Szrj #define	IEEE80211_DISCARD_IE(_vap, _m, _wh, _type, _fmt, ...) do { } while (0)
1035097e9486Szrj #define	IEEE80211_DISCARD_MAC(_vap, _m, _mac, _type, _fmt, ...) do { } while (0)
103632176cfdSRui Paulo #endif
1037820cef05SSepherosa Ziehau 
1038841ab66cSSepherosa Ziehau #endif /* _NET80211_IEEE80211_VAR_H_ */
1039