xref: /netbsd-src/sys/dev/ic/anvar.h (revision 49e1839354a8fe5634f9e3b59075cd262607a1ef)
1 /*	$NetBSD: anvar.h,v 1.22 2019/10/05 23:27:20 mrg Exp $	*/
2 /*
3  * Copyright (c) 1997, 1998, 1999
4  *	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *	This product includes software developed by Bill Paul.
17  * 4. Neither the name of the author nor the names of any co-contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
25  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31  * THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * $FreeBSD: src/sys/dev/an/if_aironet_ieee.h,v 1.2 2000/11/13 23:04:12 wpaul Exp $
34  */
35 
36 #ifndef _DEV_IC_ANVAR_H
37 #define _DEV_IC_ANVAR_H
38 
39 #include <net80211/ieee80211_radiotap.h>
40 
41 #define AN_TIMEOUT	65536
42 #define	AN_MAGIC	0x414e
43 
44 /* The interrupts we will handle */
45 #define AN_INTRS	(AN_EV_RX | AN_EV_TX | AN_EV_TX_EXC | AN_EV_LINKSTAT)
46 
47 /*
48  * register space access macros
49  */
50 #define CSR_WRITE_2(sc, reg, val)	\
51 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, reg, val)
52 
53 #define CSR_READ_2(sc, reg)		\
54 	bus_space_read_2(sc->sc_iot, sc->sc_ioh, reg)
55 
56 #ifndef __BUS_SPACE_HAS_STREAM_METHODS
57 #define bus_space_write_multi_stream_2	bus_space_write_multi_2
58 #define bus_space_read_multi_stream_2	bus_space_read_multi_2
59 #endif
60 
61 #define CSR_WRITE_MULTI_STREAM_2(sc, reg, val, count)	\
62 	bus_space_write_multi_stream_2(sc->sc_iot, sc->sc_ioh, reg, val, count)
63 #define CSR_READ_MULTI_STREAM_2(sc, reg, buf, count)	\
64 	bus_space_read_multi_stream_2(sc->sc_iot, sc->sc_ioh, reg, buf, count)
65 
66 #define	AN_TX_MAX_LEN		\
67 		(sizeof(struct an_txframe) + ETHER_TYPE_LEN + ETHER_MAX_LEN)
68 #define AN_TX_RING_CNT		4
69 #define AN_INC(x, y)		(x) = (x + 1) % y
70 
71 struct an_wepkey {
72 	int			an_wep_key[16];
73 	int			an_wep_keylen;
74 };
75 
76 /* Radio capture format for Aironet */
77 #define AN_RX_RADIOTAP_PRESENT  ((1 << IEEE80211_RADIOTAP_FLAGS) | \
78                                  (1 << IEEE80211_RADIOTAP_RATE) | \
79 	                         (1 << IEEE80211_RADIOTAP_CHANNEL) | \
80                                  (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
81 
82 struct an_rx_radiotap_header {
83         struct ieee80211_radiotap_header        ar_ihdr;
84         u_int8_t                                ar_flags;
85         u_int8_t                                ar_rate;
86         u_int16_t                               ar_chan_freq;
87         u_int16_t                               ar_chan_flags;
88         int8_t                                  ar_antsignal;
89 };
90 
91 #define AN_TX_RADIOTAP_PRESENT  ((1 << IEEE80211_RADIOTAP_FLAGS) | \
92                                  (1 << IEEE80211_RADIOTAP_RATE) | \
93                                  (1 << IEEE80211_RADIOTAP_CHANNEL))
94 
95 struct an_tx_radiotap_header {
96         struct ieee80211_radiotap_header        at_ihdr;
97         u_int8_t                                at_flags;
98         u_int8_t                                at_rate;
99         u_int16_t                               at_chan_freq;
100         u_int16_t                               at_chan_flags;
101 };
102 
103 #define	AN_GAPLEN_MAX	8
104 
105 struct an_softc	{
106 	device_t		sc_dev;
107 	struct ethercom		sc_ec;
108 	struct ieee80211com	sc_ic;
109 	bus_space_tag_t		sc_iot;
110 	bus_space_handle_t	sc_ioh;
111 	void			*sc_soft_ih;
112 	int			(*sc_enable)(struct an_softc *);
113 	void			(*sc_disable)(struct an_softc *);
114 	int			(*sc_newstate)(struct ieee80211com *,
115 				    enum ieee80211_state, int);
116 
117 	int			sc_enabled;
118 	int			sc_attached;
119 
120 	int			sc_bap_id;
121 	int			sc_bap_off;
122 
123 	int			sc_use_leap;
124 	struct an_wepkey 	sc_wepkeys[IEEE80211_WEP_NKID];
125 	int			sc_perskeylen[IEEE80211_WEP_NKID];
126 	int			sc_tx_key;
127 	int			sc_tx_perskey;
128 	int			sc_tx_timer;
129 	struct an_txdesc {
130 		int		d_fid;
131 		int		d_inuse;
132 	}			sc_txd[AN_TX_RING_CNT];
133 	int			sc_txnext;
134 	int			sc_txcur;
135 
136 	struct an_rid_genconfig	sc_config;
137 	struct an_rid_caps	sc_caps;
138 	union {
139 		u_int16_t		sc_val[1];
140 		u_int8_t		sc_txbuf[AN_TX_MAX_LEN];
141 		struct an_rid_ssidlist	sc_ssidlist;
142 		struct an_rid_aplist	sc_aplist;
143 		struct an_rid_status	sc_status;
144 		struct an_rid_wepkey	sc_wepkey;
145 		struct an_rid_leapkey	sc_leapkey;
146 		struct an_rid_encap	sc_encap;
147 	}			sc_buf;
148 
149 	/* radiotap header */
150 	struct bpf_if *			sc_drvbpf;
151 	union {
152 		struct an_rx_radiotap_header	tap;
153 		u_int8_t			pad[64];
154 	} sc_rxtapu;
155 	union {
156 		struct an_tx_radiotap_header	tap;
157 		u_int8_t			pad[64];
158 	} sc_txtapu;
159 };
160 
161 #define	sc_if	sc_ec.ec_if
162 #define	sc_rxtap	sc_rxtapu.tap
163 #define	sc_txtap	sc_txtapu.tap
164 
165 int	an_attach(struct an_softc *);
166 int	an_detach(struct an_softc *);
167 int	an_activate(device_t, enum devact);
168 int	an_intr(void *);
169 
170 #endif	/* _DEV_IC_ANVAR_H */
171