developer | 07b5baf | 2024-01-10 04:38:47 +0800 | [diff] [blame] | 1 | From 89b3bd70258ed3f943c61e88288ef6f63160a579 Mon Sep 17 00:00:00 2001 |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 2 | From: Howard Hsu <howard-yh.hsu@mediatek.com> |
| 3 | Date: Tue, 13 Jun 2023 14:49:02 +0800 |
developer | 07b5baf | 2024-01-10 04:38:47 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1032/1044] mtk: wifi: mt76: mt7996: add build the following |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 5 | MURU mcu command tlvs |
| 6 | |
| 7 | It includes the following tlvs: |
| 8 | 1. MURU tlv id 0x10, 0x33, 0xC8, 0xC9, 0xCA, 0xCC, 0xCD |
| 9 | 2. BF tlv id 0x1c |
| 10 | |
| 11 | --- |
| 12 | mt7996/mcu.h | 1 + |
| 13 | mt7996/mt7996.h | 3 ++ |
| 14 | mt7996/mtk_debugfs.c | 12 +++++++ |
| 15 | mt7996/mtk_mcu.c | 78 ++++++++++++++++++++++++++++++++++++++++++++ |
| 16 | mt7996/mtk_mcu.h | 14 ++++++++ |
| 17 | 5 files changed, 108 insertions(+) |
| 18 | |
| 19 | diff --git a/mt7996/mcu.h b/mt7996/mcu.h |
| 20 | index 347893c8..527c9c79 100644 |
| 21 | --- a/mt7996/mcu.h |
| 22 | +++ b/mt7996/mcu.h |
| 23 | @@ -776,6 +776,7 @@ enum { |
| 24 | BF_MOD_EN_CTRL = 20, |
| 25 | BF_FBRPT_DBG_INFO_READ = 23, |
| 26 | BF_TXSND_INFO = 24, |
| 27 | + BF_CFG_PHY = 28, |
| 28 | }; |
| 29 | |
| 30 | enum { |
| 31 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
developer | 07b5baf | 2024-01-10 04:38:47 +0800 | [diff] [blame] | 32 | index 33936f90..4a268a4e 100644 |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 33 | --- a/mt7996/mt7996.h |
| 34 | +++ b/mt7996/mt7996.h |
developer | 07b5baf | 2024-01-10 04:38:47 +0800 | [diff] [blame] | 35 | @@ -815,6 +815,9 @@ void mt7996_mcu_rx_bf_event(struct mt7996_dev *dev, struct sk_buff *skb); |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 36 | int mt7996_mcu_set_muru_fixed_rate_enable(struct mt7996_dev *dev, u8 action, int val); |
| 37 | int mt7996_mcu_set_muru_fixed_rate_parameter(struct mt7996_dev *dev, u8 action, void *para); |
| 38 | int mt7996_mcu_set_txbf_snd_info(struct mt7996_phy *phy, void *para); |
| 39 | +int mt7996_mcu_set_muru_cmd(struct mt7996_dev *dev, u16 action, int val); |
| 40 | +int mt7996_mcu_muru_set_prot_frame_thr(struct mt7996_dev *dev, u32 val); |
| 41 | +int mt7996_mcu_set_bypass_smthint(struct mt7996_phy *phy, u8 val); |
| 42 | #endif |
| 43 | |
| 44 | #ifdef CONFIG_NET_MEDIATEK_SOC_WED |
| 45 | diff --git a/mt7996/mtk_debugfs.c b/mt7996/mtk_debugfs.c |
developer | 07b5baf | 2024-01-10 04:38:47 +0800 | [diff] [blame] | 46 | index 651fb4a9..87c80828 100644 |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 47 | --- a/mt7996/mtk_debugfs.c |
| 48 | +++ b/mt7996/mtk_debugfs.c |
developer | 07b5baf | 2024-01-10 04:38:47 +0800 | [diff] [blame] | 49 | @@ -3005,6 +3005,16 @@ static const struct file_operations fops_muru_fixed_group_rate = { |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 50 | .llseek = default_llseek, |
| 51 | }; |
| 52 | |
| 53 | +static int mt7996_muru_prot_thr_set(void *data, u64 val) |
| 54 | +{ |
| 55 | + struct mt7996_phy *phy = data; |
| 56 | + |
| 57 | + return mt7996_mcu_muru_set_prot_frame_thr(phy->dev, (u32)val); |
| 58 | +} |
| 59 | + |
| 60 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_muru_prot_thr, NULL, |
| 61 | + mt7996_muru_prot_thr_set, "%lld\n"); |
| 62 | + |
| 63 | int mt7996_mtk_init_debugfs(struct mt7996_phy *phy, struct dentry *dir) |
| 64 | { |
| 65 | struct mt7996_dev *dev = phy->dev; |
developer | 07b5baf | 2024-01-10 04:38:47 +0800 | [diff] [blame] | 66 | @@ -3100,6 +3110,8 @@ int mt7996_mtk_init_debugfs(struct mt7996_phy *phy, struct dentry *dir) |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 67 | debugfs_create_file("bf_fbk_rpt", 0600, dir, phy, &fops_bf_fbk_rpt); |
| 68 | debugfs_create_file("pfmu_tag_read", 0600, dir, phy, &fops_bf_pfmu_tag_read); |
| 69 | |
| 70 | + debugfs_create_file("muru_prot_thr", 0200, dir, phy, &fops_muru_prot_thr); |
| 71 | + |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | diff --git a/mt7996/mtk_mcu.c b/mt7996/mtk_mcu.c |
| 76 | index 67419cd9..b7d86384 100644 |
| 77 | --- a/mt7996/mtk_mcu.c |
| 78 | +++ b/mt7996/mtk_mcu.c |
| 79 | @@ -906,4 +906,82 @@ error: |
| 80 | return -EINVAL; |
| 81 | } |
| 82 | |
| 83 | +/** |
| 84 | + * This function can be used to build the following commands |
| 85 | + * MURU_SUTX_CTRL (0x10) |
| 86 | + * SET_FORCE_MU (0x33) |
| 87 | + * SET_MUDL_ACK_POLICY (0xC8) |
| 88 | + * SET_TRIG_TYPE (0xC9) |
| 89 | + * SET_20M_DYN_ALGO (0xCA) |
| 90 | + * SET_CERT_MU_EDCA_OVERRIDE (0xCD) |
| 91 | + */ |
| 92 | +int mt7996_mcu_set_muru_cmd(struct mt7996_dev *dev, u16 action, int val) |
| 93 | +{ |
| 94 | + struct { |
| 95 | + u8 _rsv[4]; |
| 96 | + |
| 97 | + __le16 tag; |
| 98 | + __le16 len; |
| 99 | + |
| 100 | + u8 config; |
| 101 | + u8 rsv[3]; |
| 102 | + } __packed data = { |
| 103 | + .tag = cpu_to_le16(action), |
| 104 | + .len = cpu_to_le16(sizeof(data) - 4), |
| 105 | + .config = (u8) val, |
| 106 | + }; |
| 107 | + |
| 108 | + return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(MURU), &data, sizeof(data), |
| 109 | + false); |
| 110 | +} |
| 111 | + |
| 112 | +int mt7996_mcu_muru_set_prot_frame_thr(struct mt7996_dev *dev, u32 val) |
| 113 | +{ |
| 114 | + struct { |
| 115 | + u8 _rsv[4]; |
| 116 | + |
| 117 | + __le16 tag; |
| 118 | + __le16 len; |
| 119 | + |
| 120 | + __le32 prot_frame_thr; |
| 121 | + } __packed data = { |
| 122 | + .tag = cpu_to_le16(UNI_CMD_MURU_PROT_FRAME_THR), |
| 123 | + .len = cpu_to_le16(sizeof(data) - 4), |
| 124 | + .prot_frame_thr = cpu_to_le32(val), |
| 125 | + }; |
| 126 | + |
| 127 | + return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(MURU), &data, sizeof(data), |
| 128 | + false); |
| 129 | +} |
| 130 | + |
| 131 | +int mt7996_mcu_set_bypass_smthint(struct mt7996_phy *phy, u8 val) |
| 132 | +{ |
| 133 | +#define BF_PHY_SMTH_INT_BYPASS 0 |
| 134 | +#define BYPASS_VAL 1 |
| 135 | + struct mt7996_dev *dev = phy->dev; |
| 136 | + struct { |
| 137 | + u8 _rsv[4]; |
| 138 | + |
| 139 | + u16 tag; |
| 140 | + u16 len; |
| 141 | + |
| 142 | + u8 action; |
| 143 | + u8 band_idx; |
| 144 | + u8 smthintbypass; |
| 145 | + u8 __rsv2[5]; |
| 146 | + } __packed data = { |
| 147 | + .tag = cpu_to_le16(BF_CFG_PHY), |
| 148 | + .len = cpu_to_le16(sizeof(data) - 4), |
| 149 | + .action = BF_PHY_SMTH_INT_BYPASS, |
| 150 | + .band_idx = phy->mt76->band_idx, |
| 151 | + .smthintbypass = val, |
| 152 | + }; |
| 153 | + |
| 154 | + if (val != BYPASS_VAL) |
| 155 | + return -EINVAL; |
| 156 | + |
| 157 | + return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(BF), &data, sizeof(data), |
| 158 | + true); |
| 159 | +} |
| 160 | + |
| 161 | #endif |
| 162 | diff --git a/mt7996/mtk_mcu.h b/mt7996/mtk_mcu.h |
developer | 07b5baf | 2024-01-10 04:38:47 +0800 | [diff] [blame] | 163 | index 71c6684a..b061950c 100644 |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 164 | --- a/mt7996/mtk_mcu.h |
| 165 | +++ b/mt7996/mtk_mcu.h |
developer | 07b5baf | 2024-01-10 04:38:47 +0800 | [diff] [blame] | 166 | @@ -119,6 +119,20 @@ enum { |
developer | 5f4e6c3 | 2023-12-20 06:12:53 +0800 | [diff] [blame] | 167 | EDCCA_FCC = 1, |
| 168 | EDCCA_ETSI = 2, |
| 169 | EDCCA_JAPAN = 3 |
| 170 | +}; |
| 171 | + |
| 172 | +enum { |
| 173 | + UNI_CMD_MURU_SUTX_CTRL = 0x10, |
| 174 | + UNI_CMD_MURU_FIXED_RATE_CTRL, |
| 175 | + UNI_CMD_MURU_FIXED_GROUP_RATE_CTRL, |
| 176 | + UNI_CMD_MURU_SET_FORCE_MU = 0x33, |
| 177 | + UNI_CMD_MURU_MUNUAL_CONFIG = 0x64, |
| 178 | + UNI_CMD_MURU_SET_MUDL_ACK_POLICY = 0xC9, |
| 179 | + UNI_CMD_MURU_SET_TRIG_TYPE, |
| 180 | + UNI_CMD_MURU_SET_20M_DYN_ALGO, |
| 181 | + UNI_CMD_MURU_PROT_FRAME_THR = 0xCC, |
| 182 | + UNI_CMD_MURU_SET_CERT_MU_EDCA_OVERRIDE, |
| 183 | +}; |
| 184 | |
| 185 | struct bf_pfmu_tag { |
| 186 | __le16 tag; |
| 187 | -- |
| 188 | 2.18.0 |
| 189 | |