Lines Matching +full:data +full:- +full:rates

1 // SPDX-License-Identifier: ISC
20 #define to_rssi(field, rxv) ((FIELD_GET(field, rxv) - 220) / 2)
23 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
37 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
48 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
96 wcid = rcu_dereference(dev->mt76.wcid[idx]); in mt7615_rx_get_wcid()
100 if (!wcid->sta) in mt7615_rx_get_wcid()
104 if (!sta->vif) in mt7615_rx_get_wcid()
107 return &sta->vif->sta.wcid; in mt7615_rx_get_wcid()
112 struct mt7615_dev *dev = phy->dev; in mt7615_mac_reset_counters()
120 memset(phy->mt76->aggr_stats, 0, sizeof(phy->mt76->aggr_stats)); in mt7615_mac_reset_counters()
121 phy->mt76->survey_time = ktime_get_boottime(); in mt7615_mac_reset_counters()
139 s16 coverage_class = phy->coverage_class; in mt7615_mac_set_timing()
140 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_timing()
141 bool ext_phy = phy != &dev->phy; in mt7615_mac_set_timing()
148 bool is_5ghz = phy->mt76->chandef.chan->band == NL80211_BAND_5GHZ; in mt7615_mac_set_timing()
150 if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state)) in mt7615_mac_set_timing()
159 coverage_class = max_t(s16, dev->phy.coverage_class, in mt7615_mac_set_timing()
167 coverage_class = max_t(s16, phy_ext->coverage_class, in mt7615_mac_set_timing()
184 FIELD_PREP(MT_IFS_SLOT, phy->slottime)); in mt7615_mac_set_timing()
186 if (phy->slottime < 20 || is_5ghz) in mt7615_mac_set_timing()
205 if (!test_bit(MT76_HW_SCANNING, &mphy->state) && in mt7615_get_status_freq_info()
206 !test_bit(MT76_HW_SCHED_SCANNING, &mphy->state) && in mt7615_get_status_freq_info()
207 !test_bit(MT76_STATE_ROC, &mphy->state)) { in mt7615_get_status_freq_info()
208 status->freq = mphy->chandef.chan->center_freq; in mt7615_get_status_freq_info()
209 status->band = mphy->chandef.chan->band; in mt7615_get_status_freq_info()
213 status->band = chfreq <= 14 ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ; in mt7615_get_status_freq_info()
214 status->freq = ieee80211_channel_to_frequency(chfreq, status->band); in mt7615_get_status_freq_info()
236 foe -= 4096; in mt7615_mac_fill_tm_rx()
241 phy->test.last_freq_offset = foe; in mt7615_mac_fill_tm_rx()
242 phy->test.last_rcpi[0] = FIELD_GET(MT_RXV4_RCPI0, rxv4); in mt7615_mac_fill_tm_rx()
243 phy->test.last_rcpi[1] = FIELD_GET(MT_RXV4_RCPI1, rxv4); in mt7615_mac_fill_tm_rx()
244 phy->test.last_rcpi[2] = FIELD_GET(MT_RXV4_RCPI2, rxv4); in mt7615_mac_fill_tm_rx()
245 phy->test.last_rcpi[3] = FIELD_GET(MT_RXV4_RCPI3, rxv4); in mt7615_mac_fill_tm_rx()
246 phy->test.last_ib_rssi[0] = FIELD_GET(MT_RXV3_IB_RSSI, rxv3); in mt7615_mac_fill_tm_rx()
247 phy->test.last_wb_rssi[0] = FIELD_GET(MT_RXV3_WB_RSSI, rxv3); in mt7615_mac_fill_tm_rx()
254 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt7615_reverse_frag0_hdr_trans()
255 struct ethhdr *eth_hdr = (struct ethhdr *)(skb->data + hdr_gap); in mt7615_reverse_frag0_hdr_trans()
256 struct mt7615_sta *msta = (struct mt7615_sta *)status->wcid; in mt7615_reverse_frag0_hdr_trans()
257 __le32 *rxd = (__le32 *)skb->data; in mt7615_reverse_frag0_hdr_trans()
265 return -EINVAL; in mt7615_reverse_frag0_hdr_trans()
268 return -EINVAL; in mt7615_reverse_frag0_hdr_trans()
270 if (!msta || !msta->vif) in mt7615_reverse_frag0_hdr_trans()
271 return -EINVAL; in mt7615_reverse_frag0_hdr_trans()
274 vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv); in mt7615_reverse_frag0_hdr_trans()
282 ether_addr_copy(hdr.addr1, vif->addr); in mt7615_reverse_frag0_hdr_trans()
283 ether_addr_copy(hdr.addr2, sta->addr); in mt7615_reverse_frag0_hdr_trans()
287 ether_addr_copy(hdr.addr3, vif->bss_conf.bssid); in mt7615_reverse_frag0_hdr_trans()
290 ether_addr_copy(hdr.addr3, eth_hdr->h_source); in mt7615_reverse_frag0_hdr_trans()
293 ether_addr_copy(hdr.addr3, eth_hdr->h_dest); in mt7615_reverse_frag0_hdr_trans()
296 ether_addr_copy(hdr.addr3, eth_hdr->h_dest); in mt7615_reverse_frag0_hdr_trans()
297 ether_addr_copy(hdr.addr4, eth_hdr->h_source); in mt7615_reverse_frag0_hdr_trans()
303 skb_pull(skb, hdr_gap + sizeof(struct ethhdr) - 2); in mt7615_reverse_frag0_hdr_trans()
304 if (eth_hdr->h_proto == cpu_to_be16(ETH_P_AARP) || in mt7615_reverse_frag0_hdr_trans()
305 eth_hdr->h_proto == cpu_to_be16(ETH_P_IPX)) in mt7615_reverse_frag0_hdr_trans()
307 else if (be16_to_cpu(eth_hdr->h_proto) >= ETH_P_802_3_MIN) in mt7615_reverse_frag0_hdr_trans()
327 memcpy(skb_push(skb, sizeof(hdr) - 6), &hdr, sizeof(hdr) - 6); in mt7615_reverse_frag0_hdr_trans()
329 status->flag &= ~(RX_FLAG_RADIOTAP_HE | RX_FLAG_RADIOTAP_HE_MU); in mt7615_reverse_frag0_hdr_trans()
335 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt7615_mac_fill_rx()
336 struct mt76_phy *mphy = &dev->mt76.phy; in mt7615_mac_fill_rx()
337 struct mt7615_phy *phy = &dev->phy; in mt7615_mac_fill_rx()
341 __le32 *rxd = (__le32 *)skb->data; in mt7615_mac_fill_rx()
346 u32 csum_status = *(u32 *)skb->cb; in mt7615_mac_fill_rx()
359 phy2 = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL; in mt7615_mac_fill_rx()
362 else if (phy2->chfreq == phy->chfreq) in mt7615_mac_fill_rx()
363 phy_idx = -1; in mt7615_mac_fill_rx()
364 else if (phy->chfreq == chfreq) in mt7615_mac_fill_rx()
366 else if (phy2->chfreq == chfreq) in mt7615_mac_fill_rx()
369 phy_idx = -1; in mt7615_mac_fill_rx()
372 return -EINVAL; in mt7615_mac_fill_rx()
376 return -EINVAL; in mt7615_mac_fill_rx()
380 status->flag |= RX_FLAG_ONLY_MONITOR; in mt7615_mac_fill_rx()
384 status->wcid = mt7615_rx_get_wcid(dev, idx, unicast); in mt7615_mac_fill_rx()
386 if (status->wcid) { in mt7615_mac_fill_rx()
389 msta = container_of(status->wcid, struct mt7615_sta, wcid); in mt7615_mac_fill_rx()
390 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7615_mac_fill_rx()
391 if (list_empty(&msta->wcid.poll_list)) in mt7615_mac_fill_rx()
392 list_add_tail(&msta->wcid.poll_list, in mt7615_mac_fill_rx()
393 &dev->mt76.sta_poll_list); in mt7615_mac_fill_rx()
394 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7615_mac_fill_rx()
397 if (mt76_is_mmio(&dev->mt76) && (rxd0 & csum_mask) == csum_mask && in mt7615_mac_fill_rx()
399 skb->ip_summed = CHECKSUM_UNNECESSARY; in mt7615_mac_fill_rx()
402 status->flag |= RX_FLAG_FAILED_FCS_CRC; in mt7615_mac_fill_rx()
405 status->flag |= RX_FLAG_MMIC_ERROR; in mt7615_mac_fill_rx()
409 status->flag |= RX_FLAG_DECRYPTED; in mt7615_mac_fill_rx()
410 status->flag |= RX_FLAG_IV_STRIPPED; in mt7615_mac_fill_rx()
411 status->flag |= RX_FLAG_MMIC_STRIPPED | RX_FLAG_MIC_STRIPPED; in mt7615_mac_fill_rx()
417 return -EINVAL; in mt7615_mac_fill_rx()
429 if ((u8 *)rxd - skb->data >= skb->len) in mt7615_mac_fill_rx()
430 return -EINVAL; in mt7615_mac_fill_rx()
434 u8 *data = (u8 *)rxd; in mt7615_mac_fill_rx() local
436 if (status->flag & RX_FLAG_DECRYPTED) { in mt7615_mac_fill_rx()
448 status->iv[0] = data[5]; in mt7615_mac_fill_rx()
449 status->iv[1] = data[4]; in mt7615_mac_fill_rx()
450 status->iv[2] = data[3]; in mt7615_mac_fill_rx()
451 status->iv[3] = data[2]; in mt7615_mac_fill_rx()
452 status->iv[4] = data[1]; in mt7615_mac_fill_rx()
453 status->iv[5] = data[0]; in mt7615_mac_fill_rx()
460 if ((u8 *)rxd - skb->data >= skb->len) in mt7615_mac_fill_rx()
461 return -EINVAL; in mt7615_mac_fill_rx()
465 status->timestamp = le32_to_cpu(rxd[0]); in mt7615_mac_fill_rx()
466 status->flag |= RX_FLAG_MACTIME_START; in mt7615_mac_fill_rx()
470 status->flag |= RX_FLAG_AMPDU_DETAILS; in mt7615_mac_fill_rx()
472 /* all subframes of an A-MPDU have the same timestamp */ in mt7615_mac_fill_rx()
473 if (phy->rx_ampdu_ts != status->timestamp) { in mt7615_mac_fill_rx()
474 if (!++phy->ampdu_ref) in mt7615_mac_fill_rx()
475 phy->ampdu_ref++; in mt7615_mac_fill_rx()
477 phy->rx_ampdu_ts = status->timestamp; in mt7615_mac_fill_rx()
479 status->ampdu_ref = phy->ampdu_ref; in mt7615_mac_fill_rx()
483 if ((u8 *)rxd - skb->data >= skb->len) in mt7615_mac_fill_rx()
484 return -EINVAL; in mt7615_mac_fill_rx()
498 int first_chain = ffs(phy2->mt76->chainmask) - 1; in mt7615_mac_fill_rx()
505 mphy = dev->mt76.phys[MT_BAND1]; in mt7615_mac_fill_rx()
507 status->phy_idx = phy_idx; in mt7615_mac_fill_rx()
510 if (!mt7615_firmware_offload(dev) && chfreq != phy->chfreq) in mt7615_mac_fill_rx()
511 return -EINVAL; in mt7615_mac_fill_rx()
514 if (status->band == NL80211_BAND_5GHZ) in mt7615_mac_fill_rx()
515 sband = &mphy->sband_5g.sband; in mt7615_mac_fill_rx()
517 sband = &mphy->sband_2g.sband; in mt7615_mac_fill_rx()
519 if (!test_bit(MT76_STATE_RUNNING, &mphy->state)) in mt7615_mac_fill_rx()
520 return -EINVAL; in mt7615_mac_fill_rx()
522 if (!sband->channels) in mt7615_mac_fill_rx()
523 return -EINVAL; in mt7615_mac_fill_rx()
538 i = mt76_get_rate(&dev->mt76, sband, i, cck); in mt7615_mac_fill_rx()
542 status->encoding = RX_ENC_HT; in mt7615_mac_fill_rx()
544 return -EINVAL; in mt7615_mac_fill_rx()
547 status->nss = FIELD_GET(MT_RXV2_NSTS, rxdg1) + 1; in mt7615_mac_fill_rx()
548 status->encoding = RX_ENC_VHT; in mt7615_mac_fill_rx()
551 return -EINVAL; in mt7615_mac_fill_rx()
553 status->rate_idx = i; in mt7615_mac_fill_rx()
559 status->bw = RATE_INFO_BW_40; in mt7615_mac_fill_rx()
562 status->bw = RATE_INFO_BW_80; in mt7615_mac_fill_rx()
565 status->bw = RATE_INFO_BW_160; in mt7615_mac_fill_rx()
568 return -EINVAL; in mt7615_mac_fill_rx()
572 status->enc_flags |= RX_ENC_FLAG_SHORT_GI; in mt7615_mac_fill_rx()
574 status->enc_flags |= RX_ENC_FLAG_LDPC; in mt7615_mac_fill_rx()
576 status->enc_flags |= RX_ENC_FLAG_STBC_MASK * stbc; in mt7615_mac_fill_rx()
578 status->chains = mphy->antenna_mask; in mt7615_mac_fill_rx()
579 status->chain_signal[0] = to_rssi(MT_RXV4_RCPI0, rxdg3); in mt7615_mac_fill_rx()
580 status->chain_signal[1] = to_rssi(MT_RXV4_RCPI1, rxdg3); in mt7615_mac_fill_rx()
581 status->chain_signal[2] = to_rssi(MT_RXV4_RCPI2, rxdg3); in mt7615_mac_fill_rx()
582 status->chain_signal[3] = to_rssi(MT_RXV4_RCPI3, rxdg3); in mt7615_mac_fill_rx()
584 mt7615_mac_fill_tm_rx(mphy->priv, rxd); in mt7615_mac_fill_rx()
587 if ((u8 *)rxd - skb->data >= skb->len) in mt7615_mac_fill_rx()
588 return -EINVAL; in mt7615_mac_fill_rx()
592 status->amsdu = !!amsdu_info; in mt7615_mac_fill_rx()
593 if (status->amsdu) { in mt7615_mac_fill_rx()
594 status->first_amsdu = amsdu_info == MT_RXD1_FIRST_AMSDU_FRAME; in mt7615_mac_fill_rx()
595 status->last_amsdu = amsdu_info == MT_RXD1_LAST_AMSDU_FRAME; in mt7615_mac_fill_rx()
598 hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad; in mt7615_mac_fill_rx()
601 return -EINVAL; in mt7615_mac_fill_rx()
607 if (!hdr_trans && status->amsdu) { in mt7615_mac_fill_rx()
612 * the hardware will insert an extra 2-byte field in mt7615_mac_fill_rx()
613 * containing the data length after the protocol in mt7615_mac_fill_rx()
614 * type field. This happens either when the LLC-SNAP in mt7615_mac_fill_rx()
619 if (get_unaligned_be16(skb->data + pad_start) == ETH_P_8021Q) in mt7615_mac_fill_rx()
626 memmove(skb->data + 2, skb->data, pad_start); in mt7615_mac_fill_rx()
638 hdr = (struct ieee80211_hdr *)skb->data; in mt7615_mac_fill_rx()
639 fc = hdr->frame_control; in mt7615_mac_fill_rx()
641 seq_ctrl = le16_to_cpu(hdr->seq_ctrl); in mt7615_mac_fill_rx()
645 status->flag |= RX_FLAG_8023; in mt7615_mac_fill_rx()
648 if (!status->wcid || !ieee80211_is_data_qos(fc)) in mt7615_mac_fill_rx()
651 status->aggr = unicast && in mt7615_mac_fill_rx()
653 status->qos_ctl = qos_ctl; in mt7615_mac_fill_rx()
654 status->seqno = IEEE80211_SEQ_TO_SN(seq_ctrl); in mt7615_mac_fill_rx()
670 if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { in mt7615_mac_tx_rate_val()
674 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) in mt7615_mac_tx_rate_val()
676 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) in mt7615_mac_tx_rate_val()
678 else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) in mt7615_mac_tx_rate_val()
680 } else if (rate->flags & IEEE80211_TX_RC_MCS) { in mt7615_mac_tx_rate_val()
681 rate_idx = rate->idx; in mt7615_mac_tx_rate_val()
682 nss = 1 + (rate->idx >> 3); in mt7615_mac_tx_rate_val()
684 if (rate->flags & IEEE80211_TX_RC_GREEN_FIELD) in mt7615_mac_tx_rate_val()
686 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) in mt7615_mac_tx_rate_val()
690 int band = mphy->chandef.chan->band; in mt7615_mac_tx_rate_val()
694 r = &mphy->hw->wiphy->bands[band]->bitrates[rate->idx]; in mt7615_mac_tx_rate_val()
695 if (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) in mt7615_mac_tx_rate_val()
696 val = r->hw_value_short; in mt7615_mac_tx_rate_val()
698 val = r->hw_value; in mt7615_mac_tx_rate_val()
711 FIELD_PREP(MT_TX_RATE_NSS, nss - 1)); in mt7615_mac_tx_rate_val()
722 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in mt7615_mac_write_txwi()
725 struct ieee80211_tx_rate *rate = &info->control.rates[0]; in mt7615_mac_write_txwi()
726 u8 phy_idx = (info->hw_queue & MT_TX_HW_QUEUE_PHY) >> 2; in mt7615_mac_write_txwi()
727 bool multicast = is_multicast_ether_addr(hdr->addr1); in mt7615_mac_write_txwi()
728 struct ieee80211_vif *vif = info->control.vif; in mt7615_mac_write_txwi()
729 bool is_mmio = mt76_is_mmio(&dev->mt76); in mt7615_mac_write_txwi()
731 struct mt76_phy *mphy = &dev->mphy; in mt7615_mac_write_txwi()
732 __le16 fc = hdr->frame_control; in mt7615_mac_write_txwi()
737 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt7615_mac_write_txwi()
739 omac_idx = mvif->omac_idx; in mt7615_mac_write_txwi()
740 wmm_idx = mvif->wmm_idx; in mt7615_mac_write_txwi()
744 struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv; in mt7615_mac_write_txwi()
746 tx_count = msta->rate_count; in mt7615_mac_write_txwi()
749 if (phy_idx && dev->mt76.phys[MT_BAND1]) in mt7615_mac_write_txwi()
750 mphy = dev->mt76.phys[MT_BAND1]; in mt7615_mac_write_txwi()
767 val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len + sz_txd) | in mt7615_mac_write_txwi()
773 FIELD_PREP(MT_TXD1_WLAN_IDX, wcid->idx) | in mt7615_mac_write_txwi()
778 skb->priority & IEEE80211_QOS_CTL_TID_MASK) | in mt7615_mac_write_txwi()
788 key->cipher == WLAN_CIPHER_SUITE_AES_CMAC) { in mt7615_mac_write_txwi()
799 if (!(info->flags & IEEE80211_TX_CTL_AMPDU)) in mt7615_mac_write_txwi()
805 if (rate->idx >= 0 && rate->count && in mt7615_mac_write_txwi()
806 !(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)) { in mt7615_mac_write_txwi()
807 bool stbc = info->flags & IEEE80211_TX_CTL_STBC; in mt7615_mac_write_txwi()
819 if (rate->flags & IEEE80211_TX_RC_SHORT_GI) in mt7615_mac_write_txwi()
822 if (info->flags & IEEE80211_TX_CTL_LDPC) in mt7615_mac_write_txwi()
825 if (!(rate->flags & (IEEE80211_TX_RC_MCS | in mt7615_mac_write_txwi()
829 tx_count = rate->count; in mt7615_mac_write_txwi()
846 if (info->flags & IEEE80211_TX_CTL_INJECTED) { in mt7615_mac_write_txwi()
847 seqno = le16_to_cpu(hdr->seq_ctrl); in mt7615_mac_write_txwi()
849 if (ieee80211_is_back_req(hdr->frame_control)) { in mt7615_mac_write_txwi()
852 bar = (struct ieee80211_bar *)skb->data; in mt7615_mac_write_txwi()
853 seqno = le16_to_cpu(bar->start_seq_num); in mt7615_mac_write_txwi()
862 if (info->flags & IEEE80211_TX_CTL_NO_ACK) in mt7615_mac_write_txwi()
909 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7615_mac_sta_poll()
910 list_splice_init(&dev->mt76.sta_poll_list, &sta_poll_list); in mt7615_mac_sta_poll()
911 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7615_mac_sta_poll()
919 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7615_mac_sta_poll()
920 list_del_init(&msta->wcid.poll_list); in mt7615_mac_sta_poll()
921 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7615_mac_sta_poll()
923 addr = mt7615_mac_wtbl_addr(dev, msta->wcid.idx) + 19 * 4; in mt7615_mac_sta_poll()
926 u32 tx_last = msta->airtime_ac[i]; in mt7615_mac_sta_poll()
927 u32 rx_last = msta->airtime_ac[i + 4]; in mt7615_mac_sta_poll()
929 msta->airtime_ac[i] = mt76_rr(dev, addr); in mt7615_mac_sta_poll()
930 msta->airtime_ac[i + 4] = mt76_rr(dev, addr + 4); in mt7615_mac_sta_poll()
931 tx_time[i] = msta->airtime_ac[i] - tx_last; in mt7615_mac_sta_poll()
932 rx_time[i] = msta->airtime_ac[i + 4] - rx_last; in mt7615_mac_sta_poll()
939 mt7615_mac_wtbl_update(dev, msta->wcid.idx, in mt7615_mac_sta_poll()
941 memset(msta->airtime_ac, 0, sizeof(msta->airtime_ac)); in mt7615_mac_sta_poll()
944 if (!msta->wcid.sta) in mt7615_mac_sta_poll()
967 struct ieee80211_tx_rate *rates, in mt7615_mac_update_rate_desc() argument
970 struct mt7615_dev *dev = phy->dev; in mt7615_mac_update_rate_desc()
971 struct mt76_phy *mphy = phy->mt76; in mt7615_mac_update_rate_desc()
974 int n_rates = sta->n_rates; in mt7615_mac_update_rate_desc()
979 rates[i] = rates[n_rates - 1]; in mt7615_mac_update_rate_desc()
981 rateset = !(sta->rate_set_tsf & BIT(0)); in mt7615_mac_update_rate_desc()
982 memcpy(sta->rateset[rateset].rates, rates, in mt7615_mac_update_rate_desc()
983 sizeof(sta->rateset[rateset].rates)); in mt7615_mac_update_rate_desc()
985 sta->rateset[rateset].probe_rate = *probe_rate; in mt7615_mac_update_rate_desc()
986 ref = &sta->rateset[rateset].probe_rate; in mt7615_mac_update_rate_desc()
988 sta->rateset[rateset].probe_rate.idx = -1; in mt7615_mac_update_rate_desc()
989 ref = &sta->rateset[rateset].rates[0]; in mt7615_mac_update_rate_desc()
992 rates = sta->rateset[rateset].rates; in mt7615_mac_update_rate_desc()
993 for (i = 0; i < ARRAY_SIZE(sta->rateset[rateset].rates); i++) { in mt7615_mac_update_rate_desc()
1001 if ((ref->flags ^ rates[i].flags) & IEEE80211_TX_RC_SHORT_GI) in mt7615_mac_update_rate_desc()
1002 rates[i].flags ^= IEEE80211_TX_RC_SHORT_GI; in mt7615_mac_update_rate_desc()
1005 if (rates[i].idx != rates[j].idx) in mt7615_mac_update_rate_desc()
1007 if ((rates[i].flags ^ rates[j].flags) & in mt7615_mac_update_rate_desc()
1013 if (!rates[i].idx) in mt7615_mac_update_rate_desc()
1016 rates[i].idx--; in mt7615_mac_update_rate_desc()
1020 rd->val[0] = mt7615_mac_tx_rate_val(dev, mphy, &rates[0], stbc, &bw); in mt7615_mac_update_rate_desc()
1024 rd->probe_val = mt7615_mac_tx_rate_val(dev, mphy, probe_rate, in mt7615_mac_update_rate_desc()
1027 rd->bw_idx = 1; in mt7615_mac_update_rate_desc()
1031 rd->probe_val = rd->val[0]; in mt7615_mac_update_rate_desc()
1034 rd->val[1] = mt7615_mac_tx_rate_val(dev, mphy, &rates[1], stbc, &bw); in mt7615_mac_update_rate_desc()
1036 rd->bw_idx = 3; in mt7615_mac_update_rate_desc()
1040 rd->val[2] = mt7615_mac_tx_rate_val(dev, mphy, &rates[2], stbc, &bw); in mt7615_mac_update_rate_desc()
1042 rd->bw_idx = 5; in mt7615_mac_update_rate_desc()
1046 rd->val[3] = mt7615_mac_tx_rate_val(dev, mphy, &rates[3], stbc, &bw); in mt7615_mac_update_rate_desc()
1048 rd->bw_idx = 7; in mt7615_mac_update_rate_desc()
1050 rd->rateset = rateset; in mt7615_mac_update_rate_desc()
1051 rd->bw = bw; in mt7615_mac_update_rate_desc()
1057 struct ieee80211_tx_rate *rates) in mt7615_mac_queue_rate_update() argument
1059 struct mt7615_dev *dev = phy->dev; in mt7615_mac_queue_rate_update()
1062 if (work_pending(&dev->rate_work)) in mt7615_mac_queue_rate_update()
1063 return -EBUSY; in mt7615_mac_queue_rate_update()
1067 return -ENOMEM; in mt7615_mac_queue_rate_update()
1069 wrd->sta = sta; in mt7615_mac_queue_rate_update()
1070 mt7615_mac_update_rate_desc(phy, sta, probe_rate, rates, in mt7615_mac_queue_rate_update()
1071 &wrd->rate); in mt7615_mac_queue_rate_update()
1072 list_add_tail(&wrd->node, &dev->wrd_head); in mt7615_mac_queue_rate_update()
1073 queue_work(dev->mt76.wq, &dev->rate_work); in mt7615_mac_queue_rate_update()
1095 val |= val2 << (32 - offset); in mt7615_mac_get_sta_tid_sn()
1103 struct ieee80211_tx_rate *rates) in mt7615_mac_set_rates() argument
1105 int wcid = sta->wcid.idx, n_rates = sta->n_rates; in mt7615_mac_set_rates()
1106 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_rates()
1109 u16 idx = sta->vif->mt76.omac_idx; in mt7615_mac_set_rates()
1111 if (!mt76_is_mmio(&dev->mt76)) { in mt7615_mac_set_rates()
1112 mt7615_mac_queue_rate_update(phy, sta, probe_rate, rates); in mt7615_mac_set_rates()
1120 mt7615_mac_update_rate_desc(phy, sta, probe_rate, rates, &rd); in mt7615_mac_set_rates()
1134 rd.bw_idx ? rd.bw_idx - 1 : 7); in mt7615_mac_set_rates()
1165 sta->rate_set_tsf = mt76_rr(dev, MT_LPON_UTTR0) & ~BIT(0); in mt7615_mac_set_rates()
1166 sta->rate_set_tsf |= rd.rateset; in mt7615_mac_set_rates()
1168 if (!(sta->wcid.tx_info & MT_WCID_TX_INFO_SET)) in mt7615_mac_set_rates()
1171 sta->rate_count = 2 * MT7615_RATE_RETRY * n_rates; in mt7615_mac_set_rates()
1172 sta->wcid.tx_info |= MT_WCID_TX_INFO_SET; in mt7615_mac_set_rates()
1173 sta->rate_probe = !!probe_rate; in mt7615_mac_set_rates()
1180 struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; in mt7615_mac_enable_rtscts()
1183 addr = mt7615_mac_wtbl_addr(dev, mvif->sta.wcid.idx) + 3 * 4; in mt7615_mac_enable_rtscts()
1197 u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx) + 30 * 4; in mt7615_mac_wtbl_update_key()
1198 u8 data[32] = {}; in mt7615_mac_wtbl_update_key() local
1200 if (key->keylen > sizeof(data)) in mt7615_mac_wtbl_update_key()
1201 return -EINVAL; in mt7615_mac_wtbl_update_key()
1203 mt76_rr_copy(dev, addr, data, sizeof(data)); in mt7615_mac_wtbl_update_key()
1206 memcpy(data, key->key, 16); in mt7615_mac_wtbl_update_key()
1207 memcpy(data + 16, key->key + 24, 8); in mt7615_mac_wtbl_update_key()
1208 memcpy(data + 24, key->key + 16, 8); in mt7615_mac_wtbl_update_key()
1211 memcpy(data, key->key, key->keylen); in mt7615_mac_wtbl_update_key()
1213 memcpy(data, key->key, 16); in mt7615_mac_wtbl_update_key()
1215 memcpy(data + 16, key->key, 16); in mt7615_mac_wtbl_update_key()
1218 mt76_wr_copy(dev, addr, data, sizeof(data)); in mt7615_mac_wtbl_update_key()
1228 u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx), w0, w1; in mt7615_mac_wtbl_update_pk()
1231 return -ETIMEDOUT; in mt7615_mac_wtbl_update_pk()
1253 if (!mt7615_mac_wtbl_update(dev, wcid->idx, in mt7615_mac_wtbl_update_pk()
1255 return -ETIMEDOUT; in mt7615_mac_wtbl_update_pk()
1264 u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx); in mt7615_mac_wtbl_update_cipher()
1279 u16 cipher_mask = wcid->cipher; in __mt7615_mac_wtbl_set_key()
1282 cipher = mt7615_mac_get_cipher(key->cipher); in __mt7615_mac_wtbl_set_key()
1284 return -EOPNOTSUPP; in __mt7615_mac_wtbl_set_key()
1293 key->keyidx); in __mt7615_mac_wtbl_set_key()
1297 wcid->cipher = cipher_mask; in __mt7615_mac_wtbl_set_key()
1308 spin_lock_bh(&dev->mt76.lock); in mt7615_mac_wtbl_set_key()
1310 spin_unlock_bh(&dev->mt76.lock); in mt7615_mac_wtbl_set_key()
1348 info->flags |= IEEE80211_TX_STAT_ACK; in mt7615_fill_txs()
1350 info->status.ampdu_len = 1; in mt7615_fill_txs()
1351 info->status.ampdu_ack_len = !!(info->flags & in mt7615_fill_txs()
1354 if (ampdu || (info->flags & IEEE80211_TX_CTL_AMPDU)) in mt7615_fill_txs()
1355 info->flags |= IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_CTL_AMPDU; in mt7615_fill_txs()
1357 first_idx = max_t(int, 0, last_idx - (count - 1) / MT7615_RATE_RETRY); in mt7615_fill_txs()
1360 info->status.rates[0].count = count; in mt7615_fill_txs()
1365 rate_set_tsf = READ_ONCE(sta->rate_set_tsf); in mt7615_fill_txs()
1366 rs_idx = !((u32)(le32_get_bits(txs_data[4], MT_TXS4_F0_TIMESTAMP) - in mt7615_fill_txs()
1369 rs = &sta->rateset[rs_idx]; in mt7615_fill_txs()
1371 if (!first_idx && rs->probe_rate.idx >= 0) { in mt7615_fill_txs()
1372 info->status.rates[0] = rs->probe_rate; in mt7615_fill_txs()
1374 spin_lock_bh(&dev->mt76.lock); in mt7615_fill_txs()
1375 if (sta->rate_probe) { in mt7615_fill_txs()
1376 struct mt7615_phy *phy = &dev->phy; in mt7615_fill_txs()
1378 if (sta->wcid.phy_idx && dev->mt76.phys[MT_BAND1]) in mt7615_fill_txs()
1379 phy = dev->mt76.phys[MT_BAND1]->priv; in mt7615_fill_txs()
1381 mt7615_mac_set_rates(phy, sta, NULL, sta->rates); in mt7615_fill_txs()
1383 spin_unlock_bh(&dev->mt76.lock); in mt7615_fill_txs()
1385 info->status.rates[0] = rs->rates[first_idx / 2]; in mt7615_fill_txs()
1387 info->status.rates[0].count = 0; in mt7615_fill_txs()
1393 cur_rate = &rs->rates[idx / 2]; in mt7615_fill_txs()
1395 count -= cur_count; in mt7615_fill_txs()
1397 if (idx && (cur_rate->idx != info->status.rates[i].idx || in mt7615_fill_txs()
1398 cur_rate->flags != info->status.rates[i].flags)) { in mt7615_fill_txs()
1400 if (i == ARRAY_SIZE(info->status.rates)) { in mt7615_fill_txs()
1401 i--; in mt7615_fill_txs()
1405 info->status.rates[i] = *cur_rate; in mt7615_fill_txs()
1406 info->status.rates[i].count = 0; in mt7615_fill_txs()
1409 info->status.rates[i].count += cur_count; in mt7615_fill_txs()
1413 final_rate_flags = info->status.rates[i].flags; in mt7615_fill_txs()
1420 mphy = &dev->mphy; in mt7615_fill_txs()
1421 if (sta->wcid.phy_idx && dev->mt76.phys[MT_BAND1]) in mt7615_fill_txs()
1422 mphy = dev->mt76.phys[MT_BAND1]; in mt7615_fill_txs()
1424 if (mphy->chandef.chan->band == NL80211_BAND_5GHZ) in mt7615_fill_txs()
1425 sband = &mphy->sband_5g.sband; in mt7615_fill_txs()
1427 sband = &mphy->sband_2g.sband; in mt7615_fill_txs()
1429 final_rate = mt76_get_rate(&dev->mt76, sband, final_rate, in mt7615_fill_txs()
1444 final_nss--; in mt7615_fill_txs()
1453 info->status.rates[i].idx = final_rate; in mt7615_fill_txs()
1454 info->status.rates[i].flags = final_rate_flags; in mt7615_fill_txs()
1463 struct mt76_dev *mdev = &dev->mt76; in mt7615_mac_add_txs_skb()
1470 trace_mac_txdone(mdev, sta->wcid.idx, pid); in mt7615_mac_add_txs_skb()
1473 skb = mt76_tx_status_skb_get(mdev, &sta->wcid, pid, &list); in mt7615_mac_add_txs_skb()
1478 info->status.rates[0].count = 0; in mt7615_mac_add_txs_skb()
1479 info->status.rates[0].idx = -1; in mt7615_mac_add_txs_skb()
1489 static void mt7615_mac_add_txs(struct mt7615_dev *dev, void *data) in mt7615_mac_add_txs() argument
1495 struct mt76_phy *mphy = &dev->mt76.phy; in mt7615_mac_add_txs()
1496 __le32 *txs_data = data; in mt7615_mac_add_txs()
1511 wcid = rcu_dereference(dev->mt76.wcid[wcidx]); in mt7615_mac_add_txs()
1518 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7615_mac_add_txs()
1519 if (list_empty(&msta->wcid.poll_list)) in mt7615_mac_add_txs()
1520 list_add_tail(&msta->wcid.poll_list, &dev->mt76.sta_poll_list); in mt7615_mac_add_txs()
1521 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7615_mac_add_txs()
1529 if (wcid->phy_idx && dev->mt76.phys[MT_BAND1]) in mt7615_mac_add_txs()
1530 mphy = dev->mt76.phys[MT_BAND1]; in mt7615_mac_add_txs()
1533 spin_lock_bh(&dev->mt76.rx_lock); in mt7615_mac_add_txs()
1534 ieee80211_tx_status_noskb(mphy->hw, sta, &info); in mt7615_mac_add_txs()
1535 spin_unlock_bh(&dev->mt76.rx_lock); in mt7615_mac_add_txs()
1545 struct mt76_dev *mdev = &dev->mt76; in mt7615_txwi_free()
1551 if (!txwi->skb) in mt7615_txwi_free()
1557 mt76_tx_complete_skb(mdev, wcid, txwi->skb); in mt7615_txwi_free()
1560 txwi->skb = NULL; in mt7615_txwi_free()
1567 struct mt76_dev *mdev = &dev->mt76; in mt7615_mac_tx_free_token()
1578 static void mt7615_mac_tx_free(struct mt7615_dev *dev, void *data, int len) in mt7615_mac_tx_free() argument
1580 struct mt76_connac_tx_free *free = data; in mt7615_mac_tx_free()
1581 void *tx_token = data + sizeof(*free); in mt7615_mac_tx_free()
1582 void *end = data + len; in mt7615_mac_tx_free()
1585 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_PSD], false); in mt7615_mac_tx_free()
1586 if (is_mt7615(&dev->mt76)) { in mt7615_mac_tx_free()
1587 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_BE], false); in mt7615_mac_tx_free()
1590 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[i], false); in mt7615_mac_tx_free()
1593 count = le16_get_bits(free->ctrl, MT_TX_FREE_MSDU_ID_CNT); in mt7615_mac_tx_free()
1594 if (is_mt7615(&dev->mt76)) { in mt7615_mac_tx_free()
1616 mt76_worker_schedule(&dev->mt76.tx_worker); in mt7615_mac_tx_free()
1619 bool mt7615_rx_check(struct mt76_dev *mdev, void *data, int len) in mt7615_rx_check() argument
1622 __le32 *rxd = (__le32 *)data; in mt7615_rx_check()
1630 mt7615_mac_tx_free(dev, data, len); in mt7615_rx_check()
1646 __le32 *rxd = (__le32 *)skb->data; in mt7615_queue_rx_skb()
1647 __le32 *end = (__le32 *)&skb->data[skb->len]; in mt7615_queue_rx_skb()
1663 mt7615_mac_tx_free(dev, skb->data, skb->len); in mt7615_queue_rx_skb()
1672 mt76_rx(&dev->mt76, q, skb); in mt7615_queue_rx_skb()
1686 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_sensitivity()
1687 bool ext_phy = phy != &dev->phy; in mt7615_mac_set_sensitivity()
1689 if (is_mt7663(&dev->mt76)) { in mt7615_mac_set_sensitivity()
1719 phy->ofdm_sensitivity = -98; in mt7615_mac_set_default_sensitivity()
1720 phy->cck_sensitivity = -110; in mt7615_mac_set_default_sensitivity()
1721 phy->last_cca_adj = jiffies; in mt7615_mac_set_default_sensitivity()
1726 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_scs()
1727 bool ext_phy = phy != &dev->phy; in mt7615_mac_set_scs()
1732 if (phy->scs_en == enable) in mt7615_mac_set_scs()
1735 if (is_mt7663(&dev->mt76)) { in mt7615_mac_set_scs()
1745 if (is_mt7622(&dev->mt76)) { in mt7615_mac_set_scs()
1754 phy->scs_en = enable; in mt7615_mac_set_scs()
1764 if (is_mt7663(&dev->mt76)) in mt7615_mac_enable_nf()
1780 struct mt7615_dev *dev = phy->dev; in mt7615_mac_cca_stats_reset()
1781 bool ext_phy = phy != &dev->phy; in mt7615_mac_cca_stats_reset()
1784 if (is_mt7663(&dev->mt76)) in mt7615_mac_cca_stats_reset()
1798 struct mt7615_dev *dev = phy->dev; in mt7615_mac_adjust_sensitivity()
1799 int false_cca = ofdm ? phy->false_cca_ofdm : phy->false_cca_cck; in mt7615_mac_adjust_sensitivity()
1800 bool ext_phy = phy != &dev->phy; in mt7615_mac_adjust_sensitivity()
1801 s16 def_th = ofdm ? -98 : -110; in mt7615_mac_adjust_sensitivity()
1806 sensitivity = ofdm ? &phy->ofdm_sensitivity : &phy->cck_sensitivity; in mt7615_mac_adjust_sensitivity()
1807 signal = mt76_get_min_avg_rssi(&dev->mt76, ext_phy); in mt7615_mac_adjust_sensitivity()
1813 signal = min(signal, -72); in mt7615_mac_adjust_sensitivity()
1819 if (*sensitivity == def_th && signal > -90) { in mt7615_mac_adjust_sensitivity()
1820 *sensitivity = -90; in mt7615_mac_adjust_sensitivity()
1829 if (*sensitivity - 2 >= def_th) { in mt7615_mac_adjust_sensitivity()
1830 *sensitivity -= 2; in mt7615_mac_adjust_sensitivity()
1844 phy->last_cca_adj = jiffies; in mt7615_mac_adjust_sensitivity()
1851 struct mt7615_dev *dev = phy->dev; in mt7615_mac_scs_check()
1852 struct mib_stats *mib = &phy->mib; in mt7615_mac_scs_check()
1855 bool ext_phy = phy != &dev->phy; in mt7615_mac_scs_check()
1857 if (!phy->scs_en) in mt7615_mac_scs_check()
1860 if (is_mt7663(&dev->mt76)) in mt7615_mac_scs_check()
1867 if (is_mt7663(&dev->mt76)) in mt7615_mac_scs_check()
1874 phy->false_cca_ofdm = pd_ofdm - mdrdy_ofdm; in mt7615_mac_scs_check()
1875 phy->false_cca_cck = pd_cck - mdrdy_cck; in mt7615_mac_scs_check()
1878 if (mib->rts_cnt + mib->rts_retries_cnt) in mt7615_mac_scs_check()
1879 rts_err_rate = MT_FRAC(mib->rts_retries_cnt, in mt7615_mac_scs_check()
1880 mib->rts_cnt + mib->rts_retries_cnt); in mt7615_mac_scs_check()
1887 if (time_after(jiffies, phy->last_cca_adj + 10 * HZ)) in mt7615_mac_scs_check()
1898 if (is_mt7663(&dev->mt76)) in mt7615_phy_get_nf()
1918 struct mt7615_dev *dev = container_of(mphy->dev, struct mt7615_dev, mt76); in mt7615_phy_update_channel()
1919 struct mt7615_phy *phy = mphy->priv; in mt7615_phy_update_channel()
1934 if (!phy->noise) in mt7615_phy_update_channel()
1935 phy->noise = nf << 4; in mt7615_phy_update_channel()
1937 phy->noise += nf - (phy->noise >> 4); in mt7615_phy_update_channel()
1939 state = mphy->chan_state; in mt7615_phy_update_channel()
1940 state->cc_busy += busy_time; in mt7615_phy_update_channel()
1941 state->cc_tx += tx_time; in mt7615_phy_update_channel()
1942 state->cc_rx += rx_time + obss_time; in mt7615_phy_update_channel()
1943 state->cc_bss_rx += rx_time; in mt7615_phy_update_channel()
1944 state->noise = -(phy->noise >> 4); in mt7615_phy_update_channel()
1949 struct mt76_dev *mdev = &dev->mt76; in mt7615_update_survey()
1950 struct mt76_phy *mphy_ext = mdev->phys[MT_BAND1]; in mt7615_update_survey()
1957 mt7615_phy_update_channel(&mdev->phy, 0); in mt7615_update_survey()
1963 mt76_update_survey_active_time(&mdev->phy, cur_time); in mt7615_update_survey()
1973 struct mt7615_dev *dev = container_of(mphy->dev, struct mt7615_dev, mt76); in mt7615_update_channel()
1975 if (mt76_connac_pm_wake(&dev->mphy, &dev->pm)) in mt7615_update_channel()
1979 mt76_connac_power_save_sched(&dev->mphy, &dev->pm); in mt7615_update_channel()
1986 struct mt7615_dev *dev = phy->dev; in mt7615_mac_update_mib_stats()
1987 struct mib_stats *mib = &phy->mib; in mt7615_mac_update_mib_stats()
1988 bool ext_phy = phy != &dev->phy; in mt7615_mac_update_mib_stats()
1992 mib->fcs_err_cnt += mt76_get_field(dev, MT_MIB_SDR3(ext_phy), in mt7615_mac_update_mib_stats()
2000 mib->aggr_per = 1000 * (val - val2) / val; in mt7615_mac_update_mib_stats()
2005 mib->ba_miss_cnt += FIELD_GET(MT_MIB_BA_MISS_COUNT_MASK, val); in mt7615_mac_update_mib_stats()
2006 mib->ack_fail_cnt += FIELD_GET(MT_MIB_ACK_FAIL_COUNT_MASK, in mt7615_mac_update_mib_stats()
2010 mib->rts_cnt += FIELD_GET(MT_MIB_RTS_COUNT_MASK, val); in mt7615_mac_update_mib_stats()
2011 mib->rts_retries_cnt += FIELD_GET(MT_MIB_RTS_RETRIES_COUNT_MASK, in mt7615_mac_update_mib_stats()
2015 phy->mt76->aggr_stats[aggr++] += val & 0xffff; in mt7615_mac_update_mib_stats()
2016 phy->mt76->aggr_stats[aggr++] += val >> 16; in mt7615_mac_update_mib_stats()
2027 mphy = dev->phy.mt76; in mt7615_pm_wake_work()
2030 struct mt76_dev *mdev = &dev->mt76; in mt7615_pm_wake_work()
2034 mt76_connac_pm_dequeue_skbs(mphy, &dev->pm); in mt7615_pm_wake_work()
2035 mt76_worker_schedule(&mdev->sdio.txrx_worker); in mt7615_pm_wake_work()
2039 napi_schedule(&mdev->napi[i]); in mt7615_pm_wake_work()
2041 mt76_connac_pm_dequeue_skbs(mphy, &dev->pm); in mt7615_pm_wake_work()
2042 mt76_queue_tx_cleanup(dev, mdev->q_mcu[MT_MCUQ_WM], in mt7615_pm_wake_work()
2046 if (test_bit(MT76_STATE_RUNNING, &mphy->state)) { in mt7615_pm_wake_work()
2050 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, in mt7615_pm_wake_work()
2055 ieee80211_wake_queues(mphy->hw); in mt7615_pm_wake_work()
2056 wake_up(&dev->pm.wait); in mt7615_pm_wake_work()
2067 delta = dev->pm.idle_timeout; in mt7615_pm_power_save_work()
2068 if (test_bit(MT76_HW_SCANNING, &dev->mphy.state) || in mt7615_pm_power_save_work()
2069 test_bit(MT76_HW_SCHED_SCANNING, &dev->mphy.state)) in mt7615_pm_power_save_work()
2072 if (mutex_is_locked(&dev->mt76.mutex)) in mt7615_pm_power_save_work()
2080 if (time_is_after_jiffies(dev->pm.last_activity + delta)) { in mt7615_pm_power_save_work()
2081 delta = dev->pm.last_activity + delta - jiffies; in mt7615_pm_power_save_work()
2088 queue_delayed_work(dev->mt76.wq, &dev->pm.ps_work, delta); in mt7615_pm_power_save_work()
2099 phy = mphy->priv; in mt7615_mac_work()
2101 mt7615_mutex_acquire(phy->dev); in mt7615_mac_work()
2103 mt7615_update_survey(phy->dev); in mt7615_mac_work()
2104 if (++mphy->mac_work_count == 5) { in mt7615_mac_work()
2105 mphy->mac_work_count = 0; in mt7615_mac_work()
2111 mt7615_mutex_release(phy->dev); in mt7615_mac_work()
2113 mt76_tx_status_check(mphy->dev, false); in mt7615_mac_work()
2115 timeout = mt7615_get_macwork_timeout(phy->dev); in mt7615_mac_work()
2116 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, timeout); in mt7615_mac_work()
2124 spin_lock_bh(&dev->mt76.token_lock); in mt7615_tx_token_put()
2125 idr_for_each_entry(&dev->mt76.token, txwi, id) in mt7615_tx_token_put()
2127 spin_unlock_bh(&dev->mt76.token_lock); in mt7615_tx_token_put()
2128 idr_destroy(&dev->mt76.token); in mt7615_tx_token_put()
2134 struct mt7615_dev *dev = phy->dev; in mt7615_dfs_stop_radar_detector()
2136 if (phy->rdd_state & BIT(0)) in mt7615_dfs_stop_radar_detector()
2137 mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_STOP, 0, in mt7615_dfs_stop_radar_detector()
2139 if (phy->rdd_state & BIT(1)) in mt7615_dfs_stop_radar_detector()
2140 mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_STOP, 1, in mt7615_dfs_stop_radar_detector()
2148 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_START, chain, in mt7615_dfs_start_rdd()
2153 return mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_DET_MODE, chain, in mt7615_dfs_start_rdd()
2159 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7615_dfs_start_radar_detector()
2160 struct mt7615_dev *dev = phy->dev; in mt7615_dfs_start_radar_detector()
2161 bool ext_phy = phy != &dev->phy; in mt7615_dfs_start_radar_detector()
2165 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_CAC_START, ext_phy, in mt7615_dfs_start_radar_detector()
2174 phy->rdd_state |= BIT(ext_phy); in mt7615_dfs_start_radar_detector()
2176 if (chandef->width == NL80211_CHAN_WIDTH_160 || in mt7615_dfs_start_radar_detector()
2177 chandef->width == NL80211_CHAN_WIDTH_80P80) { in mt7615_dfs_start_radar_detector()
2182 phy->rdd_state |= BIT(1); in mt7615_dfs_start_radar_detector()
2192 struct mt7615_dev *dev = phy->dev; in mt7615_dfs_init_radar_specs()
2195 switch (dev->mt76.region) { in mt7615_dfs_init_radar_specs()
2207 return -EINVAL; in mt7615_dfs_init_radar_specs()
2210 /* avoid FCC radar detection in non-FCC region */ in mt7615_dfs_init_radar_specs()
2215 for (i = 0; i < ARRAY_SIZE(radar_specs->radar_pattern); i++) { in mt7615_dfs_init_radar_specs()
2217 &radar_specs->radar_pattern[i]); in mt7615_dfs_init_radar_specs()
2222 return mt7615_mcu_set_pulse_th(dev, &radar_specs->pulse_th); in mt7615_dfs_init_radar_specs()
2227 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7615_dfs_init_radar_detector()
2228 struct mt7615_dev *dev = phy->dev; in mt7615_dfs_init_radar_detector()
2229 bool ext_phy = phy != &dev->phy; in mt7615_dfs_init_radar_detector()
2233 if (is_mt7663(&dev->mt76)) in mt7615_dfs_init_radar_detector()
2236 prev_state = phy->mt76->dfs_state; in mt7615_dfs_init_radar_detector()
2237 dfs_state = mt76_phy_dfs_state(phy->mt76); in mt7615_dfs_init_radar_detector()
2238 if ((chandef->chan->flags & IEEE80211_CHAN_RADAR) && in mt7615_dfs_init_radar_detector()
2257 phy->mt76->dfs_state = MT_DFS_STATE_CAC; in mt7615_dfs_init_radar_detector()
2263 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_CAC_END, in mt7615_dfs_init_radar_detector()
2266 phy->mt76->dfs_state = MT_DFS_STATE_UNKNOWN; in mt7615_dfs_init_radar_detector()
2270 phy->mt76->dfs_state = MT_DFS_STATE_ACTIVE; in mt7615_dfs_init_radar_detector()
2274 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_NORMAL_START, ext_phy, in mt7615_dfs_init_radar_detector()
2280 phy->mt76->dfs_state = MT_DFS_STATE_DISABLED; in mt7615_dfs_init_radar_detector()
2289 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_beacon_filter()
2290 bool ext_phy = phy != &dev->phy; in mt7615_mac_set_beacon_filter()
2294 return -EOPNOTSUPP; in mt7615_mac_set_beacon_filter()
2296 switch (vif->type) { in mt7615_mac_set_beacon_filter()
2303 phy->n_beacon_vif++; in mt7615_mac_set_beacon_filter()
2305 phy->n_beacon_vif--; in mt7615_mac_set_beacon_filter()
2311 err = mt7615_mcu_set_bss_pm(dev, vif, !phy->n_beacon_vif); in mt7615_mac_set_beacon_filter()
2315 if (phy->n_beacon_vif) { in mt7615_mac_set_beacon_filter()
2316 vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER; in mt7615_mac_set_beacon_filter()
2320 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; in mt7615_mac_set_beacon_filter()
2331 char *dump, *data; in mt7615_coredump_work() local
2336 if (time_is_after_jiffies(dev->coredump.last_activity + in mt7615_coredump_work()
2338 queue_delayed_work(dev->mt76.wq, &dev->coredump.work, in mt7615_coredump_work()
2344 data = dump; in mt7615_coredump_work()
2349 spin_lock_bh(&dev->mt76.lock); in mt7615_coredump_work()
2350 skb = __skb_dequeue(&dev->coredump.msg_list); in mt7615_coredump_work()
2351 spin_unlock_bh(&dev->mt76.lock); in mt7615_coredump_work()
2357 if (!dump || data + skb->len - dump > MT76_CONNAC_COREDUMP_SZ) { in mt7615_coredump_work()
2362 memcpy(data, skb->data, skb->len); in mt7615_coredump_work()
2363 data += skb->len; in mt7615_coredump_work()
2369 dev_coredumpv(dev->mt76.dev, dump, MT76_CONNAC_COREDUMP_SZ, in mt7615_coredump_work()