blob: 671d7342eccb2e3200dbe65dc0a244b1d7b7f82e [file] [log] [blame]
From 68d3bbf7120da35068e5983d89cae5ee470e55f4 Mon Sep 17 00:00:00 2001
From: mtk27745 <rex.lu@mediatek.com>
Date: Fri, 6 Oct 2023 20:59:42 +0800
Subject: [PATCH 2013/2020] mtk: wifi: mt76: mt7996: support backaward
compatiable
revert upstream wed trigger mode to polling mode
Signed-off-by: mtk27745 <rex.lu@mediatek.com>
[Description]
Change the SW token size from 1024 to 15360 according to HW capability.
[Release-log]
N/A
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
---
mmio.c | 2 +-
mt7996/dma.c | 2 +-
mt7996/mac.c | 2 +-
mt7996/main.c | 6 +++---
mt7996/mcu.c | 2 +-
mt7996/mmio.c | 20 +++++++++++---------
mt7996/mt7996.h | 1 +
mt7996/pci.c | 17 +++++++++--------
8 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/mmio.c b/mmio.c
index 269fd932..117da4d1 100644
--- a/mmio.c
+++ b/mmio.c
@@ -134,7 +134,7 @@ EXPORT_SYMBOL_GPL(mt76_mmio_wed_release_rx_buf);
u32 mt76_mmio_wed_init_rx_buf(struct mtk_wed_device *wed, int size)
{
struct mt76_dev *dev = container_of(wed, struct mt76_dev, mmio.wed);
- struct mtk_wed_bm_desc *desc = wed->rx_buf_ring.desc;
+ struct mtk_rxbm_desc *desc = wed->rx_buf_ring.desc;
u32 length;
int i;
diff --git a/mt7996/dma.c b/mt7996/dma.c
index 8df119d0..773bab71 100644
--- a/mt7996/dma.c
+++ b/mt7996/dma.c
@@ -431,7 +431,7 @@ int mt7996_dma_rro_init(struct mt7996_dev *dev)
irq_mask = mdev->mmio.irqmask | MT_INT_RRO_RX_DONE |
MT_INT_TX_DONE_BAND2;
mt76_wr(dev, MT_INT_MASK_CSR, irq_mask);
- mtk_wed_device_start_hw_rro(&mdev->mmio.wed, irq_mask, false);
+ mtk_wed_device_start_hwrro(&mdev->mmio.wed, irq_mask, false);
mt7996_irq_enable(dev, irq_mask);
return 0;
diff --git a/mt7996/mac.c b/mt7996/mac.c
index 19e66256..8171a43d 100644
--- a/mt7996/mac.c
+++ b/mt7996/mac.c
@@ -1998,7 +1998,7 @@ void mt7996_mac_reset_work(struct work_struct *work)
mt76_wr(dev, MT_INT_MASK_CSR, wed_irq_mask);
- mtk_wed_device_start_hw_rro(&dev->mt76.mmio.wed, wed_irq_mask,
+ mtk_wed_device_start_hwrro(&dev->mt76.mmio.wed, wed_irq_mask,
true);
mt7996_irq_enable(dev, wed_irq_mask);
mt7996_irq_disable(dev, 0);
diff --git a/mt7996/main.c b/mt7996/main.c
index 939b0943..45461949 100644
--- a/mt7996/main.c
+++ b/mt7996/main.c
@@ -1593,10 +1593,10 @@ mt7996_net_fill_forward_path(struct ieee80211_hw *hw,
path->mtk_wdma.wcid = msta->wcid.idx;
if (ieee80211_hw_check(hw, SUPPORTS_AMSDU_IN_AMPDU) &&
- mtk_wed_is_amsdu_supported(wed))
- path->mtk_wdma.amsdu = msta->wcid.amsdu;
+ mtk_wed_device_support_pao(wed))
+ path->mtk_wdma.amsdu_en = msta->wcid.amsdu;
else
- path->mtk_wdma.amsdu = 0;
+ path->mtk_wdma.amsdu_en = 0;
ctx->dev = NULL;
diff --git a/mt7996/mcu.c b/mt7996/mcu.c
index 45a44cd8..57af55ec 100644
--- a/mt7996/mcu.c
+++ b/mt7996/mcu.c
@@ -3247,7 +3247,7 @@ static int mt7996_mcu_wa_red_config(struct mt7996_dev *dev)
if (!mtk_wed_device_active(&dev->mt76.mmio.wed))
req.token_per_src[RED_TOKEN_SRC_CNT - 1] =
- cpu_to_le16(MT7996_TOKEN_SIZE - MT7996_HW_TOKEN_SIZE);
+ cpu_to_le16(MT7996_SW_TOKEN_SIZE);
return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET),
&req, sizeof(req), false);
diff --git a/mt7996/mmio.c b/mt7996/mmio.c
index 488f5103..69d16dad 100644
--- a/mt7996/mmio.c
+++ b/mt7996/mmio.c
@@ -14,7 +14,7 @@
#include "../trace.h"
#include "../dma.h"
-static bool wed_enable;
+static bool wed_enable = true;
module_param(wed_enable, bool, 0644);
static const struct __base mt7996_reg_base[] = {
@@ -352,14 +352,14 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr,
}
wed->wlan.wpdma_rx_glo = wed->wlan.phy_base + hif1_ofs + MT_WFDMA0_GLO_CFG;
- wed->wlan.wpdma_rx = wed->wlan.phy_base + hif1_ofs +
+ wed->wlan.wpdma_rx[0] = wed->wlan.phy_base + hif1_ofs +
MT_RXQ_RING_BASE(MT7996_RXQ_BAND0) +
MT7996_RXQ_BAND0 * MT_RING_SIZE;
- wed->wlan.id = 0x7991;
+ wed->wlan.chip_id = 0x7991;
wed->wlan.tx_tbit[0] = ffs(MT_INT_TX_DONE_BAND2) - 1;
} else {
- wed->wlan.hw_rro = dev->has_rro; /* default on */
+ wed->wlan.hwrro = dev->has_rro; /* default on */
wed->wlan.wpdma_int = wed->wlan.phy_base + MT_INT_SOURCE_CSR;
wed->wlan.wpdma_mask = wed->wlan.phy_base + MT_INT_MASK_CSR;
wed->wlan.wpdma_tx = wed->wlan.phy_base + MT_TXQ_RING_BASE(0) +
@@ -367,7 +367,7 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr,
wed->wlan.wpdma_rx_glo = wed->wlan.phy_base + MT_WFDMA0_GLO_CFG;
- wed->wlan.wpdma_rx = wed->wlan.phy_base +
+ wed->wlan.wpdma_rx[0] = wed->wlan.phy_base +
MT_RXQ_RING_BASE(MT7996_RXQ_BAND0) +
MT7996_RXQ_BAND0 * MT_RING_SIZE;
@@ -409,11 +409,11 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr,
dev->mt76.rx_token_size = MT7996_TOKEN_SIZE + wed->wlan.rx_npkt;
}
- wed->wlan.nbuf = MT7996_HW_TOKEN_SIZE;
- wed->wlan.token_start = MT7996_TOKEN_SIZE - wed->wlan.nbuf;
+ wed->wlan.nbuf = MT7996_TOKEN_SIZE;
+ wed->wlan.token_start = 0;
- wed->wlan.amsdu_max_subframes = 8;
- wed->wlan.amsdu_max_len = 1536;
+ wed->wlan.max_amsdu_nums = 8;
+ wed->wlan.max_amsdu_len = 1536;
wed->wlan.init_buf = mt7996_wed_init_buf;
wed->wlan.init_rx_buf = mt76_mmio_wed_init_rx_buf;
@@ -431,6 +431,8 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr,
*irq = wed->irq;
dev->mt76.dma_dev = wed->dev;
+ dev->mt76.token_size = MT7996_SW_TOKEN_SIZE;
+
return 1;
#else
return 0;
diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
index 7a1cae71..056d07fe 100644
--- a/mt7996/mt7996.h
+++ b/mt7996/mt7996.h
@@ -74,6 +74,7 @@
#define MT7996_EEPROM_BLOCK_SIZE 16
#define MT7996_TOKEN_SIZE 16384
#define MT7996_HW_TOKEN_SIZE 8192
+#define MT7996_SW_TOKEN_SIZE 15360
#define MT7996_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */
#define MT7996_CFEND_RATE_11B 0x03 /* 11B LP, 11M */
diff --git a/mt7996/pci.c b/mt7996/pci.c
index 05830c01..4e957771 100644
--- a/mt7996/pci.c
+++ b/mt7996/pci.c
@@ -171,7 +171,7 @@ static int mt7996_pci_probe(struct pci_dev *pdev,
ret = mt7996_mmio_wed_init(dev, hif2_dev, true, &hif2_irq);
if (ret < 0)
- goto free_hif2_wed_irq_vector;
+ goto free_wed_or_irq_vector;
if (!ret) {
ret = pci_alloc_irq_vectors(hif2_dev, 1, 1,
@@ -180,14 +180,15 @@ static int mt7996_pci_probe(struct pci_dev *pdev,
goto free_hif2;
dev->hif2->irq = hif2_dev->irq;
- hif2_irq = dev->hif2->irq;
+ } else {
+ dev->hif2->irq = irq;
}
- ret = devm_request_irq(mdev->dev, hif2_irq, mt7996_irq_handler,
- IRQF_SHARED, KBUILD_MODNAME "-hif",
- dev);
+ ret = devm_request_irq(mdev->dev, dev->hif2->irq,
+ mt7996_irq_handler, IRQF_SHARED,
+ KBUILD_MODNAME "-hif", dev);
if (ret)
- goto free_hif2_wed_irq_vector;
+ goto free_hif2_irq_vector;
mt76_wr(dev, MT_INT1_MASK_CSR, 0);
/* master switch of PCIe tnterrupt enable */
@@ -202,8 +203,8 @@ static int mt7996_pci_probe(struct pci_dev *pdev,
free_hif2_irq:
if (dev->hif2)
- devm_free_irq(mdev->dev, hif2_irq, dev);
-free_hif2_wed_irq_vector:
+ devm_free_irq(mdev->dev, dev->hif2->irq, dev);
+free_hif2_irq_vector:
if (dev->hif2) {
if (mtk_wed_device_active(&dev->mt76.mmio.wed_hif2))
mtk_wed_device_detach(&dev->mt76.mmio.wed_hif2);
--
2.18.0