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