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