Commit 3eb50cc9 authored by Ryder Lee's avatar Ryder Lee Committed by Felix Fietkau

wifi: mt76: mt7915: rely on band_idx of mt76_phy

The commit dc44c45c added band_idx into mt76_phy, so switching to
rely on that.
Signed-off-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent e3296759
...@@ -51,7 +51,7 @@ mt7915_sys_recovery_set(struct file *file, const char __user *user_buf, ...@@ -51,7 +51,7 @@ mt7915_sys_recovery_set(struct file *file, const char __user *user_buf,
{ {
struct mt7915_phy *phy = file->private_data; struct mt7915_phy *phy = file->private_data;
struct mt7915_dev *dev = phy->dev; struct mt7915_dev *dev = phy->dev;
bool band = phy->band_idx; bool band = phy->mt76->band_idx;
char buf[16]; char buf[16];
int ret = 0; int ret = 0;
u16 val; u16 val;
...@@ -692,15 +692,16 @@ mt7915_ampdu_stat_read_phy(struct mt7915_phy *phy, ...@@ -692,15 +692,16 @@ mt7915_ampdu_stat_read_phy(struct mt7915_phy *phy,
struct mt7915_dev *dev = phy->dev; struct mt7915_dev *dev = phy->dev;
bool ext_phy = phy != &dev->phy; bool ext_phy = phy != &dev->phy;
int bound[15], range[4], i; int bound[15], range[4], i;
u8 band = phy->mt76->band_idx;
/* Tx ampdu stat */ /* Tx ampdu stat */
for (i = 0; i < ARRAY_SIZE(range); i++) for (i = 0; i < ARRAY_SIZE(range); i++)
range[i] = mt76_rr(dev, MT_MIB_ARNG(phy->band_idx, i)); range[i] = mt76_rr(dev, MT_MIB_ARNG(band, i));
for (i = 0; i < ARRAY_SIZE(bound); i++) for (i = 0; i < ARRAY_SIZE(bound); i++)
bound[i] = MT_MIB_ARNCR_RANGE(range[i / 4], i % 4) + 1; bound[i] = MT_MIB_ARNCR_RANGE(range[i / 4], i % 4) + 1;
seq_printf(file, "\nPhy %d, Phy band %d\n", ext_phy, phy->band_idx); seq_printf(file, "\nPhy %d, Phy band %d\n", ext_phy, band);
seq_printf(file, "Length: %8d | ", bound[0]); seq_printf(file, "Length: %8d | ", bound[0]);
for (i = 0; i < ARRAY_SIZE(bound) - 1; i++) for (i = 0; i < ARRAY_SIZE(bound) - 1; i++)
...@@ -983,6 +984,7 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf, ...@@ -983,6 +984,7 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf,
struct mt7915_dev *dev = phy->dev; struct mt7915_dev *dev = phy->dev;
s8 txpwr[MT7915_SKU_RATE_NUM]; s8 txpwr[MT7915_SKU_RATE_NUM];
static const size_t sz = 2048; static const size_t sz = 2048;
u8 band = phy->mt76->band_idx;
int i, offs = 0, len = 0; int i, offs = 0, len = 0;
ssize_t ret; ssize_t ret;
char *buf; char *buf;
...@@ -1038,8 +1040,8 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf, ...@@ -1038,8 +1040,8 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf,
mt7915_txpower_puts(HE996, SKU_HE_RU996); mt7915_txpower_puts(HE996, SKU_HE_RU996);
mt7915_txpower_puts(HE996x2, SKU_HE_RU2x996); mt7915_txpower_puts(HE996x2, SKU_HE_RU2x996);
reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_TPC_CTRL_STAT(phy->band_idx) : reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_TPC_CTRL_STAT(band) :
MT_WF_PHY_TPC_CTRL_STAT_MT7916(phy->band_idx); MT_WF_PHY_TPC_CTRL_STAT_MT7916(band);
len += scnprintf(buf + len, sz - len, "\nTx power (bbp) : %6ld\n", len += scnprintf(buf + len, sz - len, "\nTx power (bbp) : %6ld\n",
mt76_get_field(dev, reg, MT_WF_PHY_TPC_POWER)); mt76_get_field(dev, reg, MT_WF_PHY_TPC_POWER));
...@@ -1058,7 +1060,7 @@ mt7915_rate_txpower_set(struct file *file, const char __user *user_buf, ...@@ -1058,7 +1060,7 @@ mt7915_rate_txpower_set(struct file *file, const char __user *user_buf,
struct mt76_phy *mphy = phy->mt76; struct mt76_phy *mphy = phy->mt76;
struct mt7915_mcu_txpower_sku req = { struct mt7915_mcu_txpower_sku req = {
.format_id = TX_POWER_LIMIT_TABLE, .format_id = TX_POWER_LIMIT_TABLE,
.band_idx = phy->band_idx, .band_idx = phy->mt76->band_idx,
}; };
char buf[100]; char buf[100];
int i, ret, pwr160 = 0, pwr80 = 0, pwr40 = 0, pwr20 = 0; int i, ret, pwr160 = 0, pwr80 = 0, pwr40 = 0, pwr20 = 0;
...@@ -1241,7 +1243,7 @@ int mt7915_init_debugfs(struct mt7915_phy *phy) ...@@ -1241,7 +1243,7 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
mt7915_twt_stats); mt7915_twt_stats);
debugfs_create_file("rf_regval", 0600, dir, dev, &fops_rf_regval); debugfs_create_file("rf_regval", 0600, dir, dev, &fops_rf_regval);
if (!dev->dbdc_support || phy->band_idx) { if (!dev->dbdc_support || phy->mt76->band_idx) {
debugfs_create_u32("dfs_hw_pattern", 0400, dir, debugfs_create_u32("dfs_hw_pattern", 0400, dir,
&dev->hw_pattern); &dev->hw_pattern);
debugfs_create_file("radar_trigger", 0200, dir, dev, debugfs_create_file("radar_trigger", 0200, dir, dev,
......
...@@ -353,10 +353,10 @@ static int mt7915_dma_enable(struct mt7915_dev *dev) ...@@ -353,10 +353,10 @@ static int mt7915_dma_enable(struct mt7915_dev *dev)
MT_INT_TX_DONE_MCU | MT_INT_TX_DONE_MCU |
MT_INT_MCU_CMD; MT_INT_MCU_CMD;
if (!dev->phy.band_idx) if (!dev->phy.mt76->band_idx)
irq_mask |= MT_INT_BAND0_RX_DONE; irq_mask |= MT_INT_BAND0_RX_DONE;
if (dev->dbdc_support || dev->phy.band_idx) if (dev->dbdc_support || dev->phy.mt76->band_idx)
irq_mask |= MT_INT_BAND1_RX_DONE; irq_mask |= MT_INT_BAND1_RX_DONE;
if (mtk_wed_device_active(&dev->mt76.mmio.wed)) { if (mtk_wed_device_active(&dev->mt76.mmio.wed)) {
...@@ -418,7 +418,7 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2) ...@@ -418,7 +418,7 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2)
/* init tx queue */ /* init tx queue */
ret = mt7915_init_tx_queues(&dev->phy, ret = mt7915_init_tx_queues(&dev->phy,
MT_TXQ_ID(dev->phy.band_idx), MT_TXQ_ID(dev->phy.mt76->band_idx),
MT7915_TX_RING_SIZE, MT7915_TX_RING_SIZE,
MT_TXQ_RING_BASE(0)); MT_TXQ_RING_BASE(0));
if (ret) if (ret)
...@@ -426,7 +426,7 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2) ...@@ -426,7 +426,7 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2)
if (phy2) { if (phy2) {
ret = mt7915_init_tx_queues(phy2, ret = mt7915_init_tx_queues(phy2,
MT_TXQ_ID(phy2->band_idx), MT_TXQ_ID(phy2->mt76->band_idx),
MT7915_TX_RING_SIZE, MT7915_TX_RING_SIZE,
MT_TXQ_RING_BASE(1)); MT_TXQ_RING_BASE(1));
if (ret) if (ret)
...@@ -482,7 +482,7 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2) ...@@ -482,7 +482,7 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2)
return ret; return ret;
/* rx data queue for band0 */ /* rx data queue for band0 */
if (!dev->phy.band_idx) { if (!dev->phy.mt76->band_idx) {
if (mtk_wed_device_active(&mdev->mmio.wed) && if (mtk_wed_device_active(&mdev->mmio.wed) &&
mtk_wed_get_rx_capa(&mdev->mmio.wed)) { mtk_wed_get_rx_capa(&mdev->mmio.wed)) {
dev->mt76.q_rx[MT_RXQ_MAIN].flags = dev->mt76.q_rx[MT_RXQ_MAIN].flags =
...@@ -519,7 +519,7 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2) ...@@ -519,7 +519,7 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2)
return ret; return ret;
} }
if (dev->dbdc_support || dev->phy.band_idx) { if (dev->dbdc_support || dev->phy.mt76->band_idx) {
if (mtk_wed_device_active(&mdev->mmio.wed) && if (mtk_wed_device_active(&mdev->mmio.wed) &&
mtk_wed_get_rx_capa(&mdev->mmio.wed)) { mtk_wed_get_rx_capa(&mdev->mmio.wed)) {
dev->mt76.q_rx[MT_RXQ_BAND1].flags = dev->mt76.q_rx[MT_RXQ_BAND1].flags =
......
...@@ -131,9 +131,10 @@ static void mt7915_eeprom_parse_band_config(struct mt7915_phy *phy) ...@@ -131,9 +131,10 @@ static void mt7915_eeprom_parse_band_config(struct mt7915_phy *phy)
{ {
struct mt7915_dev *dev = phy->dev; struct mt7915_dev *dev = phy->dev;
u8 *eeprom = dev->mt76.eeprom.data; u8 *eeprom = dev->mt76.eeprom.data;
u8 band = phy->mt76->band_idx;
u32 val; u32 val;
val = eeprom[MT_EE_WIFI_CONF + phy->band_idx]; val = eeprom[MT_EE_WIFI_CONF + band];
val = FIELD_GET(MT_EE_WIFI_CONF0_BAND_SEL, val); val = FIELD_GET(MT_EE_WIFI_CONF0_BAND_SEL, val);
if (!is_mt7915(&dev->mt76)) { if (!is_mt7915(&dev->mt76)) {
...@@ -153,7 +154,7 @@ static void mt7915_eeprom_parse_band_config(struct mt7915_phy *phy) ...@@ -153,7 +154,7 @@ static void mt7915_eeprom_parse_band_config(struct mt7915_phy *phy)
return; return;
} }
} else if (val == MT_EE_BAND_SEL_DEFAULT && dev->dbdc_support) { } else if (val == MT_EE_BAND_SEL_DEFAULT && dev->dbdc_support) {
val = phy->band_idx ? MT_EE_BAND_SEL_5GHZ : MT_EE_BAND_SEL_2GHZ; val = band ? MT_EE_BAND_SEL_5GHZ : MT_EE_BAND_SEL_2GHZ;
} }
switch (val) { switch (val) {
...@@ -175,6 +176,7 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev, ...@@ -175,6 +176,7 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
{ {
u8 path, nss, nss_max = 4, *eeprom = dev->mt76.eeprom.data; u8 path, nss, nss_max = 4, *eeprom = dev->mt76.eeprom.data;
struct mt76_phy *mphy = phy->mt76; struct mt76_phy *mphy = phy->mt76;
u8 band = phy->mt76->band_idx;
mt7915_eeprom_parse_band_config(phy); mt7915_eeprom_parse_band_config(phy);
...@@ -184,7 +186,7 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev, ...@@ -184,7 +186,7 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
eeprom[MT_EE_WIFI_CONF]); eeprom[MT_EE_WIFI_CONF]);
} else { } else {
path = FIELD_GET(MT_EE_WIFI_CONF0_TX_PATH, path = FIELD_GET(MT_EE_WIFI_CONF0_TX_PATH,
eeprom[MT_EE_WIFI_CONF + phy->band_idx]); eeprom[MT_EE_WIFI_CONF + band]);
} }
if (!path || path > 4) if (!path || path > 4)
...@@ -197,12 +199,12 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev, ...@@ -197,12 +199,12 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
path = min_t(u8, path, 2); path = min_t(u8, path, 2);
nss = FIELD_GET(MT_EE_WIFI_CONF3_TX_PATH_B0, nss = FIELD_GET(MT_EE_WIFI_CONF3_TX_PATH_B0,
eeprom[MT_EE_WIFI_CONF + 3]); eeprom[MT_EE_WIFI_CONF + 3]);
if (phy->band_idx) if (band)
nss = FIELD_GET(MT_EE_WIFI_CONF3_TX_PATH_B1, nss = FIELD_GET(MT_EE_WIFI_CONF3_TX_PATH_B1,
eeprom[MT_EE_WIFI_CONF + 3]); eeprom[MT_EE_WIFI_CONF + 3]);
} else { } else {
nss = FIELD_GET(MT_EE_WIFI_CONF_STREAM_NUM, nss = FIELD_GET(MT_EE_WIFI_CONF_STREAM_NUM,
eeprom[MT_EE_WIFI_CONF + 2 + phy->band_idx]); eeprom[MT_EE_WIFI_CONF + 2 + band]);
} }
if (!is_mt7986(&dev->mt76)) if (!is_mt7986(&dev->mt76))
...@@ -214,7 +216,7 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev, ...@@ -214,7 +216,7 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
nss = min_t(u8, min_t(u8, nss_max, nss), path); nss = min_t(u8, min_t(u8, nss_max, nss), path);
mphy->chainmask = BIT(path) - 1; mphy->chainmask = BIT(path) - 1;
if (phy->band_idx) if (band)
mphy->chainmask <<= dev->chainshift; mphy->chainmask <<= dev->chainshift;
mphy->antenna_mask = BIT(nss) - 1; mphy->antenna_mask = BIT(nss) - 1;
dev->chainmask |= mphy->chainmask; dev->chainmask |= mphy->chainmask;
......
...@@ -540,7 +540,7 @@ mt7915_alloc_ext_phy(struct mt7915_dev *dev) ...@@ -540,7 +540,7 @@ mt7915_alloc_ext_phy(struct mt7915_dev *dev)
phy->mt76 = mphy; phy->mt76 = mphy;
/* Bind main phy to band0 and ext_phy to band1 for dbdc case */ /* Bind main phy to band0 and ext_phy to band1 for dbdc case */
phy->band_idx = 1; phy->mt76->band_idx = 1;
return phy; return phy;
} }
...@@ -660,7 +660,7 @@ static bool mt7915_band_config(struct mt7915_dev *dev) ...@@ -660,7 +660,7 @@ static bool mt7915_band_config(struct mt7915_dev *dev)
{ {
bool ret = true; bool ret = true;
dev->phy.band_idx = 0; dev->phy.mt76->band_idx = 0;
if (is_mt7986(&dev->mt76)) { if (is_mt7986(&dev->mt76)) {
u32 sku = mt7915_check_adie(dev, true); u32 sku = mt7915_check_adie(dev, true);
...@@ -671,7 +671,7 @@ static bool mt7915_band_config(struct mt7915_dev *dev) ...@@ -671,7 +671,7 @@ static bool mt7915_band_config(struct mt7915_dev *dev)
* dbdc is disabled. * dbdc is disabled.
*/ */
if (sku == MT7975_ONE_ADIE || sku == MT7976_ONE_ADIE) { if (sku == MT7975_ONE_ADIE || sku == MT7976_ONE_ADIE) {
dev->phy.band_idx = 1; dev->phy.mt76->band_idx = 1;
ret = false; ret = false;
} }
} else { } else {
......
...@@ -30,31 +30,35 @@ int mt7915_run(struct ieee80211_hw *hw) ...@@ -30,31 +30,35 @@ int mt7915_run(struct ieee80211_hw *hw)
running = mt7915_dev_running(dev); running = mt7915_dev_running(dev);
if (!running) { if (!running) {
ret = mt76_connac_mcu_set_pm(&dev->mt76, dev->phy.band_idx, 0); ret = mt76_connac_mcu_set_pm(&dev->mt76,
dev->phy.mt76->band_idx, 0);
if (ret) if (ret)
goto out; goto out;
ret = mt7915_mcu_set_mac(dev, dev->phy.band_idx, true, true); ret = mt7915_mcu_set_mac(dev, dev->phy.mt76->band_idx,
true, true);
if (ret) if (ret)
goto out; goto out;
mt7915_mac_enable_nf(dev, dev->phy.band_idx); mt7915_mac_enable_nf(dev, dev->phy.mt76->band_idx);
} }
if (phy != &dev->phy) { if (phy != &dev->phy) {
ret = mt76_connac_mcu_set_pm(&dev->mt76, phy->band_idx, 0); ret = mt76_connac_mcu_set_pm(&dev->mt76,
phy->mt76->band_idx, 0);
if (ret) if (ret)
goto out; goto out;
ret = mt7915_mcu_set_mac(dev, phy->band_idx, true, true); ret = mt7915_mcu_set_mac(dev, phy->mt76->band_idx,
true, true);
if (ret) if (ret)
goto out; goto out;
mt7915_mac_enable_nf(dev, phy->band_idx); mt7915_mac_enable_nf(dev, phy->mt76->band_idx);
} }
ret = mt76_connac_mcu_set_rts_thresh(&dev->mt76, 0x92b, ret = mt76_connac_mcu_set_rts_thresh(&dev->mt76, 0x92b,
phy->band_idx); phy->mt76->band_idx);
if (ret) if (ret)
goto out; goto out;
...@@ -107,13 +111,13 @@ static void mt7915_stop(struct ieee80211_hw *hw) ...@@ -107,13 +111,13 @@ static void mt7915_stop(struct ieee80211_hw *hw)
clear_bit(MT76_STATE_RUNNING, &phy->mt76->state); clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
if (phy != &dev->phy) { if (phy != &dev->phy) {
mt76_connac_mcu_set_pm(&dev->mt76, phy->band_idx, 1); mt76_connac_mcu_set_pm(&dev->mt76, phy->mt76->band_idx, 1);
mt7915_mcu_set_mac(dev, phy->band_idx, false, false); mt7915_mcu_set_mac(dev, phy->mt76->band_idx, false, false);
} }
if (!mt7915_dev_running(dev)) { if (!mt7915_dev_running(dev)) {
mt76_connac_mcu_set_pm(&dev->mt76, dev->phy.band_idx, 1); mt76_connac_mcu_set_pm(&dev->mt76, dev->phy.mt76->band_idx, 1);
mt7915_mcu_set_mac(dev, dev->phy.band_idx, false, false); mt7915_mcu_set_mac(dev, dev->phy.mt76->band_idx, false, false);
} }
mutex_unlock(&dev->mt76.mutex); mutex_unlock(&dev->mt76.mutex);
...@@ -217,7 +221,7 @@ static int mt7915_add_interface(struct ieee80211_hw *hw, ...@@ -217,7 +221,7 @@ static int mt7915_add_interface(struct ieee80211_hw *hw,
} }
mvif->mt76.omac_idx = idx; mvif->mt76.omac_idx = idx;
mvif->phy = phy; mvif->phy = phy;
mvif->mt76.band_idx = phy->band_idx; mvif->mt76.band_idx = phy->mt76->band_idx;
mvif->mt76.wmm_idx = vif->type != NL80211_IFTYPE_AP; mvif->mt76.wmm_idx = vif->type != NL80211_IFTYPE_AP;
if (ext_phy) if (ext_phy)
...@@ -467,7 +471,7 @@ static int mt7915_config(struct ieee80211_hw *hw, u32 changed) ...@@ -467,7 +471,7 @@ static int mt7915_config(struct ieee80211_hw *hw, u32 changed)
if (changed & IEEE80211_CONF_CHANGE_MONITOR) { if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
bool enabled = !!(hw->conf.flags & IEEE80211_CONF_MONITOR); bool enabled = !!(hw->conf.flags & IEEE80211_CONF_MONITOR);
bool band = phy->band_idx; bool band = phy->mt76->band_idx;
if (!enabled) if (!enabled)
phy->rxfilter |= MT_WF_RFCR_DROP_OTHER_UC; phy->rxfilter |= MT_WF_RFCR_DROP_OTHER_UC;
...@@ -506,7 +510,7 @@ static void mt7915_configure_filter(struct ieee80211_hw *hw, ...@@ -506,7 +510,7 @@ static void mt7915_configure_filter(struct ieee80211_hw *hw,
{ {
struct mt7915_dev *dev = mt7915_hw_dev(hw); struct mt7915_dev *dev = mt7915_hw_dev(hw);
struct mt7915_phy *phy = mt7915_hw_phy(hw); struct mt7915_phy *phy = mt7915_hw_phy(hw);
bool band = phy->band_idx; bool band = phy->mt76->band_idx;
u32 ctl_flags = MT_WF_RFCR1_DROP_ACK | u32 ctl_flags = MT_WF_RFCR1_DROP_ACK |
MT_WF_RFCR1_DROP_BF_POLL | MT_WF_RFCR1_DROP_BF_POLL |
MT_WF_RFCR1_DROP_BA | MT_WF_RFCR1_DROP_BA |
...@@ -743,7 +747,8 @@ static int mt7915_set_rts_threshold(struct ieee80211_hw *hw, u32 val) ...@@ -743,7 +747,8 @@ static int mt7915_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
int ret; int ret;
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
ret = mt76_connac_mcu_set_rts_thresh(&dev->mt76, val, phy->band_idx); ret = mt76_connac_mcu_set_rts_thresh(&dev->mt76, val,
phy->mt76->band_idx);
mutex_unlock(&dev->mt76.mutex); mutex_unlock(&dev->mt76.mutex);
return ret; return ret;
...@@ -846,7 +851,7 @@ u64 __mt7915_get_tsf(struct ieee80211_hw *hw, struct mt7915_vif *mvif) ...@@ -846,7 +851,7 @@ u64 __mt7915_get_tsf(struct ieee80211_hw *hw, struct mt7915_vif *mvif)
{ {
struct mt7915_dev *dev = mt7915_hw_dev(hw); struct mt7915_dev *dev = mt7915_hw_dev(hw);
struct mt7915_phy *phy = mt7915_hw_phy(hw); struct mt7915_phy *phy = mt7915_hw_phy(hw);
bool band = phy->band_idx; bool band = phy->mt76->band_idx;
union { union {
u64 t64; u64 t64;
u32 t32[2]; u32 t32[2];
...@@ -891,7 +896,7 @@ mt7915_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, ...@@ -891,7 +896,7 @@ mt7915_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
struct mt7915_dev *dev = mt7915_hw_dev(hw); struct mt7915_dev *dev = mt7915_hw_dev(hw);
struct mt7915_phy *phy = mt7915_hw_phy(hw); struct mt7915_phy *phy = mt7915_hw_phy(hw);
bool band = phy->band_idx; bool band = phy->mt76->band_idx;
union { union {
u64 t64; u64 t64;
u32 t32[2]; u32 t32[2];
...@@ -922,7 +927,7 @@ mt7915_offset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, ...@@ -922,7 +927,7 @@ mt7915_offset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
struct mt7915_dev *dev = mt7915_hw_dev(hw); struct mt7915_dev *dev = mt7915_hw_dev(hw);
struct mt7915_phy *phy = mt7915_hw_phy(hw); struct mt7915_phy *phy = mt7915_hw_phy(hw);
bool band = phy->band_idx; bool band = phy->mt76->band_idx;
union { union {
u64 t64; u64 t64;
u32 t32[2]; u32 t32[2];
...@@ -965,6 +970,7 @@ mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) ...@@ -965,6 +970,7 @@ mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
struct mt7915_phy *phy = mt7915_hw_phy(hw); struct mt7915_phy *phy = mt7915_hw_phy(hw);
int max_nss = hweight8(hw->wiphy->available_antennas_tx); int max_nss = hweight8(hw->wiphy->available_antennas_tx);
u8 chainshift = dev->chainshift; u8 chainshift = dev->chainshift;
u8 band = phy->mt76->band_idx;
if (!tx_ant || tx_ant != rx_ant || ffs(tx_ant) > max_nss) if (!tx_ant || tx_ant != rx_ant || ffs(tx_ant) > max_nss)
return -EINVAL; return -EINVAL;
...@@ -974,10 +980,10 @@ mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) ...@@ -974,10 +980,10 @@ mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
phy->mt76->antenna_mask = tx_ant; phy->mt76->antenna_mask = tx_ant;
/* handle a variant of mt7916 which has 3T3R but nss2 on 5 GHz band */ /* handle a variant of mt7916 which has 3T3R but nss2 on 5 GHz band */
if (is_mt7916(&dev->mt76) && phy->band_idx && hweight8(tx_ant) == max_nss) if (is_mt7916(&dev->mt76) && band && hweight8(tx_ant) == max_nss)
phy->mt76->chainmask = (dev->chainmask >> chainshift) << chainshift; phy->mt76->chainmask = (dev->chainmask >> chainshift) << chainshift;
else else
phy->mt76->chainmask = tx_ant << (chainshift * phy->band_idx); phy->mt76->chainmask = tx_ant << (chainshift * band);
mt76_set_stream_caps(phy->mt76, true); mt76_set_stream_caps(phy->mt76, true);
mt7915_set_stream_vht_txbf_caps(phy); mt7915_set_stream_vht_txbf_caps(phy);
......
...@@ -232,7 +232,8 @@ mt7915_mcu_rx_csa_notify(struct mt7915_dev *dev, struct sk_buff *skb) ...@@ -232,7 +232,8 @@ mt7915_mcu_rx_csa_notify(struct mt7915_dev *dev, struct sk_buff *skb)
c = (struct mt7915_mcu_csa_notify *)skb->data; c = (struct mt7915_mcu_csa_notify *)skb->data;
if ((c->band_idx && !dev->phy.band_idx) && dev->mt76.phys[MT_BAND1]) if ((c->band_idx && !dev->phy.mt76->band_idx) &&
dev->mt76.phys[MT_BAND1])
mphy = dev->mt76.phys[MT_BAND1]; mphy = dev->mt76.phys[MT_BAND1];
ieee80211_iterate_active_interfaces_atomic(mphy->hw, ieee80211_iterate_active_interfaces_atomic(mphy->hw,
...@@ -251,7 +252,8 @@ mt7915_mcu_rx_thermal_notify(struct mt7915_dev *dev, struct sk_buff *skb) ...@@ -251,7 +252,8 @@ mt7915_mcu_rx_thermal_notify(struct mt7915_dev *dev, struct sk_buff *skb)
if (t->ctrl.ctrl_id != THERMAL_PROTECT_ENABLE) if (t->ctrl.ctrl_id != THERMAL_PROTECT_ENABLE)
return; return;
if ((t->ctrl.band_idx && !dev->phy.band_idx) && dev->mt76.phys[MT_BAND1]) if ((t->ctrl.band_idx && !dev->phy.mt76->band_idx) &&
dev->mt76.phys[MT_BAND1])
mphy = dev->mt76.phys[MT_BAND1]; mphy = dev->mt76.phys[MT_BAND1];
phy = (struct mt7915_phy *)mphy->priv; phy = (struct mt7915_phy *)mphy->priv;
...@@ -266,7 +268,8 @@ mt7915_mcu_rx_radar_detected(struct mt7915_dev *dev, struct sk_buff *skb) ...@@ -266,7 +268,8 @@ mt7915_mcu_rx_radar_detected(struct mt7915_dev *dev, struct sk_buff *skb)
r = (struct mt7915_mcu_rdd_report *)skb->data; r = (struct mt7915_mcu_rdd_report *)skb->data;
if ((r->band_idx && !dev->phy.band_idx) && dev->mt76.phys[MT_BAND1]) if ((r->band_idx && !dev->phy.mt76->band_idx) &&
dev->mt76.phys[MT_BAND1])
mphy = dev->mt76.phys[MT_BAND1]; mphy = dev->mt76.phys[MT_BAND1];
if (r->band_idx == MT_RX_SEL2) if (r->band_idx == MT_RX_SEL2)
...@@ -323,7 +326,7 @@ mt7915_mcu_rx_bcc_notify(struct mt7915_dev *dev, struct sk_buff *skb) ...@@ -323,7 +326,7 @@ mt7915_mcu_rx_bcc_notify(struct mt7915_dev *dev, struct sk_buff *skb)
b = (struct mt7915_mcu_bcc_notify *)skb->data; b = (struct mt7915_mcu_bcc_notify *)skb->data;
if ((b->band_idx && !dev->phy.band_idx) && dev->mt76.phys[MT_BAND1]) if ((b->band_idx && !dev->phy.mt76->band_idx) && dev->mt76.phys[MT_BAND1])
mphy = dev->mt76.phys[MT_BAND1]; mphy = dev->mt76.phys[MT_BAND1];
ieee80211_iterate_active_interfaces_atomic(mphy->hw, ieee80211_iterate_active_interfaces_atomic(mphy->hw,
...@@ -599,7 +602,7 @@ mt7915_mcu_muar_config(struct mt7915_phy *phy, struct ieee80211_vif *vif, ...@@ -599,7 +602,7 @@ mt7915_mcu_muar_config(struct mt7915_phy *phy, struct ieee80211_vif *vif,
.mode = !!mask || enable, .mode = !!mask || enable,
.entry_count = 1, .entry_count = 1,
.write = 1, .write = 1,
.band = phy->band_idx, .band = phy->mt76->band_idx,
.index = idx * 2 + bssid, .index = idx * 2 + bssid,
}; };
...@@ -2192,7 +2195,7 @@ int mt7915_mcu_muru_debug_get(struct mt7915_phy *phy, void *ms) ...@@ -2192,7 +2195,7 @@ int mt7915_mcu_muru_debug_get(struct mt7915_phy *phy, void *ms)
u8 band_idx; u8 band_idx;
} req = { } req = {
.cmd = cpu_to_le32(MURU_GET_TXC_TX_STATS), .cmd = cpu_to_le32(MURU_GET_TXC_TX_STATS),
.band_idx = phy->band_idx, .band_idx = phy->mt76->band_idx,
}; };
ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(MURU_CTRL), ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(MURU_CTRL),
...@@ -2585,7 +2588,7 @@ mt7915_mcu_background_chain_ctrl(struct mt7915_phy *phy, ...@@ -2585,7 +2588,7 @@ mt7915_mcu_background_chain_ctrl(struct mt7915_phy *phy,
req.monitor_central_chan = req.monitor_central_chan =
ieee80211_frequency_to_channel(chandef->center_freq1); ieee80211_frequency_to_channel(chandef->center_freq1);
req.monitor_bw = mt76_connac_chan_bw(chandef); req.monitor_bw = mt76_connac_chan_bw(chandef);
req.band_idx = phy->band_idx; req.band_idx = phy->mt76->band_idx;
req.scan_mode = 1; req.scan_mode = 1;
break; break;
} }
...@@ -2593,7 +2596,7 @@ mt7915_mcu_background_chain_ctrl(struct mt7915_phy *phy, ...@@ -2593,7 +2596,7 @@ mt7915_mcu_background_chain_ctrl(struct mt7915_phy *phy,
req.monitor_chan = chandef->chan->hw_value; req.monitor_chan = chandef->chan->hw_value;
req.monitor_central_chan = req.monitor_central_chan =
ieee80211_frequency_to_channel(chandef->center_freq1); ieee80211_frequency_to_channel(chandef->center_freq1);
req.band_idx = phy->band_idx; req.band_idx = phy->mt76->band_idx;
req.scan_mode = 2; req.scan_mode = 2;
break; break;
case CH_SWITCH_BACKGROUND_SCAN_STOP: case CH_SWITCH_BACKGROUND_SCAN_STOP:
...@@ -2660,6 +2663,7 @@ int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd) ...@@ -2660,6 +2663,7 @@ int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd)
struct mt7915_dev *dev = phy->dev; struct mt7915_dev *dev = phy->dev;
struct cfg80211_chan_def *chandef = &phy->mt76->chandef; struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
int freq1 = chandef->center_freq1; int freq1 = chandef->center_freq1;
u8 band = phy->mt76->band_idx;
struct { struct {
u8 control_ch; u8 control_ch;
u8 center_ch; u8 center_ch;
...@@ -2682,8 +2686,8 @@ int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd) ...@@ -2682,8 +2686,8 @@ int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd)
.center_ch = ieee80211_frequency_to_channel(freq1), .center_ch = ieee80211_frequency_to_channel(freq1),
.bw = mt76_connac_chan_bw(chandef), .bw = mt76_connac_chan_bw(chandef),
.tx_path_num = hweight16(phy->mt76->chainmask), .tx_path_num = hweight16(phy->mt76->chainmask),
.rx_path = phy->mt76->chainmask >> (dev->chainshift * phy->band_idx), .rx_path = phy->mt76->chainmask >> (dev->chainshift * band),
.band_idx = phy->band_idx, .band_idx = band,
.channel_band = ch_band[chandef->chan->band], .channel_band = ch_band[chandef->chan->band],
}; };
...@@ -2997,7 +3001,7 @@ int mt7915_mcu_get_chan_mib_info(struct mt7915_phy *phy, bool chan_switch) ...@@ -2997,7 +3001,7 @@ int mt7915_mcu_get_chan_mib_info(struct mt7915_phy *phy, bool chan_switch)
} }
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
req[i].band = cpu_to_le32(phy->band_idx); req[i].band = cpu_to_le32(phy->mt76->band_idx);
req[i].offs = cpu_to_le32(offs[i + start]); req[i].offs = cpu_to_le32(offs[i + start]);
if (!is_mt7915(&dev->mt76) && i == 3) if (!is_mt7915(&dev->mt76) && i == 3)
...@@ -3046,7 +3050,7 @@ int mt7915_mcu_get_temperature(struct mt7915_phy *phy) ...@@ -3046,7 +3050,7 @@ int mt7915_mcu_get_temperature(struct mt7915_phy *phy)
u8 rsv[5]; u8 rsv[5];
} req = { } req = {
.ctrl_id = THERMAL_SENSOR_TEMP_QUERY, .ctrl_id = THERMAL_SENSOR_TEMP_QUERY,
.band_idx = phy->band_idx, .band_idx = phy->mt76->band_idx,
}; };
return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_CTRL), &req, return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_CTRL), &req,
...@@ -3065,7 +3069,7 @@ int mt7915_mcu_set_thermal_throttling(struct mt7915_phy *phy, u8 state) ...@@ -3065,7 +3069,7 @@ int mt7915_mcu_set_thermal_throttling(struct mt7915_phy *phy, u8 state)
u8 rsv[2]; u8 rsv[2];
} __packed req = { } __packed req = {
.ctrl = { .ctrl = {
.band_idx = phy->band_idx, .band_idx = phy->mt76->band_idx,
}, },
}; };
int level; int level;
...@@ -3115,7 +3119,7 @@ int mt7915_mcu_set_txpower_frame_min(struct mt7915_phy *phy, s8 txpower) ...@@ -3115,7 +3119,7 @@ int mt7915_mcu_set_txpower_frame_min(struct mt7915_phy *phy, s8 txpower)
s8 txpower_min; s8 txpower_min;
} __packed req = { } __packed req = {
.format_id = TX_POWER_LIMIT_FRAME_MIN, .format_id = TX_POWER_LIMIT_FRAME_MIN,
.band_idx = phy->band_idx, .band_idx = phy->mt76->band_idx,
.txpower_min = txpower * 2, /* 0.5db */ .txpower_min = txpower * 2, /* 0.5db */
}; };
...@@ -3140,7 +3144,7 @@ int mt7915_mcu_set_txpower_frame(struct mt7915_phy *phy, ...@@ -3140,7 +3144,7 @@ int mt7915_mcu_set_txpower_frame(struct mt7915_phy *phy,
s8 txpower_offs[48]; s8 txpower_offs[48];
} __packed req = { } __packed req = {
.format_id = TX_POWER_LIMIT_FRAME, .format_id = TX_POWER_LIMIT_FRAME,
.band_idx = phy->band_idx, .band_idx = phy->mt76->band_idx,
.txpower_max = DIV_ROUND_UP(mphy->txpower_cur, 2), .txpower_max = DIV_ROUND_UP(mphy->txpower_cur, 2),
.wcid = cpu_to_le16(msta->wcid.idx), .wcid = cpu_to_le16(msta->wcid.idx),
}; };
...@@ -3194,7 +3198,7 @@ int mt7915_mcu_set_txpower_sku(struct mt7915_phy *phy) ...@@ -3194,7 +3198,7 @@ int mt7915_mcu_set_txpower_sku(struct mt7915_phy *phy)
struct ieee80211_hw *hw = mphy->hw; struct ieee80211_hw *hw = mphy->hw;
struct mt7915_mcu_txpower_sku req = { struct mt7915_mcu_txpower_sku req = {
.format_id = TX_POWER_LIMIT_TABLE, .format_id = TX_POWER_LIMIT_TABLE,
.band_idx = phy->band_idx, .band_idx = phy->mt76->band_idx,
}; };
struct mt76_power_limits limits_array; struct mt76_power_limits limits_array;
s8 *la = (s8 *)&limits_array; s8 *la = (s8 *)&limits_array;
...@@ -3243,7 +3247,7 @@ int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len) ...@@ -3243,7 +3247,7 @@ int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len)
} __packed req = { } __packed req = {
.format_id = TX_POWER_LIMIT_INFO, .format_id = TX_POWER_LIMIT_INFO,
.category = RATE_POWER_INFO, .category = RATE_POWER_INFO,
.band_idx = phy->band_idx, .band_idx = phy->mt76->band_idx,
}; };
s8 txpower_sku[MT7915_SKU_RATE_NUM][2]; s8 txpower_sku[MT7915_SKU_RATE_NUM][2];
struct sk_buff *skb; struct sk_buff *skb;
...@@ -3296,7 +3300,7 @@ int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable) ...@@ -3296,7 +3300,7 @@ int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable)
u8 rsv; u8 rsv;
} __packed req = { } __packed req = {
.format_id = TX_POWER_LIMIT_ENABLE, .format_id = TX_POWER_LIMIT_ENABLE,
.band_idx = phy->band_idx, .band_idx = phy->mt76->band_idx,
.sku_enable = enable, .sku_enable = enable,
}; };
...@@ -3378,7 +3382,7 @@ mt7915_mcu_enable_obss_spr(struct mt7915_phy *phy, u8 action, u8 val) ...@@ -3378,7 +3382,7 @@ mt7915_mcu_enable_obss_spr(struct mt7915_phy *phy, u8 action, u8 val)
struct mt7915_mcu_sr_ctrl req = { struct mt7915_mcu_sr_ctrl req = {
.action = action, .action = action,
.argnum = 1, .argnum = 1,
.band_idx = phy->band_idx, .band_idx = phy->mt76->band_idx,
.val = cpu_to_le32(val), .val = cpu_to_le32(val),
}; };
...@@ -3409,7 +3413,7 @@ mt7915_mcu_set_obss_spr_pd(struct mt7915_phy *phy, ...@@ -3409,7 +3413,7 @@ mt7915_mcu_set_obss_spr_pd(struct mt7915_phy *phy,
.ctrl = { .ctrl = {
.action = SPR_SET_PARAM, .action = SPR_SET_PARAM,
.argnum = 9, .argnum = 9,
.band_idx = phy->band_idx, .band_idx = phy->mt76->band_idx,
}, },
}; };
int ret; int ret;
...@@ -3458,7 +3462,7 @@ mt7915_mcu_set_obss_spr_siga(struct mt7915_phy *phy, struct ieee80211_vif *vif, ...@@ -3458,7 +3462,7 @@ mt7915_mcu_set_obss_spr_siga(struct mt7915_phy *phy, struct ieee80211_vif *vif,
.ctrl = { .ctrl = {
.action = SPR_SET_SIGA, .action = SPR_SET_SIGA,
.argnum = 1, .argnum = 1,
.band_idx = phy->band_idx, .band_idx = phy->mt76->band_idx,
}, },
.siga = { .siga = {
.omac = omac > HW_BSSID_MAX ? omac - 12 : omac, .omac = omac > HW_BSSID_MAX ? omac - 12 : omac,
...@@ -3497,7 +3501,7 @@ mt7915_mcu_set_obss_spr_bitmap(struct mt7915_phy *phy, ...@@ -3497,7 +3501,7 @@ mt7915_mcu_set_obss_spr_bitmap(struct mt7915_phy *phy,
.ctrl = { .ctrl = {
.action = SPR_SET_SRG_BITMAP, .action = SPR_SET_SRG_BITMAP,
.argnum = 4, .argnum = 4,
.band_idx = phy->band_idx, .band_idx = phy->mt76->band_idx,
}, },
}; };
u32 bitmap; u32 bitmap;
......
...@@ -558,11 +558,11 @@ static int mt7915_mmio_wed_offload_enable(struct mtk_wed_device *wed) ...@@ -558,11 +558,11 @@ static int mt7915_mmio_wed_offload_enable(struct mtk_wed_device *wed)
return -EAGAIN; return -EAGAIN;
phy = &dev->phy; phy = &dev->phy;
mt76_set(dev, MT_AGG_ACR4(phy->band_idx), MT_AGG_ACR_PPDU_TXS2H); mt76_set(dev, MT_AGG_ACR4(phy->mt76->band_idx), MT_AGG_ACR_PPDU_TXS2H);
phy = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL; phy = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL;
if (phy) if (phy)
mt76_set(dev, MT_AGG_ACR4(phy->band_idx), mt76_set(dev, MT_AGG_ACR4(phy->mt76->band_idx),
MT_AGG_ACR_PPDU_TXS2H); MT_AGG_ACR_PPDU_TXS2H);
return 0; return 0;
...@@ -583,11 +583,11 @@ static void mt7915_mmio_wed_offload_disable(struct mtk_wed_device *wed) ...@@ -583,11 +583,11 @@ static void mt7915_mmio_wed_offload_disable(struct mtk_wed_device *wed)
* MT_AGG_ACR_PPDU_TXS2H (PPDU format) even though ACR bit is set. * MT_AGG_ACR_PPDU_TXS2H (PPDU format) even though ACR bit is set.
*/ */
phy = &dev->phy; phy = &dev->phy;
mt76_clear(dev, MT_AGG_ACR4(phy->band_idx), MT_AGG_ACR_PPDU_TXS2H); mt76_clear(dev, MT_AGG_ACR4(phy->mt76->band_idx), MT_AGG_ACR_PPDU_TXS2H);
phy = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL; phy = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL;
if (phy) if (phy)
mt76_clear(dev, MT_AGG_ACR4(phy->band_idx), mt76_clear(dev, MT_AGG_ACR4(phy->mt76->band_idx),
MT_AGG_ACR_PPDU_TXS2H); MT_AGG_ACR_PPDU_TXS2H);
} }
......
...@@ -258,7 +258,6 @@ struct mt7915_phy { ...@@ -258,7 +258,6 @@ struct mt7915_phy {
u32 rxfilter; u32 rxfilter;
u64 omac_mask; u64 omac_mask;
u8 band_idx;
u16 noise; u16 noise;
......
...@@ -51,7 +51,7 @@ mt7915_tm_set_tx_power(struct mt7915_phy *phy) ...@@ -51,7 +51,7 @@ mt7915_tm_set_tx_power(struct mt7915_phy *phy)
u8 rsv[3]; u8 rsv[3];
} __packed req = { } __packed req = {
.format_id = 0xf, .format_id = 0xf,
.band_idx = phy->band_idx, .band_idx = phy->mt76->band_idx,
.center_chan = ieee80211_frequency_to_channel(freq), .center_chan = ieee80211_frequency_to_channel(freq),
}; };
u8 *tx_power = NULL; u8 *tx_power = NULL;
...@@ -77,7 +77,7 @@ mt7915_tm_set_freq_offset(struct mt7915_phy *phy, bool en, u32 val) ...@@ -77,7 +77,7 @@ mt7915_tm_set_freq_offset(struct mt7915_phy *phy, bool en, u32 val)
struct mt7915_tm_cmd req = { struct mt7915_tm_cmd req = {
.testmode_en = en, .testmode_en = en,
.param_idx = MCU_ATE_SET_FREQ_OFFSET, .param_idx = MCU_ATE_SET_FREQ_OFFSET,
.param.freq.band = phy->band_idx, .param.freq.band = phy->mt76->band_idx,
.param.freq.freq_offset = cpu_to_le32(val), .param.freq.freq_offset = cpu_to_le32(val),
}; };
...@@ -111,7 +111,7 @@ mt7915_tm_set_trx(struct mt7915_phy *phy, int type, bool en) ...@@ -111,7 +111,7 @@ mt7915_tm_set_trx(struct mt7915_phy *phy, int type, bool en)
.param_idx = MCU_ATE_SET_TRX, .param_idx = MCU_ATE_SET_TRX,
.param.trx.type = type, .param.trx.type = type,
.param.trx.enable = en, .param.trx.enable = en,
.param.trx.band = phy->band_idx, .param.trx.band = phy->mt76->band_idx,
}; };
return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req, return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req,
...@@ -126,7 +126,7 @@ mt7915_tm_clean_hwq(struct mt7915_phy *phy, u8 wcid) ...@@ -126,7 +126,7 @@ mt7915_tm_clean_hwq(struct mt7915_phy *phy, u8 wcid)
.testmode_en = 1, .testmode_en = 1,
.param_idx = MCU_ATE_CLEAN_TXQUEUE, .param_idx = MCU_ATE_CLEAN_TXQUEUE,
.param.clean.wcid = wcid, .param.clean.wcid = wcid,
.param.clean.band = phy->band_idx, .param.clean.band = phy->mt76->band_idx,
}; };
return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req, return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req,
...@@ -144,7 +144,7 @@ mt7915_tm_set_slot_time(struct mt7915_phy *phy, u8 slot_time, u8 sifs) ...@@ -144,7 +144,7 @@ mt7915_tm_set_slot_time(struct mt7915_phy *phy, u8 slot_time, u8 sifs)
.param.slot.sifs = sifs, .param.slot.sifs = sifs,
.param.slot.rifs = 2, .param.slot.rifs = 2,
.param.slot.eifs = cpu_to_le16(60), .param.slot.eifs = cpu_to_le16(60),
.param.slot.band = phy->band_idx, .param.slot.band = phy->mt76->band_idx,
}; };
return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req, return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req,
...@@ -198,6 +198,7 @@ mt7915_tm_set_ipg_params(struct mt7915_phy *phy, u32 ipg, u8 mode) ...@@ -198,6 +198,7 @@ mt7915_tm_set_ipg_params(struct mt7915_phy *phy, u32 ipg, u8 mode)
u8 sig_ext = (mode == MT76_TM_TX_MODE_CCK) ? 0 : 6; u8 sig_ext = (mode == MT76_TM_TX_MODE_CCK) ? 0 : 6;
u8 slot_time = 9, sifs = TM_DEFAULT_SIFS; u8 slot_time = 9, sifs = TM_DEFAULT_SIFS;
u8 aifsn = TM_MIN_AIFSN; u8 aifsn = TM_MIN_AIFSN;
u8 band = phy->mt76->band_idx;
u32 i2t_time, tr2t_time, txv_time; u32 i2t_time, tr2t_time, txv_time;
u16 cw = 0; u16 cw = 0;
...@@ -232,14 +233,14 @@ mt7915_tm_set_ipg_params(struct mt7915_phy *phy, u32 ipg, u8 mode) ...@@ -232,14 +233,14 @@ mt7915_tm_set_ipg_params(struct mt7915_phy *phy, u32 ipg, u8 mode)
sifs = min_t(u32, ipg, TM_MAX_SIFS); sifs = min_t(u32, ipg, TM_MAX_SIFS);
} }
done: done:
txv_time = mt76_get_field(dev, MT_TMAC_ATCR(phy->band_idx), txv_time = mt76_get_field(dev, MT_TMAC_ATCR(band),
MT_TMAC_ATCR_TXV_TOUT); MT_TMAC_ATCR_TXV_TOUT);
txv_time *= 50; /* normal clock time */ txv_time *= 50; /* normal clock time */
i2t_time = (slot_time * 1000 - txv_time - BBP_PROC_TIME) / 50; i2t_time = (slot_time * 1000 - txv_time - BBP_PROC_TIME) / 50;
tr2t_time = (sifs * 1000 - txv_time - BBP_PROC_TIME) / 50; tr2t_time = (sifs * 1000 - txv_time - BBP_PROC_TIME) / 50;
mt76_set(dev, MT_TMAC_TRCR0(phy->band_idx), mt76_set(dev, MT_TMAC_TRCR0(band),
FIELD_PREP(MT_TMAC_TRCR0_TR2T_CHK, tr2t_time) | FIELD_PREP(MT_TMAC_TRCR0_TR2T_CHK, tr2t_time) |
FIELD_PREP(MT_TMAC_TRCR0_I2T_CHK, i2t_time)); FIELD_PREP(MT_TMAC_TRCR0_I2T_CHK, i2t_time));
...@@ -336,6 +337,7 @@ mt7915_tm_reg_backup_restore(struct mt7915_phy *phy) ...@@ -336,6 +337,7 @@ mt7915_tm_reg_backup_restore(struct mt7915_phy *phy)
int n_regs = ARRAY_SIZE(reg_backup_list); int n_regs = ARRAY_SIZE(reg_backup_list);
struct mt7915_dev *dev = phy->dev; struct mt7915_dev *dev = phy->dev;
u32 *b = phy->test.reg_backup; u32 *b = phy->test.reg_backup;
u8 band = phy->mt76->band_idx;
int i; int i;
REG_BAND_IDX(reg_backup_list[0], AGG_PCR0, 0); REG_BAND_IDX(reg_backup_list[0], AGG_PCR0, 0);
...@@ -358,7 +360,7 @@ mt7915_tm_reg_backup_restore(struct mt7915_phy *phy) ...@@ -358,7 +360,7 @@ mt7915_tm_reg_backup_restore(struct mt7915_phy *phy)
if (phy->mt76->test.state == MT76_TM_STATE_OFF) { if (phy->mt76->test.state == MT76_TM_STATE_OFF) {
for (i = 0; i < n_regs; i++) for (i = 0; i < n_regs; i++)
mt76_wr(dev, reg_backup_list[i].band[phy->band_idx], b[i]); mt76_wr(dev, reg_backup_list[i].band[band], b[i]);
return; return;
} }
...@@ -369,33 +371,33 @@ mt7915_tm_reg_backup_restore(struct mt7915_phy *phy) ...@@ -369,33 +371,33 @@ mt7915_tm_reg_backup_restore(struct mt7915_phy *phy)
phy->test.reg_backup = b; phy->test.reg_backup = b;
for (i = 0; i < n_regs; i++) for (i = 0; i < n_regs; i++)
b[i] = mt76_rr(dev, reg_backup_list[i].band[phy->band_idx]); b[i] = mt76_rr(dev, reg_backup_list[i].band[band]);
} }
mt76_clear(dev, MT_AGG_PCR0(phy->band_idx, 0), MT_AGG_PCR0_MM_PROT | mt76_clear(dev, MT_AGG_PCR0(band, 0), MT_AGG_PCR0_MM_PROT |
MT_AGG_PCR0_GF_PROT | MT_AGG_PCR0_ERP_PROT | MT_AGG_PCR0_GF_PROT | MT_AGG_PCR0_ERP_PROT |
MT_AGG_PCR0_VHT_PROT | MT_AGG_PCR0_BW20_PROT | MT_AGG_PCR0_VHT_PROT | MT_AGG_PCR0_BW20_PROT |
MT_AGG_PCR0_BW40_PROT | MT_AGG_PCR0_BW80_PROT); MT_AGG_PCR0_BW40_PROT | MT_AGG_PCR0_BW80_PROT);
mt76_set(dev, MT_AGG_PCR0(phy->band_idx, 0), MT_AGG_PCR0_PTA_WIN_DIS); mt76_set(dev, MT_AGG_PCR0(band, 0), MT_AGG_PCR0_PTA_WIN_DIS);
mt76_wr(dev, MT_AGG_PCR0(phy->band_idx, 1), MT_AGG_PCR1_RTS0_NUM_THRES | mt76_wr(dev, MT_AGG_PCR0(band, 1), MT_AGG_PCR1_RTS0_NUM_THRES |
MT_AGG_PCR1_RTS0_LEN_THRES); MT_AGG_PCR1_RTS0_LEN_THRES);
mt76_clear(dev, MT_AGG_MRCR(phy->band_idx), MT_AGG_MRCR_BAR_CNT_LIMIT | mt76_clear(dev, MT_AGG_MRCR(band), MT_AGG_MRCR_BAR_CNT_LIMIT |
MT_AGG_MRCR_LAST_RTS_CTS_RN | MT_AGG_MRCR_RTS_FAIL_LIMIT | MT_AGG_MRCR_LAST_RTS_CTS_RN | MT_AGG_MRCR_RTS_FAIL_LIMIT |
MT_AGG_MRCR_TXCMD_RTS_FAIL_LIMIT); MT_AGG_MRCR_TXCMD_RTS_FAIL_LIMIT);
mt76_rmw(dev, MT_AGG_MRCR(phy->band_idx), MT_AGG_MRCR_RTS_FAIL_LIMIT | mt76_rmw(dev, MT_AGG_MRCR(band), MT_AGG_MRCR_RTS_FAIL_LIMIT |
MT_AGG_MRCR_TXCMD_RTS_FAIL_LIMIT, MT_AGG_MRCR_TXCMD_RTS_FAIL_LIMIT,
FIELD_PREP(MT_AGG_MRCR_RTS_FAIL_LIMIT, 1) | FIELD_PREP(MT_AGG_MRCR_RTS_FAIL_LIMIT, 1) |
FIELD_PREP(MT_AGG_MRCR_TXCMD_RTS_FAIL_LIMIT, 1)); FIELD_PREP(MT_AGG_MRCR_TXCMD_RTS_FAIL_LIMIT, 1));
mt76_wr(dev, MT_TMAC_TFCR0(phy->band_idx), 0); mt76_wr(dev, MT_TMAC_TFCR0(band), 0);
mt76_clear(dev, MT_TMAC_TCR0(phy->band_idx), MT_TMAC_TCR0_TBTT_STOP_CTRL); mt76_clear(dev, MT_TMAC_TCR0(band), MT_TMAC_TCR0_TBTT_STOP_CTRL);
/* config rx filter for testmode rx */ /* config rx filter for testmode rx */
mt76_wr(dev, MT_WF_RFCR(phy->band_idx), 0xcf70a); mt76_wr(dev, MT_WF_RFCR(band), 0xcf70a);
mt76_wr(dev, MT_WF_RFCR1(phy->band_idx), 0); mt76_wr(dev, MT_WF_RFCR1(band), 0);
} }
static void static void
...@@ -488,7 +490,7 @@ mt7915_tm_set_rx_frames(struct mt7915_phy *phy, bool en) ...@@ -488,7 +490,7 @@ mt7915_tm_set_rx_frames(struct mt7915_phy *phy, bool en)
mt7915_tm_update_channel(phy); mt7915_tm_update_channel(phy);
/* read-clear */ /* read-clear */
mt76_rr(dev, MT_MIB_SDR3(phy->band_idx)); mt76_rr(dev, MT_MIB_SDR3(phy->mt76->band_idx));
mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, en); mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, en);
} }
} }
...@@ -515,6 +517,7 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en) ...@@ -515,6 +517,7 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en)
struct mt76_testmode_data *td = &phy->mt76->test; struct mt76_testmode_data *td = &phy->mt76->test;
u32 func_idx = en ? TX_CONT_START : TX_CONT_STOP; u32 func_idx = en ? TX_CONT_START : TX_CONT_STOP;
u8 rate_idx = td->tx_rate_idx, mode; u8 rate_idx = td->tx_rate_idx, mode;
u8 band = phy->mt76->band_idx;
u16 rateval; u16 rateval;
struct mt7915_tm_rf_test req = { struct mt7915_tm_rf_test req = {
.action = 1, .action = 1,
...@@ -526,7 +529,7 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en) ...@@ -526,7 +529,7 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en)
tx_cont->control_ch = chandef->chan->hw_value; tx_cont->control_ch = chandef->chan->hw_value;
tx_cont->center_ch = freq1; tx_cont->center_ch = freq1;
tx_cont->tx_ant = td->tx_antenna_mask; tx_cont->tx_ant = td->tx_antenna_mask;
tx_cont->band = phy->band_idx; tx_cont->band = band;
switch (chandef->width) { switch (chandef->width) {
case NL80211_CHAN_WIDTH_40: case NL80211_CHAN_WIDTH_40:
...@@ -558,7 +561,7 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en) ...@@ -558,7 +561,7 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en)
} }
if (!en) { if (!en) {
req.op.rf.param.func_data = cpu_to_le32(phy->band_idx); req.op.rf.param.func_data = cpu_to_le32(band);
goto out; goto out;
} }
...@@ -767,11 +770,11 @@ mt7915_tm_dump_stats(struct mt76_phy *mphy, struct sk_buff *msg) ...@@ -767,11 +770,11 @@ mt7915_tm_dump_stats(struct mt76_phy *mphy, struct sk_buff *msg)
nla_nest_end(msg, rx); nla_nest_end(msg, rx);
cnt = mt76_rr(dev, MT_MIB_SDR3(phy->band_idx)); cnt = mt76_rr(dev, MT_MIB_SDR3(phy->mt76->band_idx));
fcs_err = is_mt7915(&dev->mt76) ? FIELD_GET(MT_MIB_SDR3_FCS_ERR_MASK, cnt) : fcs_err = is_mt7915(&dev->mt76) ? FIELD_GET(MT_MIB_SDR3_FCS_ERR_MASK, cnt) :
FIELD_GET(MT_MIB_SDR3_FCS_ERR_MASK_MT7916, cnt); FIELD_GET(MT_MIB_SDR3_FCS_ERR_MASK_MT7916, cnt);
q = phy->band_idx ? MT_RXQ_BAND1 : MT_RXQ_MAIN; q = phy->mt76->band_idx ? MT_RXQ_BAND1 : MT_RXQ_MAIN;
mphy->test.rx_stats.packets[q] += fcs_err; mphy->test.rx_stats.packets[q] += fcs_err;
mphy->test.rx_stats.fcs_error[q] += fcs_err; mphy->test.rx_stats.fcs_error[q] += fcs_err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment