developer | 281084d | 2023-06-19 12:03:50 +0800 | [diff] [blame^] | 1 | From fba98d69dcbbbcbd4cbf61e997637ecead9e55a3 Mon Sep 17 00:00:00 2001 |
| 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Wed, 19 Apr 2023 18:32:41 +0800 |
| 4 | Subject: [PATCH 2006/2008] wifi: mt76: add random early drop support |
| 5 | |
| 6 | --- |
| 7 | mt7996/mcu.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++-- |
| 8 | mt7996/mcu.h | 4 ++- |
| 9 | mt7996/mt7996.h | 1 + |
| 10 | 3 files changed, 79 insertions(+), 3 deletions(-) |
| 11 | |
| 12 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
| 13 | index 1891c0d7..0c01e90b 100644 |
| 14 | --- a/mt7996/mcu.c |
| 15 | +++ b/mt7996/mcu.c |
| 16 | @@ -2933,8 +2933,8 @@ int mt7996_mcu_init_firmware(struct mt7996_dev *dev) |
| 17 | if (ret) |
| 18 | return ret; |
| 19 | |
| 20 | - return mt7996_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| 21 | - MCU_WA_PARAM_RED, 0, 0); |
| 22 | + return mt7996_mcu_red_config(dev, |
| 23 | + mtk_wed_device_active(&dev->mt76.mmio.wed)); |
| 24 | } |
| 25 | |
| 26 | int mt7996_mcu_init(struct mt7996_dev *dev) |
| 27 | @@ -2966,6 +2966,79 @@ out: |
| 28 | skb_queue_purge(&dev->mt76.mcu.res_q); |
| 29 | } |
| 30 | |
| 31 | +static int mt7996_mcu_wa_red_config(struct mt7996_dev *dev) |
| 32 | +{ |
| 33 | +#define RED_TOKEN_SRC_CNT 4 |
| 34 | +#define RED_TOKEN_CONFIG 2 |
| 35 | + struct { |
| 36 | + __le32 arg0; |
| 37 | + __le32 arg1; |
| 38 | + __le32 arg2; |
| 39 | + |
| 40 | + u8 mode; |
| 41 | + u8 version; |
| 42 | + u8 _rsv[4]; |
| 43 | + __le16 len; |
| 44 | + |
| 45 | + __le16 tcp_offset; |
| 46 | + __le16 priority_offset; |
| 47 | + __le16 token_per_src[RED_TOKEN_SRC_CNT]; |
| 48 | + __le16 token_thr_per_src[RED_TOKEN_SRC_CNT]; |
| 49 | + |
| 50 | + u8 _rsv2[604]; |
| 51 | + } __packed req = { |
| 52 | + .arg0 = cpu_to_le32(MCU_WA_PARAM_RED_CONFIG), |
| 53 | + |
| 54 | + .mode = RED_TOKEN_CONFIG, |
| 55 | + .len = cpu_to_le16(sizeof(req) - sizeof(__le32) * 3), |
| 56 | + |
| 57 | + .tcp_offset = cpu_to_le16(200), |
| 58 | + .priority_offset = cpu_to_le16(255), |
| 59 | + }; |
| 60 | + u8 i; |
| 61 | + |
| 62 | + for (i = 0; i < RED_TOKEN_SRC_CNT; i++) { |
| 63 | + req.token_per_src[i] = cpu_to_le16(MT7996_TOKEN_SIZE); |
| 64 | + req.token_thr_per_src[i] = cpu_to_le16(MT7996_TOKEN_SIZE); |
| 65 | + } |
| 66 | + |
| 67 | + return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), |
| 68 | + &req, sizeof(req), false); |
| 69 | +} |
| 70 | + |
| 71 | +int mt7996_mcu_red_config(struct mt7996_dev *dev, bool enable) |
| 72 | +{ |
| 73 | +#define RED_DISABLE 0 |
| 74 | +#define RED_BY_WA_ENABLE 2 |
| 75 | + struct { |
| 76 | + u8 __rsv1[4]; |
| 77 | + |
| 78 | + __le16 tag; |
| 79 | + __le16 len; |
| 80 | + u8 enable; |
| 81 | + u8 __rsv2[3]; |
| 82 | + } __packed req = { |
| 83 | + .tag = cpu_to_le16(UNI_VOW_RED_ENABLE), |
| 84 | + .len = cpu_to_le16(sizeof(req) - 4), |
| 85 | + .enable = enable ? RED_BY_WA_ENABLE : RED_DISABLE, |
| 86 | + }; |
| 87 | + int ret; |
| 88 | + |
| 89 | + ret = mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(VOW), &req, |
| 90 | + sizeof(req), true); |
| 91 | + |
| 92 | + if (ret) |
| 93 | + return ret; |
| 94 | + |
| 95 | + ret = mt7996_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| 96 | + MCU_WA_PARAM_RED_EN, enable, 0); |
| 97 | + |
| 98 | + if (ret || !enable) |
| 99 | + return ret; |
| 100 | + |
| 101 | + return mt7996_mcu_wa_red_config(dev); |
| 102 | +} |
| 103 | + |
| 104 | int mt7996_mcu_set_hdr_trans(struct mt7996_dev *dev, bool hdr_trans) |
| 105 | { |
| 106 | struct { |
| 107 | diff --git a/mt7996/mcu.h b/mt7996/mcu.h |
| 108 | index a0cbf922..ec074bc6 100644 |
| 109 | --- a/mt7996/mcu.h |
| 110 | +++ b/mt7996/mcu.h |
| 111 | @@ -239,8 +239,9 @@ enum { |
| 112 | enum { |
| 113 | MCU_WA_PARAM_PDMA_RX = 0x04, |
| 114 | MCU_WA_PARAM_CPU_UTIL = 0x0b, |
| 115 | - MCU_WA_PARAM_RED = 0x0e, |
| 116 | + MCU_WA_PARAM_RED_EN = 0x0e, |
| 117 | MCU_WA_PARAM_HW_PATH_HIF_VER = 0x2f, |
| 118 | + MCU_WA_PARAM_RED_CONFIG = 0x40, |
| 119 | }; |
| 120 | |
| 121 | enum mcu_mmps_mode { |
| 122 | @@ -695,6 +696,7 @@ enum { |
| 123 | UNI_VOW_DRR_CTRL, |
| 124 | UNI_VOW_RX_AT_AIRTIME_EN = 0x0b, |
| 125 | UNI_VOW_RX_AT_AIRTIME_CLR_EN = 0x0e, |
| 126 | + UNI_VOW_RED_ENABLE = 0x18, |
| 127 | }; |
| 128 | |
| 129 | enum { |
| 130 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
| 131 | index 836c7db7..b239c44c 100644 |
| 132 | --- a/mt7996/mt7996.h |
| 133 | +++ b/mt7996/mt7996.h |
| 134 | @@ -671,6 +671,7 @@ int mt7996_mcu_rf_regval(struct mt7996_dev *dev, u32 regidx, u32 *val, bool set) |
| 135 | int mt7996_mcu_set_hdr_trans(struct mt7996_dev *dev, bool hdr_trans); |
| 136 | int mt7996_mcu_set_rro(struct mt7996_dev *dev, u16 tag, u8 val); |
| 137 | int mt7996_mcu_wa_cmd(struct mt7996_dev *dev, int cmd, u32 a1, u32 a2, u32 a3); |
| 138 | +int mt7996_mcu_red_config(struct mt7996_dev *dev, bool enable); |
| 139 | int mt7996_mcu_fw_log_2_host(struct mt7996_dev *dev, u8 type, u8 ctrl); |
| 140 | int mt7996_mcu_fw_dbg_ctrl(struct mt7996_dev *dev, u32 module, u8 level); |
| 141 | int mt7996_mcu_trigger_assert(struct mt7996_dev *dev); |
| 142 | -- |
| 143 | 2.39.2 |
| 144 | |