xref: /openbsd/sys/dev/ic/rt2560var.h (revision 891d7ab6)
1 /*	$OpenBSD: rt2560var.h,v 1.9 2010/09/07 16:21:42 deraadt Exp $  */
2 
3 /*-
4  * Copyright (c) 2005, 2006
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 struct rt2560_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_antenna;
28 	uint8_t		wr_antsignal;
29 } __packed;
30 
31 #define RT2560_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_ANTENNA) |				\
37 	 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
38 
39 struct rt2560_tx_radiotap_header {
40 	struct ieee80211_radiotap_header wt_ihdr;
41 	uint8_t		wt_flags;
42 	uint8_t		wt_rate;
43 	uint16_t	wt_chan_freq;
44 	uint16_t	wt_chan_flags;
45 	uint8_t		wt_antenna;
46 } __packed;
47 
48 #define RT2560_TX_RADIOTAP_PRESENT					\
49 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
50 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
51 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
52 	 (1 << IEEE80211_RADIOTAP_ANTENNA))
53 
54 struct rt2560_tx_data {
55 	bus_dmamap_t			map;
56 	struct mbuf			*m;
57 	struct ieee80211_node		*ni;
58 };
59 
60 struct rt2560_tx_ring {
61 	bus_dmamap_t		map;
62 	bus_dma_segment_t	seg;
63 	bus_addr_t		physaddr;
64 	struct rt2560_tx_desc	*desc;
65 	struct rt2560_tx_data	*data;
66 	int			count;
67 	int			queued;
68 	int			cur;
69 	int			next;
70 	int			cur_encrypt;
71 	int			next_encrypt;
72 };
73 
74 struct rt2560_rx_data {
75 	bus_dmamap_t	map;
76 	struct mbuf	*m;
77 	int		drop;
78 };
79 
80 struct rt2560_rx_ring {
81 	bus_dmamap_t		map;
82 	bus_dma_segment_t	seg;
83 	bus_addr_t		physaddr;
84 	struct rt2560_rx_desc	*desc;
85 	struct rt2560_rx_data	*data;
86 	int			count;
87 	int			cur;
88 	int			next;
89 	int			cur_decrypt;
90 };
91 
92 struct rt2560_node {
93 	struct ieee80211_node		ni;
94 	struct ieee80211_amrr_node	amn;
95 };
96 
97 struct rt2560_softc {
98 	struct device		sc_dev;
99 
100 	struct ieee80211com	sc_ic;
101 	int			(*sc_newstate)(struct ieee80211com *,
102 				    enum ieee80211_state, int);
103 	struct ieee80211_amrr	amrr;
104 
105 	int			(*sc_enable)(struct rt2560_softc *);
106 	void			(*sc_disable)(struct rt2560_softc *);
107 
108 	bus_dma_tag_t		sc_dmat;
109 	bus_space_tag_t		sc_st;
110 	bus_space_handle_t	sc_sh;
111 
112 	struct timeout		scan_to;
113 	struct timeout		amrr_to;
114 
115 	int			sc_flags;
116 #define RT2560_ENABLED		(1 << 0)
117 #define RT2560_UPDATE_SLOT	(1 << 1)
118 #define RT2560_SET_SLOTTIME	(1 << 2)
119 
120 	int			sc_tx_timer;
121 
122 	uint32_t		asic_rev;
123 	uint8_t			rf_rev;
124 
125 	struct rt2560_tx_ring	txq;
126 	struct rt2560_tx_ring	prioq;
127 	struct rt2560_tx_ring	atimq;
128 	struct rt2560_tx_ring	bcnq;
129 	struct rt2560_rx_ring	rxq;
130 
131 	uint32_t		rf_regs[4];
132 	uint8_t			txpow[14];
133 
134 	struct {
135 		uint8_t	reg;
136 		uint8_t	val;
137 	}			bbp_prom[16];
138 
139 	int			led_mode;
140 	int			hw_radio;
141 	int			rx_ant;
142 	int			tx_ant;
143 	int			nb_ant;
144 
145 	uint8_t			*erp;
146 
147 #if NBPFILTER > 0
148 	caddr_t			sc_drvbpf;
149 
150 	union {
151 		struct rt2560_rx_radiotap_header th;
152 		uint8_t	pad[64];
153 	}			sc_rxtapu;
154 #define sc_rxtap		sc_rxtapu.th
155 	int			sc_rxtap_len;
156 
157 	union {
158 		struct rt2560_tx_radiotap_header th;
159 		uint8_t	pad[64];
160 	}			sc_txtapu;
161 #define sc_txtap		sc_txtapu.th
162 	int			sc_txtap_len;
163 #endif
164 };
165 
166 int	rt2560_attach(void *, int);
167 int	rt2560_detach(void *);
168 void	rt2560_suspend(void *);
169 void	rt2560_resume(void *);
170 int	rt2560_intr(void *);
171