xref: /openbsd/sys/dev/usb/if_uathvar.h (revision 73471bf0)
1 /*	$OpenBSD: if_uathvar.h,v 1.7 2013/04/15 09:23:01 mglocker Exp $	*/
2 
3 /*-
4  * Copyright (c) 2006
5  *	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 UATH_TX_DATA_LIST_COUNT	8	/* 16 */
21 #define UATH_TX_CMD_LIST_COUNT	8	/* 30 */
22 
23 /* XXX ehci will panic on abort_pipe if set to anything > 1 */
24 #define UATH_RX_DATA_LIST_COUNT	1	/* 128 */
25 #define UATH_RX_CMD_LIST_COUNT	1	/* 30 */
26 
27 #define UATH_DATA_TIMEOUT	10000
28 #define UATH_CMD_TIMEOUT	1000
29 
30 struct uath_rx_radiotap_header {
31 	struct ieee80211_radiotap_header wr_ihdr;
32 	uint8_t		wr_flags;
33 	uint16_t	wr_chan_freq;
34 	uint16_t	wr_chan_flags;
35 	int8_t		wr_dbm_antsignal;
36 } __packed;
37 
38 #define UATH_RX_RADIOTAP_PRESENT					\
39 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
40 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
41 	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL))
42 
43 struct uath_tx_radiotap_header {
44 	struct ieee80211_radiotap_header wt_ihdr;
45 	uint8_t		wt_flags;
46 	uint16_t	wt_chan_freq;
47 	uint16_t	wt_chan_flags;
48 } __packed;
49 
50 #define UATH_TX_RADIOTAP_PRESENT					\
51 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
52 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
53 
54 struct uath_tx_data {
55 	struct uath_softc	*sc;
56 	struct usbd_xfer	*xfer;
57 	uint8_t			*buf;
58 	struct ieee80211_node	*ni;
59 };
60 
61 struct uath_rx_data {
62 	struct uath_softc	*sc;
63 	struct usbd_xfer	*xfer;
64 	uint8_t			*buf;
65 	struct mbuf		*m;
66 };
67 
68 struct uath_tx_cmd {
69 	struct uath_softc	*sc;
70 	struct usbd_xfer	*xfer;
71 	uint8_t			*buf;
72 	void			*odata;
73 };
74 
75 struct uath_rx_cmd {
76 	struct uath_softc	*sc;
77 	struct usbd_xfer	*xfer;
78 	uint8_t			*buf;
79 };
80 
81 struct uath_wme_settings {
82 	uint8_t		aifsn;
83 	uint8_t		logcwmin;
84 	uint8_t		logcwmax;
85 	uint16_t	txop;
86 #define UATH_TXOP_TO_US(txop)	((txop) << 5)
87 
88 	uint8_t		acm;
89 };
90 
91 /* condvars */
92 #define UATH_COND_INIT(sc)	((caddr_t)sc + 1)
93 
94 /* flags for sending firmware commands */
95 #define UATH_CMD_FLAG_ASYNC	(1 << 0)
96 #define UATH_CMD_FLAG_READ	(1 << 1)
97 #define UATH_CMD_FLAG_MAGIC	(1 << 2)
98 
99 struct uath_softc {
100 	struct device			sc_dev;
101 	struct ieee80211com		sc_ic;
102 	int				(*sc_newstate)(struct ieee80211com *,
103 					    enum ieee80211_state, int);
104 
105 	struct uath_tx_data		tx_data[UATH_TX_DATA_LIST_COUNT];
106 	struct uath_rx_data		rx_data[UATH_RX_DATA_LIST_COUNT];
107 
108 	struct uath_tx_cmd		tx_cmd[UATH_TX_CMD_LIST_COUNT];
109 	struct uath_rx_cmd		rx_cmd[UATH_RX_CMD_LIST_COUNT];
110 
111 	int				sc_flags;
112 
113 	int				data_idx;
114 	int				cmd_idx;
115 	int				tx_queued;
116 
117 	struct usbd_device		*sc_udev;
118 	struct usbd_device		*sc_uhub;
119 	int				sc_port;
120 
121 	struct usbd_interface		*sc_iface;
122 
123 	struct usbd_pipe		*data_tx_pipe;
124 	struct usbd_pipe		*data_rx_pipe;
125 	struct usbd_pipe		*cmd_tx_pipe;
126 	struct usbd_pipe		*cmd_rx_pipe;
127 
128 	enum ieee80211_state		sc_state;
129 	int				sc_arg;
130 	struct usb_task			sc_task;
131 
132 	struct timeout			scan_to;
133 	struct timeout			stat_to;
134 
135 	int				sc_tx_timer;
136 
137 	int				rxbufsz;
138 
139 #if NBPFILTER > 0
140 	caddr_t				sc_drvbpf;
141 
142 	union {
143 		struct	uath_rx_radiotap_header th;
144 		uint8_t	pad[64];
145 	}				sc_rxtapu;
146 #define sc_rxtap			sc_rxtapu.th
147 	int				sc_rxtap_len;
148 
149 	union {
150 		struct	uath_tx_radiotap_header th;
151 		uint8_t	pad[64];
152 	}				sc_txtapu;
153 #define sc_txtap			sc_txtapu.th
154 	int				sc_txtap_len;
155 #endif
156 };
157