anvar.h revision 1.8 1 /* $NetBSD: anvar.h,v 1.8 2004/01/28 15:07:52 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 #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 struct an_softc {
75 struct device sc_dev;
76 struct ieee80211com sc_ic;
77 bus_space_tag_t sc_iot;
78 bus_space_handle_t sc_ioh;
79 int (*sc_enable)(struct an_softc *);
80 void (*sc_disable)(struct an_softc *);
81 int (*sc_newstate)(struct ieee80211com *,
82 enum ieee80211_state, int);
83
84 int sc_enabled;
85 int sc_invalid;
86 int sc_attached;
87
88 int sc_bap_id;
89 int sc_bap_off;
90
91 int sc_use_leap;
92 struct an_wepkey sc_wepkeys[IEEE80211_WEP_NKID];
93 int sc_perskeylen[IEEE80211_WEP_NKID];
94 int sc_tx_key;
95 int sc_tx_perskey;
96 int sc_tx_timer;
97 struct an_txdesc {
98 int d_fid;
99 int d_inuse;
100 } sc_txd[AN_TX_RING_CNT];
101 int sc_txnext;
102 int sc_txcur;
103
104 struct an_rid_genconfig sc_config;
105 struct an_rid_caps sc_caps;
106 union {
107 u_int16_t sc_val[1];
108 u_int8_t sc_txbuf[AN_TX_MAX_LEN];
109 struct an_rid_ssidlist sc_ssidlist;
110 struct an_rid_aplist sc_aplist;
111 struct an_rid_status sc_status;
112 struct an_rid_wepkey sc_wepkey;
113 struct an_rid_leapkey sc_leapkey;
114 struct an_rid_encap sc_encap;
115 } sc_buf;
116 };
117
118 int an_attach(struct an_softc *);
119 int an_detach(struct an_softc *);
120 int an_activate(struct device *, enum devact);
121 void an_power(int, void *);
122 void an_shutdown(struct an_softc *);
123 int an_intr(void *);
124
125 #endif /* _DEV_IC_ANVAR_H */
126