developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame^] | 1 | From e1ddb78f4185559bc6f9be1d1b302f9f52899f94 Mon Sep 17 00:00:00 2001 |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Tue, 13 Jun 2023 09:04:43 +0800 |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 10/98] wifi: mt76: mt7996: adjust wfdma setting to enhance |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 5 | throughput |
| 6 | |
| 7 | 1. Set band 1 traffic to pcie1. |
| 8 | 2. Refactor dma prefetch and enlarge txd prefetch size. |
| 9 | 3. Update pdma setting. |
| 10 | |
| 11 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 12 | --- |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame^] | 13 | mt7996/dma.c | 70 +++++++++++++++++++++++++++++++++++---------------- |
| 14 | mt7996/regs.h | 9 +++++++ |
| 15 | 2 files changed, 58 insertions(+), 21 deletions(-) |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 16 | |
| 17 | diff --git a/mt7996/dma.c b/mt7996/dma.c |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame^] | 18 | index 3d04470..1ed91da 100644 |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 19 | --- a/mt7996/dma.c |
| 20 | +++ b/mt7996/dma.c |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame^] | 21 | @@ -99,38 +99,49 @@ static void mt7996_dma_config(struct mt7996_dev *dev) |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 22 | MCUQ_CONFIG(MT_MCUQ_FWDL, WFDMA0, MT_INT_TX_DONE_FWDL, MT7996_TXQ_FWDL); |
| 23 | } |
| 24 | |
| 25 | +static u32 __mt7996_dma_prefetch_base(u16 *base, u8 depth) |
| 26 | +{ |
| 27 | + u32 ret = *base << 16 | depth; |
| 28 | + |
| 29 | + *base = *base + (depth << 4); |
| 30 | + |
| 31 | + return ret; |
| 32 | +} |
| 33 | + |
| 34 | static void __mt7996_dma_prefetch(struct mt7996_dev *dev, u32 ofs) |
| 35 | { |
| 36 | -#define PREFETCH(_base, _depth) ((_base) << 16 | (_depth)) |
| 37 | + u16 base = 0; |
| 38 | + |
| 39 | +#define PREFETCH(_depth) (__mt7996_dma_prefetch_base(&base, (_depth))) |
| 40 | /* prefetch SRAM wrapping boundary for tx/rx ring. */ |
| 41 | - mt76_wr(dev, MT_MCUQ_EXT_CTRL(MT_MCUQ_FWDL) + ofs, PREFETCH(0x0, 0x2)); |
| 42 | - mt76_wr(dev, MT_MCUQ_EXT_CTRL(MT_MCUQ_WM) + ofs, PREFETCH(0x20, 0x2)); |
| 43 | - mt76_wr(dev, MT_TXQ_EXT_CTRL(0) + ofs, PREFETCH(0x40, 0x4)); |
| 44 | - mt76_wr(dev, MT_TXQ_EXT_CTRL(1) + ofs, PREFETCH(0x80, 0x4)); |
| 45 | - mt76_wr(dev, MT_MCUQ_EXT_CTRL(MT_MCUQ_WA) + ofs, PREFETCH(0xc0, 0x2)); |
| 46 | - mt76_wr(dev, MT_TXQ_EXT_CTRL(2) + ofs, PREFETCH(0xe0, 0x4)); |
| 47 | - mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_MCU) + ofs, PREFETCH(0x120, 0x2)); |
| 48 | - mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_MCU_WA) + ofs, PREFETCH(0x140, 0x2)); |
| 49 | - mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_MAIN_WA) + ofs, PREFETCH(0x160, 0x2)); |
| 50 | - mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_BAND2_WA) + ofs, PREFETCH(0x180, 0x2)); |
| 51 | - mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_MAIN) + ofs, PREFETCH(0x1a0, 0x10)); |
| 52 | - mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_BAND2) + ofs, PREFETCH(0x2a0, 0x10)); |
| 53 | + mt76_wr(dev, MT_MCUQ_EXT_CTRL(MT_MCUQ_FWDL) + ofs, PREFETCH(0x2)); |
| 54 | + mt76_wr(dev, MT_MCUQ_EXT_CTRL(MT_MCUQ_WM) + ofs, PREFETCH(0x2)); |
| 55 | + mt76_wr(dev, MT_TXQ_EXT_CTRL(0) + ofs, PREFETCH(0x8)); |
| 56 | + mt76_wr(dev, MT_TXQ_EXT_CTRL(1) + ofs, PREFETCH(0x8)); |
| 57 | + mt76_wr(dev, MT_MCUQ_EXT_CTRL(MT_MCUQ_WA) + ofs, PREFETCH(0x2)); |
| 58 | + mt76_wr(dev, MT_TXQ_EXT_CTRL(2) + ofs, PREFETCH(0x8)); |
| 59 | + mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_MCU) + ofs, PREFETCH(0x2)); |
| 60 | + mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_MCU_WA) + ofs, PREFETCH(0x2)); |
| 61 | + mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_MAIN_WA) + ofs, PREFETCH(0x2)); |
| 62 | + mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_BAND2_WA) + ofs, PREFETCH(0x2)); |
| 63 | + mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_MAIN) + ofs, PREFETCH(0x10)); |
| 64 | + mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_BAND2) + ofs, PREFETCH(0x10)); |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 65 | |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame^] | 66 | if (dev->has_rro) { |
| 67 | mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_RRO_BAND0) + ofs, |
| 68 | - PREFETCH(0x3a0, 0x10)); |
| 69 | + PREFETCH(0x10)); |
| 70 | mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_RRO_BAND2) + ofs, |
| 71 | - PREFETCH(0x4a0, 0x10)); |
| 72 | + PREFETCH(0x10)); |
| 73 | mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_MSDU_PAGE_BAND0) + ofs, |
| 74 | - PREFETCH(0x5a0, 0x4)); |
| 75 | + PREFETCH(0x4)); |
| 76 | mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_MSDU_PAGE_BAND1) + ofs, |
| 77 | - PREFETCH(0x5e0, 0x4)); |
| 78 | + PREFETCH(0x4)); |
| 79 | mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_MSDU_PAGE_BAND2) + ofs, |
| 80 | - PREFETCH(0x620, 0x4)); |
| 81 | + PREFETCH(0x4)); |
| 82 | mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_TXFREE_BAND0) + ofs, |
| 83 | - PREFETCH(0x660, 0x4)); |
| 84 | + PREFETCH(0x4)); |
| 85 | mt76_wr(dev, MT_RXQ_BAND1_CTRL(MT_RXQ_TXFREE_BAND2) + ofs, |
| 86 | - PREFETCH(0x6a0, 0x4)); |
| 87 | + PREFETCH(0x4)); |
| 88 | } |
| 89 | #undef PREFETCH |
| 90 | |
| 91 | @@ -295,6 +306,12 @@ static void mt7996_dma_enable(struct mt7996_dev *dev, bool reset) |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 92 | mt76_set(dev, WF_WFDMA0_GLO_CFG_EXT1, |
| 93 | WF_WFDMA0_GLO_CFG_EXT1_TX_FCTRL_MODE); |
| 94 | |
| 95 | + /* WFDMA rx threshold */ |
| 96 | + mt76_wr(dev, MT_WFDMA0_PAUSE_RX_Q_45_TH, 0xc000c); |
| 97 | + mt76_wr(dev, MT_WFDMA0_PAUSE_RX_Q_67_TH, 0x10008); |
| 98 | + mt76_wr(dev, MT_WFDMA0_PAUSE_RX_Q_89_TH, 0x10008); |
| 99 | + mt76_wr(dev, MT_WFDMA0_PAUSE_RX_Q_RRO_TH, 0x20); |
| 100 | + |
| 101 | if (dev->hif2) { |
| 102 | /* GLO_CFG_EXT0 */ |
| 103 | mt76_set(dev, WF_WFDMA0_GLO_CFG_EXT0 + hif1_ofs, |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame^] | 104 | @@ -306,7 +323,18 @@ static void mt7996_dma_enable(struct mt7996_dev *dev, bool reset) |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 105 | WF_WFDMA0_GLO_CFG_EXT1_TX_FCTRL_MODE); |
| 106 | |
| 107 | mt76_set(dev, MT_WFDMA_HOST_CONFIG, |
| 108 | - MT_WFDMA_HOST_CONFIG_PDMA_BAND); |
| 109 | + MT_WFDMA_HOST_CONFIG_PDMA_BAND | |
| 110 | + MT_WFDMA_HOST_CONFIG_BAND2_PCIE1); |
| 111 | + |
| 112 | + /* AXI read outstanding number */ |
| 113 | + mt76_rmw(dev, MT_WFDMA_AXI_R2A_CTRL, |
| 114 | + MT_WFDMA_AXI_R2A_CTRL_OUTSTAND_MASK, 0x14); |
| 115 | + |
| 116 | + /* WFDMA rx threshold */ |
| 117 | + mt76_wr(dev, MT_WFDMA0_PAUSE_RX_Q_45_TH + hif1_ofs, 0xc000c); |
| 118 | + mt76_wr(dev, MT_WFDMA0_PAUSE_RX_Q_67_TH + hif1_ofs, 0x10008); |
| 119 | + mt76_wr(dev, MT_WFDMA0_PAUSE_RX_Q_89_TH + hif1_ofs, 0x10008); |
| 120 | + mt76_wr(dev, MT_WFDMA0_PAUSE_RX_Q_RRO_TH + hif1_ofs, 0x20); |
| 121 | } |
| 122 | |
| 123 | if (dev->hif2) { |
| 124 | diff --git a/mt7996/regs.h b/mt7996/regs.h |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame^] | 125 | index a4d5ad8..f7c99cd 100644 |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 126 | --- a/mt7996/regs.h |
| 127 | +++ b/mt7996/regs.h |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame^] | 128 | @@ -366,6 +366,11 @@ enum base_rev { |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 129 | #define MT_WFDMA0_GLO_CFG_OMIT_RX_INFO BIT(27) |
| 130 | #define MT_WFDMA0_GLO_CFG_OMIT_RX_INFO_PFET2 BIT(21) |
| 131 | |
| 132 | +#define MT_WFDMA0_PAUSE_RX_Q_45_TH MT_WFDMA0(0x268) |
| 133 | +#define MT_WFDMA0_PAUSE_RX_Q_67_TH MT_WFDMA0(0x26c) |
| 134 | +#define MT_WFDMA0_PAUSE_RX_Q_89_TH MT_WFDMA0(0x270) |
| 135 | +#define MT_WFDMA0_PAUSE_RX_Q_RRO_TH MT_WFDMA0(0x27c) |
| 136 | + |
| 137 | #define WF_WFDMA0_GLO_CFG_EXT0 MT_WFDMA0(0x2b0) |
| 138 | #define WF_WFDMA0_GLO_CFG_EXT0_RX_WB_RXD BIT(18) |
| 139 | #define WF_WFDMA0_GLO_CFG_EXT0_WED_MERGE_MODE BIT(14) |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame^] | 140 | @@ -388,10 +393,14 @@ enum base_rev { |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 141 | |
| 142 | #define MT_WFDMA_HOST_CONFIG MT_WFDMA_EXT_CSR(0x30) |
| 143 | #define MT_WFDMA_HOST_CONFIG_PDMA_BAND BIT(0) |
| 144 | +#define MT_WFDMA_HOST_CONFIG_BAND2_PCIE1 BIT(22) |
| 145 | |
| 146 | #define MT_WFDMA_EXT_CSR_HIF_MISC MT_WFDMA_EXT_CSR(0x44) |
| 147 | #define MT_WFDMA_EXT_CSR_HIF_MISC_BUSY BIT(0) |
| 148 | |
| 149 | +#define MT_WFDMA_AXI_R2A_CTRL MT_WFDMA_EXT_CSR(0x500) |
| 150 | +#define MT_WFDMA_AXI_R2A_CTRL_OUTSTAND_MASK GENMASK(4, 0) |
| 151 | + |
| 152 | #define MT_PCIE_RECOG_ID 0xd7090 |
| 153 | #define MT_PCIE_RECOG_ID_MASK GENMASK(30, 0) |
| 154 | #define MT_PCIE_RECOG_ID_SEM BIT(31) |
| 155 | -- |
developer | 3e11ee3 | 2023-09-27 12:24:47 +0800 | [diff] [blame] | 156 | 2.18.0 |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 157 | |