1 1.22 sevan /* $NetBSD: if_iwnvar.h,v 1.22 2020/03/20 16:35:41 sevan Exp $ */ 2 1.16 nonaka /* $OpenBSD: if_iwnvar.h,v 1.28 2014/09/09 18:55:08 sthen Exp $ */ 3 1.1 ober 4 1.1 ober /*- 5 1.6 christos * Copyright (c) 2007, 2008 6 1.1 ober * Damien Bergamini <damien.bergamini (at) free.fr> 7 1.1 ober * 8 1.1 ober * Permission to use, copy, modify, and distribute this software for any 9 1.1 ober * purpose with or without fee is hereby granted, provided that the above 10 1.1 ober * copyright notice and this permission notice appear in all copies. 11 1.1 ober * 12 1.1 ober * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 1.1 ober * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 1.1 ober * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 1.1 ober * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 1.1 ober * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 1.1 ober * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 1.1 ober * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 1.1 ober */ 20 1.1 ober 21 1.9 christos /* XXX Added for NetBSD */ 22 1.6 christos #define IEEE80211_NO_HT 23 1.6 christos 24 1.1 ober struct iwn_rx_radiotap_header { 25 1.1 ober struct ieee80211_radiotap_header wr_ihdr; 26 1.1 ober uint64_t wr_tsft; 27 1.1 ober uint8_t wr_flags; 28 1.1 ober uint8_t wr_rate; 29 1.1 ober uint16_t wr_chan_freq; 30 1.1 ober uint16_t wr_chan_flags; 31 1.1 ober int8_t wr_dbm_antsignal; 32 1.1 ober int8_t wr_dbm_antnoise; 33 1.21 mrg }; 34 1.1 ober 35 1.1 ober #define IWN_RX_RADIOTAP_PRESENT \ 36 1.1 ober ((1 << IEEE80211_RADIOTAP_TSFT) | \ 37 1.6 christos (1 << IEEE80211_RADIOTAP_FLAGS) | \ 38 1.6 christos (1 << IEEE80211_RADIOTAP_RATE) | \ 39 1.6 christos (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 40 1.6 christos (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \ 41 1.6 christos (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)) 42 1.1 ober 43 1.1 ober struct iwn_tx_radiotap_header { 44 1.1 ober struct ieee80211_radiotap_header wt_ihdr; 45 1.1 ober uint8_t wt_flags; 46 1.1 ober uint8_t wt_rate; 47 1.1 ober uint16_t wt_chan_freq; 48 1.1 ober uint16_t wt_chan_flags; 49 1.1 ober uint8_t wt_hwqueue; 50 1.21 mrg }; 51 1.1 ober 52 1.9 christos #define IWN_TX_RADIOTAP_PRESENT \ 53 1.9 christos ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 54 1.9 christos (1 << IEEE80211_RADIOTAP_RATE) | \ 55 1.6 christos (1 << IEEE80211_RADIOTAP_CHANNEL)) 56 1.9 christos /* XXX OpenBSD also includes IEEE80211_RADIOTAP_HWQUEUE */ 57 1.1 ober 58 1.1 ober struct iwn_dma_info { 59 1.1 ober bus_dma_tag_t tag; 60 1.1 ober bus_dmamap_t map; 61 1.1 ober bus_dma_segment_t seg; 62 1.1 ober bus_addr_t paddr; 63 1.1 ober void * vaddr; 64 1.1 ober bus_size_t size; 65 1.1 ober }; 66 1.1 ober 67 1.1 ober struct iwn_tx_data { 68 1.1 ober bus_dmamap_t map; 69 1.6 christos bus_addr_t cmd_paddr; 70 1.6 christos bus_addr_t scratch_paddr; 71 1.1 ober struct mbuf *m; 72 1.1 ober struct ieee80211_node *ni; 73 1.1 ober }; 74 1.1 ober 75 1.1 ober struct iwn_tx_ring { 76 1.1 ober struct iwn_dma_info desc_dma; 77 1.1 ober struct iwn_dma_info cmd_dma; 78 1.1 ober struct iwn_tx_desc *desc; 79 1.1 ober struct iwn_tx_cmd *cmd; 80 1.6 christos struct iwn_tx_data data[IWN_TX_RING_COUNT]; 81 1.1 ober int qid; 82 1.1 ober int queued; 83 1.1 ober int cur; 84 1.1 ober }; 85 1.1 ober 86 1.9 christos #define IWN_RBUF_COUNT (IWN_RX_RING_COUNT + 32) 87 1.1 ober 88 1.1 ober struct iwn_softc; 89 1.1 ober 90 1.1 ober struct iwn_rbuf { 91 1.1 ober struct iwn_softc *sc; 92 1.1 ober void * vaddr; 93 1.1 ober bus_addr_t paddr; 94 1.1 ober SLIST_ENTRY(iwn_rbuf) next; 95 1.1 ober }; 96 1.1 ober 97 1.1 ober struct iwn_rx_data { 98 1.1 ober struct mbuf *m; 99 1.6 christos bus_dmamap_t map; 100 1.1 ober }; 101 1.1 ober 102 1.1 ober struct iwn_rx_ring { 103 1.1 ober struct iwn_dma_info desc_dma; 104 1.6 christos struct iwn_dma_info stat_dma; 105 1.1 ober struct iwn_dma_info buf_dma; 106 1.1 ober uint32_t *desc; 107 1.6 christos struct iwn_rx_status *stat; 108 1.1 ober struct iwn_rx_data data[IWN_RX_RING_COUNT]; 109 1.1 ober struct iwn_rbuf rbuf[IWN_RBUF_COUNT]; 110 1.6 christos kmutex_t freelist_mtx; 111 1.1 ober SLIST_HEAD(, iwn_rbuf) freelist; 112 1.1 ober int nb_free_entries; 113 1.1 ober int cur; 114 1.1 ober }; 115 1.1 ober 116 1.1 ober struct iwn_node { 117 1.1 ober struct ieee80211_node ni; /* must be the first */ 118 1.1 ober struct ieee80211_amrr_node amn; 119 1.6 christos uint16_t disable_tid; 120 1.6 christos uint8_t id; 121 1.6 christos uint8_t ridx[IEEE80211_RATE_MAXSIZE]; 122 1.1 ober }; 123 1.1 ober 124 1.1 ober struct iwn_calib_state { 125 1.1 ober uint8_t state; 126 1.1 ober #define IWN_CALIB_STATE_INIT 0 127 1.1 ober #define IWN_CALIB_STATE_ASSOC 1 128 1.1 ober #define IWN_CALIB_STATE_RUN 2 129 1.1 ober 130 1.1 ober u_int nbeacons; 131 1.1 ober uint32_t noise[3]; 132 1.1 ober uint32_t rssi[3]; 133 1.6 christos uint32_t ofdm_x1; 134 1.6 christos uint32_t ofdm_mrc_x1; 135 1.6 christos uint32_t ofdm_x4; 136 1.6 christos uint32_t ofdm_mrc_x4; 137 1.6 christos uint32_t cck_x4; 138 1.6 christos uint32_t cck_mrc_x4; 139 1.1 ober uint32_t bad_plcp_ofdm; 140 1.1 ober uint32_t fa_ofdm; 141 1.1 ober uint32_t bad_plcp_cck; 142 1.1 ober uint32_t fa_cck; 143 1.1 ober uint32_t low_fa; 144 1.1 ober uint8_t cck_state; 145 1.1 ober #define IWN_CCK_STATE_INIT 0 146 1.1 ober #define IWN_CCK_STATE_LOFA 1 147 1.1 ober #define IWN_CCK_STATE_HIFA 2 148 1.1 ober 149 1.1 ober uint8_t noise_samples[20]; 150 1.1 ober u_int cur_noise_sample; 151 1.1 ober uint8_t noise_ref; 152 1.1 ober uint32_t energy_samples[10]; 153 1.1 ober u_int cur_energy_sample; 154 1.1 ober uint32_t energy_cck; 155 1.1 ober }; 156 1.1 ober 157 1.6 christos struct iwn_calib_info { 158 1.6 christos uint8_t *buf; 159 1.6 christos u_int len; 160 1.6 christos }; 161 1.6 christos 162 1.6 christos struct iwn_fw_part { 163 1.6 christos const uint8_t *text; 164 1.6 christos uint32_t textsz; 165 1.6 christos const uint8_t *data; 166 1.6 christos uint32_t datasz; 167 1.6 christos }; 168 1.6 christos 169 1.6 christos struct iwn_fw_info { 170 1.6 christos u_char *data; 171 1.11 christos size_t size; 172 1.6 christos struct iwn_fw_part init; 173 1.6 christos struct iwn_fw_part main; 174 1.6 christos struct iwn_fw_part boot; 175 1.6 christos }; 176 1.6 christos 177 1.13 christos struct iwn_ops { 178 1.6 christos int (*load_firmware)(struct iwn_softc *); 179 1.6 christos void (*read_eeprom)(struct iwn_softc *); 180 1.6 christos int (*post_alive)(struct iwn_softc *); 181 1.6 christos int (*nic_config)(struct iwn_softc *); 182 1.15 prlw1 int (*config_bt_coex)(struct iwn_softc *); 183 1.6 christos void (*update_sched)(struct iwn_softc *, int, int, uint8_t, 184 1.6 christos uint16_t); 185 1.6 christos int (*get_temperature)(struct iwn_softc *); 186 1.6 christos int (*get_rssi)(const struct iwn_rx_stat *); 187 1.6 christos int (*set_txpower)(struct iwn_softc *, int); 188 1.6 christos int (*init_gains)(struct iwn_softc *); 189 1.6 christos int (*set_gains)(struct iwn_softc *); 190 1.6 christos int (*add_node)(struct iwn_softc *, struct iwn_node_info *, 191 1.6 christos int); 192 1.6 christos void (*tx_done)(struct iwn_softc *, struct iwn_rx_desc *, 193 1.6 christos struct iwn_rx_data *); 194 1.6 christos #ifndef IEEE80211_NO_HT 195 1.6 christos void (*ampdu_tx_start)(struct iwn_softc *, 196 1.6 christos struct ieee80211_node *, uint8_t, uint16_t); 197 1.6 christos void (*ampdu_tx_stop)(struct iwn_softc *, uint8_t, 198 1.6 christos uint16_t); 199 1.6 christos #endif 200 1.6 christos }; 201 1.6 christos 202 1.1 ober struct iwn_softc { 203 1.6 christos device_t sc_dev; 204 1.6 christos 205 1.6 christos struct ethercom sc_ec; 206 1.1 ober struct ieee80211com sc_ic; 207 1.1 ober int (*sc_newstate)(struct ieee80211com *, 208 1.6 christos enum ieee80211_state, int); 209 1.1 ober 210 1.1 ober struct ieee80211_amrr amrr; 211 1.6 christos uint8_t fixed_ridx; 212 1.1 ober 213 1.1 ober bus_dma_tag_t sc_dmat; 214 1.1 ober 215 1.6 christos u_int sc_flags; 216 1.6 christos #define IWN_FLAG_HAS_5GHZ (1 << 0) 217 1.9 christos #define IWN_FLAG_HAS_OTPROM (1 << 1) 218 1.9 christos #define IWN_FLAG_CALIB_DONE (1 << 2) 219 1.9 christos #define IWN_FLAG_USE_ICT (1 << 3) 220 1.9 christos #define IWN_FLAG_INTERNAL_PA (1 << 4) 221 1.13 christos #define IWN_FLAG_HAS_11N (1 << 6) 222 1.13 christos #define IWN_FLAG_ENH_SENS (1 << 7) 223 1.9 christos /* Added for NetBSD */ 224 1.17 nonaka #define IWN_FLAG_HW_INITED (1 << 8) 225 1.17 nonaka #define IWN_FLAG_SCANNING_2GHZ (1 << 9) 226 1.17 nonaka #define IWN_FLAG_SCANNING_5GHZ (1 << 10) 227 1.17 nonaka #define IWN_FLAG_SCANNING (IWN_FLAG_SCANNING_2GHZ|IWN_FLAG_SCANNING_5GHZ) 228 1.19 nonaka #define IWN_FLAG_ATTACHED (1 << 11) 229 1.6 christos 230 1.6 christos uint8_t hw_type; 231 1.13 christos 232 1.13 christos struct iwn_ops ops; 233 1.6 christos const char *fwname; 234 1.9 christos const struct iwn_sensitivity_limits 235 1.9 christos *limits; 236 1.13 christos int ntxqs; 237 1.13 christos int ndmachnls; 238 1.13 christos uint8_t broadcast_id; 239 1.13 christos int rxonsz; 240 1.13 christos int schedsz; 241 1.13 christos uint32_t fw_text_maxsz; 242 1.13 christos uint32_t fw_data_maxsz; 243 1.13 christos uint32_t fwsz; 244 1.13 christos bus_size_t sched_txfact_addr; 245 1.6 christos 246 1.6 christos /* TX scheduler rings. */ 247 1.6 christos struct iwn_dma_info sched_dma; 248 1.6 christos uint16_t *sched; 249 1.6 christos uint32_t sched_base; 250 1.1 ober 251 1.6 christos /* "Keep Warm" page. */ 252 1.1 ober struct iwn_dma_info kw_dma; 253 1.1 ober 254 1.6 christos /* Firmware DMA transfer. */ 255 1.1 ober struct iwn_dma_info fw_dma; 256 1.1 ober 257 1.9 christos /* ICT table. */ 258 1.9 christos struct iwn_dma_info ict_dma; 259 1.9 christos uint32_t *ict; 260 1.9 christos int ict_cur; 261 1.9 christos 262 1.6 christos /* TX/RX rings. */ 263 1.6 christos struct iwn_tx_ring txq[IWN5000_NTXQUEUES]; 264 1.1 ober struct iwn_rx_ring rxq; 265 1.1 ober 266 1.1 ober bus_space_tag_t sc_st; 267 1.1 ober bus_space_handle_t sc_sh; 268 1.18 nonaka pci_intr_handle_t *sc_pihp; 269 1.1 ober void *sc_ih; 270 1.19 nonaka void *sc_soft_ih; 271 1.1 ober pci_chipset_tag_t sc_pct; 272 1.1 ober pcitag_t sc_pcitag; 273 1.1 ober bus_size_t sc_sz; 274 1.6 christos int sc_cap_off; /* PCIe Capabilities. */ 275 1.9 christos struct sysmon_envsys *sc_sme; 276 1.9 christos envsys_data_t sc_sensor; 277 1.6 christos callout_t calib_to; 278 1.1 ober int calib_cnt; 279 1.1 ober struct iwn_calib_state calib; 280 1.1 ober 281 1.6 christos struct iwn_fw_info fw; 282 1.6 christos struct iwn_calib_info calibcmd[5]; 283 1.6 christos uint32_t errptr; 284 1.6 christos 285 1.1 ober struct iwn_rx_stat last_rx_stat; 286 1.1 ober int last_rx_valid; 287 1.1 ober struct iwn_ucode_info ucode_info; 288 1.6 christos struct iwn_rxon rxon; 289 1.1 ober uint32_t rawtemp; 290 1.1 ober int temp; 291 1.1 ober int noise; 292 1.6 christos uint32_t qfullmsk; 293 1.1 ober 294 1.9 christos uint32_t prom_base; 295 1.6 christos struct iwn4965_eeprom_band 296 1.6 christos bands[IWN_NBANDS]; 297 1.6 christos uint16_t rfcfg; 298 1.9 christos uint8_t calib_ver; 299 1.6 christos char eeprom_domain[4]; 300 1.6 christos uint32_t eeprom_crystal; 301 1.13 christos int16_t eeprom_temp; 302 1.1 ober int16_t eeprom_voltage; 303 1.16 nonaka int16_t eeprom_rawtemp; 304 1.1 ober int8_t maxpwr2GHz; 305 1.1 ober int8_t maxpwr5GHz; 306 1.1 ober int8_t maxpwr[IEEE80211_CHAN_MAX]; 307 1.9 christos int8_t enh_maxpwr[35]; 308 1.1 ober 309 1.16 nonaka uint8_t reset_noise_gain; 310 1.16 nonaka uint8_t noise_gain; 311 1.16 nonaka 312 1.16 nonaka uint32_t tlv_feature_flags; 313 1.16 nonaka 314 1.9 christos int32_t temp_off; 315 1.9 christos uint32_t int_mask; 316 1.6 christos uint8_t ntxchains; 317 1.6 christos uint8_t nrxchains; 318 1.9 christos uint8_t txchainmask; 319 1.9 christos uint8_t rxchainmask; 320 1.9 christos uint8_t chainmask; 321 1.6 christos 322 1.1 ober int sc_tx_timer; 323 1.6 christos void *powerhook; 324 1.1 ober 325 1.7 pooka struct bpf_if * sc_drvbpf; 326 1.1 ober 327 1.22 sevan kmutex_t sc_media_mtx; /* XXX */ 328 1.22 sevan 329 1.1 ober union { 330 1.1 ober struct iwn_rx_radiotap_header th; 331 1.1 ober uint8_t pad[IEEE80211_RADIOTAP_HDRLEN]; 332 1.1 ober } sc_rxtapu; 333 1.1 ober #define sc_rxtap sc_rxtapu.th 334 1.1 ober int sc_rxtap_len; 335 1.1 ober 336 1.1 ober union { 337 1.1 ober struct iwn_tx_radiotap_header th; 338 1.1 ober uint8_t pad[IEEE80211_RADIOTAP_HDRLEN]; 339 1.1 ober } sc_txtapu; 340 1.1 ober #define sc_txtap sc_txtapu.th 341 1.1 ober int sc_txtap_len; 342 1.12 christos 343 1.20 mlelstv #define IWN_UCODE_API(ver) (((ver) & 0x0000ff00) >> 8) 344 1.20 mlelstv uint32_t ucode_rev; 345 1.20 mlelstv 346 1.12 christos kmutex_t sc_mtx; /* mutex for init/stop */ 347 1.12 christos 348 1.20 mlelstv int sc_beacon_wait; /* defer/skip sending */ 349 1.1 ober }; 350 1.9 christos 351