mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
wifi: mt76: mt7921: move mt7921_rx_check and mt7921_queue_rx_skb in mac.c
Since both mt7921_rx_check and mt7921_queue_rx_skb routines are used by all chipsets (mmio, usb and sdio), move them in mac.c and remove duplicated code. Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
committed by
Felix Fietkau
parent
9706ccef54
commit
74a29eb4f7
@@ -53,154 +53,6 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
mt7921_txwi_free(struct mt7921_dev *dev, struct mt76_txwi_cache *t,
|
||||
struct ieee80211_sta *sta, bool clear_status,
|
||||
struct list_head *free_list)
|
||||
{
|
||||
struct mt76_dev *mdev = &dev->mt76;
|
||||
__le32 *txwi;
|
||||
u16 wcid_idx;
|
||||
|
||||
mt76_connac_txp_skb_unmap(mdev, t);
|
||||
if (!t->skb)
|
||||
goto out;
|
||||
|
||||
txwi = (__le32 *)mt76_get_txwi_ptr(mdev, t);
|
||||
if (sta) {
|
||||
struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv;
|
||||
|
||||
if (likely(t->skb->protocol != cpu_to_be16(ETH_P_PAE)))
|
||||
mt7921_tx_check_aggr(sta, txwi);
|
||||
|
||||
wcid_idx = wcid->idx;
|
||||
} else {
|
||||
wcid_idx = le32_get_bits(txwi[1], MT_TXD1_WLAN_IDX);
|
||||
}
|
||||
|
||||
__mt76_tx_complete_skb(mdev, wcid_idx, t->skb, free_list);
|
||||
|
||||
out:
|
||||
t->skb = NULL;
|
||||
mt76_put_txwi(mdev, t);
|
||||
}
|
||||
|
||||
static void
|
||||
mt7921e_mac_tx_free(struct mt7921_dev *dev, void *data, int len)
|
||||
{
|
||||
struct mt76_connac_tx_free *free = data;
|
||||
__le32 *tx_info = (__le32 *)(data + sizeof(*free));
|
||||
struct mt76_dev *mdev = &dev->mt76;
|
||||
struct mt76_txwi_cache *txwi;
|
||||
struct ieee80211_sta *sta = NULL;
|
||||
struct sk_buff *skb, *tmp;
|
||||
void *end = data + len;
|
||||
LIST_HEAD(free_list);
|
||||
bool wake = false;
|
||||
u8 i, count;
|
||||
|
||||
/* clean DMA queues and unmap buffers first */
|
||||
mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_PSD], false);
|
||||
mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_BE], false);
|
||||
|
||||
count = le16_get_bits(free->ctrl, MT_TX_FREE_MSDU_CNT);
|
||||
if (WARN_ON_ONCE((void *)&tx_info[count] > end))
|
||||
return;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
u32 msdu, info = le32_to_cpu(tx_info[i]);
|
||||
u8 stat;
|
||||
|
||||
/* 1'b1: new wcid pair.
|
||||
* 1'b0: msdu_id with the same 'wcid pair' as above.
|
||||
*/
|
||||
if (info & MT_TX_FREE_PAIR) {
|
||||
struct mt7921_sta *msta;
|
||||
struct mt76_wcid *wcid;
|
||||
u16 idx;
|
||||
|
||||
count++;
|
||||
idx = FIELD_GET(MT_TX_FREE_WLAN_ID, info);
|
||||
wcid = rcu_dereference(dev->mt76.wcid[idx]);
|
||||
sta = wcid_to_sta(wcid);
|
||||
if (!sta)
|
||||
continue;
|
||||
|
||||
msta = container_of(wcid, struct mt7921_sta, wcid);
|
||||
spin_lock_bh(&dev->sta_poll_lock);
|
||||
if (list_empty(&msta->poll_list))
|
||||
list_add_tail(&msta->poll_list, &dev->sta_poll_list);
|
||||
spin_unlock_bh(&dev->sta_poll_lock);
|
||||
continue;
|
||||
}
|
||||
|
||||
msdu = FIELD_GET(MT_TX_FREE_MSDU_ID, info);
|
||||
stat = FIELD_GET(MT_TX_FREE_STATUS, info);
|
||||
|
||||
txwi = mt76_token_release(mdev, msdu, &wake);
|
||||
if (!txwi)
|
||||
continue;
|
||||
|
||||
mt7921_txwi_free(dev, txwi, sta, stat, &free_list);
|
||||
}
|
||||
|
||||
if (wake)
|
||||
mt76_set_tx_blocked(&dev->mt76, false);
|
||||
|
||||
list_for_each_entry_safe(skb, tmp, &free_list, list) {
|
||||
skb_list_del_init(skb);
|
||||
napi_consume_skb(skb, 1);
|
||||
}
|
||||
|
||||
rcu_read_lock();
|
||||
mt7921_mac_sta_poll(dev);
|
||||
rcu_read_unlock();
|
||||
|
||||
mt76_worker_schedule(&dev->mt76.tx_worker);
|
||||
}
|
||||
|
||||
bool mt7921e_rx_check(struct mt76_dev *mdev, void *data, int len)
|
||||
{
|
||||
struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
|
||||
__le32 *rxd = (__le32 *)data;
|
||||
__le32 *end = (__le32 *)&rxd[len / 4];
|
||||
enum rx_pkt_type type;
|
||||
|
||||
type = le32_get_bits(rxd[0], MT_RXD0_PKT_TYPE);
|
||||
|
||||
switch (type) {
|
||||
case PKT_TYPE_TXRX_NOTIFY:
|
||||
mt7921e_mac_tx_free(dev, data, len);
|
||||
return false;
|
||||
case PKT_TYPE_TXS:
|
||||
for (rxd += 2; rxd + 8 <= end; rxd += 8)
|
||||
mt7921_mac_add_txs(dev, rxd);
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void mt7921e_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
|
||||
__le32 *rxd = (__le32 *)skb->data;
|
||||
enum rx_pkt_type type;
|
||||
|
||||
type = le32_get_bits(rxd[0], MT_RXD0_PKT_TYPE);
|
||||
|
||||
switch (type) {
|
||||
case PKT_TYPE_TXRX_NOTIFY:
|
||||
mt7921e_mac_tx_free(dev, skb->data, skb->len);
|
||||
napi_consume_skb(skb, 1);
|
||||
break;
|
||||
default:
|
||||
mt7921_queue_rx_skb(mdev, q, skb);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void mt7921_tx_token_put(struct mt7921_dev *dev)
|
||||
{
|
||||
struct mt76_txwi_cache *txwi;
|
||||
|
||||
Reference in New Issue
Block a user