Skip to content

Commit

Permalink
mt76: introduce mt76_vif data structure
Browse files Browse the repository at this point in the history
Introduce mt76_vif data structure to share common fields between
mt7615_vif and mt7921_vif and create a mcu common library

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed Jan 29, 2021
1 parent 8696919 commit 261d184
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 81 deletions.
8 changes: 8 additions & 0 deletions mt76.h
Expand Up @@ -562,6 +562,14 @@ struct mt76_testmode_data {
} rx_stats;
};

struct mt76_vif {
u8 idx;
u8 omac_idx;
u8 band_idx;
u8 wmm_idx;
u8 scan_seq_num;
};

struct mt76_phy {
struct ieee80211_hw *hw;
struct mt76_dev *dev;
Expand Down
2 changes: 1 addition & 1 deletion mt7615/mac.c
Expand Up @@ -544,7 +544,7 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,
u16 seqno = 0;

if (vif) {
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;

omac_idx = mvif->omac_idx;
wmm_idx = mvif->wmm_idx;
Expand Down
38 changes: 19 additions & 19 deletions mt7615/main.c
Expand Up @@ -187,8 +187,8 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
is_zero_ether_addr(vif->addr))
phy->monitor_vif = vif;

mvif->idx = ffs(~dev->mt76.vif_mask) - 1;
if (mvif->idx >= MT7615_MAX_INTERFACES) {
mvif->mt76.idx = ffs(~dev->mt76.vif_mask) - 1;
if (mvif->mt76.idx >= MT7615_MAX_INTERFACES) {
ret = -ENOSPC;
goto out;
}
Expand All @@ -198,26 +198,26 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
ret = -ENOSPC;
goto out;
}
mvif->omac_idx = idx;
mvif->mt76.omac_idx = idx;

mvif->band_idx = ext_phy;
mvif->mt76.band_idx = ext_phy;
if (mt7615_ext_phy(dev))
mvif->wmm_idx = ext_phy * (MT7615_MAX_WMM_SETS / 2) +
mvif->idx % (MT7615_MAX_WMM_SETS / 2);
mvif->mt76.wmm_idx = ext_phy * (MT7615_MAX_WMM_SETS / 2) +
mvif->mt76.idx % (MT7615_MAX_WMM_SETS / 2);
else
mvif->wmm_idx = mvif->idx % MT7615_MAX_WMM_SETS;
mvif->mt76.wmm_idx = mvif->mt76.idx % MT7615_MAX_WMM_SETS;

dev->mt76.vif_mask |= BIT(mvif->idx);
dev->omac_mask |= BIT_ULL(mvif->omac_idx);
phy->omac_mask |= BIT_ULL(mvif->omac_idx);
dev->mt76.vif_mask |= BIT(mvif->mt76.idx);
dev->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);

mt7615_mcu_set_dbdc(dev);

idx = MT7615_WTBL_RESERVED - mvif->idx;
idx = MT7615_WTBL_RESERVED - mvif->mt76.idx;

INIT_LIST_HEAD(&mvif->sta.poll_list);
mvif->sta.wcid.idx = idx;
mvif->sta.wcid.ext_phy = mvif->band_idx;
mvif->sta.wcid.ext_phy = mvif->mt76.band_idx;
mvif->sta.wcid.hw_key_idx = -1;
mt7615_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
Expand Down Expand Up @@ -263,9 +263,9 @@ static void mt7615_remove_interface(struct ieee80211_hw *hw,

rcu_assign_pointer(dev->mt76.wcid[idx], NULL);

dev->mt76.vif_mask &= ~BIT(mvif->idx);
dev->omac_mask &= ~BIT_ULL(mvif->omac_idx);
phy->omac_mask &= ~BIT_ULL(mvif->omac_idx);
dev->mt76.vif_mask &= ~BIT(mvif->mt76.idx);
dev->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx);
phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx);

mt7615_mutex_release(dev);

Expand Down Expand Up @@ -445,7 +445,7 @@ static int
mt7615_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue,
const struct ieee80211_tx_queue_params *params)
{
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
struct mt7615_dev *dev = mt7615_hw_dev(hw);
int err;

Expand Down Expand Up @@ -589,7 +589,7 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
msta->vif = mvif;
msta->wcid.sta = 1;
msta->wcid.idx = idx;
msta->wcid.ext_phy = mvif->band_idx;
msta->wcid.ext_phy = mvif->mt76.band_idx;

err = mt7615_pm_wake(dev);
if (err)
Expand All @@ -598,7 +598,7 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) {
struct mt7615_phy *phy;

phy = mvif->band_idx ? mt7615_ext_phy(dev) : &dev->phy;
phy = mvif->mt76.band_idx ? mt7615_ext_phy(dev) : &dev->phy;
mt7615_mcu_add_bss_info(phy, vif, sta, true);
}
mt7615_mac_wtbl_update(dev, idx,
Expand Down Expand Up @@ -627,7 +627,7 @@ void mt7615_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct mt7615_phy *phy;

phy = mvif->band_idx ? mt7615_ext_phy(dev) : &dev->phy;
phy = mvif->mt76.band_idx ? mt7615_ext_phy(dev) : &dev->phy;
mt7615_mcu_add_bss_info(phy, vif, sta, false);
}

Expand Down

0 comments on commit 261d184

Please sign in to comment.