if_wivar.h revision 180919
1139749Simp/*-
293611Simp * Copyright (c) 2002
393611Simp *	M Warner Losh <imp@freebsd.org>.  All rights reserved.
493611Simp * Copyright (c) 1997, 1998, 1999
593611Simp *	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
693611Simp *
793611Simp * Redistribution and use in source and binary forms, with or without
893611Simp * modification, are permitted provided that the following conditions
993611Simp * are met:
1093611Simp * 1. Redistributions of source code must retain the above copyright
1193611Simp *    notice, this list of conditions and the following disclaimer.
1293611Simp * 2. Redistributions in binary form must reproduce the above copyright
1393611Simp *    notice, this list of conditions and the following disclaimer in the
1493611Simp *    documentation and/or other materials provided with the distribution.
1593611Simp * 3. All advertising materials mentioning features or use of this software
1693611Simp *    must display the following acknowledgement:
1793611Simp *	This product includes software developed by Bill Paul.
1893611Simp * 4. Neither the name of the author nor the names of any co-contributors
1993611Simp *    may be used to endorse or promote products derived from this software
2093611Simp *    without specific prior written permission.
2193611Simp *
2293611Simp * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
2393611Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2493611Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2593611Simp * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
2693611Simp * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2793611Simp * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2893611Simp * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2993611Simp * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3093611Simp * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3193611Simp * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
3293611Simp * THE POSSIBILITY OF SUCH DAMAGE.
3393611Simp *
3493611Simp * $FreeBSD: head/sys/dev/wi/if_wivar.h 180919 2008-07-28 17:00:37Z imp $
3593611Simp */
3693611Simp
3793611Simp/*
3893611Simp * Encryption controls. We can enable or disable encryption as
3993611Simp * well as specify up to 4 encryption keys. We can also specify
4093611Simp * which of the four keys will be used for transmit encryption.
4193611Simp */
4293611Simp#define WI_RID_ENCRYPTION	0xFC20
4393611Simp#define WI_RID_AUTHTYPE		0xFC21
4493611Simp#define WI_RID_DEFLT_CRYPT_KEYS	0xFCB0
4593611Simp#define WI_RID_TX_CRYPT_KEY	0xFCB1
4693611Simp#define WI_RID_WEP_AVAIL	0xFD4F
4793611Simp#define WI_RID_P2_TX_CRYPT_KEY	0xFC23
4893611Simp#define WI_RID_P2_CRYPT_KEY0	0xFC24
4993611Simp#define WI_RID_P2_CRYPT_KEY1	0xFC25
5093611Simp#define WI_RID_MICROWAVE_OVEN	0xFC25
5193611Simp#define WI_RID_P2_CRYPT_KEY2	0xFC26
5293611Simp#define WI_RID_P2_CRYPT_KEY3	0xFC27
5393611Simp#define WI_RID_P2_ENCRYPTION	0xFC28
5493611Simp#define WI_RID_ROAMING_MODE	0xFC2D
5593611Simp#define WI_RID_CUR_TX_RATE	0xFD44 /* current TX rate */
5693611Simp
57138571Ssam#define	WI_MAX_AID		256	/* max stations for ap operation */
58138571Ssam
59178354Ssamstruct wi_vap {
60178354Ssam	struct ieee80211vap	wv_vap;
61178354Ssam	struct ieee80211_beacon_offsets	wv_bo;
62178354Ssam	struct task		wv_connected_task;
63178354Ssam	struct task		wv_disconnected_task;
64178354Ssam	struct task		wv_assoc_failed_task;
65178354Ssam
66178354Ssam	void		(*wv_recv_mgmt)(struct ieee80211_node *,
67178354Ssam			    struct mbuf *, int, int, int, u_int32_t);
68178354Ssam	int		(*wv_newstate)(struct ieee80211vap *,
69178354Ssam			    enum ieee80211_state, int);
70178354Ssam};
71178354Ssam#define	WI_VAP(vap)		((struct wi_vap *)(vap))
72178354Ssam
73109323Ssamstruct wi_softc	{
74147256Sbrooks	struct ifnet		*sc_ifp;
75109323Ssam	device_t		sc_dev;
76109323Ssam	struct mtx		sc_mtx;
77165089Ssam	struct callout		sc_watchdog;
78178354Ssam	struct task		sc_oor_task;
79109323Ssam	int			sc_unit;
80109323Ssam	int			wi_gone;
81109323Ssam	int			sc_enabled;
82112362Simp	int			sc_reset;
83109323Ssam	int			sc_firmware_type;
84109323Ssam#define WI_NOTYPE	0
85109323Ssam#define	WI_LUCENT	1
86109323Ssam#define	WI_INTERSIL	2
87109323Ssam#define	WI_SYMBOL	3
88109323Ssam	int			sc_pri_firmware_ver;	/* Primary firmware */
89109323Ssam	int			sc_sta_firmware_ver;	/* Station firmware */
90180919Simp	unsigned int		sc_nic_id;		/* Type of NIC */
91180919Simp	char *			sc_nic_name;
9293611Simp
93109323Ssam	int			wi_bus_type;	/* Bus attachment type */
9493611Simp	struct resource *	local;
95109323Ssam	int			local_rid;
9693611Simp	struct resource *	iobase;
97109323Ssam	int			iobase_rid;
9893611Simp	struct resource *	irq;
99109323Ssam	int			irq_rid;
10093611Simp	struct resource *	mem;
101109323Ssam	int			mem_rid;
10293611Simp	bus_space_handle_t	wi_localhandle;
10393611Simp	bus_space_tag_t		wi_localtag;
10493611Simp	bus_space_handle_t	wi_bhandle;
10593611Simp	bus_space_tag_t		wi_btag;
10693611Simp	bus_space_handle_t	wi_bmemhandle;
10793611Simp	bus_space_tag_t		wi_bmemtag;
10893611Simp	void *			wi_intrhand;
109170530Ssam	struct ieee80211_channel *wi_channel;
11093733Simp	int			wi_io_addr;
111123339Simp	int			wi_cmd_count;
112109323Ssam
113109323Ssam	int			sc_flags;
114109323Ssam	int			sc_if_flags;
115109323Ssam	int			sc_bap_id;
116109323Ssam	int			sc_bap_off;
117178354Ssam
118178354Ssam	int			sc_porttype;
119109323Ssam	u_int16_t		sc_portnum;
120178354Ssam	u_int16_t		sc_encryption;
121178354Ssam	u_int16_t		sc_monitor_port;
122109323Ssam
123119784Ssam	/* RSSI interpretation */
124119784Ssam	u_int16_t		sc_min_rssi;	/* clamp sc_min_rssi < RSSI */
125119784Ssam	u_int16_t		sc_max_rssi;	/* clamp RSSI < sc_max_rssi */
126119784Ssam	u_int16_t		sc_dbm_offset;	/* dBm ~ RSSI - sc_dbm_offset */
127119784Ssam
128109323Ssam	int			sc_buflen;		/* TX buffer size */
129112363Simp	int			sc_ntxbuf;
130109323Ssam#define	WI_NTXBUF	3
13193611Simp	struct {
132109323Ssam		int		d_fid;
133109323Ssam		int		d_len;
134109323Ssam	}			sc_txd[WI_NTXBUF];	/* TX buffers */
135109323Ssam	int			sc_txnext;		/* index of next TX */
136109323Ssam	int			sc_txcur;		/* index of current TX*/
137109323Ssam	int			sc_tx_timer;
138109323Ssam
139109323Ssam	struct wi_counters	sc_stats;
140109323Ssam	u_int16_t		sc_ibss_port;
141109323Ssam
142138571Ssam	struct timeval		sc_last_syn;
143109323Ssam	int			sc_false_syns;
144109323Ssam
145109323Ssam	u_int16_t		sc_txbuf[IEEE80211_MAX_LEN/2];
146119784Ssam
147178354Ssam	struct wi_tx_radiotap_header sc_tx_th;
148127698Ssam	int			sc_tx_th_len;
149178354Ssam	struct wi_rx_radiotap_header sc_rx_th;
150127698Ssam	int			sc_rx_th_len;
15193611Simp};
15293611Simp
153109323Ssam/* maximum consecutive false change-of-BSSID indications */
154109323Ssam#define	WI_MAX_FALSE_SYNS		10
155109323Ssam
156178354Ssam#define	WI_FLAGS_HAS_ENHSECURITY	0x0001
157178354Ssam#define	WI_FLAGS_HAS_WPASUPPORT		0x0002
158109323Ssam#define	WI_FLAGS_HAS_ROAMING		0x0020
159109323Ssam#define	WI_FLAGS_HAS_FRAGTHR		0x0200
160109323Ssam#define	WI_FLAGS_HAS_DBMADJUST		0x0400
161109323Ssam
16293825Simpstruct wi_card_ident {
16393825Simp	u_int16_t	card_id;
16493825Simp	char		*card_name;
16593825Simp	u_int8_t	firm_type;
16693825Simp};
16793825Simp
168119784Ssam#define	WI_PRISM_MIN_RSSI	0x1b
169119784Ssam#define	WI_PRISM_MAX_RSSI	0x9a
170119784Ssam#define	WI_PRISM_DBM_OFFSET	100 /* XXX */
171119784Ssam
172119784Ssam#define	WI_LUCENT_MIN_RSSI	47
173119784Ssam#define	WI_LUCENT_MAX_RSSI	138
174119784Ssam#define	WI_LUCENT_DBM_OFFSET	149
175119784Ssam
176119784Ssam#define	WI_RSSI_TO_DBM(sc, rssi) (MIN((sc)->sc_max_rssi, \
177119784Ssam    MAX((sc)->sc_min_rssi, (rssi))) - (sc)->sc_dbm_offset)
178119784Ssam
179109323Ssam#define	WI_LOCK(_sc) 		mtx_lock(&(_sc)->sc_mtx)
180109323Ssam#define	WI_UNLOCK(_sc)		mtx_unlock(&(_sc)->sc_mtx)
181165087Ssam#define	WI_LOCK_ASSERT(_sc)	mtx_assert(&(_sc)->sc_mtx, MA_OWNED)
18293611Simp
183109323Ssamint	wi_attach(device_t);
184109323Ssamint	wi_detach(device_t);
185109323Ssamvoid	wi_shutdown(device_t);
186109323Ssamint	wi_alloc(device_t, int);
187109323Ssamvoid	wi_free(device_t);
18893611Simpextern devclass_t wi_devclass;
189109323Ssamvoid	wi_init(void *);
190109323Ssamvoid	wi_intr(void *);
191109323Ssamint	wi_mgmt_xmit(struct wi_softc *, caddr_t, int);
192178354Ssamvoid	wi_stop(struct wi_softc *, int);
193