mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-12-23 12:23:34 +00:00
598 lines
18 KiB
Diff
598 lines
18 KiB
Diff
From ff7ce1171852dedcaec49ea0de398dfea04aaced Mon Sep 17 00:00:00 2001
|
|
From: Shayne Chen <shayne.chen@mediatek.com>
|
|
Date: Mon, 5 Dec 2022 18:21:51 +0800
|
|
Subject: [PATCH] wifi: mt76: mt7915: add bf backoff limit table support
|
|
|
|
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
|
|
---
|
|
debugfs.c | 4 +-
|
|
eeprom.c | 38 ++++++++--
|
|
mt76.h | 8 +++
|
|
mt7915/debugfs.c | 73 +++++++++++++++++--
|
|
mt7915/init.c | 7 ++
|
|
mt7915/main.c | 6 +-
|
|
mt7915/mcu.c | 178 +++++++++++++++++++++++++++++++++++++----------
|
|
mt7915/mcu.h | 6 ++
|
|
mt7915/mt7915.h | 9 ++-
|
|
9 files changed, 275 insertions(+), 54 deletions(-)
|
|
|
|
diff --git a/debugfs.c b/debugfs.c
|
|
index 1c8328d..a626f7c 100644
|
|
--- a/debugfs.c
|
|
+++ b/debugfs.c
|
|
@@ -95,9 +95,9 @@ void mt76_seq_puts_array(struct seq_file *file, const char *str,
|
|
{
|
|
int i;
|
|
|
|
- seq_printf(file, "%10s:", str);
|
|
+ seq_printf(file, "%16s:", str);
|
|
for (i = 0; i < len; i++)
|
|
- seq_printf(file, " %2d", val[i]);
|
|
+ seq_printf(file, " %4d", val[i]);
|
|
seq_puts(file, "\n");
|
|
}
|
|
EXPORT_SYMBOL_GPL(mt76_seq_puts_array);
|
|
diff --git a/eeprom.c b/eeprom.c
|
|
index 9d029c0..aa33e7b 100644
|
|
--- a/eeprom.c
|
|
+++ b/eeprom.c
|
|
@@ -336,9 +336,10 @@ mt76_apply_array_limit(s8 *pwr, size_t pwr_len, const __be32 *data,
|
|
static void
|
|
mt76_apply_multi_array_limit(s8 *pwr, size_t pwr_len, s8 pwr_num,
|
|
const __be32 *data, size_t len, s8 target_power,
|
|
- s8 nss_delta, s8 *max_power)
|
|
+ s8 nss_delta)
|
|
{
|
|
int i, cur;
|
|
+ s8 max_power = -128;
|
|
|
|
if (!data)
|
|
return;
|
|
@@ -350,7 +351,7 @@ mt76_apply_multi_array_limit(s8 *pwr, size_t pwr_len, s8 pwr_num,
|
|
break;
|
|
|
|
mt76_apply_array_limit(pwr + pwr_len * i, pwr_len, data + 1,
|
|
- target_power, nss_delta, max_power);
|
|
+ target_power, nss_delta, &max_power);
|
|
if (--cur > 0)
|
|
continue;
|
|
|
|
@@ -377,12 +378,16 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy,
|
|
char band;
|
|
size_t len;
|
|
s8 max_power = -127;
|
|
+ s8 max_power_backoff = -127;
|
|
s8 txs_delta;
|
|
+ int n_chains = hweight16(phy->chainmask);
|
|
+ s8 target_power_combine = target_power + mt76_tx_power_nss_delta(n_chains);
|
|
|
|
if (!mcs_rates)
|
|
mcs_rates = 10;
|
|
|
|
- memset(dest, target_power, sizeof(*dest));
|
|
+ memset(dest, target_power, sizeof(*dest) - sizeof(dest->path));
|
|
+ memset(&dest->path, 0, sizeof(dest->path));
|
|
|
|
if (!IS_ENABLED(CONFIG_OF))
|
|
return target_power;
|
|
@@ -428,12 +433,35 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy,
|
|
val = mt76_get_of_array(np, "rates-mcs", &len, mcs_rates + 1);
|
|
mt76_apply_multi_array_limit(dest->mcs[0], ARRAY_SIZE(dest->mcs[0]),
|
|
ARRAY_SIZE(dest->mcs), val, len,
|
|
- target_power, txs_delta, &max_power);
|
|
+ target_power, txs_delta);
|
|
|
|
val = mt76_get_of_array(np, "rates-ru", &len, ru_rates + 1);
|
|
mt76_apply_multi_array_limit(dest->ru[0], ARRAY_SIZE(dest->ru[0]),
|
|
ARRAY_SIZE(dest->ru), val, len,
|
|
- target_power, txs_delta, &max_power);
|
|
+ target_power, txs_delta);
|
|
+
|
|
+ max_power_backoff = max_power;
|
|
+ val = mt76_get_of_array(np, "paths-cck", &len, ARRAY_SIZE(dest->path.cck));
|
|
+ mt76_apply_array_limit(dest->path.cck, ARRAY_SIZE(dest->path.cck), val,
|
|
+ target_power_combine, txs_delta, &max_power_backoff);
|
|
+
|
|
+ val = mt76_get_of_array(np, "paths-ofdm", &len, ARRAY_SIZE(dest->path.ofdm));
|
|
+ mt76_apply_array_limit(dest->path.ofdm, ARRAY_SIZE(dest->path.ofdm), val,
|
|
+ target_power_combine, txs_delta, &max_power_backoff);
|
|
+
|
|
+ val = mt76_get_of_array(np, "paths-ofdm-bf", &len, ARRAY_SIZE(dest->path.ofdm_bf));
|
|
+ mt76_apply_array_limit(dest->path.ofdm_bf, ARRAY_SIZE(dest->path.ofdm_bf), val,
|
|
+ target_power_combine, txs_delta, &max_power_backoff);
|
|
+
|
|
+ val = mt76_get_of_array(np, "paths-ru", &len, ARRAY_SIZE(dest->path.ru[0]) + 1);
|
|
+ mt76_apply_multi_array_limit(dest->path.ru[0], ARRAY_SIZE(dest->path.ru[0]),
|
|
+ ARRAY_SIZE(dest->path.ru), val, len,
|
|
+ target_power_combine, txs_delta);
|
|
+
|
|
+ val = mt76_get_of_array(np, "paths-ru-bf", &len, ARRAY_SIZE(dest->path.ru_bf[0]) + 1);
|
|
+ mt76_apply_multi_array_limit(dest->path.ru_bf[0], ARRAY_SIZE(dest->path.ru_bf[0]),
|
|
+ ARRAY_SIZE(dest->path.ru_bf), val, len,
|
|
+ target_power_combine, txs_delta);
|
|
|
|
return max_power;
|
|
}
|
|
diff --git a/mt76.h b/mt76.h
|
|
index 48e98a3..5c26715 100644
|
|
--- a/mt76.h
|
|
+++ b/mt76.h
|
|
@@ -1089,6 +1089,14 @@ struct mt76_power_limits {
|
|
s8 mcs[4][10];
|
|
s8 ru[7][12];
|
|
s8 eht[16][16];
|
|
+
|
|
+ struct {
|
|
+ s8 cck[4];
|
|
+ s8 ofdm[4];
|
|
+ s8 ofdm_bf[4];
|
|
+ s8 ru[7][10];
|
|
+ s8 ru_bf[7][10];
|
|
+ } path;
|
|
};
|
|
|
|
struct mt76_ethtool_worker_info {
|
|
diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c
|
|
index 5c08910..fa1d2ac 100644
|
|
--- a/mt7915/debugfs.c
|
|
+++ b/mt7915/debugfs.c
|
|
@@ -1020,7 +1020,7 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf,
|
|
if (!buf)
|
|
return -ENOMEM;
|
|
|
|
- ret = mt7915_mcu_get_txpower_sku(phy, txpwr, sizeof(txpwr));
|
|
+ ret = mt7915_mcu_get_txpower_sku(phy, txpwr, sizeof(txpwr), TX_POWER_INFO_RATE);
|
|
if (ret)
|
|
goto out;
|
|
|
|
@@ -1134,7 +1134,7 @@ mt7915_rate_txpower_set(struct file *file, const char __user *user_buf,
|
|
|
|
mutex_lock(&dev->mt76.mutex);
|
|
ret = mt7915_mcu_get_txpower_sku(phy, req.txpower_sku,
|
|
- sizeof(req.txpower_sku));
|
|
+ sizeof(req.txpower_sku), TX_POWER_INFO_RATE);
|
|
if (ret)
|
|
goto out;
|
|
|
|
@@ -1176,7 +1176,7 @@ out:
|
|
return ret ? ret : count;
|
|
}
|
|
|
|
-static const struct file_operations mt7915_rate_txpower_fops = {
|
|
+static const struct file_operations mt7915_txpower_fops = {
|
|
.write = mt7915_rate_txpower_set,
|
|
.read = mt7915_rate_txpower_get,
|
|
.open = simple_open,
|
|
@@ -1184,6 +1184,69 @@ static const struct file_operations mt7915_rate_txpower_fops = {
|
|
.llseek = default_llseek,
|
|
};
|
|
|
|
+static int
|
|
+mt7915_path_txpower_show(struct seq_file *file)
|
|
+{
|
|
+ struct mt7915_phy *phy = file->private;
|
|
+ s8 txpower[MT7915_SKU_PATH_NUM], *buf = txpower;
|
|
+ int ret;
|
|
+
|
|
+#define PATH_POWER_SHOW(_name, _len, _skip) do { \
|
|
+ if (_skip) { \
|
|
+ buf -= 1; \
|
|
+ *buf = 0; \
|
|
+ } \
|
|
+ mt76_seq_puts_array(file, _name, buf, _len); \
|
|
+ buf += _len; \
|
|
+ } while(0)
|
|
+
|
|
+ seq_printf(file, "\n%*c", 18, ' ');
|
|
+ seq_printf(file, "1T1S/2T1S/3T1S/4T1S/2T2S/3T2S/4T2S/3T3S/4T3S/4T4S\n");
|
|
+ ret = mt7915_mcu_get_txpower_sku(phy, txpower, sizeof(txpower),
|
|
+ TX_POWER_INFO_PATH);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ PATH_POWER_SHOW("CCK", 4, 0);
|
|
+ PATH_POWER_SHOW("OFDM", 4, 0);
|
|
+ PATH_POWER_SHOW("BF-OFDM", 4, 1);
|
|
+
|
|
+ PATH_POWER_SHOW("HT/VHT20", 10, 0);
|
|
+ PATH_POWER_SHOW("BF-HT/VHT20", 10, 1);
|
|
+ PATH_POWER_SHOW("HT/VHT40", 10, 0);
|
|
+ PATH_POWER_SHOW("BF-HT/VHT40", 10, 1);
|
|
+
|
|
+ PATH_POWER_SHOW("BW20/RU242", 10, 0);
|
|
+ PATH_POWER_SHOW("BF-BW20/RU242", 10, 1);
|
|
+ PATH_POWER_SHOW("BW40/RU484", 10, 0);
|
|
+ PATH_POWER_SHOW("BF-BW40/RU484", 10, 1);
|
|
+ PATH_POWER_SHOW("BW80/RU996", 10, 0);
|
|
+ PATH_POWER_SHOW("BF-BW80/RU996", 10, 1);
|
|
+ PATH_POWER_SHOW("BW160/RU2x996", 10, 0);
|
|
+ PATH_POWER_SHOW("BF-BW160/RU2x996", 10, 1);
|
|
+ PATH_POWER_SHOW("RU26", 10, 0);
|
|
+ PATH_POWER_SHOW("BF-RU26", 10, 0);
|
|
+ PATH_POWER_SHOW("RU52", 10, 0);
|
|
+ PATH_POWER_SHOW("BF-RU52", 10, 0);
|
|
+ PATH_POWER_SHOW("RU106", 10, 0);
|
|
+ PATH_POWER_SHOW("BF-RU106", 10, 0);
|
|
+#undef PATH_POWER_SHOW
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int
|
|
+mt7915_txpower_path_show(struct seq_file *file, void *data)
|
|
+{
|
|
+ struct mt7915_phy *phy = file->private;
|
|
+
|
|
+ seq_printf(file, "\nBand %d\n", phy != &phy->dev->phy);
|
|
+
|
|
+ return mt7915_path_txpower_show(file);
|
|
+}
|
|
+
|
|
+DEFINE_SHOW_ATTRIBUTE(mt7915_txpower_path);
|
|
+
|
|
static int
|
|
mt7915_twt_stats(struct seq_file *s, void *data)
|
|
{
|
|
@@ -1310,7 +1373,9 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
|
|
debugfs_create_file("implicit_txbf", 0600, dir, dev,
|
|
&fops_implicit_txbf);
|
|
debugfs_create_file("txpower_sku", 0400, dir, phy,
|
|
- &mt7915_rate_txpower_fops);
|
|
+ &mt7915_txpower_fops);
|
|
+ debugfs_create_file("txpower_path", 0400, dir, phy,
|
|
+ &mt7915_txpower_path_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/init.c b/mt7915/init.c
|
|
index 439403f..b32e213 100644
|
|
--- a/mt7915/init.c
|
|
+++ b/mt7915/init.c
|
|
@@ -284,6 +284,8 @@ static void __mt7915_init_txpower(struct mt7915_phy *phy,
|
|
int pwr_delta = mt7915_eeprom_get_power_delta(dev, sband->band);
|
|
struct mt76_power_limits limits;
|
|
|
|
+ phy->sku_limit_en = true;
|
|
+ phy->sku_path_en = true;
|
|
for (i = 0; i < sband->n_channels; i++) {
|
|
struct ieee80211_channel *chan = &sband->channels[i];
|
|
u32 target_power = 0;
|
|
@@ -300,6 +302,11 @@ static void __mt7915_init_txpower(struct mt7915_phy *phy,
|
|
target_power = mt76_get_rate_power_limits(phy->mt76, chan,
|
|
&limits,
|
|
target_power);
|
|
+
|
|
+ /* MT7915N can not enable Backoff table without setting value in dts */
|
|
+ if (!limits.path.ofdm[0])
|
|
+ phy->sku_path_en = false;
|
|
+
|
|
target_power += nss_delta;
|
|
target_power = DIV_ROUND_UP(target_power, 2);
|
|
chan->max_power = min_t(int, chan->max_reg_power,
|
|
diff --git a/mt7915/main.c b/mt7915/main.c
|
|
index 9fafa16..da7a87b 100644
|
|
--- a/mt7915/main.c
|
|
+++ b/mt7915/main.c
|
|
@@ -73,11 +73,7 @@ int mt7915_run(struct ieee80211_hw *hw)
|
|
if (ret)
|
|
goto out;
|
|
|
|
-#ifdef MTK_DEBUG
|
|
- ret = mt7915_mcu_set_sku_en(phy, !dev->dbg.sku_disable);
|
|
-#else
|
|
- ret = mt7915_mcu_set_sku_en(phy, true);
|
|
-#endif
|
|
+ ret = mt7915_mcu_set_sku_en(phy);
|
|
if (ret)
|
|
goto out;
|
|
|
|
diff --git a/mt7915/mcu.c b/mt7915/mcu.c
|
|
index 1262206..eb7638b 100644
|
|
--- a/mt7915/mcu.c
|
|
+++ b/mt7915/mcu.c
|
|
@@ -3422,7 +3422,8 @@ int mt7915_mcu_set_txpower_frame(struct mt7915_phy *phy,
|
|
int ret;
|
|
s8 txpower_sku[MT7915_SKU_RATE_NUM];
|
|
|
|
- ret = mt7915_mcu_get_txpower_sku(phy, txpower_sku, sizeof(txpower_sku));
|
|
+ ret = mt7915_mcu_get_txpower_sku(phy, txpower_sku, sizeof(txpower_sku),
|
|
+ TX_POWER_INFO_RATE);
|
|
if (ret)
|
|
return ret;
|
|
|
|
@@ -3462,53 +3463,139 @@ int mt7915_mcu_set_txpower_frame(struct mt7915_phy *phy,
|
|
sizeof(req), true);
|
|
}
|
|
|
|
+static void
|
|
+mt7915_update_txpower(struct mt7915_phy *phy, int tx_power)
|
|
+{
|
|
+ struct mt76_phy *mphy = phy->mt76;
|
|
+ struct ieee80211_channel *chan = mphy->main_chan;
|
|
+ int chain_idx, val, e2p_power_limit = 0;
|
|
+
|
|
+ if (chan == NULL) {
|
|
+ mphy->txpower_cur = tx_power;
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ for (chain_idx = 0; chain_idx < hweight16(mphy->chainmask); chain_idx++) {
|
|
+ val = mt7915_eeprom_get_target_power(phy->dev, chan, chain_idx);
|
|
+ val += mt7915_eeprom_get_power_delta(phy->dev, chan->band);
|
|
+
|
|
+ e2p_power_limit = max_t(int, e2p_power_limit, val);
|
|
+ }
|
|
+
|
|
+ if (phy->sku_limit_en)
|
|
+ mphy->txpower_cur = min_t(int, e2p_power_limit, tx_power);
|
|
+ else
|
|
+ mphy->txpower_cur = e2p_power_limit;
|
|
+}
|
|
+
|
|
int mt7915_mcu_set_txpower_sku(struct mt7915_phy *phy)
|
|
{
|
|
+#define TX_POWER_LIMIT_TABLE_RATE 0
|
|
+#define TX_POWER_LIMIT_TABLE_PATH 1
|
|
struct mt7915_dev *dev = phy->dev;
|
|
struct mt76_phy *mphy = phy->mt76;
|
|
struct ieee80211_hw *hw = mphy->hw;
|
|
- struct mt7915_mcu_txpower_sku req = {
|
|
+ struct mt7915_sku_val {
|
|
+ u8 format_id;
|
|
+ u8 limit_type;
|
|
+ u8 band_idx;
|
|
+ } __packed hdr = {
|
|
.format_id = TX_POWER_LIMIT_TABLE,
|
|
+ .limit_type = TX_POWER_LIMIT_TABLE_RATE,
|
|
.band_idx = phy->mt76->band_idx,
|
|
};
|
|
- struct mt76_power_limits limits_array;
|
|
- s8 *la = (s8 *)&limits_array;
|
|
- int i, idx;
|
|
- int tx_power;
|
|
+ int i, ret, tx_power;
|
|
+ const u8 *len = mt7915_sku_group_len;
|
|
+ struct mt76_power_limits la = {};
|
|
+ struct sk_buff *skb;
|
|
|
|
tx_power = mt7915_get_power_bound(phy, hw->conf.power_level);
|
|
- tx_power = mt76_get_rate_power_limits(mphy, mphy->chandef.chan,
|
|
- &limits_array, tx_power);
|
|
- mphy->txpower_cur = tx_power;
|
|
|
|
- for (i = 0, idx = 0; i < ARRAY_SIZE(mt7915_sku_group_len); i++) {
|
|
- u8 mcs_num, len = mt7915_sku_group_len[i];
|
|
- int j;
|
|
+ if (phy->sku_limit_en) {
|
|
+ tx_power = mt76_get_rate_power_limits(mphy, mphy->chandef.chan,
|
|
+ &la, tx_power);
|
|
+ mt7915_update_txpower(phy, tx_power);
|
|
+ } else {
|
|
+ mt7915_update_txpower(phy, tx_power);
|
|
+ return 0;
|
|
+ }
|
|
|
|
- if (i >= SKU_HT_BW20 && i <= SKU_VHT_BW160) {
|
|
- mcs_num = 10;
|
|
+ skb = mt76_mcu_msg_alloc(&dev->mt76, NULL,
|
|
+ sizeof(hdr) + MT7915_SKU_RATE_NUM);
|
|
+ if (!skb)
|
|
+ return -ENOMEM;
|
|
|
|
- if (i == SKU_HT_BW20 || i == SKU_VHT_BW20)
|
|
- la = (s8 *)&limits_array + 12;
|
|
- } else {
|
|
- mcs_num = len;
|
|
- }
|
|
+ skb_put_data(skb, &hdr, sizeof(hdr));
|
|
+ skb_put_data(skb, &la.cck, len[SKU_CCK] + len[SKU_OFDM]);
|
|
+ skb_put_data(skb, &la.mcs[0], len[SKU_HT_BW20]);
|
|
+ skb_put_data(skb, &la.mcs[1], len[SKU_HT_BW40]);
|
|
+
|
|
+ /* vht */
|
|
+ for (i = 0; i < 4; i++) {
|
|
+ skb_put_data(skb, &la.mcs[i], sizeof(la.mcs[i]));
|
|
+ skb_put_zero(skb, 2); /* padding */
|
|
+ }
|
|
|
|
- for (j = 0; j < min_t(u8, mcs_num, len); j++)
|
|
- req.txpower_sku[idx + j] = la[j];
|
|
+ /* he */
|
|
+ skb_put_data(skb, &la.ru[0], sizeof(la.ru));
|
|
|
|
- la += mcs_num;
|
|
- idx += len;
|
|
+ ret = mt76_mcu_skb_send_msg(&dev->mt76, skb,
|
|
+ MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), true);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ /* only set per-path power table when it's configured */
|
|
+ if (!phy->sku_path_en)
|
|
+ return 0;
|
|
+
|
|
+ skb = mt76_mcu_msg_alloc(&dev->mt76, NULL,
|
|
+ sizeof(hdr) + MT7915_SKU_PATH_NUM);
|
|
+ if (!skb)
|
|
+ return -ENOMEM;
|
|
+
|
|
+ hdr.limit_type = TX_POWER_LIMIT_TABLE_PATH;
|
|
+ skb_put_data(skb, &hdr, sizeof(hdr));
|
|
+ skb_put_data(skb, &la.path.cck, sizeof(la.path.cck));
|
|
+ skb_put_data(skb, &la.path.ofdm, sizeof(la.path.ofdm));
|
|
+ skb_put_data(skb, &la.path.ofdm_bf[1], sizeof(la.path.ofdm_bf) - 1);
|
|
+
|
|
+ /* HT20 and HT40 */
|
|
+ skb_put_data(skb, &la.path.ru[3], sizeof(la.path.ru[3]));
|
|
+ skb_put_data(skb, &la.path.ru_bf[3][1], sizeof(la.path.ru_bf[3]) - 1);
|
|
+ skb_put_data(skb, &la.path.ru[4], sizeof(la.path.ru[4]));
|
|
+ skb_put_data(skb, &la.path.ru_bf[4][1], sizeof(la.path.ru_bf[4]) - 1);
|
|
+
|
|
+ /* start from non-bf and bf fields of
|
|
+ * BW20/RU242, BW40/RU484, BW80/RU996, BW160/RU2x996,
|
|
+ * RU26, RU52, and RU106
|
|
+ */
|
|
+
|
|
+ for (i = 0; i < 8; i++) {
|
|
+ bool bf = i % 2;
|
|
+ u8 idx = (i + 6) / 2;
|
|
+ s8 *buf = bf ? la.path.ru_bf[idx] : la.path.ru[idx];
|
|
+ /* The non-bf fields of RU26 to RU106 are special cases */
|
|
+ if (bf)
|
|
+ skb_put_data(skb, buf + 1, 9);
|
|
+ else
|
|
+ skb_put_data(skb, buf, 10);
|
|
}
|
|
|
|
- return mt76_mcu_send_msg(&dev->mt76,
|
|
- MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req,
|
|
- sizeof(req), true);
|
|
+ for (i = 0; i < 6; i++) {
|
|
+ bool bf = i % 2;
|
|
+ u8 idx = i / 2;
|
|
+ s8 *buf = bf ? la.path.ru_bf[idx] : la.path.ru[idx];
|
|
+
|
|
+ skb_put_data(skb, buf, 10);
|
|
+ }
|
|
+
|
|
+ return mt76_mcu_skb_send_msg(&dev->mt76, skb,
|
|
+ MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), true);
|
|
}
|
|
|
|
-int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len)
|
|
+int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len,
|
|
+ u8 category)
|
|
{
|
|
-#define RATE_POWER_INFO 2
|
|
struct mt7915_dev *dev = phy->dev;
|
|
struct {
|
|
u8 format_id;
|
|
@@ -3517,10 +3604,9 @@ int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len)
|
|
u8 _rsv;
|
|
} __packed req = {
|
|
.format_id = TX_POWER_LIMIT_INFO,
|
|
- .category = RATE_POWER_INFO,
|
|
+ .category = category,
|
|
.band_idx = phy->mt76->band_idx,
|
|
};
|
|
- s8 txpower_sku[MT7915_SKU_RATE_NUM][2];
|
|
struct sk_buff *skb;
|
|
int ret, i;
|
|
|
|
@@ -3530,9 +3616,15 @@ int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len)
|
|
if (ret)
|
|
return ret;
|
|
|
|
- memcpy(txpower_sku, skb->data + 4, sizeof(txpower_sku));
|
|
- for (i = 0; i < len; i++)
|
|
- txpower[i] = txpower_sku[i][req.band_idx];
|
|
+ if (category == TX_POWER_INFO_RATE) {
|
|
+ s8 res[MT7915_SKU_RATE_NUM][2];
|
|
+
|
|
+ memcpy(res, skb->data + 4, sizeof(res));
|
|
+ for (i = 0; i < len; i++)
|
|
+ txpower[i] = res[i][req.band_idx];
|
|
+ } else if (category == TX_POWER_INFO_PATH) {
|
|
+ memcpy(txpower, skb->data + 4, len);
|
|
+ }
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
@@ -3561,7 +3653,7 @@ int mt7915_mcu_set_test_param(struct mt7915_dev *dev, u8 param, bool test_mode,
|
|
sizeof(req), false);
|
|
}
|
|
|
|
-int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable)
|
|
+int mt7915_mcu_set_sku_en(struct mt7915_phy *phy)
|
|
{
|
|
struct mt7915_dev *dev = phy->dev;
|
|
struct mt7915_sku {
|
|
@@ -3572,10 +3664,24 @@ int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable)
|
|
} __packed req = {
|
|
.format_id = TX_POWER_LIMIT_ENABLE,
|
|
.band_idx = phy->mt76->band_idx,
|
|
- .sku_enable = enable,
|
|
};
|
|
+ int ret, sku_disable = 0;
|
|
+
|
|
+#ifdef MTK_DEBUG
|
|
+ sku_disable = dev->dbg.sku_disable;
|
|
+#endif
|
|
+ req.sku_enable = sku_disable ? 0 : phy->sku_limit_en;
|
|
+ ret = mt76_mcu_send_msg(&dev->mt76,
|
|
+ MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req,
|
|
+ sizeof(req), true);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ pr_info("%s: sku enable = %d, path enable = %d\n", __func__,
|
|
+ sku_disable ? 0 : phy->sku_limit_en, sku_disable ? 0 : phy->sku_path_en);
|
|
|
|
- pr_info("%s: enable = %d\n", __func__, enable);
|
|
+ req.sku_enable = sku_disable ? 0 : phy->sku_path_en;
|
|
+ req.format_id = TX_POWER_LIMIT_PATH_ENABLE;
|
|
|
|
return mt76_mcu_send_msg(&dev->mt76,
|
|
MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req,
|
|
diff --git a/mt7915/mcu.h b/mt7915/mcu.h
|
|
index 1b0bd06..94eff26 100644
|
|
--- a/mt7915/mcu.h
|
|
+++ b/mt7915/mcu.h
|
|
@@ -517,12 +517,18 @@ enum {
|
|
|
|
enum {
|
|
TX_POWER_LIMIT_ENABLE,
|
|
+ TX_POWER_LIMIT_PATH_ENABLE = 0x3,
|
|
TX_POWER_LIMIT_TABLE = 0x4,
|
|
TX_POWER_LIMIT_INFO = 0x7,
|
|
TX_POWER_LIMIT_FRAME = 0x11,
|
|
TX_POWER_LIMIT_FRAME_MIN = 0x12,
|
|
};
|
|
|
|
+enum {
|
|
+ TX_POWER_INFO_PATH = 1,
|
|
+ TX_POWER_INFO_RATE,
|
|
+};
|
|
+
|
|
enum {
|
|
SPR_ENABLE = 0x1,
|
|
SPR_ENABLE_SD = 0x3,
|
|
diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
|
|
index 1e5cd94..826682b 100644
|
|
--- a/mt7915/mt7915.h
|
|
+++ b/mt7915/mt7915.h
|
|
@@ -72,6 +72,7 @@
|
|
#define MT7915_CDEV_THROTTLE_MAX 99
|
|
|
|
#define MT7915_SKU_RATE_NUM 161
|
|
+#define MT7915_SKU_PATH_NUM 185
|
|
|
|
#define MT7915_MAX_TWT_AGRT 16
|
|
#define MT7915_MAX_STA_TWT_AGRT 8
|
|
@@ -300,6 +301,9 @@ struct mt7915_phy {
|
|
struct list_head stats_list;
|
|
spinlock_t stats_lock;
|
|
|
|
+ bool sku_limit_en;
|
|
+ bool sku_path_en;
|
|
+
|
|
#ifdef CONFIG_NL80211_TESTMODE
|
|
struct {
|
|
u32 *reg_backup;
|
|
@@ -626,9 +630,10 @@ int mt7915_mcu_set_mac(struct mt7915_dev *dev, int band, bool enable,
|
|
int mt7915_mcu_set_test_param(struct mt7915_dev *dev, u8 param, bool test_mode,
|
|
u8 en);
|
|
int mt7915_mcu_set_ser(struct mt7915_dev *dev, u8 action, u8 set, u8 band);
|
|
-int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable);
|
|
+int mt7915_mcu_set_sku_en(struct mt7915_phy *phy);
|
|
int mt7915_mcu_set_txpower_sku(struct mt7915_phy *phy);
|
|
-int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len);
|
|
+int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len,
|
|
+ u8 category);
|
|
int mt7915_mcu_set_txpower_frame_min(struct mt7915_phy *phy, s8 txpower);
|
|
int mt7915_mcu_set_txpower_frame(struct mt7915_phy *phy,
|
|
struct ieee80211_vif *vif,
|
|
--
|
|
2.18.0
|
|
|