blob: 31fcb9e2755385cd7f0d14ab135cec99b495d514 [file] [log] [blame]
developer0443cd32023-09-19 14:11:49 +08001From 6cb2b319acc161e61dd875536bb2c8ee86efcad8 Mon Sep 17 00:00:00 2001
developerdeafdc92023-07-29 05:24:14 +08002From: Evelyn Tsai <evelyn.tsai@mediatek.com>
3Date: Sat, 29 Jul 2023 04:53:47 +0800
developer0443cd32023-09-19 14:11:49 +08004Subject: [PATCH 4/7] wifi: mt76: mt7915: fix txpower issues
developerdeafdc92023-07-29 05:24:14 +08005
6---
7 eeprom.c | 4 ++--
8 mac80211.c | 2 +-
9 mt7915/debugfs.c | 48 ++++++++++++++++++++++++++----------------------
10 mt7915/init.c | 2 +-
developer325d3fd2023-08-09 07:25:13 +080011 mt7915/main.c | 1 +
developerdeafdc92023-07-29 05:24:14 +080012 mt7915/mcu.h | 2 +-
developer325d3fd2023-08-09 07:25:13 +080013 6 files changed, 32 insertions(+), 27 deletions(-)
developerdeafdc92023-07-29 05:24:14 +080014
15diff --git a/eeprom.c b/eeprom.c
developer0443cd32023-09-19 14:11:49 +080016index 2558788..750e031 100644
developerdeafdc92023-07-29 05:24:14 +080017--- a/eeprom.c
18+++ b/eeprom.c
developer325d3fd2023-08-09 07:25:13 +080019@@ -338,7 +338,7 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy,
developerdeafdc92023-07-29 05:24:14 +080020 u32 ru_rates = ARRAY_SIZE(dest->ru[0]);
21 char band;
22 size_t len;
23- s8 max_power = 0;
24+ s8 max_power = -127;
25 s8 txs_delta;
26
27 if (!mcs_rates)
developer325d3fd2023-08-09 07:25:13 +080028@@ -376,7 +376,7 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy,
developerdeafdc92023-07-29 05:24:14 +080029 if (!np)
30 return target_power;
31
32- txs_delta = mt76_get_txs_delta(np, hweight8(phy->antenna_mask));
33+ txs_delta = mt76_get_txs_delta(np, hweight16(phy->chainmask));
34
35 val = mt76_get_of_array(np, "rates-cck", &len, ARRAY_SIZE(dest->cck));
36 mt76_apply_array_limit(dest->cck, ARRAY_SIZE(dest->cck), val,
37diff --git a/mac80211.c b/mac80211.c
developer0443cd32023-09-19 14:11:49 +080038index 12fcb2b..aaaf6a9 100644
developerdeafdc92023-07-29 05:24:14 +080039--- a/mac80211.c
40+++ b/mac80211.c
developer0443cd32023-09-19 14:11:49 +080041@@ -1538,7 +1538,7 @@ int mt76_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developerdeafdc92023-07-29 05:24:14 +080042 int *dbm)
43 {
44 struct mt76_phy *phy = hw->priv;
45- int n_chains = hweight8(phy->antenna_mask);
46+ int n_chains = hweight16(phy->chainmask);
47 int delta = mt76_tx_power_nss_delta(n_chains);
48
49 *dbm = DIV_ROUND_UP(phy->txpower_cur + delta, 2);
50diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c
developer0443cd32023-09-19 14:11:49 +080051index 6c3696c..93e549c 100644
developerdeafdc92023-07-29 05:24:14 +080052--- a/mt7915/debugfs.c
53+++ b/mt7915/debugfs.c
54@@ -950,9 +950,9 @@ mt7915_xmit_queues_show(struct seq_file *file, void *data)
55
56 DEFINE_SHOW_ATTRIBUTE(mt7915_xmit_queues);
57
58-#define mt7915_txpower_puts(rate) \
59+#define mt7915_txpower_puts(rate, _len) \
60 ({ \
61- len += scnprintf(buf + len, sz - len, "%-16s:", #rate " (TMAC)"); \
62+ len += scnprintf(buf + len, sz - len, "%-*s:", _len, #rate " (TMAC)"); \
63 for (i = 0; i < mt7915_sku_group_len[SKU_##rate]; i++, offs++) \
64 len += scnprintf(buf + len, sz - len, " %6d", txpwr[offs]); \
65 len += scnprintf(buf + len, sz - len, "\n"); \
66@@ -994,43 +994,47 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf,
67 len += scnprintf(buf + len, sz - len,
68 "\nPhy%d Tx power table (channel %d)\n",
69 phy != &dev->phy, phy->mt76->chandef.chan->hw_value);
70- len += scnprintf(buf + len, sz - len, "%-16s %6s %6s %6s %6s\n",
71+ len += scnprintf(buf + len, sz - len, "%-23s %6s %6s %6s %6s\n",
72 " ", "1m", "2m", "5m", "11m");
73- mt7915_txpower_puts(CCK);
74+ mt7915_txpower_puts(CCK, 23);
75
76 len += scnprintf(buf + len, sz - len,
77- "%-16s %6s %6s %6s %6s %6s %6s %6s %6s\n",
78+ "%-23s %6s %6s %6s %6s %6s %6s %6s %6s\n",
79 " ", "6m", "9m", "12m", "18m", "24m", "36m", "48m",
80 "54m");
81- mt7915_txpower_puts(OFDM);
82+ mt7915_txpower_puts(OFDM, 23);
83
84 len += scnprintf(buf + len, sz - len,
85- "%-16s %6s %6s %6s %6s %6s %6s %6s %6s\n",
86+ "%-23s %6s %6s %6s %6s %6s %6s %6s %6s\n",
87 " ", "mcs0", "mcs1", "mcs2", "mcs3", "mcs4",
88 "mcs5", "mcs6", "mcs7");
89- mt7915_txpower_puts(HT_BW20);
90+ mt7915_txpower_puts(HT_BW20, 23);
91
92 len += scnprintf(buf + len, sz - len,
93- "%-16s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n",
94+ "%-23s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n",
95 " ", "mcs0", "mcs1", "mcs2", "mcs3", "mcs4", "mcs5",
96 "mcs6", "mcs7", "mcs32");
97- mt7915_txpower_puts(HT_BW40);
98+ mt7915_txpower_puts(HT_BW40, 23);
99
100 len += scnprintf(buf + len, sz - len,
101- "%-16s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n",
102+ "%-23s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n",
103 " ", "mcs0", "mcs1", "mcs2", "mcs3", "mcs4", "mcs5",
104 "mcs6", "mcs7", "mcs8", "mcs9", "mcs10", "mcs11");
105- mt7915_txpower_puts(VHT_BW20);
106- mt7915_txpower_puts(VHT_BW40);
107- mt7915_txpower_puts(VHT_BW80);
108- mt7915_txpower_puts(VHT_BW160);
109- mt7915_txpower_puts(HE_RU26);
110- mt7915_txpower_puts(HE_RU52);
111- mt7915_txpower_puts(HE_RU106);
112- mt7915_txpower_puts(HE_RU242);
113- mt7915_txpower_puts(HE_RU484);
114- mt7915_txpower_puts(HE_RU996);
115- mt7915_txpower_puts(HE_RU2x996);
116+ mt7915_txpower_puts(VHT_BW20, 23);
117+ mt7915_txpower_puts(VHT_BW40, 23);
118+ mt7915_txpower_puts(VHT_BW80, 23);
119+ mt7915_txpower_puts(VHT_BW160, 23);
120+ mt7915_txpower_puts(HE_RU26, 23);
121+ mt7915_txpower_puts(HE_RU52, 23);
122+ mt7915_txpower_puts(HE_RU106, 23);
123+ len += scnprintf(buf + len, sz - len, "BW20/");
124+ mt7915_txpower_puts(HE_RU242, 18);
125+ len += scnprintf(buf + len, sz - len, "BW40/");
126+ mt7915_txpower_puts(HE_RU484, 18);
127+ len += scnprintf(buf + len, sz - len, "BW80/");
128+ mt7915_txpower_puts(HE_RU996, 18);
129+ len += scnprintf(buf + len, sz - len, "BW160/");
130+ mt7915_txpower_puts(HE_RU2x996, 17);
131
132 reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_TPC_CTRL_STAT(band) :
133 MT_WF_PHY_TPC_CTRL_STAT_MT7916(band);
134diff --git a/mt7915/init.c b/mt7915/init.c
developer0443cd32023-09-19 14:11:49 +0800135index 294876a..d8fd8d6 100644
developerdeafdc92023-07-29 05:24:14 +0800136--- a/mt7915/init.c
137+++ b/mt7915/init.c
developer0443cd32023-09-19 14:11:49 +0800138@@ -278,7 +278,7 @@ static void mt7915_led_set_brightness(struct led_classdev *led_cdev,
developerdeafdc92023-07-29 05:24:14 +0800139 void mt7915_init_txpower(struct mt7915_dev *dev,
140 struct ieee80211_supported_band *sband)
141 {
142- int i, n_chains = hweight8(dev->mphy.antenna_mask);
143+ int i, n_chains = hweight16(dev->mphy.chainmask);
144 int nss_delta = mt76_tx_power_nss_delta(n_chains);
145 int pwr_delta = mt7915_eeprom_get_power_delta(dev, sband->band);
146 struct mt76_power_limits limits;
147diff --git a/mt7915/main.c b/mt7915/main.c
developer0443cd32023-09-19 14:11:49 +0800148index 449c2ee..96336b6 100644
developerdeafdc92023-07-29 05:24:14 +0800149--- a/mt7915/main.c
150+++ b/mt7915/main.c
developer0443cd32023-09-19 14:11:49 +0800151@@ -1075,6 +1075,7 @@ mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
developerdeafdc92023-07-29 05:24:14 +0800152 mt76_set_stream_caps(phy->mt76, true);
153 mt7915_set_stream_vht_txbf_caps(phy);
154 mt7915_set_stream_he_caps(phy);
155+ mt7915_mcu_set_txpower_sku(phy);
156
157 mutex_unlock(&dev->mt76.mutex);
158
159diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developer0443cd32023-09-19 14:11:49 +0800160index aebacc7..8f36546 100644
developerdeafdc92023-07-29 05:24:14 +0800161--- a/mt7915/mcu.h
162+++ b/mt7915/mcu.h
163@@ -574,7 +574,7 @@ static inline s8
164 mt7915_get_power_bound(struct mt7915_phy *phy, s8 txpower)
165 {
166 struct mt76_phy *mphy = phy->mt76;
167- int n_chains = hweight8(mphy->antenna_mask);
168+ int n_chains = hweight16(mphy->chainmask);
169
170 txpower = mt76_get_sar_power(mphy, mphy->chandef.chan, txpower * 2);
171 txpower -= mt76_tx_power_nss_delta(n_chains);
172--
developer0443cd32023-09-19 14:11:49 +08001732.18.0
developerdeafdc92023-07-29 05:24:14 +0800174