anvar.h revision 1.11 1 /* $NetBSD: anvar.h,v 1.11 2005/06/22 06:15:51 dyoung 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 #define AN_TIMEOUT 65536
40 #define AN_MAGIC 0x414e
41
42 /* The interrupts we will handle */
43 #define AN_INTRS (AN_EV_RX | AN_EV_TX | AN_EV_TX_EXC | AN_EV_LINKSTAT)
44
45 /*
46 * register space access macros
47 */
48 #define CSR_WRITE_2(sc, reg, val) \
49 bus_space_write_2(sc->sc_iot, sc->sc_ioh, reg, val)
50
51 #define CSR_READ_2(sc, reg) \
52 bus_space_read_2(sc->sc_iot, sc->sc_ioh, reg)
53
54 #ifndef __BUS_SPACE_HAS_STREAM_METHODS
55 #define bus_space_write_multi_stream_2 bus_space_write_multi_2
56 #define bus_space_read_multi_stream_2 bus_space_read_multi_2
57 #endif
58
59 #define CSR_WRITE_MULTI_STREAM_2(sc, reg, val, count) \
60 bus_space_write_multi_stream_2(sc->sc_iot, sc->sc_ioh, reg, val, count)
61 #define CSR_READ_MULTI_STREAM_2(sc, reg, buf, count) \
62 bus_space_read_multi_stream_2(sc->sc_iot, sc->sc_ioh, reg, buf, count)
63
64 #define AN_TX_MAX_LEN \
65 (sizeof(struct an_txframe) + ETHER_TYPE_LEN + ETHER_MAX_LEN)
66 #define AN_TX_RING_CNT 4
67 #define AN_INC(x, y) (x) = (x + 1) % y
68
69 struct an_wepkey {
70 int an_wep_key[16];
71 int an_wep_keylen;
72 };
73
74 #define AN_GAPLEN_MAX 8
75
76 struct an_softc {
77 struct device sc_dev;
78 struct ethercom sc_ec;
79 struct ieee80211com sc_ic;
80 bus_space_tag_t sc_iot;
81 bus_space_handle_t sc_ioh;
82 int (*sc_enable)(struct an_softc *);
83 void (*sc_disable)(struct an_softc *);
84 int (*sc_newstate)(struct ieee80211com *,
85 enum ieee80211_state, int);
86
87 int sc_enabled;
88 int sc_invalid;
89 int sc_attached;
90
91 int sc_bap_id;
92 int sc_bap_off;
93
94 int sc_use_leap;
95 struct an_wepkey sc_wepkeys[IEEE80211_WEP_NKID];
96 int sc_perskeylen[IEEE80211_WEP_NKID];
97 int sc_tx_key;
98 int sc_tx_perskey;
99 int sc_tx_timer;
100 struct an_txdesc {
101 int d_fid;
102 int d_inuse;
103 } sc_txd[AN_TX_RING_CNT];
104 int sc_txnext;
105 int sc_txcur;
106
107 struct an_rid_genconfig sc_config;
108 struct an_rid_caps sc_caps;
109 union {
110 u_int16_t sc_val[1];
111 u_int8_t sc_txbuf[AN_TX_MAX_LEN];
112 struct an_rid_ssidlist sc_ssidlist;
113 struct an_rid_aplist sc_aplist;
114 struct an_rid_status sc_status;
115 struct an_rid_wepkey sc_wepkey;
116 struct an_rid_leapkey sc_leapkey;
117 struct an_rid_encap sc_encap;
118 } sc_buf;
119 };
120
121 #define sc_if sc_ec.ec_if
122
123 int an_attach(struct an_softc *);
124 int an_detach(struct an_softc *);
125 int an_activate(struct device *, enum devact);
126 void an_power(int, void *);
127 void an_shutdown(struct an_softc *);
128 int an_intr(void *);
129
130 #endif /* _DEV_IC_ANVAR_H */
131