Commit 9c54548b authored by Ryder Lee's avatar Ryder Lee Committed by Felix Fietkau

wifi: mt76: connac: add nss calculation into mt76_connac2_mac_tx_rate_val()

Take nss calculation into account since this function always wrongly
returns 0.
Signed-off-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 3d2892e0
...@@ -288,11 +288,29 @@ int mt76_connac_init_tx_queues(struct mt76_phy *phy, int idx, int n_desc, ...@@ -288,11 +288,29 @@ int mt76_connac_init_tx_queues(struct mt76_phy *phy, int idx, int n_desc,
} }
EXPORT_SYMBOL_GPL(mt76_connac_init_tx_queues); EXPORT_SYMBOL_GPL(mt76_connac_init_tx_queues);
#define __bitrate_mask_check(_mcs, _mode) \
({ \
u8 i = 0; \
for (nss = 0; i < ARRAY_SIZE(mask->control[band]._mcs); i++) { \
if (!mask->control[band]._mcs[i]) \
continue; \
if (hweight16(mask->control[band]._mcs[i]) == 1) { \
mode = MT_PHY_TYPE_##_mode; \
rateidx = ffs(mask->control[band]._mcs[i]) - 1; \
if (mode == MT_PHY_TYPE_HT) \
rateidx += 8 * i; \
else \
nss = i + 1; \
goto out; \
} \
} \
})
u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy, u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
struct ieee80211_vif *vif, struct ieee80211_vif *vif,
bool beacon, bool mcast) bool beacon, bool mcast)
{ {
u8 mode = 0, band = mphy->chandef.chan->band; u8 nss = 0, mode = 0, band = mphy->chandef.chan->band;
int rateidx = 0, mcast_rate; int rateidx = 0, mcast_rate;
if (!vif) if (!vif)
...@@ -307,19 +325,12 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy, ...@@ -307,19 +325,12 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
struct cfg80211_bitrate_mask *mask; struct cfg80211_bitrate_mask *mask;
mask = &vif->bss_conf.beacon_tx_rate; mask = &vif->bss_conf.beacon_tx_rate;
if (hweight16(mask->control[band].he_mcs[0]) == 1) {
rateidx = ffs(mask->control[band].he_mcs[0]) - 1; __bitrate_mask_check(he_mcs, HE_SU);
mode = MT_PHY_TYPE_HE_SU; __bitrate_mask_check(vht_mcs, VHT);
goto out; __bitrate_mask_check(ht_mcs, HT);
} else if (hweight16(mask->control[band].vht_mcs[0]) == 1) {
rateidx = ffs(mask->control[band].vht_mcs[0]) - 1; if (hweight32(mask->control[band].legacy) == 1) {
mode = MT_PHY_TYPE_VHT;
goto out;
} else if (hweight8(mask->control[band].ht_mcs[0]) == 1) {
rateidx = ffs(mask->control[band].ht_mcs[0]) - 1;
mode = MT_PHY_TYPE_HT;
goto out;
} else if (hweight32(mask->control[band].legacy) == 1) {
rateidx = ffs(mask->control[band].legacy) - 1; rateidx = ffs(mask->control[band].legacy) - 1;
goto legacy; goto legacy;
} }
...@@ -335,9 +346,9 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy, ...@@ -335,9 +346,9 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
rateidx = mt76_calculate_default_rate(mphy, rateidx); rateidx = mt76_calculate_default_rate(mphy, rateidx);
mode = rateidx >> 8; mode = rateidx >> 8;
rateidx &= GENMASK(7, 0); rateidx &= GENMASK(7, 0);
out: out:
return FIELD_PREP(MT_TX_RATE_IDX, rateidx) | return FIELD_PREP(MT_TX_RATE_NSS, nss) |
FIELD_PREP(MT_TX_RATE_IDX, rateidx) |
FIELD_PREP(MT_TX_RATE_MODE, mode); FIELD_PREP(MT_TX_RATE_MODE, mode);
} }
EXPORT_SYMBOL_GPL(mt76_connac2_mac_tx_rate_val); EXPORT_SYMBOL_GPL(mt76_connac2_mac_tx_rate_val);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment