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 $
| 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/urtwn/if_urtwnvar.h 300788 2016-05-26 22:43:02Z avos $
| 17 * $FreeBSD: head/sys/dev/urtwn/if_urtwnvar.h 301762 2016-06-09 21:19:46Z avos $
|
18 */ 19 20#define URTWN_RX_LIST_COUNT 64 21#define URTWN_TX_LIST_COUNT 8 22#define URTWN_HOST_CMD_RING_COUNT 32 23 24#define URTWN_RXBUFSZ (8 * 1024) 25//#define URTWN_TXBUFSZ (sizeof(struct r92c_tx_desc) + IEEE80211_MAX_LEN) 26/* Leave enough space for an A-MSDU frame */ 27#define URTWN_TXBUFSZ (16 * 1024) 28#define URTWN_RX_DESC_SIZE (sizeof(struct r92c_rx_stat)) 29#define URTWN_TX_DESC_SIZE (sizeof(struct r92c_tx_desc)) 30 31#define URTWN_TX_TIMEOUT 5000 /* ms */ 32 33#define URTWN_LED_LINK 0 34#define URTWN_LED_DATA 1 35 36struct urtwn_rx_radiotap_header { 37 struct ieee80211_radiotap_header wr_ihdr; 38 uint64_t wr_tsft; 39 uint8_t wr_flags; 40 uint8_t wr_rate; 41 uint16_t wr_chan_freq; 42 uint16_t wr_chan_flags; 43 int8_t wr_dbm_antsignal; 44 int8_t wr_dbm_antnoise; 45} __packed __aligned(8); 46 47#define URTWN_RX_RADIOTAP_PRESENT \ 48 (1 << IEEE80211_RADIOTAP_TSFT | \ 49 1 << IEEE80211_RADIOTAP_FLAGS | \ 50 1 << IEEE80211_RADIOTAP_RATE | \ 51 1 << IEEE80211_RADIOTAP_CHANNEL | \ 52 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL | \ 53 1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) 54 55struct urtwn_tx_radiotap_header { 56 struct ieee80211_radiotap_header wt_ihdr; 57 uint8_t wt_flags; 58 uint16_t wt_chan_freq; 59 uint16_t wt_chan_flags; 60} __packed __aligned(8); 61 62#define URTWN_TX_RADIOTAP_PRESENT \ 63 (1 << IEEE80211_RADIOTAP_FLAGS | \ 64 1 << IEEE80211_RADIOTAP_CHANNEL) 65 66struct urtwn_softc; 67 68struct urtwn_data { 69 struct urtwn_softc *sc; 70 uint8_t *buf; 71 uint16_t buflen; 72 struct mbuf *m; 73 struct ieee80211_node *ni; 74 STAILQ_ENTRY(urtwn_data) next; 75}; 76typedef STAILQ_HEAD(, urtwn_data) urtwn_datahead; 77 78union sec_param { 79 struct ieee80211_key key; 80}; 81 82#define CMD_FUNC_PROTO void (*func)(struct urtwn_softc *, \ 83 union sec_param *) 84 85struct urtwn_cmdq { 86 union sec_param data; 87 CMD_FUNC_PROTO; 88}; 89#define URTWN_CMDQ_SIZE 16 90 91struct urtwn_fw_info { 92 const uint8_t *data; 93 size_t size; 94}; 95 96struct urtwn_node { 97 struct ieee80211_node ni; /* must be the first */ 98 uint8_t id; 99 int last_rssi; 100}; 101#define URTWN_NODE(ni) ((struct urtwn_node *)(ni)) 102 103struct urtwn_vap { 104 struct ieee80211vap vap; 105 106 struct r92c_tx_desc bcn_desc; 107 struct mbuf *bcn_mbuf; 108 struct task tsf_task_adhoc; 109
| 18 */ 19 20#define URTWN_RX_LIST_COUNT 64 21#define URTWN_TX_LIST_COUNT 8 22#define URTWN_HOST_CMD_RING_COUNT 32 23 24#define URTWN_RXBUFSZ (8 * 1024) 25//#define URTWN_TXBUFSZ (sizeof(struct r92c_tx_desc) + IEEE80211_MAX_LEN) 26/* Leave enough space for an A-MSDU frame */ 27#define URTWN_TXBUFSZ (16 * 1024) 28#define URTWN_RX_DESC_SIZE (sizeof(struct r92c_rx_stat)) 29#define URTWN_TX_DESC_SIZE (sizeof(struct r92c_tx_desc)) 30 31#define URTWN_TX_TIMEOUT 5000 /* ms */ 32 33#define URTWN_LED_LINK 0 34#define URTWN_LED_DATA 1 35 36struct urtwn_rx_radiotap_header { 37 struct ieee80211_radiotap_header wr_ihdr; 38 uint64_t wr_tsft; 39 uint8_t wr_flags; 40 uint8_t wr_rate; 41 uint16_t wr_chan_freq; 42 uint16_t wr_chan_flags; 43 int8_t wr_dbm_antsignal; 44 int8_t wr_dbm_antnoise; 45} __packed __aligned(8); 46 47#define URTWN_RX_RADIOTAP_PRESENT \ 48 (1 << IEEE80211_RADIOTAP_TSFT | \ 49 1 << IEEE80211_RADIOTAP_FLAGS | \ 50 1 << IEEE80211_RADIOTAP_RATE | \ 51 1 << IEEE80211_RADIOTAP_CHANNEL | \ 52 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL | \ 53 1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) 54 55struct urtwn_tx_radiotap_header { 56 struct ieee80211_radiotap_header wt_ihdr; 57 uint8_t wt_flags; 58 uint16_t wt_chan_freq; 59 uint16_t wt_chan_flags; 60} __packed __aligned(8); 61 62#define URTWN_TX_RADIOTAP_PRESENT \ 63 (1 << IEEE80211_RADIOTAP_FLAGS | \ 64 1 << IEEE80211_RADIOTAP_CHANNEL) 65 66struct urtwn_softc; 67 68struct urtwn_data { 69 struct urtwn_softc *sc; 70 uint8_t *buf; 71 uint16_t buflen; 72 struct mbuf *m; 73 struct ieee80211_node *ni; 74 STAILQ_ENTRY(urtwn_data) next; 75}; 76typedef STAILQ_HEAD(, urtwn_data) urtwn_datahead; 77 78union sec_param { 79 struct ieee80211_key key; 80}; 81 82#define CMD_FUNC_PROTO void (*func)(struct urtwn_softc *, \ 83 union sec_param *) 84 85struct urtwn_cmdq { 86 union sec_param data; 87 CMD_FUNC_PROTO; 88}; 89#define URTWN_CMDQ_SIZE 16 90 91struct urtwn_fw_info { 92 const uint8_t *data; 93 size_t size; 94}; 95 96struct urtwn_node { 97 struct ieee80211_node ni; /* must be the first */ 98 uint8_t id; 99 int last_rssi; 100}; 101#define URTWN_NODE(ni) ((struct urtwn_node *)(ni)) 102 103struct urtwn_vap { 104 struct ieee80211vap vap; 105 106 struct r92c_tx_desc bcn_desc; 107 struct mbuf *bcn_mbuf; 108 struct task tsf_task_adhoc; 109
|
| 110 const struct ieee80211_key *keys[IEEE80211_WEP_NKID]; 111
|
110 int (*newstate)(struct ieee80211vap *, 111 enum ieee80211_state, int); 112 void (*recv_mgmt)(struct ieee80211_node *, 113 struct mbuf *, int, 114 const struct ieee80211_rx_stats *, 115 int, int); 116}; 117#define URTWN_VAP(vap) ((struct urtwn_vap *)(vap)) 118 119enum { 120 URTWN_BULK_RX, 121 URTWN_BULK_TX_BE, /* = WME_AC_BE */ 122 URTWN_BULK_TX_BK, /* = WME_AC_BK */ 123 URTWN_BULK_TX_VI, /* = WME_AC_VI */ 124 URTWN_BULK_TX_VO, /* = WME_AC_VI */ 125 URTWN_N_TRANSFER = 5, 126}; 127 128#define URTWN_EP_QUEUES URTWN_BULK_RX 129 130union urtwn_rom { 131 struct r92c_rom r92c_rom; 132 struct r88e_rom r88e_rom; 133}; 134 135struct urtwn_softc { 136 struct ieee80211com sc_ic; 137 struct mbufq sc_snd; 138 device_t sc_dev; 139 struct usb_device *sc_udev; 140 141 uint32_t sc_debug; 142 uint8_t sc_iface_index; 143 uint8_t sc_flags; 144#define URTWN_FLAG_CCK_HIPWR 0x01 145#define URTWN_DETACHED 0x02 146#define URTWN_RUNNING 0x04 147#define URTWN_FW_LOADED 0x08 148#define URTWN_TEMP_MEASURED 0x10 149 150 u_int chip; 151#define URTWN_CHIP_92C 0x01 152#define URTWN_CHIP_92C_1T2R 0x02 153#define URTWN_CHIP_UMC 0x04 154#define URTWN_CHIP_UMC_A_CUT 0x08 155#define URTWN_CHIP_88E 0x10 156 157#define URTWN_CHIP_HAS_RATECTL(_sc) (!!((_sc)->chip & URTWN_CHIP_88E)) 158 159 void (*sc_node_free)(struct ieee80211_node *); 160 void (*sc_rf_write)(struct urtwn_softc *, 161 int, uint8_t, uint32_t); 162 int (*sc_power_on)(struct urtwn_softc *); 163 void (*sc_power_off)(struct urtwn_softc *); 164 165 struct ieee80211_node *node_list[R88E_MACID_MAX + 1]; 166 struct mtx nt_mtx; 167 168 uint8_t board_type; 169 uint8_t regulatory; 170 uint8_t pa_setting; 171 int8_t ofdm_tx_pwr_diff; 172 int8_t bw20_tx_pwr_diff; 173 int avg_pwdb; 174 uint8_t thcal_lctemp; 175 int ntxchains; 176 int nrxchains; 177 int ledlink; 178 int sc_txtimer; 179 180 int last_rssi; 181 182 int fwcur; 183 struct urtwn_data sc_rx[URTWN_RX_LIST_COUNT]; 184 urtwn_datahead sc_rx_active; 185 urtwn_datahead sc_rx_inactive; 186 struct urtwn_data sc_tx[URTWN_TX_LIST_COUNT]; 187 urtwn_datahead sc_tx_active; 188 int sc_tx_n_active; 189 urtwn_datahead sc_tx_inactive; 190 urtwn_datahead sc_tx_pending; 191 192 union urtwn_rom rom; 193 uint16_t last_rom_addr; 194 195 struct callout sc_calib_to; 196 struct callout sc_watchdog_ch; 197 struct mtx sc_mtx; 198 uint32_t keys_bmap; 199 200 struct urtwn_cmdq cmdq[URTWN_CMDQ_SIZE]; 201 struct mtx cmdq_mtx; 202 struct task cmdq_task; 203 uint8_t cmdq_first; 204 uint8_t cmdq_last; 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 217#define URTWN_CMDQ_LOCK_INIT(sc) \ 218 mtx_init(&(sc)->cmdq_mtx, "cmdq lock", NULL, MTX_DEF) 219#define URTWN_CMDQ_LOCK(sc) mtx_lock(&(sc)->cmdq_mtx) 220#define URTWN_CMDQ_UNLOCK(sc) mtx_unlock(&(sc)->cmdq_mtx) 221#define URTWN_CMDQ_LOCK_DESTROY(sc) mtx_destroy(&(sc)->cmdq_mtx) 222 223#define URTWN_NT_LOCK_INIT(sc) \ 224 mtx_init(&(sc)->nt_mtx, "node table lock", NULL, MTX_DEF) 225#define URTWN_NT_LOCK(sc) mtx_lock(&(sc)->nt_mtx) 226#define URTWN_NT_UNLOCK(sc) mtx_unlock(&(sc)->nt_mtx) 227#define URTWN_NT_LOCK_DESTROY(sc) mtx_destroy(&(sc)->nt_mtx)
| 112 int (*newstate)(struct ieee80211vap *, 113 enum ieee80211_state, int); 114 void (*recv_mgmt)(struct ieee80211_node *, 115 struct mbuf *, int, 116 const struct ieee80211_rx_stats *, 117 int, int); 118}; 119#define URTWN_VAP(vap) ((struct urtwn_vap *)(vap)) 120 121enum { 122 URTWN_BULK_RX, 123 URTWN_BULK_TX_BE, /* = WME_AC_BE */ 124 URTWN_BULK_TX_BK, /* = WME_AC_BK */ 125 URTWN_BULK_TX_VI, /* = WME_AC_VI */ 126 URTWN_BULK_TX_VO, /* = WME_AC_VI */ 127 URTWN_N_TRANSFER = 5, 128}; 129 130#define URTWN_EP_QUEUES URTWN_BULK_RX 131 132union urtwn_rom { 133 struct r92c_rom r92c_rom; 134 struct r88e_rom r88e_rom; 135}; 136 137struct urtwn_softc { 138 struct ieee80211com sc_ic; 139 struct mbufq sc_snd; 140 device_t sc_dev; 141 struct usb_device *sc_udev; 142 143 uint32_t sc_debug; 144 uint8_t sc_iface_index; 145 uint8_t sc_flags; 146#define URTWN_FLAG_CCK_HIPWR 0x01 147#define URTWN_DETACHED 0x02 148#define URTWN_RUNNING 0x04 149#define URTWN_FW_LOADED 0x08 150#define URTWN_TEMP_MEASURED 0x10 151 152 u_int chip; 153#define URTWN_CHIP_92C 0x01 154#define URTWN_CHIP_92C_1T2R 0x02 155#define URTWN_CHIP_UMC 0x04 156#define URTWN_CHIP_UMC_A_CUT 0x08 157#define URTWN_CHIP_88E 0x10 158 159#define URTWN_CHIP_HAS_RATECTL(_sc) (!!((_sc)->chip & URTWN_CHIP_88E)) 160 161 void (*sc_node_free)(struct ieee80211_node *); 162 void (*sc_rf_write)(struct urtwn_softc *, 163 int, uint8_t, uint32_t); 164 int (*sc_power_on)(struct urtwn_softc *); 165 void (*sc_power_off)(struct urtwn_softc *); 166 167 struct ieee80211_node *node_list[R88E_MACID_MAX + 1]; 168 struct mtx nt_mtx; 169 170 uint8_t board_type; 171 uint8_t regulatory; 172 uint8_t pa_setting; 173 int8_t ofdm_tx_pwr_diff; 174 int8_t bw20_tx_pwr_diff; 175 int avg_pwdb; 176 uint8_t thcal_lctemp; 177 int ntxchains; 178 int nrxchains; 179 int ledlink; 180 int sc_txtimer; 181 182 int last_rssi; 183 184 int fwcur; 185 struct urtwn_data sc_rx[URTWN_RX_LIST_COUNT]; 186 urtwn_datahead sc_rx_active; 187 urtwn_datahead sc_rx_inactive; 188 struct urtwn_data sc_tx[URTWN_TX_LIST_COUNT]; 189 urtwn_datahead sc_tx_active; 190 int sc_tx_n_active; 191 urtwn_datahead sc_tx_inactive; 192 urtwn_datahead sc_tx_pending; 193 194 union urtwn_rom rom; 195 uint16_t last_rom_addr; 196 197 struct callout sc_calib_to; 198 struct callout sc_watchdog_ch; 199 struct mtx sc_mtx; 200 uint32_t keys_bmap; 201 202 struct urtwn_cmdq cmdq[URTWN_CMDQ_SIZE]; 203 struct mtx cmdq_mtx; 204 struct task cmdq_task; 205 uint8_t cmdq_first; 206 uint8_t cmdq_last; 207 208 uint32_t rf_chnlbw[R92C_MAX_CHAINS]; 209 struct usb_xfer *sc_xfer[URTWN_N_TRANSFER]; 210 211 struct urtwn_rx_radiotap_header sc_rxtap; 212 struct urtwn_tx_radiotap_header sc_txtap; 213}; 214 215#define URTWN_LOCK(sc) mtx_lock(&(sc)->sc_mtx) 216#define URTWN_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) 217#define URTWN_ASSERT_LOCKED(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED) 218 219#define URTWN_CMDQ_LOCK_INIT(sc) \ 220 mtx_init(&(sc)->cmdq_mtx, "cmdq lock", NULL, MTX_DEF) 221#define URTWN_CMDQ_LOCK(sc) mtx_lock(&(sc)->cmdq_mtx) 222#define URTWN_CMDQ_UNLOCK(sc) mtx_unlock(&(sc)->cmdq_mtx) 223#define URTWN_CMDQ_LOCK_DESTROY(sc) mtx_destroy(&(sc)->cmdq_mtx) 224 225#define URTWN_NT_LOCK_INIT(sc) \ 226 mtx_init(&(sc)->nt_mtx, "node table lock", NULL, MTX_DEF) 227#define URTWN_NT_LOCK(sc) mtx_lock(&(sc)->nt_mtx) 228#define URTWN_NT_UNLOCK(sc) mtx_unlock(&(sc)->nt_mtx) 229#define URTWN_NT_LOCK_DESTROY(sc) mtx_destroy(&(sc)->nt_mtx)
|