ath_netbsd.c revision 1.21.16.1 1 1.21.16.1 rmind /* $NetBSD: ath_netbsd.c,v 1.21.16.1 2014/05/18 17:45:37 rmind Exp $ */
2 1.6 xtraeme
3 1.1 dyoung /*-
4 1.1 dyoung * Copyright (c) 2003, 2004 David Young
5 1.1 dyoung * All rights reserved.
6 1.1 dyoung *
7 1.1 dyoung * Redistribution and use in source and binary forms, with or without
8 1.1 dyoung * modification, are permitted provided that the following conditions
9 1.1 dyoung * are met:
10 1.1 dyoung * 1. Redistributions of source code must retain the above copyright
11 1.1 dyoung * notice, this list of conditions and the following disclaimer.
12 1.1 dyoung * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 dyoung * notice, this list of conditions and the following disclaimer in the
14 1.1 dyoung * documentation and/or other materials provided with the distribution.
15 1.1 dyoung *
16 1.1 dyoung * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.1 dyoung * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1 dyoung * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.1 dyoung * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.1 dyoung * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 1.1 dyoung * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 1.1 dyoung * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 1.1 dyoung * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 1.1 dyoung * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 1.1 dyoung * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 1.1 dyoung */
27 1.6 xtraeme
28 1.6 xtraeme #include <sys/cdefs.h>
29 1.21.16.1 rmind __KERNEL_RCSID(0, "$NetBSD: ath_netbsd.c,v 1.21.16.1 2014/05/18 17:45:37 rmind Exp $");
30 1.6 xtraeme
31 1.1 dyoung #include <sys/param.h>
32 1.1 dyoung #include <sys/types.h>
33 1.1 dyoung #include <sys/errno.h>
34 1.9 hubertf #include <sys/systm.h>
35 1.1 dyoung #include <sys/sysctl.h>
36 1.9 hubertf #include <sys/mbuf.h>
37 1.1 dyoung #include <sys/malloc.h>
38 1.1 dyoung #include <sys/kernel.h>
39 1.1 dyoung #include <sys/socket.h>
40 1.1 dyoung #include <sys/sockio.h>
41 1.1 dyoung #include <sys/sysctl.h>
42 1.1 dyoung #include <sys/callout.h>
43 1.11 ad #include <sys/bus.h>
44 1.1 dyoung #include <sys/endian.h>
45 1.2 martin #include <sys/device.h>
46 1.19 jmcneill #include <sys/module.h>
47 1.1 dyoung
48 1.1 dyoung #include <net/if.h>
49 1.1 dyoung #include <net/if_dl.h>
50 1.1 dyoung #include <net/if_media.h>
51 1.1 dyoung #include <net/if_arp.h>
52 1.1 dyoung #include <net/if_ether.h>
53 1.1 dyoung #include <net/if_llc.h>
54 1.1 dyoung
55 1.1 dyoung #include <net80211/ieee80211_netbsd.h>
56 1.1 dyoung #include <net80211/ieee80211_var.h>
57 1.1 dyoung #include <dev/ic/ath_netbsd.h>
58 1.1 dyoung #include <dev/ic/athvar.h>
59 1.3 dyoung
60 1.1 dyoung /*
61 1.7 dyoung * Setup sysctl(3) MIB, hw.ath.*.
62 1.1 dyoung *
63 1.16 ad * TBD condition CTLFLAG_PERMANENT on being a module or not
64 1.1 dyoung */
65 1.1 dyoung SYSCTL_SETUP(sysctl_ath, "sysctl ath subtree setup")
66 1.1 dyoung {
67 1.1 dyoung int rc;
68 1.1 dyoung const struct sysctlnode *cnode, *rnode;
69 1.1 dyoung
70 1.1 dyoung if ((rnode = ath_sysctl_treetop(clog)) == NULL)
71 1.1 dyoung return;
72 1.1 dyoung
73 1.1 dyoung if ((rc = SYSCTL_GLOBAL_INT(CTLFLAG_READWRITE, "dwell",
74 1.1 dyoung "channel dwell time (ms) for AP/station scanning",
75 1.1 dyoung dwelltime)) != 0)
76 1.1 dyoung goto err;
77 1.1 dyoung
78 1.1 dyoung if ((rc = SYSCTL_GLOBAL_INT(CTLFLAG_READWRITE, "calibrate",
79 1.1 dyoung "chip calibration interval (secs)", calinterval)) != 0)
80 1.1 dyoung goto err;
81 1.1 dyoung
82 1.1 dyoung if ((rc = SYSCTL_GLOBAL_INT(CTLFLAG_READWRITE, "outdoor",
83 1.1 dyoung "outdoor operation", outdoor)) != 0)
84 1.1 dyoung goto err;
85 1.1 dyoung
86 1.1 dyoung /* country code */
87 1.1 dyoung if ((rc = SYSCTL_GLOBAL_INT(CTLFLAG_READWRITE,
88 1.1 dyoung "countrycode", "country code", countrycode)) != 0)
89 1.1 dyoung goto err;
90 1.1 dyoung
91 1.1 dyoung /* regulatory domain */
92 1.7 dyoung if ((rc = SYSCTL_GLOBAL_INT(CTLFLAG_READWRITE, "regdomain",
93 1.7 dyoung "EEPROM regdomain code", regdomain)) != 0)
94 1.1 dyoung goto err;
95 1.1 dyoung
96 1.1 dyoung if ((rc = SYSCTL_GLOBAL_INT(CTLFLAG_READWRITE, "debug",
97 1.1 dyoung "control debugging printfs", debug)) != 0)
98 1.1 dyoung goto err;
99 1.1 dyoung
100 1.7 dyoung if ((rc = SYSCTL_GLOBAL_INT(CTLFLAG_READONLY, "rxbuf",
101 1.7 dyoung "rx buffers allocated", rxbuf)) != 0)
102 1.7 dyoung goto err;
103 1.7 dyoung if ((rc = SYSCTL_GLOBAL_INT(CTLFLAG_READONLY, "txbuf",
104 1.7 dyoung "tx buffers allocated", txbuf)) != 0)
105 1.7 dyoung goto err;
106 1.7 dyoung
107 1.1 dyoung return;
108 1.1 dyoung err:
109 1.1 dyoung printf("%s: sysctl_createv failed (rc = %d)\n", __func__, rc);
110 1.1 dyoung }
111 1.1 dyoung
112 1.1 dyoung static int
113 1.1 dyoung ath_sysctl_slottime(SYSCTLFN_ARGS)
114 1.1 dyoung {
115 1.1 dyoung struct ath_softc *sc;
116 1.1 dyoung struct sysctlnode node;
117 1.1 dyoung u_int slottime;
118 1.1 dyoung int error;
119 1.1 dyoung
120 1.1 dyoung node = *rnode;
121 1.1 dyoung sc = (struct ath_softc *)node.sysctl_data;
122 1.1 dyoung slottime = ath_hal_getslottime(sc->sc_ah);
123 1.1 dyoung node.sysctl_data = &slottime;
124 1.1 dyoung error = sysctl_lookup(SYSCTLFN_CALL(&node));
125 1.1 dyoung if (error || newp == NULL)
126 1.1 dyoung return error;
127 1.1 dyoung return !ath_hal_setslottime(sc->sc_ah, slottime) ? EINVAL : 0;
128 1.1 dyoung }
129 1.1 dyoung
130 1.1 dyoung static int
131 1.1 dyoung ath_sysctl_acktimeout(SYSCTLFN_ARGS)
132 1.1 dyoung {
133 1.1 dyoung struct ath_softc *sc;
134 1.1 dyoung struct sysctlnode node;
135 1.1 dyoung u_int acktimeout;
136 1.1 dyoung int error;
137 1.1 dyoung
138 1.1 dyoung node = *rnode;
139 1.1 dyoung sc = (struct ath_softc *)node.sysctl_data;
140 1.1 dyoung acktimeout = ath_hal_getacktimeout(sc->sc_ah);
141 1.1 dyoung node.sysctl_data = &acktimeout;
142 1.1 dyoung error = sysctl_lookup(SYSCTLFN_CALL(&node));
143 1.1 dyoung if (error || newp == NULL)
144 1.1 dyoung return error;
145 1.1 dyoung return !ath_hal_setacktimeout(sc->sc_ah, acktimeout) ? EINVAL : 0;
146 1.1 dyoung }
147 1.1 dyoung
148 1.1 dyoung static int
149 1.1 dyoung ath_sysctl_ctstimeout(SYSCTLFN_ARGS)
150 1.1 dyoung {
151 1.1 dyoung struct ath_softc *sc;
152 1.1 dyoung struct sysctlnode node;
153 1.1 dyoung u_int ctstimeout;
154 1.1 dyoung int error;
155 1.1 dyoung
156 1.1 dyoung node = *rnode;
157 1.1 dyoung sc = (struct ath_softc *)node.sysctl_data;
158 1.1 dyoung ctstimeout = ath_hal_getctstimeout(sc->sc_ah);
159 1.1 dyoung node.sysctl_data = &ctstimeout;
160 1.1 dyoung error = sysctl_lookup(SYSCTLFN_CALL(&node));
161 1.1 dyoung if (error || newp == NULL)
162 1.1 dyoung return error;
163 1.1 dyoung return !ath_hal_setctstimeout(sc->sc_ah, ctstimeout) ? EINVAL : 0;
164 1.1 dyoung }
165 1.1 dyoung
166 1.1 dyoung static int
167 1.1 dyoung ath_sysctl_softled(SYSCTLFN_ARGS)
168 1.1 dyoung {
169 1.1 dyoung struct ath_softc *sc;
170 1.1 dyoung struct sysctlnode node;
171 1.1 dyoung int softled;
172 1.1 dyoung int error;
173 1.1 dyoung
174 1.1 dyoung node = *rnode;
175 1.1 dyoung sc = (struct ath_softc *)node.sysctl_data;
176 1.1 dyoung softled = sc->sc_softled;
177 1.1 dyoung node.sysctl_data = &softled;
178 1.1 dyoung error = sysctl_lookup(SYSCTLFN_CALL(&node));
179 1.1 dyoung if (error || newp == NULL)
180 1.1 dyoung return error;
181 1.1 dyoung softled = (softled != 0);
182 1.1 dyoung if (softled != sc->sc_softled) {
183 1.1 dyoung if (softled) {
184 1.1 dyoung /* NB: handle any sc_ledpin change */
185 1.20 cegger ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin,
186 1.20 cegger HAL_GPIO_MUX_MAC_NETWORK_LED);
187 1.1 dyoung ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin,
188 1.1 dyoung !sc->sc_ledon);
189 1.1 dyoung }
190 1.1 dyoung sc->sc_softled = softled;
191 1.1 dyoung }
192 1.1 dyoung return 0;
193 1.1 dyoung }
194 1.1 dyoung
195 1.1 dyoung static int
196 1.1 dyoung ath_sysctl_rxantenna(SYSCTLFN_ARGS)
197 1.1 dyoung {
198 1.1 dyoung struct ath_softc *sc;
199 1.1 dyoung struct sysctlnode node;
200 1.1 dyoung u_int defantenna;
201 1.1 dyoung int error;
202 1.1 dyoung
203 1.1 dyoung node = *rnode;
204 1.1 dyoung sc = (struct ath_softc *)node.sysctl_data;
205 1.1 dyoung defantenna = ath_hal_getdefantenna(sc->sc_ah);
206 1.1 dyoung node.sysctl_data = &defantenna;
207 1.1 dyoung error = sysctl_lookup(SYSCTLFN_CALL(&node));
208 1.1 dyoung if (error || newp == NULL)
209 1.1 dyoung return error;
210 1.1 dyoung ath_hal_setdefantenna(sc->sc_ah, defantenna);
211 1.1 dyoung return 0;
212 1.1 dyoung }
213 1.1 dyoung
214 1.1 dyoung static int
215 1.1 dyoung ath_sysctl_diversity(SYSCTLFN_ARGS)
216 1.1 dyoung {
217 1.1 dyoung struct ath_softc *sc;
218 1.1 dyoung struct sysctlnode node;
219 1.1 dyoung u_int diversity;
220 1.1 dyoung int error;
221 1.1 dyoung
222 1.1 dyoung node = *rnode;
223 1.1 dyoung sc = (struct ath_softc *)node.sysctl_data;
224 1.1 dyoung diversity = sc->sc_diversity;
225 1.1 dyoung node.sysctl_data = &diversity;
226 1.1 dyoung error = sysctl_lookup(SYSCTLFN_CALL(&node));
227 1.1 dyoung if (error || newp == NULL)
228 1.1 dyoung return error;
229 1.1 dyoung if (!ath_hal_setdiversity(sc->sc_ah, diversity))
230 1.1 dyoung return EINVAL;
231 1.1 dyoung sc->sc_diversity = diversity;
232 1.1 dyoung return 0;
233 1.1 dyoung }
234 1.1 dyoung
235 1.1 dyoung static int
236 1.1 dyoung ath_sysctl_diag(SYSCTLFN_ARGS)
237 1.1 dyoung {
238 1.1 dyoung struct ath_softc *sc;
239 1.1 dyoung struct sysctlnode node;
240 1.1 dyoung u_int32_t diag;
241 1.1 dyoung int error;
242 1.1 dyoung
243 1.1 dyoung node = *rnode;
244 1.1 dyoung sc = (struct ath_softc *)node.sysctl_data;
245 1.1 dyoung if (!ath_hal_getdiag(sc->sc_ah, &diag))
246 1.1 dyoung return EINVAL;
247 1.1 dyoung node.sysctl_data = &diag;
248 1.1 dyoung error = sysctl_lookup(SYSCTLFN_CALL(&node));
249 1.1 dyoung if (error || newp == NULL)
250 1.1 dyoung return error;
251 1.1 dyoung return !ath_hal_setdiag(sc->sc_ah, diag) ? EINVAL : 0;
252 1.1 dyoung }
253 1.1 dyoung
254 1.1 dyoung static int
255 1.1 dyoung ath_sysctl_tpscale(SYSCTLFN_ARGS)
256 1.1 dyoung {
257 1.1 dyoung struct ath_softc *sc;
258 1.1 dyoung struct sysctlnode node;
259 1.1 dyoung u_int32_t scale;
260 1.1 dyoung int error;
261 1.1 dyoung
262 1.1 dyoung node = *rnode;
263 1.1 dyoung sc = (struct ath_softc *)node.sysctl_data;
264 1.8 mrg (void)ath_hal_gettpscale(sc->sc_ah, &scale);
265 1.1 dyoung node.sysctl_data = &scale;
266 1.1 dyoung error = sysctl_lookup(SYSCTLFN_CALL(&node));
267 1.1 dyoung if (error || newp == NULL)
268 1.1 dyoung return error;
269 1.1 dyoung return !ath_hal_settpscale(sc->sc_ah, scale)
270 1.1 dyoung ? EINVAL
271 1.1 dyoung : ath_reset(&sc->sc_if);
272 1.1 dyoung }
273 1.1 dyoung
274 1.1 dyoung static int
275 1.1 dyoung ath_sysctl_tpc(SYSCTLFN_ARGS)
276 1.1 dyoung {
277 1.1 dyoung struct ath_softc *sc;
278 1.1 dyoung struct sysctlnode node;
279 1.1 dyoung u_int tpc;
280 1.1 dyoung int error;
281 1.1 dyoung
282 1.1 dyoung node = *rnode;
283 1.1 dyoung sc = (struct ath_softc *)node.sysctl_data;
284 1.1 dyoung tpc = ath_hal_gettpc(sc->sc_ah);
285 1.1 dyoung node.sysctl_data = &tpc;
286 1.1 dyoung error = sysctl_lookup(SYSCTLFN_CALL(&node));
287 1.1 dyoung if (error || newp == NULL)
288 1.1 dyoung return error;
289 1.1 dyoung return !ath_hal_settpc(sc->sc_ah, tpc) ? EINVAL : 0;
290 1.1 dyoung }
291 1.1 dyoung
292 1.7 dyoung static int
293 1.7 dyoung ath_sysctl_rfkill(SYSCTLFN_ARGS)
294 1.7 dyoung {
295 1.7 dyoung struct ath_softc *sc;
296 1.7 dyoung struct sysctlnode node;
297 1.7 dyoung u_int rfkill;
298 1.7 dyoung int error;
299 1.7 dyoung
300 1.7 dyoung node = *rnode;
301 1.7 dyoung sc = (struct ath_softc *)node.sysctl_data;
302 1.7 dyoung rfkill = ath_hal_getrfkill(sc->sc_ah);
303 1.7 dyoung node.sysctl_data = &rfkill;
304 1.7 dyoung error = sysctl_lookup(SYSCTLFN_CALL(&node));
305 1.7 dyoung if (error || newp == NULL)
306 1.7 dyoung return error;
307 1.7 dyoung return !ath_hal_setrfkill(sc->sc_ah, rfkill) ? EINVAL : 0;
308 1.7 dyoung }
309 1.7 dyoung
310 1.7 dyoung static int
311 1.7 dyoung ath_sysctl_rfsilent(SYSCTLFN_ARGS)
312 1.7 dyoung {
313 1.7 dyoung struct ath_softc *sc;
314 1.7 dyoung struct sysctlnode node;
315 1.7 dyoung u_int rfsilent;
316 1.7 dyoung int error;
317 1.7 dyoung
318 1.7 dyoung node = *rnode;
319 1.7 dyoung sc = (struct ath_softc *)node.sysctl_data;
320 1.8 mrg (void)ath_hal_getrfsilent(sc->sc_ah, &rfsilent);
321 1.7 dyoung node.sysctl_data = &rfsilent;
322 1.7 dyoung error = sysctl_lookup(SYSCTLFN_CALL(&node));
323 1.7 dyoung if (error || newp == NULL)
324 1.7 dyoung return error;
325 1.7 dyoung return !ath_hal_setrfsilent(sc->sc_ah, rfsilent) ? EINVAL : 0;
326 1.7 dyoung }
327 1.7 dyoung
328 1.7 dyoung static int
329 1.7 dyoung ath_sysctl_regdomain(SYSCTLFN_ARGS)
330 1.7 dyoung {
331 1.7 dyoung struct ath_softc *sc;
332 1.7 dyoung struct sysctlnode node;
333 1.7 dyoung u_int32_t rd;
334 1.7 dyoung int error;
335 1.7 dyoung
336 1.7 dyoung node = *rnode;
337 1.7 dyoung sc = (struct ath_softc *)node.sysctl_data;
338 1.7 dyoung if (!ath_hal_getregdomain(sc->sc_ah, &rd))
339 1.7 dyoung return EINVAL;
340 1.7 dyoung node.sysctl_data = &rd;
341 1.7 dyoung error = sysctl_lookup(SYSCTLFN_CALL(&node));
342 1.7 dyoung if (error || newp == NULL)
343 1.7 dyoung return error;
344 1.7 dyoung return !ath_hal_setregdomain(sc->sc_ah, rd) ? EINVAL : 0;
345 1.7 dyoung }
346 1.7 dyoung
347 1.7 dyoung static int
348 1.7 dyoung ath_sysctl_tpack(SYSCTLFN_ARGS)
349 1.7 dyoung {
350 1.7 dyoung struct ath_softc *sc;
351 1.7 dyoung struct sysctlnode node;
352 1.7 dyoung u_int32_t tpack;
353 1.7 dyoung int error;
354 1.7 dyoung
355 1.7 dyoung node = *rnode;
356 1.7 dyoung sc = (struct ath_softc *)node.sysctl_data;
357 1.8 mrg (void)ath_hal_gettpack(sc->sc_ah, &tpack);
358 1.7 dyoung node.sysctl_data = &tpack;
359 1.7 dyoung error = sysctl_lookup(SYSCTLFN_CALL(&node));
360 1.7 dyoung if (error || newp == NULL)
361 1.7 dyoung return error;
362 1.7 dyoung return !ath_hal_settpack(sc->sc_ah, tpack) ? EINVAL : 0;
363 1.7 dyoung }
364 1.7 dyoung
365 1.7 dyoung static int
366 1.7 dyoung ath_sysctl_tpcts(SYSCTLFN_ARGS)
367 1.7 dyoung {
368 1.7 dyoung struct ath_softc *sc;
369 1.7 dyoung struct sysctlnode node;
370 1.7 dyoung u_int32_t tpcts;
371 1.7 dyoung int error;
372 1.7 dyoung
373 1.7 dyoung node = *rnode;
374 1.7 dyoung sc = (struct ath_softc *)node.sysctl_data;
375 1.8 mrg (void)ath_hal_gettpcts(sc->sc_ah, &tpcts);
376 1.7 dyoung node.sysctl_data = &tpcts;
377 1.7 dyoung error = sysctl_lookup(SYSCTLFN_CALL(&node));
378 1.7 dyoung if (error || newp == NULL)
379 1.7 dyoung return error;
380 1.7 dyoung return !ath_hal_settpcts(sc->sc_ah, tpcts) ? EINVAL : 0;
381 1.7 dyoung }
382 1.7 dyoung
383 1.4 dyoung const struct sysctlnode *
384 1.3 dyoung ath_sysctl_instance(const char *dvname, struct sysctllog **log)
385 1.3 dyoung {
386 1.3 dyoung int rc;
387 1.3 dyoung const struct sysctlnode *rnode;
388 1.3 dyoung
389 1.3 dyoung if ((rc = sysctl_createv(log, 0, NULL, &rnode,
390 1.3 dyoung CTLFLAG_PERMANENT, CTLTYPE_NODE, dvname,
391 1.3 dyoung SYSCTL_DESCR("ath information and options"),
392 1.21.16.1 rmind NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL)) != 0)
393 1.3 dyoung goto err;
394 1.3 dyoung
395 1.3 dyoung return rnode;
396 1.3 dyoung err:
397 1.3 dyoung printf("%s: sysctl_createv failed, rc = %d\n", __func__, rc);
398 1.3 dyoung return NULL;
399 1.3 dyoung }
400 1.3 dyoung
401 1.1 dyoung const struct sysctlnode *
402 1.1 dyoung ath_sysctl_treetop(struct sysctllog **log)
403 1.1 dyoung {
404 1.1 dyoung int rc;
405 1.1 dyoung const struct sysctlnode *rnode;
406 1.1 dyoung
407 1.1 dyoung if ((rc = sysctl_createv(log, 0, NULL, &rnode,
408 1.1 dyoung CTLFLAG_PERMANENT, CTLTYPE_NODE, "ath",
409 1.1 dyoung SYSCTL_DESCR("ath information and options"),
410 1.21.16.1 rmind NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL)) != 0)
411 1.1 dyoung goto err;
412 1.1 dyoung
413 1.1 dyoung return rnode;
414 1.1 dyoung err:
415 1.1 dyoung printf("%s: sysctl_createv failed, rc = %d\n", __func__, rc);
416 1.1 dyoung return NULL;
417 1.1 dyoung }
418 1.1 dyoung
419 1.1 dyoung void
420 1.1 dyoung ath_sysctlattach(struct ath_softc *sc)
421 1.1 dyoung {
422 1.1 dyoung int rc;
423 1.1 dyoung struct sysctllog **log = &sc->sc_sysctllog;
424 1.1 dyoung const struct sysctlnode *cnode, *rnode;
425 1.1 dyoung
426 1.1 dyoung ath_hal_getcountrycode(sc->sc_ah, &sc->sc_countrycode);
427 1.8 mrg (void)ath_hal_getregdomain(sc->sc_ah, &sc->sc_regdomain);
428 1.1 dyoung sc->sc_debug = ath_debug;
429 1.1 dyoung sc->sc_txintrperiod = ATH_TXINTR_PERIOD;
430 1.1 dyoung
431 1.15 joerg if ((rnode = ath_sysctl_instance(device_xname(sc->sc_dev), log)) == NULL)
432 1.1 dyoung return;
433 1.1 dyoung
434 1.1 dyoung if ((rc = SYSCTL_INT(0, countrycode, "EEPROM country code")) != 0)
435 1.1 dyoung goto err;
436 1.1 dyoung
437 1.1 dyoung if ((rc = SYSCTL_INT(CTLFLAG_READWRITE, debug,
438 1.1 dyoung "control debugging printfs")) != 0)
439 1.1 dyoung goto err;
440 1.1 dyoung
441 1.1 dyoung #if 0
442 1.1 dyoung /* channel dwell time (ms) for AP/station scanning */
443 1.1 dyoung if ((rc = SYSCTL_INT(CTLFLAG_READWRITE, dwell,
444 1.1 dyoung "Channel dwell time (ms) for scanning")) != 0)
445 1.1 dyoung goto err;
446 1.1 dyoung #endif
447 1.1 dyoung
448 1.1 dyoung if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, slottime,
449 1.1 dyoung "802.11 slot time (us)")) != 0)
450 1.1 dyoung goto err;
451 1.1 dyoung if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, acktimeout,
452 1.1 dyoung "802.11 ACK timeout (us)")) != 0)
453 1.1 dyoung goto err;
454 1.1 dyoung if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, ctstimeout,
455 1.1 dyoung "802.11 CTS timeout (us)")) != 0)
456 1.1 dyoung goto err;
457 1.1 dyoung if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, softled,
458 1.1 dyoung "enable/disable software LED support")) != 0)
459 1.1 dyoung goto err;
460 1.1 dyoung if ((rc = SYSCTL_INT(CTLFLAG_READWRITE, ledpin,
461 1.1 dyoung "GPIO pin connected to LED")) != 0)
462 1.1 dyoung goto err;
463 1.1 dyoung if ((rc = SYSCTL_INT(CTLFLAG_READWRITE, ledon,
464 1.1 dyoung "setting to turn LED on")) != 0)
465 1.1 dyoung goto err;
466 1.1 dyoung if ((rc = SYSCTL_INT(CTLFLAG_READWRITE, ledidle,
467 1.1 dyoung "idle time for inactivity LED (ticks)")) != 0)
468 1.1 dyoung goto err;
469 1.1 dyoung if ((rc = SYSCTL_INT(CTLFLAG_READWRITE, txantenna,
470 1.1 dyoung "tx antenna (0=auto)")) != 0)
471 1.1 dyoung goto err;
472 1.1 dyoung if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, rxantenna,
473 1.1 dyoung "default/rx antenna")) != 0)
474 1.1 dyoung goto err;
475 1.5 skrll if (ath_hal_hasdiversity(sc->sc_ah)) {
476 1.1 dyoung if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, diversity,
477 1.1 dyoung "antenna diversity")) != 0)
478 1.1 dyoung goto err;
479 1.1 dyoung }
480 1.1 dyoung if ((rc = SYSCTL_INT(CTLFLAG_READWRITE, txintrperiod,
481 1.1 dyoung "tx descriptor batching")) != 0)
482 1.1 dyoung goto err;
483 1.1 dyoung if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, diag,
484 1.1 dyoung "h/w diagnostic control")) != 0)
485 1.1 dyoung goto err;
486 1.1 dyoung if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, tpscale,
487 1.1 dyoung "tx power scaling")) != 0)
488 1.1 dyoung goto err;
489 1.5 skrll if (ath_hal_hastpc(sc->sc_ah)) {
490 1.1 dyoung if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, tpc,
491 1.1 dyoung "enable/disable per-packet TPC")) != 0)
492 1.1 dyoung goto err;
493 1.7 dyoung if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, tpack,
494 1.7 dyoung "tx power for ack frames")) != 0)
495 1.7 dyoung goto err;
496 1.7 dyoung if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, tpcts,
497 1.7 dyoung "tx power for cts frames")) != 0)
498 1.7 dyoung goto err;
499 1.1 dyoung }
500 1.7 dyoung if (ath_hal_hasrfsilent(sc->sc_ah)) {
501 1.7 dyoung if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, rfsilent,
502 1.7 dyoung "h/w RF silent config")) != 0)
503 1.7 dyoung goto err;
504 1.7 dyoung if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, rfkill,
505 1.7 dyoung "enable/disable RF kill switch")) != 0)
506 1.7 dyoung goto err;
507 1.7 dyoung }
508 1.7 dyoung if ((rc = SYSCTL_INT_SUBR(CTLFLAG_READWRITE, regdomain,
509 1.7 dyoung "EEPROM regdomain code")) != 0)
510 1.7 dyoung goto err;
511 1.1 dyoung return;
512 1.1 dyoung err:
513 1.1 dyoung printf("%s: sysctl_createv failed, rc = %d\n", __func__, rc);
514 1.1 dyoung }
515 1.19 jmcneill
516 1.19 jmcneill MODULE(MODULE_CLASS_MISC, ath, "ath_hal");
517 1.19 jmcneill
518 1.19 jmcneill static int
519 1.19 jmcneill ath_modcmd(modcmd_t cmd, void *opaque)
520 1.19 jmcneill {
521 1.19 jmcneill switch (cmd) {
522 1.19 jmcneill case MODULE_CMD_INIT:
523 1.19 jmcneill case MODULE_CMD_FINI:
524 1.19 jmcneill return 0;
525 1.19 jmcneill default:
526 1.19 jmcneill return ENOTTY;
527 1.19 jmcneill }
528 1.19 jmcneill }
529