if_athvar.h revision 224588
1116742Ssam/*-
2116904Ssam * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3178354Ssam * All rights reserved.
4116742Ssam *
5116742Ssam * Redistribution and use in source and binary forms, with or without
6116742Ssam * modification, are permitted provided that the following conditions
7116742Ssam * are met:
8116742Ssam * 1. Redistributions of source code must retain the above copyright
9116742Ssam *    notice, this list of conditions and the following disclaimer,
10116904Ssam *    without modification.
11116904Ssam * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12116904Ssam *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13116904Ssam *    redistribution must be conditioned upon including a substantially
14116742Ssam *    similar Disclaimer requirement for further binary redistribution.
15116904Ssam *
16116904Ssam * NO WARRANTY
17116904Ssam * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18116904Ssam * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19116904Ssam * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20116904Ssam * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21116904Ssam * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22116904Ssam * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23116904Ssam * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24116904Ssam * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25116742Ssam * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26116742Ssam * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27116742Ssam * THE POSSIBILITY OF SUCH DAMAGES.
28116742Ssam *
29116742Ssam * $FreeBSD: head/sys/dev/ath/if_athvar.h 224588 2011-08-02 02:46:03Z adrian $
30116742Ssam */
31116742Ssam
32116742Ssam/*
33178354Ssam * Defintions for the Atheros Wireless LAN controller driver.
34116742Ssam */
35116742Ssam#ifndef _DEV_ATH_ATHVAR_H
36116742Ssam#define _DEV_ATH_ATHVAR_H
37116742Ssam
38182742Sbrooks#include <dev/ath/ath_hal/ah.h>
39116742Ssam#include <dev/ath/ath_hal/ah_desc.h>
40116742Ssam#include <net80211/ieee80211_radiotap.h>
41116742Ssam#include <dev/ath/if_athioctl.h>
42178354Ssam#include <dev/ath/if_athrate.h>
43116742Ssam
44178354Ssam#define	ATH_TIMEOUT		1000
45116742Ssam
46116742Ssam/*
47116742Ssam * 802.11n requires more TX and RX buffers to do AMPDU.
48178354Ssam */
49116742Ssam#ifdef	ATH_ENABLE_11N
50116742Ssam#define	ATH_TXBUF	512
51116742Ssam#define	ATH_RXBUF	512
52178955Ssam#endif
53178955Ssam
54178955Ssam#ifndef ATH_RXBUF
55178955Ssam#define	ATH_RXBUF	40		/* number of RX buffers */
56178955Ssam#endif
57178955Ssam#ifndef ATH_TXBUF
58178955Ssam#define	ATH_TXBUF	200		/* number of TX buffers */
59178955Ssam#endif
60178955Ssam#define	ATH_BCBUF	4		/* number of beacon buffers */
61178955Ssam
62178955Ssam#define	ATH_TXDESC	10		/* number of descriptors per buffer */
63116742Ssam#define	ATH_TXMAXTRY	11		/* max number of transmit attempts */
64178957Ssam#define	ATH_TXMGTTRY	4		/* xmit attempts for mgt/ctl frames */
65178957Ssam#define	ATH_TXINTR_PERIOD 5		/* max number of batched tx descriptors */
66178957Ssam
67178957Ssam#define	ATH_BEACON_AIFS_DEFAULT	 0	/* default aifs for ap beacon q */
68178957Ssam#define	ATH_BEACON_CWMIN_DEFAULT 0	/* default cwmin for ap beacon q */
69178957Ssam#define	ATH_BEACON_CWMAX_DEFAULT 0	/* default cwmax for ap beacon q */
70178957Ssam
71178957Ssam/*
72178957Ssam * The key cache is used for h/w cipher state and also for
73178957Ssam * tracking station state such as the current tx antenna.
74178354Ssam * We also setup a mapping table between key cache slot indices
75178354Ssam * and station state to short-circuit node lookups on rx.
76116742Ssam * Different parts have different size key caches.  We handle
77178354Ssam * up to ATH_KEYMAX entries (could dynamically allocate state).
78178354Ssam */
79178354Ssam#define	ATH_KEYMAX	128		/* max key cache size we handle */
80178354Ssam#define	ATH_KEYBYTES	(ATH_KEYMAX/NBBY)	/* storage space in bytes */
81178354Ssam
82178354Ssamstruct taskqueue;
83178354Ssamstruct kthread;
84178354Ssamstruct ath_buf;
85178354Ssam
86178354Ssam/* driver-specific node state */
87178354Ssamstruct ath_node {
88178354Ssam	struct ieee80211_node an_node;	/* base class */
89164645Ssam	u_int8_t	an_mgmtrix;	/* min h/w rate index */
90164645Ssam	u_int8_t	an_mcastrix;	/* mcast h/w rate index */
91164645Ssam	struct ath_buf	*an_ff_buf[WME_NUM_AC]; /* ff staging area */
92164645Ssam	/* variable-length rate control state follows */
93164645Ssam};
94164645Ssam#define	ATH_NODE(ni)	((struct ath_node *)(ni))
95165569Ssam#define	ATH_NODE_CONST(ni)	((const struct ath_node *)(ni))
96165569Ssam
97165569Ssam#define ATH_RSSI_LPF_LEN	10
98165569Ssam#define ATH_RSSI_DUMMY_MARKER	0x127
99164645Ssam#define ATH_EP_MUL(x, mul)	((x) * (mul))
100164645Ssam#define ATH_RSSI_IN(x)		(ATH_EP_MUL((x), HAL_RSSI_EP_MULTIPLIER))
101164645Ssam#define ATH_LPF_RSSI(x, y, len) \
102164645Ssam    ((x != ATH_RSSI_DUMMY_MARKER) ? (((x) * ((len) - 1) + (y)) / (len)) : (y))
103164645Ssam#define ATH_RSSI_LPF(x, y) do {						\
104164645Ssam    if ((y) >= -20)							\
105164645Ssam    	x = ATH_LPF_RSSI((x), ATH_RSSI_IN((y)), ATH_RSSI_LPF_LEN);	\
106140915Ssam} while (0)
107165569Ssam#define	ATH_EP_RND(x,mul) \
108165569Ssam	((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul))
109165569Ssam#define	ATH_RSSI(x)		ATH_EP_RND(x, HAL_RSSI_EP_MULTIPLIER)
110165569Ssam
111165569Ssamstruct ath_buf {
112165569Ssam	STAILQ_ENTRY(ath_buf)	bf_list;
113116742Ssam	int			bf_nseg;
114165569Ssam	uint16_t		bf_txflags;	/* tx descriptor flags */
115167468Ssam	uint16_t		bf_flags;	/* status flags (below) */
116165574Ssam	struct ath_desc		*bf_desc;	/* virtual addr of desc */
117165569Ssam	struct ath_desc_status	bf_status;	/* tx/rx status */
118116742Ssam	bus_addr_t		bf_daddr;	/* physical addr of desc */
119116742Ssam	bus_dmamap_t		bf_dmamap;	/* DMA map for mbuf chain */
120116742Ssam	struct mbuf		*bf_m;		/* mbuf for buf */
121186107Ssam	struct ieee80211_node	*bf_node;	/* pointer to the node */
122170530Ssam	bus_size_t		bf_mapsize;
123116742Ssam#define	ATH_MAX_SCATTER		ATH_TXDESC	/* max(tx,rx,beacon) desc's */
124178354Ssam	bus_dma_segment_t	bf_segs[ATH_MAX_SCATTER];
125167468Ssam};
126170530Ssamtypedef STAILQ_HEAD(, ath_buf) ath_bufhead;
127116742Ssam
128170530Ssam#define	ATH_BUF_BUSY	0x00000002	/* (tx) desc owned by h/w */
129170530Ssam
130170530Ssam/*
131170530Ssam * DMA state for tx/rx descriptors.
132170530Ssam */
133170530Ssamstruct ath_descdma {
134170530Ssam	const char*		dd_name;
135170530Ssam	struct ath_desc		*dd_desc;	/* descriptors */
136170530Ssam	bus_addr_t		dd_desc_paddr;	/* physical addr of dd_desc */
137170530Ssam	bus_size_t		dd_desc_len;	/* size of dd_desc */
138170530Ssam	bus_dma_segment_t	dd_dseg;
139170530Ssam	bus_dma_tag_t		dd_dmat;	/* bus DMA tag */
140170530Ssam	bus_dmamap_t		dd_dmamap;	/* DMA map for descriptors */
141170530Ssam	struct ath_buf		*dd_bufptr;	/* associated buffers */
142170530Ssam};
143170530Ssam
144170530Ssam/*
145170530Ssam * Data transmit queue state.  One of these exists for each
146170530Ssam * hardware transmit queue.  Packets sent to us from above
147170530Ssam * are assigned to queues based on their priority.  Not all
148170530Ssam * devices support a complete set of hardware transmit queues.
149170530Ssam * For those devices the array sc_ac2q will map multiple
150170530Ssam * priorities to fewer hardware queues (typically all to one
151116742Ssam * hardware queue).
152170530Ssam */
153170530Ssamstruct ath_txq {
154170530Ssam	u_int			axq_qnum;	/* hardware q number */
155164645Ssam#define	ATH_TXQ_SWQ	(HAL_NUM_TX_QUEUES+1)	/* qnum for s/w only queue */
156178354Ssam	u_int			axq_ac;		/* WME AC */
157178354Ssam	u_int			axq_flags;
158178354Ssam#define	ATH_TXQ_PUTPENDING	0x0001		/* ath_hal_puttxbuf pending */
159178354Ssam	u_int			axq_depth;	/* queue depth (stat only) */
160170530Ssam	u_int			axq_intrcnt;	/* interrupt count */
161172233Ssam	u_int32_t		*axq_link;	/* link ptr in last TX desc */
162178354Ssam	STAILQ_HEAD(, ath_buf)	axq_q;		/* transmit queue */
163170530Ssam	struct mtx		axq_lock;	/* lock on q and link */
164170530Ssam	char			axq_name[12];	/* e.g. "ath0_txq4" */
165170530Ssam};
166164645Ssam
167165569Ssam#define	ATH_TXQ_LOCK_INIT(_sc, _tq) do { \
168165569Ssam	snprintf((_tq)->axq_name, sizeof((_tq)->axq_name), "%s_txq%u", \
169165569Ssam		device_get_nameunit((_sc)->sc_dev), (_tq)->axq_qnum); \
170165569Ssam	mtx_init(&(_tq)->axq_lock, (_tq)->axq_name, NULL, MTX_DEF); \
171165569Ssam} while (0)
172165569Ssam#define	ATH_TXQ_LOCK_DESTROY(_tq)	mtx_destroy(&(_tq)->axq_lock)
173165569Ssam#define	ATH_TXQ_LOCK(_tq)		mtx_lock(&(_tq)->axq_lock)
174165569Ssam#define	ATH_TXQ_UNLOCK(_tq)		mtx_unlock(&(_tq)->axq_lock)
175165569Ssam#define	ATH_TXQ_LOCK_ASSERT(_tq)	mtx_assert(&(_tq)->axq_lock, MA_OWNED)
176165569Ssam
177165569Ssam#define ATH_TXQ_INSERT_TAIL(_tq, _elm, _field) do { \
178165569Ssam	STAILQ_INSERT_TAIL(&(_tq)->axq_q, (_elm), _field); \
179165569Ssam	(_tq)->axq_depth++; \
180178354Ssam} while (0)
181178354Ssam#define ATH_TXQ_REMOVE_HEAD(_tq, _field) do { \
182178354Ssam	STAILQ_REMOVE_HEAD(&(_tq)->axq_q, _field); \
183178354Ssam	(_tq)->axq_depth--; \
184178354Ssam} while (0)
185178354Ssam/* NB: this does not do the "head empty check" that STAILQ_LAST does */
186178354Ssam#define	ATH_TXQ_LAST(_tq) \
187178354Ssam	((struct ath_buf *)(void *) \
188178354Ssam	 ((char *)((_tq)->axq_q.stqh_last) - __offsetof(struct ath_buf, bf_list)))
189178354Ssam
190178354Ssamstruct ath_vap {
191178354Ssam	struct ieee80211vap av_vap;	/* base class */
192178521Ssam	int		av_bslot;	/* beacon slot index */
193178521Ssam	struct ath_buf	*av_bcbuf;	/* beacon buffer */
194178521Ssam	struct ieee80211_beacon_offsets av_boff;/* dynamic update state */
195178521Ssam	struct ath_txq	av_mcastq;	/* buffered mcast s/w queue */
196178521Ssam
197178521Ssam	void		(*av_recv_mgmt)(struct ieee80211_node *,
198178521Ssam				struct mbuf *, int, int, int);
199178521Ssam	int		(*av_newstate)(struct ieee80211vap *,
200178521Ssam				enum ieee80211_state, int);
201178521Ssam	void		(*av_bmiss)(struct ieee80211vap *);
202178521Ssam};
203178521Ssam#define	ATH_VAP(vap)	((struct ath_vap *)(vap))
204178521Ssam
205178521Ssamstruct taskqueue;
206178521Ssamstruct ath_tx99;
207178521Ssam
208178354Ssamstruct ath_softc {
209178354Ssam	struct ifnet		*sc_ifp;	/* interface common */
210178354Ssam	struct ath_stats	sc_stats;	/* interface statistics */
211178354Ssam	int			sc_debug;
212165569Ssam	int			sc_nvaps;	/* # vaps */
213165569Ssam	int			sc_nstavaps;	/* # station vaps */
214165569Ssam	int			sc_nmeshvaps;	/* # mbss vaps */
215165569Ssam	u_int8_t		sc_hwbssidmask[IEEE80211_ADDR_LEN];
216178354Ssam	u_int8_t		sc_nbssid0;	/* # vap's using base mac */
217178354Ssam	uint32_t		sc_bssidmask;	/* bssid mask */
218165569Ssam
219178354Ssam	void 			(*sc_node_free)(struct ieee80211_node *);
220165569Ssam	device_t		sc_dev;
221179388Ssam	HAL_BUS_TAG		sc_st;		/* bus space tag */
222178354Ssam	HAL_BUS_HANDLE		sc_sh;		/* bus space handle */
223165569Ssam	bus_dma_tag_t		sc_dmat;	/* bus DMA tag */
224165569Ssam	struct mtx		sc_mtx;		/* master lock (recursive) */
225165569Ssam	struct taskqueue	*sc_tq;		/* private task queue */
226165569Ssam	struct ath_hal		*sc_ah;		/* Atheros HAL */
227165569Ssam	struct ath_ratectrl	*sc_rc;		/* tx rate control support */
228178354Ssam	struct ath_tx99		*sc_tx99;	/* tx99 adjunct state */
229170530Ssam	void			(*sc_setdefantenna)(struct ath_softc *, u_int);
230178354Ssam	unsigned int		sc_invalid  : 1,/* disable hardware accesses */
231178354Ssam				sc_mrretry  : 1,/* multi-rate retry support */
232116742Ssam				sc_softled  : 1,/* enable LED gpio status */
233155688Ssam				sc_splitmic : 1,/* split TKIP MIC keys */
234155688Ssam				sc_needmib  : 1,/* enable MIB stats intr */
235138568Ssam				sc_diversity: 1,/* enable rx diversity */
236138568Ssam				sc_hasveol  : 1,/* tx VEOL support */
237170530Ssam				sc_ledstate : 1,/* LED on/off state */
238138568Ssam				sc_blinking : 1,/* LED blink operation active */
239170530Ssam				sc_mcastkey : 1,/* mcast key cache search */
240138568Ssam				sc_scanning : 1,/* scanning active */
241170530Ssam				sc_syncbeacon:1,/* sync/resync beacon timers */
242170530Ssam				sc_hasclrkey: 1,/* CLR key supported */
243178354Ssam				sc_xchanmode: 1,/* extended channel mode */
244138568Ssam				sc_outdoor  : 1,/* outdoor operation */
245178354Ssam				sc_dturbo   : 1,/* dynamic turbo in use */
246138568Ssam				sc_hasbmask : 1,/* bssid mask support */
247178354Ssam				sc_hasbmatch: 1,/* bssid match disable support*/
248178354Ssam				sc_hastsfadd: 1,/* tsf adjust support */
249178354Ssam				sc_beacons  : 1,/* beacons running */
250178354Ssam				sc_swbmiss  : 1,/* sta mode using sw bmiss */
251178354Ssam				sc_stagbeacons:1,/* use staggered beacons */
252178521Ssam				sc_wmetkipmic:1,/* can do WME+TKIP MIC */
253178521Ssam				sc_resume_up: 1,/* on resume, start all vaps */
254178521Ssam				sc_tdma	    : 1,/* TDMA in use */
255140915Ssam				sc_setcca   : 1,/* set/clr CCA with TDMA */
256178354Ssam				sc_resetcal : 1,/* reset cal state next trip */
257178354Ssam				sc_rxslink  : 1,/* do self-linked final descriptor */
258178354Ssam				sc_kickpcu  : 1;/* kick PCU RX on next RX proc */
259178354Ssam	uint32_t		sc_eerd;	/* regdomain from EEPROM */
260178354Ssam	uint32_t		sc_eecc;	/* country code from EEPROM */
261178354Ssam						/* rate tables */
262116742Ssam	const HAL_RATE_TABLE	*sc_rates[IEEE80211_MODE_MAX];
263116742Ssam	const HAL_RATE_TABLE	*sc_currates;	/* current rate table */
264178354Ssam	enum ieee80211_phymode	sc_curmode;	/* current phy mode */
265178354Ssam	HAL_OPMODE		sc_opmode;	/* current operating mode */
266178354Ssam	u_int16_t		sc_curtxpow;	/* current tx power limit */
267178354Ssam	u_int16_t		sc_curaid;	/* current association id */
268178354Ssam	struct ieee80211_channel *sc_curchan;	/* current installed channel */
269178354Ssam	u_int8_t		sc_curbssid[IEEE80211_ADDR_LEN];
270116742Ssam	u_int8_t		sc_rixmap[256];	/* IEEE to h/w rate table ix */
271138568Ssam	struct {
272116742Ssam		u_int8_t	ieeerate;	/* IEEE rate */
273138568Ssam		u_int8_t	rxflags;	/* radiotap rx flags */
274178354Ssam		u_int8_t	txflags;	/* radiotap tx flags */
275116742Ssam		u_int16_t	ledon;		/* softled on time */
276178354Ssam		u_int16_t	ledoff;		/* softled off time */
277178354Ssam	} sc_hwmap[32];				/* h/w rate ix mappings */
278178354Ssam	u_int8_t		sc_protrix;	/* protection rate index */
279138568Ssam	u_int8_t		sc_lastdatarix;	/* last data frame rate index */
280138568Ssam	u_int			sc_mcastrate;	/* ieee rate for mcastrateix */
281178354Ssam	u_int			sc_fftxqmin;	/* min frames before staging */
282170530Ssam	u_int			sc_fftxqmax;	/* max frames before drop */
283170530Ssam	u_int			sc_txantenna;	/* tx antenna (fixed or auto) */
284166012Ssam	HAL_INT			sc_imask;	/* interrupt mask copy */
285138568Ssam	u_int			sc_keymax;	/* size of key cache */
286138568Ssam	u_int8_t		sc_keymap[ATH_KEYBYTES];/* key use bit map */
287170530Ssam
288138568Ssam	u_int			sc_ledpin;	/* GPIO pin for driving LED */
289116742Ssam	u_int			sc_ledon;	/* pin setting for LED on */
290138568Ssam	u_int			sc_ledidle;	/* idle polling interval */
291170530Ssam	int			sc_ledevent;	/* time of last LED event */
292178354Ssam	u_int8_t		sc_txrix;	/* current tx rate for LED */
293178354Ssam	u_int16_t		sc_ledoff;	/* off time for current blink */
294138568Ssam	struct callout		sc_ledtimer;	/* led off timer */
295178354Ssam
296178354Ssam	u_int			sc_rfsilentpin;	/* GPIO pin for rfkill int */
297178354Ssam	u_int			sc_rfsilentpol;	/* pin setting for rfkill on */
298178354Ssam
299178354Ssam	struct ath_descdma	sc_rxdma;	/* RX descriptors */
300178354Ssam	ath_bufhead		sc_rxbuf;	/* receive buffer */
301178354Ssam	struct mbuf		*sc_rxpending;	/* pending receive data */
302178354Ssam	u_int32_t		*sc_rxlink;	/* link ptr in last RX desc */
303178354Ssam	struct task		sc_rxtask;	/* rx int processing */
304178354Ssam	u_int8_t		sc_defant;	/* current default antenna */
305178354Ssam	u_int8_t		sc_rxotherant;	/* rx's on non-default antenna*/
306178354Ssam	u_int64_t		sc_lastrx;	/* tsf at last rx'd frame */
307178354Ssam	struct ath_rx_status	*sc_lastrs;	/* h/w status of last rx */
308178354Ssam	struct ath_rx_radiotap_header sc_rx_th;
309178354Ssam	int			sc_rx_th_len;
310178354Ssam	u_int			sc_monpass;	/* frames to pass in mon.mode */
311178354Ssam
312178354Ssam	struct ath_descdma	sc_txdma;	/* TX descriptors */
313178354Ssam	ath_bufhead		sc_txbuf;	/* transmit buffer */
314178354Ssam	struct mtx		sc_txbuflock;	/* txbuf lock */
315178354Ssam	char			sc_txname[12];	/* e.g. "ath0_buf" */
316178354Ssam	u_int			sc_txqsetup;	/* h/w queues setup */
317178354Ssam	u_int			sc_txintrperiod;/* tx interrupt batching */
318178354Ssam	struct ath_txq		sc_txq[HAL_NUM_TX_QUEUES];
319178354Ssam	struct ath_txq		*sc_ac2q[5];	/* WME AC -> h/w q map */
320178354Ssam	struct task		sc_txtask;	/* tx int processing */
321178354Ssam	int			sc_wd_timer;	/* count down for wd timer */
322178354Ssam	struct callout		sc_wd_ch;	/* tx watchdog timer */
323178354Ssam	struct ath_tx_radiotap_header sc_tx_th;
324178354Ssam	int			sc_tx_th_len;
325178354Ssam
326178354Ssam	struct ath_descdma	sc_bdma;	/* beacon descriptors */
327178354Ssam	ath_bufhead		sc_bbuf;	/* beacon buffers */
328178354Ssam	u_int			sc_bhalq;	/* HAL q for outgoing beacons */
329178354Ssam	u_int			sc_bmisscount;	/* missed beacon transmits */
330178354Ssam	u_int32_t		sc_ant_tx[8];	/* recent tx frames/antenna */
331178354Ssam	struct ath_txq		*sc_cabq;	/* tx q for cab frames */
332178354Ssam	struct task		sc_bmisstask;	/* bmiss int processing */
333178354Ssam	struct task		sc_bstucktask;	/* stuck beacon processing */
334178354Ssam	enum {
335178354Ssam		OK,				/* no change needed */
336178354Ssam		UPDATE,				/* update pending */
337178354Ssam		COMMIT				/* beacon sent, commit change */
338178354Ssam	} sc_updateslot;			/* slot time update fsm */
339178354Ssam	int			sc_slotupdate;	/* slot to advance fsm */
340178354Ssam	struct ieee80211vap	*sc_bslot[ATH_BCBUF];
341178354Ssam	int			sc_nbcnvaps;	/* # vaps with beacons */
342178354Ssam
343178354Ssam	struct callout		sc_cal_ch;	/* callout handle for cals */
344178354Ssam	int			sc_lastlongcal;	/* last long cal completed */
345178354Ssam	int			sc_lastcalreset;/* last cal reset done */
346178354Ssam	int			sc_lastani;	/* last ANI poll */
347178354Ssam	int			sc_lastshortcal;	/* last short calibration */
348178354Ssam	HAL_BOOL		sc_doresetcal;	/* Yes, we're doing a reset cal atm */
349178957Ssam	HAL_NODE_STATS		sc_halstats;	/* station-mode rssi stats */
350178354Ssam	u_int			sc_tdmadbaprep;	/* TDMA DBA prep time */
351178354Ssam	u_int			sc_tdmaswbaprep;/* TDMA SWBA prep time */
352178354Ssam	u_int			sc_tdmaswba;	/* TDMA SWBA counter */
353178354Ssam	u_int32_t		sc_tdmabintval;	/* TDMA beacon interval (TU) */
354178354Ssam	u_int32_t		sc_tdmaguard;	/* TDMA guard time (usec) */
355178354Ssam	u_int			sc_tdmaslotlen;	/* TDMA slot length (usec) */
356178354Ssam	u_int32_t		sc_avgtsfdeltap;/* TDMA slot adjust (+) */
357178354Ssam	u_int32_t		sc_avgtsfdeltam;/* TDMA slot adjust (-) */
358178354Ssam	uint16_t		*sc_eepromdata;	/* Local eeprom data, if AR9100 */
359178354Ssam	int			sc_txchainmask;	/* currently configured TX chainmask */
360178354Ssam	int			sc_rxchainmask;	/* currently configured RX chainmask */
361178354Ssam
362178354Ssam	/* DFS related state */
363178354Ssam	void			*sc_dfs;	/* Used by an optional DFS module */
364178354Ssam	int			sc_dodfs;	/* Whether to enable DFS rx filter bits */
365178354Ssam	struct task		sc_dfstask;	/* DFS processing task */
366184278Ssam};
367184278Ssam
368184278Ssam#define	ATH_LOCK_INIT(_sc) \
369178354Ssam	mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \
370178354Ssam		 NULL, MTX_DEF | MTX_RECURSE)
371178354Ssam#define	ATH_LOCK_DESTROY(_sc)	mtx_destroy(&(_sc)->sc_mtx)
372178354Ssam#define	ATH_LOCK(_sc)		mtx_lock(&(_sc)->sc_mtx)
373178354Ssam#define	ATH_UNLOCK(_sc)		mtx_unlock(&(_sc)->sc_mtx)
374178354Ssam#define	ATH_LOCK_ASSERT(_sc)	mtx_assert(&(_sc)->sc_mtx, MA_OWNED)
375178354Ssam
376178354Ssam#define	ATH_TXQ_SETUP(sc, i)	((sc)->sc_txqsetup & (1<<i))
377178354Ssam
378178354Ssam#define	ATH_TXBUF_LOCK_INIT(_sc) do { \
379178354Ssam	snprintf((_sc)->sc_txname, sizeof((_sc)->sc_txname), "%s_buf", \
380178354Ssam		device_get_nameunit((_sc)->sc_dev)); \
381178354Ssam	mtx_init(&(_sc)->sc_txbuflock, (_sc)->sc_txname, NULL, MTX_DEF); \
382178354Ssam} while (0)
383178354Ssam#define	ATH_TXBUF_LOCK_DESTROY(_sc)	mtx_destroy(&(_sc)->sc_txbuflock)
384178354Ssam#define	ATH_TXBUF_LOCK(_sc)		mtx_lock(&(_sc)->sc_txbuflock)
385178957Ssam#define	ATH_TXBUF_UNLOCK(_sc)		mtx_unlock(&(_sc)->sc_txbuflock)
386178954Ssam#define	ATH_TXBUF_LOCK_ASSERT(_sc) \
387178954Ssam	mtx_assert(&(_sc)->sc_txbuflock, MA_OWNED)
388178954Ssam
389178354Ssamint	ath_attach(u_int16_t, struct ath_softc *);
390178354Ssamint	ath_detach(struct ath_softc *);
391178354Ssamvoid	ath_resume(struct ath_softc *);
392178354Ssamvoid	ath_suspend(struct ath_softc *);
393178354Ssamvoid	ath_shutdown(struct ath_softc *);
394178354Ssamvoid	ath_intr(void *);
395178354Ssam
396178354Ssam/*
397178354Ssam * HAL definitions to comply with local coding convention.
398178354Ssam */
399178354Ssam#define	ath_hal_detach(_ah) \
400178354Ssam	((*(_ah)->ah_detach)((_ah)))
401178354Ssam#define	ath_hal_reset(_ah, _opmode, _chan, _outdoor, _pstatus) \
402178354Ssam	((*(_ah)->ah_reset)((_ah), (_opmode), (_chan), (_outdoor), (_pstatus)))
403178354Ssam#define	ath_hal_macversion(_ah) \
404178354Ssam	(((_ah)->ah_macVersion << 4) | ((_ah)->ah_macRev))
405178354Ssam#define	ath_hal_getratetable(_ah, _mode) \
406178354Ssam	((*(_ah)->ah_getRateTable)((_ah), (_mode)))
407178354Ssam#define	ath_hal_getmac(_ah, _mac) \
408178354Ssam	((*(_ah)->ah_getMacAddress)((_ah), (_mac)))
409178354Ssam#define	ath_hal_setmac(_ah, _mac) \
410178354Ssam	((*(_ah)->ah_setMacAddress)((_ah), (_mac)))
411178354Ssam#define	ath_hal_getbssidmask(_ah, _mask) \
412178354Ssam	((*(_ah)->ah_getBssIdMask)((_ah), (_mask)))
413178354Ssam#define	ath_hal_setbssidmask(_ah, _mask) \
414178354Ssam	((*(_ah)->ah_setBssIdMask)((_ah), (_mask)))
415178354Ssam#define	ath_hal_intrset(_ah, _mask) \
416178354Ssam	((*(_ah)->ah_setInterrupts)((_ah), (_mask)))
417178354Ssam#define	ath_hal_intrget(_ah) \
418178354Ssam	((*(_ah)->ah_getInterrupts)((_ah)))
419178354Ssam#define	ath_hal_intrpend(_ah) \
420178354Ssam	((*(_ah)->ah_isInterruptPending)((_ah)))
421178354Ssam#define	ath_hal_getisr(_ah, _pmask) \
422178354Ssam	((*(_ah)->ah_getPendingInterrupts)((_ah), (_pmask)))
423178354Ssam#define	ath_hal_updatetxtriglevel(_ah, _inc) \
424178354Ssam	((*(_ah)->ah_updateTxTrigLevel)((_ah), (_inc)))
425178354Ssam#define	ath_hal_setpower(_ah, _mode) \
426178354Ssam	((*(_ah)->ah_setPowerMode)((_ah), (_mode), AH_TRUE))
427178354Ssam#define	ath_hal_keycachesize(_ah) \
428178354Ssam	((*(_ah)->ah_getKeyCacheSize)((_ah)))
429178354Ssam#define	ath_hal_keyreset(_ah, _ix) \
430178354Ssam	((*(_ah)->ah_resetKeyCacheEntry)((_ah), (_ix)))
431178354Ssam#define	ath_hal_keyset(_ah, _ix, _pk, _mac) \
432178354Ssam	((*(_ah)->ah_setKeyCacheEntry)((_ah), (_ix), (_pk), (_mac), AH_FALSE))
433178354Ssam#define	ath_hal_keyisvalid(_ah, _ix) \
434178354Ssam	(((*(_ah)->ah_isKeyCacheEntryValid)((_ah), (_ix))))
435178354Ssam#define	ath_hal_keysetmac(_ah, _ix, _mac) \
436178354Ssam	((*(_ah)->ah_setKeyCacheEntryMac)((_ah), (_ix), (_mac)))
437178354Ssam#define	ath_hal_getrxfilter(_ah) \
438178354Ssam	((*(_ah)->ah_getRxFilter)((_ah)))
439178354Ssam#define	ath_hal_setrxfilter(_ah, _filter) \
440178354Ssam	((*(_ah)->ah_setRxFilter)((_ah), (_filter)))
441178354Ssam#define	ath_hal_setmcastfilter(_ah, _mfilt0, _mfilt1) \
442178354Ssam	((*(_ah)->ah_setMulticastFilter)((_ah), (_mfilt0), (_mfilt1)))
443178354Ssam#define	ath_hal_waitforbeacon(_ah, _bf) \
444178354Ssam	((*(_ah)->ah_waitForBeaconDone)((_ah), (_bf)->bf_daddr))
445178354Ssam#define	ath_hal_putrxbuf(_ah, _bufaddr) \
446178354Ssam	((*(_ah)->ah_setRxDP)((_ah), (_bufaddr)))
447178354Ssam/* NB: common across all chips */
448178354Ssam#define	AR_TSF_L32	0x804c	/* MAC local clock lower 32 bits */
449178354Ssam#define	ath_hal_gettsf32(_ah) \
450178354Ssam	OS_REG_READ(_ah, AR_TSF_L32)
451178354Ssam#define	ath_hal_gettsf64(_ah) \
452178354Ssam	((*(_ah)->ah_getTsf64)((_ah)))
453178354Ssam#define	ath_hal_resettsf(_ah) \
454178354Ssam	((*(_ah)->ah_resetTsf)((_ah)))
455178354Ssam#define	ath_hal_rxena(_ah) \
456178354Ssam	((*(_ah)->ah_enableReceive)((_ah)))
457178354Ssam#define	ath_hal_puttxbuf(_ah, _q, _bufaddr) \
458178354Ssam	((*(_ah)->ah_setTxDP)((_ah), (_q), (_bufaddr)))
459178354Ssam#define	ath_hal_gettxbuf(_ah, _q) \
460178354Ssam	((*(_ah)->ah_getTxDP)((_ah), (_q)))
461178354Ssam#define	ath_hal_numtxpending(_ah, _q) \
462178354Ssam	((*(_ah)->ah_numTxPending)((_ah), (_q)))
463178354Ssam#define	ath_hal_getrxbuf(_ah) \
464178354Ssam	((*(_ah)->ah_getRxDP)((_ah)))
465178354Ssam#define	ath_hal_txstart(_ah, _q) \
466178354Ssam	((*(_ah)->ah_startTxDma)((_ah), (_q)))
467178354Ssam#define	ath_hal_setchannel(_ah, _chan) \
468178354Ssam	((*(_ah)->ah_setChannel)((_ah), (_chan)))
469178354Ssam#define	ath_hal_calibrate(_ah, _chan, _iqcal) \
470178354Ssam	((*(_ah)->ah_perCalibration)((_ah), (_chan), (_iqcal)))
471178354Ssam#define	ath_hal_calibrateN(_ah, _chan, _lcal, _isdone) \
472178354Ssam	((*(_ah)->ah_perCalibrationN)((_ah), (_chan), 0x1, (_lcal), (_isdone)))
473178354Ssam#define	ath_hal_calreset(_ah, _chan) \
474178354Ssam	((*(_ah)->ah_resetCalValid)((_ah), (_chan)))
475178354Ssam#define	ath_hal_setledstate(_ah, _state) \
476178354Ssam	((*(_ah)->ah_setLedState)((_ah), (_state)))
477178354Ssam#define	ath_hal_beaconinit(_ah, _nextb, _bperiod) \
478178354Ssam	((*(_ah)->ah_beaconInit)((_ah), (_nextb), (_bperiod)))
479178354Ssam#define	ath_hal_beaconreset(_ah) \
480178354Ssam	((*(_ah)->ah_resetStationBeaconTimers)((_ah)))
481178354Ssam#define	ath_hal_beaconsettimers(_ah, _bt) \
482178354Ssam	((*(_ah)->ah_setBeaconTimers)((_ah), (_bt)))
483178354Ssam#define	ath_hal_beacontimers(_ah, _bs) \
484178354Ssam	((*(_ah)->ah_setStationBeaconTimers)((_ah), (_bs)))
485178354Ssam#define	ath_hal_setassocid(_ah, _bss, _associd) \
486178354Ssam	((*(_ah)->ah_writeAssocid)((_ah), (_bss), (_associd)))
487178354Ssam#define	ath_hal_phydisable(_ah) \
488178354Ssam	((*(_ah)->ah_phyDisable)((_ah)))
489178354Ssam#define	ath_hal_setopmode(_ah) \
490178354Ssam	((*(_ah)->ah_setPCUConfig)((_ah)))
491178354Ssam#define	ath_hal_stoptxdma(_ah, _qnum) \
492178354Ssam	((*(_ah)->ah_stopTxDma)((_ah), (_qnum)))
493178354Ssam#define	ath_hal_stoppcurecv(_ah) \
494178354Ssam	((*(_ah)->ah_stopPcuReceive)((_ah)))
495178354Ssam#define	ath_hal_startpcurecv(_ah) \
496178354Ssam	((*(_ah)->ah_startPcuReceive)((_ah)))
497178354Ssam#define	ath_hal_stopdmarecv(_ah) \
498178354Ssam	((*(_ah)->ah_stopDmaReceive)((_ah)))
499178354Ssam#define	ath_hal_getdiagstate(_ah, _id, _indata, _insize, _outdata, _outsize) \
500178354Ssam	((*(_ah)->ah_getDiagState)((_ah), (_id), \
501178354Ssam		(_indata), (_insize), (_outdata), (_outsize)))
502178354Ssam#define	ath_hal_getfatalstate(_ah, _outdata, _outsize) \
503178354Ssam	ath_hal_getdiagstate(_ah, 29, NULL, 0, (_outdata), _outsize)
504178354Ssam#define	ath_hal_setuptxqueue(_ah, _type, _irq) \
505178354Ssam	((*(_ah)->ah_setupTxQueue)((_ah), (_type), (_irq)))
506178354Ssam#define	ath_hal_resettxqueue(_ah, _q) \
507178354Ssam	((*(_ah)->ah_resetTxQueue)((_ah), (_q)))
508178354Ssam#define	ath_hal_releasetxqueue(_ah, _q) \
509178354Ssam	((*(_ah)->ah_releaseTxQueue)((_ah), (_q)))
510178354Ssam#define	ath_hal_gettxqueueprops(_ah, _q, _qi) \
511178354Ssam	((*(_ah)->ah_getTxQueueProps)((_ah), (_q), (_qi)))
512178354Ssam#define	ath_hal_settxqueueprops(_ah, _q, _qi) \
513178354Ssam	((*(_ah)->ah_setTxQueueProps)((_ah), (_q), (_qi)))
514178354Ssam/* NB: common across all chips */
515178354Ssam#define	AR_Q_TXE	0x0840	/* MAC Transmit Queue enable */
516178354Ssam#define	ath_hal_txqenabled(_ah, _qnum) \
517178354Ssam	(OS_REG_READ(_ah, AR_Q_TXE) & (1<<(_qnum)))
518116742Ssam#define	ath_hal_getrfgain(_ah) \
519178354Ssam	((*(_ah)->ah_getRfGain)((_ah)))
520178354Ssam#define	ath_hal_getdefantenna(_ah) \
521178354Ssam	((*(_ah)->ah_getDefAntenna)((_ah)))
522178354Ssam#define	ath_hal_setdefantenna(_ah, _ant) \
523178354Ssam	((*(_ah)->ah_setDefAntenna)((_ah), (_ant)))
524178354Ssam#define	ath_hal_rxmonitor(_ah, _arg, _chan) \
525178354Ssam	((*(_ah)->ah_rxMonitor)((_ah), (_arg), (_chan)))
526178354Ssam#define	ath_hal_ani_poll(_ah, _chan) \
527178354Ssam	((*(_ah)->ah_aniPoll)((_ah), (_chan)))
528178354Ssam#define	ath_hal_mibevent(_ah, _stats) \
529178354Ssam	((*(_ah)->ah_procMibEvent)((_ah), (_stats)))
530178354Ssam#define	ath_hal_setslottime(_ah, _us) \
531182674Sweongyo	((*(_ah)->ah_setSlotTime)((_ah), (_us)))
532182674Sweongyo#define	ath_hal_getslottime(_ah) \
533116742Ssam	((*(_ah)->ah_getSlotTime)((_ah)))
534116742Ssam#define	ath_hal_setacktimeout(_ah, _us) \
535178354Ssam	((*(_ah)->ah_setAckTimeout)((_ah), (_us)))
536178354Ssam#define	ath_hal_getacktimeout(_ah) \
537178354Ssam	((*(_ah)->ah_getAckTimeout)((_ah)))
538178354Ssam#define	ath_hal_setctstimeout(_ah, _us) \
539178354Ssam	((*(_ah)->ah_setCTSTimeout)((_ah), (_us)))
540178354Ssam#define	ath_hal_getctstimeout(_ah) \
541178354Ssam	((*(_ah)->ah_getCTSTimeout)((_ah)))
542178354Ssam#define	ath_hal_getcapability(_ah, _cap, _param, _result) \
543178354Ssam	((*(_ah)->ah_getCapability)((_ah), (_cap), (_param), (_result)))
544178354Ssam#define	ath_hal_setcapability(_ah, _cap, _param, _v, _status) \
545178354Ssam	((*(_ah)->ah_setCapability)((_ah), (_cap), (_param), (_v), (_status)))
546178354Ssam#define	ath_hal_ciphersupported(_ah, _cipher) \
547178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_CIPHER, _cipher, NULL) == HAL_OK)
548178354Ssam#define	ath_hal_getregdomain(_ah, _prd) \
549178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_REG_DMN, 0, (_prd)) == HAL_OK)
550178354Ssam#define	ath_hal_setregdomain(_ah, _rd) \
551178354Ssam	ath_hal_setcapability(_ah, HAL_CAP_REG_DMN, 0, _rd, NULL)
552178354Ssam#define	ath_hal_getcountrycode(_ah, _pcc) \
553178354Ssam	(*(_pcc) = (_ah)->ah_countryCode)
554178354Ssam#define	ath_hal_gettkipmic(_ah) \
555178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_TKIP_MIC, 1, NULL) == HAL_OK)
556178354Ssam#define	ath_hal_settkipmic(_ah, _v) \
557178354Ssam	ath_hal_setcapability(_ah, HAL_CAP_TKIP_MIC, 1, _v, NULL)
558178354Ssam#define	ath_hal_hastkipsplit(_ah) \
559178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_TKIP_SPLIT, 0, NULL) == HAL_OK)
560178354Ssam#define	ath_hal_gettkipsplit(_ah) \
561178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_TKIP_SPLIT, 1, NULL) == HAL_OK)
562178354Ssam#define	ath_hal_settkipsplit(_ah, _v) \
563178354Ssam	ath_hal_setcapability(_ah, HAL_CAP_TKIP_SPLIT, 1, _v, NULL)
564178354Ssam#define	ath_hal_haswmetkipmic(_ah) \
565178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_WME_TKIPMIC, 0, NULL) == HAL_OK)
566178354Ssam#define	ath_hal_hwphycounters(_ah) \
567178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_PHYCOUNTERS, 0, NULL) == HAL_OK)
568178354Ssam#define	ath_hal_hasdiversity(_ah) \
569178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_DIVERSITY, 0, NULL) == HAL_OK)
570178354Ssam#define	ath_hal_getdiversity(_ah) \
571178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_DIVERSITY, 1, NULL) == HAL_OK)
572178354Ssam#define	ath_hal_setdiversity(_ah, _v) \
573178354Ssam	ath_hal_setcapability(_ah, HAL_CAP_DIVERSITY, 1, _v, NULL)
574178354Ssam#define	ath_hal_getantennaswitch(_ah) \
575178354Ssam	((*(_ah)->ah_getAntennaSwitch)((_ah)))
576178354Ssam#define	ath_hal_setantennaswitch(_ah, _v) \
577178354Ssam	((*(_ah)->ah_setAntennaSwitch)((_ah), (_v)))
578178354Ssam#define	ath_hal_getdiag(_ah, _pv) \
579178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_DIAG, 0, _pv) == HAL_OK)
580178354Ssam#define	ath_hal_setdiag(_ah, _v) \
581178354Ssam	ath_hal_setcapability(_ah, HAL_CAP_DIAG, 0, _v, NULL)
582178354Ssam#define	ath_hal_getnumtxqueues(_ah, _pv) \
583178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_NUM_TXQUEUES, 0, _pv) == HAL_OK)
584178354Ssam#define	ath_hal_hasveol(_ah) \
585178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_VEOL, 0, NULL) == HAL_OK)
586178354Ssam#define	ath_hal_hastxpowlimit(_ah) \
587178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_TXPOW, 0, NULL) == HAL_OK)
588178354Ssam#define	ath_hal_settxpowlimit(_ah, _pow) \
589178354Ssam	((*(_ah)->ah_setTxPowerLimit)((_ah), (_pow)))
590178354Ssam#define	ath_hal_gettxpowlimit(_ah, _ppow) \
591178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_TXPOW, 1, _ppow) == HAL_OK)
592178354Ssam#define	ath_hal_getmaxtxpow(_ah, _ppow) \
593178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_TXPOW, 2, _ppow) == HAL_OK)
594178354Ssam#define	ath_hal_gettpscale(_ah, _scale) \
595178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_TXPOW, 3, _scale) == HAL_OK)
596178354Ssam#define	ath_hal_settpscale(_ah, _v) \
597178354Ssam	ath_hal_setcapability(_ah, HAL_CAP_TXPOW, 3, _v, NULL)
598178354Ssam#define	ath_hal_hastpc(_ah) \
599178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_TPC, 0, NULL) == HAL_OK)
600178354Ssam#define	ath_hal_gettpc(_ah) \
601178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_TPC, 1, NULL) == HAL_OK)
602178354Ssam#define	ath_hal_settpc(_ah, _v) \
603178354Ssam	ath_hal_setcapability(_ah, HAL_CAP_TPC, 1, _v, NULL)
604178354Ssam#define	ath_hal_hasbursting(_ah) \
605178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_BURST, 0, NULL) == HAL_OK)
606178354Ssam#define	ath_hal_setmcastkeysearch(_ah, _v) \
607178354Ssam	ath_hal_setcapability(_ah, HAL_CAP_MCAST_KEYSRCH, 0, _v, NULL)
608178354Ssam#define	ath_hal_hasmcastkeysearch(_ah) \
609178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_MCAST_KEYSRCH, 0, NULL) == HAL_OK)
610178354Ssam#define	ath_hal_getmcastkeysearch(_ah) \
611178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_MCAST_KEYSRCH, 1, NULL) == HAL_OK)
612178354Ssam#define	ath_hal_hasfastframes(_ah) \
613178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_FASTFRAME, 0, NULL) == HAL_OK)
614178354Ssam#define	ath_hal_hasbssidmask(_ah) \
615178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_BSSIDMASK, 0, NULL) == HAL_OK)
616178354Ssam#define	ath_hal_hasbssidmatch(_ah) \
617178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_BSSIDMATCH, 0, NULL) == HAL_OK)
618178354Ssam#define	ath_hal_hastsfadjust(_ah) \
619178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_TSF_ADJUST, 0, NULL) == HAL_OK)
620178354Ssam#define	ath_hal_gettsfadjust(_ah) \
621178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_TSF_ADJUST, 1, NULL) == HAL_OK)
622178354Ssam#define	ath_hal_settsfadjust(_ah, _onoff) \
623178354Ssam	ath_hal_setcapability(_ah, HAL_CAP_TSF_ADJUST, 1, _onoff, NULL)
624178354Ssam#define	ath_hal_hasrfsilent(_ah) \
625178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_RFSILENT, 0, NULL) == HAL_OK)
626178354Ssam#define	ath_hal_getrfkill(_ah) \
627178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_RFSILENT, 1, NULL) == HAL_OK)
628178354Ssam#define	ath_hal_setrfkill(_ah, _onoff) \
629178354Ssam	ath_hal_setcapability(_ah, HAL_CAP_RFSILENT, 1, _onoff, NULL)
630178354Ssam#define	ath_hal_getrfsilent(_ah, _prfsilent) \
631178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_RFSILENT, 2, _prfsilent) == HAL_OK)
632178354Ssam#define	ath_hal_setrfsilent(_ah, _rfsilent) \
633178354Ssam	ath_hal_setcapability(_ah, HAL_CAP_RFSILENT, 2, _rfsilent, NULL)
634178354Ssam#define	ath_hal_gettpack(_ah, _ptpack) \
635178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_TPC_ACK, 0, _ptpack) == HAL_OK)
636178354Ssam#define	ath_hal_settpack(_ah, _tpack) \
637178354Ssam	ath_hal_setcapability(_ah, HAL_CAP_TPC_ACK, 0, _tpack, NULL)
638178354Ssam#define	ath_hal_gettpcts(_ah, _ptpcts) \
639178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_TPC_CTS, 0, _ptpcts) == HAL_OK)
640178354Ssam#define	ath_hal_settpcts(_ah, _tpcts) \
641178354Ssam	ath_hal_setcapability(_ah, HAL_CAP_TPC_CTS, 0, _tpcts, NULL)
642178354Ssam#define	ath_hal_hasintmit(_ah) \
643178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_INTMIT, HAL_CAP_INTMIT_PRESENT, NULL) == HAL_OK)
644178354Ssam#define	ath_hal_getintmit(_ah) \
645178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_INTMIT, HAL_CAP_INTMIT_ENABLE, NULL) == HAL_OK)
646178354Ssam#define	ath_hal_setintmit(_ah, _v) \
647178354Ssam	ath_hal_setcapability(_ah, HAL_CAP_INTMIT, HAL_CAP_INTMIT_ENABLE, _v, NULL)
648178354Ssam#define	ath_hal_getchannoise(_ah, _c) \
649178354Ssam	((*(_ah)->ah_getChanNoise)((_ah), (_c)))
650178354Ssam#define	ath_hal_getrxchainmask(_ah, _prxchainmask) \
651178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_RX_CHAINMASK, 0, _prxchainmask))
652178354Ssam#define	ath_hal_gettxchainmask(_ah, _ptxchainmask) \
653178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_TX_CHAINMASK, 0, _ptxchainmask))
654178354Ssam#define	ath_hal_split4ktrans(_ah) \
655178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_SPLIT_4KB_TRANS, 0, NULL) == HAL_OK)
656178354Ssam#define	ath_hal_self_linked_final_rxdesc(_ah) \
657178354Ssam	(ath_hal_getcapability(_ah, HAL_CAP_RXDESC_SELFLINK, 0, NULL) == HAL_OK)
658178354Ssam#define	ath_hal_gtxto_supported(_ah) \
659166012Ssam	(ath_hal_getcapability(_ah, HAL_CAP_GTXTO, 0, NULL) == HAL_OK)
660166012Ssam
661166012Ssam#define	ath_hal_setuprxdesc(_ah, _ds, _size, _intreq) \
662166012Ssam	((*(_ah)->ah_setupRxDesc)((_ah), (_ds), (_size), (_intreq)))
663166012Ssam#define	ath_hal_rxprocdesc(_ah, _ds, _dspa, _dsnext, _rs) \
664166012Ssam	((*(_ah)->ah_procRxDesc)((_ah), (_ds), (_dspa), (_dsnext), 0, (_rs)))
665166012Ssam#define	ath_hal_setuptxdesc(_ah, _ds, _plen, _hlen, _atype, _txpow, \
666166012Ssam		_txr0, _txtr0, _keyix, _ant, _flags, \
667166012Ssam		_rtsrate, _rtsdura) \
668166012Ssam	((*(_ah)->ah_setupTxDesc)((_ah), (_ds), (_plen), (_hlen), (_atype), \
669166012Ssam		(_txpow), (_txr0), (_txtr0), (_keyix), (_ant), \
670166012Ssam		(_flags), (_rtsrate), (_rtsdura), 0, 0, 0))
671166012Ssam#define	ath_hal_setupxtxdesc(_ah, _ds, \
672166012Ssam		_txr1, _txtr1, _txr2, _txtr2, _txr3, _txtr3) \
673166012Ssam	((*(_ah)->ah_setupXTxDesc)((_ah), (_ds), \
674166012Ssam		(_txr1), (_txtr1), (_txr2), (_txtr2), (_txr3), (_txtr3)))
675166012Ssam#define	ath_hal_filltxdesc(_ah, _ds, _l, _first, _last, _ds0) \
676166012Ssam	((*(_ah)->ah_fillTxDesc)((_ah), (_ds), (_l), (_first), (_last), (_ds0)))
677166012Ssam#define	ath_hal_txprocdesc(_ah, _ds, _ts) \
678166012Ssam	((*(_ah)->ah_procTxDesc)((_ah), (_ds), (_ts)))
679116742Ssam#define	ath_hal_gettxintrtxqs(_ah, _txqs) \
680116742Ssam	((*(_ah)->ah_getTxIntrQueue)((_ah), (_txqs)))
681116742Ssam#define ath_hal_gettxcompletionrates(_ah, _ds, _rates, _tries) \
682152450Ssam	((*(_ah)->ah_getTxCompletionRates)((_ah), (_ds), (_rates), (_tries)))
683116742Ssam
684116742Ssam#define	ath_hal_chaintxdesc(_ah, _ds, _pktlen, _hdrlen, _type, _keyix, \
685167430Ssam	_cipher, _delims, _seglen, _first, _last) \
686166012Ssam	((*(_ah)->ah_chainTxDesc((_ah), (_ds), (_pktlen), (_hdrlen), \
687166012Ssam	(_type), (_keyix), (_cipher), (_delims), (_seglen), \
688116742Ssam	(_first), (_last))))
689116742Ssam#define	ath_hal_setupfirsttxdesc(_ah, _ds, _aggrlen, _flags, _txpower, \
690116742Ssam		_txr0, _txtr0, _antm, _rcr, _rcd) \
691116742Ssam	((*(_ah)->ah_setupFirstTxDesc)((_ah), (_ds), (_aggrlen), (_flags), \
692152450Ssam	(_txpower), (_txr0), (_txtr0), (_antm), (_rcr), (_rcd)))
693116742Ssam#define	ath_hal_setuplasttxdesc(_ah, _ds, _ds0) \
694116742Ssam	((*(_ah)->ah_setupLastTxDesc)((_ah), (_ds), (_ds0)))
695116899Ssam#define	ath_hal_set11nratescenario(_ah, _ds, _dur, _rt, _series, _ns, _flags) \
696165569Ssam	((*(_ah)->ah_set11nRateScenario)((_ah), (_ds), (_dur), (_rt), \
697170530Ssam	(_series), (_ns), (_flags)))
698167430Ssam#define	ath_hal_set11naggrmiddle(_ah, _ds, _num) \
699166012Ssam	((*(_ah)->ah_set11nAggrMiddle((_ah), (_ds), (_num))))
700152450Ssam#define	ath_hal_set11nburstduration(_ah, _ds, _dur) \
701165569Ssam	((*(_ah)->ah_set11nBurstDuration)((_ah), (_ds), (_dur)))
702152450Ssam
703116742Ssam/*
704116742Ssam * This is badly-named; you need to set the correct parameters
705116742Ssam * to begin to receive useful radar events; and even then
706166012Ssam * it doesn't "enable" DFS. See the ath_dfs/null/ module for
707166012Ssam * more information.
708166012Ssam */
709152450Ssam#define	ath_hal_enabledfs(_ah, _param) \
710166012Ssam	((*(_ah)->ah_enableDfs)((_ah), (_param)))
711152450Ssam#define	ath_hal_getdfsthresh(_ah, _param) \
712167430Ssam	((*(_ah)->ah_getDfsThresh)((_ah), (_param)))
713166012Ssam#define	ath_hal_procradarevent(_ah, _rxs, _fulltsf, _buf, _event) \
714165569Ssam	((*(_ah)->ah_procRadarEvent)((_ah), (_rxs), (_fulltsf), (_buf), (_event)))
715152450Ssam
716152450Ssam#define ath_hal_gpioCfgOutput(_ah, _gpio, _type) \
717152450Ssam        ((*(_ah)->ah_gpioCfgOutput)((_ah), (_gpio), (_type)))
718152450Ssam#define ath_hal_gpioset(_ah, _gpio, _b) \
719116742Ssam        ((*(_ah)->ah_gpioSet)((_ah), (_gpio), (_b)))
720116742Ssam#define ath_hal_gpioget(_ah, _gpio) \
721167430Ssam        ((*(_ah)->ah_gpioGet)((_ah), (_gpio)))
722116742Ssam#define ath_hal_gpiosetintr(_ah, _gpio, _b) \
723116742Ssam        ((*(_ah)->ah_gpioSetIntr)((_ah), (_gpio), (_b)))
724116742Ssam
725116742Ssam#define ath_hal_radar_wait(_ah, _chan) \
726116742Ssam	((*(_ah)->ah_radarWait)((_ah), (_chan)))
727152450Ssam
728165825Smjacob#endif /* _DEV_ATH_ATHVAR_H */
729116742Ssam