xref: /openbsd/sys/dev/usb/if_ralvar.h (revision f6aab3d8)
1 /*	$OpenBSD: if_ralvar.h,v 1.10 2013/04/15 09:23:01 mglocker Exp $  */
2 
3 /*-
4  * Copyright (c) 2005
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 RAL_RX_LIST_COUNT	1
21 #define RAL_TX_LIST_COUNT	8
22 
23 struct ural_rx_radiotap_header {
24 	struct ieee80211_radiotap_header wr_ihdr;
25 	uint8_t		wr_flags;
26 	uint8_t		wr_rate;
27 	uint16_t	wr_chan_freq;
28 	uint16_t	wr_chan_flags;
29 	uint8_t		wr_antenna;
30 	uint8_t		wr_antsignal;
31 } __packed;
32 
33 #define RAL_RX_RADIOTAP_PRESENT						\
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 ural_tx_radiotap_header {
41 	struct ieee80211_radiotap_header wt_ihdr;
42 	uint8_t		wt_flags;
43 	uint8_t		wt_rate;
44 	uint16_t	wt_chan_freq;
45 	uint16_t	wt_chan_flags;
46 	uint8_t		wt_antenna;
47 } __packed;
48 
49 #define RAL_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 ural_softc;
56 
57 struct ural_tx_data {
58 	struct ural_softc	*sc;
59 	struct usbd_xfer	*xfer;
60 	uint8_t			*buf;
61 	struct ieee80211_node	*ni;
62 };
63 
64 struct ural_rx_data {
65 	struct ural_softc	*sc;
66 	struct usbd_xfer	*xfer;
67 	uint8_t			*buf;
68 	struct mbuf		*m;
69 };
70 
71 struct ural_softc {
72 	struct device			sc_dev;
73 	struct ieee80211com		sc_ic;
74 	int				(*sc_newstate)(struct ieee80211com *,
75 					    enum ieee80211_state, int);
76 
77 	struct usbd_device		*sc_udev;
78 	struct usbd_interface		*sc_iface;
79 
80 	int				sc_rx_no;
81 	int				sc_tx_no;
82 
83 	uint32_t			asic_rev;
84 	uint16_t			macbbp_rev;
85 	uint8_t				rf_rev;
86 
87 	struct usbd_xfer		*amrr_xfer;
88 
89 	struct usbd_pipe		*sc_rx_pipeh;
90 	struct usbd_pipe		*sc_tx_pipeh;
91 
92 	enum ieee80211_state		sc_state;
93 	int				sc_arg;
94 	struct usb_task			sc_task;
95 
96 	struct ieee80211_amrr		amrr;
97 	struct ieee80211_amrr_node	amn;
98 
99 	struct ural_rx_data		rx_data[RAL_RX_LIST_COUNT];
100 	struct ural_tx_data		tx_data[RAL_TX_LIST_COUNT];
101 	int				tx_queued;
102 	int				tx_cur;
103 
104 	struct timeout			scan_to;
105 	struct timeout			amrr_to;
106 
107 	int				sc_tx_timer;
108 
109 	uint16_t			sta[11];
110 	uint32_t			rf_regs[4];
111 	uint8_t				txpow[14];
112 
113 	struct {
114 		uint8_t	val;
115 		uint8_t	reg;
116 	} __packed			bbp_prom[16];
117 
118 	int				led_mode;
119 	int				hw_radio;
120 	int				rx_ant;
121 	int				tx_ant;
122 	int				nb_ant;
123 
124 #if NBPFILTER > 0
125 	caddr_t				sc_drvbpf;
126 
127 	union {
128 		struct ural_rx_radiotap_header th;
129 		uint8_t	pad[64];
130 	}				sc_rxtapu;
131 #define sc_rxtap	sc_rxtapu.th
132 	int				sc_rxtap_len;
133 
134 	union {
135 		struct ural_tx_radiotap_header th;
136 		uint8_t	pad[64];
137 	}				sc_txtapu;
138 #define sc_txtap	sc_txtapu.th
139 	int				sc_txtap_len;
140 #endif
141 };
142