wifi: mt76: initialize more wcid fields mt76_wcid_init

Reduces code duplication and ensures that the phy index is always set.

Link: https://patch.msgid.link/20250102163508.52945-6-nbd@nbd.name
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Felix Fietkau
2025-01-02 17:34:50 +01:00
parent 36e02101f8
commit cbf5e61da6
9 changed files with 18 additions and 31 deletions

View File

@@ -742,7 +742,7 @@ int mt76_register_device(struct mt76_dev *dev, bool vht,
int ret;
dev_set_drvdata(dev->dev, dev);
mt76_wcid_init(&dev->global_wcid);
mt76_wcid_init(&dev->global_wcid, phy->band_idx);
ret = mt76_phy_init(phy, hw);
if (ret)
return ret;
@@ -1494,11 +1494,10 @@ mt76_sta_add(struct mt76_phy *phy, struct ieee80211_vif *vif,
ewma_signal_init(&wcid->rssi);
if (phy->band_idx == MT_BAND1)
mt76_wcid_mask_set(dev->wcid_phy_mask, wcid->idx);
wcid->phy_idx = phy->band_idx;
rcu_assign_pointer(dev->wcid[wcid->idx], wcid);
phy->num_sta++;
mt76_wcid_init(wcid);
mt76_wcid_init(wcid, phy->band_idx);
out:
mutex_unlock(&dev->mutex);
@@ -1588,14 +1587,19 @@ void mt76_sta_pre_rcu_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
}
EXPORT_SYMBOL_GPL(mt76_sta_pre_rcu_remove);
void mt76_wcid_init(struct mt76_wcid *wcid)
void mt76_wcid_init(struct mt76_wcid *wcid, u8 band_idx)
{
wcid->hw_key_idx = -1;
wcid->phy_idx = band_idx;
INIT_LIST_HEAD(&wcid->tx_list);
skb_queue_head_init(&wcid->tx_pending);
skb_queue_head_init(&wcid->tx_offchannel);
INIT_LIST_HEAD(&wcid->list);
idr_init(&wcid->pktid);
INIT_LIST_HEAD(&wcid->poll_list);
}
EXPORT_SYMBOL_GPL(mt76_wcid_init);

View File

@@ -1764,7 +1764,7 @@ mt76_token_put(struct mt76_dev *dev, int token)
return txwi;
}
void mt76_wcid_init(struct mt76_wcid *wcid);
void mt76_wcid_init(struct mt76_wcid *wcid, u8 band_idx);
void mt76_wcid_cleanup(struct mt76_dev *dev, struct mt76_wcid *wcid);
void mt76_wcid_add_poll(struct mt76_dev *dev, struct mt76_wcid *wcid);

View File

@@ -66,11 +66,9 @@ mt7603_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
idx = MT7603_WTBL_RESERVED - 1 - mvif->idx;
dev->mt76.vif_mask |= BIT_ULL(mvif->idx);
INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
mvif->sta.wcid.idx = idx;
mvif->sta.wcid.hw_key_idx = -1;
mvif->sta.vif = mvif;
mt76_wcid_init(&mvif->sta.wcid);
mt76_wcid_init(&mvif->sta.wcid, 0);
eth_broadcast_addr(bc_addr);
mt7603_wtbl_init(dev, idx, mvif->idx, bc_addr);

View File

@@ -225,9 +225,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
mvif->sta.wcid.idx = idx;
mvif->sta.wcid.phy_idx = mvif->mt76.band_idx;
mvif->sta.wcid.hw_key_idx = -1;
mt76_wcid_init(&mvif->sta.wcid);
mt76_wcid_init(&mvif->sta.wcid, mvif->mt76.band_idx);
mt7615_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

View File

@@ -287,8 +287,7 @@ mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
mvif->idx = idx;
mvif->group_wcid.idx = MT_VIF_WCID(idx);
mvif->group_wcid.hw_key_idx = -1;
mt76_wcid_init(&mvif->group_wcid);
mt76_wcid_init(&mvif->group_wcid, 0);
mtxq = (struct mt76_txq *)vif->txq->drv_priv;
rcu_assign_pointer(dev->mt76.wcid[MT_VIF_WCID(idx)], &mvif->group_wcid);

View File

@@ -253,12 +253,9 @@ static int mt7915_add_interface(struct ieee80211_hw *hw,
}
INIT_LIST_HEAD(&mvif->sta.rc_list);
INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
mvif->sta.wcid.idx = idx;
mvif->sta.wcid.phy_idx = ext_phy;
mvif->sta.wcid.hw_key_idx = -1;
mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET;
mt76_wcid_init(&mvif->sta.wcid);
mt76_wcid_init(&mvif->sta.wcid, phy->mt76->band_idx);
mt7915_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

View File

@@ -325,10 +325,8 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
INIT_LIST_HEAD(&mvif->sta.deflink.wcid.poll_list);
mvif->sta.deflink.wcid.idx = idx;
mvif->sta.deflink.wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
mvif->sta.deflink.wcid.hw_key_idx = -1;
mvif->sta.deflink.wcid.tx_info |= MT_WCID_TX_INFO_SET;
mt76_wcid_init(&mvif->sta.deflink.wcid);
mt76_wcid_init(&mvif->sta.deflink.wcid, mvif->bss_conf.mt76.band_idx);
mt7921_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

View File

@@ -378,12 +378,9 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev,
idx = MT792x_WTBL_RESERVED - mconf->mt76.idx;
INIT_LIST_HEAD(&mlink->wcid.poll_list);
mlink->wcid.idx = idx;
mlink->wcid.phy_idx = 0;
mlink->wcid.hw_key_idx = -1;
mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET;
mt76_wcid_init(&mlink->wcid);
mt76_wcid_init(&mlink->wcid, 0);
mt7925_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
@@ -850,10 +847,9 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,
return -ENOSPC;
mconf = mt792x_vif_to_link(mvif, link_id);
INIT_LIST_HEAD(&mlink->wcid.poll_list);
mt76_wcid_init(&mlink->wcid, 0);
mlink->wcid.sta = 1;
mlink->wcid.idx = idx;
mlink->wcid.phy_idx = 0;
mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET;
mlink->last_txs = jiffies;
mlink->wcid.link_id = link_sta->link_id;
@@ -863,7 +859,7 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,
wcid = &mlink->wcid;
ewma_signal_init(&wcid->rssi);
rcu_assign_pointer(dev->mt76.wcid[wcid->idx], wcid);
mt76_wcid_init(wcid);
mt76_wcid_init(wcid, 0);
ewma_avg_signal_init(&mlink->avg_ack_signal);
memset(mlink->airtime_ac, 0,
sizeof(msta->deflink.airtime_ac));

View File

@@ -214,12 +214,9 @@ mt7996_vif_link_add(struct mt7996_phy *phy, struct ieee80211_vif *vif,
idx = MT7996_WTBL_RESERVED - mlink->mt76.idx;
INIT_LIST_HEAD(&mlink->sta.rc_list);
INIT_LIST_HEAD(&mlink->sta.wcid.poll_list);
mlink->sta.wcid.idx = idx;
mlink->sta.wcid.phy_idx = band_idx;
mlink->sta.wcid.hw_key_idx = -1;
mlink->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET;
mt76_wcid_init(&mlink->sta.wcid);
mt76_wcid_init(&mlink->sta.wcid, band_idx);
mt7996_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);