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