Lines Matching +full:hw +full:- +full:flow +full:- +full:ctrl
1 // SPDX-License-Identifier: ISC
17 #define to_rssi(field, rcpi) ((FIELD_GET(field, rcpi) - 220) / 2)
20 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
34 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
45 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
64 if (idx >= ARRAY_SIZE(dev->mt76.wcid)) in mt7996_rx_get_wcid()
67 wcid = rcu_dereference(dev->mt76.wcid[idx]); in mt7996_rx_get_wcid()
71 if (!wcid->sta) in mt7996_rx_get_wcid()
75 if (!sta->vif) in mt7996_rx_get_wcid()
78 return &sta->vif->sta.wcid; in mt7996_rx_get_wcid()
113 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_poll()
114 list_splice_init(&dev->mt76.sta_poll_list, &sta_poll_list); in mt7996_mac_sta_poll()
115 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_poll()
126 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_poll()
128 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_poll()
133 list_del_init(&msta->wcid.poll_list); in mt7996_mac_sta_poll()
134 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_poll()
136 idx = msta->wcid.idx; in mt7996_mac_sta_poll()
142 u32 tx_last = msta->airtime_ac[i]; in mt7996_mac_sta_poll()
143 u32 rx_last = msta->airtime_ac[i + 4]; in mt7996_mac_sta_poll()
145 msta->airtime_ac[i] = mt76_rr(dev, addr); in mt7996_mac_sta_poll()
146 msta->airtime_ac[i + 4] = mt76_rr(dev, addr + 4); in mt7996_mac_sta_poll()
148 tx_time[i] = msta->airtime_ac[i] - tx_last; in mt7996_mac_sta_poll()
149 rx_time[i] = msta->airtime_ac[i + 4] - rx_last; in mt7996_mac_sta_poll()
160 memset(msta->airtime_ac, 0, sizeof(msta->airtime_ac)); in mt7996_mac_sta_poll()
163 if (!msta->wcid.sta) in mt7996_mac_sta_poll()
183 * from per-sta counters directly. in mt7996_mac_sta_poll()
185 rate = &msta->wcid.rate; in mt7996_mac_sta_poll()
187 switch (rate->bw) { in mt7996_mac_sta_poll()
207 if (rate->flags & RATE_INFO_FLAGS_EHT_MCS) { in mt7996_mac_sta_poll()
210 rate->eht_gi = FIELD_GET(GENMASK(25, 24), val); in mt7996_mac_sta_poll()
211 } else if (rate->flags & RATE_INFO_FLAGS_HE_MCS) { in mt7996_mac_sta_poll()
214 rate->he_gi = (val & (0x3 << offs)) >> offs; in mt7996_mac_sta_poll()
215 } else if (rate->flags & in mt7996_mac_sta_poll()
218 rate->flags |= RATE_INFO_FLAGS_SHORT_GI; in mt7996_mac_sta_poll()
220 rate->flags &= ~RATE_INFO_FLAGS_SHORT_GI; in mt7996_mac_sta_poll()
232 msta->ack_signal = in mt7996_mac_sta_poll()
233 mt76_rx_signal(msta->vif->phy->mt76->antenna_mask, rssi); in mt7996_mac_sta_poll()
235 ewma_avg_signal_add(&msta->avg_ack_signal, -msta->ack_signal); in mt7996_mac_sta_poll()
244 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; in mt7996_mac_enable_rtscts()
247 addr = mt7996_mac_wtbl_lmac_addr(dev, mvif->sta.wcid.idx, 5); in mt7996_mac_enable_rtscts()
257 u32 ctrl = MT_WTBL_ITCR_WR | MT_WTBL_ITCR_EXEC | tbl_idx; in mt7996_mac_set_fixed_rate_table() local
262 mt76_wr(dev, MT_WTBL_ITCR, ctrl); in mt7996_mac_set_fixed_rate_table()
265 /* The HW does not translate the mac header to 802.3 for mesh point */
268 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt7996_reverse_frag0_hdr_trans()
269 struct ethhdr *eth_hdr = (struct ethhdr *)(skb->data + hdr_gap); in mt7996_reverse_frag0_hdr_trans()
270 struct mt7996_sta *msta = (struct mt7996_sta *)status->wcid; in mt7996_reverse_frag0_hdr_trans()
271 __le32 *rxd = (__le32 *)skb->data; in mt7996_reverse_frag0_hdr_trans()
279 return -EINVAL; in mt7996_reverse_frag0_hdr_trans()
282 return -EINVAL; in mt7996_reverse_frag0_hdr_trans()
284 if (!msta || !msta->vif) in mt7996_reverse_frag0_hdr_trans()
285 return -EINVAL; in mt7996_reverse_frag0_hdr_trans()
288 vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv); in mt7996_reverse_frag0_hdr_trans()
296 ether_addr_copy(hdr.addr1, vif->addr); in mt7996_reverse_frag0_hdr_trans()
297 ether_addr_copy(hdr.addr2, sta->addr); in mt7996_reverse_frag0_hdr_trans()
301 ether_addr_copy(hdr.addr3, vif->bss_conf.bssid); in mt7996_reverse_frag0_hdr_trans()
304 ether_addr_copy(hdr.addr3, eth_hdr->h_source); in mt7996_reverse_frag0_hdr_trans()
307 ether_addr_copy(hdr.addr3, eth_hdr->h_dest); in mt7996_reverse_frag0_hdr_trans()
310 ether_addr_copy(hdr.addr3, eth_hdr->h_dest); in mt7996_reverse_frag0_hdr_trans()
311 ether_addr_copy(hdr.addr4, eth_hdr->h_source); in mt7996_reverse_frag0_hdr_trans()
314 return -EINVAL; in mt7996_reverse_frag0_hdr_trans()
317 skb_pull(skb, hdr_gap + sizeof(struct ethhdr) - 2); in mt7996_reverse_frag0_hdr_trans()
318 if (eth_hdr->h_proto == cpu_to_be16(ETH_P_AARP) || in mt7996_reverse_frag0_hdr_trans()
319 eth_hdr->h_proto == cpu_to_be16(ETH_P_IPX)) in mt7996_reverse_frag0_hdr_trans()
321 else if (be16_to_cpu(eth_hdr->h_proto) >= ETH_P_802_3_MIN) in mt7996_reverse_frag0_hdr_trans()
340 memcpy(skb_push(skb, sizeof(hdr) - 6), &hdr, sizeof(hdr) - 6); in mt7996_reverse_frag0_hdr_trans()
374 i = mt76_get_rate(&dev->mt76, sband, i, cck); in mt7996_mac_fill_rx_rate()
378 status->encoding = RX_ENC_HT; in mt7996_mac_fill_rx_rate()
380 status->enc_flags |= RX_ENC_FLAG_SHORT_GI; in mt7996_mac_fill_rx_rate()
382 return -EINVAL; in mt7996_mac_fill_rx_rate()
385 status->nss = nss; in mt7996_mac_fill_rx_rate()
386 status->encoding = RX_ENC_VHT; in mt7996_mac_fill_rx_rate()
388 status->enc_flags |= RX_ENC_FLAG_SHORT_GI; in mt7996_mac_fill_rx_rate()
390 return -EINVAL; in mt7996_mac_fill_rx_rate()
396 status->nss = nss; in mt7996_mac_fill_rx_rate()
397 status->encoding = RX_ENC_HE; in mt7996_mac_fill_rx_rate()
401 status->he_gi = gi; in mt7996_mac_fill_rx_rate()
403 status->he_dcm = dcm; in mt7996_mac_fill_rx_rate()
408 status->nss = nss; in mt7996_mac_fill_rx_rate()
409 status->encoding = RX_ENC_EHT; in mt7996_mac_fill_rx_rate()
413 status->eht.gi = gi; in mt7996_mac_fill_rx_rate()
416 return -EINVAL; in mt7996_mac_fill_rx_rate()
418 status->rate_idx = i; in mt7996_mac_fill_rx_rate()
426 status->bw = RATE_INFO_BW_HE_RU; in mt7996_mac_fill_rx_rate()
427 status->he_ru = in mt7996_mac_fill_rx_rate()
430 status->bw = RATE_INFO_BW_40; in mt7996_mac_fill_rx_rate()
434 status->bw = RATE_INFO_BW_80; in mt7996_mac_fill_rx_rate()
437 status->bw = RATE_INFO_BW_160; in mt7996_mac_fill_rx_rate()
440 status->bw = RATE_INFO_BW_320; in mt7996_mac_fill_rx_rate()
443 return -EINVAL; in mt7996_mac_fill_rx_rate()
446 status->enc_flags |= RX_ENC_FLAG_STBC_MASK * stbc; in mt7996_mac_fill_rx_rate()
448 status->enc_flags |= RX_ENC_FLAG_SHORT_GI; in mt7996_mac_fill_rx_rate()
456 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt7996_mac_fill_rx()
457 struct mt76_phy *mphy = &dev->mt76.phy; in mt7996_mac_fill_rx()
458 struct mt7996_phy *phy = &dev->phy; in mt7996_mac_fill_rx()
460 __le32 *rxd = (__le32 *)skb->data; in mt7996_mac_fill_rx()
468 u32 csum_status = *(u32 *)skb->cb; in mt7996_mac_fill_rx()
483 mphy = dev->mt76.phys[band_idx]; in mt7996_mac_fill_rx()
484 phy = mphy->priv; in mt7996_mac_fill_rx()
485 status->phy_idx = mphy->band_idx; in mt7996_mac_fill_rx()
487 if (!test_bit(MT76_STATE_RUNNING, &mphy->state)) in mt7996_mac_fill_rx()
488 return -EINVAL; in mt7996_mac_fill_rx()
491 return -EINVAL; in mt7996_mac_fill_rx()
495 return -EINVAL; in mt7996_mac_fill_rx()
499 status->flag |= RX_FLAG_ONLY_MONITOR; in mt7996_mac_fill_rx()
503 status->wcid = mt7996_rx_get_wcid(dev, idx, unicast); in mt7996_mac_fill_rx()
505 if (status->wcid) { in mt7996_mac_fill_rx()
508 msta = container_of(status->wcid, struct mt7996_sta, wcid); in mt7996_mac_fill_rx()
509 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_fill_rx()
510 if (list_empty(&msta->wcid.poll_list)) in mt7996_mac_fill_rx()
511 list_add_tail(&msta->wcid.poll_list, in mt7996_mac_fill_rx()
512 &dev->mt76.sta_poll_list); in mt7996_mac_fill_rx()
513 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_fill_rx()
516 status->freq = mphy->chandef.chan->center_freq; in mt7996_mac_fill_rx()
517 status->band = mphy->chandef.chan->band; in mt7996_mac_fill_rx()
518 if (status->band == NL80211_BAND_5GHZ) in mt7996_mac_fill_rx()
519 sband = &mphy->sband_5g.sband; in mt7996_mac_fill_rx()
520 else if (status->band == NL80211_BAND_6GHZ) in mt7996_mac_fill_rx()
521 sband = &mphy->sband_6g.sband; in mt7996_mac_fill_rx()
523 sband = &mphy->sband_2g.sband; in mt7996_mac_fill_rx()
525 if (!sband->channels) in mt7996_mac_fill_rx()
526 return -EINVAL; in mt7996_mac_fill_rx()
530 skb->ip_summed = CHECKSUM_UNNECESSARY; in mt7996_mac_fill_rx()
533 status->flag |= RX_FLAG_FAILED_FCS_CRC; in mt7996_mac_fill_rx()
536 status->flag |= RX_FLAG_MMIC_ERROR; in mt7996_mac_fill_rx()
540 status->flag |= RX_FLAG_DECRYPTED; in mt7996_mac_fill_rx()
541 status->flag |= RX_FLAG_IV_STRIPPED; in mt7996_mac_fill_rx()
542 status->flag |= RX_FLAG_MMIC_STRIPPED | RX_FLAG_MIC_STRIPPED; in mt7996_mac_fill_rx()
548 return -EINVAL; in mt7996_mac_fill_rx()
560 if ((u8 *)rxd - skb->data >= skb->len) in mt7996_mac_fill_rx()
561 return -EINVAL; in mt7996_mac_fill_rx()
567 if (status->flag & RX_FLAG_DECRYPTED) { in mt7996_mac_fill_rx()
579 status->iv[0] = data[5]; in mt7996_mac_fill_rx()
580 status->iv[1] = data[4]; in mt7996_mac_fill_rx()
581 status->iv[2] = data[3]; in mt7996_mac_fill_rx()
582 status->iv[3] = data[2]; in mt7996_mac_fill_rx()
583 status->iv[4] = data[1]; in mt7996_mac_fill_rx()
584 status->iv[5] = data[0]; in mt7996_mac_fill_rx()
591 if ((u8 *)rxd - skb->data >= skb->len) in mt7996_mac_fill_rx()
592 return -EINVAL; in mt7996_mac_fill_rx()
596 status->timestamp = le32_to_cpu(rxd[0]); in mt7996_mac_fill_rx()
597 status->flag |= RX_FLAG_MACTIME_START; in mt7996_mac_fill_rx()
600 status->flag |= RX_FLAG_AMPDU_DETAILS; in mt7996_mac_fill_rx()
602 /* all subframes of an A-MPDU have the same timestamp */ in mt7996_mac_fill_rx()
603 if (phy->rx_ampdu_ts != status->timestamp) { in mt7996_mac_fill_rx()
604 if (!++phy->ampdu_ref) in mt7996_mac_fill_rx()
605 phy->ampdu_ref++; in mt7996_mac_fill_rx()
607 phy->rx_ampdu_ts = status->timestamp; in mt7996_mac_fill_rx()
609 status->ampdu_ref = phy->ampdu_ref; in mt7996_mac_fill_rx()
613 if ((u8 *)rxd - skb->data >= skb->len) in mt7996_mac_fill_rx()
614 return -EINVAL; in mt7996_mac_fill_rx()
617 /* RXD Group 3 - P-RXV */ in mt7996_mac_fill_rx()
624 if ((u8 *)rxd - skb->data >= skb->len) in mt7996_mac_fill_rx()
625 return -EINVAL; in mt7996_mac_fill_rx()
629 status->chains = mphy->antenna_mask; in mt7996_mac_fill_rx()
630 status->chain_signal[0] = to_rssi(MT_PRXV_RCPI0, v3); in mt7996_mac_fill_rx()
631 status->chain_signal[1] = to_rssi(MT_PRXV_RCPI1, v3); in mt7996_mac_fill_rx()
632 status->chain_signal[2] = to_rssi(MT_PRXV_RCPI2, v3); in mt7996_mac_fill_rx()
633 status->chain_signal[3] = to_rssi(MT_PRXV_RCPI3, v3); in mt7996_mac_fill_rx()
635 /* RXD Group 5 - C-RXV */ in mt7996_mac_fill_rx()
638 if ((u8 *)rxd - skb->data >= skb->len) in mt7996_mac_fill_rx()
639 return -EINVAL; in mt7996_mac_fill_rx()
648 status->amsdu = !!amsdu_info; in mt7996_mac_fill_rx()
649 if (status->amsdu) { in mt7996_mac_fill_rx()
650 status->first_amsdu = amsdu_info == MT_RXD4_FIRST_AMSDU_FRAME; in mt7996_mac_fill_rx()
651 status->last_amsdu = amsdu_info == MT_RXD4_LAST_AMSDU_FRAME; in mt7996_mac_fill_rx()
654 hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad; in mt7996_mac_fill_rx()
657 return -EINVAL; in mt7996_mac_fill_rx()
663 if (!hdr_trans && status->amsdu && !(ieee80211_has_a4(fc) && is_mesh)) { in mt7996_mac_fill_rx()
667 * the hardware will insert an extra 2-byte field in mt7996_mac_fill_rx()
669 * type field. This happens either when the LLC-SNAP in mt7996_mac_fill_rx()
674 if (get_unaligned_be16(skb->data + pad_start) == ETH_P_8021Q) in mt7996_mac_fill_rx()
681 memmove(skb->data + 2, skb->data, pad_start); in mt7996_mac_fill_rx()
696 fc = hdr->frame_control; in mt7996_mac_fill_rx()
700 seq_ctrl = le16_to_cpu(hdr->seq_ctrl); in mt7996_mac_fill_rx()
704 * de-amsdu, so here needs to clear amsdu present bit in mt7996_mac_fill_rx()
707 if (ieee80211_has_a4(fc) && is_mesh && status->amsdu) in mt7996_mac_fill_rx()
711 status->flag |= RX_FLAG_8023; in mt7996_mac_fill_rx()
714 if (rxv && mode >= MT_PHY_TYPE_HE_SU && !(status->flag & RX_FLAG_8023)) in mt7996_mac_fill_rx()
717 if (!status->wcid || !ieee80211_is_data_qos(fc)) in mt7996_mac_fill_rx()
720 status->aggr = unicast && in mt7996_mac_fill_rx()
722 status->qos_ctl = qos_ctl; in mt7996_mac_fill_rx()
723 status->seqno = IEEE80211_SEQ_TO_SN(seq_ctrl); in mt7996_mac_fill_rx()
732 u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in mt7996_mac_write_txwi_8023()
738 if (wcid->sta) { in mt7996_mac_write_txwi_8023()
742 wmm = sta->wme; in mt7996_mac_write_txwi_8023()
748 ethertype = get_unaligned_be16(&skb->data[12]); in mt7996_mac_write_txwi_8023()
767 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in mt7996_mac_write_txwi_80211()
768 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data; in mt7996_mac_write_txwi_80211()
770 bool multicast = is_multicast_ether_addr(hdr->addr1); in mt7996_mac_write_txwi_80211()
771 u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in mt7996_mac_write_txwi_80211()
772 __le16 fc = hdr->frame_control; in mt7996_mac_write_txwi_80211()
777 mgmt->u.action.category == WLAN_CATEGORY_BACK && in mt7996_mac_write_txwi_80211()
778 mgmt->u.action.u.addba_req.action_code == WLAN_ACTION_ADDBA_REQ) in mt7996_mac_write_txwi_80211()
780 else if (ieee80211_is_mgmt(hdr->frame_control)) in mt7996_mac_write_txwi_80211()
789 info->flags & IEEE80211_TX_CTL_USE_MINRATE) in mt7996_mac_write_txwi_80211()
793 key->cipher == WLAN_CIPHER_SUITE_AES_CMAC) { in mt7996_mac_write_txwi_80211()
814 if (info->flags & IEEE80211_TX_CTL_INJECTED) { in mt7996_mac_write_txwi_80211()
815 u16 seqno = le16_to_cpu(hdr->seq_ctrl); in mt7996_mac_write_txwi_80211()
817 if (ieee80211_is_back_req(hdr->frame_control)) { in mt7996_mac_write_txwi_80211()
820 bar = (struct ieee80211_bar *)skb->data; in mt7996_mac_write_txwi_80211()
821 seqno = le16_to_cpu(bar->start_seq_num); in mt7996_mac_write_txwi_80211()
837 struct ieee80211_vif *vif = info->control.vif; in mt7996_mac_write_txwi()
838 u8 band_idx = (info->hw_queue & MT_TX_HW_QUEUE_PHY) >> 2; in mt7996_mac_write_txwi()
840 bool is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP; in mt7996_mac_write_txwi()
849 mvif = vif ? (struct mt76_vif *)vif->drv_priv : NULL; in mt7996_mac_write_txwi()
851 omac_idx = mvif->omac_idx; in mt7996_mac_write_txwi()
852 wmm_idx = mvif->wmm_idx; in mt7996_mac_write_txwi()
853 band_idx = mvif->band_idx; in mt7996_mac_write_txwi()
871 val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len + MT_TXD_SIZE) | in mt7996_mac_write_txwi()
876 val = FIELD_PREP(MT_TXD1_WLAN_IDX, wcid->idx) | in mt7996_mac_write_txwi()
889 if (info->flags & IEEE80211_TX_CTL_NO_ACK) in mt7996_mac_write_txwi()
891 if (wcid->amsdu) in mt7996_mac_write_txwi()
913 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in mt7996_mac_write_txwi()
914 bool mcast = ieee80211_is_data(hdr->frame_control) && in mt7996_mac_write_txwi()
915 is_multicast_ether_addr(hdr->addr1); in mt7996_mac_write_txwi()
919 if (mcast && mvif->mcast_rates_idx) in mt7996_mac_write_txwi()
920 idx = mvif->mcast_rates_idx; in mt7996_mac_write_txwi()
921 else if (beacon && mvif->beacon_rates_idx) in mt7996_mac_write_txwi()
922 idx = mvif->beacon_rates_idx; in mt7996_mac_write_txwi()
924 idx = mvif->basic_rates_idx; in mt7996_mac_write_txwi()
937 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx_info->skb->data; in mt7996_tx_prepare_skb()
939 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_info->skb); in mt7996_tx_prepare_skb()
940 struct ieee80211_key_conf *key = info->control.hw_key; in mt7996_tx_prepare_skb()
941 struct ieee80211_vif *vif = info->control.vif; in mt7996_tx_prepare_skb()
944 int id, i, pid, nbuf = tx_info->nbuf - 1; in mt7996_tx_prepare_skb()
945 bool is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP; in mt7996_tx_prepare_skb()
948 if (unlikely(tx_info->skb->len <= ETH_HLEN)) in mt7996_tx_prepare_skb()
949 return -EINVAL; in mt7996_tx_prepare_skb()
952 wcid = &dev->mt76.global_wcid; in mt7996_tx_prepare_skb()
955 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; in mt7996_tx_prepare_skb()
957 if (time_after(jiffies, msta->jiffies + HZ / 4)) { in mt7996_tx_prepare_skb()
958 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; in mt7996_tx_prepare_skb()
959 msta->jiffies = jiffies; in mt7996_tx_prepare_skb()
963 t = (struct mt76_txwi_cache *)(txwi + mdev->drv->txwi_size); in mt7996_tx_prepare_skb()
964 t->skb = tx_info->skb; in mt7996_tx_prepare_skb()
970 pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb); in mt7996_tx_prepare_skb()
971 mt7996_mac_write_txwi(dev, txwi_ptr, tx_info->skb, wcid, key, in mt7996_tx_prepare_skb()
976 txp->fw.buf[i] = cpu_to_le32(tx_info->buf[i + 1].addr); in mt7996_tx_prepare_skb()
977 txp->fw.len[i] = cpu_to_le16(tx_info->buf[i + 1].len); in mt7996_tx_prepare_skb()
979 txp->fw.nbuf = nbuf; in mt7996_tx_prepare_skb()
981 txp->fw.flags = in mt7996_tx_prepare_skb()
985 txp->fw.flags |= cpu_to_le16(MT_CT_INFO_NONE_CIPHER_FRAME); in mt7996_tx_prepare_skb()
987 if (!is_8023 && ieee80211_is_mgmt(hdr->frame_control)) in mt7996_tx_prepare_skb()
988 txp->fw.flags |= cpu_to_le16(MT_CT_INFO_MGMT_FRAME); in mt7996_tx_prepare_skb()
991 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; in mt7996_tx_prepare_skb()
993 txp->fw.bss_idx = mvif->mt76.idx; in mt7996_tx_prepare_skb()
996 txp->fw.token = cpu_to_le16(id); in mt7996_tx_prepare_skb()
997 if (test_bit(MT_WCID_FLAG_4ADDR, &wcid->flags)) in mt7996_tx_prepare_skb()
998 txp->fw.rept_wds_wcid = cpu_to_le16(wcid->idx); in mt7996_tx_prepare_skb()
1000 txp->fw.rept_wds_wcid = cpu_to_le16(0xfff); in mt7996_tx_prepare_skb()
1001 tx_info->skb = DMA_DUMMY_DATA; in mt7996_tx_prepare_skb()
1004 tx_info->buf[1].len = MT_CT_PARSE_LEN; in mt7996_tx_prepare_skb()
1005 tx_info->buf[1].skip_unmap = true; in mt7996_tx_prepare_skb()
1006 tx_info->nbuf = MT_CT_DMA_BUF_NUM; in mt7996_tx_prepare_skb()
1018 if (!sta || !(sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he)) in mt7996_tx_check_aggr()
1031 msta = (struct mt7996_sta *)sta->drv_priv; in mt7996_tx_check_aggr()
1032 if (!test_and_set_bit(tid, &msta->wcid.ampdu_state)) in mt7996_tx_check_aggr()
1040 struct mt76_dev *mdev = &dev->mt76; in mt7996_txwi_free()
1046 if (!t->skb) in mt7996_txwi_free()
1051 wcid = (struct mt76_wcid *)sta->drv_priv; in mt7996_txwi_free()
1052 wcid_idx = wcid->idx; in mt7996_txwi_free()
1054 if (likely(t->skb->protocol != cpu_to_be16(ETH_P_PAE))) in mt7996_txwi_free()
1060 __mt76_tx_complete_skb(mdev, wcid_idx, t->skb, free_list); in mt7996_txwi_free()
1063 t->skb = NULL; in mt7996_txwi_free()
1071 struct mt76_dev *mdev = &dev->mt76; in mt7996_mac_tx_free()
1072 struct mt76_phy *phy2 = mdev->phys[MT_BAND1]; in mt7996_mac_tx_free()
1073 struct mt76_phy *phy3 = mdev->phys[MT_BAND2]; in mt7996_mac_tx_free()
1087 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_PSD], false); in mt7996_mac_tx_free()
1088 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_BE], false); in mt7996_mac_tx_free()
1090 mt76_queue_tx_cleanup(dev, phy2->q_tx[MT_TXQ_PSD], false); in mt7996_mac_tx_free()
1091 mt76_queue_tx_cleanup(dev, phy2->q_tx[MT_TXQ_BE], false); in mt7996_mac_tx_free()
1094 mt76_queue_tx_cleanup(dev, phy3->q_tx[MT_TXQ_PSD], false); in mt7996_mac_tx_free()
1095 mt76_queue_tx_cleanup(dev, phy3->q_tx[MT_TXQ_BE], false); in mt7996_mac_tx_free()
1118 wcid = rcu_dereference(dev->mt76.wcid[idx]); in mt7996_mac_tx_free()
1124 spin_lock_bh(&mdev->sta_poll_lock); in mt7996_mac_tx_free()
1125 if (list_empty(&msta->wcid.poll_list)) in mt7996_mac_tx_free()
1126 list_add_tail(&msta->wcid.poll_list, in mt7996_mac_tx_free()
1127 &mdev->sta_poll_list); in mt7996_mac_tx_free()
1128 spin_unlock_bh(&mdev->sta_poll_lock); in mt7996_mac_tx_free()
1152 mt76_set_tx_blocked(&dev->mt76, false); in mt7996_mac_tx_free()
1154 mt76_worker_schedule(&dev->mt76.tx_worker); in mt7996_mac_tx_free()
1166 struct mt76_sta_stats *stats = &wcid->stats; in mt7996_mac_add_txs_skb()
1168 struct mt76_dev *mdev = &dev->mt76; in mt7996_mac_add_txs_skb()
1186 info->flags |= IEEE80211_TX_STAT_ACK; in mt7996_mac_add_txs_skb()
1188 info->status.ampdu_len = 1; in mt7996_mac_add_txs_skb()
1189 info->status.ampdu_ack_len = !!(info->flags & in mt7996_mac_add_txs_skb()
1192 info->status.rates[0].idx = -1; in mt7996_mac_add_txs_skb()
1203 if (rate.nss - 1 < ARRAY_SIZE(stats->tx_nss)) in mt7996_mac_add_txs_skb()
1204 stats->tx_nss[rate.nss - 1]++; in mt7996_mac_add_txs_skb()
1205 if (rate.mcs < ARRAY_SIZE(stats->tx_mcs)) in mt7996_mac_add_txs_skb()
1206 stats->tx_mcs[rate.mcs]++; in mt7996_mac_add_txs_skb()
1214 mphy = mt76_dev_phy(mdev, wcid->phy_idx); in mt7996_mac_add_txs_skb()
1216 if (mphy->chandef.chan->band == NL80211_BAND_5GHZ) in mt7996_mac_add_txs_skb()
1217 sband = &mphy->sband_5g.sband; in mt7996_mac_add_txs_skb()
1218 else if (mphy->chandef.chan->band == NL80211_BAND_6GHZ) in mt7996_mac_add_txs_skb()
1219 sband = &mphy->sband_6g.sband; in mt7996_mac_add_txs_skb()
1221 sband = &mphy->sband_2g.sband; in mt7996_mac_add_txs_skb()
1223 rate.mcs = mt76_get_rate(mphy->dev, sband, rate.mcs, cck); in mt7996_mac_add_txs_skb()
1224 rate.legacy = sband->bitrates[rate.mcs].bitrate; in mt7996_mac_add_txs_skb()
1232 if (wcid->rate.flags & RATE_INFO_FLAGS_SHORT_GI) in mt7996_mac_add_txs_skb()
1248 rate.he_gi = wcid->rate.he_gi; in mt7996_mac_add_txs_skb()
1258 rate.eht_gi = wcid->rate.eht_gi; in mt7996_mac_add_txs_skb()
1265 stats->tx_mode[mode]++; in mt7996_mac_add_txs_skb()
1270 stats->tx_bw[4]++; in mt7996_mac_add_txs_skb()
1274 stats->tx_bw[3]++; in mt7996_mac_add_txs_skb()
1278 stats->tx_bw[2]++; in mt7996_mac_add_txs_skb()
1282 stats->tx_bw[1]++; in mt7996_mac_add_txs_skb()
1286 stats->tx_bw[0]++; in mt7996_mac_add_txs_skb()
1289 wcid->rate = rate; in mt7996_mac_add_txs_skb()
1322 wcid = rcu_dereference(dev->mt76.wcid[wcidx]); in mt7996_mac_add_txs()
1330 if (!wcid->sta) in mt7996_mac_add_txs()
1333 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_add_txs()
1334 if (list_empty(&msta->wcid.poll_list)) in mt7996_mac_add_txs()
1335 list_add_tail(&msta->wcid.poll_list, &dev->mt76.sta_poll_list); in mt7996_mac_add_txs()
1336 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_add_txs()
1378 __le32 *rxd = (__le32 *)skb->data; in mt7996_queue_rx_skb()
1379 __le32 *end = (__le32 *)&skb->data[skb->len]; in mt7996_queue_rx_skb()
1393 mt7996_mac_tx_free(dev, skb->data, skb->len); in mt7996_queue_rx_skb()
1405 mt7996_debugfs_rx_fw_monitor(dev, skb->data, skb->len); in mt7996_queue_rx_skb()
1410 mt76_rx(&dev->mt76, q, skb); in mt7996_queue_rx_skb()
1422 struct mt7996_dev *dev = phy->dev; in mt7996_mac_cca_stats_reset()
1423 u32 reg = MT_WF_PHYRX_BAND_RX_CTRL1(phy->mt76->band_idx); in mt7996_mac_cca_stats_reset()
1431 struct mt7996_dev *dev = phy->dev; in mt7996_mac_reset_counters()
1432 u8 band_idx = phy->mt76->band_idx; in mt7996_mac_reset_counters()
1438 phy->mt76->survey_time = ktime_get_boottime(); in mt7996_mac_reset_counters()
1440 memset(phy->mt76->aggr_stats, 0, sizeof(phy->mt76->aggr_stats)); in mt7996_mac_reset_counters()
1451 s16 coverage_class = phy->coverage_class; in mt7996_mac_set_coverage_class()
1452 struct mt7996_dev *dev = phy->dev; in mt7996_mac_set_coverage_class()
1460 u8 band_idx = phy->mt76->band_idx; in mt7996_mac_set_coverage_class()
1463 if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state)) in mt7996_mac_set_coverage_class()
1467 coverage_class = max_t(s16, dev->phy.coverage_class, in mt7996_mac_set_coverage_class()
1468 phy2->coverage_class); in mt7996_mac_set_coverage_class()
1472 phy3->coverage_class); in mt7996_mac_set_coverage_class()
1496 struct mt7996_dev *dev = phy->dev; in mt7996_phy_get_nf()
1500 for (ant = 0; ant < hweight8(phy->mt76->antenna_mask); ant++) { in mt7996_phy_get_nf()
1515 struct mt7996_phy *phy = (struct mt7996_phy *)mphy->priv; in mt7996_update_channel()
1516 struct mt76_channel_state *state = mphy->chan_state; in mt7996_update_channel()
1521 nf = mt7996_phy_get_nf(phy, mphy->band_idx); in mt7996_update_channel()
1522 if (!phy->noise) in mt7996_update_channel()
1523 phy->noise = nf << 4; in mt7996_update_channel()
1525 phy->noise += nf - (phy->noise >> 4); in mt7996_update_channel()
1527 state->noise = -(phy->noise >> 4); in mt7996_update_channel()
1535 ret = wait_event_timeout(dev->reset_wait, in mt7996_wait_reset_state()
1536 (READ_ONCE(dev->recovery.state) & state), in mt7996_wait_reset_state()
1546 struct ieee80211_hw *hw = priv; in mt7996_update_vif_beacon() local
1548 switch (vif->type) { in mt7996_update_vif_beacon()
1552 mt7996_mcu_add_beacon(hw, vif, vif->bss_conf.enable_beacon); in mt7996_update_vif_beacon()
1564 ieee80211_iterate_active_interfaces(dev->mt76.hw, in mt7996_update_beacons()
1566 mt7996_update_vif_beacon, dev->mt76.hw); in mt7996_update_beacons()
1568 phy2 = dev->mt76.phys[MT_BAND1]; in mt7996_update_beacons()
1572 ieee80211_iterate_active_interfaces(phy2->hw, in mt7996_update_beacons()
1574 mt7996_update_vif_beacon, phy2->hw); in mt7996_update_beacons()
1576 phy3 = dev->mt76.phys[MT_BAND2]; in mt7996_update_beacons()
1580 ieee80211_iterate_active_interfaces(phy3->hw, in mt7996_update_beacons()
1582 mt7996_update_vif_beacon, phy3->hw); in mt7996_update_beacons()
1590 spin_lock_bh(&dev->mt76.token_lock); in mt7996_tx_token_put()
1591 idr_for_each_entry(&dev->mt76.token, txwi, id) { in mt7996_tx_token_put()
1593 dev->mt76.token_count--; in mt7996_tx_token_put()
1595 spin_unlock_bh(&dev->mt76.token_lock); in mt7996_tx_token_put()
1596 idr_destroy(&dev->mt76.token); in mt7996_tx_token_put()
1603 struct mt76_dev *mdev = &dev->mt76; in mt7996_mac_restart()
1609 if (dev->hif2) { in mt7996_mac_restart()
1614 if (dev_is_pci(mdev->dev)) { in mt7996_mac_restart()
1616 if (dev->hif2) in mt7996_mac_restart()
1620 set_bit(MT76_RESET, &dev->mphy.state); in mt7996_mac_restart()
1621 set_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7996_mac_restart()
1622 wake_up(&dev->mt76.mcu.wait); in mt7996_mac_restart()
1624 set_bit(MT76_RESET, &phy2->mt76->state); in mt7996_mac_restart()
1625 set_bit(MT76_MCU_RESET, &phy2->mt76->state); in mt7996_mac_restart()
1628 set_bit(MT76_RESET, &phy3->mt76->state); in mt7996_mac_restart()
1629 set_bit(MT76_MCU_RESET, &phy3->mt76->state); in mt7996_mac_restart()
1633 mt76_txq_schedule_all(&dev->mphy); in mt7996_mac_restart()
1635 mt76_txq_schedule_all(phy2->mt76); in mt7996_mac_restart()
1637 mt76_txq_schedule_all(phy3->mt76); in mt7996_mac_restart()
1640 mt76_worker_disable(&dev->mt76.tx_worker); in mt7996_mac_restart()
1642 if (mdev->q_rx[i].ndesc) in mt7996_mac_restart()
1643 napi_disable(&dev->mt76.napi[i]); in mt7996_mac_restart()
1645 napi_disable(&dev->mt76.tx_napi); in mt7996_mac_restart()
1649 idr_init(&dev->mt76.token); in mt7996_mac_restart()
1655 if (mdev->q_rx[i].ndesc) { in mt7996_mac_restart()
1656 napi_enable(&dev->mt76.napi[i]); in mt7996_mac_restart()
1657 napi_schedule(&dev->mt76.napi[i]); in mt7996_mac_restart()
1661 clear_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7996_mac_restart()
1662 clear_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); in mt7996_mac_restart()
1664 mt76_wr(dev, MT_INT_MASK_CSR, dev->mt76.mmio.irqmask); in mt7996_mac_restart()
1666 if (dev->hif2) { in mt7996_mac_restart()
1667 mt76_wr(dev, MT_INT1_MASK_CSR, dev->mt76.mmio.irqmask); in mt7996_mac_restart()
1670 if (dev_is_pci(mdev->dev)) { in mt7996_mac_restart()
1672 if (dev->hif2) in mt7996_mac_restart()
1687 mt7996_init_txpower(dev, &dev->mphy.sband_2g.sband); in mt7996_mac_restart()
1688 mt7996_init_txpower(dev, &dev->mphy.sband_5g.sband); in mt7996_mac_restart()
1689 mt7996_init_txpower(dev, &dev->mphy.sband_6g.sband); in mt7996_mac_restart()
1692 if (test_bit(MT76_STATE_RUNNING, &dev->mphy.state)) { in mt7996_mac_restart()
1693 ret = mt7996_run(dev->mphy.hw); in mt7996_mac_restart()
1698 if (phy2 && test_bit(MT76_STATE_RUNNING, &phy2->mt76->state)) { in mt7996_mac_restart()
1699 ret = mt7996_run(phy2->mt76->hw); in mt7996_mac_restart()
1704 if (phy3 && test_bit(MT76_STATE_RUNNING, &phy3->mt76->state)) { in mt7996_mac_restart()
1705 ret = mt7996_run(phy3->mt76->hw); in mt7996_mac_restart()
1712 clear_bit(MT76_RESET, &dev->mphy.state); in mt7996_mac_restart()
1714 clear_bit(MT76_RESET, &phy2->mt76->state); in mt7996_mac_restart()
1716 clear_bit(MT76_RESET, &phy3->mt76->state); in mt7996_mac_restart()
1719 napi_enable(&dev->mt76.tx_napi); in mt7996_mac_restart()
1720 napi_schedule(&dev->mt76.tx_napi); in mt7996_mac_restart()
1723 mt76_worker_enable(&dev->mt76.tx_worker); in mt7996_mac_restart()
1735 dev->recovery.hw_full_reset = true; in mt7996_mac_full_reset()
1737 wake_up(&dev->mt76.mcu.wait); in mt7996_mac_full_reset()
1740 ieee80211_stop_queues(phy2->mt76->hw); in mt7996_mac_full_reset()
1742 ieee80211_stop_queues(phy3->mt76->hw); in mt7996_mac_full_reset()
1744 cancel_delayed_work_sync(&dev->mphy.mac_work); in mt7996_mac_full_reset()
1746 cancel_delayed_work_sync(&phy2->mt76->mac_work); in mt7996_mac_full_reset()
1748 cancel_delayed_work_sync(&phy3->mt76->mac_work); in mt7996_mac_full_reset()
1750 mutex_lock(&dev->mt76.mutex); in mt7996_mac_full_reset()
1755 mutex_unlock(&dev->mt76.mutex); in mt7996_mac_full_reset()
1758 dev_err(dev->mt76.dev, "chip full reset failed\n"); in mt7996_mac_full_reset()
1762 ieee80211_restart_hw(phy2->mt76->hw); in mt7996_mac_full_reset()
1764 ieee80211_restart_hw(phy3->mt76->hw); in mt7996_mac_full_reset()
1768 ieee80211_wake_queues(phy2->mt76->hw); in mt7996_mac_full_reset()
1770 ieee80211_wake_queues(phy3->mt76->hw); in mt7996_mac_full_reset()
1772 dev->recovery.hw_full_reset = false; in mt7996_mac_full_reset()
1774 &dev->mphy.mac_work, in mt7996_mac_full_reset()
1777 ieee80211_queue_delayed_work(phy2->mt76->hw, in mt7996_mac_full_reset()
1778 &phy2->mt76->mac_work, in mt7996_mac_full_reset()
1781 ieee80211_queue_delayed_work(phy3->mt76->hw, in mt7996_mac_full_reset()
1782 &phy3->mt76->mac_work, in mt7996_mac_full_reset()
1797 if (dev->recovery.restart) { in mt7996_mac_reset_work()
1802 if (READ_ONCE(dev->recovery.state) & MT_MCU_CMD_WA_WDT) in mt7996_mac_reset_work()
1803 dev->recovery.wa_reset_count++; in mt7996_mac_reset_work()
1805 dev->recovery.wm_reset_count++; in mt7996_mac_reset_work()
1816 dev->recovery.state = MT_MCU_CMD_NORMAL_STATE; in mt7996_mac_reset_work()
1817 dev->recovery.restart = false; in mt7996_mac_reset_work()
1821 if (!(READ_ONCE(dev->recovery.state) & MT_MCU_CMD_STOP_DMA)) in mt7996_mac_reset_work()
1824 dev_info(dev->mt76.dev,"\n%s L1 SER recovery start.", in mt7996_mac_reset_work()
1825 wiphy_name(dev->mt76.hw->wiphy)); in mt7996_mac_reset_work()
1828 ieee80211_stop_queues(phy2->mt76->hw); in mt7996_mac_reset_work()
1830 ieee80211_stop_queues(phy3->mt76->hw); in mt7996_mac_reset_work()
1832 set_bit(MT76_RESET, &dev->mphy.state); in mt7996_mac_reset_work()
1833 set_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7996_mac_reset_work()
1834 wake_up(&dev->mt76.mcu.wait); in mt7996_mac_reset_work()
1835 cancel_delayed_work_sync(&dev->mphy.mac_work); in mt7996_mac_reset_work()
1837 set_bit(MT76_RESET, &phy2->mt76->state); in mt7996_mac_reset_work()
1838 cancel_delayed_work_sync(&phy2->mt76->mac_work); in mt7996_mac_reset_work()
1841 set_bit(MT76_RESET, &phy3->mt76->state); in mt7996_mac_reset_work()
1842 cancel_delayed_work_sync(&phy3->mt76->mac_work); in mt7996_mac_reset_work()
1844 mt76_worker_disable(&dev->mt76.tx_worker); in mt7996_mac_reset_work()
1845 mt76_for_each_q_rx(&dev->mt76, i) in mt7996_mac_reset_work()
1846 napi_disable(&dev->mt76.napi[i]); in mt7996_mac_reset_work()
1847 napi_disable(&dev->mt76.tx_napi); in mt7996_mac_reset_work()
1849 mutex_lock(&dev->mt76.mutex); in mt7996_mac_reset_work()
1857 idr_init(&dev->mt76.token); in mt7996_mac_reset_work()
1869 clear_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7996_mac_reset_work()
1870 clear_bit(MT76_RESET, &dev->mphy.state); in mt7996_mac_reset_work()
1872 clear_bit(MT76_RESET, &phy2->mt76->state); in mt7996_mac_reset_work()
1874 clear_bit(MT76_RESET, &phy3->mt76->state); in mt7996_mac_reset_work()
1877 mt76_for_each_q_rx(&dev->mt76, i) { in mt7996_mac_reset_work()
1878 napi_enable(&dev->mt76.napi[i]); in mt7996_mac_reset_work()
1879 napi_schedule(&dev->mt76.napi[i]); in mt7996_mac_reset_work()
1883 tasklet_schedule(&dev->mt76.irq_tasklet); in mt7996_mac_reset_work()
1885 mt76_worker_enable(&dev->mt76.tx_worker); in mt7996_mac_reset_work()
1888 napi_enable(&dev->mt76.tx_napi); in mt7996_mac_reset_work()
1889 napi_schedule(&dev->mt76.tx_napi); in mt7996_mac_reset_work()
1894 ieee80211_wake_queues(phy2->mt76->hw); in mt7996_mac_reset_work()
1896 ieee80211_wake_queues(phy3->mt76->hw); in mt7996_mac_reset_work()
1898 mutex_unlock(&dev->mt76.mutex); in mt7996_mac_reset_work()
1902 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mphy.mac_work, in mt7996_mac_reset_work()
1905 ieee80211_queue_delayed_work(phy2->mt76->hw, in mt7996_mac_reset_work()
1906 &phy2->mt76->mac_work, in mt7996_mac_reset_work()
1909 ieee80211_queue_delayed_work(phy3->mt76->hw, in mt7996_mac_reset_work()
1910 &phy3->mt76->mac_work, in mt7996_mac_reset_work()
1912 dev_info(dev->mt76.dev,"\n%s L1 SER recovery completed.", in mt7996_mac_reset_work()
1913 wiphy_name(dev->mt76.hw->wiphy)); in mt7996_mac_reset_work()
1930 mutex_lock(&dev->dump_mutex); in mt7996_mac_dump_work()
1934 mutex_unlock(&dev->dump_mutex); in mt7996_mac_dump_work()
1939 if (!mem_region || !crash_data->memdump_buf_len) { in mt7996_mac_dump_work()
1940 mutex_unlock(&dev->dump_mutex); in mt7996_mac_dump_work()
1944 buf = crash_data->memdump_buf; in mt7996_mac_dump_work()
1945 buf_len = crash_data->memdump_buf_len; in mt7996_mac_dump_work()
1950 if (mem_region->len > buf_len) { in mt7996_mac_dump_work()
1951 dev_warn(dev->mt76.dev, "%s len %zu is too large\n", in mt7996_mac_dump_work()
1952 mem_region->name, mem_region->len); in mt7996_mac_dump_work()
1959 buf_len -= sizeof(*hdr); in mt7996_mac_dump_work()
1961 mt7996_memcpy_fromio(dev, buf, mem_region->start, in mt7996_mac_dump_work()
1962 mem_region->len); in mt7996_mac_dump_work()
1964 hdr->start = mem_region->start; in mt7996_mac_dump_work()
1965 hdr->len = mem_region->len; in mt7996_mac_dump_work()
1967 if (!mem_region->len) in mt7996_mac_dump_work()
1971 buf += mem_region->len; in mt7996_mac_dump_work()
1972 buf_len -= mem_region->len; in mt7996_mac_dump_work()
1977 mutex_unlock(&dev->dump_mutex); in mt7996_mac_dump_work()
1982 queue_work(dev->mt76.wq, &dev->reset_work); in mt7996_mac_dump_work()
1987 if (!dev->recovery.hw_init_done) in mt7996_reset()
1990 if (dev->recovery.hw_full_reset) in mt7996_reset()
1994 if (READ_ONCE(dev->recovery.state) & MT_MCU_CMD_WDT_MASK) { in mt7996_reset()
1995 dev->recovery.restart = true; in mt7996_reset()
1996 dev_info(dev->mt76.dev, in mt7996_reset()
1998 wiphy_name(dev->mt76.hw->wiphy)); in mt7996_reset()
2001 queue_work(dev->mt76.wq, &dev->dump_work); in mt7996_reset()
2005 queue_work(dev->mt76.wq, &dev->reset_work); in mt7996_reset()
2006 wake_up(&dev->reset_wait); in mt7996_reset()
2011 struct mt76_mib_stats *mib = &phy->mib; in mt7996_mac_update_stats()
2012 struct mt7996_dev *dev = phy->dev; in mt7996_mac_update_stats()
2013 u8 band_idx = phy->mt76->band_idx; in mt7996_mac_update_stats()
2018 mib->fcs_err_cnt += cnt; in mt7996_mac_update_stats()
2021 mib->rx_fifo_full_cnt += cnt; in mt7996_mac_update_stats()
2024 mib->rx_mpdu_cnt += cnt; in mt7996_mac_update_stats()
2027 mib->channel_idle_cnt += FIELD_GET(MT_MIB_SDR6_CHANNEL_IDL_CNT_MASK, cnt); in mt7996_mac_update_stats()
2030 mib->rx_vector_mismatch_cnt += cnt; in mt7996_mac_update_stats()
2033 mib->rx_delimiter_fail_cnt += cnt; in mt7996_mac_update_stats()
2036 mib->rx_len_mismatch_cnt += cnt; in mt7996_mac_update_stats()
2039 mib->tx_ampdu_cnt += cnt; in mt7996_mac_update_stats()
2042 mib->tx_stop_q_empty_cnt += cnt; in mt7996_mac_update_stats()
2045 mib->tx_mpdu_attempts_cnt += cnt; in mt7996_mac_update_stats()
2048 mib->tx_mpdu_success_cnt += cnt; in mt7996_mac_update_stats()
2051 mib->rx_ampdu_cnt += cnt; in mt7996_mac_update_stats()
2054 mib->rx_ampdu_bytes_cnt += cnt; in mt7996_mac_update_stats()
2057 mib->rx_ampdu_valid_subframe_cnt += cnt; in mt7996_mac_update_stats()
2060 mib->rx_ampdu_valid_subframe_bytes_cnt += cnt; in mt7996_mac_update_stats()
2063 mib->tx_rwp_fail_cnt += FIELD_GET(MT_MIB_SDR27_TX_RWP_FAIL_CNT, cnt); in mt7996_mac_update_stats()
2066 mib->tx_rwp_need_cnt += FIELD_GET(MT_MIB_SDR28_TX_RWP_NEED_CNT, cnt); in mt7996_mac_update_stats()
2069 mib->rx_pfdrop_cnt += cnt; in mt7996_mac_update_stats()
2072 mib->rx_vec_queue_overflow_drop_cnt += cnt; in mt7996_mac_update_stats()
2075 mib->rx_ba_cnt += cnt; in mt7996_mac_update_stats()
2078 mib->tx_bf_ebf_ppdu_cnt += cnt; in mt7996_mac_update_stats()
2081 mib->tx_bf_ibf_ppdu_cnt += cnt; in mt7996_mac_update_stats()
2084 mib->tx_mu_bf_cnt += cnt; in mt7996_mac_update_stats()
2087 mib->tx_mu_mpdu_cnt += cnt; in mt7996_mac_update_stats()
2090 mib->tx_mu_acked_mpdu_cnt += cnt; in mt7996_mac_update_stats()
2093 mib->tx_su_acked_mpdu_cnt += cnt; in mt7996_mac_update_stats()
2096 mib->tx_bf_rx_fb_ht_cnt += cnt; in mt7996_mac_update_stats()
2097 mib->tx_bf_rx_fb_all_cnt += cnt; in mt7996_mac_update_stats()
2100 mib->tx_bf_rx_fb_vht_cnt += cnt; in mt7996_mac_update_stats()
2101 mib->tx_bf_rx_fb_all_cnt += cnt; in mt7996_mac_update_stats()
2104 mib->tx_bf_rx_fb_he_cnt += cnt; in mt7996_mac_update_stats()
2105 mib->tx_bf_rx_fb_all_cnt += cnt; in mt7996_mac_update_stats()
2108 mib->tx_bf_rx_fb_eht_cnt += cnt; in mt7996_mac_update_stats()
2109 mib->tx_bf_rx_fb_all_cnt += cnt; in mt7996_mac_update_stats()
2112 mib->tx_bf_rx_fb_bw = FIELD_GET(MT_ETBF_RX_FB_BW, cnt); in mt7996_mac_update_stats()
2113 mib->tx_bf_rx_fb_nc_cnt += FIELD_GET(MT_ETBF_RX_FB_NC, cnt); in mt7996_mac_update_stats()
2114 mib->tx_bf_rx_fb_nr_cnt += FIELD_GET(MT_ETBF_RX_FB_NR, cnt); in mt7996_mac_update_stats()
2117 mib->tx_bf_fb_trig_cnt += cnt; in mt7996_mac_update_stats()
2120 mib->tx_bf_fb_cpl_cnt += cnt; in mt7996_mac_update_stats()
2122 for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) { in mt7996_mac_update_stats()
2124 mib->tx_amsdu[i] += cnt; in mt7996_mac_update_stats()
2125 mib->tx_amsdu_cnt += cnt; in mt7996_mac_update_stats()
2130 mib->rts_cnt += cnt; in mt7996_mac_update_stats()
2134 mib->rts_retries_cnt += cnt; in mt7996_mac_update_stats()
2138 mib->ba_miss_cnt += cnt; in mt7996_mac_update_stats()
2142 mib->ack_fail_cnt += cnt; in mt7996_mac_update_stats()
2146 phy->mt76->aggr_stats[i] += cnt; in mt7996_mac_update_stats()
2159 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_rc_work()
2160 list_splice_init(&dev->sta_rc_list, &list); in mt7996_mac_sta_rc_work()
2164 list_del_init(&msta->rc_list); in mt7996_mac_sta_rc_work()
2165 changed = msta->changed; in mt7996_mac_sta_rc_work()
2166 msta->changed = 0; in mt7996_mac_sta_rc_work()
2167 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_rc_work()
2170 vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv); in mt7996_mac_sta_rc_work()
2179 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_rc_work()
2182 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_rc_work()
2192 phy = mphy->priv; in mt7996_mac_work()
2194 mutex_lock(&mphy->dev->mutex); in mt7996_mac_work()
2197 if (++mphy->mac_work_count == 5) { in mt7996_mac_work()
2198 mphy->mac_work_count = 0; in mt7996_mac_work()
2203 mutex_unlock(&mphy->dev->mutex); in mt7996_mac_work()
2205 mt76_tx_status_check(mphy->dev, false); in mt7996_mac_work()
2207 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, in mt7996_mac_work()
2213 struct mt7996_dev *dev = phy->dev; in mt7996_dfs_stop_radar_detector()
2215 if (phy->rdd_state & BIT(0)) in mt7996_dfs_stop_radar_detector()
2218 if (phy->rdd_state & BIT(1)) in mt7996_dfs_stop_radar_detector()
2227 switch (dev->mt76.region) { in mt7996_dfs_start_rdd()
2251 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7996_dfs_start_radar_detector()
2252 struct mt7996_dev *dev = phy->dev; in mt7996_dfs_start_radar_detector()
2253 u8 band_idx = phy->mt76->band_idx; in mt7996_dfs_start_radar_detector()
2266 phy->rdd_state |= BIT(band_idx); in mt7996_dfs_start_radar_detector()
2268 if (chandef->width == NL80211_CHAN_WIDTH_160 || in mt7996_dfs_start_radar_detector()
2269 chandef->width == NL80211_CHAN_WIDTH_80P80) { in mt7996_dfs_start_radar_detector()
2274 phy->rdd_state |= BIT(1); in mt7996_dfs_start_radar_detector()
2284 struct mt7996_dev *dev = phy->dev; in mt7996_dfs_init_radar_specs()
2287 switch (dev->mt76.region) { in mt7996_dfs_init_radar_specs()
2301 return -EINVAL; in mt7996_dfs_init_radar_specs()
2304 for (i = 0; i < ARRAY_SIZE(radar_specs->radar_pattern); i++) { in mt7996_dfs_init_radar_specs()
2306 &radar_specs->radar_pattern[i]); in mt7996_dfs_init_radar_specs()
2311 return mt7996_mcu_set_pulse_th(dev, &radar_specs->pulse_th); in mt7996_dfs_init_radar_specs()
2316 struct mt7996_dev *dev = phy->dev; in mt7996_dfs_init_radar_detector()
2320 prev_state = phy->mt76->dfs_state; in mt7996_dfs_init_radar_detector()
2321 dfs_state = mt76_phy_dfs_state(phy->mt76); in mt7996_dfs_init_radar_detector()
2341 phy->mt76->dfs_state = MT_DFS_STATE_CAC; in mt7996_dfs_init_radar_detector()
2348 phy->mt76->band_idx, MT_RX_SEL0, 0); in mt7996_dfs_init_radar_detector()
2350 phy->mt76->dfs_state = MT_DFS_STATE_UNKNOWN; in mt7996_dfs_init_radar_detector()
2354 phy->mt76->dfs_state = MT_DFS_STATE_ACTIVE; in mt7996_dfs_init_radar_detector()
2359 phy->mt76->band_idx, MT_RX_SEL0, 0); in mt7996_dfs_init_radar_detector()
2364 phy->mt76->dfs_state = MT_DFS_STATE_DISABLED; in mt7996_dfs_init_radar_detector()
2377 struct mt7996_twt_flow *flow) in mt7996_mac_twt_sched_list_add() argument
2380 u32 duration = flow->duration << 8; in mt7996_mac_twt_sched_list_add()
2383 iter = list_first_entry_or_null(&dev->twt_list, in mt7996_mac_twt_sched_list_add()
2385 if (!iter || !iter->sched || iter->start_tsf > duration) { in mt7996_mac_twt_sched_list_add()
2386 /* add flow as first entry in the list */ in mt7996_mac_twt_sched_list_add()
2387 list_add(&flow->list, &dev->twt_list); in mt7996_mac_twt_sched_list_add()
2391 list_for_each_entry_safe(iter, iter_next, &dev->twt_list, list) { in mt7996_mac_twt_sched_list_add()
2392 start_tsf = iter->start_tsf + in mt7996_mac_twt_sched_list_add()
2393 mt7996_mac_twt_duration_align(iter->duration); in mt7996_mac_twt_sched_list_add()
2394 if (list_is_last(&iter->list, &dev->twt_list)) in mt7996_mac_twt_sched_list_add()
2397 if (!iter_next->sched || in mt7996_mac_twt_sched_list_add()
2398 iter_next->start_tsf > start_tsf + duration) { in mt7996_mac_twt_sched_list_add()
2399 list_add(&flow->list, &iter->list); in mt7996_mac_twt_sched_list_add()
2404 /* add flow as last entry in the list */ in mt7996_mac_twt_sched_list_add()
2405 list_add_tail(&flow->list, &dev->twt_list); in mt7996_mac_twt_sched_list_add()
2418 if (twt->control & IEEE80211_TWT_CONTROL_NEG_TYPE_BROADCAST) in mt7996_mac_check_twt_req()
2419 return -EOPNOTSUPP; in mt7996_mac_check_twt_req()
2422 if (twt->control & IEEE80211_TWT_CONTROL_WAKE_DUR_UNIT) in mt7996_mac_check_twt_req()
2423 return -EOPNOTSUPP; in mt7996_mac_check_twt_req()
2425 twt_agrt = (struct ieee80211_twt_params *)twt->params; in mt7996_mac_check_twt_req()
2428 if (!(twt_agrt->req_type & cpu_to_le16(IEEE80211_TWT_REQTYPE_IMPLICIT))) in mt7996_mac_check_twt_req()
2429 return -EOPNOTSUPP; in mt7996_mac_check_twt_req()
2432 le16_to_cpu(twt_agrt->req_type)); in mt7996_mac_check_twt_req()
2433 mantissa = le16_to_cpu(twt_agrt->mantissa); in mt7996_mac_check_twt_req()
2434 duration = twt_agrt->min_twt_dur << 8; in mt7996_mac_check_twt_req()
2438 return -EOPNOTSUPP; in mt7996_mac_check_twt_req()
2443 void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw, in mt7996_mac_add_twt_setup() argument
2448 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; in mt7996_mac_add_twt_setup()
2449 struct ieee80211_twt_params *twt_agrt = (void *)twt->params; in mt7996_mac_add_twt_setup()
2450 u16 req_type = le16_to_cpu(twt_agrt->req_type); in mt7996_mac_add_twt_setup()
2452 struct mt7996_dev *dev = mt7996_hw_dev(hw); in mt7996_mac_add_twt_setup()
2453 struct mt7996_twt_flow *flow; in mt7996_mac_add_twt_setup() local
2460 mutex_lock(&dev->mt76.mutex); in mt7996_mac_add_twt_setup()
2462 if (dev->twt.n_agrt == MT7996_MAX_TWT_AGRT) in mt7996_mac_add_twt_setup()
2465 if (hweight8(msta->twt.flowid_mask) == ARRAY_SIZE(msta->twt.flow)) in mt7996_mac_add_twt_setup()
2468 flowid = ffs(~msta->twt.flowid_mask) - 1; in mt7996_mac_add_twt_setup()
2469 le16p_replace_bits(&twt_agrt->req_type, flowid, in mt7996_mac_add_twt_setup()
2472 table_id = ffs(~dev->twt.table_mask) - 1; in mt7996_mac_add_twt_setup()
2476 flow = &msta->twt.flow[flowid]; in mt7996_mac_add_twt_setup()
2477 memset(flow, 0, sizeof(*flow)); in mt7996_mac_add_twt_setup()
2478 INIT_LIST_HEAD(&flow->list); in mt7996_mac_add_twt_setup()
2479 flow->wcid = msta->wcid.idx; in mt7996_mac_add_twt_setup()
2480 flow->table_id = table_id; in mt7996_mac_add_twt_setup()
2481 flow->id = flowid; in mt7996_mac_add_twt_setup()
2482 flow->duration = twt_agrt->min_twt_dur; in mt7996_mac_add_twt_setup()
2483 flow->mantissa = twt_agrt->mantissa; in mt7996_mac_add_twt_setup()
2484 flow->exp = exp; in mt7996_mac_add_twt_setup()
2485 flow->protection = !!(req_type & IEEE80211_TWT_REQTYPE_PROTECTION); in mt7996_mac_add_twt_setup()
2486 flow->flowtype = !!(req_type & IEEE80211_TWT_REQTYPE_FLOWTYPE); in mt7996_mac_add_twt_setup()
2487 flow->trigger = !!(req_type & IEEE80211_TWT_REQTYPE_TRIGGER); in mt7996_mac_add_twt_setup()
2491 u64 interval = (u64)le16_to_cpu(twt_agrt->mantissa) << exp; in mt7996_mac_add_twt_setup()
2495 flow->sched = true; in mt7996_mac_add_twt_setup()
2496 flow->start_tsf = mt7996_mac_twt_sched_list_add(dev, flow); in mt7996_mac_add_twt_setup()
2497 curr_tsf = __mt7996_get_tsf(hw, msta->vif); in mt7996_mac_add_twt_setup()
2498 div_u64_rem(curr_tsf - flow->start_tsf, interval, &rem); in mt7996_mac_add_twt_setup()
2499 flow_tsf = curr_tsf + interval - rem; in mt7996_mac_add_twt_setup()
2500 twt_agrt->twt = cpu_to_le64(flow_tsf); in mt7996_mac_add_twt_setup()
2502 list_add_tail(&flow->list, &dev->twt_list); in mt7996_mac_add_twt_setup()
2504 flow->tsf = le64_to_cpu(twt_agrt->twt); in mt7996_mac_add_twt_setup()
2506 if (mt7996_mcu_twt_agrt_update(dev, msta->vif, flow, MCU_TWT_AGRT_ADD)) in mt7996_mac_add_twt_setup()
2510 dev->twt.table_mask |= BIT(table_id); in mt7996_mac_add_twt_setup()
2511 msta->twt.flowid_mask |= BIT(flowid); in mt7996_mac_add_twt_setup()
2512 dev->twt.n_agrt++; in mt7996_mac_add_twt_setup()
2515 mutex_unlock(&dev->mt76.mutex); in mt7996_mac_add_twt_setup()
2517 le16p_replace_bits(&twt_agrt->req_type, setup_cmd, in mt7996_mac_add_twt_setup()
2519 twt->control = (twt->control & IEEE80211_TWT_CONTROL_WAKE_DUR_UNIT) | in mt7996_mac_add_twt_setup()
2520 (twt->control & IEEE80211_TWT_CONTROL_RX_DISABLED); in mt7996_mac_add_twt_setup()
2527 struct mt7996_twt_flow *flow; in mt7996_mac_twt_teardown_flow() local
2529 lockdep_assert_held(&dev->mt76.mutex); in mt7996_mac_twt_teardown_flow()
2531 if (flowid >= ARRAY_SIZE(msta->twt.flow)) in mt7996_mac_twt_teardown_flow()
2534 if (!(msta->twt.flowid_mask & BIT(flowid))) in mt7996_mac_twt_teardown_flow()
2537 flow = &msta->twt.flow[flowid]; in mt7996_mac_twt_teardown_flow()
2538 if (mt7996_mcu_twt_agrt_update(dev, msta->vif, flow, in mt7996_mac_twt_teardown_flow()
2542 list_del_init(&flow->list); in mt7996_mac_twt_teardown_flow()
2543 msta->twt.flowid_mask &= ~BIT(flowid); in mt7996_mac_twt_teardown_flow()
2544 dev->twt.table_mask &= ~BIT(flow->table_id); in mt7996_mac_twt_teardown_flow()
2545 dev->twt.n_agrt--; in mt7996_mac_twt_teardown_flow()