1 /* $FreeBSD$ */ 2 3 /*- 4 * Copyright (c) 2005, 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 20 struct rt2560_rx_radiotap_header { 21 struct ieee80211_radiotap_header wr_ihdr; 22 uint64_t wr_tsf; 23 uint8_t wr_flags; 24 uint8_t wr_rate; 25 uint16_t wr_chan_freq; 26 uint16_t wr_chan_flags; 27 uint8_t wr_antenna; 28 uint8_t wr_antsignal; 29 }; 30 31 #define RT2560_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_ANTENNA) | \ 37 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL)) 38 39 struct rt2560_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_antenna; 46 }; 47 48 #define RT2560_TX_RADIOTAP_PRESENT \ 49 ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 50 (1 << IEEE80211_RADIOTAP_RATE) | \ 51 (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 52 (1 << IEEE80211_RADIOTAP_ANTENNA)) 53 54 struct rt2560_tx_data { 55 bus_dmamap_t map; 56 struct mbuf *m; 57 struct ieee80211_node *ni; 58 struct ral_rssdesc id; 59 }; 60 61 struct rt2560_tx_ring { 62 bus_dma_tag_t desc_dmat; 63 bus_dma_tag_t data_dmat; 64 bus_dmamap_t desc_map; 65 bus_addr_t physaddr; 66 struct rt2560_tx_desc *desc; 67 struct rt2560_tx_data *data; 68 int count; 69 int queued; 70 int cur; 71 int next; 72 int cur_encrypt; 73 int next_encrypt; 74 }; 75 76 struct rt2560_rx_data { 77 bus_dmamap_t map; 78 struct mbuf *m; 79 int drop; 80 }; 81 82 struct rt2560_rx_ring { 83 bus_dma_tag_t desc_dmat; 84 bus_dma_tag_t data_dmat; 85 bus_dmamap_t desc_map; 86 bus_addr_t physaddr; 87 struct rt2560_rx_desc *desc; 88 struct rt2560_rx_data *data; 89 int count; 90 int cur; 91 int next; 92 int cur_decrypt; 93 }; 94 95 struct rt2560_node { 96 struct ieee80211_node ni; 97 struct ral_rssadapt rssadapt; 98 }; 99 100 struct rt2560_softc { 101 struct ifnet *sc_ifp; 102 struct ieee80211com sc_ic; 103 int (*sc_newstate)(struct ieee80211com *, 104 enum ieee80211_state, int); 105 device_t sc_dev; 106 bus_space_tag_t sc_st; 107 bus_space_handle_t sc_sh; 108 109 struct mtx sc_mtx; 110 111 struct callout watchdog_ch; 112 struct callout scan_ch; 113 struct callout rssadapt_ch; 114 115 int sc_tx_timer; 116 117 uint32_t asic_rev; 118 uint32_t eeprom_rev; 119 uint8_t rf_rev; 120 121 struct rt2560_tx_ring txq; 122 struct rt2560_tx_ring prioq; 123 struct rt2560_tx_ring atimq; 124 struct rt2560_tx_ring bcnq; 125 struct rt2560_rx_ring rxq; 126 127 struct ieee80211_beacon_offsets sc_bo; 128 129 uint32_t rf_regs[4]; 130 uint8_t txpow[14]; 131 132 struct { 133 uint8_t reg; 134 uint8_t val; 135 } bbp_prom[16]; 136 137 int led_mode; 138 int hw_radio; 139 int rx_ant; 140 int tx_ant; 141 int nb_ant; 142 143 int dwelltime; 144 145 struct bpf_if *sc_drvbpf; 146 147 union { 148 struct rt2560_rx_radiotap_header th; 149 uint8_t pad[64]; 150 } sc_rxtapu; 151 #define sc_rxtap sc_rxtapu.th 152 int sc_rxtap_len; 153 154 union { 155 struct rt2560_tx_radiotap_header th; 156 uint8_t pad[64]; 157 } sc_txtapu; 158 #define sc_txtap sc_txtapu.th 159 int sc_txtap_len; 160 }; 161 162 int rt2560_attach(device_t, int); 163 int rt2560_detach(void *); 164 void rt2560_shutdown(void *); 165 void rt2560_suspend(void *); 166 void rt2560_resume(void *); 167 void rt2560_intr(void *); 168 169 #define RAL_LOCK(sc) mtx_lock(&(sc)->sc_mtx) 170 #define RAL_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) 171