xref: /openbsd/sys/dev/pci/if_wpivar.h (revision c740c9e9)
1 /*	$OpenBSD: if_wpivar.h,v 1.11 2007/06/05 19:49:40 damien Exp $	*/
2 
3 /*-
4  * Copyright (c) 2006, 2007
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 	struct mbuf		*m;
68 	struct ieee80211_node	*ni;
69 };
70 
71 struct wpi_tx_ring {
72 	struct wpi_dma_info	desc_dma;
73 	struct wpi_dma_info	cmd_dma;
74 	struct wpi_tx_desc	*desc;
75 	struct wpi_tx_cmd	*cmd;
76 	struct wpi_tx_data	*data;
77 	int			qid;
78 	int			count;
79 	int			queued;
80 	int			cur;
81 };
82 
83 #define WPI_RBUF_COUNT	(WPI_RX_RING_COUNT + 16)
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 };
112 
113 struct wpi_power_sample {
114 	uint8_t	index;
115 	int8_t	power;
116 };
117 
118 struct wpi_power_group {
119 #define WPI_SAMPLES_COUNT	5
120 	struct	wpi_power_sample samples[WPI_SAMPLES_COUNT];
121 	uint8_t	chan;
122 	int8_t	maxpwr;
123 	int16_t	temp;
124 };
125 
126 struct wpi_softc {
127 	struct device		sc_dev;
128 
129 	struct ieee80211com	sc_ic;
130 	int			(*sc_newstate)(struct ieee80211com *,
131 				    enum ieee80211_state, int);
132 	struct ieee80211_amrr	amrr;
133 
134 	bus_dma_tag_t		sc_dmat;
135 
136 	/* shared area */
137 	struct wpi_dma_info	shared_dma;
138 	struct wpi_shared	*shared;
139 
140 	/* firmware DMA transfer */
141 	struct wpi_dma_info	fw_dma;
142 
143 	/* rings */
144 	struct wpi_tx_ring	txq[4];
145 	struct wpi_tx_ring	cmdq;
146 	struct wpi_tx_ring	svcq;
147 	struct wpi_rx_ring	rxq;
148 
149 	bus_space_tag_t		sc_st;
150 	bus_space_handle_t	sc_sh;
151 	void 			*sc_ih;
152 	pci_chipset_tag_t	sc_pct;
153 	pcitag_t		sc_pcitag;
154 	bus_size_t		sc_sz;
155 
156 	struct ksensordev	sensordev;
157 	struct ksensor		sensor;
158 	struct timeout		calib_to;
159 	int			calib_cnt;
160 
161 	struct wpi_config	config;
162 	int			temp;
163 
164 	uint8_t			cap;
165 	uint16_t		rev;
166 	uint8_t			type;
167 	struct wpi_power_group	groups[WPI_POWER_GROUPS_COUNT];
168 	int8_t			maxpwr[IEEE80211_CHAN_MAX];
169 
170 	int			sc_tx_timer;
171 	void			*powerhook;
172 
173 #if NBPFILTER > 0
174 	caddr_t			sc_drvbpf;
175 
176 	union {
177 		struct wpi_rx_radiotap_header th;
178 		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
179 	} sc_rxtapu;
180 #define sc_rxtap	sc_rxtapu.th
181 	int			sc_rxtap_len;
182 
183 	union {
184 		struct wpi_tx_radiotap_header th;
185 		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
186 	} sc_txtapu;
187 #define sc_txtap	sc_txtapu.th
188 	int			sc_txtap_len;
189 #endif
190 };
191