xref: /netbsd-src/sys/dev/ic/anvar.h (revision 49e1839354a8fe5634f9e3b59075cd262607a1ef)
1*49e18393Smrg /*	$NetBSD: anvar.h,v 1.22 2019/10/05 23:27:20 mrg Exp $	*/
29c25e920Sonoe /*
39c25e920Sonoe  * Copyright (c) 1997, 1998, 1999
49c25e920Sonoe  *	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
59c25e920Sonoe  *
69c25e920Sonoe  * Redistribution and use in source and binary forms, with or without
79c25e920Sonoe  * modification, are permitted provided that the following conditions
89c25e920Sonoe  * are met:
99c25e920Sonoe  * 1. Redistributions of source code must retain the above copyright
109c25e920Sonoe  *    notice, this list of conditions and the following disclaimer.
119c25e920Sonoe  * 2. Redistributions in binary form must reproduce the above copyright
129c25e920Sonoe  *    notice, this list of conditions and the following disclaimer in the
139c25e920Sonoe  *    documentation and/or other materials provided with the distribution.
149c25e920Sonoe  * 3. All advertising materials mentioning features or use of this software
159c25e920Sonoe  *    must display the following acknowledgement:
169c25e920Sonoe  *	This product includes software developed by Bill Paul.
179c25e920Sonoe  * 4. Neither the name of the author nor the names of any co-contributors
189c25e920Sonoe  *    may be used to endorse or promote products derived from this software
199c25e920Sonoe  *    without specific prior written permission.
209c25e920Sonoe  *
219c25e920Sonoe  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
229c25e920Sonoe  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
239c25e920Sonoe  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
249c25e920Sonoe  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
259c25e920Sonoe  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
269c25e920Sonoe  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
279c25e920Sonoe  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
289c25e920Sonoe  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
299c25e920Sonoe  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
309c25e920Sonoe  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
319c25e920Sonoe  * THE POSSIBILITY OF SUCH DAMAGE.
329c25e920Sonoe  *
339c25e920Sonoe  * $FreeBSD: src/sys/dev/an/if_aironet_ieee.h,v 1.2 2000/11/13 23:04:12 wpaul Exp $
349c25e920Sonoe  */
359c25e920Sonoe 
3699675e3dSonoe #ifndef _DEV_IC_ANVAR_H
3799675e3dSonoe #define _DEV_IC_ANVAR_H
389c25e920Sonoe 
391a85ac8dSdyoung #include <net80211/ieee80211_radiotap.h>
401a85ac8dSdyoung 
4199675e3dSonoe #define AN_TIMEOUT	65536
42c65191a4Sonoe #define	AN_MAGIC	0x414e
4399675e3dSonoe 
44c6607f2fSonoe /* The interrupts we will handle */
45c65191a4Sonoe #define AN_INTRS	(AN_EV_RX | AN_EV_TX | AN_EV_TX_EXC | AN_EV_LINKSTAT)
46c6607f2fSonoe 
479c25e920Sonoe /*
4899675e3dSonoe  * register space access macros
499c25e920Sonoe  */
5099675e3dSonoe #define CSR_WRITE_2(sc, reg, val)	\
51c65191a4Sonoe 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, reg, val)
5299675e3dSonoe 
5399675e3dSonoe #define CSR_READ_2(sc, reg)		\
54c65191a4Sonoe 	bus_space_read_2(sc->sc_iot, sc->sc_ioh, reg)
5599675e3dSonoe 
56c65191a4Sonoe #ifndef __BUS_SPACE_HAS_STREAM_METHODS
57c65191a4Sonoe #define bus_space_write_multi_stream_2	bus_space_write_multi_2
58c65191a4Sonoe #define bus_space_read_multi_stream_2	bus_space_read_multi_2
59c65191a4Sonoe #endif
6099675e3dSonoe 
61c65191a4Sonoe #define CSR_WRITE_MULTI_STREAM_2(sc, reg, val, count)	\
62c65191a4Sonoe 	bus_space_write_multi_stream_2(sc->sc_iot, sc->sc_ioh, reg, val, count)
63c65191a4Sonoe #define CSR_READ_MULTI_STREAM_2(sc, reg, buf, count)	\
64c65191a4Sonoe 	bus_space_read_multi_stream_2(sc->sc_iot, sc->sc_ioh, reg, buf, count)
659c25e920Sonoe 
66c65191a4Sonoe #define	AN_TX_MAX_LEN		\
67c65191a4Sonoe 		(sizeof(struct an_txframe) + ETHER_TYPE_LEN + ETHER_MAX_LEN)
6899675e3dSonoe #define AN_TX_RING_CNT		4
6999675e3dSonoe #define AN_INC(x, y)		(x) = (x + 1) % y
7099675e3dSonoe 
71ea8bda45Sonoe struct an_wepkey {
72ea8bda45Sonoe 	int			an_wep_key[16];
73ea8bda45Sonoe 	int			an_wep_keylen;
74ea8bda45Sonoe };
75ea8bda45Sonoe 
761a85ac8dSdyoung /* Radio capture format for Aironet */
771a85ac8dSdyoung #define AN_RX_RADIOTAP_PRESENT  ((1 << IEEE80211_RADIOTAP_FLAGS) | \
781a85ac8dSdyoung                                  (1 << IEEE80211_RADIOTAP_RATE) | \
791a85ac8dSdyoung 	                         (1 << IEEE80211_RADIOTAP_CHANNEL) | \
801a85ac8dSdyoung                                  (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
811a85ac8dSdyoung 
821a85ac8dSdyoung struct an_rx_radiotap_header {
831a85ac8dSdyoung         struct ieee80211_radiotap_header        ar_ihdr;
841a85ac8dSdyoung         u_int8_t                                ar_flags;
851a85ac8dSdyoung         u_int8_t                                ar_rate;
861a85ac8dSdyoung         u_int16_t                               ar_chan_freq;
871a85ac8dSdyoung         u_int16_t                               ar_chan_flags;
881a85ac8dSdyoung         int8_t                                  ar_antsignal;
89*49e18393Smrg };
901a85ac8dSdyoung 
911a85ac8dSdyoung #define AN_TX_RADIOTAP_PRESENT  ((1 << IEEE80211_RADIOTAP_FLAGS) | \
921a85ac8dSdyoung                                  (1 << IEEE80211_RADIOTAP_RATE) | \
931a85ac8dSdyoung                                  (1 << IEEE80211_RADIOTAP_CHANNEL))
941a85ac8dSdyoung 
951a85ac8dSdyoung struct an_tx_radiotap_header {
961a85ac8dSdyoung         struct ieee80211_radiotap_header        at_ihdr;
971a85ac8dSdyoung         u_int8_t                                at_flags;
981a85ac8dSdyoung         u_int8_t                                at_rate;
991a85ac8dSdyoung         u_int16_t                               at_chan_freq;
1001a85ac8dSdyoung         u_int16_t                               at_chan_flags;
101*49e18393Smrg };
1021a85ac8dSdyoung 
1037ce33f98Sdyoung #define	AN_GAPLEN_MAX	8
1047ce33f98Sdyoung 
10599675e3dSonoe struct an_softc	{
106363285caSdrochner 	device_t		sc_dev;
10790634029Sdyoung 	struct ethercom		sc_ec;
108c65191a4Sonoe 	struct ieee80211com	sc_ic;
109c65191a4Sonoe 	bus_space_tag_t		sc_iot;
110c65191a4Sonoe 	bus_space_handle_t	sc_ioh;
1115ffb0503Snonaka 	void			*sc_soft_ih;
112c65191a4Sonoe 	int			(*sc_enable)(struct an_softc *);
113c65191a4Sonoe 	void			(*sc_disable)(struct an_softc *);
114c65191a4Sonoe 	int			(*sc_newstate)(struct ieee80211com *,
115c65191a4Sonoe 				    enum ieee80211_state, int);
116c65191a4Sonoe 
11799675e3dSonoe 	int			sc_enabled;
118c65191a4Sonoe 	int			sc_attached;
1199c25e920Sonoe 
120c65191a4Sonoe 	int			sc_bap_id;
121c65191a4Sonoe 	int			sc_bap_off;
122c65191a4Sonoe 
123c65191a4Sonoe 	int			sc_use_leap;
124c65191a4Sonoe 	struct an_wepkey 	sc_wepkeys[IEEE80211_WEP_NKID];
125c65191a4Sonoe 	int			sc_perskeylen[IEEE80211_WEP_NKID];
126c65191a4Sonoe 	int			sc_tx_key;
127c65191a4Sonoe 	int			sc_tx_perskey;
128c65191a4Sonoe 	int			sc_tx_timer;
129c65191a4Sonoe 	struct an_txdesc {
130c65191a4Sonoe 		int		d_fid;
131c65191a4Sonoe 		int		d_inuse;
132c65191a4Sonoe 	}			sc_txd[AN_TX_RING_CNT];
133c65191a4Sonoe 	int			sc_txnext;
134c65191a4Sonoe 	int			sc_txcur;
135c65191a4Sonoe 
136c65191a4Sonoe 	struct an_rid_genconfig	sc_config;
137c65191a4Sonoe 	struct an_rid_caps	sc_caps;
138c65191a4Sonoe 	union {
139c65191a4Sonoe 		u_int16_t		sc_val[1];
140c65191a4Sonoe 		u_int8_t		sc_txbuf[AN_TX_MAX_LEN];
141c65191a4Sonoe 		struct an_rid_ssidlist	sc_ssidlist;
142c65191a4Sonoe 		struct an_rid_aplist	sc_aplist;
143c65191a4Sonoe 		struct an_rid_status	sc_status;
144c65191a4Sonoe 		struct an_rid_wepkey	sc_wepkey;
145c65191a4Sonoe 		struct an_rid_leapkey	sc_leapkey;
146c65191a4Sonoe 		struct an_rid_encap	sc_encap;
147c65191a4Sonoe 	}			sc_buf;
1481a85ac8dSdyoung 
1491a85ac8dSdyoung 	/* radiotap header */
15064da563dSpooka 	struct bpf_if *			sc_drvbpf;
1511a85ac8dSdyoung 	union {
1521a85ac8dSdyoung 		struct an_rx_radiotap_header	tap;
1531a85ac8dSdyoung 		u_int8_t			pad[64];
1541a85ac8dSdyoung 	} sc_rxtapu;
1551a85ac8dSdyoung 	union {
1561a85ac8dSdyoung 		struct an_tx_radiotap_header	tap;
1571a85ac8dSdyoung 		u_int8_t			pad[64];
1581a85ac8dSdyoung 	} sc_txtapu;
15999675e3dSonoe };
1609c25e920Sonoe 
16190634029Sdyoung #define	sc_if	sc_ec.ec_if
1621a85ac8dSdyoung #define	sc_rxtap	sc_rxtapu.tap
1631a85ac8dSdyoung #define	sc_txtap	sc_txtapu.tap
16490634029Sdyoung 
165c65191a4Sonoe int	an_attach(struct an_softc *);
166c65191a4Sonoe int	an_detach(struct an_softc *);
167529e91fcScegger int	an_activate(device_t, enum devact);
168c65191a4Sonoe int	an_intr(void *);
1699c25e920Sonoe 
17099675e3dSonoe #endif	/* _DEV_IC_ANVAR_H */
171