xref: /openbsd-src/sys/dev/ic/athnvar.h (revision 1a8dbaac879b9f3335ad7fb25429ce63ac1d6bac)
1 /*	$OpenBSD: athnvar.h,v 1.41 2020/10/11 07:05:28 mpi Exp $	*/
2 
3 /*-
4  * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifdef notyet
20 #define ATHN_BT_COEXISTENCE	1
21 #endif
22 
23 #ifdef ATHN_DEBUG
24 #define DPRINTF(x)	do { if (athn_debug > 0) printf x; } while (0)
25 #define DPRINTFN(n, x)	do { if (athn_debug >= (n)) printf x; } while (0)
26 extern int athn_debug;
27 #else
28 #define DPRINTF(x)
29 #define DPRINTFN(n, x)
30 #endif
31 
32 #define LE_READ_4(p)	((p)[0] | (p)[1] << 8 | (p)[2] << 16 | (p)[3] << 24)
33 #define LE_READ_2(p)	((p)[0] | (p)[1] << 8)
34 
35 #define ATHN_RXBUFSZ	3872
36 #define ATHN_TXBUFSZ	4096
37 
38 #define ATHN_NRXBUFS	64
39 #define ATHN_NTXBUFS	64	/* Shared between all Tx queues. */
40 
41 struct athn_rx_radiotap_header {
42 	struct ieee80211_radiotap_header wr_ihdr;
43 	uint64_t	wr_tsft;
44 	uint8_t		wr_flags;
45 	uint8_t		wr_rate;
46 	uint16_t	wr_chan_freq;
47 	uint16_t	wr_chan_flags;
48 	int8_t		wr_dbm_antsignal;
49 	uint8_t		wr_antenna;
50 } __packed;
51 
52 #define ATHN_RX_RADIOTAP_PRESENT						\
53 	(1 << IEEE80211_RADIOTAP_TSFT |					\
54 	 1 << IEEE80211_RADIOTAP_FLAGS |				\
55 	 1 << IEEE80211_RADIOTAP_RATE |					\
56 	 1 << IEEE80211_RADIOTAP_CHANNEL |				\
57 	 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL |			\
58 	 1 << IEEE80211_RADIOTAP_ANTENNA)
59 
60 struct athn_tx_radiotap_header {
61 	struct ieee80211_radiotap_header wt_ihdr;
62 	uint8_t		wt_flags;
63 	uint8_t		wt_rate;
64 	uint16_t	wt_chan_freq;
65 	uint16_t	wt_chan_flags;
66 } __packed;
67 
68 #define ATHN_TX_RADIOTAP_PRESENT						\
69 	(1 << IEEE80211_RADIOTAP_FLAGS |				\
70 	 1 << IEEE80211_RADIOTAP_RATE |					\
71 	 1 << IEEE80211_RADIOTAP_CHANNEL)
72 
73 struct athn_tx_buf {
74 	SIMPLEQ_ENTRY(athn_tx_buf)	bf_list;
75 
76 	void				*bf_descs;
77 	bus_dmamap_t			bf_map;
78 	bus_addr_t			bf_daddr;
79 
80 	struct mbuf			*bf_m;
81 	struct ieee80211_node		*bf_ni;
82 	int				bf_txflags;
83 #define ATHN_TXFLAG_PAPRD	(1 << 0)
84 #define ATHN_TXFLAG_CAB		(1 << 1)
85 };
86 
87 struct athn_txq {
88 	SIMPLEQ_HEAD(, athn_tx_buf)	head;
89 	void				*lastds;
90 	struct athn_tx_buf		*wait;
91 	int				queued;
92 };
93 
94 struct athn_rx_buf {
95 	SIMPLEQ_ENTRY(athn_rx_buf)	bf_list;
96 
97 	void				*bf_desc;
98 	bus_dmamap_t			bf_map;
99 
100 	struct mbuf			*bf_m;
101 	bus_addr_t			bf_daddr;
102 };
103 
104 struct athn_rxq {
105 	struct athn_rx_buf		*bf;
106 
107 	void				*descs;
108 	void				*lastds;
109 	bus_dmamap_t			map;
110 	bus_dma_segment_t		seg;
111 	int				count;
112 
113 	SIMPLEQ_HEAD(, athn_rx_buf)	head;
114 };
115 
116 /* Software rate indexes. */
117 #define ATHN_RIDX_CCK1	0
118 #define ATHN_RIDX_CCK2	1
119 #define ATHN_RIDX_OFDM6	4
120 #define ATHN_RIDX_MCS0	12
121 #define ATHN_RIDX_MCS8	(ATHN_RIDX_MCS0 + 8)
122 #define ATHN_RIDX_MCS15	27
123 #define ATHN_RIDX_MAX	27
124 #define ATHN_MCS_MAX	15
125 #define ATHN_NUM_MCS	(ATHN_MCS_MAX + 1)
126 #define ATHN_IS_HT_RIDX(ridx)	((ridx) >= ATHN_RIDX_MCS0)
127 #define ATHN_IS_MIMO_RIDX(ridx)	((ridx) >= ATHN_RIDX_MCS8)
128 
129 static const struct athn_rate {
130 	uint16_t	rate;		/* Rate in 500Kbps unit. */
131 	uint8_t		hwrate;		/* HW representation. */
132 	uint8_t		rspridx;	/* Control Response Frame rate index. */
133 	enum	ieee80211_phytype phy;
134 } athn_rates[] = {
135 	{    2, 0x1b, 0, IEEE80211_T_DS },
136 	{    4, 0x1a, 1, IEEE80211_T_DS },
137 	{   11, 0x19, 1, IEEE80211_T_DS },
138 	{   22, 0x18, 1, IEEE80211_T_DS },
139 	{   12, 0x0b, 4, IEEE80211_T_OFDM },
140 	{   18, 0x0f, 4, IEEE80211_T_OFDM },
141 	{   24, 0x0a, 6, IEEE80211_T_OFDM },
142 	{   36, 0x0e, 6, IEEE80211_T_OFDM },
143 	{   48, 0x09, 8, IEEE80211_T_OFDM },
144 	{   72, 0x0d, 8, IEEE80211_T_OFDM },
145 	{   96, 0x08, 8, IEEE80211_T_OFDM },
146 	{  108, 0x0c, 8, IEEE80211_T_OFDM },
147 	{   13, 0x80, 4, IEEE80211_T_OFDM },
148 	{   26, 0x81, 6, IEEE80211_T_OFDM },
149 	{   39, 0x82, 6, IEEE80211_T_OFDM },
150 	{   52, 0x83, 8, IEEE80211_T_OFDM },
151 	{   78, 0x84, 8, IEEE80211_T_OFDM },
152 	{  104, 0x85, 8, IEEE80211_T_OFDM },
153 	{  117, 0x86, 8, IEEE80211_T_OFDM },
154 	{  130, 0x87, 8, IEEE80211_T_OFDM },
155 	{   26, 0x88, 4, IEEE80211_T_OFDM },
156 	{   52, 0x89, 6, IEEE80211_T_OFDM },
157 	{   78, 0x8a, 8, IEEE80211_T_OFDM },
158 	{  104, 0x8b, 8, IEEE80211_T_OFDM },
159 	{  156, 0x8c, 8, IEEE80211_T_OFDM },
160 	{  208, 0x8d, 8, IEEE80211_T_OFDM },
161 	{  234, 0x8e, 8, IEEE80211_T_OFDM },
162 	{  260, 0x8f, 8, IEEE80211_T_OFDM }
163 };
164 
165 struct athn_series {
166 	uint16_t	dur;
167 	uint8_t		hwrate;
168 };
169 
170 struct athn_pier {
171 	uint8_t		fbin;
172 	const uint8_t	*pwr[AR_PD_GAINS_IN_MASK];
173 	const uint8_t	*vpd[AR_PD_GAINS_IN_MASK];
174 };
175 
176 /*
177  * Structures used to store initialization values.
178  */
179 struct athn_ini {
180 	int		nregs;
181 	const uint16_t	*regs;
182 	const uint32_t	*vals_5g20;
183 	const uint32_t	*vals_5g40;
184 	const uint32_t	*vals_2g40;
185 	const uint32_t	*vals_2g20;
186 	int		ncmregs;
187 	const uint16_t	*cmregs;
188 	const uint32_t	*cmvals;
189 	int		nfastregs;
190 	const uint16_t	*fastregs;
191 	const uint32_t	*fastvals_5g20;
192 	const uint32_t	*fastvals_5g40;
193 };
194 
195 struct athn_gain {
196 	int		nregs;
197 	const uint16_t	*regs;
198 	const uint32_t	*vals_5g;
199 	const uint32_t	*vals_2g;
200 };
201 
202 struct athn_addac {
203 	int		nvals;
204 	const uint32_t	*vals;
205 };
206 
207 struct athn_serdes {
208 	int		nvals;
209 	const uint32_t	*regs;
210 	const uint32_t	*vals;
211 };
212 
213 /* Rx queue software indexes. */
214 #define ATHN_QID_LP		0
215 #define ATHN_QID_HP		1
216 
217 /* Tx queue software indexes. */
218 #define ATHN_QID_AC_BE		0
219 #define ATHN_QID_PSPOLL		1
220 #define ATHN_QID_AC_BK		2
221 #define ATHN_QID_AC_VI		3
222 #define ATHN_QID_AC_VO		4
223 #define ATHN_QID_UAPSD		5
224 #define ATHN_QID_CAB		6
225 #define ATHN_QID_BEACON		7
226 #define ATHN_QID_COUNT		8
227 
228 /* Map Access Category to Tx queue Id. */
229 static const uint8_t athn_ac2qid[EDCA_NUM_AC] = {
230 	ATHN_QID_AC_BE,	/* EDCA_AC_BE */
231 	ATHN_QID_AC_BK,	/* EDCA_AC_BK */
232 	ATHN_QID_AC_VI,	/* EDCA_AC_VI */
233 	ATHN_QID_AC_VO	/* EDCA_AC_VO */
234 };
235 
236 static const uint8_t athn_5ghz_chans[] = {
237 	/* UNII 1. */
238 	36, 40, 44, 48,
239 	/* UNII 2. */
240 	52, 56, 60, 64,
241 	/* Middle band. */
242 	100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140,
243 	/* UNII 3. */
244 	149, 153, 157, 161, 165
245 };
246 
247 /* Number of data bits per OFDM symbol for MCS[0-15]. */
248 /* See tables 20-29, 20-30, 20-33, 20-34. */
249 static const uint16_t ar_mcs_ndbps[][2] = {
250 	/* 20MHz  40MHz */
251 	{     26,    54 },	/* MCS0 */
252 	{     52,   108 },	/* MCS1 */
253 	{     78,   162 },	/* MCS2 */
254 	{    104,   216 },	/* MCS3 */
255 	{    156,   324 },	/* MCS4 */
256 	{    208,   432 },	/* MCS5 */
257 	{    234,   486 },	/* MCS6 */
258 	{    260,   540 },	/* MCS7 */
259 	{     26,   108 },	/* MCS8 */
260 	{     52,   216 },	/* MCS9 */
261 	{     78,   324 },	/* MCS10 */
262 	{    104,   432 },	/* MCS11 */
263 	{    156,   648 },	/* MCS12 */
264 	{    208,   864 },	/* MCS13 */
265 	{    234,   972 },	/* MCS14 */
266 	{    260,  1080 }	/* MCS15 */
267 };
268 
269 #define ATHN_POWER_OFDM6	0
270 #define ATHN_POWER_OFDM9	1
271 #define ATHN_POWER_OFDM12	2
272 #define ATHN_POWER_OFDM18	3
273 #define ATHN_POWER_OFDM24	4
274 #define ATHN_POWER_OFDM36	5
275 #define ATHN_POWER_OFDM48	6
276 #define ATHN_POWER_OFDM54	7
277 #define ATHN_POWER_CCK1_LP	8
278 #define ATHN_POWER_CCK2_LP	9
279 #define ATHN_POWER_CCK2_SP	10
280 #define ATHN_POWER_CCK55_LP	11
281 #define ATHN_POWER_CCK55_SP	12
282 #define ATHN_POWER_CCK11_LP	13
283 #define ATHN_POWER_CCK11_SP	14
284 #define ATHN_POWER_XR		15
285 #define ATHN_POWER_HT20(mcs)	(16 + (mcs))
286 #define ATHN_POWER_HT40(mcs)	(40 + (mcs))
287 #define ATHN_POWER_CCK_DUP	64
288 #define ATHN_POWER_OFDM_DUP	65
289 #define ATHN_POWER_CCK_EXT	66
290 #define ATHN_POWER_OFDM_EXT	67
291 #define ATHN_POWER_COUNT	68
292 
293 #define ATHN_NUM_LEGACY_RATES	IEEE80211_RATE_MAXSIZE
294 #define ATHN_NUM_RATES		(ATHN_NUM_LEGACY_RATES + ATHN_NUM_MCS)
295 struct athn_node {
296 	struct ieee80211_node		ni;
297 	struct ieee80211_amrr_node	amn;
298 	struct ieee80211_mira_node	mn;
299 	uint8_t				ridx[ATHN_NUM_RATES];
300 	uint8_t				fallback[ATHN_NUM_RATES];
301 	uint8_t				sta_index;
302 };
303 
304 /*
305  * Adaptive noise immunity state.
306  */
307 #define ATHN_ANI_PERIOD		100
308 #define ATHN_ANI_RSSI_THR_HIGH	40
309 #define ATHN_ANI_RSSI_THR_LOW	7
310 struct athn_ani {
311 	uint8_t		noise_immunity_level;
312 	uint8_t		spur_immunity_level;
313 	uint8_t		firstep_level;
314 	uint8_t		ofdm_weak_signal;
315 	uint8_t		cck_weak_signal;
316 
317 	uint32_t	listen_time;
318 
319 	uint32_t	ofdm_trig_high;
320 	uint32_t	ofdm_trig_low;
321 
322 	int32_t		cck_trig_high;
323 	int32_t		cck_trig_low;
324 
325 	uint32_t	ofdm_phy_err_base;
326 	uint32_t	cck_phy_err_base;
327 	uint32_t	ofdm_phy_err_count;
328 	uint32_t	cck_phy_err_count;
329 
330 	uint32_t	cyccnt;
331 	uint32_t	txfcnt;
332 	uint32_t	rxfcnt;
333 };
334 
335 struct athn_iq_cal {
336 	uint32_t	pwr_meas_i;
337 	uint32_t	pwr_meas_q;
338 	int32_t		iq_corr_meas;
339 };
340 
341 struct athn_adc_cal {
342 	uint32_t	pwr_meas_odd_i;
343 	uint32_t	pwr_meas_even_i;
344 	uint32_t	pwr_meas_odd_q;
345 	uint32_t	pwr_meas_even_q;
346 };
347 
348 struct athn_calib {
349 	int			nsamples;
350 	struct athn_iq_cal	iq[AR_MAX_CHAINS];
351 	struct athn_adc_cal	adc_gain[AR_MAX_CHAINS];
352 	struct athn_adc_cal	adc_dc_offset[AR_MAX_CHAINS];
353 };
354 
355 #define ATHN_NF_CAL_HIST_MAX	5
356 
357 struct athn_softc;
358 
359 struct athn_ops {
360 	/* Bus callbacks. */
361 	uint32_t	(*read)(struct athn_softc *, uint32_t);
362 	void		(*write)(struct athn_softc *, uint32_t, uint32_t);
363 	void		(*write_barrier)(struct athn_softc *);
364 
365 	void	(*setup)(struct athn_softc *);
366 	void	(*set_txpower)(struct athn_softc *, struct ieee80211_channel *,
367 		    struct ieee80211_channel *);
368 	void	(*spur_mitigate)(struct athn_softc *,
369 		    struct ieee80211_channel *, struct ieee80211_channel *);
370 	const struct ar_spur_chan *
371 		(*get_spur_chans)(struct athn_softc *, int);
372 	void	(*init_from_rom)(struct athn_softc *,
373 		    struct ieee80211_channel *, struct ieee80211_channel *);
374 	int	(*set_synth)(struct athn_softc *, struct ieee80211_channel *,
375 		    struct ieee80211_channel *);
376 	int	(*read_rom_data)(struct athn_softc *, uint32_t, void *, int);
377 	const uint8_t *
378 		(*get_rom_template)(struct athn_softc *, uint8_t);
379 	void	(*swap_rom)(struct athn_softc *);
380 	void	(*olpc_init)(struct athn_softc *);
381 	void	(*olpc_temp_compensation)(struct athn_softc *);
382 	/* GPIO callbacks. */
383 	int	(*gpio_read)(struct athn_softc *, int);
384 	void	(*gpio_write)(struct athn_softc *, int, int);
385 	void	(*gpio_config_input)(struct athn_softc *, int);
386 	void	(*gpio_config_output)(struct athn_softc *, int, int);
387 	void	(*rfsilent_init)(struct athn_softc *);
388 	/* DMA callbacks. */
389 	int	(*dma_alloc)(struct athn_softc *);
390 	void	(*dma_free)(struct athn_softc *);
391 	void	(*rx_enable)(struct athn_softc *);
392 	int	(*intr)(struct athn_softc *);
393 	int	(*tx)(struct athn_softc *, struct mbuf *,
394 		    struct ieee80211_node *, int);
395 	/* PHY callbacks. */
396 	void	(*set_rf_mode)(struct athn_softc *,
397 		    struct ieee80211_channel *);
398 	int	(*rf_bus_request)(struct athn_softc *);
399 	void	(*rf_bus_release)(struct athn_softc *);
400 	void	(*set_phy)(struct athn_softc *, struct ieee80211_channel *,
401 		    struct ieee80211_channel *);
402 	void	(*set_delta_slope)(struct athn_softc *,
403 		    struct ieee80211_channel *, struct ieee80211_channel *);
404 	void	(*enable_antenna_diversity)(struct athn_softc *);
405 	void	(*init_baseband)(struct athn_softc *);
406 	void	(*disable_phy)(struct athn_softc *);
407 	void	(*set_rxchains)(struct athn_softc *);
408 	void	(*noisefloor_calib)(struct athn_softc *);
409 	void	(*init_noisefloor_calib)(struct athn_softc *);
410 	int	(*get_noisefloor)(struct athn_softc *);
411 	void	(*apply_noisefloor)(struct athn_softc *);
412 	void	(*do_calib)(struct athn_softc *);
413 	void	(*next_calib)(struct athn_softc *);
414 	void	(*hw_init)(struct athn_softc *, struct ieee80211_channel *,
415 		    struct ieee80211_channel *);
416 	void	(*get_paprd_masks)(struct athn_softc *sc,
417 		    struct ieee80211_channel *, uint32_t *, uint32_t *);
418 	/* ANI callbacks. */
419 	void	(*set_noise_immunity_level)(struct athn_softc *, int);
420 	void	(*enable_ofdm_weak_signal)(struct athn_softc *);
421 	void	(*disable_ofdm_weak_signal)(struct athn_softc *);
422 	void	(*set_cck_weak_signal)(struct athn_softc *, int);
423 	void	(*set_firstep_level)(struct athn_softc *, int);
424 	void	(*set_spur_immunity_level)(struct athn_softc *, int);
425 };
426 
427 struct athn_softc {
428 	struct device			sc_dev;
429 	struct ieee80211com		sc_ic;
430 
431 	int				(*sc_enable)(struct athn_softc *);
432 	void				(*sc_disable)(struct athn_softc *);
433 	void				(*sc_power)(struct athn_softc *, int);
434 	void				(*sc_disable_aspm)(struct athn_softc *);
435 	void				(*sc_enable_extsynch)(
436 					    struct athn_softc *);
437 
438 	int				(*sc_newstate)(struct ieee80211com *,
439 					    enum ieee80211_state, int);
440 
441 	bus_dma_tag_t			sc_dmat;
442 
443 	struct timeout			scan_to;
444 	struct timeout			calib_to;
445 	struct ieee80211_amrr		amrr;
446 
447 	u_int				flags;
448 #define ATHN_FLAG_PCIE			(1 << 0)
449 #define ATHN_FLAG_USB			(1 << 1)
450 #define ATHN_FLAG_OLPC			(1 << 2)
451 #define ATHN_FLAG_PAPRD			(1 << 3)
452 #define ATHN_FLAG_FAST_PLL_CLOCK	(1 << 4)
453 #define ATHN_FLAG_RFSILENT		(1 << 5)
454 #define ATHN_FLAG_RFSILENT_REVERSED	(1 << 6)
455 #define ATHN_FLAG_BTCOEX2WIRE		(1 << 7)
456 #define ATHN_FLAG_BTCOEX3WIRE		(1 << 8)
457 /* Shortcut. */
458 #define ATHN_FLAG_BTCOEX	(ATHN_FLAG_BTCOEX2WIRE | ATHN_FLAG_BTCOEX3WIRE)
459 #define ATHN_FLAG_11A			(1 << 9)
460 #define ATHN_FLAG_11G			(1 << 10)
461 #define ATHN_FLAG_11N			(1 << 11)
462 #define ATHN_FLAG_AN_TOP2_FIXUP		(1 << 12)
463 #define ATHN_FLAG_NON_ENTERPRISE	(1 << 13)
464 #define ATHN_FLAG_3TREDUCE_CHAIN	(1 << 14)
465 
466 	uint8_t				ngpiopins;
467 	int				led_pin;
468 	int				rfsilent_pin;
469 	int				led_state;
470 	uint32_t			isync;
471 	uint32_t			imask;
472 
473 	uint16_t			mac_ver;
474 	uint8_t				mac_rev;
475 	uint8_t				rf_rev;
476 	uint16_t			eep_rev;
477 
478 	uint8_t				txchainmask;
479 	uint8_t				rxchainmask;
480 	uint8_t				ntxchains;
481 	uint8_t				nrxchains;
482 
483 	uint8_t				sup_calib_mask;
484 	uint8_t				cur_calib_mask;
485 #define ATHN_CAL_IQ		(1 << 0)
486 #define ATHN_CAL_ADC_GAIN	(1 << 1)
487 #define ATHN_CAL_ADC_DC		(1 << 2)
488 #define ATHN_CAL_TEMP		(1 << 3)
489 
490 	struct ieee80211_channel	*curchan;
491 	struct ieee80211_channel	*curchanext;
492 
493 	/* Open Loop Power Control. */
494 	int8_t				tx_gain_tbl[AR9280_TX_GAIN_TABLE_SIZE];
495 	int8_t				pdadc;
496 	int8_t				tcomp;
497 	int				olpc_ticks;
498 	int				iqcal_ticks;
499 
500 	/* PA predistortion. */
501 	uint16_t			gain1[AR_MAX_CHAINS];
502 	uint32_t			txgain[AR9003_TX_GAIN_TABLE_SIZE];
503 	int16_t				pa_in[AR_MAX_CHAINS]
504 					     [AR9003_PAPRD_MEM_TAB_SIZE];
505 	int16_t				angle[AR_MAX_CHAINS]
506 					     [AR9003_PAPRD_MEM_TAB_SIZE];
507 	int32_t				trainpow;
508 	uint8_t				paprd_curchain;
509 
510 	uint32_t			rwbuf[64];
511 
512 	int				kc_entries;
513 
514 	void				*eep;
515 	const void			*eep_def;
516 	uint32_t			eep_base;
517 	uint32_t			eep_size;
518 
519 	struct athn_rxq			rxq[2];
520 	struct athn_txq			txq[31];
521 
522 	void				*descs;
523 	bus_dmamap_t			map;
524 	bus_dma_segment_t		seg;
525 	SIMPLEQ_HEAD(, athn_tx_buf)	txbufs;
526 	struct athn_tx_buf		*bcnbuf;
527 	struct athn_tx_buf		txpool[ATHN_NTXBUFS];
528 
529 	bus_dmamap_t			txsmap;
530 	bus_dma_segment_t		txsseg;
531 	void				*txsring;
532 	int				txscur;
533 
534 	int				sc_if_flags;
535 	int				sc_tx_timer;
536 
537 	const struct athn_ini		*ini;
538 	const struct athn_gain		*rx_gain;
539 	const struct athn_gain		*tx_gain;
540 	const struct athn_addac		*addac;
541 	const struct athn_serdes	*serdes;
542 	uint32_t			workaround;
543 	uint32_t			obs_off;
544 	uint32_t			gpio_input_en_off;
545 
546 	struct athn_ops			ops;
547 
548 	int				fixed_ridx;
549 
550 	int16_t				cca_min_2g;
551 	int16_t				cca_max_2g;
552 	int16_t				cca_min_5g;
553 	int16_t				cca_max_5g;
554 	struct {
555 		int16_t	nf[AR_MAX_CHAINS];
556 		int16_t	nf_ext[AR_MAX_CHAINS];
557 	}				nf_hist[ATHN_NF_CAL_HIST_MAX];
558 	int				nf_hist_cur;
559 	int				nf_hist_nvalid;
560 	int16_t				nf_priv[AR_MAX_CHAINS];
561 	int16_t				nf_ext_priv[AR_MAX_CHAINS];
562 	int				nf_calib_pending;
563 	int				nf_calib_ticks;
564 	int				pa_calib_ticks;
565 
566 	struct athn_calib		calib;
567 	struct athn_ani			ani;
568 
569 #if NBPFILTER > 0
570 	caddr_t				sc_drvbpf;
571 
572 	union {
573 		struct athn_rx_radiotap_header th;
574 		uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
575 	} sc_rxtapu;
576 #define sc_rxtap			sc_rxtapu.th
577 	int				sc_rxtap_len;
578 
579 	union {
580 		struct athn_tx_radiotap_header th;
581 		uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
582 	} sc_txtapu;
583 #define sc_txtap			sc_txtapu.th
584 	int				sc_txtap_len;
585 #endif
586 };
587 
588 extern int	athn_attach(struct athn_softc *);
589 extern void	athn_detach(struct athn_softc *);
590 extern void	athn_suspend(struct athn_softc *);
591 extern void	athn_wakeup(struct athn_softc *);
592 extern int	athn_intr(void *);
593