developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 1 | From a238368ceaa2abad2229a180173f54bdb2976d5f Mon Sep 17 00:00:00 2001 |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
| 3 | Date: Mon, 5 Dec 2022 18:21:51 +0800 |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 1027/1031] wifi: mt76: mt7915: add bf backoff limit table |
| 5 | support |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 6 | |
| 7 | Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> |
| 8 | --- |
| 9 | eeprom.c | 25 +++++++++- |
| 10 | mt76.h | 8 +++ |
| 11 | mt7915/debugfs.c | 73 ++++++++++++++++++++++++++-- |
| 12 | mt7915/mcu.c | 124 +++++++++++++++++++++++++++++++++++------------ |
| 13 | mt7915/mcu.h | 6 +++ |
| 14 | mt7915/mt7915.h | 4 +- |
| 15 | 6 files changed, 203 insertions(+), 37 deletions(-) |
| 16 | |
| 17 | diff --git a/eeprom.c b/eeprom.c |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 18 | index 412740f0..b2df0f44 100644 |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 19 | --- a/eeprom.c |
| 20 | +++ b/eeprom.c |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 21 | @@ -317,7 +317,8 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy, |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 22 | if (!mcs_rates) |
| 23 | mcs_rates = 10; |
| 24 | |
| 25 | - memset(dest, target_power, sizeof(*dest)); |
| 26 | + memset(dest, target_power, sizeof(*dest) - sizeof(dest->path)); |
| 27 | + memset(&dest->path, 0, sizeof(dest->path)); |
| 28 | |
| 29 | if (!IS_ENABLED(CONFIG_OF)) |
| 30 | return target_power; |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 31 | @@ -370,6 +371,28 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy, |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 32 | ARRAY_SIZE(dest->ru), val, len, |
| 33 | target_power, txs_delta, &max_power); |
| 34 | |
| 35 | + val = mt76_get_of_array(np, "paths-cck", &len, ARRAY_SIZE(dest->path.cck)); |
| 36 | + mt76_apply_array_limit(dest->path.cck, ARRAY_SIZE(dest->path.cck), val, |
| 37 | + target_power, txs_delta, &max_power); |
| 38 | + |
| 39 | + val = mt76_get_of_array(np, "paths-ofdm", &len, ARRAY_SIZE(dest->path.ofdm)); |
| 40 | + mt76_apply_array_limit(dest->path.ofdm, ARRAY_SIZE(dest->path.ofdm), val, |
| 41 | + target_power, txs_delta, &max_power); |
| 42 | + |
| 43 | + val = mt76_get_of_array(np, "paths-ofdm-bf", &len, ARRAY_SIZE(dest->path.ofdm_bf)); |
| 44 | + mt76_apply_array_limit(dest->path.ofdm_bf, ARRAY_SIZE(dest->path.ofdm_bf), val, |
| 45 | + target_power, txs_delta, &max_power); |
| 46 | + |
| 47 | + val = mt76_get_of_array(np, "paths-ru", &len, ARRAY_SIZE(dest->path.ru[0]) + 1); |
| 48 | + mt76_apply_multi_array_limit(dest->path.ru[0], ARRAY_SIZE(dest->path.ru[0]), |
| 49 | + ARRAY_SIZE(dest->path.ru), val, len, |
| 50 | + target_power, txs_delta, &max_power); |
| 51 | + |
| 52 | + val = mt76_get_of_array(np, "paths-ru-bf", &len, ARRAY_SIZE(dest->path.ru_bf[0]) + 1); |
| 53 | + mt76_apply_multi_array_limit(dest->path.ru_bf[0], ARRAY_SIZE(dest->path.ru_bf[0]), |
| 54 | + ARRAY_SIZE(dest->path.ru_bf), val, len, |
| 55 | + target_power, txs_delta, &max_power); |
| 56 | + |
| 57 | return max_power; |
| 58 | } |
| 59 | EXPORT_SYMBOL_GPL(mt76_get_rate_power_limits); |
| 60 | diff --git a/mt76.h b/mt76.h |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 61 | index 68b54579..99a853a9 100644 |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 62 | --- a/mt76.h |
| 63 | +++ b/mt76.h |
developer | f8871e8 | 2023-03-08 17:22:32 +0800 | [diff] [blame] | 64 | @@ -913,6 +913,14 @@ struct mt76_power_limits { |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 65 | s8 ofdm[8]; |
| 66 | s8 mcs[4][10]; |
| 67 | s8 ru[7][12]; |
| 68 | + |
| 69 | + struct { |
| 70 | + s8 cck[4]; |
| 71 | + s8 ofdm[4]; |
| 72 | + s8 ofdm_bf[4]; |
| 73 | + s8 ru[7][10]; |
| 74 | + s8 ru_bf[7][10]; |
| 75 | + } path; |
| 76 | }; |
| 77 | |
| 78 | struct mt76_ethtool_worker_info { |
| 79 | diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 80 | index eb149104..129a15c0 100644 |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 81 | --- a/mt7915/debugfs.c |
| 82 | +++ b/mt7915/debugfs.c |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 83 | @@ -1027,7 +1027,7 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf, |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 84 | if (!buf) |
| 85 | return -ENOMEM; |
| 86 | |
| 87 | - ret = mt7915_mcu_get_txpower_sku(phy, txpwr, sizeof(txpwr)); |
| 88 | + ret = mt7915_mcu_get_txpower_sku(phy, txpwr, sizeof(txpwr), TX_POWER_INFO_RATE); |
| 89 | if (ret) |
| 90 | goto out; |
| 91 | |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 92 | @@ -1137,7 +1137,7 @@ mt7915_rate_txpower_set(struct file *file, const char __user *user_buf, |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 93 | |
| 94 | mutex_lock(&dev->mt76.mutex); |
| 95 | ret = mt7915_mcu_get_txpower_sku(phy, req.txpower_sku, |
| 96 | - sizeof(req.txpower_sku)); |
| 97 | + sizeof(req.txpower_sku), TX_POWER_INFO_RATE); |
| 98 | if (ret) |
| 99 | goto out; |
| 100 | |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 101 | @@ -1179,7 +1179,7 @@ out: |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 102 | return ret ? ret : count; |
| 103 | } |
| 104 | |
| 105 | -static const struct file_operations mt7915_rate_txpower_fops = { |
| 106 | +static const struct file_operations mt7915_txpower_fops = { |
| 107 | .write = mt7915_rate_txpower_set, |
| 108 | .read = mt7915_rate_txpower_get, |
| 109 | .open = simple_open, |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 110 | @@ -1187,6 +1187,69 @@ static const struct file_operations mt7915_rate_txpower_fops = { |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 111 | .llseek = default_llseek, |
| 112 | }; |
| 113 | |
| 114 | +static int |
| 115 | +mt7915_path_txpower_show(struct seq_file *file) |
| 116 | +{ |
| 117 | + struct mt7915_phy *phy = file->private; |
| 118 | + s8 txpower[MT7915_SKU_PATH_NUM], *buf = txpower; |
| 119 | + int ret; |
| 120 | + |
| 121 | +#define PATH_POWER_SHOW(_name, _len, _skip) do { \ |
| 122 | + if (_skip) { \ |
| 123 | + buf -= 1; \ |
| 124 | + *buf = 0; \ |
| 125 | + } \ |
| 126 | + mt76_seq_puts_array(file, _name, buf, _len); \ |
| 127 | + buf += _len; \ |
| 128 | + } while(0) |
| 129 | + |
| 130 | + seq_printf(file, "\n%*c", 11, ' '); |
| 131 | + seq_printf(file, "1T1S/2T1S/3T1S/4T1S/2T2S/3T2S/4T2S/3T3S/4T3S/4T4S\n"); |
| 132 | + ret = mt7915_mcu_get_txpower_sku(phy, txpower, sizeof(txpower), |
| 133 | + TX_POWER_INFO_PATH); |
| 134 | + if (ret) |
| 135 | + return ret; |
| 136 | + |
| 137 | + PATH_POWER_SHOW("CCK", 4, 0); |
| 138 | + PATH_POWER_SHOW("OFDM", 4, 0); |
| 139 | + PATH_POWER_SHOW("BF-OFDM", 4, 1); |
| 140 | + |
| 141 | + PATH_POWER_SHOW("HT20", 10, 0); |
| 142 | + PATH_POWER_SHOW("BF-HT20", 10, 1); |
| 143 | + PATH_POWER_SHOW("HT40", 10, 0); |
| 144 | + PATH_POWER_SHOW("BF-HT40", 10, 1); |
| 145 | + |
| 146 | + PATH_POWER_SHOW("RU242", 10, 0); |
| 147 | + PATH_POWER_SHOW("BF-RU242", 10, 1); |
| 148 | + PATH_POWER_SHOW("RU484", 10, 0); |
| 149 | + PATH_POWER_SHOW("BF-RU484", 10, 1); |
| 150 | + PATH_POWER_SHOW("RU996", 10, 0); |
| 151 | + PATH_POWER_SHOW("BF-RU996", 10, 1); |
| 152 | + PATH_POWER_SHOW("RU2x996", 10, 0); |
| 153 | + PATH_POWER_SHOW("BF-RU2x996", 10, 1); |
| 154 | + PATH_POWER_SHOW("RU26", 10, 0); |
| 155 | + PATH_POWER_SHOW("BF-RU26", 10, 0); |
| 156 | + PATH_POWER_SHOW("RU52", 10, 0); |
| 157 | + PATH_POWER_SHOW("BF-RU52", 10, 0); |
| 158 | + PATH_POWER_SHOW("RU106", 10, 0); |
| 159 | + PATH_POWER_SHOW("BF-RU106", 10, 0); |
| 160 | +#undef PATH_POWER_SHOW |
| 161 | + |
| 162 | + return 0; |
| 163 | +} |
| 164 | + |
| 165 | +static int |
| 166 | +mt7915_txpower_path_show(struct seq_file *file, void *data) |
| 167 | +{ |
| 168 | + struct mt7915_phy *phy = file->private; |
| 169 | + |
| 170 | + seq_printf(file, "\nBand %d\n", phy != &phy->dev->phy); |
| 171 | + |
| 172 | + return mt7915_path_txpower_show(file); |
| 173 | +} |
| 174 | + |
| 175 | +DEFINE_SHOW_ATTRIBUTE(mt7915_txpower_path); |
| 176 | + |
| 177 | static int |
| 178 | mt7915_twt_stats(struct seq_file *s, void *data) |
| 179 | { |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 180 | @@ -1273,7 +1336,9 @@ int mt7915_init_debugfs(struct mt7915_phy *phy) |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 181 | debugfs_create_file("implicit_txbf", 0600, dir, dev, |
| 182 | &fops_implicit_txbf); |
| 183 | debugfs_create_file("txpower_sku", 0400, dir, phy, |
| 184 | - &mt7915_rate_txpower_fops); |
| 185 | + &mt7915_txpower_fops); |
| 186 | + debugfs_create_file("txpower_path", 0400, dir, phy, |
| 187 | + &mt7915_txpower_path_fops); |
| 188 | debugfs_create_devm_seqfile(dev->mt76.dev, "twt_stats", dir, |
| 189 | mt7915_twt_stats); |
| 190 | debugfs_create_file("rf_regval", 0600, dir, dev, &fops_rf_regval); |
| 191 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 192 | index eced0325..28e29011 100644 |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 193 | --- a/mt7915/mcu.c |
| 194 | +++ b/mt7915/mcu.c |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 195 | @@ -3344,7 +3344,8 @@ int mt7915_mcu_set_txpower_frame(struct mt7915_phy *phy, |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 196 | int ret; |
| 197 | s8 txpower_sku[MT7915_SKU_RATE_NUM]; |
| 198 | |
| 199 | - ret = mt7915_mcu_get_txpower_sku(phy, txpower_sku, sizeof(txpower_sku)); |
| 200 | + ret = mt7915_mcu_get_txpower_sku(phy, txpower_sku, sizeof(txpower_sku), |
| 201 | + TX_POWER_INFO_RATE); |
| 202 | if (ret) |
| 203 | return ret; |
| 204 | |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 205 | @@ -3386,51 +3387,98 @@ int mt7915_mcu_set_txpower_frame(struct mt7915_phy *phy, |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 206 | |
| 207 | int mt7915_mcu_set_txpower_sku(struct mt7915_phy *phy) |
| 208 | { |
| 209 | +#define TX_POWER_LIMIT_TABLE_RATE 0 |
| 210 | +#define TX_POWER_LIMIT_TABLE_PATH 1 |
| 211 | struct mt7915_dev *dev = phy->dev; |
| 212 | struct mt76_phy *mphy = phy->mt76; |
| 213 | struct ieee80211_hw *hw = mphy->hw; |
| 214 | - struct mt7915_mcu_txpower_sku req = { |
| 215 | + struct mt7915_sku_val { |
| 216 | + u8 format_id; |
| 217 | + u8 limit_type; |
| 218 | + u8 band_idx; |
| 219 | + } __packed hdr = { |
| 220 | .format_id = TX_POWER_LIMIT_TABLE, |
| 221 | + .limit_type = TX_POWER_LIMIT_TABLE_RATE, |
| 222 | .band_idx = phy->mt76->band_idx, |
| 223 | }; |
| 224 | - struct mt76_power_limits limits_array; |
| 225 | - s8 *la = (s8 *)&limits_array; |
| 226 | - int i, idx; |
| 227 | - int tx_power; |
| 228 | + int i, ret, tx_power; |
| 229 | + const u8 *len = mt7915_sku_group_len; |
| 230 | + struct mt76_power_limits la = {}; |
| 231 | + struct sk_buff *skb; |
| 232 | |
| 233 | tx_power = mt7915_get_power_bound(phy, hw->conf.power_level); |
| 234 | tx_power = mt76_get_rate_power_limits(mphy, mphy->chandef.chan, |
| 235 | - &limits_array, tx_power); |
| 236 | + &la, tx_power); |
| 237 | mphy->txpower_cur = tx_power; |
| 238 | |
| 239 | - for (i = 0, idx = 0; i < ARRAY_SIZE(mt7915_sku_group_len); i++) { |
| 240 | - u8 mcs_num, len = mt7915_sku_group_len[i]; |
| 241 | - int j; |
| 242 | + skb = mt76_mcu_msg_alloc(&dev->mt76, NULL, |
| 243 | + sizeof(hdr) + MT7915_SKU_RATE_NUM); |
| 244 | + if (!skb) |
| 245 | + return -ENOMEM; |
| 246 | |
| 247 | - if (i >= SKU_HT_BW20 && i <= SKU_VHT_BW160) { |
| 248 | - mcs_num = 10; |
| 249 | + skb_put_data(skb, &hdr, sizeof(hdr)); |
| 250 | + skb_put_data(skb, &la.cck, len[SKU_CCK] + len[SKU_OFDM]); |
| 251 | + skb_put_data(skb, &la.mcs[0], len[SKU_HT_BW20]); |
| 252 | + skb_put_data(skb, &la.mcs[1], len[SKU_HT_BW40]); |
| 253 | |
| 254 | - if (i == SKU_HT_BW20 || i == SKU_VHT_BW20) |
| 255 | - la = (s8 *)&limits_array + 12; |
| 256 | - } else { |
| 257 | - mcs_num = len; |
| 258 | - } |
| 259 | + /* vht */ |
| 260 | + for (i = 0; i < 4; i++) { |
| 261 | + skb_put_data(skb, &la.mcs[i], sizeof(la.mcs[i])); |
| 262 | + skb_put_zero(skb, 2); /* padding */ |
| 263 | + } |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 264 | |
| 265 | - for (j = 0; j < min_t(u8, mcs_num, len); j++) |
| 266 | - req.txpower_sku[idx + j] = la[j]; |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 267 | + /* he */ |
| 268 | + skb_put_data(skb, &la.ru[0], sizeof(la.ru)); |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 269 | |
| 270 | - la += mcs_num; |
| 271 | - idx += len; |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 272 | + ret = mt76_mcu_skb_send_msg(&dev->mt76, skb, |
| 273 | + MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), true); |
| 274 | + if (ret) |
| 275 | + return ret; |
| 276 | + |
| 277 | + /* only set per-path power table when it's configured */ |
| 278 | + if (!la.path.ofdm[0]) |
| 279 | + return 0; |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 280 | + |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 281 | + skb = mt76_mcu_msg_alloc(&dev->mt76, NULL, |
| 282 | + sizeof(hdr) + MT7915_SKU_PATH_NUM); |
| 283 | + if (!skb) |
| 284 | + return -ENOMEM; |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 285 | + |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 286 | + hdr.limit_type = TX_POWER_LIMIT_TABLE_PATH; |
| 287 | + skb_put_data(skb, &hdr, sizeof(hdr)); |
| 288 | + skb_put_data(skb, &la.path.cck, sizeof(la.path.cck)); |
| 289 | + skb_put_data(skb, &la.path.ofdm, sizeof(la.path.ofdm)); |
| 290 | + skb_put_data(skb, &la.path.ofdm_bf[1], sizeof(la.path.ofdm_bf) - 1); |
| 291 | + |
| 292 | + /* HT20 and HT40 */ |
| 293 | + skb_put_data(skb, &la.path.ru[0], sizeof(la.path.ru[0])); |
| 294 | + skb_put_data(skb, &la.path.ru_bf[0][1], sizeof(la.path.ru_bf[0]) - 1); |
| 295 | + skb_put_data(skb, &la.path.ru[1], sizeof(la.path.ru[1])); |
| 296 | + skb_put_data(skb, &la.path.ru_bf[1][1], sizeof(la.path.ru_bf[1]) - 1); |
| 297 | + |
| 298 | + /* start from non-bf and bf fields of |
| 299 | + * BW20/RU242, BW40/RU484, BW80/RU996, BW160/RU2x996, |
| 300 | + * RU26, RU52, and RU106 |
| 301 | + */ |
| 302 | + for (i = 7; i < 21; i++) { |
| 303 | + bool bf = !(i % 2); |
| 304 | + u8 idx = (i - 7) / 2; |
| 305 | + s8 *buf = bf ? la.path.ru_bf[idx] : la.path.ru[idx]; |
| 306 | + |
| 307 | + /* The non-bf fields of RU26 to RU106 are special cases */ |
| 308 | + if (bf && i < 15) |
| 309 | + skb_put_data(skb, buf + 1, 9); |
| 310 | + else |
| 311 | + skb_put_data(skb, buf, 10); |
| 312 | } |
| 313 | |
| 314 | - return mt76_mcu_send_msg(&dev->mt76, |
| 315 | - MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req, |
| 316 | - sizeof(req), true); |
| 317 | + return mt76_mcu_skb_send_msg(&dev->mt76, skb, |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 318 | + MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), true); |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | -int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len) |
| 322 | +int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len, |
| 323 | + u8 category) |
| 324 | { |
| 325 | -#define RATE_POWER_INFO 2 |
| 326 | struct mt7915_dev *dev = phy->dev; |
| 327 | struct { |
| 328 | u8 format_id; |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 329 | @@ -3439,10 +3487,9 @@ int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len) |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 330 | u8 _rsv; |
| 331 | } __packed req = { |
| 332 | .format_id = TX_POWER_LIMIT_INFO, |
| 333 | - .category = RATE_POWER_INFO, |
| 334 | + .category = category, |
| 335 | .band_idx = phy->mt76->band_idx, |
| 336 | }; |
| 337 | - s8 txpower_sku[MT7915_SKU_RATE_NUM][2]; |
| 338 | struct sk_buff *skb; |
| 339 | int ret, i; |
| 340 | |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 341 | @@ -3452,9 +3499,15 @@ int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len) |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 342 | if (ret) |
| 343 | return ret; |
| 344 | |
| 345 | - memcpy(txpower_sku, skb->data + 4, sizeof(txpower_sku)); |
| 346 | - for (i = 0; i < len; i++) |
| 347 | - txpower[i] = txpower_sku[i][req.band_idx]; |
| 348 | + if (category == TX_POWER_INFO_RATE) { |
| 349 | + s8 res[MT7915_SKU_RATE_NUM][2]; |
| 350 | + |
| 351 | + memcpy(res, skb->data + 4, sizeof(res)); |
| 352 | + for (i = 0; i < len; i++) |
| 353 | + txpower[i] = res[i][req.band_idx]; |
| 354 | + } else if (category == TX_POWER_INFO_PATH) { |
| 355 | + memcpy(txpower, skb->data + 4, len); |
| 356 | + } |
| 357 | |
| 358 | dev_kfree_skb(skb); |
| 359 | |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 360 | @@ -3496,9 +3549,18 @@ int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable) |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 361 | .band_idx = phy->mt76->band_idx, |
| 362 | .sku_enable = enable, |
| 363 | }; |
| 364 | + int ret; |
| 365 | + |
| 366 | + ret = mt76_mcu_send_msg(&dev->mt76, |
| 367 | + MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req, |
| 368 | + sizeof(req), true); |
| 369 | + if (ret) |
| 370 | + return ret; |
| 371 | |
| 372 | pr_info("%s: enable = %d\n", __func__, enable); |
| 373 | |
| 374 | + req.format_id = TX_POWER_LIMIT_PATH_ENABLE; |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 375 | + |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 376 | return mt76_mcu_send_msg(&dev->mt76, |
| 377 | MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req, |
| 378 | sizeof(req), true); |
| 379 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 380 | index 9f9436cd..10284065 100644 |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 381 | --- a/mt7915/mcu.h |
| 382 | +++ b/mt7915/mcu.h |
developer | f3f5d9b | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 383 | @@ -447,12 +447,18 @@ enum { |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 384 | |
| 385 | enum { |
| 386 | TX_POWER_LIMIT_ENABLE, |
| 387 | + TX_POWER_LIMIT_PATH_ENABLE = 0x3, |
| 388 | TX_POWER_LIMIT_TABLE = 0x4, |
| 389 | TX_POWER_LIMIT_INFO = 0x7, |
| 390 | TX_POWER_LIMIT_FRAME = 0x11, |
| 391 | TX_POWER_LIMIT_FRAME_MIN = 0x12, |
| 392 | }; |
| 393 | |
| 394 | +enum { |
| 395 | + TX_POWER_INFO_PATH = 1, |
| 396 | + TX_POWER_INFO_RATE, |
| 397 | +}; |
| 398 | + |
| 399 | enum { |
| 400 | SPR_ENABLE = 0x1, |
| 401 | SPR_ENABLE_SD = 0x3, |
| 402 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 403 | index 5999134d..4a5208e2 100644 |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 404 | --- a/mt7915/mt7915.h |
| 405 | +++ b/mt7915/mt7915.h |
developer | f3f5d9b | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 406 | @@ -65,6 +65,7 @@ |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 407 | #define MT7915_CDEV_THROTTLE_MAX 99 |
| 408 | |
| 409 | #define MT7915_SKU_RATE_NUM 161 |
| 410 | +#define MT7915_SKU_PATH_NUM 185 |
| 411 | |
| 412 | #define MT7915_MAX_TWT_AGRT 16 |
| 413 | #define MT7915_MAX_STA_TWT_AGRT 8 |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 414 | @@ -624,7 +625,8 @@ int mt7915_mcu_set_test_param(struct mt7915_dev *dev, u8 param, bool test_mode, |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 415 | int mt7915_mcu_set_ser(struct mt7915_dev *dev, u8 action, u8 set, u8 band); |
| 416 | int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable); |
| 417 | int mt7915_mcu_set_txpower_sku(struct mt7915_phy *phy); |
| 418 | -int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len); |
| 419 | +int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len, |
| 420 | + u8 category); |
| 421 | int mt7915_mcu_set_txpower_frame_min(struct mt7915_phy *phy, s8 txpower); |
| 422 | int mt7915_mcu_set_txpower_frame(struct mt7915_phy *phy, |
| 423 | struct ieee80211_vif *vif, |
| 424 | -- |
developer | 78848c6 | 2023-04-06 13:44:00 +0800 | [diff] [blame^] | 425 | 2.39.0 |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 426 | |