Commit cbf5e61d authored by Felix Fietkau's avatar Felix Fietkau
Browse files

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: default avatarFelix Fietkau <nbd@nbd.name>
parent 36e02101
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -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);

+1 −1
Original line number Diff line number Diff line
@@ -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);

+1 −3
Original line number Diff line number Diff line
@@ -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);
+1 −3
Original line number Diff line number Diff line
@@ -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);
+1 −2
Original line number Diff line number Diff line
@@ -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);
Loading