Lines Matching +full:txpower +full:- +full:5 +full:g
1 // SPDX-License-Identifier: ISC
12 switch (mt76_chip(&(_dev)->mt76)) { \
47 for (nss = 8; nss > 0; nss--) { in mt7915_mcu_get_sta_nss()
48 u8 nss_mcs = (mcs_map >> (2 * (nss - 1))) & 3; in mt7915_mcu_get_sta_nss()
54 return nss - 1; in mt7915_mcu_get_sta_nss()
61 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_set_sta_he_mcs()
62 struct mt7915_dev *dev = msta->vif->phy->dev; in mt7915_mcu_set_sta_he_mcs()
63 enum nl80211_band band = msta->vif->phy->mt76->chandef.chan->band; in mt7915_mcu_set_sta_he_mcs()
64 const u16 *mask = msta->vif->bitrate_mask.control[band].he_mcs; in mt7915_mcu_set_sta_he_mcs()
65 int nss, max_nss = sta->deflink.rx_nss > 3 ? 4 : sta->deflink.rx_nss; in mt7915_mcu_set_sta_he_mcs()
84 mcs = mcs ? fls(mcs & mask[nss]) - 1 : -1; in mt7915_mcu_set_sta_he_mcs()
104 if (is_mt7915(&dev->mt76) && nss > 1 && in mt7915_mcu_set_sta_he_mcs()
105 sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) in mt7915_mcu_set_sta_he_mcs()
116 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_set_sta_vht_mcs()
117 struct mt7915_dev *dev = msta->vif->phy->dev; in mt7915_mcu_set_sta_vht_mcs()
118 u16 mcs_map = le16_to_cpu(sta->deflink.vht_cap.vht_mcs.rx_mcs_map); in mt7915_mcu_set_sta_vht_mcs()
119 int nss, max_nss = sta->deflink.rx_nss > 3 ? 4 : sta->deflink.rx_nss; in mt7915_mcu_set_sta_vht_mcs()
140 if (is_mt7915(&dev->mt76) && nss > 1 && in mt7915_mcu_set_sta_vht_mcs()
141 sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) in mt7915_mcu_set_sta_vht_mcs()
150 int nss, max_nss = sta->deflink.rx_nss > 3 ? 4 : sta->deflink.rx_nss; in mt7915_mcu_set_sta_ht_mcs()
153 ht_mcs[nss] = sta->deflink.ht_cap.mcs.rx_mask[nss] & mask[nss]; in mt7915_mcu_set_sta_ht_mcs()
165 dev_err(mdev->dev, "Message %08x (seq %d) timeout\n", in mt7915_mcu_parse_response()
168 if (!test_and_set_bit(MT76_MCU_RESET, &dev->mphy.state)) { in mt7915_mcu_parse_response()
169 dev->recovery.restart = true; in mt7915_mcu_parse_response()
170 wake_up(&dev->mt76.mcu.wait); in mt7915_mcu_parse_response()
171 queue_work(dev->mt76.wq, &dev->reset_work); in mt7915_mcu_parse_response()
172 wake_up(&dev->reset_wait); in mt7915_mcu_parse_response()
175 return -ETIMEDOUT; in mt7915_mcu_parse_response()
178 rxd = (struct mt76_connac2_mcu_rxd *)skb->data; in mt7915_mcu_parse_response()
179 if (seq != rxd->seq && in mt7915_mcu_parse_response()
180 !(rxd->eid == MCU_CMD_EXT_CID && in mt7915_mcu_parse_response()
181 rxd->ext_eid == MCU_EXT_EVENT_WA_TX_STAT)) in mt7915_mcu_parse_response()
182 return -EAGAIN; in mt7915_mcu_parse_response()
185 skb_pull(skb, sizeof(*rxd) - 4); in mt7915_mcu_parse_response()
186 ret = *skb->data; in mt7915_mcu_parse_response()
189 ret = le32_to_cpu(*(__le32 *)skb->data); in mt7915_mcu_parse_response()
209 mdev->mcu.timeout = 2 * HZ; in mt7915_mcu_set_timeout()
225 else if (test_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state)) in mt7915_mcu_send_message()
232 return mt76_tx_queue_skb_raw(dev, mdev->q_mcu[qid], skb, 0); in mt7915_mcu_send_message()
247 return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), false); in mt7915_mcu_wa_cmd()
253 if (!vif->bss_conf.csa_active || vif->type == NL80211_IFTYPE_STATION) in mt7915_mcu_csa_finish()
262 struct mt76_phy *mphy = &dev->mt76.phy; in mt7915_mcu_rx_csa_notify()
265 c = (struct mt7915_mcu_csa_notify *)skb->data; in mt7915_mcu_rx_csa_notify()
267 if (c->band_idx > MT_BAND1) in mt7915_mcu_rx_csa_notify()
270 if ((c->band_idx && !dev->phy.mt76->band_idx) && in mt7915_mcu_rx_csa_notify()
271 dev->mt76.phys[MT_BAND1]) in mt7915_mcu_rx_csa_notify()
272 mphy = dev->mt76.phys[MT_BAND1]; in mt7915_mcu_rx_csa_notify()
274 ieee80211_iterate_active_interfaces_atomic(mphy->hw, in mt7915_mcu_rx_csa_notify()
276 mt7915_mcu_csa_finish, mphy->hw); in mt7915_mcu_rx_csa_notify()
282 struct mt76_phy *mphy = &dev->mt76.phy; in mt7915_mcu_rx_thermal_notify()
286 t = (struct mt7915_mcu_thermal_notify *)skb->data; in mt7915_mcu_rx_thermal_notify()
287 if (t->ctrl.ctrl_id != THERMAL_PROTECT_ENABLE) in mt7915_mcu_rx_thermal_notify()
290 if (t->ctrl.band_idx > MT_BAND1) in mt7915_mcu_rx_thermal_notify()
293 if ((t->ctrl.band_idx && !dev->phy.mt76->band_idx) && in mt7915_mcu_rx_thermal_notify()
294 dev->mt76.phys[MT_BAND1]) in mt7915_mcu_rx_thermal_notify()
295 mphy = dev->mt76.phys[MT_BAND1]; in mt7915_mcu_rx_thermal_notify()
297 phy = mphy->priv; in mt7915_mcu_rx_thermal_notify()
298 phy->throttle_state = t->ctrl.duty.duty_cycle; in mt7915_mcu_rx_thermal_notify()
304 struct mt76_phy *mphy = &dev->mt76.phy; in mt7915_mcu_rx_radar_detected()
307 r = (struct mt7915_mcu_rdd_report *)skb->data; in mt7915_mcu_rx_radar_detected()
309 if (r->band_idx > MT_RX_SEL2) in mt7915_mcu_rx_radar_detected()
312 if ((r->band_idx && !dev->phy.mt76->band_idx) && in mt7915_mcu_rx_radar_detected()
313 dev->mt76.phys[MT_BAND1]) in mt7915_mcu_rx_radar_detected()
314 mphy = dev->mt76.phys[MT_BAND1]; in mt7915_mcu_rx_radar_detected()
316 if (r->band_idx == MT_RX_SEL2) in mt7915_mcu_rx_radar_detected()
317 cfg80211_background_radar_event(mphy->hw->wiphy, in mt7915_mcu_rx_radar_detected()
318 &dev->rdd2_chandef, in mt7915_mcu_rx_radar_detected()
321 ieee80211_radar_detected(mphy->hw, NULL); in mt7915_mcu_rx_radar_detected()
322 dev->hw_pattern++; in mt7915_mcu_rx_radar_detected()
329 int len = skb->len - sizeof(*rxd); in mt7915_mcu_rx_log_message()
332 rxd = (struct mt76_connac2_mcu_rxd *)skb->data; in mt7915_mcu_rx_log_message()
335 switch (rxd->s2d_index) { in mt7915_mcu_rx_log_message()
350 wiphy_info(mt76_hw(dev)->wiphy, "%s: %.*s", type, len, data); in mt7915_mcu_rx_log_message()
356 if (!vif->bss_conf.color_change_active || vif->type == NL80211_IFTYPE_STATION) in mt7915_mcu_cca_finish()
365 struct mt76_phy *mphy = &dev->mt76.phy; in mt7915_mcu_rx_bcc_notify()
368 b = (struct mt7915_mcu_bcc_notify *)skb->data; in mt7915_mcu_rx_bcc_notify()
370 if (b->band_idx > MT_BAND1) in mt7915_mcu_rx_bcc_notify()
373 if ((b->band_idx && !dev->phy.mt76->band_idx) && in mt7915_mcu_rx_bcc_notify()
374 dev->mt76.phys[MT_BAND1]) in mt7915_mcu_rx_bcc_notify()
375 mphy = dev->mt76.phys[MT_BAND1]; in mt7915_mcu_rx_bcc_notify()
377 ieee80211_iterate_active_interfaces_atomic(mphy->hw, in mt7915_mcu_rx_bcc_notify()
379 mt7915_mcu_cca_finish, mphy->hw); in mt7915_mcu_rx_bcc_notify()
387 rxd = (struct mt76_connac2_mcu_rxd *)skb->data; in mt7915_mcu_rx_ext_event()
388 switch (rxd->ext_eid) { in mt7915_mcu_rx_ext_event()
414 rxd = (struct mt76_connac2_mcu_rxd *)skb->data; in mt7915_mcu_rx_unsolicited_event()
415 switch (rxd->eid) { in mt7915_mcu_rx_unsolicited_event()
429 rxd = (struct mt76_connac2_mcu_rxd *)skb->data; in mt7915_mcu_rx_event()
430 if ((rxd->ext_eid == MCU_EXT_EVENT_THERMAL_PROTECT || in mt7915_mcu_rx_event()
431 rxd->ext_eid == MCU_EXT_EVENT_FW_LOG_2_HOST || in mt7915_mcu_rx_event()
432 rxd->ext_eid == MCU_EXT_EVENT_ASSERT_DUMP || in mt7915_mcu_rx_event()
433 rxd->ext_eid == MCU_EXT_EVENT_PS_SYNC || in mt7915_mcu_rx_event()
434 rxd->ext_eid == MCU_EXT_EVENT_BCC_NOTIFY || in mt7915_mcu_rx_event()
435 !rxd->seq) && in mt7915_mcu_rx_event()
436 !(rxd->eid == MCU_CMD_EXT_CID && in mt7915_mcu_rx_event()
437 rxd->ext_eid == MCU_EXT_EVENT_WA_TX_STAT)) in mt7915_mcu_rx_event()
440 mt76_mcu_rx_event(&dev->mt76, skb); in mt7915_mcu_rx_event()
476 if (!elem || elem->datalen <= 10 || in mt7915_check_he_obss_narrow_bw_ru_iter()
477 !(elem->data[10] & in mt7915_check_he_obss_narrow_bw_ru_iter()
479 data->tolerated = false; in mt7915_check_he_obss_narrow_bw_ru_iter()
491 if (!(vif->bss_conf.chanreq.oper.chan->flags & IEEE80211_CHAN_RADAR)) in mt7915_check_he_obss_narrow_bw_ru()
494 cfg80211_bss_iter(hw->wiphy, &vif->bss_conf.chanreq.oper, in mt7915_check_he_obss_narrow_bw_ru()
500 * tolerate 26-tone RU UL OFDMA transmissions using HE TB PPDU. in mt7915_check_he_obss_narrow_bw_ru()
509 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7915_mcu_bss_rfch_tlv()
512 int freq1 = chandef->center_freq1; in mt7915_mcu_bss_rfch_tlv()
517 ch->pri_ch = chandef->chan->hw_value; in mt7915_mcu_bss_rfch_tlv()
518 ch->center_ch0 = ieee80211_frequency_to_channel(freq1); in mt7915_mcu_bss_rfch_tlv()
519 ch->bw = mt76_connac_chan_bw(chandef); in mt7915_mcu_bss_rfch_tlv()
521 if (chandef->width == NL80211_CHAN_WIDTH_80P80) { in mt7915_mcu_bss_rfch_tlv()
522 int freq2 = chandef->center_freq2; in mt7915_mcu_bss_rfch_tlv()
524 ch->center_ch1 = ieee80211_frequency_to_channel(freq2); in mt7915_mcu_bss_rfch_tlv()
527 if (vif->bss_conf.he_support && vif->type == NL80211_IFTYPE_STATION) { in mt7915_mcu_bss_rfch_tlv()
528 struct mt76_phy *mphy = phy->mt76; in mt7915_mcu_bss_rfch_tlv()
530 ch->he_ru26_block = in mt7915_mcu_bss_rfch_tlv()
531 mt7915_check_he_obss_narrow_bw_ru(mphy->hw, vif); in mt7915_mcu_bss_rfch_tlv()
532 ch->he_all_disable = false; in mt7915_mcu_bss_rfch_tlv()
534 ch->he_all_disable = true; in mt7915_mcu_bss_rfch_tlv()
542 int max_nss = hweight8(phy->mt76->antenna_mask); in mt7915_mcu_bss_ra_tlv()
549 ra->op_mode = vif->type == NL80211_IFTYPE_AP; in mt7915_mcu_bss_ra_tlv()
550 ra->adhoc_en = vif->type == NL80211_IFTYPE_ADHOC; in mt7915_mcu_bss_ra_tlv()
551 ra->short_preamble = true; in mt7915_mcu_bss_ra_tlv()
552 ra->tx_streams = max_nss; in mt7915_mcu_bss_ra_tlv()
553 ra->rx_streams = max_nss; in mt7915_mcu_bss_ra_tlv()
554 ra->algo = 4; in mt7915_mcu_bss_ra_tlv()
555 ra->train_up_rule = 2; in mt7915_mcu_bss_ra_tlv()
556 ra->train_up_high_thres = 110; in mt7915_mcu_bss_ra_tlv()
557 ra->train_up_rule_rssi = -70; in mt7915_mcu_bss_ra_tlv()
558 ra->low_traffic_thres = 2; in mt7915_mcu_bss_ra_tlv()
559 ra->phy_cap = cpu_to_le32(0xfdf); in mt7915_mcu_bss_ra_tlv()
560 ra->interval = cpu_to_le32(500); in mt7915_mcu_bss_ra_tlv()
561 ra->fast_interval = cpu_to_le32(100); in mt7915_mcu_bss_ra_tlv()
574 cap = mt76_connac_get_he_phy_cap(phy->mt76, vif); in mt7915_mcu_bss_he_tlv()
579 he->he_pe_duration = vif->bss_conf.htc_trig_based_pkt_ext; in mt7915_mcu_bss_he_tlv()
580 if (!he->he_pe_duration) in mt7915_mcu_bss_he_tlv()
581 he->he_pe_duration = DEFAULT_HE_PE_DURATION; in mt7915_mcu_bss_he_tlv()
583 he->he_rts_thres = cpu_to_le16(vif->bss_conf.frame_time_rts_th); in mt7915_mcu_bss_he_tlv()
584 if (!he->he_rts_thres) in mt7915_mcu_bss_he_tlv()
585 he->he_rts_thres = cpu_to_le16(DEFAULT_HE_DURATION_RTS_THRES); in mt7915_mcu_bss_he_tlv()
587 he->max_nss_mcs[CMD_HE_MCS_BW80] = cap->he_mcs_nss_supp.tx_mcs_80; in mt7915_mcu_bss_he_tlv()
588 he->max_nss_mcs[CMD_HE_MCS_BW160] = cap->he_mcs_nss_supp.tx_mcs_160; in mt7915_mcu_bss_he_tlv()
589 he->max_nss_mcs[CMD_HE_MCS_BW8080] = cap->he_mcs_nss_supp.tx_mcs_80p80; in mt7915_mcu_bss_he_tlv()
603 amsdu->cmp_bitmap_0 = cpu_to_le32(TXD_CMP_MAP1); in mt7915_mcu_bss_hw_amsdu_tlv()
604 amsdu->cmp_bitmap_1 = cpu_to_le32(TXD_CMP_MAP2); in mt7915_mcu_bss_hw_amsdu_tlv()
605 amsdu->trig_thres = cpu_to_le16(2); in mt7915_mcu_bss_hw_amsdu_tlv()
606 amsdu->enable = true; in mt7915_mcu_bss_hw_amsdu_tlv()
613 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7915_mcu_bss_bmc_tlv()
614 enum nl80211_band band = chandef->chan->band; in mt7915_mcu_bss_bmc_tlv()
621 bmc->short_preamble = true; in mt7915_mcu_bss_bmc_tlv()
623 bmc->bc_trans = cpu_to_le16(0x2000); in mt7915_mcu_bss_bmc_tlv()
624 bmc->mc_trans = cpu_to_le16(0x2080); in mt7915_mcu_bss_bmc_tlv()
632 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_muar_config()
633 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_muar_config()
634 u32 idx = mvif->mt76.omac_idx - REPEATER_BSSID_START; in mt7915_mcu_muar_config()
635 u32 mask = phy->omac_mask >> 32 & ~BIT(idx); in mt7915_mcu_muar_config()
636 const u8 *addr = vif->addr; in mt7915_mcu_muar_config()
652 .band = phy->mt76->band_idx, in mt7915_mcu_muar_config()
657 addr = vif->bss_conf.bssid; in mt7915_mcu_muar_config()
662 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(MUAR_UPDATE), &req, in mt7915_mcu_muar_config()
669 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_bss_info()
670 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_add_bss_info()
673 if (mvif->mt76.omac_idx >= REPEATER_BSSID_START) { in mt7915_mcu_add_bss_info()
678 skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, NULL, in mt7915_mcu_add_bss_info()
687 mt76_connac_mcu_bss_basic_tlv(skb, vif, NULL, phy->mt76, in mt7915_mcu_add_bss_info()
688 mvif->sta.wcid.idx, enable); in mt7915_mcu_add_bss_info()
690 if (vif->type == NL80211_IFTYPE_MONITOR) in mt7915_mcu_add_bss_info()
699 if (vif->bss_conf.he_support) in mt7915_mcu_add_bss_info()
702 if (mvif->mt76.omac_idx >= EXT_BSSID_START && in mt7915_mcu_add_bss_info()
703 mvif->mt76.omac_idx < REPEATER_BSSID_START) in mt7915_mcu_add_bss_info()
704 mt76_connac_mcu_bss_ext_tlv(skb, &mvif->mt76); in mt7915_mcu_add_bss_info()
707 return mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7915_mcu_add_bss_info()
716 struct mt7915_sta *msta = (struct mt7915_sta *)params->sta->drv_priv; in mt7915_mcu_add_tx_ba()
717 struct mt7915_vif *mvif = msta->vif; in mt7915_mcu_add_tx_ba()
720 mt76_worker_disable(&dev->mt76.tx_worker); in mt7915_mcu_add_tx_ba()
721 if (enable && !params->amsdu) in mt7915_mcu_add_tx_ba()
722 msta->wcid.amsdu = false; in mt7915_mcu_add_tx_ba()
723 ret = mt76_connac_mcu_sta_ba(&dev->mt76, &mvif->mt76, params, in mt7915_mcu_add_tx_ba()
726 mt76_worker_enable(&dev->mt76.tx_worker); in mt7915_mcu_add_tx_ba()
735 struct mt7915_sta *msta = (struct mt7915_sta *)params->sta->drv_priv; in mt7915_mcu_add_rx_ba()
736 struct mt7915_vif *mvif = msta->vif; in mt7915_mcu_add_rx_ba()
738 return mt76_connac_mcu_sta_ba(&dev->mt76, &mvif->mt76, params, in mt7915_mcu_add_rx_ba()
747 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_sta_he_tlv()
748 struct ieee80211_he_cap_elem *elem = &sta->deflink.he_cap.he_cap_elem; in mt7915_mcu_sta_he_tlv()
754 if (!sta->deflink.he_cap.has_he) in mt7915_mcu_sta_he_tlv()
761 if (elem->mac_cap_info[0] & IEEE80211_HE_MAC_CAP0_HTC_HE) in mt7915_mcu_sta_he_tlv()
764 if (elem->mac_cap_info[2] & IEEE80211_HE_MAC_CAP2_BSR) in mt7915_mcu_sta_he_tlv()
767 if (elem->mac_cap_info[3] & IEEE80211_HE_MAC_CAP3_OMI_CONTROL) in mt7915_mcu_sta_he_tlv()
770 if (elem->mac_cap_info[4] & IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU) in mt7915_mcu_sta_he_tlv()
773 if (elem->mac_cap_info[4] & IEEE80211_HE_MAC_CAP4_BQR) in mt7915_mcu_sta_he_tlv()
776 if (elem->phy_cap_info[0] & in mt7915_mcu_sta_he_tlv()
781 if (mvif->cap.he_ldpc && in mt7915_mcu_sta_he_tlv()
782 (elem->phy_cap_info[1] & in mt7915_mcu_sta_he_tlv()
786 if (elem->phy_cap_info[1] & in mt7915_mcu_sta_he_tlv()
790 if (elem->phy_cap_info[2] & in mt7915_mcu_sta_he_tlv()
794 if (elem->phy_cap_info[2] & in mt7915_mcu_sta_he_tlv()
798 if (elem->phy_cap_info[2] & in mt7915_mcu_sta_he_tlv()
802 if (elem->phy_cap_info[6] & in mt7915_mcu_sta_he_tlv()
806 if (elem->phy_cap_info[6] & in mt7915_mcu_sta_he_tlv()
810 if (elem->phy_cap_info[7] & in mt7915_mcu_sta_he_tlv()
814 if (elem->phy_cap_info[7] & in mt7915_mcu_sta_he_tlv()
818 if (elem->phy_cap_info[7] & in mt7915_mcu_sta_he_tlv()
822 if (elem->phy_cap_info[8] & in mt7915_mcu_sta_he_tlv()
826 if (elem->phy_cap_info[8] & in mt7915_mcu_sta_he_tlv()
830 if (elem->phy_cap_info[9] & in mt7915_mcu_sta_he_tlv()
834 if (elem->phy_cap_info[9] & in mt7915_mcu_sta_he_tlv()
838 he->he_cap = cpu_to_le32(cap); in mt7915_mcu_sta_he_tlv()
840 mcs_map = sta->deflink.he_cap.he_mcs_nss_supp; in mt7915_mcu_sta_he_tlv()
841 switch (sta->deflink.bandwidth) { in mt7915_mcu_sta_he_tlv()
843 if (elem->phy_cap_info[0] & in mt7915_mcu_sta_he_tlv()
846 &he->max_nss_mcs[CMD_HE_MCS_BW8080], in mt7915_mcu_sta_he_tlv()
850 &he->max_nss_mcs[CMD_HE_MCS_BW160], in mt7915_mcu_sta_he_tlv()
855 &he->max_nss_mcs[CMD_HE_MCS_BW80], in mt7915_mcu_sta_he_tlv()
860 he->t_frame_dur = in mt7915_mcu_sta_he_tlv()
861 HE_MAC(CAP1_TF_MAC_PAD_DUR_MASK, elem->mac_cap_info[1]); in mt7915_mcu_sta_he_tlv()
862 he->max_ampdu_exp = in mt7915_mcu_sta_he_tlv()
863 HE_MAC(CAP3_MAX_AMPDU_LEN_EXP_MASK, elem->mac_cap_info[3]); in mt7915_mcu_sta_he_tlv()
865 he->bw_set = in mt7915_mcu_sta_he_tlv()
866 HE_PHY(CAP0_CHANNEL_WIDTH_SET_MASK, elem->phy_cap_info[0]); in mt7915_mcu_sta_he_tlv()
867 he->device_class = in mt7915_mcu_sta_he_tlv()
868 HE_PHY(CAP1_DEVICE_CLASS_A, elem->phy_cap_info[1]); in mt7915_mcu_sta_he_tlv()
869 he->punc_pream_rx = in mt7915_mcu_sta_he_tlv()
870 HE_PHY(CAP1_PREAMBLE_PUNC_RX_MASK, elem->phy_cap_info[1]); in mt7915_mcu_sta_he_tlv()
872 he->dcm_tx_mode = in mt7915_mcu_sta_he_tlv()
873 HE_PHY(CAP3_DCM_MAX_CONST_TX_MASK, elem->phy_cap_info[3]); in mt7915_mcu_sta_he_tlv()
874 he->dcm_tx_max_nss = in mt7915_mcu_sta_he_tlv()
875 HE_PHY(CAP3_DCM_MAX_TX_NSS_2, elem->phy_cap_info[3]); in mt7915_mcu_sta_he_tlv()
876 he->dcm_rx_mode = in mt7915_mcu_sta_he_tlv()
877 HE_PHY(CAP3_DCM_MAX_CONST_RX_MASK, elem->phy_cap_info[3]); in mt7915_mcu_sta_he_tlv()
878 he->dcm_rx_max_nss = in mt7915_mcu_sta_he_tlv()
879 HE_PHY(CAP3_DCM_MAX_RX_NSS_2, elem->phy_cap_info[3]); in mt7915_mcu_sta_he_tlv()
880 he->dcm_rx_max_nss = in mt7915_mcu_sta_he_tlv()
881 HE_PHY(CAP8_DCM_MAX_RU_MASK, elem->phy_cap_info[8]); in mt7915_mcu_sta_he_tlv()
883 he->pkt_ext = 2; in mt7915_mcu_sta_he_tlv()
890 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_sta_muru_tlv()
891 struct ieee80211_he_cap_elem *elem = &sta->deflink.he_cap.he_cap_elem; in mt7915_mcu_sta_muru_tlv()
895 if (vif->type != NL80211_IFTYPE_STATION && in mt7915_mcu_sta_muru_tlv()
896 vif->type != NL80211_IFTYPE_AP) in mt7915_mcu_sta_muru_tlv()
903 muru->cfg.mimo_dl_en = mvif->cap.he_mu_ebfer || in mt7915_mcu_sta_muru_tlv()
904 mvif->cap.vht_mu_ebfer || in mt7915_mcu_sta_muru_tlv()
905 mvif->cap.vht_mu_ebfee; in mt7915_mcu_sta_muru_tlv()
906 if (!is_mt7915(&dev->mt76)) in mt7915_mcu_sta_muru_tlv()
907 muru->cfg.mimo_ul_en = true; in mt7915_mcu_sta_muru_tlv()
908 muru->cfg.ofdma_dl_en = true; in mt7915_mcu_sta_muru_tlv()
910 if (sta->deflink.vht_cap.vht_supported) in mt7915_mcu_sta_muru_tlv()
911 muru->mimo_dl.vht_mu_bfee = in mt7915_mcu_sta_muru_tlv()
912 !!(sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE); in mt7915_mcu_sta_muru_tlv()
914 if (!sta->deflink.he_cap.has_he) in mt7915_mcu_sta_muru_tlv()
917 muru->mimo_dl.partial_bw_dl_mimo = in mt7915_mcu_sta_muru_tlv()
918 HE_PHY(CAP6_PARTIAL_BANDWIDTH_DL_MUMIMO, elem->phy_cap_info[6]); in mt7915_mcu_sta_muru_tlv()
920 muru->mimo_ul.full_ul_mimo = in mt7915_mcu_sta_muru_tlv()
921 HE_PHY(CAP2_UL_MU_FULL_MU_MIMO, elem->phy_cap_info[2]); in mt7915_mcu_sta_muru_tlv()
922 muru->mimo_ul.partial_ul_mimo = in mt7915_mcu_sta_muru_tlv()
923 HE_PHY(CAP2_UL_MU_PARTIAL_MU_MIMO, elem->phy_cap_info[2]); in mt7915_mcu_sta_muru_tlv()
925 muru->ofdma_dl.punc_pream_rx = in mt7915_mcu_sta_muru_tlv()
926 HE_PHY(CAP1_PREAMBLE_PUNC_RX_MASK, elem->phy_cap_info[1]); in mt7915_mcu_sta_muru_tlv()
927 muru->ofdma_dl.he_20m_in_40m_2g = in mt7915_mcu_sta_muru_tlv()
928 HE_PHY(CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G, elem->phy_cap_info[8]); in mt7915_mcu_sta_muru_tlv()
929 muru->ofdma_dl.he_20m_in_160m = in mt7915_mcu_sta_muru_tlv()
930 HE_PHY(CAP8_20MHZ_IN_160MHZ_HE_PPDU, elem->phy_cap_info[8]); in mt7915_mcu_sta_muru_tlv()
931 muru->ofdma_dl.he_80m_in_160m = in mt7915_mcu_sta_muru_tlv()
932 HE_PHY(CAP8_80MHZ_IN_160MHZ_HE_PPDU, elem->phy_cap_info[8]); in mt7915_mcu_sta_muru_tlv()
934 muru->ofdma_ul.t_frame_dur = in mt7915_mcu_sta_muru_tlv()
935 HE_MAC(CAP1_TF_MAC_PAD_DUR_MASK, elem->mac_cap_info[1]); in mt7915_mcu_sta_muru_tlv()
936 muru->ofdma_ul.mu_cascading = in mt7915_mcu_sta_muru_tlv()
937 HE_MAC(CAP2_MU_CASCADING, elem->mac_cap_info[2]); in mt7915_mcu_sta_muru_tlv()
938 muru->ofdma_ul.uo_ra = in mt7915_mcu_sta_muru_tlv()
939 HE_MAC(CAP3_OFDMA_RA, elem->mac_cap_info[3]); in mt7915_mcu_sta_muru_tlv()
940 muru->ofdma_ul.rx_ctrl_frame_to_mbss = in mt7915_mcu_sta_muru_tlv()
941 HE_MAC(CAP3_RX_CTRL_FRAME_TO_MULTIBSS, elem->mac_cap_info[3]); in mt7915_mcu_sta_muru_tlv()
950 if (!sta->deflink.ht_cap.ht_supported) in mt7915_mcu_sta_ht_tlv()
956 ht->ht_cap = cpu_to_le16(sta->deflink.ht_cap.cap); in mt7915_mcu_sta_ht_tlv()
965 if (!sta->deflink.vht_cap.vht_supported) in mt7915_mcu_sta_vht_tlv()
971 vht->vht_cap = cpu_to_le32(sta->deflink.vht_cap.cap); in mt7915_mcu_sta_vht_tlv()
972 vht->vht_rx_mcs_map = sta->deflink.vht_cap.vht_mcs.rx_mcs_map; in mt7915_mcu_sta_vht_tlv()
973 vht->vht_tx_mcs_map = sta->deflink.vht_cap.vht_mcs.tx_mcs_map; in mt7915_mcu_sta_vht_tlv()
980 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_sta_amsdu_tlv()
984 if (vif->type != NL80211_IFTYPE_STATION && in mt7915_mcu_sta_amsdu_tlv()
985 vif->type != NL80211_IFTYPE_AP) in mt7915_mcu_sta_amsdu_tlv()
988 if (!sta->deflink.agg.max_amsdu_len) in mt7915_mcu_sta_amsdu_tlv()
993 amsdu->max_amsdu_num = 8; in mt7915_mcu_sta_amsdu_tlv()
994 amsdu->amsdu_en = true; in mt7915_mcu_sta_amsdu_tlv()
995 msta->wcid.amsdu = true; in mt7915_mcu_sta_amsdu_tlv()
997 switch (sta->deflink.agg.max_amsdu_len) { in mt7915_mcu_sta_amsdu_tlv()
999 if (!is_mt7915(&dev->mt76)) { in mt7915_mcu_sta_amsdu_tlv()
1000 amsdu->max_mpdu_size = in mt7915_mcu_sta_amsdu_tlv()
1007 amsdu->max_mpdu_size = IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; in mt7915_mcu_sta_amsdu_tlv()
1010 amsdu->max_mpdu_size = IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; in mt7915_mcu_sta_amsdu_tlv()
1019 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_sta_wtbl_tlv()
1025 msta = sta ? (struct mt7915_sta *)sta->drv_priv : &mvif->sta; in mt7915_mcu_sta_wtbl_tlv()
1026 wcid = sta ? &msta->wcid : NULL; in mt7915_mcu_sta_wtbl_tlv()
1029 wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(&dev->mt76, &msta->wcid, in mt7915_mcu_sta_wtbl_tlv()
1035 mt76_connac_mcu_wtbl_generic_tlv(&dev->mt76, skb, vif, sta, tlv, in mt7915_mcu_sta_wtbl_tlv()
1039 mt76_connac_mcu_wtbl_ht_tlv(&dev->mt76, skb, sta, tlv, in mt7915_mcu_sta_wtbl_tlv()
1040 wtbl_hdr, mvif->cap.ht_ldpc, in mt7915_mcu_sta_wtbl_tlv()
1041 mvif->cap.vht_ldpc); in mt7915_mcu_sta_wtbl_tlv()
1050 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_is_ebf_supported()
1051 int sts = hweight16(phy->mt76->chainmask); in mt7915_is_ebf_supported()
1053 if (vif->type != NL80211_IFTYPE_STATION && in mt7915_is_ebf_supported()
1054 vif->type != NL80211_IFTYPE_AP) in mt7915_is_ebf_supported()
1060 if (sta->deflink.he_cap.has_he) { in mt7915_is_ebf_supported()
1061 struct ieee80211_he_cap_elem *pe = &sta->deflink.he_cap.he_cap_elem; in mt7915_is_ebf_supported()
1064 return mvif->cap.he_su_ebfee && in mt7915_is_ebf_supported()
1065 HE_PHY(CAP3_SU_BEAMFORMER, pe->phy_cap_info[3]); in mt7915_is_ebf_supported()
1067 return mvif->cap.he_su_ebfer && in mt7915_is_ebf_supported()
1068 HE_PHY(CAP4_SU_BEAMFORMEE, pe->phy_cap_info[4]); in mt7915_is_ebf_supported()
1071 if (sta->deflink.vht_cap.vht_supported) { in mt7915_is_ebf_supported()
1072 u32 cap = sta->deflink.vht_cap.cap; in mt7915_is_ebf_supported()
1075 return mvif->cap.vht_su_ebfee && in mt7915_is_ebf_supported()
1078 return mvif->cap.vht_su_ebfer && in mt7915_is_ebf_supported()
1088 bf->sounding_phy = MT_PHY_TYPE_OFDM; in mt7915_mcu_sta_sounding_rate()
1089 bf->ndp_rate = 0; /* mcs0 */ in mt7915_mcu_sta_sounding_rate()
1090 bf->ndpa_rate = MT7915_CFEND_RATE_DEFAULT; /* ofdm 24m */ in mt7915_mcu_sta_sounding_rate()
1091 bf->rept_poll_rate = MT7915_CFEND_RATE_DEFAULT; /* ofdm 24m */ in mt7915_mcu_sta_sounding_rate()
1098 struct ieee80211_mcs_info *mcs = &sta->deflink.ht_cap.mcs; in mt7915_mcu_sta_bfer_ht()
1101 bf->tx_mode = MT_PHY_TYPE_HT; in mt7915_mcu_sta_bfer_ht()
1103 if ((mcs->tx_params & IEEE80211_HT_MCS_TX_RX_DIFF) && in mt7915_mcu_sta_bfer_ht()
1104 (mcs->tx_params & IEEE80211_HT_MCS_TX_DEFINED)) in mt7915_mcu_sta_bfer_ht()
1106 mcs->tx_params); in mt7915_mcu_sta_bfer_ht()
1107 else if (mcs->rx_mask[3]) in mt7915_mcu_sta_bfer_ht()
1109 else if (mcs->rx_mask[2]) in mt7915_mcu_sta_bfer_ht()
1111 else if (mcs->rx_mask[1]) in mt7915_mcu_sta_bfer_ht()
1114 bf->nrow = hweight8(phy->mt76->chainmask) - 1; in mt7915_mcu_sta_bfer_ht()
1115 bf->ncol = min_t(u8, bf->nrow, n); in mt7915_mcu_sta_bfer_ht()
1116 bf->ibf_ncol = n; in mt7915_mcu_sta_bfer_ht()
1123 struct ieee80211_sta_vht_cap *pc = &sta->deflink.vht_cap; in mt7915_mcu_sta_bfer_vht()
1124 struct ieee80211_sta_vht_cap *vc = &phy->mt76->sband_5g.sband.vht_cap; in mt7915_mcu_sta_bfer_vht()
1125 u16 mcs_map = le16_to_cpu(pc->vht_mcs.rx_mcs_map); in mt7915_mcu_sta_bfer_vht()
1127 u8 tx_ant = hweight8(phy->mt76->chainmask) - 1; in mt7915_mcu_sta_bfer_vht()
1129 bf->tx_mode = MT_PHY_TYPE_VHT; in mt7915_mcu_sta_bfer_vht()
1137 pc->cap); in mt7915_mcu_sta_bfer_vht()
1139 vc->cap); in mt7915_mcu_sta_bfer_vht()
1140 bf->nrow = min_t(u8, min_t(u8, snd_dim, sts), tx_ant); in mt7915_mcu_sta_bfer_vht()
1141 bf->ncol = min_t(u8, nss_mcs, bf->nrow); in mt7915_mcu_sta_bfer_vht()
1142 bf->ibf_ncol = bf->ncol; in mt7915_mcu_sta_bfer_vht()
1144 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) in mt7915_mcu_sta_bfer_vht()
1145 bf->nrow = 1; in mt7915_mcu_sta_bfer_vht()
1147 bf->nrow = tx_ant; in mt7915_mcu_sta_bfer_vht()
1148 bf->ncol = min_t(u8, nss_mcs, bf->nrow); in mt7915_mcu_sta_bfer_vht()
1149 bf->ibf_ncol = nss_mcs; in mt7915_mcu_sta_bfer_vht()
1151 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) in mt7915_mcu_sta_bfer_vht()
1152 bf->ibf_nrow = 1; in mt7915_mcu_sta_bfer_vht()
1160 struct ieee80211_sta_he_cap *pc = &sta->deflink.he_cap; in mt7915_mcu_sta_bfer_he()
1161 struct ieee80211_he_cap_elem *pe = &pc->he_cap_elem; in mt7915_mcu_sta_bfer_he()
1163 mt76_connac_get_he_phy_cap(phy->mt76, vif); in mt7915_mcu_sta_bfer_he()
1164 const struct ieee80211_he_cap_elem *ve = &vc->he_cap_elem; in mt7915_mcu_sta_bfer_he()
1165 u16 mcs_map = le16_to_cpu(pc->he_mcs_nss_supp.rx_mcs_80); in mt7915_mcu_sta_bfer_he()
1169 bf->tx_mode = MT_PHY_TYPE_HE_SU; in mt7915_mcu_sta_bfer_he()
1173 bf->trigger_su = HE_PHY(CAP6_TRIG_SU_BEAMFORMING_FB, in mt7915_mcu_sta_bfer_he()
1174 pe->phy_cap_info[6]); in mt7915_mcu_sta_bfer_he()
1175 bf->trigger_mu = HE_PHY(CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB, in mt7915_mcu_sta_bfer_he()
1176 pe->phy_cap_info[6]); in mt7915_mcu_sta_bfer_he()
1178 ve->phy_cap_info[5]); in mt7915_mcu_sta_bfer_he()
1180 pe->phy_cap_info[4]); in mt7915_mcu_sta_bfer_he()
1181 bf->nrow = min_t(u8, snd_dim, sts); in mt7915_mcu_sta_bfer_he()
1182 bf->ncol = min_t(u8, nss_mcs, bf->nrow); in mt7915_mcu_sta_bfer_he()
1183 bf->ibf_ncol = bf->ncol; in mt7915_mcu_sta_bfer_he()
1185 if (sta->deflink.bandwidth != IEEE80211_STA_RX_BW_160) in mt7915_mcu_sta_bfer_he()
1189 if (pe->phy_cap_info[0] & in mt7915_mcu_sta_bfer_he()
1191 mcs_map = le16_to_cpu(pc->he_mcs_nss_supp.rx_mcs_160); in mt7915_mcu_sta_bfer_he()
1194 bf->ncol_gt_bw80 = nss_mcs; in mt7915_mcu_sta_bfer_he()
1197 if (pe->phy_cap_info[0] & in mt7915_mcu_sta_bfer_he()
1199 mcs_map = le16_to_cpu(pc->he_mcs_nss_supp.rx_mcs_80p80); in mt7915_mcu_sta_bfer_he()
1202 if (bf->ncol_gt_bw80) in mt7915_mcu_sta_bfer_he()
1203 bf->ncol_gt_bw80 = min_t(u8, bf->ncol_gt_bw80, nss_mcs); in mt7915_mcu_sta_bfer_he()
1205 bf->ncol_gt_bw80 = nss_mcs; in mt7915_mcu_sta_bfer_he()
1209 ve->phy_cap_info[5]); in mt7915_mcu_sta_bfer_he()
1211 pe->phy_cap_info[4]); in mt7915_mcu_sta_bfer_he()
1213 bf->nrow_gt_bw80 = min_t(int, snd_dim, sts); in mt7915_mcu_sta_bfer_he()
1220 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_sta_bfer_tlv()
1221 struct mt7915_phy *phy = mvif->phy; in mt7915_mcu_sta_bfer_tlv()
1222 int tx_ant = hweight8(phy->mt76->chainmask) - 1; in mt7915_mcu_sta_bfer_tlv()
1229 {3, 5, 6, 0} /* 4x1, 4x2, 4x3, 4x4 */ in mt7915_mcu_sta_bfer_tlv()
1233 if (!(sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he)) in mt7915_mcu_sta_bfer_tlv()
1237 if (!ebf && !dev->ibf) in mt7915_mcu_sta_bfer_tlv()
1247 if (sta->deflink.he_cap.has_he && ebf) in mt7915_mcu_sta_bfer_tlv()
1249 else if (sta->deflink.vht_cap.vht_supported) in mt7915_mcu_sta_bfer_tlv()
1251 else if (sta->deflink.ht_cap.ht_supported) in mt7915_mcu_sta_bfer_tlv()
1256 bf->bf_cap = ebf ? ebf : dev->ibf << 1; in mt7915_mcu_sta_bfer_tlv()
1257 bf->bw = sta->deflink.bandwidth; in mt7915_mcu_sta_bfer_tlv()
1258 bf->ibf_dbw = sta->deflink.bandwidth; in mt7915_mcu_sta_bfer_tlv()
1259 bf->ibf_nrow = tx_ant; in mt7915_mcu_sta_bfer_tlv()
1261 if (!ebf && sta->deflink.bandwidth <= IEEE80211_STA_RX_BW_40 && !bf->ncol) in mt7915_mcu_sta_bfer_tlv()
1262 bf->ibf_timeout = 0x48; in mt7915_mcu_sta_bfer_tlv()
1264 bf->ibf_timeout = 0x18; in mt7915_mcu_sta_bfer_tlv()
1266 if (ebf && bf->nrow != tx_ant) in mt7915_mcu_sta_bfer_tlv()
1267 bf->mem_20m = matrix[tx_ant][bf->ncol]; in mt7915_mcu_sta_bfer_tlv()
1269 bf->mem_20m = matrix[bf->nrow][bf->ncol]; in mt7915_mcu_sta_bfer_tlv()
1271 switch (sta->deflink.bandwidth) { in mt7915_mcu_sta_bfer_tlv()
1274 bf->mem_total = bf->mem_20m * 2; in mt7915_mcu_sta_bfer_tlv()
1277 bf->mem_total = bf->mem_20m; in mt7915_mcu_sta_bfer_tlv()
1289 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_sta_bfee_tlv()
1290 struct mt7915_phy *phy = mvif->phy; in mt7915_mcu_sta_bfee_tlv()
1291 int tx_ant = hweight8(phy->mt76->chainmask) - 1; in mt7915_mcu_sta_bfee_tlv()
1296 if (!(sta->deflink.vht_cap.vht_supported || sta->deflink.he_cap.has_he)) in mt7915_mcu_sta_bfee_tlv()
1305 if (sta->deflink.he_cap.has_he) { in mt7915_mcu_sta_bfee_tlv()
1306 struct ieee80211_he_cap_elem *pe = &sta->deflink.he_cap.he_cap_elem; in mt7915_mcu_sta_bfee_tlv()
1309 pe->phy_cap_info[5]); in mt7915_mcu_sta_bfee_tlv()
1310 } else if (sta->deflink.vht_cap.vht_supported) { in mt7915_mcu_sta_bfee_tlv()
1311 struct ieee80211_sta_vht_cap *pc = &sta->deflink.vht_cap; in mt7915_mcu_sta_bfee_tlv()
1314 pc->cap); in mt7915_mcu_sta_bfee_tlv()
1318 bfee->fb_identity_matrix = (nrow == 1 && tx_ant == 2); in mt7915_mcu_sta_bfee_tlv()
1341 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_set_fixed_rate_ctrl()
1342 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_set_fixed_rate_ctrl()
1348 skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, in mt7915_mcu_set_fixed_rate_ctrl()
1349 &msta->wcid); in mt7915_mcu_set_fixed_rate_ctrl()
1364 ra->phy = *phy; in mt7915_mcu_set_fixed_rate_ctrl()
1367 ra->mmps_mode = mt7915_mcu_get_mmps_mode(sta->deflink.smps_mode); in mt7915_mcu_set_fixed_rate_ctrl()
1370 ra->spe_idx = *(u8 *)data; in mt7915_mcu_set_fixed_rate_ctrl()
1375 ra->field = cpu_to_le32(field); in mt7915_mcu_set_fixed_rate_ctrl()
1377 return mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7915_mcu_set_fixed_rate_ctrl()
1384 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_smps()
1385 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_add_smps()
1391 skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, in mt7915_mcu_add_smps()
1392 &msta->wcid); in mt7915_mcu_add_smps()
1398 wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(&dev->mt76, &msta->wcid, in mt7915_mcu_add_smps()
1405 ret = mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7915_mcu_add_smps()
1418 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_set_spe_idx()
1419 struct mt76_phy *mphy = mvif->phy->mt76; in mt7915_mcu_set_spe_idx()
1420 u8 spe_idx = mt76_connac_spe_idx(mphy->antenna_mask); in mt7915_mcu_set_spe_idx()
1431 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_rate_ctrl_fixed()
1432 struct cfg80211_chan_def *chandef = &mvif->phy->mt76->chandef; in mt7915_mcu_add_rate_ctrl_fixed()
1433 struct cfg80211_bitrate_mask *mask = &mvif->bitrate_mask; in mt7915_mcu_add_rate_ctrl_fixed()
1434 enum nl80211_band band = chandef->chan->band; in mt7915_mcu_add_rate_ctrl_fixed()
1440 u8 i, gi = mask->control[band]._gi; \ in mt7915_mcu_add_rate_ctrl_fixed()
1442 for (i = 0; i <= sta->deflink.bandwidth; i++) { \ in mt7915_mcu_add_rate_ctrl_fixed()
1444 phy.he_ltf |= mask->control[band].he_ltf << (i << (_he));\ in mt7915_mcu_add_rate_ctrl_fixed()
1446 for (i = 0; i < ARRAY_SIZE(mask->control[band]._mcs); i++) { \ in mt7915_mcu_add_rate_ctrl_fixed()
1447 if (!mask->control[band]._mcs[i]) \ in mt7915_mcu_add_rate_ctrl_fixed()
1449 nrates += hweight16(mask->control[band]._mcs[i]); \ in mt7915_mcu_add_rate_ctrl_fixed()
1450 phy.mcs = ffs(mask->control[band]._mcs[i]) - 1; \ in mt7915_mcu_add_rate_ctrl_fixed()
1456 if (sta->deflink.he_cap.has_he) { in mt7915_mcu_add_rate_ctrl_fixed()
1458 } else if (sta->deflink.vht_cap.vht_supported) { in mt7915_mcu_add_rate_ctrl_fixed()
1460 } else if (sta->deflink.ht_cap.ht_supported) { in mt7915_mcu_add_rate_ctrl_fixed()
1463 nrates = hweight32(mask->control[band].legacy); in mt7915_mcu_add_rate_ctrl_fixed()
1464 phy.mcs = ffs(mask->control[band].legacy) - 1; in mt7915_mcu_add_rate_ctrl_fixed()
1469 if (mask->control[band].gi == NL80211_TXRATE_DEFAULT_GI && in mt7915_mcu_add_rate_ctrl_fixed()
1470 mask->control[band].he_gi == GENMASK(7, 0) && in mt7915_mcu_add_rate_ctrl_fixed()
1471 mask->control[band].he_ltf == GENMASK(7, 0) && in mt7915_mcu_add_rate_ctrl_fixed()
1484 if (mask->control[band].gi != NL80211_TXRATE_DEFAULT_GI || in mt7915_mcu_add_rate_ctrl_fixed()
1485 mask->control[band].he_gi != GENMASK(7, 0)) { in mt7915_mcu_add_rate_ctrl_fixed()
1486 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_add_rate_ctrl_fixed()
1493 addr = mt7915_mac_wtbl_lmac_addr(dev, msta->wcid.idx, 7); in mt7915_mcu_add_rate_ctrl_fixed()
1494 if (sta->deflink.he_cap.has_he) in mt7915_mcu_add_rate_ctrl_fixed()
1506 if (mask->control[band].he_ltf != GENMASK(7, 0)) { in mt7915_mcu_add_rate_ctrl_fixed()
1520 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_sta_rate_ctrl_tlv()
1521 struct mt76_phy *mphy = mvif->phy->mt76; in mt7915_mcu_sta_rate_ctrl_tlv()
1522 struct cfg80211_chan_def *chandef = &mphy->chandef; in mt7915_mcu_sta_rate_ctrl_tlv()
1523 struct cfg80211_bitrate_mask *mask = &mvif->bitrate_mask; in mt7915_mcu_sta_rate_ctrl_tlv()
1524 enum nl80211_band band = chandef->chan->band; in mt7915_mcu_sta_rate_ctrl_tlv()
1527 u32 supp_rate = sta->deflink.supp_rates[band]; in mt7915_mcu_sta_rate_ctrl_tlv()
1528 u32 cap = sta->wme ? STA_CAP_WMM : 0; in mt7915_mcu_sta_rate_ctrl_tlv()
1533 ra->valid = true; in mt7915_mcu_sta_rate_ctrl_tlv()
1534 ra->auto_rate = true; in mt7915_mcu_sta_rate_ctrl_tlv()
1535 ra->phy_mode = mt76_connac_get_phy_mode(mphy, vif, band, &sta->deflink); in mt7915_mcu_sta_rate_ctrl_tlv()
1536 ra->channel = chandef->chan->hw_value; in mt7915_mcu_sta_rate_ctrl_tlv()
1537 ra->bw = sta->deflink.bandwidth; in mt7915_mcu_sta_rate_ctrl_tlv()
1538 ra->phy.bw = sta->deflink.bandwidth; in mt7915_mcu_sta_rate_ctrl_tlv()
1539 ra->mmps_mode = mt7915_mcu_get_mmps_mode(sta->deflink.smps_mode); in mt7915_mcu_sta_rate_ctrl_tlv()
1542 supp_rate &= mask->control[band].legacy; in mt7915_mcu_sta_rate_ctrl_tlv()
1543 ra->rate_len = hweight32(supp_rate); in mt7915_mcu_sta_rate_ctrl_tlv()
1546 ra->supp_mode = MODE_CCK; in mt7915_mcu_sta_rate_ctrl_tlv()
1547 ra->supp_cck_rate = supp_rate & GENMASK(3, 0); in mt7915_mcu_sta_rate_ctrl_tlv()
1549 if (ra->rate_len > 4) { in mt7915_mcu_sta_rate_ctrl_tlv()
1550 ra->supp_mode |= MODE_OFDM; in mt7915_mcu_sta_rate_ctrl_tlv()
1551 ra->supp_ofdm_rate = supp_rate >> 4; in mt7915_mcu_sta_rate_ctrl_tlv()
1554 ra->supp_mode = MODE_OFDM; in mt7915_mcu_sta_rate_ctrl_tlv()
1555 ra->supp_ofdm_rate = supp_rate; in mt7915_mcu_sta_rate_ctrl_tlv()
1559 if (sta->deflink.ht_cap.ht_supported) { in mt7915_mcu_sta_rate_ctrl_tlv()
1560 ra->supp_mode |= MODE_HT; in mt7915_mcu_sta_rate_ctrl_tlv()
1561 ra->af = sta->deflink.ht_cap.ampdu_factor; in mt7915_mcu_sta_rate_ctrl_tlv()
1562 ra->ht_gf = !!(sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD); in mt7915_mcu_sta_rate_ctrl_tlv()
1565 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SGI_20) in mt7915_mcu_sta_rate_ctrl_tlv()
1567 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SGI_40) in mt7915_mcu_sta_rate_ctrl_tlv()
1569 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_TX_STBC) in mt7915_mcu_sta_rate_ctrl_tlv()
1571 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_RX_STBC) in mt7915_mcu_sta_rate_ctrl_tlv()
1573 if (mvif->cap.ht_ldpc && in mt7915_mcu_sta_rate_ctrl_tlv()
1574 (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING)) in mt7915_mcu_sta_rate_ctrl_tlv()
1577 mt7915_mcu_set_sta_ht_mcs(sta, ra->ht_mcs, in mt7915_mcu_sta_rate_ctrl_tlv()
1578 mask->control[band].ht_mcs); in mt7915_mcu_sta_rate_ctrl_tlv()
1579 ra->supp_ht_mcs = *(__le32 *)ra->ht_mcs; in mt7915_mcu_sta_rate_ctrl_tlv()
1582 if (sta->deflink.vht_cap.vht_supported) { in mt7915_mcu_sta_rate_ctrl_tlv()
1585 ra->supp_mode |= MODE_VHT; in mt7915_mcu_sta_rate_ctrl_tlv()
1587 sta->deflink.vht_cap.cap); in mt7915_mcu_sta_rate_ctrl_tlv()
1588 ra->af = max_t(u8, ra->af, af); in mt7915_mcu_sta_rate_ctrl_tlv()
1591 if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80) in mt7915_mcu_sta_rate_ctrl_tlv()
1593 if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_160) in mt7915_mcu_sta_rate_ctrl_tlv()
1595 if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_TXSTBC) in mt7915_mcu_sta_rate_ctrl_tlv()
1597 if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXSTBC_1) in mt7915_mcu_sta_rate_ctrl_tlv()
1599 if (mvif->cap.vht_ldpc && in mt7915_mcu_sta_rate_ctrl_tlv()
1600 (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC)) in mt7915_mcu_sta_rate_ctrl_tlv()
1603 mt7915_mcu_set_sta_vht_mcs(sta, ra->supp_vht_mcs, in mt7915_mcu_sta_rate_ctrl_tlv()
1604 mask->control[band].vht_mcs); in mt7915_mcu_sta_rate_ctrl_tlv()
1607 if (sta->deflink.he_cap.has_he) { in mt7915_mcu_sta_rate_ctrl_tlv()
1608 ra->supp_mode |= MODE_HE; in mt7915_mcu_sta_rate_ctrl_tlv()
1611 if (sta->deflink.he_6ghz_capa.capa) in mt7915_mcu_sta_rate_ctrl_tlv()
1612 ra->af = le16_get_bits(sta->deflink.he_6ghz_capa.capa, in mt7915_mcu_sta_rate_ctrl_tlv()
1616 ra->sta_cap = cpu_to_le32(cap); in mt7915_mcu_sta_rate_ctrl_tlv()
1622 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_rate_ctrl()
1623 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_add_rate_ctrl()
1627 skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, in mt7915_mcu_add_rate_ctrl()
1628 &msta->wcid); in mt7915_mcu_add_rate_ctrl()
1633 * once dev->rc_work changes the settings driver should also in mt7915_mcu_add_rate_ctrl()
1640 * i.e 0-{7,8,9} for VHT. in mt7915_mcu_add_rate_ctrl()
1644 ret = mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7915_mcu_add_rate_ctrl()
1661 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_group()
1668 u8 rsv0[5]; in mt7915_mcu_add_group()
1673 .val = cpu_to_le32(mvif->mt76.idx % 16), in mt7915_mcu_add_group()
1676 msta = sta ? (struct mt7915_sta *)sta->drv_priv : &mvif->sta; in mt7915_mcu_add_group()
1677 req.wlan_idx_lo = to_wcid_lo(msta->wcid.idx); in mt7915_mcu_add_group()
1678 req.wlan_idx_hi = to_wcid_hi(msta->wcid.idx); in mt7915_mcu_add_group()
1680 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_DRR_CTRL), &req, in mt7915_mcu_add_group()
1687 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_sta()
1693 msta = sta ? (struct mt7915_sta *)sta->drv_priv : &mvif->sta; in mt7915_mcu_add_sta()
1694 link_sta = sta ? &sta->deflink : NULL; in mt7915_mcu_add_sta()
1696 skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, in mt7915_mcu_add_sta()
1697 &msta->wcid); in mt7915_mcu_add_sta()
1702 mt76_connac_mcu_sta_basic_tlv(&dev->mt76, skb, &vif->bss_conf, link_sta, in mt7915_mcu_add_sta()
1744 ret = mt76_connac_mcu_sta_wed_update(&dev->mt76, skb); in mt7915_mcu_add_sta()
1748 return mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7915_mcu_add_sta()
1755 struct mtk_wed_device *wed = &dev->mt76.mmio.wed; in mt7915_mcu_wed_enable_rx_stats()
1773 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_add_dev_info()
1774 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_dev_info()
1792 .omac_idx = mvif->mt76.omac_idx, in mt7915_mcu_add_dev_info()
1793 .band_idx = mvif->mt76.band_idx, in mt7915_mcu_add_dev_info()
1801 .band_idx = mvif->mt76.band_idx, in mt7915_mcu_add_dev_info()
1805 if (mvif->mt76.omac_idx >= REPEATER_BSSID_START) in mt7915_mcu_add_dev_info()
1808 memcpy(data.tlv.omac_addr, vif->addr, ETH_ALEN); in mt7915_mcu_add_dev_info()
1809 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(DEV_INFO_UPDATE), in mt7915_mcu_add_dev_info()
1822 if (!offs->cntdwn_counter_offs[0]) in mt7915_mcu_beacon_cntdwn()
1825 sub_tag = vif->bss_conf.csa_active ? BSS_INFO_BCN_CSA : BSS_INFO_BCN_BCC; in mt7915_mcu_beacon_cntdwn()
1827 &bcn->sub_ntlv, &bcn->len); in mt7915_mcu_beacon_cntdwn()
1829 info->cnt = skb->data[offs->cntdwn_counter_offs[0]]; in mt7915_mcu_beacon_cntdwn()
1841 if (!vif->bss_conf.bssid_indicator) in mt7915_mcu_beacon_mbss()
1845 sizeof(*mbss), &bcn->sub_ntlv, in mt7915_mcu_beacon_mbss()
1846 &bcn->len); in mt7915_mcu_beacon_mbss()
1849 mbss->offset[0] = cpu_to_le16(offs->tim_offset); in mt7915_mcu_beacon_mbss()
1850 mbss->bitmap = cpu_to_le32(1); in mt7915_mcu_beacon_mbss()
1853 &skb->data[offs->mbssid_off], in mt7915_mcu_beacon_mbss()
1854 skb->len - offs->mbssid_off) { in mt7915_mcu_beacon_mbss()
1857 if (elem->datalen < 2) in mt7915_mcu_beacon_mbss()
1860 for_each_element(sub_elem, elem->data + 1, elem->datalen - 1) { in mt7915_mcu_beacon_mbss()
1864 if (sub_elem->id || sub_elem->datalen < 4) in mt7915_mcu_beacon_mbss()
1871 sub_elem->data, in mt7915_mcu_beacon_mbss()
1872 sub_elem->datalen); in mt7915_mcu_beacon_mbss()
1877 if (!idx->bssid_index || idx->bssid_index > 31) in mt7915_mcu_beacon_mbss()
1880 mbss->offset[idx->bssid_index] = in mt7915_mcu_beacon_mbss()
1881 cpu_to_le16(idx_ie - skb->data); in mt7915_mcu_beacon_mbss()
1882 mbss->bitmap |= cpu_to_le32(BIT(idx->bssid_index)); in mt7915_mcu_beacon_mbss()
1893 struct mt76_wcid *wcid = &dev->mt76.global_wcid; in mt7915_mcu_beacon_cont()
1897 int len = sizeof(*cont) + MT_TXD_SIZE + skb->len; in mt7915_mcu_beacon_cont()
1901 len, &bcn->sub_ntlv, &bcn->len); in mt7915_mcu_beacon_cont()
1904 cont->pkt_len = cpu_to_le16(MT_TXD_SIZE + skb->len); in mt7915_mcu_beacon_cont()
1905 cont->tim_ofs = cpu_to_le16(offs->tim_offset); in mt7915_mcu_beacon_cont()
1907 if (offs->cntdwn_counter_offs[0]) { in mt7915_mcu_beacon_cont()
1908 u16 offset = offs->cntdwn_counter_offs[0]; in mt7915_mcu_beacon_cont()
1910 if (vif->bss_conf.csa_active) in mt7915_mcu_beacon_cont()
1911 cont->csa_ofs = cpu_to_le16(offset - 4); in mt7915_mcu_beacon_cont()
1912 if (vif->bss_conf.color_change_active) in mt7915_mcu_beacon_cont()
1913 cont->bcc_ofs = cpu_to_le16(offset - 3); in mt7915_mcu_beacon_cont()
1917 mt7915_mac_write_txwi(&dev->mt76, (__le32 *)buf, skb, wcid, 0, NULL, in mt7915_mcu_beacon_cont()
1919 memcpy(buf + MT_TXD_SIZE, skb->data, skb->len); in mt7915_mcu_beacon_cont()
1930 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_inband_discov()
1931 struct cfg80211_chan_def *chandef = &mvif->phy->mt76->chandef; in mt7915_mcu_add_inband_discov()
1932 enum nl80211_band band = chandef->chan->band; in mt7915_mcu_add_inband_discov()
1933 struct mt76_wcid *wcid = &dev->mt76.global_wcid; in mt7915_mcu_add_inband_discov()
1939 bool ext_phy = phy != &dev->phy; in mt7915_mcu_add_inband_discov()
1943 if (vif->bss_conf.nontransmitted) in mt7915_mcu_add_inband_discov()
1946 rskb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, NULL, in mt7915_mcu_add_inband_discov()
1953 bcn->enable = true; in mt7915_mcu_add_inband_discov()
1956 interval = vif->bss_conf.fils_discovery.max_interval; in mt7915_mcu_add_inband_discov()
1959 vif->bss_conf.unsol_bcast_probe_resp_interval) { in mt7915_mcu_add_inband_discov()
1960 interval = vif->bss_conf.unsol_bcast_probe_resp_interval; in mt7915_mcu_add_inband_discov()
1966 return -EINVAL; in mt7915_mcu_add_inband_discov()
1970 info->control.vif = vif; in mt7915_mcu_add_inband_discov()
1971 info->band = band; in mt7915_mcu_add_inband_discov()
1972 info->hw_queue |= FIELD_PREP(MT_TX_HW_QUEUE_PHY, ext_phy); in mt7915_mcu_add_inband_discov()
1974 len = sizeof(*discov) + MT_TXD_SIZE + skb->len; in mt7915_mcu_add_inband_discov()
1977 if (skb->len > MT7915_MAX_BEACON_SIZE) { in mt7915_mcu_add_inband_discov()
1978 dev_err(dev->mt76.dev, "inband discovery size limit exceed\n"); in mt7915_mcu_add_inband_discov()
1981 return -EINVAL; in mt7915_mcu_add_inband_discov()
1985 len, &bcn->sub_ntlv, &bcn->len); in mt7915_mcu_add_inband_discov()
1987 discov->tx_mode = OFFLOAD_TX_MODE_SU; in mt7915_mcu_add_inband_discov()
1989 discov->tx_type = !!(changed & BSS_CHANGED_FILS_DISCOVERY); in mt7915_mcu_add_inband_discov()
1990 discov->tx_interval = interval; in mt7915_mcu_add_inband_discov()
1991 discov->prob_rsp_len = cpu_to_le16(MT_TXD_SIZE + skb->len); in mt7915_mcu_add_inband_discov()
1992 discov->enable = !!interval; in mt7915_mcu_add_inband_discov()
1996 mt7915_mac_write_txwi(&dev->mt76, (__le32 *)buf, skb, wcid, 0, NULL, in mt7915_mcu_add_inband_discov()
1998 memcpy(buf + MT_TXD_SIZE, skb->data, skb->len); in mt7915_mcu_add_inband_discov()
2002 return mt76_mcu_skb_send_msg(&phy->dev->mt76, rskb, in mt7915_mcu_add_inband_discov()
2011 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_beacon()
2018 bool ext_phy = phy != &dev->phy; in mt7915_mcu_add_beacon()
2020 if (vif->bss_conf.nontransmitted) in mt7915_mcu_add_beacon()
2023 rskb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, in mt7915_mcu_add_beacon()
2030 bcn->enable = en; in mt7915_mcu_add_beacon()
2038 return -EINVAL; in mt7915_mcu_add_beacon()
2041 if (skb->len > MT7915_MAX_BEACON_SIZE) { in mt7915_mcu_add_beacon()
2042 dev_err(dev->mt76.dev, "Bcn size limit exceed\n"); in mt7915_mcu_add_beacon()
2045 return -EINVAL; in mt7915_mcu_add_beacon()
2049 info->hw_queue = FIELD_PREP(MT_TX_HW_QUEUE_PHY, ext_phy); in mt7915_mcu_add_beacon()
2057 return mt76_mcu_skb_send_msg(&phy->dev->mt76, rskb, in mt7915_mcu_add_beacon()
2066 dev_err(dev->mt76.dev, "Timeout for driver own\n"); in mt7915_driver_own()
2067 return -EIO; in mt7915_driver_own()
2085 dev_err(dev->mt76.dev, "Timeout for initializing firmware\n"); in mt7915_firmware_state()
2086 return -EIO; in mt7915_firmware_state()
2098 mt76_connac_mcu_restart(&dev->mt76); in mt7915_load_firmware()
2101 dev_err(dev->mt76.dev, in mt7915_load_firmware()
2107 ret = mt76_connac2_load_patch(&dev->mt76, fw_name_var(dev, ROM_PATCH)); in mt7915_load_firmware()
2111 ret = mt76_connac2_load_ram(&dev->mt76, fw_name_var(dev, FIRMWARE_WM), in mt7915_load_firmware()
2120 mt76_queue_tx_cleanup(dev, dev->mt76.q_mcu[MT_MCUQ_FWDL], false); in mt7915_load_firmware()
2122 dev_dbg(dev->mt76.dev, "Firmware init done\n"); in mt7915_load_firmware()
2137 return mt76_mcu_send_msg(&dev->mt76, MCU_WA_EXT_CMD(FW_LOG_2_HOST), in mt7915_mcu_fw_log_2_host()
2140 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(FW_LOG_2_HOST), &data, in mt7915_mcu_fw_log_2_host()
2158 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(FW_DBG_CTRL), &data, in mt7915_mcu_fw_dbg_ctrl()
2172 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(MURU_CTRL), &data, in mt7915_mcu_muru_debug_set()
2178 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_muru_debug_get()
2188 .band_idx = phy->mt76->band_idx, in mt7915_mcu_muru_debug_get()
2191 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(MURU_CTRL), in mt7915_mcu_muru_debug_get()
2196 mu_stats = (struct mt7915_mcu_muru_stats *)(skb->data); in mt7915_mcu_muru_debug_get()
2198 /* accumulate stats, these are clear-on-read */ in mt7915_mcu_muru_debug_get()
2199 #define __dl_u32(s) phy->mib.dl_##s += le32_to_cpu(mu_stats->dl.s) in mt7915_mcu_muru_debug_get()
2200 #define __ul_u32(s) phy->mib.ul_##s += le32_to_cpu(mu_stats->ul.s) in mt7915_mcu_muru_debug_get()
2247 return mt76_mcu_send_msg(&dev->mt76, MCU_WA_EXT_CMD(MWDS_SUPPORT), &req, in mt7915_mcu_set_mwds()
2262 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(MURU_CTRL), &req, in mt7915_mcu_set_muru_ctrl()
2294 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RX_AIRTIME_CTRL), &req, in mt7915_mcu_init_rx_airtime()
2303 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RX_AIRTIME_CTRL), &req, in mt7915_mcu_init_rx_airtime()
2322 .len = cpu_to_le16(sizeof(req) - sizeof(req.args)), in mt7915_red_set_watermark()
2323 .high_mark = cpu_to_le16(MT7915_HW_TOKEN_SIZE - 256), in mt7915_red_set_watermark()
2324 .low_mark = cpu_to_le16(MT7915_HW_TOKEN_SIZE - 256 - 1536), in mt7915_red_set_watermark()
2327 return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req, in mt7915_red_set_watermark()
2345 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req, in mt7915_mcu_set_red()
2367 if (dev->hif2) { in mt7915_mcu_init_firmware()
2377 set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); in mt7915_mcu_init_firmware()
2386 mt76_connac_mcu_del_wtbl_all(&dev->mt76); in mt7915_mcu_init_firmware()
2388 if ((mtk_wed_device_active(&dev->mt76.mmio.wed) && in mt7915_mcu_init_firmware()
2389 is_mt7915(&dev->mt76)) || in mt7915_mcu_init_firmware()
2390 !mtk_wed_get_rx_capa(&dev->mt76.mmio.wed)) in mt7915_mcu_init_firmware()
2406 return mt7915_mcu_set_red(dev, mtk_wed_device_active(&dev->mt76.mmio.wed)); in mt7915_mcu_init_firmware()
2419 dev->mt76.mcu_ops = &mt7915_mcu_ops; in mt7915_mcu_init()
2426 mt76_connac_mcu_restart(&dev->mt76); in mt7915_mcu_exit()
2428 dev_err(dev->mt76.dev, "Failed to exit mcu\n"); in mt7915_mcu_exit()
2433 if (dev->hif2) in mt7915_mcu_exit()
2437 skb_queue_purge(&dev->mt76.mcu.res_q); in mt7915_mcu_exit()
2457 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RX_HDR_TRANS), in mt7915_mcu_set_rx_hdr_trans_blacklist()
2486 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RX_HDR_TRANS), in mt7915_mcu_set_mac()
2494 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(MAC_INIT_CTRL), in mt7915_mcu_set_mac()
2501 u8 num = req->total; in mt7915_mcu_update_edca()
2502 size_t len = sizeof(*req) - in mt7915_mcu_update_edca()
2503 (IEEE80211_NUM_ACS - num) * sizeof(struct edca); in mt7915_mcu_update_edca()
2505 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(EDCA_UPDATE), req, in mt7915_mcu_update_edca()
2517 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_set_tx()
2521 struct ieee80211_tx_queue_params *q = &mvif->queue_params[ac]; in mt7915_mcu_set_tx()
2524 e->set = WMM_PARAM_SET; in mt7915_mcu_set_tx()
2525 e->queue = ac + mvif->mt76.wmm_idx * MT76_CONNAC_MAX_WMM_SETS; in mt7915_mcu_set_tx()
2526 e->aifs = q->aifs; in mt7915_mcu_set_tx()
2527 e->txop = cpu_to_le16(q->txop); in mt7915_mcu_set_tx()
2529 if (q->cw_min) in mt7915_mcu_set_tx()
2530 e->cw_min = fls(q->cw_min); in mt7915_mcu_set_tx()
2532 e->cw_min = 5; in mt7915_mcu_set_tx()
2534 if (q->cw_max) in mt7915_mcu_set_tx()
2535 e->cw_max = cpu_to_le16(fls(q->cw_max)); in mt7915_mcu_set_tx()
2537 e->cw_max = cpu_to_le16(10); in mt7915_mcu_set_tx()
2554 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_RDD_TH), &req, in mt7915_mcu_set_fcc5_lpn()
2574 #define __req_field(field) .field = cpu_to_le32(pulse->field) in mt7915_mcu_set_pulse_th()
2585 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_RDD_TH), &req, in mt7915_mcu_set_pulse_th()
2616 #define __req_field_u8(field) .field = pattern->field in mt7915_mcu_set_radar_th()
2617 #define __req_field_u32(field) .field = cpu_to_le32(pattern->field) in mt7915_mcu_set_radar_th()
2637 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_RDD_TH), &req, in mt7915_mcu_set_radar_th()
2646 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_background_chain_ctrl()
2647 struct mt76_phy *mphy = phy->mt76; in mt7915_mcu_background_chain_ctrl()
2648 struct ieee80211_channel *chan = mphy->chandef.chan; in mt7915_mcu_background_chain_ctrl()
2649 int freq = mphy->chandef.center_freq1; in mt7915_mcu_background_chain_ctrl()
2655 return -EINVAL; in mt7915_mcu_background_chain_ctrl()
2657 if (!cfg80211_chandef_valid(&mphy->chandef)) in mt7915_mcu_background_chain_ctrl()
2658 return -EINVAL; in mt7915_mcu_background_chain_ctrl()
2662 req.chan = chan->hw_value; in mt7915_mcu_background_chain_ctrl()
2664 req.bw = mt76_connac_chan_bw(&mphy->chandef); in mt7915_mcu_background_chain_ctrl()
2665 req.monitor_chan = chandef->chan->hw_value; in mt7915_mcu_background_chain_ctrl()
2667 ieee80211_frequency_to_channel(chandef->center_freq1); in mt7915_mcu_background_chain_ctrl()
2669 req.band_idx = phy->mt76->band_idx; in mt7915_mcu_background_chain_ctrl()
2674 req.monitor_chan = chandef->chan->hw_value; in mt7915_mcu_background_chain_ctrl()
2676 ieee80211_frequency_to_channel(chandef->center_freq1); in mt7915_mcu_background_chain_ctrl()
2677 req.band_idx = phy->mt76->band_idx; in mt7915_mcu_background_chain_ctrl()
2681 req.chan = chan->hw_value; in mt7915_mcu_background_chain_ctrl()
2683 req.bw = mt76_connac_chan_bw(&mphy->chandef); in mt7915_mcu_background_chain_ctrl()
2684 req.tx_stream = hweight8(mphy->antenna_mask); in mt7915_mcu_background_chain_ctrl()
2685 req.rx_stream = mphy->antenna_mask; in mt7915_mcu_background_chain_ctrl()
2688 return -EINVAL; in mt7915_mcu_background_chain_ctrl()
2690 req.band = chandef ? chandef->chan->band == NL80211_BAND_5GHZ : 1; in mt7915_mcu_background_chain_ctrl()
2692 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(OFFCH_SCAN_CTRL), in mt7915_mcu_background_chain_ctrl()
2699 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_rdd_background_enable()
2703 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_STOP, MT_RX_SEL2, in mt7915_mcu_rdd_background_enable()
2717 switch (dev->mt76.region) { in mt7915_mcu_rdd_background_enable()
2730 return mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_START, MT_RX_SEL2, in mt7915_mcu_rdd_background_enable()
2741 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_chan_info()
2742 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7915_mcu_set_chan_info()
2743 int freq1 = chandef->center_freq1; in mt7915_mcu_set_chan_info()
2744 u8 band = phy->mt76->band_idx; in mt7915_mcu_set_chan_info()
2763 .control_ch = chandef->chan->hw_value, in mt7915_mcu_set_chan_info()
2766 .tx_path_num = hweight16(phy->mt76->chainmask), in mt7915_mcu_set_chan_info()
2767 .rx_path = phy->mt76->chainmask >> (dev->chainshift * band), in mt7915_mcu_set_chan_info()
2769 .channel_band = ch_band[chandef->chan->band], in mt7915_mcu_set_chan_info()
2773 if (phy->mt76->test.tx_antenna_mask && in mt7915_mcu_set_chan_info()
2774 mt76_testmode_enabled(phy->mt76)) { in mt7915_mcu_set_chan_info()
2775 req.tx_path_num = fls(phy->mt76->test.tx_antenna_mask); in mt7915_mcu_set_chan_info()
2776 req.rx_path = phy->mt76->test.tx_antenna_mask; in mt7915_mcu_set_chan_info()
2780 if (mt76_connac_spe_idx(phy->mt76->antenna_mask)) in mt7915_mcu_set_chan_info()
2781 req.tx_path_num = fls(phy->mt76->antenna_mask); in mt7915_mcu_set_chan_info()
2783 if (phy->mt76->hw->conf.flags & IEEE80211_CONF_MONITOR) in mt7915_mcu_set_chan_info()
2785 else if (phy->mt76->offchannel || in mt7915_mcu_set_chan_info()
2786 phy->mt76->hw->conf.flags & IEEE80211_CONF_IDLE) in mt7915_mcu_set_chan_info()
2788 else if (!cfg80211_reg_can_beacon(phy->mt76->hw->wiphy, chandef, in mt7915_mcu_set_chan_info()
2797 if (chandef->width == NL80211_CHAN_WIDTH_80P80) { in mt7915_mcu_set_chan_info()
2798 int freq2 = chandef->center_freq2; in mt7915_mcu_set_chan_info()
2803 return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), true); in mt7915_mcu_set_chan_info()
2808 #define MAX_PAGE_IDX_MASK GENMASK(7, 5) in mt7915_mcu_set_eeprom_flash()
2814 u8 *eep = (u8 *)dev->mt76.eeprom.data; in mt7915_mcu_set_eeprom_flash()
2822 if (i == total - 1 && !!(eeprom_size % PER_PAGE_SIZE)) in mt7915_mcu_set_eeprom_flash()
2827 skb = mt76_mcu_msg_alloc(&dev->mt76, NULL, in mt7915_mcu_set_eeprom_flash()
2830 return -ENOMEM; in mt7915_mcu_set_eeprom_flash()
2832 req.format = FIELD_PREP(MAX_PAGE_IDX_MASK, total - 1) | in mt7915_mcu_set_eeprom_flash()
2839 ret = mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7915_mcu_set_eeprom_flash()
2855 if (dev->flash_mode) in mt7915_mcu_set_eeprom()
2858 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(EFUSE_BUFFER_MODE), in mt7915_mcu_set_eeprom()
2873 ret = mt76_mcu_send_and_get_msg(&dev->mt76, in mt7915_mcu_get_eeprom()
2879 res = (struct mt7915_mcu_eeprom_info *)skb->data; in mt7915_mcu_get_eeprom()
2880 buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr); in mt7915_mcu_get_eeprom()
2881 memcpy(buf, res->data, MT7915_EEPROM_BLOCK_SIZE); in mt7915_mcu_get_eeprom()
2900 ret = mt76_mcu_send_and_get_msg(&dev->mt76, in mt7915_mcu_get_eeprom_free_block()
2906 *block_num = *(u8 *)skb->data; in mt7915_mcu_get_eeprom_free_block()
2928 skb = mt76_mcu_msg_alloc(&dev->mt76, NULL, sizeof(req) + len); in mt7915_mcu_set_pre_cal()
2930 return -ENOMEM; in mt7915_mcu_set_pre_cal()
2937 return mt76_mcu_skb_send_msg(&dev->mt76, skb, cmd, false); in mt7915_mcu_set_pre_cal()
2942 u8 idx = 0, *cal = dev->cal, *eep = dev->mt76.eeprom.data; in mt7915_mcu_apply_group_cal()
2944 u32 offs = is_mt7915(&dev->mt76) ? MT_EE_DO_PRE_CAL : MT_EE_DO_PRE_CAL_V2; in mt7915_mcu_apply_group_cal()
2963 total -= len; in mt7915_mcu_apply_group_cal()
2979 return -1; in mt7915_find_freq_idx()
2993 /* 6G BW20*/ in mt7915_dpd_freq_idx()
3009 /* 6G BW160 */ in mt7915_dpd_freq_idx()
3012 /* 5G BW20 */ in mt7915_dpd_freq_idx()
3020 /* 5G BW160 */ in mt7915_dpd_freq_idx()
3024 /* 5G BW20 */ in mt7915_dpd_freq_idx()
3032 /* 5G BW160 */ in mt7915_dpd_freq_idx()
3039 if (!is_mt7915(&dev->mt76)) { in mt7915_dpd_freq_idx()
3040 if (is_mt7981(&dev->mt76)) { in mt7915_dpd_freq_idx()
3059 return -1; in mt7915_dpd_freq_idx()
3066 idx = mt7915_find_freq_idx(freq_list, n_freqs, freq - 10); in mt7915_dpd_freq_idx()
3076 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_apply_tx_dpd()
3077 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7915_mcu_apply_tx_dpd()
3078 enum nl80211_band band = chandef->chan->band; in mt7915_mcu_apply_tx_dpd()
3079 u32 offs = is_mt7915(&dev->mt76) ? MT_EE_DO_PRE_CAL : MT_EE_DO_PRE_CAL_V2; in mt7915_mcu_apply_tx_dpd()
3080 u16 center_freq = chandef->center_freq1; in mt7915_mcu_apply_tx_dpd()
3081 u8 *cal = dev->cal, *eep = dev->mt76.eeprom.data; in mt7915_mcu_apply_tx_dpd()
3082 u8 dpd_mask, cal_num = is_mt7915(&dev->mt76) ? 2 : 3; in mt7915_mcu_apply_tx_dpd()
3103 idx = mt7915_dpd_freq_idx(dev, center_freq, chandef->width); in mt7915_mcu_apply_tx_dpd()
3105 return -EINVAL; in mt7915_mcu_apply_tx_dpd()
3111 while (cal_num--) { in mt7915_mcu_apply_tx_dpd()
3128 struct mt76_channel_state *state = phy->mt76->chan_state; in mt7915_mcu_get_chan_mib_info()
3129 struct mt76_channel_state *state_ts = &phy->state_ts; in mt7915_mcu_get_chan_mib_info()
3130 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_get_chan_mib_info()
3131 struct mt7915_mcu_mib *res, req[5]; in mt7915_mcu_get_chan_mib_info()
3138 if (is_mt7915(&dev->mt76)) { in mt7915_mcu_get_chan_mib_info()
3162 req[i].band = cpu_to_le32(phy->mt76->band_idx); in mt7915_mcu_get_chan_mib_info()
3166 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(GET_MIB_INFO), in mt7915_mcu_get_chan_mib_info()
3171 res = (struct mt7915_mcu_mib *)(skb->data + offs_cc); in mt7915_mcu_get_chan_mib_info()
3175 if (is_mt7915(&dev->mt76)) { in mt7915_mcu_get_chan_mib_info()
3177 cc_tx = __res_u64(1) - backoff; in mt7915_mcu_get_chan_mib_info()
3185 state->cc_tx += cc_tx - state_ts->cc_tx; in mt7915_mcu_get_chan_mib_info()
3186 state->cc_bss_rx += __res_u64(2) - state_ts->cc_bss_rx; in mt7915_mcu_get_chan_mib_info()
3187 state->cc_rx += __res_u64(2) + __res_u64(3) - state_ts->cc_rx; in mt7915_mcu_get_chan_mib_info()
3188 state->cc_busy += __res_u64(0) + cc_tx + __res_u64(2) + __res_u64(3) - in mt7915_mcu_get_chan_mib_info()
3189 state_ts->cc_busy; in mt7915_mcu_get_chan_mib_info()
3192 state_ts->cc_tx = cc_tx; in mt7915_mcu_get_chan_mib_info()
3193 state_ts->cc_bss_rx = __res_u64(2); in mt7915_mcu_get_chan_mib_info()
3194 state_ts->cc_rx = __res_u64(2) + __res_u64(3); in mt7915_mcu_get_chan_mib_info()
3195 state_ts->cc_busy = __res_u64(0) + cc_tx + __res_u64(2) + __res_u64(3); in mt7915_mcu_get_chan_mib_info()
3205 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_get_temperature()
3210 u8 rsv[5]; in mt7915_mcu_get_temperature()
3213 .band_idx = phy->mt76->band_idx, in mt7915_mcu_get_temperature()
3216 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_CTRL), &req, in mt7915_mcu_get_temperature()
3222 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_thermal_throttling()
3224 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_thermal_throttling()
3235 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_PROT), in mt7915_mcu_set_thermal_throttling()
3245 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_thermal_protect()
3255 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_thermal_protect()
3263 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_PROT), in mt7915_mcu_set_thermal_protect()
3269 /* set high-temperature trigger threshold */ in mt7915_mcu_set_thermal_protect()
3272 req.restore_temp = cpu_to_le32(phy->throttle_temp[0] - 10); in mt7915_mcu_set_thermal_protect()
3273 req.trigger_temp = cpu_to_le32(phy->throttle_temp[1]); in mt7915_mcu_set_thermal_protect()
3276 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_PROT), in mt7915_mcu_set_thermal_protect()
3280 int mt7915_mcu_set_txpower_frame_min(struct mt7915_phy *phy, s8 txpower) in mt7915_mcu_set_txpower_frame_min() argument
3282 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_txpower_frame_min()
3290 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_txpower_frame_min()
3291 .txpower_min = txpower * 2, /* 0.5db */ in mt7915_mcu_set_txpower_frame_min()
3294 return mt76_mcu_send_msg(&dev->mt76, in mt7915_mcu_set_txpower_frame_min()
3301 struct ieee80211_sta *sta, s8 txpower) in mt7915_mcu_set_txpower_frame() argument
3303 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_set_txpower_frame()
3304 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_txpower_frame()
3305 struct mt76_phy *mphy = phy->mt76; in mt7915_mcu_set_txpower_frame()
3315 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_txpower_frame()
3316 .txpower_max = DIV_ROUND_UP(mphy->txpower_cur, 2), in mt7915_mcu_set_txpower_frame()
3317 .wcid = cpu_to_le16(msta->wcid.idx), in mt7915_mcu_set_txpower_frame()
3326 txpower = mt7915_get_power_bound(phy, txpower); in mt7915_mcu_set_txpower_frame()
3327 if (txpower > mphy->txpower_cur || txpower < 0) in mt7915_mcu_set_txpower_frame()
3328 return -EINVAL; in mt7915_mcu_set_txpower_frame()
3330 if (txpower) { in mt7915_mcu_set_txpower_frame()
3333 if (sta->deflink.ht_cap.ht_supported) { in mt7915_mcu_set_txpower_frame()
3339 if (sta->deflink.vht_cap.vht_supported) { in mt7915_mcu_set_txpower_frame()
3343 if (sta->deflink.he_cap.has_he) { in mt7915_mcu_set_txpower_frame()
3349 return -EINVAL; in mt7915_mcu_set_txpower_frame()
3354 DIV_ROUND_UP(txpower - txpower_sku[offs], 2); in mt7915_mcu_set_txpower_frame()
3357 return mt76_mcu_send_msg(&dev->mt76, in mt7915_mcu_set_txpower_frame()
3364 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_txpower_sku()
3365 struct mt76_phy *mphy = phy->mt76; in mt7915_mcu_set_txpower_sku()
3366 struct ieee80211_hw *hw = mphy->hw; in mt7915_mcu_set_txpower_sku()
3369 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_txpower_sku()
3376 tx_power = mt7915_get_power_bound(phy, hw->conf.power_level); in mt7915_mcu_set_txpower_sku()
3377 tx_power = mt76_get_rate_power_limits(mphy, mphy->chandef.chan, in mt7915_mcu_set_txpower_sku()
3379 mphy->txpower_cur = tx_power; in mt7915_mcu_set_txpower_sku()
3401 return mt76_mcu_send_msg(&dev->mt76, in mt7915_mcu_set_txpower_sku()
3406 int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len) in mt7915_mcu_get_txpower_sku() argument
3409 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_get_txpower_sku()
3418 .band_idx = phy->mt76->band_idx, in mt7915_mcu_get_txpower_sku()
3424 ret = mt76_mcu_send_and_get_msg(&dev->mt76, in mt7915_mcu_get_txpower_sku()
3430 memcpy(txpower_sku, skb->data + 4, sizeof(txpower_sku)); in mt7915_mcu_get_txpower_sku()
3432 txpower[i] = txpower_sku[i][req.band_idx]; in mt7915_mcu_get_txpower_sku()
3457 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req, in mt7915_mcu_set_test_param()
3463 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_sku_en()
3471 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_sku_en()
3475 return mt76_mcu_send_msg(&dev->mt76, in mt7915_mcu_set_sku_en()
3493 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_SER_TRIGGER), in mt7915_mcu_set_ser()
3518 u8 rsv[5]; in mt7915_mcu_set_txbf()
3532 req.type.ibf = dev->ibf; in mt7915_mcu_set_txbf()
3539 return -EINVAL; in mt7915_mcu_set_txbf()
3542 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TXBF_ACTION), &req, in mt7915_mcu_set_txbf()
3549 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_enable_obss_spr()
3553 .band_idx = phy->mt76->band_idx, in mt7915_mcu_enable_obss_spr()
3557 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_SPR), &req, in mt7915_mcu_enable_obss_spr()
3565 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_obss_spr_pd()
3584 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_obss_spr_pd()
3595 if (he_obss_pd->sr_ctrl & in mt7915_mcu_set_obss_spr_pd()
3598 else if (he_obss_pd->sr_ctrl & IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT) in mt7915_mcu_set_obss_spr_pd()
3599 req.param.pd_th_non_srg = max_th - he_obss_pd->non_srg_max_offset; in mt7915_mcu_set_obss_spr_pd()
3603 if (he_obss_pd->sr_ctrl & IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT) in mt7915_mcu_set_obss_spr_pd()
3604 req.param.pd_th_srg = max_th - he_obss_pd->max_offset; in mt7915_mcu_set_obss_spr_pd()
3611 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_SPR), &req, in mt7915_mcu_set_obss_spr_pd()
3619 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_set_obss_spr_siga()
3620 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_obss_spr_siga()
3621 u8 omac = mvif->mt76.omac_idx; in mt7915_mcu_set_obss_spr_siga()
3633 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_obss_spr_siga()
3636 .omac = omac > HW_BSSID_MAX ? omac - 12 : omac, in mt7915_mcu_set_obss_spr_siga()
3641 if (he_obss_pd->sr_ctrl & IEEE80211_HE_SPR_HESIGA_SR_VAL15_ALLOWED) in mt7915_mcu_set_obss_spr_siga()
3651 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_SPR), &req, in mt7915_mcu_set_obss_spr_siga()
3659 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_obss_spr_bitmap()
3672 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_obss_spr_bitmap()
3677 memcpy(&bitmap, he_obss_pd->bss_color_bitmap, sizeof(bitmap)); in mt7915_mcu_set_obss_spr_bitmap()
3680 memcpy(&bitmap, he_obss_pd->bss_color_bitmap + 4, sizeof(bitmap)); in mt7915_mcu_set_obss_spr_bitmap()
3683 memcpy(&bitmap, he_obss_pd->partial_bssid_bitmap, sizeof(bitmap)); in mt7915_mcu_set_obss_spr_bitmap()
3686 memcpy(&bitmap, he_obss_pd->partial_bssid_bitmap + 4, sizeof(bitmap)); in mt7915_mcu_set_obss_spr_bitmap()
3689 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_SPR), &req, in mt7915_mcu_set_obss_spr_bitmap()
3704 if (sr_scene_detect && !he_obss_pd->enable) in mt7915_mcu_add_obss_spr()
3708 ret = mt7915_mcu_enable_obss_spr(phy, SPR_ENABLE, he_obss_pd->enable); in mt7915_mcu_add_obss_spr()
3712 if (sr_scene_detect || !he_obss_pd->enable) in mt7915_mcu_add_obss_spr()
3719 /* set SRG/non-SRG OBSS PD threshold */ in mt7915_mcu_add_obss_spr()
3736 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_get_rx_rate()
3737 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_get_rx_rate()
3738 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_get_rx_rate()
3739 struct mt76_phy *mphy = phy->mt76; in mt7915_mcu_get_rx_rate()
3746 .band = mvif->mt76.band_idx, in mt7915_mcu_get_rx_rate()
3747 .wcid = cpu_to_le16(msta->wcid.idx), in mt7915_mcu_get_rx_rate()
3755 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(PHY_STAT_INFO), in mt7915_mcu_get_rx_rate()
3760 res = (struct mt7915_mcu_phy_rx_info *)skb->data; in mt7915_mcu_get_rx_rate()
3762 rate->mcs = res->rate; in mt7915_mcu_get_rx_rate()
3763 rate->nss = res->nsts + 1; in mt7915_mcu_get_rx_rate()
3765 switch (res->mode) { in mt7915_mcu_get_rx_rate()
3770 if (mphy->chandef.chan->band == NL80211_BAND_5GHZ) in mt7915_mcu_get_rx_rate()
3771 sband = &mphy->sband_5g.sband; in mt7915_mcu_get_rx_rate()
3772 else if (mphy->chandef.chan->band == NL80211_BAND_6GHZ) in mt7915_mcu_get_rx_rate()
3773 sband = &mphy->sband_6g.sband; in mt7915_mcu_get_rx_rate()
3775 sband = &mphy->sband_2g.sband; in mt7915_mcu_get_rx_rate()
3777 rate->mcs = mt76_get_rate(&dev->mt76, sband, rate->mcs, cck); in mt7915_mcu_get_rx_rate()
3778 rate->legacy = sband->bitrates[rate->mcs].bitrate; in mt7915_mcu_get_rx_rate()
3782 if (rate->mcs > 31) { in mt7915_mcu_get_rx_rate()
3783 ret = -EINVAL; in mt7915_mcu_get_rx_rate()
3787 rate->flags = RATE_INFO_FLAGS_MCS; in mt7915_mcu_get_rx_rate()
3788 if (res->gi) in mt7915_mcu_get_rx_rate()
3789 rate->flags |= RATE_INFO_FLAGS_SHORT_GI; in mt7915_mcu_get_rx_rate()
3792 if (rate->mcs > 9) { in mt7915_mcu_get_rx_rate()
3793 ret = -EINVAL; in mt7915_mcu_get_rx_rate()
3797 rate->flags = RATE_INFO_FLAGS_VHT_MCS; in mt7915_mcu_get_rx_rate()
3798 if (res->gi) in mt7915_mcu_get_rx_rate()
3799 rate->flags |= RATE_INFO_FLAGS_SHORT_GI; in mt7915_mcu_get_rx_rate()
3805 if (res->gi > NL80211_RATE_INFO_HE_GI_3_2 || rate->mcs > 11) { in mt7915_mcu_get_rx_rate()
3806 ret = -EINVAL; in mt7915_mcu_get_rx_rate()
3809 rate->he_gi = res->gi; in mt7915_mcu_get_rx_rate()
3810 rate->flags = RATE_INFO_FLAGS_HE_MCS; in mt7915_mcu_get_rx_rate()
3813 ret = -EINVAL; in mt7915_mcu_get_rx_rate()
3817 switch (res->bw) { in mt7915_mcu_get_rx_rate()
3819 rate->bw = RATE_INFO_BW_160; in mt7915_mcu_get_rx_rate()
3822 rate->bw = RATE_INFO_BW_80; in mt7915_mcu_get_rx_rate()
3825 rate->bw = RATE_INFO_BW_40; in mt7915_mcu_get_rx_rate()
3828 rate->bw = RATE_INFO_BW_20; in mt7915_mcu_get_rx_rate()
3842 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_update_bss_color()
3847 skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, in mt7915_mcu_update_bss_color()
3855 bss_color->disable = !he_bss_color->enabled; in mt7915_mcu_update_bss_color()
3856 bss_color->color = he_bss_color->color; in mt7915_mcu_update_bss_color()
3858 return mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7915_mcu_update_bss_color()
3888 .tbl_idx = flow->table_id, in mt7915_mcu_twt_agrt_update()
3890 .own_mac_idx = mvif->mt76.omac_idx, in mt7915_mcu_twt_agrt_update()
3891 .flowid = flow->id, in mt7915_mcu_twt_agrt_update()
3892 .peer_id = cpu_to_le16(flow->wcid), in mt7915_mcu_twt_agrt_update()
3893 .duration = flow->duration, in mt7915_mcu_twt_agrt_update()
3894 .bss_idx = mvif->mt76.idx, in mt7915_mcu_twt_agrt_update()
3895 .start_tsf = cpu_to_le64(flow->tsf), in mt7915_mcu_twt_agrt_update()
3896 .mantissa = flow->mantissa, in mt7915_mcu_twt_agrt_update()
3897 .exponent = flow->exp, in mt7915_mcu_twt_agrt_update()
3901 if (flow->protection) in mt7915_mcu_twt_agrt_update()
3903 if (!flow->flowtype) in mt7915_mcu_twt_agrt_update()
3905 if (flow->trigger) in mt7915_mcu_twt_agrt_update()
3908 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TWT_AGRT_UPDATE), in mt7915_mcu_twt_agrt_update()
3937 if (is_mt7915(&dev->mt76)) { in mt7915_mcu_wed_wa_tx_stats()
3939 len = sizeof(req) - sizeof(req.arg2); in mt7915_mcu_wed_wa_tx_stats()
3946 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_WA_PARAM_CMD(QUERY), in mt7915_mcu_wed_wa_tx_stats()
3951 if (!is_mt7915(&dev->mt76)) in mt7915_mcu_wed_wa_tx_stats()
3954 res = (struct mt7915_mcu_wa_tx_stat *)skb->data; in mt7915_mcu_wed_wa_tx_stats()
3956 ret_wcid = le16_to_cpu(res->wcid); in mt7915_mcu_wed_wa_tx_stats()
3957 if (is_mt7915(&dev->mt76)) in mt7915_mcu_wed_wa_tx_stats()
3961 ret = -EINVAL; in mt7915_mcu_wed_wa_tx_stats()
3967 wcid = rcu_dereference(dev->mt76.wcid[wlan_idx]); in mt7915_mcu_wed_wa_tx_stats()
3969 wcid->stats.tx_packets += le32_to_cpu(res->tx_packets); in mt7915_mcu_wed_wa_tx_stats()
3971 ret = -EINVAL; in mt7915_mcu_wed_wa_tx_stats()
3995 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RF_REG_ACCESS), in mt7915_mcu_rf_regval()
3998 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_QUERY(RF_REG_ACCESS), in mt7915_mcu_rf_regval()
4003 *val = le32_to_cpu(*(__le32 *)(skb->data + 8)); in mt7915_mcu_rf_regval()