| From 007ab43e5052b5bc21e5c720d09b30f0b56e6e79 Mon Sep 17 00:00:00 2001 |
| From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| Date: Fri, 2 Sep 2022 14:40:40 +0800 |
| Subject: [PATCH 3006/3013] mt76: mt7915: wed: enable red per-band token drop |
| for HW Path |
| |
| Limit the number of token used by each band. If a band uses too many token, |
| it may hurt the throughput of the other band. The SW path can solve this |
| problem by AQL. |
| |
| Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| --- |
| mt76_connac_mcu.h | 2 +- |
| mt7915/mcu.c | 45 ++++++++++++++++++++++++++++++++++++++------- |
| mt7915/mcu.h | 1 + |
| mt7915/mmio.c | 2 +- |
| mt7915/mt7915.h | 4 +++- |
| 5 files changed, 44 insertions(+), 10 deletions(-) |
| |
| diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
| index 98b0074..21ea55d 100644 |
| --- a/mt76_connac_mcu.h |
| +++ b/mt76_connac_mcu.h |
| @@ -1174,13 +1174,13 @@ enum { |
| MCU_EXT_CMD_RXDCOC_CAL = 0x59, |
| MCU_EXT_CMD_GET_MIB_INFO = 0x5a, |
| #ifdef MTK_DEBUG |
| - MCU_EXT_CMD_RED_ENABLE = 0x68, |
| MCU_EXT_CMD_RED_SHOW_STA = 0x69, |
| MCU_EXT_CMD_RED_TARGET_DELAY = 0x6A, |
| MCU_EXT_CMD_RED_TX_RPT = 0x6B, |
| #endif |
| MCU_EXT_CMD_TXDPD_CAL = 0x60, |
| MCU_EXT_CMD_CAL_CACHE = 0x67, |
| + MCU_EXT_CMD_RED_ENABLE = 0x68, |
| MCU_EXT_CMD_SET_RADAR_TH = 0x7c, |
| MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d, |
| MCU_EXT_CMD_MWDS_SUPPORT = 0x80, |
| diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
| index f494d9f..116a5cc 100644 |
| --- a/mt7915/mcu.c |
| +++ b/mt7915/mcu.c |
| @@ -2376,6 +2376,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev) |
| return ret; |
| } |
| |
| + |
| ret = mt7915_mcu_set_mwds(dev, 1); |
| if (ret) |
| return ret; |
| @@ -2389,8 +2390,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev) |
| if (ret) |
| return ret; |
| |
| - return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| - MCU_WA_PARAM_RED, 0, 0); |
| + return mt7915_mcu_set_red(dev, mtk_wed_device_active(&dev->mt76.mmio.wed)); |
| } |
| |
| int mt7915_mcu_init(struct mt7915_dev *dev) |
| @@ -4533,27 +4533,58 @@ int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a |
| |
| return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), wait_resp); |
| } |
| +#endif |
| + |
| +static int mt7915_red_set_watermark(struct mt7915_dev *dev) |
| +{ |
| +#define RED_GLOBAL_TOKEN_WATERMARK 2 |
| + struct { |
| + __le32 args[3]; |
| + |
| + u8 cmd; |
| + u8 version; |
| + u8 __rsv1[4]; |
| + u16 len; |
| + |
| + __le16 high_mark; |
| + __le16 low_mark; |
| + u8 __rsv2[12]; |
| + } __packed req = { |
| + .args[0] = cpu_to_le32(MCU_WA_PARAM_RED_SETTING), |
| + .cmd = RED_GLOBAL_TOKEN_WATERMARK, |
| + .len = cpu_to_le16(sizeof(req) - 12), |
| + |
| + .high_mark = cpu_to_le16(MT7915_HW_TOKEN_SIZE - 256), |
| + .low_mark = cpu_to_le16(MT7915_HW_TOKEN_SIZE - 256 - 1536), |
| + }; |
| + |
| + return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req, |
| + sizeof(req), false); |
| +} |
| |
| int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled) |
| { |
| #define RED_DISABLE 0 |
| -#define RED_BY_HOST_ENABLE 1 |
| #define RED_BY_WA_ENABLE 2 |
| int ret; |
| u32 red_type = enabled > 0 ? RED_BY_WA_ENABLE : RED_DISABLE; |
| __le32 req = cpu_to_le32(red_type); |
| |
| + if (enabled) { |
| + ret = mt7915_red_set_watermark(dev); |
| + if (ret < 0) |
| + return ret; |
| + } |
| + |
| ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req, |
| sizeof(req), false); |
| if (ret < 0) |
| return ret; |
| |
| - mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| - MCU_WA_PARAM_RED, enabled, 0, true); |
| + return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| + MCU_WA_PARAM_RED, enabled, 0); |
| |
| - return 0; |
| } |
| -#endif |
| |
| int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set) |
| { |
| diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
| index f2f88cc..572cc16 100644 |
| --- a/mt7915/mcu.h |
| +++ b/mt7915/mcu.h |
| @@ -285,6 +285,7 @@ enum { |
| MCU_WA_PARAM_CPU_UTIL = 0x0b, |
| MCU_WA_PARAM_RED = 0x0e, |
| MCU_WA_PARAM_WED_VERSION = 0x32, |
| + MCU_WA_PARAM_RED_SETTING = 0x40, |
| #ifdef MTK_DEBUG |
| MCU_WA_PARAM_RED_SHOW_STA = 0xf, |
| MCU_WA_PARAM_RED_TARGET_DELAY = 0x10, |
| diff --git a/mt7915/mmio.c b/mt7915/mmio.c |
| index e0761e8..b29fe7a 100644 |
| --- a/mt7915/mmio.c |
| +++ b/mt7915/mmio.c |
| @@ -759,7 +759,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
| wed->wlan.wpdma_rx_glo = res->start + MT_WPDMA_GLO_CFG; |
| wed->wlan.wpdma_rx = res->start + MT_RXQ_WED_DATA_RING_BASE; |
| } |
| - wed->wlan.nbuf = 4096; |
| + wed->wlan.nbuf = MT7915_HW_TOKEN_SIZE; |
| wed->wlan.tx_tbit[0] = is_mt7915(&dev->mt76) ? 4 : 30; |
| wed->wlan.tx_tbit[1] = is_mt7915(&dev->mt76) ? 5 : 31; |
| wed->wlan.txfree_tbit = is_mt7986(&dev->mt76) ? 2 : 1; |
| diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
| index 89c13db..2335f78 100644 |
| --- a/mt7915/mt7915.h |
| +++ b/mt7915/mt7915.h |
| @@ -56,6 +56,7 @@ |
| |
| #define MT7915_EEPROM_BLOCK_SIZE 16 |
| #define MT7915_TOKEN_SIZE 8192 |
| +#define MT7915_HW_TOKEN_SIZE 7168 |
| |
| #define MT7915_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */ |
| #define MT7915_CFEND_RATE_11B 0x03 /* 11B LP, 11M */ |
| @@ -771,13 +772,14 @@ int mt7915_vendor_amnt_sta_remove(struct mt7915_phy *phy, |
| #endif |
| int mt7915_mcu_set_edcca(struct mt7915_phy *phy, int mode, u8 *value, s8 compensation); |
| int mt7915_mcu_get_edcca(struct mt7915_phy *phy, u8 mode, s8 *value); |
| +int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled); |
| + |
| int mt7915_mcu_ipi_hist_ctrl(struct mt7915_phy *phy, void *data, u8 cmd, bool wait_resp); |
| int mt7915_mcu_ipi_hist_scan(struct mt7915_phy *phy, void *data, u8 mode, bool wait_resp); |
| |
| #ifdef MTK_DEBUG |
| int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir); |
| int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp); |
| -int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled); |
| void mt7915_dump_tmac_info(u8 *tmac_info); |
| int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level); |
| void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len); |
| -- |
| 2.18.0 |
| |