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