FreeBSD kernel usb device Code
if_urtwvar.h
Go to the documentation of this file.
1/* $FreeBSD$ */
3/*-
4 * Copyright (c) 2008 Weongyo Jeong <weongyo@FreeBSD.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19enum {
28};
29
30enum {
35};
36
37/* XXX no definition at net80211? */
38#define URTW_MAX_CHANNELS 15
39
40struct urtw_data {
41 struct urtw_softc *sc;
42 uint8_t *buf;
43 uint16_t buflen;
44 struct mbuf *m;
45 struct ieee80211_node *ni; /* NB: tx only */
47};
48typedef STAILQ_HEAD(, urtw_data) urtw_datahead;
49
50#define URTW_RX_DATA_LIST_COUNT 4
51#define URTW_TX_DATA_LIST_COUNT 16
52#define URTW_RX_MAXSIZE 0x9c4
53#define URTW_TX_MAXSIZE 0x9c4
54#define URTW_TX_MAXRETRY 11
55
57 struct ieee80211_radiotap_header wr_ihdr;
58 uint64_t wr_tsf;
59 uint8_t wr_flags;
60 uint8_t wr_pad;
61 uint16_t wr_chan_freq;
62 uint16_t wr_chan_flags;
65
66#define URTW_RX_RADIOTAP_PRESENT \
67 ((1 << IEEE80211_RADIOTAP_TSFT) | \
68 (1 << IEEE80211_RADIOTAP_FLAGS) | \
69 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
70 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL))
71
73 struct ieee80211_radiotap_header wt_ihdr;
74 uint8_t wt_flags;
75 uint8_t wt_pad;
76 uint16_t wt_chan_freq;
77 uint16_t wt_chan_flags;
79
80#define URTW_TX_RADIOTAP_PRESENT \
81 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
82 (1 << IEEE80211_RADIOTAP_CHANNEL))
83
84struct urtw_stats {
85 unsigned int txrates[12];
86};
87
88struct urtw_vap {
89 struct ieee80211vap vap;
90 int (*newstate)(struct ieee80211vap *,
91 enum ieee80211_state, int);
92};
93#define URTW_VAP(vap) ((struct urtw_vap *)(vap))
94
95struct urtw_softc {
96 struct ieee80211com sc_ic;
97 struct mbufq sc_snd;
98 device_t sc_dev;
100 struct mtx sc_mtx;
102
105#define URTW_INIT_ONCE (1 << 1)
106#define URTW_RTL8187B (1 << 2)
107#define URTW_RTL8187B_REV_B (1 << 3)
108#define URTW_RTL8187B_REV_D (1 << 4)
109#define URTW_RTL8187B_REV_E (1 << 5)
110#define URTW_DETACHED (1 << 6)
111#define URTW_RUNNING (1 << 7)
112 enum ieee80211_state sc_state;
113
115#define URTW_EEPROM_93C46 0
116#define URTW_EEPROM_93C56 1
117 uint8_t sc_crcmon;
118
119 struct ieee80211_channel *sc_curchan;
120
121 /* for RF */
124 int);
126 int);
128 uint8_t sc_rfchip;
129 uint32_t sc_max_sens;
130 uint32_t sc_sens;
131 /* for LED */
133 struct task sc_led_task;
134 uint8_t sc_psr;
135 uint8_t sc_strategy;
136#define URTW_LED_GPIO 1
143 /* RX/TX */
145#define URTW_PRIORITY_LOW 0
146#define URTW_PRIORITY_NORMAL 1
147#define URTW_DATA_TIMEOUT 10000 /* 10 sec */
148#define URTW_8187B_TXPIPE_BE 0x6 /* best effort */
149#define URTW_8187B_TXPIPE_BK 0x7 /* background */
150#define URTW_8187B_TXPIPE_VI 0x5 /* video */
151#define URTW_8187B_TXPIPE_VO 0x4 /* voice */
152#define URTW_8187B_TXPIPE_MAX 4
154 urtw_datahead sc_rx_active;
155 urtw_datahead sc_rx_inactive;
157 urtw_datahead sc_tx_active;
158 urtw_datahead sc_tx_inactive;
159 urtw_datahead sc_tx_pending;
161 uint8_t sc_tx_retry;
163#define URTW_PREAMBLE_MODE_SHORT 1
164#define URTW_PREAMBLE_MODE_LONG 2
165 struct callout sc_watchdog_ch;
168 /* TX power */
173
174 uint8_t sc_acmctl;
175 uint64_t sc_txstatus; /* only for 8187B */
177
179
182};
183
184#define URTW_LOCK(sc) mtx_lock(&(sc)->sc_mtx)
185#define URTW_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx)
186#define URTW_ASSERT_LOCKED(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED)
struct ehci_itd * next
Definition: ehci.h:29
#define URTW_TX_DATA_LIST_COUNT
Definition: if_urtwvar.h:51
@ URTW_8187B_N_XFERS
Definition: if_urtwvar.h:27
@ URTW_8187B_BULK_TX_VI
Definition: if_urtwvar.h:24
@ URTW_8187B_BULK_TX_BK
Definition: if_urtwvar.h:23
@ URTW_8187B_BULK_TX_EP12
Definition: if_urtwvar.h:26
@ URTW_8187B_BULK_RX
Definition: if_urtwvar.h:20
@ URTW_8187B_BULK_TX_VO
Definition: if_urtwvar.h:25
@ URTW_8187B_BULK_TX_STATUS
Definition: if_urtwvar.h:21
@ URTW_8187B_BULK_TX_BE
Definition: if_urtwvar.h:22
@ URTW_8187L_BULK_TX_LOW
Definition: if_urtwvar.h:32
@ URTW_8187L_N_XFERS
Definition: if_urtwvar.h:34
@ URTW_8187L_BULK_RX
Definition: if_urtwvar.h:31
@ URTW_8187L_BULK_TX_NORMAL
Definition: if_urtwvar.h:33
typedef STAILQ_HEAD(, urtw_data) urtw_datahead
struct urtw_rx_radiotap_header __aligned(8)
#define URTW_MAX_CHANNELS
Definition: if_urtwvar.h:38
struct urtw_tx_radiotap_header __packed
#define URTW_RX_DATA_LIST_COUNT
Definition: if_urtwvar.h:50
uint16_t buflen
Definition: if_urtwvar.h:43
struct mbuf * m
Definition: if_urtwvar.h:44
STAILQ_ENTRY(urtw_data) next
struct ieee80211_node * ni
Definition: if_urtwvar.h:45
uint8_t * buf
Definition: if_urtwvar.h:42
struct urtw_softc * sc
Definition: if_urtwvar.h:41
struct ieee80211_radiotap_header wr_ihdr
Definition: if_urtwvar.h:57
uint8_t sc_gpio_ledstate
Definition: if_urtwvar.h:139
int sc_debug
Definition: if_urtwvar.h:103
struct urtw_rx_radiotap_header sc_rxtap
Definition: if_urtwvar.h:180
struct ieee80211_channel * sc_curchan
Definition: if_urtwvar.h:119
struct mtx sc_mtx
Definition: if_urtwvar.h:100
uint8_t sc_gpio_blinktime
Definition: if_urtwvar.h:141
uint32_t sc_max_sens
Definition: if_urtwvar.h:129
struct mbufq sc_snd
Definition: if_urtwvar.h:97
void * sc_tx_dma_buf
Definition: if_urtwvar.h:101
uint8_t sc_tx_retry
Definition: if_urtwvar.h:161
usb_error_t(* sc_rf_init)(struct urtw_softc *)
Definition: if_urtwvar.h:122
struct task sc_updateslot_task
Definition: if_urtwvar.h:176
urtw_datahead sc_rx_active
Definition: if_urtwvar.h:154
struct usb_callout sc_led_ch
Definition: if_urtwvar.h:132
struct usb_device * sc_udev
Definition: if_urtwvar.h:99
urtw_datahead sc_rx_inactive
Definition: if_urtwvar.h:155
uint8_t sc_txpwr_ofdm_base
Definition: if_urtwvar.h:172
uint8_t sc_preamble_mode
Definition: if_urtwvar.h:162
urtw_datahead sc_tx_inactive
Definition: if_urtwvar.h:158
uint8_t sc_txpwr_ofdm[URTW_MAX_CHANNELS]
Definition: if_urtwvar.h:171
device_t sc_dev
Definition: if_urtwvar.h:98
struct urtw_data sc_tx[URTW_TX_DATA_LIST_COUNT]
Definition: if_urtwvar.h:156
uint8_t sc_rfchip
Definition: if_urtwvar.h:128
usb_error_t(* sc_rf_set_chan)(struct urtw_softc *, int)
Definition: if_urtwvar.h:123
uint8_t sc_rts_retry
Definition: if_urtwvar.h:160
urtw_datahead sc_tx_pending
Definition: if_urtwvar.h:159
struct callout sc_watchdog_ch
Definition: if_urtwvar.h:165
uint8_t sc_acmctl
Definition: if_urtwvar.h:174
int sc_currate
Definition: if_urtwvar.h:167
int sc_epromtype
Definition: if_urtwvar.h:114
struct urtw_tx_radiotap_header sc_txtap
Definition: if_urtwvar.h:181
uint8_t sc_gpio_ledinprogress
Definition: if_urtwvar.h:138
uint8_t sc_txpwr_cck[URTW_MAX_CHANNELS]
Definition: if_urtwvar.h:169
uint32_t sc_sens
Definition: if_urtwvar.h:130
struct urtw_stats sc_stats
Definition: if_urtwvar.h:178
usb_error_t(* sc_rf_set_sens)(struct urtw_softc *, int)
Definition: if_urtwvar.h:125
struct urtw_data sc_rx[URTW_RX_DATA_LIST_COUNT]
Definition: if_urtwvar.h:153
uint8_t sc_gpio_ledon
Definition: if_urtwvar.h:137
struct ieee80211com sc_ic
Definition: if_urtwvar.h:96
urtw_datahead sc_tx_active
Definition: if_urtwvar.h:157
int sc_txtimer
Definition: if_urtwvar.h:166
usb_error_t(* sc_rf_stop)(struct urtw_softc *)
Definition: if_urtwvar.h:127
uint8_t sc_gpio_ledpin
Definition: if_urtwvar.h:140
uint64_t sc_txstatus
Definition: if_urtwvar.h:175
enum ieee80211_state sc_state
Definition: if_urtwvar.h:112
uint8_t sc_strategy
Definition: if_urtwvar.h:135
uint8_t sc_psr
Definition: if_urtwvar.h:134
int sc_flags
Definition: if_urtwvar.h:104
uint8_t sc_crcmon
Definition: if_urtwvar.h:117
uint8_t sc_txpwr_cck_base
Definition: if_urtwvar.h:170
struct usb_xfer * sc_xfer[URTW_8187B_N_XFERS]
Definition: if_urtwvar.h:144
uint8_t sc_gpio_blinkstate
Definition: if_urtwvar.h:142
struct task sc_led_task
Definition: if_urtwvar.h:133
unsigned int txrates[12]
Definition: if_urtwvar.h:85
struct ieee80211_radiotap_header wt_ihdr
Definition: if_urtwvar.h:73
int(* newstate)(struct ieee80211vap *, enum ieee80211_state, int)
Definition: if_urtwvar.h:90
struct ieee80211vap vap
Definition: if_urtwvar.h:89
usb_error_t
Definition: usbdi.h:45