1 /* $OpenBSD: if_uathvar.h,v 1.3 2006/09/20 19:47:17 damien Exp $ */
6 * Damien Bergamini <damien.bergamini@free.fr>
7 * Copyright (c) 2006 Sam Leffler, Errno Consulting
8 * Copyright (c) 2008-2009 Weongyo Jeong <weongyo@freebsd.org>
10 * Permission to use, copy, modify, and distribute this software for any
11 * purpose with or without fee is hereby granted, provided that the above
12 * copyright notice and this permission notice appear in all copies.
14 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
31 #define UATH_ID_BSS 2 /* Connection ID */
33 #define UATH_RX_DATA_LIST_COUNT 128
34 #define UATH_TX_DATA_LIST_COUNT 16
35 #define UATH_CMD_LIST_COUNT 60
37 #define UATH_DATA_TIMEOUT 10000
38 #define UATH_CMD_TIMEOUT 1000
40 /* flags for sending firmware commands */
41 #define UATH_CMD_FLAG_ASYNC (1 << 0)
42 #define UATH_CMD_FLAG_READ (1 << 1)
43 #define UATH_CMD_FLAG_MAGIC (1 << 2)
45 struct uath_rx_radiotap_header {
46 struct ieee80211_radiotap_header wr_ihdr;
50 uint16_t wr_chan_freq;
51 uint16_t wr_chan_flags;
57 #define UATH_RX_RADIOTAP_PRESENT ( \
58 (1 << IEEE80211_RADIOTAP_TSFT) | \
59 (1 << IEEE80211_RADIOTAP_FLAGS) | \
60 (1 << IEEE80211_RADIOTAP_RATE) | \
61 (1 << IEEE80211_RADIOTAP_ANTENNA) | \
62 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
63 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \
64 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | \
67 struct uath_tx_radiotap_header {
68 struct ieee80211_radiotap_header wt_ihdr;
70 uint16_t wt_chan_freq;
71 uint16_t wt_chan_flags;
74 #define UATH_TX_RADIOTAP_PRESENT \
75 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
76 (1 << IEEE80211_RADIOTAP_CHANNEL))
79 struct uath_softc *sc;
83 struct ieee80211_node *ni; /* NB: tx only */
84 STAILQ_ENTRY(uath_data) next;
86 typedef STAILQ_HEAD(, uath_data) uath_datahead;
89 struct uath_softc *sc;
94 void *odata; /* NB: tx only */
95 int olen; /* space in odata */
96 STAILQ_ENTRY(uath_cmd) next;
98 typedef STAILQ_HEAD(, uath_cmd) uath_cmdhead;
100 struct uath_wme_settings {
105 #define UATH_TXOP_TO_US(txop) ((txop) << 5)
110 uint32_t targetVersion;
111 uint32_t targetRevision;
113 uint32_t macRevision;
114 uint32_t phyRevision;
115 uint32_t analog5GhzRevision;
116 uint32_t analog2GhzRevision;
119 uint32_t countryCode;
120 uint32_t keyCacheSize;
121 uint32_t numTxQueues;
122 uint32_t connectionIdMax;
123 uint32_t wirelessModes;
124 #define UATH_WIRELESS_MODE_11A 0x01
125 #define UATH_WIRELESS_MODE_TURBO 0x02
126 #define UATH_WIRELESS_MODE_11B 0x04
127 #define UATH_WIRELESS_MODE_11G 0x08
128 #define UATH_WIRELESS_MODE_108G 0x10
129 uint32_t chanSpreadSupport;
130 uint32_t compressSupport;
131 uint32_t burstSupport;
132 uint32_t fastFramesSupport;
133 uint32_t chapTuningSupport;
134 uint32_t turboGSupport;
135 uint32_t turboPrimeSupport;
138 uint32_t low2GhzChan;
139 uint32_t high2GhzChan;
140 uint32_t low5GhzChan;
141 uint32_t high5GhzChan;
142 uint32_t supportCipherWEP;
143 uint32_t supportCipherAES_CCM;
144 uint32_t supportCipherTKIP;
145 uint32_t supportCipherMicAES_CCM;
146 uint32_t supportMicTKIP;
147 uint32_t twiceAntennaGain5G;
148 uint32_t twiceAntennaGain2G;
152 uint32_t st_badchunkseqnum;
153 uint32_t st_invalidlen;
154 uint32_t st_multichunk;
155 uint32_t st_toobigrxpkt;
156 uint32_t st_stopinprogress;
159 uint32_t st_decrypt_crcerr;
160 uint32_t st_decrypt_micerr;
161 uint32_t st_decomperr;
164 /* CMD/RX/TX queues */
165 uint32_t st_cmd_active;
166 uint32_t st_cmd_inactive;
167 uint32_t st_cmd_pending;
168 uint32_t st_cmd_waiting;
169 uint32_t st_rx_active;
170 uint32_t st_rx_inactive;
171 uint32_t st_tx_active;
172 uint32_t st_tx_inactive;
173 uint32_t st_tx_pending;
175 #define UATH_STAT_INC(sc, var) (sc)->sc_stat.var++
176 #define UATH_STAT_DEC(sc, var) (sc)->sc_stat.var--
179 struct ieee80211vap vap;
180 int (*newstate)(struct ieee80211vap *,
181 enum ieee80211_state, int);
183 #define UATH_VAP(vap) ((struct uath_vap *)(vap))
186 struct ifnet *sc_ifp;
188 struct usb_device *sc_udev;
192 struct uath_stat sc_stat;
193 int (*sc_newstate)(struct ieee80211com *,
194 enum ieee80211_state, int);
196 struct usb_xfer *sc_xfer[UATH_N_XFERS];
197 struct uath_cmd sc_cmd[UATH_CMD_LIST_COUNT];
198 uath_cmdhead sc_cmd_active;
199 uath_cmdhead sc_cmd_inactive;
200 uath_cmdhead sc_cmd_pending;
201 uath_cmdhead sc_cmd_waiting;
202 struct uath_data sc_rx[UATH_RX_DATA_LIST_COUNT];
203 uath_datahead sc_rx_active;
204 uath_datahead sc_rx_inactive;
205 struct uath_data sc_tx[UATH_TX_DATA_LIST_COUNT];
206 uath_datahead sc_tx_active;
207 uath_datahead sc_tx_inactive;
208 uath_datahead sc_tx_pending;
213 struct callout watchdog_ch;
214 struct callout stat_ch;
215 /* multi-chunked support */
216 struct mbuf *sc_intrx_head;
217 struct mbuf *sc_intrx_tail;
218 uint8_t sc_intrx_nextnum;
219 uint32_t sc_intrx_len;
220 #define UATH_MAX_INTRX_SIZE 3616
222 struct uath_devcap sc_devcap;
223 uint8_t sc_serial[16];
227 #define UATH_FLAG_INVALID (1 << 1)
228 #define UATH_FLAG_INITDONE (1 << 2)
230 struct uath_rx_radiotap_header sc_rxtap;
232 struct uath_tx_radiotap_header sc_txtap;
236 #define UATH_LOCK(sc) mtx_lock(&(sc)->sc_mtx)
237 #define UATH_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx)
238 #define UATH_ASSERT_LOCKED(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED)
240 #define UATH_RESET_INTRX(sc) do { \
241 (sc)->sc_intrx_head = NULL; \
242 (sc)->sc_intrx_tail = NULL; \
243 (sc)->sc_intrx_nextnum = 0; \
244 (sc)->sc_intrx_len = 0; \