anvar.h revision 1.6 1 /* $NetBSD: anvar.h,v 1.6 2001/06/21 12:49:06 onoe Exp $ */
2 /*
3 * Copyright (c) 1997, 1998, 1999
4 * Bill Paul <wpaul (at) 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 /*
40 * This header defines a simple command interface to the FreeBSD
41 * Aironet driver (an) driver, which is used to set certain
42 * device-specific parameters which can't be easily managed through
43 * ifconfig(8). No, sysctl(2) is not the answer. I said a _simple_
44 * interface, didn't I.
45 */
46
47 #ifndef SIOCSAIRONET
48 #define SIOCSAIRONET SIOCSIFGENERIC
49 #endif
50
51 #ifndef SIOCGAIRONET
52 #define SIOCGAIRONET SIOCGIFGENERIC
53 #endif
54
55 #define AN_TIMEOUT 65536
56
57 /* Default network name: ANY */
58 #define AN_DEFAULT_NETNAME ""
59
60 /* The nodename must be less than 16 bytes */
61 #define AN_DEFAULT_NODENAME "NetBSD"
62
63 #define AN_DEFAULT_IBSS "NetBSD IBSS"
64
65 /* The interrupts we will handle */
66 #define AN_INTRS \
67 (AN_EV_RX|AN_EV_TX|AN_EV_TX_EXC|AN_EV_ALLOC|AN_EV_LINKSTAT)
68
69 /*
70 * register space access macros
71 */
72 #define CSR_WRITE_2(sc, reg, val) \
73 bus_space_write_2(sc->an_btag, sc->an_bhandle, reg, val)
74
75 #define CSR_READ_2(sc, reg) \
76 bus_space_read_2(sc->an_btag, sc->an_bhandle, reg)
77
78 #define CSR_WRITE_1(sc, reg, val) \
79 bus_space_write_1(sc->an_btag, sc->an_bhandle, reg, val)
80
81 #define CSR_READ_1(sc, reg) \
82 bus_space_read_1(sc->an_btag, sc->an_bhandle, reg)
83
84 /*
85 * Technically I don't think there's a limit to a record
86 * length. The largest record is the one that contains the CIS
87 * data, which is 240 words long, so 256 should be a safe
88 * value.
89 */
90 #define AN_MAX_DATALEN 512
91
92 struct an_req {
93 u_int16_t an_len;
94 u_int16_t an_type;
95 u_int16_t an_val[AN_MAX_DATALEN];
96 };
97
98 /*
99 * Private LTV records (interpreted only by the driver). This is
100 * a minor kludge to allow reading the interface statistics from
101 * the driver.
102 */
103 #define AN_RID_IFACE_STATS 0x0100
104 #define AN_RID_MGMT_XMIT 0x0200
105 #define AN_RID_ZERO_CACHE 0x0300
106 #define AN_RID_READ_CACHE 0x0400
107 #define AN_RID_TX_SPEED 0x1234
108
109 /*
110 * Aironet IEEE signal strength cache
111 *
112 * driver keeps cache of last
113 * MAXANCACHE packets to arrive including signal strength info.
114 * daemons may read this via ioctl
115 *
116 * Each entry in the wi_sigcache has a unique macsrc.
117 */
118 #define MAXANCACHE 10
119
120 struct an_sigcache {
121 char macsrc[6]; /* unique MAC address for entry */
122 int ipsrc; /* ip address associated with packet */
123 int signal; /* signal strength of the packet */
124 int noise; /* noise value */
125 int quality; /* quality of the packet */
126 };
127
128 #define AN_TXGAP_80211 0
129 #define AN_TXGAP_8023 0
130
131 #define AN_TX_RING_CNT 4
132 #define AN_INC(x, y) (x) = (x + 1) % y
133
134 struct an_tx_ring_data {
135 u_int16_t an_tx_fids[AN_TX_RING_CNT];
136 u_int16_t an_tx_ring[AN_TX_RING_CNT];
137 int an_tx_prod;
138 int an_tx_cons;
139 };
140
141 struct an_wepkey {
142 int an_wep_key[16];
143 int an_wep_keylen;
144 };
145
146 struct an_softc {
147 struct device an_dev;
148 struct ethercom arpcom;
149 int (*sc_enable) __P((struct an_softc *));
150 void (*sc_disable) __P((struct an_softc *));
151 int sc_enabled;
152 int sc_invalid;
153 struct ifmedia sc_media;
154
155 bus_space_handle_t an_bhandle;
156 bus_space_tag_t an_btag;
157 struct an_ltv_genconfig an_config;
158 struct an_ltv_caps an_caps;
159 struct an_ltv_ssidlist an_ssidlist;
160 struct an_ltv_aplist an_aplist;
161 struct an_wepkey an_wepkeys[IEEE80211_WEP_NKID];
162 int an_tx_key;
163 int an_perskeylen[IEEE80211_WEP_NKID];
164 int an_tx_perskey;
165 int an_tx_rate;
166 int an_if_flags;
167 struct an_tx_ring_data an_rdata;
168 struct an_ltv_status an_status;
169 u_int8_t an_associated;
170 int an_sigitems;
171 struct an_sigcache an_sigcache[MAXANCACHE];
172 int an_nextitem;
173 struct callout an_stat_ch;
174 struct an_req an_reqbuf;
175 };
176
177 int an_attach __P((struct an_softc *));
178 int an_detach __P((struct an_softc *));
179 int an_activate __P((struct device *, enum devact));
180 void an_power __P((int, void *));
181 void an_shutdown __P((void *));
182 int an_intr __P((void *));
183
184 #endif /* _DEV_IC_ANVAR_H */
185