1 | /* $NetBSD: anvar.h,v 1.20 2010/01/17 19:45:06 pooka 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 { |
83 | struct ieee80211_radiotap_header ; |
84 | u_int8_t ; |
85 | u_int8_t ; |
86 | u_int16_t ; |
87 | u_int16_t ; |
88 | int8_t ; |
89 | } __packed; |
90 | |
91 | #define AN_TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_FLAGS) | \ |
92 | (1 << IEEE80211_RADIOTAP_RATE) | \ |
93 | (1 << IEEE80211_RADIOTAP_CHANNEL)) |
94 | |
95 | struct { |
96 | struct ieee80211_radiotap_header ; |
97 | u_int8_t ; |
98 | u_int8_t ; |
99 | u_int16_t ; |
100 | u_int16_t ; |
101 | } __packed; |
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 | int (*sc_enable)(struct an_softc *); |
112 | void (*sc_disable)(struct an_softc *); |
113 | int (*sc_newstate)(struct ieee80211com *, |
114 | enum ieee80211_state, int); |
115 | |
116 | int sc_enabled; |
117 | int sc_attached; |
118 | |
119 | int sc_bap_id; |
120 | int sc_bap_off; |
121 | |
122 | int sc_use_leap; |
123 | struct an_wepkey sc_wepkeys[IEEE80211_WEP_NKID]; |
124 | int sc_perskeylen[IEEE80211_WEP_NKID]; |
125 | int sc_tx_key; |
126 | int sc_tx_perskey; |
127 | int sc_tx_timer; |
128 | struct an_txdesc { |
129 | int d_fid; |
130 | int d_inuse; |
131 | } sc_txd[AN_TX_RING_CNT]; |
132 | int sc_txnext; |
133 | int sc_txcur; |
134 | |
135 | struct an_rid_genconfig sc_config; |
136 | struct an_rid_caps sc_caps; |
137 | union { |
138 | u_int16_t sc_val[1]; |
139 | u_int8_t sc_txbuf[AN_TX_MAX_LEN]; |
140 | struct an_rid_ssidlist sc_ssidlist; |
141 | struct an_rid_aplist sc_aplist; |
142 | struct an_rid_status sc_status; |
143 | struct an_rid_wepkey sc_wepkey; |
144 | struct an_rid_leapkey sc_leapkey; |
145 | struct an_rid_encap sc_encap; |
146 | } sc_buf; |
147 | |
148 | /* radiotap header */ |
149 | struct bpf_if * sc_drvbpf; |
150 | union { |
151 | struct an_rx_radiotap_header tap; |
152 | u_int8_t pad[64]; |
153 | } sc_rxtapu; |
154 | union { |
155 | struct an_tx_radiotap_header tap; |
156 | u_int8_t pad[64]; |
157 | } sc_txtapu; |
158 | }; |
159 | |
160 | #define sc_if sc_ec.ec_if |
161 | #define sc_rxtap sc_rxtapu.tap |
162 | #define sc_txtap sc_txtapu.tap |
163 | |
164 | int an_attach(struct an_softc *); |
165 | int an_detach(struct an_softc *); |
166 | int an_activate(device_t, enum devact); |
167 | int an_intr(void *); |
168 | |
169 | #endif /* _DEV_IC_ANVAR_H */ |
170 | |