developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 1 | From 4483bcc086666bb2eaf40774c30d35d60911524b Mon Sep 17 00:00:00 2001 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Fri, 31 May 2024 10:55:03 +0800 |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 135/223] mtk: mt76: mt7996: add debugfs knob to set agc |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 5 | |
| 6 | Add the following debugfs knob |
| 7 | - /sys/kernel/debug/ieee80211/phy0/mt76/mlo_agc_tx |
| 8 | - /sys/kernel/debug/ieee80211/phy0/mt76/mlo_agc_trig |
| 9 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 10 | Change-Id: I7e847be11b3083b6d776e7b00c6089dec3ad1a41 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 11 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 12 | --- |
| 13 | mt76_connac_mcu.h | 1 + |
| 14 | mt7996/mcu.h | 20 ++++++++ |
| 15 | mt7996/mt7996.h | 1 + |
| 16 | mt7996/mtk_debugfs_i.c | 103 +++++++++++++++++++++++++++++++++++++++++ |
| 17 | mt7996/mtk_mcu.c | 6 +++ |
| 18 | 5 files changed, 131 insertions(+) |
| 19 | |
| 20 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 21 | index 2daa09cc..73cf311a 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 22 | --- a/mt76_connac_mcu.h |
| 23 | +++ b/mt76_connac_mcu.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 24 | @@ -1317,6 +1317,7 @@ enum { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 25 | MCU_UNI_CMD_THERMAL_CAL = 0x4c, |
| 26 | MCU_UNI_CMD_RRO = 0x57, |
| 27 | MCU_UNI_CMD_OFFCH_SCAN_CTRL = 0x58, |
| 28 | + MCU_UNI_CMD_MLO = 0x59, |
| 29 | MCU_UNI_CMD_PER_STA_INFO = 0x6d, |
| 30 | MCU_UNI_CMD_ALL_STA_INFO = 0x6e, |
| 31 | MCU_UNI_CMD_ASSERT_DUMP = 0x6f, |
| 32 | diff --git a/mt7996/mcu.h b/mt7996/mcu.h |
| 33 | index c39dcc3c..389aab63 100644 |
| 34 | --- a/mt7996/mcu.h |
| 35 | +++ b/mt7996/mcu.h |
| 36 | @@ -1157,6 +1157,26 @@ enum { |
| 37 | UNI_CMD_SCS_ENABLE, |
| 38 | }; |
| 39 | |
| 40 | +enum { |
| 41 | + UNI_CMD_MLO_AGC_TX = 4, |
| 42 | + UNI_CMD_MLO_AGC_TRIG = 5, |
| 43 | +}; |
| 44 | + |
| 45 | +struct mt7996_mlo_agc_set { |
| 46 | + u8 rsv[4]; |
| 47 | + |
| 48 | + __le16 tag; |
| 49 | + __le16 len; |
| 50 | + |
| 51 | + u8 mld_id; |
| 52 | + u8 link_id; |
| 53 | + u8 ac; |
| 54 | + u8 disp_pol; |
| 55 | + u8 ratio; |
| 56 | + u8 order; |
| 57 | + __le16 mgf; |
| 58 | +} __packed; |
| 59 | + |
| 60 | #define MT7996_PATCH_SEC GENMASK(31, 24) |
| 61 | #define MT7996_PATCH_SCRAMBLE_KEY GENMASK(15, 8) |
| 62 | #define MT7996_PATCH_AES_KEY GENMASK(7, 0) |
| 63 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 64 | index 8af3c400..7bb17126 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 65 | --- a/mt7996/mt7996.h |
| 66 | +++ b/mt7996/mt7996.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 67 | @@ -1328,6 +1328,7 @@ void mt7996_dump_bmac_txd_info(struct seq_file *s, struct mt7996_dev *dev, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 68 | __le32 *txd, bool is_hif_txd, bool dump_txp); |
| 69 | int mt7996_mtk_init_dev_debugfs_internal(struct mt7996_phy *phy, struct dentry *dir); |
| 70 | int mt7996_mtk_init_band_debugfs_internal(struct mt7996_phy *phy, struct dentry *dir); |
| 71 | +int mt7996_mcu_mlo_agc(struct mt7996_dev *dev, const void *data, int len); |
| 72 | #endif |
| 73 | |
| 74 | #ifdef CONFIG_NET_MEDIATEK_SOC_WED |
| 75 | diff --git a/mt7996/mtk_debugfs_i.c b/mt7996/mtk_debugfs_i.c |
| 76 | index 839c3e31..852d1b12 100644 |
| 77 | --- a/mt7996/mtk_debugfs_i.c |
| 78 | +++ b/mt7996/mtk_debugfs_i.c |
| 79 | @@ -774,6 +774,106 @@ mt7996_agg_table_show(struct seq_file *s, void *data) |
| 80 | } |
| 81 | DEFINE_SHOW_ATTRIBUTE(mt7996_agg_table); |
| 82 | |
| 83 | +static ssize_t mt7996_mlo_agc_tx_set(struct file *file, |
| 84 | + const char __user *user_buf, |
| 85 | + size_t count, loff_t *ppos) |
| 86 | +{ |
| 87 | + struct mt7996_dev *dev = file->private_data; |
| 88 | + struct mt7996_mlo_agc_set req; |
| 89 | + char buf[100]; |
| 90 | + int ret; |
| 91 | + u16 mgf; |
| 92 | + |
| 93 | + memset(&req, 0, sizeof(req)); |
| 94 | + |
| 95 | + if (count >= sizeof(buf)) |
| 96 | + return -EINVAL; |
| 97 | + |
| 98 | + if (copy_from_user(buf, user_buf, count)) |
| 99 | + return -EFAULT; |
| 100 | + |
| 101 | + if (count && buf[count - 1] == '\n') |
| 102 | + buf[count - 1] = '\0'; |
| 103 | + else |
| 104 | + buf[count] = '\0'; |
| 105 | + |
| 106 | + if (sscanf(buf, "%hhu %hhu %hhu %hhu %hu %hhu %hhu", |
| 107 | + &req.mld_id, &req.link_id, &req.ac, &req.disp_pol, |
| 108 | + &mgf, &req.ratio, &req.order) != 7) { |
| 109 | + dev_warn(dev->mt76.dev, |
| 110 | + "format: [MldRecIdx] [Link] [Ac] [DispPol] [MGF] [Ratio] [Order]\n"); |
| 111 | + goto out; |
| 112 | + } |
| 113 | + |
| 114 | + req.tag = cpu_to_le16(UNI_CMD_MLO_AGC_TX); |
| 115 | + req.len = cpu_to_le16(sizeof(req) - 4); |
| 116 | + req.mgf = cpu_to_le16(mgf); |
| 117 | + |
| 118 | + ret = mt7996_mcu_mlo_agc(dev, &req, sizeof(req)); |
| 119 | + if (ret) |
| 120 | + return -EFAULT; |
| 121 | + |
| 122 | +out: |
| 123 | + return count; |
| 124 | +} |
| 125 | + |
| 126 | +static const struct file_operations fops_mlo_agc_tx = { |
| 127 | + .write = mt7996_mlo_agc_tx_set, |
| 128 | + .open = simple_open, |
| 129 | + .owner = THIS_MODULE, |
| 130 | + .llseek = default_llseek, |
| 131 | +}; |
| 132 | + |
| 133 | +static ssize_t mt7996_mlo_agc_trig_set(struct file *file, |
| 134 | + const char __user *user_buf, |
| 135 | + size_t count, loff_t *ppos) |
| 136 | +{ |
| 137 | + struct mt7996_dev *dev = file->private_data; |
| 138 | + struct mt7996_mlo_agc_set req; |
| 139 | + char buf[100]; |
| 140 | + int ret; |
| 141 | + u16 mgf; |
| 142 | + |
| 143 | + memset(&req, 0, sizeof(req)); |
| 144 | + |
| 145 | + if (count >= sizeof(buf)) |
| 146 | + return -EINVAL; |
| 147 | + |
| 148 | + if (copy_from_user(buf, user_buf, count)) |
| 149 | + return -EFAULT; |
| 150 | + |
| 151 | + if (count && buf[count - 1] == '\n') |
| 152 | + buf[count - 1] = '\0'; |
| 153 | + else |
| 154 | + buf[count] = '\0'; |
| 155 | + |
| 156 | + if (sscanf(buf, "%hhu %hhu %hhu %hhu %hu %hhu", |
| 157 | + &req.mld_id, &req.link_id, &req.ac, &req.disp_pol, |
| 158 | + &mgf, &req.ratio) != 6) { |
| 159 | + dev_warn(dev->mt76.dev, |
| 160 | + "format: [MldRecIdx] [Link] [Ac] [DispPol] [MGF] [Ratio]\n"); |
| 161 | + goto out; |
| 162 | + } |
| 163 | + |
| 164 | + req.tag = cpu_to_le16(UNI_CMD_MLO_AGC_TRIG); |
| 165 | + req.len = cpu_to_le16(sizeof(req) - 4); |
| 166 | + req.mgf = cpu_to_le16(mgf); |
| 167 | + |
| 168 | + ret = mt7996_mcu_mlo_agc(dev, &req, sizeof(req)); |
| 169 | + if (ret) |
| 170 | + return -EFAULT; |
| 171 | + |
| 172 | +out: |
| 173 | + return count; |
| 174 | +} |
| 175 | + |
| 176 | +static const struct file_operations fops_mlo_agc_trig = { |
| 177 | + .write = mt7996_mlo_agc_trig_set, |
| 178 | + .open = simple_open, |
| 179 | + .owner = THIS_MODULE, |
| 180 | + .llseek = default_llseek, |
| 181 | +}; |
| 182 | + |
| 183 | int mt7996_mtk_init_dev_debugfs_internal(struct mt7996_phy *phy, struct dentry *dir) |
| 184 | { |
| 185 | struct mt7996_dev *dev = phy->dev; |
| 186 | @@ -796,6 +896,9 @@ int mt7996_mtk_init_dev_debugfs_internal(struct mt7996_phy *phy, struct dentry * |
| 187 | |
| 188 | /* MLO related Table */ |
| 189 | debugfs_create_file("mat_table", 0400, dir, dev, &mt7996_mat_table_fops); |
| 190 | + debugfs_create_file("mlo_agc_tx", 0200, dir, dev, &fops_mlo_agc_tx); |
| 191 | + debugfs_create_file("mlo_agc_trig", 0200, dir, dev, &fops_mlo_agc_trig); |
| 192 | + |
| 193 | return 0; |
| 194 | } |
| 195 | |
| 196 | diff --git a/mt7996/mtk_mcu.c b/mt7996/mtk_mcu.c |
| 197 | index 809181e0..82e3f721 100644 |
| 198 | --- a/mt7996/mtk_mcu.c |
| 199 | +++ b/mt7996/mtk_mcu.c |
| 200 | @@ -1364,4 +1364,10 @@ int mt7996_mcu_thermal_debug(struct mt7996_dev *dev, u8 mode, u8 action) |
| 201 | return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(THERMAL_CAL), &req, |
| 202 | sizeof(req), true); |
| 203 | } |
| 204 | + |
| 205 | +int mt7996_mcu_mlo_agc(struct mt7996_dev *dev, const void *data, int len) |
| 206 | +{ |
| 207 | + return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(MLO), data, |
| 208 | + len, true); |
| 209 | +} |
| 210 | #endif |
| 211 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 212 | 2.45.2 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 213 | |