Lines Matching +full:in +full:- +full:band +full:- +full:status
1 // SPDX-License-Identifier: ISC
12 #define to_rssi(field, rcpi) ((FIELD_GET(field, rcpi) - 220) / 2)
15 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
29 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
40 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
59 if (idx >= ARRAY_SIZE(dev->mt76.wcid)) in mt7915_rx_get_wcid()
62 wcid = rcu_dereference(dev->mt76.wcid[idx]); in mt7915_rx_get_wcid()
66 if (!wcid->sta) in mt7915_rx_get_wcid()
70 if (!sta->vif) in mt7915_rx_get_wcid()
73 return &sta->vif->sta.wcid; in mt7915_rx_get_wcid()
108 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_poll()
109 list_splice_init(&dev->mt76.sta_poll_list, &sta_poll_list); in mt7915_mac_sta_poll()
110 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_poll()
121 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_poll()
123 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_poll()
128 list_del_init(&msta->wcid.poll_list); in mt7915_mac_sta_poll()
129 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_poll()
131 idx = msta->wcid.idx; in mt7915_mac_sta_poll()
137 u32 tx_last = msta->airtime_ac[i]; in mt7915_mac_sta_poll()
138 u32 rx_last = msta->airtime_ac[i + 4]; in mt7915_mac_sta_poll()
140 msta->airtime_ac[i] = mt76_rr(dev, addr); in mt7915_mac_sta_poll()
141 msta->airtime_ac[i + 4] = mt76_rr(dev, addr + 4); in mt7915_mac_sta_poll()
143 tx_time[i] = msta->airtime_ac[i] - tx_last; in mt7915_mac_sta_poll()
144 rx_time[i] = msta->airtime_ac[i + 4] - rx_last; in mt7915_mac_sta_poll()
155 memset(msta->airtime_ac, 0, sizeof(msta->airtime_ac)); in mt7915_mac_sta_poll()
158 if (!msta->wcid.sta) in mt7915_mac_sta_poll()
178 * For accurate tx status reporting and AQL improvement, in mt7915_mac_sta_poll()
180 * from per-sta counters directly. in mt7915_mac_sta_poll()
182 rate = &msta->wcid.rate; in mt7915_mac_sta_poll()
186 switch (rate->bw) { in mt7915_mac_sta_poll()
201 if (rate->flags & RATE_INFO_FLAGS_HE_MCS) { in mt7915_mac_sta_poll()
204 rate->he_gi = (val & (0x3 << offs)) >> offs; in mt7915_mac_sta_poll()
205 } else if (rate->flags & in mt7915_mac_sta_poll()
208 rate->flags |= RATE_INFO_FLAGS_SHORT_GI; in mt7915_mac_sta_poll()
210 rate->flags &= ~RATE_INFO_FLAGS_SHORT_GI; in mt7915_mac_sta_poll()
222 msta->ack_signal = in mt7915_mac_sta_poll()
223 mt76_rx_signal(msta->vif->phy->mt76->antenna_mask, rssi); in mt7915_mac_sta_poll()
225 ewma_avg_signal_add(&msta->avg_ack_signal, -msta->ack_signal); in mt7915_mac_sta_poll()
234 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_mac_enable_rtscts()
237 addr = mt7915_mac_wtbl_lmac_addr(dev, mvif->sta.wcid.idx, 5); in mt7915_mac_enable_rtscts()
252 if (!msta || !msta->vif) in mt7915_wed_check_ppe()
261 vif = container_of((void *)msta->vif, struct ieee80211_vif, in mt7915_wed_check_ppe()
264 skb->dev = wdev->netdev; in mt7915_wed_check_ppe()
266 mtk_wed_device_ppe_check(&dev->mt76.mmio.wed, skb, in mt7915_wed_check_ppe()
275 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt7915_mac_fill_rx() local
276 struct mt76_phy *mphy = &dev->mt76.phy; in mt7915_mac_fill_rx()
277 struct mt7915_phy *phy = &dev->phy; in mt7915_mac_fill_rx()
279 __le32 *rxd = (__le32 *)skb->data; in mt7915_mac_fill_rx()
291 u32 csum_status = *(u32 *)skb->cb; in mt7915_mac_fill_rx()
298 memset(status, 0, sizeof(*status)); in mt7915_mac_fill_rx()
300 if ((rxd1 & MT_RXD1_NORMAL_BAND_IDX) && !phy->mt76->band_idx) { in mt7915_mac_fill_rx()
301 mphy = dev->mt76.phys[MT_BAND1]; in mt7915_mac_fill_rx()
303 return -EINVAL; in mt7915_mac_fill_rx()
305 phy = mphy->priv; in mt7915_mac_fill_rx()
306 status->phy_idx = 1; in mt7915_mac_fill_rx()
309 if (!test_bit(MT76_STATE_RUNNING, &mphy->state)) in mt7915_mac_fill_rx()
310 return -EINVAL; in mt7915_mac_fill_rx()
313 return -EINVAL; in mt7915_mac_fill_rx()
317 return -EINVAL; in mt7915_mac_fill_rx()
321 status->flag |= RX_FLAG_ONLY_MONITOR; in mt7915_mac_fill_rx()
325 status->wcid = mt7915_rx_get_wcid(dev, idx, unicast); in mt7915_mac_fill_rx()
327 if (status->wcid) { in mt7915_mac_fill_rx()
328 msta = container_of(status->wcid, struct mt7915_sta, wcid); in mt7915_mac_fill_rx()
329 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_fill_rx()
330 if (list_empty(&msta->wcid.poll_list)) in mt7915_mac_fill_rx()
331 list_add_tail(&msta->wcid.poll_list, in mt7915_mac_fill_rx()
332 &dev->mt76.sta_poll_list); in mt7915_mac_fill_rx()
333 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_fill_rx()
336 status->freq = mphy->chandef.chan->center_freq; in mt7915_mac_fill_rx()
337 status->band = mphy->chandef.chan->band; in mt7915_mac_fill_rx()
338 if (status->band == NL80211_BAND_5GHZ) in mt7915_mac_fill_rx()
339 sband = &mphy->sband_5g.sband; in mt7915_mac_fill_rx()
340 else if (status->band == NL80211_BAND_6GHZ) in mt7915_mac_fill_rx()
341 sband = &mphy->sband_6g.sband; in mt7915_mac_fill_rx()
343 sband = &mphy->sband_2g.sband; in mt7915_mac_fill_rx()
345 if (!sband->channels) in mt7915_mac_fill_rx()
346 return -EINVAL; in mt7915_mac_fill_rx()
350 skb->ip_summed = CHECKSUM_UNNECESSARY; in mt7915_mac_fill_rx()
353 status->flag |= RX_FLAG_FAILED_FCS_CRC; in mt7915_mac_fill_rx()
356 status->flag |= RX_FLAG_MMIC_ERROR; in mt7915_mac_fill_rx()
360 status->flag |= RX_FLAG_DECRYPTED; in mt7915_mac_fill_rx()
361 status->flag |= RX_FLAG_IV_STRIPPED; in mt7915_mac_fill_rx()
362 status->flag |= RX_FLAG_MMIC_STRIPPED | RX_FLAG_MIC_STRIPPED; in mt7915_mac_fill_rx()
368 return -EINVAL; in mt7915_mac_fill_rx()
380 if ((u8 *)rxd - skb->data >= skb->len) in mt7915_mac_fill_rx()
381 return -EINVAL; in mt7915_mac_fill_rx()
387 if (status->flag & RX_FLAG_DECRYPTED) { in mt7915_mac_fill_rx()
399 status->iv[0] = data[5]; in mt7915_mac_fill_rx()
400 status->iv[1] = data[4]; in mt7915_mac_fill_rx()
401 status->iv[2] = data[3]; in mt7915_mac_fill_rx()
402 status->iv[3] = data[2]; in mt7915_mac_fill_rx()
403 status->iv[4] = data[1]; in mt7915_mac_fill_rx()
404 status->iv[5] = data[0]; in mt7915_mac_fill_rx()
411 if ((u8 *)rxd - skb->data >= skb->len) in mt7915_mac_fill_rx()
412 return -EINVAL; in mt7915_mac_fill_rx()
416 status->timestamp = le32_to_cpu(rxd[0]); in mt7915_mac_fill_rx()
417 status->flag |= RX_FLAG_MACTIME_START; in mt7915_mac_fill_rx()
420 status->flag |= RX_FLAG_AMPDU_DETAILS; in mt7915_mac_fill_rx()
422 /* all subframes of an A-MPDU have the same timestamp */ in mt7915_mac_fill_rx()
423 if (phy->rx_ampdu_ts != status->timestamp) { in mt7915_mac_fill_rx()
424 if (!++phy->ampdu_ref) in mt7915_mac_fill_rx()
425 phy->ampdu_ref++; in mt7915_mac_fill_rx()
427 phy->rx_ampdu_ts = status->timestamp; in mt7915_mac_fill_rx()
429 status->ampdu_ref = phy->ampdu_ref; in mt7915_mac_fill_rx()
433 if ((u8 *)rxd - skb->data >= skb->len) in mt7915_mac_fill_rx()
434 return -EINVAL; in mt7915_mac_fill_rx()
437 /* RXD Group 3 - P-RXV */ in mt7915_mac_fill_rx()
444 if ((u8 *)rxd - skb->data >= skb->len) in mt7915_mac_fill_rx()
445 return -EINVAL; in mt7915_mac_fill_rx()
451 status->enc_flags |= RX_ENC_FLAG_LDPC; in mt7915_mac_fill_rx()
453 status->chains = mphy->antenna_mask; in mt7915_mac_fill_rx()
454 status->chain_signal[0] = to_rssi(MT_PRXV_RCPI0, v1); in mt7915_mac_fill_rx()
455 status->chain_signal[1] = to_rssi(MT_PRXV_RCPI1, v1); in mt7915_mac_fill_rx()
456 status->chain_signal[2] = to_rssi(MT_PRXV_RCPI2, v1); in mt7915_mac_fill_rx()
457 status->chain_signal[3] = to_rssi(MT_PRXV_RCPI3, v1); in mt7915_mac_fill_rx()
459 /* RXD Group 5 - C-RXV */ in mt7915_mac_fill_rx()
462 if ((u8 *)rxd - skb->data >= skb->len) in mt7915_mac_fill_rx()
463 return -EINVAL; in mt7915_mac_fill_rx()
466 if (!is_mt7915(&dev->mt76) || (rxd1 & MT_RXD1_NORMAL_GROUP_5)) { in mt7915_mac_fill_rx()
467 ret = mt76_connac2_mac_fill_rx_rate(&dev->mt76, status, in mt7915_mac_fill_rx()
475 status->amsdu = !!amsdu_info; in mt7915_mac_fill_rx()
476 if (status->amsdu) { in mt7915_mac_fill_rx()
477 status->first_amsdu = amsdu_info == MT_RXD4_FIRST_AMSDU_FRAME; in mt7915_mac_fill_rx()
478 status->last_amsdu = amsdu_info == MT_RXD4_LAST_AMSDU_FRAME; in mt7915_mac_fill_rx()
481 hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad; in mt7915_mac_fill_rx()
486 if (!msta || !msta->vif) in mt7915_mac_fill_rx()
487 return -EINVAL; in mt7915_mac_fill_rx()
489 vif = container_of((void *)msta->vif, struct ieee80211_vif, in mt7915_mac_fill_rx()
500 if (!hdr_trans && status->amsdu) { in mt7915_mac_fill_rx()
505 * the hardware will insert an extra 2-byte field in mt7915_mac_fill_rx()
507 * type field. This happens either when the LLC-SNAP in mt7915_mac_fill_rx()
512 if (get_unaligned_be16(skb->data + pad_start) == ETH_P_8021Q) in mt7915_mac_fill_rx()
519 memmove(skb->data + 2, skb->data, pad_start); in mt7915_mac_fill_rx()
534 fc = hdr->frame_control; in mt7915_mac_fill_rx()
536 seq_ctrl = le16_to_cpu(hdr->seq_ctrl); in mt7915_mac_fill_rx()
540 status->flag |= RX_FLAG_8023; in mt7915_mac_fill_rx()
541 mt7915_wed_check_ppe(dev, &dev->mt76.q_rx[q], msta, skb, in mt7915_mac_fill_rx()
545 if (rxv && mode >= MT_PHY_TYPE_HE_SU && !(status->flag & RX_FLAG_8023)) in mt7915_mac_fill_rx()
546 mt76_connac2_mac_decode_he_radiotap(&dev->mt76, skb, rxv, mode); in mt7915_mac_fill_rx()
548 if (!status->wcid || !ieee80211_is_data_qos(fc)) in mt7915_mac_fill_rx()
551 status->aggr = unicast && in mt7915_mac_fill_rx()
553 status->qos_ctl = qos_ctl; in mt7915_mac_fill_rx()
554 status->seqno = IEEE80211_SEQ_TO_SN(seq_ctrl); in mt7915_mac_fill_rx()
563 struct mt7915_phy *phy = &dev->phy; in mt7915_mac_fill_rx_vector()
564 __le32 *rxd = (__le32 *)skb->data; in mt7915_mac_fill_rx_vector()
574 if (band_idx && !phy->mt76->band_idx) { in mt7915_mac_fill_rx_vector()
588 phy->test.last_rcpi[i] = rcpi & 0xff; in mt7915_mac_fill_rx_vector()
589 phy->test.last_ib_rssi[i] = ib_rssi & 0xff; in mt7915_mac_fill_rx_vector()
590 phy->test.last_wb_rssi[i] = wb_rssi & 0xff; in mt7915_mac_fill_rx_vector()
599 snr = FIELD_GET(MT_CRXV_SNR, v20) - 16; in mt7915_mac_fill_rx_vector()
601 phy->test.last_freq_offset = foe; in mt7915_mac_fill_rx_vector()
602 phy->test.last_snr = snr; in mt7915_mac_fill_rx_vector()
613 struct mt76_testmode_data *td = &phy->mt76->test; in mt7915_mac_write_txwi_tm()
615 u8 bw, mode, nss = td->tx_rate_nss; in mt7915_mac_write_txwi_tm()
616 u8 rate_idx = td->tx_rate_idx; in mt7915_mac_write_txwi_tm()
620 int band; in mt7915_mac_write_txwi_tm() local
622 if (skb != phy->mt76->test.tx_skb) in mt7915_mac_write_txwi_tm()
625 switch (td->tx_rate_mode) { in mt7915_mac_write_txwi_tm()
649 band = phy->mt76->chandef.chan->band; in mt7915_mac_write_txwi_tm()
650 if (band == NL80211_BAND_2GHZ && !cck) in mt7915_mac_write_txwi_tm()
653 r = &phy->mt76->hw->wiphy->bands[band]->bitrates[rate_idx]; in mt7915_mac_write_txwi_tm()
654 val = cck ? r->hw_value_short : r->hw_value; in mt7915_mac_write_txwi_tm()
664 switch (phy->mt76->chandef.width) { in mt7915_mac_write_txwi_tm()
680 if (td->tx_rate_stbc && nss == 1) { in mt7915_mac_write_txwi_tm()
687 FIELD_PREP(MT_TX_RATE_NSS, nss - 1); in mt7915_mac_write_txwi_tm()
692 if (td->tx_rate_mode < MT76_TM_TX_MODE_HT) in mt7915_mac_write_txwi_tm()
698 FIELD_PREP(MT_TXD6_SGI, td->tx_rate_sgi); in mt7915_mac_write_txwi_tm()
701 * - 1x, 2x, 4x LTF + 0.8us GI in mt7915_mac_write_txwi_tm()
702 * - 2x LTF + 1.6us GI, 4x LTF + 3.2us GI in mt7915_mac_write_txwi_tm()
704 * - 2x, 4x LTF + 0.8us GI in mt7915_mac_write_txwi_tm()
705 * - 2x LTF + 1.6us GI, 4x LTF + 3.2us GI in mt7915_mac_write_txwi_tm()
707 * - 1x, 2x LTF + 1.6us GI in mt7915_mac_write_txwi_tm()
708 * - 4x LTF + 3.2us GI in mt7915_mac_write_txwi_tm()
711 val |= FIELD_PREP(MT_TXD6_HELTF, td->tx_ltf); in mt7915_mac_write_txwi_tm()
713 if (td->tx_rate_ldpc || (bw > 0 && mode >= MT_PHY_TYPE_HE_SU)) in mt7915_mac_write_txwi_tm()
719 phy->test.spe_idx)); in mt7915_mac_write_txwi_tm()
729 u8 phy_idx = (info->hw_queue & MT_TX_HW_QUEUE_PHY) >> 2; in mt7915_mac_write_txwi()
730 struct mt76_phy *mphy = &dev->phy; in mt7915_mac_write_txwi()
732 if (phy_idx && dev->phys[MT_BAND1]) in mt7915_mac_write_txwi()
733 mphy = dev->phys[MT_BAND1]; in mt7915_mac_write_txwi()
738 mt7915_mac_write_txwi_tm(mphy->priv, txwi, skb); in mt7915_mac_write_txwi()
746 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx_info->skb->data; in mt7915_tx_prepare_skb()
748 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_info->skb); in mt7915_tx_prepare_skb()
749 struct ieee80211_key_conf *key = info->control.hw_key; in mt7915_tx_prepare_skb()
750 struct ieee80211_vif *vif = info->control.vif; in mt7915_tx_prepare_skb()
753 int id, i, nbuf = tx_info->nbuf - 1; in mt7915_tx_prepare_skb()
757 if (unlikely(tx_info->skb->len <= ETH_HLEN)) in mt7915_tx_prepare_skb()
758 return -EINVAL; in mt7915_tx_prepare_skb()
761 wcid = &dev->mt76.global_wcid; in mt7915_tx_prepare_skb()
766 msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_tx_prepare_skb()
768 if (time_after(jiffies, msta->jiffies + HZ / 4)) { in mt7915_tx_prepare_skb()
769 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; in mt7915_tx_prepare_skb()
770 msta->jiffies = jiffies; in mt7915_tx_prepare_skb()
774 t = (struct mt76_txwi_cache *)(txwi + mdev->drv->txwi_size); in mt7915_tx_prepare_skb()
775 t->skb = tx_info->skb; in mt7915_tx_prepare_skb()
781 pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb); in mt7915_tx_prepare_skb()
782 mt7915_mac_write_txwi(mdev, txwi_ptr, tx_info->skb, wcid, pid, key, in mt7915_tx_prepare_skb()
787 txp->buf[i] = cpu_to_le32(tx_info->buf[i + 1].addr); in mt7915_tx_prepare_skb()
788 txp->len[i] = cpu_to_le16(tx_info->buf[i + 1].len); in mt7915_tx_prepare_skb()
790 txp->nbuf = nbuf; in mt7915_tx_prepare_skb()
792 txp->flags = cpu_to_le16(MT_CT_INFO_APPLY_TXD | MT_CT_INFO_FROM_HOST); in mt7915_tx_prepare_skb()
795 txp->flags |= cpu_to_le16(MT_CT_INFO_NONE_CIPHER_FRAME); in mt7915_tx_prepare_skb()
797 if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) && in mt7915_tx_prepare_skb()
798 ieee80211_is_mgmt(hdr->frame_control)) in mt7915_tx_prepare_skb()
799 txp->flags |= cpu_to_le16(MT_CT_INFO_MGMT_FRAME); in mt7915_tx_prepare_skb()
802 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; in mt7915_tx_prepare_skb()
804 txp->bss_idx = mvif->mt76.idx; in mt7915_tx_prepare_skb()
807 txp->token = cpu_to_le16(id); in mt7915_tx_prepare_skb()
808 if (test_bit(MT_WCID_FLAG_4ADDR, &wcid->flags)) in mt7915_tx_prepare_skb()
809 txp->rept_wds_wcid = cpu_to_le16(wcid->idx); in mt7915_tx_prepare_skb()
811 txp->rept_wds_wcid = cpu_to_le16(0x3ff); in mt7915_tx_prepare_skb()
812 tx_info->skb = NULL; in mt7915_tx_prepare_skb()
815 tx_info->buf[1].len = MT_CT_PARSE_LEN; in mt7915_tx_prepare_skb()
816 tx_info->buf[1].skip_unmap = true; in mt7915_tx_prepare_skb()
817 tx_info->nbuf = MT_CT_DMA_BUF_NUM; in mt7915_tx_prepare_skb()
838 txp->token = cpu_to_le16(token_id); in mt7915_wed_init_buf()
839 txp->nbuf = 1; in mt7915_wed_init_buf()
840 txp->buf[0] = cpu_to_le32(phys + MT_TXD_SIZE + sizeof(*txp)); in mt7915_wed_init_buf()
848 struct mt76_dev *mdev = &dev->mt76; in mt7915_mac_tx_free_prepare()
849 struct mt76_phy *mphy_ext = mdev->phys[MT_BAND1]; in mt7915_mac_tx_free_prepare()
852 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_PSD], false); in mt7915_mac_tx_free_prepare()
853 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_BE], false); in mt7915_mac_tx_free_prepare()
855 mt76_queue_tx_cleanup(dev, mphy_ext->q_tx[MT_TXQ_PSD], false); in mt7915_mac_tx_free_prepare()
856 mt76_queue_tx_cleanup(dev, mphy_ext->q_tx[MT_TXQ_BE], false); in mt7915_mac_tx_free_prepare()
869 mt76_set_tx_blocked(&dev->mt76, false); in mt7915_mac_tx_free_done()
871 mt76_worker_schedule(&dev->mt76.tx_worker); in mt7915_mac_tx_free_done()
884 struct mt76_dev *mdev = &dev->mt76; in mt7915_mac_tx_free()
892 u32 txd = le32_to_cpu(free->txd); in mt7915_mac_tx_free()
897 total = le16_get_bits(free->ctrl, MT_TX_FREE_MSDU_CNT); in mt7915_mac_tx_free()
917 wcid = rcu_dereference(dev->mt76.wcid[idx]); in mt7915_mac_tx_free()
923 spin_lock_bh(&mdev->sta_poll_lock); in mt7915_mac_tx_free()
924 if (list_empty(&msta->wcid.poll_list)) in mt7915_mac_tx_free()
925 list_add_tail(&msta->wcid.poll_list, in mt7915_mac_tx_free()
926 &mdev->sta_poll_list); in mt7915_mac_tx_free()
927 spin_unlock_bh(&mdev->sta_poll_lock); in mt7915_mac_tx_free()
931 if (!mtk_wed_device_active(&mdev->mmio.wed) && wcid) { in mt7915_mac_tx_free()
936 FIELD_GET(MT_TX_FREE_COUNT_V3, info) - 1; in mt7915_mac_tx_free()
941 FIELD_GET(MT_TX_FREE_COUNT, info) - 1; in mt7915_mac_tx_free()
945 wcid->stats.tx_retries += tx_retries; in mt7915_mac_tx_free()
946 wcid->stats.tx_failed += tx_failed; in mt7915_mac_tx_free()
977 struct mt76_dev *mdev = &dev->mt76; in mt7915_mac_tx_free_v0()
985 count = FIELD_GET(MT_TX_FREE_MSDU_CNT_V0, le16_to_cpu(free->ctrl)); in mt7915_mac_tx_free_v0()
1022 wcid = rcu_dereference(dev->mt76.wcid[wcidx]); in mt7915_mac_add_txs()
1029 mt76_connac2_mac_fill_txs(&dev->mt76, wcid, txs_data); in mt7915_mac_add_txs()
1031 mt76_connac2_mac_add_txs_skb(&dev->mt76, wcid, pid, txs_data); in mt7915_mac_add_txs()
1033 if (!wcid->sta) in mt7915_mac_add_txs()
1036 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_add_txs()
1037 if (list_empty(&msta->wcid.poll_list)) in mt7915_mac_add_txs()
1038 list_add_tail(&msta->wcid.poll_list, &dev->mt76.sta_poll_list); in mt7915_mac_add_txs()
1039 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_add_txs()
1077 __le32 *rxd = (__le32 *)skb->data; in mt7915_queue_rx_skb()
1078 __le32 *end = (__le32 *)&skb->data[skb->len]; in mt7915_queue_rx_skb()
1085 mt7915_mac_tx_free(dev, skb->data, skb->len); in mt7915_queue_rx_skb()
1089 mt7915_mac_tx_free_v0(dev, skb->data, skb->len); in mt7915_queue_rx_skb()
1104 mt7915_debugfs_rx_fw_monitor(dev, skb->data, skb->len); in mt7915_queue_rx_skb()
1109 mt76_rx(&dev->mt76, q, skb); in mt7915_queue_rx_skb()
1121 struct mt7915_dev *dev = phy->dev; in mt7915_mac_cca_stats_reset()
1122 u32 reg = MT_WF_PHY_RX_CTRL1(phy->mt76->band_idx); in mt7915_mac_cca_stats_reset()
1130 struct mt7915_dev *dev = phy->dev; in mt7915_mac_reset_counters()
1134 mt76_rr(dev, MT_TX_AGG_CNT(phy->mt76->band_idx, i)); in mt7915_mac_reset_counters()
1135 mt76_rr(dev, MT_TX_AGG_CNT2(phy->mt76->band_idx, i)); in mt7915_mac_reset_counters()
1138 phy->mt76->survey_time = ktime_get_boottime(); in mt7915_mac_reset_counters()
1139 memset(phy->mt76->aggr_stats, 0, sizeof(phy->mt76->aggr_stats)); in mt7915_mac_reset_counters()
1142 mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0(phy->mt76->band_idx), in mt7915_mac_reset_counters()
1150 s16 coverage_class = phy->coverage_class; in mt7915_mac_set_timing()
1151 struct mt7915_dev *dev = phy->dev; in mt7915_mac_set_timing()
1158 u8 band = phy->mt76->band_idx; in mt7915_mac_set_timing() local
1160 bool a_band = !(phy->mt76->chandef.chan->band == NL80211_BAND_2GHZ); in mt7915_mac_set_timing()
1162 if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state)) in mt7915_mac_set_timing()
1166 coverage_class = max_t(s16, dev->phy.coverage_class, in mt7915_mac_set_timing()
1167 ext_phy->coverage_class); in mt7915_mac_set_timing()
1169 mt76_set(dev, MT_ARB_SCR(band), in mt7915_mac_set_timing()
1177 if (!is_mt7915(&dev->mt76)) { in mt7915_mac_set_timing()
1179 mt76_wr(dev, MT_TMAC_ICR1(band), in mt7915_mac_set_timing()
1189 mt76_wr(dev, MT_TMAC_CDTR(band), cck + reg_offset); in mt7915_mac_set_timing()
1190 mt76_wr(dev, MT_TMAC_ODTR(band), ofdm + reg_offset); in mt7915_mac_set_timing()
1191 mt76_wr(dev, MT_TMAC_ICR0(band), in mt7915_mac_set_timing()
1195 FIELD_PREP(MT_IFS_SLOT, phy->slottime)); in mt7915_mac_set_timing()
1197 if (phy->slottime < 20 || a_band) in mt7915_mac_set_timing()
1202 mt76_rmw_field(dev, MT_AGG_ACR0(band), MT_AGG_ACR_CFEND_RATE, val); in mt7915_mac_set_timing()
1203 mt76_clear(dev, MT_ARB_SCR(band), in mt7915_mac_set_timing()
1207 void mt7915_mac_enable_nf(struct mt7915_dev *dev, bool band) in mt7915_mac_enable_nf() argument
1211 reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_RXTD12(band) : in mt7915_mac_enable_nf()
1212 MT_WF_PHY_RXTD12_MT7916(band); in mt7915_mac_enable_nf()
1217 reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_RX_CTRL1(band) : in mt7915_mac_enable_nf()
1218 MT_WF_PHY_RX_CTRL1_MT7916(band); in mt7915_mac_enable_nf()
1226 struct mt7915_dev *dev = phy->dev; in mt7915_phy_get_nf()
1230 for (nss = 0; nss < hweight8(phy->mt76->chainmask); nss++) { in mt7915_phy_get_nf()
1231 u32 reg = is_mt7915(&dev->mt76) ? in mt7915_phy_get_nf()
1232 MT_WF_IRPI_NSS(0, nss + (idx << dev->dbdc_support)) : in mt7915_phy_get_nf()
1250 struct mt7915_phy *phy = mphy->priv; in mt7915_update_channel()
1251 struct mt76_channel_state *state = mphy->chan_state; in mt7915_update_channel()
1256 nf = mt7915_phy_get_nf(phy, phy->mt76->band_idx); in mt7915_update_channel()
1257 if (!phy->noise) in mt7915_update_channel()
1258 phy->noise = nf << 4; in mt7915_update_channel()
1260 phy->noise += nf - (phy->noise >> 4); in mt7915_update_channel()
1262 state->noise = -(phy->noise >> 4); in mt7915_update_channel()
1270 ret = wait_event_timeout(dev->reset_wait, in mt7915_wait_reset_state()
1271 (READ_ONCE(dev->recovery.state) & state), in mt7915_wait_reset_state()
1283 switch (vif->type) { in mt7915_update_vif_beacon()
1287 mt7915_mcu_add_beacon(hw, vif, vif->bss_conf.enable_beacon, in mt7915_update_vif_beacon()
1298 struct mt76_phy *mphy_ext = dev->mt76.phys[MT_BAND1]; in mt7915_update_beacons()
1300 ieee80211_iterate_active_interfaces(dev->mt76.hw, in mt7915_update_beacons()
1302 mt7915_update_vif_beacon, dev->mt76.hw); in mt7915_update_beacons()
1307 ieee80211_iterate_active_interfaces(mphy_ext->hw, in mt7915_update_beacons()
1309 mt7915_update_vif_beacon, mphy_ext->hw); in mt7915_update_beacons()
1317 struct mt76_dev *mdev = &dev->mt76; in mt7915_mac_restart()
1320 ext_phy = dev->mt76.phys[MT_BAND1]; in mt7915_mac_restart()
1321 phy2 = ext_phy ? ext_phy->priv : NULL; in mt7915_mac_restart()
1323 if (dev->hif2) { in mt7915_mac_restart()
1328 if (dev_is_pci(mdev->dev)) { in mt7915_mac_restart()
1330 if (dev->hif2) { in mt7915_mac_restart()
1338 set_bit(MT76_RESET, &dev->mphy.state); in mt7915_mac_restart()
1339 set_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7915_mac_restart()
1340 wake_up(&dev->mt76.mcu.wait); in mt7915_mac_restart()
1342 set_bit(MT76_RESET, &ext_phy->state); in mt7915_mac_restart()
1343 set_bit(MT76_MCU_RESET, &ext_phy->state); in mt7915_mac_restart()
1347 mt76_txq_schedule_all(&dev->mphy); in mt7915_mac_restart()
1352 mt76_worker_disable(&dev->mt76.tx_worker); in mt7915_mac_restart()
1354 if (mdev->q_rx[i].ndesc) in mt7915_mac_restart()
1355 napi_disable(&dev->mt76.napi[i]); in mt7915_mac_restart()
1357 napi_disable(&dev->mt76.tx_napi); in mt7915_mac_restart()
1360 mt76_connac2_tx_token_put(&dev->mt76); in mt7915_mac_restart()
1361 idr_init(&dev->mt76.token); in mt7915_mac_restart()
1367 if (mdev->q_rx[i].ndesc) { in mt7915_mac_restart()
1368 napi_enable(&dev->mt76.napi[i]); in mt7915_mac_restart()
1369 napi_schedule(&dev->mt76.napi[i]); in mt7915_mac_restart()
1373 clear_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7915_mac_restart()
1374 clear_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); in mt7915_mac_restart()
1376 mt76_wr(dev, MT_INT_MASK_CSR, dev->mt76.mmio.irqmask); in mt7915_mac_restart()
1379 if (dev->hif2) { in mt7915_mac_restart()
1380 mt76_wr(dev, MT_INT1_MASK_CSR, dev->mt76.mmio.irqmask); in mt7915_mac_restart()
1383 if (dev_is_pci(mdev->dev)) { in mt7915_mac_restart()
1385 if (dev->hif2) { in mt7915_mac_restart()
1404 mt7915_init_txpower(&dev->phy); in mt7915_mac_restart()
1408 if (test_bit(MT76_STATE_RUNNING, &dev->mphy.state)) { in mt7915_mac_restart()
1409 ret = mt7915_run(dev->mphy.hw); in mt7915_mac_restart()
1414 if (ext_phy && test_bit(MT76_STATE_RUNNING, &ext_phy->state)) { in mt7915_mac_restart()
1415 ret = mt7915_run(ext_phy->hw); in mt7915_mac_restart()
1422 clear_bit(MT76_RESET, &dev->mphy.state); in mt7915_mac_restart()
1424 clear_bit(MT76_RESET, &phy2->mt76->state); in mt7915_mac_restart()
1427 napi_enable(&dev->mt76.tx_napi); in mt7915_mac_restart()
1428 napi_schedule(&dev->mt76.tx_napi); in mt7915_mac_restart()
1431 mt76_worker_enable(&dev->mt76.tx_worker); in mt7915_mac_restart()
1442 ext_phy = dev->mt76.phys[MT_BAND1]; in mt7915_mac_full_reset()
1444 dev->recovery.hw_full_reset = true; in mt7915_mac_full_reset()
1446 wake_up(&dev->mt76.mcu.wait); in mt7915_mac_full_reset()
1449 ieee80211_stop_queues(ext_phy->hw); in mt7915_mac_full_reset()
1451 cancel_delayed_work_sync(&dev->mphy.mac_work); in mt7915_mac_full_reset()
1453 cancel_delayed_work_sync(&ext_phy->mac_work); in mt7915_mac_full_reset()
1455 mutex_lock(&dev->mt76.mutex); in mt7915_mac_full_reset()
1460 mutex_unlock(&dev->mt76.mutex); in mt7915_mac_full_reset()
1463 dev_err(dev->mt76.dev, "chip full reset failed\n"); in mt7915_mac_full_reset()
1467 ieee80211_restart_hw(ext_phy->hw); in mt7915_mac_full_reset()
1471 ieee80211_wake_queues(ext_phy->hw); in mt7915_mac_full_reset()
1473 dev->recovery.hw_full_reset = false; in mt7915_mac_full_reset()
1474 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mphy.mac_work, in mt7915_mac_full_reset()
1477 ieee80211_queue_delayed_work(ext_phy->hw, in mt7915_mac_full_reset()
1478 &ext_phy->mac_work, in mt7915_mac_full_reset()
1491 ext_phy = dev->mt76.phys[MT_BAND1]; in mt7915_mac_reset_work()
1492 phy2 = ext_phy ? ext_phy->priv : NULL; in mt7915_mac_reset_work()
1495 if (dev->recovery.restart) { in mt7915_mac_reset_work()
1500 if (READ_ONCE(dev->recovery.state) & MT_MCU_CMD_WA_WDT) in mt7915_mac_reset_work()
1501 dev->recovery.wa_reset_count++; in mt7915_mac_reset_work()
1503 dev->recovery.wm_reset_count++; in mt7915_mac_reset_work()
1514 dev->recovery.state = MT_MCU_CMD_NORMAL_STATE; in mt7915_mac_reset_work()
1515 dev->recovery.restart = false; in mt7915_mac_reset_work()
1520 if (!(READ_ONCE(dev->recovery.state) & MT_MCU_CMD_STOP_DMA)) in mt7915_mac_reset_work()
1523 if (mtk_wed_device_active(&dev->mt76.mmio.wed)) { in mt7915_mac_reset_work()
1524 mtk_wed_device_stop(&dev->mt76.mmio.wed); in mt7915_mac_reset_work()
1525 if (!is_mt798x(&dev->mt76)) in mt7915_mac_reset_work()
1531 ieee80211_stop_queues(ext_phy->hw); in mt7915_mac_reset_work()
1533 set_bit(MT76_RESET, &dev->mphy.state); in mt7915_mac_reset_work()
1534 set_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7915_mac_reset_work()
1535 wake_up(&dev->mt76.mcu.wait); in mt7915_mac_reset_work()
1536 cancel_delayed_work_sync(&dev->mphy.mac_work); in mt7915_mac_reset_work()
1538 set_bit(MT76_RESET, &phy2->mt76->state); in mt7915_mac_reset_work()
1539 cancel_delayed_work_sync(&phy2->mt76->mac_work); in mt7915_mac_reset_work()
1541 mt76_worker_disable(&dev->mt76.tx_worker); in mt7915_mac_reset_work()
1542 mt76_for_each_q_rx(&dev->mt76, i) in mt7915_mac_reset_work()
1543 napi_disable(&dev->mt76.napi[i]); in mt7915_mac_reset_work()
1544 napi_disable(&dev->mt76.tx_napi); in mt7915_mac_reset_work()
1546 mutex_lock(&dev->mt76.mutex); in mt7915_mac_reset_work()
1553 mt76_connac2_tx_token_put(&dev->mt76); in mt7915_mac_reset_work()
1554 idr_init(&dev->mt76.token); in mt7915_mac_reset_work()
1566 clear_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7915_mac_reset_work()
1567 clear_bit(MT76_RESET, &dev->mphy.state); in mt7915_mac_reset_work()
1569 clear_bit(MT76_RESET, &phy2->mt76->state); in mt7915_mac_reset_work()
1572 mt76_for_each_q_rx(&dev->mt76, i) { in mt7915_mac_reset_work()
1573 napi_enable(&dev->mt76.napi[i]); in mt7915_mac_reset_work()
1574 napi_schedule(&dev->mt76.napi[i]); in mt7915_mac_reset_work()
1578 tasklet_schedule(&dev->mt76.irq_tasklet); in mt7915_mac_reset_work()
1580 mt76_worker_enable(&dev->mt76.tx_worker); in mt7915_mac_reset_work()
1583 napi_enable(&dev->mt76.tx_napi); in mt7915_mac_reset_work()
1584 napi_schedule(&dev->mt76.tx_napi); in mt7915_mac_reset_work()
1589 ieee80211_wake_queues(ext_phy->hw); in mt7915_mac_reset_work()
1591 mutex_unlock(&dev->mt76.mutex); in mt7915_mac_reset_work()
1595 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mphy.mac_work, in mt7915_mac_reset_work()
1598 ieee80211_queue_delayed_work(ext_phy->hw, in mt7915_mac_reset_work()
1599 &phy2->mt76->mac_work, in mt7915_mac_reset_work()
1617 mutex_lock(&dev->dump_mutex); in mt7915_mac_dump_work()
1621 mutex_unlock(&dev->dump_mutex); in mt7915_mac_dump_work()
1626 if (!mem_region || !crash_data->memdump_buf_len) { in mt7915_mac_dump_work()
1627 mutex_unlock(&dev->dump_mutex); in mt7915_mac_dump_work()
1631 buf = crash_data->memdump_buf; in mt7915_mac_dump_work()
1632 buf_len = crash_data->memdump_buf_len; in mt7915_mac_dump_work()
1637 if (mem_region->len > buf_len) { in mt7915_mac_dump_work()
1638 dev_warn(dev->mt76.dev, "%s len %lu is too large\n", in mt7915_mac_dump_work()
1639 mem_region->name, in mt7915_mac_dump_work()
1640 (unsigned long)mem_region->len); in mt7915_mac_dump_work()
1647 buf_len -= sizeof(*hdr); in mt7915_mac_dump_work()
1649 mt7915_memcpy_fromio(dev, buf, mem_region->start, in mt7915_mac_dump_work()
1650 mem_region->len); in mt7915_mac_dump_work()
1652 hdr->start = mem_region->start; in mt7915_mac_dump_work()
1653 hdr->len = mem_region->len; in mt7915_mac_dump_work()
1655 if (!mem_region->len) in mt7915_mac_dump_work()
1659 buf += mem_region->len; in mt7915_mac_dump_work()
1660 buf_len -= mem_region->len; in mt7915_mac_dump_work()
1665 mutex_unlock(&dev->dump_mutex); in mt7915_mac_dump_work()
1670 queue_work(dev->mt76.wq, &dev->reset_work); in mt7915_mac_dump_work()
1675 if (!dev->recovery.hw_init_done) in mt7915_reset()
1678 if (dev->recovery.hw_full_reset) in mt7915_reset()
1682 if (READ_ONCE(dev->recovery.state) & MT_MCU_CMD_WDT_MASK) { in mt7915_reset()
1683 dev->recovery.restart = true; in mt7915_reset()
1684 dev_info(dev->mt76.dev, in mt7915_reset()
1686 wiphy_name(dev->mt76.hw->wiphy)); in mt7915_reset()
1689 queue_work(dev->mt76.wq, &dev->dump_work); in mt7915_reset()
1693 queue_work(dev->mt76.wq, &dev->reset_work); in mt7915_reset()
1694 wake_up(&dev->reset_wait); in mt7915_reset()
1699 struct mt76_mib_stats *mib = &phy->mib; in mt7915_mac_update_stats()
1700 struct mt7915_dev *dev = phy->dev; in mt7915_mac_update_stats()
1702 u8 band = phy->mt76->band_idx; in mt7915_mac_update_stats() local
1705 cnt = mt76_rr(dev, MT_MIB_SDR3(band)); in mt7915_mac_update_stats()
1706 mib->fcs_err_cnt += is_mt7915(&dev->mt76) ? in mt7915_mac_update_stats()
1710 cnt = mt76_rr(dev, MT_MIB_SDR4(band)); in mt7915_mac_update_stats()
1711 mib->rx_fifo_full_cnt += FIELD_GET(MT_MIB_SDR4_RX_FIFO_FULL_MASK, cnt); in mt7915_mac_update_stats()
1713 cnt = mt76_rr(dev, MT_MIB_SDR5(band)); in mt7915_mac_update_stats()
1714 mib->rx_mpdu_cnt += cnt; in mt7915_mac_update_stats()
1716 cnt = mt76_rr(dev, MT_MIB_SDR6(band)); in mt7915_mac_update_stats()
1717 mib->channel_idle_cnt += FIELD_GET(MT_MIB_SDR6_CHANNEL_IDL_CNT_MASK, cnt); in mt7915_mac_update_stats()
1719 cnt = mt76_rr(dev, MT_MIB_SDR7(band)); in mt7915_mac_update_stats()
1720 mib->rx_vector_mismatch_cnt += in mt7915_mac_update_stats()
1723 cnt = mt76_rr(dev, MT_MIB_SDR8(band)); in mt7915_mac_update_stats()
1724 mib->rx_delimiter_fail_cnt += in mt7915_mac_update_stats()
1727 cnt = mt76_rr(dev, MT_MIB_SDR10(band)); in mt7915_mac_update_stats()
1728 mib->rx_mrdy_cnt += is_mt7915(&dev->mt76) ? in mt7915_mac_update_stats()
1732 cnt = mt76_rr(dev, MT_MIB_SDR11(band)); in mt7915_mac_update_stats()
1733 mib->rx_len_mismatch_cnt += in mt7915_mac_update_stats()
1736 cnt = mt76_rr(dev, MT_MIB_SDR12(band)); in mt7915_mac_update_stats()
1737 mib->tx_ampdu_cnt += cnt; in mt7915_mac_update_stats()
1739 cnt = mt76_rr(dev, MT_MIB_SDR13(band)); in mt7915_mac_update_stats()
1740 mib->tx_stop_q_empty_cnt += in mt7915_mac_update_stats()
1743 cnt = mt76_rr(dev, MT_MIB_SDR14(band)); in mt7915_mac_update_stats()
1744 mib->tx_mpdu_attempts_cnt += is_mt7915(&dev->mt76) ? in mt7915_mac_update_stats()
1748 cnt = mt76_rr(dev, MT_MIB_SDR15(band)); in mt7915_mac_update_stats()
1749 mib->tx_mpdu_success_cnt += is_mt7915(&dev->mt76) ? in mt7915_mac_update_stats()
1753 cnt = mt76_rr(dev, MT_MIB_SDR16(band)); in mt7915_mac_update_stats()
1754 mib->primary_cca_busy_time += in mt7915_mac_update_stats()
1757 cnt = mt76_rr(dev, MT_MIB_SDR17(band)); in mt7915_mac_update_stats()
1758 mib->secondary_cca_busy_time += in mt7915_mac_update_stats()
1761 cnt = mt76_rr(dev, MT_MIB_SDR18(band)); in mt7915_mac_update_stats()
1762 mib->primary_energy_detect_time += in mt7915_mac_update_stats()
1765 cnt = mt76_rr(dev, MT_MIB_SDR19(band)); in mt7915_mac_update_stats()
1766 mib->cck_mdrdy_time += FIELD_GET(MT_MIB_SDR19_CCK_MDRDY_TIME_MASK, cnt); in mt7915_mac_update_stats()
1768 cnt = mt76_rr(dev, MT_MIB_SDR20(band)); in mt7915_mac_update_stats()
1769 mib->ofdm_mdrdy_time += in mt7915_mac_update_stats()
1772 cnt = mt76_rr(dev, MT_MIB_SDR21(band)); in mt7915_mac_update_stats()
1773 mib->green_mdrdy_time += in mt7915_mac_update_stats()
1776 cnt = mt76_rr(dev, MT_MIB_SDR22(band)); in mt7915_mac_update_stats()
1777 mib->rx_ampdu_cnt += cnt; in mt7915_mac_update_stats()
1779 cnt = mt76_rr(dev, MT_MIB_SDR23(band)); in mt7915_mac_update_stats()
1780 mib->rx_ampdu_bytes_cnt += cnt; in mt7915_mac_update_stats()
1782 cnt = mt76_rr(dev, MT_MIB_SDR24(band)); in mt7915_mac_update_stats()
1783 mib->rx_ampdu_valid_subframe_cnt += is_mt7915(&dev->mt76) ? in mt7915_mac_update_stats()
1787 cnt = mt76_rr(dev, MT_MIB_SDR25(band)); in mt7915_mac_update_stats()
1788 mib->rx_ampdu_valid_subframe_bytes_cnt += cnt; in mt7915_mac_update_stats()
1790 cnt = mt76_rr(dev, MT_MIB_SDR27(band)); in mt7915_mac_update_stats()
1791 mib->tx_rwp_fail_cnt += in mt7915_mac_update_stats()
1794 cnt = mt76_rr(dev, MT_MIB_SDR28(band)); in mt7915_mac_update_stats()
1795 mib->tx_rwp_need_cnt += in mt7915_mac_update_stats()
1798 cnt = mt76_rr(dev, MT_MIB_SDR29(band)); in mt7915_mac_update_stats()
1799 mib->rx_pfdrop_cnt += is_mt7915(&dev->mt76) ? in mt7915_mac_update_stats()
1803 cnt = mt76_rr(dev, MT_MIB_SDRVEC(band)); in mt7915_mac_update_stats()
1804 mib->rx_vec_queue_overflow_drop_cnt += is_mt7915(&dev->mt76) ? in mt7915_mac_update_stats()
1808 cnt = mt76_rr(dev, MT_MIB_SDR31(band)); in mt7915_mac_update_stats()
1809 mib->rx_ba_cnt += cnt; in mt7915_mac_update_stats()
1811 cnt = mt76_rr(dev, MT_MIB_SDRMUBF(band)); in mt7915_mac_update_stats()
1812 mib->tx_bf_cnt += FIELD_GET(MT_MIB_MU_BF_TX_CNT, cnt); in mt7915_mac_update_stats()
1814 cnt = mt76_rr(dev, MT_MIB_DR8(band)); in mt7915_mac_update_stats()
1815 mib->tx_mu_mpdu_cnt += cnt; in mt7915_mac_update_stats()
1817 cnt = mt76_rr(dev, MT_MIB_DR9(band)); in mt7915_mac_update_stats()
1818 mib->tx_mu_acked_mpdu_cnt += cnt; in mt7915_mac_update_stats()
1820 cnt = mt76_rr(dev, MT_MIB_DR11(band)); in mt7915_mac_update_stats()
1821 mib->tx_su_acked_mpdu_cnt += cnt; in mt7915_mac_update_stats()
1823 cnt = mt76_rr(dev, MT_ETBF_PAR_RPT0(band)); in mt7915_mac_update_stats()
1824 mib->tx_bf_rx_fb_bw = FIELD_GET(MT_ETBF_PAR_RPT0_FB_BW, cnt); in mt7915_mac_update_stats()
1825 mib->tx_bf_rx_fb_nc_cnt += FIELD_GET(MT_ETBF_PAR_RPT0_FB_NC, cnt); in mt7915_mac_update_stats()
1826 mib->tx_bf_rx_fb_nr_cnt += FIELD_GET(MT_ETBF_PAR_RPT0_FB_NR, cnt); in mt7915_mac_update_stats()
1828 for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) { in mt7915_mac_update_stats()
1830 mib->tx_amsdu[i] += cnt; in mt7915_mac_update_stats()
1831 mib->tx_amsdu_cnt += cnt; in mt7915_mac_update_stats()
1834 if (is_mt7915(&dev->mt76)) { in mt7915_mac_update_stats()
1836 val = mt76_rr(dev, MT_MIB_MB_SDR1(band, (i << 4))); in mt7915_mac_update_stats()
1837 mib->ba_miss_cnt += in mt7915_mac_update_stats()
1839 mib->ack_fail_cnt += in mt7915_mac_update_stats()
1842 val = mt76_rr(dev, MT_MIB_MB_SDR0(band, (i << 4))); in mt7915_mac_update_stats()
1843 mib->rts_cnt += FIELD_GET(MT_MIB_RTS_COUNT_MASK, val); in mt7915_mac_update_stats()
1844 mib->rts_retries_cnt += in mt7915_mac_update_stats()
1847 val = mt76_rr(dev, MT_TX_AGG_CNT(band, i)); in mt7915_mac_update_stats()
1848 phy->mt76->aggr_stats[aggr0++] += val & 0xffff; in mt7915_mac_update_stats()
1849 phy->mt76->aggr_stats[aggr0++] += val >> 16; in mt7915_mac_update_stats()
1851 val = mt76_rr(dev, MT_TX_AGG_CNT2(band, i)); in mt7915_mac_update_stats()
1852 phy->mt76->aggr_stats[aggr1++] += val & 0xffff; in mt7915_mac_update_stats()
1853 phy->mt76->aggr_stats[aggr1++] += val >> 16; in mt7915_mac_update_stats()
1856 cnt = mt76_rr(dev, MT_MIB_SDR32(band)); in mt7915_mac_update_stats()
1857 mib->tx_pkt_ebf_cnt += FIELD_GET(MT_MIB_SDR32_TX_PKT_EBF_CNT, cnt); in mt7915_mac_update_stats()
1859 cnt = mt76_rr(dev, MT_MIB_SDR33(band)); in mt7915_mac_update_stats()
1860 mib->tx_pkt_ibf_cnt += FIELD_GET(MT_MIB_SDR33_TX_PKT_IBF_CNT, cnt); in mt7915_mac_update_stats()
1862 cnt = mt76_rr(dev, MT_ETBF_TX_APP_CNT(band)); in mt7915_mac_update_stats()
1863 mib->tx_bf_ibf_ppdu_cnt += FIELD_GET(MT_ETBF_TX_IBF_CNT, cnt); in mt7915_mac_update_stats()
1864 mib->tx_bf_ebf_ppdu_cnt += FIELD_GET(MT_ETBF_TX_EBF_CNT, cnt); in mt7915_mac_update_stats()
1866 cnt = mt76_rr(dev, MT_ETBF_TX_NDP_BFRP(band)); in mt7915_mac_update_stats()
1867 mib->tx_bf_fb_cpl_cnt += FIELD_GET(MT_ETBF_TX_FB_CPL, cnt); in mt7915_mac_update_stats()
1868 mib->tx_bf_fb_trig_cnt += FIELD_GET(MT_ETBF_TX_FB_TRI, cnt); in mt7915_mac_update_stats()
1870 cnt = mt76_rr(dev, MT_ETBF_RX_FB_CNT(band)); in mt7915_mac_update_stats()
1871 mib->tx_bf_rx_fb_all_cnt += FIELD_GET(MT_ETBF_RX_FB_ALL, cnt); in mt7915_mac_update_stats()
1872 mib->tx_bf_rx_fb_he_cnt += FIELD_GET(MT_ETBF_RX_FB_HE, cnt); in mt7915_mac_update_stats()
1873 mib->tx_bf_rx_fb_vht_cnt += FIELD_GET(MT_ETBF_RX_FB_VHT, cnt); in mt7915_mac_update_stats()
1874 mib->tx_bf_rx_fb_ht_cnt += FIELD_GET(MT_ETBF_RX_FB_HT, cnt); in mt7915_mac_update_stats()
1878 val = mt76_rr(dev, MT_MIB_MB_SDR0(band, (i << 2))); in mt7915_mac_update_stats()
1879 mib->rts_cnt += FIELD_GET(GENMASK(15, 0), val); in mt7915_mac_update_stats()
1880 mib->rts_cnt += FIELD_GET(GENMASK(31, 16), val); in mt7915_mac_update_stats()
1883 val = mt76_rr(dev, MT_MIB_MB_SDR1(band, (i << 2))); in mt7915_mac_update_stats()
1884 mib->rts_retries_cnt += FIELD_GET(GENMASK(15, 0), val); in mt7915_mac_update_stats()
1885 mib->rts_retries_cnt += FIELD_GET(GENMASK(31, 16), val); in mt7915_mac_update_stats()
1888 val = mt76_rr(dev, MT_MIB_MB_SDR2(band, (i << 2))); in mt7915_mac_update_stats()
1889 mib->ba_miss_cnt += FIELD_GET(GENMASK(15, 0), val); in mt7915_mac_update_stats()
1890 mib->ba_miss_cnt += FIELD_GET(GENMASK(31, 16), val); in mt7915_mac_update_stats()
1893 val = mt76_rr(dev, MT_MIB_MB_BFTF(band, (i << 2))); in mt7915_mac_update_stats()
1894 mib->ack_fail_cnt += FIELD_GET(GENMASK(15, 0), val); in mt7915_mac_update_stats()
1895 mib->ack_fail_cnt += FIELD_GET(GENMASK(31, 16), val); in mt7915_mac_update_stats()
1899 val = mt76_rr(dev, MT_TX_AGG_CNT(band, i)); in mt7915_mac_update_stats()
1900 phy->mt76->aggr_stats[aggr0++] += FIELD_GET(GENMASK(15, 0), val); in mt7915_mac_update_stats()
1901 phy->mt76->aggr_stats[aggr0++] += FIELD_GET(GENMASK(31, 16), val); in mt7915_mac_update_stats()
1904 cnt = mt76_rr(dev, MT_MIB_SDR32(band)); in mt7915_mac_update_stats()
1905 mib->tx_pkt_ibf_cnt += FIELD_GET(MT_MIB_SDR32_TX_PKT_IBF_CNT, cnt); in mt7915_mac_update_stats()
1906 mib->tx_bf_ibf_ppdu_cnt += FIELD_GET(MT_MIB_SDR32_TX_PKT_IBF_CNT, cnt); in mt7915_mac_update_stats()
1907 mib->tx_pkt_ebf_cnt += FIELD_GET(MT_MIB_SDR32_TX_PKT_EBF_CNT, cnt); in mt7915_mac_update_stats()
1908 mib->tx_bf_ebf_ppdu_cnt += FIELD_GET(MT_MIB_SDR32_TX_PKT_EBF_CNT, cnt); in mt7915_mac_update_stats()
1910 cnt = mt76_rr(dev, MT_MIB_BFCR7(band)); in mt7915_mac_update_stats()
1911 mib->tx_bf_fb_cpl_cnt += FIELD_GET(MT_MIB_BFCR7_BFEE_TX_FB_CPL, cnt); in mt7915_mac_update_stats()
1913 cnt = mt76_rr(dev, MT_MIB_BFCR2(band)); in mt7915_mac_update_stats()
1914 mib->tx_bf_fb_trig_cnt += FIELD_GET(MT_MIB_BFCR2_BFEE_TX_FB_TRIG, cnt); in mt7915_mac_update_stats()
1916 cnt = mt76_rr(dev, MT_MIB_BFCR0(band)); in mt7915_mac_update_stats()
1917 mib->tx_bf_rx_fb_vht_cnt += FIELD_GET(MT_MIB_BFCR0_RX_FB_VHT, cnt); in mt7915_mac_update_stats()
1918 mib->tx_bf_rx_fb_all_cnt += FIELD_GET(MT_MIB_BFCR0_RX_FB_VHT, cnt); in mt7915_mac_update_stats()
1919 mib->tx_bf_rx_fb_ht_cnt += FIELD_GET(MT_MIB_BFCR0_RX_FB_HT, cnt); in mt7915_mac_update_stats()
1920 mib->tx_bf_rx_fb_all_cnt += FIELD_GET(MT_MIB_BFCR0_RX_FB_HT, cnt); in mt7915_mac_update_stats()
1922 cnt = mt76_rr(dev, MT_MIB_BFCR1(band)); in mt7915_mac_update_stats()
1923 mib->tx_bf_rx_fb_he_cnt += FIELD_GET(MT_MIB_BFCR1_RX_FB_HE, cnt); in mt7915_mac_update_stats()
1924 mib->tx_bf_rx_fb_all_cnt += FIELD_GET(MT_MIB_BFCR1_RX_FB_HE, cnt); in mt7915_mac_update_stats()
1930 struct mt7915_dev *dev = phy->dev; in mt7915_mac_severe_check()
1933 if (!phy->omac_mask) in mt7915_mac_severe_check()
1936 /* In rare cases, TRB pointers might be out of sync leads to RMAC in mt7915_mac_severe_check()
1937 * stopping Rx, so check status periodically to see if TRB hardware in mt7915_mac_severe_check()
1940 trb = mt76_rr(dev, MT_TRB_RXPSR0(phy->mt76->band_idx)); in mt7915_mac_severe_check()
1944 (FIELD_GET(MT_TRB_RXPSR0_RX_RMAC_PTR, phy->trb_ts) != in mt7915_mac_severe_check()
1945 FIELD_GET(MT_TRB_RXPSR0_RX_WTBL_PTR, phy->trb_ts)) && in mt7915_mac_severe_check()
1946 trb == phy->trb_ts) in mt7915_mac_severe_check()
1948 phy->mt76->band_idx); in mt7915_mac_severe_check()
1950 phy->trb_ts = trb; in mt7915_mac_severe_check()
1962 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_rc_work()
1963 list_splice_init(&dev->sta_rc_list, &list); in mt7915_mac_sta_rc_work()
1967 list_del_init(&msta->rc_list); in mt7915_mac_sta_rc_work()
1968 changed = msta->changed; in mt7915_mac_sta_rc_work()
1969 msta->changed = 0; in mt7915_mac_sta_rc_work()
1970 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_rc_work()
1973 vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv); in mt7915_mac_sta_rc_work()
1983 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_rc_work()
1986 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_rc_work()
1996 phy = mphy->priv; in mt7915_mac_work()
1998 mutex_lock(&mphy->dev->mutex); in mt7915_mac_work()
2001 if (++mphy->mac_work_count == 5) { in mt7915_mac_work()
2002 mphy->mac_work_count = 0; in mt7915_mac_work()
2007 if (phy->dev->muru_debug) in mt7915_mac_work()
2011 mutex_unlock(&mphy->dev->mutex); in mt7915_mac_work()
2013 mt76_tx_status_check(mphy->dev, false); in mt7915_mac_work()
2015 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, in mt7915_mac_work()
2021 struct mt7915_dev *dev = phy->dev; in mt7915_dfs_stop_radar_detector()
2023 if (phy->rdd_state & BIT(0)) in mt7915_dfs_stop_radar_detector()
2024 mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_STOP, 0, in mt7915_dfs_stop_radar_detector()
2026 if (phy->rdd_state & BIT(1)) in mt7915_dfs_stop_radar_detector()
2027 mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_STOP, 1, in mt7915_dfs_stop_radar_detector()
2035 switch (dev->mt76.region) { in mt7915_dfs_start_rdd()
2048 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_START, chain, in mt7915_dfs_start_rdd()
2053 if (is_mt7915(&dev->mt76)) { in mt7915_dfs_start_rdd()
2054 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_SET_WF_ANT, chain, in mt7915_dfs_start_rdd()
2055 0, dev->dbdc_support ? 2 : 0); in mt7915_dfs_start_rdd()
2060 return mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_DET_MODE, chain, in mt7915_dfs_start_rdd()
2066 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7915_dfs_start_radar_detector()
2067 struct mt7915_dev *dev = phy->dev; in mt7915_dfs_start_radar_detector()
2071 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_CAC_START, in mt7915_dfs_start_radar_detector()
2072 phy->mt76->band_idx, MT_RX_SEL0, 0); in mt7915_dfs_start_radar_detector()
2076 err = mt7915_dfs_start_rdd(dev, phy->mt76->band_idx); in mt7915_dfs_start_radar_detector()
2080 phy->rdd_state |= BIT(phy->mt76->band_idx); in mt7915_dfs_start_radar_detector()
2082 if (!is_mt7915(&dev->mt76)) in mt7915_dfs_start_radar_detector()
2085 if (chandef->width == NL80211_CHAN_WIDTH_160 || in mt7915_dfs_start_radar_detector()
2086 chandef->width == NL80211_CHAN_WIDTH_80P80) { in mt7915_dfs_start_radar_detector()
2091 phy->rdd_state |= BIT(1); in mt7915_dfs_start_radar_detector()
2101 struct mt7915_dev *dev = phy->dev; in mt7915_dfs_init_radar_specs()
2104 switch (dev->mt76.region) { in mt7915_dfs_init_radar_specs()
2118 return -EINVAL; in mt7915_dfs_init_radar_specs()
2121 for (i = 0; i < ARRAY_SIZE(radar_specs->radar_pattern); i++) { in mt7915_dfs_init_radar_specs()
2123 &radar_specs->radar_pattern[i]); in mt7915_dfs_init_radar_specs()
2128 return mt7915_mcu_set_pulse_th(dev, &radar_specs->pulse_th); in mt7915_dfs_init_radar_specs()
2133 struct mt7915_dev *dev = phy->dev; in mt7915_dfs_init_radar_detector()
2137 prev_state = phy->mt76->dfs_state; in mt7915_dfs_init_radar_detector()
2138 dfs_state = mt76_phy_dfs_state(phy->mt76); in mt7915_dfs_init_radar_detector()
2158 phy->mt76->dfs_state = MT_DFS_STATE_CAC; in mt7915_dfs_init_radar_detector()
2164 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_CAC_END, in mt7915_dfs_init_radar_detector()
2165 phy->mt76->band_idx, MT_RX_SEL0, 0); in mt7915_dfs_init_radar_detector()
2167 phy->mt76->dfs_state = MT_DFS_STATE_UNKNOWN; in mt7915_dfs_init_radar_detector()
2171 phy->mt76->dfs_state = MT_DFS_STATE_ACTIVE; in mt7915_dfs_init_radar_detector()
2175 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_NORMAL_START, in mt7915_dfs_init_radar_detector()
2176 phy->mt76->band_idx, MT_RX_SEL0, 0); in mt7915_dfs_init_radar_detector()
2180 if (is_mt7915(&dev->mt76)) { in mt7915_dfs_init_radar_detector()
2181 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_SET_WF_ANT, in mt7915_dfs_init_radar_detector()
2182 phy->mt76->band_idx, 0, in mt7915_dfs_init_radar_detector()
2183 dev->dbdc_support ? 2 : 0); in mt7915_dfs_init_radar_detector()
2189 phy->mt76->dfs_state = MT_DFS_STATE_DISABLED; in mt7915_dfs_init_radar_detector()
2205 u32 duration = flow->duration << 8; in mt7915_mac_twt_sched_list_add()
2208 iter = list_first_entry_or_null(&dev->twt_list, in mt7915_mac_twt_sched_list_add()
2210 if (!iter || !iter->sched || iter->start_tsf > duration) { in mt7915_mac_twt_sched_list_add()
2211 /* add flow as first entry in the list */ in mt7915_mac_twt_sched_list_add()
2212 list_add(&flow->list, &dev->twt_list); in mt7915_mac_twt_sched_list_add()
2216 list_for_each_entry_safe(iter, iter_next, &dev->twt_list, list) { in mt7915_mac_twt_sched_list_add()
2217 start_tsf = iter->start_tsf + in mt7915_mac_twt_sched_list_add()
2218 mt7915_mac_twt_duration_align(iter->duration); in mt7915_mac_twt_sched_list_add()
2219 if (list_is_last(&iter->list, &dev->twt_list)) in mt7915_mac_twt_sched_list_add()
2222 if (!iter_next->sched || in mt7915_mac_twt_sched_list_add()
2223 iter_next->start_tsf > start_tsf + duration) { in mt7915_mac_twt_sched_list_add()
2224 list_add(&flow->list, &iter->list); in mt7915_mac_twt_sched_list_add()
2229 /* add flow as last entry in the list */ in mt7915_mac_twt_sched_list_add()
2230 list_add_tail(&flow->list, &dev->twt_list); in mt7915_mac_twt_sched_list_add()
2243 if (twt->control & IEEE80211_TWT_CONTROL_NEG_TYPE_BROADCAST) in mt7915_mac_check_twt_req()
2244 return -EOPNOTSUPP; in mt7915_mac_check_twt_req()
2247 if (twt->control & IEEE80211_TWT_CONTROL_WAKE_DUR_UNIT) in mt7915_mac_check_twt_req()
2248 return -EOPNOTSUPP; in mt7915_mac_check_twt_req()
2250 twt_agrt = (struct ieee80211_twt_params *)twt->params; in mt7915_mac_check_twt_req()
2253 if (!(twt_agrt->req_type & cpu_to_le16(IEEE80211_TWT_REQTYPE_IMPLICIT))) in mt7915_mac_check_twt_req()
2254 return -EOPNOTSUPP; in mt7915_mac_check_twt_req()
2257 le16_to_cpu(twt_agrt->req_type)); in mt7915_mac_check_twt_req()
2258 mantissa = le16_to_cpu(twt_agrt->mantissa); in mt7915_mac_check_twt_req()
2259 duration = twt_agrt->min_twt_dur << 8; in mt7915_mac_check_twt_req()
2263 return -EOPNOTSUPP; in mt7915_mac_check_twt_req()
2272 u16 type = le16_to_cpu(twt_agrt->req_type); in mt7915_mac_twt_param_equal()
2280 if (!(msta->twt.flowid_mask & BIT(i))) in mt7915_mac_twt_param_equal()
2283 f = &msta->twt.flow[i]; in mt7915_mac_twt_param_equal()
2284 if (f->duration == twt_agrt->min_twt_dur && in mt7915_mac_twt_param_equal()
2285 f->mantissa == twt_agrt->mantissa && in mt7915_mac_twt_param_equal()
2286 f->exp == exp && in mt7915_mac_twt_param_equal()
2287 f->protection == !!(type & IEEE80211_TWT_REQTYPE_PROTECTION) && in mt7915_mac_twt_param_equal()
2288 f->flowtype == !!(type & IEEE80211_TWT_REQTYPE_FLOWTYPE) && in mt7915_mac_twt_param_equal()
2289 f->trigger == !!(type & IEEE80211_TWT_REQTYPE_TRIGGER)) in mt7915_mac_twt_param_equal()
2301 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; in mt7915_mac_add_twt_setup()
2302 struct ieee80211_twt_params *twt_agrt = (void *)twt->params; in mt7915_mac_add_twt_setup()
2303 u16 req_type = le16_to_cpu(twt_agrt->req_type); in mt7915_mac_add_twt_setup()
2313 mutex_lock(&dev->mt76.mutex); in mt7915_mac_add_twt_setup()
2315 if (dev->twt.n_agrt == MT7915_MAX_TWT_AGRT) in mt7915_mac_add_twt_setup()
2318 if (hweight8(msta->twt.flowid_mask) == ARRAY_SIZE(msta->twt.flow)) in mt7915_mac_add_twt_setup()
2321 if (twt_agrt->min_twt_dur < MT7915_MIN_TWT_DUR) { in mt7915_mac_add_twt_setup()
2323 twt_agrt->min_twt_dur = MT7915_MIN_TWT_DUR; in mt7915_mac_add_twt_setup()
2327 flowid = ffs(~msta->twt.flowid_mask) - 1; in mt7915_mac_add_twt_setup()
2328 twt_agrt->req_type &= ~cpu_to_le16(IEEE80211_TWT_REQTYPE_FLOWID); in mt7915_mac_add_twt_setup()
2329 twt_agrt->req_type |= le16_encode_bits(flowid, in mt7915_mac_add_twt_setup()
2332 table_id = ffs(~dev->twt.table_mask) - 1; in mt7915_mac_add_twt_setup()
2339 flow = &msta->twt.flow[flowid]; in mt7915_mac_add_twt_setup()
2341 INIT_LIST_HEAD(&flow->list); in mt7915_mac_add_twt_setup()
2342 flow->wcid = msta->wcid.idx; in mt7915_mac_add_twt_setup()
2343 flow->table_id = table_id; in mt7915_mac_add_twt_setup()
2344 flow->id = flowid; in mt7915_mac_add_twt_setup()
2345 flow->duration = twt_agrt->min_twt_dur; in mt7915_mac_add_twt_setup()
2346 flow->mantissa = twt_agrt->mantissa; in mt7915_mac_add_twt_setup()
2347 flow->exp = exp; in mt7915_mac_add_twt_setup()
2348 flow->protection = !!(req_type & IEEE80211_TWT_REQTYPE_PROTECTION); in mt7915_mac_add_twt_setup()
2349 flow->flowtype = !!(req_type & IEEE80211_TWT_REQTYPE_FLOWTYPE); in mt7915_mac_add_twt_setup()
2350 flow->trigger = !!(req_type & IEEE80211_TWT_REQTYPE_TRIGGER); in mt7915_mac_add_twt_setup()
2354 u64 interval = (u64)le16_to_cpu(twt_agrt->mantissa) << exp; in mt7915_mac_add_twt_setup()
2358 flow->sched = true; in mt7915_mac_add_twt_setup()
2359 flow->start_tsf = mt7915_mac_twt_sched_list_add(dev, flow); in mt7915_mac_add_twt_setup()
2360 curr_tsf = __mt7915_get_tsf(hw, msta->vif); in mt7915_mac_add_twt_setup()
2361 div_u64_rem(curr_tsf - flow->start_tsf, interval, &rem); in mt7915_mac_add_twt_setup()
2362 flow_tsf = curr_tsf + interval - rem; in mt7915_mac_add_twt_setup()
2363 twt_agrt->twt = cpu_to_le64(flow_tsf); in mt7915_mac_add_twt_setup()
2365 list_add_tail(&flow->list, &dev->twt_list); in mt7915_mac_add_twt_setup()
2367 flow->tsf = le64_to_cpu(twt_agrt->twt); in mt7915_mac_add_twt_setup()
2369 if (mt7915_mcu_twt_agrt_update(dev, msta->vif, flow, MCU_TWT_AGRT_ADD)) in mt7915_mac_add_twt_setup()
2373 dev->twt.table_mask |= BIT(table_id); in mt7915_mac_add_twt_setup()
2374 msta->twt.flowid_mask |= BIT(flowid); in mt7915_mac_add_twt_setup()
2375 dev->twt.n_agrt++; in mt7915_mac_add_twt_setup()
2378 mutex_unlock(&dev->mt76.mutex); in mt7915_mac_add_twt_setup()
2380 twt_agrt->req_type &= ~cpu_to_le16(IEEE80211_TWT_REQTYPE_SETUP_CMD); in mt7915_mac_add_twt_setup()
2381 twt_agrt->req_type |= in mt7915_mac_add_twt_setup()
2383 twt->control = (twt->control & IEEE80211_TWT_CONTROL_WAKE_DUR_UNIT) | in mt7915_mac_add_twt_setup()
2384 (twt->control & IEEE80211_TWT_CONTROL_RX_DISABLED); in mt7915_mac_add_twt_setup()
2393 lockdep_assert_held(&dev->mt76.mutex); in mt7915_mac_twt_teardown_flow()
2395 if (flowid >= ARRAY_SIZE(msta->twt.flow)) in mt7915_mac_twt_teardown_flow()
2398 if (!(msta->twt.flowid_mask & BIT(flowid))) in mt7915_mac_twt_teardown_flow()
2401 flow = &msta->twt.flow[flowid]; in mt7915_mac_twt_teardown_flow()
2402 if (mt7915_mcu_twt_agrt_update(dev, msta->vif, flow, in mt7915_mac_twt_teardown_flow()
2406 list_del_init(&flow->list); in mt7915_mac_twt_teardown_flow()
2407 msta->twt.flowid_mask &= ~BIT(flowid); in mt7915_mac_twt_teardown_flow()
2408 dev->twt.table_mask &= ~BIT(flow->table_id); in mt7915_mac_twt_teardown_flow()
2409 dev->twt.n_agrt--; in mt7915_mac_twt_teardown_flow()