diff options
Diffstat (limited to 'drivers/net/wireless/mediatek/mt76/mt7615/testmode.c')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt7615/testmode.c | 101 |
1 files changed, 49 insertions, 52 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/testmode.c b/drivers/net/wireless/mediatek/mt76/mt7615/testmode.c index 8fc97a52411a..59d99264f5e5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/testmode.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/testmode.c @@ -67,8 +67,8 @@ mt7615_tm_set_tx_power(struct mt7615_phy *phy) }; u8 *tx_power = NULL; - if (dev->mt76.test.state != MT76_TM_STATE_OFF) - tx_power = dev->mt76.test.tx_power; + if (mphy->test.state != MT76_TM_STATE_OFF) + tx_power = mphy->test.tx_power; len = MT7615_EE_MAX - MT_EE_NIC_CONF_0; skb = mt76_mcu_msg_alloc(&dev->mt76, NULL, sizeof(req_hdr) + len); @@ -95,14 +95,15 @@ mt7615_tm_set_tx_power(struct mt7615_phy *phy) } static void -mt7615_tm_reg_backup_restore(struct mt7615_dev *dev) +mt7615_tm_reg_backup_restore(struct mt7615_phy *phy) { - u32 *b = dev->test.reg_backup; + struct mt7615_dev *dev = phy->dev; + u32 *b = phy->test.reg_backup; int n_regs = ARRAY_SIZE(reg_backup_list); int n_rf_regs = ARRAY_SIZE(rf_backup_list); int i; - if (dev->mt76.test.state == MT76_TM_STATE_OFF) { + if (phy->mt76->test.state == MT76_TM_STATE_OFF) { for (i = 0; i < n_regs; i++) mt76_wr(dev, reg_backup_list[i], b[i]); @@ -120,7 +121,7 @@ mt7615_tm_reg_backup_restore(struct mt7615_dev *dev) if (!b) return; - dev->test.reg_backup = b; + phy->test.reg_backup = b; for (i = 0; i < n_regs; i++) b[i] = mt76_rr(dev, reg_backup_list[i]); for (i = 0; i < n_rf_regs; i++) @@ -128,30 +129,23 @@ mt7615_tm_reg_backup_restore(struct mt7615_dev *dev) rf_backup_list[i].reg); } - static void -mt7615_tm_init_phy(struct mt7615_dev *dev, struct mt7615_phy *phy) +mt7615_tm_init(struct mt7615_phy *phy) { + struct mt7615_dev *dev = phy->dev; unsigned int total_flags = ~0; if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state)) return; + mt7615_mcu_set_sku_en(phy, phy->mt76->test.state == MT76_TM_STATE_OFF); + mutex_unlock(&dev->mt76.mutex); mt7615_set_channel(phy); mt7615_ops.configure_filter(phy->mt76->hw, 0, &total_flags, 0); mutex_lock(&dev->mt76.mutex); - mt7615_tm_reg_backup_restore(dev); -} - -static void -mt7615_tm_init(struct mt7615_dev *dev) -{ - mt7615_tm_init_phy(dev, &dev->phy); - - if (dev->mt76.phy2) - mt7615_tm_init_phy(dev, dev->mt76.phy2->priv); + mt7615_tm_reg_backup_restore(phy); } static void @@ -175,9 +169,10 @@ mt7615_tm_set_rx_enable(struct mt7615_dev *dev, bool en) } static void -mt7615_tm_set_tx_antenna(struct mt7615_dev *dev, bool en) +mt7615_tm_set_tx_antenna(struct mt7615_phy *phy, bool en) { - struct mt76_testmode_data *td = &dev->mt76.test; + struct mt7615_dev *dev = phy->dev; + struct mt76_testmode_data *td = &phy->mt76->test; u8 mask = td->tx_antenna_mask; int i; @@ -185,7 +180,7 @@ mt7615_tm_set_tx_antenna(struct mt7615_dev *dev, bool en) return; if (!en) - mask = dev->phy.chainmask; + mask = phy->mt76->chainmask; for (i = 0; i < 4; i++) { mt76_rmw_field(dev, MT_WF_PHY_RFINTF3_0(i), @@ -228,26 +223,28 @@ mt7615_tm_set_tx_antenna(struct mt7615_dev *dev, bool en) } static void -mt7615_tm_set_tx_frames(struct mt7615_dev *dev, bool en) +mt7615_tm_set_tx_frames(struct mt7615_phy *phy, bool en) { + struct mt7615_dev *dev = phy->dev; struct ieee80211_tx_info *info; - struct sk_buff *skb = dev->mt76.test.tx_skb; + struct sk_buff *skb = phy->mt76->test.tx_skb; - mt7615_mcu_set_chan_info(&dev->phy, MCU_EXT_CMD_SET_RX_PATH); - mt7615_tm_set_tx_antenna(dev, en); + mt7615_mcu_set_chan_info(phy, MCU_EXT_CMD_SET_RX_PATH); + mt7615_tm_set_tx_antenna(phy, en); mt7615_tm_set_rx_enable(dev, !en); if (!en || !skb) return; info = IEEE80211_SKB_CB(skb); - info->control.vif = dev->phy.monitor_vif; + info->control.vif = phy->monitor_vif; } static void -mt7615_tm_update_params(struct mt7615_dev *dev, u32 changed) +mt7615_tm_update_params(struct mt7615_phy *phy, u32 changed) { - struct mt76_testmode_data *td = &dev->mt76.test; - bool en = dev->mt76.test.state != MT76_TM_STATE_OFF; + struct mt7615_dev *dev = phy->dev; + struct mt76_testmode_data *td = &phy->mt76->test; + bool en = phy->mt76->test.state != MT76_TM_STATE_OFF; if (changed & BIT(TM_CHANGED_TXPOWER_CTRL)) mt7615_mcu_set_test_param(dev, MCU_ATE_SET_TX_POWER_CONTROL, @@ -256,25 +253,25 @@ mt7615_tm_update_params(struct mt7615_dev *dev, u32 changed) mt7615_mcu_set_test_param(dev, MCU_ATE_SET_FREQ_OFFSET, en, en ? td->freq_offset : 0); if (changed & BIT(TM_CHANGED_TXPOWER)) - mt7615_tm_set_tx_power(&dev->phy); + mt7615_tm_set_tx_power(phy); } static int -mt7615_tm_set_state(struct mt76_dev *mdev, enum mt76_testmode_state state) +mt7615_tm_set_state(struct mt76_phy *mphy, enum mt76_testmode_state state) { - struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76); - struct mt76_testmode_data *td = &mdev->test; + struct mt7615_phy *phy = mphy->priv; + struct mt76_testmode_data *td = &mphy->test; enum mt76_testmode_state prev_state = td->state; - mdev->test.state = state; + mphy->test.state = state; if (prev_state == MT76_TM_STATE_TX_FRAMES) - mt7615_tm_set_tx_frames(dev, false); + mt7615_tm_set_tx_frames(phy, false); else if (state == MT76_TM_STATE_TX_FRAMES) - mt7615_tm_set_tx_frames(dev, true); + mt7615_tm_set_tx_frames(phy, true); if (state <= MT76_TM_STATE_IDLE) - mt7615_tm_init(dev); + mt7615_tm_init(phy); if ((state == MT76_TM_STATE_IDLE && prev_state == MT76_TM_STATE_OFF) || @@ -290,18 +287,18 @@ mt7615_tm_set_state(struct mt76_dev *mdev, enum mt76_testmode_state state) changed |= BIT(i); } - mt7615_tm_update_params(dev, changed); + mt7615_tm_update_params(phy, changed); } return 0; } static int -mt7615_tm_set_params(struct mt76_dev *mdev, struct nlattr **tb, +mt7615_tm_set_params(struct mt76_phy *mphy, struct nlattr **tb, enum mt76_testmode_state new_state) { - struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76); - struct mt76_testmode_data *td = &dev->mt76.test; + struct mt76_testmode_data *td = &mphy->test; + struct mt7615_phy *phy = mphy->priv; u32 changed = 0; int i; @@ -311,7 +308,7 @@ mt7615_tm_set_params(struct mt76_dev *mdev, struct nlattr **tb, td->state == MT76_TM_STATE_OFF) return 0; - if (td->tx_antenna_mask & ~dev->phy.chainmask) + if (td->tx_antenna_mask & ~mphy->chainmask) return -EINVAL; for (i = 0; i < ARRAY_SIZE(tm_change_map); i++) { @@ -319,15 +316,15 @@ mt7615_tm_set_params(struct mt76_dev *mdev, struct nlattr **tb, changed |= BIT(i); } - mt7615_tm_update_params(dev, changed); + mt7615_tm_update_params(phy, changed); return 0; } static int -mt7615_tm_dump_stats(struct mt76_dev *mdev, struct sk_buff *msg) +mt7615_tm_dump_stats(struct mt76_phy *mphy, struct sk_buff *msg) { - struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76); + struct mt7615_phy *phy = mphy->priv; void *rx, *rssi; int i; @@ -335,15 +332,15 @@ mt7615_tm_dump_stats(struct mt76_dev *mdev, struct sk_buff *msg) if (!rx) return -ENOMEM; - if (nla_put_s32(msg, MT76_TM_RX_ATTR_FREQ_OFFSET, dev->test.last_freq_offset)) + if (nla_put_s32(msg, MT76_TM_RX_ATTR_FREQ_OFFSET, phy->test.last_freq_offset)) return -ENOMEM; rssi = nla_nest_start(msg, MT76_TM_RX_ATTR_RCPI); if (!rssi) return -ENOMEM; - for (i = 0; i < ARRAY_SIZE(dev->test.last_rcpi); i++) - if (nla_put_u8(msg, i, dev->test.last_rcpi[i])) + for (i = 0; i < ARRAY_SIZE(phy->test.last_rcpi); i++) + if (nla_put_u8(msg, i, phy->test.last_rcpi[i])) return -ENOMEM; nla_nest_end(msg, rssi); @@ -352,8 +349,8 @@ mt7615_tm_dump_stats(struct mt76_dev *mdev, struct sk_buff *msg) if (!rssi) return -ENOMEM; - for (i = 0; i < ARRAY_SIZE(dev->test.last_ib_rssi); i++) - if (nla_put_s8(msg, i, dev->test.last_ib_rssi[i])) + for (i = 0; i < ARRAY_SIZE(phy->test.last_ib_rssi); i++) + if (nla_put_s8(msg, i, phy->test.last_ib_rssi[i])) return -ENOMEM; nla_nest_end(msg, rssi); @@ -362,8 +359,8 @@ mt7615_tm_dump_stats(struct mt76_dev *mdev, struct sk_buff *msg) if (!rssi) return -ENOMEM; - for (i = 0; i < ARRAY_SIZE(dev->test.last_wb_rssi); i++) - if (nla_put_s8(msg, i, dev->test.last_wb_rssi[i])) + for (i = 0; i < ARRAY_SIZE(phy->test.last_wb_rssi); i++) + if (nla_put_s8(msg, i, phy->test.last_wb_rssi[i])) return -ENOMEM; nla_nest_end(msg, rssi); |