if_rumvar.h revision 206358
1/*	$FreeBSD: head/sys/dev/usb/wlan/if_rumvar.h 206358 2010-04-07 15:29:13Z rpaulo $	*/
2
3/*-
4 * Copyright (c) 2005, 2006 Damien Bergamini <damien.bergamini@free.fr>
5 * Copyright (c) 2006 Niall O'Higgins <niallo@openbsd.org>
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 RUM_TX_LIST_COUNT	8
21#define RUM_TX_MINFREE		2
22
23struct rum_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	int8_t		wr_antsignal;
30	int8_t		wr_antnoise;
31	uint8_t		wr_antenna;
32};
33
34#define RT2573_RX_RADIOTAP_PRESENT					\
35	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
36	 (1 << IEEE80211_RADIOTAP_RATE) |				\
37	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
38	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
39	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |			\
40	 (1 << IEEE80211_RADIOTAP_ANTENNA) |				\
41	 0)
42
43struct rum_tx_radiotap_header {
44	struct ieee80211_radiotap_header wt_ihdr;
45	uint8_t		wt_flags;
46	uint8_t		wt_rate;
47	uint16_t	wt_chan_freq;
48	uint16_t	wt_chan_flags;
49	uint8_t		wt_antenna;
50};
51
52#define RT2573_TX_RADIOTAP_PRESENT					\
53	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
54	 (1 << IEEE80211_RADIOTAP_RATE) |				\
55	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
56	 (1 << IEEE80211_RADIOTAP_ANTENNA))
57
58struct rum_softc;
59
60struct rum_tx_data {
61	STAILQ_ENTRY(rum_tx_data)	next;
62	struct rum_softc		*sc;
63	struct rum_tx_desc		desc;
64	struct mbuf			*m;
65	struct ieee80211_node		*ni;
66	int				rate;
67};
68typedef STAILQ_HEAD(, rum_tx_data) rum_txdhead;
69
70struct rum_vap {
71	struct ieee80211vap		vap;
72	struct ieee80211_beacon_offsets	bo;
73	struct usb_callout		ratectl_ch;
74	struct task			ratectl_task;
75
76	int				(*newstate)(struct ieee80211vap *,
77					    enum ieee80211_state, int);
78};
79#define	RUM_VAP(vap)	((struct rum_vap *)(vap))
80
81enum {
82	RUM_BULK_WR,
83	RUM_BULK_RD,
84	RUM_N_TRANSFER = 2,
85};
86
87struct rum_softc {
88	struct ifnet			*sc_ifp;
89	device_t			sc_dev;
90	struct usb_device		*sc_udev;
91
92	struct usb_xfer		*sc_xfer[RUM_N_TRANSFER];
93
94	uint8_t				rf_rev;
95	uint8_t				rffreq;
96
97	struct rum_tx_data		tx_data[RUM_TX_LIST_COUNT];
98	rum_txdhead			tx_q;
99	rum_txdhead			tx_free;
100	int				tx_nfree;
101	struct rum_rx_desc		sc_rx_desc;
102
103	struct mtx			sc_mtx;
104
105	uint32_t			sta[6];
106	uint32_t			rf_regs[4];
107	uint8_t				txpow[44];
108	uint8_t				sc_bssid[6];
109
110	struct {
111		uint8_t	val;
112		uint8_t	reg;
113	} __packed			bbp_prom[16];
114
115	int				hw_radio;
116	int				rx_ant;
117	int				tx_ant;
118	int				nb_ant;
119	int				ext_2ghz_lna;
120	int				ext_5ghz_lna;
121	int				rssi_2ghz_corr;
122	int				rssi_5ghz_corr;
123	uint8_t				bbp17;
124
125	struct rum_rx_radiotap_header	sc_rxtap;
126	int				sc_rxtap_len;
127
128	struct rum_tx_radiotap_header	sc_txtap;
129	int				sc_txtap_len;
130};
131
132#define RUM_LOCK(sc)		mtx_lock(&(sc)->sc_mtx)
133#define RUM_UNLOCK(sc)		mtx_unlock(&(sc)->sc_mtx)
134#define RUM_LOCK_ASSERT(sc, t)	mtx_assert(&(sc)->sc_mtx, t)
135