Skip to content

Commit 2ffbe6d

Browse files
Felix Fietkaujmberg-intel
authored andcommitted
mac80211: fix and optimize MCS mask handling
Currently the code always copies the configured MCS mask (even if it is set to default), but only uses it if legacy rates were also masked out. Fix this by adding a flag that tracks whether the configured MCS mask is set to default or not. Optimize the code further by storing a pointer to the configured rate mask in txrc instead of using memcpy. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent dad6330 commit 2ffbe6d

5 files changed

Lines changed: 28 additions & 10 deletions

File tree

‎include/net/mac80211.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4107,7 +4107,7 @@ void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn);
41074107
* (deprecated; this will be removed once drivers get updated to use
41084108
* rate_idx_mask)
41094109
* @rate_idx_mask: user-requested (legacy) rate mask
4110-
* @rate_idx_mcs_mask: user-requested MCS rate mask
4110+
* @rate_idx_mcs_mask: user-requested MCS rate mask (NULL if not in use)
41114111
* @bss: whether this frame is sent out in AP or IBSS mode
41124112
*/
41134113
struct ieee80211_tx_rate_control {
@@ -4119,7 +4119,7 @@ struct ieee80211_tx_rate_control {
41194119
bool rts, short_preamble;
41204120
u8 max_rate_idx;
41214121
u32 rate_idx_mask;
4122-
u8 rate_idx_mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
4122+
u8 *rate_idx_mcs_mask;
41234123
bool bss;
41244124
};
41254125

‎net/mac80211/cfg.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,9 +2417,22 @@ static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
24172417
}
24182418

24192419
for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
2420+
struct ieee80211_supported_band *sband = wiphy->bands[i];
2421+
int j;
2422+
24202423
sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
24212424
memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs,
24222425
sizeof(mask->control[i].mcs));
2426+
2427+
sdata->rc_has_mcs_mask[i] = false;
2428+
if (!sband)
2429+
continue;
2430+
2431+
for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++)
2432+
if (~sdata->rc_rateidx_mcs_mask[i][j]) {
2433+
sdata->rc_has_mcs_mask[i] = true;
2434+
break;
2435+
}
24232436
}
24242437

24252438
return 0;

‎net/mac80211/ieee80211_i.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,8 @@ struct ieee80211_sub_if_data {
739739

740740
/* bitmap of allowed (non-MCS) rate indexes for rate control */
741741
u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
742+
743+
bool rc_has_mcs_mask[IEEE80211_NUM_BANDS];
742744
u8 rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
743745

744746
union {

‎net/mac80211/rate.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,12 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
460460
* the common case.
461461
*/
462462
mask = sdata->rc_rateidx_mask[info->band];
463-
memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band],
464-
sizeof(mcs_mask));
465-
if (mask != (1 << txrc->sband->n_bitrates) - 1) {
463+
if (mask != (1 << txrc->sband->n_bitrates) - 1 || txrc->rate_idx_mcs_mask) {
464+
if (txrc->rate_idx_mcs_mask)
465+
memcpy(mcs_mask, txrc->rate_idx_mcs_mask, sizeof(mcs_mask));
466+
else
467+
memset(mcs_mask, 0xff, sizeof(mcs_mask));
468+
466469
if (sta) {
467470
/* Filter out rates that the STA does not support */
468471
mask &= sta->sta.supp_rates[info->band];

‎net/mac80211/tx.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,11 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
642642
txrc.max_rate_idx = -1;
643643
else
644644
txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
645-
memcpy(txrc.rate_idx_mcs_mask,
646-
tx->sdata->rc_rateidx_mcs_mask[info->band],
647-
sizeof(txrc.rate_idx_mcs_mask));
645+
646+
if (tx->sdata->rc_has_mcs_mask[info->band])
647+
txrc.rate_idx_mcs_mask =
648+
tx->sdata->rc_rateidx_mcs_mask[info->band];
649+
648650
txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP ||
649651
tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
650652
tx->sdata->vif.type == NL80211_IFTYPE_ADHOC);
@@ -2508,8 +2510,6 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
25082510
txrc.max_rate_idx = -1;
25092511
else
25102512
txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
2511-
memcpy(txrc.rate_idx_mcs_mask, sdata->rc_rateidx_mcs_mask[band],
2512-
sizeof(txrc.rate_idx_mcs_mask));
25132513
txrc.bss = true;
25142514
rate_control_get_rate(sdata, NULL, &txrc);
25152515

0 commit comments

Comments
 (0)