blob: e3e2aa71d53d4f298263c8bdeb45ac8fab50d2b1 [file] [log] [blame]
From b159ab04d85f593ca0785404469f2ea23eababef Mon Sep 17 00:00:00 2001
From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Date: Mon, 11 Sep 2023 14:43:07 +0800
Subject: [PATCH 1036/1044] mtk: wifi: mt76: testmode: add channel 68 & 96
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Add all the channel between 68 & 96 since ibf 5g channel group 3 will use channel 84.
Also, "mtk: wifi: mt76: testmode: add channel 68 & 96" can be
merged into to "mtk: wifi: mt76: testmode: add basic testmode support"
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Fix 5g channel list size
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
---
mac80211.c | 9 +++++++++
mt7996/eeprom.c | 49 +++++++++++++++++++++++++++++++++++++++++++++--
mt7996/eeprom.h | 2 ++
mt7996/mcu.c | 10 +++++++++-
mt7996/testmode.c | 15 ++++++++++++---
mt7996/testmode.h | 6 +++---
6 files changed, 82 insertions(+), 9 deletions(-)
diff --git a/mac80211.c b/mac80211.c
index ae040ec4..f7cd47f9 100644
--- a/mac80211.c
+++ b/mac80211.c
@@ -35,6 +35,15 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
CHAN5G(60, 5300),
CHAN5G(64, 5320),
+ CHAN5G(68, 5340),
+ CHAN5G(72, 5360),
+ CHAN5G(76, 5380),
+ CHAN5G(80, 5400),
+ CHAN5G(84, 5420),
+ CHAN5G(88, 5440),
+ CHAN5G(92, 5460),
+ CHAN5G(96, 5480),
+
CHAN5G(100, 5500),
CHAN5G(104, 5520),
CHAN5G(108, 5540),
diff --git a/mt7996/eeprom.c b/mt7996/eeprom.c
index d93b1558..1eb292c0 100644
--- a/mt7996/eeprom.c
+++ b/mt7996/eeprom.c
@@ -18,6 +18,17 @@ const struct ieee80211_channel dpd_2g_ch_list_bw20[] = {
CHAN2G(11, 2462)
};
+const struct ieee80211_channel dpd_5g_skip_ch_list[] = {
+ CHAN5G(68, 5340),
+ CHAN5G(72, 5360),
+ CHAN5G(76, 5380),
+ CHAN5G(80, 5400),
+ CHAN5G(84, 5420),
+ CHAN5G(88, 5440),
+ CHAN5G(92, 5460),
+ CHAN5G(96, 5480)
+};
+
const struct ieee80211_channel dpd_5g_ch_list_bw160[] = {
CHAN5G(50, 5250),
CHAN5G(114, 5570),
@@ -44,6 +55,7 @@ const struct ieee80211_channel dpd_6g_ch_list_bw320[] = {
};
const u32 dpd_2g_bw20_ch_num = ARRAY_SIZE(dpd_2g_ch_list_bw20);
+const u32 dpd_5g_skip_ch_num = ARRAY_SIZE(dpd_5g_skip_ch_list);
const u32 dpd_5g_bw160_ch_num = ARRAY_SIZE(dpd_5g_ch_list_bw160);
const u32 dpd_6g_bw160_ch_num = ARRAY_SIZE(dpd_6g_ch_list_bw160);
const u32 dpd_6g_bw320_ch_num = ARRAY_SIZE(dpd_6g_ch_list_bw320);
@@ -138,8 +150,8 @@ mt7996_get_dpd_per_band_size(struct mt7996_dev *dev, enum nl80211_band band)
if (band == NL80211_BAND_2GHZ)
dpd_size = dpd_2g_bw20_ch_num * DPD_PER_CH_BW20_SIZE;
else if (band == NL80211_BAND_5GHZ)
- dpd_size = mphy->sband_5g.sband.n_channels * DPD_PER_CH_BW20_SIZE +
- dpd_5g_bw160_ch_num * DPD_PER_CH_GT_BW20_SIZE;
+ dpd_size = (mphy->sband_5g.sband.n_channels - dpd_5g_skip_ch_num) *
+ DPD_PER_CH_BW20_SIZE + dpd_5g_bw160_ch_num * DPD_PER_CH_GT_BW20_SIZE;
else
dpd_size = mphy->sband_6g.sband.n_channels * DPD_PER_CH_BW20_SIZE +
(dpd_6g_bw160_ch_num + dpd_6g_bw320_ch_num) * DPD_PER_CH_GT_BW20_SIZE;
@@ -399,6 +411,39 @@ out:
return ret;
}
+static void mt7996_eeprom_init_precal(struct mt7996_dev *dev)
+{
+#define MT76_CHANNELS_5GHZ_SIZE 36 /* ARRAY_SIZE(mt76_channels_5ghz) */
+#define MT76_CHANNELS_6GHZ_SIZE 59 /* ARRAY_SIZE(mt76_channels_6ghz) */
+
+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW20_2G] = ARRAY_SIZE(dpd_2g_ch_list_bw20);
+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW20_5G_SKIP] = ARRAY_SIZE(dpd_5g_skip_ch_list);
+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW20_5G] = MT76_CHANNELS_5GHZ_SIZE -
+ DPD_CH_NUM(BW20_5G_SKIP);
+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW160_5G] = ARRAY_SIZE(dpd_5g_ch_list_bw160);
+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW20_6G] = MT76_CHANNELS_6GHZ_SIZE;
+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW160_6G] = ARRAY_SIZE(dpd_6g_ch_list_bw160);
+
+ switch (mt76_chip(&dev->mt76)) {
+ case 0x7990:
+ dev->prek.rev = mt7996_prek_rev;
+ /* 5g & 6g bw 80 dpd channel list is not used */
+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW320_6G] = ARRAY_SIZE(dpd_6g_ch_list_bw320);
+ break;
+ case 0x7992:
+ dev->prek.rev = mt7992_prek_rev;
+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW80_5G] = ARRAY_SIZE(dpd_5g_ch_list_bw80);
+ /* 6g is not used in current sku */
+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW20_6G] = 0;
+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW80_6G] = 0;
+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW160_6G] = 0;
+ break;
+ default:
+ dev->prek.rev = mt7996_prek_rev;
+ break;
+ }
+}
+
static int mt7996_eeprom_load_precal(struct mt7996_dev *dev)
{
struct mt76_dev *mdev = &dev->mt76;
diff --git a/mt7996/eeprom.h b/mt7996/eeprom.h
index 8f0f87b6..3e9992a3 100644
--- a/mt7996/eeprom.h
+++ b/mt7996/eeprom.h
@@ -67,6 +67,8 @@ enum mt7996_eeprom_field {
extern const struct ieee80211_channel dpd_2g_ch_list_bw20[];
extern const u32 dpd_2g_bw20_ch_num;
+extern const struct ieee80211_channel dpd_5g_skip_ch_list[];
+extern const u32 dpd_5g_skip_ch_num;
extern const struct ieee80211_channel dpd_5g_ch_list_bw160[];
extern const u32 dpd_5g_bw160_ch_num;
extern const struct ieee80211_channel dpd_6g_ch_list_bw160[];
diff --git a/mt7996/mcu.c b/mt7996/mcu.c
index ded28e9a..cf46fee4 100644
--- a/mt7996/mcu.c
+++ b/mt7996/mcu.c
@@ -3780,7 +3780,8 @@ int mt7996_mcu_apply_tx_dpd(struct mt7996_phy *phy)
chan_list_size = mphy->sband_5g.sband.n_channels;
base_offset += dpd_size_2g;
if (bw == NL80211_CHAN_WIDTH_160) {
- base_offset += mphy->sband_5g.sband.n_channels * DPD_PER_CH_BW20_SIZE;
+ base_offset += (mphy->sband_5g.sband.n_channels - dpd_5g_skip_ch_num) *
+ DPD_PER_CH_BW20_SIZE;
per_chan_size = DPD_PER_CH_GT_BW20_SIZE;
cal_id = RF_DPD_FLAT_5G_MEM_CAL;
chan_list = dpd_5g_ch_list_bw160;
@@ -3789,6 +3790,9 @@ int mt7996_mcu_apply_tx_dpd(struct mt7996_phy *phy)
/* apply (center channel - 2)'s dpd cal data for bw 40/80 channels */
channel -= 2;
}
+ if (channel >= dpd_5g_skip_ch_list[0].hw_value &&
+ channel <= dpd_5g_skip_ch_list[dpd_5g_skip_ch_num - 1].hw_value)
+ return 0;
break;
case NL80211_BAND_6GHZ:
dpd_mask = MT_EE_WIFI_CAL_DPD_6G;
@@ -3828,6 +3832,10 @@ int mt7996_mcu_apply_tx_dpd(struct mt7996_phy *phy)
if (idx == chan_list_size)
return -EINVAL;
+ if (band == NL80211_BAND_5GHZ && bw != NL80211_CHAN_WIDTH_160 &&
+ channel > dpd_5g_skip_ch_list[dpd_5g_skip_ch_num - 1].hw_value)
+ idx -= dpd_5g_skip_ch_num;
+
cal += MT_EE_CAL_GROUP_SIZE + base_offset + idx * per_chan_size;
for (i = 0; i < per_chan_size / MT_EE_CAL_UNIT; i++) {
diff --git a/mt7996/testmode.c b/mt7996/testmode.c
index 2fb36a97..0dc6629d 100644
--- a/mt7996/testmode.c
+++ b/mt7996/testmode.c
@@ -531,6 +531,11 @@ mt7996_tm_dpd_prek_send_req(struct mt7996_phy *phy, struct mt7996_tm_req *req,
memcpy(&chandef_backup, chandef, sizeof(struct cfg80211_chan_def));
for (i = 0; i < channel_size; i++) {
+ if (chan_list[i].band == NL80211_BAND_5GHZ &&
+ chan_list[i].hw_value >= dpd_5g_skip_ch_list[0].hw_value &&
+ chan_list[i].hw_value <= dpd_5g_skip_ch_list[dpd_5g_skip_ch_num - 1].hw_value)
+ continue;
+
memcpy(chandef->chan, &chan_list[i], sizeof(struct ieee80211_channel));
chandef->width = width;
@@ -612,7 +617,8 @@ mt7996_tm_dpd_prek(struct mt7996_phy *phy, enum mt76_testmode_state state)
NL80211_CHAN_WIDTH_20, RF_DPD_FLAT_5G_CAL);
if (ret)
return ret;
- wait_on_prek_offset += mphy->sband_5g.sband.n_channels * DPD_PER_CH_BW20_SIZE;
+ wait_on_prek_offset += (mphy->sband_5g.sband.n_channels - dpd_5g_skip_ch_num) *
+ DPD_PER_CH_BW20_SIZE;
wait_event_timeout(mdev->mcu.wait,
dev->cur_prek_offset == wait_on_prek_offset, 30 * HZ);
@@ -868,6 +874,7 @@ mt7996_tm_get_center_chan(struct mt7996_phy *phy, struct cfg80211_chan_def *chan
const struct ieee80211_channel *chan = mphy->sband_5g.sband.channels;
u32 bitmap, i, offset, width_mhz, size = mphy->sband_5g.sband.n_channels;
u16 first_control = 0, control_chan = chandef->chan->hw_value;
+ bool not_first;
bitmap = mt7996_tm_bw_mapping(chandef->width, BW_MAP_NL_TO_CONTROL_BITMAP_5G);
if (!bitmap)
@@ -877,7 +884,9 @@ mt7996_tm_get_center_chan(struct mt7996_phy *phy, struct cfg80211_chan_def *chan
offset = width_mhz / 10 - 2;
for (i = 0; i < size; i++) {
- if (!((1 << i) & bitmap))
+ not_first = (chandef->width != NL80211_CHAN_WIDTH_160) ?
+ (i % bitmap) : (i >= 32) || !((1 << i) & bitmap);
+ if (not_first)
continue;
if (control_chan >= chan[i].hw_value)
@@ -886,7 +895,7 @@ mt7996_tm_get_center_chan(struct mt7996_phy *phy, struct cfg80211_chan_def *chan
break;
}
- if (i == size || first_control == 0)
+ if (first_control == 0)
return control_chan;
return first_control + offset;
diff --git a/mt7996/testmode.h b/mt7996/testmode.h
index f97ccb26..ba1767ae 100644
--- a/mt7996/testmode.h
+++ b/mt7996/testmode.h
@@ -38,9 +38,9 @@ enum {
BF_CDBW_8080MHZ,
};
-#define FIRST_CONTROL_CHAN_BITMAP_BW40 0x5555555
-#define FIRST_CONTROL_CHAN_BITMAP_BW80 0x111111
-#define FIRST_CONTROL_CHAN_BITMAP_BW160 0x100101
+#define FIRST_CONTROL_CHAN_BITMAP_BW40 2
+#define FIRST_CONTROL_CHAN_BITMAP_BW80 4
+#define FIRST_CONTROL_CHAN_BITMAP_BW160 0x10010101
enum bw_mapping_method {
BW_MAP_NL_TO_FW,
--
2.18.0