Skip to content

Commit

Permalink
mt76: mt7921: fix OMAC idx usage
Browse files Browse the repository at this point in the history
[ Upstream commit 213f872 ]

OMAC idx have to be same with BSS idx according to firmware usage.

Fixes: e0f9fdd ("mt76: mt7921: add ieee80211_ops")
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: YN Chen <yn.chen@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
moore-bros authored and gregkh committed Jul 14, 2021
1 parent e176fef commit a641c9e
Showing 1 changed file with 1 addition and 54 deletions.
55 changes: 1 addition & 54 deletions drivers/net/wireless/mediatek/mt76/mt7921/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,54 +223,6 @@ static void mt7921_stop(struct ieee80211_hw *hw)
mt7921_mutex_release(dev);
}

static inline int get_free_idx(u32 mask, u8 start, u8 end)
{
return ffs(~mask & GENMASK(end, start));
}

static int get_omac_idx(enum nl80211_iftype type, u64 mask)
{
int i;

switch (type) {
case NL80211_IFTYPE_STATION:
/* prefer hw bssid slot 1-3 */
i = get_free_idx(mask, HW_BSSID_1, HW_BSSID_3);
if (i)
return i - 1;

/* next, try to find a free repeater entry for the sta */
i = get_free_idx(mask >> REPEATER_BSSID_START, 0,
REPEATER_BSSID_MAX - REPEATER_BSSID_START);
if (i)
return i + 32 - 1;

i = get_free_idx(mask, EXT_BSSID_1, EXT_BSSID_MAX);
if (i)
return i - 1;

if (~mask & BIT(HW_BSSID_0))
return HW_BSSID_0;

break;
case NL80211_IFTYPE_MONITOR:
/* ap uses hw bssid 0 and ext bssid */
if (~mask & BIT(HW_BSSID_0))
return HW_BSSID_0;

i = get_free_idx(mask, EXT_BSSID_1, EXT_BSSID_MAX);
if (i)
return i - 1;

break;
default:
WARN_ON(1);
break;
}

return -1;
}

static int mt7921_add_interface(struct ieee80211_hw *hw,
struct ieee80211_vif *vif)
{
Expand All @@ -292,12 +244,7 @@ static int mt7921_add_interface(struct ieee80211_hw *hw,
goto out;
}

idx = get_omac_idx(vif->type, phy->omac_mask);
if (idx < 0) {
ret = -ENOSPC;
goto out;
}
mvif->mt76.omac_idx = idx;
mvif->mt76.omac_idx = mvif->mt76.idx;
mvif->phy = phy;
mvif->mt76.band_idx = 0;
mvif->mt76.wmm_idx = mvif->mt76.idx % MT7921_MAX_WMM_SETS;
Expand Down

0 comments on commit a641c9e

Please sign in to comment.