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