xref: /dragonfly/sys/dev/netif/ral/rt2661var.h (revision f02303f9)
1 /*
2  * Copyright (c) 2005
3  *	Damien Bergamini <damien.bergamini@free.fr>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  *
17  * $FreeBSD: src/sys/dev/ral/rt2661var.h,v 1.1 2006/03/05 20:36:56 damien Exp $
18  * $DragonFly: src/sys/dev/netif/ral/rt2661var.h,v 1.5 2007/04/02 13:46:07 sephe Exp $
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_ratectl {
52 	struct ieee80211_node	*ni;
53 	int			len;
54 	int			rateidx;
55 	STAILQ_ENTRY(rt2661_tx_ratectl)	link;
56 };
57 
58 struct rt2661_data {
59 	bus_dmamap_t	map;
60 	struct mbuf	*m;
61 };
62 
63 struct rt2661_tx_ring {
64 	bus_dma_tag_t		desc_dmat;
65 	bus_dma_tag_t		data_dmat;
66 	bus_dmamap_t		desc_map;
67 	bus_addr_t		physaddr;
68 	struct rt2661_tx_desc	*desc;
69 	struct rt2661_data	*data;
70 	int			count;
71 	int			queued;
72 	int			cur;
73 	int			next;
74 };
75 
76 struct rt2661_rx_ring {
77 	bus_dma_tag_t		desc_dmat;
78 	bus_dma_tag_t		data_dmat;
79 	bus_dmamap_t		desc_map;
80 	bus_addr_t		physaddr;
81 	struct rt2661_rx_desc	*desc;
82 	struct rt2661_data	*data;
83 	int			count;
84 	int			cur;
85 	int			next;
86 };
87 
88 struct rt2661_softc {
89 	struct ieee80211com		sc_ic;
90 	bus_space_tag_t			sc_st;
91 	bus_space_handle_t		sc_sh;
92 	device_t			sc_dev;
93 
94 	int				sc_irq_rid;
95 	struct resource			*sc_irq;
96 	void				*sc_ih;
97 
98 	int				(*sc_newstate)(struct ieee80211com *,
99 					    enum ieee80211_state, int);
100 
101 	struct callout			scan_ch;
102 
103 	int				sc_tx_timer;
104 	int				sc_sifs;
105 
106 	struct ieee80211_channel	*sc_curchan;
107 
108 	uint8_t				rf_rev;
109 
110 	uint8_t				rfprog;
111 	uint8_t				rffreq;
112 
113 	struct rt2661_tx_ring		txq[4];
114 	struct rt2661_tx_ring		mgtq;
115 	struct rt2661_rx_ring		rxq;
116 
117 	uint32_t			rf_regs[4];
118 	int8_t				txpow[38];
119 
120 	struct {
121 		uint8_t	reg;
122 		uint8_t	val;
123 	}				bbp_prom[16];
124 
125 	int				hw_radio;
126 	int				rx_ant;
127 	int				tx_ant;
128 	int				nb_ant;
129 	int				ext_2ghz_lna;
130 	int				ext_5ghz_lna;
131 	int				rssi_2ghz_corr;
132 	int				rssi_5ghz_corr;
133 
134 	uint8_t				bbp18;
135 	uint8_t				bbp21;
136 	uint8_t				bbp22;
137 	uint8_t				bbp16;
138 	uint8_t				bbp17;
139 	uint8_t				bbp64;
140 	uint16_t			mcu_led;
141 
142 	STAILQ_HEAD(, rt2661_tx_ratectl) tx_ratectl;
143 
144 	int				dwelltime;
145 
146 	struct bpf_if			*sc_drvbpf;
147 
148 	union {
149 		struct rt2661_rx_radiotap_header th;
150 		uint8_t	pad[64];
151 	}				sc_rxtapu;
152 #define sc_rxtap	sc_rxtapu.th
153 	int				sc_rxtap_len;
154 
155 	union {
156 		struct rt2661_tx_radiotap_header th;
157 		uint8_t	pad[64];
158 	}				sc_txtapu;
159 #define sc_txtap	sc_txtapu.th
160 	int				sc_txtap_len;
161 
162 	struct sysctl_ctx_list		sysctl_ctx;
163 	struct sysctl_oid		*sysctl_tree;
164 };
165 
166 int	rt2661_attach(device_t, int);
167 int	rt2661_detach(void *);
168 void	rt2661_shutdown(void *);
169 void	rt2661_suspend(void *);
170 void	rt2661_resume(void *);
171