developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 1 | From 76d6af5ef0539cfa09fadf9e7dd60c015428d12d Mon Sep 17 00:00:00 2001 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 2 | From: Sujuan Chen <sujuan.chen@mediatek.com> |
| 3 | Date: Sun, 12 Jun 2022 16:38:45 +0800 |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 4 | Subject: [PATCH] mt76 add wed tx support |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com> |
| 7 | --- |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 8 | mt76_connac.h | 1 + |
| 9 | mt7915/mac.c | 11 +++++++---- |
| 10 | mt7915/main.c | 4 ++-- |
| 11 | mt7915/mmio.c | 10 +++++++++- |
| 12 | 4 files changed, 19 insertions(+), 7 deletions(-) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 13 | |
| 14 | diff --git a/mt76_connac.h b/mt76_connac.h |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 15 | index 0915eb57..9a468878 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 16 | --- a/mt76_connac.h |
| 17 | +++ b/mt76_connac.h |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 18 | @@ -116,6 +116,7 @@ struct mt76_connac_sta_key_conf { |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 19 | }; |
| 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; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 26 | diff --git a/mt7915/mac.c b/mt7915/mac.c |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 27 | index 961b7afc..65e47f95 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 28 | --- a/mt7915/mac.c |
| 29 | +++ b/mt7915/mac.c |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 30 | @@ -826,9 +826,9 @@ u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 31 | |
| 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 |
developer | 36936c3 | 2022-09-30 12:55:06 +0800 | [diff] [blame] | 42 | @@ -944,6 +944,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) |
| 43 | 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; |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 50 | @@ -999,12 +1000,14 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) |
developer | 36936c3 | 2022-09-30 12:55:06 +0800 | [diff] [blame] | 51 | txwi = mt76_token_release(mdev, msdu, &wake); |
| 52 | if (!txwi) |
| 53 | continue; |
| 54 | + else |
| 55 | + with_txwi = false; |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 56 | |
developer | 36936c3 | 2022-09-30 12:55:06 +0800 | [diff] [blame] | 57 | 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 | } |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 65 | |
developer | 36936c3 | 2022-09-30 12:55:06 +0800 | [diff] [blame] | 66 | static void |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 67 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 68 | index 80f4d9dd..4e915279 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 69 | --- a/mt7915/main.c |
| 70 | +++ b/mt7915/main.c |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 71 | @@ -1457,14 +1457,14 @@ mt7915_net_fill_forward_path(struct ieee80211_hw *hw, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 72 | 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; |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 83 | - path->mtk_wdma.wcid = is_mt7915(&dev->mt76) ? msta->wcid.idx : 0x3ff; |
| 84 | + path->mtk_wdma.wcid = is_mt7915(&dev->mt76) ? 0xff : 0x3ff; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 85 | path->mtk_wdma.queue = phy != &dev->phy; |
| 86 | |
| 87 | ctx->dev = NULL; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 88 | diff --git a/mt7915/mmio.c b/mt7915/mmio.c |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 89 | index 1eda361f..0b37f1b3 100644 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 90 | --- a/mt7915/mmio.c |
| 91 | +++ b/mt7915/mmio.c |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 92 | @@ -10,7 +10,7 @@ |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 93 | #include "mac.h" |
| 94 | #include "../trace.h" |
| 95 | |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 96 | -static bool wed_enable; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 97 | +static bool wed_enable = true; |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 98 | module_param(wed_enable, bool, 0644); |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 99 | |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 100 | static const u32 mt7915_reg[] = { |
| 101 | @@ -556,6 +556,9 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 102 | |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 103 | wed->wlan.pci_dev = pci_dev; |
| 104 | wed->wlan.bus_type = MTK_WED_BUS_PCIE; |
| 105 | + wed->wlan.base = (void __iomem *)ioremap( |
| 106 | + pci_resource_start(pci_dev, 0), |
| 107 | + pci_resource_len(pci_dev, 0)); |
| 108 | wed->wlan.wpdma_int = pci_resource_start(pci_dev, 0) + |
| 109 | MT_INT_WED_SOURCE_CSR; |
| 110 | wed->wlan.wpdma_mask = pci_resource_start(pci_dev, 0) + |
| 111 | @@ -566,6 +569,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
| 112 | MT_TXQ_WED_RING_BASE; |
| 113 | wed->wlan.wpdma_txfree = pci_resource_start(pci_dev, 0) + |
| 114 | MT_RXQ_WED_RING_BASE; |
| 115 | + wed->wlan.phy_base = pci_resource_start(pci_dev, 0); |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 116 | } else { |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 117 | struct platform_device *plat_dev = pdev_ptr; |
| 118 | struct resource *res; |
| 119 | @@ -576,10 +580,13 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 120 | |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 121 | wed->wlan.platform_dev = plat_dev; |
| 122 | wed->wlan.bus_type = MTK_WED_BUS_AXI; |
| 123 | + wed->wlan.base = (void __iomem *)ioremap(res->start, |
| 124 | + resource_size(res)); |
| 125 | wed->wlan.wpdma_int = res->start + MT_INT_SOURCE_CSR; |
| 126 | wed->wlan.wpdma_mask = res->start + MT_INT_MASK_CSR; |
| 127 | wed->wlan.wpdma_tx = res->start + MT_TXQ_WED_RING_BASE; |
| 128 | wed->wlan.wpdma_txfree = res->start + MT_RXQ_WED_RING_BASE; |
| 129 | + wed->wlan.phy_base = res->start; |
| 130 | } |
| 131 | wed->wlan.nbuf = 4096; |
| 132 | wed->wlan.tx_tbit[0] = is_mt7915(&dev->mt76) ? 4 : 30; |
| 133 | @@ -595,6 +602,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 134 | |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 135 | *irq = wed->irq; |
| 136 | dev->mt76.dma_dev = wed->dev; |
| 137 | + dev->mt76.token_size = wed->wlan.token_start; |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 138 | |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 139 | ret = dma_set_mask(wed->dev, DMA_BIT_MASK(32)); |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 140 | if (ret) |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 141 | -- |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 142 | 2.18.0 |
developer | 3262bf8 | 2022-07-12 11:37:54 +0800 | [diff] [blame] | 143 | |