xref: /openbsd-src/sys/dev/pci/if_wpivar.h (revision a28daedfc357b214be5c701aa8ba8adb29a7f1c2)
1 /*	$OpenBSD: if_wpivar.h,v 1.18 2008/12/03 17:17:08 damien Exp $	*/
2 
3 /*-
4  * Copyright (c) 2006-2008
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 wpi_rx_radiotap_header {
21 	struct ieee80211_radiotap_header wr_ihdr;
22 	uint64_t	wr_tsft;
23 	uint8_t		wr_flags;
24 	uint8_t		wr_rate;
25 	uint16_t	wr_chan_freq;
26 	uint16_t	wr_chan_flags;
27 	int8_t		wr_dbm_antsignal;
28 	int8_t		wr_dbm_antnoise;
29 	uint8_t		wr_antenna;
30 } __packed;
31 
32 #define WPI_RX_RADIOTAP_PRESENT						\
33 	((1 << IEEE80211_RADIOTAP_TSFT) |				\
34 	 (1 << IEEE80211_RADIOTAP_FLAGS) |				\
35 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
36 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
37 	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
38 	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |			\
39 	 (1 << IEEE80211_RADIOTAP_ANTENNA))
40 
41 struct wpi_tx_radiotap_header {
42 	struct ieee80211_radiotap_header wt_ihdr;
43 	uint8_t		wt_flags;
44 	uint8_t		wt_rate;
45 	uint16_t	wt_chan_freq;
46 	uint16_t	wt_chan_flags;
47 	uint8_t		wt_hwqueue;
48 } __packed;
49 
50 #define WPI_TX_RADIOTAP_PRESENT						\
51 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
52 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
53 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
54 	 (1 << IEEE80211_RADIOTAP_HWQUEUE))
55 
56 struct wpi_dma_info {
57 	bus_dma_tag_t		tag;
58 	bus_dmamap_t		map;
59 	bus_dma_segment_t	seg;
60 	bus_addr_t		paddr;
61 	caddr_t			vaddr;
62 	bus_size_t		size;
63 };
64 
65 struct wpi_tx_data {
66 	bus_dmamap_t		map;
67 	bus_addr_t		cmd_paddr;
68 	struct mbuf		*m;
69 	struct ieee80211_node	*ni;
70 };
71 
72 struct wpi_tx_ring {
73 	struct wpi_dma_info	desc_dma;
74 	struct wpi_dma_info	cmd_dma;
75 	struct wpi_tx_desc	*desc;
76 	struct wpi_tx_cmd	*cmd;
77 	struct wpi_tx_data	data[WPI_TX_RING_COUNT];
78 	int			qid;
79 	int			queued;
80 	int			cur;
81 };
82 
83 #define WPI_RBUF_COUNT	(WPI_RX_RING_COUNT + 32)
84 
85 struct wpi_softc;
86 
87 struct wpi_rbuf {
88 	struct wpi_softc	*sc;
89 	caddr_t			vaddr;
90 	bus_addr_t		paddr;
91 	SLIST_ENTRY(wpi_rbuf)	next;
92 };
93 
94 struct wpi_rx_data {
95 	struct mbuf	*m;
96 };
97 
98 struct wpi_rx_ring {
99 	struct wpi_dma_info	desc_dma;
100 	struct wpi_dma_info	buf_dma;
101 	uint32_t		*desc;
102 	struct wpi_rx_data	data[WPI_RX_RING_COUNT];
103 	struct wpi_rbuf		rbuf[WPI_RBUF_COUNT];
104 	SLIST_HEAD(, wpi_rbuf)	freelist;
105 	int			cur;
106 };
107 
108 struct wpi_node {
109 	struct	ieee80211_node		ni;	/* must be the first */
110 	struct	ieee80211_amrr_node	amn;
111 	uint8_t				id;
112 	uint8_t				ridx[IEEE80211_RATE_MAXSIZE];
113 };
114 
115 struct wpi_power_sample {
116 	uint8_t	index;
117 	int8_t	power;
118 };
119 
120 struct wpi_power_group {
121 #define WPI_SAMPLES_COUNT	5
122 	struct	wpi_power_sample samples[WPI_SAMPLES_COUNT];
123 	uint8_t	chan;
124 	int8_t	maxpwr;
125 	int16_t	temp;
126 };
127 
128 struct wpi_fw_part {
129 	const uint8_t	*text;
130 	uint32_t	textsz;
131 	const uint8_t	*data;
132 	uint32_t	datasz;
133 };
134 
135 struct wpi_fw_info {
136 	u_char			*data;
137 	struct wpi_fw_part	init;
138 	struct wpi_fw_part	main;
139 	struct wpi_fw_part	boot;
140 };
141 
142 struct wpi_softc {
143 	struct device		sc_dev;
144 
145 	struct ieee80211com	sc_ic;
146 	int			(*sc_newstate)(struct ieee80211com *,
147 				    enum ieee80211_state, int);
148 
149 	struct ieee80211_amrr	amrr;
150 	uint8_t			fixed_ridx;
151 
152 	bus_dma_tag_t		sc_dmat;
153 
154 	u_int			sc_flags;
155 #define WPI_FLAG_HAS_5GHZ	(1 << 0)
156 
157 	/* Shared area. */
158 	struct wpi_dma_info	shared_dma;
159 	struct wpi_shared	*shared;
160 
161 	/* Firmware DMA transfer. */
162 	struct wpi_dma_info	fw_dma;
163 
164 	/* TX/RX rings. */
165 	struct wpi_tx_ring	txq[WPI_NTXQUEUES];
166 	struct wpi_rx_ring	rxq;
167 
168 	bus_space_tag_t		sc_st;
169 	bus_space_handle_t	sc_sh;
170 	void 			*sc_ih;
171 	pci_chipset_tag_t	sc_pct;
172 	pcitag_t		sc_pcitag;
173 	bus_size_t		sc_sz;
174 	int			sc_cap_off;	/* PCIe Capabilities. */
175 
176 	struct ksensordev	sensordev;
177 	struct ksensor		sensor;
178 	struct timeout		calib_to;
179 	int			calib_cnt;
180 
181 	struct wpi_fw_info	fw;
182 	uint32_t		errptr;
183 
184 	struct wpi_rxon		rxon;
185 	int			temp;
186 	uint32_t		qfullmsk;
187 
188 	uint8_t			cap;
189 	uint16_t		rev;
190 	uint8_t			type;
191 	struct wpi_power_group	groups[WPI_POWER_GROUPS_COUNT];
192 	int8_t			maxpwr[IEEE80211_CHAN_MAX];
193 
194 	int			sc_tx_timer;
195 	void			*powerhook;
196 
197 #if NBPFILTER > 0
198 	caddr_t			sc_drvbpf;
199 
200 	union {
201 		struct wpi_rx_radiotap_header th;
202 		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
203 	} sc_rxtapu;
204 #define sc_rxtap	sc_rxtapu.th
205 	int			sc_rxtap_len;
206 
207 	union {
208 		struct wpi_tx_radiotap_header th;
209 		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
210 	} sc_txtapu;
211 #define sc_txtap	sc_txtapu.th
212 	int			sc_txtap_len;
213 #endif
214 };
215