Lines Matching +full:traffic +full:- +full:patterns

1 // SPDX-License-Identifier: ISC
25 dev_err(mdev->dev, "Message %08x (seq %d) timeout\n", cmd, seq); in mt7925_mcu_parse_response()
28 return -ETIMEDOUT; in mt7925_mcu_parse_response()
31 rxd = (struct mt7925_mcu_rxd *)skb->data; in mt7925_mcu_parse_response()
32 if (seq != rxd->seq) in mt7925_mcu_parse_response()
33 return -EAGAIN; in mt7925_mcu_parse_response()
37 skb_pull(skb, sizeof(*rxd) - 4); in mt7925_mcu_parse_response()
38 ret = *skb->data; in mt7925_mcu_parse_response()
47 event = (struct mt7925_mcu_uni_event *)skb->data; in mt7925_mcu_parse_response()
48 ret = le32_to_cpu(event->status); in mt7925_mcu_parse_response()
50 if (mcu_cmd != event->cid) in mt7925_mcu_parse_response()
51 ret = -EAGAIN; in mt7925_mcu_parse_response()
101 return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(REG_ACCESS), in mt7925_mcu_regval()
104 ret = mt76_mcu_send_and_get_msg(&dev->mt76, in mt7925_mcu_regval()
110 res = (void *)skb->data; in mt7925_mcu_regval()
112 *val = le32_to_cpu(res->rf_reg.data); in mt7925_mcu_regval()
114 *val = le32_to_cpu(res->reg.data); in mt7925_mcu_regval()
126 struct ieee80211_vif *mvif = link_conf->vif; in mt7925_mcu_update_arp_filter()
128 int i, len = min_t(int, mvif->cfg.arp_addr_cnt, in mt7925_mcu_update_arp_filter()
138 .bss_idx = mconf->mt76.idx, in mt7925_mcu_update_arp_filter()
142 .len = cpu_to_le16(sizeof(req) - 4 + len * 2 * sizeof(__be32)), in mt7925_mcu_update_arp_filter()
150 return -ENOMEM; in mt7925_mcu_update_arp_filter()
154 skb_put_data(skb, &mvif->cfg.arp_addr_list[i], sizeof(__be32)); in mt7925_mcu_update_arp_filter()
166 struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv; in mt7925_connac_mcu_set_wow_ctrl()
167 struct mt76_dev *dev = phy->dev; in mt7925_connac_mcu_set_wow_ctrl()
177 .bss_idx = mvif->idx, in mt7925_connac_mcu_set_wow_ctrl()
191 if (wowlan->magic_pkt) in mt7925_connac_mcu_set_wow_ctrl()
193 if (wowlan->disconnect) in mt7925_connac_mcu_set_wow_ctrl()
196 if (wowlan->nd_config) { in mt7925_connac_mcu_set_wow_ctrl()
197 mt7925_mcu_sched_scan_req(phy, vif, wowlan->nd_config); in mt7925_connac_mcu_set_wow_ctrl()
201 if (wowlan->n_patterns) in mt7925_connac_mcu_set_wow_ctrl()
221 struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv; in mt7925_mcu_set_wow_pattern()
228 .bss_idx = mvif->idx, in mt7925_mcu_set_wow_pattern()
233 return -ENOMEM; in mt7925_mcu_set_wow_pattern()
237 tlv->tag = cpu_to_le16(UNI_SUSPEND_WOW_PATTERN); in mt7925_mcu_set_wow_pattern()
238 tlv->len = cpu_to_le16(sizeof(*tlv)); in mt7925_mcu_set_wow_pattern()
239 tlv->bss_idx = 0xF; in mt7925_mcu_set_wow_pattern()
240 tlv->data_len = pattern->pattern_len; in mt7925_mcu_set_wow_pattern()
241 tlv->enable = enable; in mt7925_mcu_set_wow_pattern()
242 tlv->index = index; in mt7925_mcu_set_wow_pattern()
243 tlv->offset = 0; in mt7925_mcu_set_wow_pattern()
245 memcpy(tlv->pattern, pattern->pattern, pattern->pattern_len); in mt7925_mcu_set_wow_pattern()
246 memcpy(tlv->mask, pattern->mask, DIV_ROUND_UP(pattern->pattern_len, 8)); in mt7925_mcu_set_wow_pattern()
255 bool suspend = !test_bit(MT76_STATE_RUNNING, &phy->state); in mt7925_mcu_set_suspend_iter()
256 struct ieee80211_hw *hw = phy->hw; in mt7925_mcu_set_suspend_iter()
257 struct cfg80211_wowlan *wowlan = hw->wiphy->wowlan_config; in mt7925_mcu_set_suspend_iter()
260 mt76_connac_mcu_set_gtk_rekey(phy->dev, vif, suspend); in mt7925_mcu_set_suspend_iter()
262 mt76_connac_mcu_set_suspend_mode(phy->dev, vif, suspend, 1, true); in mt7925_mcu_set_suspend_iter()
264 for (i = 0; i < wowlan->n_patterns; i++) in mt7925_mcu_set_suspend_iter()
265 mt7925_mcu_set_wow_pattern(phy->dev, vif, i, suspend, in mt7925_mcu_set_suspend_iter()
266 &wowlan->patterns[i]); in mt7925_mcu_set_suspend_iter()
276 struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv; in mt7925_mcu_connection_loss_iter()
279 if (mvif->idx != event->hdr.bss_idx) in mt7925_mcu_connection_loss_iter()
282 if (!(vif->driver_flags & IEEE80211_VIF_BEACON_FILTER) || in mt7925_mcu_connection_loss_iter()
283 vif->type != NL80211_IFTYPE_STATION) in mt7925_mcu_connection_loss_iter()
293 struct mt76_phy *mphy = &dev->mt76.phy; in mt7925_mcu_connection_loss_event()
296 event = (struct mt7925_uni_beacon_loss_event *)skb->data; in mt7925_mcu_connection_loss_event()
298 ieee80211_iterate_active_interfaces_atomic(mphy->hw, in mt7925_mcu_connection_loss_event()
306 struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv; in mt7925_mcu_roc_iter()
309 if (ieee80211_vif_is_mld(vif) && vif->type == NL80211_IFTYPE_STATION) in mt7925_mcu_roc_iter()
312 if (mvif->idx != grant->bss_idx) in mt7925_mcu_roc_iter()
315 mvif->band_idx = grant->dbdcband; in mt7925_mcu_roc_iter()
321 struct ieee80211_hw *hw = dev->mt76.hw; in mt7925_mcu_roc_handle_grant()
328 WARN_ON_ONCE((le16_to_cpu(grant->tag) != UNI_EVENT_ROC_GRANT)); in mt7925_mcu_roc_handle_grant()
330 if (grant->reqtype == MT7925_ROC_REQ_ROC) in mt7925_mcu_roc_handle_grant()
332 else if (grant->reqtype == MT7925_ROC_REQ_JOIN) in mt7925_mcu_roc_handle_grant()
336 dev->phy.roc_grant = true; in mt7925_mcu_roc_handle_grant()
337 wake_up(&dev->phy.roc_wait); in mt7925_mcu_roc_handle_grant()
338 duration = le32_to_cpu(grant->max_interval); in mt7925_mcu_roc_handle_grant()
339 mod_timer(&dev->phy.roc_timer, in mt7925_mcu_roc_handle_grant()
350 if (basic->hifsuspend) { in mt7925_mcu_handle_hif_ctrl_basic()
351 dev->hif_idle = true; in mt7925_mcu_handle_hif_ctrl_basic()
352 if (!(basic->hif_tx_traffic_status == HIF_TRAFFIC_IDLE && in mt7925_mcu_handle_hif_ctrl_basic()
353 basic->hif_rx_traffic_status == HIF_TRAFFIC_IDLE)) in mt7925_mcu_handle_hif_ctrl_basic()
354 dev_info(dev->mt76.dev, "Hif traffic not idle.\n"); in mt7925_mcu_handle_hif_ctrl_basic()
356 dev->hif_resumed = true; in mt7925_mcu_handle_hif_ctrl_basic()
358 wake_up(&dev->wait); in mt7925_mcu_handle_hif_ctrl_basic()
368 tlv = (struct tlv *)skb->data; in mt7925_mcu_uni_hif_ctrl_event()
369 tlv_len = skb->len; in mt7925_mcu_uni_hif_ctrl_event()
371 while (tlv_len > 0 && le16_to_cpu(tlv->len) <= tlv_len) { in mt7925_mcu_uni_hif_ctrl_event()
372 switch (le16_to_cpu(tlv->tag)) { in mt7925_mcu_uni_hif_ctrl_event()
379 tlv_len -= le16_to_cpu(tlv->len); in mt7925_mcu_uni_hif_ctrl_event()
380 tlv = (struct tlv *)((char *)(tlv) + le16_to_cpu(tlv->len)); in mt7925_mcu_uni_hif_ctrl_event()
392 while (i < skb->len) { in mt7925_mcu_uni_roc_event()
393 tlv = (struct tlv *)(skb->data + i); in mt7925_mcu_uni_roc_event()
395 switch (le16_to_cpu(tlv->tag)) { in mt7925_mcu_uni_roc_event()
403 i += le16_to_cpu(tlv->len); in mt7925_mcu_uni_roc_event()
410 struct mt76_phy *mphy = &dev->mt76.phy; in mt7925_mcu_scan_event()
411 struct mt792x_phy *phy = mphy->priv; in mt7925_mcu_scan_event()
413 spin_lock_bh(&dev->mt76.lock); in mt7925_mcu_scan_event()
414 __skb_queue_tail(&phy->scan_event_list, skb); in mt7925_mcu_scan_event()
415 spin_unlock_bh(&dev->mt76.lock); in mt7925_mcu_scan_event()
417 ieee80211_queue_delayed_work(mphy->hw, &phy->scan_work, in mt7925_mcu_scan_event()
435 tlv = (struct tlv *)skb->data; in mt7925_mcu_tx_done_event()
436 tlv_len = skb->len; in mt7925_mcu_tx_done_event()
438 while (tlv_len > 0 && le16_to_cpu(tlv->len) <= tlv_len) { in mt7925_mcu_tx_done_event()
439 switch (le16_to_cpu(tlv->tag)) { in mt7925_mcu_tx_done_event()
441 txs = (struct mt7925_mcu_txs_event *)tlv->data; in mt7925_mcu_tx_done_event()
442 mt7925_mac_add_txs(dev, txs->data); in mt7925_mcu_tx_done_event()
447 tlv_len -= le16_to_cpu(tlv->len); in mt7925_mcu_tx_done_event()
448 tlv = (struct tlv *)((char *)(tlv) + le16_to_cpu(tlv->len)); in mt7925_mcu_tx_done_event()
480 hdr = (struct mt7925_uni_debug_msg *)skb->data; in mt7925_mcu_uni_debug_msg_event()
482 if (hdr->id == 0x28) { in mt7925_mcu_uni_debug_msg_event()
484 wiphy_info(mt76_hw(dev)->wiphy, "%.*s", skb->len, skb->data); in mt7925_mcu_uni_debug_msg_event()
486 } else if (hdr->id != 0xa8) { in mt7925_mcu_uni_debug_msg_event()
490 if (hdr->type == 0) { /* idx log */ in mt7925_mcu_uni_debug_msg_event()
491 int i, ret, len = PAGE_SIZE - 1, nr_val; in mt7925_mcu_uni_debug_msg_event()
502 nr_val = (le16_to_cpu(hdr->len) - sizeof(*hdr)) / 4; in mt7925_mcu_uni_debug_msg_event()
503 val = (__le32 *)hdr->idx.data; in mt7925_mcu_uni_debug_msg_event()
510 len -= ret; in mt7925_mcu_uni_debug_msg_event()
513 wiphy_info(mt76_hw(dev)->wiphy, "idx: 0x%X,%d,%s", in mt7925_mcu_uni_debug_msg_event()
514 le32_to_cpu(hdr->idx.idx), nr_val, buf); in mt7925_mcu_uni_debug_msg_event()
516 } else if (hdr->type == 2) { /* str log */ in mt7925_mcu_uni_debug_msg_event()
517 wiphy_info(mt76_hw(dev)->wiphy, "%.*s", hdr->txt.len, hdr->txt.data); in mt7925_mcu_uni_debug_msg_event()
527 rxd = (struct mt7925_mcu_rxd *)skb->data; in mt7925_mcu_uni_rx_unsolicited_event()
529 switch (rxd->eid) { in mt7925_mcu_uni_rx_unsolicited_event()
549 dev->fw_assert = true; in mt7925_mcu_uni_rx_unsolicited_event()
550 mt76_connac_mcu_coredump_event(&dev->mt76, skb, &dev->coredump); in mt7925_mcu_uni_rx_unsolicited_event()
560 struct mt7925_mcu_rxd *rxd = (struct mt7925_mcu_rxd *)skb->data; in mt7925_mcu_rx_event()
565 if (rxd->option & MCU_UNI_CMD_UNSOLICITED_EVENT) { in mt7925_mcu_rx_event()
570 mt76_mcu_rx_event(&dev->mt76, skb); in mt7925_mcu_rx_event()
578 struct mt76_wcid *wcid = (struct mt76_wcid *)params->sta->drv_priv; in mt7925_mcu_sta_ba()
593 ba->ba_type = tx ? MT_BA_TYPE_ORIGINATOR : MT_BA_TYPE_RECIPIENT; in mt7925_mcu_sta_ba()
594 ba->winsize = cpu_to_le16(params->buf_size); in mt7925_mcu_sta_ba()
595 ba->ssn = cpu_to_le16(params->ssn); in mt7925_mcu_sta_ba()
596 ba->ba_en = enable << params->tid; in mt7925_mcu_sta_ba()
597 ba->amsdu = params->amsdu; in mt7925_mcu_sta_ba()
598 ba->tid = params->tid; in mt7925_mcu_sta_ba()
609 struct mt792x_sta *msta = (struct mt792x_sta *)params->sta->drv_priv; in mt7925_mcu_uni_tx_ba()
610 struct mt792x_vif *mvif = msta->vif; in mt7925_mcu_uni_tx_ba()
612 if (enable && !params->amsdu) in mt7925_mcu_uni_tx_ba()
613 msta->deflink.wcid.amsdu = false; in mt7925_mcu_uni_tx_ba()
615 return mt7925_mcu_sta_ba(&dev->mt76, &mvif->bss_conf.mt76, params, in mt7925_mcu_uni_tx_ba()
623 struct mt792x_sta *msta = (struct mt792x_sta *)params->sta->drv_priv; in mt7925_mcu_uni_rx_ba()
624 struct mt792x_vif *mvif = msta->vif; in mt7925_mcu_uni_rx_ba()
626 return mt7925_mcu_sta_ba(&dev->mt76, &mvif->bss_conf.mt76, params, in mt7925_mcu_uni_rx_ba()
643 .len = cpu_to_le16(sizeof(req) - 4), in mt7925_mcu_read_eeprom()
665 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_WM_UNI_CMD_QUERY(EFUSE_CTRL), in mt7925_mcu_read_eeprom()
670 res = (struct evt *)skb->data; in mt7925_mcu_read_eeprom()
671 *val = res->data[offset % MT7925_EEPROM_BLOCK_SIZE]; in mt7925_mcu_read_eeprom()
683 struct mt76_dev *mdev = &dev->mt76; in mt7925_load_clc()
684 struct mt792x_phy *phy = &dev->phy; in mt7925_load_clc()
689 dev->phy.clc_chan_conf = 0xff; in mt7925_load_clc()
691 mt76_is_usb(&dev->mt76)) in mt7925_load_clc()
694 if (mt76_is_mmio(&dev->mt76)) { in mt7925_load_clc()
701 ret = request_firmware(&fw, fw_name, mdev->dev); in mt7925_load_clc()
705 if (!fw || !fw->data || fw->size < sizeof(*hdr)) { in mt7925_load_clc()
706 dev_err(mdev->dev, "Invalid firmware\n"); in mt7925_load_clc()
707 ret = -EINVAL; in mt7925_load_clc()
711 hdr = (const void *)(fw->data + fw->size - sizeof(*hdr)); in mt7925_load_clc()
712 for (i = 0; i < hdr->n_region; i++) { in mt7925_load_clc()
713 region = (const void *)((const u8 *)hdr - in mt7925_load_clc()
714 (hdr->n_region - i) * sizeof(*region)); in mt7925_load_clc()
715 len = le32_to_cpu(region->len); in mt7925_load_clc()
718 if (offset + len > fw->size) { in mt7925_load_clc()
719 dev_err(mdev->dev, "Invalid firmware region\n"); in mt7925_load_clc()
720 ret = -EINVAL; in mt7925_load_clc()
724 if ((region->feature_set & FW_FEATURE_NON_DL) && in mt7925_load_clc()
725 region->type == FW_TYPE_CLC) { in mt7925_load_clc()
726 clc_base = (u8 *)(fw->data + offset); in mt7925_load_clc()
735 for (offset = 0; offset < len; offset += le32_to_cpu(clc->len)) { in mt7925_load_clc()
738 if (clc->idx >= ARRAY_SIZE(phy->clc)) in mt7925_load_clc()
742 if (phy->clc[clc->idx]) in mt7925_load_clc()
746 if ((clc->idx == MT792x_CLC_BE_CTRL && in mt7925_load_clc()
747 u8_get_bits(clc->t2.type, MT_EE_HW_TYPE_ENCAP) != hw_encap) || in mt7925_load_clc()
748 u8_get_bits(clc->t0.type, MT_EE_HW_TYPE_ENCAP) != hw_encap) in mt7925_load_clc()
751 phy->clc[clc->idx] = devm_kmemdup(mdev->dev, clc, in mt7925_load_clc()
752 le32_to_cpu(clc->len), in mt7925_load_clc()
755 if (!phy->clc[clc->idx]) { in mt7925_load_clc()
756 ret = -ENOMEM; in mt7925_load_clc()
780 .len = cpu_to_le16(sizeof(req) - 4), in mt7925_mcu_fw_log_2_host()
785 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_UNI_CMD(WSYS_CONFIG), in mt7925_mcu_fw_log_2_host()
800 .len = cpu_to_le16(sizeof(req) - 4), in mt7925_mcu_get_temperature()
806 struct mt792x_dev *dev = phy->dev; in mt7925_mcu_get_temperature()
810 ret = mt76_mcu_send_and_get_msg(&dev->mt76, in mt7925_mcu_get_temperature()
817 evt = (struct mt7925_thermal_evt *)skb->data; in mt7925_mcu_get_temperature()
819 temperature = le32_to_cpu(evt->temperature); in mt7925_mcu_get_temperature()
829 struct mt76_phy *mphy = &dev->mt76.phy; in mt7925_mcu_parse_phy_cap()
830 struct mt76_dev *mdev = mphy->dev; in mt7925_mcu_parse_phy_cap()
853 mdev->phy.antenna_mask = BIT(cap->nss) - 1; in mt7925_mcu_parse_phy_cap()
854 mdev->phy.chainmask = mdev->phy.antenna_mask; in mt7925_mcu_parse_phy_cap()
855 mdev->phy.cap.has_2ghz = cap->hw_path & BIT(WF0_24G); in mt7925_mcu_parse_phy_cap()
856 mdev->phy.cap.has_5ghz = cap->hw_path & BIT(WF0_5G); in mt7925_mcu_parse_phy_cap()
870 dev->phy.eml_cap = le16_to_cpu(cap->eml_cap); in mt7925_mcu_parse_eml_cap()
876 struct mt76_phy *mphy = &dev->mt76.phy; in mt7925_mcu_get_nic_capability()
884 .len = cpu_to_le16(sizeof(req) - 4), in mt7925_mcu_get_nic_capability()
893 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_UNI_CMD(CHIP_CONFIG), in mt7925_mcu_get_nic_capability()
898 hdr = (struct mt76_connac_cap_hdr *)skb->data; in mt7925_mcu_get_nic_capability()
899 if (skb->len < sizeof(*hdr)) { in mt7925_mcu_get_nic_capability()
900 ret = -EINVAL; in mt7925_mcu_get_nic_capability()
906 for (i = 0; i < le16_to_cpu(hdr->n_element); i++) { in mt7925_mcu_get_nic_capability()
907 struct tlv *tlv = (struct tlv *)skb->data; in mt7925_mcu_get_nic_capability()
910 if (skb->len < sizeof(*tlv)) in mt7925_mcu_get_nic_capability()
913 len = le16_to_cpu(tlv->len); in mt7925_mcu_get_nic_capability()
914 if (skb->len < len) in mt7925_mcu_get_nic_capability()
917 switch (le16_to_cpu(tlv->tag)) { in mt7925_mcu_get_nic_capability()
919 mphy->cap.has_6ghz = !!tlv->data[0]; in mt7925_mcu_get_nic_capability()
922 memcpy(mphy->macaddr, (void *)tlv->data, ETH_ALEN); in mt7925_mcu_get_nic_capability()
925 mt7925_mcu_parse_phy_cap(dev, tlv->data); in mt7925_mcu_get_nic_capability()
928 dev->phy.chip_cap = le64_to_cpu(*(__le64 *)tlv->data); in mt7925_mcu_get_nic_capability()
931 mt7925_mcu_parse_eml_cap(dev, tlv->data); in mt7925_mcu_get_nic_capability()
953 .len = cpu_to_le16(sizeof(req) - 4), in mt7925_mcu_chip_config()
963 return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(CHIP_CONFIG), in mt7925_mcu_chip_config()
989 set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); in mt7925_run_firmware()
1003 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mcu_sta_hdr_trans_tlv()
1010 hdr_trans->dis_rx_hdr_tran = true; in mt7925_mcu_sta_hdr_trans_tlv()
1012 if (vif->type == NL80211_IFTYPE_STATION) in mt7925_mcu_sta_hdr_trans_tlv()
1013 hdr_trans->to_ds = true; in mt7925_mcu_sta_hdr_trans_tlv()
1015 hdr_trans->from_ds = true; in mt7925_mcu_sta_hdr_trans_tlv()
1018 struct mt792x_sta *msta = (struct mt792x_sta *)link_sta->sta->drv_priv; in mt7925_mcu_sta_hdr_trans_tlv()
1021 mlink = mt792x_sta_to_link(msta, link_sta->link_id); in mt7925_mcu_sta_hdr_trans_tlv()
1022 wcid = &mlink->wcid; in mt7925_mcu_sta_hdr_trans_tlv()
1024 wcid = &mvif->sta.deflink.wcid; in mt7925_mcu_sta_hdr_trans_tlv()
1030 hdr_trans->dis_rx_hdr_tran = !test_bit(MT_WCID_FLAG_HDR_TRANS, &wcid->flags); in mt7925_mcu_sta_hdr_trans_tlv()
1031 if (test_bit(MT_WCID_FLAG_4ADDR, &wcid->flags)) { in mt7925_mcu_sta_hdr_trans_tlv()
1032 hdr_trans->to_ds = true; in mt7925_mcu_sta_hdr_trans_tlv()
1033 hdr_trans->from_ds = true; in mt7925_mcu_sta_hdr_trans_tlv()
1042 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mcu_wtbl_update_hdr_trans()
1043 struct ieee80211_link_sta *link_sta = sta ? &sta->deflink : NULL; in mt7925_mcu_wtbl_update_hdr_trans()
1049 msta = sta ? (struct mt792x_sta *)sta->drv_priv : &mvif->sta; in mt7925_mcu_wtbl_update_hdr_trans()
1055 skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, in mt7925_mcu_wtbl_update_hdr_trans()
1056 &mlink->wcid, in mt7925_mcu_wtbl_update_hdr_trans()
1063 return mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7925_mcu_wtbl_update_hdr_trans()
1082 .bss_idx = mconf->mt76.idx, in mt7925_mcu_set_tx()
1088 skb = mt76_mcu_msg_alloc(&dev->mt76, NULL, len); in mt7925_mcu_set_tx()
1090 return -ENOMEM; in mt7925_mcu_set_tx()
1095 struct ieee80211_tx_queue_params *q = &mconf->queue_params[ac]; in mt7925_mcu_set_tx()
1102 e->set = WMM_PARAM_SET; in mt7925_mcu_set_tx()
1103 e->queue = ac; in mt7925_mcu_set_tx()
1104 e->aifs = q->aifs; in mt7925_mcu_set_tx()
1105 e->txop = cpu_to_le16(q->txop); in mt7925_mcu_set_tx()
1107 if (q->cw_min) in mt7925_mcu_set_tx()
1108 e->cw_min = fls(q->cw_min); in mt7925_mcu_set_tx()
1110 e->cw_min = 5; in mt7925_mcu_set_tx()
1112 if (q->cw_max) in mt7925_mcu_set_tx()
1113 e->cw_max = fls(q->cw_max); in mt7925_mcu_set_tx()
1115 e->cw_max = 10; in mt7925_mcu_set_tx()
1118 return mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7925_mcu_set_tx()
1130 struct mt792x_vif *mvif = msta->vif; in mt7925_mcu_sta_key_tlv()
1131 struct mt792x_bss_conf *mconf = mt792x_vif_to_link(mvif, wcid->link_id); in mt7925_mcu_sta_key_tlv()
1137 sta = msta == &mvif->sta ? in mt7925_mcu_sta_key_tlv()
1144 sec->bss_idx = mconf->mt76.idx; in mt7925_mcu_sta_key_tlv()
1145 sec->is_authenticator = 0; in mt7925_mcu_sta_key_tlv()
1146 sec->mgmt_prot = 1; /* only used in MLO mode */ in mt7925_mcu_sta_key_tlv()
1147 sec->wlan_idx = (u8)wcid->idx; in mt7925_mcu_sta_key_tlv()
1152 sec->tx_key = 1; in mt7925_mcu_sta_key_tlv()
1153 sec->key_type = 1; in mt7925_mcu_sta_key_tlv()
1154 link_sta = mt792x_sta_to_link_sta(vif, sta, wcid->link_id); in mt7925_mcu_sta_key_tlv()
1157 memcpy(sec->peer_addr, link_sta->addr, ETH_ALEN); in mt7925_mcu_sta_key_tlv()
1161 link_conf = mt792x_vif_to_bss_conf(vif, wcid->link_id); in mt7925_mcu_sta_key_tlv()
1164 memcpy(sec->peer_addr, link_conf->bssid, ETH_ALEN); in mt7925_mcu_sta_key_tlv()
1170 sec->add = 1; in mt7925_mcu_sta_key_tlv()
1171 cipher = mt7925_mcu_get_cipher(key->cipher); in mt7925_mcu_sta_key_tlv()
1173 return -EOPNOTSUPP; in mt7925_mcu_sta_key_tlv()
1176 sec->cipher_id = CONNAC3_CIPHER_BIP_CMAC_128; in mt7925_mcu_sta_key_tlv()
1177 sec->key_id = sta_key_conf->keyidx; in mt7925_mcu_sta_key_tlv()
1178 sec->key_len = 32; in mt7925_mcu_sta_key_tlv()
1179 memcpy(sec->key, sta_key_conf->key, 16); in mt7925_mcu_sta_key_tlv()
1180 memcpy(sec->key + 16, key->key, 16); in mt7925_mcu_sta_key_tlv()
1182 sec->cipher_id = cipher; in mt7925_mcu_sta_key_tlv()
1183 sec->key_id = key->keyidx; in mt7925_mcu_sta_key_tlv()
1184 sec->key_len = key->keylen; in mt7925_mcu_sta_key_tlv()
1185 memcpy(sec->key, key->key, key->keylen); in mt7925_mcu_sta_key_tlv()
1189 memcpy(sec->key + 16, key->key + 24, 8); in mt7925_mcu_sta_key_tlv()
1190 memcpy(sec->key + 24, key->key + 16, 8); in mt7925_mcu_sta_key_tlv()
1195 memcpy(sta_key_conf->key, key->key, key->keylen); in mt7925_mcu_sta_key_tlv()
1196 sta_key_conf->keyidx = key->keyidx; in mt7925_mcu_sta_key_tlv()
1200 sec->add = 0; in mt7925_mcu_sta_key_tlv()
1212 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mcu_add_key()
1213 struct mt792x_bss_conf *mconf = mt792x_vif_to_link(mvif, wcid->link_id); in mt7925_mcu_add_key()
1217 skb = __mt76_connac_mcu_alloc_sta_req(dev, &mconf->mt76, wcid, in mt7925_mcu_add_key()
1232 struct mt792x_vif *mvif = mconf->vif; in mt7925_mcu_set_mlo_roc()
1265 if (!mconf || hweight16(vif->valid_links) < 2 || in mt7925_mcu_set_mlo_roc()
1267 return -EPERM; in mt7925_mcu_set_mlo_roc()
1270 links[i].id = i ? __ffs(~BIT(mconf->link_id) & sel_links) : in mt7925_mcu_set_mlo_roc()
1271 mconf->link_id; in mt7925_mcu_set_mlo_roc()
1274 return -EPERM; in mt7925_mcu_set_mlo_roc()
1276 links[i].chan = link_conf->chanreq.oper.chan; in mt7925_mcu_set_mlo_roc()
1278 return -EPERM; in mt7925_mcu_set_mlo_roc()
1281 links[i].tag = links[i].id == mconf->link_id ? in mt7925_mcu_set_mlo_roc()
1284 is_AG_band |= links[i].chan->band == NL80211_BAND_2GHZ; in mt7925_mcu_set_mlo_roc()
1287 if (vif->cfg.eml_cap & IEEE80211_EML_CAP_EMLSR_SUPP) in mt7925_mcu_set_mlo_roc()
1293 for (i = 0; i < ARRAY_SIZE(links) && i < hweight16(vif->active_links); i++) { in mt7925_mcu_set_mlo_roc()
1298 center_ch = ieee80211_frequency_to_channel(chan->center_freq); in mt7925_mcu_set_mlo_roc()
1304 req.roc[i].bss_idx = links[i].mconf->mt76.idx; in mt7925_mcu_set_mlo_roc()
1305 req.roc[i].control_channel = chan->hw_value; in mt7925_mcu_set_mlo_roc()
1318 if (chan->hw_value < center_ch) in mt7925_mcu_set_mlo_roc()
1320 else if (chan->hw_value > center_ch) in mt7925_mcu_set_mlo_roc()
1323 req.roc[i].band = ch_band[chan->band]; in mt7925_mcu_set_mlo_roc()
1326 return mt76_mcu_send_msg(&mvif->phy->dev->mt76, MCU_UNI_CMD(ROC), in mt7925_mcu_set_mlo_roc()
1334 int center_ch = ieee80211_frequency_to_channel(chan->center_freq); in mt7925_mcu_set_roc()
1335 struct mt792x_dev *dev = phy->dev; in mt7925_mcu_set_roc()
1348 .bss_idx = mconf->mt76.idx, in mt7925_mcu_set_roc()
1349 .control_channel = chan->hw_value, in mt7925_mcu_set_roc()
1358 if (chan->hw_value < center_ch) in mt7925_mcu_set_roc()
1360 else if (chan->hw_value > center_ch) in mt7925_mcu_set_roc()
1363 switch (chan->band) { in mt7925_mcu_set_roc()
1375 return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(ROC), in mt7925_mcu_set_roc()
1382 struct mt792x_dev *dev = phy->dev; in mt7925_mcu_abort_roc()
1400 .bss_idx = mconf->mt76.idx, in mt7925_mcu_abort_roc()
1405 return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(ROC), in mt7925_mcu_abort_roc()
1421 .len = cpu_to_le16(sizeof(req) - 4), in mt7925_mcu_set_eeprom()
1426 return mt76_mcu_send_and_get_msg(&dev->mt76, MCU_UNI_CMD(EFUSE_CTRL), in mt7925_mcu_set_eeprom()
1453 .bss_idx = mconf->mt76.idx, in mt7925_mcu_uni_bss_ps()
1458 .ps_state = link_conf->vif->cfg.ps ? 2 : 0, in mt7925_mcu_uni_bss_ps()
1462 if (link_conf->vif->type != NL80211_IFTYPE_STATION) in mt7925_mcu_uni_bss_ps()
1463 return -EOPNOTSUPP; in mt7925_mcu_uni_bss_ps()
1465 return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(BSS_INFO_UPDATE), in mt7925_mcu_uni_bss_ps()
1490 .bss_idx = mconf->mt76.idx, in mt7925_mcu_uni_bss_bcnft()
1495 .bcn_interval = cpu_to_le16(link_conf->beacon_int), in mt7925_mcu_uni_bss_bcnft()
1496 .dtim_period = link_conf->dtim_period, in mt7925_mcu_uni_bss_bcnft()
1500 if (link_conf->vif->type != NL80211_IFTYPE_STATION) in mt7925_mcu_uni_bss_bcnft()
1503 return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(BSS_INFO_UPDATE), in mt7925_mcu_uni_bss_bcnft()
1529 .bss_idx = mconf->mt76.idx, in mt7925_mcu_set_bss_pm()
1534 .dtim_period = link_conf->dtim_period, in mt7925_mcu_set_bss_pm()
1535 .bcn_interval = cpu_to_le16(link_conf->beacon_int), in mt7925_mcu_set_bss_pm()
1549 .bss_idx = mconf->mt76.idx, in mt7925_mcu_set_bss_pm()
1558 err = mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(BSS_INFO_UPDATE), in mt7925_mcu_set_bss_pm()
1563 return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(BSS_INFO_UPDATE), in mt7925_mcu_set_bss_pm()
1570 if (!link_sta->he_cap.has_he) in mt7925_mcu_sta_he_tlv()
1573 mt76_connac_mcu_sta_he_tlv_v2(skb, link_sta->sta); in mt7925_mcu_sta_he_tlv()
1583 if (!link_sta->he_6ghz_capa.capa) in mt7925_mcu_sta_he_6g_tlv()
1589 he_6g->capa = link_sta->he_6ghz_capa.capa; in mt7925_mcu_sta_he_6g_tlv()
1600 if (!link_sta->eht_cap.has_eht) in mt7925_mcu_sta_eht_tlv()
1603 mcs_map = &link_sta->eht_cap.eht_mcs_nss_supp; in mt7925_mcu_sta_eht_tlv()
1604 elem = &link_sta->eht_cap.eht_cap_elem; in mt7925_mcu_sta_eht_tlv()
1609 eht->tid_bitmap = 0xff; in mt7925_mcu_sta_eht_tlv()
1610 eht->mac_cap = cpu_to_le16(*(u16 *)elem->mac_cap_info); in mt7925_mcu_sta_eht_tlv()
1611 eht->phy_cap = cpu_to_le64(*(u64 *)elem->phy_cap_info); in mt7925_mcu_sta_eht_tlv()
1612 eht->phy_cap_ext = cpu_to_le64(elem->phy_cap_info[8]); in mt7925_mcu_sta_eht_tlv()
1614 if (link_sta->bandwidth == IEEE80211_STA_RX_BW_20) in mt7925_mcu_sta_eht_tlv()
1615 memcpy(eht->mcs_map_bw20, &mcs_map->only_20mhz, sizeof(eht->mcs_map_bw20)); in mt7925_mcu_sta_eht_tlv()
1616 memcpy(eht->mcs_map_bw80, &mcs_map->bw._80, sizeof(eht->mcs_map_bw80)); in mt7925_mcu_sta_eht_tlv()
1617 memcpy(eht->mcs_map_bw160, &mcs_map->bw._160, sizeof(eht->mcs_map_bw160)); in mt7925_mcu_sta_eht_tlv()
1626 if (!link_sta->ht_cap.ht_supported) in mt7925_mcu_sta_ht_tlv()
1632 ht->ht_cap = cpu_to_le16(link_sta->ht_cap.cap); in mt7925_mcu_sta_ht_tlv()
1642 if (!link_sta->he_6ghz_capa.capa && !link_sta->vht_cap.vht_supported) in mt7925_mcu_sta_vht_tlv()
1648 vht->vht_cap = cpu_to_le32(link_sta->vht_cap.cap); in mt7925_mcu_sta_vht_tlv()
1649 vht->vht_rx_mcs_map = link_sta->vht_cap.vht_mcs.rx_mcs_map; in mt7925_mcu_sta_vht_tlv()
1650 vht->vht_tx_mcs_map = link_sta->vht_cap.vht_mcs.tx_mcs_map; in mt7925_mcu_sta_vht_tlv()
1658 struct mt792x_sta *msta = (struct mt792x_sta *)link_sta->sta->drv_priv; in mt7925_mcu_sta_amsdu_tlv()
1663 if (vif->type != NL80211_IFTYPE_STATION && in mt7925_mcu_sta_amsdu_tlv()
1664 vif->type != NL80211_IFTYPE_AP) in mt7925_mcu_sta_amsdu_tlv()
1667 if (!link_sta->agg.max_amsdu_len) in mt7925_mcu_sta_amsdu_tlv()
1672 amsdu->max_amsdu_num = 8; in mt7925_mcu_sta_amsdu_tlv()
1673 amsdu->amsdu_en = true; in mt7925_mcu_sta_amsdu_tlv()
1675 mlink = mt792x_sta_to_link(msta, link_sta->link_id); in mt7925_mcu_sta_amsdu_tlv()
1676 mlink->wcid.amsdu = true; in mt7925_mcu_sta_amsdu_tlv()
1678 switch (link_sta->agg.max_amsdu_len) { in mt7925_mcu_sta_amsdu_tlv()
1680 amsdu->max_mpdu_size = in mt7925_mcu_sta_amsdu_tlv()
1685 amsdu->max_mpdu_size = IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; in mt7925_mcu_sta_amsdu_tlv()
1688 amsdu->max_mpdu_size = IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; in mt7925_mcu_sta_amsdu_tlv()
1698 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mcu_sta_phy_tlv()
1706 link_conf = mt792x_vif_to_bss_conf(vif, link_sta->link_id); in mt7925_mcu_sta_phy_tlv()
1707 mconf = mt792x_vif_to_link(mvif, link_sta->link_id); in mt7925_mcu_sta_phy_tlv()
1708 chandef = mconf->mt76.ctx ? &mconf->mt76.ctx->def : in mt7925_mcu_sta_phy_tlv()
1709 &link_conf->chanreq.oper; in mt7925_mcu_sta_phy_tlv()
1713 phy->phy_type = mt76_connac_get_phy_mode_v2(mvif->phy->mt76, vif, in mt7925_mcu_sta_phy_tlv()
1714 chandef->chan->band, in mt7925_mcu_sta_phy_tlv()
1716 phy->basic_rate = cpu_to_le16((u16)link_conf->basic_rates); in mt7925_mcu_sta_phy_tlv()
1717 if (link_sta->ht_cap.ht_supported) { in mt7925_mcu_sta_phy_tlv()
1718 af = link_sta->ht_cap.ampdu_factor; in mt7925_mcu_sta_phy_tlv()
1719 mm = link_sta->ht_cap.ampdu_density; in mt7925_mcu_sta_phy_tlv()
1722 if (link_sta->vht_cap.vht_supported) { in mt7925_mcu_sta_phy_tlv()
1724 link_sta->vht_cap.cap); in mt7925_mcu_sta_phy_tlv()
1729 if (link_sta->he_6ghz_capa.capa) { in mt7925_mcu_sta_phy_tlv()
1730 af = le16_get_bits(link_sta->he_6ghz_capa.capa, in mt7925_mcu_sta_phy_tlv()
1732 mm = le16_get_bits(link_sta->he_6ghz_capa.capa, in mt7925_mcu_sta_phy_tlv()
1736 phy->ampdu = FIELD_PREP(IEEE80211_HT_AMPDU_PARM_FACTOR, af) | in mt7925_mcu_sta_phy_tlv()
1738 phy->max_ampdu_len = af; in mt7925_mcu_sta_phy_tlv()
1761 state->state = sta_state; in mt7925_mcu_sta_state_v2_tlv()
1763 if (link_sta->vht_cap.vht_supported) { in mt7925_mcu_sta_state_v2_tlv()
1764 state->vht_opmode = link_sta->bandwidth; in mt7925_mcu_sta_state_v2_tlv()
1765 state->vht_opmode |= link_sta->rx_nss << in mt7925_mcu_sta_state_v2_tlv()
1775 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mcu_sta_rate_ctrl_tlv()
1784 link_conf = mt792x_vif_to_bss_conf(vif, link_sta->link_id); in mt7925_mcu_sta_rate_ctrl_tlv()
1785 mconf = mt792x_vif_to_link(mvif, link_sta->link_id); in mt7925_mcu_sta_rate_ctrl_tlv()
1786 chandef = mconf->mt76.ctx ? &mconf->mt76.ctx->def : in mt7925_mcu_sta_rate_ctrl_tlv()
1787 &link_conf->chanreq.oper; in mt7925_mcu_sta_rate_ctrl_tlv()
1788 band = chandef->chan->band; in mt7925_mcu_sta_rate_ctrl_tlv()
1793 supp_rates = link_sta->supp_rates[band]; in mt7925_mcu_sta_rate_ctrl_tlv()
1800 ra_info->legacy = cpu_to_le16(supp_rates); in mt7925_mcu_sta_rate_ctrl_tlv()
1802 if (link_sta->ht_cap.ht_supported) in mt7925_mcu_sta_rate_ctrl_tlv()
1803 memcpy(ra_info->rx_mcs_bitmask, in mt7925_mcu_sta_rate_ctrl_tlv()
1804 link_sta->ht_cap.mcs.rx_mask, in mt7925_mcu_sta_rate_ctrl_tlv()
1812 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mcu_sta_eht_mld_tlv()
1813 struct wiphy *wiphy = mvif->phy->mt76->hw->wiphy; in mt7925_mcu_sta_eht_mld_tlv()
1821 eht_mld->mld_type = 0xff; in mt7925_mcu_sta_eht_mld_tlv()
1831 eml_cap = (vif->cfg.eml_cap & (IEEE80211_EML_CAP_EMLSR_SUPP | in mt7925_mcu_sta_eht_mld_tlv()
1833 (ext_capa->eml_capabilities & (IEEE80211_EML_CAP_EMLSR_PADDING_DELAY | in mt7925_mcu_sta_eht_mld_tlv()
1837 eht_mld->eml_cap[0] = u16_get_bits(eml_cap, GENMASK(7, 0)); in mt7925_mcu_sta_eht_mld_tlv()
1838 eht_mld->eml_cap[1] = u16_get_bits(eml_cap, GENMASK(15, 8)); in mt7925_mcu_sta_eht_mld_tlv()
1840 eht_mld->str_cap[0] = BIT(1); in mt7925_mcu_sta_eht_mld_tlv()
1848 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mcu_sta_mld_tlv()
1849 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; in mt7925_mcu_sta_mld_tlv()
1850 unsigned long valid = mvif->valid_links; in mt7925_mcu_sta_mld_tlv()
1859 memcpy(mld->mac_addr, sta->addr, ETH_ALEN); in mt7925_mcu_sta_mld_tlv()
1860 mld->primary_id = cpu_to_le16(msta->deflink.wcid.idx); in mt7925_mcu_sta_mld_tlv()
1861 mld->wlan_id = cpu_to_le16(msta->deflink.wcid.idx); in mt7925_mcu_sta_mld_tlv()
1862 mld->link_num = min_t(u8, hweight16(mvif->valid_links), 2); in mt7925_mcu_sta_mld_tlv()
1865 if (cnt == mld->link_num) in mt7925_mcu_sta_mld_tlv()
1870 mld->link[cnt].wlan_id = cpu_to_le16(mlink->wcid.idx); in mt7925_mcu_sta_mld_tlv()
1871 mld->link[cnt++].bss_idx = mconf->mt76.idx; in mt7925_mcu_sta_mld_tlv()
1873 if (mlink != &msta->deflink) in mt7925_mcu_sta_mld_tlv()
1874 mld->secondary_id = cpu_to_le16(mlink->wcid.idx); in mt7925_mcu_sta_mld_tlv()
1886 rem->action = 0; in mt7925_mcu_sta_remove_tlv()
1893 struct mt792x_vif *mvif = (struct mt792x_vif *)info->vif->drv_priv; in mt7925_mcu_sta_cmd()
1894 struct mt76_dev *dev = phy->dev; in mt7925_mcu_sta_cmd()
1898 mconf = mt792x_vif_to_link(mvif, info->wcid->link_id); in mt7925_mcu_sta_cmd()
1900 skb = __mt76_connac_mcu_alloc_sta_req(dev, &mconf->mt76, info->wcid, in mt7925_mcu_sta_cmd()
1905 if (info->enable && info->link_sta) { in mt7925_mcu_sta_cmd()
1906 mt76_connac_mcu_sta_basic_tlv(dev, skb, info->link_conf, in mt7925_mcu_sta_cmd()
1907 info->link_sta, in mt7925_mcu_sta_cmd()
1908 info->enable, info->newly); in mt7925_mcu_sta_cmd()
1909 mt7925_mcu_sta_phy_tlv(skb, info->vif, info->link_sta); in mt7925_mcu_sta_cmd()
1910 mt7925_mcu_sta_ht_tlv(skb, info->link_sta); in mt7925_mcu_sta_cmd()
1911 mt7925_mcu_sta_vht_tlv(skb, info->link_sta); in mt7925_mcu_sta_cmd()
1912 mt76_connac_mcu_sta_uapsd(skb, info->vif, info->link_sta->sta); in mt7925_mcu_sta_cmd()
1913 mt7925_mcu_sta_amsdu_tlv(skb, info->vif, info->link_sta); in mt7925_mcu_sta_cmd()
1914 mt7925_mcu_sta_he_tlv(skb, info->link_sta); in mt7925_mcu_sta_cmd()
1915 mt7925_mcu_sta_he_6g_tlv(skb, info->link_sta); in mt7925_mcu_sta_cmd()
1916 mt7925_mcu_sta_eht_tlv(skb, info->link_sta); in mt7925_mcu_sta_cmd()
1917 mt7925_mcu_sta_rate_ctrl_tlv(skb, info->vif, in mt7925_mcu_sta_cmd()
1918 info->link_sta); in mt7925_mcu_sta_cmd()
1919 mt7925_mcu_sta_state_v2_tlv(phy, skb, info->link_sta, in mt7925_mcu_sta_cmd()
1920 info->vif, info->rcpi, in mt7925_mcu_sta_cmd()
1921 info->state); in mt7925_mcu_sta_cmd()
1923 if (info->state != MT76_STA_INFO_STATE_NONE) { in mt7925_mcu_sta_cmd()
1924 mt7925_mcu_sta_mld_tlv(skb, info->vif, info->link_sta->sta); in mt7925_mcu_sta_cmd()
1925 mt7925_mcu_sta_eht_mld_tlv(skb, info->vif, info->link_sta->sta); in mt7925_mcu_sta_cmd()
1929 if (!info->enable) { in mt7925_mcu_sta_cmd()
1934 mt7925_mcu_sta_hdr_trans_tlv(skb, info->vif, info->link_sta); in mt7925_mcu_sta_cmd()
1937 return mt76_mcu_skb_send_msg(dev, skb, info->cmd, true); in mt7925_mcu_sta_cmd()
1945 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mcu_sta_update()
1946 int rssi = -ewma_rssi_read(&mvif->bss_conf.rssi); in mt7925_mcu_sta_update()
1950 .link_conf = &vif->bss_conf, in mt7925_mcu_sta_update()
1961 msta = (struct mt792x_sta *)link_sta->sta->drv_priv; in mt7925_mcu_sta_update()
1962 mlink = mt792x_sta_to_link(msta, link_sta->link_id); in mt7925_mcu_sta_update()
1964 info.wcid = link_sta ? &mlink->wcid : &mvif->sta.deflink.wcid; in mt7925_mcu_sta_update()
1967 return mt7925_mcu_sta_cmd(&dev->mphy, &info); in mt7925_mcu_sta_update()
1979 err = mt7925_mcu_uni_bss_bcnft(dev, &vif->bss_conf, true); in mt7925_mcu_set_beacon_filter()
1988 err = mt7925_mcu_set_bss_pm(dev, &vif->bss_conf, false); in mt7925_mcu_set_beacon_filter()
2004 .len = cpu_to_le16(sizeof(req) - 4), in mt7925_get_txpwr_info()
2011 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_UNI_CMD(TXPOWER), in mt7925_get_txpwr_info()
2016 event = (struct mt7925_txpwr_event *)skb->data; in mt7925_get_txpwr_info()
2017 memcpy(txpwr, &event->txpwr, sizeof(event->txpwr)); in mt7925_get_txpwr_info()
2049 mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(SNIFFER), &req, sizeof(req), true); in mt7925_mcu_set_sniffer()
2051 return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(SNIFFER), &req, sizeof(req), in mt7925_mcu_set_sniffer()
2058 struct mt76_phy *mphy = vif->phy->mt76; in mt7925_mcu_config_sniffer()
2059 struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &mphy->chandef; in mt7925_mcu_config_sniffer()
2060 int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2; in mt7925_mcu_config_sniffer()
2104 .control_ch = chandef->chan->hw_value, in mt7925_mcu_config_sniffer()
2110 if (chandef->chan->band < ARRAY_SIZE(ch_band)) in mt7925_mcu_config_sniffer()
2111 req.tlv.ch_band = ch_band[chandef->chan->band]; in mt7925_mcu_config_sniffer()
2112 if (chandef->width < ARRAY_SIZE(ch_width)) in mt7925_mcu_config_sniffer()
2113 req.tlv.bw = ch_width[chandef->width]; in mt7925_mcu_config_sniffer()
2123 return mt76_mcu_send_msg(mphy->dev, MCU_UNI_CMD(SNIFFER), in mt7925_mcu_config_sniffer()
2133 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mcu_uni_add_beacon_offload()
2160 .bss_idx = mvif->bss_conf.mt76.idx, in mt7925_mcu_uni_add_beacon_offload()
2176 return -EOPNOTSUPP; in mt7925_mcu_uni_add_beacon_offload()
2180 return -EINVAL; in mt7925_mcu_uni_add_beacon_offload()
2184 dev_err(dev->mt76.dev, "beacon format err\n"); in mt7925_mcu_uni_add_beacon_offload()
2186 return -EINVAL; in mt7925_mcu_uni_add_beacon_offload()
2189 if (skb->len > 512) { in mt7925_mcu_uni_add_beacon_offload()
2190 dev_err(dev->mt76.dev, "beacon size limit exceed\n"); in mt7925_mcu_uni_add_beacon_offload()
2192 return -EINVAL; in mt7925_mcu_uni_add_beacon_offload()
2195 memcpy(req.beacon_tlv.pkt, skb->data, skb->len); in mt7925_mcu_uni_add_beacon_offload()
2196 req.beacon_tlv.pkt_len = cpu_to_le16(skb->len); in mt7925_mcu_uni_add_beacon_offload()
2197 offs.tim_offset -= cap_offs; in mt7925_mcu_uni_add_beacon_offload()
2203 csa_offs = offs.cntdwn_counter_offs[0] - cap_offs - 4; in mt7925_mcu_uni_add_beacon_offload()
2208 return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(BSS_INFO_UPDATE), in mt7925_mcu_uni_add_beacon_offload()
2217 struct cfg80211_chan_def *chandef = ctx ? &ctx->def : in mt7925_mcu_bss_rlm_tlv()
2218 &link_conf->chanreq.oper; in mt7925_mcu_bss_rlm_tlv()
2219 int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2; in mt7925_mcu_bss_rlm_tlv()
2220 enum nl80211_band band = chandef->chan->band; in mt7925_mcu_bss_rlm_tlv()
2226 req->control_channel = chandef->chan->hw_value; in mt7925_mcu_bss_rlm_tlv()
2227 req->center_chan = ieee80211_frequency_to_channel(freq1); in mt7925_mcu_bss_rlm_tlv()
2228 req->center_chan2 = 0; in mt7925_mcu_bss_rlm_tlv()
2229 req->tx_streams = hweight8(phy->antenna_mask); in mt7925_mcu_bss_rlm_tlv()
2230 req->ht_op_info = 4; /* set HT 40M allowed */ in mt7925_mcu_bss_rlm_tlv()
2231 req->rx_streams = hweight8(phy->antenna_mask); in mt7925_mcu_bss_rlm_tlv()
2232 req->center_chan2 = 0; in mt7925_mcu_bss_rlm_tlv()
2233 req->sco = 0; in mt7925_mcu_bss_rlm_tlv()
2234 req->band = 1; in mt7925_mcu_bss_rlm_tlv()
2238 req->band = 1; in mt7925_mcu_bss_rlm_tlv()
2241 req->band = 2; in mt7925_mcu_bss_rlm_tlv()
2244 req->band = 3; in mt7925_mcu_bss_rlm_tlv()
2250 switch (chandef->width) { in mt7925_mcu_bss_rlm_tlv()
2252 req->bw = CMD_CBW_40MHZ; in mt7925_mcu_bss_rlm_tlv()
2255 req->bw = CMD_CBW_80MHZ; in mt7925_mcu_bss_rlm_tlv()
2258 req->bw = CMD_CBW_8080MHZ; in mt7925_mcu_bss_rlm_tlv()
2259 req->center_chan2 = ieee80211_frequency_to_channel(freq2); in mt7925_mcu_bss_rlm_tlv()
2262 req->bw = CMD_CBW_160MHZ; in mt7925_mcu_bss_rlm_tlv()
2265 req->bw = CMD_CBW_5MHZ; in mt7925_mcu_bss_rlm_tlv()
2268 req->bw = CMD_CBW_10MHZ; in mt7925_mcu_bss_rlm_tlv()
2273 req->bw = CMD_CBW_20MHZ; in mt7925_mcu_bss_rlm_tlv()
2274 req->ht_op_info = 0; in mt7925_mcu_bss_rlm_tlv()
2278 if (req->control_channel < req->center_chan) in mt7925_mcu_bss_rlm_tlv()
2279 req->sco = 1; /* SCA */ in mt7925_mcu_bss_rlm_tlv()
2280 else if (req->control_channel > req->center_chan) in mt7925_mcu_bss_rlm_tlv()
2281 req->sco = 3; /* SCB */ in mt7925_mcu_bss_rlm_tlv()
2288 .bss_idx = mvif->idx, in __mt7925_mcu_alloc_bss_req()
2294 return ERR_PTR(-ENOMEM); in __mt7925_mcu_alloc_bss_req()
2307 skb = __mt7925_mcu_alloc_bss_req(phy->dev, mvif, in mt7925_mcu_set_chctx()
2314 return mt76_mcu_skb_send_msg(phy->dev, skb, in mt7925_mcu_set_chctx()
2329 he_6ghz_capa = &link_sta->he_6ghz_capa; in mt7925_get_phy_mode_ext()
2330 eht_cap = &link_sta->eht_cap; in mt7925_get_phy_mode_ext()
2334 sband = phy->hw->wiphy->bands[band]; in mt7925_get_phy_mode_ext()
2335 capa = ieee80211_get_he_6ghz_capa(sband, vif->type); in mt7925_get_phy_mode_ext()
2338 eht_cap = ieee80211_get_eht_iftype_cap(sband, vif->type); in mt7925_get_phy_mode_ext()
2343 if (eht_cap && eht_cap->has_eht) in mt7925_get_phy_mode_ext()
2347 if (eht_cap && eht_cap->has_eht) in mt7925_get_phy_mode_ext()
2351 if (he_6ghz_capa && he_6ghz_capa->capa) in mt7925_get_phy_mode_ext()
2354 if (eht_cap && eht_cap->has_eht) in mt7925_get_phy_mode_ext()
2372 struct ieee80211_vif *vif = link_conf->vif; in mt7925_mcu_bss_basic_tlv()
2374 struct cfg80211_chan_def *chandef = ctx ? &ctx->def : in mt7925_mcu_bss_basic_tlv()
2375 &link_conf->chanreq.oper; in mt7925_mcu_bss_basic_tlv()
2376 enum nl80211_band band = chandef->chan->band; in mt7925_mcu_bss_basic_tlv()
2386 idx = mconf->mt76.omac_idx > EXT_BSSID_START ? HW_BSSID_0 : in mt7925_mcu_bss_basic_tlv()
2387 mconf->mt76.omac_idx; in mt7925_mcu_bss_basic_tlv()
2388 basic_req->hw_bss_idx = idx; in mt7925_mcu_bss_basic_tlv()
2390 basic_req->phymode_ext = mt7925_get_phy_mode_ext(phy, vif, band, in mt7925_mcu_bss_basic_tlv()
2394 basic_req->nonht_basic_phy = cpu_to_le16(PHY_TYPE_ERP_INDEX); in mt7925_mcu_bss_basic_tlv()
2396 basic_req->nonht_basic_phy = cpu_to_le16(PHY_TYPE_OFDM_INDEX); in mt7925_mcu_bss_basic_tlv()
2398 memcpy(basic_req->bssid, link_conf->bssid, ETH_ALEN); in mt7925_mcu_bss_basic_tlv()
2399 basic_req->phymode = mt76_connac_get_phy_mode(phy, vif, band, link_sta); in mt7925_mcu_bss_basic_tlv()
2400 basic_req->bcn_interval = cpu_to_le16(link_conf->beacon_int); in mt7925_mcu_bss_basic_tlv()
2401 basic_req->dtim_period = link_conf->dtim_period; in mt7925_mcu_bss_basic_tlv()
2402 basic_req->bmc_tx_wlan_idx = cpu_to_le16(wlan_idx); in mt7925_mcu_bss_basic_tlv()
2403 basic_req->link_idx = mconf->mt76.idx; in mt7925_mcu_bss_basic_tlv()
2408 msta = (struct mt792x_sta *)link_sta->sta->drv_priv; in mt7925_mcu_bss_basic_tlv()
2409 mlink = mt792x_sta_to_link(msta, link_sta->link_id); in mt7925_mcu_bss_basic_tlv()
2412 mlink = &mconf->vif->sta.deflink; in mt7925_mcu_bss_basic_tlv()
2415 basic_req->sta_idx = cpu_to_le16(mlink->wcid.idx); in mt7925_mcu_bss_basic_tlv()
2416 basic_req->omac_idx = mconf->mt76.omac_idx; in mt7925_mcu_bss_basic_tlv()
2417 basic_req->band_idx = mconf->mt76.band_idx; in mt7925_mcu_bss_basic_tlv()
2418 basic_req->wmm_idx = mconf->mt76.wmm_idx; in mt7925_mcu_bss_basic_tlv()
2419 basic_req->conn_state = !enable; in mt7925_mcu_bss_basic_tlv()
2421 switch (vif->type) { in mt7925_mcu_bss_basic_tlv()
2424 if (vif->p2p) in mt7925_mcu_bss_basic_tlv()
2428 basic_req->conn_type = cpu_to_le32(conn_type); in mt7925_mcu_bss_basic_tlv()
2429 basic_req->active = enable; in mt7925_mcu_bss_basic_tlv()
2432 if (vif->p2p) in mt7925_mcu_bss_basic_tlv()
2436 basic_req->conn_type = cpu_to_le32(conn_type); in mt7925_mcu_bss_basic_tlv()
2437 basic_req->active = true; in mt7925_mcu_bss_basic_tlv()
2440 basic_req->conn_type = cpu_to_le32(CONNECTION_IBSS_ADHOC); in mt7925_mcu_bss_basic_tlv()
2441 basic_req->active = true; in mt7925_mcu_bss_basic_tlv()
2454 struct mt76_vif_link *mvif = &mconf->mt76; in mt7925_mcu_bss_sec_tlv()
2468 switch (mvif->cipher) { in mt7925_mcu_bss_sec_tlv()
2471 sec->mode = MODE_WPA3_SAE; in mt7925_mcu_bss_sec_tlv()
2472 sec->status = 8; in mt7925_mcu_bss_sec_tlv()
2475 sec->mode = MODE_WPA2_PSK; in mt7925_mcu_bss_sec_tlv()
2476 sec->status = 6; in mt7925_mcu_bss_sec_tlv()
2479 sec->mode = MODE_WPA2_PSK; in mt7925_mcu_bss_sec_tlv()
2480 sec->status = 4; in mt7925_mcu_bss_sec_tlv()
2484 sec->mode = MODE_SHARED; in mt7925_mcu_bss_sec_tlv()
2485 sec->status = 0; in mt7925_mcu_bss_sec_tlv()
2488 sec->mode = MODE_OPEN; in mt7925_mcu_bss_sec_tlv()
2489 sec->status = 1; in mt7925_mcu_bss_sec_tlv()
2493 sec->cipher = mvif->cipher; in mt7925_mcu_bss_sec_tlv()
2501 struct cfg80211_chan_def *chandef = ctx ? &ctx->def : in mt7925_mcu_bss_bmc_tlv()
2502 &link_conf->chanreq.oper; in mt7925_mcu_bss_bmc_tlv()
2504 enum nl80211_band band = chandef->chan->band; in mt7925_mcu_bss_bmc_tlv()
2505 struct mt76_vif_link *mvif = &mconf->mt76; in mt7925_mcu_bss_bmc_tlv()
2508 u8 idx = mvif->mcast_rates_idx ? in mt7925_mcu_bss_bmc_tlv()
2509 mvif->mcast_rates_idx : mvif->basic_rates_idx; in mt7925_mcu_bss_bmc_tlv()
2516 bmc->basic_rate = cpu_to_le16(HR_DSSS_ERP_BASIC_RATE); in mt7925_mcu_bss_bmc_tlv()
2518 bmc->basic_rate = cpu_to_le16(OFDM_BASIC_RATE); in mt7925_mcu_bss_bmc_tlv()
2520 bmc->short_preamble = (band == NL80211_BAND_2GHZ); in mt7925_mcu_bss_bmc_tlv()
2521 bmc->bc_fixed_rate = idx; in mt7925_mcu_bss_bmc_tlv()
2522 bmc->mc_fixed_rate = idx; in mt7925_mcu_bss_bmc_tlv()
2529 struct ieee80211_vif *vif = link_conf->vif; in mt7925_mcu_bss_mld_tlv()
2531 struct mt792x_vif *mvif = (struct mt792x_vif *)link_conf->vif->drv_priv; in mt7925_mcu_bss_mld_tlv()
2532 struct mt792x_phy *phy = mvif->phy; in mt7925_mcu_bss_mld_tlv()
2537 is_mld = ieee80211_vif_is_mld(link_conf->vif) || in mt7925_mcu_bss_mld_tlv()
2538 (hweight16(mvif->valid_links) > 1); in mt7925_mcu_bss_mld_tlv()
2543 mld->link_id = is_mld ? link_conf->link_id : 0xff; in mt7925_mcu_bss_mld_tlv()
2545 mld->group_mld_id = is_mld ? mvif->bss_conf.mt76.idx : 0xff; in mt7925_mcu_bss_mld_tlv()
2546 mld->own_mld_id = mconf->mt76.idx + 32; in mt7925_mcu_bss_mld_tlv()
2547 mld->remap_idx = 0xff; in mt7925_mcu_bss_mld_tlv()
2549 if (phy->chip_cap & MT792x_CHIP_CAP_MLO_EML_EN) { in mt7925_mcu_bss_mld_tlv()
2550 mld->eml_enable = !!(link_conf->vif->cfg.eml_cap & in mt7925_mcu_bss_mld_tlv()
2553 mld->eml_enable = 0; in mt7925_mcu_bss_mld_tlv()
2556 memcpy(mld->mac_addr, vif->addr, ETH_ALEN); in mt7925_mcu_bss_mld_tlv()
2567 qos->qos = link_conf->qos; in mt7925_mcu_bss_qos_tlv()
2580 cap = mt76_connac_get_he_phy_cap(phy->mt76, link_conf->vif); in mt7925_mcu_bss_he_tlv()
2585 he->he_pe_duration = link_conf->htc_trig_based_pkt_ext; in mt7925_mcu_bss_he_tlv()
2586 if (!he->he_pe_duration) in mt7925_mcu_bss_he_tlv()
2587 he->he_pe_duration = DEFAULT_HE_PE_DURATION; in mt7925_mcu_bss_he_tlv()
2589 he->he_rts_thres = cpu_to_le16(link_conf->frame_time_rts_th); in mt7925_mcu_bss_he_tlv()
2590 if (!he->he_rts_thres) in mt7925_mcu_bss_he_tlv()
2591 he->he_rts_thres = cpu_to_le16(DEFAULT_HE_DURATION_RTS_THRES); in mt7925_mcu_bss_he_tlv()
2593 he->max_nss_mcs[CMD_HE_MCS_BW80] = cap->he_mcs_nss_supp.tx_mcs_80; in mt7925_mcu_bss_he_tlv()
2594 he->max_nss_mcs[CMD_HE_MCS_BW160] = cap->he_mcs_nss_supp.tx_mcs_160; in mt7925_mcu_bss_he_tlv()
2595 he->max_nss_mcs[CMD_HE_MCS_BW8080] = cap->he_mcs_nss_supp.tx_mcs_80p80; in mt7925_mcu_bss_he_tlv()
2608 color->enable = enable ? in mt7925_mcu_bss_color_tlv()
2609 link_conf->he_bss_color.enabled : 0; in mt7925_mcu_bss_color_tlv()
2610 color->bss_color = enable ? in mt7925_mcu_bss_color_tlv()
2611 link_conf->he_bss_color.color : 0; in mt7925_mcu_bss_color_tlv()
2618 struct mt792x_vif *mvif = (struct mt792x_vif *)link_conf->vif->drv_priv; in mt7925_mcu_bss_ifs_tlv()
2619 struct mt792x_phy *phy = mvif->phy; in mt7925_mcu_bss_ifs_tlv()
2625 ifs_time->slot_valid = true; in mt7925_mcu_bss_ifs_tlv()
2626 ifs_time->slot_time = cpu_to_le16(phy->slottime); in mt7925_mcu_bss_ifs_tlv()
2633 struct mt792x_dev *dev = phy->dev; in mt7925_mcu_set_timing()
2636 skb = __mt7925_mcu_alloc_bss_req(&dev->mt76, &mconf->mt76, in mt7925_mcu_set_timing()
2643 return mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7925_mcu_set_timing()
2650 struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv; in mt7925_mcu_del_dev()
2686 dev_req.hdr.omac_idx = mvif->omac_idx; in mt7925_mcu_del_dev()
2687 dev_req.hdr.band_idx = mvif->band_idx; in mt7925_mcu_del_dev()
2689 basic_req.hdr.bss_idx = mvif->idx; in mt7925_mcu_del_dev()
2690 basic_req.basic.omac_idx = mvif->omac_idx; in mt7925_mcu_del_dev()
2691 basic_req.basic.band_idx = mvif->band_idx; in mt7925_mcu_del_dev()
2692 basic_req.basic.link_idx = mvif->link_idx; in mt7925_mcu_del_dev()
2698 memcpy(dev_req.tlv.omac_addr, vif->addr, ETH_ALEN); in mt7925_mcu_del_dev()
2709 struct mt792x_vif *mvif = (struct mt792x_vif *)link_conf->vif->drv_priv; in mt7925_mcu_add_bss_info()
2711 struct mt792x_dev *dev = phy->dev; in mt7925_mcu_add_bss_info()
2715 skb = __mt7925_mcu_alloc_bss_req(&dev->mt76, &mconf->mt76, in mt7925_mcu_add_bss_info()
2720 mlink_bc = mt792x_sta_to_link(&mvif->sta, mconf->link_id); in mt7925_mcu_add_bss_info()
2723 mt7925_mcu_bss_basic_tlv(skb, link_conf, link_sta, ctx, phy->mt76, in mt7925_mcu_add_bss_info()
2724 mlink_bc->wcid.idx, enable); in mt7925_mcu_add_bss_info()
2731 if (link_conf->he_support) { in mt7925_mcu_add_bss_info()
2737 mt7925_mcu_bss_rlm_tlv(skb, phy->mt76, link_conf, ctx); in mt7925_mcu_add_bss_info()
2739 return mt76_mcu_skb_send_msg(&dev->mt76, skb, in mt7925_mcu_add_bss_info()
2745 struct mt76_dev *mdev = phy->dev; in mt7925_mcu_set_dbdc()
2756 return -ENOMEM; in mt7925_mcu_set_dbdc()
2763 conf->mbmc_en = enable; in mt7925_mcu_set_dbdc()
2764 conf->band = 0; /* unused */ in mt7925_mcu_set_dbdc()
2775 struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv; in mt7925_mcu_hw_scan()
2776 struct cfg80211_scan_request *sreq = &scan_req->req; in mt7925_mcu_hw_scan()
2778 struct ieee80211_channel **scan_list = sreq->channels; in mt7925_mcu_hw_scan()
2779 struct mt76_dev *mdev = phy->dev; in mt7925_mcu_hw_scan()
2799 return -ENOMEM; in mt7925_mcu_hw_scan()
2801 set_bit(MT76_HW_SCANNING, &phy->state); in mt7925_mcu_hw_scan()
2802 mvif->scan_seq_num = (mvif->scan_seq_num + 1) & 0x7f; in mt7925_mcu_hw_scan()
2805 hdr->seq_num = mvif->scan_seq_num | mvif->band_idx << 7; in mt7925_mcu_hw_scan()
2806 hdr->bss_idx = mvif->idx; in mt7925_mcu_hw_scan()
2810 req->scan_type = sreq->n_ssids ? 1 : 0; in mt7925_mcu_hw_scan()
2811 req->probe_req_num = sreq->n_ssids ? 2 : 0; in mt7925_mcu_hw_scan()
2815 for (i = 0; i < sreq->n_ssids; i++) { in mt7925_mcu_hw_scan()
2816 if (!sreq->ssids[i].ssid_len) in mt7925_mcu_hw_scan()
2819 ssid->ssids[i].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len); in mt7925_mcu_hw_scan()
2820 memcpy(ssid->ssids[i].ssid, sreq->ssids[i].ssid, in mt7925_mcu_hw_scan()
2821 sreq->ssids[i].ssid_len); in mt7925_mcu_hw_scan()
2824 ssid->ssid_type = n_ssids ? BIT(2) : BIT(0); in mt7925_mcu_hw_scan()
2825 ssid->ssids_num = n_ssids; in mt7925_mcu_hw_scan()
2830 memcpy(bssid->bssid, sreq->bssid, ETH_ALEN); in mt7925_mcu_hw_scan()
2834 chan_info->channels_num = min_t(u8, sreq->n_channels, in mt7925_mcu_hw_scan()
2835 ARRAY_SIZE(chan_info->channels)); in mt7925_mcu_hw_scan()
2836 for (i = 0; i < chan_info->channels_num; i++) { in mt7925_mcu_hw_scan()
2837 chan = &chan_info->channels[i]; in mt7925_mcu_hw_scan()
2839 switch (scan_list[i]->band) { in mt7925_mcu_hw_scan()
2841 chan->band = 1; in mt7925_mcu_hw_scan()
2844 chan->band = 3; in mt7925_mcu_hw_scan()
2847 chan->band = 2; in mt7925_mcu_hw_scan()
2850 chan->channel_num = scan_list[i]->hw_value; in mt7925_mcu_hw_scan()
2852 chan_info->channel_type = sreq->n_channels ? 4 : 0; in mt7925_mcu_hw_scan()
2856 if (sreq->ie_len > 0) { in mt7925_mcu_hw_scan()
2857 memcpy(ie->ies, sreq->ie, sreq->ie_len); in mt7925_mcu_hw_scan()
2858 ie->ies_len = cpu_to_le16(sreq->ie_len); in mt7925_mcu_hw_scan()
2861 req->scan_func |= SCAN_FUNC_SPLIT_SCAN; in mt7925_mcu_hw_scan()
2865 if (sreq->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) { in mt7925_mcu_hw_scan()
2866 get_random_mask_addr(misc->random_mac, sreq->mac_addr, in mt7925_mcu_hw_scan()
2867 sreq->mac_addr_mask); in mt7925_mcu_hw_scan()
2868 req->scan_func |= SCAN_FUNC_RANDOM_MAC; in mt7925_mcu_hw_scan()
2874 clear_bit(MT76_HW_SCANNING, &phy->state); in mt7925_mcu_hw_scan()
2884 struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv; in mt7925_mcu_sched_scan_req()
2885 struct ieee80211_channel **scan_list = sreq->channels; in mt7925_mcu_sched_scan_req()
2887 struct mt76_dev *mdev = phy->dev; in mt7925_mcu_sched_scan_req()
2907 return -ENOMEM; in mt7925_mcu_sched_scan_req()
2909 mvif->scan_seq_num = (mvif->scan_seq_num + 1) & 0x7f; in mt7925_mcu_sched_scan_req()
2912 hdr->seq_num = mvif->scan_seq_num | mvif->band_idx << 7; in mt7925_mcu_sched_scan_req()
2913 hdr->bss_idx = mvif->idx; in mt7925_mcu_sched_scan_req()
2917 req->version = 1; in mt7925_mcu_sched_scan_req()
2919 if (sreq->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) in mt7925_mcu_sched_scan_req()
2920 req->scan_func |= SCAN_FUNC_RANDOM_MAC; in mt7925_mcu_sched_scan_req()
2922 req->intervals_num = sreq->n_scan_plans; in mt7925_mcu_sched_scan_req()
2923 for (i = 0; i < req->intervals_num; i++) in mt7925_mcu_sched_scan_req()
2924 req->intervals[i] = cpu_to_le16(sreq->scan_plans[i].interval); in mt7925_mcu_sched_scan_req()
2929 ssid->ssids_num = sreq->n_ssids; in mt7925_mcu_sched_scan_req()
2930 ssid->ssid_type = BIT(2); in mt7925_mcu_sched_scan_req()
2931 for (i = 0; i < ssid->ssids_num; i++) { in mt7925_mcu_sched_scan_req()
2932 cfg_ssid = &sreq->ssids[i]; in mt7925_mcu_sched_scan_req()
2933 memcpy(ssid->ssids[i].ssid, cfg_ssid->ssid, cfg_ssid->ssid_len); in mt7925_mcu_sched_scan_req()
2934 ssid->ssids[i].ssid_len = cpu_to_le32(cfg_ssid->ssid_len); in mt7925_mcu_sched_scan_req()
2939 match->match_num = sreq->n_match_sets; in mt7925_mcu_sched_scan_req()
2940 for (i = 0; i < match->match_num; i++) { in mt7925_mcu_sched_scan_req()
2941 cfg_match = &sreq->match_sets[i]; in mt7925_mcu_sched_scan_req()
2942 memcpy(match->match[i].ssid, cfg_match->ssid.ssid, in mt7925_mcu_sched_scan_req()
2943 cfg_match->ssid.ssid_len); in mt7925_mcu_sched_scan_req()
2944 match->match[i].rssi_th = cpu_to_le32(cfg_match->rssi_thold); in mt7925_mcu_sched_scan_req()
2945 match->match[i].ssid_len = cfg_match->ssid.ssid_len; in mt7925_mcu_sched_scan_req()
2950 chan_info->channels_num = min_t(u8, sreq->n_channels, in mt7925_mcu_sched_scan_req()
2951 ARRAY_SIZE(chan_info->channels)); in mt7925_mcu_sched_scan_req()
2952 for (i = 0; i < chan_info->channels_num; i++) { in mt7925_mcu_sched_scan_req()
2953 chan = &chan_info->channels[i]; in mt7925_mcu_sched_scan_req()
2955 switch (scan_list[i]->band) { in mt7925_mcu_sched_scan_req()
2957 chan->band = 1; in mt7925_mcu_sched_scan_req()
2960 chan->band = 3; in mt7925_mcu_sched_scan_req()
2963 chan->band = 2; in mt7925_mcu_sched_scan_req()
2966 chan->channel_num = scan_list[i]->hw_value; in mt7925_mcu_sched_scan_req()
2968 chan_info->channel_type = sreq->n_channels ? 4 : 0; in mt7925_mcu_sched_scan_req()
2972 if (sreq->ie_len > 0) { in mt7925_mcu_sched_scan_req()
2973 memcpy(ie->ies, sreq->ie, sreq->ie_len); in mt7925_mcu_sched_scan_req()
2974 ie->ies_len = cpu_to_le16(sreq->ie_len); in mt7925_mcu_sched_scan_req()
2987 struct mt76_dev *mdev = phy->dev; in mt7925_mcu_sched_scan_enable()
2998 return -ENOMEM; in mt7925_mcu_sched_scan_enable()
3001 hdr->seq_num = 0; in mt7925_mcu_sched_scan_enable()
3002 hdr->bss_idx = 0; in mt7925_mcu_sched_scan_enable()
3006 req->active = !enable; in mt7925_mcu_sched_scan_enable()
3009 set_bit(MT76_HW_SCHED_SCANNING, &phy->state); in mt7925_mcu_sched_scan_enable()
3011 clear_bit(MT76_HW_SCHED_SCANNING, &phy->state); in mt7925_mcu_sched_scan_enable()
3020 struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv; in mt7925_mcu_cancel_hw_scan()
3035 .seq_num = mvif->scan_seq_num, in mt7925_mcu_cancel_hw_scan()
3036 .bss_idx = mvif->idx, in mt7925_mcu_cancel_hw_scan()
3044 if (test_and_clear_bit(MT76_HW_SCANNING, &phy->state)) { in mt7925_mcu_cancel_hw_scan()
3049 ieee80211_scan_completed(phy->hw, &info); in mt7925_mcu_cancel_hw_scan()
3052 return mt76_mcu_send_msg(phy->dev, MCU_UNI_CMD(SCAN_REQ), in mt7925_mcu_cancel_hw_scan()
3096 struct mt76_dev *dev = phy->dev; in mt7925_mcu_set_channel_domain()
3100 n_max_channels = phy->sband_2g.sband.n_channels + in mt7925_mcu_set_channel_domain()
3101 phy->sband_5g.sband.n_channels + in mt7925_mcu_set_channel_domain()
3102 phy->sband_6g.sband.n_channels; in mt7925_mcu_set_channel_domain()
3107 return -ENOMEM; in mt7925_mcu_set_channel_domain()
3111 for (i = 0; i < phy->sband_2g.sband.n_channels; i++) { in mt7925_mcu_set_channel_domain()
3112 chan = &phy->sband_2g.sband.channels[i]; in mt7925_mcu_set_channel_domain()
3113 if (chan->flags & IEEE80211_CHAN_DISABLED) in mt7925_mcu_set_channel_domain()
3116 channel.hw_value = cpu_to_le16(chan->hw_value); in mt7925_mcu_set_channel_domain()
3117 channel.flags = cpu_to_le32(chan->flags); in mt7925_mcu_set_channel_domain()
3123 for (i = 0; i < phy->sband_5g.sband.n_channels; i++) { in mt7925_mcu_set_channel_domain()
3124 chan = &phy->sband_5g.sband.channels[i]; in mt7925_mcu_set_channel_domain()
3125 if (chan->flags & IEEE80211_CHAN_DISABLED) in mt7925_mcu_set_channel_domain()
3128 channel.hw_value = cpu_to_le16(chan->hw_value); in mt7925_mcu_set_channel_domain()
3129 channel.flags = cpu_to_le32(chan->flags); in mt7925_mcu_set_channel_domain()
3135 for (i = 0; i < phy->sband_6g.sband.n_channels; i++) { in mt7925_mcu_set_channel_domain()
3136 chan = &phy->sband_6g.sband.channels[i]; in mt7925_mcu_set_channel_domain()
3137 if (chan->flags & IEEE80211_CHAN_DISABLED) in mt7925_mcu_set_channel_domain()
3140 channel.hw_value = cpu_to_le16(chan->hw_value); in mt7925_mcu_set_channel_domain()
3141 channel.flags = cpu_to_le32(chan->flags); in mt7925_mcu_set_channel_domain()
3148 BUILD_BUG_ON(sizeof(dev->alpha2) > sizeof(req.hdr.alpha2)); in mt7925_mcu_set_channel_domain()
3149 memcpy(req.hdr.alpha2, dev->alpha2, sizeof(dev->alpha2)); in mt7925_mcu_set_channel_domain()
3186 .len = cpu_to_le16(sizeof(req) - 4), in __mt7925_mcu_set_clc()
3197 req.ver = clc->ver; in __mt7925_mcu_set_clc()
3198 pos = clc->data + sizeof(*seg) * clc->t0.nr_seg; in __mt7925_mcu_set_clc()
3199 last_pos = clc->data + le32_to_cpu(*(__le32 *)(clc->data + 4)); in __mt7925_mcu_set_clc()
3204 if (rule->alpha2[0] != alpha2[0] || in __mt7925_mcu_set_clc()
3205 rule->alpha2[1] != alpha2[1]) in __mt7925_mcu_set_clc()
3208 seg = (struct mt7925_clc_segment *)clc->data in __mt7925_mcu_set_clc()
3209 + rule->seg_idx - 1; in __mt7925_mcu_set_clc()
3211 memcpy(req.alpha2, rule->alpha2, 2); in __mt7925_mcu_set_clc()
3212 memcpy(req.type, rule->type, 2); in __mt7925_mcu_set_clc()
3214 req.size = cpu_to_le16(seg->len); in __mt7925_mcu_set_clc()
3215 dev->phy.clc_chan_conf = clc->ver == 1 ? 0xff : rule->flag; in __mt7925_mcu_set_clc()
3216 skb = __mt76_mcu_msg_alloc(&dev->mt76, &req, in __mt7925_mcu_set_clc()
3220 return -ENOMEM; in __mt7925_mcu_set_clc()
3221 skb_put_data(skb, clc->data + seg->offset, seg->len); in __mt7925_mcu_set_clc()
3223 ret = mt76_mcu_skb_send_msg(&dev->mt76, skb, in __mt7925_mcu_set_clc()
3232 dev->phy.clc_chan_conf = 0xff; in __mt7925_mcu_set_clc()
3233 return -ENOENT; in __mt7925_mcu_set_clc()
3242 struct mt792x_phy *phy = (struct mt792x_phy *)&dev->phy; in mt7925_mcu_set_clc()
3246 for (i = 0; i < ARRAY_SIZE(phy->clc); i++) { in mt7925_mcu_set_clc()
3251 phy->clc[i], i); in mt7925_mcu_set_clc()
3254 if (ret == -ENOENT) in mt7925_mcu_set_clc()
3257 phy->clc[i], i); in mt7925_mcu_set_clc()
3275 mdev->mcu.timeout = 20 * HZ; in mt7925_mcu_fill_message()
3277 seq = ++mdev->mcu.msg_seq & 0xf; in mt7925_mcu_fill_message()
3279 seq = ++mdev->mcu.msg_seq & 0xf; in mt7925_mcu_fill_message()
3287 val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len) | in mt7925_mcu_fill_message()
3297 uni_txd->len = cpu_to_le16(skb->len - sizeof(uni_txd->txd)); in mt7925_mcu_fill_message()
3298 uni_txd->cid = cpu_to_le16(mcu_cmd); in mt7925_mcu_fill_message()
3299 uni_txd->s2d_index = MCU_S2D_H2N; in mt7925_mcu_fill_message()
3300 uni_txd->pkt_type = MCU_PKT_ID; in mt7925_mcu_fill_message()
3301 uni_txd->seq = seq; in mt7925_mcu_fill_message()
3304 uni_txd->option = MCU_CMD_UNI_QUERY_ACK; in mt7925_mcu_fill_message()
3306 uni_txd->option = MCU_CMD_UNI_EXT_ACK; in mt7925_mcu_fill_message()
3309 uni_txd->option &= ~MCU_CMD_ACK; in mt7925_mcu_fill_message()
3315 mcu_txd->len = cpu_to_le16(skb->len - sizeof(mcu_txd->txd)); in mt7925_mcu_fill_message()
3316 mcu_txd->pq_id = cpu_to_le16(MCU_PQ_ID(MT_TX_PORT_IDX_MCU, in mt7925_mcu_fill_message()
3318 mcu_txd->pkt_type = MCU_PKT_ID; in mt7925_mcu_fill_message()
3319 mcu_txd->seq = seq; in mt7925_mcu_fill_message()
3320 mcu_txd->cid = mcu_cmd; in mt7925_mcu_fill_message()
3321 mcu_txd->ext_cid = FIELD_GET(__MCU_CMD_FIELD_EXT_ID, cmd); in mt7925_mcu_fill_message()
3323 if (mcu_txd->ext_cid || (cmd & __MCU_CMD_FIELD_CE)) { in mt7925_mcu_fill_message()
3325 mcu_txd->set_query = MCU_Q_QUERY; in mt7925_mcu_fill_message()
3327 mcu_txd->set_query = MCU_Q_SET; in mt7925_mcu_fill_message()
3328 mcu_txd->ext_cid_ack = !!mcu_txd->ext_cid; in mt7925_mcu_fill_message()
3330 mcu_txd->set_query = MCU_Q_NA; in mt7925_mcu_fill_message()
3334 mcu_txd->s2d_index = MCU_S2D_H2C; in mt7925_mcu_fill_message()
3336 mcu_txd->s2d_index = MCU_S2D_H2N; in mt7925_mcu_fill_message()
3357 .band_idx = phy->mt76->band_idx, in mt7925_mcu_set_rts_thresh()
3359 .len = cpu_to_le16(sizeof(req) - 4), in mt7925_mcu_set_rts_thresh()
3364 return mt76_mcu_send_msg(&phy->dev->mt76, MCU_UNI_CMD(BAND_CONFIG), in mt7925_mcu_set_rts_thresh()
3379 .band_idx = phy->mt76->band_idx, in mt7925_mcu_set_radio_en()
3381 .len = cpu_to_le16(sizeof(req) - 4), in mt7925_mcu_set_radio_en()
3385 return mt76_mcu_send_msg(&phy->dev->mt76, MCU_UNI_CMD(BAND_CONFIG), in mt7925_mcu_set_radio_en()
3394 int i, offset = sizeof(limits->cck); in mt7925_mcu_build_sku()
3400 memcpy(sku, limits->cck, sizeof(limits->cck)); in mt7925_mcu_build_sku()
3404 memcpy(&sku[offset], limits->ofdm, sizeof(limits->ofdm)); in mt7925_mcu_build_sku()
3405 offset += (sizeof(limits->ofdm) * 5); in mt7925_mcu_build_sku()
3409 memcpy(&sku[offset], limits->mcs[i], 8); in mt7925_mcu_build_sku()
3412 sku[offset++] = limits->mcs[0][0]; in mt7925_mcu_build_sku()
3415 for (i = 0; i < ARRAY_SIZE(limits->mcs); i++) { in mt7925_mcu_build_sku()
3416 memcpy(&sku[offset], limits->mcs[i], in mt7925_mcu_build_sku()
3417 ARRAY_SIZE(limits->mcs[i])); in mt7925_mcu_build_sku()
3422 for (i = 0; i < ARRAY_SIZE(limits->ru); i++) { in mt7925_mcu_build_sku()
3423 memcpy(&sku[offset], limits->ru[i], ARRAY_SIZE(limits->ru[i])); in mt7925_mcu_build_sku()
3424 offset += ARRAY_SIZE(limits->ru[i]); in mt7925_mcu_build_sku()
3428 for (i = 0; i < ARRAY_SIZE(limits->eht); i++) { in mt7925_mcu_build_sku()
3429 memcpy(&sku[offset], limits->eht[i], ARRAY_SIZE(limits->eht[i])); in mt7925_mcu_build_sku()
3430 offset += ARRAY_SIZE(limits->eht[i]); in mt7925_mcu_build_sku()
3440 struct mt76_dev *dev = phy->dev; in mt7925_mcu_rate_txpower_band()
3477 tx_power = 2 * phy->hw->conf.power_level; in mt7925_mcu_rate_txpower_band()
3484 last_ch = chan_list_2ghz[ARRAY_SIZE(chan_list_2ghz) - 1]; in mt7925_mcu_rate_txpower_band()
3488 last_ch = chan_list_6ghz[ARRAY_SIZE(chan_list_6ghz) - 1]; in mt7925_mcu_rate_txpower_band()
3492 last_ch = chan_list_5ghz[ARRAY_SIZE(chan_list_5ghz) - 1]; in mt7925_mcu_rate_txpower_band()
3496 limits = devm_kmalloc(dev->dev, sizeof(*limits), GFP_KERNEL); in mt7925_mcu_rate_txpower_band()
3498 return -ENOMEM; in mt7925_mcu_rate_txpower_band()
3500 sku_tlbv = devm_kmalloc(dev->dev, sku_len, GFP_KERNEL); in mt7925_mcu_rate_txpower_band()
3502 devm_kfree(dev->dev, limits); in mt7925_mcu_rate_txpower_band()
3503 return -ENOMEM; in mt7925_mcu_rate_txpower_band()
3511 num_ch = i == batch_size - 1 ? n_chan % batch_len : batch_len; in mt7925_mcu_rate_txpower_band()
3515 err = -ENOMEM; in mt7925_mcu_rate_txpower_band()
3522 BUILD_BUG_ON(sizeof(dev->alpha2) > sizeof(tx_power_tlv->alpha2)); in mt7925_mcu_rate_txpower_band()
3523 memcpy(tx_power_tlv->alpha2, dev->alpha2, sizeof(dev->alpha2)); in mt7925_mcu_rate_txpower_band()
3524 tx_power_tlv->n_chan = num_ch; in mt7925_mcu_rate_txpower_band()
3525 tx_power_tlv->tag = cpu_to_le16(0x1); in mt7925_mcu_rate_txpower_band()
3526 tx_power_tlv->len = cpu_to_le16(sizeof(*tx_power_tlv)); in mt7925_mcu_rate_txpower_band()
3530 tx_power_tlv->band = 1; in mt7925_mcu_rate_txpower_band()
3533 tx_power_tlv->band = 3; in mt7925_mcu_rate_txpower_band()
3536 tx_power_tlv->band = 2; in mt7925_mcu_rate_txpower_band()
3554 tx_power_tlv->last_msg = ch_list[idx] == last_ch; in mt7925_mcu_rate_txpower_band()
3555 sku_tlbv->channel = ch_list[idx]; in mt7925_mcu_rate_txpower_band()
3557 mt7925_mcu_build_sku(dev, sku_tlbv->pwr_limit, in mt7925_mcu_rate_txpower_band()
3569 devm_kfree(dev->dev, sku_tlbv); in mt7925_mcu_rate_txpower_band()
3570 devm_kfree(dev->dev, limits); in mt7925_mcu_rate_txpower_band()
3578 if (phy->cap.has_2ghz) { in mt7925_mcu_set_rate_txpower()
3585 if (phy->cap.has_5ghz) { in mt7925_mcu_set_rate_txpower()
3592 if (phy->cap.has_6ghz) { in mt7925_mcu_set_rate_txpower()
3605 struct mt792x_phy *phy = &dev->phy; in mt7925_mcu_set_rxfilter()
3619 .band_idx = phy->mt76->band_idx, in mt7925_mcu_set_rxfilter()
3621 .len = cpu_to_le16(sizeof(req) - 4), in mt7925_mcu_set_rxfilter()
3629 return mt76_mcu_send_msg(&phy->dev->mt76, MCU_UNI_CMD(BAND_CONFIG), in mt7925_mcu_set_rxfilter()