Lines Matching +full:phy +full:- +full:reset +full:- +full:duration
1 // SPDX-License-Identifier: ISC
14 #define to_rssi(field, rcpi) ((FIELD_GET(field, rcpi) - 220) / 2)
17 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
31 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
42 .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()
74 if (wcid->phy_idx == band_idx) in mt7996_rx_get_wcid()
78 msta = msta_link->sta; in mt7996_rx_get_wcid()
79 if (!msta || !msta->vif) in mt7996_rx_get_wcid()
82 mvif = msta->vif; in mt7996_rx_get_wcid()
83 for (i = 0; i < ARRAY_SIZE(mvif->mt76.link); i++) { in mt7996_rx_get_wcid()
86 mlink = rcu_dereference(mvif->mt76.link[i]); in mt7996_rx_get_wcid()
90 if (mlink->band_idx != band_idx) in mt7996_rx_get_wcid()
93 msta_link = rcu_dereference(msta->link[i]); in mt7996_rx_get_wcid()
97 return &msta_link->wcid; in mt7996_rx_get_wcid()
134 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_poll()
135 list_splice_init(&dev->mt76.sta_poll_list, &sta_poll_list); in mt7996_mac_sta_poll()
136 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_poll()
146 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_poll()
148 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_poll()
154 msta = msta_link->sta; in mt7996_mac_sta_poll()
155 wcid = &msta_link->wcid; in mt7996_mac_sta_poll()
156 list_del_init(&wcid->poll_list); in mt7996_mac_sta_poll()
157 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_poll()
159 idx = wcid->idx; in mt7996_mac_sta_poll()
165 u32 tx_last = msta_link->airtime_ac[i]; in mt7996_mac_sta_poll()
166 u32 rx_last = msta_link->airtime_ac[i + 4]; in mt7996_mac_sta_poll()
168 msta_link->airtime_ac[i] = mt76_rr(dev, addr); in mt7996_mac_sta_poll()
169 msta_link->airtime_ac[i + 4] = mt76_rr(dev, addr + 4); in mt7996_mac_sta_poll()
171 tx_time[i] = msta_link->airtime_ac[i] - tx_last; in mt7996_mac_sta_poll()
172 rx_time[i] = msta_link->airtime_ac[i + 4] - rx_last; in mt7996_mac_sta_poll()
183 memset(msta_link->airtime_ac, 0, in mt7996_mac_sta_poll()
184 sizeof(msta_link->airtime_ac)); in mt7996_mac_sta_poll()
187 if (!wcid->sta) in mt7996_mac_sta_poll()
213 mlink = rcu_dereference(msta->vif->mt76.link[wcid->link_id]); in mt7996_mac_sta_poll()
218 msta_link->ack_signal = in mt7996_mac_sta_poll()
219 mt76_rx_signal(mphy->antenna_mask, in mt7996_mac_sta_poll()
223 ewma_avg_signal_add(&msta_link->avg_ack_signal, in mt7996_mac_sta_poll()
224 -msta_link->ack_signal); in mt7996_mac_sta_poll()
233 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt7996_reverse_frag0_hdr_trans()
234 struct ethhdr *eth_hdr = (struct ethhdr *)(skb->data + hdr_gap); in mt7996_reverse_frag0_hdr_trans()
235 struct mt7996_sta *msta = (struct mt7996_sta *)status->wcid; in mt7996_reverse_frag0_hdr_trans()
236 __le32 *rxd = (__le32 *)skb->data; in mt7996_reverse_frag0_hdr_trans()
244 return -EINVAL; in mt7996_reverse_frag0_hdr_trans()
247 return -EINVAL; in mt7996_reverse_frag0_hdr_trans()
249 if (!msta || !msta->vif) in mt7996_reverse_frag0_hdr_trans()
250 return -EINVAL; in mt7996_reverse_frag0_hdr_trans()
253 vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv); in mt7996_reverse_frag0_hdr_trans()
261 ether_addr_copy(hdr.addr1, vif->addr); in mt7996_reverse_frag0_hdr_trans()
262 ether_addr_copy(hdr.addr2, sta->addr); in mt7996_reverse_frag0_hdr_trans()
266 ether_addr_copy(hdr.addr3, vif->bss_conf.bssid); in mt7996_reverse_frag0_hdr_trans()
269 ether_addr_copy(hdr.addr3, eth_hdr->h_source); in mt7996_reverse_frag0_hdr_trans()
272 ether_addr_copy(hdr.addr3, eth_hdr->h_dest); in mt7996_reverse_frag0_hdr_trans()
275 ether_addr_copy(hdr.addr3, eth_hdr->h_dest); in mt7996_reverse_frag0_hdr_trans()
276 ether_addr_copy(hdr.addr4, eth_hdr->h_source); in mt7996_reverse_frag0_hdr_trans()
279 return -EINVAL; in mt7996_reverse_frag0_hdr_trans()
282 skb_pull(skb, hdr_gap + sizeof(struct ethhdr) - 2); in mt7996_reverse_frag0_hdr_trans()
283 if (eth_hdr->h_proto == cpu_to_be16(ETH_P_AARP) || in mt7996_reverse_frag0_hdr_trans()
284 eth_hdr->h_proto == cpu_to_be16(ETH_P_IPX)) in mt7996_reverse_frag0_hdr_trans()
286 else if (be16_to_cpu(eth_hdr->h_proto) >= ETH_P_802_3_MIN) in mt7996_reverse_frag0_hdr_trans()
305 memcpy(skb_push(skb, sizeof(hdr) - 6), &hdr, sizeof(hdr) - 6); in mt7996_reverse_frag0_hdr_trans()
339 i = mt76_get_rate(&dev->mt76, sband, i, cck); in mt7996_mac_fill_rx_rate()
343 status->encoding = RX_ENC_HT; in mt7996_mac_fill_rx_rate()
345 status->enc_flags |= RX_ENC_FLAG_SHORT_GI; in mt7996_mac_fill_rx_rate()
347 return -EINVAL; in mt7996_mac_fill_rx_rate()
350 status->nss = nss; in mt7996_mac_fill_rx_rate()
351 status->encoding = RX_ENC_VHT; in mt7996_mac_fill_rx_rate()
353 status->enc_flags |= RX_ENC_FLAG_SHORT_GI; in mt7996_mac_fill_rx_rate()
355 return -EINVAL; in mt7996_mac_fill_rx_rate()
361 status->nss = nss; in mt7996_mac_fill_rx_rate()
362 status->encoding = RX_ENC_HE; in mt7996_mac_fill_rx_rate()
366 status->he_gi = gi; in mt7996_mac_fill_rx_rate()
368 status->he_dcm = dcm; in mt7996_mac_fill_rx_rate()
373 status->nss = nss; in mt7996_mac_fill_rx_rate()
374 status->encoding = RX_ENC_EHT; in mt7996_mac_fill_rx_rate()
378 status->eht.gi = gi; in mt7996_mac_fill_rx_rate()
381 return -EINVAL; in mt7996_mac_fill_rx_rate()
383 status->rate_idx = i; in mt7996_mac_fill_rx_rate()
391 status->bw = RATE_INFO_BW_HE_RU; in mt7996_mac_fill_rx_rate()
392 status->he_ru = in mt7996_mac_fill_rx_rate()
395 status->bw = RATE_INFO_BW_40; in mt7996_mac_fill_rx_rate()
399 status->bw = RATE_INFO_BW_80; in mt7996_mac_fill_rx_rate()
402 status->bw = RATE_INFO_BW_160; in mt7996_mac_fill_rx_rate()
404 /* rxv reports bw 320-1 and 320-2 separately */ in mt7996_mac_fill_rx_rate()
407 status->bw = RATE_INFO_BW_320; in mt7996_mac_fill_rx_rate()
410 return -EINVAL; in mt7996_mac_fill_rx_rate()
413 status->enc_flags |= RX_ENC_FLAG_STBC_MASK * stbc; in mt7996_mac_fill_rx_rate()
415 status->enc_flags |= RX_ENC_FLAG_SHORT_GI; in mt7996_mac_fill_rx_rate()
428 if (!msta || !msta->vif) in mt7996_wed_check_ppe()
437 vif = container_of((void *)msta->vif, struct ieee80211_vif, in mt7996_wed_check_ppe()
440 skb->dev = wdev->netdev; in mt7996_wed_check_ppe()
442 mtk_wed_device_ppe_check(&dev->mt76.mmio.wed, skb, in mt7996_wed_check_ppe()
451 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt7996_mac_fill_rx()
452 struct mt76_phy *mphy = &dev->mt76.phy; in mt7996_mac_fill_rx()
453 struct mt7996_phy *phy = &dev->phy; in mt7996_mac_fill_rx() local
455 __le32 *rxd = (__le32 *)skb->data; in mt7996_mac_fill_rx()
463 u32 csum_status = *(u32 *)skb->cb; in mt7996_mac_fill_rx()
477 hw_aggr = status->aggr; in mt7996_mac_fill_rx()
481 mphy = dev->mt76.phys[band_idx]; in mt7996_mac_fill_rx()
482 phy = mphy->priv; in mt7996_mac_fill_rx()
483 status->phy_idx = mphy->band_idx; in mt7996_mac_fill_rx()
485 if (!test_bit(MT76_STATE_RUNNING, &mphy->state)) in mt7996_mac_fill_rx()
486 return -EINVAL; in mt7996_mac_fill_rx()
489 return -EINVAL; in mt7996_mac_fill_rx()
493 return -EINVAL; in mt7996_mac_fill_rx()
497 status->flag |= RX_FLAG_ONLY_MONITOR; in mt7996_mac_fill_rx()
501 status->wcid = mt7996_rx_get_wcid(dev, idx, band_idx); in mt7996_mac_fill_rx()
503 if (status->wcid) { in mt7996_mac_fill_rx()
506 msta_link = container_of(status->wcid, struct mt7996_sta_link, in mt7996_mac_fill_rx()
508 msta = msta_link->sta; in mt7996_mac_fill_rx()
509 mt76_wcid_add_poll(&dev->mt76, &msta_link->wcid); in mt7996_mac_fill_rx()
512 status->freq = mphy->chandef.chan->center_freq; in mt7996_mac_fill_rx()
513 status->band = mphy->chandef.chan->band; in mt7996_mac_fill_rx()
514 if (status->band == NL80211_BAND_5GHZ) in mt7996_mac_fill_rx()
515 sband = &mphy->sband_5g.sband; in mt7996_mac_fill_rx()
516 else if (status->band == NL80211_BAND_6GHZ) in mt7996_mac_fill_rx()
517 sband = &mphy->sband_6g.sband; in mt7996_mac_fill_rx()
519 sband = &mphy->sband_2g.sband; in mt7996_mac_fill_rx()
521 if (!sband->channels) in mt7996_mac_fill_rx()
522 return -EINVAL; in mt7996_mac_fill_rx()
526 skb->ip_summed = CHECKSUM_UNNECESSARY; in mt7996_mac_fill_rx()
529 status->flag |= RX_FLAG_FAILED_FCS_CRC; in mt7996_mac_fill_rx()
532 status->flag |= RX_FLAG_MMIC_ERROR; in mt7996_mac_fill_rx()
536 status->flag |= RX_FLAG_DECRYPTED; in mt7996_mac_fill_rx()
537 status->flag |= RX_FLAG_IV_STRIPPED; in mt7996_mac_fill_rx()
538 status->flag |= RX_FLAG_MMIC_STRIPPED | RX_FLAG_MIC_STRIPPED; in mt7996_mac_fill_rx()
544 return -EINVAL; in mt7996_mac_fill_rx()
556 if ((u8 *)rxd - skb->data >= skb->len) in mt7996_mac_fill_rx()
557 return -EINVAL; in mt7996_mac_fill_rx()
563 if (status->flag & RX_FLAG_DECRYPTED) { in mt7996_mac_fill_rx()
575 status->iv[0] = data[5]; in mt7996_mac_fill_rx()
576 status->iv[1] = data[4]; in mt7996_mac_fill_rx()
577 status->iv[2] = data[3]; in mt7996_mac_fill_rx()
578 status->iv[3] = data[2]; in mt7996_mac_fill_rx()
579 status->iv[4] = data[1]; in mt7996_mac_fill_rx()
580 status->iv[5] = data[0]; in mt7996_mac_fill_rx()
587 if ((u8 *)rxd - skb->data >= skb->len) in mt7996_mac_fill_rx()
588 return -EINVAL; in mt7996_mac_fill_rx()
592 status->timestamp = le32_to_cpu(rxd[0]); in mt7996_mac_fill_rx()
593 status->flag |= RX_FLAG_MACTIME_START; in mt7996_mac_fill_rx()
596 status->flag |= RX_FLAG_AMPDU_DETAILS; in mt7996_mac_fill_rx()
598 /* all subframes of an A-MPDU have the same timestamp */ in mt7996_mac_fill_rx()
599 if (phy->rx_ampdu_ts != status->timestamp) { in mt7996_mac_fill_rx()
600 if (!++phy->ampdu_ref) in mt7996_mac_fill_rx()
601 phy->ampdu_ref++; in mt7996_mac_fill_rx()
603 phy->rx_ampdu_ts = status->timestamp; in mt7996_mac_fill_rx()
605 status->ampdu_ref = phy->ampdu_ref; in mt7996_mac_fill_rx()
609 if ((u8 *)rxd - skb->data >= skb->len) in mt7996_mac_fill_rx()
610 return -EINVAL; in mt7996_mac_fill_rx()
613 /* RXD Group 3 - P-RXV */ in mt7996_mac_fill_rx()
620 if ((u8 *)rxd - skb->data >= skb->len) in mt7996_mac_fill_rx()
621 return -EINVAL; in mt7996_mac_fill_rx()
625 status->chains = mphy->antenna_mask; in mt7996_mac_fill_rx()
626 status->chain_signal[0] = to_rssi(MT_PRXV_RCPI0, v3); in mt7996_mac_fill_rx()
627 status->chain_signal[1] = to_rssi(MT_PRXV_RCPI1, v3); in mt7996_mac_fill_rx()
628 status->chain_signal[2] = to_rssi(MT_PRXV_RCPI2, v3); in mt7996_mac_fill_rx()
629 status->chain_signal[3] = to_rssi(MT_PRXV_RCPI3, v3); in mt7996_mac_fill_rx()
631 /* RXD Group 5 - C-RXV */ in mt7996_mac_fill_rx()
634 if ((u8 *)rxd - skb->data >= skb->len) in mt7996_mac_fill_rx()
635 return -EINVAL; in mt7996_mac_fill_rx()
644 status->amsdu = !!amsdu_info; in mt7996_mac_fill_rx()
645 if (status->amsdu) { in mt7996_mac_fill_rx()
646 status->first_amsdu = amsdu_info == MT_RXD4_FIRST_AMSDU_FRAME; in mt7996_mac_fill_rx()
647 status->last_amsdu = amsdu_info == MT_RXD4_LAST_AMSDU_FRAME; in mt7996_mac_fill_rx()
650 hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad; in mt7996_mac_fill_rx()
653 return -EINVAL; in mt7996_mac_fill_rx()
659 if (!hdr_trans && status->amsdu && !(ieee80211_has_a4(fc) && is_mesh)) { in mt7996_mac_fill_rx()
663 * the hardware will insert an extra 2-byte field in mt7996_mac_fill_rx()
665 * type field. This happens either when the LLC-SNAP in mt7996_mac_fill_rx()
670 if (get_unaligned_be16(skb->data + pad_start) == ETH_P_8021Q) in mt7996_mac_fill_rx()
677 memmove(skb->data + 2, skb->data, pad_start); in mt7996_mac_fill_rx()
692 fc = hdr->frame_control; in mt7996_mac_fill_rx()
696 seq_ctrl = le16_to_cpu(hdr->seq_ctrl); in mt7996_mac_fill_rx()
700 * de-amsdu, so here needs to clear amsdu present bit in mt7996_mac_fill_rx()
703 if (ieee80211_has_a4(fc) && is_mesh && status->amsdu) in mt7996_mac_fill_rx()
706 skb_set_mac_header(skb, (unsigned char *)hdr - skb->data); in mt7996_mac_fill_rx()
708 status->flag |= RX_FLAG_8023; in mt7996_mac_fill_rx()
709 mt7996_wed_check_ppe(dev, &dev->mt76.q_rx[q], msta, skb, in mt7996_mac_fill_rx()
713 if (rxv && !(status->flag & RX_FLAG_8023)) { in mt7996_mac_fill_rx()
714 switch (status->encoding) { in mt7996_mac_fill_rx()
726 if (!status->wcid || !ieee80211_is_data_qos(fc) || hw_aggr) in mt7996_mac_fill_rx()
729 status->aggr = unicast && in mt7996_mac_fill_rx()
731 status->qos_ctl = qos_ctl; in mt7996_mac_fill_rx()
732 status->seqno = IEEE80211_SEQ_TO_SN(seq_ctrl); in mt7996_mac_fill_rx()
741 u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in mt7996_mac_write_txwi_8023()
747 if (wcid->sta) { in mt7996_mac_write_txwi_8023()
750 wmm = sta->wme; in mt7996_mac_write_txwi_8023()
756 ethertype = get_unaligned_be16(&skb->data[12]); in mt7996_mac_write_txwi_8023()
770 if (wcid->amsdu) in mt7996_mac_write_txwi_8023()
780 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in mt7996_mac_write_txwi_80211()
781 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data; in mt7996_mac_write_txwi_80211()
783 bool multicast = is_multicast_ether_addr(hdr->addr1); in mt7996_mac_write_txwi_80211()
784 u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in mt7996_mac_write_txwi_80211()
785 __le16 fc = hdr->frame_control, sc = hdr->seq_ctrl; in mt7996_mac_write_txwi_80211()
791 mgmt->u.action.category == WLAN_CATEGORY_BACK && in mt7996_mac_write_txwi_80211()
792 mgmt->u.action.u.addba_req.action_code == WLAN_ACTION_ADDBA_REQ) in mt7996_mac_write_txwi_80211()
794 else if (ieee80211_is_mgmt(hdr->frame_control)) in mt7996_mac_write_txwi_80211()
803 info->flags & IEEE80211_TX_CTL_USE_MINRATE) in mt7996_mac_write_txwi_80211()
836 if (multicast && ieee80211_vif_is_mld(info->control.vif)) { in mt7996_mac_write_txwi_80211()
842 if (info->flags & IEEE80211_TX_CTL_INJECTED) { in mt7996_mac_write_txwi_80211()
843 if (ieee80211_is_back_req(hdr->frame_control)) { in mt7996_mac_write_txwi_80211()
846 bar = (struct ieee80211_bar *)skb->data; in mt7996_mac_write_txwi_80211()
847 seqno = le16_to_cpu(bar->start_seq_num); in mt7996_mac_write_txwi_80211()
856 if (ieee80211_vif_is_mld(info->control.vif) && in mt7996_mac_write_txwi_80211()
857 (multicast || unlikely(skb->protocol == cpu_to_be16(ETH_P_PAE)))) in mt7996_mac_write_txwi_80211()
861 ieee80211_vif_is_mld(info->control.vif)) { in mt7996_mac_write_txwi_80211()
866 if (!wcid->sta && ieee80211_is_mgmt(fc)) in mt7996_mac_write_txwi_80211()
875 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in mt7996_mac_write_txwi()
877 struct ieee80211_vif *vif = info->control.vif; in mt7996_mac_write_txwi()
878 u8 band_idx = (info->hw_queue & MT_TX_HW_QUEUE_PHY) >> 2; in mt7996_mac_write_txwi()
880 bool is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP; in mt7996_mac_write_txwi()
891 if (wcid != &dev->mt76.global_wcid) in mt7996_mac_write_txwi()
892 link_id = wcid->link_id; in mt7996_mac_write_txwi()
894 link_id = u32_get_bits(info->control.flags, in mt7996_mac_write_txwi()
897 mvif = vif ? (struct mt7996_vif *)vif->drv_priv : NULL; in mt7996_mac_write_txwi()
899 mlink = rcu_dereference(mvif->mt76.link[link_id]); in mt7996_mac_write_txwi()
902 omac_idx = mlink->omac_idx; in mt7996_mac_write_txwi()
903 wmm_idx = mlink->wmm_idx; in mt7996_mac_write_txwi()
904 band_idx = mlink->band_idx; in mt7996_mac_write_txwi()
922 val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len + MT_TXD_SIZE) | in mt7996_mac_write_txwi()
927 val = FIELD_PREP(MT_TXD1_WLAN_IDX, wcid->idx) | in mt7996_mac_write_txwi()
940 if (info->flags & IEEE80211_TX_CTL_NO_ACK) in mt7996_mac_write_txwi()
955 if (is_mt7996(&dev->mt76)) in mt7996_mac_write_txwi()
957 else if (is_8023 || !ieee80211_is_mgmt(hdr->frame_control)) in mt7996_mac_write_txwi()
969 bool mcast = ieee80211_is_data(hdr->frame_control) && in mt7996_mac_write_txwi()
970 is_multicast_ether_addr(hdr->addr1); in mt7996_mac_write_txwi()
974 if (mcast && mlink->mcast_rates_idx) in mt7996_mac_write_txwi()
975 idx = mlink->mcast_rates_idx; in mt7996_mac_write_txwi()
976 else if (beacon && mlink->beacon_rates_idx) in mt7996_mac_write_txwi()
977 idx = mlink->beacon_rates_idx; in mt7996_mac_write_txwi()
979 idx = mlink->basic_rates_idx; in mt7996_mac_write_txwi()
995 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx_info->skb->data; in mt7996_tx_prepare_skb()
997 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_info->skb); in mt7996_tx_prepare_skb()
998 struct ieee80211_key_conf *key = info->control.hw_key; in mt7996_tx_prepare_skb()
999 struct ieee80211_vif *vif = info->control.vif; in mt7996_tx_prepare_skb()
1002 int id, i, pid, nbuf = tx_info->nbuf - 1; in mt7996_tx_prepare_skb()
1003 bool is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP; in mt7996_tx_prepare_skb()
1006 if (unlikely(tx_info->skb->len <= ETH_HLEN)) in mt7996_tx_prepare_skb()
1007 return -EINVAL; in mt7996_tx_prepare_skb()
1010 wcid = &dev->mt76.global_wcid; in mt7996_tx_prepare_skb()
1012 t = (struct mt76_txwi_cache *)(txwi + mdev->drv->txwi_size); in mt7996_tx_prepare_skb()
1013 t->skb = tx_info->skb; in mt7996_tx_prepare_skb()
1019 pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb); in mt7996_tx_prepare_skb()
1020 mt7996_mac_write_txwi(dev, txwi_ptr, tx_info->skb, wcid, key, in mt7996_tx_prepare_skb()
1027 len = FIELD_PREP(MT_TXP_BUF_LEN, tx_info->buf[i + 1].len); in mt7996_tx_prepare_skb()
1030 tx_info->buf[i + 1].addr >> 32); in mt7996_tx_prepare_skb()
1033 txp->fw.buf[i] = cpu_to_le32(tx_info->buf[i + 1].addr); in mt7996_tx_prepare_skb()
1034 txp->fw.len[i] = cpu_to_le16(len); in mt7996_tx_prepare_skb()
1036 txp->fw.nbuf = nbuf; in mt7996_tx_prepare_skb()
1038 txp->fw.flags = in mt7996_tx_prepare_skb()
1042 txp->fw.flags |= cpu_to_le16(MT_CT_INFO_NONE_CIPHER_FRAME); in mt7996_tx_prepare_skb()
1044 if (!is_8023 && ieee80211_is_mgmt(hdr->frame_control)) in mt7996_tx_prepare_skb()
1045 txp->fw.flags |= cpu_to_le16(MT_CT_INFO_MGMT_FRAME); in mt7996_tx_prepare_skb()
1048 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; in mt7996_tx_prepare_skb()
1051 if (wcid->offchannel) in mt7996_tx_prepare_skb()
1052 mlink = rcu_dereference(mvif->mt76.offchannel_link); in mt7996_tx_prepare_skb()
1054 mlink = &mvif->deflink.mt76; in mt7996_tx_prepare_skb()
1056 txp->fw.bss_idx = mlink->idx; in mt7996_tx_prepare_skb()
1059 txp->fw.token = cpu_to_le16(id); in mt7996_tx_prepare_skb()
1060 txp->fw.rept_wds_wcid = cpu_to_le16(sta ? wcid->idx : 0xfff); in mt7996_tx_prepare_skb()
1062 tx_info->skb = NULL; in mt7996_tx_prepare_skb()
1065 tx_info->buf[1].len = MT_CT_PARSE_LEN; in mt7996_tx_prepare_skb()
1066 tx_info->buf[1].skip_unmap = true; in mt7996_tx_prepare_skb()
1067 tx_info->nbuf = MT_CT_DMA_BUF_NUM; in mt7996_tx_prepare_skb()
1088 txp->token = cpu_to_le16(token_id); in mt7996_wed_init_buf()
1089 txp->nbuf = 1; in mt7996_wed_init_buf()
1090 txp->buf[0] = cpu_to_le32(phys + MT_TXD_SIZE + sizeof(*txp)); in mt7996_wed_init_buf()
1099 bool is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP; in mt7996_tx_check_aggr()
1104 if (!sta || !(sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he)) in mt7996_tx_check_aggr()
1107 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in mt7996_tx_check_aggr()
1113 (sta->wme ? IEEE80211_STYPE_QOS_DATA : IEEE80211_STYPE_DATA); in mt7996_tx_check_aggr()
1120 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in mt7996_tx_check_aggr()
1122 fc = le16_to_cpu(hdr->frame_control) & in mt7996_tx_check_aggr()
1129 msta = (struct mt7996_sta *)sta->drv_priv; in mt7996_tx_check_aggr()
1130 msta_link = &msta->deflink; in mt7996_tx_check_aggr()
1132 if (!test_and_set_bit(tid, &msta_link->wcid.ampdu_state)) in mt7996_tx_check_aggr()
1140 struct mt76_dev *mdev = &dev->mt76; in mt7996_txwi_free()
1146 if (!t->skb) in mt7996_txwi_free()
1151 wcid = (struct mt76_wcid *)sta->drv_priv; in mt7996_txwi_free()
1152 wcid_idx = wcid->idx; in mt7996_txwi_free()
1154 if (likely(t->skb->protocol != cpu_to_be16(ETH_P_PAE))) in mt7996_txwi_free()
1155 mt7996_tx_check_aggr(sta, t->skb); in mt7996_txwi_free()
1160 __mt76_tx_complete_skb(mdev, wcid_idx, t->skb, free_list); in mt7996_txwi_free()
1163 t->skb = NULL; in mt7996_txwi_free()
1171 struct mt76_dev *mdev = &dev->mt76; in mt7996_mac_tx_free()
1172 struct mt76_phy *phy2 = mdev->phys[MT_BAND1]; in mt7996_mac_tx_free()
1173 struct mt76_phy *phy3 = mdev->phys[MT_BAND2]; in mt7996_mac_tx_free()
1184 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_PSD], false); in mt7996_mac_tx_free()
1185 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_BE], false); in mt7996_mac_tx_free()
1187 mt76_queue_tx_cleanup(dev, phy2->q_tx[MT_TXQ_PSD], false); in mt7996_mac_tx_free()
1188 mt76_queue_tx_cleanup(dev, phy2->q_tx[MT_TXQ_BE], false); in mt7996_mac_tx_free()
1191 mt76_queue_tx_cleanup(dev, phy3->q_tx[MT_TXQ_PSD], false); in mt7996_mac_tx_free()
1192 mt76_queue_tx_cleanup(dev, phy3->q_tx[MT_TXQ_BE], false); in mt7996_mac_tx_free()
1214 wcid = rcu_dereference(dev->mt76.wcid[idx]); in mt7996_mac_tx_free()
1221 mt76_wcid_add_poll(&dev->mt76, &msta_link->wcid); in mt7996_mac_tx_free()
1230 FIELD_GET(MT_TXFREE_INFO_COUNT, info) - 1; in mt7996_mac_tx_free()
1234 wcid->stats.tx_retries += tx_retries; in mt7996_mac_tx_free()
1235 wcid->stats.tx_failed += tx_failed; in mt7996_mac_tx_free()
1256 mt76_set_tx_blocked(&dev->mt76, false); in mt7996_mac_tx_free()
1258 mt76_worker_schedule(&dev->mt76.tx_worker); in mt7996_mac_tx_free()
1270 struct mt76_sta_stats *stats = &wcid->stats; in mt7996_mac_add_txs_skb()
1272 struct mt76_dev *mdev = &dev->mt76; in mt7996_mac_add_txs_skb()
1291 info->flags |= IEEE80211_TX_STAT_ACK; in mt7996_mac_add_txs_skb()
1293 info->status.ampdu_len = 1; in mt7996_mac_add_txs_skb()
1294 info->status.ampdu_ack_len = in mt7996_mac_add_txs_skb()
1295 !!(info->flags & IEEE80211_TX_STAT_ACK); in mt7996_mac_add_txs_skb()
1297 info->status.rates[0].idx = -1; in mt7996_mac_add_txs_skb()
1301 if (mtk_wed_device_active(&dev->mt76.mmio.wed) && wcid->sta) { in mt7996_mac_add_txs_skb()
1319 if (rate.nss - 1 < ARRAY_SIZE(stats->tx_nss)) in mt7996_mac_add_txs_skb()
1320 stats->tx_nss[rate.nss - 1]++; in mt7996_mac_add_txs_skb()
1321 if (rate.mcs < ARRAY_SIZE(stats->tx_mcs)) in mt7996_mac_add_txs_skb()
1322 stats->tx_mcs[rate.mcs]++; in mt7996_mac_add_txs_skb()
1330 mphy = mt76_dev_phy(mdev, wcid->phy_idx); in mt7996_mac_add_txs_skb()
1332 if (mphy->chandef.chan->band == NL80211_BAND_5GHZ) in mt7996_mac_add_txs_skb()
1333 sband = &mphy->sband_5g.sband; in mt7996_mac_add_txs_skb()
1334 else if (mphy->chandef.chan->band == NL80211_BAND_6GHZ) in mt7996_mac_add_txs_skb()
1335 sband = &mphy->sband_6g.sband; in mt7996_mac_add_txs_skb()
1337 sband = &mphy->sband_2g.sband; in mt7996_mac_add_txs_skb()
1339 rate.mcs = mt76_get_rate(mphy->dev, sband, rate.mcs, cck); in mt7996_mac_add_txs_skb()
1340 rate.legacy = sband->bitrates[rate.mcs].bitrate; in mt7996_mac_add_txs_skb()
1348 if (wcid->rate.flags & RATE_INFO_FLAGS_SHORT_GI) in mt7996_mac_add_txs_skb()
1356 if (wcid->rate.flags & RATE_INFO_FLAGS_SHORT_GI) in mt7996_mac_add_txs_skb()
1366 rate.he_gi = wcid->rate.he_gi; in mt7996_mac_add_txs_skb()
1376 rate.eht_gi = wcid->rate.eht_gi; in mt7996_mac_add_txs_skb()
1383 stats->tx_mode[mode]++; in mt7996_mac_add_txs_skb()
1388 stats->tx_bw[4]++; in mt7996_mac_add_txs_skb()
1392 stats->tx_bw[3]++; in mt7996_mac_add_txs_skb()
1396 stats->tx_bw[2]++; in mt7996_mac_add_txs_skb()
1400 stats->tx_bw[1]++; in mt7996_mac_add_txs_skb()
1404 stats->tx_bw[0]++; in mt7996_mac_add_txs_skb()
1407 wcid->rate = rate; in mt7996_mac_add_txs_skb()
1436 wcid = rcu_dereference(dev->mt76.wcid[wcidx]); in mt7996_mac_add_txs()
1442 if (!wcid->sta) in mt7996_mac_add_txs()
1446 mt76_wcid_add_poll(&dev->mt76, &msta_link->wcid); in mt7996_mac_add_txs()
1488 __le32 *rxd = (__le32 *)skb->data; in mt7996_queue_rx_skb()
1489 __le32 *end = (__le32 *)&skb->data[skb->len]; in mt7996_queue_rx_skb()
1503 if (mtk_wed_device_active(&dev->mt76.mmio.wed_hif2) && in mt7996_queue_rx_skb()
1509 mt7996_mac_tx_free(dev, skb->data, skb->len); in mt7996_queue_rx_skb()
1521 mt7996_debugfs_rx_fw_monitor(dev, skb->data, skb->len); in mt7996_queue_rx_skb()
1526 mt76_rx(&dev->mt76, q, skb); in mt7996_queue_rx_skb()
1536 void mt7996_mac_cca_stats_reset(struct mt7996_phy *phy) in mt7996_mac_cca_stats_reset() argument
1538 struct mt7996_dev *dev = phy->dev; in mt7996_mac_cca_stats_reset()
1539 u32 reg = MT_WF_PHYRX_BAND_RX_CTRL1(phy->mt76->band_idx); in mt7996_mac_cca_stats_reset()
1545 void mt7996_mac_reset_counters(struct mt7996_phy *phy) in mt7996_mac_reset_counters() argument
1547 struct mt7996_dev *dev = phy->dev; in mt7996_mac_reset_counters()
1548 u8 band_idx = phy->mt76->band_idx; in mt7996_mac_reset_counters()
1554 phy->mt76->survey_time = ktime_get_boottime(); in mt7996_mac_reset_counters()
1556 memset(phy->mt76->aggr_stats, 0, sizeof(phy->mt76->aggr_stats)); in mt7996_mac_reset_counters()
1558 /* reset airtime counters */ in mt7996_mac_reset_counters()
1562 mt7996_mcu_get_chan_mib_info(phy, true); in mt7996_mac_reset_counters()
1565 void mt7996_mac_set_coverage_class(struct mt7996_phy *phy) in mt7996_mac_set_coverage_class() argument
1567 s16 coverage_class = phy->coverage_class; in mt7996_mac_set_coverage_class()
1568 struct mt7996_dev *dev = phy->dev; in mt7996_mac_set_coverage_class()
1576 u8 band_idx = phy->mt76->band_idx; in mt7996_mac_set_coverage_class()
1579 if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state)) in mt7996_mac_set_coverage_class()
1583 coverage_class = max_t(s16, dev->phy.coverage_class, in mt7996_mac_set_coverage_class()
1584 phy2->coverage_class); in mt7996_mac_set_coverage_class()
1588 phy3->coverage_class); in mt7996_mac_set_coverage_class()
1609 mt7996_phy_get_nf(struct mt7996_phy *phy, u8 band_idx) in mt7996_phy_get_nf() argument
1612 struct mt7996_dev *dev = phy->dev; in mt7996_phy_get_nf()
1616 for (ant = 0; ant < hweight8(phy->mt76->antenna_mask); ant++) { in mt7996_phy_get_nf()
1631 struct mt7996_phy *phy = mphy->priv; in mt7996_update_channel() local
1632 struct mt76_channel_state *state = mphy->chan_state; in mt7996_update_channel()
1635 mt7996_mcu_get_chan_mib_info(phy, false); in mt7996_update_channel()
1637 nf = mt7996_phy_get_nf(phy, mphy->band_idx); in mt7996_update_channel()
1638 if (!phy->noise) in mt7996_update_channel()
1639 phy->noise = nf << 4; in mt7996_update_channel()
1641 phy->noise += nf - (phy->noise >> 4); in mt7996_update_channel()
1643 state->noise = -(phy->noise >> 4); in mt7996_update_channel()
1651 ret = wait_event_timeout(dev->reset_wait, in mt7996_wait_reset_state()
1652 (READ_ONCE(dev->recovery.state) & state), in mt7996_wait_reset_state()
1655 WARN(!ret, "Timeout waiting for MCU reset state %x\n", state); in mt7996_wait_reset_state()
1664 switch (vif->type) { in mt7996_update_vif_beacon()
1668 mt7996_mcu_add_beacon(hw, vif, &vif->bss_conf); in mt7996_update_vif_beacon()
1680 ieee80211_iterate_active_interfaces(dev->mt76.hw, in mt7996_update_beacons()
1682 mt7996_update_vif_beacon, dev->mt76.hw); in mt7996_update_beacons()
1684 phy2 = dev->mt76.phys[MT_BAND1]; in mt7996_update_beacons()
1688 ieee80211_iterate_active_interfaces(phy2->hw, in mt7996_update_beacons()
1690 mt7996_update_vif_beacon, phy2->hw); in mt7996_update_beacons()
1692 phy3 = dev->mt76.phys[MT_BAND2]; in mt7996_update_beacons()
1696 ieee80211_iterate_active_interfaces(phy3->hw, in mt7996_update_beacons()
1698 mt7996_update_vif_beacon, phy3->hw); in mt7996_update_beacons()
1706 spin_lock_bh(&dev->mt76.token_lock); in mt7996_tx_token_put()
1707 idr_for_each_entry(&dev->mt76.token, txwi, id) { in mt7996_tx_token_put()
1709 dev->mt76.token_count--; in mt7996_tx_token_put()
1711 spin_unlock_bh(&dev->mt76.token_lock); in mt7996_tx_token_put()
1712 idr_destroy(&dev->mt76.token); in mt7996_tx_token_put()
1719 struct mt76_dev *mdev = &dev->mt76; in mt7996_mac_restart()
1725 if (dev->hif2) { in mt7996_mac_restart()
1730 if (dev_is_pci(mdev->dev)) { in mt7996_mac_restart()
1732 if (dev->hif2) in mt7996_mac_restart()
1736 set_bit(MT76_RESET, &dev->mphy.state); in mt7996_mac_restart()
1737 set_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7996_mac_restart()
1738 wake_up(&dev->mt76.mcu.wait); in mt7996_mac_restart()
1740 set_bit(MT76_RESET, &phy2->mt76->state); in mt7996_mac_restart()
1742 set_bit(MT76_RESET, &phy3->mt76->state); in mt7996_mac_restart()
1745 mt76_txq_schedule_all(&dev->mphy); in mt7996_mac_restart()
1747 mt76_txq_schedule_all(phy2->mt76); in mt7996_mac_restart()
1749 mt76_txq_schedule_all(phy3->mt76); in mt7996_mac_restart()
1752 mt76_worker_disable(&dev->mt76.tx_worker); in mt7996_mac_restart()
1754 if (mtk_wed_device_active(&dev->mt76.mmio.wed) && in mt7996_mac_restart()
1755 mt76_queue_is_wed_rro(&mdev->q_rx[i])) in mt7996_mac_restart()
1758 if (mdev->q_rx[i].ndesc) in mt7996_mac_restart()
1759 napi_disable(&dev->mt76.napi[i]); in mt7996_mac_restart()
1761 napi_disable(&dev->mt76.tx_napi); in mt7996_mac_restart()
1765 idr_init(&dev->mt76.token); in mt7996_mac_restart()
1770 if (mtk_wed_device_active(&dev->mt76.mmio.wed) && in mt7996_mac_restart()
1771 mt76_queue_is_wed_rro(&mdev->q_rx[i])) in mt7996_mac_restart()
1774 if (mdev->q_rx[i].ndesc) { in mt7996_mac_restart()
1775 napi_enable(&dev->mt76.napi[i]); in mt7996_mac_restart()
1777 napi_schedule(&dev->mt76.napi[i]); in mt7996_mac_restart()
1781 clear_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7996_mac_restart()
1782 clear_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); in mt7996_mac_restart()
1784 mt76_wr(dev, MT_INT_MASK_CSR, dev->mt76.mmio.irqmask); in mt7996_mac_restart()
1786 if (dev->hif2) { in mt7996_mac_restart()
1787 mt76_wr(dev, MT_INT1_MASK_CSR, dev->mt76.mmio.irqmask); in mt7996_mac_restart()
1790 if (dev_is_pci(mdev->dev)) { in mt7996_mac_restart()
1792 if (dev->hif2) in mt7996_mac_restart()
1807 mt7996_init_txpower(&dev->phy); in mt7996_mac_restart()
1812 if (test_bit(MT76_STATE_RUNNING, &dev->mphy.state)) { in mt7996_mac_restart()
1813 ret = mt7996_run(&dev->phy); in mt7996_mac_restart()
1818 if (phy2 && test_bit(MT76_STATE_RUNNING, &phy2->mt76->state)) { in mt7996_mac_restart()
1824 if (phy3 && test_bit(MT76_STATE_RUNNING, &phy3->mt76->state)) { in mt7996_mac_restart()
1831 /* reset done */ in mt7996_mac_restart()
1832 clear_bit(MT76_RESET, &dev->mphy.state); in mt7996_mac_restart()
1834 clear_bit(MT76_RESET, &phy2->mt76->state); in mt7996_mac_restart()
1836 clear_bit(MT76_RESET, &phy3->mt76->state); in mt7996_mac_restart()
1838 napi_enable(&dev->mt76.tx_napi); in mt7996_mac_restart()
1840 napi_schedule(&dev->mt76.tx_napi); in mt7996_mac_restart()
1843 mt76_worker_enable(&dev->mt76.tx_worker); in mt7996_mac_restart()
1855 dev->recovery.hw_full_reset = true; in mt7996_mac_full_reset()
1857 wake_up(&dev->mt76.mcu.wait); in mt7996_mac_full_reset()
1860 ieee80211_stop_queues(phy2->mt76->hw); in mt7996_mac_full_reset()
1862 ieee80211_stop_queues(phy3->mt76->hw); in mt7996_mac_full_reset()
1864 cancel_work_sync(&dev->wed_rro.work); in mt7996_mac_full_reset()
1865 cancel_delayed_work_sync(&dev->mphy.mac_work); in mt7996_mac_full_reset()
1867 cancel_delayed_work_sync(&phy2->mt76->mac_work); in mt7996_mac_full_reset()
1869 cancel_delayed_work_sync(&phy3->mt76->mac_work); in mt7996_mac_full_reset()
1871 mutex_lock(&dev->mt76.mutex); in mt7996_mac_full_reset()
1876 mutex_unlock(&dev->mt76.mutex); in mt7996_mac_full_reset()
1879 dev_err(dev->mt76.dev, "chip full reset failed\n"); in mt7996_mac_full_reset()
1883 ieee80211_restart_hw(phy2->mt76->hw); in mt7996_mac_full_reset()
1885 ieee80211_restart_hw(phy3->mt76->hw); in mt7996_mac_full_reset()
1889 ieee80211_wake_queues(phy2->mt76->hw); in mt7996_mac_full_reset()
1891 ieee80211_wake_queues(phy3->mt76->hw); in mt7996_mac_full_reset()
1893 dev->recovery.hw_full_reset = false; in mt7996_mac_full_reset()
1895 &dev->mphy.mac_work, in mt7996_mac_full_reset()
1898 ieee80211_queue_delayed_work(phy2->mt76->hw, in mt7996_mac_full_reset()
1899 &phy2->mt76->mac_work, in mt7996_mac_full_reset()
1902 ieee80211_queue_delayed_work(phy3->mt76->hw, in mt7996_mac_full_reset()
1903 &phy3->mt76->mac_work, in mt7996_mac_full_reset()
1917 /* chip full reset */ in mt7996_mac_reset_work()
1918 if (dev->recovery.restart) { in mt7996_mac_reset_work()
1923 if (READ_ONCE(dev->recovery.state) & MT_MCU_CMD_WA_WDT) in mt7996_mac_reset_work()
1924 dev->recovery.wa_reset_count++; in mt7996_mac_reset_work()
1926 dev->recovery.wm_reset_count++; in mt7996_mac_reset_work()
1937 dev->recovery.state = MT_MCU_CMD_NORMAL_STATE; in mt7996_mac_reset_work()
1938 dev->recovery.restart = false; in mt7996_mac_reset_work()
1942 if (!(READ_ONCE(dev->recovery.state) & MT_MCU_CMD_STOP_DMA)) in mt7996_mac_reset_work()
1945 dev_info(dev->mt76.dev,"\n%s L1 SER recovery start.", in mt7996_mac_reset_work()
1946 wiphy_name(dev->mt76.hw->wiphy)); in mt7996_mac_reset_work()
1948 if (mtk_wed_device_active(&dev->mt76.mmio.wed_hif2)) in mt7996_mac_reset_work()
1949 mtk_wed_device_stop(&dev->mt76.mmio.wed_hif2); in mt7996_mac_reset_work()
1951 if (mtk_wed_device_active(&dev->mt76.mmio.wed)) in mt7996_mac_reset_work()
1952 mtk_wed_device_stop(&dev->mt76.mmio.wed); in mt7996_mac_reset_work()
1956 ieee80211_stop_queues(phy2->mt76->hw); in mt7996_mac_reset_work()
1958 ieee80211_stop_queues(phy3->mt76->hw); in mt7996_mac_reset_work()
1960 set_bit(MT76_RESET, &dev->mphy.state); in mt7996_mac_reset_work()
1961 set_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7996_mac_reset_work()
1962 wake_up(&dev->mt76.mcu.wait); in mt7996_mac_reset_work()
1964 cancel_work_sync(&dev->wed_rro.work); in mt7996_mac_reset_work()
1965 cancel_delayed_work_sync(&dev->mphy.mac_work); in mt7996_mac_reset_work()
1967 set_bit(MT76_RESET, &phy2->mt76->state); in mt7996_mac_reset_work()
1968 cancel_delayed_work_sync(&phy2->mt76->mac_work); in mt7996_mac_reset_work()
1971 set_bit(MT76_RESET, &phy3->mt76->state); in mt7996_mac_reset_work()
1972 cancel_delayed_work_sync(&phy3->mt76->mac_work); in mt7996_mac_reset_work()
1974 mt76_worker_disable(&dev->mt76.tx_worker); in mt7996_mac_reset_work()
1975 mt76_for_each_q_rx(&dev->mt76, i) { in mt7996_mac_reset_work()
1976 if (mtk_wed_device_active(&dev->mt76.mmio.wed) && in mt7996_mac_reset_work()
1977 mt76_queue_is_wed_rro(&dev->mt76.q_rx[i])) in mt7996_mac_reset_work()
1980 napi_disable(&dev->mt76.napi[i]); in mt7996_mac_reset_work()
1982 napi_disable(&dev->mt76.tx_napi); in mt7996_mac_reset_work()
1984 mutex_lock(&dev->mt76.mutex); in mt7996_mac_reset_work()
1992 idr_init(&dev->mt76.token); in mt7996_mac_reset_work()
2004 if (mtk_wed_device_active(&dev->mt76.mmio.wed)) { in mt7996_mac_reset_work()
2006 dev->mt76.mmio.irqmask; in mt7996_mac_reset_work()
2008 if (mtk_wed_get_rx_capa(&dev->mt76.mmio.wed)) in mt7996_mac_reset_work()
2013 mtk_wed_device_start_hw_rro(&dev->mt76.mmio.wed, wed_irq_mask, in mt7996_mac_reset_work()
2019 if (mtk_wed_device_active(&dev->mt76.mmio.wed_hif2)) { in mt7996_mac_reset_work()
2021 mtk_wed_device_start(&dev->mt76.mmio.wed_hif2, in mt7996_mac_reset_work()
2025 clear_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7996_mac_reset_work()
2026 clear_bit(MT76_RESET, &dev->mphy.state); in mt7996_mac_reset_work()
2028 clear_bit(MT76_RESET, &phy2->mt76->state); in mt7996_mac_reset_work()
2030 clear_bit(MT76_RESET, &phy3->mt76->state); in mt7996_mac_reset_work()
2032 mt76_for_each_q_rx(&dev->mt76, i) { in mt7996_mac_reset_work()
2033 if (mtk_wed_device_active(&dev->mt76.mmio.wed) && in mt7996_mac_reset_work()
2034 mt76_queue_is_wed_rro(&dev->mt76.q_rx[i])) in mt7996_mac_reset_work()
2037 napi_enable(&dev->mt76.napi[i]); in mt7996_mac_reset_work()
2039 napi_schedule(&dev->mt76.napi[i]); in mt7996_mac_reset_work()
2043 tasklet_schedule(&dev->mt76.irq_tasklet); in mt7996_mac_reset_work()
2045 mt76_worker_enable(&dev->mt76.tx_worker); in mt7996_mac_reset_work()
2047 napi_enable(&dev->mt76.tx_napi); in mt7996_mac_reset_work()
2049 napi_schedule(&dev->mt76.tx_napi); in mt7996_mac_reset_work()
2054 ieee80211_wake_queues(phy2->mt76->hw); in mt7996_mac_reset_work()
2056 ieee80211_wake_queues(phy3->mt76->hw); in mt7996_mac_reset_work()
2058 mutex_unlock(&dev->mt76.mutex); in mt7996_mac_reset_work()
2062 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mphy.mac_work, in mt7996_mac_reset_work()
2065 ieee80211_queue_delayed_work(phy2->mt76->hw, in mt7996_mac_reset_work()
2066 &phy2->mt76->mac_work, in mt7996_mac_reset_work()
2069 ieee80211_queue_delayed_work(phy3->mt76->hw, in mt7996_mac_reset_work()
2070 &phy3->mt76->mac_work, in mt7996_mac_reset_work()
2072 dev_info(dev->mt76.dev,"\n%s L1 SER recovery completed.", in mt7996_mac_reset_work()
2073 wiphy_name(dev->mt76.hw->wiphy)); in mt7996_mac_reset_work()
2090 mutex_lock(&dev->dump_mutex); in mt7996_mac_dump_work()
2094 mutex_unlock(&dev->dump_mutex); in mt7996_mac_dump_work()
2099 if (!mem_region || !crash_data->memdump_buf_len) { in mt7996_mac_dump_work()
2100 mutex_unlock(&dev->dump_mutex); in mt7996_mac_dump_work()
2104 buf = crash_data->memdump_buf; in mt7996_mac_dump_work()
2105 buf_len = crash_data->memdump_buf_len; in mt7996_mac_dump_work()
2110 if (mem_region->len > buf_len) { in mt7996_mac_dump_work()
2111 dev_warn(dev->mt76.dev, "%s len %zu is too large\n", in mt7996_mac_dump_work()
2112 mem_region->name, mem_region->len); in mt7996_mac_dump_work()
2119 buf_len -= sizeof(*hdr); in mt7996_mac_dump_work()
2121 mt7996_memcpy_fromio(dev, buf, mem_region->start, in mt7996_mac_dump_work()
2122 mem_region->len); in mt7996_mac_dump_work()
2124 hdr->start = mem_region->start; in mt7996_mac_dump_work()
2125 hdr->len = mem_region->len; in mt7996_mac_dump_work()
2127 if (!mem_region->len) in mt7996_mac_dump_work()
2131 buf += mem_region->len; in mt7996_mac_dump_work()
2132 buf_len -= mem_region->len; in mt7996_mac_dump_work()
2137 mutex_unlock(&dev->dump_mutex); in mt7996_mac_dump_work()
2142 queue_work(dev->mt76.wq, &dev->reset_work); in mt7996_mac_dump_work()
2147 if (!dev->recovery.hw_init_done) in mt7996_reset()
2150 if (dev->recovery.hw_full_reset) in mt7996_reset()
2154 if (READ_ONCE(dev->recovery.state) & MT_MCU_CMD_WDT_MASK) { in mt7996_reset()
2155 dev->recovery.restart = true; in mt7996_reset()
2156 dev_info(dev->mt76.dev, in mt7996_reset()
2158 wiphy_name(dev->mt76.hw->wiphy)); in mt7996_reset()
2161 queue_work(dev->mt76.wq, &dev->dump_work); in mt7996_reset()
2165 queue_work(dev->mt76.wq, &dev->reset_work); in mt7996_reset()
2166 wake_up(&dev->reset_wait); in mt7996_reset()
2169 void mt7996_mac_update_stats(struct mt7996_phy *phy) in mt7996_mac_update_stats() argument
2171 struct mt76_mib_stats *mib = &phy->mib; in mt7996_mac_update_stats()
2172 struct mt7996_dev *dev = phy->dev; in mt7996_mac_update_stats()
2173 u8 band_idx = phy->mt76->band_idx; in mt7996_mac_update_stats()
2178 mib->fcs_err_cnt += cnt; in mt7996_mac_update_stats()
2181 mib->rx_fifo_full_cnt += cnt; in mt7996_mac_update_stats()
2184 mib->rx_mpdu_cnt += cnt; in mt7996_mac_update_stats()
2187 mib->channel_idle_cnt += FIELD_GET(MT_MIB_SDR6_CHANNEL_IDL_CNT_MASK, cnt); in mt7996_mac_update_stats()
2190 mib->rx_vector_mismatch_cnt += cnt; in mt7996_mac_update_stats()
2193 mib->rx_delimiter_fail_cnt += cnt; in mt7996_mac_update_stats()
2196 mib->rx_len_mismatch_cnt += cnt; in mt7996_mac_update_stats()
2199 mib->tx_ampdu_cnt += cnt; in mt7996_mac_update_stats()
2202 mib->tx_stop_q_empty_cnt += cnt; in mt7996_mac_update_stats()
2205 mib->tx_mpdu_attempts_cnt += cnt; in mt7996_mac_update_stats()
2208 mib->tx_mpdu_success_cnt += cnt; in mt7996_mac_update_stats()
2211 mib->rx_ampdu_cnt += cnt; in mt7996_mac_update_stats()
2214 mib->rx_ampdu_bytes_cnt += cnt; in mt7996_mac_update_stats()
2217 mib->rx_ampdu_valid_subframe_cnt += cnt; in mt7996_mac_update_stats()
2220 mib->rx_ampdu_valid_subframe_bytes_cnt += cnt; in mt7996_mac_update_stats()
2223 mib->tx_rwp_fail_cnt += FIELD_GET(MT_MIB_SDR27_TX_RWP_FAIL_CNT, cnt); in mt7996_mac_update_stats()
2226 mib->tx_rwp_need_cnt += FIELD_GET(MT_MIB_SDR28_TX_RWP_NEED_CNT, cnt); in mt7996_mac_update_stats()
2229 mib->rx_pfdrop_cnt += cnt; in mt7996_mac_update_stats()
2232 mib->rx_vec_queue_overflow_drop_cnt += cnt; in mt7996_mac_update_stats()
2235 mib->rx_ba_cnt += cnt; in mt7996_mac_update_stats()
2238 mib->tx_bf_ebf_ppdu_cnt += cnt; in mt7996_mac_update_stats()
2241 mib->tx_bf_ibf_ppdu_cnt += cnt; in mt7996_mac_update_stats()
2244 mib->tx_mu_bf_cnt += cnt; in mt7996_mac_update_stats()
2247 mib->tx_mu_mpdu_cnt += cnt; in mt7996_mac_update_stats()
2250 mib->tx_mu_acked_mpdu_cnt += cnt; in mt7996_mac_update_stats()
2253 mib->tx_su_acked_mpdu_cnt += cnt; in mt7996_mac_update_stats()
2256 mib->tx_bf_rx_fb_ht_cnt += cnt; in mt7996_mac_update_stats()
2257 mib->tx_bf_rx_fb_all_cnt += cnt; in mt7996_mac_update_stats()
2260 mib->tx_bf_rx_fb_vht_cnt += cnt; in mt7996_mac_update_stats()
2261 mib->tx_bf_rx_fb_all_cnt += cnt; in mt7996_mac_update_stats()
2264 mib->tx_bf_rx_fb_he_cnt += cnt; in mt7996_mac_update_stats()
2265 mib->tx_bf_rx_fb_all_cnt += cnt; in mt7996_mac_update_stats()
2268 mib->tx_bf_rx_fb_eht_cnt += cnt; in mt7996_mac_update_stats()
2269 mib->tx_bf_rx_fb_all_cnt += cnt; in mt7996_mac_update_stats()
2272 mib->tx_bf_rx_fb_bw = FIELD_GET(MT_ETBF_RX_FB_BW, cnt); in mt7996_mac_update_stats()
2273 mib->tx_bf_rx_fb_nc_cnt += FIELD_GET(MT_ETBF_RX_FB_NC, cnt); in mt7996_mac_update_stats()
2274 mib->tx_bf_rx_fb_nr_cnt += FIELD_GET(MT_ETBF_RX_FB_NR, cnt); in mt7996_mac_update_stats()
2277 mib->tx_bf_fb_trig_cnt += cnt; in mt7996_mac_update_stats()
2280 mib->tx_bf_fb_cpl_cnt += cnt; in mt7996_mac_update_stats()
2282 for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) { in mt7996_mac_update_stats()
2284 mib->tx_amsdu[i] += cnt; in mt7996_mac_update_stats()
2285 mib->tx_amsdu_cnt += cnt; in mt7996_mac_update_stats()
2290 mib->rts_cnt += cnt; in mt7996_mac_update_stats()
2294 mib->rts_retries_cnt += cnt; in mt7996_mac_update_stats()
2298 mib->ba_miss_cnt += cnt; in mt7996_mac_update_stats()
2302 mib->ack_fail_cnt += cnt; in mt7996_mac_update_stats()
2306 phy->mt76->aggr_stats[i] += cnt; in mt7996_mac_update_stats()
2327 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_rc_work()
2328 list_splice_init(&dev->sta_rc_list, &list); in mt7996_mac_sta_rc_work()
2333 list_del_init(&msta_link->rc_list); in mt7996_mac_sta_rc_work()
2335 changed = msta_link->changed; in mt7996_mac_sta_rc_work()
2336 msta_link->changed = 0; in mt7996_mac_sta_rc_work()
2338 sta = wcid_to_sta(&msta_link->wcid); in mt7996_mac_sta_rc_work()
2339 link_id = msta_link->wcid.link_id; in mt7996_mac_sta_rc_work()
2340 msta = msta_link->sta; in mt7996_mac_sta_rc_work()
2341 mvif = msta->vif; in mt7996_mac_sta_rc_work()
2344 mlink = rcu_dereference(mvif->mt76.link[link_id]); in mt7996_mac_sta_rc_work()
2348 link_sta = rcu_dereference(sta->link[link_id]); in mt7996_mac_sta_rc_work()
2352 link_conf = rcu_dereference(vif->link_conf[link_id]); in mt7996_mac_sta_rc_work()
2356 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_rc_work()
2372 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_rc_work()
2375 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7996_mac_sta_rc_work()
2381 struct mt7996_phy *phy; in mt7996_mac_work() local
2386 phy = mphy->priv; in mt7996_mac_work()
2388 mutex_lock(&mphy->dev->mutex); in mt7996_mac_work()
2391 if (++mphy->mac_work_count == 5) { in mt7996_mac_work()
2392 mphy->mac_work_count = 0; in mt7996_mac_work()
2394 mt7996_mac_update_stats(phy); in mt7996_mac_work()
2396 mt7996_mcu_get_all_sta_info(phy, UNI_ALL_STA_TXRX_RATE); in mt7996_mac_work()
2397 if (mtk_wed_device_active(&phy->dev->mt76.mmio.wed)) { in mt7996_mac_work()
2398 mt7996_mcu_get_all_sta_info(phy, UNI_ALL_STA_TXRX_ADM_STAT); in mt7996_mac_work()
2399 mt7996_mcu_get_all_sta_info(phy, UNI_ALL_STA_TXRX_MSDU_COUNT); in mt7996_mac_work()
2403 mutex_unlock(&mphy->dev->mutex); in mt7996_mac_work()
2405 mt76_tx_status_check(mphy->dev, false); in mt7996_mac_work()
2407 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, in mt7996_mac_work()
2411 static void mt7996_dfs_stop_radar_detector(struct mt7996_phy *phy) in mt7996_dfs_stop_radar_detector() argument
2413 struct mt7996_dev *dev = phy->dev; in mt7996_dfs_stop_radar_detector()
2415 if (phy->rdd_state & BIT(0)) in mt7996_dfs_stop_radar_detector()
2418 if (phy->rdd_state & BIT(1)) in mt7996_dfs_stop_radar_detector()
2427 switch (dev->mt76.region) { in mt7996_dfs_start_rdd()
2449 static int mt7996_dfs_start_radar_detector(struct mt7996_phy *phy) in mt7996_dfs_start_radar_detector() argument
2451 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7996_dfs_start_radar_detector()
2452 struct mt7996_dev *dev = phy->dev; in mt7996_dfs_start_radar_detector()
2453 u8 band_idx = phy->mt76->band_idx; in mt7996_dfs_start_radar_detector()
2466 phy->rdd_state |= BIT(band_idx); in mt7996_dfs_start_radar_detector()
2468 if (chandef->width == NL80211_CHAN_WIDTH_160 || in mt7996_dfs_start_radar_detector()
2469 chandef->width == NL80211_CHAN_WIDTH_80P80) { in mt7996_dfs_start_radar_detector()
2474 phy->rdd_state |= BIT(1); in mt7996_dfs_start_radar_detector()
2481 mt7996_dfs_init_radar_specs(struct mt7996_phy *phy) in mt7996_dfs_init_radar_specs() argument
2484 struct mt7996_dev *dev = phy->dev; in mt7996_dfs_init_radar_specs()
2487 switch (dev->mt76.region) { in mt7996_dfs_init_radar_specs()
2501 return -EINVAL; in mt7996_dfs_init_radar_specs()
2504 for (i = 0; i < ARRAY_SIZE(radar_specs->radar_pattern); i++) { in mt7996_dfs_init_radar_specs()
2506 &radar_specs->radar_pattern[i]); in mt7996_dfs_init_radar_specs()
2511 return mt7996_mcu_set_pulse_th(dev, &radar_specs->pulse_th); in mt7996_dfs_init_radar_specs()
2514 int mt7996_dfs_init_radar_detector(struct mt7996_phy *phy) in mt7996_dfs_init_radar_detector() argument
2516 struct mt7996_dev *dev = phy->dev; in mt7996_dfs_init_radar_detector()
2520 prev_state = phy->mt76->dfs_state; in mt7996_dfs_init_radar_detector()
2521 dfs_state = mt76_phy_dfs_state(phy->mt76); in mt7996_dfs_init_radar_detector()
2527 mt7996_dfs_stop_radar_detector(phy); in mt7996_dfs_init_radar_detector()
2533 err = mt7996_dfs_init_radar_specs(phy); in mt7996_dfs_init_radar_detector()
2537 err = mt7996_dfs_start_radar_detector(phy); in mt7996_dfs_init_radar_detector()
2541 phy->mt76->dfs_state = MT_DFS_STATE_CAC; in mt7996_dfs_init_radar_detector()
2548 phy->mt76->band_idx, MT_RX_SEL0, 0); in mt7996_dfs_init_radar_detector()
2550 phy->mt76->dfs_state = MT_DFS_STATE_UNKNOWN; in mt7996_dfs_init_radar_detector()
2554 phy->mt76->dfs_state = MT_DFS_STATE_ACTIVE; in mt7996_dfs_init_radar_detector()
2559 phy->mt76->band_idx, MT_RX_SEL0, 0); in mt7996_dfs_init_radar_detector()
2563 mt7996_dfs_stop_radar_detector(phy); in mt7996_dfs_init_radar_detector()
2564 phy->mt76->dfs_state = MT_DFS_STATE_DISABLED; in mt7996_dfs_init_radar_detector()
2570 mt7996_mac_twt_duration_align(int duration) in mt7996_mac_twt_duration_align() argument
2572 return duration << 8; in mt7996_mac_twt_duration_align()
2580 u32 duration = flow->duration << 8; in mt7996_mac_twt_sched_list_add() local
2583 iter = list_first_entry_or_null(&dev->twt_list, in mt7996_mac_twt_sched_list_add()
2585 if (!iter || !iter->sched || iter->start_tsf > duration) { in mt7996_mac_twt_sched_list_add()
2587 list_add(&flow->list, &dev->twt_list); in mt7996_mac_twt_sched_list_add()
2591 list_for_each_entry_safe(iter, iter_next, &dev->twt_list, list) { in mt7996_mac_twt_sched_list_add()
2592 start_tsf = iter->start_tsf + in mt7996_mac_twt_sched_list_add()
2593 mt7996_mac_twt_duration_align(iter->duration); in mt7996_mac_twt_sched_list_add()
2594 if (list_is_last(&iter->list, &dev->twt_list)) in mt7996_mac_twt_sched_list_add()
2597 if (!iter_next->sched || in mt7996_mac_twt_sched_list_add()
2598 iter_next->start_tsf > start_tsf + duration) { in mt7996_mac_twt_sched_list_add()
2599 list_add(&flow->list, &iter->list); in mt7996_mac_twt_sched_list_add()
2605 list_add_tail(&flow->list, &dev->twt_list); in mt7996_mac_twt_sched_list_add()
2613 u64 interval, duration; in mt7996_mac_check_twt_req() local
2618 if (twt->control & IEEE80211_TWT_CONTROL_NEG_TYPE_BROADCAST) in mt7996_mac_check_twt_req()
2619 return -EOPNOTSUPP; in mt7996_mac_check_twt_req()
2622 if (twt->control & IEEE80211_TWT_CONTROL_WAKE_DUR_UNIT) in mt7996_mac_check_twt_req()
2623 return -EOPNOTSUPP; in mt7996_mac_check_twt_req()
2625 twt_agrt = (struct ieee80211_twt_params *)twt->params; in mt7996_mac_check_twt_req()
2628 if (!(twt_agrt->req_type & cpu_to_le16(IEEE80211_TWT_REQTYPE_IMPLICIT))) in mt7996_mac_check_twt_req()
2629 return -EOPNOTSUPP; in mt7996_mac_check_twt_req()
2632 le16_to_cpu(twt_agrt->req_type)); in mt7996_mac_check_twt_req()
2633 mantissa = le16_to_cpu(twt_agrt->mantissa); in mt7996_mac_check_twt_req()
2634 duration = twt_agrt->min_twt_dur << 8; in mt7996_mac_check_twt_req()
2637 if (interval < duration) in mt7996_mac_check_twt_req()
2638 return -EOPNOTSUPP; in mt7996_mac_check_twt_req()
2647 u16 type = le16_to_cpu(twt_agrt->req_type); in mt7996_mac_twt_param_equal()
2655 if (!(msta_link->twt.flowid_mask & BIT(i))) in mt7996_mac_twt_param_equal()
2658 f = &msta_link->twt.flow[i]; in mt7996_mac_twt_param_equal()
2659 if (f->duration == twt_agrt->min_twt_dur && in mt7996_mac_twt_param_equal()
2660 f->mantissa == twt_agrt->mantissa && in mt7996_mac_twt_param_equal()
2661 f->exp == exp && in mt7996_mac_twt_param_equal()
2662 f->protection == !!(type & IEEE80211_TWT_REQTYPE_PROTECTION) && in mt7996_mac_twt_param_equal()
2663 f->flowtype == !!(type & IEEE80211_TWT_REQTYPE_FLOWTYPE) && in mt7996_mac_twt_param_equal()
2664 f->trigger == !!(type & IEEE80211_TWT_REQTYPE_TRIGGER)) in mt7996_mac_twt_param_equal()
2676 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; in mt7996_mac_add_twt_setup()
2677 struct ieee80211_twt_params *twt_agrt = (void *)twt->params; in mt7996_mac_add_twt_setup()
2678 struct mt7996_sta_link *msta_link = &msta->deflink; in mt7996_mac_add_twt_setup()
2679 u16 req_type = le16_to_cpu(twt_agrt->req_type); in mt7996_mac_add_twt_setup()
2688 mutex_lock(&dev->mt76.mutex); in mt7996_mac_add_twt_setup()
2690 if (dev->twt.n_agrt == MT7996_MAX_TWT_AGRT) in mt7996_mac_add_twt_setup()
2693 if (hweight8(msta_link->twt.flowid_mask) == in mt7996_mac_add_twt_setup()
2694 ARRAY_SIZE(msta_link->twt.flow)) in mt7996_mac_add_twt_setup()
2697 if (twt_agrt->min_twt_dur < MT7996_MIN_TWT_DUR) { in mt7996_mac_add_twt_setup()
2699 twt_agrt->min_twt_dur = MT7996_MIN_TWT_DUR; in mt7996_mac_add_twt_setup()
2706 flowid = ffs(~msta_link->twt.flowid_mask) - 1; in mt7996_mac_add_twt_setup()
2707 twt_agrt->req_type &= ~cpu_to_le16(IEEE80211_TWT_REQTYPE_FLOWID); in mt7996_mac_add_twt_setup()
2708 twt_agrt->req_type |= le16_encode_bits(flowid, in mt7996_mac_add_twt_setup()
2711 table_id = ffs(~dev->twt.table_mask) - 1; in mt7996_mac_add_twt_setup()
2715 flow = &msta_link->twt.flow[flowid]; in mt7996_mac_add_twt_setup()
2717 INIT_LIST_HEAD(&flow->list); in mt7996_mac_add_twt_setup()
2718 flow->wcid = msta_link->wcid.idx; in mt7996_mac_add_twt_setup()
2719 flow->table_id = table_id; in mt7996_mac_add_twt_setup()
2720 flow->id = flowid; in mt7996_mac_add_twt_setup()
2721 flow->duration = twt_agrt->min_twt_dur; in mt7996_mac_add_twt_setup()
2722 flow->mantissa = twt_agrt->mantissa; in mt7996_mac_add_twt_setup()
2723 flow->exp = exp; in mt7996_mac_add_twt_setup()
2724 flow->protection = !!(req_type & IEEE80211_TWT_REQTYPE_PROTECTION); in mt7996_mac_add_twt_setup()
2725 flow->flowtype = !!(req_type & IEEE80211_TWT_REQTYPE_FLOWTYPE); in mt7996_mac_add_twt_setup()
2726 flow->trigger = !!(req_type & IEEE80211_TWT_REQTYPE_TRIGGER); in mt7996_mac_add_twt_setup()
2730 u64 interval = (u64)le16_to_cpu(twt_agrt->mantissa) << exp; in mt7996_mac_add_twt_setup()
2734 flow->sched = true; in mt7996_mac_add_twt_setup()
2735 flow->start_tsf = mt7996_mac_twt_sched_list_add(dev, flow); in mt7996_mac_add_twt_setup()
2736 curr_tsf = __mt7996_get_tsf(hw, &msta->vif->deflink); in mt7996_mac_add_twt_setup()
2737 div_u64_rem(curr_tsf - flow->start_tsf, interval, &rem); in mt7996_mac_add_twt_setup()
2738 flow_tsf = curr_tsf + interval - rem; in mt7996_mac_add_twt_setup()
2739 twt_agrt->twt = cpu_to_le64(flow_tsf); in mt7996_mac_add_twt_setup()
2741 list_add_tail(&flow->list, &dev->twt_list); in mt7996_mac_add_twt_setup()
2743 flow->tsf = le64_to_cpu(twt_agrt->twt); in mt7996_mac_add_twt_setup()
2745 if (mt7996_mcu_twt_agrt_update(dev, &msta->vif->deflink, flow, in mt7996_mac_add_twt_setup()
2750 dev->twt.table_mask |= BIT(table_id); in mt7996_mac_add_twt_setup()
2751 msta_link->twt.flowid_mask |= BIT(flowid); in mt7996_mac_add_twt_setup()
2752 dev->twt.n_agrt++; in mt7996_mac_add_twt_setup()
2755 mutex_unlock(&dev->mt76.mutex); in mt7996_mac_add_twt_setup()
2757 twt_agrt->req_type &= ~cpu_to_le16(IEEE80211_TWT_REQTYPE_SETUP_CMD); in mt7996_mac_add_twt_setup()
2758 twt_agrt->req_type |= in mt7996_mac_add_twt_setup()
2760 twt->control = twt->control & IEEE80211_TWT_CONTROL_RX_DISABLED; in mt7996_mac_add_twt_setup()
2770 lockdep_assert_held(&dev->mt76.mutex); in mt7996_mac_twt_teardown_flow()
2772 if (flowid >= ARRAY_SIZE(msta_link->twt.flow)) in mt7996_mac_twt_teardown_flow()
2775 if (!(msta_link->twt.flowid_mask & BIT(flowid))) in mt7996_mac_twt_teardown_flow()
2778 flow = &msta_link->twt.flow[flowid]; in mt7996_mac_twt_teardown_flow()
2782 list_del_init(&flow->list); in mt7996_mac_twt_teardown_flow()
2783 msta_link->twt.flowid_mask &= ~BIT(flowid); in mt7996_mac_twt_teardown_flow()
2784 dev->twt.table_mask &= ~BIT(flow->table_id); in mt7996_mac_twt_teardown_flow()
2785 dev->twt.n_agrt--; in mt7996_mac_twt_teardown_flow()