Home | History | Annotate | Line # | Download | only in ic
awivar.h revision 1.1
      1 /*-
      2  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      3  * All rights reserved.
      4  *
      5  * This code is derived from software contributed to The NetBSD Foundation
      6  * by Bill Sommerfeld
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *        This product includes software developed by the NetBSD
     19  *        Foundation, Inc. and its contributors.
     20  * 4. Neither the name of The NetBSD Foundation nor the names of its
     21  *    contributors may be used to endorse or promote products derived
     22  *    from this software without specific prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     25  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     26  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     27  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     28  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     30  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     32  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     34  * POSSIBILITY OF SUCH DAMAGE.
     35  */
     36 
     37 
     38 enum awi_state {
     39 	AWI_ST_OFF,		/* powered off */
     40 	AWI_ST_SELFTEST,		/* waiting for selftest to complete*/
     41 	AWI_ST_IFTEST,		/* waiting for interface to respond */
     42 	AWI_ST_MIB_GET,		/* fetching MIB variables */
     43 	AWI_ST_MIB_SET,		/* stuffing MIB variables */
     44 	AWI_ST_TXINIT,		/* initializing TX side */
     45 	AWI_ST_RXINIT,		/* initializing RX side */
     46 	AWI_ST_SCAN,		/* hunting for a BSS */
     47 	AWI_ST_SYNCED,		/* synced?  trying to auth.. */
     48 	/* there are probably some missing 802.11 states here.. */
     49 	AWI_ST_AUTHED,		/* authenticated */
     50 	AWI_ST_RUNNING,		/* ready to send user data.. */
     51 	AWI_ST_INSANE,		/* failed to respond.. */
     52 };
     53 
     54 #define AWI_FL_CMD_INPROG 		0x0001
     55 
     56 #define AWI_SSID_LEN 33
     57 
     58 struct awi_bss_binding
     59 {
     60 	u_int8_t	chanset; /* channel set to use */
     61 	u_int8_t	pattern; /* hop pattern to use */
     62 	u_int8_t	index;	/* index to use */
     63 	u_int8_t	rssi;	/* strenght of this beacon */
     64 	u_int16_t	dwell_time; /* dwell time */
     65 	u_int8_t	bss_timestamp[8]; /* timestamp of this bss */
     66 	u_int8_t	bss_id[6];
     67 	u_int32_t	rxtime;	/* unit's local time */
     68 	u_int8_t	sslen;
     69 	u_int8_t	ssid[AWI_SSID_LEN];
     70 };
     71 
     72 #define NBND 4
     73 #define NTXD 4
     74 
     75 struct awi_txbd
     76 {
     77 	u_int32_t	descr;	/* offset to descriptor */
     78 	u_int32_t	frame;	/* offset to frame */
     79 	u_int32_t	len;	/* frame length */
     80 };
     81 
     82 struct awi_softc
     83 {
     84 	struct device 		sc_dev;
     85 	struct am79c930_softc 	sc_chip;
     86 	struct ethercom		sc_ec;
     87 	int 			sc_enabled;
     88 	enum awi_state 	sc_state;
     89 	int			sc_flags;
     90 	void			*sc_ih; /* interrupt handler */
     91 	struct ifnet		*sc_ifp;	/* XXX */
     92 	int			(*sc_enable) __P((struct awi_softc *));
     93 	void			(*sc_disable) __P((struct awi_softc *));
     94 	void			(*sc_completion) __P((struct awi_softc *,
     95 	    u_int8_t));
     96 
     97 	struct ifqueue		sc_mgtq;
     98 
     99 	u_int32_t		sc_txbase;
    100 	u_int32_t		sc_txlen;
    101 	u_int32_t		sc_rxbase;
    102 	u_int32_t		sc_rxlen;
    103 
    104 	u_int32_t		sc_rx_data_desc;
    105 	u_int32_t		sc_rx_mgt_desc;
    106 
    107 	u_int16_t		sc_scan_duration;
    108 	u_int8_t		sc_scan_chanset;
    109 	u_int8_t		sc_scan_pattern;
    110 
    111 	int			sc_nbindings;
    112 
    113 	u_int8_t		sc_my_addr[6];
    114 
    115 	int			sc_new_bss;
    116 	struct awi_bss_binding	sc_active_bss;
    117 	/*
    118 	 * BSS's found during a scan.. XXX doesn't need to be in-line
    119 	 */
    120 	struct awi_bss_binding	sc_bindings[NBND];
    121 
    122 	int			sc_txpending;
    123 	int			sc_ntxd;
    124 	int			sc_txnext; /* next txd to be given to driver */
    125 	int			sc_txfirst; /* first unsent txd dev has */
    126 	struct awi_txbd	sc_txd[NTXD];
    127 	u_int8_t		sc_curmib;
    128 
    129 	int			sc_scan_timer;
    130 	int			sc_tx_timer;
    131 	int			sc_mgt_timer;
    132 	int			sc_cmd_timer;
    133 	int			sc_selftest_tries;
    134 };
    135 
    136 extern int awi_activate __P((struct device *, enum devact));
    137 extern int awi_attach __P((struct awi_softc *));
    138 
    139 #define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off)
    140 #define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off)
    141 #define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off)
    142 #define awi_read_bytes(sc, off, ptr, len) ((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len)
    143 
    144 #define awi_write_1(sc, off, val) \
    145 	((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val)
    146 #define awi_write_2(sc, off, val) \
    147 	((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val)
    148 #define awi_write_4(sc, off, val) \
    149 	((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val)
    150 #define awi_write_bytes(sc, off, ptr, len) \
    151 	((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len)
    152 
    153 #define awi_drvstate(sc, state) \
    154 	awi_write_1(sc, AWI_DRIVERSTATE, \
    155 	    ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED));
    156 
    157 /* Number of trips around the loop waiting for the device.. */
    158 
    159 #define AWI_LOCKOUT_SPIN	10000 /* 10ms */
    160 
    161 /* 24-byte mac header + 8 byte SNAP header + 1500-byte ether MTU */
    162 #define AWI_FRAME_SIZE		1532
    163 
    164 /* refresh associations every 300s */
    165 
    166 #define AWI_ASSOC_REFRESH	300
    167 
    168 extern int awi_intr __P((void *));
    169