if_urtwvar.h revision 193045
1145510Sdarrenr/* $FreeBSD: head/sys/dev/usb/wlan/if_urtwvar.h 193045 2009-05-29 18:46:57Z thompsa $ */ 2145510Sdarrenr 322514Sdarrenr/*- 453024Sguido * Copyright (c) 2008 Weongyo Jeong <weongyo@FreeBSD.org> 522514Sdarrenr * 680486Sdarrenr * Permission to use, copy, modify, and distribute this software for any 7145510Sdarrenr * purpose with or without fee is hereby granted, provided that the above 822514Sdarrenr * copyright notice and this permission notice appear in all copies. 931183Speter * 1031183Speter * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11145510Sdarrenr * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1222514Sdarrenr * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1322514Sdarrenr * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1422514Sdarrenr * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1522514Sdarrenr * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1622514Sdarrenr * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1722514Sdarrenr */ 1822514Sdarrenr 1922514Sdarrenrenum { 2022514Sdarrenr URTW_8187B_BULK_RX, 2122514Sdarrenr URTW_8187B_BULK_TX_BE, 2222514Sdarrenr URTW_8187B_BULK_TX_BK, 2322514Sdarrenr URTW_8187B_BULK_TX_VI, 2422514Sdarrenr URTW_8187B_BULK_TX_VO, 2522514Sdarrenr URTW_8187B_BULK_TX_EP12, 2622514Sdarrenr URTW_8187B_N_XFERS = 6 2722514Sdarrenr}; 2822514Sdarrenr 2922514Sdarrenrenum { 3022514Sdarrenr URTW_8187L_BULK_RX, 3122514Sdarrenr URTW_8187L_BULK_TX_LOW, 3222514Sdarrenr URTW_8187L_BULK_TX_NORMAL, 3322514Sdarrenr URTW_8187L_N_XFERS = 3 3422514Sdarrenr}; 3522514Sdarrenr 3622514Sdarrenr/* XXX no definition at net80211? */ 3722514Sdarrenr#define URTW_MAX_CHANNELS 15 3822514Sdarrenr 3922514Sdarrenrstruct urtw_data { 4022514Sdarrenr struct urtw_softc *sc; 4122514Sdarrenr uint8_t *buf; 4222514Sdarrenr uint16_t buflen; 4322514Sdarrenr struct mbuf *m; 4422514Sdarrenr struct ieee80211_node *ni; /* NB: tx only */ 4522514Sdarrenr STAILQ_ENTRY(urtw_data) next; 4622514Sdarrenr}; 4722514Sdarrenrtypedef STAILQ_HEAD(, urtw_data) urtw_datahead; 4831183Speter 4922514Sdarrenr/* XXX not correct.. */ 5022514Sdarrenr#define URTW_MIN_RXBUFSZ \ 5124583Sdarrenr (sizeof(struct ieee80211_frame_min)) 5222514Sdarrenr 5322514Sdarrenr#define URTW_RX_DATA_LIST_COUNT 4 5422514Sdarrenr#define URTW_TX_DATA_LIST_COUNT 16 5522514Sdarrenr#define URTW_RX_MAXSIZE 0x9c4 5622514Sdarrenr#define URTW_TX_MAXSIZE 0x9c4 5722514Sdarrenr 5822514Sdarrenrstruct urtw_rx_radiotap_header { 5922514Sdarrenr struct ieee80211_radiotap_header wr_ihdr; 6022514Sdarrenr uint8_t wr_flags; 6122514Sdarrenr uint16_t wr_chan_freq; 6222514Sdarrenr uint16_t wr_chan_flags; 6322514Sdarrenr int8_t wr_dbm_antsignal; 6422514Sdarrenr} __packed; 6522514Sdarrenr 6622514Sdarrenr#define URTW_RX_RADIOTAP_PRESENT \ 6722514Sdarrenr ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 6822514Sdarrenr (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 6922514Sdarrenr (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL)) 7022514Sdarrenr 7122514Sdarrenrstruct urtw_tx_radiotap_header { 7222514Sdarrenr struct ieee80211_radiotap_header wt_ihdr; 7322514Sdarrenr uint8_t wt_flags; 7422514Sdarrenr uint16_t wt_chan_freq; 7522514Sdarrenr uint16_t wt_chan_flags; 7622514Sdarrenr} __packed; 7722514Sdarrenr 7822514Sdarrenr#define URTW_TX_RADIOTAP_PRESENT \ 7922514Sdarrenr ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 8022514Sdarrenr (1 << IEEE80211_RADIOTAP_CHANNEL)) 8122514Sdarrenr 8222514Sdarrenrstruct urtw_vap { 8322514Sdarrenr struct ieee80211vap vap; 8422514Sdarrenr int (*newstate)(struct ieee80211vap *, 8522514Sdarrenr enum ieee80211_state, int); 8622514Sdarrenr}; 8722514Sdarrenr#define URTW_VAP(vap) ((struct urtw_vap *)(vap)) 8822514Sdarrenr 8922514Sdarrenrstruct urtw_softc { 9022514Sdarrenr struct ifnet *sc_ifp; 9122514Sdarrenr device_t sc_dev; 9222514Sdarrenr struct usb_device *sc_udev; 9322514Sdarrenr struct mtx sc_mtx; 9422514Sdarrenr 9522514Sdarrenr int sc_debug; 9622514Sdarrenr int sc_if_flags; 9722514Sdarrenr int sc_flags; 9822514Sdarrenr#define URTW_INIT_ONCE (1 << 1) 9922514Sdarrenr#define URTW_RTL8187B (1 << 2) 10022514Sdarrenr#define URTW_RTL8187B_REV_B (1 << 3) 10122514Sdarrenr#define URTW_RTL8187B_REV_D (1 << 4) 10222514Sdarrenr#define URTW_RTL8187B_REV_E (1 << 5) 10322514Sdarrenr enum ieee80211_state sc_state; 10422514Sdarrenr 10522514Sdarrenr int sc_epromtype; 10622514Sdarrenr#define URTW_EEPROM_93C46 0 10722514Sdarrenr#define URTW_EEPROM_93C56 1 10822514Sdarrenr uint8_t sc_crcmon; 10922514Sdarrenr uint8_t sc_bssid[IEEE80211_ADDR_LEN]; 11024583Sdarrenr 11122514Sdarrenr struct ieee80211_channel *sc_curchan; 11222514Sdarrenr 11322514Sdarrenr /* for RF */ 11422514Sdarrenr usb_error_t (*sc_rf_init)(struct urtw_softc *); 11522514Sdarrenr usb_error_t (*sc_rf_set_chan)(struct urtw_softc *, 11624583Sdarrenr int); 11722514Sdarrenr usb_error_t (*sc_rf_set_sens)(struct urtw_softc *, 11822514Sdarrenr int); 11922514Sdarrenr usb_error_t (*sc_rf_stop)(struct urtw_softc *); 12022514Sdarrenr uint8_t sc_rfchip; 12122514Sdarrenr uint32_t sc_max_sens; 12222514Sdarrenr uint32_t sc_sens; 12324583Sdarrenr /* for LED */ 12422514Sdarrenr struct usb_callout sc_led_ch; 12522514Sdarrenr struct task sc_led_task; 12622514Sdarrenr uint8_t sc_psr; 12722514Sdarrenr uint8_t sc_strategy; 12822514Sdarrenr#define URTW_LED_GPIO 1 12922514Sdarrenr uint8_t sc_gpio_ledon; 13022514Sdarrenr uint8_t sc_gpio_ledinprogress; 13122514Sdarrenr uint8_t sc_gpio_ledstate; 13224583Sdarrenr uint8_t sc_gpio_ledpin; 13322514Sdarrenr uint8_t sc_gpio_blinktime; 13422514Sdarrenr uint8_t sc_gpio_blinkstate; 13522514Sdarrenr /* RX/TX */ 13622514Sdarrenr struct usb_xfer *sc_xfer[URTW_8187B_N_XFERS]; 13722514Sdarrenr#define URTW_PRIORITY_LOW 0 13822514Sdarrenr#define URTW_PRIORITY_NORMAL 1 13922514Sdarrenr#define URTW_DATA_TIMEOUT 10000 /* 10 sec */ 14022514Sdarrenr#define URTW_8187B_TXPIPE_BE 0x6 /* best effort */ 14122514Sdarrenr#define URTW_8187B_TXPIPE_BK 0x7 /* background */ 14222514Sdarrenr#define URTW_8187B_TXPIPE_VI 0x5 /* video */ 14322514Sdarrenr#define URTW_8187B_TXPIPE_VO 0x4 /* voice */ 14422514Sdarrenr#define URTW_8187B_TXPIPE_MAX 4 14522514Sdarrenr struct urtw_data sc_rx[URTW_RX_DATA_LIST_COUNT]; 14622514Sdarrenr urtw_datahead sc_rx_active; 14722514Sdarrenr urtw_datahead sc_rx_inactive; 14822514Sdarrenr struct urtw_data sc_tx[URTW_TX_DATA_LIST_COUNT]; 14922514Sdarrenr urtw_datahead sc_tx_active; 15022514Sdarrenr urtw_datahead sc_tx_inactive; 15122514Sdarrenr urtw_datahead sc_tx_pending; 15222514Sdarrenr uint8_t sc_rts_retry; 15322514Sdarrenr uint8_t sc_tx_retry; 15422514Sdarrenr uint8_t sc_preamble_mode; 15522514Sdarrenr#define URTW_PREAMBLE_MODE_SHORT 1 15622514Sdarrenr#define URTW_PREAMBLE_MODE_LONG 2 15722514Sdarrenr struct callout sc_watchdog_ch; 15822514Sdarrenr int sc_txtimer; 15922514Sdarrenr int sc_currate; 16022514Sdarrenr /* TX power */ 16122514Sdarrenr uint8_t sc_txpwr_cck[URTW_MAX_CHANNELS]; 16222514Sdarrenr uint8_t sc_txpwr_cck_base; 16322514Sdarrenr uint8_t sc_txpwr_ofdm[URTW_MAX_CHANNELS]; 16422514Sdarrenr uint8_t sc_txpwr_ofdm_base; 16522514Sdarrenr 16622514Sdarrenr struct urtw_rx_radiotap_header sc_rxtap; 16724583Sdarrenr int sc_rxtap_len; 16822514Sdarrenr struct urtw_tx_radiotap_header sc_txtap; 16922514Sdarrenr int sc_txtap_len; 17022514Sdarrenr}; 17122514Sdarrenr 17222514Sdarrenr#define URTW_LOCK(sc) mtx_lock(&(sc)->sc_mtx) 17322514Sdarrenr#define URTW_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) 17424583Sdarrenr#define URTW_ASSERT_LOCKED(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED) 17522514Sdarrenr