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()
200 mdev->mcu.timeout = 5 * HZ; in mt7915_mcu_set_timeout()
211 mdev->mcu.timeout = 2 * HZ; in mt7915_mcu_set_timeout()
214 mdev->mcu.timeout = 10 * HZ; in mt7915_mcu_set_timeout()
230 else if (test_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state)) in mt7915_mcu_send_message()
237 return mt76_tx_queue_skb_raw(dev, mdev->q_mcu[qid], skb, 0); in mt7915_mcu_send_message()
252 return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), false); in mt7915_mcu_wa_cmd()
258 if (!vif->bss_conf.csa_active || vif->type == NL80211_IFTYPE_STATION) in mt7915_mcu_csa_finish()
267 struct mt76_phy *mphy = &dev->mt76.phy; in mt7915_mcu_rx_csa_notify()
270 c = (struct mt7915_mcu_csa_notify *)skb->data; in mt7915_mcu_rx_csa_notify()
272 if (c->band_idx > MT_BAND1) in mt7915_mcu_rx_csa_notify()
275 if ((c->band_idx && !dev->phy.mt76->band_idx) && in mt7915_mcu_rx_csa_notify()
276 dev->mt76.phys[MT_BAND1]) in mt7915_mcu_rx_csa_notify()
277 mphy = dev->mt76.phys[MT_BAND1]; in mt7915_mcu_rx_csa_notify()
279 ieee80211_iterate_active_interfaces_atomic(mphy->hw, in mt7915_mcu_rx_csa_notify()
281 mt7915_mcu_csa_finish, mphy->hw); in mt7915_mcu_rx_csa_notify()
287 struct mt76_phy *mphy = &dev->mt76.phy; in mt7915_mcu_rx_thermal_notify()
291 t = (struct mt7915_mcu_thermal_notify *)skb->data; in mt7915_mcu_rx_thermal_notify()
292 if (t->ctrl.ctrl_id != THERMAL_PROTECT_ENABLE) in mt7915_mcu_rx_thermal_notify()
295 if (t->ctrl.band_idx > MT_BAND1) in mt7915_mcu_rx_thermal_notify()
298 if ((t->ctrl.band_idx && !dev->phy.mt76->band_idx) && in mt7915_mcu_rx_thermal_notify()
299 dev->mt76.phys[MT_BAND1]) in mt7915_mcu_rx_thermal_notify()
300 mphy = dev->mt76.phys[MT_BAND1]; in mt7915_mcu_rx_thermal_notify()
302 phy = mphy->priv; in mt7915_mcu_rx_thermal_notify()
303 phy->throttle_state = t->ctrl.duty.duty_cycle; in mt7915_mcu_rx_thermal_notify()
309 struct mt76_phy *mphy = &dev->mt76.phy; in mt7915_mcu_rx_radar_detected()
313 r = (struct mt7915_mcu_rdd_report *)skb->data; in mt7915_mcu_rx_radar_detected()
315 switch (r->rdd_idx) { in mt7915_mcu_rx_radar_detected()
321 if (is_mt7986(&dev->mt76) && in mt7915_mcu_rx_radar_detected()
324 mphy = dev->mt76.phys[MT_BAND1]; in mt7915_mcu_rx_radar_detected()
327 if (!dev->rdd2_phy) in mt7915_mcu_rx_radar_detected()
329 mphy = dev->rdd2_phy->mt76; in mt7915_mcu_rx_radar_detected()
332 dev_err(dev->mt76.dev, "Unknown RDD idx %d\n", r->rdd_idx); in mt7915_mcu_rx_radar_detected()
339 if (r->rdd_idx == MT_RDD_IDX_BACKGROUND) in mt7915_mcu_rx_radar_detected()
340 cfg80211_background_radar_event(mphy->hw->wiphy, in mt7915_mcu_rx_radar_detected()
341 &dev->rdd2_chandef, in mt7915_mcu_rx_radar_detected()
344 ieee80211_radar_detected(mphy->hw, NULL); in mt7915_mcu_rx_radar_detected()
345 dev->hw_pattern++; in mt7915_mcu_rx_radar_detected()
352 int len = skb->len - sizeof(*rxd); in mt7915_mcu_rx_log_message()
355 rxd = (struct mt76_connac2_mcu_rxd *)skb->data; in mt7915_mcu_rx_log_message()
358 switch (rxd->s2d_index) { in mt7915_mcu_rx_log_message()
375 wiphy_info(mt76_hw(dev)->wiphy, "%s: %.*s", type, len, data); in mt7915_mcu_rx_log_message()
381 if (!vif->bss_conf.color_change_active || vif->type == NL80211_IFTYPE_STATION) in mt7915_mcu_cca_finish()
390 struct mt76_phy *mphy = &dev->mt76.phy; in mt7915_mcu_rx_bcc_notify()
393 b = (struct mt7915_mcu_bcc_notify *)skb->data; in mt7915_mcu_rx_bcc_notify()
395 if (b->band_idx > MT_BAND1) in mt7915_mcu_rx_bcc_notify()
398 if ((b->band_idx && !dev->phy.mt76->band_idx) && in mt7915_mcu_rx_bcc_notify()
399 dev->mt76.phys[MT_BAND1]) in mt7915_mcu_rx_bcc_notify()
400 mphy = dev->mt76.phys[MT_BAND1]; in mt7915_mcu_rx_bcc_notify()
402 ieee80211_iterate_active_interfaces_atomic(mphy->hw, in mt7915_mcu_rx_bcc_notify()
404 mt7915_mcu_cca_finish, mphy->hw); in mt7915_mcu_rx_bcc_notify()
412 rxd = (struct mt76_connac2_mcu_rxd *)skb->data; in mt7915_mcu_rx_ext_event()
413 switch (rxd->ext_eid) { in mt7915_mcu_rx_ext_event()
439 rxd = (struct mt76_connac2_mcu_rxd *)skb->data; in mt7915_mcu_rx_unsolicited_event()
440 switch (rxd->eid) { in mt7915_mcu_rx_unsolicited_event()
454 rxd = (struct mt76_connac2_mcu_rxd *)skb->data; in mt7915_mcu_rx_event()
455 if ((rxd->ext_eid == MCU_EXT_EVENT_THERMAL_PROTECT || in mt7915_mcu_rx_event()
456 rxd->ext_eid == MCU_EXT_EVENT_FW_LOG_2_HOST || in mt7915_mcu_rx_event()
457 rxd->ext_eid == MCU_EXT_EVENT_ASSERT_DUMP || in mt7915_mcu_rx_event()
458 rxd->ext_eid == MCU_EXT_EVENT_PS_SYNC || in mt7915_mcu_rx_event()
459 rxd->ext_eid == MCU_EXT_EVENT_BCC_NOTIFY || in mt7915_mcu_rx_event()
460 !rxd->seq) && in mt7915_mcu_rx_event()
461 !(rxd->eid == MCU_CMD_EXT_CID && in mt7915_mcu_rx_event()
462 rxd->ext_eid == MCU_EXT_EVENT_WA_TX_STAT)) in mt7915_mcu_rx_event()
465 mt76_mcu_rx_event(&dev->mt76, skb); in mt7915_mcu_rx_event()
501 if (!elem || elem->datalen <= 10 || in mt7915_check_he_obss_narrow_bw_ru_iter()
502 !(elem->data[10] & in mt7915_check_he_obss_narrow_bw_ru_iter()
504 data->tolerated = false; in mt7915_check_he_obss_narrow_bw_ru_iter()
516 if (!(vif->bss_conf.chanreq.oper.chan->flags & IEEE80211_CHAN_RADAR)) in mt7915_check_he_obss_narrow_bw_ru()
519 cfg80211_bss_iter(hw->wiphy, &vif->bss_conf.chanreq.oper, in mt7915_check_he_obss_narrow_bw_ru()
525 * tolerate 26-tone RU UL OFDMA transmissions using HE TB PPDU. in mt7915_check_he_obss_narrow_bw_ru()
534 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7915_mcu_bss_rfch_tlv()
537 int freq1 = chandef->center_freq1; in mt7915_mcu_bss_rfch_tlv()
542 ch->pri_ch = chandef->chan->hw_value; in mt7915_mcu_bss_rfch_tlv()
543 ch->center_ch0 = ieee80211_frequency_to_channel(freq1); in mt7915_mcu_bss_rfch_tlv()
544 ch->bw = mt76_connac_chan_bw(chandef); in mt7915_mcu_bss_rfch_tlv()
546 if (chandef->width == NL80211_CHAN_WIDTH_80P80) { in mt7915_mcu_bss_rfch_tlv()
547 int freq2 = chandef->center_freq2; in mt7915_mcu_bss_rfch_tlv()
549 ch->center_ch1 = ieee80211_frequency_to_channel(freq2); in mt7915_mcu_bss_rfch_tlv()
552 if (vif->bss_conf.he_support && vif->type == NL80211_IFTYPE_STATION) { in mt7915_mcu_bss_rfch_tlv()
553 struct mt76_phy *mphy = phy->mt76; in mt7915_mcu_bss_rfch_tlv()
555 ch->he_ru26_block = in mt7915_mcu_bss_rfch_tlv()
556 mt7915_check_he_obss_narrow_bw_ru(mphy->hw, vif); in mt7915_mcu_bss_rfch_tlv()
557 ch->he_all_disable = false; in mt7915_mcu_bss_rfch_tlv()
559 ch->he_all_disable = true; in mt7915_mcu_bss_rfch_tlv()
567 int max_nss = hweight8(phy->mt76->antenna_mask); in mt7915_mcu_bss_ra_tlv()
574 ra->op_mode = vif->type == NL80211_IFTYPE_AP; in mt7915_mcu_bss_ra_tlv()
575 ra->adhoc_en = vif->type == NL80211_IFTYPE_ADHOC; in mt7915_mcu_bss_ra_tlv()
576 ra->short_preamble = true; in mt7915_mcu_bss_ra_tlv()
577 ra->tx_streams = max_nss; in mt7915_mcu_bss_ra_tlv()
578 ra->rx_streams = max_nss; in mt7915_mcu_bss_ra_tlv()
579 ra->algo = 4; in mt7915_mcu_bss_ra_tlv()
580 ra->train_up_rule = 2; in mt7915_mcu_bss_ra_tlv()
581 ra->train_up_high_thres = 110; in mt7915_mcu_bss_ra_tlv()
582 ra->train_up_rule_rssi = -70; in mt7915_mcu_bss_ra_tlv()
583 ra->low_traffic_thres = 2; in mt7915_mcu_bss_ra_tlv()
584 ra->phy_cap = cpu_to_le32(0xfdf); in mt7915_mcu_bss_ra_tlv()
585 ra->interval = cpu_to_le32(500); in mt7915_mcu_bss_ra_tlv()
586 ra->fast_interval = cpu_to_le32(100); in mt7915_mcu_bss_ra_tlv()
599 cap = mt76_connac_get_he_phy_cap(phy->mt76, vif); in mt7915_mcu_bss_he_tlv()
604 he->he_pe_duration = vif->bss_conf.htc_trig_based_pkt_ext; in mt7915_mcu_bss_he_tlv()
605 if (!he->he_pe_duration) in mt7915_mcu_bss_he_tlv()
606 he->he_pe_duration = DEFAULT_HE_PE_DURATION; in mt7915_mcu_bss_he_tlv()
608 he->he_rts_thres = cpu_to_le16(vif->bss_conf.frame_time_rts_th); in mt7915_mcu_bss_he_tlv()
609 if (!he->he_rts_thres) in mt7915_mcu_bss_he_tlv()
610 he->he_rts_thres = cpu_to_le16(DEFAULT_HE_DURATION_RTS_THRES); in mt7915_mcu_bss_he_tlv()
612 he->max_nss_mcs[CMD_HE_MCS_BW80] = cap->he_mcs_nss_supp.tx_mcs_80; in mt7915_mcu_bss_he_tlv()
613 he->max_nss_mcs[CMD_HE_MCS_BW160] = cap->he_mcs_nss_supp.tx_mcs_160; in mt7915_mcu_bss_he_tlv()
614 he->max_nss_mcs[CMD_HE_MCS_BW8080] = cap->he_mcs_nss_supp.tx_mcs_80p80; in mt7915_mcu_bss_he_tlv()
628 amsdu->cmp_bitmap_0 = cpu_to_le32(TXD_CMP_MAP1); in mt7915_mcu_bss_hw_amsdu_tlv()
629 amsdu->cmp_bitmap_1 = cpu_to_le32(TXD_CMP_MAP2); in mt7915_mcu_bss_hw_amsdu_tlv()
630 amsdu->trig_thres = cpu_to_le16(2); in mt7915_mcu_bss_hw_amsdu_tlv()
631 amsdu->enable = true; in mt7915_mcu_bss_hw_amsdu_tlv()
638 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7915_mcu_bss_bmc_tlv()
639 enum nl80211_band band = chandef->chan->band; in mt7915_mcu_bss_bmc_tlv()
646 bmc->short_preamble = true; in mt7915_mcu_bss_bmc_tlv()
648 bmc->bc_trans = cpu_to_le16(0x2000); in mt7915_mcu_bss_bmc_tlv()
649 bmc->mc_trans = cpu_to_le16(0x2080); in mt7915_mcu_bss_bmc_tlv()
657 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_muar_config()
658 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_muar_config()
659 u32 idx = mvif->mt76.omac_idx - REPEATER_BSSID_START; in mt7915_mcu_muar_config()
660 u32 mask = phy->omac_mask >> 32 & ~BIT(idx); in mt7915_mcu_muar_config()
661 const u8 *addr = vif->addr; in mt7915_mcu_muar_config()
677 .band = phy->mt76->band_idx, in mt7915_mcu_muar_config()
682 addr = vif->bss_conf.bssid; in mt7915_mcu_muar_config()
687 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(MUAR_UPDATE), &req, in mt7915_mcu_muar_config()
694 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_bss_info()
695 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_add_bss_info()
698 if (mvif->mt76.omac_idx >= REPEATER_BSSID_START) { in mt7915_mcu_add_bss_info()
703 skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, NULL, in mt7915_mcu_add_bss_info()
712 mt76_connac_mcu_bss_basic_tlv(skb, vif, NULL, phy->mt76, in mt7915_mcu_add_bss_info()
713 mvif->sta.wcid.idx, enable); in mt7915_mcu_add_bss_info()
715 if (vif->type == NL80211_IFTYPE_MONITOR) in mt7915_mcu_add_bss_info()
724 if (vif->bss_conf.he_support) in mt7915_mcu_add_bss_info()
727 if (mvif->mt76.omac_idx >= EXT_BSSID_START && in mt7915_mcu_add_bss_info()
728 mvif->mt76.omac_idx < REPEATER_BSSID_START) in mt7915_mcu_add_bss_info()
729 mt76_connac_mcu_bss_ext_tlv(skb, &mvif->mt76); in mt7915_mcu_add_bss_info()
732 return mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7915_mcu_add_bss_info()
741 struct mt7915_sta *msta = (struct mt7915_sta *)params->sta->drv_priv; in mt7915_mcu_add_tx_ba()
742 struct mt7915_vif *mvif = msta->vif; in mt7915_mcu_add_tx_ba()
745 mt76_worker_disable(&dev->mt76.tx_worker); in mt7915_mcu_add_tx_ba()
746 if (enable && !params->amsdu) in mt7915_mcu_add_tx_ba()
747 msta->wcid.amsdu = false; in mt7915_mcu_add_tx_ba()
748 ret = mt76_connac_mcu_sta_ba(&dev->mt76, &mvif->mt76, params, in mt7915_mcu_add_tx_ba()
751 mt76_worker_enable(&dev->mt76.tx_worker); in mt7915_mcu_add_tx_ba()
760 struct mt7915_sta *msta = (struct mt7915_sta *)params->sta->drv_priv; in mt7915_mcu_add_rx_ba()
761 struct mt7915_vif *mvif = msta->vif; in mt7915_mcu_add_rx_ba()
763 return mt76_connac_mcu_sta_ba(&dev->mt76, &mvif->mt76, params, in mt7915_mcu_add_rx_ba()
772 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_sta_he_tlv()
773 struct ieee80211_he_cap_elem *elem = &sta->deflink.he_cap.he_cap_elem; in mt7915_mcu_sta_he_tlv()
779 if (!sta->deflink.he_cap.has_he) in mt7915_mcu_sta_he_tlv()
786 if (elem->mac_cap_info[0] & IEEE80211_HE_MAC_CAP0_HTC_HE) in mt7915_mcu_sta_he_tlv()
789 if (elem->mac_cap_info[2] & IEEE80211_HE_MAC_CAP2_BSR) in mt7915_mcu_sta_he_tlv()
792 if (elem->mac_cap_info[3] & IEEE80211_HE_MAC_CAP3_OMI_CONTROL) in mt7915_mcu_sta_he_tlv()
795 if (elem->mac_cap_info[4] & IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU) in mt7915_mcu_sta_he_tlv()
798 if (elem->mac_cap_info[4] & IEEE80211_HE_MAC_CAP4_BQR) in mt7915_mcu_sta_he_tlv()
801 if (elem->phy_cap_info[0] & in mt7915_mcu_sta_he_tlv()
806 if (mvif->cap.he_ldpc && in mt7915_mcu_sta_he_tlv()
807 (elem->phy_cap_info[1] & in mt7915_mcu_sta_he_tlv()
811 if (elem->phy_cap_info[1] & in mt7915_mcu_sta_he_tlv()
815 if (elem->phy_cap_info[2] & in mt7915_mcu_sta_he_tlv()
819 if (elem->phy_cap_info[2] & in mt7915_mcu_sta_he_tlv()
823 if (elem->phy_cap_info[2] & in mt7915_mcu_sta_he_tlv()
827 if (elem->phy_cap_info[6] & in mt7915_mcu_sta_he_tlv()
831 if (elem->phy_cap_info[6] & in mt7915_mcu_sta_he_tlv()
835 if (elem->phy_cap_info[7] & in mt7915_mcu_sta_he_tlv()
839 if (elem->phy_cap_info[7] & in mt7915_mcu_sta_he_tlv()
843 if (elem->phy_cap_info[7] & in mt7915_mcu_sta_he_tlv()
847 if (elem->phy_cap_info[8] & in mt7915_mcu_sta_he_tlv()
851 if (elem->phy_cap_info[8] & in mt7915_mcu_sta_he_tlv()
855 if (elem->phy_cap_info[9] & in mt7915_mcu_sta_he_tlv()
859 if (elem->phy_cap_info[9] & in mt7915_mcu_sta_he_tlv()
863 he->he_cap = cpu_to_le32(cap); in mt7915_mcu_sta_he_tlv()
865 mcs_map = sta->deflink.he_cap.he_mcs_nss_supp; in mt7915_mcu_sta_he_tlv()
866 switch (sta->deflink.bandwidth) { in mt7915_mcu_sta_he_tlv()
868 if (elem->phy_cap_info[0] & in mt7915_mcu_sta_he_tlv()
871 &he->max_nss_mcs[CMD_HE_MCS_BW8080], in mt7915_mcu_sta_he_tlv()
875 &he->max_nss_mcs[CMD_HE_MCS_BW160], in mt7915_mcu_sta_he_tlv()
880 &he->max_nss_mcs[CMD_HE_MCS_BW80], in mt7915_mcu_sta_he_tlv()
885 he->t_frame_dur = in mt7915_mcu_sta_he_tlv()
886 HE_MAC(CAP1_TF_MAC_PAD_DUR_MASK, elem->mac_cap_info[1]); in mt7915_mcu_sta_he_tlv()
887 he->max_ampdu_exp = in mt7915_mcu_sta_he_tlv()
888 HE_MAC(CAP3_MAX_AMPDU_LEN_EXP_MASK, elem->mac_cap_info[3]); in mt7915_mcu_sta_he_tlv()
890 he->bw_set = in mt7915_mcu_sta_he_tlv()
891 HE_PHY(CAP0_CHANNEL_WIDTH_SET_MASK, elem->phy_cap_info[0]); in mt7915_mcu_sta_he_tlv()
892 he->device_class = in mt7915_mcu_sta_he_tlv()
893 HE_PHY(CAP1_DEVICE_CLASS_A, elem->phy_cap_info[1]); in mt7915_mcu_sta_he_tlv()
894 he->punc_pream_rx = in mt7915_mcu_sta_he_tlv()
895 HE_PHY(CAP1_PREAMBLE_PUNC_RX_MASK, elem->phy_cap_info[1]); in mt7915_mcu_sta_he_tlv()
897 he->dcm_tx_mode = in mt7915_mcu_sta_he_tlv()
898 HE_PHY(CAP3_DCM_MAX_CONST_TX_MASK, elem->phy_cap_info[3]); in mt7915_mcu_sta_he_tlv()
899 he->dcm_tx_max_nss = in mt7915_mcu_sta_he_tlv()
900 HE_PHY(CAP3_DCM_MAX_TX_NSS_2, elem->phy_cap_info[3]); in mt7915_mcu_sta_he_tlv()
901 he->dcm_rx_mode = in mt7915_mcu_sta_he_tlv()
902 HE_PHY(CAP3_DCM_MAX_CONST_RX_MASK, elem->phy_cap_info[3]); in mt7915_mcu_sta_he_tlv()
903 he->dcm_rx_max_nss = in mt7915_mcu_sta_he_tlv()
904 HE_PHY(CAP3_DCM_MAX_RX_NSS_2, elem->phy_cap_info[3]); in mt7915_mcu_sta_he_tlv()
905 he->dcm_rx_max_nss = in mt7915_mcu_sta_he_tlv()
906 HE_PHY(CAP8_DCM_MAX_RU_MASK, elem->phy_cap_info[8]); in mt7915_mcu_sta_he_tlv()
908 he->pkt_ext = 2; in mt7915_mcu_sta_he_tlv()
915 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_sta_muru_tlv()
916 struct ieee80211_he_cap_elem *elem = &sta->deflink.he_cap.he_cap_elem; in mt7915_mcu_sta_muru_tlv()
920 if (vif->type != NL80211_IFTYPE_STATION && in mt7915_mcu_sta_muru_tlv()
921 vif->type != NL80211_IFTYPE_AP) in mt7915_mcu_sta_muru_tlv()
928 muru->cfg.mimo_dl_en = mvif->cap.he_mu_ebfer || in mt7915_mcu_sta_muru_tlv()
929 mvif->cap.vht_mu_ebfer || in mt7915_mcu_sta_muru_tlv()
930 mvif->cap.vht_mu_ebfee; in mt7915_mcu_sta_muru_tlv()
931 if (!is_mt7915(&dev->mt76)) in mt7915_mcu_sta_muru_tlv()
932 muru->cfg.mimo_ul_en = true; in mt7915_mcu_sta_muru_tlv()
933 muru->cfg.ofdma_dl_en = true; in mt7915_mcu_sta_muru_tlv()
935 if (sta->deflink.vht_cap.vht_supported) in mt7915_mcu_sta_muru_tlv()
936 muru->mimo_dl.vht_mu_bfee = in mt7915_mcu_sta_muru_tlv()
937 !!(sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE); in mt7915_mcu_sta_muru_tlv()
939 if (!sta->deflink.he_cap.has_he) in mt7915_mcu_sta_muru_tlv()
942 muru->mimo_dl.partial_bw_dl_mimo = in mt7915_mcu_sta_muru_tlv()
943 HE_PHY(CAP6_PARTIAL_BANDWIDTH_DL_MUMIMO, elem->phy_cap_info[6]); in mt7915_mcu_sta_muru_tlv()
945 muru->mimo_ul.full_ul_mimo = in mt7915_mcu_sta_muru_tlv()
946 HE_PHY(CAP2_UL_MU_FULL_MU_MIMO, elem->phy_cap_info[2]); in mt7915_mcu_sta_muru_tlv()
947 muru->mimo_ul.partial_ul_mimo = in mt7915_mcu_sta_muru_tlv()
948 HE_PHY(CAP2_UL_MU_PARTIAL_MU_MIMO, elem->phy_cap_info[2]); in mt7915_mcu_sta_muru_tlv()
950 muru->ofdma_dl.punc_pream_rx = in mt7915_mcu_sta_muru_tlv()
951 HE_PHY(CAP1_PREAMBLE_PUNC_RX_MASK, elem->phy_cap_info[1]); in mt7915_mcu_sta_muru_tlv()
952 muru->ofdma_dl.he_20m_in_40m_2g = in mt7915_mcu_sta_muru_tlv()
953 HE_PHY(CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G, elem->phy_cap_info[8]); in mt7915_mcu_sta_muru_tlv()
954 muru->ofdma_dl.he_20m_in_160m = in mt7915_mcu_sta_muru_tlv()
955 HE_PHY(CAP8_20MHZ_IN_160MHZ_HE_PPDU, elem->phy_cap_info[8]); in mt7915_mcu_sta_muru_tlv()
956 muru->ofdma_dl.he_80m_in_160m = in mt7915_mcu_sta_muru_tlv()
957 HE_PHY(CAP8_80MHZ_IN_160MHZ_HE_PPDU, elem->phy_cap_info[8]); in mt7915_mcu_sta_muru_tlv()
959 muru->ofdma_ul.t_frame_dur = in mt7915_mcu_sta_muru_tlv()
960 HE_MAC(CAP1_TF_MAC_PAD_DUR_MASK, elem->mac_cap_info[1]); in mt7915_mcu_sta_muru_tlv()
961 muru->ofdma_ul.mu_cascading = in mt7915_mcu_sta_muru_tlv()
962 HE_MAC(CAP2_MU_CASCADING, elem->mac_cap_info[2]); in mt7915_mcu_sta_muru_tlv()
963 muru->ofdma_ul.uo_ra = in mt7915_mcu_sta_muru_tlv()
964 HE_MAC(CAP3_OFDMA_RA, elem->mac_cap_info[3]); in mt7915_mcu_sta_muru_tlv()
965 muru->ofdma_ul.rx_ctrl_frame_to_mbss = in mt7915_mcu_sta_muru_tlv()
966 HE_MAC(CAP3_RX_CTRL_FRAME_TO_MULTIBSS, elem->mac_cap_info[3]); in mt7915_mcu_sta_muru_tlv()
975 if (!sta->deflink.ht_cap.ht_supported) in mt7915_mcu_sta_ht_tlv()
981 ht->ht_cap = cpu_to_le16(sta->deflink.ht_cap.cap); in mt7915_mcu_sta_ht_tlv()
990 if (!sta->deflink.vht_cap.vht_supported) in mt7915_mcu_sta_vht_tlv()
996 vht->vht_cap = cpu_to_le32(sta->deflink.vht_cap.cap); in mt7915_mcu_sta_vht_tlv()
997 vht->vht_rx_mcs_map = sta->deflink.vht_cap.vht_mcs.rx_mcs_map; in mt7915_mcu_sta_vht_tlv()
998 vht->vht_tx_mcs_map = sta->deflink.vht_cap.vht_mcs.tx_mcs_map; in mt7915_mcu_sta_vht_tlv()
1005 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_sta_amsdu_tlv()
1009 if (vif->type != NL80211_IFTYPE_STATION && in mt7915_mcu_sta_amsdu_tlv()
1010 vif->type != NL80211_IFTYPE_AP) in mt7915_mcu_sta_amsdu_tlv()
1013 if (!sta->deflink.agg.max_amsdu_len) in mt7915_mcu_sta_amsdu_tlv()
1018 amsdu->max_amsdu_num = 8; in mt7915_mcu_sta_amsdu_tlv()
1019 amsdu->amsdu_en = true; in mt7915_mcu_sta_amsdu_tlv()
1020 msta->wcid.amsdu = true; in mt7915_mcu_sta_amsdu_tlv()
1022 switch (sta->deflink.agg.max_amsdu_len) { in mt7915_mcu_sta_amsdu_tlv()
1024 if (!is_mt7915(&dev->mt76)) { in mt7915_mcu_sta_amsdu_tlv()
1025 amsdu->max_mpdu_size = in mt7915_mcu_sta_amsdu_tlv()
1032 amsdu->max_mpdu_size = IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; in mt7915_mcu_sta_amsdu_tlv()
1035 amsdu->max_mpdu_size = IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; in mt7915_mcu_sta_amsdu_tlv()
1044 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_sta_wtbl_tlv()
1050 msta = sta ? (struct mt7915_sta *)sta->drv_priv : &mvif->sta; in mt7915_mcu_sta_wtbl_tlv()
1051 wcid = sta ? &msta->wcid : NULL; in mt7915_mcu_sta_wtbl_tlv()
1054 wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(&dev->mt76, &msta->wcid, in mt7915_mcu_sta_wtbl_tlv()
1060 mt76_connac_mcu_wtbl_generic_tlv(&dev->mt76, skb, vif, sta, tlv, in mt7915_mcu_sta_wtbl_tlv()
1064 mt76_connac_mcu_wtbl_ht_tlv(&dev->mt76, skb, sta, tlv, in mt7915_mcu_sta_wtbl_tlv()
1065 wtbl_hdr, mvif->cap.ht_ldpc, in mt7915_mcu_sta_wtbl_tlv()
1066 mvif->cap.vht_ldpc); in mt7915_mcu_sta_wtbl_tlv()
1075 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_is_ebf_supported()
1076 int sts = hweight16(phy->mt76->chainmask); in mt7915_is_ebf_supported()
1078 if (vif->type != NL80211_IFTYPE_STATION && in mt7915_is_ebf_supported()
1079 vif->type != NL80211_IFTYPE_AP) in mt7915_is_ebf_supported()
1085 if (sta->deflink.he_cap.has_he) { in mt7915_is_ebf_supported()
1086 struct ieee80211_he_cap_elem *pe = &sta->deflink.he_cap.he_cap_elem; in mt7915_is_ebf_supported()
1089 return mvif->cap.he_su_ebfee && in mt7915_is_ebf_supported()
1090 HE_PHY(CAP3_SU_BEAMFORMER, pe->phy_cap_info[3]); in mt7915_is_ebf_supported()
1092 return mvif->cap.he_su_ebfer && in mt7915_is_ebf_supported()
1093 HE_PHY(CAP4_SU_BEAMFORMEE, pe->phy_cap_info[4]); in mt7915_is_ebf_supported()
1096 if (sta->deflink.vht_cap.vht_supported) { in mt7915_is_ebf_supported()
1097 u32 cap = sta->deflink.vht_cap.cap; in mt7915_is_ebf_supported()
1100 return mvif->cap.vht_su_ebfee && in mt7915_is_ebf_supported()
1103 return mvif->cap.vht_su_ebfer && in mt7915_is_ebf_supported()
1113 bf->sounding_phy = MT_PHY_TYPE_OFDM; in mt7915_mcu_sta_sounding_rate()
1114 bf->ndp_rate = 0; /* mcs0 */ in mt7915_mcu_sta_sounding_rate()
1115 bf->ndpa_rate = MT7915_CFEND_RATE_DEFAULT; /* ofdm 24m */ in mt7915_mcu_sta_sounding_rate()
1116 bf->rept_poll_rate = MT7915_CFEND_RATE_DEFAULT; /* ofdm 24m */ in mt7915_mcu_sta_sounding_rate()
1123 struct ieee80211_mcs_info *mcs = &sta->deflink.ht_cap.mcs; in mt7915_mcu_sta_bfer_ht()
1126 bf->tx_mode = MT_PHY_TYPE_HT; in mt7915_mcu_sta_bfer_ht()
1128 if ((mcs->tx_params & IEEE80211_HT_MCS_TX_RX_DIFF) && in mt7915_mcu_sta_bfer_ht()
1129 (mcs->tx_params & IEEE80211_HT_MCS_TX_DEFINED)) in mt7915_mcu_sta_bfer_ht()
1131 mcs->tx_params); in mt7915_mcu_sta_bfer_ht()
1132 else if (mcs->rx_mask[3]) in mt7915_mcu_sta_bfer_ht()
1134 else if (mcs->rx_mask[2]) in mt7915_mcu_sta_bfer_ht()
1136 else if (mcs->rx_mask[1]) in mt7915_mcu_sta_bfer_ht()
1139 bf->nrow = hweight8(phy->mt76->chainmask) - 1; in mt7915_mcu_sta_bfer_ht()
1140 bf->ncol = min_t(u8, bf->nrow, n); in mt7915_mcu_sta_bfer_ht()
1141 bf->ibf_ncol = n; in mt7915_mcu_sta_bfer_ht()
1148 struct ieee80211_sta_vht_cap *pc = &sta->deflink.vht_cap; in mt7915_mcu_sta_bfer_vht()
1149 struct ieee80211_sta_vht_cap *vc = &phy->mt76->sband_5g.sband.vht_cap; in mt7915_mcu_sta_bfer_vht()
1150 u16 mcs_map = le16_to_cpu(pc->vht_mcs.rx_mcs_map); in mt7915_mcu_sta_bfer_vht()
1152 u8 tx_ant = hweight8(phy->mt76->chainmask) - 1; in mt7915_mcu_sta_bfer_vht()
1154 bf->tx_mode = MT_PHY_TYPE_VHT; in mt7915_mcu_sta_bfer_vht()
1162 pc->cap); in mt7915_mcu_sta_bfer_vht()
1164 vc->cap); in mt7915_mcu_sta_bfer_vht()
1165 bf->nrow = min_t(u8, min_t(u8, snd_dim, sts), tx_ant); in mt7915_mcu_sta_bfer_vht()
1166 bf->ncol = min_t(u8, nss_mcs, bf->nrow); in mt7915_mcu_sta_bfer_vht()
1167 bf->ibf_ncol = bf->ncol; in mt7915_mcu_sta_bfer_vht()
1169 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) in mt7915_mcu_sta_bfer_vht()
1170 bf->nrow = 1; in mt7915_mcu_sta_bfer_vht()
1172 bf->nrow = tx_ant; in mt7915_mcu_sta_bfer_vht()
1173 bf->ncol = min_t(u8, nss_mcs, bf->nrow); in mt7915_mcu_sta_bfer_vht()
1174 bf->ibf_ncol = nss_mcs; in mt7915_mcu_sta_bfer_vht()
1176 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) in mt7915_mcu_sta_bfer_vht()
1177 bf->ibf_nrow = 1; in mt7915_mcu_sta_bfer_vht()
1185 struct ieee80211_sta_he_cap *pc = &sta->deflink.he_cap; in mt7915_mcu_sta_bfer_he()
1186 struct ieee80211_he_cap_elem *pe = &pc->he_cap_elem; in mt7915_mcu_sta_bfer_he()
1188 mt76_connac_get_he_phy_cap(phy->mt76, vif); in mt7915_mcu_sta_bfer_he()
1189 const struct ieee80211_he_cap_elem *ve = &vc->he_cap_elem; in mt7915_mcu_sta_bfer_he()
1190 u16 mcs_map = le16_to_cpu(pc->he_mcs_nss_supp.rx_mcs_80); in mt7915_mcu_sta_bfer_he()
1194 bf->tx_mode = MT_PHY_TYPE_HE_SU; in mt7915_mcu_sta_bfer_he()
1198 bf->trigger_su = HE_PHY(CAP6_TRIG_SU_BEAMFORMING_FB, in mt7915_mcu_sta_bfer_he()
1199 pe->phy_cap_info[6]); in mt7915_mcu_sta_bfer_he()
1200 bf->trigger_mu = HE_PHY(CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB, in mt7915_mcu_sta_bfer_he()
1201 pe->phy_cap_info[6]); in mt7915_mcu_sta_bfer_he()
1203 ve->phy_cap_info[5]); in mt7915_mcu_sta_bfer_he()
1205 pe->phy_cap_info[4]); in mt7915_mcu_sta_bfer_he()
1206 bf->nrow = min_t(u8, snd_dim, sts); in mt7915_mcu_sta_bfer_he()
1207 bf->ncol = min_t(u8, nss_mcs, bf->nrow); in mt7915_mcu_sta_bfer_he()
1208 bf->ibf_ncol = bf->ncol; in mt7915_mcu_sta_bfer_he()
1210 if (sta->deflink.bandwidth != IEEE80211_STA_RX_BW_160) in mt7915_mcu_sta_bfer_he()
1214 if (pe->phy_cap_info[0] & in mt7915_mcu_sta_bfer_he()
1216 mcs_map = le16_to_cpu(pc->he_mcs_nss_supp.rx_mcs_160); in mt7915_mcu_sta_bfer_he()
1219 bf->ncol_gt_bw80 = nss_mcs; in mt7915_mcu_sta_bfer_he()
1222 if (pe->phy_cap_info[0] & in mt7915_mcu_sta_bfer_he()
1224 mcs_map = le16_to_cpu(pc->he_mcs_nss_supp.rx_mcs_80p80); in mt7915_mcu_sta_bfer_he()
1227 if (bf->ncol_gt_bw80) in mt7915_mcu_sta_bfer_he()
1228 bf->ncol_gt_bw80 = min_t(u8, bf->ncol_gt_bw80, nss_mcs); in mt7915_mcu_sta_bfer_he()
1230 bf->ncol_gt_bw80 = nss_mcs; in mt7915_mcu_sta_bfer_he()
1234 ve->phy_cap_info[5]); in mt7915_mcu_sta_bfer_he()
1236 pe->phy_cap_info[4]); in mt7915_mcu_sta_bfer_he()
1238 bf->nrow_gt_bw80 = min_t(int, snd_dim, sts); in mt7915_mcu_sta_bfer_he()
1245 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_sta_bfer_tlv()
1246 struct mt7915_phy *phy = mvif->phy; in mt7915_mcu_sta_bfer_tlv()
1247 int tx_ant = hweight8(phy->mt76->chainmask) - 1; in mt7915_mcu_sta_bfer_tlv()
1254 {3, 5, 6, 0} /* 4x1, 4x2, 4x3, 4x4 */ in mt7915_mcu_sta_bfer_tlv()
1258 if (!(sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he)) in mt7915_mcu_sta_bfer_tlv()
1262 if (!ebf && !dev->ibf) in mt7915_mcu_sta_bfer_tlv()
1272 if (sta->deflink.he_cap.has_he && ebf) in mt7915_mcu_sta_bfer_tlv()
1274 else if (sta->deflink.vht_cap.vht_supported) in mt7915_mcu_sta_bfer_tlv()
1276 else if (sta->deflink.ht_cap.ht_supported) in mt7915_mcu_sta_bfer_tlv()
1281 bf->bf_cap = ebf ? ebf : dev->ibf << 1; in mt7915_mcu_sta_bfer_tlv()
1282 bf->bw = sta->deflink.bandwidth; in mt7915_mcu_sta_bfer_tlv()
1283 bf->ibf_dbw = sta->deflink.bandwidth; in mt7915_mcu_sta_bfer_tlv()
1284 bf->ibf_nrow = tx_ant; in mt7915_mcu_sta_bfer_tlv()
1286 if (!ebf && sta->deflink.bandwidth <= IEEE80211_STA_RX_BW_40 && !bf->ncol) in mt7915_mcu_sta_bfer_tlv()
1287 bf->ibf_timeout = 0x48; in mt7915_mcu_sta_bfer_tlv()
1289 bf->ibf_timeout = 0x18; in mt7915_mcu_sta_bfer_tlv()
1291 if (ebf && bf->nrow != tx_ant) in mt7915_mcu_sta_bfer_tlv()
1292 bf->mem_20m = matrix[tx_ant][bf->ncol]; in mt7915_mcu_sta_bfer_tlv()
1294 bf->mem_20m = matrix[bf->nrow][bf->ncol]; in mt7915_mcu_sta_bfer_tlv()
1296 switch (sta->deflink.bandwidth) { in mt7915_mcu_sta_bfer_tlv()
1299 bf->mem_total = bf->mem_20m * 2; in mt7915_mcu_sta_bfer_tlv()
1302 bf->mem_total = bf->mem_20m; in mt7915_mcu_sta_bfer_tlv()
1314 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_sta_bfee_tlv()
1315 struct mt7915_phy *phy = mvif->phy; in mt7915_mcu_sta_bfee_tlv()
1316 int tx_ant = hweight8(phy->mt76->chainmask) - 1; in mt7915_mcu_sta_bfee_tlv()
1321 if (!(sta->deflink.vht_cap.vht_supported || sta->deflink.he_cap.has_he)) in mt7915_mcu_sta_bfee_tlv()
1330 if (sta->deflink.he_cap.has_he) { in mt7915_mcu_sta_bfee_tlv()
1331 struct ieee80211_he_cap_elem *pe = &sta->deflink.he_cap.he_cap_elem; in mt7915_mcu_sta_bfee_tlv()
1334 pe->phy_cap_info[5]); in mt7915_mcu_sta_bfee_tlv()
1335 } else if (sta->deflink.vht_cap.vht_supported) { in mt7915_mcu_sta_bfee_tlv()
1336 struct ieee80211_sta_vht_cap *pc = &sta->deflink.vht_cap; in mt7915_mcu_sta_bfee_tlv()
1339 pc->cap); in mt7915_mcu_sta_bfee_tlv()
1343 bfee->fb_identity_matrix = (nrow == 1 && tx_ant == 2); in mt7915_mcu_sta_bfee_tlv()
1366 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_set_fixed_rate_ctrl()
1367 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_set_fixed_rate_ctrl()
1373 skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, in mt7915_mcu_set_fixed_rate_ctrl()
1374 &msta->wcid); in mt7915_mcu_set_fixed_rate_ctrl()
1389 ra->phy = *phy; in mt7915_mcu_set_fixed_rate_ctrl()
1392 ra->mmps_mode = mt7915_mcu_get_mmps_mode(sta->deflink.smps_mode); in mt7915_mcu_set_fixed_rate_ctrl()
1395 ra->spe_idx = *(u8 *)data; in mt7915_mcu_set_fixed_rate_ctrl()
1400 ra->field = cpu_to_le32(field); in mt7915_mcu_set_fixed_rate_ctrl()
1402 return mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7915_mcu_set_fixed_rate_ctrl()
1409 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_smps()
1410 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_add_smps()
1416 skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, in mt7915_mcu_add_smps()
1417 &msta->wcid); in mt7915_mcu_add_smps()
1423 wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(&dev->mt76, &msta->wcid, in mt7915_mcu_add_smps()
1430 ret = mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7915_mcu_add_smps()
1443 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_set_spe_idx()
1444 struct mt76_phy *mphy = mvif->phy->mt76; in mt7915_mcu_set_spe_idx()
1445 u8 spe_idx = mt76_connac_spe_idx(mphy->antenna_mask); in mt7915_mcu_set_spe_idx()
1456 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_rate_ctrl_fixed()
1457 struct cfg80211_chan_def *chandef = &mvif->phy->mt76->chandef; in mt7915_mcu_add_rate_ctrl_fixed()
1458 struct cfg80211_bitrate_mask *mask = &mvif->bitrate_mask; in mt7915_mcu_add_rate_ctrl_fixed()
1459 enum nl80211_band band = chandef->chan->band; in mt7915_mcu_add_rate_ctrl_fixed()
1465 u8 i, gi = mask->control[band]._gi; \ in mt7915_mcu_add_rate_ctrl_fixed()
1467 for (i = 0; i <= sta->deflink.bandwidth; i++) { \ in mt7915_mcu_add_rate_ctrl_fixed()
1469 phy.he_ltf |= mask->control[band].he_ltf << (i << (_he));\ in mt7915_mcu_add_rate_ctrl_fixed()
1471 for (i = 0; i < ARRAY_SIZE(mask->control[band]._mcs); i++) { \ in mt7915_mcu_add_rate_ctrl_fixed()
1472 if (!mask->control[band]._mcs[i]) \ in mt7915_mcu_add_rate_ctrl_fixed()
1474 nrates += hweight16(mask->control[band]._mcs[i]); \ in mt7915_mcu_add_rate_ctrl_fixed()
1475 phy.mcs = ffs(mask->control[band]._mcs[i]) - 1; \ in mt7915_mcu_add_rate_ctrl_fixed()
1481 if (sta->deflink.he_cap.has_he) { in mt7915_mcu_add_rate_ctrl_fixed()
1483 } else if (sta->deflink.vht_cap.vht_supported) { in mt7915_mcu_add_rate_ctrl_fixed()
1485 } else if (sta->deflink.ht_cap.ht_supported) { in mt7915_mcu_add_rate_ctrl_fixed()
1488 nrates = hweight32(mask->control[band].legacy); in mt7915_mcu_add_rate_ctrl_fixed()
1489 phy.mcs = ffs(mask->control[band].legacy) - 1; in mt7915_mcu_add_rate_ctrl_fixed()
1494 if (mask->control[band].gi == NL80211_TXRATE_DEFAULT_GI && in mt7915_mcu_add_rate_ctrl_fixed()
1495 mask->control[band].he_gi == GENMASK(7, 0) && in mt7915_mcu_add_rate_ctrl_fixed()
1496 mask->control[band].he_ltf == GENMASK(7, 0) && in mt7915_mcu_add_rate_ctrl_fixed()
1509 if (mask->control[band].gi != NL80211_TXRATE_DEFAULT_GI || in mt7915_mcu_add_rate_ctrl_fixed()
1510 mask->control[band].he_gi != GENMASK(7, 0)) { in mt7915_mcu_add_rate_ctrl_fixed()
1511 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_add_rate_ctrl_fixed()
1518 addr = mt7915_mac_wtbl_lmac_addr(dev, msta->wcid.idx, 7); in mt7915_mcu_add_rate_ctrl_fixed()
1519 if (sta->deflink.he_cap.has_he) in mt7915_mcu_add_rate_ctrl_fixed()
1531 if (mask->control[band].he_ltf != GENMASK(7, 0)) { in mt7915_mcu_add_rate_ctrl_fixed()
1545 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_sta_rate_ctrl_tlv()
1546 struct mt76_phy *mphy = mvif->phy->mt76; in mt7915_mcu_sta_rate_ctrl_tlv()
1547 struct cfg80211_chan_def *chandef = &mphy->chandef; in mt7915_mcu_sta_rate_ctrl_tlv()
1548 struct cfg80211_bitrate_mask *mask = &mvif->bitrate_mask; in mt7915_mcu_sta_rate_ctrl_tlv()
1549 enum nl80211_band band = chandef->chan->band; in mt7915_mcu_sta_rate_ctrl_tlv()
1552 u32 supp_rate = sta->deflink.supp_rates[band]; in mt7915_mcu_sta_rate_ctrl_tlv()
1553 u32 cap = sta->wme ? STA_CAP_WMM : 0; in mt7915_mcu_sta_rate_ctrl_tlv()
1558 ra->valid = true; in mt7915_mcu_sta_rate_ctrl_tlv()
1559 ra->auto_rate = true; in mt7915_mcu_sta_rate_ctrl_tlv()
1560 ra->phy_mode = mt76_connac_get_phy_mode(mphy, vif, band, &sta->deflink); in mt7915_mcu_sta_rate_ctrl_tlv()
1561 ra->channel = chandef->chan->hw_value; in mt7915_mcu_sta_rate_ctrl_tlv()
1562 ra->bw = sta->deflink.bandwidth; in mt7915_mcu_sta_rate_ctrl_tlv()
1563 ra->phy.bw = sta->deflink.bandwidth; in mt7915_mcu_sta_rate_ctrl_tlv()
1564 ra->mmps_mode = mt7915_mcu_get_mmps_mode(sta->deflink.smps_mode); in mt7915_mcu_sta_rate_ctrl_tlv()
1567 supp_rate &= mask->control[band].legacy; in mt7915_mcu_sta_rate_ctrl_tlv()
1568 ra->rate_len = hweight32(supp_rate); in mt7915_mcu_sta_rate_ctrl_tlv()
1571 ra->supp_mode = MODE_CCK; in mt7915_mcu_sta_rate_ctrl_tlv()
1572 ra->supp_cck_rate = supp_rate & GENMASK(3, 0); in mt7915_mcu_sta_rate_ctrl_tlv()
1574 if (ra->rate_len > 4) { in mt7915_mcu_sta_rate_ctrl_tlv()
1575 ra->supp_mode |= MODE_OFDM; in mt7915_mcu_sta_rate_ctrl_tlv()
1576 ra->supp_ofdm_rate = supp_rate >> 4; in mt7915_mcu_sta_rate_ctrl_tlv()
1579 ra->supp_mode = MODE_OFDM; in mt7915_mcu_sta_rate_ctrl_tlv()
1580 ra->supp_ofdm_rate = supp_rate; in mt7915_mcu_sta_rate_ctrl_tlv()
1584 if (sta->deflink.ht_cap.ht_supported) { in mt7915_mcu_sta_rate_ctrl_tlv()
1585 ra->supp_mode |= MODE_HT; in mt7915_mcu_sta_rate_ctrl_tlv()
1586 ra->af = sta->deflink.ht_cap.ampdu_factor; in mt7915_mcu_sta_rate_ctrl_tlv()
1587 ra->ht_gf = !!(sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD); in mt7915_mcu_sta_rate_ctrl_tlv()
1590 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SGI_20) in mt7915_mcu_sta_rate_ctrl_tlv()
1592 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SGI_40) in mt7915_mcu_sta_rate_ctrl_tlv()
1594 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_TX_STBC) in mt7915_mcu_sta_rate_ctrl_tlv()
1596 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_RX_STBC) in mt7915_mcu_sta_rate_ctrl_tlv()
1598 if (mvif->cap.ht_ldpc && in mt7915_mcu_sta_rate_ctrl_tlv()
1599 (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING)) in mt7915_mcu_sta_rate_ctrl_tlv()
1602 mt7915_mcu_set_sta_ht_mcs(sta, ra->ht_mcs, in mt7915_mcu_sta_rate_ctrl_tlv()
1603 mask->control[band].ht_mcs); in mt7915_mcu_sta_rate_ctrl_tlv()
1604 ra->supp_ht_mcs = *(__le32 *)ra->ht_mcs; in mt7915_mcu_sta_rate_ctrl_tlv()
1607 if (sta->deflink.vht_cap.vht_supported) { in mt7915_mcu_sta_rate_ctrl_tlv()
1610 ra->supp_mode |= MODE_VHT; in mt7915_mcu_sta_rate_ctrl_tlv()
1612 sta->deflink.vht_cap.cap); in mt7915_mcu_sta_rate_ctrl_tlv()
1613 ra->af = max_t(u8, ra->af, af); in mt7915_mcu_sta_rate_ctrl_tlv()
1616 if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80) in mt7915_mcu_sta_rate_ctrl_tlv()
1618 if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_160) in mt7915_mcu_sta_rate_ctrl_tlv()
1620 if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_TXSTBC) in mt7915_mcu_sta_rate_ctrl_tlv()
1622 if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXSTBC_1) in mt7915_mcu_sta_rate_ctrl_tlv()
1624 if (mvif->cap.vht_ldpc && in mt7915_mcu_sta_rate_ctrl_tlv()
1625 (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC)) in mt7915_mcu_sta_rate_ctrl_tlv()
1628 mt7915_mcu_set_sta_vht_mcs(sta, ra->supp_vht_mcs, in mt7915_mcu_sta_rate_ctrl_tlv()
1629 mask->control[band].vht_mcs); in mt7915_mcu_sta_rate_ctrl_tlv()
1632 if (sta->deflink.he_cap.has_he) { in mt7915_mcu_sta_rate_ctrl_tlv()
1633 ra->supp_mode |= MODE_HE; in mt7915_mcu_sta_rate_ctrl_tlv()
1636 if (sta->deflink.he_6ghz_capa.capa) in mt7915_mcu_sta_rate_ctrl_tlv()
1637 ra->af = le16_get_bits(sta->deflink.he_6ghz_capa.capa, in mt7915_mcu_sta_rate_ctrl_tlv()
1641 ra->sta_cap = cpu_to_le32(cap); in mt7915_mcu_sta_rate_ctrl_tlv()
1647 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_rate_ctrl()
1648 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_add_rate_ctrl()
1652 skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, in mt7915_mcu_add_rate_ctrl()
1653 &msta->wcid); in mt7915_mcu_add_rate_ctrl()
1658 * once dev->rc_work changes the settings driver should also in mt7915_mcu_add_rate_ctrl()
1665 * i.e 0-{7,8,9} for VHT. in mt7915_mcu_add_rate_ctrl()
1669 ret = mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7915_mcu_add_rate_ctrl()
1686 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_group()
1693 u8 rsv0[5]; in mt7915_mcu_add_group()
1698 .val = cpu_to_le32(mvif->mt76.idx % 16), in mt7915_mcu_add_group()
1701 msta = sta ? (struct mt7915_sta *)sta->drv_priv : &mvif->sta; in mt7915_mcu_add_group()
1702 req.wlan_idx_lo = to_wcid_lo(msta->wcid.idx); in mt7915_mcu_add_group()
1703 req.wlan_idx_hi = to_wcid_hi(msta->wcid.idx); in mt7915_mcu_add_group()
1705 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_DRR_CTRL), &req, in mt7915_mcu_add_group()
1712 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_sta()
1718 msta = sta ? (struct mt7915_sta *)sta->drv_priv : &mvif->sta; in mt7915_mcu_add_sta()
1719 link_sta = sta ? &sta->deflink : NULL; in mt7915_mcu_add_sta()
1721 skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, in mt7915_mcu_add_sta()
1722 &msta->wcid); in mt7915_mcu_add_sta()
1727 mt76_connac_mcu_sta_basic_tlv(&dev->mt76, skb, &vif->bss_conf, link_sta, in mt7915_mcu_add_sta()
1769 ret = mt76_connac_mcu_sta_wed_update(&dev->mt76, skb); in mt7915_mcu_add_sta()
1773 return mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7915_mcu_add_sta()
1780 struct mtk_wed_device *wed = &dev->mt76.mmio.wed; in mt7915_mcu_wed_enable_rx_stats()
1798 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_add_dev_info()
1799 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_dev_info()
1817 .omac_idx = mvif->mt76.omac_idx, in mt7915_mcu_add_dev_info()
1818 .band_idx = mvif->mt76.band_idx, in mt7915_mcu_add_dev_info()
1826 .band_idx = mvif->mt76.band_idx, in mt7915_mcu_add_dev_info()
1830 if (mvif->mt76.omac_idx >= REPEATER_BSSID_START) in mt7915_mcu_add_dev_info()
1833 memcpy(data.tlv.omac_addr, vif->addr, ETH_ALEN); in mt7915_mcu_add_dev_info()
1834 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(DEV_INFO_UPDATE), in mt7915_mcu_add_dev_info()
1847 if (!offs->cntdwn_counter_offs[0]) in mt7915_mcu_beacon_cntdwn()
1850 sub_tag = vif->bss_conf.csa_active ? BSS_INFO_BCN_CSA : BSS_INFO_BCN_BCC; in mt7915_mcu_beacon_cntdwn()
1852 &bcn->sub_ntlv, &bcn->len); in mt7915_mcu_beacon_cntdwn()
1854 info->cnt = skb->data[offs->cntdwn_counter_offs[0]]; in mt7915_mcu_beacon_cntdwn()
1866 if (!vif->bss_conf.bssid_indicator) in mt7915_mcu_beacon_mbss()
1870 sizeof(*mbss), &bcn->sub_ntlv, in mt7915_mcu_beacon_mbss()
1871 &bcn->len); in mt7915_mcu_beacon_mbss()
1874 mbss->offset[0] = cpu_to_le16(offs->tim_offset); in mt7915_mcu_beacon_mbss()
1875 mbss->bitmap = cpu_to_le32(1); in mt7915_mcu_beacon_mbss()
1878 &skb->data[offs->mbssid_off], in mt7915_mcu_beacon_mbss()
1879 skb->len - offs->mbssid_off) { in mt7915_mcu_beacon_mbss()
1882 if (elem->datalen < 2) in mt7915_mcu_beacon_mbss()
1885 for_each_element(sub_elem, elem->data + 1, elem->datalen - 1) { in mt7915_mcu_beacon_mbss()
1889 if (sub_elem->id || sub_elem->datalen < 4) in mt7915_mcu_beacon_mbss()
1896 sub_elem->data, in mt7915_mcu_beacon_mbss()
1897 sub_elem->datalen); in mt7915_mcu_beacon_mbss()
1906 if (!idx->bssid_index || idx->bssid_index > 31) in mt7915_mcu_beacon_mbss()
1909 mbss->offset[idx->bssid_index] = in mt7915_mcu_beacon_mbss()
1910 cpu_to_le16(idx_ie - skb->data); in mt7915_mcu_beacon_mbss()
1911 mbss->bitmap |= cpu_to_le32(BIT(idx->bssid_index)); in mt7915_mcu_beacon_mbss()
1922 struct mt76_wcid *wcid = &dev->mt76.global_wcid; in mt7915_mcu_beacon_cont()
1926 int len = sizeof(*cont) + MT_TXD_SIZE + skb->len; in mt7915_mcu_beacon_cont()
1930 len, &bcn->sub_ntlv, &bcn->len); in mt7915_mcu_beacon_cont()
1933 cont->pkt_len = cpu_to_le16(MT_TXD_SIZE + skb->len); in mt7915_mcu_beacon_cont()
1934 cont->tim_ofs = cpu_to_le16(offs->tim_offset); in mt7915_mcu_beacon_cont()
1936 if (offs->cntdwn_counter_offs[0]) { in mt7915_mcu_beacon_cont()
1937 u16 offset = offs->cntdwn_counter_offs[0]; in mt7915_mcu_beacon_cont()
1939 if (vif->bss_conf.csa_active) in mt7915_mcu_beacon_cont()
1940 cont->csa_ofs = cpu_to_le16(offset - 4); in mt7915_mcu_beacon_cont()
1941 if (vif->bss_conf.color_change_active) in mt7915_mcu_beacon_cont()
1942 cont->bcc_ofs = cpu_to_le16(offset - 3); in mt7915_mcu_beacon_cont()
1946 mt7915_mac_write_txwi(&dev->mt76, (__le32 *)buf, skb, wcid, 0, NULL, in mt7915_mcu_beacon_cont()
1948 memcpy(buf + MT_TXD_SIZE, skb->data, skb->len); in mt7915_mcu_beacon_cont()
1959 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_inband_discov()
1960 struct cfg80211_chan_def *chandef = &mvif->phy->mt76->chandef; in mt7915_mcu_add_inband_discov()
1961 enum nl80211_band band = chandef->chan->band; in mt7915_mcu_add_inband_discov()
1962 struct mt76_wcid *wcid = &dev->mt76.global_wcid; in mt7915_mcu_add_inband_discov()
1968 bool ext_phy = phy != &dev->phy; in mt7915_mcu_add_inband_discov()
1972 if (vif->bss_conf.nontransmitted) in mt7915_mcu_add_inband_discov()
1975 rskb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, NULL, in mt7915_mcu_add_inband_discov()
1982 bcn->enable = true; in mt7915_mcu_add_inband_discov()
1985 interval = vif->bss_conf.fils_discovery.max_interval; in mt7915_mcu_add_inband_discov()
1988 vif->bss_conf.unsol_bcast_probe_resp_interval) { in mt7915_mcu_add_inband_discov()
1989 interval = vif->bss_conf.unsol_bcast_probe_resp_interval; in mt7915_mcu_add_inband_discov()
1995 return -EINVAL; in mt7915_mcu_add_inband_discov()
1999 info->control.vif = vif; in mt7915_mcu_add_inband_discov()
2000 info->band = band; in mt7915_mcu_add_inband_discov()
2001 info->hw_queue |= FIELD_PREP(MT_TX_HW_QUEUE_PHY, ext_phy); in mt7915_mcu_add_inband_discov()
2003 len = sizeof(*discov) + MT_TXD_SIZE + skb->len; in mt7915_mcu_add_inband_discov()
2006 if (skb->len > MT7915_MAX_BEACON_SIZE) { in mt7915_mcu_add_inband_discov()
2007 dev_err(dev->mt76.dev, "inband discovery size limit exceed\n"); in mt7915_mcu_add_inband_discov()
2010 return -EINVAL; in mt7915_mcu_add_inband_discov()
2014 len, &bcn->sub_ntlv, &bcn->len); in mt7915_mcu_add_inband_discov()
2016 discov->tx_mode = OFFLOAD_TX_MODE_SU; in mt7915_mcu_add_inband_discov()
2018 discov->tx_type = !!(changed & BSS_CHANGED_FILS_DISCOVERY); in mt7915_mcu_add_inband_discov()
2019 discov->tx_interval = interval; in mt7915_mcu_add_inband_discov()
2020 discov->prob_rsp_len = cpu_to_le16(MT_TXD_SIZE + skb->len); in mt7915_mcu_add_inband_discov()
2021 discov->enable = !!interval; in mt7915_mcu_add_inband_discov()
2025 mt7915_mac_write_txwi(&dev->mt76, (__le32 *)buf, skb, wcid, 0, NULL, in mt7915_mcu_add_inband_discov()
2027 memcpy(buf + MT_TXD_SIZE, skb->data, skb->len); in mt7915_mcu_add_inband_discov()
2031 return mt76_mcu_skb_send_msg(&phy->dev->mt76, rskb, in mt7915_mcu_add_inband_discov()
2040 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_add_beacon()
2047 bool ext_phy = phy != &dev->phy; in mt7915_mcu_add_beacon()
2049 if (vif->bss_conf.nontransmitted) in mt7915_mcu_add_beacon()
2052 rskb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, in mt7915_mcu_add_beacon()
2059 bcn->enable = en; in mt7915_mcu_add_beacon()
2067 return -EINVAL; in mt7915_mcu_add_beacon()
2070 if (skb->len > MT7915_MAX_BEACON_SIZE) { in mt7915_mcu_add_beacon()
2071 dev_err(dev->mt76.dev, "Bcn size limit exceed\n"); in mt7915_mcu_add_beacon()
2074 return -EINVAL; in mt7915_mcu_add_beacon()
2078 info->hw_queue = FIELD_PREP(MT_TX_HW_QUEUE_PHY, ext_phy); in mt7915_mcu_add_beacon()
2086 return mt76_mcu_skb_send_msg(&phy->dev->mt76, rskb, in mt7915_mcu_add_beacon()
2095 dev_err(dev->mt76.dev, "Timeout for driver own\n"); in mt7915_driver_own()
2096 return -EIO; in mt7915_driver_own()
2114 dev_err(dev->mt76.dev, "Timeout for initializing firmware\n"); in mt7915_firmware_state()
2115 return -EIO; in mt7915_firmware_state()
2125 ret = mt76_connac_mcu_patch_sem_ctrl(&dev->mt76, false); in mt7915_load_firmware()
2127 dev_err(dev->mt76.dev, "Could not release semaphore\n"); in mt7915_load_firmware()
2132 mt76_connac_mcu_restart(&dev->mt76); in mt7915_load_firmware()
2137 dev_err(dev->mt76.dev, "Firmware did not enter download state\n"); in mt7915_load_firmware()
2141 ret = mt76_connac2_load_patch(&dev->mt76, fw_name_var(dev, ROM_PATCH)); in mt7915_load_firmware()
2145 ret = mt76_connac2_load_ram(&dev->mt76, fw_name_var(dev, FIRMWARE_WM), in mt7915_load_firmware()
2154 mt76_queue_tx_cleanup(dev, dev->mt76.q_mcu[MT_MCUQ_FWDL], false); in mt7915_load_firmware()
2156 dev_dbg(dev->mt76.dev, "Firmware init done\n"); in mt7915_load_firmware()
2171 return mt76_mcu_send_msg(&dev->mt76, MCU_WA_EXT_CMD(FW_LOG_2_HOST), in mt7915_mcu_fw_log_2_host()
2174 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(FW_LOG_2_HOST), &data, in mt7915_mcu_fw_log_2_host()
2192 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(FW_DBG_CTRL), &data, in mt7915_mcu_fw_dbg_ctrl()
2206 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(MURU_CTRL), &data, in mt7915_mcu_muru_debug_set()
2212 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_muru_debug_get()
2222 .band_idx = phy->mt76->band_idx, in mt7915_mcu_muru_debug_get()
2225 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(MURU_CTRL), in mt7915_mcu_muru_debug_get()
2230 mu_stats = (struct mt7915_mcu_muru_stats *)(skb->data); in mt7915_mcu_muru_debug_get()
2232 /* accumulate stats, these are clear-on-read */ in mt7915_mcu_muru_debug_get()
2233 #define __dl_u32(s) phy->mib.dl_##s += le32_to_cpu(mu_stats->dl.s) in mt7915_mcu_muru_debug_get()
2234 #define __ul_u32(s) phy->mib.ul_##s += le32_to_cpu(mu_stats->ul.s) in mt7915_mcu_muru_debug_get()
2281 return mt76_mcu_send_msg(&dev->mt76, MCU_WA_EXT_CMD(MWDS_SUPPORT), &req, in mt7915_mcu_set_mwds()
2296 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(MURU_CTRL), &req, in mt7915_mcu_set_muru_ctrl()
2328 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RX_AIRTIME_CTRL), &req, in mt7915_mcu_init_rx_airtime()
2337 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RX_AIRTIME_CTRL), &req, in mt7915_mcu_init_rx_airtime()
2356 .len = cpu_to_le16(sizeof(req) - sizeof(req.args)), in mt7915_red_set_watermark()
2357 .high_mark = cpu_to_le16(MT7915_HW_TOKEN_SIZE - 256), in mt7915_red_set_watermark()
2358 .low_mark = cpu_to_le16(MT7915_HW_TOKEN_SIZE - 256 - 1536), in mt7915_red_set_watermark()
2361 return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req, in mt7915_red_set_watermark()
2379 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req, in mt7915_mcu_set_red()
2401 if (dev->hif2) { in mt7915_mcu_init_firmware()
2411 set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); in mt7915_mcu_init_firmware()
2420 mt76_connac_mcu_del_wtbl_all(&dev->mt76); in mt7915_mcu_init_firmware()
2422 if ((mtk_wed_device_active(&dev->mt76.mmio.wed) && in mt7915_mcu_init_firmware()
2423 is_mt7915(&dev->mt76)) || in mt7915_mcu_init_firmware()
2424 !mtk_wed_get_rx_capa(&dev->mt76.mmio.wed)) in mt7915_mcu_init_firmware()
2440 return mt7915_mcu_set_red(dev, mtk_wed_device_active(&dev->mt76.mmio.wed)); in mt7915_mcu_init_firmware()
2453 dev->mt76.mcu_ops = &mt7915_mcu_ops; in mt7915_mcu_init()
2460 mt76_connac_mcu_restart(&dev->mt76); in mt7915_mcu_exit()
2462 dev_err(dev->mt76.dev, "Failed to exit mcu\n"); in mt7915_mcu_exit()
2467 if (dev->hif2) in mt7915_mcu_exit()
2471 skb_queue_purge(&dev->mt76.mcu.res_q); in mt7915_mcu_exit()
2491 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RX_HDR_TRANS), in mt7915_mcu_set_rx_hdr_trans_blacklist()
2520 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RX_HDR_TRANS), in mt7915_mcu_set_mac()
2528 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(MAC_INIT_CTRL), in mt7915_mcu_set_mac()
2535 u8 num = req->total; in mt7915_mcu_update_edca()
2536 size_t len = sizeof(*req) - in mt7915_mcu_update_edca()
2537 (IEEE80211_NUM_ACS - num) * sizeof(struct edca); in mt7915_mcu_update_edca()
2539 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(EDCA_UPDATE), req, in mt7915_mcu_update_edca()
2551 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_set_tx()
2555 struct ieee80211_tx_queue_params *q = &mvif->queue_params[ac]; in mt7915_mcu_set_tx()
2558 e->set = WMM_PARAM_SET; in mt7915_mcu_set_tx()
2559 e->queue = ac + mvif->mt76.wmm_idx * MT76_CONNAC_MAX_WMM_SETS; in mt7915_mcu_set_tx()
2560 e->aifs = q->aifs; in mt7915_mcu_set_tx()
2561 e->txop = cpu_to_le16(q->txop); in mt7915_mcu_set_tx()
2563 if (q->cw_min) in mt7915_mcu_set_tx()
2564 e->cw_min = fls(q->cw_min); in mt7915_mcu_set_tx()
2566 e->cw_min = 5; in mt7915_mcu_set_tx()
2568 if (q->cw_max) in mt7915_mcu_set_tx()
2569 e->cw_max = cpu_to_le16(fls(q->cw_max)); in mt7915_mcu_set_tx()
2571 e->cw_max = cpu_to_le16(10); in mt7915_mcu_set_tx()
2588 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_RDD_TH), &req, in mt7915_mcu_set_fcc5_lpn()
2608 #define __req_field(field) .field = cpu_to_le32(pulse->field) in mt7915_mcu_set_pulse_th()
2619 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_RDD_TH), &req, in mt7915_mcu_set_pulse_th()
2650 #define __req_field_u8(field) .field = pattern->field in mt7915_mcu_set_radar_th()
2651 #define __req_field_u32(field) .field = cpu_to_le32(pattern->field) in mt7915_mcu_set_radar_th()
2671 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_RDD_TH), &req, in mt7915_mcu_set_radar_th()
2680 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_background_chain_ctrl()
2681 struct mt76_phy *mphy = phy->mt76; in mt7915_mcu_background_chain_ctrl()
2682 struct ieee80211_channel *chan = mphy->chandef.chan; in mt7915_mcu_background_chain_ctrl()
2683 int freq = mphy->chandef.center_freq1; in mt7915_mcu_background_chain_ctrl()
2689 return -EINVAL; in mt7915_mcu_background_chain_ctrl()
2691 if (!cfg80211_chandef_valid(&mphy->chandef)) in mt7915_mcu_background_chain_ctrl()
2692 return -EINVAL; in mt7915_mcu_background_chain_ctrl()
2696 req.chan = chan->hw_value; in mt7915_mcu_background_chain_ctrl()
2698 req.bw = mt76_connac_chan_bw(&mphy->chandef); in mt7915_mcu_background_chain_ctrl()
2699 req.monitor_chan = chandef->chan->hw_value; in mt7915_mcu_background_chain_ctrl()
2701 ieee80211_frequency_to_channel(chandef->center_freq1); in mt7915_mcu_background_chain_ctrl()
2703 req.band_idx = phy->mt76->band_idx; in mt7915_mcu_background_chain_ctrl()
2708 req.monitor_chan = chandef->chan->hw_value; in mt7915_mcu_background_chain_ctrl()
2710 ieee80211_frequency_to_channel(chandef->center_freq1); in mt7915_mcu_background_chain_ctrl()
2711 req.band_idx = phy->mt76->band_idx; in mt7915_mcu_background_chain_ctrl()
2715 req.chan = chan->hw_value; in mt7915_mcu_background_chain_ctrl()
2717 req.bw = mt76_connac_chan_bw(&mphy->chandef); in mt7915_mcu_background_chain_ctrl()
2718 req.tx_stream = hweight8(mphy->antenna_mask); in mt7915_mcu_background_chain_ctrl()
2719 req.rx_stream = mphy->antenna_mask; in mt7915_mcu_background_chain_ctrl()
2722 return -EINVAL; in mt7915_mcu_background_chain_ctrl()
2724 req.band = chandef ? chandef->chan->band == NL80211_BAND_5GHZ : 1; in mt7915_mcu_background_chain_ctrl()
2726 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(OFFCH_SCAN_CTRL), in mt7915_mcu_background_chain_ctrl()
2733 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_rdd_background_enable()
2738 return -EINVAL; in mt7915_mcu_rdd_background_enable()
2741 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_STOP, rdd_idx, 0, 0); in mt7915_mcu_rdd_background_enable()
2754 switch (dev->mt76.region) { in mt7915_mcu_rdd_background_enable()
2767 return mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_START, rdd_idx, 0, region); in mt7915_mcu_rdd_background_enable()
2777 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_chan_info()
2778 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7915_mcu_set_chan_info()
2779 int freq1 = chandef->center_freq1; in mt7915_mcu_set_chan_info()
2780 u8 band = phy->mt76->band_idx; in mt7915_mcu_set_chan_info()
2799 .control_ch = chandef->chan->hw_value, in mt7915_mcu_set_chan_info()
2802 .tx_path_num = hweight16(phy->mt76->chainmask), in mt7915_mcu_set_chan_info()
2803 .rx_path = phy->mt76->chainmask >> (dev->chainshift * band), in mt7915_mcu_set_chan_info()
2805 .channel_band = ch_band[chandef->chan->band], in mt7915_mcu_set_chan_info()
2809 if (phy->mt76->test.tx_antenna_mask && in mt7915_mcu_set_chan_info()
2810 mt76_testmode_enabled(phy->mt76)) { in mt7915_mcu_set_chan_info()
2811 req.tx_path_num = fls(phy->mt76->test.tx_antenna_mask); in mt7915_mcu_set_chan_info()
2812 req.rx_path = phy->mt76->test.tx_antenna_mask; in mt7915_mcu_set_chan_info()
2816 if (mt76_connac_spe_idx(phy->mt76->antenna_mask)) in mt7915_mcu_set_chan_info()
2817 req.tx_path_num = fls(phy->mt76->antenna_mask); in mt7915_mcu_set_chan_info()
2819 if (phy->mt76->hw->conf.flags & IEEE80211_CONF_MONITOR) in mt7915_mcu_set_chan_info()
2821 else if (phy->mt76->offchannel || in mt7915_mcu_set_chan_info()
2822 phy->mt76->hw->conf.flags & IEEE80211_CONF_IDLE) in mt7915_mcu_set_chan_info()
2824 else if (!cfg80211_reg_can_beacon(phy->mt76->hw->wiphy, chandef, in mt7915_mcu_set_chan_info()
2833 if (chandef->width == NL80211_CHAN_WIDTH_80P80) { in mt7915_mcu_set_chan_info()
2834 int freq2 = chandef->center_freq2; in mt7915_mcu_set_chan_info()
2839 return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), true); in mt7915_mcu_set_chan_info()
2844 #define MAX_PAGE_IDX_MASK GENMASK(7, 5) in mt7915_mcu_set_eeprom_flash()
2850 u8 *eep = (u8 *)dev->mt76.eeprom.data; in mt7915_mcu_set_eeprom_flash()
2858 if (i == total - 1 && !!(eeprom_size % PER_PAGE_SIZE)) in mt7915_mcu_set_eeprom_flash()
2863 skb = mt76_mcu_msg_alloc(&dev->mt76, NULL, in mt7915_mcu_set_eeprom_flash()
2866 return -ENOMEM; in mt7915_mcu_set_eeprom_flash()
2868 req.format = FIELD_PREP(MAX_PAGE_IDX_MASK, total - 1) | in mt7915_mcu_set_eeprom_flash()
2875 ret = mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7915_mcu_set_eeprom_flash()
2891 if (dev->flash_mode) in mt7915_mcu_set_eeprom()
2894 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(EFUSE_BUFFER_MODE), in mt7915_mcu_set_eeprom()
2909 ret = mt76_mcu_send_and_get_msg(&dev->mt76, in mt7915_mcu_get_eeprom()
2915 res = (struct mt7915_mcu_eeprom_info *)skb->data; in mt7915_mcu_get_eeprom()
2918 buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr); in mt7915_mcu_get_eeprom()
2920 buf = (u8 *)dev->mt76.eeprom.data + le32_to_cpu(res->addr); in mt7915_mcu_get_eeprom()
2922 memcpy(buf, res->data, MT7915_EEPROM_BLOCK_SIZE); in mt7915_mcu_get_eeprom()
2942 ret = mt76_mcu_send_and_get_msg(&dev->mt76, in mt7915_mcu_get_eeprom_free_block()
2948 *block_num = *(u8 *)skb->data; in mt7915_mcu_get_eeprom_free_block()
2970 skb = mt76_mcu_msg_alloc(&dev->mt76, NULL, sizeof(req) + len); in mt7915_mcu_set_pre_cal()
2972 return -ENOMEM; in mt7915_mcu_set_pre_cal()
2979 return mt76_mcu_skb_send_msg(&dev->mt76, skb, cmd, false); in mt7915_mcu_set_pre_cal()
2984 u8 idx = 0, *cal = dev->cal, *eep = dev->mt76.eeprom.data; in mt7915_mcu_apply_group_cal()
2986 u32 offs = is_mt7915(&dev->mt76) ? MT_EE_DO_PRE_CAL : MT_EE_DO_PRE_CAL_V2; in mt7915_mcu_apply_group_cal()
3005 total -= len; in mt7915_mcu_apply_group_cal()
3021 return -1; in mt7915_find_freq_idx()
3035 /* 6G BW20*/ in mt7915_dpd_freq_idx()
3051 /* 6G BW160 */ in mt7915_dpd_freq_idx()
3054 /* 5G BW20 */ in mt7915_dpd_freq_idx()
3062 /* 5G BW160 */ in mt7915_dpd_freq_idx()
3066 /* 5G BW20 */ in mt7915_dpd_freq_idx()
3074 /* 5G BW160 */ in mt7915_dpd_freq_idx()
3081 if (!is_mt7915(&dev->mt76)) { in mt7915_dpd_freq_idx()
3082 if (is_mt7981(&dev->mt76)) { in mt7915_dpd_freq_idx()
3101 return -1; in mt7915_dpd_freq_idx()
3108 idx = mt7915_find_freq_idx(freq_list, n_freqs, freq - 10); in mt7915_dpd_freq_idx()
3118 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_apply_tx_dpd()
3119 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7915_mcu_apply_tx_dpd()
3120 enum nl80211_band band = chandef->chan->band; in mt7915_mcu_apply_tx_dpd()
3121 u32 offs = is_mt7915(&dev->mt76) ? MT_EE_DO_PRE_CAL : MT_EE_DO_PRE_CAL_V2; in mt7915_mcu_apply_tx_dpd()
3122 u16 center_freq = chandef->center_freq1; in mt7915_mcu_apply_tx_dpd()
3123 u8 *cal = dev->cal, *eep = dev->mt76.eeprom.data; in mt7915_mcu_apply_tx_dpd()
3124 u8 dpd_mask, cal_num = is_mt7915(&dev->mt76) ? 2 : 3; in mt7915_mcu_apply_tx_dpd()
3145 idx = mt7915_dpd_freq_idx(dev, center_freq, chandef->width); in mt7915_mcu_apply_tx_dpd()
3147 return -EINVAL; in mt7915_mcu_apply_tx_dpd()
3153 while (cal_num--) { in mt7915_mcu_apply_tx_dpd()
3170 struct mt76_channel_state *state = phy->mt76->chan_state; in mt7915_mcu_get_chan_mib_info()
3171 struct mt76_channel_state *state_ts = &phy->state_ts; in mt7915_mcu_get_chan_mib_info()
3172 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_get_chan_mib_info()
3173 struct mt7915_mcu_mib *res, req[5]; in mt7915_mcu_get_chan_mib_info()
3180 if (is_mt7915(&dev->mt76)) { in mt7915_mcu_get_chan_mib_info()
3204 req[i].band = cpu_to_le32(phy->mt76->band_idx); in mt7915_mcu_get_chan_mib_info()
3208 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(GET_MIB_INFO), in mt7915_mcu_get_chan_mib_info()
3213 res = (struct mt7915_mcu_mib *)(skb->data + offs_cc); in mt7915_mcu_get_chan_mib_info()
3217 if (is_mt7915(&dev->mt76)) { in mt7915_mcu_get_chan_mib_info()
3219 cc_tx = __res_u64(1) - backoff; in mt7915_mcu_get_chan_mib_info()
3227 state->cc_tx += cc_tx - state_ts->cc_tx; in mt7915_mcu_get_chan_mib_info()
3228 state->cc_bss_rx += __res_u64(2) - state_ts->cc_bss_rx; in mt7915_mcu_get_chan_mib_info()
3229 state->cc_rx += __res_u64(2) + __res_u64(3) - state_ts->cc_rx; in mt7915_mcu_get_chan_mib_info()
3230 state->cc_busy += __res_u64(0) + cc_tx + __res_u64(2) + __res_u64(3) - in mt7915_mcu_get_chan_mib_info()
3231 state_ts->cc_busy; in mt7915_mcu_get_chan_mib_info()
3234 state_ts->cc_tx = cc_tx; in mt7915_mcu_get_chan_mib_info()
3235 state_ts->cc_bss_rx = __res_u64(2); in mt7915_mcu_get_chan_mib_info()
3236 state_ts->cc_rx = __res_u64(2) + __res_u64(3); in mt7915_mcu_get_chan_mib_info()
3237 state_ts->cc_busy = __res_u64(0) + cc_tx + __res_u64(2) + __res_u64(3); in mt7915_mcu_get_chan_mib_info()
3247 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_get_temperature()
3252 u8 rsv[5]; in mt7915_mcu_get_temperature()
3255 .band_idx = phy->mt76->band_idx, in mt7915_mcu_get_temperature()
3258 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_CTRL), &req, in mt7915_mcu_get_temperature()
3264 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_thermal_throttling()
3266 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_thermal_throttling()
3277 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_PROT), in mt7915_mcu_set_thermal_throttling()
3287 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_thermal_protect()
3297 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_thermal_protect()
3305 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_PROT), in mt7915_mcu_set_thermal_protect()
3311 /* set high-temperature trigger threshold */ in mt7915_mcu_set_thermal_protect()
3314 req.restore_temp = cpu_to_le32(phy->throttle_temp[0] - 10); in mt7915_mcu_set_thermal_protect()
3315 req.trigger_temp = cpu_to_le32(phy->throttle_temp[1]); in mt7915_mcu_set_thermal_protect()
3318 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_PROT), in mt7915_mcu_set_thermal_protect()
3322 int mt7915_mcu_set_txpower_frame_min(struct mt7915_phy *phy, s8 txpower) in mt7915_mcu_set_txpower_frame_min() argument
3324 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_txpower_frame_min()
3332 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_txpower_frame_min()
3333 .txpower_min = txpower * 2, /* 0.5db */ in mt7915_mcu_set_txpower_frame_min()
3336 return mt76_mcu_send_msg(&dev->mt76, in mt7915_mcu_set_txpower_frame_min()
3343 struct ieee80211_sta *sta, s8 txpower) in mt7915_mcu_set_txpower_frame() argument
3345 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_set_txpower_frame()
3346 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_txpower_frame()
3347 struct mt76_phy *mphy = phy->mt76; in mt7915_mcu_set_txpower_frame()
3357 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_txpower_frame()
3358 .txpower_max = DIV_ROUND_UP(mphy->txpower_cur, 2), in mt7915_mcu_set_txpower_frame()
3359 .wcid = cpu_to_le16(msta->wcid.idx), in mt7915_mcu_set_txpower_frame()
3368 txpower = mt76_get_power_bound(mphy, txpower); in mt7915_mcu_set_txpower_frame()
3369 if (txpower > mphy->txpower_cur || txpower < 0) in mt7915_mcu_set_txpower_frame()
3370 return -EINVAL; in mt7915_mcu_set_txpower_frame()
3372 if (txpower) { in mt7915_mcu_set_txpower_frame()
3375 if (sta->deflink.ht_cap.ht_supported) { in mt7915_mcu_set_txpower_frame()
3381 if (sta->deflink.vht_cap.vht_supported) { in mt7915_mcu_set_txpower_frame()
3385 if (sta->deflink.he_cap.has_he) { in mt7915_mcu_set_txpower_frame()
3391 return -EINVAL; in mt7915_mcu_set_txpower_frame()
3396 DIV_ROUND_UP(txpower - txpower_sku[offs], 2); in mt7915_mcu_set_txpower_frame()
3399 return mt76_mcu_send_msg(&dev->mt76, in mt7915_mcu_set_txpower_frame()
3406 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_txpower_sku()
3407 struct mt76_phy *mphy = phy->mt76; in mt7915_mcu_set_txpower_sku()
3408 struct ieee80211_hw *hw = mphy->hw; in mt7915_mcu_set_txpower_sku()
3411 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_txpower_sku()
3418 tx_power = mt76_get_power_bound(mphy, hw->conf.power_level); in mt7915_mcu_set_txpower_sku()
3419 tx_power = mt76_get_rate_power_limits(mphy, mphy->chandef.chan, in mt7915_mcu_set_txpower_sku()
3421 mphy->txpower_cur = tx_power; in mt7915_mcu_set_txpower_sku()
3443 return mt76_mcu_send_msg(&dev->mt76, in mt7915_mcu_set_txpower_sku()
3448 int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len) in mt7915_mcu_get_txpower_sku() argument
3451 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_get_txpower_sku()
3460 .band_idx = phy->mt76->band_idx, in mt7915_mcu_get_txpower_sku()
3466 ret = mt76_mcu_send_and_get_msg(&dev->mt76, in mt7915_mcu_get_txpower_sku()
3472 memcpy(txpower_sku, skb->data + 4, sizeof(txpower_sku)); in mt7915_mcu_get_txpower_sku()
3474 txpower[i] = txpower_sku[i][req.band_idx]; in mt7915_mcu_get_txpower_sku()
3499 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req, in mt7915_mcu_set_test_param()
3505 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_sku_en()
3513 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_sku_en()
3517 return mt76_mcu_send_msg(&dev->mt76, in mt7915_mcu_set_sku_en()
3535 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_SER_TRIGGER), in mt7915_mcu_set_ser()
3560 u8 rsv[5]; in mt7915_mcu_set_txbf()
3574 req.type.ibf = dev->ibf; in mt7915_mcu_set_txbf()
3581 return -EINVAL; in mt7915_mcu_set_txbf()
3584 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TXBF_ACTION), &req, in mt7915_mcu_set_txbf()
3591 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_enable_obss_spr()
3595 .band_idx = phy->mt76->band_idx, in mt7915_mcu_enable_obss_spr()
3599 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_SPR), &req, in mt7915_mcu_enable_obss_spr()
3607 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_obss_spr_pd()
3626 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_obss_spr_pd()
3637 if (he_obss_pd->sr_ctrl & in mt7915_mcu_set_obss_spr_pd()
3640 else if (he_obss_pd->sr_ctrl & IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT) in mt7915_mcu_set_obss_spr_pd()
3641 req.param.pd_th_non_srg = max_th - he_obss_pd->non_srg_max_offset; in mt7915_mcu_set_obss_spr_pd()
3645 if (he_obss_pd->sr_ctrl & IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT) in mt7915_mcu_set_obss_spr_pd()
3646 req.param.pd_th_srg = max_th - he_obss_pd->max_offset; in mt7915_mcu_set_obss_spr_pd()
3653 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_SPR), &req, in mt7915_mcu_set_obss_spr_pd()
3661 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_set_obss_spr_siga()
3662 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_obss_spr_siga()
3663 u8 omac = mvif->mt76.omac_idx; in mt7915_mcu_set_obss_spr_siga()
3675 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_obss_spr_siga()
3678 .omac = omac > HW_BSSID_MAX ? omac - 12 : omac, in mt7915_mcu_set_obss_spr_siga()
3683 if (he_obss_pd->sr_ctrl & IEEE80211_HE_SPR_HESIGA_SR_VAL15_ALLOWED) in mt7915_mcu_set_obss_spr_siga()
3693 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_SPR), &req, in mt7915_mcu_set_obss_spr_siga()
3701 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_set_obss_spr_bitmap()
3714 .band_idx = phy->mt76->band_idx, in mt7915_mcu_set_obss_spr_bitmap()
3719 memcpy(&bitmap, he_obss_pd->bss_color_bitmap, sizeof(bitmap)); in mt7915_mcu_set_obss_spr_bitmap()
3722 memcpy(&bitmap, he_obss_pd->bss_color_bitmap + 4, sizeof(bitmap)); in mt7915_mcu_set_obss_spr_bitmap()
3725 memcpy(&bitmap, he_obss_pd->partial_bssid_bitmap, sizeof(bitmap)); in mt7915_mcu_set_obss_spr_bitmap()
3728 memcpy(&bitmap, he_obss_pd->partial_bssid_bitmap + 4, sizeof(bitmap)); in mt7915_mcu_set_obss_spr_bitmap()
3731 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_SPR), &req, in mt7915_mcu_set_obss_spr_bitmap()
3746 if (sr_scene_detect && !he_obss_pd->enable) in mt7915_mcu_add_obss_spr()
3750 ret = mt7915_mcu_enable_obss_spr(phy, SPR_ENABLE, he_obss_pd->enable); in mt7915_mcu_add_obss_spr()
3754 if (sr_scene_detect || !he_obss_pd->enable) in mt7915_mcu_add_obss_spr()
3761 /* set SRG/non-SRG OBSS PD threshold */ in mt7915_mcu_add_obss_spr()
3778 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_get_rx_rate()
3779 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mcu_get_rx_rate()
3780 struct mt7915_dev *dev = phy->dev; in mt7915_mcu_get_rx_rate()
3781 struct mt76_phy *mphy = phy->mt76; in mt7915_mcu_get_rx_rate()
3788 .band = mvif->mt76.band_idx, in mt7915_mcu_get_rx_rate()
3789 .wcid = cpu_to_le16(msta->wcid.idx), in mt7915_mcu_get_rx_rate()
3797 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(PHY_STAT_INFO), in mt7915_mcu_get_rx_rate()
3802 res = (struct mt7915_mcu_phy_rx_info *)skb->data; in mt7915_mcu_get_rx_rate()
3804 rate->mcs = res->rate; in mt7915_mcu_get_rx_rate()
3805 rate->nss = res->nsts + 1; in mt7915_mcu_get_rx_rate()
3807 switch (res->mode) { in mt7915_mcu_get_rx_rate()
3812 if (mphy->chandef.chan->band == NL80211_BAND_5GHZ) in mt7915_mcu_get_rx_rate()
3813 sband = &mphy->sband_5g.sband; in mt7915_mcu_get_rx_rate()
3814 else if (mphy->chandef.chan->band == NL80211_BAND_6GHZ) in mt7915_mcu_get_rx_rate()
3815 sband = &mphy->sband_6g.sband; in mt7915_mcu_get_rx_rate()
3817 sband = &mphy->sband_2g.sband; in mt7915_mcu_get_rx_rate()
3819 rate->mcs = mt76_get_rate(&dev->mt76, sband, rate->mcs, cck); in mt7915_mcu_get_rx_rate()
3820 rate->legacy = sband->bitrates[rate->mcs].bitrate; in mt7915_mcu_get_rx_rate()
3824 if (rate->mcs > 31) { in mt7915_mcu_get_rx_rate()
3825 ret = -EINVAL; in mt7915_mcu_get_rx_rate()
3829 rate->flags = RATE_INFO_FLAGS_MCS; in mt7915_mcu_get_rx_rate()
3830 if (res->gi) in mt7915_mcu_get_rx_rate()
3831 rate->flags |= RATE_INFO_FLAGS_SHORT_GI; in mt7915_mcu_get_rx_rate()
3834 if (rate->mcs > 9) { in mt7915_mcu_get_rx_rate()
3835 ret = -EINVAL; in mt7915_mcu_get_rx_rate()
3839 rate->flags = RATE_INFO_FLAGS_VHT_MCS; in mt7915_mcu_get_rx_rate()
3840 if (res->gi) in mt7915_mcu_get_rx_rate()
3841 rate->flags |= RATE_INFO_FLAGS_SHORT_GI; in mt7915_mcu_get_rx_rate()
3847 if (res->gi > NL80211_RATE_INFO_HE_GI_3_2 || rate->mcs > 11) { in mt7915_mcu_get_rx_rate()
3848 ret = -EINVAL; in mt7915_mcu_get_rx_rate()
3851 rate->he_gi = res->gi; in mt7915_mcu_get_rx_rate()
3852 rate->flags = RATE_INFO_FLAGS_HE_MCS; in mt7915_mcu_get_rx_rate()
3855 ret = -EINVAL; in mt7915_mcu_get_rx_rate()
3859 switch (res->bw) { in mt7915_mcu_get_rx_rate()
3861 rate->bw = RATE_INFO_BW_160; in mt7915_mcu_get_rx_rate()
3864 rate->bw = RATE_INFO_BW_80; in mt7915_mcu_get_rx_rate()
3867 rate->bw = RATE_INFO_BW_40; in mt7915_mcu_get_rx_rate()
3870 rate->bw = RATE_INFO_BW_20; in mt7915_mcu_get_rx_rate()
3884 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mcu_update_bss_color()
3889 skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, in mt7915_mcu_update_bss_color()
3897 bss_color->disable = !he_bss_color->enabled; in mt7915_mcu_update_bss_color()
3898 bss_color->color = he_bss_color->color; in mt7915_mcu_update_bss_color()
3900 return mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7915_mcu_update_bss_color()
3930 .tbl_idx = flow->table_id, in mt7915_mcu_twt_agrt_update()
3932 .own_mac_idx = mvif->mt76.omac_idx, in mt7915_mcu_twt_agrt_update()
3933 .flowid = flow->id, in mt7915_mcu_twt_agrt_update()
3934 .peer_id = cpu_to_le16(flow->wcid), in mt7915_mcu_twt_agrt_update()
3935 .duration = flow->duration, in mt7915_mcu_twt_agrt_update()
3936 .bss_idx = mvif->mt76.idx, in mt7915_mcu_twt_agrt_update()
3937 .start_tsf = cpu_to_le64(flow->tsf), in mt7915_mcu_twt_agrt_update()
3938 .mantissa = flow->mantissa, in mt7915_mcu_twt_agrt_update()
3939 .exponent = flow->exp, in mt7915_mcu_twt_agrt_update()
3943 if (flow->protection) in mt7915_mcu_twt_agrt_update()
3945 if (!flow->flowtype) in mt7915_mcu_twt_agrt_update()
3947 if (flow->trigger) in mt7915_mcu_twt_agrt_update()
3950 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TWT_AGRT_UPDATE), in mt7915_mcu_twt_agrt_update()
3979 if (is_mt7915(&dev->mt76)) { in mt7915_mcu_wed_wa_tx_stats()
3981 len = sizeof(req) - sizeof(req.arg2); in mt7915_mcu_wed_wa_tx_stats()
3988 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_WA_PARAM_CMD(QUERY), in mt7915_mcu_wed_wa_tx_stats()
3993 if (!is_mt7915(&dev->mt76)) in mt7915_mcu_wed_wa_tx_stats()
3996 res = (struct mt7915_mcu_wa_tx_stat *)skb->data; in mt7915_mcu_wed_wa_tx_stats()
3998 ret_wcid = le16_to_cpu(res->wcid); in mt7915_mcu_wed_wa_tx_stats()
3999 if (is_mt7915(&dev->mt76)) in mt7915_mcu_wed_wa_tx_stats()
4003 ret = -EINVAL; in mt7915_mcu_wed_wa_tx_stats()
4011 wcid->stats.tx_packets += le32_to_cpu(res->tx_packets); in mt7915_mcu_wed_wa_tx_stats()
4013 ret = -EINVAL; in mt7915_mcu_wed_wa_tx_stats()
4037 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RF_REG_ACCESS), in mt7915_mcu_rf_regval()
4040 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_QUERY(RF_REG_ACCESS), in mt7915_mcu_rf_regval()
4045 *val = le32_to_cpu(*(__le32 *)(skb->data + 8)); in mt7915_mcu_rf_regval()