developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 1 | From 2f0b6e966f10cfcdb3a325238e10966c25c1ea3b Mon Sep 17 00:00:00 2001 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Fri, 2 Sep 2022 14:40:40 +0800 |
developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 4 | Subject: [PATCH] mt76: mt7915: wed: enable red per-band token drop for HW Path |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 5 | |
| 6 | Limit the number of token used by each band. If a band uses too many token, |
| 7 | it may hurt the throughput of the other band. The SW path can solve this |
| 8 | problem by AQL. |
| 9 | |
| 10 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 11 | --- |
developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 12 | mt76_connac_mcu.h | 2 +- |
| 13 | mt7915/mcu.c | 45 ++++++++++++++++++++++++++++++++++++++------- |
| 14 | mt7915/mcu.h | 1 + |
| 15 | mt7915/mmio.c | 2 +- |
| 16 | mt7915/mt7915.h | 4 +++- |
| 17 | 5 files changed, 44 insertions(+), 10 deletions(-) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 18 | |
developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 19 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
| 20 | index 98b00747..21ea55d1 100644 |
| 21 | --- a/mt76_connac_mcu.h |
| 22 | +++ b/mt76_connac_mcu.h |
| 23 | @@ -1174,13 +1174,13 @@ enum { |
| 24 | MCU_EXT_CMD_RXDCOC_CAL = 0x59, |
| 25 | MCU_EXT_CMD_GET_MIB_INFO = 0x5a, |
| 26 | #ifdef MTK_DEBUG |
| 27 | - MCU_EXT_CMD_RED_ENABLE = 0x68, |
| 28 | MCU_EXT_CMD_RED_SHOW_STA = 0x69, |
| 29 | MCU_EXT_CMD_RED_TARGET_DELAY = 0x6A, |
| 30 | MCU_EXT_CMD_RED_TX_RPT = 0x6B, |
| 31 | #endif |
| 32 | MCU_EXT_CMD_TXDPD_CAL = 0x60, |
| 33 | MCU_EXT_CMD_CAL_CACHE = 0x67, |
| 34 | + MCU_EXT_CMD_RED_ENABLE = 0x68, |
| 35 | MCU_EXT_CMD_SET_RADAR_TH = 0x7c, |
| 36 | MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d, |
| 37 | MCU_EXT_CMD_MWDS_SUPPORT = 0x80, |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 38 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 39 | index f494d9f6..116a5cc9 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 40 | --- a/mt7915/mcu.c |
| 41 | +++ b/mt7915/mcu.c |
developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 42 | @@ -2376,6 +2376,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev) |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 43 | return ret; |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | + |
| 47 | ret = mt7915_mcu_set_mwds(dev, 1); |
| 48 | if (ret) |
| 49 | return ret; |
developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 50 | @@ -2389,8 +2390,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 51 | if (ret) |
| 52 | return ret; |
| 53 | |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 54 | - return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| 55 | - MCU_WA_PARAM_RED, 0, 0); |
developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 56 | + return mt7915_mcu_set_red(dev, mtk_wed_device_active(&dev->mt76.mmio.wed)); |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | int mt7915_mcu_init(struct mt7915_dev *dev) |
developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 60 | @@ -4533,27 +4533,58 @@ int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 61 | |
| 62 | return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), wait_resp); |
| 63 | } |
| 64 | +#endif |
| 65 | + |
| 66 | +static int mt7915_red_set_watermark(struct mt7915_dev *dev) |
| 67 | +{ |
| 68 | +#define RED_GLOBAL_TOKEN_WATERMARK 2 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 69 | + struct { |
| 70 | + __le32 args[3]; |
| 71 | + |
| 72 | + u8 cmd; |
| 73 | + u8 version; |
| 74 | + u8 __rsv1[4]; |
| 75 | + u16 len; |
| 76 | + |
| 77 | + __le16 high_mark; |
| 78 | + __le16 low_mark; |
| 79 | + u8 __rsv2[12]; |
developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 80 | + } __packed req = { |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 81 | + .args[0] = cpu_to_le32(MCU_WA_PARAM_RED_SETTING), |
| 82 | + .cmd = RED_GLOBAL_TOKEN_WATERMARK, |
| 83 | + .len = cpu_to_le16(sizeof(req) - 12), |
| 84 | + |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 85 | + .high_mark = cpu_to_le16(MT7915_HW_TOKEN_SIZE - 256), |
| 86 | + .low_mark = cpu_to_le16(MT7915_HW_TOKEN_SIZE - 256 - 1536), |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 87 | + }; |
| 88 | + |
| 89 | + return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req, |
| 90 | + sizeof(req), false); |
| 91 | +} |
| 92 | |
| 93 | int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled) |
| 94 | { |
developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 95 | #define RED_DISABLE 0 |
| 96 | -#define RED_BY_HOST_ENABLE 1 |
| 97 | #define RED_BY_WA_ENABLE 2 |
| 98 | int ret; |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 99 | u32 red_type = enabled > 0 ? RED_BY_WA_ENABLE : RED_DISABLE; |
| 100 | __le32 req = cpu_to_le32(red_type); |
| 101 | |
| 102 | + if (enabled) { |
| 103 | + ret = mt7915_red_set_watermark(dev); |
| 104 | + if (ret < 0) |
| 105 | + return ret; |
| 106 | + } |
| 107 | + |
| 108 | ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req, |
| 109 | sizeof(req), false); |
| 110 | if (ret < 0) |
| 111 | return ret; |
| 112 | |
| 113 | - mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| 114 | - MCU_WA_PARAM_RED, enabled, 0, true); |
| 115 | + return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| 116 | + MCU_WA_PARAM_RED, enabled, 0); |
| 117 | |
| 118 | - return 0; |
| 119 | } |
| 120 | -#endif |
| 121 | |
| 122 | int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set) |
| 123 | { |
| 124 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 125 | index f2f88cc4..572cc16a 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 126 | --- a/mt7915/mcu.h |
| 127 | +++ b/mt7915/mcu.h |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 128 | @@ -285,6 +285,7 @@ enum { |
| 129 | MCU_WA_PARAM_CPU_UTIL = 0x0b, |
| 130 | MCU_WA_PARAM_RED = 0x0e, |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 131 | MCU_WA_PARAM_WED_VERSION = 0x32, |
| 132 | + MCU_WA_PARAM_RED_SETTING = 0x40, |
developer | 780b915 | 2022-12-15 14:09:45 +0800 | [diff] [blame] | 133 | #ifdef MTK_DEBUG |
| 134 | MCU_WA_PARAM_RED_SHOW_STA = 0xf, |
| 135 | MCU_WA_PARAM_RED_TARGET_DELAY = 0x10, |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 136 | diff --git a/mt7915/mmio.c b/mt7915/mmio.c |
developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 137 | index e0761e89..b29fe7a4 100644 |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 138 | --- a/mt7915/mmio.c |
| 139 | +++ b/mt7915/mmio.c |
| 140 | @@ -759,7 +759,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
| 141 | wed->wlan.wpdma_rx_glo = res->start + MT_WPDMA_GLO_CFG; |
| 142 | wed->wlan.wpdma_rx = res->start + MT_RXQ_WED_DATA_RING_BASE; |
| 143 | } |
| 144 | - wed->wlan.nbuf = 4096; |
| 145 | + wed->wlan.nbuf = MT7915_HW_TOKEN_SIZE; |
| 146 | wed->wlan.tx_tbit[0] = is_mt7915(&dev->mt76) ? 4 : 30; |
| 147 | wed->wlan.tx_tbit[1] = is_mt7915(&dev->mt76) ? 5 : 31; |
| 148 | wed->wlan.txfree_tbit = is_mt7986(&dev->mt76) ? 2 : 1; |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 149 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 150 | index 89c13dbe..2335f78f 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 151 | --- a/mt7915/mt7915.h |
| 152 | +++ b/mt7915/mt7915.h |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 153 | @@ -56,6 +56,7 @@ |
| 154 | |
| 155 | #define MT7915_EEPROM_BLOCK_SIZE 16 |
| 156 | #define MT7915_TOKEN_SIZE 8192 |
developer | efb40c1 | 2022-12-21 18:05:47 +0800 | [diff] [blame] | 157 | +#define MT7915_HW_TOKEN_SIZE 7168 |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 158 | |
| 159 | #define MT7915_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */ |
| 160 | #define MT7915_CFEND_RATE_11B 0x03 /* 11B LP, 11M */ |
| 161 | @@ -771,13 +772,14 @@ int mt7915_vendor_amnt_sta_remove(struct mt7915_phy *phy, |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 162 | #endif |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 163 | int mt7915_mcu_set_edcca(struct mt7915_phy *phy, int mode, u8 *value, s8 compensation); |
| 164 | int mt7915_mcu_get_edcca(struct mt7915_phy *phy, u8 mode, s8 *value); |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 165 | +int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled); |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 166 | + |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 167 | int mt7915_mcu_ipi_hist_ctrl(struct mt7915_phy *phy, void *data, u8 cmd, bool wait_resp); |
| 168 | int mt7915_mcu_ipi_hist_scan(struct mt7915_phy *phy, void *data, u8 mode, bool wait_resp); |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 169 | |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 170 | #ifdef MTK_DEBUG |
| 171 | int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir); |
| 172 | int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp); |
| 173 | -int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled); |
| 174 | void mt7915_dump_tmac_info(u8 *tmac_info); |
| 175 | int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level); |
| 176 | void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len); |
| 177 | -- |
developer | 5e59976 | 2023-01-03 16:01:51 +0800 | [diff] [blame] | 178 | 2.18.0 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 179 | |