Home | History | Annotate | Line # | Download | only in ic
wivar.h revision 1.37
      1  1.37   dyoung /*	$NetBSD: wivar.h,v 1.37 2003/10/13 08:07:21 dyoung Exp $	*/
      2   1.1   ichiro 
      3   1.1   ichiro /*
      4   1.1   ichiro  * Copyright (c) 1997, 1998, 1999
      5   1.1   ichiro  *	Bill Paul <wpaul (at) ctr.columbia.edu>.  All rights reserved.
      6   1.1   ichiro  *
      7   1.1   ichiro  * Redistribution and use in source and binary forms, with or without
      8   1.1   ichiro  * modification, are permitted provided that the following conditions
      9   1.1   ichiro  * are met:
     10   1.1   ichiro  * 1. Redistributions of source code must retain the above copyright
     11   1.1   ichiro  *    notice, this list of conditions and the following disclaimer.
     12   1.1   ichiro  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1   ichiro  *    notice, this list of conditions and the following disclaimer in the
     14   1.1   ichiro  *    documentation and/or other materials provided with the distribution.
     15   1.1   ichiro  * 3. All advertising materials mentioning features or use of this software
     16   1.1   ichiro  *    must display the following acknowledgement:
     17   1.1   ichiro  *	This product includes software developed by Bill Paul.
     18   1.1   ichiro  * 4. Neither the name of the author nor the names of any co-contributors
     19   1.1   ichiro  *    may be used to endorse or promote products derived from this software
     20   1.1   ichiro  *    without specific prior written permission.
     21   1.1   ichiro  *
     22   1.1   ichiro  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
     23   1.1   ichiro  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24   1.1   ichiro  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25   1.1   ichiro  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
     26   1.1   ichiro  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     27   1.1   ichiro  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     28   1.1   ichiro  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     29   1.1   ichiro  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     30   1.1   ichiro  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     31   1.1   ichiro  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     32   1.1   ichiro  * THE POSSIBILITY OF SUCH DAMAGE.
     33   1.1   ichiro  */
     34   1.1   ichiro 
     35   1.1   ichiro /*
     36   1.1   ichiro  * FreeBSD driver ported to NetBSD by Bill Sommerfeld in the back of the
     37   1.1   ichiro  * Oslo IETF plenary meeting.
     38   1.1   ichiro  */
     39   1.1   ichiro struct wi_softc	{
     40   1.1   ichiro 	struct device		sc_dev;
     41  1.21     onoe 	struct ieee80211com	sc_ic;
     42  1.21     onoe 	void			*sc_ih;		/* interrupt handler */
     43  1.21     onoe 	int			(*sc_enable)(struct wi_softc *);
     44  1.21     onoe 	void			(*sc_disable)(struct wi_softc *);
     45  1.30   dyoung 	void			(*sc_reset)(struct wi_softc *);
     46  1.37   dyoung 
     47  1.37   dyoung 	int			(*sc_newstate)(struct ieee80211com *,
     48  1.37   dyoung 				    enum ieee80211_state, int);
     49  1.21     onoe 
     50  1.21     onoe 	int			sc_attached;
     51  1.21     onoe 	int			sc_enabled;
     52  1.34   dyoung 	int			sc_invalid;
     53  1.21     onoe 	int			sc_firmware_type;
     54  1.14   ichiro #define	WI_NOTYPE	0
     55  1.14   ichiro #define	WI_LUCENT	1
     56  1.14   ichiro #define	WI_INTERSIL	2
     57  1.14   ichiro #define	WI_SYMBOL	3
     58  1.21     onoe 	int			sc_pri_firmware_ver;	/* Primary firm vers */
     59  1.21     onoe 	int			sc_sta_firmware_ver;	/* Station firm vers */
     60  1.21     onoe 	int			sc_pci;			/* attach to PCI-Bus */
     61  1.21     onoe 
     62  1.21     onoe 	bus_space_tag_t		sc_iot;			/* bus cookie */
     63  1.21     onoe 	bus_space_handle_t	sc_ioh;			/* bus i/o handle */
     64  1.19  thorpej 
     65  1.21     onoe 	caddr_t			sc_drvbpf;
     66  1.21     onoe 	int			sc_flags;
     67  1.21     onoe 	int			sc_bap_id;
     68  1.21     onoe 	int			sc_bap_off;
     69  1.31   dyoung 
     70  1.31   dyoung 	u_int16_t		sc_portnum;
     71  1.21     onoe 
     72  1.35   dyoung 	/* RSSI interpretation */
     73  1.35   dyoung 	u_int16_t		sc_min_rssi;	/* clamp sc_min_rssi < RSSI */
     74  1.35   dyoung 	u_int16_t		sc_max_rssi;	/* clamp RSSI < sc_max_rssi */
     75  1.35   dyoung 	u_int16_t		sc_dbm_offset;	/* dBm ~ RSSI - sc_dbm_offset */
     76  1.21     onoe 	u_int16_t		sc_max_datalen;
     77  1.24   dyoung 	u_int16_t		sc_frag_thresh;
     78  1.21     onoe 	u_int16_t		sc_rts_thresh;
     79  1.21     onoe 	u_int16_t		sc_system_scale;
     80  1.21     onoe 	u_int16_t		sc_tx_rate;
     81  1.21     onoe 	u_int16_t		sc_cnfauthmode;
     82  1.21     onoe 	u_int16_t		sc_roaming_mode;
     83  1.21     onoe 	u_int16_t		sc_microwave_oven;
     84  1.21     onoe 
     85  1.21     onoe 	int			sc_nodelen;
     86  1.21     onoe 	char			sc_nodename[IEEE80211_NWID_LEN];
     87  1.21     onoe 
     88  1.21     onoe 	int			sc_buflen;
     89  1.21     onoe #define	WI_NTXBUF	3
     90  1.21     onoe 	struct sc_txdesc {
     91  1.21     onoe 		int		d_fid;
     92  1.21     onoe 		int		d_len;
     93  1.21     onoe 	}			sc_txd[WI_NTXBUF];
     94  1.21     onoe 	int			sc_txnext;
     95  1.21     onoe 	int			sc_txcur;
     96  1.21     onoe 	int			sc_tx_timer;
     97  1.21     onoe 	int			sc_scan_timer;
     98  1.27   dyoung 	int			sc_syn_timer;
     99  1.21     onoe 
    100  1.21     onoe 	struct wi_counters	sc_stats;
    101  1.21     onoe 	u_int16_t		sc_ibss_port;
    102  1.19  thorpej 
    103  1.21     onoe 	struct wi_apinfo	sc_aps[MAXAPINFO];
    104  1.21     onoe 	int 			sc_naps;
    105  1.27   dyoung 
    106  1.27   dyoung 	int			sc_false_syns;
    107  1.28   dyoung 
    108  1.28   dyoung 	u_int16_t		sc_txbuf[IEEE80211_MAX_LEN/2];
    109  1.12   ichiro };
    110  1.20     onoe 
    111  1.21     onoe #define	sc_if			sc_ic.ic_if
    112  1.27   dyoung 
    113  1.27   dyoung /* maximum consecutive false change-of-BSSID indications */
    114  1.27   dyoung #define	WI_MAX_FALSE_SYNS		10
    115  1.35   dyoung 
    116  1.35   dyoung #define	WI_PRISM_MIN_RSSI	0x1b
    117  1.35   dyoung #define	WI_PRISM_MAX_RSSI	0x9a
    118  1.35   dyoung #define	WI_PRISM_DBM_OFFSET	100 /* XXX */
    119  1.35   dyoung 
    120  1.35   dyoung #define	WI_LUCENT_MIN_RSSI	47
    121  1.35   dyoung #define	WI_LUCENT_MAX_RSSI	138
    122  1.35   dyoung #define	WI_LUCENT_DBM_OFFSET	149
    123  1.35   dyoung 
    124  1.35   dyoung #define	WI_RSSI_TO_DBM(sc, rssi) (MIN((sc)->sc_max_rssi, \
    125  1.35   dyoung     MAX((sc)->sc_min_rssi, (rssi))) - (sc)->sc_dbm_offset)
    126  1.21     onoe 
    127  1.21     onoe #define	WI_SCAN_INQWAIT			3	/* wait sec before inquire */
    128  1.21     onoe #define	WI_SCAN_WAIT			5	/* maximum scan wait */
    129  1.16  thorpej 
    130  1.16  thorpej /* Values for wi_flags. */
    131  1.16  thorpej #define	WI_FLAGS_ATTACHED		0x0001
    132  1.16  thorpej #define	WI_FLAGS_INITIALIZED		0x0002
    133  1.23     onoe #define	WI_FLAGS_OUTRANGE		0x0004
    134  1.21     onoe #define	WI_FLAGS_HAS_MOR		0x0010
    135  1.21     onoe #define	WI_FLAGS_HAS_ROAMING		0x0020
    136  1.21     onoe #define	WI_FLAGS_HAS_DIVERSITY		0x0040
    137  1.21     onoe #define	WI_FLAGS_HAS_SYSSCALE		0x0080
    138  1.21     onoe #define	WI_FLAGS_BUG_AUTOINC		0x0100
    139  1.25   dyoung #define	WI_FLAGS_HAS_FRAGTHR		0x0200
    140  1.26   dyoung #define	WI_FLAGS_HAS_DBMADJUST		0x0400
    141  1.12   ichiro 
    142  1.12   ichiro struct wi_card_ident {
    143  1.12   ichiro 	u_int16_t	card_id;
    144  1.12   ichiro 	char		*card_name;
    145  1.12   ichiro 	u_int8_t	firm_type;
    146   1.1   ichiro };
    147   1.1   ichiro 
    148  1.21     onoe /*
    149  1.21     onoe  * register space access macros
    150  1.21     onoe  */
    151  1.21     onoe #ifdef WI_AT_BIGENDIAN_BUS_HACK
    152  1.21     onoe 	/*
    153  1.21     onoe 	 * XXX - ugly hack for sparc bus_space_* macro deficiencies:
    154  1.21     onoe 	 *       assume the bus we are accessing is big endian.
    155  1.21     onoe 	 */
    156  1.21     onoe 
    157  1.21     onoe #define CSR_WRITE_4(sc, reg, val)	\
    158  1.21     onoe 	bus_space_write_4(sc->sc_iot, sc->sc_ioh,	\
    159  1.21     onoe 			(sc->sc_pci? reg * 2: reg) , htole32(val))
    160  1.21     onoe #define CSR_WRITE_2(sc, reg, val)	\
    161  1.21     onoe 	bus_space_write_2(sc->sc_iot, sc->sc_ioh,	\
    162  1.21     onoe 			(sc->sc_pci? reg * 2: reg), htole16(val))
    163  1.21     onoe #define CSR_WRITE_1(sc, reg, val)	\
    164  1.21     onoe 	bus_space_write_1(sc->sc_iot, sc->sc_ioh,	\
    165  1.21     onoe 			(sc->sc_pci? reg * 2: reg), val)
    166  1.21     onoe 
    167  1.21     onoe #define CSR_READ_4(sc, reg)		\
    168  1.21     onoe 	le32toh(bus_space_read_4(sc->sc_iot, sc->sc_ioh,	\
    169  1.21     onoe 			(sc->sc_pci? reg * 2: reg)))
    170  1.21     onoe #define CSR_READ_2(sc, reg)		\
    171  1.21     onoe 	le16toh(bus_space_read_2(sc->sc_iot, sc->sc_ioh,	\
    172  1.21     onoe 			(sc->sc_pci? reg * 2: reg)))
    173  1.21     onoe #define CSR_READ_1(sc, reg)		\
    174  1.21     onoe 	bus_space_read_1(sc->sc_iot, sc->sc_ioh,	\
    175  1.21     onoe 			(sc->sc_pci? reg * 2: reg))
    176  1.21     onoe 
    177  1.21     onoe #else
    178  1.21     onoe 
    179  1.21     onoe #define CSR_WRITE_4(sc, reg, val)	\
    180  1.21     onoe 	bus_space_write_4(sc->sc_iot, sc->sc_ioh,	\
    181  1.21     onoe 			(sc->sc_pci? reg * 2: reg) , val)
    182  1.21     onoe #define CSR_WRITE_2(sc, reg, val)	\
    183  1.21     onoe 	bus_space_write_2(sc->sc_iot, sc->sc_ioh,	\
    184  1.21     onoe 			(sc->sc_pci? reg * 2: reg), val)
    185  1.21     onoe #define CSR_WRITE_1(sc, reg, val)	\
    186  1.21     onoe 	bus_space_write_1(sc->sc_iot, sc->sc_ioh,	\
    187  1.21     onoe 			(sc->sc_pci? reg * 2: reg), val)
    188  1.21     onoe 
    189  1.21     onoe #define CSR_READ_4(sc, reg)		\
    190  1.21     onoe 	bus_space_read_4(sc->sc_iot, sc->sc_ioh,	\
    191  1.21     onoe 			(sc->sc_pci? reg * 2: reg))
    192  1.21     onoe #define CSR_READ_2(sc, reg)		\
    193  1.21     onoe 	bus_space_read_2(sc->sc_iot, sc->sc_ioh,	\
    194  1.21     onoe 			(sc->sc_pci? reg * 2: reg))
    195  1.21     onoe #define CSR_READ_1(sc, reg)		\
    196  1.21     onoe 	bus_space_read_1(sc->sc_iot, sc->sc_ioh,	\
    197  1.21     onoe 			(sc->sc_pci? reg * 2: reg))
    198  1.21     onoe #endif
    199  1.21     onoe 
    200  1.21     onoe #ifndef __BUS_SPACE_HAS_STREAM_METHODS
    201  1.21     onoe #define bus_space_write_stream_2	bus_space_write_2
    202  1.21     onoe #define bus_space_write_multi_stream_2	bus_space_write_multi_2
    203  1.21     onoe #define bus_space_read_stream_2		bus_space_read_2
    204  1.21     onoe #define bus_space_read_multi_stream_2		bus_space_read_multi_2
    205  1.21     onoe #endif
    206  1.21     onoe 
    207  1.21     onoe #define CSR_WRITE_STREAM_2(sc, reg, val)	\
    208  1.21     onoe 	bus_space_write_stream_2(sc->sc_iot, sc->sc_ioh,	\
    209  1.21     onoe 			(sc->sc_pci? reg * 2: reg), val)
    210  1.21     onoe #define CSR_WRITE_MULTI_STREAM_2(sc, reg, val, count)	\
    211  1.21     onoe 	bus_space_write_multi_stream_2(sc->sc_iot, sc->sc_ioh,	\
    212  1.21     onoe 			(sc->sc_pci? reg * 2: reg), val, count)
    213  1.21     onoe #define CSR_READ_STREAM_2(sc, reg)		\
    214  1.21     onoe 	bus_space_read_stream_2(sc->sc_iot, sc->sc_ioh,	\
    215  1.21     onoe 			(sc->sc_pci? reg * 2: reg))
    216  1.21     onoe #define CSR_READ_MULTI_STREAM_2(sc, reg, buf, count)		\
    217  1.21     onoe 	bus_space_read_multi_stream_2(sc->sc_iot, sc->sc_ioh,	\
    218  1.21     onoe 			(sc->sc_pci? reg * 2: reg), buf, count)
    219  1.21     onoe 
    220  1.21     onoe 
    221  1.21     onoe int	wi_attach(struct wi_softc *);
    222  1.21     onoe int	wi_detach(struct wi_softc *);
    223  1.21     onoe int	wi_activate(struct device *, enum devact);
    224  1.21     onoe int	wi_intr(void *arg);
    225  1.21     onoe void	wi_power(struct wi_softc *, int);
    226  1.21     onoe void	wi_shutdown(struct wi_softc *);
    227