ieee80211_rssadapt.c revision 1.21.16.5 1 1.21.16.5 christos /* $NetBSD: ieee80211_rssadapt.c,v 1.21.16.5 2019/06/10 22:09:46 christos Exp $ */
2 1.21.16.2 phil
3 1.1 dyoung /*-
4 1.21.16.1 phil * SPDX-License-Identifier: BSD-3-Clause
5 1.21.16.1 phil *
6 1.21.16.1 phil * Copyright (c) 2010 Rui Paulo <rpaulo (at) FreeBSD.org>
7 1.1 dyoung * Copyright (c) 2003, 2004 David Young. All rights reserved.
8 1.1 dyoung *
9 1.1 dyoung * Redistribution and use in source and binary forms, with or
10 1.1 dyoung * without modification, are permitted provided that the following
11 1.1 dyoung * conditions are met:
12 1.1 dyoung * 1. Redistributions of source code must retain the above copyright
13 1.1 dyoung * notice, this list of conditions and the following disclaimer.
14 1.1 dyoung * 2. Redistributions in binary form must reproduce the above
15 1.1 dyoung * copyright notice, this list of conditions and the following
16 1.1 dyoung * disclaimer in the documentation and/or other materials provided
17 1.1 dyoung * with the distribution.
18 1.21.16.1 phil * 3. The name of David Young may not be used to endorse or promote
19 1.21.16.1 phil * products derived from this software without specific prior
20 1.21.16.1 phil * written permission.
21 1.1 dyoung *
22 1.1 dyoung * THIS SOFTWARE IS PROVIDED BY David Young ``AS IS'' AND ANY
23 1.1 dyoung * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24 1.1 dyoung * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25 1.1 dyoung * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David
26 1.1 dyoung * Young BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 1.1 dyoung * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
28 1.1 dyoung * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 1.1 dyoung * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 1.1 dyoung * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 1.1 dyoung * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 dyoung * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
33 1.1 dyoung * OF SUCH DAMAGE.
34 1.1 dyoung */
35 1.21.16.5 christos #include <sys/cdefs.h>
36 1.21.16.5 christos #ifdef __NetBSD__
37 1.21.16.5 christos __KERNEL_RCSID(0, "$NetBSD: ieee80211_rssadapt.c,v 1.21.16.5 2019/06/10 22:09:46 christos Exp $");
38 1.21.16.5 christos #endif
39 1.21.16.5 christos
40 1.21.16.5 christos #ifdef _KERNEL_OPT
41 1.21.16.1 phil #include "opt_wlan.h"
42 1.21.16.5 christos #endif
43 1.11 dyoung
44 1.1 dyoung #include <sys/param.h>
45 1.21.16.1 phil #include <sys/systm.h>
46 1.21.16.1 phil #include <sys/kernel.h>
47 1.21.16.1 phil #include <sys/malloc.h>
48 1.21.16.1 phil #include <sys/module.h>
49 1.21.16.2 phil #ifdef __NetBSD__
50 1.21.16.2 phil /* Why doesn't FreeBSD have this? */
51 1.21.16.2 phil #include <sys/sbuf.h>
52 1.21.16.2 phil #endif
53 1.21.16.1 phil #include <sys/socket.h>
54 1.5 dyoung #include <sys/sysctl.h>
55 1.1 dyoung
56 1.1 dyoung #include <net/if.h>
57 1.21.16.2 phil #ifdef __FreeBSD__
58 1.21.16.1 phil #include <net/if_var.h>
59 1.21.16.2 phil #endif
60 1.1 dyoung #include <net/if_media.h>
61 1.21.16.2 phil #ifdef __FreeBSD__
62 1.21.16.1 phil #include <net/ethernet.h>
63 1.21.16.2 phil #endif
64 1.21.16.2 phil #ifdef __NetBSD__
65 1.21.16.2 phil #include <net/route.h>
66 1.21.16.2 phil #endif
67 1.1 dyoung
68 1.1 dyoung #include <net80211/ieee80211_var.h>
69 1.1 dyoung #include <net80211/ieee80211_rssadapt.h>
70 1.21.16.1 phil #include <net80211/ieee80211_ratectl.h>
71 1.1 dyoung
72 1.21.16.2 phil #ifdef __NetBSD__
73 1.21.16.2 phil #undef KASSERT
74 1.21.16.2 phil #define KASSERT(__cond, __complaint) FBSDKASSERT(__cond, __complaint)
75 1.21.16.2 phil #endif
76 1.21.16.2 phil
77 1.21.16.1 phil struct rssadapt_expavgctl {
78 1.21.16.1 phil /* RSS threshold decay. */
79 1.21.16.1 phil u_int rc_decay_denom;
80 1.21.16.1 phil u_int rc_decay_old;
81 1.21.16.1 phil /* RSS threshold update. */
82 1.21.16.1 phil u_int rc_thresh_denom;
83 1.21.16.1 phil u_int rc_thresh_old;
84 1.21.16.1 phil /* RSS average update. */
85 1.21.16.1 phil u_int rc_avgrssi_denom;
86 1.21.16.1 phil u_int rc_avgrssi_old;
87 1.21.16.1 phil };
88 1.1 dyoung
89 1.21.16.1 phil static struct rssadapt_expavgctl master_expavgctl = {
90 1.15 gmcgarry .rc_decay_denom = 16,
91 1.15 gmcgarry .rc_decay_old = 15,
92 1.15 gmcgarry .rc_thresh_denom = 8,
93 1.15 gmcgarry .rc_thresh_old = 4,
94 1.15 gmcgarry .rc_avgrssi_denom = 8,
95 1.15 gmcgarry .rc_avgrssi_old = 4
96 1.3 dyoung };
97 1.3 dyoung
98 1.21.16.1 phil #ifdef interpolate
99 1.21.16.1 phil #undef interpolate
100 1.21.16.1 phil #endif
101 1.21.16.1 phil #define interpolate(parm, old, new) ((parm##_old * (old) + \
102 1.21.16.1 phil (parm##_denom - parm##_old) * (new)) / \
103 1.21.16.1 phil parm##_denom)
104 1.5 dyoung
105 1.21.16.1 phil static void rssadapt_setinterval(const struct ieee80211vap *, int);
106 1.21.16.1 phil static void rssadapt_init(struct ieee80211vap *);
107 1.21.16.1 phil static void rssadapt_deinit(struct ieee80211vap *);
108 1.21.16.1 phil static void rssadapt_updatestats(struct ieee80211_rssadapt_node *);
109 1.21.16.1 phil static void rssadapt_node_init(struct ieee80211_node *);
110 1.21.16.1 phil static void rssadapt_node_deinit(struct ieee80211_node *);
111 1.21.16.1 phil static int rssadapt_rate(struct ieee80211_node *, void *, uint32_t);
112 1.21.16.1 phil static void rssadapt_lower_rate(struct ieee80211_rssadapt_node *, int, int);
113 1.21.16.1 phil static void rssadapt_raise_rate(struct ieee80211_rssadapt_node *,
114 1.21.16.1 phil int, int);
115 1.21.16.1 phil static void rssadapt_tx_complete(const struct ieee80211_node *,
116 1.21.16.1 phil const struct ieee80211_ratectl_tx_status *);
117 1.21.16.4 phil #ifdef notyet
118 1.21.16.1 phil static void rssadapt_sysctlattach(struct ieee80211vap *,
119 1.21.16.1 phil struct sysctl_ctx_list *, struct sysctl_oid *);
120 1.21.16.4 phil #endif
121 1.21.16.1 phil
122 1.21.16.1 phil /* number of references from net80211 layer */
123 1.21.16.1 phil static int nrefs = 0;
124 1.21.16.1 phil
125 1.21.16.3 phil #if __FreeBSD__
126 1.21.16.3 phil static const struct ieee80211_ratectl rssadapt = {
127 1.21.16.3 phil #elif __NetBSD__
128 1.21.16.3 phil const struct ieee80211_ratectl ratectl_rssadapt = {
129 1.21.16.3 phil #endif
130 1.21.16.1 phil .ir_name = "rssadapt",
131 1.21.16.1 phil .ir_attach = NULL,
132 1.21.16.1 phil .ir_detach = NULL,
133 1.21.16.1 phil .ir_init = rssadapt_init,
134 1.21.16.1 phil .ir_deinit = rssadapt_deinit,
135 1.21.16.1 phil .ir_node_init = rssadapt_node_init,
136 1.21.16.1 phil .ir_node_deinit = rssadapt_node_deinit,
137 1.21.16.1 phil .ir_rate = rssadapt_rate,
138 1.21.16.1 phil .ir_tx_complete = rssadapt_tx_complete,
139 1.21.16.1 phil .ir_tx_update = NULL,
140 1.21.16.1 phil .ir_setinterval = rssadapt_setinterval,
141 1.21.16.1 phil };
142 1.21.16.3 phil #if __FreeBSD__
143 1.21.16.1 phil IEEE80211_RATECTL_MODULE(rssadapt, 1);
144 1.21.16.1 phil IEEE80211_RATECTL_ALG(rssadapt, IEEE80211_RATECTL_RSSADAPT, rssadapt);
145 1.21.16.3 phil #endif
146 1.5 dyoung
147 1.21.16.1 phil static void
148 1.21.16.1 phil rssadapt_setinterval(const struct ieee80211vap *vap, int msecs)
149 1.21.16.1 phil {
150 1.21.16.1 phil struct ieee80211_rssadapt *rs = vap->iv_rs;
151 1.21.16.1 phil int t;
152 1.5 dyoung
153 1.21.16.1 phil if (msecs < 100)
154 1.21.16.1 phil msecs = 100;
155 1.21.16.1 phil t = msecs_to_ticks(msecs);
156 1.21.16.1 phil rs->interval = (t < 1) ? 1 : t;
157 1.5 dyoung }
158 1.5 dyoung
159 1.21.16.1 phil static void
160 1.21.16.1 phil rssadapt_init(struct ieee80211vap *vap)
161 1.5 dyoung {
162 1.21.16.1 phil struct ieee80211_rssadapt *rs;
163 1.5 dyoung
164 1.21.16.1 phil KASSERT(vap->iv_rs == NULL, ("%s: iv_rs already initialized",
165 1.21.16.1 phil __func__));
166 1.5 dyoung
167 1.21.16.1 phil nrefs++; /* XXX locking */
168 1.21.16.1 phil vap->iv_rs = rs = IEEE80211_MALLOC(sizeof(struct ieee80211_rssadapt),
169 1.21.16.1 phil M_80211_RATECTL, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO);
170 1.21.16.1 phil if (rs == NULL) {
171 1.21.16.1 phil if_printf(vap->iv_ifp, "couldn't alloc ratectl structure\n");
172 1.21.16.1 phil return;
173 1.21.16.1 phil }
174 1.21.16.1 phil rs->vap = vap;
175 1.21.16.1 phil rssadapt_setinterval(vap, 500 /* msecs */);
176 1.21.16.4 phil #ifdef notyet
177 1.21.16.1 phil rssadapt_sysctlattach(vap, vap->iv_sysctl, vap->iv_oid);
178 1.21.16.4 phil #endif
179 1.5 dyoung }
180 1.5 dyoung
181 1.21.16.1 phil static void
182 1.21.16.1 phil rssadapt_deinit(struct ieee80211vap *vap)
183 1.5 dyoung {
184 1.21.16.1 phil IEEE80211_FREE(vap->iv_rs, M_80211_RATECTL);
185 1.21.16.1 phil KASSERT(nrefs > 0, ("imbalanced attach/detach"));
186 1.21.16.1 phil nrefs--; /* XXX locking */
187 1.21.16.1 phil }
188 1.5 dyoung
189 1.21.16.1 phil static void
190 1.21.16.1 phil rssadapt_updatestats(struct ieee80211_rssadapt_node *ra)
191 1.3 dyoung {
192 1.21.16.1 phil long interval;
193 1.3 dyoung
194 1.21.16.1 phil ra->ra_pktrate = (ra->ra_pktrate + 10*(ra->ra_nfail + ra->ra_nok))/2;
195 1.21.16.1 phil ra->ra_nfail = ra->ra_nok = 0;
196 1.3 dyoung
197 1.21.16.1 phil /*
198 1.21.16.1 phil * A node is eligible for its rate to be raised every 1/10 to 10
199 1.21.16.1 phil * seconds, more eligible in proportion to recent packet rates.
200 1.21.16.1 phil */
201 1.21.16.1 phil interval = MAX(10*1000, 10*1000 / MAX(1, 10 * ra->ra_pktrate));
202 1.21.16.1 phil ra->ra_raise_interval = msecs_to_ticks(interval);
203 1.21.16.1 phil }
204 1.3 dyoung
205 1.21.16.1 phil static void
206 1.21.16.1 phil rssadapt_node_init(struct ieee80211_node *ni)
207 1.21.16.1 phil {
208 1.21.16.1 phil struct ieee80211_rssadapt_node *ra;
209 1.21.16.1 phil struct ieee80211vap *vap = ni->ni_vap;
210 1.21.16.1 phil struct ieee80211_rssadapt *rsa = vap->iv_rs;
211 1.21.16.1 phil const struct ieee80211_rateset *rs = &ni->ni_rates;
212 1.21.16.1 phil
213 1.21.16.1 phil if (ni->ni_rctls == NULL) {
214 1.21.16.1 phil ni->ni_rctls = ra =
215 1.21.16.1 phil IEEE80211_MALLOC(sizeof(struct ieee80211_rssadapt_node),
216 1.21.16.1 phil M_80211_RATECTL, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO);
217 1.21.16.1 phil if (ra == NULL) {
218 1.21.16.1 phil if_printf(vap->iv_ifp, "couldn't alloc per-node ratectl "
219 1.21.16.1 phil "structure\n");
220 1.21.16.1 phil return;
221 1.3 dyoung }
222 1.3 dyoung } else
223 1.21.16.1 phil ra = ni->ni_rctls;
224 1.21.16.1 phil ra->ra_rs = rsa;
225 1.21.16.1 phil ra->ra_rates = *rs;
226 1.21.16.1 phil rssadapt_updatestats(ra);
227 1.21.16.1 phil
228 1.21.16.1 phil /* pick initial rate */
229 1.21.16.1 phil for (ra->ra_rix = rs->rs_nrates - 1;
230 1.21.16.1 phil ra->ra_rix > 0 && (rs->rs_rates[ra->ra_rix] & IEEE80211_RATE_VAL) > 72;
231 1.21.16.1 phil ra->ra_rix--)
232 1.21.16.1 phil ;
233 1.21.16.1 phil ni->ni_txrate = rs->rs_rates[ra->ra_rix] & IEEE80211_RATE_VAL;
234 1.21.16.1 phil ra->ra_ticks = ticks;
235 1.3 dyoung
236 1.21.16.1 phil IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
237 1.21.16.1 phil "RSSADAPT initial rate %d", ni->ni_txrate);
238 1.3 dyoung }
239 1.1 dyoung
240 1.21.16.1 phil static void
241 1.21.16.1 phil rssadapt_node_deinit(struct ieee80211_node *ni)
242 1.1 dyoung {
243 1.1 dyoung
244 1.21.16.1 phil IEEE80211_FREE(ni->ni_rctls, M_80211_RATECTL);
245 1.21.16.1 phil }
246 1.1 dyoung
247 1.21.16.1 phil static __inline int
248 1.21.16.1 phil bucket(int pktlen)
249 1.21.16.1 phil {
250 1.21.16.1 phil int i, top, thridx;
251 1.21.16.1 phil
252 1.21.16.1 phil for (i = 0, top = IEEE80211_RSSADAPT_BKT0;
253 1.21.16.1 phil i < IEEE80211_RSSADAPT_BKTS;
254 1.21.16.1 phil i++, top <<= IEEE80211_RSSADAPT_BKTPOWER) {
255 1.21.16.1 phil thridx = i;
256 1.21.16.1 phil if (pktlen <= top)
257 1.21.16.1 phil break;
258 1.21.16.1 phil }
259 1.21.16.1 phil return thridx;
260 1.1 dyoung }
261 1.1 dyoung
262 1.21.16.1 phil static int
263 1.21.16.1 phil rssadapt_rate(struct ieee80211_node *ni, void *arg __unused, uint32_t iarg)
264 1.1 dyoung {
265 1.21.16.1 phil struct ieee80211_rssadapt_node *ra = ni->ni_rctls;
266 1.21.16.1 phil u_int pktlen = iarg;
267 1.21.16.1 phil const struct ieee80211_rateset *rs = &ra->ra_rates;
268 1.21.16.1 phil uint16_t (*thrs)[IEEE80211_RATE_SIZE];
269 1.21.16.1 phil int rix, rssi;
270 1.21.16.1 phil
271 1.21.16.1 phil if ((ticks - ra->ra_ticks) > ra->ra_rs->interval) {
272 1.21.16.1 phil rssadapt_updatestats(ra);
273 1.21.16.1 phil ra->ra_ticks = ticks;
274 1.21.16.1 phil }
275 1.1 dyoung
276 1.21.16.1 phil thrs = &ra->ra_rate_thresh[bucket(pktlen)];
277 1.1 dyoung
278 1.21.16.1 phil /* XXX this is average rssi, should be using last value */
279 1.21.16.1 phil rssi = ni->ni_ic->ic_node_getrssi(ni);
280 1.21.16.1 phil for (rix = rs->rs_nrates-1; rix >= 0; rix--)
281 1.21.16.1 phil if ((*thrs)[rix] < (rssi << 8))
282 1.21.16.1 phil break;
283 1.21.16.1 phil if (rix != ra->ra_rix) {
284 1.21.16.1 phil /* update public rate */
285 1.21.16.1 phil ni->ni_txrate = ni->ni_rates.rs_rates[rix] & IEEE80211_RATE_VAL;
286 1.21.16.1 phil ra->ra_rix = rix;
287 1.21.16.1 phil
288 1.21.16.1 phil IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
289 1.21.16.1 phil "RSSADAPT new rate %d (pktlen %d rssi %d)",
290 1.21.16.1 phil ni->ni_txrate, pktlen, rssi);
291 1.21.16.1 phil }
292 1.21.16.1 phil return rix;
293 1.1 dyoung }
294 1.1 dyoung
295 1.1 dyoung /*
296 1.1 dyoung * Adapt the data rate to suit the conditions. When a transmitted
297 1.21.16.1 phil * packet is dropped after RAL_RSSADAPT_RETRY_LIMIT retransmissions,
298 1.1 dyoung * raise the RSS threshold for transmitting packets of similar length at
299 1.1 dyoung * the same data rate.
300 1.1 dyoung */
301 1.21.16.1 phil static void
302 1.21.16.1 phil rssadapt_lower_rate(struct ieee80211_rssadapt_node *ra, int pktlen, int rssi)
303 1.21.16.1 phil {
304 1.21.16.1 phil uint16_t last_thr;
305 1.21.16.1 phil uint16_t (*thrs)[IEEE80211_RATE_SIZE];
306 1.21.16.1 phil u_int rix;
307 1.21.16.1 phil
308 1.21.16.1 phil thrs = &ra->ra_rate_thresh[bucket(pktlen)];
309 1.21.16.1 phil
310 1.21.16.1 phil rix = ra->ra_rix;
311 1.21.16.1 phil last_thr = (*thrs)[rix];
312 1.21.16.1 phil (*thrs)[rix] = interpolate(master_expavgctl.rc_thresh,
313 1.21.16.1 phil last_thr, (rssi << 8));
314 1.21.16.1 phil
315 1.21.16.1 phil IEEE80211_DPRINTF(ra->ra_rs->vap, IEEE80211_MSG_RATECTL,
316 1.21.16.1 phil "RSSADAPT lower threshold for rate %d (last_thr %d new thr %d rssi %d)\n",
317 1.21.16.1 phil ra->ra_rates.rs_rates[rix + 1] & IEEE80211_RATE_VAL,
318 1.21.16.1 phil last_thr, (*thrs)[rix], rssi);
319 1.21.16.1 phil }
320 1.1 dyoung
321 1.21.16.1 phil static void
322 1.21.16.1 phil rssadapt_raise_rate(struct ieee80211_rssadapt_node *ra, int pktlen, int rssi)
323 1.21.16.1 phil {
324 1.21.16.1 phil uint16_t (*thrs)[IEEE80211_RATE_SIZE];
325 1.21.16.1 phil uint16_t newthr, oldthr;
326 1.21.16.1 phil int rix;
327 1.21.16.1 phil
328 1.21.16.1 phil thrs = &ra->ra_rate_thresh[bucket(pktlen)];
329 1.21.16.1 phil
330 1.21.16.1 phil rix = ra->ra_rix;
331 1.21.16.1 phil if ((*thrs)[rix + 1] > (*thrs)[rix]) {
332 1.21.16.1 phil oldthr = (*thrs)[rix + 1];
333 1.21.16.1 phil if ((*thrs)[rix] == 0)
334 1.21.16.1 phil newthr = (rssi << 8);
335 1.21.16.1 phil else
336 1.21.16.1 phil newthr = (*thrs)[rix];
337 1.21.16.1 phil (*thrs)[rix + 1] = interpolate(master_expavgctl.rc_decay,
338 1.21.16.1 phil oldthr, newthr);
339 1.21.16.1 phil
340 1.21.16.1 phil IEEE80211_DPRINTF(ra->ra_rs->vap, IEEE80211_MSG_RATECTL,
341 1.21.16.1 phil "RSSADAPT raise threshold for rate %d (oldthr %d newthr %d rssi %d)\n",
342 1.21.16.1 phil ra->ra_rates.rs_rates[rix + 1] & IEEE80211_RATE_VAL,
343 1.21.16.1 phil oldthr, newthr, rssi);
344 1.1 dyoung
345 1.21.16.1 phil ra->ra_last_raise = ticks;
346 1.21.16.1 phil }
347 1.21.16.1 phil }
348 1.1 dyoung
349 1.21.16.1 phil static void
350 1.21.16.1 phil rssadapt_tx_complete(const struct ieee80211_node *ni,
351 1.21.16.1 phil const struct ieee80211_ratectl_tx_status *status)
352 1.21.16.1 phil {
353 1.21.16.1 phil struct ieee80211_rssadapt_node *ra = ni->ni_rctls;
354 1.21.16.1 phil int pktlen, rssi;
355 1.1 dyoung
356 1.21.16.1 phil if ((status->flags &
357 1.21.16.1 phil (IEEE80211_RATECTL_STATUS_PKTLEN|IEEE80211_RATECTL_STATUS_RSSI)) !=
358 1.21.16.1 phil (IEEE80211_RATECTL_STATUS_PKTLEN|IEEE80211_RATECTL_STATUS_RSSI))
359 1.1 dyoung return;
360 1.1 dyoung
361 1.21.16.1 phil pktlen = status->pktlen;
362 1.21.16.1 phil rssi = status->rssi;
363 1.21.16.1 phil
364 1.21.16.1 phil if (status->status == IEEE80211_RATECTL_TX_SUCCESS) {
365 1.21.16.1 phil ra->ra_nok++;
366 1.21.16.1 phil if ((ra->ra_rix + 1) < ra->ra_rates.rs_nrates &&
367 1.21.16.1 phil (ticks - ra->ra_last_raise) >= ra->ra_raise_interval)
368 1.21.16.1 phil rssadapt_raise_rate(ra, pktlen, rssi);
369 1.21.16.1 phil } else {
370 1.21.16.1 phil ra->ra_nfail++;
371 1.21.16.1 phil rssadapt_lower_rate(ra, pktlen, rssi);
372 1.1 dyoung }
373 1.21.16.1 phil }
374 1.1 dyoung
375 1.21.16.2 phil #ifdef notyet
376 1.21.16.1 phil static int
377 1.21.16.1 phil rssadapt_sysctl_interval(SYSCTL_HANDLER_ARGS)
378 1.21.16.1 phil {
379 1.21.16.1 phil struct ieee80211vap *vap = arg1;
380 1.21.16.1 phil struct ieee80211_rssadapt *rs = vap->iv_rs;
381 1.21.16.1 phil int msecs = ticks_to_msecs(rs->interval);
382 1.21.16.1 phil int error;
383 1.1 dyoung
384 1.21.16.1 phil error = sysctl_handle_int(oidp, &msecs, 0, req);
385 1.21.16.1 phil if (error || !req->newptr)
386 1.21.16.1 phil return error;
387 1.21.16.1 phil rssadapt_setinterval(vap, msecs);
388 1.21.16.1 phil return 0;
389 1.21.16.1 phil }
390 1.1 dyoung
391 1.21.16.1 phil static void
392 1.21.16.1 phil rssadapt_sysctlattach(struct ieee80211vap *vap,
393 1.21.16.1 phil struct sysctl_ctx_list *ctx, struct sysctl_oid *tree)
394 1.21.16.1 phil {
395 1.21.16.1 phil SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
396 1.21.16.1 phil "rssadapt_rate_interval", CTLTYPE_INT | CTLFLAG_RW, vap,
397 1.21.16.1 phil 0, rssadapt_sysctl_interval, "I", "rssadapt operation interval (ms)");
398 1.1 dyoung }
399 1.21.16.4 phil #endif
400