Deleted Added
full compact
if_ath_sysctl.c (227868) if_ath_sysctl.c (228888)
1/*-
2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13 * redistribution must be conditioned upon including a substantially
14 * similar Disclaimer requirement for further binary redistribution.
15 *
16 * NO WARRANTY
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13 * redistribution must be conditioned upon including a substantially
14 * similar Disclaimer requirement for further binary redistribution.
15 *
16 * NO WARRANTY
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath_sysctl.c 227868 2011-11-23 05:00:25Z adrian $");
31__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath_sysctl.c 228888 2011-12-26 05:46:22Z adrian $");
32
33/*
34 * Driver for the Atheros Wireless LAN controller.
35 *
36 * This software is derived from work of Atsushi Onoe; his contribution
37 * is greatly appreciated.
38 */
39
40#include "opt_inet.h"
41#include "opt_ath.h"
42#include "opt_wlan.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/sysctl.h>
47#include <sys/mbuf.h>
48#include <sys/malloc.h>
49#include <sys/lock.h>
50#include <sys/mutex.h>
51#include <sys/kernel.h>
52#include <sys/socket.h>
53#include <sys/sockio.h>
54#include <sys/errno.h>
55#include <sys/callout.h>
56#include <sys/bus.h>
57#include <sys/endian.h>
58#include <sys/kthread.h>
59#include <sys/taskqueue.h>
60#include <sys/priv.h>
61
62#include <machine/bus.h>
63
64#include <net/if.h>
65#include <net/if_dl.h>
66#include <net/if_media.h>
67#include <net/if_types.h>
68#include <net/if_arp.h>
69#include <net/ethernet.h>
70#include <net/if_llc.h>
71
72#include <net80211/ieee80211_var.h>
73#include <net80211/ieee80211_regdomain.h>
74#ifdef IEEE80211_SUPPORT_SUPERG
75#include <net80211/ieee80211_superg.h>
76#endif
77#ifdef IEEE80211_SUPPORT_TDMA
78#include <net80211/ieee80211_tdma.h>
79#endif
80
81#include <net/bpf.h>
82
83#ifdef INET
84#include <netinet/in.h>
85#include <netinet/if_ether.h>
86#endif
87
88#include <dev/ath/if_athvar.h>
89#include <dev/ath/ath_hal/ah_devid.h> /* XXX for softled */
90#include <dev/ath/ath_hal/ah_diagcodes.h>
91
92#include <dev/ath/if_ath_debug.h>
32
33/*
34 * Driver for the Atheros Wireless LAN controller.
35 *
36 * This software is derived from work of Atsushi Onoe; his contribution
37 * is greatly appreciated.
38 */
39
40#include "opt_inet.h"
41#include "opt_ath.h"
42#include "opt_wlan.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/sysctl.h>
47#include <sys/mbuf.h>
48#include <sys/malloc.h>
49#include <sys/lock.h>
50#include <sys/mutex.h>
51#include <sys/kernel.h>
52#include <sys/socket.h>
53#include <sys/sockio.h>
54#include <sys/errno.h>
55#include <sys/callout.h>
56#include <sys/bus.h>
57#include <sys/endian.h>
58#include <sys/kthread.h>
59#include <sys/taskqueue.h>
60#include <sys/priv.h>
61
62#include <machine/bus.h>
63
64#include <net/if.h>
65#include <net/if_dl.h>
66#include <net/if_media.h>
67#include <net/if_types.h>
68#include <net/if_arp.h>
69#include <net/ethernet.h>
70#include <net/if_llc.h>
71
72#include <net80211/ieee80211_var.h>
73#include <net80211/ieee80211_regdomain.h>
74#ifdef IEEE80211_SUPPORT_SUPERG
75#include <net80211/ieee80211_superg.h>
76#endif
77#ifdef IEEE80211_SUPPORT_TDMA
78#include <net80211/ieee80211_tdma.h>
79#endif
80
81#include <net/bpf.h>
82
83#ifdef INET
84#include <netinet/in.h>
85#include <netinet/if_ether.h>
86#endif
87
88#include <dev/ath/if_athvar.h>
89#include <dev/ath/ath_hal/ah_devid.h> /* XXX for softled */
90#include <dev/ath/ath_hal/ah_diagcodes.h>
91
92#include <dev/ath/if_ath_debug.h>
93#include <dev/ath/if_ath_led.h>
93#include <dev/ath/if_ath_misc.h>
94#include <dev/ath/if_ath_tx.h>
95#include <dev/ath/if_ath_sysctl.h>
96
97#ifdef ATH_TX99_DIAG
98#include <dev/ath/ath_tx99/ath_tx99.h>
99#endif
100
101static int
102ath_sysctl_slottime(SYSCTL_HANDLER_ARGS)
103{
104 struct ath_softc *sc = arg1;
105 u_int slottime = ath_hal_getslottime(sc->sc_ah);
106 int error;
107
108 error = sysctl_handle_int(oidp, &slottime, 0, req);
109 if (error || !req->newptr)
110 return error;
111 return !ath_hal_setslottime(sc->sc_ah, slottime) ? EINVAL : 0;
112}
113
114static int
115ath_sysctl_acktimeout(SYSCTL_HANDLER_ARGS)
116{
117 struct ath_softc *sc = arg1;
118 u_int acktimeout = ath_hal_getacktimeout(sc->sc_ah);
119 int error;
120
121 error = sysctl_handle_int(oidp, &acktimeout, 0, req);
122 if (error || !req->newptr)
123 return error;
124 return !ath_hal_setacktimeout(sc->sc_ah, acktimeout) ? EINVAL : 0;
125}
126
127static int
128ath_sysctl_ctstimeout(SYSCTL_HANDLER_ARGS)
129{
130 struct ath_softc *sc = arg1;
131 u_int ctstimeout = ath_hal_getctstimeout(sc->sc_ah);
132 int error;
133
134 error = sysctl_handle_int(oidp, &ctstimeout, 0, req);
135 if (error || !req->newptr)
136 return error;
137 return !ath_hal_setctstimeout(sc->sc_ah, ctstimeout) ? EINVAL : 0;
138}
139
140static int
141ath_sysctl_softled(SYSCTL_HANDLER_ARGS)
142{
143 struct ath_softc *sc = arg1;
144 int softled = sc->sc_softled;
145 int error;
146
147 error = sysctl_handle_int(oidp, &softled, 0, req);
148 if (error || !req->newptr)
149 return error;
150 softled = (softled != 0);
151 if (softled != sc->sc_softled) {
152 if (softled) {
153 /* NB: handle any sc_ledpin change */
94#include <dev/ath/if_ath_misc.h>
95#include <dev/ath/if_ath_tx.h>
96#include <dev/ath/if_ath_sysctl.h>
97
98#ifdef ATH_TX99_DIAG
99#include <dev/ath/ath_tx99/ath_tx99.h>
100#endif
101
102static int
103ath_sysctl_slottime(SYSCTL_HANDLER_ARGS)
104{
105 struct ath_softc *sc = arg1;
106 u_int slottime = ath_hal_getslottime(sc->sc_ah);
107 int error;
108
109 error = sysctl_handle_int(oidp, &slottime, 0, req);
110 if (error || !req->newptr)
111 return error;
112 return !ath_hal_setslottime(sc->sc_ah, slottime) ? EINVAL : 0;
113}
114
115static int
116ath_sysctl_acktimeout(SYSCTL_HANDLER_ARGS)
117{
118 struct ath_softc *sc = arg1;
119 u_int acktimeout = ath_hal_getacktimeout(sc->sc_ah);
120 int error;
121
122 error = sysctl_handle_int(oidp, &acktimeout, 0, req);
123 if (error || !req->newptr)
124 return error;
125 return !ath_hal_setacktimeout(sc->sc_ah, acktimeout) ? EINVAL : 0;
126}
127
128static int
129ath_sysctl_ctstimeout(SYSCTL_HANDLER_ARGS)
130{
131 struct ath_softc *sc = arg1;
132 u_int ctstimeout = ath_hal_getctstimeout(sc->sc_ah);
133 int error;
134
135 error = sysctl_handle_int(oidp, &ctstimeout, 0, req);
136 if (error || !req->newptr)
137 return error;
138 return !ath_hal_setctstimeout(sc->sc_ah, ctstimeout) ? EINVAL : 0;
139}
140
141static int
142ath_sysctl_softled(SYSCTL_HANDLER_ARGS)
143{
144 struct ath_softc *sc = arg1;
145 int softled = sc->sc_softled;
146 int error;
147
148 error = sysctl_handle_int(oidp, &softled, 0, req);
149 if (error || !req->newptr)
150 return error;
151 softled = (softled != 0);
152 if (softled != sc->sc_softled) {
153 if (softled) {
154 /* NB: handle any sc_ledpin change */
154 ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin,
155 HAL_GPIO_MUX_MAC_NETWORK_LED);
156 ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin,
157 !sc->sc_ledon);
155 ath_led_config(sc);
158 }
159 sc->sc_softled = softled;
160 }
161 return 0;
162}
163
164static int
165ath_sysctl_ledpin(SYSCTL_HANDLER_ARGS)
166{
167 struct ath_softc *sc = arg1;
168 int ledpin = sc->sc_ledpin;
169 int error;
170
171 error = sysctl_handle_int(oidp, &ledpin, 0, req);
172 if (error || !req->newptr)
173 return error;
174 if (ledpin != sc->sc_ledpin) {
175 sc->sc_ledpin = ledpin;
176 if (sc->sc_softled) {
156 }
157 sc->sc_softled = softled;
158 }
159 return 0;
160}
161
162static int
163ath_sysctl_ledpin(SYSCTL_HANDLER_ARGS)
164{
165 struct ath_softc *sc = arg1;
166 int ledpin = sc->sc_ledpin;
167 int error;
168
169 error = sysctl_handle_int(oidp, &ledpin, 0, req);
170 if (error || !req->newptr)
171 return error;
172 if (ledpin != sc->sc_ledpin) {
173 sc->sc_ledpin = ledpin;
174 if (sc->sc_softled) {
177 ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin,
178 HAL_GPIO_MUX_MAC_NETWORK_LED);
179 ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin,
180 !sc->sc_ledon);
175 ath_led_config(sc);
181 }
182 }
183 return 0;
184}
185
186static int
187ath_sysctl_txantenna(SYSCTL_HANDLER_ARGS)
188{
189 struct ath_softc *sc = arg1;
190 u_int txantenna = ath_hal_getantennaswitch(sc->sc_ah);
191 int error;
192
193 error = sysctl_handle_int(oidp, &txantenna, 0, req);
194 if (!error && req->newptr) {
195 /* XXX assumes 2 antenna ports */
196 if (txantenna < HAL_ANT_VARIABLE || txantenna > HAL_ANT_FIXED_B)
197 return EINVAL;
198 ath_hal_setantennaswitch(sc->sc_ah, txantenna);
199 /*
200 * NB: with the switch locked this isn't meaningful,
201 * but set it anyway so things like radiotap get
202 * consistent info in their data.
203 */
204 sc->sc_txantenna = txantenna;
205 }
206 return error;
207}
208
209static int
210ath_sysctl_rxantenna(SYSCTL_HANDLER_ARGS)
211{
212 struct ath_softc *sc = arg1;
213 u_int defantenna = ath_hal_getdefantenna(sc->sc_ah);
214 int error;
215
216 error = sysctl_handle_int(oidp, &defantenna, 0, req);
217 if (!error && req->newptr)
218 ath_hal_setdefantenna(sc->sc_ah, defantenna);
219 return error;
220}
221
222static int
223ath_sysctl_diversity(SYSCTL_HANDLER_ARGS)
224{
225 struct ath_softc *sc = arg1;
226 u_int diversity = ath_hal_getdiversity(sc->sc_ah);
227 int error;
228
229 error = sysctl_handle_int(oidp, &diversity, 0, req);
230 if (error || !req->newptr)
231 return error;
232 if (!ath_hal_setdiversity(sc->sc_ah, diversity))
233 return EINVAL;
234 sc->sc_diversity = diversity;
235 return 0;
236}
237
238static int
239ath_sysctl_diag(SYSCTL_HANDLER_ARGS)
240{
241 struct ath_softc *sc = arg1;
242 u_int32_t diag;
243 int error;
244
245 if (!ath_hal_getdiag(sc->sc_ah, &diag))
246 return EINVAL;
247 error = sysctl_handle_int(oidp, &diag, 0, req);
248 if (error || !req->newptr)
249 return error;
250 return !ath_hal_setdiag(sc->sc_ah, diag) ? EINVAL : 0;
251}
252
253static int
254ath_sysctl_tpscale(SYSCTL_HANDLER_ARGS)
255{
256 struct ath_softc *sc = arg1;
257 struct ifnet *ifp = sc->sc_ifp;
258 u_int32_t scale;
259 int error;
260
261 (void) ath_hal_gettpscale(sc->sc_ah, &scale);
262 error = sysctl_handle_int(oidp, &scale, 0, req);
263 if (error || !req->newptr)
264 return error;
265 return !ath_hal_settpscale(sc->sc_ah, scale) ? EINVAL :
266 (ifp->if_drv_flags & IFF_DRV_RUNNING) ?
267 ath_reset(ifp, ATH_RESET_NOLOSS) : 0;
268}
269
270static int
271ath_sysctl_tpc(SYSCTL_HANDLER_ARGS)
272{
273 struct ath_softc *sc = arg1;
274 u_int tpc = ath_hal_gettpc(sc->sc_ah);
275 int error;
276
277 error = sysctl_handle_int(oidp, &tpc, 0, req);
278 if (error || !req->newptr)
279 return error;
280 return !ath_hal_settpc(sc->sc_ah, tpc) ? EINVAL : 0;
281}
282
283static int
284ath_sysctl_rfkill(SYSCTL_HANDLER_ARGS)
285{
286 struct ath_softc *sc = arg1;
287 struct ifnet *ifp = sc->sc_ifp;
288 struct ath_hal *ah = sc->sc_ah;
289 u_int rfkill = ath_hal_getrfkill(ah);
290 int error;
291
292 error = sysctl_handle_int(oidp, &rfkill, 0, req);
293 if (error || !req->newptr)
294 return error;
295 if (rfkill == ath_hal_getrfkill(ah)) /* unchanged */
296 return 0;
297 if (!ath_hal_setrfkill(ah, rfkill))
298 return EINVAL;
299 return (ifp->if_drv_flags & IFF_DRV_RUNNING) ?
300 ath_reset(ifp, ATH_RESET_FULL) : 0;
301}
302
303static int
304ath_sysctl_txagg(SYSCTL_HANDLER_ARGS)
305{
306 struct ath_softc *sc = arg1;
307 int i, t, param = 0;
308 int error;
309 struct ath_buf *bf;
310
311 error = sysctl_handle_int(oidp, &param, 0, req);
312 if (error || !req->newptr)
313 return error;
314
315 if (param != 1)
316 return 0;
317
318 printf("no tx bufs (empty list): %d\n", sc->sc_stats.ast_tx_getnobuf);
319 printf("no tx bufs (was busy): %d\n", sc->sc_stats.ast_tx_getbusybuf);
320
321 printf("aggr single packet: %d\n",
322 sc->sc_aggr_stats.aggr_single_pkt);
323 printf("aggr single packet w/ BAW closed: %d\n",
324 sc->sc_aggr_stats.aggr_baw_closed_single_pkt);
325 printf("aggr non-baw packet: %d\n",
326 sc->sc_aggr_stats.aggr_nonbaw_pkt);
327 printf("aggr aggregate packet: %d\n",
328 sc->sc_aggr_stats.aggr_aggr_pkt);
329 printf("aggr single packet low hwq: %d\n",
330 sc->sc_aggr_stats.aggr_low_hwq_single_pkt);
331 printf("aggr sched, no work: %d\n",
332 sc->sc_aggr_stats.aggr_sched_nopkt);
333 for (i = 0; i < 64; i++) {
334 printf("%2d: %10d ", i, sc->sc_aggr_stats.aggr_pkts[i]);
335 if (i % 4 == 3)
336 printf("\n");
337 }
338 printf("\n");
339
340 for (i = 0; i < HAL_NUM_TX_QUEUES; i++) {
341 if (ATH_TXQ_SETUP(sc, i)) {
342 printf("HW TXQ %d: axq_depth=%d, axq_aggr_depth=%d\n",
343 i,
344 sc->sc_txq[i].axq_depth,
345 sc->sc_txq[i].axq_aggr_depth);
346 }
347 }
348
349 i = t = 0;
350 ATH_TXBUF_LOCK(sc);
351 TAILQ_FOREACH(bf, &sc->sc_txbuf, bf_list) {
352 if (bf->bf_flags & ATH_BUF_BUSY) {
353 printf("Busy: %d\n", t);
354 i++;
355 }
356 t++;
357 }
358 ATH_TXBUF_UNLOCK(sc);
359 printf("Total TX buffers: %d; Total TX buffers busy: %d\n",
360 t, i);
361
362 return 0;
363}
364
365static int
366ath_sysctl_rfsilent(SYSCTL_HANDLER_ARGS)
367{
368 struct ath_softc *sc = arg1;
369 u_int rfsilent;
370 int error;
371
372 (void) ath_hal_getrfsilent(sc->sc_ah, &rfsilent);
373 error = sysctl_handle_int(oidp, &rfsilent, 0, req);
374 if (error || !req->newptr)
375 return error;
376 if (!ath_hal_setrfsilent(sc->sc_ah, rfsilent))
377 return EINVAL;
378 sc->sc_rfsilentpin = rfsilent & 0x1c;
379 sc->sc_rfsilentpol = (rfsilent & 0x2) != 0;
380 return 0;
381}
382
383static int
384ath_sysctl_tpack(SYSCTL_HANDLER_ARGS)
385{
386 struct ath_softc *sc = arg1;
387 u_int32_t tpack;
388 int error;
389
390 (void) ath_hal_gettpack(sc->sc_ah, &tpack);
391 error = sysctl_handle_int(oidp, &tpack, 0, req);
392 if (error || !req->newptr)
393 return error;
394 return !ath_hal_settpack(sc->sc_ah, tpack) ? EINVAL : 0;
395}
396
397static int
398ath_sysctl_tpcts(SYSCTL_HANDLER_ARGS)
399{
400 struct ath_softc *sc = arg1;
401 u_int32_t tpcts;
402 int error;
403
404 (void) ath_hal_gettpcts(sc->sc_ah, &tpcts);
405 error = sysctl_handle_int(oidp, &tpcts, 0, req);
406 if (error || !req->newptr)
407 return error;
408 return !ath_hal_settpcts(sc->sc_ah, tpcts) ? EINVAL : 0;
409}
410
411static int
412ath_sysctl_intmit(SYSCTL_HANDLER_ARGS)
413{
414 struct ath_softc *sc = arg1;
415 int intmit, error;
416
417 intmit = ath_hal_getintmit(sc->sc_ah);
418 error = sysctl_handle_int(oidp, &intmit, 0, req);
419 if (error || !req->newptr)
420 return error;
421
422 /* reusing error; 1 here means "good"; 0 means "fail" */
423 error = ath_hal_setintmit(sc->sc_ah, intmit);
424 if (! error)
425 return EINVAL;
426
427 /*
428 * Reset the hardware here - disabling ANI in the HAL
429 * doesn't reset ANI related registers, so it'll leave
430 * things in an inconsistent state.
431 */
432 if (sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING)
433 ath_reset(sc->sc_ifp, ATH_RESET_NOLOSS);
434
435 return 0;
436}
437
438#ifdef IEEE80211_SUPPORT_TDMA
439static int
440ath_sysctl_setcca(SYSCTL_HANDLER_ARGS)
441{
442 struct ath_softc *sc = arg1;
443 int setcca, error;
444
445 setcca = sc->sc_setcca;
446 error = sysctl_handle_int(oidp, &setcca, 0, req);
447 if (error || !req->newptr)
448 return error;
449 sc->sc_setcca = (setcca != 0);
450 return 0;
451}
452#endif /* IEEE80211_SUPPORT_TDMA */
453
454static int
455ath_sysctl_forcebstuck(SYSCTL_HANDLER_ARGS)
456{
457 struct ath_softc *sc = arg1;
458 int val = 0;
459 int error;
460
461 error = sysctl_handle_int(oidp, &val, 0, req);
462 if (error || !req->newptr)
463 return error;
464 if (val == 0)
465 return 0;
466
467 taskqueue_enqueue_fast(sc->sc_tq, &sc->sc_bstucktask);
468 val = 0;
469 return 0;
470}
471
472void
473ath_sysctlattach(struct ath_softc *sc)
474{
475 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
476 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
477 struct ath_hal *ah = sc->sc_ah;
478
479 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
480 "countrycode", CTLFLAG_RD, &sc->sc_eecc, 0,
481 "EEPROM country code");
482 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
483 "regdomain", CTLFLAG_RD, &sc->sc_eerd, 0,
484 "EEPROM regdomain code");
485#ifdef ATH_DEBUG
486 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
487 "debug", CTLFLAG_RW, &sc->sc_debug, 0,
488 "control debugging printfs");
489#endif
490 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
491 "slottime", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
492 ath_sysctl_slottime, "I", "802.11 slot time (us)");
493 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
494 "acktimeout", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
495 ath_sysctl_acktimeout, "I", "802.11 ACK timeout (us)");
496 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
497 "ctstimeout", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
498 ath_sysctl_ctstimeout, "I", "802.11 CTS timeout (us)");
499 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
500 "softled", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
501 ath_sysctl_softled, "I", "enable/disable software LED support");
502 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
503 "ledpin", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
504 ath_sysctl_ledpin, "I", "GPIO pin connected to LED");
505 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
506 "ledon", CTLFLAG_RW, &sc->sc_ledon, 0,
507 "setting to turn LED on");
508 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
509 "ledidle", CTLFLAG_RW, &sc->sc_ledidle, 0,
510 "idle time for inactivity LED (ticks)");
511 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
512 "txantenna", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
513 ath_sysctl_txantenna, "I", "antenna switch");
514 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
515 "rxantenna", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
516 ath_sysctl_rxantenna, "I", "default/rx antenna");
517 if (ath_hal_hasdiversity(ah))
518 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
519 "diversity", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
520 ath_sysctl_diversity, "I", "antenna diversity");
521 sc->sc_txintrperiod = ATH_TXINTR_PERIOD;
522 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
523 "txintrperiod", CTLFLAG_RW, &sc->sc_txintrperiod, 0,
524 "tx descriptor batching");
525 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
526 "diag", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
527 ath_sysctl_diag, "I", "h/w diagnostic control");
528 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
529 "tpscale", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
530 ath_sysctl_tpscale, "I", "tx power scaling");
531 if (ath_hal_hastpc(ah)) {
532 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
533 "tpc", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
534 ath_sysctl_tpc, "I", "enable/disable per-packet TPC");
535 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
536 "tpack", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
537 ath_sysctl_tpack, "I", "tx power for ack frames");
538 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
539 "tpcts", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
540 ath_sysctl_tpcts, "I", "tx power for cts frames");
541 }
542 if (ath_hal_hasrfsilent(ah)) {
543 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
544 "rfsilent", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
545 ath_sysctl_rfsilent, "I", "h/w RF silent config");
546 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
547 "rfkill", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
548 ath_sysctl_rfkill, "I", "enable/disable RF kill switch");
549 }
550
551 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
552 "txagg", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
553 ath_sysctl_txagg, "I", "");
554
555 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
556 "forcebstuck", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
557 ath_sysctl_forcebstuck, "I", "");
558
559 if (ath_hal_hasintmit(ah)) {
560 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
561 "intmit", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
562 ath_sysctl_intmit, "I", "interference mitigation");
563 }
564 sc->sc_monpass = HAL_RXERR_DECRYPT | HAL_RXERR_MIC;
565 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
566 "monpass", CTLFLAG_RW, &sc->sc_monpass, 0,
567 "mask of error frames to pass when monitoring");
568
569 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
570 "hwq_limit", CTLFLAG_RW, &sc->sc_hwq_limit, 0,
571 "");
572 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
573 "tid_hwq_lo", CTLFLAG_RW, &sc->sc_tid_hwq_lo, 0,
574 "");
575 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
576 "tid_hwq_hi", CTLFLAG_RW, &sc->sc_tid_hwq_hi, 0,
577 "");
578
579#ifdef IEEE80211_SUPPORT_TDMA
580 if (ath_hal_macversion(ah) > 0x78) {
581 sc->sc_tdmadbaprep = 2;
582 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
583 "dbaprep", CTLFLAG_RW, &sc->sc_tdmadbaprep, 0,
584 "TDMA DBA preparation time");
585 sc->sc_tdmaswbaprep = 10;
586 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
587 "swbaprep", CTLFLAG_RW, &sc->sc_tdmaswbaprep, 0,
588 "TDMA SWBA preparation time");
589 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
590 "guardtime", CTLFLAG_RW, &sc->sc_tdmaguard, 0,
591 "TDMA slot guard time");
592 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
593 "superframe", CTLFLAG_RD, &sc->sc_tdmabintval, 0,
594 "TDMA calculated super frame");
595 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
596 "setcca", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
597 ath_sysctl_setcca, "I", "enable CCA control");
598 }
599#endif
600}
601
602static int
603ath_sysctl_clearstats(SYSCTL_HANDLER_ARGS)
604{
605 struct ath_softc *sc = arg1;
606 int val = 0;
607 int error;
608
609 error = sysctl_handle_int(oidp, &val, 0, req);
610 if (error || !req->newptr)
611 return error;
612 if (val == 0)
613 return 0; /* Not clearing the stats is still valid */
614 memset(&sc->sc_stats, 0, sizeof(sc->sc_stats));
615 memset(&sc->sc_aggr_stats, 0, sizeof(sc->sc_aggr_stats));
616
617 val = 0;
618 return 0;
619}
620
621static void
622ath_sysctl_stats_attach_rxphyerr(struct ath_softc *sc, struct sysctl_oid_list *parent)
623{
624 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
625 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
626 struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
627 int i;
628 char sn[8];
629
630 tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "rx_phy_err", CTLFLAG_RD, NULL, "Per-code RX PHY Errors");
631 child = SYSCTL_CHILDREN(tree);
632 for (i = 0; i < 64; i++) {
633 snprintf(sn, sizeof(sn), "%d", i);
634 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, sn, CTLFLAG_RD, &sc->sc_stats.ast_rx_phy[i], 0, "");
635 }
636}
637
638void
639ath_sysctl_stats_attach(struct ath_softc *sc)
640{
641 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
642 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
643 struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
644
645 /* Create "clear" node */
646 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
647 "clear_stats", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
648 ath_sysctl_clearstats, "I", "clear stats");
649
650 /* Create stats node */
651 tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats", CTLFLAG_RD,
652 NULL, "Statistics");
653 child = SYSCTL_CHILDREN(tree);
654
655 /* This was generated from if_athioctl.h */
656
657 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_watchdog", CTLFLAG_RD,
658 &sc->sc_stats.ast_watchdog, 0, "device reset by watchdog");
659 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_hardware", CTLFLAG_RD,
660 &sc->sc_stats.ast_hardware, 0, "fatal hardware error interrupts");
661 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_bmiss", CTLFLAG_RD,
662 &sc->sc_stats.ast_bmiss, 0, "beacon miss interrupts");
663 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_bmiss_phantom", CTLFLAG_RD,
664 &sc->sc_stats.ast_bmiss_phantom, 0, "beacon miss interrupts");
665 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_bstuck", CTLFLAG_RD,
666 &sc->sc_stats.ast_bstuck, 0, "beacon stuck interrupts");
667 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rxorn", CTLFLAG_RD,
668 &sc->sc_stats.ast_rxorn, 0, "rx overrun interrupts");
669 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rxeol", CTLFLAG_RD,
670 &sc->sc_stats.ast_rxeol, 0, "rx eol interrupts");
671 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_txurn", CTLFLAG_RD,
672 &sc->sc_stats.ast_txurn, 0, "tx underrun interrupts");
673 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_mib", CTLFLAG_RD,
674 &sc->sc_stats.ast_mib, 0, "mib interrupts");
675 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_intrcoal", CTLFLAG_RD,
676 &sc->sc_stats.ast_intrcoal, 0, "interrupts coalesced");
677 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_packets", CTLFLAG_RD,
678 &sc->sc_stats.ast_tx_packets, 0, "packet sent on the interface");
679 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_mgmt", CTLFLAG_RD,
680 &sc->sc_stats.ast_tx_mgmt, 0, "management frames transmitted");
681 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_discard", CTLFLAG_RD,
682 &sc->sc_stats.ast_tx_discard, 0, "frames discarded prior to assoc");
683 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_qstop", CTLFLAG_RD,
684 &sc->sc_stats.ast_tx_qstop, 0, "output stopped 'cuz no buffer");
685 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_encap", CTLFLAG_RD,
686 &sc->sc_stats.ast_tx_encap, 0, "tx encapsulation failed");
687 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nonode", CTLFLAG_RD,
688 &sc->sc_stats.ast_tx_nonode, 0, "tx failed 'cuz no node");
689 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nombuf", CTLFLAG_RD,
690 &sc->sc_stats.ast_tx_nombuf, 0, "tx failed 'cuz no mbuf");
691 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nomcl", CTLFLAG_RD,
692 &sc->sc_stats.ast_tx_nomcl, 0, "tx failed 'cuz no cluster");
693 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_linear", CTLFLAG_RD,
694 &sc->sc_stats.ast_tx_linear, 0, "tx linearized to cluster");
695 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nodata", CTLFLAG_RD,
696 &sc->sc_stats.ast_tx_nodata, 0, "tx discarded empty frame");
697 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_busdma", CTLFLAG_RD,
698 &sc->sc_stats.ast_tx_busdma, 0, "tx failed for dma resrcs");
699 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_xretries", CTLFLAG_RD,
700 &sc->sc_stats.ast_tx_xretries, 0, "tx failed 'cuz too many retries");
701 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_fifoerr", CTLFLAG_RD,
702 &sc->sc_stats.ast_tx_fifoerr, 0, "tx failed 'cuz FIFO underrun");
703 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_filtered", CTLFLAG_RD,
704 &sc->sc_stats.ast_tx_filtered, 0, "tx failed 'cuz xmit filtered");
705 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_shortretry", CTLFLAG_RD,
706 &sc->sc_stats.ast_tx_shortretry, 0, "tx on-chip retries (short)");
707 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_longretry", CTLFLAG_RD,
708 &sc->sc_stats.ast_tx_longretry, 0, "tx on-chip retries (long)");
709 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_badrate", CTLFLAG_RD,
710 &sc->sc_stats.ast_tx_badrate, 0, "tx failed 'cuz bogus xmit rate");
711 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_noack", CTLFLAG_RD,
712 &sc->sc_stats.ast_tx_noack, 0, "tx frames with no ack marked");
713 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_rts", CTLFLAG_RD,
714 &sc->sc_stats.ast_tx_rts, 0, "tx frames with rts enabled");
715 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_cts", CTLFLAG_RD,
716 &sc->sc_stats.ast_tx_cts, 0, "tx frames with cts enabled");
717 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_shortpre", CTLFLAG_RD,
718 &sc->sc_stats.ast_tx_shortpre, 0, "tx frames with short preamble");
719 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_altrate", CTLFLAG_RD,
720 &sc->sc_stats.ast_tx_altrate, 0, "tx frames with alternate rate");
721 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_protect", CTLFLAG_RD,
722 &sc->sc_stats.ast_tx_protect, 0, "tx frames with protection");
723 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_ctsburst", CTLFLAG_RD,
724 &sc->sc_stats.ast_tx_ctsburst, 0, "tx frames with cts and bursting");
725 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_ctsext", CTLFLAG_RD,
726 &sc->sc_stats.ast_tx_ctsext, 0, "tx frames with cts extension");
727 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_nombuf", CTLFLAG_RD,
728 &sc->sc_stats.ast_rx_nombuf, 0, "rx setup failed 'cuz no mbuf");
729 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_busdma", CTLFLAG_RD,
730 &sc->sc_stats.ast_rx_busdma, 0, "rx setup failed for dma resrcs");
731 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_orn", CTLFLAG_RD,
732 &sc->sc_stats.ast_rx_orn, 0, "rx failed 'cuz of desc overrun");
733 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_crcerr", CTLFLAG_RD,
734 &sc->sc_stats.ast_rx_crcerr, 0, "rx failed 'cuz of bad CRC");
735 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_fifoerr", CTLFLAG_RD,
736 &sc->sc_stats.ast_rx_fifoerr, 0, "rx failed 'cuz of FIFO overrun");
737 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_badcrypt", CTLFLAG_RD,
738 &sc->sc_stats.ast_rx_badcrypt, 0, "rx failed 'cuz decryption");
739 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_badmic", CTLFLAG_RD,
740 &sc->sc_stats.ast_rx_badmic, 0, "rx failed 'cuz MIC failure");
741 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_phyerr", CTLFLAG_RD,
742 &sc->sc_stats.ast_rx_phyerr, 0, "rx failed 'cuz of PHY err");
743 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_tooshort", CTLFLAG_RD,
744 &sc->sc_stats.ast_rx_tooshort, 0, "rx discarded 'cuz frame too short");
745 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_toobig", CTLFLAG_RD,
746 &sc->sc_stats.ast_rx_toobig, 0, "rx discarded 'cuz frame too large");
747 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_packets", CTLFLAG_RD,
748 &sc->sc_stats.ast_rx_packets, 0, "packet recv on the interface");
749 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_mgt", CTLFLAG_RD,
750 &sc->sc_stats.ast_rx_mgt, 0, "management frames received");
751 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_ctl", CTLFLAG_RD,
752 &sc->sc_stats.ast_rx_ctl, 0, "rx discarded 'cuz ctl frame");
753 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_be_xmit", CTLFLAG_RD,
754 &sc->sc_stats.ast_be_xmit, 0, "beacons transmitted");
755 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_be_nombuf", CTLFLAG_RD,
756 &sc->sc_stats.ast_be_nombuf, 0, "beacon setup failed 'cuz no mbuf");
757 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_per_cal", CTLFLAG_RD,
758 &sc->sc_stats.ast_per_cal, 0, "periodic calibration calls");
759 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_per_calfail", CTLFLAG_RD,
760 &sc->sc_stats.ast_per_calfail, 0, "periodic calibration failed");
761 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_per_rfgain", CTLFLAG_RD,
762 &sc->sc_stats.ast_per_rfgain, 0, "periodic calibration rfgain reset");
763 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rate_calls", CTLFLAG_RD,
764 &sc->sc_stats.ast_rate_calls, 0, "rate control checks");
765 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rate_raise", CTLFLAG_RD,
766 &sc->sc_stats.ast_rate_raise, 0, "rate control raised xmit rate");
767 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rate_drop", CTLFLAG_RD,
768 &sc->sc_stats.ast_rate_drop, 0, "rate control dropped xmit rate");
769 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ant_defswitch", CTLFLAG_RD,
770 &sc->sc_stats.ast_ant_defswitch, 0, "rx/default antenna switches");
771 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ant_txswitch", CTLFLAG_RD,
772 &sc->sc_stats.ast_ant_txswitch, 0, "tx antenna switches");
773 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_cabq_xmit", CTLFLAG_RD,
774 &sc->sc_stats.ast_cabq_xmit, 0, "cabq frames transmitted");
775 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_cabq_busy", CTLFLAG_RD,
776 &sc->sc_stats.ast_cabq_busy, 0, "cabq found busy");
777 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_raw", CTLFLAG_RD,
778 &sc->sc_stats.ast_tx_raw, 0, "tx frames through raw api");
779 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ff_txok", CTLFLAG_RD,
780 &sc->sc_stats.ast_ff_txok, 0, "fast frames tx'd successfully");
781 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ff_txerr", CTLFLAG_RD,
782 &sc->sc_stats.ast_ff_txerr, 0, "fast frames tx'd w/ error");
783 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ff_rx", CTLFLAG_RD,
784 &sc->sc_stats.ast_ff_rx, 0, "fast frames rx'd");
785 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ff_flush", CTLFLAG_RD,
786 &sc->sc_stats.ast_ff_flush, 0, "fast frames flushed from staging q");
787 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_qfull", CTLFLAG_RD,
788 &sc->sc_stats.ast_tx_qfull, 0, "tx dropped 'cuz of queue limit");
789 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nobuf", CTLFLAG_RD,
790 &sc->sc_stats.ast_tx_nobuf, 0, "tx dropped 'cuz no ath buffer");
791 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tdma_update", CTLFLAG_RD,
792 &sc->sc_stats.ast_tdma_update, 0, "TDMA slot timing updates");
793 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tdma_timers", CTLFLAG_RD,
794 &sc->sc_stats.ast_tdma_timers, 0, "TDMA slot update set beacon timers");
795 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tdma_tsf", CTLFLAG_RD,
796 &sc->sc_stats.ast_tdma_tsf, 0, "TDMA slot update set TSF");
797 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tdma_ack", CTLFLAG_RD,
798 &sc->sc_stats.ast_tdma_ack, 0, "TDMA tx failed 'cuz ACK required");
799 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_raw_fail", CTLFLAG_RD,
800 &sc->sc_stats.ast_tx_raw_fail, 0, "raw tx failed 'cuz h/w down");
801 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nofrag", CTLFLAG_RD,
802 &sc->sc_stats.ast_tx_nofrag, 0, "tx dropped 'cuz no ath frag buffer");
803 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_be_missed", CTLFLAG_RD,
804 &sc->sc_stats.ast_be_missed, 0, "number of -missed- beacons");
805 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ani_cal", CTLFLAG_RD,
806 &sc->sc_stats.ast_ani_cal, 0, "number of ANI polls");
807 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_agg", CTLFLAG_RD,
808 &sc->sc_stats.ast_rx_agg, 0, "number of aggregate frames received");
809
810 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_halfgi", CTLFLAG_RD,
811 &sc->sc_stats.ast_rx_halfgi, 0, "number of frames received with half-GI");
812 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_2040", CTLFLAG_RD,
813 &sc->sc_stats.ast_rx_2040, 0, "number of HT/40 frames received");
814 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_pre_crc_err", CTLFLAG_RD,
815 &sc->sc_stats.ast_rx_pre_crc_err, 0, "number of delimeter-CRC errors detected");
816 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_post_crc_err", CTLFLAG_RD,
817 &sc->sc_stats.ast_rx_post_crc_err, 0, "number of post-delimiter CRC errors detected");
818 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_decrypt_busy_err", CTLFLAG_RD,
819 &sc->sc_stats.ast_rx_decrypt_busy_err, 0, "number of frames received w/ busy decrypt engine");
820 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_hi_rx_chain", CTLFLAG_RD,
821 &sc->sc_stats.ast_rx_hi_rx_chain, 0, "");
822 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_htprotect", CTLFLAG_RD,
823 &sc->sc_stats.ast_tx_htprotect, 0, "HT tx frames with protection");
824 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_hitqueueend", CTLFLAG_RD,
825 &sc->sc_stats.ast_rx_hitqueueend, 0, "RX hit queue end");
826 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_timeout", CTLFLAG_RD,
827 &sc->sc_stats.ast_tx_timeout, 0, "TX Global Timeout");
828 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_cst", CTLFLAG_RD,
829 &sc->sc_stats.ast_tx_cst, 0, "TX Carrier Sense Timeout");
830 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_xtxop", CTLFLAG_RD,
831 &sc->sc_stats.ast_tx_xtxop, 0, "TX exceeded TXOP");
832 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_timerexpired", CTLFLAG_RD,
833 &sc->sc_stats.ast_tx_timerexpired, 0, "TX exceeded TX_TIMER register");
834 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_desccfgerr", CTLFLAG_RD,
835 &sc->sc_stats.ast_tx_desccfgerr, 0, "TX Descriptor Cfg Error");
836 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_swretries", CTLFLAG_RD,
837 &sc->sc_stats.ast_tx_swretries, 0, "TX software retry count");
838 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_swretrymax", CTLFLAG_RD,
839 &sc->sc_stats.ast_tx_swretrymax, 0, "TX software retry max reached");
840
841 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_data_underrun", CTLFLAG_RD,
842 &sc->sc_stats.ast_tx_data_underrun, 0, "");
843 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_delim_underrun", CTLFLAG_RD,
844 &sc->sc_stats.ast_tx_delim_underrun, 0, "");
845 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_aggr_failall", CTLFLAG_RD,
846 &sc->sc_stats.ast_tx_aggr_failall, 0,
847 "Number of aggregate TX failures (whole frame)");
848 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_aggr_ok", CTLFLAG_RD,
849 &sc->sc_stats.ast_tx_aggr_ok, 0,
850 "Number of aggregate TX OK completions (subframe)");
851 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_aggr_fail", CTLFLAG_RD,
852 &sc->sc_stats.ast_tx_aggr_fail, 0,
853 "Number of aggregate TX failures (subframe)");
854
855 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_intr", CTLFLAG_RD,
856 &sc->sc_stats.ast_rx_intr, 0, "RX interrupts");
857 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_intr", CTLFLAG_RD,
858 &sc->sc_stats.ast_tx_intr, 0, "TX interrupts");
859
860 /* Attach the RX phy error array */
861 ath_sysctl_stats_attach_rxphyerr(sc, child);
862}
863
864/*
865 * This doesn't necessarily belong here (because it's HAL related, not
866 * driver related).
867 */
868void
869ath_sysctl_hal_attach(struct ath_softc *sc)
870{
871 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
872 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
873 struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
874
875 tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "hal", CTLFLAG_RD,
876 NULL, "Atheros HAL parameters");
877 child = SYSCTL_CHILDREN(tree);
878
879 sc->sc_ah->ah_config.ah_debug = 0;
880 SYSCTL_ADD_INT(ctx, child, OID_AUTO, "debug", CTLFLAG_RW,
881 &sc->sc_ah->ah_config.ah_debug, 0, "Atheros HAL debugging printfs");
882
883 sc->sc_ah->ah_config.ah_ar5416_biasadj = 0;
884 SYSCTL_ADD_INT(ctx, child, OID_AUTO, "ar5416_biasadj", CTLFLAG_RW,
885 &sc->sc_ah->ah_config.ah_ar5416_biasadj, 0,
886 "Enable 2ghz AR5416 direction sensitivity bias adjust");
887
888 sc->sc_ah->ah_config.ah_dma_beacon_response_time = 2;
889 SYSCTL_ADD_INT(ctx, child, OID_AUTO, "dma_brt", CTLFLAG_RW,
890 &sc->sc_ah->ah_config.ah_dma_beacon_response_time, 0,
891 "Atheros HAL DMA beacon response time");
892
893 sc->sc_ah->ah_config.ah_sw_beacon_response_time = 10;
894 SYSCTL_ADD_INT(ctx, child, OID_AUTO, "sw_brt", CTLFLAG_RW,
895 &sc->sc_ah->ah_config.ah_sw_beacon_response_time, 0,
896 "Atheros HAL software beacon response time");
897
898 sc->sc_ah->ah_config.ah_additional_swba_backoff = 0;
899 SYSCTL_ADD_INT(ctx, child, OID_AUTO, "swba_backoff", CTLFLAG_RW,
900 &sc->sc_ah->ah_config.ah_additional_swba_backoff, 0,
901 "Atheros HAL additional SWBA backoff time");
902
903 sc->sc_ah->ah_config.ah_force_full_reset = 0;
904 SYSCTL_ADD_INT(ctx, child, OID_AUTO, "force_full_reset", CTLFLAG_RW,
905 &sc->sc_ah->ah_config.ah_force_full_reset, 0,
906 "Force full chip reset rather than a warm reset");
907
908 /*
909 * This is initialised by the driver.
910 */
911 SYSCTL_ADD_INT(ctx, child, OID_AUTO, "serialise_reg_war", CTLFLAG_RW,
912 &sc->sc_ah->ah_config.ah_serialise_reg_war, 0,
913 "Force register access serialisation");
914}
176 }
177 }
178 return 0;
179}
180
181static int
182ath_sysctl_txantenna(SYSCTL_HANDLER_ARGS)
183{
184 struct ath_softc *sc = arg1;
185 u_int txantenna = ath_hal_getantennaswitch(sc->sc_ah);
186 int error;
187
188 error = sysctl_handle_int(oidp, &txantenna, 0, req);
189 if (!error && req->newptr) {
190 /* XXX assumes 2 antenna ports */
191 if (txantenna < HAL_ANT_VARIABLE || txantenna > HAL_ANT_FIXED_B)
192 return EINVAL;
193 ath_hal_setantennaswitch(sc->sc_ah, txantenna);
194 /*
195 * NB: with the switch locked this isn't meaningful,
196 * but set it anyway so things like radiotap get
197 * consistent info in their data.
198 */
199 sc->sc_txantenna = txantenna;
200 }
201 return error;
202}
203
204static int
205ath_sysctl_rxantenna(SYSCTL_HANDLER_ARGS)
206{
207 struct ath_softc *sc = arg1;
208 u_int defantenna = ath_hal_getdefantenna(sc->sc_ah);
209 int error;
210
211 error = sysctl_handle_int(oidp, &defantenna, 0, req);
212 if (!error && req->newptr)
213 ath_hal_setdefantenna(sc->sc_ah, defantenna);
214 return error;
215}
216
217static int
218ath_sysctl_diversity(SYSCTL_HANDLER_ARGS)
219{
220 struct ath_softc *sc = arg1;
221 u_int diversity = ath_hal_getdiversity(sc->sc_ah);
222 int error;
223
224 error = sysctl_handle_int(oidp, &diversity, 0, req);
225 if (error || !req->newptr)
226 return error;
227 if (!ath_hal_setdiversity(sc->sc_ah, diversity))
228 return EINVAL;
229 sc->sc_diversity = diversity;
230 return 0;
231}
232
233static int
234ath_sysctl_diag(SYSCTL_HANDLER_ARGS)
235{
236 struct ath_softc *sc = arg1;
237 u_int32_t diag;
238 int error;
239
240 if (!ath_hal_getdiag(sc->sc_ah, &diag))
241 return EINVAL;
242 error = sysctl_handle_int(oidp, &diag, 0, req);
243 if (error || !req->newptr)
244 return error;
245 return !ath_hal_setdiag(sc->sc_ah, diag) ? EINVAL : 0;
246}
247
248static int
249ath_sysctl_tpscale(SYSCTL_HANDLER_ARGS)
250{
251 struct ath_softc *sc = arg1;
252 struct ifnet *ifp = sc->sc_ifp;
253 u_int32_t scale;
254 int error;
255
256 (void) ath_hal_gettpscale(sc->sc_ah, &scale);
257 error = sysctl_handle_int(oidp, &scale, 0, req);
258 if (error || !req->newptr)
259 return error;
260 return !ath_hal_settpscale(sc->sc_ah, scale) ? EINVAL :
261 (ifp->if_drv_flags & IFF_DRV_RUNNING) ?
262 ath_reset(ifp, ATH_RESET_NOLOSS) : 0;
263}
264
265static int
266ath_sysctl_tpc(SYSCTL_HANDLER_ARGS)
267{
268 struct ath_softc *sc = arg1;
269 u_int tpc = ath_hal_gettpc(sc->sc_ah);
270 int error;
271
272 error = sysctl_handle_int(oidp, &tpc, 0, req);
273 if (error || !req->newptr)
274 return error;
275 return !ath_hal_settpc(sc->sc_ah, tpc) ? EINVAL : 0;
276}
277
278static int
279ath_sysctl_rfkill(SYSCTL_HANDLER_ARGS)
280{
281 struct ath_softc *sc = arg1;
282 struct ifnet *ifp = sc->sc_ifp;
283 struct ath_hal *ah = sc->sc_ah;
284 u_int rfkill = ath_hal_getrfkill(ah);
285 int error;
286
287 error = sysctl_handle_int(oidp, &rfkill, 0, req);
288 if (error || !req->newptr)
289 return error;
290 if (rfkill == ath_hal_getrfkill(ah)) /* unchanged */
291 return 0;
292 if (!ath_hal_setrfkill(ah, rfkill))
293 return EINVAL;
294 return (ifp->if_drv_flags & IFF_DRV_RUNNING) ?
295 ath_reset(ifp, ATH_RESET_FULL) : 0;
296}
297
298static int
299ath_sysctl_txagg(SYSCTL_HANDLER_ARGS)
300{
301 struct ath_softc *sc = arg1;
302 int i, t, param = 0;
303 int error;
304 struct ath_buf *bf;
305
306 error = sysctl_handle_int(oidp, &param, 0, req);
307 if (error || !req->newptr)
308 return error;
309
310 if (param != 1)
311 return 0;
312
313 printf("no tx bufs (empty list): %d\n", sc->sc_stats.ast_tx_getnobuf);
314 printf("no tx bufs (was busy): %d\n", sc->sc_stats.ast_tx_getbusybuf);
315
316 printf("aggr single packet: %d\n",
317 sc->sc_aggr_stats.aggr_single_pkt);
318 printf("aggr single packet w/ BAW closed: %d\n",
319 sc->sc_aggr_stats.aggr_baw_closed_single_pkt);
320 printf("aggr non-baw packet: %d\n",
321 sc->sc_aggr_stats.aggr_nonbaw_pkt);
322 printf("aggr aggregate packet: %d\n",
323 sc->sc_aggr_stats.aggr_aggr_pkt);
324 printf("aggr single packet low hwq: %d\n",
325 sc->sc_aggr_stats.aggr_low_hwq_single_pkt);
326 printf("aggr sched, no work: %d\n",
327 sc->sc_aggr_stats.aggr_sched_nopkt);
328 for (i = 0; i < 64; i++) {
329 printf("%2d: %10d ", i, sc->sc_aggr_stats.aggr_pkts[i]);
330 if (i % 4 == 3)
331 printf("\n");
332 }
333 printf("\n");
334
335 for (i = 0; i < HAL_NUM_TX_QUEUES; i++) {
336 if (ATH_TXQ_SETUP(sc, i)) {
337 printf("HW TXQ %d: axq_depth=%d, axq_aggr_depth=%d\n",
338 i,
339 sc->sc_txq[i].axq_depth,
340 sc->sc_txq[i].axq_aggr_depth);
341 }
342 }
343
344 i = t = 0;
345 ATH_TXBUF_LOCK(sc);
346 TAILQ_FOREACH(bf, &sc->sc_txbuf, bf_list) {
347 if (bf->bf_flags & ATH_BUF_BUSY) {
348 printf("Busy: %d\n", t);
349 i++;
350 }
351 t++;
352 }
353 ATH_TXBUF_UNLOCK(sc);
354 printf("Total TX buffers: %d; Total TX buffers busy: %d\n",
355 t, i);
356
357 return 0;
358}
359
360static int
361ath_sysctl_rfsilent(SYSCTL_HANDLER_ARGS)
362{
363 struct ath_softc *sc = arg1;
364 u_int rfsilent;
365 int error;
366
367 (void) ath_hal_getrfsilent(sc->sc_ah, &rfsilent);
368 error = sysctl_handle_int(oidp, &rfsilent, 0, req);
369 if (error || !req->newptr)
370 return error;
371 if (!ath_hal_setrfsilent(sc->sc_ah, rfsilent))
372 return EINVAL;
373 sc->sc_rfsilentpin = rfsilent & 0x1c;
374 sc->sc_rfsilentpol = (rfsilent & 0x2) != 0;
375 return 0;
376}
377
378static int
379ath_sysctl_tpack(SYSCTL_HANDLER_ARGS)
380{
381 struct ath_softc *sc = arg1;
382 u_int32_t tpack;
383 int error;
384
385 (void) ath_hal_gettpack(sc->sc_ah, &tpack);
386 error = sysctl_handle_int(oidp, &tpack, 0, req);
387 if (error || !req->newptr)
388 return error;
389 return !ath_hal_settpack(sc->sc_ah, tpack) ? EINVAL : 0;
390}
391
392static int
393ath_sysctl_tpcts(SYSCTL_HANDLER_ARGS)
394{
395 struct ath_softc *sc = arg1;
396 u_int32_t tpcts;
397 int error;
398
399 (void) ath_hal_gettpcts(sc->sc_ah, &tpcts);
400 error = sysctl_handle_int(oidp, &tpcts, 0, req);
401 if (error || !req->newptr)
402 return error;
403 return !ath_hal_settpcts(sc->sc_ah, tpcts) ? EINVAL : 0;
404}
405
406static int
407ath_sysctl_intmit(SYSCTL_HANDLER_ARGS)
408{
409 struct ath_softc *sc = arg1;
410 int intmit, error;
411
412 intmit = ath_hal_getintmit(sc->sc_ah);
413 error = sysctl_handle_int(oidp, &intmit, 0, req);
414 if (error || !req->newptr)
415 return error;
416
417 /* reusing error; 1 here means "good"; 0 means "fail" */
418 error = ath_hal_setintmit(sc->sc_ah, intmit);
419 if (! error)
420 return EINVAL;
421
422 /*
423 * Reset the hardware here - disabling ANI in the HAL
424 * doesn't reset ANI related registers, so it'll leave
425 * things in an inconsistent state.
426 */
427 if (sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING)
428 ath_reset(sc->sc_ifp, ATH_RESET_NOLOSS);
429
430 return 0;
431}
432
433#ifdef IEEE80211_SUPPORT_TDMA
434static int
435ath_sysctl_setcca(SYSCTL_HANDLER_ARGS)
436{
437 struct ath_softc *sc = arg1;
438 int setcca, error;
439
440 setcca = sc->sc_setcca;
441 error = sysctl_handle_int(oidp, &setcca, 0, req);
442 if (error || !req->newptr)
443 return error;
444 sc->sc_setcca = (setcca != 0);
445 return 0;
446}
447#endif /* IEEE80211_SUPPORT_TDMA */
448
449static int
450ath_sysctl_forcebstuck(SYSCTL_HANDLER_ARGS)
451{
452 struct ath_softc *sc = arg1;
453 int val = 0;
454 int error;
455
456 error = sysctl_handle_int(oidp, &val, 0, req);
457 if (error || !req->newptr)
458 return error;
459 if (val == 0)
460 return 0;
461
462 taskqueue_enqueue_fast(sc->sc_tq, &sc->sc_bstucktask);
463 val = 0;
464 return 0;
465}
466
467void
468ath_sysctlattach(struct ath_softc *sc)
469{
470 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
471 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
472 struct ath_hal *ah = sc->sc_ah;
473
474 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
475 "countrycode", CTLFLAG_RD, &sc->sc_eecc, 0,
476 "EEPROM country code");
477 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
478 "regdomain", CTLFLAG_RD, &sc->sc_eerd, 0,
479 "EEPROM regdomain code");
480#ifdef ATH_DEBUG
481 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
482 "debug", CTLFLAG_RW, &sc->sc_debug, 0,
483 "control debugging printfs");
484#endif
485 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
486 "slottime", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
487 ath_sysctl_slottime, "I", "802.11 slot time (us)");
488 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
489 "acktimeout", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
490 ath_sysctl_acktimeout, "I", "802.11 ACK timeout (us)");
491 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
492 "ctstimeout", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
493 ath_sysctl_ctstimeout, "I", "802.11 CTS timeout (us)");
494 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
495 "softled", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
496 ath_sysctl_softled, "I", "enable/disable software LED support");
497 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
498 "ledpin", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
499 ath_sysctl_ledpin, "I", "GPIO pin connected to LED");
500 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
501 "ledon", CTLFLAG_RW, &sc->sc_ledon, 0,
502 "setting to turn LED on");
503 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
504 "ledidle", CTLFLAG_RW, &sc->sc_ledidle, 0,
505 "idle time for inactivity LED (ticks)");
506 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
507 "txantenna", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
508 ath_sysctl_txantenna, "I", "antenna switch");
509 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
510 "rxantenna", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
511 ath_sysctl_rxantenna, "I", "default/rx antenna");
512 if (ath_hal_hasdiversity(ah))
513 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
514 "diversity", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
515 ath_sysctl_diversity, "I", "antenna diversity");
516 sc->sc_txintrperiod = ATH_TXINTR_PERIOD;
517 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
518 "txintrperiod", CTLFLAG_RW, &sc->sc_txintrperiod, 0,
519 "tx descriptor batching");
520 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
521 "diag", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
522 ath_sysctl_diag, "I", "h/w diagnostic control");
523 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
524 "tpscale", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
525 ath_sysctl_tpscale, "I", "tx power scaling");
526 if (ath_hal_hastpc(ah)) {
527 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
528 "tpc", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
529 ath_sysctl_tpc, "I", "enable/disable per-packet TPC");
530 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
531 "tpack", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
532 ath_sysctl_tpack, "I", "tx power for ack frames");
533 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
534 "tpcts", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
535 ath_sysctl_tpcts, "I", "tx power for cts frames");
536 }
537 if (ath_hal_hasrfsilent(ah)) {
538 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
539 "rfsilent", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
540 ath_sysctl_rfsilent, "I", "h/w RF silent config");
541 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
542 "rfkill", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
543 ath_sysctl_rfkill, "I", "enable/disable RF kill switch");
544 }
545
546 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
547 "txagg", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
548 ath_sysctl_txagg, "I", "");
549
550 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
551 "forcebstuck", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
552 ath_sysctl_forcebstuck, "I", "");
553
554 if (ath_hal_hasintmit(ah)) {
555 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
556 "intmit", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
557 ath_sysctl_intmit, "I", "interference mitigation");
558 }
559 sc->sc_monpass = HAL_RXERR_DECRYPT | HAL_RXERR_MIC;
560 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
561 "monpass", CTLFLAG_RW, &sc->sc_monpass, 0,
562 "mask of error frames to pass when monitoring");
563
564 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
565 "hwq_limit", CTLFLAG_RW, &sc->sc_hwq_limit, 0,
566 "");
567 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
568 "tid_hwq_lo", CTLFLAG_RW, &sc->sc_tid_hwq_lo, 0,
569 "");
570 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
571 "tid_hwq_hi", CTLFLAG_RW, &sc->sc_tid_hwq_hi, 0,
572 "");
573
574#ifdef IEEE80211_SUPPORT_TDMA
575 if (ath_hal_macversion(ah) > 0x78) {
576 sc->sc_tdmadbaprep = 2;
577 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
578 "dbaprep", CTLFLAG_RW, &sc->sc_tdmadbaprep, 0,
579 "TDMA DBA preparation time");
580 sc->sc_tdmaswbaprep = 10;
581 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
582 "swbaprep", CTLFLAG_RW, &sc->sc_tdmaswbaprep, 0,
583 "TDMA SWBA preparation time");
584 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
585 "guardtime", CTLFLAG_RW, &sc->sc_tdmaguard, 0,
586 "TDMA slot guard time");
587 SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
588 "superframe", CTLFLAG_RD, &sc->sc_tdmabintval, 0,
589 "TDMA calculated super frame");
590 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
591 "setcca", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
592 ath_sysctl_setcca, "I", "enable CCA control");
593 }
594#endif
595}
596
597static int
598ath_sysctl_clearstats(SYSCTL_HANDLER_ARGS)
599{
600 struct ath_softc *sc = arg1;
601 int val = 0;
602 int error;
603
604 error = sysctl_handle_int(oidp, &val, 0, req);
605 if (error || !req->newptr)
606 return error;
607 if (val == 0)
608 return 0; /* Not clearing the stats is still valid */
609 memset(&sc->sc_stats, 0, sizeof(sc->sc_stats));
610 memset(&sc->sc_aggr_stats, 0, sizeof(sc->sc_aggr_stats));
611
612 val = 0;
613 return 0;
614}
615
616static void
617ath_sysctl_stats_attach_rxphyerr(struct ath_softc *sc, struct sysctl_oid_list *parent)
618{
619 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
620 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
621 struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
622 int i;
623 char sn[8];
624
625 tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "rx_phy_err", CTLFLAG_RD, NULL, "Per-code RX PHY Errors");
626 child = SYSCTL_CHILDREN(tree);
627 for (i = 0; i < 64; i++) {
628 snprintf(sn, sizeof(sn), "%d", i);
629 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, sn, CTLFLAG_RD, &sc->sc_stats.ast_rx_phy[i], 0, "");
630 }
631}
632
633void
634ath_sysctl_stats_attach(struct ath_softc *sc)
635{
636 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
637 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
638 struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
639
640 /* Create "clear" node */
641 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
642 "clear_stats", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
643 ath_sysctl_clearstats, "I", "clear stats");
644
645 /* Create stats node */
646 tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats", CTLFLAG_RD,
647 NULL, "Statistics");
648 child = SYSCTL_CHILDREN(tree);
649
650 /* This was generated from if_athioctl.h */
651
652 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_watchdog", CTLFLAG_RD,
653 &sc->sc_stats.ast_watchdog, 0, "device reset by watchdog");
654 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_hardware", CTLFLAG_RD,
655 &sc->sc_stats.ast_hardware, 0, "fatal hardware error interrupts");
656 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_bmiss", CTLFLAG_RD,
657 &sc->sc_stats.ast_bmiss, 0, "beacon miss interrupts");
658 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_bmiss_phantom", CTLFLAG_RD,
659 &sc->sc_stats.ast_bmiss_phantom, 0, "beacon miss interrupts");
660 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_bstuck", CTLFLAG_RD,
661 &sc->sc_stats.ast_bstuck, 0, "beacon stuck interrupts");
662 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rxorn", CTLFLAG_RD,
663 &sc->sc_stats.ast_rxorn, 0, "rx overrun interrupts");
664 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rxeol", CTLFLAG_RD,
665 &sc->sc_stats.ast_rxeol, 0, "rx eol interrupts");
666 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_txurn", CTLFLAG_RD,
667 &sc->sc_stats.ast_txurn, 0, "tx underrun interrupts");
668 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_mib", CTLFLAG_RD,
669 &sc->sc_stats.ast_mib, 0, "mib interrupts");
670 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_intrcoal", CTLFLAG_RD,
671 &sc->sc_stats.ast_intrcoal, 0, "interrupts coalesced");
672 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_packets", CTLFLAG_RD,
673 &sc->sc_stats.ast_tx_packets, 0, "packet sent on the interface");
674 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_mgmt", CTLFLAG_RD,
675 &sc->sc_stats.ast_tx_mgmt, 0, "management frames transmitted");
676 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_discard", CTLFLAG_RD,
677 &sc->sc_stats.ast_tx_discard, 0, "frames discarded prior to assoc");
678 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_qstop", CTLFLAG_RD,
679 &sc->sc_stats.ast_tx_qstop, 0, "output stopped 'cuz no buffer");
680 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_encap", CTLFLAG_RD,
681 &sc->sc_stats.ast_tx_encap, 0, "tx encapsulation failed");
682 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nonode", CTLFLAG_RD,
683 &sc->sc_stats.ast_tx_nonode, 0, "tx failed 'cuz no node");
684 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nombuf", CTLFLAG_RD,
685 &sc->sc_stats.ast_tx_nombuf, 0, "tx failed 'cuz no mbuf");
686 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nomcl", CTLFLAG_RD,
687 &sc->sc_stats.ast_tx_nomcl, 0, "tx failed 'cuz no cluster");
688 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_linear", CTLFLAG_RD,
689 &sc->sc_stats.ast_tx_linear, 0, "tx linearized to cluster");
690 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nodata", CTLFLAG_RD,
691 &sc->sc_stats.ast_tx_nodata, 0, "tx discarded empty frame");
692 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_busdma", CTLFLAG_RD,
693 &sc->sc_stats.ast_tx_busdma, 0, "tx failed for dma resrcs");
694 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_xretries", CTLFLAG_RD,
695 &sc->sc_stats.ast_tx_xretries, 0, "tx failed 'cuz too many retries");
696 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_fifoerr", CTLFLAG_RD,
697 &sc->sc_stats.ast_tx_fifoerr, 0, "tx failed 'cuz FIFO underrun");
698 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_filtered", CTLFLAG_RD,
699 &sc->sc_stats.ast_tx_filtered, 0, "tx failed 'cuz xmit filtered");
700 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_shortretry", CTLFLAG_RD,
701 &sc->sc_stats.ast_tx_shortretry, 0, "tx on-chip retries (short)");
702 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_longretry", CTLFLAG_RD,
703 &sc->sc_stats.ast_tx_longretry, 0, "tx on-chip retries (long)");
704 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_badrate", CTLFLAG_RD,
705 &sc->sc_stats.ast_tx_badrate, 0, "tx failed 'cuz bogus xmit rate");
706 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_noack", CTLFLAG_RD,
707 &sc->sc_stats.ast_tx_noack, 0, "tx frames with no ack marked");
708 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_rts", CTLFLAG_RD,
709 &sc->sc_stats.ast_tx_rts, 0, "tx frames with rts enabled");
710 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_cts", CTLFLAG_RD,
711 &sc->sc_stats.ast_tx_cts, 0, "tx frames with cts enabled");
712 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_shortpre", CTLFLAG_RD,
713 &sc->sc_stats.ast_tx_shortpre, 0, "tx frames with short preamble");
714 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_altrate", CTLFLAG_RD,
715 &sc->sc_stats.ast_tx_altrate, 0, "tx frames with alternate rate");
716 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_protect", CTLFLAG_RD,
717 &sc->sc_stats.ast_tx_protect, 0, "tx frames with protection");
718 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_ctsburst", CTLFLAG_RD,
719 &sc->sc_stats.ast_tx_ctsburst, 0, "tx frames with cts and bursting");
720 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_ctsext", CTLFLAG_RD,
721 &sc->sc_stats.ast_tx_ctsext, 0, "tx frames with cts extension");
722 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_nombuf", CTLFLAG_RD,
723 &sc->sc_stats.ast_rx_nombuf, 0, "rx setup failed 'cuz no mbuf");
724 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_busdma", CTLFLAG_RD,
725 &sc->sc_stats.ast_rx_busdma, 0, "rx setup failed for dma resrcs");
726 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_orn", CTLFLAG_RD,
727 &sc->sc_stats.ast_rx_orn, 0, "rx failed 'cuz of desc overrun");
728 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_crcerr", CTLFLAG_RD,
729 &sc->sc_stats.ast_rx_crcerr, 0, "rx failed 'cuz of bad CRC");
730 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_fifoerr", CTLFLAG_RD,
731 &sc->sc_stats.ast_rx_fifoerr, 0, "rx failed 'cuz of FIFO overrun");
732 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_badcrypt", CTLFLAG_RD,
733 &sc->sc_stats.ast_rx_badcrypt, 0, "rx failed 'cuz decryption");
734 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_badmic", CTLFLAG_RD,
735 &sc->sc_stats.ast_rx_badmic, 0, "rx failed 'cuz MIC failure");
736 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_phyerr", CTLFLAG_RD,
737 &sc->sc_stats.ast_rx_phyerr, 0, "rx failed 'cuz of PHY err");
738 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_tooshort", CTLFLAG_RD,
739 &sc->sc_stats.ast_rx_tooshort, 0, "rx discarded 'cuz frame too short");
740 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_toobig", CTLFLAG_RD,
741 &sc->sc_stats.ast_rx_toobig, 0, "rx discarded 'cuz frame too large");
742 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_packets", CTLFLAG_RD,
743 &sc->sc_stats.ast_rx_packets, 0, "packet recv on the interface");
744 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_mgt", CTLFLAG_RD,
745 &sc->sc_stats.ast_rx_mgt, 0, "management frames received");
746 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_ctl", CTLFLAG_RD,
747 &sc->sc_stats.ast_rx_ctl, 0, "rx discarded 'cuz ctl frame");
748 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_be_xmit", CTLFLAG_RD,
749 &sc->sc_stats.ast_be_xmit, 0, "beacons transmitted");
750 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_be_nombuf", CTLFLAG_RD,
751 &sc->sc_stats.ast_be_nombuf, 0, "beacon setup failed 'cuz no mbuf");
752 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_per_cal", CTLFLAG_RD,
753 &sc->sc_stats.ast_per_cal, 0, "periodic calibration calls");
754 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_per_calfail", CTLFLAG_RD,
755 &sc->sc_stats.ast_per_calfail, 0, "periodic calibration failed");
756 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_per_rfgain", CTLFLAG_RD,
757 &sc->sc_stats.ast_per_rfgain, 0, "periodic calibration rfgain reset");
758 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rate_calls", CTLFLAG_RD,
759 &sc->sc_stats.ast_rate_calls, 0, "rate control checks");
760 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rate_raise", CTLFLAG_RD,
761 &sc->sc_stats.ast_rate_raise, 0, "rate control raised xmit rate");
762 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rate_drop", CTLFLAG_RD,
763 &sc->sc_stats.ast_rate_drop, 0, "rate control dropped xmit rate");
764 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ant_defswitch", CTLFLAG_RD,
765 &sc->sc_stats.ast_ant_defswitch, 0, "rx/default antenna switches");
766 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ant_txswitch", CTLFLAG_RD,
767 &sc->sc_stats.ast_ant_txswitch, 0, "tx antenna switches");
768 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_cabq_xmit", CTLFLAG_RD,
769 &sc->sc_stats.ast_cabq_xmit, 0, "cabq frames transmitted");
770 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_cabq_busy", CTLFLAG_RD,
771 &sc->sc_stats.ast_cabq_busy, 0, "cabq found busy");
772 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_raw", CTLFLAG_RD,
773 &sc->sc_stats.ast_tx_raw, 0, "tx frames through raw api");
774 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ff_txok", CTLFLAG_RD,
775 &sc->sc_stats.ast_ff_txok, 0, "fast frames tx'd successfully");
776 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ff_txerr", CTLFLAG_RD,
777 &sc->sc_stats.ast_ff_txerr, 0, "fast frames tx'd w/ error");
778 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ff_rx", CTLFLAG_RD,
779 &sc->sc_stats.ast_ff_rx, 0, "fast frames rx'd");
780 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ff_flush", CTLFLAG_RD,
781 &sc->sc_stats.ast_ff_flush, 0, "fast frames flushed from staging q");
782 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_qfull", CTLFLAG_RD,
783 &sc->sc_stats.ast_tx_qfull, 0, "tx dropped 'cuz of queue limit");
784 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nobuf", CTLFLAG_RD,
785 &sc->sc_stats.ast_tx_nobuf, 0, "tx dropped 'cuz no ath buffer");
786 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tdma_update", CTLFLAG_RD,
787 &sc->sc_stats.ast_tdma_update, 0, "TDMA slot timing updates");
788 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tdma_timers", CTLFLAG_RD,
789 &sc->sc_stats.ast_tdma_timers, 0, "TDMA slot update set beacon timers");
790 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tdma_tsf", CTLFLAG_RD,
791 &sc->sc_stats.ast_tdma_tsf, 0, "TDMA slot update set TSF");
792 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tdma_ack", CTLFLAG_RD,
793 &sc->sc_stats.ast_tdma_ack, 0, "TDMA tx failed 'cuz ACK required");
794 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_raw_fail", CTLFLAG_RD,
795 &sc->sc_stats.ast_tx_raw_fail, 0, "raw tx failed 'cuz h/w down");
796 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nofrag", CTLFLAG_RD,
797 &sc->sc_stats.ast_tx_nofrag, 0, "tx dropped 'cuz no ath frag buffer");
798 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_be_missed", CTLFLAG_RD,
799 &sc->sc_stats.ast_be_missed, 0, "number of -missed- beacons");
800 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_ani_cal", CTLFLAG_RD,
801 &sc->sc_stats.ast_ani_cal, 0, "number of ANI polls");
802 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_agg", CTLFLAG_RD,
803 &sc->sc_stats.ast_rx_agg, 0, "number of aggregate frames received");
804
805 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_halfgi", CTLFLAG_RD,
806 &sc->sc_stats.ast_rx_halfgi, 0, "number of frames received with half-GI");
807 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_2040", CTLFLAG_RD,
808 &sc->sc_stats.ast_rx_2040, 0, "number of HT/40 frames received");
809 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_pre_crc_err", CTLFLAG_RD,
810 &sc->sc_stats.ast_rx_pre_crc_err, 0, "number of delimeter-CRC errors detected");
811 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_post_crc_err", CTLFLAG_RD,
812 &sc->sc_stats.ast_rx_post_crc_err, 0, "number of post-delimiter CRC errors detected");
813 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_decrypt_busy_err", CTLFLAG_RD,
814 &sc->sc_stats.ast_rx_decrypt_busy_err, 0, "number of frames received w/ busy decrypt engine");
815 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_hi_rx_chain", CTLFLAG_RD,
816 &sc->sc_stats.ast_rx_hi_rx_chain, 0, "");
817 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_htprotect", CTLFLAG_RD,
818 &sc->sc_stats.ast_tx_htprotect, 0, "HT tx frames with protection");
819 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_hitqueueend", CTLFLAG_RD,
820 &sc->sc_stats.ast_rx_hitqueueend, 0, "RX hit queue end");
821 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_timeout", CTLFLAG_RD,
822 &sc->sc_stats.ast_tx_timeout, 0, "TX Global Timeout");
823 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_cst", CTLFLAG_RD,
824 &sc->sc_stats.ast_tx_cst, 0, "TX Carrier Sense Timeout");
825 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_xtxop", CTLFLAG_RD,
826 &sc->sc_stats.ast_tx_xtxop, 0, "TX exceeded TXOP");
827 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_timerexpired", CTLFLAG_RD,
828 &sc->sc_stats.ast_tx_timerexpired, 0, "TX exceeded TX_TIMER register");
829 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_desccfgerr", CTLFLAG_RD,
830 &sc->sc_stats.ast_tx_desccfgerr, 0, "TX Descriptor Cfg Error");
831 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_swretries", CTLFLAG_RD,
832 &sc->sc_stats.ast_tx_swretries, 0, "TX software retry count");
833 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_swretrymax", CTLFLAG_RD,
834 &sc->sc_stats.ast_tx_swretrymax, 0, "TX software retry max reached");
835
836 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_data_underrun", CTLFLAG_RD,
837 &sc->sc_stats.ast_tx_data_underrun, 0, "");
838 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_delim_underrun", CTLFLAG_RD,
839 &sc->sc_stats.ast_tx_delim_underrun, 0, "");
840 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_aggr_failall", CTLFLAG_RD,
841 &sc->sc_stats.ast_tx_aggr_failall, 0,
842 "Number of aggregate TX failures (whole frame)");
843 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_aggr_ok", CTLFLAG_RD,
844 &sc->sc_stats.ast_tx_aggr_ok, 0,
845 "Number of aggregate TX OK completions (subframe)");
846 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_aggr_fail", CTLFLAG_RD,
847 &sc->sc_stats.ast_tx_aggr_fail, 0,
848 "Number of aggregate TX failures (subframe)");
849
850 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_intr", CTLFLAG_RD,
851 &sc->sc_stats.ast_rx_intr, 0, "RX interrupts");
852 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_intr", CTLFLAG_RD,
853 &sc->sc_stats.ast_tx_intr, 0, "TX interrupts");
854
855 /* Attach the RX phy error array */
856 ath_sysctl_stats_attach_rxphyerr(sc, child);
857}
858
859/*
860 * This doesn't necessarily belong here (because it's HAL related, not
861 * driver related).
862 */
863void
864ath_sysctl_hal_attach(struct ath_softc *sc)
865{
866 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
867 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
868 struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
869
870 tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "hal", CTLFLAG_RD,
871 NULL, "Atheros HAL parameters");
872 child = SYSCTL_CHILDREN(tree);
873
874 sc->sc_ah->ah_config.ah_debug = 0;
875 SYSCTL_ADD_INT(ctx, child, OID_AUTO, "debug", CTLFLAG_RW,
876 &sc->sc_ah->ah_config.ah_debug, 0, "Atheros HAL debugging printfs");
877
878 sc->sc_ah->ah_config.ah_ar5416_biasadj = 0;
879 SYSCTL_ADD_INT(ctx, child, OID_AUTO, "ar5416_biasadj", CTLFLAG_RW,
880 &sc->sc_ah->ah_config.ah_ar5416_biasadj, 0,
881 "Enable 2ghz AR5416 direction sensitivity bias adjust");
882
883 sc->sc_ah->ah_config.ah_dma_beacon_response_time = 2;
884 SYSCTL_ADD_INT(ctx, child, OID_AUTO, "dma_brt", CTLFLAG_RW,
885 &sc->sc_ah->ah_config.ah_dma_beacon_response_time, 0,
886 "Atheros HAL DMA beacon response time");
887
888 sc->sc_ah->ah_config.ah_sw_beacon_response_time = 10;
889 SYSCTL_ADD_INT(ctx, child, OID_AUTO, "sw_brt", CTLFLAG_RW,
890 &sc->sc_ah->ah_config.ah_sw_beacon_response_time, 0,
891 "Atheros HAL software beacon response time");
892
893 sc->sc_ah->ah_config.ah_additional_swba_backoff = 0;
894 SYSCTL_ADD_INT(ctx, child, OID_AUTO, "swba_backoff", CTLFLAG_RW,
895 &sc->sc_ah->ah_config.ah_additional_swba_backoff, 0,
896 "Atheros HAL additional SWBA backoff time");
897
898 sc->sc_ah->ah_config.ah_force_full_reset = 0;
899 SYSCTL_ADD_INT(ctx, child, OID_AUTO, "force_full_reset", CTLFLAG_RW,
900 &sc->sc_ah->ah_config.ah_force_full_reset, 0,
901 "Force full chip reset rather than a warm reset");
902
903 /*
904 * This is initialised by the driver.
905 */
906 SYSCTL_ADD_INT(ctx, child, OID_AUTO, "serialise_reg_war", CTLFLAG_RW,
907 &sc->sc_ah->ah_config.ah_serialise_reg_war, 0,
908 "Force register access serialisation");
909}