xref: /freebsd/sys/dev/ath/if_ath_sysctl.c (revision 685dc743dc3b5645e34836464128e1c0558b404b)
16079fdbeSAdrian Chadd /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
46079fdbeSAdrian Chadd  * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
56079fdbeSAdrian Chadd  * All rights reserved.
66079fdbeSAdrian Chadd  *
76079fdbeSAdrian Chadd  * Redistribution and use in source and binary forms, with or without
86079fdbeSAdrian Chadd  * modification, are permitted provided that the following conditions
96079fdbeSAdrian Chadd  * are met:
106079fdbeSAdrian Chadd  * 1. Redistributions of source code must retain the above copyright
116079fdbeSAdrian Chadd  *    notice, this list of conditions and the following disclaimer,
126079fdbeSAdrian Chadd  *    without modification.
136079fdbeSAdrian Chadd  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
146079fdbeSAdrian Chadd  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
156079fdbeSAdrian Chadd  *    redistribution must be conditioned upon including a substantially
166079fdbeSAdrian Chadd  *    similar Disclaimer requirement for further binary redistribution.
176079fdbeSAdrian Chadd  *
186079fdbeSAdrian Chadd  * NO WARRANTY
196079fdbeSAdrian Chadd  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
206079fdbeSAdrian Chadd  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
216079fdbeSAdrian Chadd  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
226079fdbeSAdrian Chadd  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
236079fdbeSAdrian Chadd  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
246079fdbeSAdrian Chadd  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
256079fdbeSAdrian Chadd  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
266079fdbeSAdrian Chadd  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
276079fdbeSAdrian Chadd  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
286079fdbeSAdrian Chadd  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
296079fdbeSAdrian Chadd  * THE POSSIBILITY OF SUCH DAMAGES.
306079fdbeSAdrian Chadd  */
316079fdbeSAdrian Chadd 
326079fdbeSAdrian Chadd #include <sys/cdefs.h>
336079fdbeSAdrian Chadd /*
346079fdbeSAdrian Chadd  * Driver for the Atheros Wireless LAN controller.
356079fdbeSAdrian Chadd  *
366079fdbeSAdrian Chadd  * This software is derived from work of Atsushi Onoe; his contribution
376079fdbeSAdrian Chadd  * is greatly appreciated.
386079fdbeSAdrian Chadd  */
396079fdbeSAdrian Chadd 
406079fdbeSAdrian Chadd #include "opt_inet.h"
416079fdbeSAdrian Chadd #include "opt_ath.h"
426079fdbeSAdrian Chadd #include "opt_wlan.h"
436079fdbeSAdrian Chadd 
446079fdbeSAdrian Chadd #include <sys/param.h>
456079fdbeSAdrian Chadd #include <sys/systm.h>
466079fdbeSAdrian Chadd #include <sys/sysctl.h>
476079fdbeSAdrian Chadd #include <sys/mbuf.h>
486079fdbeSAdrian Chadd #include <sys/malloc.h>
496079fdbeSAdrian Chadd #include <sys/lock.h>
506079fdbeSAdrian Chadd #include <sys/mutex.h>
516079fdbeSAdrian Chadd #include <sys/kernel.h>
526079fdbeSAdrian Chadd #include <sys/socket.h>
536079fdbeSAdrian Chadd #include <sys/sockio.h>
546079fdbeSAdrian Chadd #include <sys/errno.h>
556079fdbeSAdrian Chadd #include <sys/callout.h>
566079fdbeSAdrian Chadd #include <sys/bus.h>
576079fdbeSAdrian Chadd #include <sys/endian.h>
586079fdbeSAdrian Chadd #include <sys/kthread.h>
596079fdbeSAdrian Chadd #include <sys/taskqueue.h>
606079fdbeSAdrian Chadd #include <sys/priv.h>
616079fdbeSAdrian Chadd 
626079fdbeSAdrian Chadd #include <machine/bus.h>
636079fdbeSAdrian Chadd 
646079fdbeSAdrian Chadd #include <net/if.h>
6576039bc8SGleb Smirnoff #include <net/if_var.h>
666079fdbeSAdrian Chadd #include <net/if_dl.h>
676079fdbeSAdrian Chadd #include <net/if_media.h>
686079fdbeSAdrian Chadd #include <net/if_types.h>
696079fdbeSAdrian Chadd #include <net/if_arp.h>
706079fdbeSAdrian Chadd #include <net/ethernet.h>
716079fdbeSAdrian Chadd #include <net/if_llc.h>
726079fdbeSAdrian Chadd 
736079fdbeSAdrian Chadd #include <net80211/ieee80211_var.h>
746079fdbeSAdrian Chadd #include <net80211/ieee80211_regdomain.h>
756079fdbeSAdrian Chadd #ifdef IEEE80211_SUPPORT_SUPERG
766079fdbeSAdrian Chadd #include <net80211/ieee80211_superg.h>
776079fdbeSAdrian Chadd #endif
786079fdbeSAdrian Chadd #ifdef IEEE80211_SUPPORT_TDMA
796079fdbeSAdrian Chadd #include <net80211/ieee80211_tdma.h>
806079fdbeSAdrian Chadd #endif
816079fdbeSAdrian Chadd 
826079fdbeSAdrian Chadd #include <net/bpf.h>
836079fdbeSAdrian Chadd 
846079fdbeSAdrian Chadd #ifdef INET
856079fdbeSAdrian Chadd #include <netinet/in.h>
866079fdbeSAdrian Chadd #include <netinet/if_ether.h>
876079fdbeSAdrian Chadd #endif
886079fdbeSAdrian Chadd 
896079fdbeSAdrian Chadd #include <dev/ath/if_athvar.h>
906079fdbeSAdrian Chadd #include <dev/ath/ath_hal/ah_devid.h>		/* XXX for softled */
916079fdbeSAdrian Chadd #include <dev/ath/ath_hal/ah_diagcodes.h>
926079fdbeSAdrian Chadd 
936079fdbeSAdrian Chadd #include <dev/ath/if_ath_debug.h>
946558ffd9SAdrian Chadd #include <dev/ath/if_ath_led.h>
956079fdbeSAdrian Chadd #include <dev/ath/if_ath_misc.h>
966079fdbeSAdrian Chadd #include <dev/ath/if_ath_tx.h>
976079fdbeSAdrian Chadd #include <dev/ath/if_ath_sysctl.h>
986079fdbeSAdrian Chadd 
996079fdbeSAdrian Chadd #ifdef ATH_TX99_DIAG
1006079fdbeSAdrian Chadd #include <dev/ath/ath_tx99/ath_tx99.h>
1016079fdbeSAdrian Chadd #endif
1026079fdbeSAdrian Chadd 
103bbee93a8SAdrian Chadd #ifdef	ATH_DEBUG_ALQ
104bbee93a8SAdrian Chadd #include <dev/ath/if_ath_alq.h>
105bbee93a8SAdrian Chadd #endif
106bbee93a8SAdrian Chadd 
1076079fdbeSAdrian Chadd static int
ath_sysctl_slottime(SYSCTL_HANDLER_ARGS)1086079fdbeSAdrian Chadd ath_sysctl_slottime(SYSCTL_HANDLER_ARGS)
1096079fdbeSAdrian Chadd {
1106079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
111f5c30c4eSAdrian Chadd 	u_int slottime;
1126079fdbeSAdrian Chadd 	int error;
1136079fdbeSAdrian Chadd 
114f5c30c4eSAdrian Chadd 	ATH_LOCK(sc);
115f5c30c4eSAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
116f5c30c4eSAdrian Chadd 	slottime = ath_hal_getslottime(sc->sc_ah);
117f5c30c4eSAdrian Chadd 	ATH_UNLOCK(sc);
118f5c30c4eSAdrian Chadd 
1196079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &slottime, 0, req);
1206079fdbeSAdrian Chadd 	if (error || !req->newptr)
121f5c30c4eSAdrian Chadd 		goto finish;
122f5c30c4eSAdrian Chadd 
123f5c30c4eSAdrian Chadd 	error = !ath_hal_setslottime(sc->sc_ah, slottime) ? EINVAL : 0;
124f5c30c4eSAdrian Chadd 
125f5c30c4eSAdrian Chadd finish:
126f5c30c4eSAdrian Chadd 	ATH_LOCK(sc);
127f5c30c4eSAdrian Chadd 	ath_power_restore_power_state(sc);
128f5c30c4eSAdrian Chadd 	ATH_UNLOCK(sc);
129f5c30c4eSAdrian Chadd 
1306079fdbeSAdrian Chadd 	return error;
1316079fdbeSAdrian Chadd }
1326079fdbeSAdrian Chadd 
1336079fdbeSAdrian Chadd static int
ath_sysctl_acktimeout(SYSCTL_HANDLER_ARGS)1346079fdbeSAdrian Chadd ath_sysctl_acktimeout(SYSCTL_HANDLER_ARGS)
1356079fdbeSAdrian Chadd {
1366079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
13752f55153SAdrian Chadd 	u_int acktimeout;
1386079fdbeSAdrian Chadd 	int error;
1396079fdbeSAdrian Chadd 
14052f55153SAdrian Chadd 	ATH_LOCK(sc);
14152f55153SAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
14252f55153SAdrian Chadd 	acktimeout = ath_hal_getacktimeout(sc->sc_ah);
14352f55153SAdrian Chadd 	ATH_UNLOCK(sc);
14452f55153SAdrian Chadd 
1456079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &acktimeout, 0, req);
1466079fdbeSAdrian Chadd 	if (error || !req->newptr)
14752f55153SAdrian Chadd 		goto finish;
14852f55153SAdrian Chadd 
14952f55153SAdrian Chadd 	error = !ath_hal_setacktimeout(sc->sc_ah, acktimeout) ? EINVAL : 0;
15052f55153SAdrian Chadd 
15152f55153SAdrian Chadd finish:
15252f55153SAdrian Chadd 	ATH_LOCK(sc);
15352f55153SAdrian Chadd 	ath_power_restore_power_state(sc);
15452f55153SAdrian Chadd 	ATH_UNLOCK(sc);
15552f55153SAdrian Chadd 
15652f55153SAdrian Chadd 	return (error);
1576079fdbeSAdrian Chadd }
1586079fdbeSAdrian Chadd 
1596079fdbeSAdrian Chadd static int
ath_sysctl_ctstimeout(SYSCTL_HANDLER_ARGS)1606079fdbeSAdrian Chadd ath_sysctl_ctstimeout(SYSCTL_HANDLER_ARGS)
1616079fdbeSAdrian Chadd {
1626079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
16352f55153SAdrian Chadd 	u_int ctstimeout;
1646079fdbeSAdrian Chadd 	int error;
1656079fdbeSAdrian Chadd 
16652f55153SAdrian Chadd 	ATH_LOCK(sc);
16752f55153SAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
16852f55153SAdrian Chadd 	ctstimeout = ath_hal_getctstimeout(sc->sc_ah);
16952f55153SAdrian Chadd 	ATH_UNLOCK(sc);
17052f55153SAdrian Chadd 
1716079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &ctstimeout, 0, req);
1726079fdbeSAdrian Chadd 	if (error || !req->newptr)
17352f55153SAdrian Chadd 		goto finish;
17452f55153SAdrian Chadd 
17552f55153SAdrian Chadd 	error = !ath_hal_setctstimeout(sc->sc_ah, ctstimeout) ? EINVAL : 0;
17652f55153SAdrian Chadd 
17752f55153SAdrian Chadd finish:
17852f55153SAdrian Chadd 	ATH_LOCK(sc);
17952f55153SAdrian Chadd 	ath_power_restore_power_state(sc);
18052f55153SAdrian Chadd 	ATH_UNLOCK(sc);
18152f55153SAdrian Chadd 
18252f55153SAdrian Chadd 	return (error);
1836079fdbeSAdrian Chadd }
1846079fdbeSAdrian Chadd 
1856079fdbeSAdrian Chadd static int
ath_sysctl_softled(SYSCTL_HANDLER_ARGS)1866079fdbeSAdrian Chadd ath_sysctl_softled(SYSCTL_HANDLER_ARGS)
1876079fdbeSAdrian Chadd {
1886079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
1896079fdbeSAdrian Chadd 	int softled = sc->sc_softled;
1906079fdbeSAdrian Chadd 	int error;
1916079fdbeSAdrian Chadd 
1926079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &softled, 0, req);
1936079fdbeSAdrian Chadd 	if (error || !req->newptr)
1946079fdbeSAdrian Chadd 		return error;
1956079fdbeSAdrian Chadd 	softled = (softled != 0);
1966079fdbeSAdrian Chadd 	if (softled != sc->sc_softled) {
1976079fdbeSAdrian Chadd 		if (softled) {
1986079fdbeSAdrian Chadd 			/* NB: handle any sc_ledpin change */
1996558ffd9SAdrian Chadd 			ath_led_config(sc);
2006079fdbeSAdrian Chadd 		}
2016079fdbeSAdrian Chadd 		sc->sc_softled = softled;
2026079fdbeSAdrian Chadd 	}
2036079fdbeSAdrian Chadd 	return 0;
2046079fdbeSAdrian Chadd }
2056079fdbeSAdrian Chadd 
2066079fdbeSAdrian Chadd static int
ath_sysctl_ledpin(SYSCTL_HANDLER_ARGS)2076079fdbeSAdrian Chadd ath_sysctl_ledpin(SYSCTL_HANDLER_ARGS)
2086079fdbeSAdrian Chadd {
2096079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
2106079fdbeSAdrian Chadd 	int ledpin = sc->sc_ledpin;
2116079fdbeSAdrian Chadd 	int error;
2126079fdbeSAdrian Chadd 
2136079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &ledpin, 0, req);
2146079fdbeSAdrian Chadd 	if (error || !req->newptr)
2156079fdbeSAdrian Chadd 		return error;
2166079fdbeSAdrian Chadd 	if (ledpin != sc->sc_ledpin) {
2176079fdbeSAdrian Chadd 		sc->sc_ledpin = ledpin;
2186079fdbeSAdrian Chadd 		if (sc->sc_softled) {
2196558ffd9SAdrian Chadd 			ath_led_config(sc);
2206079fdbeSAdrian Chadd 		}
2216079fdbeSAdrian Chadd 	}
2226079fdbeSAdrian Chadd 	return 0;
2236079fdbeSAdrian Chadd }
2246079fdbeSAdrian Chadd 
2256079fdbeSAdrian Chadd static int
ath_sysctl_hardled(SYSCTL_HANDLER_ARGS)2263440495aSAdrian Chadd ath_sysctl_hardled(SYSCTL_HANDLER_ARGS)
2273440495aSAdrian Chadd {
2283440495aSAdrian Chadd 	struct ath_softc *sc = arg1;
2293440495aSAdrian Chadd 	int hardled = sc->sc_hardled;
2303440495aSAdrian Chadd 	int error;
2313440495aSAdrian Chadd 
2323440495aSAdrian Chadd 	error = sysctl_handle_int(oidp, &hardled, 0, req);
2333440495aSAdrian Chadd 	if (error || !req->newptr)
2343440495aSAdrian Chadd 		return error;
2353440495aSAdrian Chadd 	hardled = (hardled != 0);
2363440495aSAdrian Chadd 	if (hardled != sc->sc_hardled) {
2373440495aSAdrian Chadd 		if (hardled) {
2383440495aSAdrian Chadd 			/* NB: handle any sc_ledpin change */
2393440495aSAdrian Chadd 			ath_led_config(sc);
2403440495aSAdrian Chadd 		}
2413440495aSAdrian Chadd 		sc->sc_hardled = hardled;
2423440495aSAdrian Chadd 	}
2433440495aSAdrian Chadd 	return 0;
2443440495aSAdrian Chadd }
2453440495aSAdrian Chadd 
2463440495aSAdrian Chadd static int
ath_sysctl_txantenna(SYSCTL_HANDLER_ARGS)2476079fdbeSAdrian Chadd ath_sysctl_txantenna(SYSCTL_HANDLER_ARGS)
2486079fdbeSAdrian Chadd {
2496079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
25052f55153SAdrian Chadd 	u_int txantenna;
2516079fdbeSAdrian Chadd 	int error;
2526079fdbeSAdrian Chadd 
25352f55153SAdrian Chadd 	ATH_LOCK(sc);
25452f55153SAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
25552f55153SAdrian Chadd 	ATH_UNLOCK(sc);
25652f55153SAdrian Chadd 
25752f55153SAdrian Chadd 	txantenna = ath_hal_getantennaswitch(sc->sc_ah);
25852f55153SAdrian Chadd 
2596079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &txantenna, 0, req);
2606079fdbeSAdrian Chadd 	if (!error && req->newptr) {
2616079fdbeSAdrian Chadd 		/* XXX assumes 2 antenna ports */
26252f55153SAdrian Chadd 		if (txantenna < HAL_ANT_VARIABLE || txantenna > HAL_ANT_FIXED_B) {
26352f55153SAdrian Chadd 			error = EINVAL;
26452f55153SAdrian Chadd 			goto finish;
26552f55153SAdrian Chadd 		}
2666079fdbeSAdrian Chadd 		ath_hal_setantennaswitch(sc->sc_ah, txantenna);
2676079fdbeSAdrian Chadd 		/*
2686079fdbeSAdrian Chadd 		 * NB: with the switch locked this isn't meaningful,
2696079fdbeSAdrian Chadd 		 *     but set it anyway so things like radiotap get
2706079fdbeSAdrian Chadd 		 *     consistent info in their data.
2716079fdbeSAdrian Chadd 		 */
2726079fdbeSAdrian Chadd 		sc->sc_txantenna = txantenna;
2736079fdbeSAdrian Chadd 	}
27452f55153SAdrian Chadd 
27552f55153SAdrian Chadd finish:
27652f55153SAdrian Chadd 	ATH_LOCK(sc);
27752f55153SAdrian Chadd 	ath_power_restore_power_state(sc);
27852f55153SAdrian Chadd 	ATH_UNLOCK(sc);
27952f55153SAdrian Chadd 
28052f55153SAdrian Chadd 	return (error);
2816079fdbeSAdrian Chadd }
2826079fdbeSAdrian Chadd 
2836079fdbeSAdrian Chadd static int
ath_sysctl_rxantenna(SYSCTL_HANDLER_ARGS)2846079fdbeSAdrian Chadd ath_sysctl_rxantenna(SYSCTL_HANDLER_ARGS)
2856079fdbeSAdrian Chadd {
2866079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
28752f55153SAdrian Chadd 	u_int defantenna;
2886079fdbeSAdrian Chadd 	int error;
2896079fdbeSAdrian Chadd 
29052f55153SAdrian Chadd 	ATH_LOCK(sc);
29152f55153SAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
29252f55153SAdrian Chadd 	defantenna = ath_hal_getdefantenna(sc->sc_ah);
29352f55153SAdrian Chadd 	ATH_UNLOCK(sc);
29452f55153SAdrian Chadd 
2956079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &defantenna, 0, req);
2966079fdbeSAdrian Chadd 	if (!error && req->newptr)
2976079fdbeSAdrian Chadd 		ath_hal_setdefantenna(sc->sc_ah, defantenna);
29852f55153SAdrian Chadd 
29952f55153SAdrian Chadd 	ATH_LOCK(sc);
30052f55153SAdrian Chadd 	ath_power_restore_power_state(sc);
30152f55153SAdrian Chadd 	ATH_UNLOCK(sc);
30252f55153SAdrian Chadd 
30352f55153SAdrian Chadd 	return (error);
3046079fdbeSAdrian Chadd }
3056079fdbeSAdrian Chadd 
3066079fdbeSAdrian Chadd static int
ath_sysctl_diversity(SYSCTL_HANDLER_ARGS)3076079fdbeSAdrian Chadd ath_sysctl_diversity(SYSCTL_HANDLER_ARGS)
3086079fdbeSAdrian Chadd {
3096079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
31052f55153SAdrian Chadd 	u_int diversity;
3116079fdbeSAdrian Chadd 	int error;
3126079fdbeSAdrian Chadd 
31352f55153SAdrian Chadd 	ATH_LOCK(sc);
31452f55153SAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
31552f55153SAdrian Chadd 	ATH_UNLOCK(sc);
31652f55153SAdrian Chadd 
31752f55153SAdrian Chadd 	diversity = ath_hal_getdiversity(sc->sc_ah);
31852f55153SAdrian Chadd 
3196079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &diversity, 0, req);
3206079fdbeSAdrian Chadd 	if (error || !req->newptr)
32152f55153SAdrian Chadd 		goto finish;
32252f55153SAdrian Chadd 	if (!ath_hal_setdiversity(sc->sc_ah, diversity)) {
32352f55153SAdrian Chadd 		error = EINVAL;
32452f55153SAdrian Chadd 		goto finish;
32552f55153SAdrian Chadd 	}
3266079fdbeSAdrian Chadd 	sc->sc_diversity = diversity;
32752f55153SAdrian Chadd 	error = 0;
32852f55153SAdrian Chadd 
32952f55153SAdrian Chadd finish:
33052f55153SAdrian Chadd 	ATH_LOCK(sc);
33152f55153SAdrian Chadd 	ath_power_restore_power_state(sc);
33252f55153SAdrian Chadd 	ATH_UNLOCK(sc);
33352f55153SAdrian Chadd 
33452f55153SAdrian Chadd 	return (error);
3356079fdbeSAdrian Chadd }
3366079fdbeSAdrian Chadd 
3376079fdbeSAdrian Chadd static int
ath_sysctl_diag(SYSCTL_HANDLER_ARGS)3386079fdbeSAdrian Chadd ath_sysctl_diag(SYSCTL_HANDLER_ARGS)
3396079fdbeSAdrian Chadd {
3406079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
3416079fdbeSAdrian Chadd 	u_int32_t diag;
3426079fdbeSAdrian Chadd 	int error;
3436079fdbeSAdrian Chadd 
34452f55153SAdrian Chadd 	ATH_LOCK(sc);
34552f55153SAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
34652f55153SAdrian Chadd 	ATH_UNLOCK(sc);
34752f55153SAdrian Chadd 
34852f55153SAdrian Chadd 	if (!ath_hal_getdiag(sc->sc_ah, &diag)) {
34952f55153SAdrian Chadd 		error = EINVAL;
35052f55153SAdrian Chadd 		goto finish;
35152f55153SAdrian Chadd 	}
35252f55153SAdrian Chadd 
3536079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &diag, 0, req);
3546079fdbeSAdrian Chadd 	if (error || !req->newptr)
35552f55153SAdrian Chadd 		goto finish;
35652f55153SAdrian Chadd 	error = !ath_hal_setdiag(sc->sc_ah, diag) ? EINVAL : 0;
35752f55153SAdrian Chadd 
35852f55153SAdrian Chadd finish:
35952f55153SAdrian Chadd 	ATH_LOCK(sc);
36052f55153SAdrian Chadd 	ath_power_restore_power_state(sc);
36152f55153SAdrian Chadd 	ATH_UNLOCK(sc);
36252f55153SAdrian Chadd 
36352f55153SAdrian Chadd 	return (error);
3646079fdbeSAdrian Chadd }
3656079fdbeSAdrian Chadd 
3666079fdbeSAdrian Chadd static int
ath_sysctl_tpscale(SYSCTL_HANDLER_ARGS)3676079fdbeSAdrian Chadd ath_sysctl_tpscale(SYSCTL_HANDLER_ARGS)
3686079fdbeSAdrian Chadd {
3696079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
3706079fdbeSAdrian Chadd 	u_int32_t scale;
3716079fdbeSAdrian Chadd 	int error;
3726079fdbeSAdrian Chadd 
37352f55153SAdrian Chadd 	ATH_LOCK(sc);
37452f55153SAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
37552f55153SAdrian Chadd 	ATH_UNLOCK(sc);
37652f55153SAdrian Chadd 
3776079fdbeSAdrian Chadd 	(void) ath_hal_gettpscale(sc->sc_ah, &scale);
3786079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &scale, 0, req);
3796079fdbeSAdrian Chadd 	if (error || !req->newptr)
38052f55153SAdrian Chadd 		goto finish;
38152f55153SAdrian Chadd 
38252f55153SAdrian Chadd 	error = !ath_hal_settpscale(sc->sc_ah, scale) ? EINVAL :
3838c01c3dcSAdrian Chadd 	    (sc->sc_running) ? ath_reset(sc, ATH_RESET_NOLOSS,
3848c01c3dcSAdrian Chadd 	    HAL_RESET_NORMAL) : 0;
38552f55153SAdrian Chadd 
38652f55153SAdrian Chadd finish:
38752f55153SAdrian Chadd 	ATH_LOCK(sc);
38852f55153SAdrian Chadd 	ath_power_restore_power_state(sc);
38952f55153SAdrian Chadd 	ATH_UNLOCK(sc);
39052f55153SAdrian Chadd 
39152f55153SAdrian Chadd 	return (error);
3926079fdbeSAdrian Chadd }
3936079fdbeSAdrian Chadd 
3946079fdbeSAdrian Chadd static int
ath_sysctl_tpc(SYSCTL_HANDLER_ARGS)3956079fdbeSAdrian Chadd ath_sysctl_tpc(SYSCTL_HANDLER_ARGS)
3966079fdbeSAdrian Chadd {
3976079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
39852f55153SAdrian Chadd 	u_int tpc;
3996079fdbeSAdrian Chadd 	int error;
4006079fdbeSAdrian Chadd 
40152f55153SAdrian Chadd 	ATH_LOCK(sc);
40252f55153SAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
40352f55153SAdrian Chadd 	ATH_UNLOCK(sc);
40452f55153SAdrian Chadd 
40552f55153SAdrian Chadd 	tpc = ath_hal_gettpc(sc->sc_ah);
40652f55153SAdrian Chadd 
4076079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &tpc, 0, req);
4086079fdbeSAdrian Chadd 	if (error || !req->newptr)
40952f55153SAdrian Chadd 		goto finish;
41052f55153SAdrian Chadd 	error = !ath_hal_settpc(sc->sc_ah, tpc) ? EINVAL : 0;
41152f55153SAdrian Chadd 
41252f55153SAdrian Chadd finish:
41352f55153SAdrian Chadd 	ATH_LOCK(sc);
41452f55153SAdrian Chadd 	ath_power_restore_power_state(sc);
41552f55153SAdrian Chadd 	ATH_UNLOCK(sc);
41652f55153SAdrian Chadd 
41752f55153SAdrian Chadd 	return (error);
4186079fdbeSAdrian Chadd }
4196079fdbeSAdrian Chadd 
4206079fdbeSAdrian Chadd static int
ath_sysctl_rfkill(SYSCTL_HANDLER_ARGS)4216079fdbeSAdrian Chadd ath_sysctl_rfkill(SYSCTL_HANDLER_ARGS)
4226079fdbeSAdrian Chadd {
4236079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
4246079fdbeSAdrian Chadd 	struct ath_hal *ah = sc->sc_ah;
42552f55153SAdrian Chadd 	u_int rfkill;
4266079fdbeSAdrian Chadd 	int error;
4276079fdbeSAdrian Chadd 
42852f55153SAdrian Chadd 	ATH_LOCK(sc);
42952f55153SAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
43052f55153SAdrian Chadd 	ATH_UNLOCK(sc);
43152f55153SAdrian Chadd 
43252f55153SAdrian Chadd 	rfkill = ath_hal_getrfkill(ah);
43352f55153SAdrian Chadd 
4346079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &rfkill, 0, req);
4356079fdbeSAdrian Chadd 	if (error || !req->newptr)
43652f55153SAdrian Chadd 		goto finish;
43752f55153SAdrian Chadd 	if (rfkill == ath_hal_getrfkill(ah)) {	/* unchanged */
43852f55153SAdrian Chadd 		error = 0;
43952f55153SAdrian Chadd 		goto finish;
44052f55153SAdrian Chadd 	}
44152f55153SAdrian Chadd 	if (!ath_hal_setrfkill(ah, rfkill)) {
44252f55153SAdrian Chadd 		error = EINVAL;
44352f55153SAdrian Chadd 		goto finish;
44452f55153SAdrian Chadd 	}
4458c01c3dcSAdrian Chadd 	error = sc->sc_running ? ath_reset(sc, ATH_RESET_FULL,
4468c01c3dcSAdrian Chadd 	    HAL_RESET_NORMAL) : 0;
44752f55153SAdrian Chadd 
44852f55153SAdrian Chadd finish:
44952f55153SAdrian Chadd 	ATH_LOCK(sc);
45052f55153SAdrian Chadd 	ath_power_restore_power_state(sc);
45152f55153SAdrian Chadd 	ATH_UNLOCK(sc);
45252f55153SAdrian Chadd 
45352f55153SAdrian Chadd 	return (error);
4546079fdbeSAdrian Chadd }
4556079fdbeSAdrian Chadd 
4566079fdbeSAdrian Chadd static int
ath_sysctl_txagg(SYSCTL_HANDLER_ARGS)4573dd85b26SAdrian Chadd ath_sysctl_txagg(SYSCTL_HANDLER_ARGS)
4583dd85b26SAdrian Chadd {
4593dd85b26SAdrian Chadd 	struct ath_softc *sc = arg1;
4603dd85b26SAdrian Chadd 	int i, t, param = 0;
4613dd85b26SAdrian Chadd 	int error;
4623dd85b26SAdrian Chadd 	struct ath_buf *bf;
4633dd85b26SAdrian Chadd 
4643dd85b26SAdrian Chadd 	error = sysctl_handle_int(oidp, &param, 0, req);
4653dd85b26SAdrian Chadd 	if (error || !req->newptr)
4663dd85b26SAdrian Chadd 		return error;
4673dd85b26SAdrian Chadd 
4683dd85b26SAdrian Chadd 	if (param != 1)
4693dd85b26SAdrian Chadd 		return 0;
4703dd85b26SAdrian Chadd 
4713dd85b26SAdrian Chadd 	printf("no tx bufs (empty list): %d\n", sc->sc_stats.ast_tx_getnobuf);
4723dd85b26SAdrian Chadd 	printf("no tx bufs (was busy): %d\n", sc->sc_stats.ast_tx_getbusybuf);
4733dd85b26SAdrian Chadd 
4743dd85b26SAdrian Chadd 	printf("aggr single packet: %d\n",
4753dd85b26SAdrian Chadd 	    sc->sc_aggr_stats.aggr_single_pkt);
4763dd85b26SAdrian Chadd 	printf("aggr single packet w/ BAW closed: %d\n",
4773dd85b26SAdrian Chadd 	    sc->sc_aggr_stats.aggr_baw_closed_single_pkt);
4783dd85b26SAdrian Chadd 	printf("aggr non-baw packet: %d\n",
4793dd85b26SAdrian Chadd 	    sc->sc_aggr_stats.aggr_nonbaw_pkt);
4803dd85b26SAdrian Chadd 	printf("aggr aggregate packet: %d\n",
4813dd85b26SAdrian Chadd 	    sc->sc_aggr_stats.aggr_aggr_pkt);
4823dd85b26SAdrian Chadd 	printf("aggr single packet low hwq: %d\n",
4833dd85b26SAdrian Chadd 	    sc->sc_aggr_stats.aggr_low_hwq_single_pkt);
484e2e4a2c2SAdrian Chadd 	printf("aggr single packet RTS aggr limited: %d\n",
485e2e4a2c2SAdrian Chadd 	    sc->sc_aggr_stats.aggr_rts_aggr_limited);
4863dd85b26SAdrian Chadd 	printf("aggr sched, no work: %d\n",
4873dd85b26SAdrian Chadd 	    sc->sc_aggr_stats.aggr_sched_nopkt);
4883dd85b26SAdrian Chadd 	for (i = 0; i < 64; i++) {
4893dd85b26SAdrian Chadd 		printf("%2d: %10d ", i, sc->sc_aggr_stats.aggr_pkts[i]);
4903dd85b26SAdrian Chadd 		if (i % 4 == 3)
4913dd85b26SAdrian Chadd 			printf("\n");
4923dd85b26SAdrian Chadd 	}
4933dd85b26SAdrian Chadd 	printf("\n");
4943dd85b26SAdrian Chadd 
4953dd85b26SAdrian Chadd 	for (i = 0; i < HAL_NUM_TX_QUEUES; i++) {
4963dd85b26SAdrian Chadd 		if (ATH_TXQ_SETUP(sc, i)) {
497629ce218SAdrian Chadd 			printf("HW TXQ %d: axq_depth=%d, axq_aggr_depth=%d, "
498629ce218SAdrian Chadd 			    "axq_fifo_depth=%d, holdingbf=%p\n",
4993dd85b26SAdrian Chadd 			    i,
5003dd85b26SAdrian Chadd 			    sc->sc_txq[i].axq_depth,
501edd3e98fSAdrian Chadd 			    sc->sc_txq[i].axq_aggr_depth,
502629ce218SAdrian Chadd 			    sc->sc_txq[i].axq_fifo_depth,
503629ce218SAdrian Chadd 			    sc->sc_txq[i].axq_holdingbf);
5043dd85b26SAdrian Chadd 		}
5053dd85b26SAdrian Chadd 	}
5063dd85b26SAdrian Chadd 
5073dd85b26SAdrian Chadd 	i = t = 0;
5083dd85b26SAdrian Chadd 	ATH_TXBUF_LOCK(sc);
5096b349e5aSAdrian Chadd 	TAILQ_FOREACH(bf, &sc->sc_txbuf, bf_list) {
5103dd85b26SAdrian Chadd 		if (bf->bf_flags & ATH_BUF_BUSY) {
5113dd85b26SAdrian Chadd 			printf("Busy: %d\n", t);
5123dd85b26SAdrian Chadd 			i++;
5133dd85b26SAdrian Chadd 		}
5143dd85b26SAdrian Chadd 		t++;
5153dd85b26SAdrian Chadd 	}
5163dd85b26SAdrian Chadd 	ATH_TXBUF_UNLOCK(sc);
51723ced6c1SAdrian Chadd 	printf("Total TX buffers: %d; Total TX buffers busy: %d (%d)\n",
51823ced6c1SAdrian Chadd 	    t, i, sc->sc_txbuf_cnt);
5193dd85b26SAdrian Chadd 
520af33d486SAdrian Chadd 	i = t = 0;
521af33d486SAdrian Chadd 	ATH_TXBUF_LOCK(sc);
522af33d486SAdrian Chadd 	TAILQ_FOREACH(bf, &sc->sc_txbuf_mgmt, bf_list) {
523af33d486SAdrian Chadd 		if (bf->bf_flags & ATH_BUF_BUSY) {
524af33d486SAdrian Chadd 			printf("Busy: %d\n", t);
525af33d486SAdrian Chadd 			i++;
526af33d486SAdrian Chadd 		}
527af33d486SAdrian Chadd 		t++;
528af33d486SAdrian Chadd 	}
529af33d486SAdrian Chadd 	ATH_TXBUF_UNLOCK(sc);
530af33d486SAdrian Chadd 	printf("Total mgmt TX buffers: %d; Total mgmt TX buffers busy: %d\n",
531af33d486SAdrian Chadd 	    t, i);
532af33d486SAdrian Chadd 
533eefc93a9SAdrian Chadd 	ATH_RX_LOCK(sc);
534eefc93a9SAdrian Chadd 	for (i = 0; i < 2; i++) {
53567aaf739SAdrian Chadd 		printf("%d: fifolen: %d/%d; head=%d; tail=%d; m_pending=%p, m_holdbf=%p\n",
536eefc93a9SAdrian Chadd 		    i,
5371ab002f4SAdrian Chadd 		    sc->sc_rxedma[i].m_fifo_depth,
538eefc93a9SAdrian Chadd 		    sc->sc_rxedma[i].m_fifolen,
539eefc93a9SAdrian Chadd 		    sc->sc_rxedma[i].m_fifo_head,
54067aaf739SAdrian Chadd 		    sc->sc_rxedma[i].m_fifo_tail,
54167aaf739SAdrian Chadd 		    sc->sc_rxedma[i].m_rxpending,
54267aaf739SAdrian Chadd 		    sc->sc_rxedma[i].m_holdbf);
543eefc93a9SAdrian Chadd 	}
544eefc93a9SAdrian Chadd 	i = 0;
545eefc93a9SAdrian Chadd 	TAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) {
546eefc93a9SAdrian Chadd 		i++;
547eefc93a9SAdrian Chadd 	}
548eefc93a9SAdrian Chadd 	printf("Total RX buffers in free list: %d buffers\n",
549eefc93a9SAdrian Chadd 	    i);
550eefc93a9SAdrian Chadd 	ATH_RX_UNLOCK(sc);
551eefc93a9SAdrian Chadd 
5523dd85b26SAdrian Chadd 	return 0;
5533dd85b26SAdrian Chadd }
5543dd85b26SAdrian Chadd 
5553dd85b26SAdrian Chadd static int
ath_sysctl_rfsilent(SYSCTL_HANDLER_ARGS)5566079fdbeSAdrian Chadd ath_sysctl_rfsilent(SYSCTL_HANDLER_ARGS)
5576079fdbeSAdrian Chadd {
5586079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
5596079fdbeSAdrian Chadd 	u_int rfsilent;
5606079fdbeSAdrian Chadd 	int error;
5616079fdbeSAdrian Chadd 
56252f55153SAdrian Chadd 	ATH_LOCK(sc);
56352f55153SAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
56452f55153SAdrian Chadd 	ATH_UNLOCK(sc);
56552f55153SAdrian Chadd 
5666079fdbeSAdrian Chadd 	(void) ath_hal_getrfsilent(sc->sc_ah, &rfsilent);
5676079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &rfsilent, 0, req);
5686079fdbeSAdrian Chadd 	if (error || !req->newptr)
56952f55153SAdrian Chadd 		goto finish;
57052f55153SAdrian Chadd 	if (!ath_hal_setrfsilent(sc->sc_ah, rfsilent)) {
57152f55153SAdrian Chadd 		error = EINVAL;
57252f55153SAdrian Chadd 		goto finish;
57352f55153SAdrian Chadd 	}
57470bd9518SAdrian Chadd 	/*
57570bd9518SAdrian Chadd 	 * Earlier chips (< AR5212) have up to 8 GPIO
57670bd9518SAdrian Chadd 	 * pins exposed.
57770bd9518SAdrian Chadd 	 *
57870bd9518SAdrian Chadd 	 * AR5416 and later chips have many more GPIO
57970bd9518SAdrian Chadd 	 * pins (up to 16) so the mask is expanded to
58070bd9518SAdrian Chadd 	 * four bits.
58170bd9518SAdrian Chadd 	 */
58270bd9518SAdrian Chadd 	sc->sc_rfsilentpin = rfsilent & 0x3c;
5836079fdbeSAdrian Chadd 	sc->sc_rfsilentpol = (rfsilent & 0x2) != 0;
58452f55153SAdrian Chadd 	error = 0;
58552f55153SAdrian Chadd 
58652f55153SAdrian Chadd finish:
58752f55153SAdrian Chadd 	ATH_LOCK(sc);
58852f55153SAdrian Chadd 	ath_power_restore_power_state(sc);
58952f55153SAdrian Chadd 	ATH_UNLOCK(sc);
59052f55153SAdrian Chadd 
59152f55153SAdrian Chadd 	return (error);
5926079fdbeSAdrian Chadd }
5936079fdbeSAdrian Chadd 
5946079fdbeSAdrian Chadd static int
ath_sysctl_tpack(SYSCTL_HANDLER_ARGS)5956079fdbeSAdrian Chadd ath_sysctl_tpack(SYSCTL_HANDLER_ARGS)
5966079fdbeSAdrian Chadd {
5976079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
5986079fdbeSAdrian Chadd 	u_int32_t tpack;
5996079fdbeSAdrian Chadd 	int error;
6006079fdbeSAdrian Chadd 
60152f55153SAdrian Chadd 	ATH_LOCK(sc);
60252f55153SAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
60352f55153SAdrian Chadd 	ATH_UNLOCK(sc);
60452f55153SAdrian Chadd 
6056079fdbeSAdrian Chadd 	(void) ath_hal_gettpack(sc->sc_ah, &tpack);
6066079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &tpack, 0, req);
6076079fdbeSAdrian Chadd 	if (error || !req->newptr)
60852f55153SAdrian Chadd 		goto finish;
60952f55153SAdrian Chadd 	error = !ath_hal_settpack(sc->sc_ah, tpack) ? EINVAL : 0;
61052f55153SAdrian Chadd 
61152f55153SAdrian Chadd finish:
61252f55153SAdrian Chadd 	ATH_LOCK(sc);
61352f55153SAdrian Chadd 	ath_power_restore_power_state(sc);
61452f55153SAdrian Chadd 	ATH_UNLOCK(sc);
61552f55153SAdrian Chadd 
61652f55153SAdrian Chadd 	return (error);
6176079fdbeSAdrian Chadd }
6186079fdbeSAdrian Chadd 
6196079fdbeSAdrian Chadd static int
ath_sysctl_tpcts(SYSCTL_HANDLER_ARGS)6206079fdbeSAdrian Chadd ath_sysctl_tpcts(SYSCTL_HANDLER_ARGS)
6216079fdbeSAdrian Chadd {
6226079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
6236079fdbeSAdrian Chadd 	u_int32_t tpcts;
6246079fdbeSAdrian Chadd 	int error;
6256079fdbeSAdrian Chadd 
62652f55153SAdrian Chadd 	ATH_LOCK(sc);
62752f55153SAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
62852f55153SAdrian Chadd 	ATH_UNLOCK(sc);
62952f55153SAdrian Chadd 
6306079fdbeSAdrian Chadd 	(void) ath_hal_gettpcts(sc->sc_ah, &tpcts);
6316079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &tpcts, 0, req);
6326079fdbeSAdrian Chadd 	if (error || !req->newptr)
63352f55153SAdrian Chadd 		goto finish;
63452f55153SAdrian Chadd 
63552f55153SAdrian Chadd 	error = !ath_hal_settpcts(sc->sc_ah, tpcts) ? EINVAL : 0;
63652f55153SAdrian Chadd 
63752f55153SAdrian Chadd finish:
63852f55153SAdrian Chadd 	ATH_LOCK(sc);
63952f55153SAdrian Chadd 	ath_power_restore_power_state(sc);
64052f55153SAdrian Chadd 	ATH_UNLOCK(sc);
64152f55153SAdrian Chadd 
64252f55153SAdrian Chadd 	return (error);
6436079fdbeSAdrian Chadd }
6446079fdbeSAdrian Chadd 
6456079fdbeSAdrian Chadd static int
ath_sysctl_intmit(SYSCTL_HANDLER_ARGS)6466079fdbeSAdrian Chadd ath_sysctl_intmit(SYSCTL_HANDLER_ARGS)
6476079fdbeSAdrian Chadd {
6486079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
6496079fdbeSAdrian Chadd 	int intmit, error;
6506079fdbeSAdrian Chadd 
65152f55153SAdrian Chadd 	ATH_LOCK(sc);
65252f55153SAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
65352f55153SAdrian Chadd 	ATH_UNLOCK(sc);
65452f55153SAdrian Chadd 
6556079fdbeSAdrian Chadd 	intmit = ath_hal_getintmit(sc->sc_ah);
6566079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &intmit, 0, req);
6576079fdbeSAdrian Chadd 	if (error || !req->newptr)
65852f55153SAdrian Chadd 		goto finish;
659f9da901eSAdrian Chadd 
660f9da901eSAdrian Chadd 	/* reusing error; 1 here means "good"; 0 means "fail" */
661f9da901eSAdrian Chadd 	error = ath_hal_setintmit(sc->sc_ah, intmit);
66252f55153SAdrian Chadd 	if (! error) {
66352f55153SAdrian Chadd 		error = EINVAL;
66452f55153SAdrian Chadd 		goto finish;
66552f55153SAdrian Chadd 	}
666f9da901eSAdrian Chadd 
667f9da901eSAdrian Chadd 	/*
668f9da901eSAdrian Chadd 	 * Reset the hardware here - disabling ANI in the HAL
669f9da901eSAdrian Chadd 	 * doesn't reset ANI related registers, so it'll leave
670f9da901eSAdrian Chadd 	 * things in an inconsistent state.
671f9da901eSAdrian Chadd 	 */
6727a79cebfSGleb Smirnoff 	if (sc->sc_running)
6738c01c3dcSAdrian Chadd 		ath_reset(sc, ATH_RESET_NOLOSS, HAL_RESET_NORMAL);
674f9da901eSAdrian Chadd 
67552f55153SAdrian Chadd 	error = 0;
67652f55153SAdrian Chadd 
67752f55153SAdrian Chadd finish:
67852f55153SAdrian Chadd 	ATH_LOCK(sc);
67952f55153SAdrian Chadd 	ath_power_restore_power_state(sc);
68052f55153SAdrian Chadd 	ATH_UNLOCK(sc);
68152f55153SAdrian Chadd 
68252f55153SAdrian Chadd 	return (error);
6836079fdbeSAdrian Chadd }
6846079fdbeSAdrian Chadd 
6856079fdbeSAdrian Chadd #ifdef IEEE80211_SUPPORT_TDMA
6866079fdbeSAdrian Chadd static int
ath_sysctl_setcca(SYSCTL_HANDLER_ARGS)6876079fdbeSAdrian Chadd ath_sysctl_setcca(SYSCTL_HANDLER_ARGS)
6886079fdbeSAdrian Chadd {
6896079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
6906079fdbeSAdrian Chadd 	int setcca, error;
6916079fdbeSAdrian Chadd 
6926079fdbeSAdrian Chadd 	setcca = sc->sc_setcca;
6936079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &setcca, 0, req);
6946079fdbeSAdrian Chadd 	if (error || !req->newptr)
6956079fdbeSAdrian Chadd 		return error;
6966079fdbeSAdrian Chadd 	sc->sc_setcca = (setcca != 0);
6976079fdbeSAdrian Chadd 	return 0;
6986079fdbeSAdrian Chadd }
6996079fdbeSAdrian Chadd #endif /* IEEE80211_SUPPORT_TDMA */
7006079fdbeSAdrian Chadd 
7013dd85b26SAdrian Chadd static int
ath_sysctl_forcebstuck(SYSCTL_HANDLER_ARGS)7023dd85b26SAdrian Chadd ath_sysctl_forcebstuck(SYSCTL_HANDLER_ARGS)
7033dd85b26SAdrian Chadd {
7043dd85b26SAdrian Chadd 	struct ath_softc *sc = arg1;
7053dd85b26SAdrian Chadd 	int val = 0;
7063dd85b26SAdrian Chadd 	int error;
7073dd85b26SAdrian Chadd 
7083dd85b26SAdrian Chadd 	error = sysctl_handle_int(oidp, &val, 0, req);
7093dd85b26SAdrian Chadd 	if (error || !req->newptr)
7103dd85b26SAdrian Chadd 		return error;
7113dd85b26SAdrian Chadd 	if (val == 0)
7123dd85b26SAdrian Chadd 		return 0;
7133dd85b26SAdrian Chadd 
714cbc4d2dbSJohn Baldwin 	taskqueue_enqueue(sc->sc_tq, &sc->sc_bstucktask);
7153dd85b26SAdrian Chadd 	val = 0;
7163dd85b26SAdrian Chadd 	return 0;
7173dd85b26SAdrian Chadd }
7183dd85b26SAdrian Chadd 
719c5239edbSAdrian Chadd static int
ath_sysctl_hangcheck(SYSCTL_HANDLER_ARGS)720c5239edbSAdrian Chadd ath_sysctl_hangcheck(SYSCTL_HANDLER_ARGS)
721c5239edbSAdrian Chadd {
722c5239edbSAdrian Chadd 	struct ath_softc *sc = arg1;
723c5239edbSAdrian Chadd 	int val = 0;
724c5239edbSAdrian Chadd 	int error;
725c5239edbSAdrian Chadd 	uint32_t mask = 0xffffffff;
726c5239edbSAdrian Chadd 	uint32_t *sp;
727c5239edbSAdrian Chadd 	uint32_t rsize;
728c5239edbSAdrian Chadd 	struct ath_hal *ah = sc->sc_ah;
729c5239edbSAdrian Chadd 
730c5239edbSAdrian Chadd 	error = sysctl_handle_int(oidp, &val, 0, req);
731c5239edbSAdrian Chadd 	if (error || !req->newptr)
732c5239edbSAdrian Chadd 		return error;
733c5239edbSAdrian Chadd 	if (val == 0)
734c5239edbSAdrian Chadd 		return 0;
735c5239edbSAdrian Chadd 
73652f55153SAdrian Chadd 	ATH_LOCK(sc);
73752f55153SAdrian Chadd 	ath_power_set_power_state(sc, HAL_PM_AWAKE);
73852f55153SAdrian Chadd 	ATH_UNLOCK(sc);
73952f55153SAdrian Chadd 
740c5239edbSAdrian Chadd 	/* Do a hang check */
741c5239edbSAdrian Chadd 	if (!ath_hal_getdiagstate(ah, HAL_DIAG_CHECK_HANGS,
742c5239edbSAdrian Chadd 	    &mask, sizeof(mask),
74352f55153SAdrian Chadd 	    (void *) &sp, &rsize)) {
74452f55153SAdrian Chadd 		error = 0;
74552f55153SAdrian Chadd 		goto finish;
74652f55153SAdrian Chadd 	}
74752f55153SAdrian Chadd 
748c5239edbSAdrian Chadd 	device_printf(sc->sc_dev, "%s: sp=0x%08x\n", __func__, *sp);
749c5239edbSAdrian Chadd 
750c5239edbSAdrian Chadd 	val = 0;
75152f55153SAdrian Chadd 	error = 0;
75252f55153SAdrian Chadd finish:
75352f55153SAdrian Chadd 	ATH_LOCK(sc);
75452f55153SAdrian Chadd 	ath_power_restore_power_state(sc);
75552f55153SAdrian Chadd 	ATH_UNLOCK(sc);
75652f55153SAdrian Chadd 
75752f55153SAdrian Chadd 	return (error);
758c5239edbSAdrian Chadd }
759b69b0dccSAdrian Chadd 
760bbee93a8SAdrian Chadd #ifdef ATH_DEBUG_ALQ
761b69b0dccSAdrian Chadd static int
ath_sysctl_alq_log(SYSCTL_HANDLER_ARGS)762b69b0dccSAdrian Chadd ath_sysctl_alq_log(SYSCTL_HANDLER_ARGS)
763b69b0dccSAdrian Chadd {
764b69b0dccSAdrian Chadd 	struct ath_softc *sc = arg1;
765b69b0dccSAdrian Chadd 	int error, enable;
766b69b0dccSAdrian Chadd 
767b69b0dccSAdrian Chadd 	enable = (sc->sc_alq.sc_alq_isactive);
768b69b0dccSAdrian Chadd 
769b69b0dccSAdrian Chadd 	error = sysctl_handle_int(oidp, &enable, 0, req);
770b69b0dccSAdrian Chadd 	if (error || !req->newptr)
771b69b0dccSAdrian Chadd 		return (error);
772b69b0dccSAdrian Chadd 	else if (enable)
773b69b0dccSAdrian Chadd 		error = if_ath_alq_start(&sc->sc_alq);
774b69b0dccSAdrian Chadd 	else
775b69b0dccSAdrian Chadd 		error = if_ath_alq_stop(&sc->sc_alq);
776b69b0dccSAdrian Chadd 	return (error);
777b69b0dccSAdrian Chadd }
778b69b0dccSAdrian Chadd 
779b69b0dccSAdrian Chadd /*
780b69b0dccSAdrian Chadd  * Attach the ALQ debugging if required.
781b69b0dccSAdrian Chadd  */
782b69b0dccSAdrian Chadd static void
ath_sysctl_alq_attach(struct ath_softc * sc)783b69b0dccSAdrian Chadd ath_sysctl_alq_attach(struct ath_softc *sc)
784b69b0dccSAdrian Chadd {
785b69b0dccSAdrian Chadd 	struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
786b69b0dccSAdrian Chadd 	struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
787b69b0dccSAdrian Chadd 	struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
788b69b0dccSAdrian Chadd 
78908f5e6bbSPawel Biernacki 	tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "alq",
79008f5e6bbSPawel Biernacki 	    CTLFLAG_RD | CTLFLAG_MPSAFE, NULL,
79108f5e6bbSPawel Biernacki 	    "Atheros ALQ logging parameters");
792b69b0dccSAdrian Chadd 	child = SYSCTL_CHILDREN(tree);
793b69b0dccSAdrian Chadd 
794b69b0dccSAdrian Chadd 	SYSCTL_ADD_STRING(ctx, child, OID_AUTO, "filename",
795b69b0dccSAdrian Chadd 	    CTLFLAG_RW, sc->sc_alq.sc_alq_filename, 0, "ALQ filename");
796b69b0dccSAdrian Chadd 
797b69b0dccSAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
79808f5e6bbSPawel Biernacki 	    "enable", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
799b69b0dccSAdrian Chadd 	    ath_sysctl_alq_log, "I", "");
800b69b0dccSAdrian Chadd 
801b69b0dccSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
802b69b0dccSAdrian Chadd 		"debugmask", CTLFLAG_RW, &sc->sc_alq.sc_alq_debug, 0,
803b69b0dccSAdrian Chadd 		"ALQ debug mask");
804b69b0dccSAdrian Chadd 
805b69b0dccSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
806b69b0dccSAdrian Chadd 		"numlost", CTLFLAG_RW, &sc->sc_alq.sc_alq_numlost, 0,
807b69b0dccSAdrian Chadd 		"number lost");
808b69b0dccSAdrian Chadd }
809bbee93a8SAdrian Chadd #endif /* ATH_DEBUG_ALQ */
810b69b0dccSAdrian Chadd 
8116079fdbeSAdrian Chadd void
ath_sysctlattach(struct ath_softc * sc)8126079fdbeSAdrian Chadd ath_sysctlattach(struct ath_softc *sc)
8136079fdbeSAdrian Chadd {
8146079fdbeSAdrian Chadd 	struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
8156079fdbeSAdrian Chadd 	struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
8166079fdbeSAdrian Chadd 	struct ath_hal *ah = sc->sc_ah;
8176079fdbeSAdrian Chadd 
8186079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
8196079fdbeSAdrian Chadd 		"countrycode", CTLFLAG_RD, &sc->sc_eecc, 0,
8206079fdbeSAdrian Chadd 		"EEPROM country code");
8216079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
8226079fdbeSAdrian Chadd 		"regdomain", CTLFLAG_RD, &sc->sc_eerd, 0,
8236079fdbeSAdrian Chadd 		"EEPROM regdomain code");
8245f9fe65dSAdrian Chadd #ifdef	ATH_DEBUG
8250e22ed0eSAdrian Chadd 	SYSCTL_ADD_QUAD(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
8260e22ed0eSAdrian Chadd 		"debug", CTLFLAG_RW, &sc->sc_debug,
8276079fdbeSAdrian Chadd 		"control debugging printfs");
8285f9fe65dSAdrian Chadd #endif
8295f9fe65dSAdrian Chadd #ifdef	ATH_DEBUG_ALQ
83003682514SAdrian Chadd 	SYSCTL_ADD_QUAD(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
83103682514SAdrian Chadd 		"ktrdebug", CTLFLAG_RW, &sc->sc_ktrdebug,
83203682514SAdrian Chadd 		"control debugging KTR");
833bbee93a8SAdrian Chadd #endif /* ATH_DEBUG_ALQ */
8346079fdbeSAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
83508f5e6bbSPawel Biernacki 	    "slottime", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
8366079fdbeSAdrian Chadd 	    ath_sysctl_slottime, "I", "802.11 slot time (us)");
8376079fdbeSAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
83808f5e6bbSPawel Biernacki 	    "acktimeout", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
8396079fdbeSAdrian Chadd 	    ath_sysctl_acktimeout, "I", "802.11 ACK timeout (us)");
8406079fdbeSAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
84108f5e6bbSPawel Biernacki 	    "ctstimeout", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
8426079fdbeSAdrian Chadd 	    ath_sysctl_ctstimeout, "I", "802.11 CTS timeout (us)");
8433440495aSAdrian Chadd 
8446079fdbeSAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
84508f5e6bbSPawel Biernacki 	    "softled", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
8466079fdbeSAdrian Chadd 	    ath_sysctl_softled, "I", "enable/disable software LED support");
8476079fdbeSAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
84808f5e6bbSPawel Biernacki 	    "ledpin", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
8496079fdbeSAdrian Chadd 	    ath_sysctl_ledpin, "I", "GPIO pin connected to LED");
8506079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
8516079fdbeSAdrian Chadd 		"ledon", CTLFLAG_RW, &sc->sc_ledon, 0,
8526079fdbeSAdrian Chadd 		"setting to turn LED on");
8536079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
8546079fdbeSAdrian Chadd 		"ledidle", CTLFLAG_RW, &sc->sc_ledidle, 0,
8556079fdbeSAdrian Chadd 		"idle time for inactivity LED (ticks)");
8563440495aSAdrian Chadd 
8573440495aSAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
85808f5e6bbSPawel Biernacki 	    "hardled", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
8593440495aSAdrian Chadd 	    ath_sysctl_hardled, "I", "enable/disable hardware LED support");
8603440495aSAdrian Chadd 	/* XXX Laziness - configure pins, then flip hardled off/on */
8613440495aSAdrian Chadd 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
8623440495aSAdrian Chadd 		"led_net_pin", CTLFLAG_RW, &sc->sc_led_net_pin, 0,
8633440495aSAdrian Chadd 		"MAC Network LED pin, or -1 to disable");
8643440495aSAdrian Chadd 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
8653440495aSAdrian Chadd 		"led_pwr_pin", CTLFLAG_RW, &sc->sc_led_pwr_pin, 0,
8663440495aSAdrian Chadd 		"MAC Power LED pin, or -1 to disable");
8673440495aSAdrian Chadd 
8686079fdbeSAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
86908f5e6bbSPawel Biernacki 	    "txantenna", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
8706079fdbeSAdrian Chadd 	    ath_sysctl_txantenna, "I", "antenna switch");
8716079fdbeSAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
87208f5e6bbSPawel Biernacki 	    "rxantenna", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
8736079fdbeSAdrian Chadd 	    ath_sysctl_rxantenna, "I", "default/rx antenna");
8746079fdbeSAdrian Chadd 	if (ath_hal_hasdiversity(ah))
8756079fdbeSAdrian Chadd 		SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
87608f5e6bbSPawel Biernacki 		    "diversity", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
87708f5e6bbSPawel Biernacki 		    sc, 0, ath_sysctl_diversity, "I", "antenna diversity");
8786079fdbeSAdrian Chadd 	sc->sc_txintrperiod = ATH_TXINTR_PERIOD;
8796079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
8806079fdbeSAdrian Chadd 		"txintrperiod", CTLFLAG_RW, &sc->sc_txintrperiod, 0,
8816079fdbeSAdrian Chadd 		"tx descriptor batching");
8826079fdbeSAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
88308f5e6bbSPawel Biernacki 	    "diag", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
8846079fdbeSAdrian Chadd 	    ath_sysctl_diag, "I", "h/w diagnostic control");
8856079fdbeSAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
88608f5e6bbSPawel Biernacki 	    "tpscale", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
8876079fdbeSAdrian Chadd 	    ath_sysctl_tpscale, "I", "tx power scaling");
8886079fdbeSAdrian Chadd 	if (ath_hal_hastpc(ah)) {
8896079fdbeSAdrian Chadd 		SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
89008f5e6bbSPawel Biernacki 		    "tpc", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
8916079fdbeSAdrian Chadd 		    ath_sysctl_tpc, "I", "enable/disable per-packet TPC");
8926079fdbeSAdrian Chadd 		SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
89308f5e6bbSPawel Biernacki 		    "tpack", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc,
89408f5e6bbSPawel Biernacki 		    0, ath_sysctl_tpack, "I", "tx power for ack frames");
8956079fdbeSAdrian Chadd 		SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
89608f5e6bbSPawel Biernacki 		    "tpcts", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc,
89708f5e6bbSPawel Biernacki 		    0, ath_sysctl_tpcts, "I", "tx power for cts frames");
8986079fdbeSAdrian Chadd 	}
8996079fdbeSAdrian Chadd 	if (ath_hal_hasrfsilent(ah)) {
9006079fdbeSAdrian Chadd 		SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
90108f5e6bbSPawel Biernacki 		    "rfsilent", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
90208f5e6bbSPawel Biernacki 		    sc, 0, ath_sysctl_rfsilent, "I", "h/w RF silent config");
9036079fdbeSAdrian Chadd 		SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
90408f5e6bbSPawel Biernacki 		    "rfkill", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc,
90508f5e6bbSPawel Biernacki 		    0, ath_sysctl_rfkill, "I", "enable/disable RF kill switch");
9066079fdbeSAdrian Chadd 	}
9073dd85b26SAdrian Chadd 
9083dd85b26SAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
90908f5e6bbSPawel Biernacki 	    "txagg", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
9103dd85b26SAdrian Chadd 	    ath_sysctl_txagg, "I", "");
9113dd85b26SAdrian Chadd 
9123dd85b26SAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
91308f5e6bbSPawel Biernacki 	    "forcebstuck", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc,
91408f5e6bbSPawel Biernacki 	    0, ath_sysctl_forcebstuck, "I", "");
9153dd85b26SAdrian Chadd 
916c5239edbSAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
91708f5e6bbSPawel Biernacki 	    "hangcheck", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
918c5239edbSAdrian Chadd 	    ath_sysctl_hangcheck, "I", "");
919c5239edbSAdrian Chadd 
9206079fdbeSAdrian Chadd 	if (ath_hal_hasintmit(ah)) {
9216079fdbeSAdrian Chadd 		SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
92208f5e6bbSPawel Biernacki 		    "intmit", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc,
92308f5e6bbSPawel Biernacki 		    0, ath_sysctl_intmit, "I", "interference mitigation");
9246079fdbeSAdrian Chadd 	}
9256079fdbeSAdrian Chadd 	sc->sc_monpass = HAL_RXERR_DECRYPT | HAL_RXERR_MIC;
9266079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
9276079fdbeSAdrian Chadd 		"monpass", CTLFLAG_RW, &sc->sc_monpass, 0,
9286079fdbeSAdrian Chadd 		"mask of error frames to pass when monitoring");
9293dd85b26SAdrian Chadd 
9303dd85b26SAdrian Chadd 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
93172910f03SAdrian Chadd 		"hwq_limit_nonaggr", CTLFLAG_RW, &sc->sc_hwq_limit_nonaggr, 0,
93272910f03SAdrian Chadd 		"Hardware non-AMPDU queue depth before software-queuing TX frames");
93372910f03SAdrian Chadd 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
93472910f03SAdrian Chadd 		"hwq_limit_aggr", CTLFLAG_RW, &sc->sc_hwq_limit_aggr, 0,
93572910f03SAdrian Chadd 		"Hardware AMPDU queue depth before software-queuing TX frames");
9363dd85b26SAdrian Chadd 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
9373dd85b26SAdrian Chadd 		"tid_hwq_lo", CTLFLAG_RW, &sc->sc_tid_hwq_lo, 0,
9383dd85b26SAdrian Chadd 		"");
9393dd85b26SAdrian Chadd 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
9403dd85b26SAdrian Chadd 		"tid_hwq_hi", CTLFLAG_RW, &sc->sc_tid_hwq_hi, 0,
9413dd85b26SAdrian Chadd 		"");
9423dd85b26SAdrian Chadd 
9434a502c33SAdrian Chadd 	/* Aggregate length twiddles */
9444a502c33SAdrian Chadd 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
945a54ecf78SAdrian Chadd 		"aggr_limit", CTLFLAG_RW, &sc->sc_aggr_limit, 0,
946a54ecf78SAdrian Chadd 		"Maximum A-MPDU size, or 0 for 'default'");
9474a502c33SAdrian Chadd 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
948a54ecf78SAdrian Chadd 		"rts_aggr_limit", CTLFLAG_RW, &sc->sc_rts_aggr_limit, 0,
949a54ecf78SAdrian Chadd 		"Maximum A-MPDU size for RTS-protected frames, or '0' "
950a54ecf78SAdrian Chadd 		"for default");
951a54ecf78SAdrian Chadd 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
952a54ecf78SAdrian Chadd 		"delim_min_pad", CTLFLAG_RW, &sc->sc_delim_min_pad, 0,
953a54ecf78SAdrian Chadd 		"Enforce a minimum number of delimiters per A-MPDU "
954a54ecf78SAdrian Chadd 		" sub-frame");
9554a502c33SAdrian Chadd 
9569c85ff91SAdrian Chadd 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
9579c85ff91SAdrian Chadd 		"txq_data_minfree", CTLFLAG_RW, &sc->sc_txq_data_minfree,
9589c85ff91SAdrian Chadd 		0, "Minimum free buffers before adding a data frame"
9599c85ff91SAdrian Chadd 		" to the TX queue");
9609c85ff91SAdrian Chadd 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
9619c85ff91SAdrian Chadd 		"txq_mcastq_maxdepth", CTLFLAG_RW,
9629c85ff91SAdrian Chadd 		&sc->sc_txq_mcastq_maxdepth, 0,
9639c85ff91SAdrian Chadd 		"Maximum buffer depth for multicast/broadcast frames");
9647dcb2beaSAdrian Chadd 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
9657dcb2beaSAdrian Chadd 		"txq_node_maxdepth", CTLFLAG_RW,
9667dcb2beaSAdrian Chadd 		&sc->sc_txq_node_maxdepth, 0,
9677dcb2beaSAdrian Chadd 		"Maximum buffer depth for a single node");
9689c85ff91SAdrian Chadd 
969b837332dSAdrian Chadd #if 0
970b837332dSAdrian Chadd 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
971b837332dSAdrian Chadd 		"cabq_enable", CTLFLAG_RW,
972b837332dSAdrian Chadd 		&sc->sc_cabq_enable, 0,
973b837332dSAdrian Chadd 		"Whether to transmit on the CABQ or not");
974b837332dSAdrian Chadd #endif
975b837332dSAdrian Chadd 
9766079fdbeSAdrian Chadd #ifdef IEEE80211_SUPPORT_TDMA
9776079fdbeSAdrian Chadd 	if (ath_hal_macversion(ah) > 0x78) {
9786079fdbeSAdrian Chadd 		sc->sc_tdmadbaprep = 2;
9796079fdbeSAdrian Chadd 		SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
9806079fdbeSAdrian Chadd 			"dbaprep", CTLFLAG_RW, &sc->sc_tdmadbaprep, 0,
9816079fdbeSAdrian Chadd 			"TDMA DBA preparation time");
9826079fdbeSAdrian Chadd 		sc->sc_tdmaswbaprep = 10;
9836079fdbeSAdrian Chadd 		SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
9846079fdbeSAdrian Chadd 			"swbaprep", CTLFLAG_RW, &sc->sc_tdmaswbaprep, 0,
9856079fdbeSAdrian Chadd 			"TDMA SWBA preparation time");
9866079fdbeSAdrian Chadd 		SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
9876079fdbeSAdrian Chadd 			"guardtime", CTLFLAG_RW, &sc->sc_tdmaguard, 0,
9886079fdbeSAdrian Chadd 			"TDMA slot guard time");
9896079fdbeSAdrian Chadd 		SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
9906079fdbeSAdrian Chadd 			"superframe", CTLFLAG_RD, &sc->sc_tdmabintval, 0,
9916079fdbeSAdrian Chadd 			"TDMA calculated super frame");
9926079fdbeSAdrian Chadd 		SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
99308f5e6bbSPawel Biernacki 		    "setcca", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
99408f5e6bbSPawel Biernacki 		    sc, 0, ath_sysctl_setcca, "I", "enable CCA control");
9956079fdbeSAdrian Chadd 	}
9966079fdbeSAdrian Chadd #endif
997b69b0dccSAdrian Chadd 
998f78d5b7eSKevin Lo #ifdef	ATH_DEBUG_ALQ
999b69b0dccSAdrian Chadd 	ath_sysctl_alq_attach(sc);
1000b69b0dccSAdrian Chadd #endif
10016079fdbeSAdrian Chadd }
10026079fdbeSAdrian Chadd 
10036079fdbeSAdrian Chadd static int
ath_sysctl_clearstats(SYSCTL_HANDLER_ARGS)10046079fdbeSAdrian Chadd ath_sysctl_clearstats(SYSCTL_HANDLER_ARGS)
10056079fdbeSAdrian Chadd {
10066079fdbeSAdrian Chadd 	struct ath_softc *sc = arg1;
10076079fdbeSAdrian Chadd 	int val = 0;
10086079fdbeSAdrian Chadd 	int error;
10096079fdbeSAdrian Chadd 
10106079fdbeSAdrian Chadd 	error = sysctl_handle_int(oidp, &val, 0, req);
10116079fdbeSAdrian Chadd 	if (error || !req->newptr)
10126079fdbeSAdrian Chadd 		return error;
10136079fdbeSAdrian Chadd 	if (val == 0)
10146079fdbeSAdrian Chadd 		return 0;       /* Not clearing the stats is still valid */
10156079fdbeSAdrian Chadd 	memset(&sc->sc_stats, 0, sizeof(sc->sc_stats));
10163dd85b26SAdrian Chadd 	memset(&sc->sc_aggr_stats, 0, sizeof(sc->sc_aggr_stats));
10179467e3f3SAdrian Chadd 	memset(&sc->sc_intr_stats, 0, sizeof(sc->sc_intr_stats));
10183dd85b26SAdrian Chadd 
10196079fdbeSAdrian Chadd 	val = 0;
10206079fdbeSAdrian Chadd 	return 0;
10216079fdbeSAdrian Chadd }
10226079fdbeSAdrian Chadd 
10236079fdbeSAdrian Chadd static void
ath_sysctl_stats_attach_rxphyerr(struct ath_softc * sc,struct sysctl_oid_list * parent)10246079fdbeSAdrian Chadd ath_sysctl_stats_attach_rxphyerr(struct ath_softc *sc, struct sysctl_oid_list *parent)
10256079fdbeSAdrian Chadd {
10266079fdbeSAdrian Chadd 	struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
10276079fdbeSAdrian Chadd 	struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
10286079fdbeSAdrian Chadd 	struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
10296079fdbeSAdrian Chadd 	int i;
10306079fdbeSAdrian Chadd 	char sn[8];
10316079fdbeSAdrian Chadd 
103208f5e6bbSPawel Biernacki 	tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "rx_phy_err",
103308f5e6bbSPawel Biernacki 	    CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Per-code RX PHY Errors");
10346079fdbeSAdrian Chadd 	child = SYSCTL_CHILDREN(tree);
10356079fdbeSAdrian Chadd 	for (i = 0; i < 64; i++) {
10366079fdbeSAdrian Chadd 		snprintf(sn, sizeof(sn), "%d", i);
10376079fdbeSAdrian Chadd 		SYSCTL_ADD_UINT(ctx, child, OID_AUTO, sn, CTLFLAG_RD, &sc->sc_stats.ast_rx_phy[i], 0, "");
10386079fdbeSAdrian Chadd 	}
10396079fdbeSAdrian Chadd }
10406079fdbeSAdrian Chadd 
10419467e3f3SAdrian Chadd static void
ath_sysctl_stats_attach_intr(struct ath_softc * sc,struct sysctl_oid_list * parent)10429467e3f3SAdrian Chadd ath_sysctl_stats_attach_intr(struct ath_softc *sc,
10439467e3f3SAdrian Chadd     struct sysctl_oid_list *parent)
10449467e3f3SAdrian Chadd {
10459467e3f3SAdrian Chadd 	struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
10469467e3f3SAdrian Chadd 	struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
10479467e3f3SAdrian Chadd 	struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
10489467e3f3SAdrian Chadd 	int i;
10499467e3f3SAdrian Chadd 	char sn[8];
10509467e3f3SAdrian Chadd 
10519467e3f3SAdrian Chadd 	tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "sync_intr",
105208f5e6bbSPawel Biernacki 	    CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Sync interrupt statistics");
10539467e3f3SAdrian Chadd 	child = SYSCTL_CHILDREN(tree);
10549467e3f3SAdrian Chadd 	for (i = 0; i < 32; i++) {
10559467e3f3SAdrian Chadd 		snprintf(sn, sizeof(sn), "%d", i);
10569467e3f3SAdrian Chadd 		SYSCTL_ADD_UINT(ctx, child, OID_AUTO, sn, CTLFLAG_RD,
10579467e3f3SAdrian Chadd 		    &sc->sc_intr_stats.sync_intr[i], 0, "");
10589467e3f3SAdrian Chadd 	}
10599467e3f3SAdrian Chadd }
10609467e3f3SAdrian Chadd 
10616079fdbeSAdrian Chadd void
ath_sysctl_stats_attach(struct ath_softc * sc)10626079fdbeSAdrian Chadd ath_sysctl_stats_attach(struct ath_softc *sc)
10636079fdbeSAdrian Chadd {
10646079fdbeSAdrian Chadd 	struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
10656079fdbeSAdrian Chadd 	struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
10666079fdbeSAdrian Chadd 	struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
10676079fdbeSAdrian Chadd 
10686079fdbeSAdrian Chadd 	/* Create "clear" node */
10696079fdbeSAdrian Chadd 	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
107008f5e6bbSPawel Biernacki 	    "clear_stats", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc,
107108f5e6bbSPawel Biernacki 	    0, ath_sysctl_clearstats, "I", "clear stats");
10726079fdbeSAdrian Chadd 
10736079fdbeSAdrian Chadd 	/* Create stats node */
107408f5e6bbSPawel Biernacki 	tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats",
107508f5e6bbSPawel Biernacki 	    CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Statistics");
10766079fdbeSAdrian Chadd 	child = SYSCTL_CHILDREN(tree);
10776079fdbeSAdrian Chadd 
10786079fdbeSAdrian Chadd 	/* This was generated from if_athioctl.h */
10796079fdbeSAdrian Chadd 
10806079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_watchdog", CTLFLAG_RD,
10816079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_watchdog, 0, "device reset by watchdog");
10826079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_hardware", CTLFLAG_RD,
10836079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_hardware, 0, "fatal hardware error interrupts");
10846079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_bmiss", CTLFLAG_RD,
10856079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_bmiss, 0, "beacon miss interrupts");
10866079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_bmiss_phantom", CTLFLAG_RD,
10876079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_bmiss_phantom, 0, "beacon miss interrupts");
10886079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_bstuck", CTLFLAG_RD,
10896079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_bstuck, 0, "beacon stuck interrupts");
10906079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rxorn", CTLFLAG_RD,
10916079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rxorn, 0, "rx overrun interrupts");
10926079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rxeol", CTLFLAG_RD,
10936079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rxeol, 0, "rx eol interrupts");
10946079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_txurn", CTLFLAG_RD,
10956079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_txurn, 0, "tx underrun interrupts");
10966079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_mib", CTLFLAG_RD,
10976079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_mib, 0, "mib interrupts");
10986079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_intrcoal", CTLFLAG_RD,
10996079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_intrcoal, 0, "interrupts coalesced");
11006079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_packets", CTLFLAG_RD,
11016079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_packets, 0, "packet sent on the interface");
11026079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_mgmt", CTLFLAG_RD,
11036079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_mgmt, 0, "management frames transmitted");
11046079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_discard", CTLFLAG_RD,
11056079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_discard, 0, "frames discarded prior to assoc");
11066079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_qstop", CTLFLAG_RD,
11076079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_qstop, 0, "output stopped 'cuz no buffer");
11086079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_encap", CTLFLAG_RD,
11096079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_encap, 0, "tx encapsulation failed");
11106079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nonode", CTLFLAG_RD,
11116079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_nonode, 0, "tx failed 'cuz no node");
11126079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nombuf", CTLFLAG_RD,
11136079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_nombuf, 0, "tx failed 'cuz no mbuf");
11146079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nomcl", CTLFLAG_RD,
11156079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_nomcl, 0, "tx failed 'cuz no cluster");
11166079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_linear", CTLFLAG_RD,
11176079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_linear, 0, "tx linearized to cluster");
11186079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nodata", CTLFLAG_RD,
11196079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_nodata, 0, "tx discarded empty frame");
11206079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_busdma", CTLFLAG_RD,
11216079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_busdma, 0, "tx failed for dma resrcs");
11226079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_xretries", CTLFLAG_RD,
11236079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_xretries, 0, "tx failed 'cuz too many retries");
11246079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_fifoerr", CTLFLAG_RD,
11256079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_fifoerr, 0, "tx failed 'cuz FIFO underrun");
11266079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_filtered", CTLFLAG_RD,
11276079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_filtered, 0, "tx failed 'cuz xmit filtered");
11286079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_shortretry", CTLFLAG_RD,
11296079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_shortretry, 0, "tx on-chip retries (short)");
11306079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_longretry", CTLFLAG_RD,
11316079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_longretry, 0, "tx on-chip retries (long)");
11326079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_badrate", CTLFLAG_RD,
11336079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_badrate, 0, "tx failed 'cuz bogus xmit rate");
11346079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_noack", CTLFLAG_RD,
11356079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_noack, 0, "tx frames with no ack marked");
11366079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_rts", CTLFLAG_RD,
11376079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_rts, 0, "tx frames with rts enabled");
11386079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_cts", CTLFLAG_RD,
11396079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_cts, 0, "tx frames with cts enabled");
11406079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_shortpre", CTLFLAG_RD,
11416079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_shortpre, 0, "tx frames with short preamble");
11426079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_altrate", CTLFLAG_RD,
11436079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_altrate, 0, "tx frames with alternate rate");
11446079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_protect", CTLFLAG_RD,
11456079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_protect, 0, "tx frames with protection");
11466079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_ctsburst", CTLFLAG_RD,
11476079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_ctsburst, 0, "tx frames with cts and bursting");
11486079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_ctsext", CTLFLAG_RD,
11496079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_ctsext, 0, "tx frames with cts extension");
11506079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_nombuf", CTLFLAG_RD,
11516079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_nombuf, 0, "rx setup failed 'cuz no mbuf");
11526079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_busdma", CTLFLAG_RD,
11536079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_busdma, 0, "rx setup failed for dma resrcs");
11546079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_orn", CTLFLAG_RD,
11556079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_orn, 0, "rx failed 'cuz of desc overrun");
11566079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_crcerr", CTLFLAG_RD,
11576079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_crcerr, 0, "rx failed 'cuz of bad CRC");
11586079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_fifoerr", CTLFLAG_RD,
11596079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_fifoerr, 0, "rx failed 'cuz of FIFO overrun");
11606079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_badcrypt", CTLFLAG_RD,
11616079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_badcrypt, 0, "rx failed 'cuz decryption");
11626079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_badmic", CTLFLAG_RD,
11636079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_badmic, 0, "rx failed 'cuz MIC failure");
11646079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_phyerr", CTLFLAG_RD,
11656079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_phyerr, 0, "rx failed 'cuz of PHY err");
11666079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_tooshort", CTLFLAG_RD,
11676079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_tooshort, 0, "rx discarded 'cuz frame too short");
11686079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_toobig", CTLFLAG_RD,
11696079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_toobig, 0, "rx discarded 'cuz frame too large");
11706079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_packets", CTLFLAG_RD,
11716079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_packets, 0, "packet recv on the interface");
11726079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_mgt", CTLFLAG_RD,
11736079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_mgt, 0, "management frames received");
11746079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_ctl", CTLFLAG_RD,
11756079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_ctl, 0, "rx discarded 'cuz ctl frame");
11766079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_be_xmit", CTLFLAG_RD,
11776079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_be_xmit, 0, "beacons transmitted");
11786079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_be_nombuf", CTLFLAG_RD,
11796079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_be_nombuf, 0, "beacon setup failed 'cuz no mbuf");
11806079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_per_cal", CTLFLAG_RD,
11816079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_per_cal, 0, "periodic calibration calls");
11826079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_per_calfail", CTLFLAG_RD,
11836079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_per_calfail, 0, "periodic calibration failed");
11846079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_per_rfgain", CTLFLAG_RD,
11856079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_per_rfgain, 0, "periodic calibration rfgain reset");
11866079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rate_calls", CTLFLAG_RD,
11876079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rate_calls, 0, "rate control checks");
11886079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rate_raise", CTLFLAG_RD,
11896079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rate_raise, 0, "rate control raised xmit rate");
11906079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rate_drop", CTLFLAG_RD,
11916079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rate_drop, 0, "rate control dropped xmit rate");
11926079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ant_defswitch", CTLFLAG_RD,
11936079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_ant_defswitch, 0, "rx/default antenna switches");
11946079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ant_txswitch", CTLFLAG_RD,
11956079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_ant_txswitch, 0, "tx antenna switches");
11966079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_cabq_xmit", CTLFLAG_RD,
11976079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_cabq_xmit, 0, "cabq frames transmitted");
11986079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_cabq_busy", CTLFLAG_RD,
11996079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_cabq_busy, 0, "cabq found busy");
12006079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_raw", CTLFLAG_RD,
12016079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_raw, 0, "tx frames through raw api");
12026079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ff_txok", CTLFLAG_RD,
12036079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_ff_txok, 0, "fast frames tx'd successfully");
12046079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ff_txerr", CTLFLAG_RD,
12056079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_ff_txerr, 0, "fast frames tx'd w/ error");
12066079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ff_rx", CTLFLAG_RD,
12076079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_ff_rx, 0, "fast frames rx'd");
12086079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ff_flush", CTLFLAG_RD,
12096079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_ff_flush, 0, "fast frames flushed from staging q");
12106079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_qfull", CTLFLAG_RD,
12116079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_qfull, 0, "tx dropped 'cuz of queue limit");
12126079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nobuf", CTLFLAG_RD,
12136079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_nobuf, 0, "tx dropped 'cuz no ath buffer");
12146079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tdma_update", CTLFLAG_RD,
12156079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tdma_update, 0, "TDMA slot timing updates");
12166079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tdma_timers", CTLFLAG_RD,
12176079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tdma_timers, 0, "TDMA slot update set beacon timers");
12186079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tdma_tsf", CTLFLAG_RD,
12196079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tdma_tsf, 0, "TDMA slot update set TSF");
12206079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tdma_ack", CTLFLAG_RD,
12216079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tdma_ack, 0, "TDMA tx failed 'cuz ACK required");
12226079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_raw_fail", CTLFLAG_RD,
12236079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_raw_fail, 0, "raw tx failed 'cuz h/w down");
12246079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nofrag", CTLFLAG_RD,
12256079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_nofrag, 0, "tx dropped 'cuz no ath frag buffer");
12266079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_be_missed", CTLFLAG_RD,
12276079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_be_missed, 0, "number of -missed- beacons");
12286079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ani_cal", CTLFLAG_RD,
12296079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_ani_cal, 0, "number of ANI polls");
12306079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_agg", CTLFLAG_RD,
12316079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_agg, 0, "number of aggregate frames received");
12326079fdbeSAdrian Chadd 
12336079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_halfgi", CTLFLAG_RD,
12346079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_halfgi, 0, "number of frames received with half-GI");
12356079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_2040", CTLFLAG_RD,
12366079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_2040, 0, "number of HT/40 frames received");
12376079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_pre_crc_err", CTLFLAG_RD,
1238e4b7980cSGordon Bergling 	    &sc->sc_stats.ast_rx_pre_crc_err, 0, "number of delimiter-CRC errors detected");
12396079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_post_crc_err", CTLFLAG_RD,
12406079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_post_crc_err, 0, "number of post-delimiter CRC errors detected");
12416079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_decrypt_busy_err", CTLFLAG_RD,
12426079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_decrypt_busy_err, 0, "number of frames received w/ busy decrypt engine");
12436079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_hi_rx_chain", CTLFLAG_RD,
12446079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_rx_hi_rx_chain, 0, "");
12456079fdbeSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_htprotect", CTLFLAG_RD,
12466079fdbeSAdrian Chadd 	    &sc->sc_stats.ast_tx_htprotect, 0, "HT tx frames with protection");
1247f77057dbSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_hitqueueend", CTLFLAG_RD,
1248f77057dbSAdrian Chadd 	    &sc->sc_stats.ast_rx_hitqueueend, 0, "RX hit queue end");
12496ad02dbaSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_timeout", CTLFLAG_RD,
12506ad02dbaSAdrian Chadd 	    &sc->sc_stats.ast_tx_timeout, 0, "TX Global Timeout");
12515594f5c0SAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_cst", CTLFLAG_RD,
12525594f5c0SAdrian Chadd 	    &sc->sc_stats.ast_tx_cst, 0, "TX Carrier Sense Timeout");
1253e9d1191fSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_xtxop", CTLFLAG_RD,
1254e9d1191fSAdrian Chadd 	    &sc->sc_stats.ast_tx_xtxop, 0, "TX exceeded TXOP");
1255e9d1191fSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_timerexpired", CTLFLAG_RD,
1256e9d1191fSAdrian Chadd 	    &sc->sc_stats.ast_tx_timerexpired, 0, "TX exceeded TX_TIMER register");
1257e9d1191fSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_desccfgerr", CTLFLAG_RD,
1258e9d1191fSAdrian Chadd 	    &sc->sc_stats.ast_tx_desccfgerr, 0, "TX Descriptor Cfg Error");
1259b390e40aSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_swretries", CTLFLAG_RD,
1260b390e40aSAdrian Chadd 	    &sc->sc_stats.ast_tx_swretries, 0, "TX software retry count");
1261b390e40aSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_swretrymax", CTLFLAG_RD,
1262b390e40aSAdrian Chadd 	    &sc->sc_stats.ast_tx_swretrymax, 0, "TX software retry max reached");
1263b390e40aSAdrian Chadd 
1264b390e40aSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_data_underrun", CTLFLAG_RD,
1265b390e40aSAdrian Chadd 	    &sc->sc_stats.ast_tx_data_underrun, 0, "");
1266b390e40aSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_delim_underrun", CTLFLAG_RD,
1267b390e40aSAdrian Chadd 	    &sc->sc_stats.ast_tx_delim_underrun, 0, "");
12682d3d4776SAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_aggr_failall", CTLFLAG_RD,
12692d3d4776SAdrian Chadd 	    &sc->sc_stats.ast_tx_aggr_failall, 0,
1270b390e40aSAdrian Chadd 	    "Number of aggregate TX failures (whole frame)");
12712d3d4776SAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_aggr_ok", CTLFLAG_RD,
12722d3d4776SAdrian Chadd 	    &sc->sc_stats.ast_tx_aggr_ok, 0,
12732d3d4776SAdrian Chadd 	    "Number of aggregate TX OK completions (subframe)");
12742d3d4776SAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_aggr_fail", CTLFLAG_RD,
12752d3d4776SAdrian Chadd 	    &sc->sc_stats.ast_tx_aggr_fail, 0,
12762d3d4776SAdrian Chadd 	    "Number of aggregate TX failures (subframe)");
1277b390e40aSAdrian Chadd 
1278b390e40aSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_intr", CTLFLAG_RD,
1279b390e40aSAdrian Chadd 	    &sc->sc_stats.ast_rx_intr, 0, "RX interrupts");
1280b390e40aSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_intr", CTLFLAG_RD,
1281b390e40aSAdrian Chadd 	    &sc->sc_stats.ast_tx_intr, 0, "TX interrupts");
12829c85ff91SAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_mcastq_overflow",
12839c85ff91SAdrian Chadd 	    CTLFLAG_RD, &sc->sc_stats.ast_tx_mcastq_overflow, 0,
12849c85ff91SAdrian Chadd 	    "Number of multicast frames exceeding maximum mcast queue depth");
1285c7f5bb7aSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_keymiss", CTLFLAG_RD,
1286c7f5bb7aSAdrian Chadd 	    &sc->sc_stats.ast_rx_keymiss, 0, "");
1287f1bc738eSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_swfiltered", CTLFLAG_RD,
1288f1bc738eSAdrian Chadd 	    &sc->sc_stats.ast_tx_swfiltered, 0, "");
1289729ecfbbSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nodeq_overflow",
1290729ecfbbSAdrian Chadd 	    CTLFLAG_RD, &sc->sc_stats.ast_tx_nodeq_overflow, 0,
1291729ecfbbSAdrian Chadd 	    "tx dropped 'cuz nodeq overflow");
12922c47932cSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_stbc",
12932c47932cSAdrian Chadd 	    CTLFLAG_RD, &sc->sc_stats.ast_rx_stbc, 0,
12942c47932cSAdrian Chadd 	    "Number of STBC frames received");
12953c6b488bSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_stbc",
12963c6b488bSAdrian Chadd 	    CTLFLAG_RD, &sc->sc_stats.ast_tx_stbc, 0,
12973c6b488bSAdrian Chadd 	    "Number of STBC frames transmitted");
12983c6b488bSAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_ldpc",
12993c6b488bSAdrian Chadd 	    CTLFLAG_RD, &sc->sc_stats.ast_tx_ldpc, 0,
13003c6b488bSAdrian Chadd 	    "Number of LDPC frames transmitted");
13016079fdbeSAdrian Chadd 
13021ca39968SAdrian Chadd 	SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tsfoor",
13031ca39968SAdrian Chadd 	    CTLFLAG_RD, &sc->sc_stats.ast_tsfoor, 0,
13041ca39968SAdrian Chadd 	    "Number of TSF out of range interrupts/resets");
13051ca39968SAdrian Chadd 
13066079fdbeSAdrian Chadd 	/* Attach the RX phy error array */
13076079fdbeSAdrian Chadd 	ath_sysctl_stats_attach_rxphyerr(sc, child);
13089467e3f3SAdrian Chadd 
13099467e3f3SAdrian Chadd 	/* Attach the interrupt statistics array */
13109467e3f3SAdrian Chadd 	ath_sysctl_stats_attach_intr(sc, child);
13116079fdbeSAdrian Chadd }
131237931a35SAdrian Chadd 
131337931a35SAdrian Chadd /*
131437931a35SAdrian Chadd  * This doesn't necessarily belong here (because it's HAL related, not
131537931a35SAdrian Chadd  * driver related).
131637931a35SAdrian Chadd  */
131737931a35SAdrian Chadd void
ath_sysctl_hal_attach(struct ath_softc * sc)131837931a35SAdrian Chadd ath_sysctl_hal_attach(struct ath_softc *sc)
131937931a35SAdrian Chadd {
132037931a35SAdrian Chadd 	struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
132137931a35SAdrian Chadd 	struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
132237931a35SAdrian Chadd 	struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
132337931a35SAdrian Chadd 
132408f5e6bbSPawel Biernacki 	tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "hal",
132508f5e6bbSPawel Biernacki 	    CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Atheros HAL parameters");
132637931a35SAdrian Chadd 	child = SYSCTL_CHILDREN(tree);
132737931a35SAdrian Chadd 
132837931a35SAdrian Chadd 	sc->sc_ah->ah_config.ah_debug = 0;
132937931a35SAdrian Chadd 	SYSCTL_ADD_INT(ctx, child, OID_AUTO, "debug", CTLFLAG_RW,
133037931a35SAdrian Chadd 	    &sc->sc_ah->ah_config.ah_debug, 0, "Atheros HAL debugging printfs");
133137931a35SAdrian Chadd 
133237931a35SAdrian Chadd 	sc->sc_ah->ah_config.ah_ar5416_biasadj = 0;
133337931a35SAdrian Chadd 	SYSCTL_ADD_INT(ctx, child, OID_AUTO, "ar5416_biasadj", CTLFLAG_RW,
133437931a35SAdrian Chadd 	    &sc->sc_ah->ah_config.ah_ar5416_biasadj, 0,
13351748d1e5SGavin Atkinson 	    "Enable 2GHz AR5416 direction sensitivity bias adjust");
133637931a35SAdrian Chadd 
133737931a35SAdrian Chadd 	sc->sc_ah->ah_config.ah_dma_beacon_response_time = 2;
133837931a35SAdrian Chadd 	SYSCTL_ADD_INT(ctx, child, OID_AUTO, "dma_brt", CTLFLAG_RW,
133937931a35SAdrian Chadd 	    &sc->sc_ah->ah_config.ah_dma_beacon_response_time, 0,
134037931a35SAdrian Chadd 	    "Atheros HAL DMA beacon response time");
134137931a35SAdrian Chadd 
134237931a35SAdrian Chadd 	sc->sc_ah->ah_config.ah_sw_beacon_response_time = 10;
134337931a35SAdrian Chadd 	SYSCTL_ADD_INT(ctx, child, OID_AUTO, "sw_brt", CTLFLAG_RW,
134437931a35SAdrian Chadd 	    &sc->sc_ah->ah_config.ah_sw_beacon_response_time, 0,
134537931a35SAdrian Chadd 	    "Atheros HAL software beacon response time");
134637931a35SAdrian Chadd 
134737931a35SAdrian Chadd 	sc->sc_ah->ah_config.ah_additional_swba_backoff = 0;
134837931a35SAdrian Chadd 	SYSCTL_ADD_INT(ctx, child, OID_AUTO, "swba_backoff", CTLFLAG_RW,
134937931a35SAdrian Chadd 	    &sc->sc_ah->ah_config.ah_additional_swba_backoff, 0,
135037931a35SAdrian Chadd 	    "Atheros HAL additional SWBA backoff time");
1351d3054f72SAdrian Chadd 
1352d3054f72SAdrian Chadd 	sc->sc_ah->ah_config.ah_force_full_reset = 0;
1353d3054f72SAdrian Chadd 	SYSCTL_ADD_INT(ctx, child, OID_AUTO, "force_full_reset", CTLFLAG_RW,
1354d3054f72SAdrian Chadd 	    &sc->sc_ah->ah_config.ah_force_full_reset, 0,
1355d3054f72SAdrian Chadd 	    "Force full chip reset rather than a warm reset");
1356ddbe3036SAdrian Chadd 
1357ddbe3036SAdrian Chadd 	/*
1358ddbe3036SAdrian Chadd 	 * This is initialised by the driver.
1359ddbe3036SAdrian Chadd 	 */
1360ddbe3036SAdrian Chadd 	SYSCTL_ADD_INT(ctx, child, OID_AUTO, "serialise_reg_war", CTLFLAG_RW,
1361ddbe3036SAdrian Chadd 	    &sc->sc_ah->ah_config.ah_serialise_reg_war, 0,
1362ddbe3036SAdrian Chadd 	    "Force register access serialisation");
136337931a35SAdrian Chadd }
1364