if_uralvar.h revision 192984
1/*	$FreeBSD: head/sys/dev/usb/wlan/if_uralvar.h 192984 2009-05-28 17:36:36Z 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 RAL_TX_LIST_COUNT	8
21#define RAL_TX_MINFREE		2
22
23#define URAL_SCAN_START         1
24#define URAL_SCAN_END           2
25#define URAL_SET_CHANNEL        3
26
27
28struct ural_rx_radiotap_header {
29	struct ieee80211_radiotap_header wr_ihdr;
30	uint8_t		wr_flags;
31	uint8_t		wr_rate;
32	uint16_t	wr_chan_freq;
33	uint16_t	wr_chan_flags;
34	int8_t		wr_antsignal;
35	int8_t		wr_antnoise;
36	uint8_t		wr_antenna;
37};
38
39#define RAL_RX_RADIOTAP_PRESENT						\
40	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
41	 (1 << IEEE80211_RADIOTAP_RATE) |				\
42	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
43	 (1 << IEEE80211_RADIOTAP_ANTENNA) |				\
44	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
45	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
46
47struct ural_tx_radiotap_header {
48	struct ieee80211_radiotap_header wt_ihdr;
49	uint8_t		wt_flags;
50	uint8_t		wt_rate;
51	uint16_t	wt_chan_freq;
52	uint16_t	wt_chan_flags;
53	uint8_t		wt_antenna;
54};
55
56#define RAL_TX_RADIOTAP_PRESENT						\
57	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
58	 (1 << IEEE80211_RADIOTAP_RATE) |				\
59	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
60	 (1 << IEEE80211_RADIOTAP_ANTENNA))
61
62struct ural_softc;
63
64struct ural_tx_data {
65	STAILQ_ENTRY(ural_tx_data)	next;
66	struct ural_softc		*sc;
67	struct ural_tx_desc		desc;
68	struct mbuf			*m;
69	struct ieee80211_node		*ni;
70	int				rate;
71};
72typedef STAILQ_HEAD(, ural_tx_data) ural_txdhead;
73
74struct ural_node {
75	struct ieee80211_node		ni;
76	struct ieee80211_amrr_node	amn;
77};
78#define	URAL_NODE(ni)	((struct ural_node *)(ni))
79
80struct ural_vap {
81	struct ieee80211vap		vap;
82	struct ieee80211_beacon_offsets	bo;
83	struct ieee80211_amrr		amrr;
84	struct usb_callout		amrr_ch;
85	struct task			amrr_task;
86
87	int				(*newstate)(struct ieee80211vap *,
88					    enum ieee80211_state, int);
89};
90#define	URAL_VAP(vap)	((struct ural_vap *)(vap))
91
92enum {
93	URAL_BULK_WR,
94	URAL_BULK_RD,
95	URAL_N_TRANSFER = 2,
96};
97
98struct ural_softc {
99	struct ifnet			*sc_ifp;
100	device_t			sc_dev;
101	struct usb_device		*sc_udev;
102
103	uint32_t			asic_rev;
104	uint8_t				rf_rev;
105
106	struct usb_xfer		*sc_xfer[URAL_N_TRANSFER];
107
108	struct ural_tx_data		tx_data[RAL_TX_LIST_COUNT];
109	ural_txdhead			tx_q;
110	ural_txdhead			tx_free;
111	int				tx_nfree;
112	struct ural_rx_desc		sc_rx_desc;
113
114	struct mtx			sc_mtx;
115
116	uint16_t			sta[11];
117	uint32_t			rf_regs[4];
118	uint8_t				txpow[14];
119	uint8_t				sc_bssid[6];
120
121	struct {
122		uint8_t			val;
123		uint8_t			reg;
124	} __packed			bbp_prom[16];
125
126	int				led_mode;
127	int				hw_radio;
128	int				rx_ant;
129	int				tx_ant;
130	int				nb_ant;
131
132	struct ural_rx_radiotap_header	sc_rxtap;
133	int				sc_rxtap_len;
134
135	struct ural_tx_radiotap_header	sc_txtap;
136	int				sc_txtap_len;
137};
138
139#define RAL_LOCK(sc)		mtx_lock(&(sc)->sc_mtx)
140#define RAL_UNLOCK(sc)		mtx_unlock(&(sc)->sc_mtx)
141#define RAL_LOCK_ASSERT(sc, t)	mtx_assert(&(sc)->sc_mtx, t)
142