rt2661var.h revision 178354
1/*	$FreeBSD: head/sys/dev/ral/rt2661var.h 178354 2008-04-20 20:35:46Z sam $	*/
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 rt2661_rx_radiotap_header {
21	struct ieee80211_radiotap_header wr_ihdr;
22	uint64_t	wr_tsf;
23	uint8_t		wr_flags;
24	uint8_t		wr_rate;
25	uint16_t	wr_chan_freq;
26	uint16_t	wr_chan_flags;
27	uint8_t		wr_antsignal;
28} __packed;
29
30#define RT2661_RX_RADIOTAP_PRESENT					\
31	((1 << IEEE80211_RADIOTAP_TSFT) |				\
32	 (1 << IEEE80211_RADIOTAP_FLAGS) |				\
33	 (1 << IEEE80211_RADIOTAP_RATE) |				\
34	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
35	 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
36
37struct rt2661_tx_radiotap_header {
38	struct ieee80211_radiotap_header wt_ihdr;
39	uint8_t		wt_flags;
40	uint8_t		wt_rate;
41	uint16_t	wt_chan_freq;
42	uint16_t	wt_chan_flags;
43} __packed;
44
45#define RT2661_TX_RADIOTAP_PRESENT					\
46	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
47	 (1 << IEEE80211_RADIOTAP_RATE) |				\
48	 (1 << IEEE80211_RADIOTAP_CHANNEL))
49
50struct rt2661_tx_data {
51	bus_dmamap_t		map;
52	struct mbuf		*m;
53	struct ieee80211_node	*ni;
54	uint8_t			rix;
55	int8_t			rssi;
56};
57
58struct rt2661_tx_ring {
59	bus_dma_tag_t		desc_dmat;
60	bus_dma_tag_t		data_dmat;
61	bus_dmamap_t		desc_map;
62	bus_addr_t		physaddr;
63	struct rt2661_tx_desc	*desc;
64	struct rt2661_tx_data	*data;
65	int			count;
66	int			queued;
67	int			cur;
68	int			next;
69	int			stat;
70};
71
72struct rt2661_rx_data {
73	bus_dmamap_t	map;
74	struct mbuf	*m;
75};
76
77struct rt2661_rx_ring {
78	bus_dma_tag_t		desc_dmat;
79	bus_dma_tag_t		data_dmat;
80	bus_dmamap_t		desc_map;
81	bus_addr_t		physaddr;
82	struct rt2661_rx_desc	*desc;
83	struct rt2661_rx_data	*data;
84	int			count;
85	int			cur;
86	int			next;
87};
88
89struct rt2661_node {
90	struct ieee80211_node	ni;
91	struct ieee80211_amrr_node amrr;
92};
93#define	RT2661_NODE(ni)		((struct rt2661_node *)(ni))
94
95struct rt2661_vap {
96	struct ieee80211vap	ral_vap;
97	struct ieee80211_amrr	amrr;
98
99	int			(*ral_newstate)(struct ieee80211vap *,
100				    enum ieee80211_state, int);
101};
102#define	RT2661_VAP(vap)		((struct rt2661_vap *)(vap))
103
104struct rt2661_softc {
105	struct ifnet			*sc_ifp;
106	device_t			sc_dev;
107	bus_space_tag_t			sc_st;
108	bus_space_handle_t		sc_sh;
109
110	struct mtx			sc_mtx;
111
112	struct callout			watchdog_ch;
113
114	int				sc_tx_timer;
115	int                             sc_invalid;
116	int				sc_debug;
117
118	const struct ieee80211_rate_table *sc_rates;
119/*
120 * The same in both up to here
121 * ------------------------------------------------
122 */
123
124	int                             sc_flags;
125#define	RAL_FW_LOADED		0x1
126#define	RAL_INPUT_RUNNING	0x2
127	int				sc_id;
128	struct ieee80211_channel	*sc_curchan;
129
130	uint8_t				rf_rev;
131
132	uint8_t				rfprog;
133	uint8_t				rffreq;
134
135	struct rt2661_tx_ring		txq[4];
136	struct rt2661_tx_ring		mgtq;
137	struct rt2661_rx_ring		rxq;
138
139	uint32_t			rf_regs[4];
140	int8_t				txpow[38];
141
142	struct {
143		uint8_t	reg;
144		uint8_t	val;
145	}				bbp_prom[16];
146
147	int				hw_radio;
148	int				rx_ant;
149	int				tx_ant;
150	int				nb_ant;
151	int				ext_2ghz_lna;
152	int				ext_5ghz_lna;
153	int				rssi_2ghz_corr;
154	int				rssi_5ghz_corr;
155
156	uint8_t				bbp18;
157	uint8_t				bbp21;
158	uint8_t				bbp22;
159	uint8_t				bbp16;
160	uint8_t				bbp17;
161	uint8_t				bbp64;
162
163	int				dwelltime;
164
165	struct rt2661_rx_radiotap_header sc_rxtap;
166	int				sc_rxtap_len;
167	struct rt2661_tx_radiotap_header sc_txtap;
168	int				sc_txtap_len;
169};
170
171int	rt2661_attach(device_t, int);
172int	rt2661_detach(void *);
173void	rt2661_shutdown(void *);
174void	rt2661_suspend(void *);
175void	rt2661_resume(void *);
176void	rt2661_intr(void *);
177
178#define RAL_LOCK(sc)		mtx_lock(&(sc)->sc_mtx)
179#define RAL_LOCK_ASSERT(sc)	mtx_assert(&(sc)->sc_mtx, MA_OWNED)
180#define RAL_UNLOCK(sc)		mtx_unlock(&(sc)->sc_mtx)
181