Home | History | Annotate | Line # | Download | only in ic
ath_netbsd.c revision 1.2
      1  1.1  dyoung /*-
      2  1.1  dyoung  * Copyright (c) 2003, 2004 David Young
      3  1.1  dyoung  * All rights reserved.
      4  1.1  dyoung  *
      5  1.1  dyoung  * Redistribution and use in source and binary forms, with or without
      6  1.1  dyoung  * modification, are permitted provided that the following conditions
      7  1.1  dyoung  * are met:
      8  1.1  dyoung  * 1. Redistributions of source code must retain the above copyright
      9  1.1  dyoung  *    notice, this list of conditions and the following disclaimer.
     10  1.1  dyoung  * 2. Redistributions in binary form must reproduce the above copyright
     11  1.1  dyoung  *    notice, this list of conditions and the following disclaimer in the
     12  1.1  dyoung  *    documentation and/or other materials provided with the distribution.
     13  1.1  dyoung  * 3. The name of the author may not be used to endorse or promote products
     14  1.1  dyoung  *    derived from this software without specific prior written permission.
     15  1.1  dyoung  *
     16  1.1  dyoung  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  1.1  dyoung  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  1.1  dyoung  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  1.1  dyoung  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  1.1  dyoung  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21  1.1  dyoung  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22  1.1  dyoung  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23  1.1  dyoung  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24  1.1  dyoung  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25  1.1  dyoung  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26  1.1  dyoung  */
     27  1.1  dyoung #include <sys/param.h>
     28  1.1  dyoung #include <sys/types.h>
     29  1.1  dyoung #include <sys/errno.h>
     30  1.1  dyoung #include <sys/systm.h>
     31  1.1  dyoung #include <sys/sysctl.h>
     32  1.1  dyoung #include <sys/mbuf.h>
     33  1.1  dyoung #include <sys/malloc.h>
     34  1.1  dyoung #include <sys/lock.h>
     35  1.1  dyoung #include <sys/kernel.h>
     36  1.1  dyoung #include <sys/socket.h>
     37  1.1  dyoung #include <sys/sockio.h>
     38  1.1  dyoung #include <sys/sysctl.h>
     39  1.1  dyoung #include <sys/callout.h>
     40  1.1  dyoung #include <machine/bus.h>
     41  1.1  dyoung #include <machine/stdarg.h>
     42  1.1  dyoung #include <sys/endian.h>
     43  1.2  martin #include <sys/device.h>
     44  1.1  dyoung 
     45  1.1  dyoung #include <net/if.h>
     46  1.1  dyoung #include <net/if_dl.h>
     47  1.1  dyoung #include <net/if_media.h>
     48  1.1  dyoung #include <net/if_arp.h>
     49  1.1  dyoung #include <net/if_ether.h>
     50  1.1  dyoung #include <net/if_llc.h>
     51  1.1  dyoung 
     52  1.1  dyoung #include <net80211/ieee80211_netbsd.h>
     53  1.1  dyoung #include <net80211/ieee80211_var.h>
     54  1.1  dyoung #include <dev/ic/ath_netbsd.h>
     55  1.1  dyoung #include <dev/ic/athvar.h>
     56  1.1  dyoung 
     57  1.1  dyoung void
     58  1.1  dyoung device_printf(struct device dv, const char *fmt, ...)
     59  1.1  dyoung {
     60  1.1  dyoung         va_list ap;
     61  1.1  dyoung 
     62  1.1  dyoung         va_start(ap, fmt);
     63  1.1  dyoung         printf("%s: ", dv.dv_xname);
     64  1.1  dyoung         vprintf(fmt, ap);
     65  1.1  dyoung         va_end(ap);
     66  1.1  dyoung 	return;
     67  1.1  dyoung }
     68  1.1  dyoung 
     69  1.1  dyoung struct mbuf *
     70  1.1  dyoung m_defrag(struct mbuf *m0, int flags)
     71  1.1  dyoung {
     72  1.1  dyoung 	struct mbuf *m;
     73  1.1  dyoung 	MGETHDR(m, flags, MT_DATA);
     74  1.1  dyoung 	if (m == NULL)
     75  1.1  dyoung 		return NULL;
     76  1.1  dyoung 
     77  1.1  dyoung 	M_COPY_PKTHDR(m, m0);
     78  1.1  dyoung 	MCLGET(m, flags);
     79  1.1  dyoung 	if ((m->m_flags & M_EXT) == 0) {
     80  1.1  dyoung 		m_free(m);
     81  1.1  dyoung 		return NULL;
     82  1.1  dyoung 	}
     83  1.1  dyoung 	m_copydata(m0, 0, m0->m_pkthdr.len, mtod(m, caddr_t));
     84  1.1  dyoung 	m->m_len = m->m_pkthdr.len;
     85  1.1  dyoung 	return m;
     86  1.1  dyoung }
     87  1.1  dyoung 
     88  1.1  dyoung /*
     89  1.1  dyoung  * Setup sysctl(3) MIB, ath.*.
     90  1.1  dyoung  *
     91  1.1  dyoung  * TBD condition CTLFLAG_PERMANENT on being an LKM or not
     92  1.1  dyoung  */
     93  1.1  dyoung SYSCTL_SETUP(sysctl_ath, "sysctl ath subtree setup")
     94  1.1  dyoung {
     95  1.1  dyoung 	int rc;
     96  1.1  dyoung 	const struct sysctlnode *cnode, *rnode;
     97  1.1  dyoung 
     98  1.1  dyoung 	if ((rnode = ath_sysctl_treetop(clog)) == NULL)
     99  1.1  dyoung 		return;
    100  1.1  dyoung 
    101  1.1  dyoung 	if ((rc = SYSCTL_GLOBAL_INT(CTLFLAG_READWRITE, "dwell",
    102  1.1  dyoung 	    "channel dwell time (ms) for AP/station scanning",
    103  1.1  dyoung 	    dwelltime)) != 0)
    104  1.1  dyoung 		goto err;
    105  1.1  dyoung 
    106  1.1  dyoung 	if ((rc = SYSCTL_GLOBAL_INT(CTLFLAG_READWRITE, "calibrate",
    107  1.1  dyoung 	    "chip calibration interval (secs)", calinterval)) != 0)
    108  1.1  dyoung 		goto err;
    109  1.1  dyoung 
    110  1.1  dyoung 	if ((rc = SYSCTL_GLOBAL_INT(CTLFLAG_READWRITE, "outdoor",
    111  1.1  dyoung 	    "outdoor operation", outdoor)) != 0)
    112  1.1  dyoung 		goto err;
    113  1.1  dyoung 
    114  1.1  dyoung 	/* country code */
    115  1.1  dyoung 	if ((rc = SYSCTL_GLOBAL_INT(CTLFLAG_READWRITE,
    116  1.1  dyoung 	    "countrycode", "country code", countrycode)) != 0)
    117  1.1  dyoung 		goto err;
    118  1.1  dyoung 
    119  1.1  dyoung 	/* regulatory domain */
    120  1.1  dyoung 	if ((rc = SYSCTL_GLOBAL_INT(CTLFLAG_READONLY, "regdomain",
    121  1.1  dyoung 	    "regulatory domain", regdomain)) != 0)
    122  1.1  dyoung 		goto err;
    123  1.1  dyoung 
    124  1.1  dyoung 	if ((rc = SYSCTL_GLOBAL_INT(CTLFLAG_READWRITE, "debug",
    125  1.1  dyoung 	    "control debugging printfs", debug)) != 0)
    126  1.1  dyoung 		goto err;
    127  1.1  dyoung 
    128  1.1  dyoung 	return;
    129  1.1  dyoung err:
    130  1.1  dyoung 	printf("%s: sysctl_createv failed (rc = %d)\n", __func__, rc);
    131  1.1  dyoung }
    132  1.1  dyoung 
    133  1.1  dyoung static int
    134  1.1  dyoung ath_sysctl_slottime(SYSCTLFN_ARGS)
    135  1.1  dyoung {
    136  1.1  dyoung 	struct ath_softc *sc;
    137  1.1  dyoung 	struct sysctlnode node;
    138  1.1  dyoung 	u_int slottime;
    139  1.1  dyoung 	int error;
    140  1.1  dyoung 
    141  1.1  dyoung 	node = *rnode;
    142  1.1  dyoung 	sc = (struct ath_softc *)node.sysctl_data;
    143  1.1  dyoung 	slottime = ath_hal_getslottime(sc->sc_ah);
    144  1.1  dyoung 	node.sysctl_data = &slottime;
    145  1.1  dyoung 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
    146  1.1  dyoung 	if (error || newp == NULL)
    147  1.1  dyoung 		return error;
    148  1.1  dyoung 	return !ath_hal_setslottime(sc->sc_ah, slottime) ? EINVAL : 0;
    149  1.1  dyoung }
    150  1.1  dyoung 
    151  1.1  dyoung static int
    152  1.1  dyoung ath_sysctl_acktimeout(SYSCTLFN_ARGS)
    153  1.1  dyoung {
    154  1.1  dyoung 	struct ath_softc *sc;
    155  1.1  dyoung 	struct sysctlnode node;
    156  1.1  dyoung 	u_int acktimeout;
    157  1.1  dyoung 	int error;
    158  1.1  dyoung 
    159  1.1  dyoung 	node = *rnode;
    160  1.1  dyoung 	sc = (struct ath_softc *)node.sysctl_data;
    161  1.1  dyoung 	acktimeout = ath_hal_getacktimeout(sc->sc_ah);
    162  1.1  dyoung 	node.sysctl_data = &acktimeout;
    163  1.1  dyoung 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
    164  1.1  dyoung 	if (error || newp == NULL)
    165  1.1  dyoung 		return error;
    166  1.1  dyoung 	return !ath_hal_setacktimeout(sc->sc_ah, acktimeout) ? EINVAL : 0;
    167  1.1  dyoung }
    168  1.1  dyoung 
    169  1.1  dyoung static int
    170  1.1  dyoung ath_sysctl_ctstimeout(SYSCTLFN_ARGS)
    171  1.1  dyoung {
    172  1.1  dyoung 	struct ath_softc *sc;
    173  1.1  dyoung 	struct sysctlnode node;
    174  1.1  dyoung 	u_int ctstimeout;
    175  1.1  dyoung 	int error;
    176  1.1  dyoung 
    177  1.1  dyoung 	node = *rnode;
    178  1.1  dyoung 	sc = (struct ath_softc *)node.sysctl_data;
    179  1.1  dyoung 	ctstimeout = ath_hal_getctstimeout(sc->sc_ah);
    180  1.1  dyoung 	node.sysctl_data = &ctstimeout;
    181  1.1  dyoung 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
    182  1.1  dyoung 	if (error || newp == NULL)
    183  1.1  dyoung 		return error;
    184  1.1  dyoung 	return !ath_hal_setctstimeout(sc->sc_ah, ctstimeout) ? EINVAL : 0;
    185  1.1  dyoung }
    186  1.1  dyoung 
    187  1.1  dyoung static int
    188  1.1  dyoung ath_sysctl_softled(SYSCTLFN_ARGS)
    189  1.1  dyoung {
    190  1.1  dyoung 	struct ath_softc *sc;
    191  1.1  dyoung 	struct sysctlnode node;
    192  1.1  dyoung 	int softled;
    193  1.1  dyoung 	int error;
    194  1.1  dyoung 
    195  1.1  dyoung 	node = *rnode;
    196  1.1  dyoung 	sc = (struct ath_softc *)node.sysctl_data;
    197  1.1  dyoung 	softled = sc->sc_softled;
    198  1.1  dyoung 	node.sysctl_data = &softled;
    199  1.1  dyoung 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
    200  1.1  dyoung 	if (error || newp == NULL)
    201  1.1  dyoung 		return error;
    202  1.1  dyoung 	softled = (softled != 0);
    203  1.1  dyoung 	if (softled != sc->sc_softled) {
    204  1.1  dyoung 		if (softled) {
    205  1.1  dyoung 			/* NB: handle any sc_ledpin change */
    206  1.1  dyoung 			ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin);
    207  1.1  dyoung 			ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin,
    208  1.1  dyoung 				!sc->sc_ledon);
    209  1.1  dyoung 		}
    210  1.1  dyoung 		sc->sc_softled = softled;
    211  1.1  dyoung 	}
    212  1.1  dyoung 	return 0;
    213  1.1  dyoung }
    214  1.1  dyoung 
    215  1.1  dyoung static int
    216  1.1  dyoung ath_sysctl_rxantenna(SYSCTLFN_ARGS)
    217  1.1  dyoung {
    218  1.1  dyoung 	struct ath_softc *sc;
    219  1.1  dyoung 	struct sysctlnode node;
    220  1.1  dyoung 	u_int defantenna;
    221  1.1  dyoung 	int error;
    222  1.1  dyoung 
    223  1.1  dyoung 	node = *rnode;
    224  1.1  dyoung 	sc = (struct ath_softc *)node.sysctl_data;
    225  1.1  dyoung 	defantenna = ath_hal_getdefantenna(sc->sc_ah);
    226  1.1  dyoung 	node.sysctl_data = &defantenna;
    227  1.1  dyoung 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
    228  1.1  dyoung 	if (error || newp == NULL)
    229  1.1  dyoung 		return error;
    230  1.1  dyoung 	ath_hal_setdefantenna(sc->sc_ah, defantenna);
    231  1.1  dyoung 	return 0;
    232  1.1  dyoung }
    233  1.1  dyoung 
    234  1.1  dyoung static int
    235  1.1  dyoung ath_sysctl_diversity(SYSCTLFN_ARGS)
    236  1.1  dyoung {
    237  1.1  dyoung 	struct ath_softc *sc;
    238  1.1  dyoung 	struct sysctlnode node;
    239  1.1  dyoung 	u_int diversity;
    240  1.1  dyoung 	int error;
    241  1.1  dyoung 
    242  1.1  dyoung 	node = *rnode;
    243  1.1  dyoung 	sc = (struct ath_softc *)node.sysctl_data;
    244  1.1  dyoung 	diversity = sc->sc_diversity;
    245  1.1  dyoung 	node.sysctl_data = &diversity;
    246  1.1  dyoung 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
    247  1.1  dyoung 	if (error || newp == NULL)
    248  1.1  dyoung 		return error;
    249  1.1  dyoung 	if (!ath_hal_setdiversity(sc->sc_ah, diversity))
    250  1.1  dyoung 		return EINVAL;
    251  1.1  dyoung 	sc->sc_diversity = diversity;
    252  1.1  dyoung 	return 0;
    253  1.1  dyoung }
    254  1.1  dyoung 
    255  1.1  dyoung static int
    256  1.1  dyoung ath_sysctl_diag(SYSCTLFN_ARGS)
    257  1.1  dyoung {
    258  1.1  dyoung 	struct ath_softc *sc;
    259  1.1  dyoung 	struct sysctlnode node;
    260  1.1  dyoung 	u_int32_t diag;
    261  1.1  dyoung 	int error;
    262  1.1  dyoung 
    263  1.1  dyoung 	node = *rnode;
    264  1.1  dyoung 	sc = (struct ath_softc *)node.sysctl_data;
    265  1.1  dyoung 	if (!ath_hal_getdiag(sc->sc_ah, &diag))
    266  1.1  dyoung 		return EINVAL;
    267  1.1  dyoung 	node.sysctl_data = &diag;
    268  1.1  dyoung 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
    269  1.1  dyoung 	if (error || newp == NULL)
    270  1.1  dyoung 		return error;
    271  1.1  dyoung 	return !ath_hal_setdiag(sc->sc_ah, diag) ? EINVAL : 0;
    272  1.1  dyoung }
    273  1.1  dyoung 
    274  1.1  dyoung static int
    275  1.1  dyoung ath_sysctl_tpscale(SYSCTLFN_ARGS)
    276  1.1  dyoung {
    277  1.1  dyoung 	struct ath_softc *sc;
    278  1.1  dyoung 	struct sysctlnode node;
    279  1.1  dyoung 	u_int32_t scale;
    280  1.1  dyoung 	int error;
    281  1.1  dyoung 
    282  1.1  dyoung 	node = *rnode;
    283  1.1  dyoung 	sc = (struct ath_softc *)node.sysctl_data;
    284  1.1  dyoung 	ath_hal_gettpscale(sc->sc_ah, &scale);
    285  1.1  dyoung 	node.sysctl_data = &scale;
    286  1.1  dyoung 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
    287  1.1  dyoung 	if (error || newp == NULL)
    288  1.1  dyoung 		return error;
    289  1.1  dyoung 	return !ath_hal_settpscale(sc->sc_ah, scale)
    290  1.1  dyoung 	    ? EINVAL
    291  1.1  dyoung 	    : ath_reset(&sc->sc_if);
    292  1.1  dyoung }
    293  1.1  dyoung 
    294  1.1  dyoung static int
    295  1.1  dyoung ath_sysctl_tpc(SYSCTLFN_ARGS)
    296  1.1  dyoung {
    297  1.1  dyoung 	struct ath_softc *sc;
    298  1.1  dyoung 	struct sysctlnode node;
    299  1.1  dyoung 	u_int tpc;
    300  1.1  dyoung 	int error;
    301  1.1  dyoung 
    302  1.1  dyoung 	node = *rnode;
    303  1.1  dyoung 	sc = (struct ath_softc *)node.sysctl_data;
    304  1.1  dyoung 	tpc = ath_hal_gettpc(sc->sc_ah);
    305  1.1  dyoung 	node.sysctl_data = &tpc;
    306  1.1  dyoung 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
    307  1.1  dyoung 	if (error || newp == NULL)
    308  1.1  dyoung 		return error;
    309  1.1  dyoung 	return !ath_hal_settpc(sc->sc_ah, tpc) ? EINVAL : 0;
    310  1.1  dyoung }
    311  1.1  dyoung 
    312  1.1  dyoung const struct sysctlnode *
    313  1.1  dyoung ath_sysctl_treetop(struct sysctllog **log)
    314  1.1  dyoung {
    315  1.1  dyoung 	int rc;
    316  1.1  dyoung 	const struct sysctlnode *rnode;
    317  1.1  dyoung 
    318  1.1  dyoung 	if ((rc = sysctl_createv(log, 0, NULL, &rnode,
    319  1.1  dyoung 	    CTLFLAG_PERMANENT, CTLTYPE_NODE, "hw", NULL,
    320  1.1  dyoung 	    NULL, 0, NULL, 0, CTL_HW, CTL_EOL)) != 0)
    321  1.1  dyoung 		goto err;
    322  1.1  dyoung 
    323  1.1  dyoung 	if ((rc = sysctl_createv(log, 0, &rnode, &rnode,
    324  1.1  dyoung 	    CTLFLAG_PERMANENT, CTLTYPE_NODE, "ath",
    325  1.1  dyoung 	    SYSCTL_DESCR("ath information and options"),
    326  1.1  dyoung 	    NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0)
    327  1.1  dyoung 		goto err;
    328  1.1  dyoung 
    329  1.1  dyoung 	return rnode;
    330  1.1  dyoung err:
    331  1.1  dyoung 	printf("%s: sysctl_createv failed, rc = %d\n", __func__, rc);
    332  1.1  dyoung 	return NULL;
    333  1.1  dyoung }
    334  1.1  dyoung 
    335  1.1  dyoung void
    336  1.1  dyoung ath_sysctlattach(struct ath_softc *sc)
    337  1.1  dyoung {
    338  1.1  dyoung 	int rc;
    339  1.1  dyoung 	struct sysctllog **log = &sc->sc_sysctllog;
    340  1.1  dyoung 	const struct sysctlnode *cnode, *rnode;
    341  1.1  dyoung 
    342  1.1  dyoung 	ath_hal_getcountrycode(sc->sc_ah, &sc->sc_countrycode);
    343  1.1  dyoung 	ath_hal_getregdomain(sc->sc_ah, &sc->sc_regdomain);
    344  1.1  dyoung 	sc->sc_debug = ath_debug;
    345  1.1  dyoung 	sc->sc_txintrperiod = ATH_TXINTR_PERIOD;
    346  1.1  dyoung 
    347  1.1  dyoung 	if ((rnode = ath_sysctl_treetop(NULL)) == NULL)
    348  1.1  dyoung 		return;
    349  1.1  dyoung 
    350  1.1  dyoung 	if ((rc = SYSCTL_INT(0, countrycode, "EEPROM country code")) != 0)
    351  1.1  dyoung 		goto err;
    352  1.1  dyoung 
    353  1.1  dyoung 	if ((rc = SYSCTL_INT(0, regdomain, "EEPROM regdomain code")) != 0)
    354  1.1  dyoung 		goto err;
    355  1.1  dyoung 
    356  1.1  dyoung 	if ((rc = SYSCTL_INT(CTLFLAG_READWRITE, debug,
    357  1.1  dyoung 	    "control debugging printfs")) != 0)
    358  1.1  dyoung 		goto err;
    359  1.1  dyoung 
    360  1.1  dyoung #if 0
    361  1.1  dyoung 	/* channel dwell time (ms) for AP/station scanning */
    362  1.1  dyoung 	if ((rc = SYSCTL_INT(CTLFLAG_READWRITE, dwell,
    363  1.1  dyoung 	    "Channel dwell time (ms) for scanning")) != 0)
    364  1.1  dyoung 		goto err;
    365  1.1  dyoung #endif
    366  1.1  dyoung 
    367  1.1  dyoung 	if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, slottime,
    368  1.1  dyoung 	    "802.11 slot time (us)")) != 0)
    369  1.1  dyoung 		goto err;
    370  1.1  dyoung 	if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, acktimeout,
    371  1.1  dyoung 	    "802.11 ACK timeout (us)")) != 0)
    372  1.1  dyoung 		goto err;
    373  1.1  dyoung 	if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, ctstimeout,
    374  1.1  dyoung 	    "802.11 CTS timeout (us)")) != 0)
    375  1.1  dyoung 		goto err;
    376  1.1  dyoung 	if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, softled,
    377  1.1  dyoung 	    "enable/disable software LED support")) != 0)
    378  1.1  dyoung 		goto err;
    379  1.1  dyoung 	if ((rc = SYSCTL_INT(CTLFLAG_READWRITE, ledpin,
    380  1.1  dyoung 	    "GPIO pin connected to LED")) != 0)
    381  1.1  dyoung 		goto err;
    382  1.1  dyoung 	if ((rc = SYSCTL_INT(CTLFLAG_READWRITE, ledon,
    383  1.1  dyoung 	    "setting to turn LED on")) != 0)
    384  1.1  dyoung 		goto err;
    385  1.1  dyoung 	if ((rc = SYSCTL_INT(CTLFLAG_READWRITE, ledidle,
    386  1.1  dyoung 	    "idle time for inactivity LED (ticks)")) != 0)
    387  1.1  dyoung 		goto err;
    388  1.1  dyoung 	if ((rc = SYSCTL_INT(CTLFLAG_READWRITE, txantenna,
    389  1.1  dyoung 	    "tx antenna (0=auto)")) != 0)
    390  1.1  dyoung 		goto err;
    391  1.1  dyoung 	if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, rxantenna,
    392  1.1  dyoung 	    "default/rx antenna")) != 0)
    393  1.1  dyoung 		goto err;
    394  1.1  dyoung 	if (sc->sc_hasdiversity) {
    395  1.1  dyoung 		if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, diversity,
    396  1.1  dyoung 		    "antenna diversity")) != 0)
    397  1.1  dyoung 			goto err;
    398  1.1  dyoung 	}
    399  1.1  dyoung 	if ((rc = SYSCTL_INT(CTLFLAG_READWRITE, txintrperiod,
    400  1.1  dyoung 	    "tx descriptor batching")) != 0)
    401  1.1  dyoung 		goto err;
    402  1.1  dyoung 	if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, diag,
    403  1.1  dyoung 	    "h/w diagnostic control")) != 0)
    404  1.1  dyoung 		goto err;
    405  1.1  dyoung 	if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, tpscale,
    406  1.1  dyoung 	    "tx power scaling")) != 0)
    407  1.1  dyoung 		goto err;
    408  1.1  dyoung 	if (sc->sc_hastpc) {
    409  1.1  dyoung 		if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, tpc,
    410  1.1  dyoung 		    "enable/disable per-packet TPC")) != 0)
    411  1.1  dyoung 			goto err;
    412  1.1  dyoung 	}
    413  1.1  dyoung 	return;
    414  1.1  dyoung err:
    415  1.1  dyoung 	printf("%s: sysctl_createv failed, rc = %d\n", __func__, rc);
    416  1.1  dyoung }
    417