xref: /openbsd/sys/dev/ic/rt2560var.h (revision 37ecb596)
1 /*	$OpenBSD: rt2560var.h,v 1.11 2013/12/06 21:03:03 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 #define RT2560_PRIO_OACTIVE	(1 << 3)
120 #define RT2560_DATA_OACTIVE	(1 << 4)
121 
122 	int			sc_tx_timer;
123 
124 	uint32_t		asic_rev;
125 	uint8_t			rf_rev;
126 
127 	struct rt2560_tx_ring	txq;
128 	struct rt2560_tx_ring	prioq;
129 	struct rt2560_tx_ring	atimq;
130 	struct rt2560_tx_ring	bcnq;
131 	struct rt2560_rx_ring	rxq;
132 
133 	uint32_t		rf_regs[4];
134 	uint8_t			txpow[14];
135 
136 	struct {
137 		uint8_t	reg;
138 		uint8_t	val;
139 	}			bbp_prom[16];
140 
141 	int			led_mode;
142 	int			hw_radio;
143 	int			rx_ant;
144 	int			tx_ant;
145 	int			nb_ant;
146 
147 	uint8_t			*erp;
148 
149 #if NBPFILTER > 0
150 	caddr_t			sc_drvbpf;
151 
152 	union {
153 		struct rt2560_rx_radiotap_header th;
154 		uint8_t	pad[64];
155 	}			sc_rxtapu;
156 #define sc_rxtap		sc_rxtapu.th
157 	int			sc_rxtap_len;
158 
159 	union {
160 		struct rt2560_tx_radiotap_header th;
161 		uint8_t	pad[64];
162 	}			sc_txtapu;
163 #define sc_txtap		sc_txtapu.th
164 	int			sc_txtap_len;
165 #endif
166 };
167 
168 int	rt2560_attach(void *, int);
169 int	rt2560_detach(void *);
170 void	rt2560_suspend(void *);
171 void	rt2560_wakeup(void *);
172 int	rt2560_intr(void *);
173