Home | History | Annotate | Line # | Download | only in ic
wivar.h revision 1.34.2.6
      1  1.34.2.6    skrll /*	$NetBSD: wivar.h,v 1.34.2.6 2005/11/10 14:04:16 skrll 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.34.2.1    skrll /* Radio capture format for Prism. */
     36  1.34.2.1    skrll 
     37  1.34.2.1    skrll #define WI_RX_RADIOTAP_PRESENT	((1 << IEEE80211_RADIOTAP_FLAGS) | \
     38  1.34.2.1    skrll 				 (1 << IEEE80211_RADIOTAP_RATE) | \
     39  1.34.2.1    skrll 				 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
     40  1.34.2.2    skrll 				 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) | \
     41  1.34.2.2    skrll 				 (1 << IEEE80211_RADIOTAP_DB_ANTNOISE))
     42  1.34.2.1    skrll 
     43  1.34.2.1    skrll struct wi_rx_radiotap_header {
     44  1.34.2.1    skrll 	struct ieee80211_radiotap_header	wr_ihdr;
     45  1.34.2.1    skrll 	u_int8_t				wr_flags;
     46  1.34.2.1    skrll 	u_int8_t				wr_rate;
     47  1.34.2.1    skrll 	u_int16_t				wr_chan_freq;
     48  1.34.2.1    skrll 	u_int16_t				wr_chan_flags;
     49  1.34.2.1    skrll 	int8_t					wr_antsignal;
     50  1.34.2.1    skrll 	int8_t					wr_antnoise;
     51  1.34.2.1    skrll } __attribute__((__packed__));
     52  1.34.2.1    skrll 
     53  1.34.2.1    skrll #define WI_TX_RADIOTAP_PRESENT	((1 << IEEE80211_RADIOTAP_FLAGS) | \
     54  1.34.2.1    skrll 				 (1 << IEEE80211_RADIOTAP_RATE) | \
     55  1.34.2.1    skrll 				 (1 << IEEE80211_RADIOTAP_CHANNEL))
     56  1.34.2.1    skrll 
     57  1.34.2.1    skrll struct wi_tx_radiotap_header {
     58  1.34.2.1    skrll 	struct ieee80211_radiotap_header	wt_ihdr;
     59  1.34.2.1    skrll 	u_int8_t				wt_flags;
     60  1.34.2.1    skrll 	u_int8_t				wt_rate;
     61  1.34.2.1    skrll 	u_int16_t				wt_chan_freq;
     62  1.34.2.1    skrll 	u_int16_t				wt_chan_flags;
     63  1.34.2.1    skrll } __attribute__((__packed__));
     64  1.34.2.1    skrll 
     65  1.34.2.1    skrll struct wi_rssdesc {
     66  1.34.2.1    skrll 	struct ieee80211_rssdesc	rd_desc;
     67  1.34.2.1    skrll 	SLIST_ENTRY(wi_rssdesc)		rd_next;
     68  1.34.2.1    skrll };
     69  1.34.2.1    skrll 
     70  1.34.2.1    skrll typedef SLIST_HEAD(,wi_rssdesc) wi_rssdescq_t;
     71  1.34.2.1    skrll 
     72       1.1   ichiro /*
     73       1.1   ichiro  * FreeBSD driver ported to NetBSD by Bill Sommerfeld in the back of the
     74       1.1   ichiro  * Oslo IETF plenary meeting.
     75       1.1   ichiro  */
     76       1.1   ichiro struct wi_softc	{
     77       1.1   ichiro 	struct device		sc_dev;
     78  1.34.2.6    skrll 	struct ethercom		sc_ec;
     79      1.21     onoe 	struct ieee80211com	sc_ic;
     80  1.34.2.6    skrll 	u_int32_t		sc_ic_flags;	/* backup of ic->ic_flags */
     81      1.21     onoe 	void			*sc_ih;		/* interrupt handler */
     82      1.21     onoe 	int			(*sc_enable)(struct wi_softc *);
     83      1.21     onoe 	void			(*sc_disable)(struct wi_softc *);
     84      1.30   dyoung 	void			(*sc_reset)(struct wi_softc *);
     85      1.21     onoe 
     86  1.34.2.1    skrll 	int			(*sc_newstate)(struct ieee80211com *,
     87  1.34.2.1    skrll 				    enum ieee80211_state, int);
     88  1.34.2.6    skrll 	void			(*sc_set_tim)(struct ieee80211com *,
     89  1.34.2.6    skrll 				    struct ieee80211_node *, int);
     90  1.34.2.1    skrll 
     91      1.21     onoe 	int			sc_attached;
     92      1.21     onoe 	int			sc_enabled;
     93      1.34   dyoung 	int			sc_invalid;
     94      1.21     onoe 	int			sc_firmware_type;
     95      1.14   ichiro #define	WI_NOTYPE	0
     96      1.14   ichiro #define	WI_LUCENT	1
     97      1.14   ichiro #define	WI_INTERSIL	2
     98      1.14   ichiro #define	WI_SYMBOL	3
     99      1.21     onoe 	int			sc_pri_firmware_ver;	/* Primary firm vers */
    100      1.21     onoe 	int			sc_sta_firmware_ver;	/* Station firm vers */
    101      1.21     onoe 	int			sc_pci;			/* attach to PCI-Bus */
    102      1.21     onoe 
    103      1.21     onoe 	bus_space_tag_t		sc_iot;			/* bus cookie */
    104      1.21     onoe 	bus_space_handle_t	sc_ioh;			/* bus i/o handle */
    105      1.19  thorpej 
    106      1.21     onoe 	caddr_t			sc_drvbpf;
    107      1.21     onoe 	int			sc_flags;
    108      1.21     onoe 	int			sc_bap_id;
    109      1.21     onoe 	int			sc_bap_off;
    110      1.31   dyoung 
    111      1.31   dyoung 	u_int16_t		sc_portnum;
    112      1.21     onoe 
    113  1.34.2.1    skrll 	/* RSSI interpretation */
    114  1.34.2.1    skrll 	u_int16_t		sc_dbm_offset;	/* dBm ~ RSSI - sc_dbm_offset */
    115      1.21     onoe 	u_int16_t		sc_max_datalen;
    116      1.24   dyoung 	u_int16_t		sc_frag_thresh;
    117      1.21     onoe 	u_int16_t		sc_rts_thresh;
    118      1.21     onoe 	u_int16_t		sc_system_scale;
    119      1.21     onoe 	u_int16_t		sc_tx_rate;
    120      1.21     onoe 	u_int16_t		sc_cnfauthmode;
    121      1.21     onoe 	u_int16_t		sc_roaming_mode;
    122      1.21     onoe 	u_int16_t		sc_microwave_oven;
    123      1.21     onoe 
    124      1.21     onoe 	int			sc_nodelen;
    125      1.21     onoe 	char			sc_nodename[IEEE80211_NWID_LEN];
    126      1.21     onoe 
    127      1.21     onoe 	int			sc_buflen;
    128      1.21     onoe #define	WI_NTXBUF	3
    129  1.34.2.1    skrll #define	WI_NTXRSS	10
    130  1.34.2.1    skrll 	struct {
    131  1.34.2.1    skrll 		int				d_fid;
    132      1.21     onoe 	}			sc_txd[WI_NTXBUF];
    133  1.34.2.1    skrll 	int			sc_txalloc;	/* next FID to allocate */
    134  1.34.2.1    skrll 	int			sc_txalloced;	/* FIDs currently allocated */
    135  1.34.2.1    skrll 	int			sc_txqueue;	/* next FID to queue */
    136  1.34.2.1    skrll 	int			sc_txqueued;	/* FIDs currently queued */
    137  1.34.2.1    skrll 	int			sc_txstart;	/* next FID to start */
    138  1.34.2.1    skrll 	int			sc_txstarted;	/* FIDs currently started */
    139  1.34.2.4    skrll 	int			sc_txcmds;
    140  1.34.2.4    skrll 
    141  1.34.2.4    skrll 	int			sc_status;
    142  1.34.2.4    skrll 
    143  1.34.2.1    skrll 	struct wi_rssdesc 	sc_rssd[WI_NTXRSS];
    144  1.34.2.1    skrll 	wi_rssdescq_t		sc_rssdfree;
    145      1.21     onoe 	int			sc_tx_timer;
    146      1.21     onoe 	int			sc_scan_timer;
    147      1.27   dyoung 	int			sc_syn_timer;
    148      1.21     onoe 
    149      1.21     onoe 	struct wi_counters	sc_stats;
    150      1.21     onoe 	u_int16_t		sc_ibss_port;
    151      1.19  thorpej 
    152      1.21     onoe 	struct wi_apinfo	sc_aps[MAXAPINFO];
    153      1.21     onoe 	int 			sc_naps;
    154      1.27   dyoung 
    155  1.34.2.3    skrll 	struct timeval		sc_last_syn;
    156      1.27   dyoung 	int			sc_false_syns;
    157  1.34.2.1    skrll 	int			sc_alt_retry;
    158      1.28   dyoung 
    159  1.34.2.1    skrll 	union {
    160  1.34.2.1    skrll 		struct wi_rx_radiotap_header	tap;
    161  1.34.2.1    skrll 		u_int8_t			pad[64];
    162  1.34.2.1    skrll 	} sc_rxtapu;
    163  1.34.2.1    skrll 	union {
    164  1.34.2.1    skrll 		struct wi_tx_radiotap_header	tap;
    165  1.34.2.1    skrll 		u_int8_t			pad[64];
    166  1.34.2.1    skrll 	} sc_txtapu;
    167      1.28   dyoung 	u_int16_t		sc_txbuf[IEEE80211_MAX_LEN/2];
    168  1.34.2.1    skrll 	/* number of transmissions pending at each data rate */
    169  1.34.2.1    skrll 	u_int8_t		sc_txpending[IEEE80211_RATE_MAXSIZE];
    170  1.34.2.1    skrll 	struct callout		sc_rssadapt_ch;
    171      1.12   ichiro };
    172      1.20     onoe 
    173  1.34.2.6    skrll #define	sc_if		sc_ec.ec_if
    174  1.34.2.1    skrll #define sc_rxtap	sc_rxtapu.tap
    175  1.34.2.1    skrll #define sc_txtap	sc_txtapu.tap
    176  1.34.2.1    skrll 
    177  1.34.2.1    skrll struct wi_node {
    178  1.34.2.1    skrll 	struct ieee80211_node		wn_node;
    179  1.34.2.1    skrll 	struct ieee80211_rssadapt	wn_rssadapt;
    180  1.34.2.1    skrll };
    181  1.34.2.1    skrll 
    182  1.34.2.3    skrll /* maximum false change-of-BSSID indications per second */
    183  1.34.2.5    skrll #define	WI_MAX_FALSE_SYNS		10
    184      1.21     onoe 
    185  1.34.2.1    skrll #define	WI_PRISM_DBM_OFFSET	100	/* XXX */
    186  1.34.2.1    skrll 
    187  1.34.2.1    skrll #define	WI_LUCENT_DBM_OFFSET	149
    188  1.34.2.1    skrll 
    189      1.21     onoe #define	WI_SCAN_INQWAIT			3	/* wait sec before inquire */
    190      1.21     onoe #define	WI_SCAN_WAIT			5	/* maximum scan wait */
    191      1.16  thorpej 
    192      1.16  thorpej /* Values for wi_flags. */
    193      1.16  thorpej #define	WI_FLAGS_ATTACHED		0x0001
    194      1.16  thorpej #define	WI_FLAGS_INITIALIZED		0x0002
    195      1.23     onoe #define	WI_FLAGS_OUTRANGE		0x0004
    196  1.34.2.1    skrll #define	WI_FLAGS_RSSADAPTSTA		0x0008
    197      1.21     onoe #define	WI_FLAGS_HAS_MOR		0x0010
    198      1.21     onoe #define	WI_FLAGS_HAS_ROAMING		0x0020
    199      1.21     onoe #define	WI_FLAGS_HAS_DIVERSITY		0x0040
    200      1.21     onoe #define	WI_FLAGS_HAS_SYSSCALE		0x0080
    201      1.21     onoe #define	WI_FLAGS_BUG_AUTOINC		0x0100
    202      1.25   dyoung #define	WI_FLAGS_HAS_FRAGTHR		0x0200
    203      1.26   dyoung #define	WI_FLAGS_HAS_DBMADJUST		0x0400
    204  1.34.2.6    skrll #define	WI_FLAGS_WEP_VALID		0x0800
    205      1.12   ichiro 
    206      1.12   ichiro struct wi_card_ident {
    207      1.12   ichiro 	u_int16_t	card_id;
    208  1.34.2.6    skrll 	const char	*card_name;
    209      1.12   ichiro 	u_int8_t	firm_type;
    210       1.1   ichiro };
    211       1.1   ichiro 
    212      1.21     onoe /*
    213      1.21     onoe  * register space access macros
    214      1.21     onoe  */
    215      1.21     onoe #ifdef WI_AT_BIGENDIAN_BUS_HACK
    216      1.21     onoe 	/*
    217      1.21     onoe 	 * XXX - ugly hack for sparc bus_space_* macro deficiencies:
    218      1.21     onoe 	 *       assume the bus we are accessing is big endian.
    219      1.21     onoe 	 */
    220      1.21     onoe 
    221      1.21     onoe #define CSR_WRITE_4(sc, reg, val)	\
    222      1.21     onoe 	bus_space_write_4(sc->sc_iot, sc->sc_ioh,	\
    223      1.21     onoe 			(sc->sc_pci? reg * 2: reg) , htole32(val))
    224      1.21     onoe #define CSR_WRITE_2(sc, reg, val)	\
    225      1.21     onoe 	bus_space_write_2(sc->sc_iot, sc->sc_ioh,	\
    226      1.21     onoe 			(sc->sc_pci? reg * 2: reg), htole16(val))
    227      1.21     onoe #define CSR_WRITE_1(sc, reg, val)	\
    228      1.21     onoe 	bus_space_write_1(sc->sc_iot, sc->sc_ioh,	\
    229      1.21     onoe 			(sc->sc_pci? reg * 2: reg), val)
    230      1.21     onoe 
    231      1.21     onoe #define CSR_READ_4(sc, reg)		\
    232      1.21     onoe 	le32toh(bus_space_read_4(sc->sc_iot, sc->sc_ioh,	\
    233      1.21     onoe 			(sc->sc_pci? reg * 2: reg)))
    234      1.21     onoe #define CSR_READ_2(sc, reg)		\
    235      1.21     onoe 	le16toh(bus_space_read_2(sc->sc_iot, sc->sc_ioh,	\
    236      1.21     onoe 			(sc->sc_pci? reg * 2: reg)))
    237      1.21     onoe #define CSR_READ_1(sc, reg)		\
    238      1.21     onoe 	bus_space_read_1(sc->sc_iot, sc->sc_ioh,	\
    239      1.21     onoe 			(sc->sc_pci? reg * 2: reg))
    240      1.21     onoe 
    241      1.21     onoe #else
    242      1.21     onoe 
    243      1.21     onoe #define CSR_WRITE_4(sc, reg, val)	\
    244      1.21     onoe 	bus_space_write_4(sc->sc_iot, sc->sc_ioh,	\
    245      1.21     onoe 			(sc->sc_pci? reg * 2: reg) , val)
    246      1.21     onoe #define CSR_WRITE_2(sc, reg, val)	\
    247      1.21     onoe 	bus_space_write_2(sc->sc_iot, sc->sc_ioh,	\
    248      1.21     onoe 			(sc->sc_pci? reg * 2: reg), val)
    249      1.21     onoe #define CSR_WRITE_1(sc, reg, val)	\
    250      1.21     onoe 	bus_space_write_1(sc->sc_iot, sc->sc_ioh,	\
    251      1.21     onoe 			(sc->sc_pci? reg * 2: reg), val)
    252      1.21     onoe 
    253      1.21     onoe #define CSR_READ_4(sc, reg)		\
    254      1.21     onoe 	bus_space_read_4(sc->sc_iot, sc->sc_ioh,	\
    255      1.21     onoe 			(sc->sc_pci? reg * 2: reg))
    256      1.21     onoe #define CSR_READ_2(sc, reg)		\
    257      1.21     onoe 	bus_space_read_2(sc->sc_iot, sc->sc_ioh,	\
    258      1.21     onoe 			(sc->sc_pci? reg * 2: reg))
    259      1.21     onoe #define CSR_READ_1(sc, reg)		\
    260      1.21     onoe 	bus_space_read_1(sc->sc_iot, sc->sc_ioh,	\
    261      1.21     onoe 			(sc->sc_pci? reg * 2: reg))
    262      1.21     onoe #endif
    263      1.21     onoe 
    264      1.21     onoe #ifndef __BUS_SPACE_HAS_STREAM_METHODS
    265      1.21     onoe #define bus_space_write_stream_2	bus_space_write_2
    266      1.21     onoe #define bus_space_write_multi_stream_2	bus_space_write_multi_2
    267      1.21     onoe #define bus_space_read_stream_2		bus_space_read_2
    268      1.21     onoe #define bus_space_read_multi_stream_2		bus_space_read_multi_2
    269      1.21     onoe #endif
    270      1.21     onoe 
    271      1.21     onoe #define CSR_WRITE_STREAM_2(sc, reg, val)	\
    272      1.21     onoe 	bus_space_write_stream_2(sc->sc_iot, sc->sc_ioh,	\
    273      1.21     onoe 			(sc->sc_pci? reg * 2: reg), val)
    274      1.21     onoe #define CSR_WRITE_MULTI_STREAM_2(sc, reg, val, count)	\
    275      1.21     onoe 	bus_space_write_multi_stream_2(sc->sc_iot, sc->sc_ioh,	\
    276      1.21     onoe 			(sc->sc_pci? reg * 2: reg), val, count)
    277      1.21     onoe #define CSR_READ_STREAM_2(sc, reg)		\
    278      1.21     onoe 	bus_space_read_stream_2(sc->sc_iot, sc->sc_ioh,	\
    279      1.21     onoe 			(sc->sc_pci? reg * 2: reg))
    280      1.21     onoe #define CSR_READ_MULTI_STREAM_2(sc, reg, buf, count)		\
    281      1.21     onoe 	bus_space_read_multi_stream_2(sc->sc_iot, sc->sc_ioh,	\
    282      1.21     onoe 			(sc->sc_pci? reg * 2: reg), buf, count)
    283      1.21     onoe 
    284      1.21     onoe 
    285  1.34.2.2    skrll int	wi_attach(struct wi_softc *, const u_int8_t *);
    286      1.21     onoe int	wi_detach(struct wi_softc *);
    287      1.21     onoe int	wi_activate(struct device *, enum devact);
    288      1.21     onoe int	wi_intr(void *arg);
    289      1.21     onoe void	wi_power(struct wi_softc *, int);
    290      1.21     onoe void	wi_shutdown(struct wi_softc *);
    291