1 /* $OpenBSD: rt2860var.h,v 1.11 2008/12/29 13:27:27 damien Exp $ */ 2 3 /*- 4 * Copyright (c) 2007 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 #define RT2860_TX_RING_COUNT 64 21 #define RT2860_RX_RING_COUNT 128 22 #define RT2860_TX_POOL_COUNT (RT2860_TX_RING_COUNT * 2) 23 24 #define RT2860_MAX_SCATTER ((RT2860_TX_RING_COUNT * 2) - 1) 25 26 /* HW supports up to 255 STAs */ 27 #define RT2860_WCID_MAX 254 28 #define RT2860_AID2WCID(aid) ((aid) & 0xff) 29 30 struct rt2860_rx_radiotap_header { 31 struct ieee80211_radiotap_header wr_ihdr; 32 uint8_t wr_flags; 33 uint8_t wr_rate; 34 uint16_t wr_chan_freq; 35 uint16_t wr_chan_flags; 36 uint8_t wr_dbm_antsignal; 37 uint8_t wr_antenna; 38 uint8_t wr_antsignal; 39 } __packed; 40 41 #define RT2860_RX_RADIOTAP_PRESENT \ 42 (1 << IEEE80211_RADIOTAP_FLAGS | \ 43 1 << IEEE80211_RADIOTAP_RATE | \ 44 1 << IEEE80211_RADIOTAP_CHANNEL | \ 45 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL | \ 46 1 << IEEE80211_RADIOTAP_ANTENNA | \ 47 1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) 48 49 struct rt2860_tx_radiotap_header { 50 struct ieee80211_radiotap_header wt_ihdr; 51 uint8_t wt_flags; 52 uint8_t wt_rate; 53 uint16_t wt_chan_freq; 54 uint16_t wt_chan_flags; 55 uint8_t wt_hwqueue; 56 } __packed; 57 58 #define RT2860_TX_RADIOTAP_PRESENT \ 59 (1 << IEEE80211_RADIOTAP_FLAGS | \ 60 1 << IEEE80211_RADIOTAP_RATE | \ 61 1 << IEEE80211_RADIOTAP_CHANNEL | \ 62 1 << IEEE80211_RADIOTAP_HWQUEUE) 63 64 struct rt2860_tx_data { 65 struct rt2860_txwi *txwi; 66 struct mbuf *m; 67 struct ieee80211_node *ni; 68 bus_dmamap_t map; 69 bus_addr_t paddr; 70 SLIST_ENTRY(rt2860_tx_data) next; 71 }; 72 73 struct rt2860_tx_ring { 74 struct rt2860_txd *txd; 75 bus_addr_t paddr; 76 bus_dmamap_t map; 77 bus_dma_segment_t seg; 78 struct rt2860_tx_data *data[RT2860_TX_RING_COUNT]; 79 int cur; 80 int next; 81 int queued; 82 }; 83 84 struct rt2860_rx_data { 85 struct mbuf *m; 86 bus_dmamap_t map; 87 }; 88 89 struct rt2860_rx_ring { 90 struct rt2860_rxd *rxd; 91 bus_addr_t paddr; 92 bus_dmamap_t map; 93 bus_dma_segment_t seg; 94 unsigned int cur; /* must be unsigned */ 95 struct rt2860_rx_data data[RT2860_RX_RING_COUNT]; 96 }; 97 98 struct rt2860_node { 99 struct ieee80211_node ni; 100 uint8_t ridx[IEEE80211_RATE_MAXSIZE]; 101 uint8_t ctl_ridx[IEEE80211_RATE_MAXSIZE]; 102 }; 103 104 struct rt2860_softc { 105 struct device sc_dev; 106 107 struct ieee80211com sc_ic; 108 int (*sc_newstate)(struct ieee80211com *, 109 enum ieee80211_state, int); 110 struct ieee80211_amrr amrr; 111 112 int (*sc_enable)(struct rt2860_softc *); 113 void (*sc_disable)(struct rt2860_softc *); 114 void (*sc_power)(struct rt2860_softc *, int); 115 116 bus_dma_tag_t sc_dmat; 117 bus_space_tag_t sc_st; 118 bus_space_handle_t sc_sh; 119 120 int sc_flags; 121 #define RT2860_ENABLED (1 << 0) 122 #define RT2860_FWLOADED (1 << 1) 123 #define RT2860_ADVANCED_PS (1 << 2) 124 125 uint32_t sc_ic_flags; 126 int fixed_ridx; 127 128 struct rt2860_tx_ring txq[6]; 129 struct rt2860_rx_ring rxq; 130 131 SLIST_HEAD(, rt2860_tx_data) data_pool; 132 struct rt2860_tx_data data[RT2860_TX_POOL_COUNT]; 133 bus_dmamap_t txwi_map; 134 bus_dma_segment_t txwi_seg; 135 caddr_t txwi_vaddr; 136 137 int sc_tx_timer; 138 int mgtqid; 139 int sifs; 140 uint8_t qfullmsk; 141 142 uint32_t mac_rev; 143 uint8_t rf_rev; 144 uint8_t freq; 145 uint8_t ntxchains; 146 uint8_t nrxchains; 147 uint8_t pslevel; 148 int8_t txpow1[50]; 149 int8_t txpow2[50]; 150 int8_t rssi_2ghz[3]; 151 int8_t rssi_5ghz[3]; 152 uint8_t lna[4]; 153 uint8_t ext_2ghz_lna; 154 uint8_t ext_5ghz_lna; 155 uint8_t calib_2ghz; 156 uint8_t calib_5ghz; 157 uint8_t tssi_2ghz[9]; 158 uint8_t tssi_5ghz[9]; 159 uint8_t step_2ghz; 160 uint8_t step_5ghz; 161 struct { 162 uint8_t reg; 163 uint8_t val; 164 } bbp[8]; 165 uint8_t leds; 166 uint16_t led[3]; 167 uint32_t txpow20mhz[5]; 168 uint32_t txpow40mhz_2ghz[5]; 169 uint32_t txpow40mhz_5ghz[5]; 170 171 struct ieee80211_amrr_node amn[RT2860_WCID_MAX + 1]; 172 173 #if NBPFILTER > 0 174 caddr_t sc_drvbpf; 175 union { 176 struct rt2860_rx_radiotap_header th; 177 uint8_t pad[64]; 178 } sc_rxtapu; 179 #define sc_rxtap sc_rxtapu.th 180 int sc_rxtap_len; 181 182 union { 183 struct rt2860_tx_radiotap_header th; 184 uint8_t pad[64]; 185 } sc_txtapu; 186 #define sc_txtap sc_txtapu.th 187 int sc_txtap_len; 188 #endif 189 void *sc_sdhook; 190 void *sc_powerhook; 191 }; 192 193 int rt2860_attach(void *, int); 194 int rt2860_detach(void *); 195 int rt2860_intr(void *); 196 void rt2860_shutdown(void *); 197