1 | /* $NetBSD: if_runvar.h,v 1.3 2016/09/16 09:25:30 mlelstv Exp $ */ |
2 | /* $OpenBSD: if_runvar.h,v 1.8 2010/02/08 18:46:47 damien Exp $ */ |
3 | |
4 | /*- |
5 | * Copyright (c) 2008,2009 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 | #define RUN_MAX_RXSZ \ |
21 | 4096 |
22 | #if 0 |
23 | (sizeof(uint32_t) + \ |
24 | sizeof(struct rt2860_rxwi) + \ |
25 | sizeof(uint16_t) + \ |
26 | MCLBYTES + \ |
27 | sizeof(struct rt2870_rxd)) |
28 | #endif |
29 | /* NB: "11" is the maximum number of padding bytes needed for Tx */ |
30 | #define RUN_MAX_TXSZ \ |
31 | (sizeof(struct rt2870_txd) + \ |
32 | sizeof(struct rt2860_rxwi) + \ |
33 | MCLBYTES + 11) |
34 | |
35 | #define RUN_TX_TIMEOUT 5000 /* ms */ |
36 | |
37 | #define RUN_RX_RING_COUNT 1 |
38 | #define RUN_TX_RING_COUNT 8 |
39 | |
40 | #define RT2870_WCID_MAX 253 |
41 | #define RUN_AID2WCID(aid) ((aid) & 0xff) |
42 | |
43 | struct { |
44 | struct ieee80211_radiotap_header ; |
45 | uint8_t ; |
46 | uint8_t ; |
47 | uint16_t ; |
48 | uint16_t ; |
49 | uint8_t ; |
50 | uint8_t ; |
51 | uint8_t ; |
52 | } __packed; |
53 | |
54 | #define RUN_RX_RADIOTAP_PRESENT \ |
55 | (1 << IEEE80211_RADIOTAP_FLAGS | \ |
56 | 1 << IEEE80211_RADIOTAP_RATE | \ |
57 | 1 << IEEE80211_RADIOTAP_CHANNEL | \ |
58 | 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL | \ |
59 | 1 << IEEE80211_RADIOTAP_ANTENNA | \ |
60 | 1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) |
61 | |
62 | struct { |
63 | struct ieee80211_radiotap_header ; |
64 | uint8_t ; |
65 | uint8_t ; |
66 | uint16_t ; |
67 | uint16_t ; |
68 | uint8_t ; |
69 | } __packed; |
70 | |
71 | #define RUN_TX_RADIOTAP_PRESENT \ |
72 | (1 << IEEE80211_RADIOTAP_FLAGS | \ |
73 | 1 << IEEE80211_RADIOTAP_RATE | \ |
74 | 1 << IEEE80211_RADIOTAP_CHANNEL/* | \ |
75 | 1 << IEEE80211_RADIOTAP_HWQUEUE*/) |
76 | |
77 | struct run_softc; |
78 | |
79 | struct run_tx_data { |
80 | struct run_softc *sc; |
81 | struct usbd_xfer *xfer; |
82 | uint8_t *buf; |
83 | uint8_t qid; |
84 | }; |
85 | |
86 | struct run_rx_data { |
87 | struct run_softc *sc; |
88 | struct usbd_xfer *xfer; |
89 | uint8_t *buf; |
90 | }; |
91 | |
92 | struct run_tx_ring { |
93 | struct run_tx_data data[RUN_TX_RING_COUNT]; |
94 | struct usbd_pipe * pipeh; |
95 | int cur; |
96 | int queued; |
97 | uint8_t pipe_no; |
98 | }; |
99 | |
100 | struct run_rx_ring { |
101 | struct run_rx_data data[RUN_RX_RING_COUNT]; |
102 | struct usbd_pipe * pipeh; |
103 | uint8_t pipe_no; |
104 | }; |
105 | |
106 | struct run_host_cmd { |
107 | void (*cb)(struct run_softc *, void *); |
108 | uint8_t data[256]; |
109 | }; |
110 | |
111 | struct run_cmd_newstate { |
112 | enum ieee80211_state state; |
113 | int arg; |
114 | }; |
115 | |
116 | struct run_cmd_key { |
117 | struct ieee80211_key key; |
118 | uint16_t associd; |
119 | }; |
120 | |
121 | #define RUN_HOST_CMD_RING_COUNT 32 |
122 | struct run_host_cmd_ring { |
123 | struct run_host_cmd cmd[RUN_HOST_CMD_RING_COUNT]; |
124 | int cur; |
125 | int next; |
126 | int queued; |
127 | }; |
128 | |
129 | struct run_node { |
130 | struct ieee80211_node ni; |
131 | uint8_t ridx[IEEE80211_RATE_MAXSIZE]; |
132 | uint8_t ctl_ridx[IEEE80211_RATE_MAXSIZE]; |
133 | }; |
134 | |
135 | struct run_softc { |
136 | device_t sc_dev; |
137 | struct ethercom sc_ec; |
138 | #define sc_if sc_ec.ec_if |
139 | struct ieee80211com sc_ic; |
140 | int (*sc_newstate)(struct ieee80211com *, |
141 | enum ieee80211_state, int); |
142 | int (*sc_srom_read)(struct run_softc *, |
143 | uint16_t, uint16_t *); |
144 | |
145 | struct usbd_device * sc_udev; |
146 | struct usbd_interface * sc_iface; |
147 | |
148 | uint16_t mac_ver; |
149 | uint16_t mac_rev; |
150 | uint16_t rf_rev; |
151 | uint8_t freq; |
152 | uint8_t ntxchains; |
153 | uint8_t nrxchains; |
154 | int fixed_ridx; |
155 | |
156 | uint8_t bbp25; |
157 | uint8_t bbp26; |
158 | uint8_t rf24_20mhz; |
159 | uint8_t rf24_40mhz; |
160 | uint8_t patch_dac; |
161 | uint8_t rfswitch; |
162 | uint8_t ext_2ghz_lna; |
163 | uint8_t ext_5ghz_lna; |
164 | uint8_t calib_2ghz; |
165 | uint8_t calib_5ghz; |
166 | uint8_t txmixgain_2ghz; |
167 | uint8_t txmixgain_5ghz; |
168 | int8_t txpow1[54]; |
169 | int8_t txpow2[54]; |
170 | int8_t txpow3[54]; |
171 | int8_t [3]; |
172 | int8_t [3]; |
173 | uint8_t lna[4]; |
174 | |
175 | struct { |
176 | uint8_t reg; |
177 | uint8_t val; |
178 | } bbp[10], rf[10]; |
179 | uint8_t leds; |
180 | uint16_t led[3]; |
181 | uint32_t txpow20mhz[5]; |
182 | uint32_t txpow40mhz_2ghz[5]; |
183 | uint32_t txpow40mhz_5ghz[5]; |
184 | |
185 | struct usb_task sc_task; |
186 | |
187 | struct ieee80211_amrr amrr; |
188 | struct ieee80211_amrr_node amn; |
189 | |
190 | callout_t scan_to; |
191 | callout_t calib_to; |
192 | |
193 | struct run_rx_ring rxq; |
194 | struct run_tx_ring txq[4]; |
195 | struct run_host_cmd_ring cmdq; |
196 | uint8_t qfullmsk; |
197 | int sc_tx_timer; |
198 | struct ieee80211_beacon_offsets sc_bo; |
199 | int sc_flags; |
200 | #define RUN_FWLOADED (1 << 0) |
201 | #define RUN_DETACHING (1 << 1) |
202 | |
203 | struct bpf_if * sc_drvbpf; |
204 | |
205 | union { |
206 | struct run_rx_radiotap_header th; |
207 | uint8_t pad[64]; |
208 | } sc_rxtapu; |
209 | #define sc_rxtap sc_rxtapu.th |
210 | int sc_rxtap_len; |
211 | |
212 | union { |
213 | struct run_tx_radiotap_header th; |
214 | uint8_t pad[64]; |
215 | } sc_txtapu; |
216 | #define sc_txtap sc_txtapu.th |
217 | int sc_txtap_len; |
218 | }; |
219 | |