Lines Matching +full:key +full:- +full:enable
1 // SPDX-License-Identifier: ISC
108 struct mt76_dev *dev = phy->dev; in mt76_connac_mcu_set_channel_domain()
112 n_max_channels = phy->sband_2g.sband.n_channels + in mt76_connac_mcu_set_channel_domain()
113 phy->sband_5g.sband.n_channels + in mt76_connac_mcu_set_channel_domain()
114 phy->sband_6g.sband.n_channels; in mt76_connac_mcu_set_channel_domain()
119 return -ENOMEM; in mt76_connac_mcu_set_channel_domain()
123 for (i = 0; i < phy->sband_2g.sband.n_channels; i++) { in mt76_connac_mcu_set_channel_domain()
124 chan = &phy->sband_2g.sband.channels[i]; in mt76_connac_mcu_set_channel_domain()
125 if (chan->flags & IEEE80211_CHAN_DISABLED) in mt76_connac_mcu_set_channel_domain()
128 channel.hw_value = cpu_to_le16(chan->hw_value); in mt76_connac_mcu_set_channel_domain()
129 channel.flags = cpu_to_le32(chan->flags); in mt76_connac_mcu_set_channel_domain()
135 for (i = 0; i < phy->sband_5g.sband.n_channels; i++) { in mt76_connac_mcu_set_channel_domain()
136 chan = &phy->sband_5g.sband.channels[i]; in mt76_connac_mcu_set_channel_domain()
137 if (chan->flags & IEEE80211_CHAN_DISABLED) in mt76_connac_mcu_set_channel_domain()
140 channel.hw_value = cpu_to_le16(chan->hw_value); in mt76_connac_mcu_set_channel_domain()
141 channel.flags = cpu_to_le32(chan->flags); in mt76_connac_mcu_set_channel_domain()
147 for (i = 0; i < phy->sband_6g.sband.n_channels; i++) { in mt76_connac_mcu_set_channel_domain()
148 chan = &phy->sband_6g.sband.channels[i]; in mt76_connac_mcu_set_channel_domain()
149 if (chan->flags & IEEE80211_CHAN_DISABLED) in mt76_connac_mcu_set_channel_domain()
152 channel.hw_value = cpu_to_le16(chan->hw_value); in mt76_connac_mcu_set_channel_domain()
153 channel.flags = cpu_to_le32(chan->flags); in mt76_connac_mcu_set_channel_domain()
160 BUILD_BUG_ON(sizeof(dev->alpha2) > sizeof(hdr.alpha2)); in mt76_connac_mcu_set_channel_domain()
161 memcpy(hdr.alpha2, dev->alpha2, sizeof(dev->alpha2)); in mt76_connac_mcu_set_channel_domain()
173 int mt76_connac_mcu_set_mac_enable(struct mt76_dev *dev, int band, bool enable, in mt76_connac_mcu_set_mac_enable() argument
177 u8 enable; in mt76_connac_mcu_set_mac_enable() member
181 .enable = enable, in mt76_connac_mcu_set_mac_enable()
192 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_set_vif_ps()
200 .bss_idx = mvif->idx, in mt76_connac_mcu_set_vif_ps()
201 .ps_state = vif->cfg.ps ? 2 : 0, in mt76_connac_mcu_set_vif_ps()
204 if (vif->type != NL80211_IFTYPE_STATION) in mt76_connac_mcu_set_vif_ps()
205 return -EOPNOTSUPP; in mt76_connac_mcu_set_vif_ps()
235 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_beacon_loss_iter()
238 if (mvif->idx != event->bss_idx) in mt76_connac_mcu_beacon_loss_iter()
241 if (!(vif->driver_flags & IEEE80211_VIF_BEACON_FILTER)) in mt76_connac_mcu_beacon_loss_iter()
263 ntlv = le16_to_cpu(ntlv_hdr->tlv_num); in mt76_connac_mcu_add_nested_tlv()
264 ntlv_hdr->tlv_num = cpu_to_le16(ntlv + 1); in mt76_connac_mcu_add_nested_tlv()
267 len += le16_to_cpu(sta_hdr->len); in mt76_connac_mcu_add_nested_tlv()
268 sta_hdr->len = cpu_to_le16(len); in mt76_connac_mcu_add_nested_tlv()
280 .bss_idx = mvif->idx, in __mt76_connac_mcu_alloc_sta_req()
281 .muar_idx = wcid ? mvif->omac_idx : 0, in __mt76_connac_mcu_alloc_sta_req()
286 if (wcid && !wcid->sta && !wcid->sta_disabled) in __mt76_connac_mcu_alloc_sta_req()
293 return ERR_PTR(-ENOMEM); in __mt76_connac_mcu_alloc_sta_req()
317 return ERR_PTR(-ENOMEM); in mt76_connac_mcu_alloc_wtbl_req()
323 le16_add_cpu(&sta_hdr->len, sizeof(hdr)); in mt76_connac_mcu_alloc_wtbl_req()
332 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_bss_omac_tlv()
333 u8 omac_idx = mvif->omac_idx; in mt76_connac_mcu_bss_omac_tlv()
338 switch (vif->type) { in mt76_connac_mcu_bss_omac_tlv()
342 if (vif->p2p) in mt76_connac_mcu_bss_omac_tlv()
348 if (vif->p2p) in mt76_connac_mcu_bss_omac_tlv()
364 omac->conn_type = cpu_to_le32(type); in mt76_connac_mcu_bss_omac_tlv()
365 omac->omac_idx = mvif->omac_idx; in mt76_connac_mcu_bss_omac_tlv()
366 omac->band_idx = mvif->band_idx; in mt76_connac_mcu_bss_omac_tlv()
367 omac->hw_bss_idx = omac_idx > EXT_BSSID_START ? HW_BSSID_0 : omac_idx; in mt76_connac_mcu_bss_omac_tlv()
383 basic->extra_info = cpu_to_le16(EXTRA_INFO_VER); in mt76_connac_mcu_sta_basic_tlv()
386 basic->extra_info |= cpu_to_le16(EXTRA_INFO_NEW); in mt76_connac_mcu_sta_basic_tlv()
387 basic->conn_state = conn_state; in mt76_connac_mcu_sta_basic_tlv()
390 basic->conn_type = cpu_to_le32(CONNECTION_INFRA_BC); in mt76_connac_mcu_sta_basic_tlv()
392 if (vif->type == NL80211_IFTYPE_STATION && in mt76_connac_mcu_sta_basic_tlv()
393 !is_zero_ether_addr(vif->bss_conf.bssid)) { in mt76_connac_mcu_sta_basic_tlv()
394 memcpy(basic->peer_addr, vif->bss_conf.bssid, ETH_ALEN); in mt76_connac_mcu_sta_basic_tlv()
395 basic->aid = cpu_to_le16(vif->cfg.aid); in mt76_connac_mcu_sta_basic_tlv()
397 eth_broadcast_addr(basic->peer_addr); in mt76_connac_mcu_sta_basic_tlv()
402 switch (vif->type) { in mt76_connac_mcu_sta_basic_tlv()
405 if (vif->p2p && !is_mt7921(dev)) in mt76_connac_mcu_sta_basic_tlv()
409 basic->conn_type = cpu_to_le32(conn_type); in mt76_connac_mcu_sta_basic_tlv()
410 basic->aid = cpu_to_le16(link_sta->sta->aid); in mt76_connac_mcu_sta_basic_tlv()
413 if (vif->p2p && !is_mt7921(dev)) in mt76_connac_mcu_sta_basic_tlv()
417 basic->conn_type = cpu_to_le32(conn_type); in mt76_connac_mcu_sta_basic_tlv()
418 basic->aid = cpu_to_le16(vif->cfg.aid); in mt76_connac_mcu_sta_basic_tlv()
421 basic->conn_type = cpu_to_le32(CONNECTION_IBSS_ADHOC); in mt76_connac_mcu_sta_basic_tlv()
422 basic->aid = cpu_to_le16(link_sta->sta->aid); in mt76_connac_mcu_sta_basic_tlv()
429 memcpy(basic->peer_addr, link_sta->addr, ETH_ALEN); in mt76_connac_mcu_sta_basic_tlv()
430 basic->qos = link_sta->sta->wme; in mt76_connac_mcu_sta_basic_tlv()
440 if (vif->type != NL80211_IFTYPE_AP || !sta->wme) in mt76_connac_mcu_sta_uapsd()
446 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) { in mt76_connac_mcu_sta_uapsd()
447 uapsd->dac_map |= BIT(3); in mt76_connac_mcu_sta_uapsd()
448 uapsd->tac_map |= BIT(3); in mt76_connac_mcu_sta_uapsd()
450 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI) { in mt76_connac_mcu_sta_uapsd()
451 uapsd->dac_map |= BIT(2); in mt76_connac_mcu_sta_uapsd()
452 uapsd->tac_map |= BIT(2); in mt76_connac_mcu_sta_uapsd()
454 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE) { in mt76_connac_mcu_sta_uapsd()
455 uapsd->dac_map |= BIT(1); in mt76_connac_mcu_sta_uapsd()
456 uapsd->tac_map |= BIT(1); in mt76_connac_mcu_sta_uapsd()
458 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK) { in mt76_connac_mcu_sta_uapsd()
459 uapsd->dac_map |= BIT(0); in mt76_connac_mcu_sta_uapsd()
460 uapsd->tac_map |= BIT(0); in mt76_connac_mcu_sta_uapsd()
462 uapsd->max_sp = sta->max_sp; in mt76_connac_mcu_sta_uapsd()
478 htr->no_rx_trans = true; in mt76_connac_mcu_wtbl_hdr_trans_tlv()
480 if (vif->type == NL80211_IFTYPE_STATION) in mt76_connac_mcu_wtbl_hdr_trans_tlv()
481 htr->to_ds = true; in mt76_connac_mcu_wtbl_hdr_trans_tlv()
483 htr->from_ds = true; in mt76_connac_mcu_wtbl_hdr_trans_tlv()
488 htr->no_rx_trans = !test_bit(MT_WCID_FLAG_HDR_TRANS, &wcid->flags); in mt76_connac_mcu_wtbl_hdr_trans_tlv()
489 if (test_bit(MT_WCID_FLAG_4ADDR, &wcid->flags)) { in mt76_connac_mcu_wtbl_hdr_trans_tlv()
490 htr->to_ds = true; in mt76_connac_mcu_wtbl_hdr_trans_tlv()
491 htr->from_ds = true; in mt76_connac_mcu_wtbl_hdr_trans_tlv()
500 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_sta_update_hdr_trans()
527 struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv; in mt76_connac_mcu_wtbl_update_hdr_trans()
548 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_wtbl_generic_tlv()
561 if (vif->type == NL80211_IFTYPE_STATION) in mt76_connac_mcu_wtbl_generic_tlv()
562 generic->partial_aid = cpu_to_le16(vif->cfg.aid); in mt76_connac_mcu_wtbl_generic_tlv()
564 generic->partial_aid = cpu_to_le16(sta->aid); in mt76_connac_mcu_wtbl_generic_tlv()
565 memcpy(generic->peer_addr, sta->addr, ETH_ALEN); in mt76_connac_mcu_wtbl_generic_tlv()
566 generic->muar_idx = mvif->omac_idx; in mt76_connac_mcu_wtbl_generic_tlv()
567 generic->qos = sta->wme; in mt76_connac_mcu_wtbl_generic_tlv()
569 if (!is_connac_v1(dev) && vif->type == NL80211_IFTYPE_STATION) in mt76_connac_mcu_wtbl_generic_tlv()
570 memcpy(generic->peer_addr, vif->bss_conf.bssid, in mt76_connac_mcu_wtbl_generic_tlv()
573 eth_broadcast_addr(generic->peer_addr); in mt76_connac_mcu_wtbl_generic_tlv()
575 generic->muar_idx = 0xe; in mt76_connac_mcu_wtbl_generic_tlv()
582 rx->rca1 = sta ? vif->type != NL80211_IFTYPE_AP : 1; in mt76_connac_mcu_wtbl_generic_tlv()
583 rx->rca2 = 1; in mt76_connac_mcu_wtbl_generic_tlv()
584 rx->rv = 1; in mt76_connac_mcu_wtbl_generic_tlv()
592 spe->spe_idx = 24; in mt76_connac_mcu_wtbl_generic_tlv()
600 struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv; in mt76_connac_mcu_sta_amsdu_tlv()
604 if (vif->type != NL80211_IFTYPE_AP && in mt76_connac_mcu_sta_amsdu_tlv()
605 vif->type != NL80211_IFTYPE_STATION) in mt76_connac_mcu_sta_amsdu_tlv()
608 if (!sta->deflink.agg.max_amsdu_len) in mt76_connac_mcu_sta_amsdu_tlv()
613 amsdu->max_amsdu_num = 8; in mt76_connac_mcu_sta_amsdu_tlv()
614 amsdu->amsdu_en = true; in mt76_connac_mcu_sta_amsdu_tlv()
615 amsdu->max_mpdu_size = sta->deflink.agg.max_amsdu_len >= in mt76_connac_mcu_sta_amsdu_tlv()
618 wcid->amsdu = true; in mt76_connac_mcu_sta_amsdu_tlv()
626 struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap; in mt76_connac_mcu_sta_he_tlv()
627 struct ieee80211_he_cap_elem *elem = &he_cap->he_cap_elem; in mt76_connac_mcu_sta_he_tlv()
636 if (elem->mac_cap_info[0] & IEEE80211_HE_MAC_CAP0_HTC_HE) in mt76_connac_mcu_sta_he_tlv()
639 if (elem->mac_cap_info[2] & IEEE80211_HE_MAC_CAP2_BSR) in mt76_connac_mcu_sta_he_tlv()
642 if (elem->mac_cap_info[3] & IEEE80211_HE_MAC_CAP3_OMI_CONTROL) in mt76_connac_mcu_sta_he_tlv()
645 if (elem->mac_cap_info[4] & IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU) in mt76_connac_mcu_sta_he_tlv()
648 if (elem->mac_cap_info[4] & IEEE80211_HE_MAC_CAP4_BQR) in mt76_connac_mcu_sta_he_tlv()
651 if (elem->phy_cap_info[0] & in mt76_connac_mcu_sta_he_tlv()
656 if (elem->phy_cap_info[1] & in mt76_connac_mcu_sta_he_tlv()
660 if (elem->phy_cap_info[1] & in mt76_connac_mcu_sta_he_tlv()
664 if (elem->phy_cap_info[2] & in mt76_connac_mcu_sta_he_tlv()
668 if (elem->phy_cap_info[2] & in mt76_connac_mcu_sta_he_tlv()
672 if (elem->phy_cap_info[2] & in mt76_connac_mcu_sta_he_tlv()
676 if (elem->phy_cap_info[6] & in mt76_connac_mcu_sta_he_tlv()
680 if (elem->phy_cap_info[7] & in mt76_connac_mcu_sta_he_tlv()
684 if (elem->phy_cap_info[7] & in mt76_connac_mcu_sta_he_tlv()
688 if (elem->phy_cap_info[7] & in mt76_connac_mcu_sta_he_tlv()
692 if (elem->phy_cap_info[8] & in mt76_connac_mcu_sta_he_tlv()
696 if (elem->phy_cap_info[8] & in mt76_connac_mcu_sta_he_tlv()
700 if (elem->phy_cap_info[9] & in mt76_connac_mcu_sta_he_tlv()
704 if (elem->phy_cap_info[9] & in mt76_connac_mcu_sta_he_tlv()
708 if (elem->phy_cap_info[9] & in mt76_connac_mcu_sta_he_tlv()
712 he->he_cap = cpu_to_le32(cap); in mt76_connac_mcu_sta_he_tlv()
714 switch (sta->deflink.bandwidth) { in mt76_connac_mcu_sta_he_tlv()
716 if (elem->phy_cap_info[0] & in mt76_connac_mcu_sta_he_tlv()
718 he->max_nss_mcs[CMD_HE_MCS_BW8080] = in mt76_connac_mcu_sta_he_tlv()
719 he_cap->he_mcs_nss_supp.rx_mcs_80p80; in mt76_connac_mcu_sta_he_tlv()
721 he->max_nss_mcs[CMD_HE_MCS_BW160] = in mt76_connac_mcu_sta_he_tlv()
722 he_cap->he_mcs_nss_supp.rx_mcs_160; in mt76_connac_mcu_sta_he_tlv()
725 he->max_nss_mcs[CMD_HE_MCS_BW80] = in mt76_connac_mcu_sta_he_tlv()
726 he_cap->he_mcs_nss_supp.rx_mcs_80; in mt76_connac_mcu_sta_he_tlv()
730 he->t_frame_dur = in mt76_connac_mcu_sta_he_tlv()
731 HE_MAC(CAP1_TF_MAC_PAD_DUR_MASK, elem->mac_cap_info[1]); in mt76_connac_mcu_sta_he_tlv()
732 he->max_ampdu_exp = in mt76_connac_mcu_sta_he_tlv()
733 HE_MAC(CAP3_MAX_AMPDU_LEN_EXP_MASK, elem->mac_cap_info[3]); in mt76_connac_mcu_sta_he_tlv()
735 he->bw_set = in mt76_connac_mcu_sta_he_tlv()
736 HE_PHY(CAP0_CHANNEL_WIDTH_SET_MASK, elem->phy_cap_info[0]); in mt76_connac_mcu_sta_he_tlv()
737 he->device_class = in mt76_connac_mcu_sta_he_tlv()
738 HE_PHY(CAP1_DEVICE_CLASS_A, elem->phy_cap_info[1]); in mt76_connac_mcu_sta_he_tlv()
739 he->punc_pream_rx = in mt76_connac_mcu_sta_he_tlv()
740 HE_PHY(CAP1_PREAMBLE_PUNC_RX_MASK, elem->phy_cap_info[1]); in mt76_connac_mcu_sta_he_tlv()
742 he->dcm_tx_mode = in mt76_connac_mcu_sta_he_tlv()
743 HE_PHY(CAP3_DCM_MAX_CONST_TX_MASK, elem->phy_cap_info[3]); in mt76_connac_mcu_sta_he_tlv()
744 he->dcm_tx_max_nss = in mt76_connac_mcu_sta_he_tlv()
745 HE_PHY(CAP3_DCM_MAX_TX_NSS_2, elem->phy_cap_info[3]); in mt76_connac_mcu_sta_he_tlv()
746 he->dcm_rx_mode = in mt76_connac_mcu_sta_he_tlv()
747 HE_PHY(CAP3_DCM_MAX_CONST_RX_MASK, elem->phy_cap_info[3]); in mt76_connac_mcu_sta_he_tlv()
748 he->dcm_rx_max_nss = in mt76_connac_mcu_sta_he_tlv()
749 HE_PHY(CAP3_DCM_MAX_RX_NSS_2, elem->phy_cap_info[3]); in mt76_connac_mcu_sta_he_tlv()
750 he->dcm_rx_max_nss = in mt76_connac_mcu_sta_he_tlv()
751 HE_PHY(CAP8_DCM_MAX_RU_MASK, elem->phy_cap_info[8]); in mt76_connac_mcu_sta_he_tlv()
753 he->pkt_ext = 2; in mt76_connac_mcu_sta_he_tlv()
759 struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap; in mt76_connac_mcu_sta_he_tlv_v2()
760 struct ieee80211_he_cap_elem *elem = &he_cap->he_cap_elem; in mt76_connac_mcu_sta_he_tlv_v2()
767 memcpy(he->he_phy_cap, elem->phy_cap_info, sizeof(he->he_phy_cap)); in mt76_connac_mcu_sta_he_tlv_v2()
768 memcpy(he->he_mac_cap, elem->mac_cap_info, sizeof(he->he_mac_cap)); in mt76_connac_mcu_sta_he_tlv_v2()
770 switch (sta->deflink.bandwidth) { in mt76_connac_mcu_sta_he_tlv_v2()
772 if (elem->phy_cap_info[0] & in mt76_connac_mcu_sta_he_tlv_v2()
774 he->max_nss_mcs[CMD_HE_MCS_BW8080] = in mt76_connac_mcu_sta_he_tlv_v2()
775 he_cap->he_mcs_nss_supp.rx_mcs_80p80; in mt76_connac_mcu_sta_he_tlv_v2()
777 he->max_nss_mcs[CMD_HE_MCS_BW160] = in mt76_connac_mcu_sta_he_tlv_v2()
778 he_cap->he_mcs_nss_supp.rx_mcs_160; in mt76_connac_mcu_sta_he_tlv_v2()
781 he->max_nss_mcs[CMD_HE_MCS_BW80] = in mt76_connac_mcu_sta_he_tlv_v2()
782 he_cap->he_mcs_nss_supp.rx_mcs_80; in mt76_connac_mcu_sta_he_tlv_v2()
786 he->pkt_ext = IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US; in mt76_connac_mcu_sta_he_tlv_v2()
802 ht_cap = &link_sta->ht_cap; in mt76_connac_get_phy_mode_v2()
803 vht_cap = &link_sta->vht_cap; in mt76_connac_get_phy_mode_v2()
804 he_cap = &link_sta->he_cap; in mt76_connac_get_phy_mode_v2()
805 eht_cap = &link_sta->eht_cap; in mt76_connac_get_phy_mode_v2()
809 sband = mphy->hw->wiphy->bands[band]; in mt76_connac_get_phy_mode_v2()
810 ht_cap = &sband->ht_cap; in mt76_connac_get_phy_mode_v2()
811 vht_cap = &sband->vht_cap; in mt76_connac_get_phy_mode_v2()
812 he_cap = ieee80211_get_he_iftype_cap(sband, vif->type); in mt76_connac_get_phy_mode_v2()
813 eht_cap = ieee80211_get_eht_iftype_cap(sband, vif->type); in mt76_connac_get_phy_mode_v2()
819 if (ht_cap->ht_supported) in mt76_connac_get_phy_mode_v2()
822 if (he_cap && he_cap->has_he) in mt76_connac_get_phy_mode_v2()
825 if (eht_cap && eht_cap->has_eht) in mt76_connac_get_phy_mode_v2()
830 if (ht_cap->ht_supported) in mt76_connac_get_phy_mode_v2()
833 if (vht_cap->vht_supported) in mt76_connac_get_phy_mode_v2()
836 if (he_cap && he_cap->has_he) in mt76_connac_get_phy_mode_v2()
839 if (eht_cap && eht_cap->has_eht) in mt76_connac_get_phy_mode_v2()
852 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_sta_tlv()
853 struct cfg80211_chan_def *chandef = mvif->ctx ? in mt76_connac_mcu_sta_tlv()
854 &mvif->ctx->def : &mphy->chandef; in mt76_connac_mcu_sta_tlv()
855 enum nl80211_band band = chandef->chan->band; in mt76_connac_mcu_sta_tlv()
856 struct mt76_dev *dev = mphy->dev; in mt76_connac_mcu_sta_tlv()
864 if (sta->deflink.ht_cap.ht_supported) { in mt76_connac_mcu_sta_tlv()
869 ht->ht_cap = cpu_to_le16(sta->deflink.ht_cap.cap); in mt76_connac_mcu_sta_tlv()
873 if (sta->deflink.vht_cap.vht_supported) { in mt76_connac_mcu_sta_tlv()
877 len = is_mt7921(dev) ? sizeof(*vht) : sizeof(*vht) - 4; in mt76_connac_mcu_sta_tlv()
880 vht->vht_cap = cpu_to_le32(sta->deflink.vht_cap.cap); in mt76_connac_mcu_sta_tlv()
881 vht->vht_rx_mcs_map = sta->deflink.vht_cap.vht_mcs.rx_mcs_map; in mt76_connac_mcu_sta_tlv()
882 vht->vht_tx_mcs_map = sta->deflink.vht_cap.vht_mcs.tx_mcs_map; in mt76_connac_mcu_sta_tlv()
891 if (sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he) in mt76_connac_mcu_sta_tlv()
895 if (sta->deflink.he_cap.has_he) { in mt76_connac_mcu_sta_tlv()
905 he_6g_capa->capa = sta->deflink.he_6ghz_capa.capa; in mt76_connac_mcu_sta_tlv()
911 phy->phy_type = mt76_connac_get_phy_mode_v2(mphy, vif, band, in mt76_connac_mcu_sta_tlv()
912 &sta->deflink); in mt76_connac_mcu_sta_tlv()
913 phy->basic_rate = cpu_to_le16((u16)vif->bss_conf.basic_rates); in mt76_connac_mcu_sta_tlv()
914 phy->rcpi = rcpi; in mt76_connac_mcu_sta_tlv()
915 phy->ampdu = FIELD_PREP(IEEE80211_HT_AMPDU_PARM_FACTOR, in mt76_connac_mcu_sta_tlv()
916 sta->deflink.ht_cap.ampdu_factor) | in mt76_connac_mcu_sta_tlv()
918 sta->deflink.ht_cap.ampdu_density); in mt76_connac_mcu_sta_tlv()
923 supp_rates = sta->deflink.supp_rates[band]; in mt76_connac_mcu_sta_tlv()
930 ra_info->legacy = cpu_to_le16(supp_rates); in mt76_connac_mcu_sta_tlv()
932 if (sta->deflink.ht_cap.ht_supported) in mt76_connac_mcu_sta_tlv()
933 memcpy(ra_info->rx_mcs_bitmask, in mt76_connac_mcu_sta_tlv()
934 sta->deflink.ht_cap.mcs.rx_mask, in mt76_connac_mcu_sta_tlv()
939 state->state = sta_state; in mt76_connac_mcu_sta_tlv()
941 if (sta->deflink.vht_cap.vht_supported) { in mt76_connac_mcu_sta_tlv()
942 state->vht_opmode = sta->deflink.bandwidth; in mt76_connac_mcu_sta_tlv()
943 state->vht_opmode |= (sta->deflink.rx_nss - 1) << in mt76_connac_mcu_sta_tlv()
959 smps->smps = (sta->deflink.smps_mode == IEEE80211_SMPS_DYNAMIC); in mt76_connac_mcu_wtbl_smps_tlv()
971 if (sta->deflink.ht_cap.ht_supported || sta->deflink.he_6ghz_capa.capa) { in mt76_connac_mcu_wtbl_ht_tlv()
975 ht->ldpc = ht_ldpc && in mt76_connac_mcu_wtbl_ht_tlv()
976 !!(sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING); in mt76_connac_mcu_wtbl_ht_tlv()
978 if (sta->deflink.ht_cap.ht_supported) { in mt76_connac_mcu_wtbl_ht_tlv()
979 ht->af = sta->deflink.ht_cap.ampdu_factor; in mt76_connac_mcu_wtbl_ht_tlv()
980 ht->mm = sta->deflink.ht_cap.ampdu_density; in mt76_connac_mcu_wtbl_ht_tlv()
982 ht->af = le16_get_bits(sta->deflink.he_6ghz_capa.capa, in mt76_connac_mcu_wtbl_ht_tlv()
984 ht->mm = le16_get_bits(sta->deflink.he_6ghz_capa.capa, in mt76_connac_mcu_wtbl_ht_tlv()
988 ht->ht = true; in mt76_connac_mcu_wtbl_ht_tlv()
991 if (sta->deflink.vht_cap.vht_supported || sta->deflink.he_6ghz_capa.capa) { in mt76_connac_mcu_wtbl_ht_tlv()
999 vht->ldpc = vht_ldpc && in mt76_connac_mcu_wtbl_ht_tlv()
1000 !!(sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC); in mt76_connac_mcu_wtbl_ht_tlv()
1001 vht->vht = true; in mt76_connac_mcu_wtbl_ht_tlv()
1004 sta->deflink.vht_cap.cap); in mt76_connac_mcu_wtbl_ht_tlv()
1006 ht->af = max(ht->af, af); in mt76_connac_mcu_wtbl_ht_tlv()
1011 if (is_connac_v1(dev) && sta->deflink.ht_cap.ht_supported) { in mt76_connac_mcu_wtbl_ht_tlv()
1021 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SGI_20) in mt76_connac_mcu_wtbl_ht_tlv()
1023 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SGI_40) in mt76_connac_mcu_wtbl_ht_tlv()
1026 if (sta->deflink.vht_cap.vht_supported) { in mt76_connac_mcu_wtbl_ht_tlv()
1027 if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80) in mt76_connac_mcu_wtbl_ht_tlv()
1029 if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_160) in mt76_connac_mcu_wtbl_ht_tlv()
1033 raw->val = cpu_to_le32(flags); in mt76_connac_mcu_wtbl_ht_tlv()
1034 raw->msk = cpu_to_le32(~msk); in mt76_connac_mcu_wtbl_ht_tlv()
1035 raw->wtbl_idx = 1; in mt76_connac_mcu_wtbl_ht_tlv()
1036 raw->dw = 5; in mt76_connac_mcu_wtbl_ht_tlv()
1044 struct mt76_vif *mvif = (struct mt76_vif *)info->vif->drv_priv; in mt76_connac_mcu_sta_cmd()
1046 struct mt76_dev *dev = phy->dev; in mt76_connac_mcu_sta_cmd()
1052 skb = mt76_connac_mcu_alloc_sta_req(dev, mvif, info->wcid); in mt76_connac_mcu_sta_cmd()
1056 conn_state = info->enable ? CONN_STATE_PORT_SECURE : in mt76_connac_mcu_sta_cmd()
1058 link_sta = info->sta ? &info->sta->deflink : NULL; in mt76_connac_mcu_sta_cmd()
1059 if (info->sta || !info->offload_fw) in mt76_connac_mcu_sta_cmd()
1060 mt76_connac_mcu_sta_basic_tlv(dev, skb, info->vif, in mt76_connac_mcu_sta_cmd()
1062 info->newly); in mt76_connac_mcu_sta_cmd()
1063 if (info->sta && info->enable) in mt76_connac_mcu_sta_cmd()
1064 mt76_connac_mcu_sta_tlv(phy, skb, info->sta, in mt76_connac_mcu_sta_cmd()
1065 info->vif, info->rcpi, in mt76_connac_mcu_sta_cmd()
1066 info->state); in mt76_connac_mcu_sta_cmd()
1071 wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(dev, info->wcid, in mt76_connac_mcu_sta_cmd()
1077 if (info->enable) { in mt76_connac_mcu_sta_cmd()
1078 mt76_connac_mcu_wtbl_generic_tlv(dev, skb, info->vif, in mt76_connac_mcu_sta_cmd()
1079 info->sta, sta_wtbl, in mt76_connac_mcu_sta_cmd()
1081 mt76_connac_mcu_wtbl_hdr_trans_tlv(skb, info->vif, info->wcid, in mt76_connac_mcu_sta_cmd()
1083 if (info->sta) in mt76_connac_mcu_sta_cmd()
1084 mt76_connac_mcu_wtbl_ht_tlv(dev, skb, info->sta, in mt76_connac_mcu_sta_cmd()
1089 return mt76_mcu_skb_send_msg(dev, skb, info->cmd, true); in mt76_connac_mcu_sta_cmd()
1095 bool enable, bool tx, void *sta_wtbl, in mt76_connac_mcu_wtbl_ba_tlv() argument
1105 ba->tid = params->tid; in mt76_connac_mcu_wtbl_ba_tlv()
1108 ba->ba_type = MT_BA_TYPE_ORIGINATOR; in mt76_connac_mcu_wtbl_ba_tlv()
1109 ba->sn = enable ? cpu_to_le16(params->ssn) : 0; in mt76_connac_mcu_wtbl_ba_tlv()
1110 ba->ba_winsize = enable ? cpu_to_le16(params->buf_size) : 0; in mt76_connac_mcu_wtbl_ba_tlv()
1111 ba->ba_en = enable; in mt76_connac_mcu_wtbl_ba_tlv()
1113 memcpy(ba->peer_addr, params->sta->addr, ETH_ALEN); in mt76_connac_mcu_wtbl_ba_tlv()
1114 ba->ba_type = MT_BA_TYPE_RECIPIENT; in mt76_connac_mcu_wtbl_ba_tlv()
1115 ba->rst_ba_tid = params->tid; in mt76_connac_mcu_wtbl_ba_tlv()
1116 ba->rst_ba_sel = RST_BA_MAC_TID_MATCH; in mt76_connac_mcu_wtbl_ba_tlv()
1117 ba->rst_ba_sb = 1; in mt76_connac_mcu_wtbl_ba_tlv()
1121 ba->ba_winsize = enable ? cpu_to_le16(params->buf_size) : 0; in mt76_connac_mcu_wtbl_ba_tlv()
1125 if (enable && tx) { in mt76_connac_mcu_wtbl_ba_tlv()
1129 for (i = 7; i > 0; i--) { in mt76_connac_mcu_wtbl_ba_tlv()
1130 if (params->buf_size >= ba_range[i]) in mt76_connac_mcu_wtbl_ba_tlv()
1133 ba->ba_winsize_idx = i; in mt76_connac_mcu_wtbl_ba_tlv()
1141 bool enable) in mt76_connac_mcu_uni_add_dev() argument
1143 struct mt76_vif *mvif = (struct mt76_vif *)bss_conf->vif->drv_priv; in mt76_connac_mcu_uni_add_dev()
1144 struct mt76_dev *dev = phy->dev; in mt76_connac_mcu_uni_add_dev()
1160 .omac_idx = mvif->omac_idx, in mt76_connac_mcu_uni_add_dev()
1161 .band_idx = mvif->band_idx, in mt76_connac_mcu_uni_add_dev()
1166 .active = enable, in mt76_connac_mcu_uni_add_dev()
1167 .link_idx = mvif->idx, in mt76_connac_mcu_uni_add_dev()
1178 .bss_idx = mvif->idx, in mt76_connac_mcu_uni_add_dev()
1183 .omac_idx = mvif->omac_idx, in mt76_connac_mcu_uni_add_dev()
1184 .band_idx = mvif->band_idx, in mt76_connac_mcu_uni_add_dev()
1185 .wmm_idx = mvif->wmm_idx, in mt76_connac_mcu_uni_add_dev()
1186 .active = enable, in mt76_connac_mcu_uni_add_dev()
1187 .bmc_tx_wlan_idx = cpu_to_le16(wcid->idx), in mt76_connac_mcu_uni_add_dev()
1188 .sta_idx = cpu_to_le16(wcid->idx), in mt76_connac_mcu_uni_add_dev()
1190 .link_idx = mvif->idx, in mt76_connac_mcu_uni_add_dev()
1196 switch (bss_conf->vif->type) { in mt76_connac_mcu_uni_add_dev()
1213 idx = mvif->omac_idx > EXT_BSSID_START ? HW_BSSID_0 : mvif->omac_idx; in mt76_connac_mcu_uni_add_dev()
1216 memcpy(dev_req.tlv.omac_addr, bss_conf->addr, ETH_ALEN); in mt76_connac_mcu_uni_add_dev()
1218 cmd = enable ? MCU_UNI_CMD(DEV_INFO_UPDATE) : MCU_UNI_CMD(BSS_INFO_UPDATE); in mt76_connac_mcu_uni_add_dev()
1219 data = enable ? (void *)&dev_req : (void *)&basic_req; in mt76_connac_mcu_uni_add_dev()
1220 len = enable ? sizeof(dev_req) : sizeof(basic_req); in mt76_connac_mcu_uni_add_dev()
1226 cmd = enable ? MCU_UNI_CMD(BSS_INFO_UPDATE) : MCU_UNI_CMD(DEV_INFO_UPDATE); in mt76_connac_mcu_uni_add_dev()
1227 data = enable ? (void *)&basic_req : (void *)&dev_req; in mt76_connac_mcu_uni_add_dev()
1228 len = enable ? sizeof(basic_req) : sizeof(dev_req); in mt76_connac_mcu_uni_add_dev()
1236 bool enable, bool tx) in mt76_connac_mcu_sta_ba_tlv() argument
1244 ba->ba_type = tx ? MT_BA_TYPE_ORIGINATOR : MT_BA_TYPE_RECIPIENT; in mt76_connac_mcu_sta_ba_tlv()
1245 ba->winsize = cpu_to_le16(params->buf_size); in mt76_connac_mcu_sta_ba_tlv()
1246 ba->ssn = cpu_to_le16(params->ssn); in mt76_connac_mcu_sta_ba_tlv()
1247 ba->ba_en = enable << params->tid; in mt76_connac_mcu_sta_ba_tlv()
1248 ba->amsdu = params->amsdu; in mt76_connac_mcu_sta_ba_tlv()
1249 ba->tid = params->tid; in mt76_connac_mcu_sta_ba_tlv()
1258 if (!mtk_wed_device_active(&dev->mmio.wed)) in mt76_connac_mcu_sta_wed_update()
1261 return mtk_wed_device_update_msg(&dev->mmio.wed, WED_WO_STA_REC, in mt76_connac_mcu_sta_wed_update()
1262 skb->data, skb->len); in mt76_connac_mcu_sta_wed_update()
1268 int cmd, bool enable, bool tx) in mt76_connac_mcu_sta_ba() argument
1270 struct mt76_wcid *wcid = (struct mt76_wcid *)params->sta->drv_priv; in mt76_connac_mcu_sta_ba()
1288 mt76_connac_mcu_wtbl_ba_tlv(dev, skb, params, enable, tx, sta_wtbl, in mt76_connac_mcu_sta_ba()
1303 mt76_connac_mcu_sta_ba_tlv(skb, params, enable, tx); in mt76_connac_mcu_sta_ba()
1317 struct mt76_dev *dev = phy->dev; in mt76_connac_get_phy_mode()
1327 ht_cap = &link_sta->ht_cap; in mt76_connac_get_phy_mode()
1328 vht_cap = &link_sta->vht_cap; in mt76_connac_get_phy_mode()
1329 he_cap = &link_sta->he_cap; in mt76_connac_get_phy_mode()
1333 sband = phy->hw->wiphy->bands[band]; in mt76_connac_get_phy_mode()
1334 ht_cap = &sband->ht_cap; in mt76_connac_get_phy_mode()
1335 vht_cap = &sband->vht_cap; in mt76_connac_get_phy_mode()
1336 he_cap = ieee80211_get_he_iftype_cap(sband, vif->type); in mt76_connac_get_phy_mode()
1342 if (ht_cap->ht_supported) in mt76_connac_get_phy_mode()
1345 if (he_cap && he_cap->has_he) in mt76_connac_get_phy_mode()
1350 if (ht_cap->ht_supported) in mt76_connac_get_phy_mode()
1353 if (vht_cap->vht_supported) in mt76_connac_get_phy_mode()
1356 if (he_cap && he_cap->has_he) in mt76_connac_get_phy_mode()
1377 sband = phy->hw->wiphy->bands[band]; in mt76_connac_get_phy_mode_ext()
1378 eht_cap = ieee80211_get_eht_iftype_cap(sband, vif->type); in mt76_connac_get_phy_mode_ext()
1380 if (!eht_cap || !eht_cap->has_eht || !vif->bss_conf.eht_support) in mt76_connac_get_phy_mode_ext()
1404 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_get_he_phy_cap()
1405 struct cfg80211_chan_def *chandef = mvif->ctx ? in mt76_connac_get_he_phy_cap()
1406 &mvif->ctx->def : &phy->chandef; in mt76_connac_get_he_phy_cap()
1407 enum nl80211_band band = chandef->chan->band; in mt76_connac_get_he_phy_cap()
1410 sband = phy->hw->wiphy->bands[band]; in mt76_connac_get_he_phy_cap()
1412 return ieee80211_get_he_iftype_cap(sband, vif->type); in mt76_connac_get_he_phy_cap()
1419 enum nl80211_band band = phy->chandef.chan->band; in mt76_connac_get_eht_phy_cap()
1422 sband = phy->hw->wiphy->bands[band]; in mt76_connac_get_eht_phy_cap()
1424 return ieee80211_get_eht_iftype_cap(sband, vif->type); in mt76_connac_get_eht_phy_cap()
1440 he->he_pe_duration = vif->bss_conf.htc_trig_based_pkt_ext; in mt76_connac_mcu_uni_bss_he_tlv()
1441 if (!he->he_pe_duration) in mt76_connac_mcu_uni_bss_he_tlv()
1442 he->he_pe_duration = DEFAULT_HE_PE_DURATION; in mt76_connac_mcu_uni_bss_he_tlv()
1444 he->he_rts_thres = cpu_to_le16(vif->bss_conf.frame_time_rts_th); in mt76_connac_mcu_uni_bss_he_tlv()
1445 if (!he->he_rts_thres) in mt76_connac_mcu_uni_bss_he_tlv()
1446 he->he_rts_thres = cpu_to_le16(DEFAULT_HE_DURATION_RTS_THRES); in mt76_connac_mcu_uni_bss_he_tlv()
1448 he->max_nss_mcs[CMD_HE_MCS_BW80] = cap->he_mcs_nss_supp.tx_mcs_80; in mt76_connac_mcu_uni_bss_he_tlv()
1449 he->max_nss_mcs[CMD_HE_MCS_BW160] = cap->he_mcs_nss_supp.tx_mcs_160; in mt76_connac_mcu_uni_bss_he_tlv()
1450 he->max_nss_mcs[CMD_HE_MCS_BW8080] = cap->he_mcs_nss_supp.tx_mcs_80p80; in mt76_connac_mcu_uni_bss_he_tlv()
1456 struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->chandef; in mt76_connac_mcu_uni_set_chctx()
1457 int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2; in mt76_connac_mcu_uni_set_chctx()
1458 enum nl80211_band band = chandef->chan->band; in mt76_connac_mcu_uni_set_chctx()
1459 struct mt76_dev *mdev = phy->dev; in mt76_connac_mcu_uni_set_chctx()
1482 .bss_idx = mvif->idx, in mt76_connac_mcu_uni_set_chctx()
1487 .control_channel = chandef->chan->hw_value, in mt76_connac_mcu_uni_set_chctx()
1490 .tx_streams = hweight8(phy->antenna_mask), in mt76_connac_mcu_uni_set_chctx()
1492 .rx_streams = phy->chainmask, in mt76_connac_mcu_uni_set_chctx()
1498 switch (chandef->width) { in mt76_connac_mcu_uni_set_chctx()
1538 bool enable, in mt76_connac_mcu_uni_add_bss() argument
1541 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_uni_add_bss()
1542 struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->chandef; in mt76_connac_mcu_uni_add_bss()
1543 enum nl80211_band band = chandef->chan->band; in mt76_connac_mcu_uni_add_bss()
1544 struct mt76_dev *mdev = phy->dev; in mt76_connac_mcu_uni_add_bss()
1554 .bss_idx = mvif->idx, in mt76_connac_mcu_uni_add_bss()
1559 .bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int), in mt76_connac_mcu_uni_add_bss()
1560 .dtim_period = vif->bss_conf.dtim_period, in mt76_connac_mcu_uni_add_bss()
1561 .omac_idx = mvif->omac_idx, in mt76_connac_mcu_uni_add_bss()
1562 .band_idx = mvif->band_idx, in mt76_connac_mcu_uni_add_bss()
1563 .wmm_idx = mvif->wmm_idx, in mt76_connac_mcu_uni_add_bss()
1570 .qos = vif->bss_conf.qos, in mt76_connac_mcu_uni_add_bss()
1576 idx = mvif->omac_idx > EXT_BSSID_START ? HW_BSSID_0 : mvif->omac_idx; in mt76_connac_mcu_uni_add_bss()
1584 switch (vif->type) { in mt76_connac_mcu_uni_add_bss()
1587 if (vif->p2p) in mt76_connac_mcu_uni_add_bss()
1593 basic_req.basic.active = enable; in mt76_connac_mcu_uni_add_bss()
1596 if (vif->p2p) in mt76_connac_mcu_uni_add_bss()
1610 memcpy(basic_req.basic.bssid, vif->bss_conf.bssid, ETH_ALEN); in mt76_connac_mcu_uni_add_bss()
1611 basic_req.basic.bmc_tx_wlan_idx = cpu_to_le16(wcid->idx); in mt76_connac_mcu_uni_add_bss()
1612 basic_req.basic.sta_idx = cpu_to_le16(wcid->idx); in mt76_connac_mcu_uni_add_bss()
1613 basic_req.basic.conn_state = !enable; in mt76_connac_mcu_uni_add_bss()
1620 if (vif->bss_conf.he_support) { in mt76_connac_mcu_uni_add_bss()
1630 .bss_idx = mvif->idx, in mt76_connac_mcu_uni_add_bss()
1639 .enable = 0, in mt76_connac_mcu_uni_add_bss()
1644 if (enable) { in mt76_connac_mcu_uni_add_bss()
1645 he_req.bss_color.enable = in mt76_connac_mcu_uni_add_bss()
1646 vif->bss_conf.he_bss_color.enabled; in mt76_connac_mcu_uni_add_bss()
1648 vif->bss_conf.he_bss_color.color; in mt76_connac_mcu_uni_add_bss()
1667 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_hw_scan()
1668 struct cfg80211_scan_request *sreq = &scan_req->req; in mt76_connac_mcu_hw_scan()
1670 int ext_channels_num = max_t(int, sreq->n_channels - 32, 0); in mt76_connac_mcu_hw_scan()
1671 struct ieee80211_channel **scan_list = sreq->channels; in mt76_connac_mcu_hw_scan()
1672 struct mt76_dev *mdev = phy->dev; in mt76_connac_mcu_hw_scan()
1677 if (test_bit(MT76_HW_SCANNING, &phy->state)) in mt76_connac_mcu_hw_scan()
1678 return -EBUSY; in mt76_connac_mcu_hw_scan()
1682 return -ENOMEM; in mt76_connac_mcu_hw_scan()
1684 set_bit(MT76_HW_SCANNING, &phy->state); in mt76_connac_mcu_hw_scan()
1685 mvif->scan_seq_num = (mvif->scan_seq_num + 1) & 0x7f; in mt76_connac_mcu_hw_scan()
1689 req->seq_num = mvif->scan_seq_num | mvif->band_idx << 7; in mt76_connac_mcu_hw_scan()
1690 req->bss_idx = mvif->idx; in mt76_connac_mcu_hw_scan()
1691 req->scan_type = sreq->n_ssids ? 1 : 0; in mt76_connac_mcu_hw_scan()
1692 req->probe_req_num = sreq->n_ssids ? 2 : 0; in mt76_connac_mcu_hw_scan()
1693 req->version = 1; in mt76_connac_mcu_hw_scan()
1695 for (i = 0; i < sreq->n_ssids; i++) { in mt76_connac_mcu_hw_scan()
1696 if (!sreq->ssids[i].ssid_len) in mt76_connac_mcu_hw_scan()
1699 req->ssids[i].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len); in mt76_connac_mcu_hw_scan()
1700 memcpy(req->ssids[i].ssid, sreq->ssids[i].ssid, in mt76_connac_mcu_hw_scan()
1701 sreq->ssids[i].ssid_len); in mt76_connac_mcu_hw_scan()
1704 req->ssid_type = n_ssids ? BIT(2) : BIT(0); in mt76_connac_mcu_hw_scan()
1705 req->ssid_type_ext = n_ssids ? BIT(0) : 0; in mt76_connac_mcu_hw_scan()
1706 req->ssids_num = n_ssids; in mt76_connac_mcu_hw_scan()
1708 duration = is_mt7921(phy->dev) ? 0 : MT76_CONNAC_SCAN_CHANNEL_TIME; in mt76_connac_mcu_hw_scan()
1710 if (!sreq->n_ssids) in mt76_connac_mcu_hw_scan()
1712 req->timeout_value = cpu_to_le16(sreq->n_channels * duration); in mt76_connac_mcu_hw_scan()
1713 req->channel_min_dwell_time = cpu_to_le16(duration); in mt76_connac_mcu_hw_scan()
1714 req->channel_dwell_time = cpu_to_le16(duration); in mt76_connac_mcu_hw_scan()
1716 if (sreq->n_channels == 0 || sreq->n_channels > 64) { in mt76_connac_mcu_hw_scan()
1717 req->channel_type = 0; in mt76_connac_mcu_hw_scan()
1718 req->channels_num = 0; in mt76_connac_mcu_hw_scan()
1719 req->ext_channels_num = 0; in mt76_connac_mcu_hw_scan()
1721 req->channel_type = 4; in mt76_connac_mcu_hw_scan()
1722 req->channels_num = min_t(u8, sreq->n_channels, 32); in mt76_connac_mcu_hw_scan()
1723 req->ext_channels_num = min_t(u8, ext_channels_num, 32); in mt76_connac_mcu_hw_scan()
1726 for (i = 0; i < req->channels_num + req->ext_channels_num; i++) { in mt76_connac_mcu_hw_scan()
1728 chan = &req->ext_channels[i - 32]; in mt76_connac_mcu_hw_scan()
1730 chan = &req->channels[i]; in mt76_connac_mcu_hw_scan()
1732 switch (scan_list[i]->band) { in mt76_connac_mcu_hw_scan()
1734 chan->band = 1; in mt76_connac_mcu_hw_scan()
1737 chan->band = 3; in mt76_connac_mcu_hw_scan()
1740 chan->band = 2; in mt76_connac_mcu_hw_scan()
1743 chan->channel_num = scan_list[i]->hw_value; in mt76_connac_mcu_hw_scan()
1746 if (sreq->ie_len > 0) { in mt76_connac_mcu_hw_scan()
1747 memcpy(req->ies, sreq->ie, sreq->ie_len); in mt76_connac_mcu_hw_scan()
1748 req->ies_len = cpu_to_le16(sreq->ie_len); in mt76_connac_mcu_hw_scan()
1751 if (is_mt7921(phy->dev)) in mt76_connac_mcu_hw_scan()
1752 req->scan_func |= SCAN_FUNC_SPLIT_SCAN; in mt76_connac_mcu_hw_scan()
1754 memcpy(req->bssid, sreq->bssid, ETH_ALEN); in mt76_connac_mcu_hw_scan()
1755 if (sreq->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) { in mt76_connac_mcu_hw_scan()
1756 get_random_mask_addr(req->random_mac, sreq->mac_addr, in mt76_connac_mcu_hw_scan()
1757 sreq->mac_addr_mask); in mt76_connac_mcu_hw_scan()
1758 req->scan_func |= SCAN_FUNC_RANDOM_MAC; in mt76_connac_mcu_hw_scan()
1764 clear_bit(MT76_HW_SCANNING, &phy->state); in mt76_connac_mcu_hw_scan()
1773 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_cancel_hw_scan()
1779 .seq_num = mvif->scan_seq_num, in mt76_connac_mcu_cancel_hw_scan()
1782 if (test_and_clear_bit(MT76_HW_SCANNING, &phy->state)) { in mt76_connac_mcu_cancel_hw_scan()
1787 ieee80211_scan_completed(phy->hw, &info); in mt76_connac_mcu_cancel_hw_scan()
1790 return mt76_mcu_send_msg(phy->dev, MCU_CE_CMD(CANCEL_HW_SCAN), in mt76_connac_mcu_cancel_hw_scan()
1799 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_sched_scan_req()
1800 struct ieee80211_channel **scan_list = sreq->channels; in mt76_connac_mcu_sched_scan_req()
1803 struct mt76_dev *mdev = phy->dev; in mt76_connac_mcu_sched_scan_req()
1809 skb = mt76_mcu_msg_alloc(mdev, NULL, sizeof(*req) + sreq->ie_len); in mt76_connac_mcu_sched_scan_req()
1811 return -ENOMEM; in mt76_connac_mcu_sched_scan_req()
1813 mvif->scan_seq_num = (mvif->scan_seq_num + 1) & 0x7f; in mt76_connac_mcu_sched_scan_req()
1816 req->version = 1; in mt76_connac_mcu_sched_scan_req()
1817 req->seq_num = mvif->scan_seq_num | mvif->band_idx << 7; in mt76_connac_mcu_sched_scan_req()
1819 if (sreq->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) { in mt76_connac_mcu_sched_scan_req()
1820 u8 *addr = is_mt7663(phy->dev) ? req->mt7663.random_mac in mt76_connac_mcu_sched_scan_req()
1821 : req->mt7921.random_mac; in mt76_connac_mcu_sched_scan_req()
1823 req->scan_func = 1; in mt76_connac_mcu_sched_scan_req()
1824 get_random_mask_addr(addr, sreq->mac_addr, in mt76_connac_mcu_sched_scan_req()
1825 sreq->mac_addr_mask); in mt76_connac_mcu_sched_scan_req()
1827 if (is_mt7921(phy->dev)) { in mt76_connac_mcu_sched_scan_req()
1828 req->mt7921.bss_idx = mvif->idx; in mt76_connac_mcu_sched_scan_req()
1829 req->mt7921.delay = cpu_to_le32(sreq->delay); in mt76_connac_mcu_sched_scan_req()
1832 req->ssids_num = sreq->n_ssids; in mt76_connac_mcu_sched_scan_req()
1833 for (i = 0; i < req->ssids_num; i++) { in mt76_connac_mcu_sched_scan_req()
1834 ssid = &sreq->ssids[i]; in mt76_connac_mcu_sched_scan_req()
1835 memcpy(req->ssids[i].ssid, ssid->ssid, ssid->ssid_len); in mt76_connac_mcu_sched_scan_req()
1836 req->ssids[i].ssid_len = cpu_to_le32(ssid->ssid_len); in mt76_connac_mcu_sched_scan_req()
1839 req->match_num = sreq->n_match_sets; in mt76_connac_mcu_sched_scan_req()
1840 for (i = 0; i < req->match_num; i++) { in mt76_connac_mcu_sched_scan_req()
1841 match = &sreq->match_sets[i]; in mt76_connac_mcu_sched_scan_req()
1842 memcpy(req->match[i].ssid, match->ssid.ssid, in mt76_connac_mcu_sched_scan_req()
1843 match->ssid.ssid_len); in mt76_connac_mcu_sched_scan_req()
1844 req->match[i].rssi_th = cpu_to_le32(match->rssi_thold); in mt76_connac_mcu_sched_scan_req()
1845 req->match[i].ssid_len = match->ssid.ssid_len; in mt76_connac_mcu_sched_scan_req()
1848 req->channel_type = sreq->n_channels ? 4 : 0; in mt76_connac_mcu_sched_scan_req()
1849 req->channels_num = min_t(u8, sreq->n_channels, 64); in mt76_connac_mcu_sched_scan_req()
1850 for (i = 0; i < req->channels_num; i++) { in mt76_connac_mcu_sched_scan_req()
1851 chan = &req->channels[i]; in mt76_connac_mcu_sched_scan_req()
1853 switch (scan_list[i]->band) { in mt76_connac_mcu_sched_scan_req()
1855 chan->band = 1; in mt76_connac_mcu_sched_scan_req()
1858 chan->band = 3; in mt76_connac_mcu_sched_scan_req()
1861 chan->band = 2; in mt76_connac_mcu_sched_scan_req()
1864 chan->channel_num = scan_list[i]->hw_value; in mt76_connac_mcu_sched_scan_req()
1867 req->intervals_num = sreq->n_scan_plans; in mt76_connac_mcu_sched_scan_req()
1868 for (i = 0; i < req->intervals_num; i++) in mt76_connac_mcu_sched_scan_req()
1869 req->intervals[i] = cpu_to_le16(sreq->scan_plans[i].interval); in mt76_connac_mcu_sched_scan_req()
1871 if (sreq->ie_len > 0) { in mt76_connac_mcu_sched_scan_req()
1872 req->ie_len = cpu_to_le16(sreq->ie_len); in mt76_connac_mcu_sched_scan_req()
1873 memcpy(skb_put(skb, sreq->ie_len), sreq->ie, sreq->ie_len); in mt76_connac_mcu_sched_scan_req()
1883 bool enable) in mt76_connac_mcu_sched_scan_enable() argument
1889 .active = !enable, in mt76_connac_mcu_sched_scan_enable()
1892 if (enable) in mt76_connac_mcu_sched_scan_enable()
1893 set_bit(MT76_HW_SCHED_SCANNING, &phy->state); in mt76_connac_mcu_sched_scan_enable()
1895 clear_bit(MT76_HW_SCHED_SCANNING, &phy->state); in mt76_connac_mcu_sched_scan_enable()
1897 return mt76_mcu_send_msg(phy->dev, MCU_CE_CMD(SCHED_SCAN_ENABLE), in mt76_connac_mcu_sched_scan_enable()
1915 int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable) in mt76_connac_mcu_set_deep_sleep() argument
1921 snprintf(req.data, sizeof(req.data), "KeepFullPwr %d", !enable); in mt76_connac_mcu_set_deep_sleep()
1951 spin_lock_bh(&dev->lock); in mt76_connac_mcu_coredump_event()
1952 __skb_queue_tail(&coredump->msg_list, skb); in mt76_connac_mcu_coredump_event()
1953 spin_unlock_bh(&dev->lock); in mt76_connac_mcu_coredump_event()
1955 coredump->last_activity = jiffies; in mt76_connac_mcu_coredump_event()
1957 queue_delayed_work(dev->wq, &coredump->work, in mt76_connac_mcu_coredump_event()
1968 int i, offset = sizeof(limits->cck); in mt76_connac_mcu_build_sku()
1974 memcpy(sku, limits->cck, sizeof(limits->cck)); in mt76_connac_mcu_build_sku()
1978 memcpy(&sku[offset], limits->ofdm, sizeof(limits->ofdm)); in mt76_connac_mcu_build_sku()
1979 offset += sizeof(limits->ofdm); in mt76_connac_mcu_build_sku()
1983 memcpy(&sku[offset], limits->mcs[i], 8); in mt76_connac_mcu_build_sku()
1986 sku[offset++] = limits->mcs[0][0]; in mt76_connac_mcu_build_sku()
1989 for (i = 0; i < ARRAY_SIZE(limits->mcs); i++) { in mt76_connac_mcu_build_sku()
1990 memcpy(&sku[offset], limits->mcs[i], in mt76_connac_mcu_build_sku()
1991 ARRAY_SIZE(limits->mcs[i])); in mt76_connac_mcu_build_sku()
1999 for (i = 0; i < ARRAY_SIZE(limits->ru); i++) { in mt76_connac_mcu_build_sku()
2000 memcpy(&sku[offset], limits->ru[i], ARRAY_SIZE(limits->ru[i])); in mt76_connac_mcu_build_sku()
2001 offset += ARRAY_SIZE(limits->ru[i]); in mt76_connac_mcu_build_sku()
2009 struct mt76_dev *dev = phy->dev; in mt76_connac_get_ch_power()
2013 switch (chan->band) { in mt76_connac_get_ch_power()
2015 sband = &phy->sband_2g.sband; in mt76_connac_get_ch_power()
2018 sband = &phy->sband_5g.sband; in mt76_connac_get_ch_power()
2021 sband = &phy->sband_6g.sband; in mt76_connac_get_ch_power()
2027 for (i = 0; i < sband->n_channels; i++) { in mt76_connac_get_ch_power()
2028 struct ieee80211_channel *ch = &sband->channels[i]; in mt76_connac_get_ch_power()
2030 if (ch->hw_value == chan->hw_value) { in mt76_connac_get_ch_power()
2031 if (!(ch->flags & IEEE80211_CHAN_DISABLED)) { in mt76_connac_get_ch_power()
2032 int power = 2 * ch->max_reg_power; in mt76_connac_get_ch_power()
2034 if (is_mt7663(dev) && (power > 63 || power < -64)) in mt76_connac_get_ch_power()
2050 struct mt76_dev *dev = phy->dev; in mt76_connac_mcu_rate_txpower_band()
2088 limits = devm_kmalloc(dev->dev, sizeof(*limits), GFP_KERNEL); in mt76_connac_mcu_rate_txpower_band()
2090 return -ENOMEM; in mt76_connac_mcu_rate_txpower_band()
2092 sku_len = is_mt7921(dev) ? sizeof(sku_tlbv) : sizeof(sku_tlbv) - 92; in mt76_connac_mcu_rate_txpower_band()
2093 tx_power = 2 * phy->hw->conf.power_level; in mt76_connac_mcu_rate_txpower_band()
2109 if (phy->cap.has_6ghz) in mt76_connac_mcu_rate_txpower_band()
2110 last_ch = chan_list_6ghz[ARRAY_SIZE(chan_list_6ghz) - 1]; in mt76_connac_mcu_rate_txpower_band()
2111 else if (phy->cap.has_5ghz) in mt76_connac_mcu_rate_txpower_band()
2112 last_ch = chan_list_5ghz[ARRAY_SIZE(chan_list_5ghz) - 1]; in mt76_connac_mcu_rate_txpower_band()
2114 last_ch = chan_list_2ghz[ARRAY_SIZE(chan_list_2ghz) - 1]; in mt76_connac_mcu_rate_txpower_band()
2121 num_ch = i == batch_size - 1 ? n_chan - i * batch_len : batch_len; in mt76_connac_mcu_rate_txpower_band()
2125 err = -ENOMEM; in mt76_connac_mcu_rate_txpower_band()
2131 BUILD_BUG_ON(sizeof(dev->alpha2) > sizeof(tx_power_tlv.alpha2)); in mt76_connac_mcu_rate_txpower_band()
2132 memcpy(tx_power_tlv.alpha2, dev->alpha2, sizeof(dev->alpha2)); in mt76_connac_mcu_rate_txpower_band()
2169 memcpy(skb->data, &tx_power_tlv, sizeof(tx_power_tlv)); in mt76_connac_mcu_rate_txpower_band()
2179 devm_kfree(dev->dev, limits); in mt76_connac_mcu_rate_txpower_band()
2187 if (phy->cap.has_2ghz) { in mt76_connac_mcu_set_rate_txpower()
2193 if (phy->cap.has_5ghz) { in mt76_connac_mcu_set_rate_txpower()
2199 if (phy->cap.has_6ghz) { in mt76_connac_mcu_set_rate_txpower()
2217 int i, len = min_t(int, mvif->cfg.arp_addr_cnt, in mt76_connac_mcu_update_arp_filter()
2227 .bss_idx = vif->idx, in mt76_connac_mcu_update_arp_filter()
2241 return -ENOMEM; in mt76_connac_mcu_update_arp_filter()
2245 skb_put_data(skb, &mvif->cfg.arp_addr_list[i], sizeof(__be32)); in mt76_connac_mcu_update_arp_filter()
2254 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_set_p2p_oppps()
2255 int ct_window = vif->bss_conf.p2p_noa_attr.oppps_ctwindow; in mt76_connac_mcu_set_p2p_oppps()
2256 struct mt76_phy *phy = hw->priv; in mt76_connac_mcu_set_p2p_oppps()
2263 .bss_idx = mvif->idx, in mt76_connac_mcu_set_p2p_oppps()
2266 return mt76_mcu_send_msg(phy->dev, MCU_CE_CMD(SET_P2P_OPPPS), in mt76_connac_mcu_set_p2p_oppps()
2287 struct ieee80211_key_conf *key, in mt76_connac_mcu_key_iter() argument
2293 if (key->cipher != WLAN_CIPHER_SUITE_AES_CMAC && in mt76_connac_mcu_key_iter()
2294 key->cipher != WLAN_CIPHER_SUITE_CCMP && in mt76_connac_mcu_key_iter()
2295 key->cipher != WLAN_CIPHER_SUITE_TKIP) in mt76_connac_mcu_key_iter()
2298 if (key->cipher == WLAN_CIPHER_SUITE_TKIP) in mt76_connac_mcu_key_iter()
2303 /* we are assuming here to have a single pairwise key */ in mt76_connac_mcu_key_iter()
2304 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { in mt76_connac_mcu_key_iter()
2305 if (key->cipher == WLAN_CIPHER_SUITE_TKIP) in mt76_connac_mcu_key_iter()
2306 gtk_tlv->proto = cpu_to_le32(NL80211_WPA_VERSION_1); in mt76_connac_mcu_key_iter()
2308 gtk_tlv->proto = cpu_to_le32(NL80211_WPA_VERSION_2); in mt76_connac_mcu_key_iter()
2310 gtk_tlv->pairwise_cipher = cpu_to_le32(cipher); in mt76_connac_mcu_key_iter()
2311 gtk_tlv->keyid = key->keyidx; in mt76_connac_mcu_key_iter()
2313 gtk_tlv->group_cipher = cpu_to_le32(cipher); in mt76_connac_mcu_key_iter()
2319 struct cfg80211_gtk_rekey_data *key) in mt76_connac_mcu_update_gtk_rekey() argument
2321 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_update_gtk_rekey()
2323 struct mt76_phy *phy = hw->priv; in mt76_connac_mcu_update_gtk_rekey()
2329 .bss_idx = mvif->idx, in mt76_connac_mcu_update_gtk_rekey()
2332 skb = mt76_mcu_msg_alloc(phy->dev, NULL, in mt76_connac_mcu_update_gtk_rekey()
2335 return -ENOMEM; in mt76_connac_mcu_update_gtk_rekey()
2340 gtk_tlv->tag = cpu_to_le16(UNI_OFFLOAD_OFFLOAD_GTK_REKEY); in mt76_connac_mcu_update_gtk_rekey()
2341 gtk_tlv->len = cpu_to_le16(sizeof(*gtk_tlv)); in mt76_connac_mcu_update_gtk_rekey()
2342 gtk_tlv->rekey_mode = 2; in mt76_connac_mcu_update_gtk_rekey()
2343 gtk_tlv->option = 1; in mt76_connac_mcu_update_gtk_rekey()
2349 memcpy(gtk_tlv->kek, key->kek, NL80211_KEK_LEN); in mt76_connac_mcu_update_gtk_rekey()
2350 memcpy(gtk_tlv->kck, key->kck, NL80211_KCK_LEN); in mt76_connac_mcu_update_gtk_rekey()
2351 memcpy(gtk_tlv->replay_ctr, key->replay_ctr, NL80211_REPLAY_CTR_LEN); in mt76_connac_mcu_update_gtk_rekey()
2353 return mt76_mcu_skb_send_msg(phy->dev, skb, in mt76_connac_mcu_update_gtk_rekey()
2362 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_set_arp_filter()
2371 .bss_idx = mvif->idx, in mt76_connac_mcu_set_arp_filter()
2388 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_set_gtk_rekey()
2397 .bss_idx = mvif->idx, in mt76_connac_mcu_set_gtk_rekey()
2414 bool enable, u8 mdtim, in mt76_connac_mcu_set_suspend_mode() argument
2417 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_set_suspend_mode()
2426 .bss_idx = mvif->idx, in mt76_connac_mcu_set_suspend_mode()
2431 .enable = enable, in mt76_connac_mcu_set_suspend_mode()
2445 u8 index, bool enable, in mt76_connac_mcu_set_wow_pattern() argument
2448 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_set_wow_pattern()
2455 .bss_idx = mvif->idx, in mt76_connac_mcu_set_wow_pattern()
2460 return -ENOMEM; in mt76_connac_mcu_set_wow_pattern()
2464 ptlv->tag = cpu_to_le16(UNI_SUSPEND_WOW_PATTERN); in mt76_connac_mcu_set_wow_pattern()
2465 ptlv->len = cpu_to_le16(sizeof(*ptlv)); in mt76_connac_mcu_set_wow_pattern()
2466 ptlv->data_len = pattern->pattern_len; in mt76_connac_mcu_set_wow_pattern()
2467 ptlv->enable = enable; in mt76_connac_mcu_set_wow_pattern()
2468 ptlv->index = index; in mt76_connac_mcu_set_wow_pattern()
2470 memcpy(ptlv->pattern, pattern->pattern, pattern->pattern_len); in mt76_connac_mcu_set_wow_pattern()
2471 memcpy(ptlv->mask, pattern->mask, DIV_ROUND_UP(pattern->pattern_len, 8)); in mt76_connac_mcu_set_wow_pattern()
2480 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_set_wow_ctrl()
2481 struct mt76_dev *dev = phy->dev; in mt76_connac_mcu_set_wow_ctrl()
2491 .bss_idx = mvif->idx, in mt76_connac_mcu_set_wow_ctrl()
2505 if (wowlan->magic_pkt) in mt76_connac_mcu_set_wow_ctrl()
2507 if (wowlan->disconnect) in mt76_connac_mcu_set_wow_ctrl()
2510 if (wowlan->nd_config) { in mt76_connac_mcu_set_wow_ctrl()
2511 mt76_connac_mcu_sched_scan_req(phy, vif, wowlan->nd_config); in mt76_connac_mcu_set_wow_ctrl()
2515 if (wowlan->n_patterns) in mt76_connac_mcu_set_wow_ctrl()
2570 bool suspend = !test_bit(MT76_STATE_RUNNING, &phy->state); in mt76_connac_mcu_set_suspend_iter()
2571 struct ieee80211_hw *hw = phy->hw; in mt76_connac_mcu_set_suspend_iter()
2572 struct cfg80211_wowlan *wowlan = hw->wiphy->wowlan_config; in mt76_connac_mcu_set_suspend_iter()
2575 mt76_connac_mcu_set_gtk_rekey(phy->dev, vif, suspend); in mt76_connac_mcu_set_suspend_iter()
2576 mt76_connac_mcu_set_arp_filter(phy->dev, vif, suspend); in mt76_connac_mcu_set_suspend_iter()
2578 mt76_connac_mcu_set_suspend_mode(phy->dev, vif, suspend, 1, true); in mt76_connac_mcu_set_suspend_iter()
2580 for (i = 0; i < wowlan->n_patterns; i++) in mt76_connac_mcu_set_suspend_iter()
2581 mt76_connac_mcu_set_wow_pattern(phy->dev, vif, i, suspend, in mt76_connac_mcu_set_suspend_iter()
2582 &wowlan->patterns[i]); in mt76_connac_mcu_set_suspend_iter()
2620 struct ieee80211_key_conf *key, in mt76_connac_mcu_sta_key_tlv() argument
2629 sec->add = cmd; in mt76_connac_mcu_sta_key_tlv()
2635 cipher = mt76_connac_mcu_get_cipher(key->cipher); in mt76_connac_mcu_sta_key_tlv()
2637 return -EOPNOTSUPP; in mt76_connac_mcu_sta_key_tlv()
2639 sec_key = &sec->key[0]; in mt76_connac_mcu_sta_key_tlv()
2640 sec_key->cipher_len = sizeof(*sec_key); in mt76_connac_mcu_sta_key_tlv()
2643 sec_key->cipher_id = MCU_CIPHER_AES_CCMP; in mt76_connac_mcu_sta_key_tlv()
2644 sec_key->key_id = sta_key_conf->keyidx; in mt76_connac_mcu_sta_key_tlv()
2645 sec_key->key_len = 16; in mt76_connac_mcu_sta_key_tlv()
2646 memcpy(sec_key->key, sta_key_conf->key, 16); in mt76_connac_mcu_sta_key_tlv()
2648 sec_key = &sec->key[1]; in mt76_connac_mcu_sta_key_tlv()
2649 sec_key->cipher_id = MCU_CIPHER_BIP_CMAC_128; in mt76_connac_mcu_sta_key_tlv()
2650 sec_key->cipher_len = sizeof(*sec_key); in mt76_connac_mcu_sta_key_tlv()
2651 sec_key->key_len = 16; in mt76_connac_mcu_sta_key_tlv()
2652 memcpy(sec_key->key, key->key, 16); in mt76_connac_mcu_sta_key_tlv()
2653 sec->n_cipher = 2; in mt76_connac_mcu_sta_key_tlv()
2655 sec_key->cipher_id = cipher; in mt76_connac_mcu_sta_key_tlv()
2656 sec_key->key_id = key->keyidx; in mt76_connac_mcu_sta_key_tlv()
2657 sec_key->key_len = key->keylen; in mt76_connac_mcu_sta_key_tlv()
2658 memcpy(sec_key->key, key->key, key->keylen); in mt76_connac_mcu_sta_key_tlv()
2662 memcpy(sec_key->key + 16, key->key + 24, 8); in mt76_connac_mcu_sta_key_tlv()
2663 memcpy(sec_key->key + 24, key->key + 16, 8); in mt76_connac_mcu_sta_key_tlv()
2668 memcpy(sta_key_conf->key, key->key, key->keylen); in mt76_connac_mcu_sta_key_tlv()
2669 sta_key_conf->keyidx = key->keyidx; in mt76_connac_mcu_sta_key_tlv()
2672 len -= sizeof(*sec_key); in mt76_connac_mcu_sta_key_tlv()
2673 sec->n_cipher = 1; in mt76_connac_mcu_sta_key_tlv()
2676 len -= sizeof(sec->key); in mt76_connac_mcu_sta_key_tlv()
2677 sec->n_cipher = 0; in mt76_connac_mcu_sta_key_tlv()
2679 sec->len = cpu_to_le16(len); in mt76_connac_mcu_sta_key_tlv()
2686 struct ieee80211_key_conf *key, int mcu_cmd, in mt76_connac_mcu_add_key() argument
2689 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_add_key()
2697 ret = mt76_connac_mcu_sta_key_tlv(sta_key_conf, skb, key, cmd); in mt76_connac_mcu_add_key()
2717 ext_bss_idx = mvif->omac_idx - EXT_BSSID_START; in mt76_connac_mcu_bss_ext_tlv()
2725 ext->mbss_tsf_offset = cpu_to_le32(tsf_offset); in mt76_connac_mcu_bss_ext_tlv()
2733 bool enable) in mt76_connac_mcu_bss_basic_tlv() argument
2735 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt76_connac_mcu_bss_basic_tlv()
2736 u32 type = vif->p2p ? NETWORK_P2P : NETWORK_INFRA; in mt76_connac_mcu_bss_basic_tlv()
2743 switch (vif->type) { in mt76_connac_mcu_bss_basic_tlv()
2748 if (ieee80211_hw_check(phy->hw, SUPPORTS_MULTI_BSSID)) { in mt76_connac_mcu_bss_basic_tlv()
2749 u8 bssid_id = vif->bss_conf.bssid_indicator; in mt76_connac_mcu_bss_basic_tlv()
2750 struct wiphy *wiphy = phy->hw->wiphy; in mt76_connac_mcu_bss_basic_tlv()
2752 if (bssid_id > ilog2(wiphy->mbssid_max_interfaces)) in mt76_connac_mcu_bss_basic_tlv()
2753 return -EINVAL; in mt76_connac_mcu_bss_basic_tlv()
2755 bss->non_tx_bssid = vif->bss_conf.bssid_index; in mt76_connac_mcu_bss_basic_tlv()
2756 bss->max_bssid = bssid_id; in mt76_connac_mcu_bss_basic_tlv()
2760 if (enable) { in mt76_connac_mcu_bss_basic_tlv()
2764 vif->bss_conf.bssid); in mt76_connac_mcu_bss_basic_tlv()
2765 /* TODO: enable BSS_INFO_UAPSD & BSS_INFO_PM */ in mt76_connac_mcu_bss_basic_tlv()
2769 wcid = (struct mt76_wcid *)sta->drv_priv; in mt76_connac_mcu_bss_basic_tlv()
2770 wlan_idx = wcid->idx; in mt76_connac_mcu_bss_basic_tlv()
2783 bss->network_type = cpu_to_le32(type); in mt76_connac_mcu_bss_basic_tlv()
2784 bss->bmc_wcid_lo = to_wcid_lo(wlan_idx); in mt76_connac_mcu_bss_basic_tlv()
2785 bss->bmc_wcid_hi = to_wcid_hi(wlan_idx); in mt76_connac_mcu_bss_basic_tlv()
2786 bss->wmm_idx = mvif->wmm_idx; in mt76_connac_mcu_bss_basic_tlv()
2787 bss->active = enable; in mt76_connac_mcu_bss_basic_tlv()
2788 bss->cipher = mvif->cipher; in mt76_connac_mcu_bss_basic_tlv()
2790 if (vif->type != NL80211_IFTYPE_MONITOR) { in mt76_connac_mcu_bss_basic_tlv()
2791 struct cfg80211_chan_def *chandef = &phy->chandef; in mt76_connac_mcu_bss_basic_tlv()
2793 memcpy(bss->bssid, vif->bss_conf.bssid, ETH_ALEN); in mt76_connac_mcu_bss_basic_tlv()
2794 bss->bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int); in mt76_connac_mcu_bss_basic_tlv()
2795 bss->dtim_period = vif->bss_conf.dtim_period; in mt76_connac_mcu_bss_basic_tlv()
2796 bss->phy_mode = mt76_connac_get_phy_mode(phy, vif, in mt76_connac_mcu_bss_basic_tlv()
2797 chandef->chan->band, NULL); in mt76_connac_mcu_bss_basic_tlv()
2799 memcpy(bss->bssid, phy->macaddr, ETH_ALEN); in mt76_connac_mcu_bss_basic_tlv()
2892 for (i = 0; i < hdr->n_region; i++) { in mt76_connac_mcu_send_ram_firmware()
2897 region = (const void *)((const u8 *)hdr - in mt76_connac_mcu_send_ram_firmware()
2898 (hdr->n_region - i) * sizeof(*region)); in mt76_connac_mcu_send_ram_firmware()
2899 mode = mt76_connac_mcu_gen_dl_mode(dev, region->feature_set, in mt76_connac_mcu_send_ram_firmware()
2901 len = le32_to_cpu(region->len); in mt76_connac_mcu_send_ram_firmware()
2902 addr = le32_to_cpu(region->addr); in mt76_connac_mcu_send_ram_firmware()
2904 if (region->feature_set & FW_FEATURE_NON_DL) in mt76_connac_mcu_send_ram_firmware()
2907 if (region->feature_set & FW_FEATURE_OVERRIDE_ADDR) in mt76_connac_mcu_send_ram_firmware()
2912 dev_err(dev->dev, "Download request failed\n"); in mt76_connac_mcu_send_ram_firmware()
2919 dev_err(dev->dev, "Failed to send firmware.\n"); in mt76_connac_mcu_send_ram_firmware()
2942 ret = request_firmware(&fw, fw_wm, dev->dev); in mt76_connac2_load_ram()
2946 if (!fw || !fw->data || fw->size < sizeof(*hdr)) { in mt76_connac2_load_ram()
2947 dev_err(dev->dev, "Invalid firmware\n"); in mt76_connac2_load_ram()
2948 ret = -EINVAL; in mt76_connac2_load_ram()
2952 hdr = (const void *)(fw->data + fw->size - sizeof(*hdr)); in mt76_connac2_load_ram()
2953 dev_info(dev->dev, "WM Firmware Version: %.10s, Build Time: %.15s\n", in mt76_connac2_load_ram()
2954 hdr->fw_ver, hdr->build_date); in mt76_connac2_load_ram()
2956 ret = mt76_connac_mcu_send_ram_firmware(dev, hdr, fw->data, false); in mt76_connac2_load_ram()
2958 dev_err(dev->dev, "Failed to start WM firmware\n"); in mt76_connac2_load_ram()
2962 snprintf(dev->hw->wiphy->fw_version, in mt76_connac2_load_ram()
2963 sizeof(dev->hw->wiphy->fw_version), in mt76_connac2_load_ram()
2964 "%.10s-%.15s", hdr->fw_ver, hdr->build_date); in mt76_connac2_load_ram()
2971 ret = request_firmware(&fw, fw_wa, dev->dev); in mt76_connac2_load_ram()
2975 if (!fw || !fw->data || fw->size < sizeof(*hdr)) { in mt76_connac2_load_ram()
2976 dev_err(dev->dev, "Invalid firmware\n"); in mt76_connac2_load_ram()
2977 ret = -EINVAL; in mt76_connac2_load_ram()
2981 hdr = (const void *)(fw->data + fw->size - sizeof(*hdr)); in mt76_connac2_load_ram()
2982 dev_info(dev->dev, "WA Firmware Version: %.10s, Build Time: %.15s\n", in mt76_connac2_load_ram()
2983 hdr->fw_ver, hdr->build_date); in mt76_connac2_load_ram()
2985 ret = mt76_connac_mcu_send_ram_firmware(dev, hdr, fw->data, true); in mt76_connac2_load_ram()
2987 dev_err(dev->dev, "Failed to start WA firmware\n"); in mt76_connac2_load_ram()
2991 snprintf(dev->hw->wiphy->fw_version, in mt76_connac2_load_ram()
2992 sizeof(dev->hw->wiphy->fw_version), in mt76_connac2_load_ram()
2993 "%.10s-%.15s", hdr->fw_ver, hdr->build_date); in mt76_connac2_load_ram()
3024 dev_err(dev->dev, "Encryption type not support!\n"); in mt76_connac2_get_data_mode()
3043 dev_err(dev->dev, "Failed to get patch semaphore\n"); in mt76_connac2_load_patch()
3044 return -EAGAIN; in mt76_connac2_load_patch()
3047 ret = request_firmware(&fw, fw_name, dev->dev); in mt76_connac2_load_patch()
3051 if (!fw || !fw->data || fw->size < sizeof(*hdr)) { in mt76_connac2_load_patch()
3052 dev_err(dev->dev, "Invalid firmware\n"); in mt76_connac2_load_patch()
3053 ret = -EINVAL; in mt76_connac2_load_patch()
3057 hdr = (const void *)fw->data; in mt76_connac2_load_patch()
3058 dev_info(dev->dev, "HW/SW Version: 0x%x, Build Time: %.16s\n", in mt76_connac2_load_patch()
3059 be32_to_cpu(hdr->hw_sw_ver), hdr->build_date); in mt76_connac2_load_patch()
3061 for (i = 0; i < be32_to_cpu(hdr->desc.n_region); i++) { in mt76_connac2_load_patch()
3067 sec = (void *)(fw->data + sizeof(*hdr) + i * sizeof(*sec)); in mt76_connac2_load_patch()
3068 if ((be32_to_cpu(sec->type) & PATCH_SEC_TYPE_MASK) != in mt76_connac2_load_patch()
3070 ret = -EINVAL; in mt76_connac2_load_patch()
3074 addr = be32_to_cpu(sec->info.addr); in mt76_connac2_load_patch()
3075 len = be32_to_cpu(sec->info.len); in mt76_connac2_load_patch()
3076 dl = fw->data + be32_to_cpu(sec->offs); in mt76_connac2_load_patch()
3077 sec_info = be32_to_cpu(sec->info.sec_key_idx); in mt76_connac2_load_patch()
3082 dev_err(dev->dev, "Download request failed\n"); in mt76_connac2_load_patch()
3089 dev_err(dev->dev, "Failed to send patch\n"); in mt76_connac2_load_patch()
3096 dev_err(dev->dev, "Failed to start patch\n"); in mt76_connac2_load_patch()
3104 ret = -EAGAIN; in mt76_connac2_load_patch()
3105 dev_err(dev->dev, "Failed to release patch semaphore\n"); in mt76_connac2_load_patch()
3126 dev->mcu.timeout = 20 * HZ; in mt76_connac2_mcu_fill_message()
3128 seq = ++dev->mcu.msg_seq & 0xf; in mt76_connac2_mcu_fill_message()
3130 seq = ++dev->mcu.msg_seq & 0xf; in mt76_connac2_mcu_fill_message()
3138 val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len) | in mt76_connac2_mcu_fill_message()
3149 uni_txd->len = cpu_to_le16(skb->len - sizeof(uni_txd->txd)); in mt76_connac2_mcu_fill_message()
3150 uni_txd->option = MCU_CMD_UNI_EXT_ACK; in mt76_connac2_mcu_fill_message()
3151 uni_txd->cid = cpu_to_le16(mcu_cmd); in mt76_connac2_mcu_fill_message()
3152 uni_txd->s2d_index = MCU_S2D_H2N; in mt76_connac2_mcu_fill_message()
3153 uni_txd->pkt_type = MCU_PKT_ID; in mt76_connac2_mcu_fill_message()
3154 uni_txd->seq = seq; in mt76_connac2_mcu_fill_message()
3160 mcu_txd->len = cpu_to_le16(skb->len - sizeof(mcu_txd->txd)); in mt76_connac2_mcu_fill_message()
3161 mcu_txd->pq_id = cpu_to_le16(MCU_PQ_ID(MT_TX_PORT_IDX_MCU, in mt76_connac2_mcu_fill_message()
3163 mcu_txd->pkt_type = MCU_PKT_ID; in mt76_connac2_mcu_fill_message()
3164 mcu_txd->seq = seq; in mt76_connac2_mcu_fill_message()
3165 mcu_txd->cid = mcu_cmd; in mt76_connac2_mcu_fill_message()
3166 mcu_txd->ext_cid = FIELD_GET(__MCU_CMD_FIELD_EXT_ID, cmd); in mt76_connac2_mcu_fill_message()
3168 if (mcu_txd->ext_cid || (cmd & __MCU_CMD_FIELD_CE)) { in mt76_connac2_mcu_fill_message()
3170 mcu_txd->set_query = MCU_Q_QUERY; in mt76_connac2_mcu_fill_message()
3172 mcu_txd->set_query = MCU_Q_SET; in mt76_connac2_mcu_fill_message()
3173 mcu_txd->ext_cid_ack = !!mcu_txd->ext_cid; in mt76_connac2_mcu_fill_message()
3175 mcu_txd->set_query = MCU_Q_NA; in mt76_connac2_mcu_fill_message()
3179 mcu_txd->s2d_index = MCU_S2D_H2C; in mt76_connac2_mcu_fill_message()
3181 mcu_txd->s2d_index = MCU_S2D_H2N; in mt76_connac2_mcu_fill_message()