1 /* $OpenBSD: if_wpivar.h,v 1.25 2013/11/28 20:07:32 kettenis Exp $ */ 2 3 /*- 4 * Copyright (c) 2006-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 wpi_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 uint8_t wr_antenna; 30 } __packed; 31 32 #define WPI_RX_RADIOTAP_PRESENT \ 33 ((1 << IEEE80211_RADIOTAP_TSFT) | \ 34 (1 << IEEE80211_RADIOTAP_FLAGS) | \ 35 (1 << IEEE80211_RADIOTAP_RATE) | \ 36 (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 37 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \ 38 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | \ 39 (1 << IEEE80211_RADIOTAP_ANTENNA)) 40 41 struct wpi_tx_radiotap_header { 42 struct ieee80211_radiotap_header wt_ihdr; 43 uint8_t wt_flags; 44 uint8_t wt_rate; 45 uint16_t wt_chan_freq; 46 uint16_t wt_chan_flags; 47 uint8_t wt_hwqueue; 48 } __packed; 49 50 #define WPI_TX_RADIOTAP_PRESENT \ 51 ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 52 (1 << IEEE80211_RADIOTAP_RATE) | \ 53 (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 54 (1 << IEEE80211_RADIOTAP_HWQUEUE)) 55 56 struct wpi_dma_info { 57 bus_dma_tag_t tag; 58 bus_dmamap_t map; 59 bus_dma_segment_t seg; 60 bus_addr_t paddr; 61 caddr_t vaddr; 62 bus_size_t size; 63 }; 64 65 struct wpi_tx_data { 66 bus_dmamap_t map; 67 bus_addr_t cmd_paddr; 68 struct mbuf *m; 69 struct ieee80211_node *ni; 70 }; 71 72 struct wpi_tx_ring { 73 struct wpi_dma_info desc_dma; 74 struct wpi_dma_info cmd_dma; 75 struct wpi_tx_desc *desc; 76 struct wpi_tx_cmd *cmd; 77 struct wpi_tx_data data[WPI_TX_RING_COUNT]; 78 int qid; 79 int queued; 80 int cur; 81 }; 82 83 struct wpi_softc; 84 85 struct wpi_rx_data { 86 struct mbuf *m; 87 bus_dmamap_t map; 88 }; 89 90 struct wpi_rx_ring { 91 struct wpi_dma_info desc_dma; 92 uint32_t *desc; 93 struct wpi_rx_data data[WPI_RX_RING_COUNT]; 94 int cur; 95 }; 96 97 struct wpi_node { 98 struct ieee80211_node ni; /* must be the first */ 99 struct ieee80211_amrr_node amn; 100 uint8_t id; 101 uint8_t ridx[IEEE80211_RATE_MAXSIZE]; 102 }; 103 104 struct wpi_power_sample { 105 uint8_t index; 106 int8_t power; 107 }; 108 109 struct wpi_power_group { 110 #define WPI_SAMPLES_COUNT 5 111 struct wpi_power_sample samples[WPI_SAMPLES_COUNT]; 112 uint8_t chan; 113 int8_t maxpwr; 114 int16_t temp; 115 }; 116 117 struct wpi_fw_part { 118 const uint8_t *text; 119 uint32_t textsz; 120 const uint8_t *data; 121 uint32_t datasz; 122 }; 123 124 struct wpi_fw_info { 125 u_char *data; 126 struct wpi_fw_part init; 127 struct wpi_fw_part main; 128 struct wpi_fw_part boot; 129 }; 130 131 struct wpi_softc { 132 struct device sc_dev; 133 134 struct ieee80211com sc_ic; 135 int (*sc_newstate)(struct ieee80211com *, 136 enum ieee80211_state, int); 137 138 struct ieee80211_amrr amrr; 139 uint8_t fixed_ridx; 140 141 bus_dma_tag_t sc_dmat; 142 143 u_int sc_flags; 144 #define WPI_FLAG_HAS_5GHZ (1 << 0) 145 #define WPI_FLAG_BUSY (1 << 1) 146 147 /* Shared area. */ 148 struct wpi_dma_info shared_dma; 149 struct wpi_shared *shared; 150 151 /* Firmware DMA transfer. */ 152 struct wpi_dma_info fw_dma; 153 154 /* TX/RX rings. */ 155 struct wpi_tx_ring txq[WPI_NTXQUEUES]; 156 struct wpi_rx_ring rxq; 157 158 bus_space_tag_t sc_st; 159 bus_space_handle_t sc_sh; 160 void *sc_ih; 161 pci_chipset_tag_t sc_pct; 162 pcitag_t sc_pcitag; 163 bus_size_t sc_sz; 164 int sc_cap_off; /* PCIe Capabilities. */ 165 166 struct timeout calib_to; 167 int calib_cnt; 168 169 struct task init_task; 170 171 struct wpi_fw_info fw; 172 uint32_t errptr; 173 174 struct wpi_rxon rxon; 175 int temp; 176 uint32_t qfullmsk; 177 178 uint8_t cap; 179 uint16_t rev; 180 uint8_t type; 181 struct wpi_power_group groups[WPI_POWER_GROUPS_COUNT]; 182 int8_t maxpwr[IEEE80211_CHAN_MAX]; 183 184 int sc_tx_timer; 185 186 #if NBPFILTER > 0 187 caddr_t sc_drvbpf; 188 189 union { 190 struct wpi_rx_radiotap_header th; 191 uint8_t pad[IEEE80211_RADIOTAP_HDRLEN]; 192 } sc_rxtapu; 193 #define sc_rxtap sc_rxtapu.th 194 int sc_rxtap_len; 195 196 union { 197 struct wpi_tx_radiotap_header th; 198 uint8_t pad[IEEE80211_RADIOTAP_HDRLEN]; 199 } sc_txtapu; 200 #define sc_txtap sc_txtapu.th 201 int sc_txtap_len; 202 #endif 203 }; 204