Commit bd1e3e7b authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau
Browse files

mt76: introduce packet_id idr



Introduce per-wcid idr to manage packet id for txs. This allow fast idr
lookup and skb queueing at the same time.

Tested-by: default avatar <mrkiko.rs@gmail.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 50ac15a5
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -566,6 +566,8 @@ mt76_alloc_device(struct device *pdev, unsigned int size,
	spin_lock_init(&dev->token_lock);
	idr_init(&dev->token);

	INIT_LIST_HEAD(&dev->wcid_list);

	INIT_LIST_HEAD(&dev->txwi_cache);

	for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++)
@@ -1237,6 +1239,7 @@ mt76_sta_add(struct mt76_dev *dev, struct ieee80211_vif *vif,
	wcid->ext_phy = ext_phy;
	rcu_assign_pointer(dev->wcid[wcid->idx], wcid);

	mt76_packet_id_init(wcid);
out:
	mutex_unlock(&dev->mutex);

@@ -1255,7 +1258,8 @@ void __mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif,
	if (dev->drv->sta_remove)
		dev->drv->sta_remove(dev, vif, sta);

	mt76_tx_status_check(dev, wcid, true);
	mt76_packet_id_flush(dev, wcid);

	mt76_wcid_mask_clear(dev->wcid_mask, idx);
	mt76_wcid_mask_clear(dev->wcid_phy_mask, idx);
}
+18 −8
Original line number Diff line number Diff line
@@ -261,7 +261,8 @@ struct mt76_wcid {
	u32 tx_info;
	bool sw_iv;

	u8 packet_id;
	struct list_head list;
	struct idr pktid;
};

struct mt76_txq {
@@ -701,6 +702,7 @@ struct mt76_dev {

	struct mt76_wcid global_wcid;
	struct mt76_wcid __rcu *wcid[MT76_N_WCIDS];
	struct list_head wcid_list;

	u32 rev;

@@ -1311,14 +1313,22 @@ mt76_token_put(struct mt76_dev *dev, int token)
	return txwi;
}

static inline int
mt76_get_next_pkt_id(struct mt76_wcid *wcid)
static inline void mt76_packet_id_init(struct mt76_wcid *wcid)
{
	INIT_LIST_HEAD(&wcid->list);
	idr_init(&wcid->pktid);
}

static inline void
mt76_packet_id_flush(struct mt76_dev *dev, struct mt76_wcid *wcid)
{
	wcid->packet_id = (wcid->packet_id + 1) & MT_PACKET_ID_MASK;
	if (wcid->packet_id == MT_PACKET_ID_NO_ACK ||
	    wcid->packet_id == MT_PACKET_ID_NO_SKB)
		wcid->packet_id = MT_PACKET_ID_FIRST;
	struct sk_buff_head list;

	return wcid->packet_id;
	mt76_tx_status_lock(dev, &list);
	mt76_tx_status_skb_get(dev, wcid, -1, &list);
	mt76_tx_status_unlock(dev, &list);

	idr_destroy(&wcid->pktid);
}

#endif
+3 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ mt7603_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
	INIT_LIST_HEAD(&mvif->sta.poll_list);
	mvif->sta.wcid.idx = idx;
	mvif->sta.wcid.hw_key_idx = -1;
	mt76_packet_id_init(&mvif->sta.wcid);

	eth_broadcast_addr(bc_addr);
	mt7603_wtbl_init(dev, idx, mvif->idx, bc_addr);
@@ -107,6 +108,8 @@ mt7603_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
	mutex_lock(&dev->mt76.mutex);
	dev->mt76.vif_mask &= ~BIT(mvif->idx);
	mutex_unlock(&dev->mt76.mutex);

	mt76_packet_id_flush(&dev->mt76, &mvif->sta.wcid);
}

void mt7603_init_edcca(struct mt7603_dev *dev)
+4 −0
Original line number Diff line number Diff line
@@ -231,6 +231,8 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
	mvif->sta.wcid.idx = idx;
	mvif->sta.wcid.ext_phy = mvif->mt76.band_idx;
	mvif->sta.wcid.hw_key_idx = -1;
	mt76_packet_id_init(&mvif->sta.wcid);

	mt7615_mac_wtbl_update(dev, idx,
			       MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

@@ -281,6 +283,8 @@ static void mt7615_remove_interface(struct ieee80211_hw *hw,
	if (!list_empty(&msta->poll_list))
		list_del_init(&msta->poll_list);
	spin_unlock_bh(&dev->sta_poll_lock);

	mt76_packet_id_flush(&dev->mt76, &mvif->sta.wcid);
}

static void mt7615_init_dfs_state(struct mt7615_phy *phy)
+3 −0
Original line number Diff line number Diff line
@@ -287,6 +287,8 @@ 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_packet_id_init(&mvif->group_wcid);

	mtxq = (struct mt76_txq *)vif->txq->drv_priv;
	mtxq->wcid = &mvif->group_wcid;
}
@@ -341,6 +343,7 @@ void mt76x02_remove_interface(struct ieee80211_hw *hw,
	struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;

	dev->mt76.vif_mask &= ~BIT(mvif->idx);
	mt76_packet_id_flush(&dev->mt76, &mvif->group_wcid);
}
EXPORT_SYMBOL_GPL(mt76x02_remove_interface);

Loading