Mon Jan 21 16:48:23 2013 UTC ()
remove trailing line


(christos)
diff -r1.4 -r1.5 src/sys/dev/usb/if_otusvar.h

cvs diff -r1.4 -r1.5 src/sys/dev/usb/if_otusvar.h (switch to unified diff)

--- src/sys/dev/usb/if_otusvar.h 2013/01/20 21:50:41 1.4
+++ src/sys/dev/usb/if_otusvar.h 2013/01/21 16:48:23 1.5
@@ -1,298 +1,297 @@ @@ -1,298 +1,297 @@
1/* $NetBSD: if_otusvar.h,v 1.4 2013/01/20 21:50:41 christos Exp $ */ 1/* $NetBSD: if_otusvar.h,v 1.5 2013/01/21 16:48:23 christos Exp $ */
2/* $OpenBSD: if_otusreg.h,v 1.6 2009/04/06 18:17:01 damien Exp $ */ 2/* $OpenBSD: if_otusreg.h,v 1.6 2009/04/06 18:17:01 damien Exp $ */
3 3
4/*- 4/*-
5 * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr> 5 * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
6 * Copyright (c) 2007-2008 Atheros Communications, Inc. 6 * Copyright (c) 2007-2008 Atheros Communications, Inc.
7 * 7 *
8 * Permission to use, copy, modify, and distribute this software for any 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 9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies. 10 * copyright notice and this permission notice appear in all copies.
11 * 11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 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 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */ 19 */
20#ifndef _IF_OTUSVAR_H_ 20#ifndef _IF_OTUSVAR_H_
21#define _IF_OTUSVAR_H_ 21#define _IF_OTUSVAR_H_
22 22
23#ifdef EDCA_NUM_AC 23#ifdef EDCA_NUM_AC
24#define HAVE_EDCA 24#define HAVE_EDCA
25#endif 25#endif
26 26
27#ifndef HAVE_EDCA 27#ifndef HAVE_EDCA
28/************************************************************ 28/************************************************************
29 * XXX: This block belongs in sys/net80211/ieee80211_var.h. 29 * XXX: This block belongs in sys/net80211/ieee80211_var.h.
30 */ 30 */
31/* 31/*
32 * EDCA AC parameters. 32 * EDCA AC parameters.
33 */ 33 */
34struct ieee80211_edca_ac_params { 34struct ieee80211_edca_ac_params {
35 u_int8_t ac_ecwmin; /* CWmin = 2^ECWmin - 1 */ 35 u_int8_t ac_ecwmin; /* CWmin = 2^ECWmin - 1 */
36 u_int8_t ac_ecwmax; /* CWmax = 2^ECWmax - 1 */ 36 u_int8_t ac_ecwmax; /* CWmax = 2^ECWmax - 1 */
37 u_int8_t ac_aifsn; 37 u_int8_t ac_aifsn;
38 u_int16_t ac_txoplimit; /* 32TU */ 38 u_int16_t ac_txoplimit; /* 32TU */
39 u_int8_t ac_acm; 39 u_int8_t ac_acm;
40}; 40};
41/************************************************************/ 41/************************************************************/
42#endif /* ! HAVE_EDCA */ 42#endif /* ! HAVE_EDCA */
43 43
44#ifndef HAVE_EDCA 44#ifndef HAVE_EDCA
45/************************************************************ 45/************************************************************
46 * XXX: This block belongs in sys/net80211/ieee80211.h. 46 * XXX: This block belongs in sys/net80211/ieee80211.h.
47 */ 47 */
48 48
49/* 49/*
50 * EDCA Access Categories. 50 * EDCA Access Categories.
51 */ 51 */
52enum ieee80211_edca_ac { 52enum ieee80211_edca_ac {
53 EDCA_AC_BK = 1, /* Background */ 53 EDCA_AC_BK = 1, /* Background */
54 EDCA_AC_BE = 0, /* Best Effort */ 54 EDCA_AC_BE = 0, /* Best Effort */
55 EDCA_AC_VI = 2, /* Video */ 55 EDCA_AC_VI = 2, /* Video */
56 EDCA_AC_VO = 3 /* Voice */ 56 EDCA_AC_VO = 3 /* Voice */
57}; 57};
58#define EDCA_NUM_AC 4 58#define EDCA_NUM_AC 4
59 59
60/* XXX: OpenBSD has more of these defined with the standard referenced */ 60/* XXX: OpenBSD has more of these defined with the standard referenced */
61#define IEEE80211_QOS_ACK_POLICY_NOACK 0x0020 61#define IEEE80211_QOS_ACK_POLICY_NOACK 0x0020
62#define IEEE80211_QOS_ACK_POLICY_MASK 0x0060 62#define IEEE80211_QOS_ACK_POLICY_MASK 0x0060
63 63
64static __inline int 64static __inline int
65ieee80211_has_addr4(const struct ieee80211_frame *wh) 65ieee80211_has_addr4(const struct ieee80211_frame *wh)
66{ 66{
67 return (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == 67 return (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) ==
68 IEEE80211_FC1_DIR_DSTODS; 68 IEEE80211_FC1_DIR_DSTODS;
69} 69}
70 70
71static __inline int 71static __inline int
72ieee80211_has_qos(const struct ieee80211_frame *wh) 72ieee80211_has_qos(const struct ieee80211_frame *wh)
73{ 73{
74 return (wh->i_fc[0] & 74 return (wh->i_fc[0] &
75 (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == 75 (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) ==
76 (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS); 76 (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS);
77} 77}
78 78
79static __inline u_int16_t 79static __inline u_int16_t
80ieee80211_get_qos(const struct ieee80211_frame *wh) 80ieee80211_get_qos(const struct ieee80211_frame *wh)
81{ 81{
82 const u_int8_t *frm; 82 const u_int8_t *frm;
83 83
84 if (ieee80211_has_addr4(wh)) 84 if (ieee80211_has_addr4(wh))
85 frm = ((const struct ieee80211_qosframe_addr4 *)wh)->i_qos; 85 frm = ((const struct ieee80211_qosframe_addr4 *)wh)->i_qos;
86 else 86 else
87 frm = ((const struct ieee80211_qosframe *)wh)->i_qos; 87 frm = ((const struct ieee80211_qosframe *)wh)->i_qos;
88 88
89 return le16toh(*(const u_int16_t *)frm); 89 return le16toh(*(const u_int16_t *)frm);
90} 90}
91/************************************************************/ 91/************************************************************/
92#endif /* ! HAVE_EDCA */ 92#endif /* ! HAVE_EDCA */
93 93
94/* Default EDCA parameters for when QoS is disabled. */ 94/* Default EDCA parameters for when QoS is disabled. */
95static const struct ieee80211_edca_ac_params otus_edca_def[] = { 95static const struct ieee80211_edca_ac_params otus_edca_def[] = {
96 { 4, 10, 3, 0, 0 }, 96 { 4, 10, 3, 0, 0 },
97 { 4, 10, 7, 0, 0 }, 97 { 4, 10, 7, 0, 0 },
98 { 3, 4, 2, 94, 0 }, 98 { 3, 4, 2, 94, 0 },
99 { 2, 3, 2, 47, 0 } 99 { 2, 3, 2, 47, 0 }
100}; 100};
101 101
102#define OTUS_TX_DATA_LIST_COUNT 8 102#define OTUS_TX_DATA_LIST_COUNT 8
103#define OTUS_RX_DATA_LIST_COUNT 1 103#define OTUS_RX_DATA_LIST_COUNT 1
104 104
105#define OTUS_CMD_TIMEOUT 1000 105#define OTUS_CMD_TIMEOUT 1000
106#define OTUS_TX_TIMEOUT 1000 106#define OTUS_TX_TIMEOUT 1000
107 107
108#define OTUS_UID(aid) (IEEE80211_AID(aid) + 4) 108#define OTUS_UID(aid) (IEEE80211_AID(aid) + 4)
109 109
110#define OTUS_MAX_TXCMDSZ 64 110#define OTUS_MAX_TXCMDSZ 64
111#define OTUS_RXBUFSZ (8 * 1024) 111#define OTUS_RXBUFSZ (8 * 1024)
112#define OTUS_TXBUFSZ (4 * 1024) 112#define OTUS_TXBUFSZ (4 * 1024)
113 113
114#define OTUS_RIDX_CCK1 0 114#define OTUS_RIDX_CCK1 0
115#define OTUS_RIDX_OFDM6 4 115#define OTUS_RIDX_OFDM6 4
116#define OTUS_RIDX_OFDM24 8 116#define OTUS_RIDX_OFDM24 8
117#define OTUS_RIDX_MAX 11 117#define OTUS_RIDX_MAX 11
118static const struct otus_rate { 118static const struct otus_rate {
119 uint8_t rate; 119 uint8_t rate;
120 uint8_t mcs; 120 uint8_t mcs;
121} otus_rates[] = { 121} otus_rates[] = {
122 { 2, 0x0 }, 122 { 2, 0x0 },
123 { 4, 0x1 }, 123 { 4, 0x1 },
124 { 11, 0x2 }, 124 { 11, 0x2 },
125 { 22, 0x3 }, 125 { 22, 0x3 },
126 { 12, 0xb }, 126 { 12, 0xb },
127 { 18, 0xf }, 127 { 18, 0xf },
128 { 24, 0xa }, 128 { 24, 0xa },
129 { 36, 0xe }, 129 { 36, 0xe },
130 { 48, 0x9 }, 130 { 48, 0x9 },
131 { 72, 0xd }, 131 { 72, 0xd },
132 { 96, 0x8 }, 132 { 96, 0x8 },
133 { 108, 0xc } 133 { 108, 0xc }
134}; 134};
135 135
136struct otus_rx_radiotap_header { 136struct otus_rx_radiotap_header {
137 struct ieee80211_radiotap_header wr_ihdr; 137 struct ieee80211_radiotap_header wr_ihdr;
138 uint8_t wr_flags; 138 uint8_t wr_flags;
139 uint8_t wr_rate; 139 uint8_t wr_rate;
140 uint16_t wr_chan_freq; 140 uint16_t wr_chan_freq;
141 uint16_t wr_chan_flags; 141 uint16_t wr_chan_flags;
142 uint8_t wr_antsignal; 142 uint8_t wr_antsignal;
143} __packed; 143} __packed;
144 144
145#define OTUS_RX_RADIOTAP_PRESENT \ 145#define OTUS_RX_RADIOTAP_PRESENT \
146 (1 << IEEE80211_RADIOTAP_FLAGS | \ 146 (1 << IEEE80211_RADIOTAP_FLAGS | \
147 1 << IEEE80211_RADIOTAP_RATE | \ 147 1 << IEEE80211_RADIOTAP_RATE | \
148 1 << IEEE80211_RADIOTAP_CHANNEL | \ 148 1 << IEEE80211_RADIOTAP_CHANNEL | \
149 1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) 149 1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL)
150 150
151struct otus_tx_radiotap_header { 151struct otus_tx_radiotap_header {
152 struct ieee80211_radiotap_header wt_ihdr; 152 struct ieee80211_radiotap_header wt_ihdr;
153 uint8_t wt_flags; 153 uint8_t wt_flags;
154 uint8_t wt_rate; 154 uint8_t wt_rate;
155 uint16_t wt_chan_freq; 155 uint16_t wt_chan_freq;
156 uint16_t wt_chan_flags; 156 uint16_t wt_chan_flags;
157} __packed; 157} __packed;
158 158
159#define OTUS_TX_RADIOTAP_PRESENT \ 159#define OTUS_TX_RADIOTAP_PRESENT \
160 (1 << IEEE80211_RADIOTAP_FLAGS | \ 160 (1 << IEEE80211_RADIOTAP_FLAGS | \
161 1 << IEEE80211_RADIOTAP_RATE | \ 161 1 << IEEE80211_RADIOTAP_RATE | \
162 1 << IEEE80211_RADIOTAP_CHANNEL) 162 1 << IEEE80211_RADIOTAP_CHANNEL)
163 163
164 164
165struct otus_softc; 165struct otus_softc;
166 166
167struct otus_tx_cmd { 167struct otus_tx_cmd {
168 usbd_xfer_handle xfer; 168 usbd_xfer_handle xfer;
169 uint8_t *buf; 169 uint8_t *buf;
170 void *odata; 170 void *odata;
171 uint16_t token; 171 uint16_t token;
172 uint8_t done; 172 uint8_t done;
173}; 173};
174 174
175struct otus_rx_data { 175struct otus_rx_data {
176 struct otus_softc *sc; 176 struct otus_softc *sc;
177 usbd_xfer_handle xfer; 177 usbd_xfer_handle xfer;
178 uint8_t *buf; 178 uint8_t *buf;
179}; 179};
180 180
181struct otus_tx_data { 181struct otus_tx_data {
182 struct otus_softc *sc; 182 struct otus_softc *sc;
183 usbd_xfer_handle xfer; 183 usbd_xfer_handle xfer;
184 uint8_t *buf; 184 uint8_t *buf;
185 TAILQ_ENTRY(otus_tx_data) next; 185 TAILQ_ENTRY(otus_tx_data) next;
186}; 186};
187 187
188struct otus_host_cmd { 188struct otus_host_cmd {
189 void (*cb)(struct otus_softc *, void *); 189 void (*cb)(struct otus_softc *, void *);
190 uint8_t data[256]; 190 uint8_t data[256];
191}; 191};
192 192
193#define OTUS_HOST_CMD_RING_COUNT 32 193#define OTUS_HOST_CMD_RING_COUNT 32
194struct otus_host_cmd_ring { 194struct otus_host_cmd_ring {
195 struct otus_host_cmd cmd[OTUS_HOST_CMD_RING_COUNT]; 195 struct otus_host_cmd cmd[OTUS_HOST_CMD_RING_COUNT];
196 int cur; 196 int cur;
197 int next; 197 int next;
198 int queued; 198 int queued;
199}; 199};
200 200
201struct otus_node { 201struct otus_node {
202 struct ieee80211_node ni; /* must be first */ 202 struct ieee80211_node ni; /* must be first */
203 struct ieee80211_amrr_node amn; 203 struct ieee80211_amrr_node amn;
204 uint8_t ridx[IEEE80211_RATE_MAXSIZE]; 204 uint8_t ridx[IEEE80211_RATE_MAXSIZE];
205}; 205};
206 206
207struct otus_cmd_newstate { 207struct otus_cmd_newstate {
208 enum ieee80211_state state; 208 enum ieee80211_state state;
209 int arg; 209 int arg;
210}; 210};
211 211
212struct otus_cmd_key { 212struct otus_cmd_key {
213 struct ieee80211_key key; 213 struct ieee80211_key key;
214 uint16_t associd; 214 uint16_t associd;
215}; 215};
216 216
217struct otus_softc { 217struct otus_softc {
218 device_t sc_dev; 218 device_t sc_dev;
219 struct ieee80211com sc_ic; 219 struct ieee80211com sc_ic;
220 struct ethercom sc_ec; 220 struct ethercom sc_ec;
221#define sc_if sc_ec.ec_if 221#define sc_if sc_ec.ec_if
222 int (*sc_newstate)(struct ieee80211com *, 222 int (*sc_newstate)(struct ieee80211com *,
223 enum ieee80211_state, int); 223 enum ieee80211_state, int);
224 void (*sc_led_newstate)(struct otus_softc *); 224 void (*sc_led_newstate)(struct otus_softc *);
225 225
226 usbd_device_handle sc_udev; 226 usbd_device_handle sc_udev;
227 usbd_interface_handle sc_iface; 227 usbd_interface_handle sc_iface;
228 228
229 struct ar5416eeprom sc_eeprom; 229 struct ar5416eeprom sc_eeprom;
230 uint8_t sc_capflags; 230 uint8_t sc_capflags;
231 uint8_t sc_rxmask; 231 uint8_t sc_rxmask;
232 uint8_t sc_txmask; 232 uint8_t sc_txmask;
233 233
234 usbd_pipe_handle sc_data_tx_pipe; 234 usbd_pipe_handle sc_data_tx_pipe;
235 usbd_pipe_handle sc_data_rx_pipe; 235 usbd_pipe_handle sc_data_rx_pipe;
236 usbd_pipe_handle sc_cmd_tx_pipe; 236 usbd_pipe_handle sc_cmd_tx_pipe;
237 usbd_pipe_handle sc_cmd_rx_pipe; 237 usbd_pipe_handle sc_cmd_rx_pipe;
238 uint8_t *sc_ibuf; 238 uint8_t *sc_ibuf;
239 239
240 int sc_if_flags; 240 int sc_if_flags;
241 int sc_tx_timer; 241 int sc_tx_timer;
242 int sc_fixed_ridx; 242 int sc_fixed_ridx;
243 int sc_bb_reset; 243 int sc_bb_reset;
244 244
245 struct ieee80211_channel *sc_curchan; 245 struct ieee80211_channel *sc_curchan;
246 246
247 struct usb_task sc_task; 247 struct usb_task sc_task;
248 callout_t sc_scan_to; 248 callout_t sc_scan_to;
249 callout_t sc_calib_to; 249 callout_t sc_calib_to;
250 struct ieee80211_amrr sc_amrr; 250 struct ieee80211_amrr sc_amrr;
251 251
252 unsigned int sc_write_idx; 252 unsigned int sc_write_idx;
253 uint32_t sc_led_state; 253 uint32_t sc_led_state;
254 254
255 kmutex_t sc_cmd_mtx; 255 kmutex_t sc_cmd_mtx;
256 kmutex_t sc_task_mtx; 256 kmutex_t sc_task_mtx;
257 kmutex_t sc_write_mtx; 257 kmutex_t sc_write_mtx;
258 kmutex_t sc_tx_mtx; 258 kmutex_t sc_tx_mtx;
259 259
260 const uint32_t *sc_phy_vals; 260 const uint32_t *sc_phy_vals;
261 261
262 struct { 262 struct {
263 uint32_t reg; 263 uint32_t reg;
264 uint32_t val; 264 uint32_t val;
265 } __packed sc_write_buf[AR_FW_MAX_WRITES]; 265 } __packed sc_write_buf[AR_FW_MAX_WRITES];
266 266
267 struct otus_host_cmd_ring sc_cmdq; 267 struct otus_host_cmd_ring sc_cmdq;
268 struct otus_tx_cmd sc_tx_cmd; 268 struct otus_tx_cmd sc_tx_cmd;
269 struct otus_tx_data sc_tx_data[OTUS_TX_DATA_LIST_COUNT]; 269 struct otus_tx_data sc_tx_data[OTUS_TX_DATA_LIST_COUNT];
270 TAILQ_HEAD(, otus_tx_data) sc_tx_free_list; 270 TAILQ_HEAD(, otus_tx_data) sc_tx_free_list;
271 struct otus_rx_data sc_rx_data[OTUS_RX_DATA_LIST_COUNT]; 271 struct otus_rx_data sc_rx_data[OTUS_RX_DATA_LIST_COUNT];
272 272
273 struct bpf_if * sc_drvbpf; 273 struct bpf_if * sc_drvbpf;
274 union { 274 union {
275 struct otus_rx_radiotap_header th; 275 struct otus_rx_radiotap_header th;
276 uint8_t pad[64]; 276 uint8_t pad[64];
277 } sc_rxtapu; 277 } sc_rxtapu;
278#define sc_rxtap sc_rxtapu.th 278#define sc_rxtap sc_rxtapu.th
279 int sc_rxtap_len; 279 int sc_rxtap_len;
280 union { 280 union {
281 struct otus_tx_radiotap_header th; 281 struct otus_tx_radiotap_header th;
282 uint8_t pad[64]; 282 uint8_t pad[64];
283 } sc_txtapu; 283 } sc_txtapu;
284#define sc_txtap sc_txtapu.th 284#define sc_txtap sc_txtapu.th
285 int sc_txtap_len; 285 int sc_txtap_len;
286 286
287 uint8_t sc_rx_error_msk; 287 uint8_t sc_rx_error_msk;
288 int sc_dying; 288 int sc_dying;
289 289
290#if IEEE80211_INJECTION /* XXX: ljt */ 290#if IEEE80211_INJECTION /* XXX: ljt */
291 int (*sc_if_output) /* ether output routine */ 291 int (*sc_if_output) /* ether output routine */
292 (struct ifnet *, struct mbuf *, const struct sockaddr *, 292 (struct ifnet *, struct mbuf *, const struct sockaddr *,
293 struct rtentry *); 293 struct rtentry *);
294#endif 294#endif
295}; 295};
296 296
297#endif /* _IF_OTUSVAR_H_ */ 297#endif /* _IF_OTUSVAR_H_ */
298