if_urtwnvar.h revision 292014
1/*- 2 * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> 3 * 4 * Permission to use, copy, modify, and distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 * 16 * $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $ 17 * $FreeBSD: head/sys/dev/usb/wlan/if_urtwnvar.h 292014 2015-12-09 09:29:38Z avos $ 18 */ 19 20#define URTWN_RX_LIST_COUNT 1 21#define URTWN_TX_LIST_COUNT 8 22#define URTWN_HOST_CMD_RING_COUNT 32 23 24#define URTWN_RXBUFSZ (16 * 1024) 25#define URTWN_TXBUFSZ (sizeof(struct r92c_tx_desc) + IEEE80211_MAX_LEN) 26#define URTWN_RX_DESC_SIZE (sizeof(struct r92c_rx_stat)) 27#define URTWN_TX_DESC_SIZE (sizeof(struct r92c_tx_desc)) 28 29#define URTWN_TX_TIMEOUT 5000 /* ms */ 30 31#define URTWN_LED_LINK 0 32#define URTWN_LED_DATA 1 33 34struct urtwn_rx_radiotap_header { 35 struct ieee80211_radiotap_header wr_ihdr; 36 uint8_t wr_flags; 37 uint8_t wr_rate; 38 uint16_t wr_chan_freq; 39 uint16_t wr_chan_flags; 40 int8_t wr_dbm_antsignal; 41 int8_t wr_dbm_antnoise; 42} __packed __aligned(8); 43 44#define URTWN_RX_RADIOTAP_PRESENT \ 45 (1 << IEEE80211_RADIOTAP_FLAGS | \ 46 1 << IEEE80211_RADIOTAP_RATE | \ 47 1 << IEEE80211_RADIOTAP_CHANNEL | \ 48 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL | \ 49 1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) 50 51struct urtwn_tx_radiotap_header { 52 struct ieee80211_radiotap_header wt_ihdr; 53 uint8_t wt_flags; 54 uint16_t wt_chan_freq; 55 uint16_t wt_chan_flags; 56} __packed __aligned(8); 57 58#define URTWN_TX_RADIOTAP_PRESENT \ 59 (1 << IEEE80211_RADIOTAP_FLAGS | \ 60 1 << IEEE80211_RADIOTAP_CHANNEL) 61 62struct urtwn_softc; 63 64struct urtwn_data { 65 struct urtwn_softc *sc; 66 uint8_t *buf; 67 uint16_t buflen; 68 struct mbuf *m; 69 struct ieee80211_node *ni; 70 STAILQ_ENTRY(urtwn_data) next; 71}; 72typedef STAILQ_HEAD(, urtwn_data) urtwn_datahead; 73 74struct urtwn_cmdq { 75 void *arg0; 76 void *arg1; 77 void (*func)(void *); 78 struct ieee80211_key *k; 79 struct ieee80211_key key; 80 uint8_t mac[IEEE80211_ADDR_LEN]; 81 uint8_t wcid; 82}; 83 84struct urtwn_fw_info { 85 const uint8_t *data; 86 size_t size; 87}; 88 89struct urtwn_vap { 90 struct ieee80211vap vap; 91 92 struct r92c_tx_desc bcn_desc; 93 struct mbuf *bcn_mbuf; 94 struct task tsf_task_adhoc; 95 96 int (*newstate)(struct ieee80211vap *, 97 enum ieee80211_state, int); 98 void (*recv_mgmt)(struct ieee80211_node *, 99 struct mbuf *, int, 100 const struct ieee80211_rx_stats *, 101 int, int); 102}; 103#define URTWN_VAP(vap) ((struct urtwn_vap *)(vap)) 104 105struct urtwn_host_cmd { 106 void (*cb)(struct urtwn_softc *, void *); 107 uint8_t data[256]; 108}; 109 110struct urtwn_cmd_newstate { 111 enum ieee80211_state state; 112 int arg; 113}; 114 115struct urtwn_cmd_key { 116 struct ieee80211_key key; 117 uint16_t associd; 118}; 119 120enum { 121 URTWN_BULK_RX, 122 URTWN_BULK_TX_BE, /* = WME_AC_BE */ 123 URTWN_BULK_TX_BK, /* = WME_AC_BK */ 124 URTWN_BULK_TX_VI, /* = WME_AC_VI */ 125 URTWN_BULK_TX_VO, /* = WME_AC_VI */ 126 URTWN_N_TRANSFER = 5, 127}; 128 129#define URTWN_EP_QUEUES URTWN_BULK_RX 130 131union urtwn_rom { 132 struct r92c_rom r92c_rom; 133 uint8_t r88e_rom[URTWN_EFUSE_MAX_LEN]; 134}; 135 136struct urtwn_softc { 137 struct ieee80211com sc_ic; 138 struct mbufq sc_snd; 139 device_t sc_dev; 140 struct usb_device *sc_udev; 141 142 uint8_t sc_iface_index; 143 u_int sc_flags; 144#define URTWN_FLAG_CCK_HIPWR 0x01 145#define URTWN_DETACHED 0x02 146#define URTWN_RUNNING 0x04 147 148 u_int chip; 149#define URTWN_CHIP_92C 0x01 150#define URTWN_CHIP_92C_1T2R 0x02 151#define URTWN_CHIP_UMC 0x04 152#define URTWN_CHIP_UMC_A_CUT 0x08 153#define URTWN_CHIP_88E 0x10 154 155 void (*sc_rf_write)(struct urtwn_softc *, 156 int, uint8_t, uint32_t); 157 int (*sc_power_on)(struct urtwn_softc *); 158 159 uint8_t board_type; 160 uint8_t regulatory; 161 uint8_t pa_setting; 162 int avg_pwdb; 163 int thcal_state; 164 int thcal_lctemp; 165 int ntxchains; 166 int nrxchains; 167 int ledlink; 168 int sc_txtimer; 169 170 int fwcur; 171 struct urtwn_data sc_rx[URTWN_RX_LIST_COUNT]; 172 urtwn_datahead sc_rx_active; 173 urtwn_datahead sc_rx_inactive; 174 struct urtwn_data sc_tx[URTWN_TX_LIST_COUNT]; 175 urtwn_datahead sc_tx_active; 176 urtwn_datahead sc_tx_inactive; 177 urtwn_datahead sc_tx_pending; 178 179 const char *fwname; 180 const struct firmware *fw_fp; 181 struct urtwn_fw_info fw; 182 void *fw_virtaddr; 183 184 union urtwn_rom rom; 185 uint8_t cck_tx_pwr[6]; 186 uint8_t ht40_tx_pwr[5]; 187 int8_t bw20_tx_pwr_diff; 188 int8_t ofdm_tx_pwr_diff; 189 uint16_t last_rom_addr; 190 191 struct callout sc_watchdog_ch; 192 struct mtx sc_mtx; 193 194/* need to be power of 2, otherwise URTWN_CMDQ_GET fails */ 195#define URTWN_CMDQ_MAX 16 196#define URTWN_CMDQ_MASQ (URTWN_CMDQ_MAX - 1) 197 struct urtwn_cmdq cmdq[URTWN_CMDQ_MAX]; 198 struct task cmdq_task; 199 uint32_t cmdq_store; 200 uint8_t cmdq_exec; 201 uint8_t cmdq_run; 202 uint8_t cmdq_key_set; 203#define URTWN_CMDQ_ABORT 0 204#define URTWN_CMDQ_GO 1 205 206 uint32_t rf_chnlbw[R92C_MAX_CHAINS]; 207 struct usb_xfer *sc_xfer[URTWN_N_TRANSFER]; 208 209 struct urtwn_rx_radiotap_header sc_rxtap; 210 struct urtwn_tx_radiotap_header sc_txtap; 211}; 212 213#define URTWN_LOCK(sc) mtx_lock(&(sc)->sc_mtx) 214#define URTWN_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) 215#define URTWN_ASSERT_LOCKED(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED) 216