Home | History | Annotate | Line # | Download | only in ic
awivar.h revision 1.7
      1  1.7      onoe /* $NetBSD: awivar.h,v 1.7 2000/03/27 12:55:00 onoe Exp $ */
      2  1.2  sommerfe 
      3  1.6      onoe /*
      4  1.6      onoe  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5  1.1  sommerfe  * All rights reserved.
      6  1.1  sommerfe  *
      7  1.1  sommerfe  * This code is derived from software contributed to The NetBSD Foundation
      8  1.6      onoe  * by Atsushi Onoe
      9  1.1  sommerfe  *
     10  1.1  sommerfe  * Redistribution and use in source and binary forms, with or without
     11  1.1  sommerfe  * modification, are permitted provided that the following conditions
     12  1.1  sommerfe  * are met:
     13  1.1  sommerfe  * 1. Redistributions of source code must retain the above copyright
     14  1.1  sommerfe  *    notice, this list of conditions and the following disclaimer.
     15  1.1  sommerfe  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  sommerfe  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  sommerfe  *    documentation and/or other materials provided with the distribution.
     18  1.1  sommerfe  * 3. All advertising materials mentioning features or use of this software
     19  1.1  sommerfe  *    must display the following acknowledgement:
     20  1.1  sommerfe  *        This product includes software developed by the NetBSD
     21  1.1  sommerfe  *        Foundation, Inc. and its contributors.
     22  1.1  sommerfe  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.1  sommerfe  *    contributors may be used to endorse or promote products derived
     24  1.1  sommerfe  *    from this software without specific prior written permission.
     25  1.1  sommerfe  *
     26  1.1  sommerfe  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.1  sommerfe  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.1  sommerfe  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.1  sommerfe  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.1  sommerfe  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.1  sommerfe  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.1  sommerfe  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.1  sommerfe  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.1  sommerfe  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.1  sommerfe  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.1  sommerfe  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1  sommerfe  */
     38  1.1  sommerfe 
     39  1.6      onoe /* timer values in msec */
     40  1.6      onoe #define	AWI_SELFTEST_TIMEOUT	5000
     41  1.6      onoe #define	AWI_CMD_TIMEOUT		2000
     42  1.6      onoe #define	AWI_LOCKOUT_TIMEOUT	50
     43  1.6      onoe #define	AWI_ASCAN_DURATION	100
     44  1.6      onoe #define	AWI_ASCAN_WAIT		3000
     45  1.6      onoe #define	AWI_PSCAN_DURATION	200
     46  1.6      onoe #define	AWI_PSCAN_WAIT		5000
     47  1.6      onoe #define	AWI_TRANS_TIMEOUT	2000
     48  1.6      onoe 
     49  1.6      onoe #define	AWI_NTXBUFS		4
     50  1.6      onoe 
     51  1.6      onoe enum awi_status {
     52  1.6      onoe 	AWI_ST_INIT,
     53  1.6      onoe 	AWI_ST_SCAN,
     54  1.6      onoe 	AWI_ST_SETSS,
     55  1.6      onoe 	AWI_ST_SYNC,
     56  1.6      onoe 	AWI_ST_AUTH,
     57  1.6      onoe 	AWI_ST_ASSOC,
     58  1.6      onoe 	AWI_ST_RUNNING
     59  1.1  sommerfe };
     60  1.1  sommerfe 
     61  1.6      onoe struct awi_bss
     62  1.1  sommerfe {
     63  1.6      onoe 	TAILQ_ENTRY(awi_bss)	list;
     64  1.6      onoe 	u_int8_t	esrc[ETHER_ADDR_LEN];
     65  1.6      onoe 	u_int8_t	chanset;	/* channel set to use */
     66  1.6      onoe 	u_int8_t	pattern;	/* hop pattern to use */
     67  1.6      onoe 	u_int8_t	index;		/* index to use */
     68  1.6      onoe 	u_int8_t	rssi;		/* strength of this beacon */
     69  1.6      onoe 	u_int16_t	dwell_time;	/* dwell time */
     70  1.6      onoe 	u_int8_t	timestamp[8];	/* timestamp of this bss */
     71  1.6      onoe 	u_int8_t	bssid[ETHER_ADDR_LEN];
     72  1.6      onoe 	u_int32_t	rxtime;		/* unit's local time */
     73  1.6      onoe 	u_int16_t	interval;	/* beacon interval */
     74  1.6      onoe 	u_int8_t	txrate;
     75  1.6      onoe 	u_int8_t	fails;
     76  1.6      onoe 	u_int8_t	essid[IEEE80211_NWID_LEN + 2];
     77  1.1  sommerfe };
     78  1.1  sommerfe 
     79  1.1  sommerfe struct awi_softc
     80  1.1  sommerfe {
     81  1.6      onoe #ifdef __NetBSD__
     82  1.1  sommerfe 	struct device 		sc_dev;
     83  1.1  sommerfe 	struct ethercom		sc_ec;
     84  1.1  sommerfe 	void			*sc_ih; /* interrupt handler */
     85  1.6      onoe #endif
     86  1.6      onoe #ifdef __FreeBSD__
     87  1.6      onoe #if __FreeBSD__ >= 4
     88  1.6      onoe 	struct {
     89  1.6      onoe 		char	dv_xname[64];	/*XXX*/
     90  1.6      onoe 	}			sc_dev;
     91  1.6      onoe #else
     92  1.6      onoe 	struct device		sc_dev;
     93  1.6      onoe #endif
     94  1.6      onoe 	struct arpcom		sc_ec;
     95  1.6      onoe 	struct callout_handle	sc_tohandle;
     96  1.6      onoe #endif
     97  1.6      onoe 	struct am79c930_softc 	sc_chip;
     98  1.6      onoe 	struct ifnet		*sc_ifp;
     99  1.1  sommerfe 	int			(*sc_enable) __P((struct awi_softc *));
    100  1.1  sommerfe 	void			(*sc_disable) __P((struct awi_softc *));
    101  1.1  sommerfe 
    102  1.6      onoe 	struct ifmedia		sc_media;
    103  1.6      onoe 	enum awi_status		sc_status;
    104  1.6      onoe 	unsigned int		sc_enabled:1,
    105  1.6      onoe 				sc_busy:1,
    106  1.6      onoe 				sc_cansleep:1,
    107  1.6      onoe 				sc_invalid:1,
    108  1.7      onoe 				sc_enab_intr:1,
    109  1.6      onoe 				sc_cmd_inprog:1,
    110  1.6      onoe 				sc_format_llc:1,
    111  1.6      onoe 				sc_start_bss:1,
    112  1.6      onoe 				sc_rawbpf:1,
    113  1.6      onoe 				sc_no_bssid:1,
    114  1.6      onoe 				sc_active_scan:1;
    115  1.6      onoe 	int			sc_sleep_cnt;
    116  1.1  sommerfe 
    117  1.1  sommerfe 	int			sc_mgt_timer;
    118  1.4  sommerfe 
    119  1.6      onoe 	TAILQ_HEAD(, awi_bss)	sc_scan;
    120  1.6      onoe 	u_int8_t		sc_scan_cur;
    121  1.6      onoe 	u_int8_t		sc_scan_min;
    122  1.6      onoe 	u_int8_t		sc_scan_max;
    123  1.6      onoe 	u_int8_t		sc_scan_set;
    124  1.6      onoe 	struct awi_bss		sc_bss;
    125  1.6      onoe 
    126  1.6      onoe 	int			sc_rx_timer;
    127  1.6      onoe 	u_int32_t		sc_rxdoff;
    128  1.6      onoe 	u_int32_t		sc_rxmoff;
    129  1.6      onoe 	struct mbuf		*sc_rxpend;
    130  1.6      onoe 
    131  1.6      onoe 	int			sc_tx_timer;
    132  1.6      onoe 	u_int8_t		sc_tx_rate;
    133  1.6      onoe 	struct ifqueue		sc_mgtq;
    134  1.6      onoe 	u_int32_t		sc_txbase;
    135  1.6      onoe 	u_int32_t		sc_txend;
    136  1.6      onoe 	u_int32_t		sc_txnext;
    137  1.6      onoe 	u_int32_t		sc_txdone;
    138  1.6      onoe 
    139  1.6      onoe 	struct awi_mib_local	sc_mib_local;
    140  1.6      onoe 	struct awi_mib_addr	sc_mib_addr;
    141  1.6      onoe 	struct awi_mib_mac	sc_mib_mac;
    142  1.6      onoe 	struct awi_mib_stat	sc_mib_stat;
    143  1.6      onoe 	struct awi_mib_mgt	sc_mib_mgt;
    144  1.6      onoe 	struct awi_mib_phy	sc_mib_phy;
    145  1.1  sommerfe };
    146  1.1  sommerfe 
    147  1.1  sommerfe #define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off)
    148  1.1  sommerfe #define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off)
    149  1.1  sommerfe #define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off)
    150  1.1  sommerfe #define awi_read_bytes(sc, off, ptr, len) ((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len)
    151  1.1  sommerfe 
    152  1.1  sommerfe #define awi_write_1(sc, off, val) \
    153  1.1  sommerfe 	((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val)
    154  1.1  sommerfe #define awi_write_2(sc, off, val) \
    155  1.1  sommerfe 	((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val)
    156  1.1  sommerfe #define awi_write_4(sc, off, val) \
    157  1.1  sommerfe 	((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val)
    158  1.1  sommerfe #define awi_write_bytes(sc, off, ptr, len) \
    159  1.1  sommerfe 	((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len)
    160  1.1  sommerfe 
    161  1.1  sommerfe #define awi_drvstate(sc, state) \
    162  1.1  sommerfe 	awi_write_1(sc, AWI_DRIVERSTATE, \
    163  1.6      onoe 	    ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED))
    164  1.1  sommerfe 
    165  1.6      onoe /* unalligned little endian access */
    166  1.6      onoe #define	LE_READ_2(p)							\
    167  1.6      onoe 	(((u_int8_t *)(p))[0] | (((u_int8_t *)(p))[1] << 8))
    168  1.6      onoe #define	LE_READ_4(p)							\
    169  1.6      onoe 	(((u_int8_t *)(p))[0] | (((u_int8_t *)(p))[1] << 8) |		\
    170  1.6      onoe 	 (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24))
    171  1.6      onoe #define	LE_WRITE_2(p, v)						\
    172  1.6      onoe 	((((u_int8_t *)(p))[0] = ((u_int32_t)(v) & 0xff)),		\
    173  1.6      onoe 	 (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)))
    174  1.6      onoe #define	LE_WRITE_4(p, v)						\
    175  1.6      onoe 	((((u_int8_t *)(p))[0] = ((u_int32_t)(v) & 0xff)),		\
    176  1.6      onoe 	 (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)),	\
    177  1.6      onoe 	 (((u_int8_t *)(p))[2] = (((u_int32_t)(v) >> 16) & 0xff)),	\
    178  1.6      onoe 	 (((u_int8_t *)(p))[3] = (((u_int32_t)(v) >> 24) & 0xff)))
    179  1.6      onoe 
    180  1.6      onoe #define	AWI_80211_RATE(rate)	(((rate) & 0x7f) * 5)
    181  1.6      onoe 
    182  1.6      onoe int	awi_attach __P((struct awi_softc *));
    183  1.6      onoe int	awi_intr __P((void *));
    184  1.6      onoe void	awi_reset __P((struct awi_softc *));
    185  1.6      onoe #ifdef __NetBSD__
    186  1.6      onoe int	awi_activate __P((struct device *, enum devact));
    187  1.6      onoe int	awi_detach __P((struct awi_softc *));
    188  1.6      onoe #endif
    189