developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 1 | From 8a932d446bb0da8b7aa4cc7ea8ed541e002cf015 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 | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 4 | Subject: [PATCH] mt76: mt7915: 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 | --- |
| 12 | mt7915/mcu.c | 53 +++++++++++++++++++++++++++++++++++++++---------- |
| 13 | mt7915/mcu.h | 1 + |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 14 | mt7915/mt7915.h | 3 ++- |
| 15 | 3 files changed, 46 insertions(+), 11 deletions(-) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 16 | |
| 17 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 18 | index 16349c58..2ef353b2 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 19 | --- a/mt7915/mcu.c |
| 20 | +++ b/mt7915/mcu.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 21 | @@ -2320,8 +2320,13 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 22 | mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| 23 | MCU_WA_PARAM_WED_VERSION, |
| 24 | wed->rev_id, 0); |
| 25 | + |
| 26 | + mt7915_mcu_set_red(dev, true); |
| 27 | + } else { |
| 28 | + mt7915_mcu_set_red(dev, false); |
| 29 | } |
| 30 | |
| 31 | + |
| 32 | ret = mt7915_mcu_set_mwds(dev, 1); |
| 33 | if (ret) |
| 34 | return ret; |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 35 | @@ -2331,12 +2336,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 36 | if (ret) |
| 37 | return ret; |
| 38 | |
| 39 | - ret = mt7915_mcu_init_rx_airtime(dev); |
| 40 | - if (ret) |
| 41 | - return ret; |
| 42 | - |
| 43 | - return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| 44 | - MCU_WA_PARAM_RED, 0, 0); |
| 45 | + return mt7915_mcu_init_rx_airtime(dev); |
| 46 | } |
| 47 | |
| 48 | int mt7915_mcu_init(struct mt7915_dev *dev) |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 49 | @@ -4162,6 +4162,35 @@ 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] | 50 | |
| 51 | return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), wait_resp); |
| 52 | } |
| 53 | +#endif |
| 54 | + |
| 55 | +static int mt7915_red_set_watermark(struct mt7915_dev *dev) |
| 56 | +{ |
| 57 | +#define RED_GLOBAL_TOKEN_WATERMARK 2 |
| 58 | +#define TOTAL_HW_TOKEN_SIZE 8192 |
| 59 | + struct { |
| 60 | + __le32 args[3]; |
| 61 | + |
| 62 | + u8 cmd; |
| 63 | + u8 version; |
| 64 | + u8 __rsv1[4]; |
| 65 | + u16 len; |
| 66 | + |
| 67 | + __le16 high_mark; |
| 68 | + __le16 low_mark; |
| 69 | + u8 __rsv2[12]; |
| 70 | + } req = { |
| 71 | + .args[0] = cpu_to_le32(MCU_WA_PARAM_RED_SETTING), |
| 72 | + .cmd = RED_GLOBAL_TOKEN_WATERMARK, |
| 73 | + .len = cpu_to_le16(sizeof(req) - 12), |
| 74 | + |
| 75 | + .high_mark = cpu_to_le16(TOTAL_HW_TOKEN_SIZE - 256), |
| 76 | + .low_mark = cpu_to_le16(TOTAL_HW_TOKEN_SIZE - 256 - 1536), |
| 77 | + }; |
| 78 | + |
| 79 | + return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req, |
| 80 | + sizeof(req), false); |
| 81 | +} |
| 82 | |
| 83 | int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled) |
| 84 | { |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 85 | @@ -4172,17 +4201,21 @@ int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 86 | u32 red_type = enabled > 0 ? RED_BY_WA_ENABLE : RED_DISABLE; |
| 87 | __le32 req = cpu_to_le32(red_type); |
| 88 | |
| 89 | + if (enabled) { |
| 90 | + ret = mt7915_red_set_watermark(dev); |
| 91 | + if (ret < 0) |
| 92 | + return ret; |
| 93 | + } |
| 94 | + |
| 95 | ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req, |
| 96 | sizeof(req), false); |
| 97 | if (ret < 0) |
| 98 | return ret; |
| 99 | |
| 100 | - mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| 101 | - MCU_WA_PARAM_RED, enabled, 0, true); |
| 102 | + return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| 103 | + MCU_WA_PARAM_RED, enabled, 0); |
| 104 | |
| 105 | - return 0; |
| 106 | } |
| 107 | -#endif |
| 108 | |
| 109 | int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set) |
| 110 | { |
| 111 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 112 | index 4ae8d532..14a0972b 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 113 | --- a/mt7915/mcu.h |
| 114 | +++ b/mt7915/mcu.h |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 115 | @@ -271,6 +271,7 @@ enum { |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 116 | MCU_WA_PARAM_RED_TARGET_DELAY = 0x10, |
| 117 | #endif |
| 118 | MCU_WA_PARAM_WED_VERSION = 0x32, |
| 119 | + MCU_WA_PARAM_RED_SETTING = 0x40, |
| 120 | }; |
| 121 | |
| 122 | enum mcu_mmps_mode { |
| 123 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 124 | index 46670de4..d8765041 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 125 | --- a/mt7915/mt7915.h |
| 126 | +++ b/mt7915/mt7915.h |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 127 | @@ -773,13 +773,14 @@ int mt7915_vendor_amnt_sta_remove(struct mt7915_phy *phy, |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 128 | #endif |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 129 | int mt7915_mcu_set_edcca(struct mt7915_phy *phy, int mode, u8 *value, s8 compensation); |
| 130 | int mt7915_mcu_get_edcca(struct mt7915_phy *phy, u8 mode, s8 *value); |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 131 | +int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled); |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 132 | + |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 133 | int mt7915_mcu_ipi_hist_ctrl(struct mt7915_phy *phy, void *data, u8 cmd, bool wait_resp); |
| 134 | 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^] | 135 | |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 136 | #ifdef MTK_DEBUG |
| 137 | int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir); |
| 138 | int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp); |
| 139 | -int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled); |
| 140 | void mt7915_dump_tmac_info(u8 *tmac_info); |
| 141 | int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level); |
| 142 | void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len); |
| 143 | -- |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 144 | 2.18.0 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 145 | |