developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 1 | From 5bd260ef2bcd50c4bc56a2b7a1150d8c3b975374 Mon Sep 17 00:00:00 2001 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 2 | From: Howard Hsu <howard-yh.hsu@mediatek.com> |
| 3 | Date: Tue, 13 Jun 2023 14:49:02 +0800 |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 036/193] mtk: mt76: mt7996: add build the following MURU mcu |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 5 | 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 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 11 | Change-Id: I0ae5cbed5b4370d39a6cfca50721873845659006 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 12 | --- |
| 13 | mt7996/mcu.h | 1 + |
| 14 | mt7996/mt7996.h | 3 ++ |
| 15 | mt7996/mtk_debugfs.c | 123 +++++++++++++++++++++++++++++++++++++++++++ |
| 16 | mt7996/mtk_mcu.c | 78 +++++++++++++++++++++++++++ |
| 17 | mt7996/mtk_mcu.h | 14 +++++ |
| 18 | 5 files changed, 219 insertions(+) |
| 19 | |
| 20 | diff --git a/mt7996/mcu.h b/mt7996/mcu.h |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 21 | index 8a71851..a98b174 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 22 | --- a/mt7996/mcu.h |
| 23 | +++ b/mt7996/mcu.h |
| 24 | @@ -776,6 +776,7 @@ enum { |
| 25 | BF_MOD_EN_CTRL = 20, |
| 26 | BF_FBRPT_DBG_INFO_READ = 23, |
| 27 | BF_TXSND_INFO = 24, |
| 28 | + BF_CFG_PHY = 28, |
| 29 | }; |
| 30 | |
| 31 | enum { |
| 32 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 33 | index 8d986de..ed998c0 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 34 | --- a/mt7996/mt7996.h |
| 35 | +++ b/mt7996/mt7996.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 36 | @@ -852,6 +852,9 @@ void mt7996_mcu_rx_bf_event(struct mt7996_dev *dev, struct sk_buff *skb); |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 37 | int mt7996_mcu_set_muru_fixed_rate_enable(struct mt7996_dev *dev, u8 action, int val); |
| 38 | int mt7996_mcu_set_muru_fixed_rate_parameter(struct mt7996_dev *dev, u8 action, void *para); |
| 39 | int mt7996_mcu_set_txbf_snd_info(struct mt7996_phy *phy, void *para); |
| 40 | +int mt7996_mcu_set_muru_cmd(struct mt7996_dev *dev, u16 action, int val); |
| 41 | +int mt7996_mcu_muru_set_prot_frame_thr(struct mt7996_dev *dev, u32 val); |
| 42 | +int mt7996_mcu_set_bypass_smthint(struct mt7996_phy *phy, u8 val); |
| 43 | #endif |
| 44 | |
| 45 | #ifdef CONFIG_NET_MEDIATEK_SOC_WED |
| 46 | diff --git a/mt7996/mtk_debugfs.c b/mt7996/mtk_debugfs.c |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 47 | index 51449df..1c4e2c9 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 48 | --- a/mt7996/mtk_debugfs.c |
| 49 | +++ b/mt7996/mtk_debugfs.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 50 | @@ -2911,6 +2911,127 @@ mt7996_sr_scene_cond_show(struct seq_file *file, void *data) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 51 | } |
| 52 | DEFINE_SHOW_ATTRIBUTE(mt7996_sr_scene_cond); |
| 53 | |
| 54 | +static int |
| 55 | +mt7996_starec_bf_read_set(void *data, u64 wlan_idx) |
| 56 | +{ |
| 57 | + struct mt7996_phy *phy = data; |
| 58 | + |
| 59 | + return mt7996_mcu_set_txbf_internal(phy, BF_STA_REC_READ, wlan_idx); |
| 60 | +} |
| 61 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_starec_bf_read, NULL, |
| 62 | + mt7996_starec_bf_read_set, "%lld\n"); |
| 63 | + |
| 64 | +static ssize_t |
| 65 | +mt7996_bf_txsnd_info_set(struct file *file, |
| 66 | + const char __user *user_buf, |
| 67 | + size_t count, loff_t *ppos) |
| 68 | +{ |
| 69 | + struct mt7996_phy *phy = file->private_data; |
| 70 | + char buf[40]; |
| 71 | + int ret; |
| 72 | + |
| 73 | + if (count >= sizeof(buf)) |
| 74 | + return -EINVAL; |
| 75 | + |
| 76 | + if (copy_from_user(buf, user_buf, count)) |
| 77 | + return -EFAULT; |
| 78 | + |
| 79 | + if (count && buf[count - 1] == '\n') |
| 80 | + buf[count - 1] = '\0'; |
| 81 | + else |
| 82 | + buf[count] = '\0'; |
| 83 | + |
| 84 | + ret = mt7996_mcu_set_txbf_snd_info(phy, buf); |
| 85 | + |
| 86 | + if (ret) return -EFAULT; |
| 87 | + |
| 88 | + return count; |
| 89 | +} |
| 90 | + |
| 91 | +static const struct file_operations fops_bf_txsnd_info = { |
| 92 | + .write = mt7996_bf_txsnd_info_set, |
| 93 | + .read = NULL, |
| 94 | + .open = simple_open, |
| 95 | + .llseek = default_llseek, |
| 96 | +}; |
| 97 | + |
| 98 | +static int |
| 99 | +mt7996_bf_fbk_rpt_set(void *data, u64 wlan_idx) |
| 100 | +{ |
| 101 | + struct mt7996_phy *phy = data; |
| 102 | + |
| 103 | + return mt7996_mcu_set_txbf_internal(phy, BF_FBRPT_DBG_INFO_READ, wlan_idx); |
| 104 | +} |
| 105 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_bf_fbk_rpt, NULL, |
| 106 | + mt7996_bf_fbk_rpt_set, "%lld\n"); |
| 107 | + |
| 108 | +static int |
| 109 | +mt7996_bf_pfmu_tag_read_set(void *data, u64 wlan_idx) |
| 110 | +{ |
| 111 | + struct mt7996_phy *phy = data; |
| 112 | + |
| 113 | + return mt7996_mcu_set_txbf_internal(phy, BF_PFMU_TAG_READ, wlan_idx); |
| 114 | +} |
| 115 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_bf_pfmu_tag_read, NULL, |
| 116 | + mt7996_bf_pfmu_tag_read_set, "%lld\n"); |
| 117 | + |
| 118 | +static int |
| 119 | +mt7996_muru_fixed_rate_set(void *data, u64 val) |
| 120 | +{ |
| 121 | + struct mt7996_dev *dev = data; |
| 122 | + |
| 123 | + return mt7996_mcu_set_muru_fixed_rate_enable(dev, UNI_CMD_MURU_FIXED_RATE_CTRL, |
| 124 | + val); |
| 125 | +} |
| 126 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_muru_fixed_rate_enable, NULL, |
| 127 | + mt7996_muru_fixed_rate_set, "%lld\n"); |
| 128 | + |
| 129 | +static ssize_t |
| 130 | +mt7996_muru_fixed_rate_parameter_set(struct file *file, |
| 131 | + const char __user *user_buf, |
| 132 | + size_t count, loff_t *ppos) |
| 133 | +{ |
| 134 | + struct mt7996_dev *dev = file->private_data; |
| 135 | + char buf[40]; |
| 136 | + int ret; |
| 137 | + |
| 138 | + if (count >= sizeof(buf)) |
| 139 | + return -EINVAL; |
| 140 | + |
| 141 | + if (copy_from_user(buf, user_buf, count)) |
| 142 | + return -EFAULT; |
| 143 | + |
| 144 | + if (count && buf[count - 1] == '\n') |
| 145 | + buf[count - 1] = '\0'; |
| 146 | + else |
| 147 | + buf[count] = '\0'; |
| 148 | + |
| 149 | + |
| 150 | + ret = mt7996_mcu_set_muru_fixed_rate_parameter(dev, UNI_CMD_MURU_FIXED_GROUP_RATE_CTRL, |
| 151 | + buf); |
| 152 | + |
| 153 | + if (ret) return -EFAULT; |
| 154 | + |
| 155 | + return count; |
| 156 | +} |
| 157 | + |
| 158 | +static const struct file_operations fops_muru_fixed_group_rate = { |
| 159 | + .write = mt7996_muru_fixed_rate_parameter_set, |
| 160 | + .read = NULL, |
| 161 | + .open = simple_open, |
| 162 | + .llseek = default_llseek, |
| 163 | +}; |
| 164 | + |
| 165 | +static int mt7996_muru_prot_thr_set(void *data, u64 val) |
| 166 | +{ |
| 167 | + struct mt7996_phy *phy = data; |
| 168 | + |
| 169 | + return mt7996_mcu_muru_set_prot_frame_thr(phy->dev, (u32)val); |
| 170 | +} |
| 171 | + |
| 172 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_muru_prot_thr, NULL, |
| 173 | + mt7996_muru_prot_thr_set, "%lld\n"); |
| 174 | + |
| 175 | int mt7996_mtk_init_debugfs(struct mt7996_phy *phy, struct dentry *dir) |
| 176 | { |
| 177 | struct mt7996_dev *dev = phy->dev; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 178 | @@ -3005,6 +3126,8 @@ int mt7996_mtk_init_debugfs(struct mt7996_phy *phy, struct dentry *dir) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 179 | debugfs_create_file("bf_fbk_rpt", 0600, dir, phy, &fops_bf_fbk_rpt); |
| 180 | debugfs_create_file("pfmu_tag_read", 0600, dir, phy, &fops_bf_pfmu_tag_read); |
| 181 | |
| 182 | + debugfs_create_file("muru_prot_thr", 0200, dir, phy, &fops_muru_prot_thr); |
| 183 | + |
| 184 | return 0; |
| 185 | } |
| 186 | |
| 187 | diff --git a/mt7996/mtk_mcu.c b/mt7996/mtk_mcu.c |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 188 | index 6b2cdad..6865062 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 189 | --- a/mt7996/mtk_mcu.c |
| 190 | +++ b/mt7996/mtk_mcu.c |
| 191 | @@ -904,4 +904,82 @@ error: |
| 192 | return -EINVAL; |
| 193 | } |
| 194 | |
| 195 | +/** |
| 196 | + * This function can be used to build the following commands |
| 197 | + * MURU_SUTX_CTRL (0x10) |
| 198 | + * SET_FORCE_MU (0x33) |
| 199 | + * SET_MUDL_ACK_POLICY (0xC8) |
| 200 | + * SET_TRIG_TYPE (0xC9) |
| 201 | + * SET_20M_DYN_ALGO (0xCA) |
| 202 | + * SET_CERT_MU_EDCA_OVERRIDE (0xCD) |
| 203 | + */ |
| 204 | +int mt7996_mcu_set_muru_cmd(struct mt7996_dev *dev, u16 action, int val) |
| 205 | +{ |
| 206 | + struct { |
| 207 | + u8 _rsv[4]; |
| 208 | + |
| 209 | + __le16 tag; |
| 210 | + __le16 len; |
| 211 | + |
| 212 | + u8 config; |
| 213 | + u8 rsv[3]; |
| 214 | + } __packed data = { |
| 215 | + .tag = cpu_to_le16(action), |
| 216 | + .len = cpu_to_le16(sizeof(data) - 4), |
| 217 | + .config = (u8) val, |
| 218 | + }; |
| 219 | + |
| 220 | + return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(MURU), &data, sizeof(data), |
| 221 | + false); |
| 222 | +} |
| 223 | + |
| 224 | +int mt7996_mcu_muru_set_prot_frame_thr(struct mt7996_dev *dev, u32 val) |
| 225 | +{ |
| 226 | + struct { |
| 227 | + u8 _rsv[4]; |
| 228 | + |
| 229 | + __le16 tag; |
| 230 | + __le16 len; |
| 231 | + |
| 232 | + __le32 prot_frame_thr; |
| 233 | + } __packed data = { |
| 234 | + .tag = cpu_to_le16(UNI_CMD_MURU_PROT_FRAME_THR), |
| 235 | + .len = cpu_to_le16(sizeof(data) - 4), |
| 236 | + .prot_frame_thr = cpu_to_le32(val), |
| 237 | + }; |
| 238 | + |
| 239 | + return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(MURU), &data, sizeof(data), |
| 240 | + false); |
| 241 | +} |
| 242 | + |
| 243 | +int mt7996_mcu_set_bypass_smthint(struct mt7996_phy *phy, u8 val) |
| 244 | +{ |
| 245 | +#define BF_PHY_SMTH_INT_BYPASS 0 |
| 246 | +#define BYPASS_VAL 1 |
| 247 | + struct mt7996_dev *dev = phy->dev; |
| 248 | + struct { |
| 249 | + u8 _rsv[4]; |
| 250 | + |
| 251 | + u16 tag; |
| 252 | + u16 len; |
| 253 | + |
| 254 | + u8 action; |
| 255 | + u8 band_idx; |
| 256 | + u8 smthintbypass; |
| 257 | + u8 __rsv2[5]; |
| 258 | + } __packed data = { |
| 259 | + .tag = cpu_to_le16(BF_CFG_PHY), |
| 260 | + .len = cpu_to_le16(sizeof(data) - 4), |
| 261 | + .action = BF_PHY_SMTH_INT_BYPASS, |
| 262 | + .band_idx = phy->mt76->band_idx, |
| 263 | + .smthintbypass = val, |
| 264 | + }; |
| 265 | + |
| 266 | + if (val != BYPASS_VAL) |
| 267 | + return -EINVAL; |
| 268 | + |
| 269 | + return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(BF), &data, sizeof(data), |
| 270 | + true); |
| 271 | +} |
| 272 | + |
| 273 | #endif |
| 274 | diff --git a/mt7996/mtk_mcu.h b/mt7996/mtk_mcu.h |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 275 | index 27d6a05..d9686eb 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 276 | --- a/mt7996/mtk_mcu.h |
| 277 | +++ b/mt7996/mtk_mcu.h |
| 278 | @@ -119,6 +119,20 @@ enum { |
| 279 | EDCCA_FCC = 1, |
| 280 | EDCCA_ETSI = 2, |
| 281 | EDCCA_JAPAN = 3 |
| 282 | +}; |
| 283 | + |
| 284 | +enum { |
| 285 | + UNI_CMD_MURU_SUTX_CTRL = 0x10, |
| 286 | + UNI_CMD_MURU_FIXED_RATE_CTRL, |
| 287 | + UNI_CMD_MURU_FIXED_GROUP_RATE_CTRL, |
| 288 | + UNI_CMD_MURU_SET_FORCE_MU = 0x33, |
| 289 | + UNI_CMD_MURU_MUNUAL_CONFIG = 0x64, |
| 290 | + UNI_CMD_MURU_SET_MUDL_ACK_POLICY = 0xC9, |
| 291 | + UNI_CMD_MURU_SET_TRIG_TYPE, |
| 292 | + UNI_CMD_MURU_SET_20M_DYN_ALGO, |
| 293 | + UNI_CMD_MURU_PROT_FRAME_THR = 0xCC, |
| 294 | + UNI_CMD_MURU_SET_CERT_MU_EDCA_OVERRIDE, |
| 295 | +}; |
| 296 | |
| 297 | struct bf_pfmu_tag { |
| 298 | __le16 tag; |
| 299 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 300 | 2.45.2 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 301 | |