blob: 9f2bfc838097e514caf15f1ead60e78df9283895 [file] [log] [blame]
developerefb40c12022-12-21 18:05:47 +08001From 0f99f68ae5aaabbb8a3c8a6b2f70114fe685267a Mon Sep 17 00:00:00 2001
developer3262bf82022-07-12 11:37:54 +08002From: Sujuan Chen <sujuan.chen@mediatek.com>
developer3d5faf22022-11-29 18:07:22 +08003Date: Fri, 25 Nov 2022 10:38:53 +0800
developer2aa1e642022-12-19 11:33:22 +08004Subject: [PATCH 3001/3013] mt76: mt7915: wed: add wed tx support
developer3262bf82022-07-12 11:37:54 +08005
6Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
7---
developerf1313102022-10-11 11:02:55 +08008 mt76_connac.h | 1 +
9 mt7915/mac.c | 11 +++++++----
10 mt7915/main.c | 4 ++--
developer3d5faf22022-11-29 18:07:22 +080011 mt7915/mmio.c | 5 +++--
12 4 files changed, 13 insertions(+), 8 deletions(-)
developer3262bf82022-07-12 11:37:54 +080013
14diff --git a/mt76_connac.h b/mt76_connac.h
developer2aa1e642022-12-19 11:33:22 +080015index 8ba883b..f70987d 100644
developer3262bf82022-07-12 11:37:54 +080016--- a/mt76_connac.h
17+++ b/mt76_connac.h
developer4df64ba2022-09-01 14:44:55 +080018@@ -116,6 +116,7 @@ struct mt76_connac_sta_key_conf {
developer3262bf82022-07-12 11:37:54 +080019 };
20
21 #define MT_TXP_MAX_BUF_NUM 6
22+#define MT_TXD_TXP_BUF_SIZE 128
23
24 struct mt76_connac_fw_txp {
25 __le16 flags;
developer3262bf82022-07-12 11:37:54 +080026diff --git a/mt7915/mac.c b/mt7915/mac.c
developer2aa1e642022-12-19 11:33:22 +080027index a0df785..0984357 100644
developer3262bf82022-07-12 11:37:54 +080028--- a/mt7915/mac.c
29+++ b/mt7915/mac.c
developer2aa1e642022-12-19 11:33:22 +080030@@ -891,9 +891,9 @@ u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id)
developer3262bf82022-07-12 11:37:54 +080031
32 txp->token = cpu_to_le16(token_id);
33 txp->nbuf = 1;
34- txp->buf[0] = cpu_to_le32(phys + MT_TXD_SIZE + sizeof(*txp));
35+ txp->buf[0] = cpu_to_le32(phys + MT_TXD_TXP_BUF_SIZE);
36
37- return MT_TXD_SIZE + sizeof(*txp);
38+ return MT_TXD_TXP_BUF_SIZE;
39 }
40
41 static void
developer2aa1e642022-12-19 11:33:22 +080042@@ -1009,6 +1009,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
developer36936c32022-09-30 12:55:06 +080043 LIST_HEAD(free_list);
44 void *end = data + len;
45 bool v3, wake = false;
46+ bool with_txwi = true;
47 u16 total, count = 0;
48 u32 txd = le32_to_cpu(free->txd);
49 __le32 *cur_info;
developer2aa1e642022-12-19 11:33:22 +080050@@ -1064,12 +1065,14 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
developer36936c32022-09-30 12:55:06 +080051 txwi = mt76_token_release(mdev, msdu, &wake);
52 if (!txwi)
53 continue;
54+ else
55+ with_txwi = false;
developerf1313102022-10-11 11:02:55 +080056
developer36936c32022-09-30 12:55:06 +080057 mt7915_txwi_free(dev, txwi, sta, &free_list);
58 }
59 }
60-
61- mt7915_mac_tx_free_done(dev, &free_list, wake);
62+ if (!with_txwi)
63+ mt7915_mac_tx_free_done(dev, &free_list, wake);
64 }
developerf1313102022-10-11 11:02:55 +080065
developer36936c32022-09-30 12:55:06 +080066 static void
developer3262bf82022-07-12 11:37:54 +080067diff --git a/mt7915/main.c b/mt7915/main.c
developer2aa1e642022-12-19 11:33:22 +080068index 09cf35c..2dd78ca 100644
developer3262bf82022-07-12 11:37:54 +080069--- a/mt7915/main.c
70+++ b/mt7915/main.c
developer2aa1e642022-12-19 11:33:22 +080071@@ -1533,14 +1533,14 @@ mt7915_net_fill_forward_path(struct ieee80211_hw *hw,
developer3262bf82022-07-12 11:37:54 +080072 if (!mtk_wed_device_active(wed))
73 return -ENODEV;
74
75- if (msta->wcid.idx > 0xff)
76+ if (msta->wcid.idx > MT7915_WTBL_STA)
77 return -EIO;
78
79 path->type = DEV_PATH_MTK_WDMA;
80 path->dev = ctx->dev;
81 path->mtk_wdma.wdma_idx = wed->wdma_idx;
82 path->mtk_wdma.bss = mvif->mt76.idx;
developerf1313102022-10-11 11:02:55 +080083- path->mtk_wdma.wcid = is_mt7915(&dev->mt76) ? msta->wcid.idx : 0x3ff;
84+ path->mtk_wdma.wcid = is_mt7915(&dev->mt76) ? 0xff : 0x3ff;
developer3262bf82022-07-12 11:37:54 +080085 path->mtk_wdma.queue = phy != &dev->phy;
86
87 ctx->dev = NULL;
developer3262bf82022-07-12 11:37:54 +080088diff --git a/mt7915/mmio.c b/mt7915/mmio.c
developer2aa1e642022-12-19 11:33:22 +080089index c1b421d..04411e7 100644
developer3262bf82022-07-12 11:37:54 +080090--- a/mt7915/mmio.c
91+++ b/mt7915/mmio.c
developer3d5faf22022-11-29 18:07:22 +080092@@ -11,7 +11,7 @@
developer3262bf82022-07-12 11:37:54 +080093 #include "../trace.h"
developer3d5faf22022-11-29 18:07:22 +080094 #include "../dma.h"
developer3262bf82022-07-12 11:37:54 +080095
developerf1313102022-10-11 11:02:55 +080096-static bool wed_enable;
developer3262bf82022-07-12 11:37:54 +080097+static bool wed_enable = true;
developerf1313102022-10-11 11:02:55 +080098 module_param(wed_enable, bool, 0644);
developer3d5faf22022-11-29 18:07:22 +080099 MODULE_PARM_DESC(wed_enable, "Enable Wireless Ethernet Dispatch support");
developer3262bf82022-07-12 11:37:54 +0800100
developer2aa1e642022-12-19 11:33:22 +0800101@@ -582,7 +582,7 @@ static void mt7915_mmio_wed_offload_disable(struct mtk_wed_device *wed)
developercaeb1a02022-10-12 18:25:15 +0800102 dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
103
104 spin_lock_bh(&dev->mt76.token_lock);
105- dev->mt76.token_size = MT7915_TOKEN_SIZE;
106+ dev->mt76.token_size = wed->wlan.token_start;//MT7915_TOKEN_SIZE
107 spin_unlock_bh(&dev->mt76.token_lock);
108
109 /* MT_TXD5_TX_STATUS_HOST (MPDU format) has higher priority than
developer2aa1e642022-12-19 11:33:22 +0800110@@ -792,6 +792,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
developer3262bf82022-07-12 11:37:54 +0800111
developerf1313102022-10-11 11:02:55 +0800112 *irq = wed->irq;
113 dev->mt76.dma_dev = wed->dev;
114+ dev->mt76.token_size = wed->wlan.token_start;
developer3262bf82022-07-12 11:37:54 +0800115
developerf1313102022-10-11 11:02:55 +0800116 ret = dma_set_mask(wed->dev, DMA_BIT_MASK(32));
developer3262bf82022-07-12 11:37:54 +0800117 if (ret)
developer3262bf82022-07-12 11:37:54 +0800118--
developer2aa1e642022-12-19 11:33:22 +08001192.36.1
developer3262bf82022-07-12 11:37:54 +0800120