if_uralvar.h revision 187259
1/*	$FreeBSD: head/sys/dev/usb2/wlan/if_uralvar.h 187259 2009-01-15 02:35:40Z thompsa $	*/
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
20struct ural_node {
21	struct ieee80211_node ni;
22	struct ieee80211_amrr_node amn;
23};
24
25#define	URAL_NODE(ni)   ((struct ural_node *)(ni))
26
27struct ural_vap {
28	struct ieee80211vap vap;
29	struct ieee80211_beacon_offsets bo;
30	struct ieee80211_amrr amrr;
31
32	int     (*newstate) (struct ieee80211vap *,
33	    	enum	ieee80211_state, int);
34};
35
36#define	URAL_VAP(vap)   ((struct ural_vap *)(vap))
37
38struct ural_config_copy_chan {
39	uint32_t chan_to_ieee;
40	enum ieee80211_phymode chan_to_mode;
41	uint8_t	chan_is_5ghz:1;
42	uint8_t	chan_is_2ghz:1;
43	uint8_t	chan_is_b:1;
44	uint8_t	chan_is_a:1;
45	uint8_t	chan_is_g:1;
46	uint8_t	unused:3;
47};
48
49struct ural_config_copy_bss {
50	uint16_t ni_intval;
51	uint8_t	ni_bssid[IEEE80211_ADDR_LEN];
52	uint8_t	fixed_rate_none;
53};
54
55struct ural_config_copy {
56	struct ural_config_copy_chan ic_curchan;
57	struct ural_config_copy_chan ic_bsschan;
58	struct ural_config_copy_bss iv_bss;
59
60	enum ieee80211_opmode ic_opmode;
61	uint32_t ic_flags;
62	uint32_t if_flags;
63
64	uint16_t ic_txpowlimit;
65	uint16_t ic_curmode;
66
67	uint8_t	ic_myaddr[IEEE80211_ADDR_LEN];
68	uint8_t	if_broadcastaddr[IEEE80211_ADDR_LEN];
69};
70
71struct ural_rx_radiotap_header {
72	struct ieee80211_radiotap_header wr_ihdr;
73	uint8_t	wr_flags;
74	uint8_t	wr_rate;
75	uint16_t wr_chan_freq;
76	uint16_t wr_chan_flags;
77	uint8_t	wr_antenna;
78	uint8_t	wr_antsignal;
79};
80
81#define	RAL_RX_RADIOTAP_PRESENT						\
82	    ((1 << IEEE80211_RADIOTAP_FLAGS) |				\
83	     (1 << IEEE80211_RADIOTAP_RATE) |				\
84	     (1 << IEEE80211_RADIOTAP_CHANNEL) |			\
85	     (1 << IEEE80211_RADIOTAP_ANTENNA) |			\
86	     (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
87
88struct ural_tx_radiotap_header {
89	struct ieee80211_radiotap_header wt_ihdr;
90	uint8_t	wt_flags;
91	uint8_t	wt_rate;
92	uint16_t wt_chan_freq;
93	uint16_t wt_chan_flags;
94	uint8_t	wt_antenna;
95};
96
97#define	RAL_TX_RADIOTAP_PRESENT						\
98	    ((1 << IEEE80211_RADIOTAP_FLAGS) |				\
99	     (1 << IEEE80211_RADIOTAP_RATE) |				\
100	     (1 << IEEE80211_RADIOTAP_CHANNEL) |			\
101	     (1 << IEEE80211_RADIOTAP_ANTENNA))
102
103struct ural_bbp_prom {
104	uint8_t	val;
105	uint8_t	reg;
106} __packed;
107
108struct ural_ifq {
109	struct mbuf *ifq_head;
110	struct mbuf *ifq_tail;
111	uint16_t ifq_len;
112};
113
114enum {
115	URAL_BULK_DT_WR,
116	URAL_BULK_DT_RD,
117	URAL_BULK_CS_WR,
118	URAL_BULK_CS_RD,
119	URAL_N_TRANSFER = 4,
120};
121
122struct ural_softc {
123	void   *sc_evilhack;		/* XXX this pointer must be first */
124
125	struct ural_ifq sc_tx_queue;
126	struct usb2_config_td sc_config_td;
127	struct ural_tx_desc sc_tx_desc;
128	struct ural_rx_desc sc_rx_desc;
129	struct mtx sc_mtx;
130	struct usb2_callout sc_watchdog;
131	struct ural_bbp_prom sc_bbp_prom[16];
132	struct ural_rx_radiotap_header sc_rxtap;
133	struct ural_tx_radiotap_header sc_txtap;
134
135	struct usb2_xfer *sc_xfer[URAL_N_TRANSFER];
136	struct ifnet *sc_ifp;
137	struct usb2_device *sc_udev;
138	const struct ieee80211_rate_table *sc_rates;
139
140	enum ieee80211_state sc_ns_state;
141	uint32_t sc_unit;
142	uint32_t sc_asic_rev;
143	uint32_t sc_rf_regs[4];
144	int	sc_ns_arg;
145
146	uint16_t sc_flags;
147#define	URAL_FLAG_READ_STALL		0x0001
148#define	URAL_FLAG_WRITE_STALL		0x0002
149#define	URAL_FLAG_LL_READY		0x0004
150#define	URAL_FLAG_HL_READY		0x0008
151#define	URAL_FLAG_WAIT_COMMAND		0x0010
152	uint16_t sc_txtap_len;
153	uint16_t sc_rxtap_len;
154	uint16_t sc_sta[11];
155
156	uint8_t	sc_rf_rev;
157	uint8_t	sc_txpow[14];
158	uint8_t	sc_led_mode;
159	uint8_t	sc_hw_radio;
160	uint8_t	sc_rx_ant;
161	uint8_t	sc_tx_ant;
162	uint8_t	sc_nb_ant;
163	uint8_t	sc_amrr_timer;
164	uint8_t	sc_myaddr[IEEE80211_ADDR_LEN];
165
166	char	sc_name[32];
167};
168