anvar.h revision 1.4 1 /* $NetBSD: anvar.h,v 1.4 2000/12/19 08:00:56 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 /*
66 * register space access macros
67 */
68 #define CSR_WRITE_2(sc, reg, val) \
69 bus_space_write_2(sc->an_btag, sc->an_bhandle, reg, val)
70
71 #define CSR_READ_2(sc, reg) \
72 bus_space_read_2(sc->an_btag, sc->an_bhandle, reg)
73
74 #define CSR_WRITE_1(sc, reg, val) \
75 bus_space_write_1(sc->an_btag, sc->an_bhandle, reg, val)
76
77 #define CSR_READ_1(sc, reg) \
78 bus_space_read_1(sc->an_btag, sc->an_bhandle, reg)
79
80 /*
81 * Technically I don't think there's a limit to a record
82 * length. The largest record is the one that contains the CIS
83 * data, which is 240 words long, so 256 should be a safe
84 * value.
85 */
86 #define AN_MAX_DATALEN 512
87
88 struct an_req {
89 u_int16_t an_len;
90 u_int16_t an_type;
91 u_int16_t an_val[AN_MAX_DATALEN];
92 };
93
94 /*
95 * Private LTV records (interpreted only by the driver). This is
96 * a minor kludge to allow reading the interface statistics from
97 * the driver.
98 */
99 #define AN_RID_IFACE_STATS 0x0100
100 #define AN_RID_MGMT_XMIT 0x0200
101 #define AN_RID_ZERO_CACHE 0x0300
102 #define AN_RID_READ_CACHE 0x0400
103 #define AN_RID_TX_SPEED 0x1234
104
105 /*
106 * Aironet IEEE signal strength cache
107 *
108 * driver keeps cache of last
109 * MAXANCACHE packets to arrive including signal strength info.
110 * daemons may read this via ioctl
111 *
112 * Each entry in the wi_sigcache has a unique macsrc.
113 */
114 #define MAXANCACHE 10
115
116 struct an_sigcache {
117 char macsrc[6]; /* unique MAC address for entry */
118 int ipsrc; /* ip address associated with packet */
119 int signal; /* signal strength of the packet */
120 int noise; /* noise value */
121 int quality; /* quality of the packet */
122 };
123
124 #define AN_TXGAP_80211 0
125 #define AN_TXGAP_8023 0
126
127 #define AN_TX_RING_CNT 4
128 #define AN_INC(x, y) (x) = (x + 1) % y
129
130 struct an_tx_ring_data {
131 u_int16_t an_tx_fids[AN_TX_RING_CNT];
132 u_int16_t an_tx_ring[AN_TX_RING_CNT];
133 int an_tx_prod;
134 int an_tx_cons;
135 };
136
137 struct an_softc {
138 struct device an_dev;
139 struct ethercom arpcom;
140 int (*sc_enable) __P((struct an_softc *));
141 void (*sc_disable) __P((struct an_softc *));
142 int sc_enabled;
143 int sc_invalid;
144 struct ifmedia sc_media;
145
146 bus_space_handle_t an_bhandle;
147 bus_space_tag_t an_btag;
148 struct an_ltv_genconfig an_config;
149 struct an_ltv_caps an_caps;
150 struct an_ltv_ssidlist an_ssidlist;
151 struct an_ltv_aplist an_aplist;
152 struct an_ltv_wepkey an_temp_keys;
153 struct an_ltv_wepkey an_perm_keys;
154 int an_tx_rate;
155 int an_rxmode;
156 int an_if_flags;
157 u_int8_t an_txbuf[1536];
158 struct an_tx_ring_data an_rdata;
159 struct an_ltv_stats an_stats;
160 struct an_ltv_status an_status;
161 u_int8_t an_associated;
162 int an_sigitems;
163 struct an_sigcache an_sigcache[MAXANCACHE];
164 int an_nextitem;
165 struct callout an_stat_ch;
166 };
167
168 int an_attach __P((struct an_softc *));
169 int an_detach __P((struct an_softc *));
170 int an_activate __P((struct device *, enum devact));
171 void an_power __P((int, void *));
172 void an_shutdown __P((void *));
173 int an_intr __P((void *));
174
175 #endif /* _DEV_IC_ANVAR_H */
176