1 /* $NetBSD: rt2560var.h,v 1.11 2019/10/05 23:27:20 mrg Exp $ */ 2 /* $OpenBSD: rt2560var.h,v 1.2 2006/01/14 12:43:27 damien Exp $ */ 3 4 /*- 5 * Copyright (c) 2005, 2006 6 * Damien Bergamini <damien.bergamini@free.fr> 7 * 8 * Permission to use, copy, modify, and distribute this software for any 9 * purpose with or without fee is hereby granted, provided that the above 10 * copyright notice and this permission notice appear in all copies. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 */ 20 21 struct rt2560_rx_radiotap_header { 22 struct ieee80211_radiotap_header wr_ihdr; 23 uint64_t wr_tsf; 24 uint8_t wr_flags; 25 uint8_t wr_rate; 26 uint16_t wr_chan_freq; 27 uint16_t wr_chan_flags; 28 uint8_t wr_antenna; 29 uint8_t wr_antsignal; 30 }; 31 32 #define RT2560_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_ANTENNA) | \ 38 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL)) 39 40 struct rt2560_tx_radiotap_header { 41 struct ieee80211_radiotap_header wt_ihdr; 42 uint8_t wt_flags; 43 uint8_t wt_rate; 44 uint16_t wt_chan_freq; 45 uint16_t wt_chan_flags; 46 uint8_t wt_antenna; 47 }; 48 49 #define RT2560_TX_RADIOTAP_PRESENT \ 50 ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 51 (1 << IEEE80211_RADIOTAP_RATE) | \ 52 (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 53 (1 << IEEE80211_RADIOTAP_ANTENNA)) 54 55 struct rt2560_tx_data { 56 bus_dmamap_t map; 57 struct mbuf *m; 58 struct ieee80211_node *ni; 59 struct ieee80211_rssdesc id; 60 }; 61 62 struct rt2560_tx_ring { 63 bus_dmamap_t map; 64 bus_dma_segment_t seg; 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_dmamap_t map; 84 bus_dma_segment_t seg; 85 bus_addr_t physaddr; 86 struct rt2560_rx_desc *desc; 87 struct rt2560_rx_data *data; 88 int count; 89 int cur; 90 int next; 91 int cur_decrypt; 92 }; 93 94 struct rt2560_node { 95 struct ieee80211_node ni; 96 struct ieee80211_rssadapt rssadapt; 97 }; 98 99 struct rt2560_softc { 100 device_t sc_dev; 101 102 struct ieee80211com sc_ic; 103 int (*sc_newstate)(struct ieee80211com *, 104 enum ieee80211_state, int); 105 106 int (*sc_enable)(struct rt2560_softc *); 107 void (*sc_disable)(struct rt2560_softc *); 108 109 bus_dma_tag_t sc_dmat; 110 bus_space_tag_t sc_st; 111 bus_space_handle_t sc_sh; 112 void *sc_soft_ih; 113 114 struct sysctllog *sc_sysctllog; 115 116 struct ethercom sc_ec; 117 118 struct callout scan_ch; 119 struct callout rssadapt_ch; 120 121 int sc_flags; 122 #define RT2560_ENABLED (1 << 0) 123 124 int sc_tx_timer; 125 126 uint32_t asic_rev; 127 uint8_t rf_rev; 128 129 struct rt2560_tx_ring txq; 130 struct rt2560_tx_ring prioq; 131 struct rt2560_tx_ring atimq; 132 struct rt2560_tx_ring bcnq; 133 struct rt2560_rx_ring rxq; 134 135 struct ieee80211_beacon_offsets sc_bo; 136 137 uint32_t rf_regs[4]; 138 uint8_t txpow[14]; 139 140 struct { 141 uint8_t reg; 142 uint8_t val; 143 } bbp_prom[16]; 144 145 int led_mode; 146 int hw_radio; 147 int rx_ant; 148 int tx_ant; 149 int nb_ant; 150 151 int dwelltime; 152 153 struct bpf_if * sc_drvbpf; 154 155 union { 156 struct rt2560_rx_radiotap_header th; 157 uint8_t pad[64]; 158 } sc_rxtapu; 159 #define sc_rxtap sc_rxtapu.th 160 int sc_rxtap_len; 161 162 union { 163 struct rt2560_tx_radiotap_header th; 164 uint8_t pad[64]; 165 } sc_txtapu; 166 #define sc_txtap sc_txtapu.th 167 int sc_txtap_len; 168 }; 169 170 #define sc_if sc_ec.ec_if 171 172 int rt2560_attach(void *, int); 173 int rt2560_detach(void *); 174 int rt2560_intr(void *); 175