Commit beffe070 authored by Felix Fietkau's avatar Felix Fietkau

mt76: vif_mask to struct mt76_phy

All drivers use this in pretty much the same way. Moving it to core helps with
some checks for the upcoming testmode support
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent b8c97866
...@@ -491,6 +491,8 @@ struct mt76_phy { ...@@ -491,6 +491,8 @@ struct mt76_phy {
struct mt76_sband sband_2g; struct mt76_sband sband_2g;
struct mt76_sband sband_5g; struct mt76_sband sband_5g;
u32 vif_mask;
int txpower_cur; int txpower_cur;
u8 antenna_mask; u8 antenna_mask;
}; };
......
...@@ -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->vif_mask) - 1; mvif->idx = ffs(~dev->mphy.vif_mask) - 1;
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->vif_mask |= BIT(mvif->idx); dev->mphy.vif_mask |= BIT(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;
...@@ -107,7 +107,7 @@ mt7603_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) ...@@ -107,7 +107,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->vif_mask &= ~BIT(mvif->idx); dev->mphy.vif_mask &= ~BIT(mvif->idx);
mutex_unlock(&dev->mt76.mutex); mutex_unlock(&dev->mt76.mutex);
} }
......
...@@ -108,8 +108,6 @@ struct mt7603_dev { ...@@ -108,8 +108,6 @@ struct mt7603_dev {
u32 rxfilter; u32 rxfilter;
u8 vif_mask;
struct list_head sta_poll_list; struct list_head sta_poll_list;
spinlock_t sta_poll_lock; spinlock_t sta_poll_lock;
......
...@@ -137,7 +137,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw, ...@@ -137,7 +137,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
mvif->idx = ffs(~dev->vif_mask) - 1; mvif->idx = ffs(~dev->mphy.vif_mask) - 1;
if (mvif->idx >= MT7615_MAX_INTERFACES) { if (mvif->idx >= MT7615_MAX_INTERFACES) {
ret = -ENOSPC; ret = -ENOSPC;
goto out; goto out;
...@@ -157,7 +157,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw, ...@@ -157,7 +157,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
else else
mvif->wmm_idx = mvif->idx % MT7615_MAX_WMM_SETS; mvif->wmm_idx = mvif->idx % MT7615_MAX_WMM_SETS;
dev->vif_mask |= BIT(mvif->idx); dev->mphy.vif_mask |= BIT(mvif->idx);
dev->omac_mask |= BIT(mvif->omac_idx); dev->omac_mask |= BIT(mvif->omac_idx);
phy->omac_mask |= BIT(mvif->omac_idx); phy->omac_mask |= BIT(mvif->omac_idx);
...@@ -204,7 +204,7 @@ static void mt7615_remove_interface(struct ieee80211_hw *hw, ...@@ -204,7 +204,7 @@ static void mt7615_remove_interface(struct ieee80211_hw *hw,
mt76_txq_remove(&dev->mt76, vif->txq); mt76_txq_remove(&dev->mt76, vif->txq);
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
dev->vif_mask &= ~BIT(mvif->idx); dev->mphy.vif_mask &= ~BIT(mvif->idx);
dev->omac_mask &= ~BIT(mvif->omac_idx); dev->omac_mask &= ~BIT(mvif->omac_idx);
phy->omac_mask &= ~BIT(mvif->omac_idx); phy->omac_mask &= ~BIT(mvif->omac_idx);
mutex_unlock(&dev->mt76.mutex); mutex_unlock(&dev->mt76.mutex);
......
...@@ -244,7 +244,6 @@ struct mt7615_dev { ...@@ -244,7 +244,6 @@ struct mt7615_dev {
struct tasklet_struct irq_tasklet; struct tasklet_struct irq_tasklet;
struct mt7615_phy phy; struct mt7615_phy phy;
u32 vif_mask;
u32 omac_mask; u32 omac_mask;
u16 chainmask; u16 chainmask;
......
...@@ -80,7 +80,6 @@ struct mt76x02_dev { ...@@ -80,7 +80,6 @@ struct mt76x02_dev {
struct mutex phy_mutex; struct mutex phy_mutex;
u16 vif_mask;
u16 chainmask; u16 chainmask;
u8 txdone_seq; u8 txdone_seq;
......
...@@ -439,7 +439,7 @@ static void mt76x02_reset_state(struct mt76x02_dev *dev) ...@@ -439,7 +439,7 @@ static void mt76x02_reset_state(struct mt76x02_dev *dev)
memset(msta, 0, sizeof(*msta)); memset(msta, 0, sizeof(*msta));
} }
dev->vif_mask = 0; dev->mphy.vif_mask = 0;
dev->mt76.beacon_mask = 0; dev->mt76.beacon_mask = 0;
} }
......
...@@ -305,7 +305,7 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) ...@@ -305,7 +305,7 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
unsigned int idx = 0; unsigned int idx = 0;
/* Allow to change address in HW if we create first interface. */ /* Allow to change address in HW if we create first interface. */
if (!dev->vif_mask && if (!dev->mphy.vif_mask &&
(((vif->addr[0] ^ dev->mt76.macaddr[0]) & ~GENMASK(4, 1)) || (((vif->addr[0] ^ dev->mt76.macaddr[0]) & ~GENMASK(4, 1)) ||
memcmp(vif->addr + 1, dev->mt76.macaddr + 1, ETH_ALEN - 1))) memcmp(vif->addr + 1, dev->mt76.macaddr + 1, ETH_ALEN - 1)))
mt76x02_mac_setaddr(dev, vif->addr); mt76x02_mac_setaddr(dev, vif->addr);
...@@ -330,11 +330,11 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) ...@@ -330,11 +330,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->vif_mask & BIT(idx) || if (dev->mphy.vif_mask & BIT(idx) ||
(vif->type != NL80211_IFTYPE_STATION && idx > 7)) (vif->type != NL80211_IFTYPE_STATION && idx > 7))
return -EBUSY; return -EBUSY;
dev->vif_mask |= BIT(idx); dev->mphy.vif_mask |= BIT(idx);
mt76x02_vif_init(dev, vif, idx); mt76x02_vif_init(dev, vif, idx);
return 0; return 0;
...@@ -348,7 +348,7 @@ void mt76x02_remove_interface(struct ieee80211_hw *hw, ...@@ -348,7 +348,7 @@ void mt76x02_remove_interface(struct ieee80211_hw *hw,
struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv; struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
mt76_txq_remove(&dev->mt76, vif->txq); mt76_txq_remove(&dev->mt76, vif->txq);
dev->vif_mask &= ~BIT(mvif->idx); dev->mphy.vif_mask &= ~BIT(mvif->idx);
} }
EXPORT_SYMBOL_GPL(mt76x02_remove_interface); EXPORT_SYMBOL_GPL(mt76x02_remove_interface);
......
...@@ -125,7 +125,7 @@ static int mt7915_add_interface(struct ieee80211_hw *hw, ...@@ -125,7 +125,7 @@ static int mt7915_add_interface(struct ieee80211_hw *hw,
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
mvif->idx = ffs(~phy->vif_mask) - 1; mvif->idx = ffs(~phy->mt76->vif_mask) - 1;
if (mvif->idx >= MT7915_MAX_INTERFACES) { if (mvif->idx >= MT7915_MAX_INTERFACES) {
ret = -ENOSPC; ret = -ENOSPC;
goto out; goto out;
...@@ -150,7 +150,7 @@ static int mt7915_add_interface(struct ieee80211_hw *hw, ...@@ -150,7 +150,7 @@ static int mt7915_add_interface(struct ieee80211_hw *hw,
if (ret) if (ret)
goto out; goto out;
phy->vif_mask |= BIT(mvif->idx); phy->mt76->vif_mask |= BIT(mvif->idx);
phy->omac_mask |= BIT(mvif->omac_idx); phy->omac_mask |= BIT(mvif->omac_idx);
idx = MT7915_WTBL_RESERVED - mvif->idx; idx = MT7915_WTBL_RESERVED - mvif->idx;
...@@ -194,7 +194,7 @@ static void mt7915_remove_interface(struct ieee80211_hw *hw, ...@@ -194,7 +194,7 @@ static void mt7915_remove_interface(struct ieee80211_hw *hw,
mt76_txq_remove(&dev->mt76, vif->txq); mt76_txq_remove(&dev->mt76, vif->txq);
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
phy->vif_mask &= ~BIT(mvif->idx); phy->mt76->vif_mask &= ~BIT(mvif->idx);
phy->omac_mask &= ~BIT(mvif->omac_idx); phy->omac_mask &= ~BIT(mvif->omac_idx);
mutex_unlock(&dev->mt76.mutex); mutex_unlock(&dev->mt76.mutex);
......
...@@ -120,7 +120,6 @@ struct mt7915_phy { ...@@ -120,7 +120,6 @@ struct mt7915_phy {
struct ieee80211_sband_iftype_data iftype[2][NUM_NL80211_IFTYPES]; struct ieee80211_sband_iftype_data iftype[2][NUM_NL80211_IFTYPES];
u32 rxfilter; u32 rxfilter;
u32 vif_mask;
u32 omac_mask; u32 omac_mask;
u16 noise; u16 noise;
......
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