Commit b619e013 authored by Evelyn Tsai's avatar Evelyn Tsai Committed by Felix Fietkau

mt76: fix MBSS index condition in DBDC mode

MT7915_MAX_INTERFACES is per-band declaration in MT7915/MT7986/MT7916.
Enlarge vif_mask to 64 bits wide, including the bit operation.
Reviewed-by: default avatarShayne Chen <shayne.chen@mediatek.com>
Signed-off-by: default avatarEvelyn Tsai <evelyn.tsai@mediatek.com>
Signed-off-by: default avatarBo Jiao <bo.jiao@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 51fb1278
...@@ -727,7 +727,7 @@ struct mt76_dev { ...@@ -727,7 +727,7 @@ struct mt76_dev {
u32 wcid_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)]; u32 wcid_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)];
u32 wcid_phy_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)]; u32 wcid_phy_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)];
u32 vif_mask; u64 vif_mask;
struct mt76_wcid global_wcid; struct mt76_wcid global_wcid;
struct mt76_wcid __rcu *wcid[MT76_N_WCIDS]; struct mt76_wcid __rcu *wcid[MT76_N_WCIDS];
......
...@@ -44,7 +44,7 @@ mt7603_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) ...@@ -44,7 +44,7 @@ mt7603_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
mvif->idx = ffs(~dev->mt76.vif_mask) - 1; mvif->idx = __ffs64(~dev->mt76.vif_mask);
if (mvif->idx >= MT7603_MAX_INTERFACES) { if (mvif->idx >= MT7603_MAX_INTERFACES) {
ret = -ENOSPC; ret = -ENOSPC;
goto out; goto out;
...@@ -65,7 +65,7 @@ mt7603_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) ...@@ -65,7 +65,7 @@ mt7603_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
} }
idx = MT7603_WTBL_RESERVED - 1 - mvif->idx; idx = MT7603_WTBL_RESERVED - 1 - mvif->idx;
dev->mt76.vif_mask |= BIT(mvif->idx); dev->mt76.vif_mask |= BIT_ULL(mvif->idx);
INIT_LIST_HEAD(&mvif->sta.poll_list); INIT_LIST_HEAD(&mvif->sta.poll_list);
mvif->sta.wcid.idx = idx; mvif->sta.wcid.idx = idx;
mvif->sta.wcid.hw_key_idx = -1; mvif->sta.wcid.hw_key_idx = -1;
...@@ -106,7 +106,7 @@ mt7603_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) ...@@ -106,7 +106,7 @@ mt7603_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
spin_unlock_bh(&dev->sta_poll_lock); spin_unlock_bh(&dev->sta_poll_lock);
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
dev->mt76.vif_mask &= ~BIT(mvif->idx); dev->mt76.vif_mask &= ~BIT_ULL(mvif->idx);
mutex_unlock(&dev->mt76.mutex); mutex_unlock(&dev->mt76.mutex);
mt76_packet_id_flush(&dev->mt76, &mvif->sta.wcid); mt76_packet_id_flush(&dev->mt76, &mvif->sta.wcid);
......
...@@ -194,7 +194,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw, ...@@ -194,7 +194,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
is_zero_ether_addr(vif->addr)) is_zero_ether_addr(vif->addr))
phy->monitor_vif = vif; phy->monitor_vif = vif;
mvif->mt76.idx = ffs(~dev->mt76.vif_mask) - 1; mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask);
if (mvif->mt76.idx >= MT7615_MAX_INTERFACES) { if (mvif->mt76.idx >= MT7615_MAX_INTERFACES) {
ret = -ENOSPC; ret = -ENOSPC;
goto out; goto out;
...@@ -212,7 +212,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw, ...@@ -212,7 +212,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
if (ext_phy) if (ext_phy)
mvif->mt76.wmm_idx += 2; mvif->mt76.wmm_idx += 2;
dev->mt76.vif_mask |= BIT(mvif->mt76.idx); dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx);
dev->omac_mask |= BIT_ULL(mvif->mt76.omac_idx); dev->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx); phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
...@@ -268,7 +268,7 @@ static void mt7615_remove_interface(struct ieee80211_hw *hw, ...@@ -268,7 +268,7 @@ static void mt7615_remove_interface(struct ieee80211_hw *hw,
rcu_assign_pointer(dev->mt76.wcid[idx], NULL); rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
dev->mt76.vif_mask &= ~BIT(mvif->mt76.idx); dev->mt76.vif_mask &= ~BIT_ULL(mvif->mt76.idx);
dev->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx); dev->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx);
phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx); phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx);
......
...@@ -328,11 +328,11 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) ...@@ -328,11 +328,11 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
idx += 8; idx += 8;
/* vif is already set or idx is 8 for AP/Mesh/... */ /* vif is already set or idx is 8 for AP/Mesh/... */
if (dev->mt76.vif_mask & BIT(idx) || if (dev->mt76.vif_mask & BIT_ULL(idx) ||
(vif->type != NL80211_IFTYPE_STATION && idx > 7)) (vif->type != NL80211_IFTYPE_STATION && idx > 7))
return -EBUSY; return -EBUSY;
dev->mt76.vif_mask |= BIT(idx); dev->mt76.vif_mask |= BIT_ULL(idx);
mt76x02_vif_init(dev, vif, idx); mt76x02_vif_init(dev, vif, idx);
return 0; return 0;
...@@ -345,7 +345,7 @@ void mt76x02_remove_interface(struct ieee80211_hw *hw, ...@@ -345,7 +345,7 @@ void mt76x02_remove_interface(struct ieee80211_hw *hw,
struct mt76x02_dev *dev = hw->priv; struct mt76x02_dev *dev = hw->priv;
struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv; struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
dev->mt76.vif_mask &= ~BIT(mvif->idx); dev->mt76.vif_mask &= ~BIT_ULL(mvif->idx);
rcu_assign_pointer(dev->mt76.wcid[mvif->group_wcid.idx], NULL); rcu_assign_pointer(dev->mt76.wcid[mvif->group_wcid.idx], NULL);
mt76_packet_id_flush(&dev->mt76, &mvif->group_wcid); mt76_packet_id_flush(&dev->mt76, &mvif->group_wcid);
} }
......
...@@ -204,8 +204,8 @@ static int mt7915_add_interface(struct ieee80211_hw *hw, ...@@ -204,8 +204,8 @@ static int mt7915_add_interface(struct ieee80211_hw *hw,
is_zero_ether_addr(vif->addr)) is_zero_ether_addr(vif->addr))
phy->monitor_vif = vif; phy->monitor_vif = vif;
mvif->mt76.idx = ffs(~dev->mt76.vif_mask) - 1; mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask);
if (mvif->mt76.idx >= MT7915_MAX_INTERFACES) { if (mvif->mt76.idx >= (MT7915_MAX_INTERFACES << dev->dbdc_support)) {
ret = -ENOSPC; ret = -ENOSPC;
goto out; goto out;
} }
...@@ -227,7 +227,7 @@ static int mt7915_add_interface(struct ieee80211_hw *hw, ...@@ -227,7 +227,7 @@ static int mt7915_add_interface(struct ieee80211_hw *hw,
if (ret) if (ret)
goto out; goto out;
dev->mt76.vif_mask |= BIT(mvif->mt76.idx); dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx);
phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx); phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
idx = MT7915_WTBL_RESERVED - mvif->mt76.idx; idx = MT7915_WTBL_RESERVED - mvif->mt76.idx;
...@@ -290,7 +290,7 @@ static void mt7915_remove_interface(struct ieee80211_hw *hw, ...@@ -290,7 +290,7 @@ static void mt7915_remove_interface(struct ieee80211_hw *hw,
rcu_assign_pointer(dev->mt76.wcid[idx], NULL); rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
dev->mt76.vif_mask &= ~BIT(mvif->mt76.idx); dev->mt76.vif_mask &= ~BIT_ULL(mvif->mt76.idx);
phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx); phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx);
mutex_unlock(&dev->mt76.mutex); mutex_unlock(&dev->mt76.mutex);
......
...@@ -294,7 +294,7 @@ static int mt7921_add_interface(struct ieee80211_hw *hw, ...@@ -294,7 +294,7 @@ static int mt7921_add_interface(struct ieee80211_hw *hw,
mt7921_mutex_acquire(dev); mt7921_mutex_acquire(dev);
mvif->mt76.idx = ffs(~dev->mt76.vif_mask) - 1; mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask);
if (mvif->mt76.idx >= MT7921_MAX_INTERFACES) { if (mvif->mt76.idx >= MT7921_MAX_INTERFACES) {
ret = -ENOSPC; ret = -ENOSPC;
goto out; goto out;
...@@ -310,7 +310,7 @@ static int mt7921_add_interface(struct ieee80211_hw *hw, ...@@ -310,7 +310,7 @@ static int mt7921_add_interface(struct ieee80211_hw *hw,
if (ret) if (ret)
goto out; goto out;
dev->mt76.vif_mask |= BIT(mvif->mt76.idx); dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx);
phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx); phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
idx = MT7921_WTBL_RESERVED - mvif->mt76.idx; idx = MT7921_WTBL_RESERVED - mvif->mt76.idx;
...@@ -354,7 +354,7 @@ static void mt7921_remove_interface(struct ieee80211_hw *hw, ...@@ -354,7 +354,7 @@ static void mt7921_remove_interface(struct ieee80211_hw *hw,
rcu_assign_pointer(dev->mt76.wcid[idx], NULL); rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
dev->mt76.vif_mask &= ~BIT(mvif->mt76.idx); dev->mt76.vif_mask &= ~BIT_ULL(mvif->mt76.idx);
phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx); phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx);
mt7921_mutex_release(dev); mt7921_mutex_release(dev);
......
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