1 /* $OpenBSD: if_iwnvar.h,v 1.39 2020/10/11 07:05:28 mpi Exp $ */ 2 3 /*- 4 * Copyright (c) 2007, 2008 5 * 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 struct iwn_rx_radiotap_header { 21 struct ieee80211_radiotap_header wr_ihdr; 22 uint64_t wr_tsft; 23 uint8_t wr_flags; 24 uint8_t wr_rate; 25 uint16_t wr_chan_freq; 26 uint16_t wr_chan_flags; 27 int8_t wr_dbm_antsignal; 28 int8_t wr_dbm_antnoise; 29 } __packed; 30 31 #define IWN_RX_RADIOTAP_PRESENT \ 32 ((1 << IEEE80211_RADIOTAP_TSFT) | \ 33 (1 << IEEE80211_RADIOTAP_FLAGS) | \ 34 (1 << IEEE80211_RADIOTAP_RATE) | \ 35 (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 36 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \ 37 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)) 38 39 struct iwn_tx_radiotap_header { 40 struct ieee80211_radiotap_header wt_ihdr; 41 uint8_t wt_flags; 42 uint8_t wt_rate; 43 uint16_t wt_chan_freq; 44 uint16_t wt_chan_flags; 45 } __packed; 46 47 #define IWN_TX_RADIOTAP_PRESENT \ 48 ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 49 (1 << IEEE80211_RADIOTAP_RATE) | \ 50 (1 << IEEE80211_RADIOTAP_CHANNEL)) 51 52 struct iwn_dma_info { 53 bus_dma_tag_t tag; 54 bus_dmamap_t map; 55 bus_dma_segment_t seg; 56 bus_addr_t paddr; 57 caddr_t vaddr; 58 bus_size_t size; 59 }; 60 61 struct iwn_tx_data { 62 bus_dmamap_t map; 63 bus_addr_t cmd_paddr; 64 bus_addr_t scratch_paddr; 65 struct mbuf *m; 66 struct ieee80211_node *ni; 67 int totlen; 68 int retries; 69 int txfail; 70 int txmcs; 71 int txrate; 72 73 /* A-MPDU subframes */ 74 int ampdu_id; 75 int ampdu_txmcs; 76 int ampdu_nframes; 77 int ampdu_size; 78 }; 79 80 struct iwn_tx_ring { 81 struct iwn_dma_info desc_dma; 82 struct iwn_dma_info cmd_dma; 83 struct iwn_tx_desc *desc; 84 struct iwn_tx_cmd *cmd; 85 struct iwn_tx_data data[IWN_TX_RING_COUNT]; 86 int qid; 87 int queued; 88 int cur; 89 int read; 90 }; 91 92 struct iwn_softc; 93 94 struct iwn_rx_data { 95 struct mbuf *m; 96 bus_dmamap_t map; 97 }; 98 99 struct iwn_rx_ring { 100 struct iwn_dma_info desc_dma; 101 struct iwn_dma_info stat_dma; 102 uint32_t *desc; 103 struct iwn_rx_status *stat; 104 struct iwn_rx_data data[IWN_RX_RING_COUNT]; 105 int cur; 106 }; 107 108 struct iwn_node { 109 struct ieee80211_node ni; /* must be the first */ 110 struct ieee80211_amrr_node amn; 111 struct ieee80211_mira_node mn; 112 uint16_t disable_tid; 113 uint8_t id; 114 uint8_t ridx[IEEE80211_RATE_MAXSIZE]; 115 uint32_t next_ampdu_id; 116 }; 117 118 struct iwn_calib_state { 119 uint8_t state; 120 #define IWN_CALIB_STATE_INIT 0 121 #define IWN_CALIB_STATE_ASSOC 1 122 #define IWN_CALIB_STATE_RUN 2 123 124 u_int nbeacons; 125 uint32_t noise[3]; 126 uint32_t rssi[3]; 127 uint32_t ofdm_x1; 128 uint32_t ofdm_mrc_x1; 129 uint32_t ofdm_x4; 130 uint32_t ofdm_mrc_x4; 131 uint32_t cck_x4; 132 uint32_t cck_mrc_x4; 133 uint32_t bad_plcp_ofdm; 134 uint32_t fa_ofdm; 135 uint32_t bad_plcp_cck; 136 uint32_t fa_cck; 137 uint32_t low_fa; 138 uint8_t cck_state; 139 #define IWN_CCK_STATE_INIT 0 140 #define IWN_CCK_STATE_LOFA 1 141 #define IWN_CCK_STATE_HIFA 2 142 143 uint8_t noise_samples[20]; 144 u_int cur_noise_sample; 145 uint8_t noise_ref; 146 uint32_t energy_samples[10]; 147 u_int cur_energy_sample; 148 uint32_t energy_cck; 149 }; 150 151 struct iwn_calib_info { 152 uint8_t *buf; 153 u_int len; 154 }; 155 156 struct iwn_fw_part { 157 const uint8_t *text; 158 uint32_t textsz; 159 const uint8_t *data; 160 uint32_t datasz; 161 }; 162 163 struct iwn_fw_info { 164 u_char *data; 165 size_t size; 166 struct iwn_fw_part init; 167 struct iwn_fw_part main; 168 struct iwn_fw_part boot; 169 }; 170 171 struct iwn_ops { 172 int (*load_firmware)(struct iwn_softc *); 173 void (*read_eeprom)(struct iwn_softc *); 174 int (*post_alive)(struct iwn_softc *); 175 int (*nic_config)(struct iwn_softc *); 176 void (*reset_sched)(struct iwn_softc *, int, int); 177 void (*update_sched)(struct iwn_softc *, int, int, uint8_t, 178 uint16_t); 179 int (*get_temperature)(struct iwn_softc *); 180 int (*get_rssi)(const struct iwn_rx_stat *); 181 int (*set_txpower)(struct iwn_softc *, int); 182 int (*init_gains)(struct iwn_softc *); 183 int (*set_gains)(struct iwn_softc *); 184 int (*add_node)(struct iwn_softc *, struct iwn_node_info *, 185 int); 186 void (*tx_done)(struct iwn_softc *, struct iwn_rx_desc *, 187 struct iwn_rx_data *); 188 void (*ampdu_tx_start)(struct iwn_softc *, 189 struct ieee80211_node *, uint8_t, uint16_t); 190 void (*ampdu_tx_stop)(struct iwn_softc *, uint8_t, 191 uint16_t); 192 }; 193 194 struct iwn_tx_ba { 195 struct iwn_node * wn; 196 }; 197 198 struct iwn_softc { 199 struct device sc_dev; 200 201 struct ieee80211com sc_ic; 202 int (*sc_newstate)(struct ieee80211com *, 203 enum ieee80211_state, int); 204 205 struct ieee80211_amrr amrr; 206 uint8_t fixed_ridx; 207 208 bus_dma_tag_t sc_dmat; 209 210 struct rwlock sc_rwlock; 211 u_int sc_flags; 212 #define IWN_FLAG_HAS_5GHZ (1 << 0) 213 #define IWN_FLAG_HAS_OTPROM (1 << 1) 214 #define IWN_FLAG_CALIB_DONE (1 << 2) 215 #define IWN_FLAG_USE_ICT (1 << 3) 216 #define IWN_FLAG_INTERNAL_PA (1 << 4) 217 #define IWN_FLAG_HAS_11N (1 << 6) 218 #define IWN_FLAG_ENH_SENS (1 << 7) 219 #define IWN_FLAG_ADV_BT_COEX (1 << 8) 220 #define IWN_FLAG_BGSCAN (1 << 9) 221 #define IWN_FLAG_SCANNING (1 << 10) 222 223 uint8_t hw_type; 224 225 struct iwn_ops ops; 226 const char *fwname; 227 const struct iwn_sensitivity_limits 228 *limits; 229 int ntxqs; 230 int first_agg_txq; 231 int agg_queue_mask; 232 int ndmachnls; 233 uint8_t broadcast_id; 234 int rxonsz; 235 int schedsz; 236 uint32_t fw_text_maxsz; 237 uint32_t fw_data_maxsz; 238 uint32_t fwsz; 239 bus_size_t sched_txfact_addr; 240 241 /* TX scheduler rings. */ 242 struct iwn_dma_info sched_dma; 243 uint16_t *sched; 244 uint32_t sched_base; 245 246 /* "Keep Warm" page. */ 247 struct iwn_dma_info kw_dma; 248 249 /* Firmware DMA transfer. */ 250 struct iwn_dma_info fw_dma; 251 252 /* ICT table. */ 253 struct iwn_dma_info ict_dma; 254 uint32_t *ict; 255 int ict_cur; 256 257 /* TX/RX rings. */ 258 struct iwn_tx_ring txq[IWN5000_NTXQUEUES]; 259 struct iwn_rx_ring rxq; 260 261 bus_space_tag_t sc_st; 262 bus_space_handle_t sc_sh; 263 void *sc_ih; 264 pci_chipset_tag_t sc_pct; 265 pcitag_t sc_pcitag; 266 bus_size_t sc_sz; 267 int sc_cap_off; /* PCIe Capabilities. */ 268 269 struct timeout calib_to; 270 int calib_cnt; 271 struct iwn_calib_state calib; 272 273 struct task init_task; 274 275 struct iwn_fw_info fw; 276 struct iwn_calib_info calibcmd[5]; 277 uint32_t errptr; 278 279 uint8_t bss_node_addr[IEEE80211_ADDR_LEN]; 280 281 struct iwn_rx_stat last_rx_stat; 282 int last_rx_valid; 283 #define IWN_LAST_RX_VALID 0x01 284 #define IWN_LAST_RX_AMPDU 0x02 285 struct iwn_ucode_info ucode_info; 286 struct iwn_rxon rxon; 287 uint32_t rawtemp; 288 int temp; 289 int noise; 290 uint32_t qfullmsk; 291 292 uint32_t prom_base; 293 struct iwn4965_eeprom_band 294 bands[IWN_NBANDS]; 295 uint16_t rfcfg; 296 uint8_t calib_ver; 297 char eeprom_domain[4]; 298 uint32_t eeprom_crystal; 299 int16_t eeprom_temp; 300 int16_t eeprom_voltage; 301 int16_t eeprom_rawtemp; 302 int8_t maxpwr2GHz; 303 int8_t maxpwr5GHz; 304 int8_t maxpwr[IEEE80211_CHAN_MAX]; 305 int8_t enh_maxpwr[35]; 306 307 uint8_t reset_noise_gain; 308 uint8_t noise_gain; 309 310 uint32_t tlv_feature_flags; 311 312 int32_t temp_off; 313 uint32_t int_mask; 314 uint8_t ntxchains; 315 uint8_t nrxchains; 316 uint8_t txchainmask; 317 uint8_t rxchainmask; 318 uint8_t chainmask; 319 320 int sc_tx_timer; 321 322 struct iwn_tx_ba sc_tx_ba[IEEE80211_NUM_TID]; 323 324 #if NBPFILTER > 0 325 caddr_t sc_drvbpf; 326 327 union { 328 struct iwn_rx_radiotap_header th; 329 uint8_t pad[IEEE80211_RADIOTAP_HDRLEN]; 330 } sc_rxtapu; 331 #define sc_rxtap sc_rxtapu.th 332 int sc_rxtap_len; 333 334 union { 335 struct iwn_tx_radiotap_header th; 336 uint8_t pad[IEEE80211_RADIOTAP_HDRLEN]; 337 } sc_txtapu; 338 #define sc_txtap sc_txtapu.th 339 int sc_txtap_len; 340 #endif 341 }; 342