Commit c17780e7 authored by Bo Jiao's avatar Bo Jiao Committed by Felix Fietkau

mt76: mt7915: add txfree event v3

Update txfree v3 format.
This is an intermediate patch to add mt7916 support.
Co-developed-by: default avatarSujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: default avatarSujuan Chen <sujuan.chen@mediatek.com>
Co-developed-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarBo Jiao <Bo.Jiao@mediatek.com>
Reviewed-by: default avatarShayne Chen <shayne.chen@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent b37d0c97
...@@ -1387,8 +1387,10 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) ...@@ -1387,8 +1387,10 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
LIST_HEAD(free_list); LIST_HEAD(free_list);
struct sk_buff *skb, *tmp; struct sk_buff *skb, *tmp;
void *end = data + len; void *end = data + len;
u8 i, count; bool v3, wake = false;
bool wake = false; u16 total, count = 0;
u32 txd = le32_to_cpu(free->txd);
u32 *cur_info;
/* clean DMA queues and unmap buffers first */ /* 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_PSD], false);
...@@ -1403,12 +1405,14 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) ...@@ -1403,12 +1405,14 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
* to the time ack is received or dropped by hw (air + hw queue time). * to the time ack is received or dropped by hw (air + hw queue time).
* Should avoid accessing WTBL to get Tx airtime, and use it instead. * Should avoid accessing WTBL to get Tx airtime, and use it instead.
*/ */
count = FIELD_GET(MT_TX_FREE_MSDU_CNT, le16_to_cpu(free->ctrl)); total = FIELD_GET(MT_TX_FREE_MSDU_CNT, le16_to_cpu(free->ctrl));
if (WARN_ON_ONCE((void *)&free->info[count] > end)) v3 = (FIELD_GET(MT_TX_FREE_VER, txd) == 0x4);
if (WARN_ON_ONCE((void *)&free->info[total >> v3] > end))
return; return;
for (i = 0; i < count; i++) { for (cur_info = &free->info[0]; count < total; cur_info++) {
u32 msdu, info = le32_to_cpu(free->info[i]); u32 msdu, info = le32_to_cpu(*cur_info);
u8 i;
/* /*
* 1'b1: new wcid pair. * 1'b1: new wcid pair.
...@@ -1419,7 +1423,6 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) ...@@ -1419,7 +1423,6 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
struct mt76_wcid *wcid; struct mt76_wcid *wcid;
u16 idx; u16 idx;
count++;
idx = FIELD_GET(MT_TX_FREE_WLAN_ID, info); idx = FIELD_GET(MT_TX_FREE_WLAN_ID, info);
wcid = rcu_dereference(dev->mt76.wcid[idx]); wcid = rcu_dereference(dev->mt76.wcid[idx]);
sta = wcid_to_sta(wcid); sta = wcid_to_sta(wcid);
...@@ -1434,12 +1437,24 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) ...@@ -1434,12 +1437,24 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
continue; continue;
} }
msdu = FIELD_GET(MT_TX_FREE_MSDU_ID, info); if (v3 && (info & MT_TX_FREE_MPDU_HEADER))
txwi = mt76_token_release(mdev, msdu, &wake);
if (!txwi)
continue; continue;
mt7915_txwi_free(dev, txwi, sta, &free_list); for (i = 0; i < 1 + v3; i++) {
if (v3) {
msdu = (info >> (15 * i)) & MT_TX_FREE_MSDU_ID_V3;
if (msdu == MT_TX_FREE_MSDU_ID_V3)
continue;
} else {
msdu = FIELD_GET(MT_TX_FREE_MSDU_ID, info);
}
count++;
txwi = mt76_token_release(mdev, msdu, &wake);
if (!txwi)
continue;
mt7915_txwi_free(dev, txwi, sta, &free_list);
}
} }
mt7915_mac_sta_poll(dev); mt7915_mac_sta_poll(dev);
......
...@@ -298,18 +298,20 @@ struct mt7915_txp { ...@@ -298,18 +298,20 @@ struct mt7915_txp {
struct mt7915_tx_free { struct mt7915_tx_free {
__le16 rx_byte_cnt; __le16 rx_byte_cnt;
__le16 ctrl; __le16 ctrl;
u8 txd_cnt; __le32 txd;
u8 rsv[3];
__le32 info[]; __le32 info[];
} __packed __aligned(4); } __packed __aligned(4);
#define MT_TX_FREE_VER GENMASK(18, 16)
#define MT_TX_FREE_MSDU_CNT GENMASK(9, 0) #define MT_TX_FREE_MSDU_CNT GENMASK(9, 0)
#define MT_TX_FREE_WLAN_ID GENMASK(23, 14) #define MT_TX_FREE_WLAN_ID GENMASK(23, 14)
#define MT_TX_FREE_LATENCY GENMASK(12, 0) #define MT_TX_FREE_LATENCY GENMASK(12, 0)
/* 0: success, others: dropped */ /* 0: success, others: dropped */
#define MT_TX_FREE_STATUS GENMASK(14, 13)
#define MT_TX_FREE_MSDU_ID GENMASK(30, 16) #define MT_TX_FREE_MSDU_ID GENMASK(30, 16)
#define MT_TX_FREE_PAIR BIT(31) #define MT_TX_FREE_PAIR BIT(31)
#define MT_TX_FREE_MPDU_HEADER BIT(30)
#define MT_TX_FREE_MSDU_ID_V3 GENMASK(14, 0)
/* will support this field in further revision */ /* will support this field in further revision */
#define MT_TX_FREE_RATE GENMASK(13, 0) #define MT_TX_FREE_RATE GENMASK(13, 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment