summaryrefslogtreecommitdiff
path: root/sys/dev/ic/awivar.h
blob: d50fa7c9b66d9f68691906055893ab0fe4196496 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/* $NetBSD: awivar.h,v 1.4 1999/11/09 14:58:07 sommerfeld Exp $ */
/* $OpenBSD: awivar.h,v 1.1 1999/12/16 02:56:56 deraadt Exp $ */

/*-
 * Copyright (c) 1999 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Bill Sommerfeld
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *        This product includes software developed by the NetBSD
 *        Foundation, Inc. and its contributors.
 * 4. Neither the name of The NetBSD Foundation nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */


enum awi_state {
	AWI_ST_OFF,		/* powered off */
	AWI_ST_SELFTEST,		/* waiting for selftest to complete*/
	AWI_ST_IFTEST,		/* waiting for interface to respond */
	AWI_ST_MIB_GET,		/* fetching MIB variables */
	AWI_ST_MIB_SET,		/* stuffing MIB variables */
	AWI_ST_TXINIT,		/* initializing TX side */
	AWI_ST_RXINIT,		/* initializing RX side */
	AWI_ST_SCAN,		/* hunting for a BSS */
	AWI_ST_SYNCED,		/* synced?  trying to auth.. */
	/* there are probably some missing 802.11 states here.. */
	AWI_ST_AUTHED,		/* authenticated */
	AWI_ST_RUNNING,		/* ready to send user data.. */
	AWI_ST_INSANE,		/* failed to respond.. */
};

#define AWI_FL_CMD_INPROG 		0x0001

#define AWI_SSID_LEN 33

struct awi_bss_binding 
{
	u_int8_t	chanset; /* channel set to use */
	u_int8_t	pattern; /* hop pattern to use */
	u_int8_t	index;	/* index to use */
	u_int8_t	rssi;	/* strenght of this beacon */
	u_int16_t	dwell_time; /* dwell time */
	u_int8_t	bss_timestamp[8]; /* timestamp of this bss */
	u_int8_t	bss_id[6];
	u_int32_t	rxtime;	/* unit's local time */
	u_int8_t	sslen;
	u_int8_t	ssid[AWI_SSID_LEN];
};

#define NBND 4
#define NTXD 4

struct awi_txbd 
{
	u_int32_t	descr;	/* offset to descriptor */
	u_int32_t	frame;	/* offset to frame */
	u_int32_t	len;	/* frame length */	
};

struct awi_softc 
{
	struct device 		sc_dev;
	struct am79c930_softc 	sc_chip;
	struct arpcom		sc_ec;
	int 			sc_enabled;
	enum awi_state		sc_state;
	int			sc_flags;
	void			*sc_ih; /* interrupt handler */
	struct ifnet		*sc_ifp;	/* XXX */
	int			(*sc_enable) __P((struct awi_softc *));
	void			(*sc_disable) __P((struct awi_softc *));
	void			(*sc_completion) __P((struct awi_softc *,
	    u_int8_t));

	struct ifqueue		sc_mgtq;
	
	u_int32_t		sc_txbase;
	u_int32_t		sc_txlen;
	u_int32_t		sc_rxbase;
	u_int32_t		sc_rxlen;

	u_int32_t		sc_rx_data_desc;
	u_int32_t		sc_rx_mgt_desc;

	u_int16_t		sc_scan_duration;
	u_int8_t		sc_scan_chanset;
	u_int8_t		sc_scan_pattern;

	int			sc_nbindings;

	u_int8_t		sc_my_addr[6];
	
	int			sc_new_bss;
	struct awi_bss_binding	sc_active_bss;
	/*
	 * BSS's found during a scan.. XXX doesn't need to be in-line
	 */
	struct awi_bss_binding	sc_bindings[NBND];
	
	int			sc_txpending;
	int			sc_ntxd;
	int			sc_txnext; /* next txd to be given to driver */
	int			sc_txfirst; /* first unsent txd dev has */
	struct awi_txbd	sc_txd[NTXD];
	u_int8_t		sc_curmib;

	int			sc_scan_timer;
	int			sc_tx_timer;
	int			sc_mgt_timer;
	int			sc_cmd_timer;
	int			sc_selftest_tries;

	/*
	 * packet parsing state.
	 */

	struct mbuf		*sc_nextpkt;
	struct mbuf		*sc_m;
	u_int8_t		*sc_mptr;
	u_int32_t		sc_mleft;
	int			sc_flushpkt;
};

extern int awi_activate __P((struct device *, enum devact));
extern int awi_attach __P((struct awi_softc *, u_int8_t *macaddr));
extern void awi_init __P((struct awi_softc *));
extern void awi_stop __P((struct awi_softc *));

#define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off)
#define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off)
#define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off)
#define awi_read_bytes(sc, off, ptr, len) ((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len)

#define awi_write_1(sc, off, val) \
	((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val)
#define awi_write_2(sc, off, val) \
	((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val)
#define awi_write_4(sc, off, val) \
	((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val)
#define awi_write_bytes(sc, off, ptr, len) \
	((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len)

#define awi_drvstate(sc, state) \
	awi_write_1(sc, AWI_DRIVERSTATE, \
	    ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED));

/* Number of trips around the loop waiting for the device.. */

#define AWI_LOCKOUT_SPIN	10000 /* 10ms */

/* 24-byte mac header + 8 byte SNAP header + 1500-byte ether MTU */
#define AWI_FRAME_SIZE		1532

/* refresh associations every 300s */
  
#define AWI_ASSOC_REFRESH	300

extern int awi_intr __P((void *));