blob: 1d5e56748fa67c0c7358b15e117cf5a55483ac69 [file] [log] [blame]
developera20cdc22024-05-31 18:57:31 +08001From 3af8d78c5f9622276367d9e71921fe25f9d211b5 Mon Sep 17 00:00:00 2001
developerf79ad452022-07-12 11:37:54 +08002From: Sujuan Chen <sujuan.chen@mediatek.com>
developer3609d782022-11-29 18:07:22 +08003Date: Fri, 25 Nov 2022 10:38:53 +0800
developera20cdc22024-05-31 18:57:31 +08004Subject: [PATCH 2000/2015] wifi: mt76: mt7915: wed: add wed tx support
developerf79ad452022-07-12 11:37:54 +08005
6Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
7---
developer7a520b52023-03-14 14:09:34 +08008 mt76_connac.h | 1 +
developer47efbdb2023-06-29 20:33:22 +08009 mt7915/mac.c | 10 +++++++---
developer7a520b52023-03-14 14:09:34 +080010 mt7915/main.c | 4 ++--
developer1a173672023-12-21 14:49:33 +080011 mt7915/mmio.c | 3 ++-
developer7a520b52023-03-14 14:09:34 +080012 mt7915/mt7915.h | 2 +-
developer753619c2024-02-22 13:42:45 +080013 wed.c | 2 +-
developer1a173672023-12-21 14:49:33 +080014 6 files changed, 14 insertions(+), 8 deletions(-)
developerf79ad452022-07-12 11:37:54 +080015
16diff --git a/mt76_connac.h b/mt76_connac.h
developerdc9eeae2024-04-08 14:36:46 +080017index 8e7068c..e1d6ca2 100644
developerf79ad452022-07-12 11:37:54 +080018--- a/mt76_connac.h
19+++ b/mt76_connac.h
developer7af0f762023-05-22 15:16:16 +080020@@ -130,6 +130,7 @@ struct mt76_connac_sta_key_conf {
developerf79ad452022-07-12 11:37:54 +080021 };
22
23 #define MT_TXP_MAX_BUF_NUM 6
24+#define MT_TXD_TXP_BUF_SIZE 128
25
26 struct mt76_connac_fw_txp {
27 __le16 flags;
developerf79ad452022-07-12 11:37:54 +080028diff --git a/mt7915/mac.c b/mt7915/mac.c
developerdc9eeae2024-04-08 14:36:46 +080029index c84b957..1c8b873 100644
developerf79ad452022-07-12 11:37:54 +080030--- a/mt7915/mac.c
31+++ b/mt7915/mac.c
developera46f6132024-03-26 14:09:54 +080032@@ -878,9 +878,9 @@ u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id)
developerf79ad452022-07-12 11:37:54 +080033
34 txp->token = cpu_to_le16(token_id);
35 txp->nbuf = 1;
36- txp->buf[0] = cpu_to_le32(phys + MT_TXD_SIZE + sizeof(*txp));
37+ txp->buf[0] = cpu_to_le32(phys + MT_TXD_TXP_BUF_SIZE);
38
39- return MT_TXD_SIZE + sizeof(*txp);
40+ return MT_TXD_TXP_BUF_SIZE;
41 }
42
43 static void
developera46f6132024-03-26 14:09:54 +080044@@ -929,6 +929,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
developer61c4ae82022-09-30 12:55:06 +080045 LIST_HEAD(free_list);
46 void *end = data + len;
47 bool v3, wake = false;
48+ bool with_txwi = true;
49 u16 total, count = 0;
50 u32 txd = le32_to_cpu(free->txd);
51 __le32 *cur_info;
developera46f6132024-03-26 14:09:54 +080052@@ -1010,12 +1011,15 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
developer61c4ae82022-09-30 12:55:06 +080053 txwi = mt76_token_release(mdev, msdu, &wake);
54 if (!txwi)
55 continue;
56+ else
57+ with_txwi = false;
developerec567112022-10-11 11:02:55 +080058
developera46f6132024-03-26 14:09:54 +080059 mt76_connac2_txwi_free(mdev, txwi, sta, &free_list);
developer61c4ae82022-09-30 12:55:06 +080060 }
61 }
developer47efbdb2023-06-29 20:33:22 +080062
developer61c4ae82022-09-30 12:55:06 +080063- mt7915_mac_tx_free_done(dev, &free_list, wake);
64+ if (!with_txwi)
65+ mt7915_mac_tx_free_done(dev, &free_list, wake);
66 }
developerec567112022-10-11 11:02:55 +080067
developer61c4ae82022-09-30 12:55:06 +080068 static void
developerf79ad452022-07-12 11:37:54 +080069diff --git a/mt7915/main.c b/mt7915/main.c
developera20cdc22024-05-31 18:57:31 +080070index c97974a..ed7ade1 100644
developerf79ad452022-07-12 11:37:54 +080071--- a/mt7915/main.c
72+++ b/mt7915/main.c
developera20cdc22024-05-31 18:57:31 +080073@@ -1761,14 +1761,14 @@ mt7915_net_fill_forward_path(struct ieee80211_hw *hw,
developerf79ad452022-07-12 11:37:54 +080074 if (!mtk_wed_device_active(wed))
75 return -ENODEV;
76
77- if (msta->wcid.idx > 0xff)
78+ if (msta->wcid.idx > MT7915_WTBL_STA)
79 return -EIO;
80
81 path->type = DEV_PATH_MTK_WDMA;
82 path->dev = ctx->dev;
83 path->mtk_wdma.wdma_idx = wed->wdma_idx;
84 path->mtk_wdma.bss = mvif->mt76.idx;
developerec567112022-10-11 11:02:55 +080085- path->mtk_wdma.wcid = is_mt7915(&dev->mt76) ? msta->wcid.idx : 0x3ff;
86+ path->mtk_wdma.wcid = is_mt7915(&dev->mt76) ? 0xff : 0x3ff;
developerf79ad452022-07-12 11:37:54 +080087 path->mtk_wdma.queue = phy != &dev->phy;
88
89 ctx->dev = NULL;
developerf79ad452022-07-12 11:37:54 +080090diff --git a/mt7915/mmio.c b/mt7915/mmio.c
developerdc9eeae2024-04-08 14:36:46 +080091index 437a9b0..91100f1 100644
developerf79ad452022-07-12 11:37:54 +080092--- a/mt7915/mmio.c
93+++ b/mt7915/mmio.c
developer60a3d662023-02-07 15:24:34 +080094@@ -13,7 +13,7 @@
developerf79ad452022-07-12 11:37:54 +080095 #include "../trace.h"
developer3609d782022-11-29 18:07:22 +080096 #include "../dma.h"
developerf79ad452022-07-12 11:37:54 +080097
developerec567112022-10-11 11:02:55 +080098-static bool wed_enable;
developerf79ad452022-07-12 11:37:54 +080099+static bool wed_enable = true;
developerec567112022-10-11 11:02:55 +0800100 module_param(wed_enable, bool, 0644);
developer3609d782022-11-29 18:07:22 +0800101 MODULE_PARM_DESC(wed_enable, "Enable Wireless Ethernet Dispatch support");
developerf79ad452022-07-12 11:37:54 +0800102
developer753619c2024-02-22 13:42:45 +0800103@@ -732,6 +732,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
developerf79ad452022-07-12 11:37:54 +0800104
developerec567112022-10-11 11:02:55 +0800105 *irq = wed->irq;
106 dev->mt76.dma_dev = wed->dev;
107+ dev->mt76.token_size = wed->wlan.token_start;
developerf79ad452022-07-12 11:37:54 +0800108
developerec567112022-10-11 11:02:55 +0800109 ret = dma_set_mask(wed->dev, DMA_BIT_MASK(32));
developerf79ad452022-07-12 11:37:54 +0800110 if (ret)
developer7a520b52023-03-14 14:09:34 +0800111diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developera20cdc22024-05-31 18:57:31 +0800112index a6901dd..2dce288 100644
developer7a520b52023-03-14 14:09:34 +0800113--- a/mt7915/mt7915.h
114+++ b/mt7915/mt7915.h
developer7af0f762023-05-22 15:16:16 +0800115@@ -62,7 +62,7 @@
developer7a520b52023-03-14 14:09:34 +0800116 #define MT7916_EEPROM_SIZE 4096
117
118 #define MT7915_EEPROM_BLOCK_SIZE 16
119-#define MT7915_HW_TOKEN_SIZE 4096
120+#define MT7915_HW_TOKEN_SIZE 7168
121 #define MT7915_TOKEN_SIZE 8192
122
123 #define MT7915_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */
developer753619c2024-02-22 13:42:45 +0800124diff --git a/wed.c b/wed.c
developerdc9eeae2024-04-08 14:36:46 +0800125index f7a3f1b..47c81a2 100644
developer753619c2024-02-22 13:42:45 +0800126--- a/wed.c
127+++ b/wed.c
128@@ -187,7 +187,7 @@ void mt76_wed_offload_disable(struct mtk_wed_device *wed)
129 struct mt76_dev *dev = container_of(wed, struct mt76_dev, mmio.wed);
130
131 spin_lock_bh(&dev->token_lock);
132- dev->token_size = dev->drv->token_size;
133+ dev->token_size = wed->wlan.token_start;
134 spin_unlock_bh(&dev->token_lock);
135 }
136 EXPORT_SYMBOL_GPL(mt76_wed_offload_disable);
developerf79ad452022-07-12 11:37:54 +0800137--
developerbddc9db2023-09-11 13:34:36 +08001382.18.0
developerf79ad452022-07-12 11:37:54 +0800139