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