Lines Matching +full:data +full:- +full:rates

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2005-2006, Devicescape Software, Inc.
33 struct ieee80211_local *local = sta->sdata->local; in rate_control_rate_init()
34 struct rate_control_ref *ref = sta->rate_ctrl; in rate_control_rate_init()
35 struct ieee80211_sta *ista = &sta->sta; in rate_control_rate_init()
36 void *priv_sta = sta->rate_ctrl_priv; in rate_control_rate_init()
40 ieee80211_sta_init_nss(&sta->deflink); in rate_control_rate_init()
47 chanctx_conf = rcu_dereference(sta->sdata->vif.bss_conf.chanctx_conf); in rate_control_rate_init()
53 sband = local->hw.wiphy->bands[chanctx_conf->def.chan->band]; in rate_control_rate_init()
56 if (sband->band == NL80211_BAND_S1GHZ) { in rate_control_rate_init()
62 spin_lock_bh(&sta->rate_ctrl_lock); in rate_control_rate_init()
63 ref->ops->rate_init(ref->priv, sband, &chanctx_conf->def, ista, in rate_control_rate_init()
65 spin_unlock_bh(&sta->rate_ctrl_lock); in rate_control_rate_init()
73 struct rate_control_ref *ref = local->rate_ctrl; in rate_control_tx_status()
74 struct sta_info *sta = container_of(st->sta, struct sta_info, sta); in rate_control_tx_status()
75 void *priv_sta = sta->rate_ctrl_priv; in rate_control_tx_status()
81 sband = local->hw.wiphy->bands[st->info->band]; in rate_control_tx_status()
83 spin_lock_bh(&sta->rate_ctrl_lock); in rate_control_tx_status()
84 if (ref->ops->tx_status_ext) in rate_control_tx_status()
85 ref->ops->tx_status_ext(ref->priv, sband, priv_sta, st); in rate_control_tx_status()
86 else if (st->skb) in rate_control_tx_status()
87 ref->ops->tx_status(ref->priv, sband, st->sta, priv_sta, st->skb); in rate_control_tx_status()
91 spin_unlock_bh(&sta->rate_ctrl_lock); in rate_control_tx_status()
99 struct rate_control_ref *ref = local->rate_ctrl; in rate_control_rate_update()
100 struct ieee80211_sta *ista = &sta->sta; in rate_control_rate_update()
101 void *priv_sta = sta->rate_ctrl_priv; in rate_control_rate_update()
106 if (ref && ref->ops->rate_update) { in rate_control_rate_update()
109 chanctx_conf = rcu_dereference(sta->sdata->vif.bss_conf.chanctx_conf); in rate_control_rate_update()
115 spin_lock_bh(&sta->rate_ctrl_lock); in rate_control_rate_update()
116 ref->ops->rate_update(ref->priv, sband, &chanctx_conf->def, in rate_control_rate_update()
118 spin_unlock_bh(&sta->rate_ctrl_lock); in rate_control_rate_update()
122 if (sta->uploaded) in rate_control_rate_update()
123 drv_sta_rc_update(local, sta->sdata, &sta->sta, changed); in rate_control_rate_update()
130 if (!ops->name) in ieee80211_rate_control_register()
131 return -EINVAL; in ieee80211_rate_control_register()
135 if (!strcmp(alg->ops->name, ops->name)) { in ieee80211_rate_control_register()
139 return -EALREADY; in ieee80211_rate_control_register()
146 return -ENOMEM; in ieee80211_rate_control_register()
148 alg->ops = ops; in ieee80211_rate_control_register()
150 list_add_tail(&alg->list, &rate_ctrl_algs); in ieee80211_rate_control_register()
163 if (alg->ops == ops) { in ieee80211_rate_control_unregister()
164 list_del(&alg->list); in ieee80211_rate_control_unregister()
184 if (!strcmp(alg->ops->name, name)) { in ieee80211_try_rate_control_ops_get()
185 ops = alg->ops; in ieee80211_try_rate_control_ops_get()
213 /* try built-in one if specific alg requested but not found */ in ieee80211_rate_control_ops_get()
225 struct rate_control_ref *ref = file->private_data; in rcname_read()
226 int len = strlen(ref->ops->name); in rcname_read()
229 ref->ops->name, len); in rcname_read()
247 ref->ops = ieee80211_rate_control_ops_get(name); in rate_control_alloc()
248 if (!ref->ops) in rate_control_alloc()
251 ref->priv = ref->ops->alloc(&local->hw); in rate_control_alloc()
252 if (!ref->priv) in rate_control_alloc()
264 ctrl_ref->ops->free(ctrl_ref->priv); in rate_control_free()
267 debugfs_remove_recursive(local->debugfs.rcdir); in rate_control_free()
268 local->debugfs.rcdir = NULL; in rate_control_free()
276 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_check_rate_mask()
277 struct ieee80211_local *local = sdata->local; in ieee80211_check_rate_mask()
279 u32 user_mask, basic_rates = link->conf->basic_rates; in ieee80211_check_rate_mask()
282 if (WARN_ON(!link->conf->chandef.chan)) in ieee80211_check_rate_mask()
285 band = link->conf->chandef.chan->band; in ieee80211_check_rate_mask()
294 user_mask = sdata->rc_rateidx_mask[band]; in ieee80211_check_rate_mask()
295 sband = local->hw.wiphy->bands[band]; in ieee80211_check_rate_mask()
301 "no overlap between basic rates (0x%x) and user mask (0x%x on band %d) - clearing the latter", in ieee80211_check_rate_mask()
303 sdata->rc_rateidx_mask[band] = (1 << sband->n_bitrates) - 1; in ieee80211_check_rate_mask()
308 struct sk_buff *skb = txrc->skb; in rc_no_data_or_no_ack_use_min()
311 return (info->flags & (IEEE80211_TX_CTL_NO_ACK | in rc_no_data_or_no_ack_use_min()
322 if (sband->band == NL80211_BAND_S1GHZ) { in rc_send_low_basicrate()
324 rate->flags |= IEEE80211_TX_RC_S1G_MCS; in rc_send_low_basicrate()
325 rate->idx = 0; in rc_send_low_basicrate()
330 return; /* assume basic rates unknown and accept rate */ in rc_send_low_basicrate()
331 if (rate->idx < 0) in rc_send_low_basicrate()
333 if (basic_rates & (1 << rate->idx)) in rc_send_low_basicrate()
336 for (i = rate->idx + 1; i <= sband->n_bitrates; i++) { in rc_send_low_basicrate()
338 rate->idx = i; in rc_send_low_basicrate()
354 ieee80211_chandef_rate_flags(&hw->conf.chandef); in __rate_control_send_low()
356 if (sband->band == NL80211_BAND_S1GHZ) { in __rate_control_send_low()
357 info->control.rates[0].flags |= IEEE80211_TX_RC_S1G_MCS; in __rate_control_send_low()
358 info->control.rates[0].idx = 0; in __rate_control_send_low()
362 if ((sband->band == NL80211_BAND_2GHZ) && in __rate_control_send_low()
363 (info->flags & IEEE80211_TX_CTL_NO_CCK_RATE)) in __rate_control_send_low()
366 info->control.rates[0].idx = 0; in __rate_control_send_low()
367 for (i = 0; i < sband->n_bitrates; i++) { in __rate_control_send_low()
371 if ((rate_flags & sband->bitrates[i].flags) != rate_flags) in __rate_control_send_low()
374 if (!rate_supported(sta, sband->band, i)) in __rate_control_send_low()
377 info->control.rates[0].idx = i; in __rate_control_send_low()
380 WARN_ONCE(i == sband->n_bitrates, in __rate_control_send_low()
381 "no supported rates for sta %pM (0x%x, band %d) in rate_mask 0x%x with flags 0x%x\n", in __rate_control_send_low()
382 sta ? sta->addr : NULL, in __rate_control_send_low()
383 sta ? sta->deflink.supp_rates[sband->band] : -1, in __rate_control_send_low()
384 sband->band, in __rate_control_send_low()
387 info->control.rates[0].count = in __rate_control_send_low()
388 (info->flags & IEEE80211_TX_CTL_NO_ACK) ? in __rate_control_send_low()
389 1 : hw->max_rate_tries; in __rate_control_send_low()
391 info->control.skip_table = 1; in __rate_control_send_low()
398 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); in rate_control_send_low()
399 struct ieee80211_supported_band *sband = txrc->sband; in rate_control_send_low()
405 __rate_control_send_low(txrc->hw, sband, pubsta, info, in rate_control_send_low()
406 txrc->rate_idx_mask); in rate_control_send_low()
408 if (!pubsta && txrc->bss) { in rate_control_send_low()
409 mcast_rate = txrc->bss_conf->mcast_rate[sband->band]; in rate_control_send_low()
411 info->control.rates[0].idx = mcast_rate - 1; in rate_control_send_low()
417 if (ieee80211_vif_is_mesh(&sta->sdata->vif)) in rate_control_send_low()
422 rc_send_low_basicrate(&info->control.rates[0], in rate_control_send_low()
423 txrc->bss_conf->basic_rates, in rate_control_send_low()
436 for (j = *rate_idx; j >= 0; j--) { in rate_idx_match_legacy_mask()
468 for (i = ridx; i >= 0; i--) { in rate_idx_match_mcs_mask()
469 for (j = rbit; j >= 0; j--) in rate_idx_match_mcs_mask()
504 for (i = ridx; i >= 0; i--) { in rate_idx_match_vht_mcs_mask()
505 for (j = rbit; j >= 0; j--) { in rate_idx_match_vht_mcs_mask()
538 /* handle VHT rates */ in rate_idx_match_mask()
555 /* also try the legacy rates. */ in rate_idx_match_mask()
558 if (rate_idx_match_legacy_mask(rate_idx, sband->n_bitrates, in rate_idx_match_mask()
562 /* handle HT rates */ in rate_idx_match_mask()
566 /* also try the legacy rates. */ in rate_idx_match_mask()
572 if (rate_idx_match_legacy_mask(rate_idx, sband->n_bitrates, in rate_idx_match_mask()
576 /* handle legacy rates */ in rate_idx_match_mask()
577 if (rate_idx_match_legacy_mask(rate_idx, sband->n_bitrates, in rate_idx_match_mask()
581 /* if HT BSS, and we handle a data frame, also try HT rates */ in rate_idx_match_mask()
609 * configure supported rates and TX rate mask in incompatible way, in rate_idx_match_mask()
618 struct ieee80211_tx_rate *rates, in rate_fixup_ratelist() argument
627 * that is not faster than the data rate unless there in rate_fixup_ratelist()
628 * is no basic rate slower than the data rate, in which in rate_fixup_ratelist()
631 * XXX: Should this check all retry rates? in rate_fixup_ratelist()
633 if (!(rates[0].flags & in rate_fixup_ratelist()
635 u32 basic_rates = vif->bss_conf.basic_rates; in rate_fixup_ratelist()
636 s8 baserate = basic_rates ? ffs(basic_rates) - 1 : 0; in rate_fixup_ratelist()
638 rate = &sband->bitrates[rates[0].idx]; in rate_fixup_ratelist()
640 for (i = 0; i < sband->n_bitrates; i++) { in rate_fixup_ratelist()
644 /* must not be faster than the data rate */ in rate_fixup_ratelist()
645 if (sband->bitrates[i].bitrate > rate->bitrate) in rate_fixup_ratelist()
648 if (sband->bitrates[baserate].bitrate < in rate_fixup_ratelist()
649 sband->bitrates[i].bitrate) in rate_fixup_ratelist()
653 info->control.rts_cts_rate_idx = baserate; in rate_fixup_ratelist()
660 * take the API seriously to stop at -1. in rate_fixup_ratelist()
663 rates[i].idx = -1; in rate_fixup_ratelist()
666 if (rates[i].idx < 0) { in rate_fixup_ratelist()
675 if (rates[i].flags & IEEE80211_TX_RC_MCS) { in rate_fixup_ratelist()
676 WARN_ON(rates[i].idx > 76); in rate_fixup_ratelist()
678 if (!(rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) && in rate_fixup_ratelist()
679 info->control.use_cts_prot) in rate_fixup_ratelist()
680 rates[i].flags |= in rate_fixup_ratelist()
685 if (rates[i].flags & IEEE80211_TX_RC_VHT_MCS) { in rate_fixup_ratelist()
686 WARN_ON(ieee80211_rate_get_vht_mcs(&rates[i]) > 9); in rate_fixup_ratelist()
691 if (info->control.use_rts) { in rate_fixup_ratelist()
692 rates[i].flags |= IEEE80211_TX_RC_USE_RTS_CTS; in rate_fixup_ratelist()
693 info->control.use_cts_prot = false; in rate_fixup_ratelist()
697 if (WARN_ON_ONCE(rates[i].idx >= sband->n_bitrates)) { in rate_fixup_ratelist()
698 rates[i].idx = -1; in rate_fixup_ratelist()
702 rate = &sband->bitrates[rates[i].idx]; in rate_fixup_ratelist()
705 if (info->control.short_preamble && in rate_fixup_ratelist()
706 rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) in rate_fixup_ratelist()
707 rates[i].flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE; in rate_fixup_ratelist()
710 if (!(rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) && in rate_fixup_ratelist()
711 info->control.use_cts_prot && in rate_fixup_ratelist()
712 rate->flags & IEEE80211_RATE_ERP_G) in rate_fixup_ratelist()
713 rates[i].flags |= IEEE80211_TX_RC_USE_CTS_PROTECT; in rate_fixup_ratelist()
720 struct ieee80211_tx_rate *rates, in rate_control_fill_sta_table() argument
726 if (sta && !info->control.skip_table) in rate_control_fill_sta_table()
727 ratetbl = rcu_dereference(sta->rates); in rate_control_fill_sta_table()
729 /* Fill remaining rate slots with data from the sta rate table. */ in rate_control_fill_sta_table()
732 if (i < ARRAY_SIZE(info->control.rates) && in rate_control_fill_sta_table()
733 info->control.rates[i].idx >= 0 && in rate_control_fill_sta_table()
734 info->control.rates[i].count) { in rate_control_fill_sta_table()
735 if (rates != info->control.rates) in rate_control_fill_sta_table()
736 rates[i] = info->control.rates[i]; in rate_control_fill_sta_table()
738 rates[i].idx = ratetbl->rate[i].idx; in rate_control_fill_sta_table()
739 rates[i].flags = ratetbl->rate[i].flags; in rate_control_fill_sta_table()
740 if (info->control.use_rts) in rate_control_fill_sta_table()
741 rates[i].count = ratetbl->rate[i].count_rts; in rate_control_fill_sta_table()
742 else if (info->control.use_cts_prot) in rate_control_fill_sta_table()
743 rates[i].count = ratetbl->rate[i].count_cts; in rate_control_fill_sta_table()
745 rates[i].count = ratetbl->rate[i].count; in rate_control_fill_sta_table()
747 rates[i].idx = -1; in rate_control_fill_sta_table()
748 rates[i].count = 0; in rate_control_fill_sta_table()
751 if (rates[i].idx < 0 || !rates[i].count) in rate_control_fill_sta_table()
764 *mask = sdata->rc_rateidx_mask[sband->band]; in rate_control_cap_mask()
765 flags = ieee80211_chandef_rate_flags(&sdata->vif.bss_conf.chandef); in rate_control_cap_mask()
766 for (i = 0; i < sband->n_bitrates; i++) { in rate_control_cap_mask()
767 if ((flags & sband->bitrates[i].flags) != flags) in rate_control_cap_mask()
771 if (*mask == (1 << sband->n_bitrates) - 1 && in rate_control_cap_mask()
772 !sdata->rc_has_mcs_mask[sband->band] && in rate_control_cap_mask()
773 !sdata->rc_has_vht_mcs_mask[sband->band]) in rate_control_cap_mask()
776 if (sdata->rc_has_mcs_mask[sband->band]) in rate_control_cap_mask()
777 memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[sband->band], in rate_control_cap_mask()
782 if (sdata->rc_has_vht_mcs_mask[sband->band]) in rate_control_cap_mask()
783 memcpy(vht_mask, sdata->rc_rateidx_vht_mcs_mask[sband->band], in rate_control_cap_mask()
792 /* Filter out rates that the STA does not support */ in rate_control_cap_mask()
793 *mask &= sta->deflink.supp_rates[sband->band]; in rate_control_cap_mask()
795 mcs_mask[i] &= sta->deflink.ht_cap.mcs.rx_mask[i]; in rate_control_cap_mask()
797 sta_vht_cap = sta->deflink.vht_cap.vht_mcs.rx_mcs_map; in rate_control_cap_mask()
809 struct ieee80211_sta_rates *rates) in rate_control_apply_mask_ratetbl() argument
817 if (!rate_control_cap_mask(sta->sdata, sband, &sta->sta, &mask, in rate_control_apply_mask_ratetbl()
821 chan_width = sta->sdata->vif.bss_conf.chandef.width; in rate_control_apply_mask_ratetbl()
823 if (rates->rate[i].idx < 0) in rate_control_apply_mask_ratetbl()
826 rate_idx_match_mask(&rates->rate[i].idx, &rates->rate[i].flags, in rate_control_apply_mask_ratetbl()
835 struct ieee80211_tx_rate *rates, in rate_control_apply_mask() argument
846 * default mask (allow all rates) is used to save some processing for in rate_control_apply_mask()
858 chan_width = sdata->vif.bss_conf.chandef.width; in rate_control_apply_mask()
860 /* Skip invalid rates */ in rate_control_apply_mask()
861 if (rates[i].idx < 0) in rate_control_apply_mask()
864 rate_flags = rates[i].flags; in rate_control_apply_mask()
865 rate_idx_match_mask(&rates[i].idx, &rate_flags, sband, in rate_control_apply_mask()
867 rates[i].flags = rate_flags; in rate_control_apply_mask()
888 sband = sdata->local->hw.wiphy->bands[info->band]; in ieee80211_get_tx_rates()
893 if (!(info->control.flags & IEEE80211_TX_CTRL_DONT_USE_RATE_MASK)) in ieee80211_get_tx_rates()
894 mask = sdata->rc_rateidx_mask[info->band]; in ieee80211_get_tx_rates()
897 __rate_control_send_low(&sdata->local->hw, sband, sta, info, in ieee80211_get_tx_rates()
909 struct rate_control_ref *ref = sdata->local->rate_ctrl; in rate_control_get_rate()
912 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); in rate_control_get_rate()
916 info->control.rates[i].idx = -1; in rate_control_get_rate()
917 info->control.rates[i].flags = 0; in rate_control_get_rate()
918 info->control.rates[i].count = 0; in rate_control_get_rate()
921 if (rate_control_send_low(sta ? &sta->sta : NULL, txrc)) in rate_control_get_rate()
924 if (ieee80211_hw_check(&sdata->local->hw, HAS_RATE_CONTROL)) in rate_control_get_rate()
928 ista = &sta->sta; in rate_control_get_rate()
929 priv_sta = sta->rate_ctrl_priv; in rate_control_get_rate()
933 spin_lock_bh(&sta->rate_ctrl_lock); in rate_control_get_rate()
934 ref->ops->get_rate(ref->priv, ista, priv_sta, txrc); in rate_control_get_rate()
935 spin_unlock_bh(&sta->rate_ctrl_lock); in rate_control_get_rate()
940 if (ieee80211_hw_check(&sdata->local->hw, SUPPORTS_RC_TABLE)) in rate_control_get_rate()
943 ieee80211_get_tx_rates(&sdata->vif, ista, txrc->skb, in rate_control_get_rate()
944 info->control.rates, in rate_control_get_rate()
945 ARRAY_SIZE(info->control.rates)); in rate_control_get_rate()
950 struct ieee80211_sta_rates *rates) in rate_control_set_rates() argument
956 sband = ieee80211_get_sband(sta->sdata); in rate_control_set_rates()
958 return -EINVAL; in rate_control_set_rates()
959 rate_control_apply_mask_ratetbl(sta, sband, rates); in rate_control_set_rates()
966 old = rcu_dereference_protected(pubsta->rates, true); in rate_control_set_rates()
967 rcu_assign_pointer(pubsta->rates, rates); in rate_control_set_rates()
971 if (sta->uploaded) in rate_control_set_rates()
972 drv_sta_rate_tbl_update(hw_to_local(hw), sta->sdata, pubsta); in rate_control_set_rates()
987 if (local->open_count) in ieee80211_init_rate_ctrl_alg()
988 return -EBUSY; in ieee80211_init_rate_ctrl_alg()
990 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) { in ieee80211_init_rate_ctrl_alg()
991 if (WARN_ON(!local->ops->set_rts_threshold)) in ieee80211_init_rate_ctrl_alg()
992 return -EINVAL; in ieee80211_init_rate_ctrl_alg()
998 wiphy_warn(local->hw.wiphy, in ieee80211_init_rate_ctrl_alg()
1000 return -ENOENT; in ieee80211_init_rate_ctrl_alg()
1003 WARN_ON(local->rate_ctrl); in ieee80211_init_rate_ctrl_alg()
1004 local->rate_ctrl = ref; in ieee80211_init_rate_ctrl_alg()
1006 wiphy_debug(local->hw.wiphy, "Selected rate control algorithm '%s'\n", in ieee80211_init_rate_ctrl_alg()
1007 ref->ops->name); in ieee80211_init_rate_ctrl_alg()
1016 ref = local->rate_ctrl; in rate_control_deinitialize()
1021 local->rate_ctrl = NULL; in rate_control_deinitialize()