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