3 4/*- 5 * Copyright (c) 2006 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> 9 * 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. 13 * 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. 21 */ 22 23enum { 24 UATH_INTR_RX, 25 UATH_INTR_TX, 26 UATH_BULK_RX, 27 UATH_BULK_TX, 28 UATH_N_XFERS = 4, 29}; 30 31#define UATH_ID_BSS 2 /* Connection ID */ 32 33#define UATH_RX_DATA_LIST_COUNT 128 34#define UATH_TX_DATA_LIST_COUNT 16 35#define UATH_CMD_LIST_COUNT 60 36 37#define UATH_DATA_TIMEOUT 10000 38#define UATH_CMD_TIMEOUT 1000 39 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) 44 45struct uath_rx_radiotap_header { 46 struct ieee80211_radiotap_header wr_ihdr; 47 u_int64_t wr_tsf; 48 u_int8_t wr_flags; 49 u_int8_t wr_rate; 50 uint16_t wr_chan_freq; 51 uint16_t wr_chan_flags; 52 int8_t wr_antsignal; 53 int8_t wr_antnoise; 54 u_int8_t wr_antenna; 55} __packed; 56 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) | \ 65 0) 66 67struct uath_tx_radiotap_header { 68 struct ieee80211_radiotap_header wt_ihdr; 69 uint8_t wt_flags; 70 uint16_t wt_chan_freq; 71 uint16_t wt_chan_flags; 72} __packed; 73 74#define UATH_TX_RADIOTAP_PRESENT \ 75 ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 76 (1 << IEEE80211_RADIOTAP_CHANNEL)) 77 78struct uath_data { 79 struct uath_softc *sc; 80 uint8_t *buf; 81 uint16_t buflen; 82 struct mbuf *m; 83 struct ieee80211_node *ni; /* NB: tx only */ 84 STAILQ_ENTRY(uath_data) next; 85}; 86typedef STAILQ_HEAD(, uath_data) uath_datahead; 87 88struct uath_cmd { 89 struct uath_softc *sc; 90 uint32_t flags; 91 uint32_t msgid; 92 uint8_t *buf; 93 uint16_t buflen; 94 void *odata; /* NB: tx only */ 95 int olen; /* space in odata */ 96 STAILQ_ENTRY(uath_cmd) next; 97}; 98typedef STAILQ_HEAD(, uath_cmd) uath_cmdhead; 99 100struct uath_wme_settings { 101 uint8_t aifsn; 102 uint8_t logcwmin; 103 uint8_t logcwmax; 104 uint16_t txop; 105#define UATH_TXOP_TO_US(txop) ((txop) << 5) 106 uint8_t acm; 107}; 108 109struct uath_devcap { 110 uint32_t targetVersion; 111 uint32_t targetRevision; 112 uint32_t macVersion; 113 uint32_t macRevision; 114 uint32_t phyRevision; 115 uint32_t analog5GhzRevision; 116 uint32_t analog2GhzRevision; 117 uint32_t regDomain; 118 uint32_t regCapBits; 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; 136 uint32_t deviceType; 137 uint32_t wmeSupport; 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; 149}; 150 151struct uath_stat { 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; 157 uint32_t st_crcerr; 158 uint32_t st_phyerr; 159 uint32_t st_decrypt_crcerr; 160 uint32_t st_decrypt_micerr; 161 uint32_t st_decomperr; 162 uint32_t st_keyerr; 163 uint32_t st_err; 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; 174}; 175#define UATH_STAT_INC(sc, var) (sc)->sc_stat.var++ 176#define UATH_STAT_DEC(sc, var) (sc)->sc_stat.var-- 177 178struct uath_vap { 179 struct ieee80211vap vap; 180 int (*newstate)(struct ieee80211vap *, 181 enum ieee80211_state, int); 182}; 183#define UATH_VAP(vap) ((struct uath_vap *)(vap)) 184 185struct uath_softc { 186 struct ifnet *sc_ifp; 187 device_t sc_dev; 188 struct usb_device *sc_udev;
| 3 4/*- 5 * Copyright (c) 2006 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> 9 * 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. 13 * 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. 21 */ 22 23enum { 24 UATH_INTR_RX, 25 UATH_INTR_TX, 26 UATH_BULK_RX, 27 UATH_BULK_TX, 28 UATH_N_XFERS = 4, 29}; 30 31#define UATH_ID_BSS 2 /* Connection ID */ 32 33#define UATH_RX_DATA_LIST_COUNT 128 34#define UATH_TX_DATA_LIST_COUNT 16 35#define UATH_CMD_LIST_COUNT 60 36 37#define UATH_DATA_TIMEOUT 10000 38#define UATH_CMD_TIMEOUT 1000 39 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) 44 45struct uath_rx_radiotap_header { 46 struct ieee80211_radiotap_header wr_ihdr; 47 u_int64_t wr_tsf; 48 u_int8_t wr_flags; 49 u_int8_t wr_rate; 50 uint16_t wr_chan_freq; 51 uint16_t wr_chan_flags; 52 int8_t wr_antsignal; 53 int8_t wr_antnoise; 54 u_int8_t wr_antenna; 55} __packed; 56 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) | \ 65 0) 66 67struct uath_tx_radiotap_header { 68 struct ieee80211_radiotap_header wt_ihdr; 69 uint8_t wt_flags; 70 uint16_t wt_chan_freq; 71 uint16_t wt_chan_flags; 72} __packed; 73 74#define UATH_TX_RADIOTAP_PRESENT \ 75 ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 76 (1 << IEEE80211_RADIOTAP_CHANNEL)) 77 78struct uath_data { 79 struct uath_softc *sc; 80 uint8_t *buf; 81 uint16_t buflen; 82 struct mbuf *m; 83 struct ieee80211_node *ni; /* NB: tx only */ 84 STAILQ_ENTRY(uath_data) next; 85}; 86typedef STAILQ_HEAD(, uath_data) uath_datahead; 87 88struct uath_cmd { 89 struct uath_softc *sc; 90 uint32_t flags; 91 uint32_t msgid; 92 uint8_t *buf; 93 uint16_t buflen; 94 void *odata; /* NB: tx only */ 95 int olen; /* space in odata */ 96 STAILQ_ENTRY(uath_cmd) next; 97}; 98typedef STAILQ_HEAD(, uath_cmd) uath_cmdhead; 99 100struct uath_wme_settings { 101 uint8_t aifsn; 102 uint8_t logcwmin; 103 uint8_t logcwmax; 104 uint16_t txop; 105#define UATH_TXOP_TO_US(txop) ((txop) << 5) 106 uint8_t acm; 107}; 108 109struct uath_devcap { 110 uint32_t targetVersion; 111 uint32_t targetRevision; 112 uint32_t macVersion; 113 uint32_t macRevision; 114 uint32_t phyRevision; 115 uint32_t analog5GhzRevision; 116 uint32_t analog2GhzRevision; 117 uint32_t regDomain; 118 uint32_t regCapBits; 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; 136 uint32_t deviceType; 137 uint32_t wmeSupport; 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; 149}; 150 151struct uath_stat { 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; 157 uint32_t st_crcerr; 158 uint32_t st_phyerr; 159 uint32_t st_decrypt_crcerr; 160 uint32_t st_decrypt_micerr; 161 uint32_t st_decomperr; 162 uint32_t st_keyerr; 163 uint32_t st_err; 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; 174}; 175#define UATH_STAT_INC(sc, var) (sc)->sc_stat.var++ 176#define UATH_STAT_DEC(sc, var) (sc)->sc_stat.var-- 177 178struct uath_vap { 179 struct ieee80211vap vap; 180 int (*newstate)(struct ieee80211vap *, 181 enum ieee80211_state, int); 182}; 183#define UATH_VAP(vap) ((struct uath_vap *)(vap)) 184 185struct uath_softc { 186 struct ifnet *sc_ifp; 187 device_t sc_dev; 188 struct usb_device *sc_udev;
|
189 struct mtx sc_mtx; 190 uint32_t sc_debug; 191 192 struct uath_stat sc_stat; 193 int (*sc_newstate)(struct ieee80211com *, 194 enum ieee80211_state, int); 195 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; 209 210 uint32_t sc_msgid; 211 uint32_t sc_seqnum; 212 int sc_tx_timer; 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 221 222 struct uath_devcap sc_devcap; 223 uint8_t sc_serial[16]; 224 225 /* unsorted */ 226 uint32_t sc_flags; 227#define UATH_FLAG_INVALID (1 << 1) 228#define UATH_FLAG_INITDONE (1 << 2) 229 230 struct uath_rx_radiotap_header sc_rxtap; 231 int sc_rxtap_len; 232 struct uath_tx_radiotap_header sc_txtap; 233 int sc_txtap_len; 234}; 235 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) 239 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; \ 245} while (0)
| 191 struct mtx sc_mtx; 192 uint32_t sc_debug; 193 194 struct uath_stat sc_stat; 195 int (*sc_newstate)(struct ieee80211com *, 196 enum ieee80211_state, int); 197 198 struct usb_xfer *sc_xfer[UATH_N_XFERS]; 199 struct uath_cmd sc_cmd[UATH_CMD_LIST_COUNT]; 200 uath_cmdhead sc_cmd_active; 201 uath_cmdhead sc_cmd_inactive; 202 uath_cmdhead sc_cmd_pending; 203 uath_cmdhead sc_cmd_waiting; 204 struct uath_data sc_rx[UATH_RX_DATA_LIST_COUNT]; 205 uath_datahead sc_rx_active; 206 uath_datahead sc_rx_inactive; 207 struct uath_data sc_tx[UATH_TX_DATA_LIST_COUNT]; 208 uath_datahead sc_tx_active; 209 uath_datahead sc_tx_inactive; 210 uath_datahead sc_tx_pending; 211 212 uint32_t sc_msgid; 213 uint32_t sc_seqnum; 214 int sc_tx_timer; 215 struct callout watchdog_ch; 216 struct callout stat_ch; 217 /* multi-chunked support */ 218 struct mbuf *sc_intrx_head; 219 struct mbuf *sc_intrx_tail; 220 uint8_t sc_intrx_nextnum; 221 uint32_t sc_intrx_len; 222#define UATH_MAX_INTRX_SIZE 3616 223 224 struct uath_devcap sc_devcap; 225 uint8_t sc_serial[16]; 226 227 /* unsorted */ 228 uint32_t sc_flags; 229#define UATH_FLAG_INVALID (1 << 1) 230#define UATH_FLAG_INITDONE (1 << 2) 231 232 struct uath_rx_radiotap_header sc_rxtap; 233 int sc_rxtap_len; 234 struct uath_tx_radiotap_header sc_txtap; 235 int sc_txtap_len; 236}; 237 238#define UATH_LOCK(sc) mtx_lock(&(sc)->sc_mtx) 239#define UATH_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) 240#define UATH_ASSERT_LOCKED(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED) 241 242#define UATH_RESET_INTRX(sc) do { \ 243 (sc)->sc_intrx_head = NULL; \ 244 (sc)->sc_intrx_tail = NULL; \ 245 (sc)->sc_intrx_nextnum = 0; \ 246 (sc)->sc_intrx_len = 0; \ 247} while (0)
|