| 1 | /* $NetBSD: rt2560var.h,v 1.9 2012/02/18 13:38:36 drochner 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 { |
| 22 | struct ieee80211_radiotap_header ; |
| 23 | uint64_t ; |
| 24 | uint8_t ; |
| 25 | uint8_t ; |
| 26 | uint16_t ; |
| 27 | uint16_t ; |
| 28 | uint8_t ; |
| 29 | uint8_t ; |
| 30 | } __packed; |
| 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 { |
| 41 | struct ieee80211_radiotap_header ; |
| 42 | uint8_t ; |
| 43 | uint8_t ; |
| 44 | uint16_t ; |
| 45 | uint16_t ; |
| 46 | uint8_t ; |
| 47 | } __packed; |
| 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 ; |
| 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 | |
| 113 | struct sysctllog *sc_sysctllog; |
| 114 | |
| 115 | struct ethercom sc_ec; |
| 116 | |
| 117 | struct callout scan_ch; |
| 118 | struct callout ; |
| 119 | |
| 120 | int sc_flags; |
| 121 | #define RT2560_ENABLED (1 << 0) |
| 122 | |
| 123 | int sc_tx_timer; |
| 124 | |
| 125 | uint32_t asic_rev; |
| 126 | uint8_t rf_rev; |
| 127 | |
| 128 | struct rt2560_tx_ring txq; |
| 129 | struct rt2560_tx_ring prioq; |
| 130 | struct rt2560_tx_ring atimq; |
| 131 | struct rt2560_tx_ring bcnq; |
| 132 | struct rt2560_rx_ring rxq; |
| 133 | |
| 134 | struct ieee80211_beacon_offsets sc_bo; |
| 135 | |
| 136 | uint32_t rf_regs[4]; |
| 137 | uint8_t txpow[14]; |
| 138 | |
| 139 | struct { |
| 140 | uint8_t reg; |
| 141 | uint8_t val; |
| 142 | } bbp_prom[16]; |
| 143 | |
| 144 | int led_mode; |
| 145 | int hw_radio; |
| 146 | int rx_ant; |
| 147 | int tx_ant; |
| 148 | int nb_ant; |
| 149 | |
| 150 | int dwelltime; |
| 151 | |
| 152 | struct bpf_if * sc_drvbpf; |
| 153 | |
| 154 | union { |
| 155 | struct rt2560_rx_radiotap_header th; |
| 156 | uint8_t pad[64]; |
| 157 | } sc_rxtapu; |
| 158 | #define sc_rxtap sc_rxtapu.th |
| 159 | int sc_rxtap_len; |
| 160 | |
| 161 | union { |
| 162 | struct rt2560_tx_radiotap_header th; |
| 163 | uint8_t pad[64]; |
| 164 | } sc_txtapu; |
| 165 | #define sc_txtap sc_txtapu.th |
| 166 | int sc_txtap_len; |
| 167 | }; |
| 168 | |
| 169 | #define sc_if sc_ec.ec_if |
| 170 | |
| 171 | int rt2560_attach(void *, int); |
| 172 | int rt2560_detach(void *); |
| 173 | int rt2560_intr(void *); |
| 174 | |