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