if_wivar.h revision 288095
1122394Sharti/*-
2150920Sharti * Copyright (c) 2002
3150920Sharti *	M Warner Losh <imp@freebsd.org>.  All rights reserved.
4150920Sharti * Copyright (c) 1997, 1998, 1999
5122394Sharti *	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
6122394Sharti *
7122394Sharti * Redistribution and use in source and binary forms, with or without
8122394Sharti * modification, are permitted provided that the following conditions
9208483Suqs * are met:
10133211Sharti * 1. Redistributions of source code must retain the above copyright
11133211Sharti *    notice, this list of conditions and the following disclaimer.
12133211Sharti * 2. Redistributions in binary form must reproduce the above copyright
13133211Sharti *    notice, this list of conditions and the following disclaimer in the
14133211Sharti *    documentation and/or other materials provided with the distribution.
15133211Sharti * 3. All advertising materials mentioning features or use of this software
16122394Sharti *    must display the following acknowledgement:
17122394Sharti *	This product includes software developed by Bill Paul.
18122394Sharti * 4. Neither the name of the author nor the names of any co-contributors
19133211Sharti *    may be used to endorse or promote products derived from this software
20133211Sharti *    without specific prior written permission.
21133211Sharti *
22133211Sharti * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23133211Sharti * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24133211Sharti * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25133211Sharti * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
26133211Sharti * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27133211Sharti * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28133211Sharti * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29133211Sharti * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30133211Sharti * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31122394Sharti * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32156066Sharti * THE POSSIBILITY OF SUCH DAMAGE.
33122394Sharti *
34216294Ssyrinx * $FreeBSD: head/sys/dev/wi/if_wivar.h 288095 2015-09-22 06:34:07Z adrian $
35156066Sharti */
36122394Sharti
37122394Sharti/*
38150920Sharti * Encryption controls. We can enable or disable encryption as
39150920Sharti * well as specify up to 4 encryption keys. We can also specify
40122394Sharti * which of the four keys will be used for transmit encryption.
41122394Sharti */
42122394Sharti#define WI_RID_ENCRYPTION	0xFC20
43122394Sharti#define WI_RID_AUTHTYPE		0xFC21
44122394Sharti#define WI_RID_DEFLT_CRYPT_KEYS	0xFCB0
45216294Ssyrinx#define WI_RID_TX_CRYPT_KEY	0xFCB1
46122394Sharti#define WI_RID_WEP_AVAIL	0xFD4F
47122394Sharti#define WI_RID_P2_TX_CRYPT_KEY	0xFC23
48122394Sharti#define WI_RID_P2_CRYPT_KEY0	0xFC24
49122394Sharti#define WI_RID_P2_CRYPT_KEY1	0xFC25
50122394Sharti#define WI_RID_MICROWAVE_OVEN	0xFC25
51122394Sharti#define WI_RID_P2_CRYPT_KEY2	0xFC26
52122394Sharti#define WI_RID_P2_CRYPT_KEY3	0xFC27
53211401Suqs#define WI_RID_P2_ENCRYPTION	0xFC28
54142810Sharti#define WI_RID_ROAMING_MODE	0xFC2D
55150920Sharti#define WI_RID_CUR_TX_RATE	0xFD44 /* current TX rate */
56150920Sharti
57122394Sharti#define	WI_MAX_AID		256	/* max stations for ap operation */
58122394Sharti
59122394Shartistruct wi_vap {
60122394Sharti	struct ieee80211vap	wv_vap;
61122394Sharti
62122394Sharti	void		(*wv_recv_mgmt)(struct ieee80211_node *, struct mbuf *,
63211401Suqs			    int, const struct ieee80211_rx_stats *rxs, int, int);
64211401Suqs	int		(*wv_newstate)(struct ieee80211vap *,
65122394Sharti			    enum ieee80211_state, int);
66211401Suqs};
67122394Sharti#define	WI_VAP(vap)		((struct wi_vap *)(vap))
68122394Sharti
69122394Shartistruct wi_softc	{
70122394Sharti	struct ieee80211com	sc_ic;
71122394Sharti	struct mbufq		sc_snd;
72216294Ssyrinx	device_t		sc_dev;
73216294Ssyrinx	struct mtx		sc_mtx;
74216294Ssyrinx	struct callout		sc_watchdog;
75122394Sharti	int			sc_unit;
76216294Ssyrinx	int			wi_gone;
77122394Sharti	int			sc_enabled;
78211401Suqs	int			sc_reset;
79122394Sharti	int			sc_firmware_type;
80211401Suqs#define WI_NOTYPE	0
81122394Sharti#define	WI_LUCENT	1
82211401Suqs#define	WI_INTERSIL	2
83122394Sharti#define	WI_SYMBOL	3
84211401Suqs	int			sc_pri_firmware_ver;	/* Primary firmware */
85150920Sharti	int			sc_sta_firmware_ver;	/* Station firmware */
86216294Ssyrinx	unsigned int		sc_nic_id;		/* Type of NIC */
87150920Sharti	char *			sc_nic_name;
88216294Ssyrinx
89216294Ssyrinx	int			wi_bus_type;	/* Bus attachment type */
90216294Ssyrinx	struct resource *	local;
91122394Sharti	int			local_rid;
92211401Suqs	struct resource *	iobase;
93211401Suqs	int			iobase_rid;
94150920Sharti	struct resource *	irq;
95122394Sharti	int			irq_rid;
96142810Sharti	struct resource *	mem;
97122394Sharti	int			mem_rid;
98211401Suqs	bus_space_handle_t	wi_localhandle;
99122394Sharti	bus_space_tag_t		wi_localtag;
100211401Suqs	bus_space_handle_t	wi_bhandle;
101122394Sharti	bus_space_tag_t		wi_btag;
102122394Sharti	bus_space_handle_t	wi_bmemhandle;
103122394Sharti	bus_space_tag_t		wi_bmemtag;
104122394Sharti	void *			wi_intrhand;
105122394Sharti	struct ieee80211_channel *wi_channel;
106122394Sharti	int			wi_io_addr;
107122394Sharti	int			wi_cmd_count;
108122394Sharti
109150920Sharti	int			sc_flags;
110150920Sharti	int			sc_bap_id;
111122394Sharti	int			sc_bap_off;
112122394Sharti
113122394Sharti	int			sc_porttype;
114122394Sharti	u_int16_t		sc_portnum;
115122394Sharti	u_int16_t		sc_encryption;
116122394Sharti	u_int16_t		sc_monitor_port;
117122394Sharti
118122394Sharti	/* RSSI interpretation */
119122394Sharti	u_int16_t		sc_min_rssi;	/* clamp sc_min_rssi < RSSI */
120122394Sharti	u_int16_t		sc_max_rssi;	/* clamp RSSI < sc_max_rssi */
121122394Sharti	u_int16_t		sc_dbm_offset;	/* dBm ~ RSSI - sc_dbm_offset */
122122394Sharti
123150920Sharti	int			sc_buflen;		/* TX buffer size */
124150920Sharti	int			sc_ntxbuf;
125122394Sharti#define	WI_NTXBUF	3
126122394Sharti	struct {
127122394Sharti		int		d_fid;
128122394Sharti		int		d_len;
129150920Sharti	}			sc_txd[WI_NTXBUF];	/* TX buffers */
130150920Sharti	int			sc_txnext;		/* index of next TX */
131150920Sharti	int			sc_txcur;		/* index of current TX*/
132122394Sharti	int			sc_tx_timer;
133150920Sharti
134150920Sharti	struct wi_counters	sc_stats;
135122394Sharti	u_int16_t		sc_ibss_port;
136122394Sharti
137150920Sharti	struct timeval		sc_last_syn;
138122394Sharti	int			sc_false_syns;
139122394Sharti
140122394Sharti	u_int16_t		sc_txbuf[IEEE80211_MAX_LEN/2];
141122394Sharti
142122394Sharti	struct wi_tx_radiotap_header sc_tx_th;
143122394Sharti	struct wi_rx_radiotap_header sc_rx_th;
144122394Sharti};
145122394Sharti
146122394Sharti/* maximum consecutive false change-of-BSSID indications */
147122394Sharti#define	WI_MAX_FALSE_SYNS		10
148122394Sharti
149122394Sharti#define	WI_FLAGS_HAS_ENHSECURITY	0x0001
150122394Sharti#define	WI_FLAGS_HAS_WPASUPPORT		0x0002
151122394Sharti#define	WI_FLAGS_HAS_ROAMING		0x0020
152150920Sharti#define	WI_FLAGS_HAS_FRAGTHR		0x0200
153150920Sharti#define	WI_FLAGS_HAS_DBMADJUST		0x0400
154122394Sharti#define	WI_FLAGS_RUNNING		0x0800
155122394Sharti#define	WI_FLAGS_PROMISC		0x1000
156122394Sharti
157122394Shartistruct wi_card_ident {
158122394Sharti	u_int16_t	card_id;
159122394Sharti	char		*card_name;
160150920Sharti	u_int8_t	firm_type;
161150920Sharti};
162122394Sharti
163122394Sharti#define	WI_PRISM_MIN_RSSI	0x1b
164122394Sharti#define	WI_PRISM_MAX_RSSI	0x9a
165150920Sharti#define	WI_PRISM_DBM_OFFSET	100 /* XXX */
166150920Sharti
167122394Sharti#define	WI_LUCENT_MIN_RSSI	47
168122394Sharti#define	WI_LUCENT_MAX_RSSI	138
169150920Sharti#define	WI_LUCENT_DBM_OFFSET	149
170150920Sharti
171122394Sharti#define	WI_RSSI_TO_DBM(sc, rssi) (MIN((sc)->sc_max_rssi, \
172122394Sharti    MAX((sc)->sc_min_rssi, (rssi))) - (sc)->sc_dbm_offset)
173122394Sharti
174122394Sharti#define	WI_LOCK(_sc) 		mtx_lock(&(_sc)->sc_mtx)
175122394Sharti#define	WI_UNLOCK(_sc)		mtx_unlock(&(_sc)->sc_mtx)
176122394Sharti#define	WI_LOCK_ASSERT(_sc)	mtx_assert(&(_sc)->sc_mtx, MA_OWNED)
177122394Sharti
178122394Shartiint	wi_attach(device_t);
179150920Shartiint	wi_detach(device_t);
180150920Shartiint	wi_shutdown(device_t);
181122394Shartiint	wi_alloc(device_t, int);
182150920Shartivoid	wi_free(device_t);
183150920Shartiextern devclass_t wi_devclass;
184122394Shartivoid	wi_intr(void *);
185122394Shartiint	wi_mgmt_xmit(struct wi_softc *, caddr_t, int);
186122394Shartivoid	wi_stop(struct wi_softc *, int);
187122394Shartivoid	wi_init(struct wi_softc *);
188122394Sharti