1 | /* $NetBSD: rt2860var.h,v 1.3 2016/07/08 01:24:53 christos Exp $ */ |
2 | /* $OpenBSD: rt2860var.h,v 1.23 2016/03/21 21:16:30 stsp Exp $ */ |
3 | |
4 | /*- |
5 | * Copyright (c) 2007 |
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 | #define RT2860_MAX_SCATTER 15 |
22 | #define RT2860_MAX_SCATTER_TXD (1 + (RT2860_MAX_SCATTER / 2)) |
23 | |
24 | #define RT2860_RX_RING_COUNT 128 |
25 | #define RT2860_TX_RING_COUNT 64 |
26 | #define RT2860_TX_RING_MAX (RT2860_TX_RING_COUNT - 1) |
27 | #define RT2860_TX_RING_ONEMORE (RT2860_TX_RING_MAX - RT2860_MAX_SCATTER_TXD) |
28 | #define RT2860_TX_POOL_COUNT (RT2860_TX_RING_COUNT * 2) |
29 | |
30 | /* HW supports up to 255 STAs */ |
31 | #define RT2860_WCID_MAX 254 |
32 | #define RT2860_AID2WCID(aid) ((aid) & 0xff) |
33 | |
34 | #define IEEE80211_NO_HT |
35 | |
36 | struct { |
37 | struct ieee80211_radiotap_header ; |
38 | uint8_t ; |
39 | uint8_t ; |
40 | uint16_t ; |
41 | uint16_t ; |
42 | uint8_t ; |
43 | uint8_t ; |
44 | uint8_t ; |
45 | } __packed __aligned(8); |
46 | |
47 | #define RT2860_RX_RADIOTAP_PRESENT \ |
48 | (1 << IEEE80211_RADIOTAP_FLAGS | \ |
49 | 1 << IEEE80211_RADIOTAP_RATE | \ |
50 | 1 << IEEE80211_RADIOTAP_CHANNEL | \ |
51 | 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL | \ |
52 | 1 << IEEE80211_RADIOTAP_ANTENNA | \ |
53 | 1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) |
54 | |
55 | struct { |
56 | struct ieee80211_radiotap_header ; |
57 | uint8_t ; |
58 | uint8_t ; |
59 | uint16_t ; |
60 | uint16_t ; |
61 | uint8_t ; |
62 | } __packed __aligned(8); |
63 | |
64 | #define RT2860_TX_RADIOTAP_PRESENT \ |
65 | (1 << IEEE80211_RADIOTAP_FLAGS | \ |
66 | 1 << IEEE80211_RADIOTAP_RATE | \ |
67 | 1 << IEEE80211_RADIOTAP_CHANNEL) |
68 | |
69 | struct rt2860_tx_data { |
70 | struct rt2860_txwi *txwi; |
71 | struct mbuf *m; |
72 | struct ieee80211_node *ni; |
73 | bus_dmamap_t map; |
74 | bus_addr_t paddr; |
75 | SLIST_ENTRY(rt2860_tx_data) next; |
76 | }; |
77 | |
78 | struct rt2860_tx_ring { |
79 | struct rt2860_txd *txd; |
80 | bus_addr_t paddr; |
81 | bus_dmamap_t map; |
82 | bus_dma_segment_t seg; |
83 | struct rt2860_tx_data *data[RT2860_TX_RING_COUNT]; |
84 | int cur; |
85 | int next; |
86 | int queued; |
87 | }; |
88 | |
89 | struct rt2860_rx_data { |
90 | struct mbuf *m; |
91 | bus_dmamap_t map; |
92 | }; |
93 | |
94 | struct rt2860_rx_ring { |
95 | struct rt2860_rxd *rxd; |
96 | bus_addr_t paddr; |
97 | bus_dmamap_t map; |
98 | bus_dma_segment_t seg; |
99 | unsigned int cur; /* must be unsigned */ |
100 | struct rt2860_rx_data data[RT2860_RX_RING_COUNT]; |
101 | }; |
102 | |
103 | struct rt2860_node { |
104 | struct ieee80211_node ni; |
105 | uint8_t wcid; |
106 | uint8_t ridx[IEEE80211_RATE_MAXSIZE]; |
107 | uint8_t ctl_ridx[IEEE80211_RATE_MAXSIZE]; |
108 | }; |
109 | |
110 | struct rt2860_softc { |
111 | device_t sc_dev; |
112 | |
113 | struct ieee80211com sc_ic; |
114 | int (*sc_newstate)(struct ieee80211com *, |
115 | enum ieee80211_state, int); |
116 | |
117 | int (*sc_enable)(struct rt2860_softc *); |
118 | void (*sc_disable)(struct rt2860_softc *); |
119 | |
120 | bus_dma_tag_t sc_dmat; |
121 | bus_space_tag_t sc_st; |
122 | bus_space_handle_t sc_sh; |
123 | |
124 | struct ethercom sc_ec; |
125 | #define sc_if sc_ec.ec_if |
126 | |
127 | uint16_t (*sc_srom_read)(struct rt2860_softc *, |
128 | uint16_t); |
129 | |
130 | int sc_flags; |
131 | #define RT2860_ENABLED (1 << 0) |
132 | #define RT2860_ADVANCED_PS (1 << 1) |
133 | #define RT2860_PCIE (1 << 2) |
134 | #define RT2860_RUNNING (1 << 3) |
135 | |
136 | struct ieee80211_amrr amrr; |
137 | |
138 | uint32_t sc_ic_flags; |
139 | int fixed_ridx; |
140 | |
141 | u_char *ucode; |
142 | size_t ucsize; |
143 | |
144 | struct rt2860_tx_ring txq[6]; |
145 | struct rt2860_rx_ring rxq; |
146 | |
147 | SLIST_HEAD(, rt2860_tx_data) data_pool; |
148 | struct rt2860_tx_data data[RT2860_TX_POOL_COUNT]; |
149 | bus_dmamap_t txwi_map; |
150 | bus_dma_segment_t txwi_seg; |
151 | void *txwi_vaddr; |
152 | |
153 | int sc_tx_timer; |
154 | struct ieee80211_beacon_offsets sc_bo; |
155 | int mgtqid; |
156 | uint8_t qfullmsk; |
157 | |
158 | uint16_t mac_ver; |
159 | uint16_t mac_rev; |
160 | uint32_t rf_rev; |
161 | uint8_t freq; |
162 | uint8_t ntxchains; |
163 | uint8_t nrxchains; |
164 | uint8_t pslevel; |
165 | int8_t txpow1[54]; |
166 | int8_t txpow2[54]; |
167 | int8_t [3]; |
168 | int8_t [3]; |
169 | uint8_t lna[4]; |
170 | uint8_t rf24_20mhz; |
171 | uint8_t rf24_40mhz; |
172 | uint8_t patch_dac; |
173 | uint8_t rfswitch; |
174 | uint8_t ext_2ghz_lna; |
175 | uint8_t ext_5ghz_lna; |
176 | uint8_t calib_2ghz; |
177 | uint8_t calib_5ghz; |
178 | uint8_t txmixgain_2ghz; |
179 | uint8_t txmixgain_5ghz; |
180 | uint8_t tssi_2ghz[9]; |
181 | uint8_t tssi_5ghz[9]; |
182 | uint8_t step_2ghz; |
183 | uint8_t step_5ghz; |
184 | struct { |
185 | uint8_t reg; |
186 | uint8_t val; |
187 | } bbp[8], rf[10]; |
188 | uint8_t leds; |
189 | uint16_t led[3]; |
190 | uint32_t txpow20mhz[5]; |
191 | uint32_t txpow40mhz_2ghz[5]; |
192 | uint32_t txpow40mhz_5ghz[5]; |
193 | |
194 | struct ieee80211_amrr_node amn[RT2860_WCID_MAX + 1]; |
195 | |
196 | struct bpf_if *sc_drvbpf; |
197 | union { |
198 | struct rt2860_rx_radiotap_header th; |
199 | uint8_t pad[64]; |
200 | } sc_rxtapu; |
201 | #define sc_rxtap sc_rxtapu.th |
202 | int sc_rxtap_len; |
203 | |
204 | union { |
205 | struct rt2860_tx_radiotap_header th; |
206 | uint8_t pad[64]; |
207 | } sc_txtapu; |
208 | #define sc_txtap sc_txtapu.th |
209 | int sc_txtap_len; |
210 | }; |
211 | |
212 | int rt2860_attach(void *, int); |
213 | int rt2860_detach(void *); |
214 | void rt2860_suspend(void *); |
215 | void rt2860_wakeup(void *); |
216 | int rt2860_intr(void *); |
217 | |