11 #include <linux/kernel.h>
12 #include <linux/rtnetlink.h>
13 #include <linux/slab.h>
14 #include <linux/module.h>
27 static char *ieee80211_default_rc_algo = CONFIG_MAC80211_RC_DEFAULT;
30 "Default rate control algorithm for mac80211 to use");
69 if (alg->
ops == ops) {
80 ieee80211_try_rate_control_ops_get(
const char *
name)
91 if (try_module_get(alg->
ops->module)) {
102 ieee80211_rate_control_ops_get(
const char *name)
105 const char *alg_name;
109 alg_name = ieee80211_default_rc_algo;
113 ops = ieee80211_try_rate_control_ops_get(alg_name);
115 request_module(
"rc80211_%s", alg_name);
116 ops = ieee80211_try_rate_control_ops_get(alg_name);
120 ops = ieee80211_try_rate_control_ops_get(ieee80211_default_rc_algo);
123 if (!ops &&
strlen(CONFIG_MAC80211_RC_DEFAULT))
124 ops = ieee80211_try_rate_control_ops_get(CONFIG_MAC80211_RC_DEFAULT);
135 #ifdef CONFIG_MAC80211_DEBUGFS
137 size_t count, loff_t *ppos)
143 ref->
ops->name, len);
163 ref->
ops = ieee80211_rate_control_ops_get(name);
167 #ifdef CONFIG_MAC80211_DEBUGFS
169 local->debugfs.rcdir = debugfsdir;
173 ref->
priv = ref->
ops->alloc(&local->
hw, debugfsdir);
179 ieee80211_rate_control_ops_put(ref->
ops);
188 ctrl_ref->
ops->free(ctrl_ref->
priv);
190 #ifdef CONFIG_MAC80211_DEBUGFS
195 ieee80211_rate_control_ops_put(ctrl_ref->
ops);
210 !ieee80211_is_data(fc);
213 static void rc_send_low_broadcast(
s8 *
idx,
u32 basic_rates,
218 if (basic_rates == 0)
222 if (basic_rates & (1 << *idx))
225 for (i = *idx + 1; i <= sband->
n_bitrates; i++) {
226 if (basic_rates & (1 << i)) {
247 if (rate_supported(sta, sband->
band, i))
264 if (!sta || !priv_sta || rc_no_data_or_no_ack_use_min(txrc)) {
268 rate_lowest_index(txrc->
sband, sta);
271 rate_lowest_non_cck_index(txrc->
sband, sta);
274 1 : txrc->
hw->max_rate_tries;
275 if (!sta && txrc->
bss) {
277 if (mcast_rate > 0) {
278 info->
control.rates[0].idx = mcast_rate - 1;
282 rc_send_low_broadcast(&info->
control.rates[0].idx,
298 for (j = rate->
idx; j >= 0; j--) {
299 if (mask & (1 << j)) {
307 for (j = rate->
idx + 1; j < n_bitrates; j++) {
308 if (mask & (1 << j)) {
323 ridx = rate->
idx / 8;
324 rbit = rate->
idx % 8;
327 if (ridx < 0 || ridx >= IEEE80211_HT_MCS_MASK_LEN)
331 for (i = ridx; i >= 0; i--) {
332 for (j = rbit; j >= 0; j--)
333 if (mcs_mask[i] &
BIT(j)) {
334 rate->
idx = i * 8 +
j;
341 ridx = (rate->
idx + 1) / 8;
342 rbit = (rate->
idx + 1) % 8;
345 for (j = rbit; j < 8; j++)
346 if (mcs_mask[i] &
BIT(j)) {
347 rate->
idx = i * 8 +
j;
360 u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN])
366 if (rate_idx_match_mcs_mask(rate, mcs_mask))
372 alt_rate.flags = rate->
flags &
376 alt_rate.count = rate->
count;
377 if (rate_idx_match_legacy_mask(&alt_rate,
378 txrc->
sband->n_bitrates,
389 if (rate_idx_match_legacy_mask(rate, txrc->
sband->n_bitrates,
398 if (!ieee80211_is_data(fc))
403 alt_rate.flags = rate->
flags &
407 alt_rate.count = rate->
count;
415 if (rate_idx_match_mcs_mask(&alt_rate, mcs_mask)) {
435 void *priv_sta =
NULL;
456 ref->
ops->get_rate(ref->
priv, ista, priv_sta, txrc);
466 if (mask != (1 << txrc->
sband->n_bitrates) - 1) {
469 mask &= sta->
sta.supp_rates[info->
band];
470 for (i = 0; i <
sizeof(mcs_mask); i++)
471 mcs_mask[i] &= sta->
sta.ht_cap.mcs.rx_mask[i];
480 if (info->
control.rates[i].idx < 0)
482 rate_idx_match_mask(&info->
control.rates[i], txrc,
506 ref = rate_control_alloc(name, local);
509 "Failed to select rate control algorithm\n");
516 wiphy_debug(local->
hw.wiphy,
"Selected rate control algorithm '%s'\n",
532 rate_control_free(ref);