| From a47fd43195b6f5b1b9c0b29e1bad986818d57404 Mon Sep 17 00:00:00 2001 |
| From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| Date: Tue, 11 Jul 2023 17:06:04 +0800 |
| Subject: [PATCH] wifi: mt76: mt7915: add txpower info dump support |
| |
| Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| --- |
| mt7915/debugfs.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ |
| mt7915/mcu.c | 2 ++ |
| mt7915/mcu.h | 3 +- |
| 3 files changed, 91 insertions(+), 1 deletion(-) |
| |
| diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c |
| index 99ce0a9..592fc08 100644 |
| --- a/mt7915/debugfs.c |
| +++ b/mt7915/debugfs.c |
| @@ -1254,6 +1254,91 @@ mt7915_txpower_path_show(struct seq_file *file, void *data) |
| |
| DEFINE_SHOW_ATTRIBUTE(mt7915_txpower_path); |
| |
| +static int |
| +mt7915_txpower_info_show(struct seq_file *file, void *data) |
| +{ |
| + struct mt7915_phy *phy = file->private; |
| + struct { |
| + u8 category; |
| + u8 rsv1; |
| + |
| + /* basic info */ |
| + u8 band_idx; |
| + u8 band; |
| + |
| + /* board type info */ |
| + bool is_epa; |
| + bool is_elna; |
| + |
| + /* power percentage info */ |
| + bool percentage_ctrl_enable; |
| + s8 power_drop_level; |
| + |
| + /* frond-end loss TX info */ |
| + s8 front_end_loss_tx[4]; |
| + |
| + /* frond-end loss RX info */ |
| + s8 front_end_loss_rx[4]; |
| + |
| + /* thermal info */ |
| + bool thermal_compensate_enable; |
| + s8 thermal_compensate_value; |
| + u8 rsv2; |
| + |
| + /* TX power max/min limit info */ |
| + s8 max_power_bound; |
| + s8 min_power_bound; |
| + |
| + /* power limit info */ |
| + bool sku_enable; |
| + bool bf_backoff_enable; |
| + |
| + /* MU TX power info */ |
| + bool mu_tx_power_manual_enable; |
| + s8 mu_tx_power_auto; |
| + s8 mu_tx_power_manual; |
| + u8 rsv3; |
| + } __packed basic_info = {}; |
| + int ret; |
| + |
| + ret = mt7915_mcu_get_txpower_sku(phy, (s8 *)&basic_info, sizeof(basic_info), |
| + TX_POWER_INFO_BASIC); |
| + if (ret || basic_info.category != TX_POWER_INFO_BASIC) |
| + goto out; |
| + |
| + seq_puts(file, "======================== BASIC INFO ========================\n"); |
| + seq_printf(file, " Band Index: %d, Channel Band: %d\n", |
| + basic_info.band_idx, basic_info.band); |
| + seq_printf(file, " PA Type: %s\n", basic_info.is_epa ? "ePA" : "iPA"); |
| + seq_printf(file, " LNA Type: %s\n", basic_info.is_elna ? "eLNA" : "iLNA"); |
| + seq_puts(file, "------------------------------------------------------------\n"); |
| + seq_printf(file, " SKU: %s\n", basic_info.sku_enable ? "enable" : "disable"); |
| + seq_printf(file, " Percentage Control: %s\n", |
| + basic_info.percentage_ctrl_enable ? "enable" : "disable"); |
| + seq_printf(file, " Power Drop: %d [dBm]\n", basic_info.power_drop_level >> 1); |
| + seq_printf(file, " Backoff: %s\n", |
| + basic_info.bf_backoff_enable ? "enable" : "disable"); |
| + seq_printf(file, " TX Front-end Loss: %d, %d, %d, %d\n", |
| + basic_info.front_end_loss_tx[0], basic_info.front_end_loss_tx[1], |
| + basic_info.front_end_loss_tx[2], basic_info.front_end_loss_tx[3]); |
| + seq_printf(file, " RX Front-end Loss: %d, %d, %d, %d\n", |
| + basic_info.front_end_loss_rx[0], basic_info.front_end_loss_rx[1], |
| + basic_info.front_end_loss_rx[2], basic_info.front_end_loss_rx[3]); |
| + seq_printf(file, " MU TX Power Mode: %s\n", |
| + basic_info.mu_tx_power_manual_enable ? "manual" : "auto"); |
| + seq_printf(file, " MU TX Power (Auto / Manual): %d / %d [0.5 dBm]\n", |
| + basic_info.mu_tx_power_auto, basic_info.mu_tx_power_manual); |
| + seq_printf(file, " Thermal Compensation: %s\n", |
| + basic_info.thermal_compensate_enable ? "enable" : "disable"); |
| + seq_printf(file, " Theraml Compensation Value: %d\n", |
| + basic_info.thermal_compensate_value); |
| + |
| +out: |
| + return ret; |
| +} |
| + |
| +DEFINE_SHOW_ATTRIBUTE(mt7915_txpower_info); |
| + |
| static int |
| mt7915_twt_stats(struct seq_file *s, void *data) |
| { |
| @@ -1343,6 +1428,8 @@ int mt7915_init_debugfs(struct mt7915_phy *phy) |
| &mt7915_txpower_fops); |
| debugfs_create_file("txpower_path", 0400, dir, phy, |
| &mt7915_txpower_path_fops); |
| + debugfs_create_file("txpower_info", 0400, dir, phy, |
| + &mt7915_txpower_info_fops); |
| debugfs_create_devm_seqfile(dev->mt76.dev, "twt_stats", dir, |
| mt7915_twt_stats); |
| debugfs_create_file("rf_regval", 0600, dir, dev, &fops_rf_regval); |
| diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
| index 8a5bc0c..995c568 100644 |
| --- a/mt7915/mcu.c |
| +++ b/mt7915/mcu.c |
| @@ -3466,6 +3466,8 @@ int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len, |
| txpower[i] = res[i][req.band_idx]; |
| } else if (category == TX_POWER_INFO_PATH) { |
| memcpy(txpower, skb->data + 4, len); |
| + } else if (category == TX_POWER_INFO_BASIC) { |
| + memcpy(txpower, skb->data, len); |
| } |
| |
| dev_kfree_skb(skb); |
| diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
| index 7febe65..f38420c 100644 |
| --- a/mt7915/mcu.h |
| +++ b/mt7915/mcu.h |
| @@ -510,7 +510,8 @@ enum { |
| }; |
| |
| enum { |
| - TX_POWER_INFO_PATH = 1, |
| + TX_POWER_INFO_BASIC, |
| + TX_POWER_INFO_PATH, |
| TX_POWER_INFO_RATE, |
| }; |
| |
| -- |
| 2.18.0 |
| |