1/* $NetBSD: if_runvar.h,v 1.9 2020/06/06 13:53:43 gson Exp $ */ 2/* $OpenBSD: if_runvar.h,v 1.8 2010/02/08 18:46:47 damien Exp $ */ 3 4/*- 5 * Copyright (c) 2008,2009 Damien Bergamini <damien.bergamini@free.fr> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20#define RUN_MAX_RXSZ \ 21 4096 22#if 0 23 (sizeof(uint32_t) + \ 24 sizeof(struct rt2860_rxwi) + \ 25 sizeof(uint16_t) + \ 26 MCLBYTES + \ 27 sizeof(struct rt2870_rxd)) 28#endif 29/* NB: "11" is the maximum number of padding bytes needed for Tx */ 30#define RUN_MAX_TXSZ \ 31 (sizeof(struct rt2870_txd) + \ 32 sizeof(struct rt2860_txwi) + \ 33 MCLBYTES + 11) 34 35#define RUN_TX_TIMEOUT 5000 /* ms */ 36 37#define RUN_RX_RING_COUNT 1 38#define RUN_TX_RING_COUNT 8 39 40#define RT2870_WCID_MAX 64 41#define RUN_AID2WCID(aid) ((aid) & 0xff) 42 43struct run_rx_radiotap_header { 44 struct ieee80211_radiotap_header wr_ihdr; 45 uint8_t wr_flags; 46 uint8_t wr_rate; 47 uint16_t wr_chan_freq; 48 uint16_t wr_chan_flags; 49 uint8_t wr_dbm_antsignal; 50 uint8_t wr_antenna; 51 uint8_t wr_antsignal; 52}; 53 54#define RUN_RX_RADIOTAP_PRESENT \ 55 (1 << IEEE80211_RADIOTAP_FLAGS | \ 56 1 << IEEE80211_RADIOTAP_RATE | \ 57 1 << IEEE80211_RADIOTAP_CHANNEL | \ 58 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL | \ 59 1 << IEEE80211_RADIOTAP_ANTENNA | \ 60 1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) 61 62struct run_tx_radiotap_header { 63 struct ieee80211_radiotap_header wt_ihdr; 64 uint8_t wt_flags; 65 uint8_t wt_rate; 66 uint16_t wt_chan_freq; 67 uint16_t wt_chan_flags; 68 uint8_t wt_hwqueue; 69}; 70 71#define RUN_TX_RADIOTAP_PRESENT \ 72 (1 << IEEE80211_RADIOTAP_FLAGS | \ 73 1 << IEEE80211_RADIOTAP_RATE | \ 74 1 << IEEE80211_RADIOTAP_CHANNEL/* | \ 75 1 << IEEE80211_RADIOTAP_HWQUEUE*/) 76 77struct run_softc; 78 79struct run_tx_data { 80 struct run_softc *sc; 81 struct usbd_xfer *xfer; 82 uint8_t *buf; 83 uint8_t qid; 84}; 85 86struct run_rx_data { 87 struct run_softc *sc; 88 struct usbd_xfer *xfer; 89 uint8_t *buf; 90}; 91 92struct run_tx_ring { 93 struct run_tx_data data[RUN_TX_RING_COUNT]; 94 struct usbd_pipe * pipeh; 95 int cur; 96 volatile unsigned queued; 97 uint8_t pipe_no; 98}; 99 100struct run_rx_ring { 101 struct run_rx_data data[RUN_RX_RING_COUNT]; 102 struct usbd_pipe * pipeh; 103 uint8_t pipe_no; 104}; 105 106struct run_host_cmd { 107 void (*cb)(struct run_softc *, void *); 108 uint8_t data[256]; 109}; 110 111struct run_cmd_newstate { 112 enum ieee80211_state state; 113 int arg; 114}; 115 116struct run_cmd_key { 117 struct ieee80211_key key; 118 uint16_t associd; 119}; 120 121#define RUN_HOST_CMD_RING_COUNT 32 122struct run_host_cmd_ring { 123 struct run_host_cmd cmd[RUN_HOST_CMD_RING_COUNT]; 124 int cur; 125 int next; 126 int queued; 127}; 128 129struct run_node { 130 struct ieee80211_node ni; 131 uint8_t ridx[IEEE80211_RATE_MAXSIZE]; 132 uint8_t ctl_ridx[IEEE80211_RATE_MAXSIZE]; 133}; 134 135#define RUN_MAXEPOUT 4 136 137struct run_softc { 138 device_t sc_dev; 139 struct ethercom sc_ec; 140#define sc_if sc_ec.ec_if 141 struct ieee80211com sc_ic; 142 int (*sc_newstate)(struct ieee80211com *, 143 enum ieee80211_state, int); 144 int (*sc_srom_read)(struct run_softc *, 145 uint16_t, uint16_t *); 146 147 kmutex_t sc_media_mtx; /* XXX */ 148 149 struct usbd_device * sc_udev; 150 struct usbd_interface * sc_iface; 151 152 uint16_t mac_ver; 153 uint16_t mac_rev; 154 uint16_t rf_rev; 155 uint8_t freq; 156 uint8_t ntxchains; 157 uint8_t nrxchains; 158 int fixed_ridx; 159 160 uint8_t bbp25; 161 uint8_t bbp26; 162 uint8_t rf24_20mhz; 163 uint8_t rf24_40mhz; 164 uint8_t patch_dac; 165 uint8_t rfswitch; 166 uint8_t ext_2ghz_lna; 167 uint8_t ext_5ghz_lna; 168 uint8_t calib_2ghz; 169 uint8_t calib_5ghz; 170 uint8_t txmixgain_2ghz; 171 uint8_t txmixgain_5ghz; 172 int8_t txpow1[54]; 173 int8_t txpow2[54]; 174 int8_t txpow3[54]; 175 int8_t rssi_2ghz[3]; 176 int8_t rssi_5ghz[3]; 177 uint8_t lna[4]; 178 179 struct { 180 uint8_t reg; 181 uint8_t val; 182 } bbp[10], rf[10]; 183 uint8_t leds; 184 uint16_t led[3]; 185 uint32_t txpow20mhz[5]; 186 uint32_t txpow40mhz_2ghz[5]; 187 uint32_t txpow40mhz_5ghz[5]; 188 189 struct usb_task sc_task; 190 191 struct ieee80211_amrr amrr; 192 struct ieee80211_amrr_node amn; 193 194 callout_t scan_to; 195 callout_t calib_to; 196 197 struct run_rx_ring rxq; 198 struct run_tx_ring txq[RUN_MAXEPOUT]; 199 struct run_host_cmd_ring cmdq; 200 uint8_t qfullmsk; 201 int sc_tx_timer; 202 struct ieee80211_beacon_offsets sc_bo; 203 int sc_flags; 204#define RUN_FWLOADED (1 << 0) 205#define RUN_DETACHING (1 << 1) 206#define RUN_USE_BLOCK_WRITE (1 << 2) 207 208 struct bpf_if * sc_drvbpf; 209 210 union { 211 struct run_rx_radiotap_header th; 212 uint8_t pad[64]; 213 } sc_rxtapu; 214#define sc_rxtap sc_rxtapu.th 215 int sc_rxtap_len; 216 217 union { 218 struct run_tx_radiotap_header th; 219 uint8_t pad[64]; 220 } sc_txtapu; 221#define sc_txtap sc_txtapu.th 222 int sc_txtap_len; 223}; 224