xref: /netbsd-src/sys/dev/ic/rt2661var.h (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1 /*	$NetBSD: rt2661var.h,v 1.7 2007/12/09 20:27:59 jmcneill Exp $	*/
2 /*	$OpenBSD: rt2661var.h,v 1.4 2006/02/25 12:56:47 damien Exp $	*/
3 
4 /*-
5  * Copyright (c) 2006
6  *	Damien Bergamini <damien.bergamini@free.fr>
7  *
8  * Permission to use, copy, modify, and distribute this software for any
9  * purpose with or without fee is hereby granted, provided that the above
10  * copyright notice and this permission notice appear in all copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19  */
20 
21 struct rt2661_rx_radiotap_header {
22 	struct ieee80211_radiotap_header wr_ihdr;
23 	uint64_t	wr_tsf;
24 	uint8_t		wr_flags;
25 	uint8_t		wr_rate;
26 	uint16_t	wr_chan_freq;
27 	uint16_t	wr_chan_flags;
28 	uint8_t		wr_antsignal;
29 } __packed;
30 
31 #define RT2661_RX_RADIOTAP_PRESENT					\
32 	((1 << IEEE80211_RADIOTAP_TSFT) |				\
33 	 (1 << IEEE80211_RADIOTAP_FLAGS) |				\
34 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
35 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
36 	 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
37 
38 struct rt2661_tx_radiotap_header {
39 	struct ieee80211_radiotap_header wt_ihdr;
40 	uint8_t		wt_flags;
41 	uint8_t		wt_rate;
42 	uint16_t	wt_chan_freq;
43 	uint16_t	wt_chan_flags;
44 } __packed;
45 
46 #define RT2661_TX_RADIOTAP_PRESENT					\
47 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
48 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
49 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
50 
51 struct rt2661_tx_data {
52 	bus_dmamap_t			map;
53 	struct mbuf			*m;
54 	struct ieee80211_node		*ni;
55 	struct ieee80211_rssdesc	id;
56 };
57 
58 struct rt2661_tx_ring {
59 	bus_dmamap_t		map;
60 	bus_dma_segment_t	seg;
61 	bus_addr_t		physaddr;
62 	struct rt2661_tx_desc	*desc;
63 	struct rt2661_tx_data	*data;
64 	int			count;
65 	int			queued;
66 	int			cur;
67 	int			next;
68 	int			stat;
69 };
70 
71 struct rt2661_rx_data {
72 	bus_dmamap_t	map;
73 	struct mbuf	*m;
74 };
75 
76 struct rt2661_rx_ring {
77 	bus_dmamap_t		map;
78 	bus_dma_segment_t	seg;
79 	bus_addr_t		physaddr;
80 	struct rt2661_rx_desc	*desc;
81 	struct rt2661_rx_data	*data;
82 	int			count;
83 	int			cur;
84 	int			next;
85 };
86 
87 struct rt2661_node {
88 	struct ieee80211_node		ni;
89 	struct ieee80211_rssadapt	rssadapt;
90 };
91 
92 struct rt2661_softc {
93 	struct device			sc_dev;
94 
95 	struct ieee80211com		sc_ic;
96 	int				(*sc_newstate)(struct ieee80211com *,
97 					    enum ieee80211_state, int);
98 
99 	int				(*sc_enable)(struct rt2661_softc *);
100 	void				(*sc_disable)(struct rt2661_softc *);
101 
102 	bus_dma_tag_t			sc_dmat;
103 	bus_space_tag_t			sc_st;
104 	bus_space_handle_t		sc_sh;
105 
106 	struct ethercom			sc_ec;
107 
108 	struct callout			scan_ch;
109 	struct callout			rssadapt_ch;
110 
111 	int				sc_id;
112 	int				sc_flags;
113 #define RT2661_ENABLED	(1 << 0)
114 #define RT2661_FWLOADED	(1 << 1)
115 
116 	int				sc_tx_timer;
117 
118 	struct ieee80211_channel	*sc_curchan;
119 
120 	uint8_t				rf_rev;
121 
122 	uint8_t				rfprog;
123 	uint8_t				rffreq;
124 
125 	struct rt2661_tx_ring		txq[5];
126 	struct rt2661_tx_ring		mgtq;
127 	struct rt2661_rx_ring		rxq;
128 
129 	uint32_t			rf_regs[4];
130 	int8_t				txpow[38];
131 
132 	struct {
133 		uint8_t	reg;
134 		uint8_t	val;
135 	}				bbp_prom[16];
136 
137 	int				hw_radio;
138 	int				rx_ant;
139 	int				tx_ant;
140 	int				nb_ant;
141 	int				ext_2ghz_lna;
142 	int				ext_5ghz_lna;
143 	int				rssi_2ghz_corr;
144 	int				rssi_5ghz_corr;
145 
146 	uint8_t				bbp18;
147 	uint8_t				bbp21;
148 	uint8_t				bbp22;
149 	uint8_t				bbp16;
150 	uint8_t				bbp17;
151 	uint8_t				bbp64;
152 
153 #if NBPFILTER > 0
154 	void *			sc_drvbpf;
155 
156 	union {
157 		struct rt2661_rx_radiotap_header th;
158 		uint8_t	pad[64];
159 	}			sc_rxtapu;
160 #define sc_rxtap		sc_rxtapu.th
161 	int			sc_rxtap_len;
162 
163 	union {
164 		struct rt2661_tx_radiotap_header th;
165 		uint8_t	pad[64];
166 	}			sc_txtapu;
167 #define sc_txtap		sc_txtapu.th
168 	int			sc_txtap_len;
169 #endif
170 };
171 
172 #define	sc_if		sc_ec.ec_if
173 
174 int	rt2661_attach(void *, int);
175 int	rt2661_detach(void *);
176 int	rt2661_intr(void *);
177