developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 1 | From ac55beffc7c153e47a63dd889a80f90656afa5a4 Mon Sep 17 00:00:00 2001 |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Tue, 11 Jul 2023 17:06:04 +0800 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1030/1052] wifi: mt76: mt7915: add txpower info dump support |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 7 | --- |
| 8 | mt7915/debugfs.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ |
| 9 | mt7915/mcu.c | 2 ++ |
| 10 | mt7915/mcu.h | 3 +- |
| 11 | 3 files changed, 91 insertions(+), 1 deletion(-) |
| 12 | |
| 13 | diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 14 | index 06c62dd3..223f9a37 100644 |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 15 | --- a/mt7915/debugfs.c |
| 16 | +++ b/mt7915/debugfs.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 17 | @@ -1259,6 +1259,91 @@ mt7915_txpower_path_show(struct seq_file *file, void *data) |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 18 | |
| 19 | DEFINE_SHOW_ATTRIBUTE(mt7915_txpower_path); |
| 20 | |
| 21 | +static int |
| 22 | +mt7915_txpower_info_show(struct seq_file *file, void *data) |
| 23 | +{ |
| 24 | + struct mt7915_phy *phy = file->private; |
| 25 | + struct { |
| 26 | + u8 category; |
| 27 | + u8 rsv1; |
| 28 | + |
| 29 | + /* basic info */ |
| 30 | + u8 band_idx; |
| 31 | + u8 band; |
| 32 | + |
| 33 | + /* board type info */ |
| 34 | + bool is_epa; |
| 35 | + bool is_elna; |
| 36 | + |
| 37 | + /* power percentage info */ |
| 38 | + bool percentage_ctrl_enable; |
| 39 | + s8 power_drop_level; |
| 40 | + |
| 41 | + /* frond-end loss TX info */ |
| 42 | + s8 front_end_loss_tx[4]; |
| 43 | + |
| 44 | + /* frond-end loss RX info */ |
| 45 | + s8 front_end_loss_rx[4]; |
| 46 | + |
| 47 | + /* thermal info */ |
| 48 | + bool thermal_compensate_enable; |
| 49 | + s8 thermal_compensate_value; |
| 50 | + u8 rsv2; |
| 51 | + |
| 52 | + /* TX power max/min limit info */ |
| 53 | + s8 max_power_bound; |
| 54 | + s8 min_power_bound; |
| 55 | + |
| 56 | + /* power limit info */ |
| 57 | + bool sku_enable; |
| 58 | + bool bf_backoff_enable; |
| 59 | + |
| 60 | + /* MU TX power info */ |
| 61 | + bool mu_tx_power_manual_enable; |
| 62 | + s8 mu_tx_power_auto; |
| 63 | + s8 mu_tx_power_manual; |
| 64 | + u8 rsv3; |
| 65 | + } __packed basic_info = {}; |
| 66 | + int ret; |
| 67 | + |
| 68 | + ret = mt7915_mcu_get_txpower_sku(phy, (s8 *)&basic_info, sizeof(basic_info), |
| 69 | + TX_POWER_INFO_BASIC); |
| 70 | + if (ret || basic_info.category != TX_POWER_INFO_BASIC) |
| 71 | + goto out; |
| 72 | + |
| 73 | + seq_puts(file, "======================== BASIC INFO ========================\n"); |
| 74 | + seq_printf(file, " Band Index: %d, Channel Band: %d\n", |
| 75 | + basic_info.band_idx, basic_info.band); |
| 76 | + seq_printf(file, " PA Type: %s\n", basic_info.is_epa ? "ePA" : "iPA"); |
| 77 | + seq_printf(file, " LNA Type: %s\n", basic_info.is_elna ? "eLNA" : "iLNA"); |
| 78 | + seq_puts(file, "------------------------------------------------------------\n"); |
| 79 | + seq_printf(file, " SKU: %s\n", basic_info.sku_enable ? "enable" : "disable"); |
| 80 | + seq_printf(file, " Percentage Control: %s\n", |
| 81 | + basic_info.percentage_ctrl_enable ? "enable" : "disable"); |
| 82 | + seq_printf(file, " Power Drop: %d [dBm]\n", basic_info.power_drop_level >> 1); |
| 83 | + seq_printf(file, " Backoff: %s\n", |
| 84 | + basic_info.bf_backoff_enable ? "enable" : "disable"); |
| 85 | + seq_printf(file, " TX Front-end Loss: %d, %d, %d, %d\n", |
| 86 | + basic_info.front_end_loss_tx[0], basic_info.front_end_loss_tx[1], |
| 87 | + basic_info.front_end_loss_tx[2], basic_info.front_end_loss_tx[3]); |
| 88 | + seq_printf(file, " RX Front-end Loss: %d, %d, %d, %d\n", |
| 89 | + basic_info.front_end_loss_rx[0], basic_info.front_end_loss_rx[1], |
| 90 | + basic_info.front_end_loss_rx[2], basic_info.front_end_loss_rx[3]); |
| 91 | + seq_printf(file, " MU TX Power Mode: %s\n", |
| 92 | + basic_info.mu_tx_power_manual_enable ? "manual" : "auto"); |
| 93 | + seq_printf(file, " MU TX Power (Auto / Manual): %d / %d [0.5 dBm]\n", |
| 94 | + basic_info.mu_tx_power_auto, basic_info.mu_tx_power_manual); |
| 95 | + seq_printf(file, " Thermal Compensation: %s\n", |
| 96 | + basic_info.thermal_compensate_enable ? "enable" : "disable"); |
| 97 | + seq_printf(file, " Theraml Compensation Value: %d\n", |
| 98 | + basic_info.thermal_compensate_value); |
| 99 | + |
| 100 | +out: |
| 101 | + return ret; |
| 102 | +} |
| 103 | + |
| 104 | +DEFINE_SHOW_ATTRIBUTE(mt7915_txpower_info); |
| 105 | + |
| 106 | static int |
| 107 | mt7915_twt_stats(struct seq_file *s, void *data) |
| 108 | { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 109 | @@ -1433,6 +1518,8 @@ int mt7915_init_debugfs(struct mt7915_phy *phy) |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 110 | &mt7915_txpower_fops); |
| 111 | debugfs_create_file("txpower_path", 0400, dir, phy, |
| 112 | &mt7915_txpower_path_fops); |
| 113 | + debugfs_create_file("txpower_info", 0400, dir, phy, |
| 114 | + &mt7915_txpower_info_fops); |
| 115 | debugfs_create_devm_seqfile(dev->mt76.dev, "twt_stats", dir, |
| 116 | mt7915_twt_stats); |
| 117 | debugfs_create_file("rf_regval", 0600, dir, dev, &fops_rf_regval); |
| 118 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 119 | index 7a7b3bac..34d36e50 100644 |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 120 | --- a/mt7915/mcu.c |
| 121 | +++ b/mt7915/mcu.c |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 122 | @@ -3624,6 +3624,8 @@ int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len, |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 123 | txpower[i] = res[i][req.band_idx]; |
| 124 | } else if (category == TX_POWER_INFO_PATH) { |
| 125 | memcpy(txpower, skb->data + 4, len); |
| 126 | + } else if (category == TX_POWER_INFO_BASIC) { |
| 127 | + memcpy(txpower, skb->data, len); |
| 128 | } |
| 129 | |
| 130 | dev_kfree_skb(skb); |
| 131 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 132 | index 035ad97d..3089fb64 100644 |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 133 | --- a/mt7915/mcu.h |
| 134 | +++ b/mt7915/mcu.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 135 | @@ -525,7 +525,8 @@ enum { |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | enum { |
| 139 | - TX_POWER_INFO_PATH = 1, |
| 140 | + TX_POWER_INFO_BASIC, |
| 141 | + TX_POWER_INFO_PATH, |
| 142 | TX_POWER_INFO_RATE, |
| 143 | }; |
| 144 | |
| 145 | -- |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 146 | 2.18.0 |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 147 | |