2005-11-18 19:53:56 +03:00
|
|
|
/* $NetBSD: wivar.h,v 1.58 2005/11/18 16:53:56 skrll Exp $ */
|
1999-07-15 02:24:07 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1997, 1998, 1999
|
|
|
|
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Bill Paul.
|
|
|
|
* 4. Neither the name of the author nor the names of any co-contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2003-11-16 12:02:42 +03:00
|
|
|
/* Radio capture format for Prism. */
|
|
|
|
|
|
|
|
#define WI_RX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_FLAGS) | \
|
|
|
|
(1 << IEEE80211_RADIOTAP_RATE) | \
|
|
|
|
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
|
2004-08-06 02:57:32 +04:00
|
|
|
(1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) | \
|
|
|
|
(1 << IEEE80211_RADIOTAP_DB_ANTNOISE))
|
2003-11-16 12:02:42 +03:00
|
|
|
|
|
|
|
struct wi_rx_radiotap_header {
|
|
|
|
struct ieee80211_radiotap_header wr_ihdr;
|
|
|
|
u_int8_t wr_flags;
|
|
|
|
u_int8_t wr_rate;
|
|
|
|
u_int16_t wr_chan_freq;
|
|
|
|
u_int16_t wr_chan_flags;
|
|
|
|
int8_t wr_antsignal;
|
|
|
|
int8_t wr_antnoise;
|
|
|
|
} __attribute__((__packed__));
|
|
|
|
|
|
|
|
#define WI_TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_FLAGS) | \
|
|
|
|
(1 << IEEE80211_RADIOTAP_RATE) | \
|
|
|
|
(1 << IEEE80211_RADIOTAP_CHANNEL))
|
|
|
|
|
|
|
|
struct wi_tx_radiotap_header {
|
|
|
|
struct ieee80211_radiotap_header wt_ihdr;
|
|
|
|
u_int8_t wt_flags;
|
|
|
|
u_int8_t wt_rate;
|
|
|
|
u_int16_t wt_chan_freq;
|
|
|
|
u_int16_t wt_chan_flags;
|
|
|
|
} __attribute__((__packed__));
|
|
|
|
|
2004-02-10 03:47:41 +03:00
|
|
|
struct wi_rssdesc {
|
|
|
|
struct ieee80211_rssdesc rd_desc;
|
|
|
|
SLIST_ENTRY(wi_rssdesc) rd_next;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef SLIST_HEAD(,wi_rssdesc) wi_rssdescq_t;
|
|
|
|
|
1999-07-15 02:24:07 +04:00
|
|
|
/*
|
|
|
|
* FreeBSD driver ported to NetBSD by Bill Sommerfeld in the back of the
|
|
|
|
* Oslo IETF plenary meeting.
|
|
|
|
*/
|
|
|
|
struct wi_softc {
|
2001-05-06 07:26:38 +04:00
|
|
|
struct device sc_dev;
|
2005-06-22 10:14:51 +04:00
|
|
|
struct ethercom sc_ec;
|
2002-09-30 10:50:35 +04:00
|
|
|
struct ieee80211com sc_ic;
|
2005-06-25 07:56:53 +04:00
|
|
|
u_int32_t sc_ic_flags; /* backup of ic->ic_flags */
|
2002-09-30 10:50:35 +04:00
|
|
|
void *sc_ih; /* interrupt handler */
|
|
|
|
int (*sc_enable)(struct wi_softc *);
|
|
|
|
void (*sc_disable)(struct wi_softc *);
|
2003-03-27 07:53:52 +03:00
|
|
|
void (*sc_reset)(struct wi_softc *);
|
2002-09-30 10:50:35 +04:00
|
|
|
|
2003-10-13 12:07:21 +04:00
|
|
|
int (*sc_newstate)(struct ieee80211com *,
|
|
|
|
enum ieee80211_state, int);
|
2005-11-18 19:53:56 +03:00
|
|
|
void (*sc_set_tim)(struct ieee80211_node *, int);
|
2003-10-13 12:07:21 +04:00
|
|
|
|
2002-09-30 10:50:35 +04:00
|
|
|
int sc_attached;
|
|
|
|
int sc_enabled;
|
2003-05-20 05:29:35 +04:00
|
|
|
int sc_invalid;
|
2002-09-30 10:50:35 +04:00
|
|
|
int sc_firmware_type;
|
2002-04-05 04:54:51 +04:00
|
|
|
#define WI_NOTYPE 0
|
|
|
|
#define WI_LUCENT 1
|
|
|
|
#define WI_INTERSIL 2
|
|
|
|
#define WI_SYMBOL 3
|
2002-09-30 10:50:35 +04:00
|
|
|
int sc_pri_firmware_ver; /* Primary firm vers */
|
|
|
|
int sc_sta_firmware_ver; /* Station firm vers */
|
|
|
|
int sc_pci; /* attach to PCI-Bus */
|
2000-03-23 10:01:25 +03:00
|
|
|
|
2002-09-30 10:50:35 +04:00
|
|
|
bus_space_tag_t sc_iot; /* bus cookie */
|
|
|
|
bus_space_handle_t sc_ioh; /* bus i/o handle */
|
Jumbo patch, from David Young <dyoung@ojctech.com>, with small tweaks
by me:
* Speed up reading/writing buffers from the hardware by avoiding
slow forward seeks. In preparation to use the optimization, do
not read overlapping bytes. This is currently disabled, but can
be enabled with OPTIMIZE_RW_DATA.
* Hand 802.11 and Prism-specific frames to BPF. User can watch these
frames by specifying an alternate DLT to e.g. tcpdump(8).
* Add support for SIOC[SG]80211BSSID and SIOC[SG]80211CHANNEL.
* Issue join requests and track join/create state through link-status
notifications.
* Split wi_rxeof into separate routines for receiving Ethernet II,
802.11 data, and 802.11 management frames.
* Bug fix: Account for aligning m_data to a word boundary in the Rx
buffer size check.
* Bug fix: Check for LLC/SNAP even if the firmware tells us the frame
is Ethernet II, as the firmware sometimes gets this wrong.
* Process as many events as possible when we get an interrupt, using
a simple heuristic to avoid reprocessing an event (which can have
bad side-effects). Clamp the time spent in the interrupt handler
to 4ms.
* Redo the timeout loops to be consistent and less prone to error.
* Add delays to timeout loops which were missing them, so that a
fast CPU won't win the race.
* Borrow some timeout loop values from the linux-wlan-ng driver,
which seems to reflect a high level of clue (due to direct support
from Intersil).
* Get rid of silly wi_read_data(..., len + 2) idiom; simply round up
in wi_read_data() and wi_write_data(). Also, protect against a
length of 0.
* Name some frequently-used constants. Correct spelling. Other style nits.
* Bug fix: On Prism, set Create IBSS register to 0 *always*. The meaning
of Create IBSS == 1 is join an IBSS or *ESS*, and we do not want to
join an ESS, because that would put us in an inconsistent state. 0
is the right value for Prism.
* Bug fix: Clean up state at the top of wi_init(), in the event that
we don't reach the bottom.
* Simplify wi_start() by always providing an RFC1042-encoded 802.11
frame to the firmware.
* Larval powersave support for HostAP mode, enabled by WI_HOSTAP_POWERSAVE.
* Bug fix: Call wi_stop() from wi_shutdown().
* Bug fix: sync media options with HostAP mode in wi_sync_media().
* In wi_media_status(), inquire firmware for current media state if
media == auto. From FreeBSD.
* Clean up the way buffer lengths are computed by using pointer
arithmetic rather than magic constants.
* Swap the order of comparisons in addr_cmp() for speed.
* Bug fix: Send ReAssoc Response instead of Assoc Response to a
ReAssoc Request.
* Bug fix: Copy SSID using the correct size.
* Give more meaningful names to offsets in a wi_frame.
* Bug fix: Assign the right values to the named constants for
Rx frame encoding.
* Get rid of useless SNAP constants.
2002-09-23 18:31:27 +04:00
|
|
|
|
2002-09-30 10:50:35 +04:00
|
|
|
caddr_t sc_drvbpf;
|
|
|
|
int sc_flags;
|
|
|
|
int sc_bap_id;
|
|
|
|
int sc_bap_off;
|
|
|
|
|
2003-05-13 10:33:40 +04:00
|
|
|
u_int16_t sc_portnum;
|
|
|
|
|
2003-07-06 11:15:55 +04:00
|
|
|
/* RSSI interpretation */
|
|
|
|
u_int16_t sc_dbm_offset; /* dBm ~ RSSI - sc_dbm_offset */
|
2002-09-30 10:50:35 +04:00
|
|
|
u_int16_t sc_max_datalen;
|
2002-11-16 09:02:53 +03:00
|
|
|
u_int16_t sc_frag_thresh;
|
2002-09-30 10:50:35 +04:00
|
|
|
u_int16_t sc_rts_thresh;
|
|
|
|
u_int16_t sc_system_scale;
|
|
|
|
u_int16_t sc_tx_rate;
|
|
|
|
u_int16_t sc_cnfauthmode;
|
|
|
|
u_int16_t sc_roaming_mode;
|
|
|
|
u_int16_t sc_microwave_oven;
|
|
|
|
|
|
|
|
int sc_nodelen;
|
|
|
|
char sc_nodename[IEEE80211_NWID_LEN];
|
|
|
|
|
|
|
|
int sc_buflen;
|
|
|
|
#define WI_NTXBUF 3
|
2003-12-07 08:44:49 +03:00
|
|
|
#define WI_NTXRSS 10
|
2004-07-23 00:39:15 +04:00
|
|
|
struct {
|
2003-12-07 08:44:49 +03:00
|
|
|
int d_fid;
|
2002-09-30 10:50:35 +04:00
|
|
|
} sc_txd[WI_NTXBUF];
|
2004-07-23 00:39:15 +04:00
|
|
|
int sc_txalloc; /* next FID to allocate */
|
|
|
|
int sc_txalloced; /* FIDs currently allocated */
|
|
|
|
int sc_txqueue; /* next FID to queue */
|
|
|
|
int sc_txqueued; /* FIDs currently queued */
|
2004-07-23 01:56:58 +04:00
|
|
|
int sc_txstart; /* next FID to start */
|
|
|
|
int sc_txstarted; /* FIDs currently started */
|
2004-12-13 20:55:28 +03:00
|
|
|
int sc_txcmds;
|
|
|
|
|
|
|
|
int sc_status;
|
|
|
|
|
2004-02-10 03:47:41 +03:00
|
|
|
struct wi_rssdesc sc_rssd[WI_NTXRSS];
|
|
|
|
wi_rssdescq_t sc_rssdfree;
|
2002-09-30 10:50:35 +04:00
|
|
|
int sc_tx_timer;
|
|
|
|
int sc_scan_timer;
|
2003-01-01 05:06:47 +03:00
|
|
|
int sc_syn_timer;
|
2002-09-30 10:50:35 +04:00
|
|
|
|
|
|
|
struct wi_counters sc_stats;
|
|
|
|
u_int16_t sc_ibss_port;
|
|
|
|
|
|
|
|
struct wi_apinfo sc_aps[MAXAPINFO];
|
|
|
|
int sc_naps;
|
2003-01-01 05:06:47 +03:00
|
|
|
|
2004-09-28 04:42:11 +04:00
|
|
|
struct timeval sc_last_syn;
|
2003-01-01 05:06:47 +03:00
|
|
|
int sc_false_syns;
|
2003-12-07 08:44:49 +03:00
|
|
|
int sc_alt_retry;
|
2003-01-09 11:49:39 +03:00
|
|
|
|
2003-11-16 12:02:42 +03:00
|
|
|
union {
|
|
|
|
struct wi_rx_radiotap_header tap;
|
|
|
|
u_int8_t pad[64];
|
|
|
|
} sc_rxtapu;
|
|
|
|
union {
|
|
|
|
struct wi_tx_radiotap_header tap;
|
|
|
|
u_int8_t pad[64];
|
|
|
|
} sc_txtapu;
|
2003-01-09 11:49:39 +03:00
|
|
|
u_int16_t sc_txbuf[IEEE80211_MAX_LEN/2];
|
2003-12-07 08:44:49 +03:00
|
|
|
/* number of transmissions pending at each data rate */
|
|
|
|
u_int8_t sc_txpending[IEEE80211_RATE_MAXSIZE];
|
|
|
|
struct callout sc_rssadapt_ch;
|
1999-07-15 02:24:07 +04:00
|
|
|
};
|
2001-05-06 07:26:38 +04:00
|
|
|
|
2005-06-22 10:14:51 +04:00
|
|
|
#define sc_if sc_ec.ec_if
|
2003-11-16 12:02:42 +03:00
|
|
|
#define sc_rxtap sc_rxtapu.tap
|
|
|
|
#define sc_txtap sc_txtapu.tap
|
|
|
|
|
2003-12-07 08:44:49 +03:00
|
|
|
struct wi_node {
|
|
|
|
struct ieee80211_node wn_node;
|
|
|
|
struct ieee80211_rssadapt wn_rssadapt;
|
|
|
|
};
|
|
|
|
|
2004-09-28 04:42:11 +04:00
|
|
|
/* maximum false change-of-BSSID indications per second */
|
2005-02-27 03:26:58 +03:00
|
|
|
#define WI_MAX_FALSE_SYNS 10
|
2003-01-01 05:06:47 +03:00
|
|
|
|
2003-10-16 14:38:07 +04:00
|
|
|
#define WI_PRISM_DBM_OFFSET 100 /* XXX */
|
2003-07-06 11:15:55 +04:00
|
|
|
|
|
|
|
#define WI_LUCENT_DBM_OFFSET 149
|
|
|
|
|
2002-09-30 10:50:35 +04:00
|
|
|
#define WI_SCAN_INQWAIT 3 /* wait sec before inquire */
|
|
|
|
#define WI_SCAN_WAIT 5 /* maximum scan wait */
|
2002-09-30 10:29:29 +04:00
|
|
|
|
2002-08-11 05:30:28 +04:00
|
|
|
/* Values for wi_flags. */
|
|
|
|
#define WI_FLAGS_ATTACHED 0x0001
|
|
|
|
#define WI_FLAGS_INITIALIZED 0x0002
|
2002-10-04 08:23:20 +04:00
|
|
|
#define WI_FLAGS_OUTRANGE 0x0004
|
2004-02-10 03:59:38 +03:00
|
|
|
#define WI_FLAGS_RSSADAPTSTA 0x0008
|
2002-09-30 10:50:35 +04:00
|
|
|
#define WI_FLAGS_HAS_MOR 0x0010
|
|
|
|
#define WI_FLAGS_HAS_ROAMING 0x0020
|
|
|
|
#define WI_FLAGS_HAS_DIVERSITY 0x0040
|
|
|
|
#define WI_FLAGS_HAS_SYSSCALE 0x0080
|
|
|
|
#define WI_FLAGS_BUG_AUTOINC 0x0100
|
2002-11-18 18:10:22 +03:00
|
|
|
#define WI_FLAGS_HAS_FRAGTHR 0x0200
|
2002-12-27 10:54:35 +03:00
|
|
|
#define WI_FLAGS_HAS_DBMADJUST 0x0400
|
2005-06-25 07:56:53 +04:00
|
|
|
#define WI_FLAGS_WEP_VALID 0x0800
|
2002-08-11 05:30:28 +04:00
|
|
|
|
2002-04-04 11:06:16 +04:00
|
|
|
struct wi_card_ident {
|
|
|
|
u_int16_t card_id;
|
2005-05-30 08:43:46 +04:00
|
|
|
const char *card_name;
|
2002-04-04 11:06:16 +04:00
|
|
|
u_int8_t firm_type;
|
|
|
|
};
|
|
|
|
|
2002-09-30 10:50:35 +04:00
|
|
|
/*
|
|
|
|
* register space access macros
|
|
|
|
*/
|
|
|
|
#ifdef WI_AT_BIGENDIAN_BUS_HACK
|
|
|
|
/*
|
|
|
|
* XXX - ugly hack for sparc bus_space_* macro deficiencies:
|
|
|
|
* assume the bus we are accessing is big endian.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define CSR_WRITE_4(sc, reg, val) \
|
|
|
|
bus_space_write_4(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg) , htole32(val))
|
|
|
|
#define CSR_WRITE_2(sc, reg, val) \
|
|
|
|
bus_space_write_2(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg), htole16(val))
|
|
|
|
#define CSR_WRITE_1(sc, reg, val) \
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg), val)
|
|
|
|
|
|
|
|
#define CSR_READ_4(sc, reg) \
|
|
|
|
le32toh(bus_space_read_4(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg)))
|
|
|
|
#define CSR_READ_2(sc, reg) \
|
|
|
|
le16toh(bus_space_read_2(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg)))
|
|
|
|
#define CSR_READ_1(sc, reg) \
|
|
|
|
bus_space_read_1(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg))
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define CSR_WRITE_4(sc, reg, val) \
|
|
|
|
bus_space_write_4(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg) , val)
|
|
|
|
#define CSR_WRITE_2(sc, reg, val) \
|
|
|
|
bus_space_write_2(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg), val)
|
|
|
|
#define CSR_WRITE_1(sc, reg, val) \
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg), val)
|
|
|
|
|
|
|
|
#define CSR_READ_4(sc, reg) \
|
|
|
|
bus_space_read_4(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg))
|
|
|
|
#define CSR_READ_2(sc, reg) \
|
|
|
|
bus_space_read_2(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg))
|
|
|
|
#define CSR_READ_1(sc, reg) \
|
|
|
|
bus_space_read_1(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __BUS_SPACE_HAS_STREAM_METHODS
|
|
|
|
#define bus_space_write_stream_2 bus_space_write_2
|
|
|
|
#define bus_space_write_multi_stream_2 bus_space_write_multi_2
|
|
|
|
#define bus_space_read_stream_2 bus_space_read_2
|
|
|
|
#define bus_space_read_multi_stream_2 bus_space_read_multi_2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define CSR_WRITE_STREAM_2(sc, reg, val) \
|
|
|
|
bus_space_write_stream_2(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg), val)
|
|
|
|
#define CSR_WRITE_MULTI_STREAM_2(sc, reg, val, count) \
|
|
|
|
bus_space_write_multi_stream_2(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg), val, count)
|
|
|
|
#define CSR_READ_STREAM_2(sc, reg) \
|
|
|
|
bus_space_read_stream_2(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg))
|
|
|
|
#define CSR_READ_MULTI_STREAM_2(sc, reg, buf, count) \
|
|
|
|
bus_space_read_multi_stream_2(sc->sc_iot, sc->sc_ioh, \
|
|
|
|
(sc->sc_pci? reg * 2: reg), buf, count)
|
|
|
|
|
|
|
|
|
2004-08-07 21:12:44 +04:00
|
|
|
int wi_attach(struct wi_softc *, const u_int8_t *);
|
2002-09-30 10:50:35 +04:00
|
|
|
int wi_detach(struct wi_softc *);
|
|
|
|
int wi_activate(struct device *, enum devact);
|
|
|
|
int wi_intr(void *arg);
|
|
|
|
void wi_power(struct wi_softc *, int);
|
|
|
|
void wi_shutdown(struct wi_softc *);
|