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