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