[][MAC80211][wifi6][mt76][Rebase][for upstream]

[Description]
Change some patches for the preparation of next upstream series.

[Release-log]
N/A

Change-Id: I7b77a67f54dc2e1c778161a256cc20fe92cc9c8f
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7949840
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/0012-wifi-mt76-mt7915-fix-txpower-issues.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/0012-wifi-mt76-mt7915-fix-txpower-issues.patch
new file mode 100644
index 0000000..d0665af
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/0012-wifi-mt76-mt7915-fix-txpower-issues.patch
@@ -0,0 +1,174 @@
+From 285ce41898a1c7c49e89681a31cd7daa1d8b6ad3 Mon Sep 17 00:00:00 2001
+From: Evelyn Tsai <evelyn.tsai@mediatek.com>
+Date: Sat, 29 Jul 2023 04:53:47 +0800
+Subject: [PATCH 12/15] wifi: mt76: mt7915: fix txpower issues
+
+---
+ eeprom.c         |  4 ++--
+ mac80211.c       |  2 +-
+ mt7915/debugfs.c | 48 ++++++++++++++++++++++++++----------------------
+ mt7915/init.c    |  2 +-
+ mt7915/main.c    |  1 +
+ mt7915/mcu.h     |  2 +-
+ 6 files changed, 32 insertions(+), 27 deletions(-)
+
+diff --git a/eeprom.c b/eeprom.c
+index 2558788f..750e031d 100644
+--- a/eeprom.c
++++ b/eeprom.c
+@@ -338,7 +338,7 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy,
+ 	u32 ru_rates = ARRAY_SIZE(dest->ru[0]);
+ 	char band;
+ 	size_t len;
+-	s8 max_power = 0;
++	s8 max_power = -127;
+ 	s8 txs_delta;
+ 
+ 	if (!mcs_rates)
+@@ -376,7 +376,7 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy,
+ 	if (!np)
+ 		return target_power;
+ 
+-	txs_delta = mt76_get_txs_delta(np, hweight8(phy->antenna_mask));
++	txs_delta = mt76_get_txs_delta(np, hweight16(phy->chainmask));
+ 
+ 	val = mt76_get_of_array(np, "rates-cck", &len, ARRAY_SIZE(dest->cck));
+ 	mt76_apply_array_limit(dest->cck, ARRAY_SIZE(dest->cck), val,
+diff --git a/mac80211.c b/mac80211.c
+index 85407387..0a081613 100644
+--- a/mac80211.c
++++ b/mac80211.c
+@@ -1486,7 +1486,7 @@ int mt76_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+ 		     int *dbm)
+ {
+ 	struct mt76_phy *phy = hw->priv;
+-	int n_chains = hweight8(phy->antenna_mask);
++	int n_chains = hweight16(phy->chainmask);
+ 	int delta = mt76_tx_power_nss_delta(n_chains);
+ 
+ 	*dbm = DIV_ROUND_UP(phy->txpower_cur + delta, 2);
+diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c
+index 6c3696c8..93e549c3 100644
+--- a/mt7915/debugfs.c
++++ b/mt7915/debugfs.c
+@@ -950,9 +950,9 @@ mt7915_xmit_queues_show(struct seq_file *file, void *data)
+ 
+ DEFINE_SHOW_ATTRIBUTE(mt7915_xmit_queues);
+ 
+-#define mt7915_txpower_puts(rate)						\
++#define mt7915_txpower_puts(rate, _len)						\
+ ({										\
+-	len += scnprintf(buf + len, sz - len, "%-16s:", #rate " (TMAC)");	\
++	len += scnprintf(buf + len, sz - len, "%-*s:", _len, #rate " (TMAC)");	\
+ 	for (i = 0; i < mt7915_sku_group_len[SKU_##rate]; i++, offs++)		\
+ 		len += scnprintf(buf + len, sz - len, " %6d", txpwr[offs]);	\
+ 	len += scnprintf(buf + len, sz - len, "\n");				\
+@@ -994,43 +994,47 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf,
+ 	len += scnprintf(buf + len, sz - len,
+ 			 "\nPhy%d Tx power table (channel %d)\n",
+ 			 phy != &dev->phy, phy->mt76->chandef.chan->hw_value);
+-	len += scnprintf(buf + len, sz - len, "%-16s  %6s %6s %6s %6s\n",
++	len += scnprintf(buf + len, sz - len, "%-23s  %6s %6s %6s %6s\n",
+ 			 " ", "1m", "2m", "5m", "11m");
+-	mt7915_txpower_puts(CCK);
++	mt7915_txpower_puts(CCK, 23);
+ 
+ 	len += scnprintf(buf + len, sz - len,
+-			 "%-16s  %6s %6s %6s %6s %6s %6s %6s %6s\n",
++			 "%-23s  %6s %6s %6s %6s %6s %6s %6s %6s\n",
+ 			 " ", "6m", "9m", "12m", "18m", "24m", "36m", "48m",
+ 			 "54m");
+-	mt7915_txpower_puts(OFDM);
++	mt7915_txpower_puts(OFDM, 23);
+ 
+ 	len += scnprintf(buf + len, sz - len,
+-			 "%-16s  %6s %6s %6s %6s %6s %6s %6s %6s\n",
++			 "%-23s  %6s %6s %6s %6s %6s %6s %6s %6s\n",
+ 			 " ", "mcs0", "mcs1", "mcs2", "mcs3", "mcs4",
+ 			 "mcs5", "mcs6", "mcs7");
+-	mt7915_txpower_puts(HT_BW20);
++	mt7915_txpower_puts(HT_BW20, 23);
+ 
+ 	len += scnprintf(buf + len, sz - len,
+-			 "%-16s  %6s %6s %6s %6s %6s %6s %6s %6s %6s\n",
++			 "%-23s  %6s %6s %6s %6s %6s %6s %6s %6s %6s\n",
+ 			 " ", "mcs0", "mcs1", "mcs2", "mcs3", "mcs4", "mcs5",
+ 			 "mcs6", "mcs7", "mcs32");
+-	mt7915_txpower_puts(HT_BW40);
++	mt7915_txpower_puts(HT_BW40, 23);
+ 
+ 	len += scnprintf(buf + len, sz - len,
+-			 "%-16s  %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n",
++			 "%-23s  %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n",
+ 			 " ", "mcs0", "mcs1", "mcs2", "mcs3", "mcs4", "mcs5",
+ 			 "mcs6", "mcs7", "mcs8", "mcs9", "mcs10", "mcs11");
+-	mt7915_txpower_puts(VHT_BW20);
+-	mt7915_txpower_puts(VHT_BW40);
+-	mt7915_txpower_puts(VHT_BW80);
+-	mt7915_txpower_puts(VHT_BW160);
+-	mt7915_txpower_puts(HE_RU26);
+-	mt7915_txpower_puts(HE_RU52);
+-	mt7915_txpower_puts(HE_RU106);
+-	mt7915_txpower_puts(HE_RU242);
+-	mt7915_txpower_puts(HE_RU484);
+-	mt7915_txpower_puts(HE_RU996);
+-	mt7915_txpower_puts(HE_RU2x996);
++	mt7915_txpower_puts(VHT_BW20, 23);
++	mt7915_txpower_puts(VHT_BW40, 23);
++	mt7915_txpower_puts(VHT_BW80, 23);
++	mt7915_txpower_puts(VHT_BW160, 23);
++	mt7915_txpower_puts(HE_RU26, 23);
++	mt7915_txpower_puts(HE_RU52, 23);
++	mt7915_txpower_puts(HE_RU106, 23);
++	len += scnprintf(buf + len, sz - len, "BW20/");
++	mt7915_txpower_puts(HE_RU242, 18);
++	len += scnprintf(buf + len, sz - len, "BW40/");
++	mt7915_txpower_puts(HE_RU484, 18);
++	len += scnprintf(buf + len, sz - len, "BW80/");
++	mt7915_txpower_puts(HE_RU996, 18);
++	len += scnprintf(buf + len, sz - len, "BW160/");
++	mt7915_txpower_puts(HE_RU2x996, 17);
+ 
+ 	reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_TPC_CTRL_STAT(band) :
+ 	      MT_WF_PHY_TPC_CTRL_STAT_MT7916(band);
+diff --git a/mt7915/init.c b/mt7915/init.c
+index bcd37172..15b719fa 100644
+--- a/mt7915/init.c
++++ b/mt7915/init.c
+@@ -281,7 +281,7 @@ static void mt7915_led_set_brightness(struct led_classdev *led_cdev,
+ void mt7915_init_txpower(struct mt7915_dev *dev,
+ 			 struct ieee80211_supported_band *sband)
+ {
+-	int i, n_chains = hweight8(dev->mphy.antenna_mask);
++	int i, n_chains = hweight16(dev->mphy.chainmask);
+ 	int nss_delta = mt76_tx_power_nss_delta(n_chains);
+ 	int pwr_delta = mt7915_eeprom_get_power_delta(dev, sband->band);
+ 	struct mt76_power_limits limits;
+diff --git a/mt7915/main.c b/mt7915/main.c
+index 33813259..a90ac456 100644
+--- a/mt7915/main.c
++++ b/mt7915/main.c
+@@ -1063,6 +1063,7 @@ mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
+ 	mt76_set_stream_caps(phy->mt76, true);
+ 	mt7915_set_stream_vht_txbf_caps(phy);
+ 	mt7915_set_stream_he_caps(phy);
++	mt7915_mcu_set_txpower_sku(phy);
+ 
+ 	mutex_unlock(&dev->mt76.mutex);
+ 
+diff --git a/mt7915/mcu.h b/mt7915/mcu.h
+index aebacc7d..8f365461 100644
+--- a/mt7915/mcu.h
++++ b/mt7915/mcu.h
+@@ -574,7 +574,7 @@ static inline s8
+ mt7915_get_power_bound(struct mt7915_phy *phy, s8 txpower)
+ {
+ 	struct mt76_phy *mphy = phy->mt76;
+-	int n_chains = hweight8(mphy->antenna_mask);
++	int n_chains = hweight16(mphy->chainmask);
+ 
+ 	txpower = mt76_get_sar_power(mphy, mphy->chandef.chan, txpower * 2);
+ 	txpower -= mt76_tx_power_nss_delta(n_chains);
+-- 
+2.39.2
+