if_rumvar.h revision 288531
1/*	$FreeBSD: head/sys/dev/usb/wlan/if_rumvar.h 288531 2015-10-03 05:44:05Z adrian $	*/
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} __packed __aligned(8);
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} __packed __aligned(8);
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 ieee80211com		sc_ic;
89	struct mbufq			sc_snd;
90	device_t			sc_dev;
91	struct usb_device		*sc_udev;
92
93	struct usb_xfer			*sc_xfer[RUM_N_TRANSFER];
94
95	uint8_t				rf_rev;
96	uint8_t				rffreq;
97
98	struct rum_tx_data		tx_data[RUM_TX_LIST_COUNT];
99	rum_txdhead			tx_q;
100	rum_txdhead			tx_free;
101	int				tx_nfree;
102	struct rum_rx_desc		sc_rx_desc;
103
104	struct mtx			sc_mtx;
105
106	uint32_t			sta[6];
107	uint32_t			rf_regs[4];
108	uint8_t				txpow[44];
109	u_int				sc_detached:1,
110					sc_running:1;
111
112	struct {
113		uint8_t	val;
114		uint8_t	reg;
115	} __packed			bbp_prom[16];
116
117	int				hw_radio;
118	int				rx_ant;
119	int				tx_ant;
120	int				nb_ant;
121	int				ext_2ghz_lna;
122	int				ext_5ghz_lna;
123	int				rssi_2ghz_corr;
124	int				rssi_5ghz_corr;
125	uint8_t				bbp17;
126
127	struct rum_rx_radiotap_header	sc_rxtap;
128	struct rum_tx_radiotap_header	sc_txtap;
129};
130
131#define RUM_LOCK(sc)		mtx_lock(&(sc)->sc_mtx)
132#define RUM_UNLOCK(sc)		mtx_unlock(&(sc)->sc_mtx)
133#define RUM_LOCK_ASSERT(sc)	mtx_assert(&(sc)->sc_mtx, MA_OWNED)
134