if_wpivar.h revision 1.20
1/* $NetBSD: if_wpivar.h,v 1.20 2017/02/02 03:41:22 jakllsch Exp $ */ 2 3/*- 4 * Copyright (c) 2006 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 20struct 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}; 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 41struct 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}; 49 50#define WPI_TX_RADIOTAP_PRESENT \ 51 ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 52 (1 << IEEE80211_RADIOTAP_RATE) | \ 53 (1 << IEEE80211_RADIOTAP_CHANNEL)) 54 55struct wpi_dma_info { 56 bus_dma_tag_t tag; 57 bus_dmamap_t map; 58 bus_dma_segment_t seg; 59 bus_addr_t paddr; 60 void * vaddr; 61 bus_size_t size; 62}; 63 64struct wpi_tx_data { 65 bus_dmamap_t map; 66 struct mbuf *m; 67 struct ieee80211_node *ni; 68}; 69 70struct wpi_tx_ring { 71 struct wpi_dma_info desc_dma; 72 struct wpi_dma_info cmd_dma; 73 struct wpi_tx_desc *desc; 74 struct wpi_tx_cmd *cmd; 75 struct wpi_tx_data *data; 76 int qid; 77 int count; 78 int queued; 79 int cur; 80}; 81 82#define WPI_RBUF_COUNT (WPI_RX_RING_COUNT * 2) 83 84struct wpi_softc; 85 86struct wpi_rbuf { 87 struct wpi_softc *sc; 88 void * vaddr; 89 bus_addr_t paddr; 90 SLIST_ENTRY(wpi_rbuf) next; 91}; 92 93struct wpi_rx_data { 94 bus_dmamap_t map; 95 struct mbuf *m; 96}; 97 98struct wpi_rx_ring { 99 struct wpi_dma_info desc_dma; 100 struct wpi_dma_info buf_dma; 101 uint32_t *desc; 102 struct wpi_rx_data data[WPI_RX_RING_COUNT]; 103 struct wpi_rbuf rbuf[WPI_RBUF_COUNT]; 104 SLIST_HEAD(, wpi_rbuf) freelist; 105 kmutex_t freelist_mtx; 106 int cur; 107}; 108 109struct wpi_node { 110 struct ieee80211_node ni; /* must be the first */ 111 struct ieee80211_amrr_node amn; 112}; 113 114struct wpi_power_sample { 115 uint8_t index; 116 int8_t power; 117}; 118 119struct wpi_power_group { 120#define WPI_SAMPLES_COUNT 5 121 struct wpi_power_sample samples[WPI_SAMPLES_COUNT]; 122 uint8_t chan; 123 int8_t maxpwr; 124 int16_t temp; 125}; 126 127struct wpi_softc { 128 device_t sc_dev; 129 struct ethercom sc_ec; 130 struct ieee80211com sc_ic; 131 int (*sc_newstate)(struct ieee80211com *, 132 enum ieee80211_state, int); 133 134 struct ieee80211_amrr amrr; 135 136 bus_dma_tag_t sc_dmat; 137 138 /* shared area */ 139 struct wpi_dma_info shared_dma; 140 struct wpi_shared *shared; 141 142 /* firmware DMA transfer */ 143 struct wpi_dma_info fw_dma; 144 bool fw_used; 145 146 struct wpi_tx_ring txq[4]; 147 struct wpi_tx_ring cmdq; 148 struct wpi_rx_ring rxq; 149 150 bus_space_tag_t sc_st; 151 bus_space_handle_t sc_sh; 152 void *sc_ih; 153 pci_intr_handle_t *sc_pihp; 154 pci_chipset_tag_t sc_pct; 155 pcitag_t sc_pcitag; 156 bus_size_t sc_sz; 157 158 struct callout calib_to; 159 int calib_cnt; 160 161 struct wpi_config config; 162 int temp; 163 164 uint8_t cap; 165 uint16_t rev; 166 uint8_t type; 167 struct wpi_power_group groups[WPI_POWER_GROUPS_COUNT]; 168 int8_t maxpwr[IEEE80211_CHAN_MAX]; 169 170 int sc_tx_timer; 171 172 struct bpf_if * sc_drvbpf; 173 174 union { 175 struct wpi_rx_radiotap_header th; 176 uint8_t pad[IEEE80211_RADIOTAP_HDRLEN]; 177 } sc_rxtapu; 178#define sc_rxtap sc_rxtapu.th 179 int sc_rxtap_len; 180 181 union { 182 struct wpi_tx_radiotap_header th; 183 uint8_t pad[IEEE80211_RADIOTAP_HDRLEN]; 184 } sc_txtapu; 185#define sc_txtap sc_txtapu.th 186 int sc_txtap_len; 187 188 bool is_scanning; 189 190 struct sysctllog *sc_sysctllog; 191 struct sysmon_pswitch sc_rsw; /* for radio switch events */ 192 int sc_rsw_status; 193#define WPI_RSW_UNKNOWN 0 194#define WPI_RSW_OFF 1 195#define WPI_RSW_ON 2 196 struct lwp *sc_rsw_lwp; 197 struct kmutex sc_rsw_mtx; 198 struct kcondvar sc_rsw_cv; 199 int sc_dying; 200}; 201