1 /* 2 * Copyright (c) 2005 3 * Damien Bergamini <damien.bergamini@free.fr> 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * 17 * $FreeBSD: src/sys/dev/ral/rt2661var.h,v 1.1 2006/03/05 20:36:56 damien Exp $ 18 * $DragonFly: src/sys/dev/netif/ral/rt2661var.h,v 1.1 2006/05/20 09:13:09 sephe Exp $ 19 */ 20 21 struct rt2661_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_antsignal; 29 } __packed; 30 31 #define RT2661_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_DB_ANTSIGNAL)) 37 38 struct rt2661_tx_radiotap_header { 39 struct ieee80211_radiotap_header wt_ihdr; 40 uint8_t wt_flags; 41 uint8_t wt_rate; 42 uint16_t wt_chan_freq; 43 uint16_t wt_chan_flags; 44 } __packed; 45 46 #define RT2661_TX_RADIOTAP_PRESENT \ 47 ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 48 (1 << IEEE80211_RADIOTAP_RATE) | \ 49 (1 << IEEE80211_RADIOTAP_CHANNEL)) 50 51 struct rt2661_tx_data { 52 bus_dmamap_t map; 53 struct mbuf *m; 54 struct ieee80211_node *ni; 55 struct ral_rssdesc id; 56 }; 57 58 struct rt2661_tx_ring { 59 bus_dma_tag_t desc_dmat; 60 bus_dma_tag_t data_dmat; 61 bus_dmamap_t desc_map; 62 bus_addr_t physaddr; 63 struct rt2661_tx_desc *desc; 64 struct rt2661_tx_data *data; 65 int count; 66 int queued; 67 int cur; 68 int next; 69 int stat; 70 }; 71 72 struct rt2661_rx_data { 73 bus_dmamap_t map; 74 struct mbuf *m; 75 }; 76 77 struct rt2661_rx_ring { 78 bus_dma_tag_t desc_dmat; 79 bus_dma_tag_t data_dmat; 80 bus_dmamap_t desc_map; 81 bus_addr_t physaddr; 82 struct rt2661_rx_desc *desc; 83 struct rt2661_rx_data *data; 84 int count; 85 int cur; 86 int next; 87 }; 88 89 struct rt2661_node { 90 struct ieee80211_node ni; 91 struct ral_rssadapt rssadapt; 92 }; 93 94 struct rt2661_softc { 95 struct ieee80211com sc_ic; 96 bus_space_tag_t sc_st; 97 bus_space_handle_t sc_sh; 98 device_t sc_dev; 99 100 int sc_irq_rid; 101 struct resource *sc_irq; 102 void *sc_ih; 103 104 int (*sc_newstate)(struct ieee80211com *, 105 enum ieee80211_state, int); 106 107 struct callout scan_ch; 108 struct callout rssadapt_ch; 109 110 int sc_tx_timer; 111 112 struct ieee80211_channel *sc_curchan; 113 114 uint8_t rf_rev; 115 116 uint8_t rfprog; 117 uint8_t rffreq; 118 119 struct rt2661_tx_ring txq[4]; 120 struct rt2661_tx_ring mgtq; 121 struct rt2661_rx_ring rxq; 122 123 uint32_t rf_regs[4]; 124 int8_t txpow[38]; 125 126 struct { 127 uint8_t reg; 128 uint8_t val; 129 } bbp_prom[16]; 130 131 int hw_radio; 132 int rx_ant; 133 int tx_ant; 134 int nb_ant; 135 int ext_2ghz_lna; 136 int ext_5ghz_lna; 137 int rssi_2ghz_corr; 138 int rssi_5ghz_corr; 139 140 uint8_t bbp18; 141 uint8_t bbp21; 142 uint8_t bbp22; 143 uint8_t bbp16; 144 uint8_t bbp17; 145 uint8_t bbp64; 146 147 int dwelltime; 148 149 struct bpf_if *sc_drvbpf; 150 151 union { 152 struct rt2661_rx_radiotap_header th; 153 uint8_t pad[64]; 154 } sc_rxtapu; 155 #define sc_rxtap sc_rxtapu.th 156 int sc_rxtap_len; 157 158 union { 159 struct rt2661_tx_radiotap_header th; 160 uint8_t pad[64]; 161 } sc_txtapu; 162 #define sc_txtap sc_txtapu.th 163 int sc_txtap_len; 164 165 struct sysctl_ctx_list sysctl_ctx; 166 struct sysctl_oid *sysctl_tree; 167 }; 168 169 int rt2661_attach(device_t, int); 170 int rt2661_detach(void *); 171 void rt2661_shutdown(void *); 172 void rt2661_suspend(void *); 173 void rt2661_resume(void *); 174