Lines Matching +full:int +full:- +full:threshold

2 /*-
3 * SPDX-License-Identifier: BSD-3-Clause
54 /* RSS threshold decay. */
57 /* RSS threshold update. */
78 (parm##_denom - parm##_old) * (new)) / \
81 static void rssadapt_setinterval(const struct ieee80211vap *, int);
87 static int rssadapt_rate(struct ieee80211_node *, void *, uint32_t);
88 static void rssadapt_lower_rate(struct ieee80211_rssadapt_node *, int, int);
90 int, int);
97 static int nrefs = 0;
116 rssadapt_setinterval(const struct ieee80211vap *vap, int msecs) in rssadapt_setinterval()
118 struct ieee80211_rssadapt *rs = vap->iv_rs; in rssadapt_setinterval()
125 rs->interval = msecs_to_ticks(msecs); in rssadapt_setinterval()
133 KASSERT(vap->iv_rs == NULL, ("%s: iv_rs already initialized", in rssadapt_init()
137 vap->iv_rs = rs = IEEE80211_MALLOC(sizeof(struct ieee80211_rssadapt), in rssadapt_init()
140 if_printf(vap->iv_ifp, "couldn't alloc ratectl structure\n"); in rssadapt_init()
143 rs->vap = vap; in rssadapt_init()
145 rssadapt_sysctlattach(vap, vap->iv_sysctl, vap->iv_oid); in rssadapt_init()
151 IEEE80211_FREE(vap->iv_rs, M_80211_RATECTL); in rssadapt_deinit()
153 nrefs--; /* XXX locking */ in rssadapt_deinit()
161 ra->ra_pktrate = (ra->ra_pktrate + 10*(ra->ra_nfail + ra->ra_nok))/2; in rssadapt_updatestats()
162 ra->ra_nfail = ra->ra_nok = 0; in rssadapt_updatestats()
168 interval = MAX(10*1000, 10*1000 / MAX(1, 10 * ra->ra_pktrate)); in rssadapt_updatestats()
169 ra->ra_raise_interval = msecs_to_ticks(interval); in rssadapt_updatestats()
176 struct ieee80211vap *vap = ni->ni_vap; in rssadapt_node_init()
177 struct ieee80211_rssadapt *rsa = vap->iv_rs; in rssadapt_node_init()
178 const struct ieee80211_rateset *rs = &ni->ni_rates; in rssadapt_node_init()
181 if_printf(vap->iv_ifp, "ratectl structure was not allocated, " in rssadapt_node_init()
182 "per-node structure allocation skipped\n"); in rssadapt_node_init()
186 if (ni->ni_rctls == NULL) { in rssadapt_node_init()
187 ni->ni_rctls = ra = in rssadapt_node_init()
191 if_printf(vap->iv_ifp, "couldn't alloc per-node ratectl " in rssadapt_node_init()
196 ra = ni->ni_rctls; in rssadapt_node_init()
197 ra->ra_rs = rsa; in rssadapt_node_init()
198 ra->ra_rates = *rs; in rssadapt_node_init()
202 for (ra->ra_rix = rs->rs_nrates - 1; in rssadapt_node_init()
203 ra->ra_rix > 0 && (rs->rs_rates[ra->ra_rix] & IEEE80211_RATE_VAL) > 72; in rssadapt_node_init()
204 ra->ra_rix--) in rssadapt_node_init()
206 ni->ni_txrate = rs->rs_rates[ra->ra_rix] & IEEE80211_RATE_VAL; in rssadapt_node_init()
207 ra->ra_ticks = ticks; in rssadapt_node_init()
209 IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, in rssadapt_node_init()
210 "RSSADAPT initial rate %d", ni->ni_txrate); in rssadapt_node_init()
217 IEEE80211_FREE(ni->ni_rctls, M_80211_RATECTL); in rssadapt_node_deinit()
220 static __inline int
221 bucket(int pktlen) in bucket()
223 int i, top, thridx; in bucket()
235 static int
238 struct ieee80211_rssadapt_node *ra = ni->ni_rctls; in rssadapt_rate()
242 int rix, rssi; in rssadapt_rate()
244 /* XXX should return -1 here, but drivers may not expect this... */ in rssadapt_rate()
247 ni->ni_txrate = ni->ni_rates.rs_rates[0]; in rssadapt_rate()
251 rs = &ra->ra_rates; in rssadapt_rate()
252 if ((ticks - ra->ra_ticks) > ra->ra_rs->interval) { in rssadapt_rate()
254 ra->ra_ticks = ticks; in rssadapt_rate()
257 thrs = &ra->ra_rate_thresh[bucket(pktlen)]; in rssadapt_rate()
260 rssi = ni->ni_ic->ic_node_getrssi(ni); in rssadapt_rate()
261 for (rix = rs->rs_nrates-1; rix >= 0; rix--) in rssadapt_rate()
264 if (rix != ra->ra_rix) { in rssadapt_rate()
266 ni->ni_txrate = ni->ni_rates.rs_rates[rix] & IEEE80211_RATE_VAL; in rssadapt_rate()
267 ra->ra_rix = rix; in rssadapt_rate()
269 IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, in rssadapt_rate()
271 ni->ni_txrate, pktlen, rssi); in rssadapt_rate()
279 * raise the RSS threshold for transmitting packets of similar length at
283 rssadapt_lower_rate(struct ieee80211_rssadapt_node *ra, int pktlen, int rssi) in rssadapt_lower_rate()
289 thrs = &ra->ra_rate_thresh[bucket(pktlen)]; in rssadapt_lower_rate()
291 rix = ra->ra_rix; in rssadapt_lower_rate()
296 IEEE80211_DPRINTF(ra->ra_rs->vap, IEEE80211_MSG_RATECTL, in rssadapt_lower_rate()
297 "RSSADAPT lower threshold for rate %d (last_thr %d new thr %d rssi %d)\n", in rssadapt_lower_rate()
298 ra->ra_rates.rs_rates[rix + 1] & IEEE80211_RATE_VAL, in rssadapt_lower_rate()
303 rssadapt_raise_rate(struct ieee80211_rssadapt_node *ra, int pktlen, int rssi) in rssadapt_raise_rate()
307 int rix; in rssadapt_raise_rate()
309 thrs = &ra->ra_rate_thresh[bucket(pktlen)]; in rssadapt_raise_rate()
311 rix = ra->ra_rix; in rssadapt_raise_rate()
321 IEEE80211_DPRINTF(ra->ra_rs->vap, IEEE80211_MSG_RATECTL, in rssadapt_raise_rate()
322 "RSSADAPT raise threshold for rate %d (oldthr %d newthr %d rssi %d)\n", in rssadapt_raise_rate()
323 ra->ra_rates.rs_rates[rix + 1] & IEEE80211_RATE_VAL, in rssadapt_raise_rate()
326 ra->ra_last_raise = ticks; in rssadapt_raise_rate()
334 struct ieee80211_rssadapt_node *ra = ni->ni_rctls; in rssadapt_tx_complete()
335 int pktlen, rssi; in rssadapt_tx_complete()
340 if ((status->flags & in rssadapt_tx_complete()
345 pktlen = status->pktlen; in rssadapt_tx_complete()
346 rssi = status->rssi; in rssadapt_tx_complete()
348 if (status->status == IEEE80211_RATECTL_TX_SUCCESS) { in rssadapt_tx_complete()
349 ra->ra_nok++; in rssadapt_tx_complete()
350 if ((ra->ra_rix + 1) < ra->ra_rates.rs_nrates && in rssadapt_tx_complete()
351 (ticks - ra->ra_last_raise) >= ra->ra_raise_interval) in rssadapt_tx_complete()
354 ra->ra_nfail++; in rssadapt_tx_complete()
359 static int
363 struct ieee80211_rssadapt *rs = vap->iv_rs; in rssadapt_sysctl_interval()
364 int msecs, error; in rssadapt_sysctl_interval()
369 msecs = ticks_to_msecs(rs->interval); in rssadapt_sysctl_interval()
371 if (error || !req->newptr) in rssadapt_sysctl_interval()