Lines Matching +full:- +full:phy

1 // SPDX-License-Identifier: ISC
38 mt7915_tm_set_tx_power(struct mt7915_phy *phy) in mt7915_tm_set_tx_power() argument
40 struct mt7915_dev *dev = phy->dev; in mt7915_tm_set_tx_power()
41 struct mt76_phy *mphy = phy->mt76; in mt7915_tm_set_tx_power()
42 struct cfg80211_chan_def *chandef = &mphy->chandef; in mt7915_tm_set_tx_power()
43 int freq = chandef->center_freq1; in mt7915_tm_set_tx_power()
54 .band_idx = phy->mt76->band_idx, in mt7915_tm_set_tx_power()
59 if (phy->mt76->test.state != MT76_TM_STATE_OFF) in mt7915_tm_set_tx_power()
60 tx_power = phy->mt76->test.tx_power; in mt7915_tm_set_tx_power()
66 ret = mt76_mcu_send_msg(&dev->mt76, in mt7915_tm_set_tx_power()
74 mt7915_tm_set_freq_offset(struct mt7915_phy *phy, bool en, u32 val) in mt7915_tm_set_freq_offset() argument
76 struct mt7915_dev *dev = phy->dev; in mt7915_tm_set_freq_offset()
80 .param.freq.band = phy->mt76->band_idx, in mt7915_tm_set_freq_offset()
84 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req, in mt7915_tm_set_freq_offset()
100 return mt76_mcu_send_msg(&dev->mt76, in mt7915_tm_mode_ctrl()
106 mt7915_tm_set_trx(struct mt7915_phy *phy, int type, bool en) in mt7915_tm_set_trx() argument
108 struct mt7915_dev *dev = phy->dev; in mt7915_tm_set_trx()
114 .param.trx.band = phy->mt76->band_idx, in mt7915_tm_set_trx()
117 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req, in mt7915_tm_set_trx()
122 mt7915_tm_clean_hwq(struct mt7915_phy *phy, u8 wcid) in mt7915_tm_clean_hwq() argument
124 struct mt7915_dev *dev = phy->dev; in mt7915_tm_clean_hwq()
129 .param.clean.band = phy->mt76->band_idx, in mt7915_tm_clean_hwq()
132 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req, in mt7915_tm_clean_hwq()
137 mt7915_tm_set_slot_time(struct mt7915_phy *phy, u8 slot_time, u8 sifs) in mt7915_tm_set_slot_time() argument
139 struct mt7915_dev *dev = phy->dev; in mt7915_tm_set_slot_time()
141 .testmode_en = !(phy->mt76->test.state == MT76_TM_STATE_OFF), in mt7915_tm_set_slot_time()
147 .param.slot.band = phy->mt76->band_idx, in mt7915_tm_set_slot_time()
150 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req, in mt7915_tm_set_slot_time()
155 mt7915_tm_set_tam_arb(struct mt7915_phy *phy, bool enable, bool mu) in mt7915_tm_set_tam_arb() argument
157 struct mt7915_dev *dev = phy->dev; in mt7915_tm_set_tam_arb()
171 mt7915_tm_set_wmm_qid(struct mt7915_phy *phy, u8 qid, u8 aifs, u8 cw_min, in mt7915_tm_set_wmm_qid() argument
174 struct mt7915_vif *mvif = (struct mt7915_vif *)phy->monitor_vif->drv_priv; in mt7915_tm_set_wmm_qid()
178 e->queue = qid + mvif->mt76.wmm_idx * MT76_CONNAC_MAX_WMM_SETS; in mt7915_tm_set_wmm_qid()
179 e->set = WMM_PARAM_SET; in mt7915_tm_set_wmm_qid()
181 e->aifs = aifs; in mt7915_tm_set_wmm_qid()
182 e->cw_min = cw_min; in mt7915_tm_set_wmm_qid()
183 e->cw_max = cpu_to_le16(cw_max); in mt7915_tm_set_wmm_qid()
184 e->txop = cpu_to_le16(txop); in mt7915_tm_set_wmm_qid()
186 return mt7915_mcu_update_edca(phy->dev, &req); in mt7915_tm_set_wmm_qid()
190 mt7915_tm_set_ipg_params(struct mt7915_phy *phy, u32 ipg, u8 mode) in mt7915_tm_set_ipg_params() argument
197 struct mt7915_dev *dev = phy->dev; in mt7915_tm_set_ipg_params()
201 u8 band = phy->mt76->band_idx; in mt7915_tm_set_ipg_params()
211 ipg -= sig_ext; in mt7915_tm_set_ipg_params()
214 sifs = ipg - slot_time; in mt7915_tm_set_ipg_params()
224 ipg -= ((1 << cw) - 1) * slot_time; in mt7915_tm_set_ipg_params()
230 ipg -= aifsn * slot_time; in mt7915_tm_set_ipg_params()
240 i2t_time = (slot_time * 1000 - txv_time - BBP_PROC_TIME) / 50; in mt7915_tm_set_ipg_params()
241 tr2t_time = (sifs * 1000 - txv_time - BBP_PROC_TIME) / 50; in mt7915_tm_set_ipg_params()
247 mt7915_tm_set_slot_time(phy, slot_time, sifs); in mt7915_tm_set_ipg_params()
249 return mt7915_tm_set_wmm_qid(phy, in mt7915_tm_set_ipg_params()
255 mt7915_tm_set_tx_len(struct mt7915_phy *phy, u32 tx_time) in mt7915_tm_set_tx_len() argument
257 struct mt76_phy *mphy = phy->mt76; in mt7915_tm_set_tx_len()
258 struct mt76_testmode_data *td = &mphy->test; in mt7915_tm_set_tx_len()
268 rate.mcs = td->tx_rate_idx; in mt7915_tm_set_tx_len()
269 rate.nss = td->tx_rate_nss; in mt7915_tm_set_tx_len()
271 switch (td->tx_rate_mode) { in mt7915_tm_set_tx_len()
274 if (mphy->chandef.chan->band == NL80211_BAND_5GHZ) in mt7915_tm_set_tx_len()
275 sband = &mphy->sband_5g.sband; in mt7915_tm_set_tx_len()
276 else if (mphy->chandef.chan->band == NL80211_BAND_6GHZ) in mt7915_tm_set_tx_len()
277 sband = &mphy->sband_6g.sband; in mt7915_tm_set_tx_len()
279 sband = &mphy->sband_2g.sband; in mt7915_tm_set_tx_len()
281 rate.legacy = sband->bitrates[rate.mcs].bitrate; in mt7915_tm_set_tx_len()
287 if (td->tx_rate_sgi) in mt7915_tm_set_tx_len()
293 if (td->tx_rate_sgi) in mt7915_tm_set_tx_len()
300 rate.he_gi = td->tx_rate_sgi; in mt7915_tm_set_tx_len()
308 switch (mphy->chandef.width) { in mt7915_tm_set_tx_len()
327 ret = mt76_testmode_alloc_skb(phy->mt76, tx_len); in mt7915_tm_set_tx_len()
335 mt7915_tm_reg_backup_restore(struct mt7915_phy *phy) in mt7915_tm_reg_backup_restore() argument
338 struct mt7915_dev *dev = phy->dev; in mt7915_tm_reg_backup_restore()
339 u32 *b = phy->test.reg_backup; in mt7915_tm_reg_backup_restore()
340 u8 band = phy->mt76->band_idx; in mt7915_tm_reg_backup_restore()
361 if (phy->mt76->test.state == MT76_TM_STATE_OFF) { in mt7915_tm_reg_backup_restore()
368 b = devm_kzalloc(dev->mt76.dev, 4 * n_regs, GFP_KERNEL); in mt7915_tm_reg_backup_restore()
372 phy->test.reg_backup = b; in mt7915_tm_reg_backup_restore()
404 mt7915_tm_init(struct mt7915_phy *phy, bool en) in mt7915_tm_init() argument
406 struct mt7915_dev *dev = phy->dev; in mt7915_tm_init()
409 if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state)) in mt7915_tm_init()
412 mt7915_mcu_set_sku_en(phy, !en); in mt7915_tm_init()
415 mt7915_tm_reg_backup_restore(phy); in mt7915_tm_init()
416 mt7915_tm_set_trx(phy, TM_MAC_TXRX, !en); in mt7915_tm_init()
418 mt7915_mcu_add_bss_info(phy, phy->monitor_vif, en); in mt7915_tm_init()
420 mt7915_mcu_add_sta(dev, phy->monitor_vif, NULL, state, true); in mt7915_tm_init()
423 mt7915_tm_set_tam_arb(phy, en, 0); in mt7915_tm_init()
427 mt7915_tm_update_channel(struct mt7915_phy *phy) in mt7915_tm_update_channel() argument
429 mutex_unlock(&phy->dev->mt76.mutex); in mt7915_tm_update_channel()
430 mt76_update_channel(phy->mt76); in mt7915_tm_update_channel()
431 mutex_lock(&phy->dev->mt76.mutex); in mt7915_tm_update_channel()
433 mt7915_mcu_set_chan_info(phy, MCU_EXT_CMD(SET_RX_PATH)); in mt7915_tm_update_channel()
437 mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en) in mt7915_tm_set_tx_frames() argument
439 struct mt76_testmode_data *td = &phy->mt76->test; in mt7915_tm_set_tx_frames()
440 struct mt7915_dev *dev = phy->dev; in mt7915_tm_set_tx_frames()
442 u8 duty_cycle = td->tx_duty_cycle; in mt7915_tm_set_tx_frames()
443 u32 tx_time = td->tx_time; in mt7915_tm_set_tx_frames()
444 u32 ipg = td->tx_ipg; in mt7915_tm_set_tx_frames()
446 mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, false); in mt7915_tm_set_tx_frames()
447 mt7915_tm_clean_hwq(phy, dev->mt76.global_wcid.idx); in mt7915_tm_set_tx_frames()
450 mt7915_tm_update_channel(phy); in mt7915_tm_set_tx_frames()
452 if (td->tx_spe_idx) in mt7915_tm_set_tx_frames()
453 phy->test.spe_idx = td->tx_spe_idx; in mt7915_tm_set_tx_frames()
455 phy->test.spe_idx = mt76_connac_spe_idx(td->tx_antenna_mask); in mt7915_tm_set_tx_frames()
458 mt7915_tm_set_tam_arb(phy, en, in mt7915_tm_set_tx_frames()
459 td->tx_rate_mode == MT76_TM_TX_MODE_HE_MU); in mt7915_tm_set_tx_frames()
463 ipg = tx_time * 100 / duty_cycle - tx_time; in mt7915_tm_set_tx_frames()
466 tx_time = duty_cycle * ipg / (100 - duty_cycle); in mt7915_tm_set_tx_frames()
469 mt7915_tm_set_ipg_params(phy, ipg, td->tx_rate_mode); in mt7915_tm_set_tx_frames()
470 mt7915_tm_set_tx_len(phy, tx_time); in mt7915_tm_set_tx_frames()
473 td->tx_queued_limit = MT76_TM_TIMEOUT * 1000000 / ipg / 2; in mt7915_tm_set_tx_frames()
475 if (!en || !td->tx_skb) in mt7915_tm_set_tx_frames()
478 info = IEEE80211_SKB_CB(td->tx_skb); in mt7915_tm_set_tx_frames()
479 info->control.vif = phy->monitor_vif; in mt7915_tm_set_tx_frames()
481 mt7915_tm_set_trx(phy, TM_MAC_TX, en); in mt7915_tm_set_tx_frames()
485 mt7915_tm_set_rx_frames(struct mt7915_phy *phy, bool en) in mt7915_tm_set_rx_frames() argument
487 mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, false); in mt7915_tm_set_rx_frames()
490 struct mt7915_dev *dev = phy->dev; in mt7915_tm_set_rx_frames()
492 mt7915_tm_update_channel(phy); in mt7915_tm_set_rx_frames()
494 /* read-clear */ in mt7915_tm_set_rx_frames()
495 mt76_rr(dev, MT_MIB_SDR3(phy->mt76->band_idx)); in mt7915_tm_set_rx_frames()
496 mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, en); in mt7915_tm_set_rx_frames()
507 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RF_TEST), &req, in mt7915_tm_rf_switch_mode()
512 mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en) in mt7915_tm_set_tx_cont() argument
516 struct mt7915_dev *dev = phy->dev; in mt7915_tm_set_tx_cont()
517 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7915_tm_set_tx_cont()
518 int freq1 = ieee80211_frequency_to_channel(chandef->center_freq1); in mt7915_tm_set_tx_cont()
519 struct mt76_testmode_data *td = &phy->mt76->test; in mt7915_tm_set_tx_cont()
521 u8 rate_idx = td->tx_rate_idx, mode; in mt7915_tm_set_tx_cont()
522 u8 band = phy->mt76->band_idx; in mt7915_tm_set_tx_cont()
531 tx_cont->control_ch = chandef->chan->hw_value; in mt7915_tm_set_tx_cont()
532 tx_cont->center_ch = freq1; in mt7915_tm_set_tx_cont()
533 tx_cont->tx_ant = td->tx_antenna_mask; in mt7915_tm_set_tx_cont()
534 tx_cont->band = band; in mt7915_tm_set_tx_cont()
536 switch (chandef->width) { in mt7915_tm_set_tx_cont()
538 tx_cont->bw = CMD_CBW_40MHZ; in mt7915_tm_set_tx_cont()
541 tx_cont->bw = CMD_CBW_80MHZ; in mt7915_tm_set_tx_cont()
544 tx_cont->bw = CMD_CBW_8080MHZ; in mt7915_tm_set_tx_cont()
547 tx_cont->bw = CMD_CBW_160MHZ; in mt7915_tm_set_tx_cont()
550 tx_cont->bw = CMD_CBW_5MHZ; in mt7915_tm_set_tx_cont()
553 tx_cont->bw = CMD_CBW_10MHZ; in mt7915_tm_set_tx_cont()
556 tx_cont->bw = CMD_CBW_20MHZ; in mt7915_tm_set_tx_cont()
559 tx_cont->bw = CMD_CBW_20MHZ; in mt7915_tm_set_tx_cont()
562 return -EINVAL; in mt7915_tm_set_tx_cont()
570 if (td->tx_rate_mode <= MT76_TM_TX_MODE_OFDM) { in mt7915_tm_set_tx_cont()
574 if (chandef->chan->band == NL80211_BAND_5GHZ) in mt7915_tm_set_tx_cont()
575 sband = &phy->mt76->sband_5g.sband; in mt7915_tm_set_tx_cont()
576 else if (chandef->chan->band == NL80211_BAND_6GHZ) in mt7915_tm_set_tx_cont()
577 sband = &phy->mt76->sband_6g.sband; in mt7915_tm_set_tx_cont()
579 sband = &phy->mt76->sband_2g.sband; in mt7915_tm_set_tx_cont()
581 if (td->tx_rate_mode == MT76_TM_TX_MODE_OFDM) in mt7915_tm_set_tx_cont()
583 rate_idx = sband->bitrates[idx].hw_value & 0xff; in mt7915_tm_set_tx_cont()
586 switch (td->tx_rate_mode) { in mt7915_tm_set_tx_cont()
612 return -EINVAL; in mt7915_tm_set_tx_cont()
616 tx_cont->rateval = cpu_to_le16(rateval); in mt7915_tm_set_tx_cont()
622 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RF_TEST), &req, in mt7915_tm_set_tx_cont()
631 mt7915_tm_update_channel(phy); in mt7915_tm_set_tx_cont()
633 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RF_TEST), &req, in mt7915_tm_set_tx_cont()
638 mt7915_tm_update_params(struct mt7915_phy *phy, u32 changed) in mt7915_tm_update_params() argument
640 struct mt76_testmode_data *td = &phy->mt76->test; in mt7915_tm_update_params()
641 bool en = phy->mt76->test.state != MT76_TM_STATE_OFF; in mt7915_tm_update_params()
644 mt7915_tm_set_freq_offset(phy, en, en ? td->freq_offset : 0); in mt7915_tm_update_params()
646 mt7915_tm_set_tx_power(phy); in mt7915_tm_update_params()
652 struct mt76_testmode_data *td = &mphy->test; in mt7915_tm_set_state()
653 struct mt7915_phy *phy = mphy->priv; in mt7915_tm_set_state() local
654 enum mt76_testmode_state prev_state = td->state; in mt7915_tm_set_state()
656 mphy->test.state = state; in mt7915_tm_set_state()
660 mt7915_tm_set_tx_frames(phy, state == MT76_TM_STATE_TX_FRAMES); in mt7915_tm_set_state()
663 mt7915_tm_set_rx_frames(phy, state == MT76_TM_STATE_RX_FRAMES); in mt7915_tm_set_state()
666 mt7915_tm_set_tx_cont(phy, state == MT76_TM_STATE_TX_CONT); in mt7915_tm_set_state()
669 mt7915_tm_init(phy, !(state == MT76_TM_STATE_OFF)); in mt7915_tm_set_state()
681 if (td->param_set[cur / 32] & BIT(cur % 32)) in mt7915_tm_set_state()
685 mt7915_tm_update_params(phy, changed); in mt7915_tm_set_state()
695 struct mt76_testmode_data *td = &mphy->test; in mt7915_tm_set_params()
696 struct mt7915_phy *phy = mphy->priv; in mt7915_tm_set_params() local
697 struct mt7915_dev *dev = phy->dev; in mt7915_tm_set_params()
698 u32 chainmask = mphy->chainmask, changed = 0; in mt7915_tm_set_params()
699 bool ext_phy = phy != &dev->phy; in mt7915_tm_set_params()
705 td->state == MT76_TM_STATE_OFF) in mt7915_tm_set_params()
708 chainmask = ext_phy ? chainmask >> dev->chainshift : chainmask; in mt7915_tm_set_params()
709 if (td->tx_antenna_mask > chainmask) in mt7915_tm_set_params()
710 return -EINVAL; in mt7915_tm_set_params()
717 mt7915_tm_update_params(phy, changed); in mt7915_tm_set_params()
725 struct mt7915_phy *phy = mphy->priv; in mt7915_tm_dump_stats() local
726 struct mt7915_dev *dev = phy->dev; in mt7915_tm_dump_stats()
735 return -ENOMEM; in mt7915_tm_dump_stats()
737 if (nla_put_s32(msg, MT76_TM_RX_ATTR_FREQ_OFFSET, phy->test.last_freq_offset)) in mt7915_tm_dump_stats()
738 return -ENOMEM; in mt7915_tm_dump_stats()
742 return -ENOMEM; in mt7915_tm_dump_stats()
744 for (i = 0; i < ARRAY_SIZE(phy->test.last_rcpi); i++) in mt7915_tm_dump_stats()
745 if (nla_put_u8(msg, i, phy->test.last_rcpi[i])) in mt7915_tm_dump_stats()
746 return -ENOMEM; in mt7915_tm_dump_stats()
752 return -ENOMEM; in mt7915_tm_dump_stats()
754 for (i = 0; i < ARRAY_SIZE(phy->test.last_ib_rssi); i++) in mt7915_tm_dump_stats()
755 if (nla_put_s8(msg, i, phy->test.last_ib_rssi[i])) in mt7915_tm_dump_stats()
756 return -ENOMEM; in mt7915_tm_dump_stats()
762 return -ENOMEM; in mt7915_tm_dump_stats()
764 for (i = 0; i < ARRAY_SIZE(phy->test.last_wb_rssi); i++) in mt7915_tm_dump_stats()
765 if (nla_put_s8(msg, i, phy->test.last_wb_rssi[i])) in mt7915_tm_dump_stats()
766 return -ENOMEM; in mt7915_tm_dump_stats()
770 if (nla_put_u8(msg, MT76_TM_RX_ATTR_SNR, phy->test.last_snr)) in mt7915_tm_dump_stats()
771 return -ENOMEM; in mt7915_tm_dump_stats()
775 cnt = mt76_rr(dev, MT_MIB_SDR3(phy->mt76->band_idx)); in mt7915_tm_dump_stats()
776 fcs_err = is_mt7915(&dev->mt76) ? FIELD_GET(MT_MIB_SDR3_FCS_ERR_MASK, cnt) : in mt7915_tm_dump_stats()
779 q = phy->mt76->band_idx ? MT_RXQ_BAND1 : MT_RXQ_MAIN; in mt7915_tm_dump_stats()
780 mphy->test.rx_stats.packets[q] += fcs_err; in mt7915_tm_dump_stats()
781 mphy->test.rx_stats.fcs_error[q] += fcs_err; in mt7915_tm_dump_stats()