Lines Matching +full:max +full:- +full:adj
1 // SPDX-License-Identifier: ISC
42 memset(dev->mphy.aggr_stats, 0, sizeof(dev->mphy.aggr_stats)); in mt7603_mac_reset_counters()
51 int offset = 3 * dev->coverage_class; in mt7603_mac_set_timing()
54 bool is_5ghz = dev->mphy.chandef.chan->band == NL80211_BAND_5GHZ; in mt7603_mac_set_timing()
73 FIELD_PREP(MT_IFS_SLOT, dev->slottime)); in mt7603_mac_set_timing()
75 if (dev->slottime < 20 || is_5ghz) in mt7603_mac_set_timing()
229 u32 addr = mt7603_wtbl1_addr(sta->wcid.idx); in mt7603_wtbl_set_smps()
231 if (sta->smps == enabled) in mt7603_wtbl_set_smps()
235 sta->smps = enabled; in mt7603_wtbl_set_smps()
241 int idx = sta->wcid.idx; in mt7603_wtbl_set_ps()
244 spin_lock_bh(&dev->ps_lock); in mt7603_wtbl_set_ps()
246 if (sta->ps == enabled) in mt7603_wtbl_set_ps()
259 mt7603_filter_tx(dev, sta->vif->idx, idx, false); in mt7603_wtbl_set_ps()
266 sta->ps = enabled; in mt7603_wtbl_set_ps()
269 spin_unlock_bh(&dev->ps_lock); in mt7603_wtbl_set_ps()
332 struct mt7603_sta *msta = (struct mt7603_sta *)sta->drv_priv; in mt7603_wtbl_update_cap()
333 int idx = msta->wcid.idx; in mt7603_wtbl_update_cap()
340 ampdu_density = sta->deflink.ht_cap.ampdu_density; in mt7603_wtbl_update_cap()
347 sta->deflink.ht_cap.ampdu_factor) | in mt7603_wtbl_update_cap()
349 sta->deflink.ht_cap.ampdu_density) | in mt7603_wtbl_update_cap()
352 if (sta->deflink.ht_cap.cap) in mt7603_wtbl_update_cap()
354 if (sta->deflink.vht_cap.cap) in mt7603_wtbl_update_cap()
363 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SGI_20) in mt7603_wtbl_update_cap()
365 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SGI_40) in mt7603_wtbl_update_cap()
395 for (i = 7; i > 0; i--) { in mt7603_mac_tx_ba_reset()
426 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7603_mac_sta_poll()
427 if (list_empty(&dev->mt76.sta_poll_list)) { in mt7603_mac_sta_poll()
428 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7603_mac_sta_poll()
432 msta = list_first_entry(&dev->mt76.sta_poll_list, in mt7603_mac_sta_poll()
434 list_del_init(&msta->wcid.poll_list); in mt7603_mac_sta_poll()
435 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7603_mac_sta_poll()
437 addr = mt7603_wtbl4_addr(msta->wcid.idx); in mt7603_mac_sta_poll()
439 u32 airtime_last = msta->tx_airtime_ac[i]; in mt7603_mac_sta_poll()
441 msta->tx_airtime_ac[i] = mt76_rr(dev, addr + i * 8); in mt7603_mac_sta_poll()
442 airtime[i] = msta->tx_airtime_ac[i] - airtime_last; in mt7603_mac_sta_poll()
446 if (msta->tx_airtime_ac[i] & BIT(22)) in mt7603_mac_sta_poll()
451 mt7603_wtbl_update(dev, msta->wcid.idx, in mt7603_mac_sta_poll()
453 memset(msta->tx_airtime_ac, 0, in mt7603_mac_sta_poll()
454 sizeof(msta->tx_airtime_ac)); in mt7603_mac_sta_poll()
457 if (!msta->wcid.sta) in mt7603_mac_sta_poll()
462 struct mt76_queue *q = dev->mphy.q_tx[i]; in mt7603_mac_sta_poll()
463 u8 qidx = q->hw_idx; in mt7603_mac_sta_poll()
479 spin_lock_bh(&dev->mt76.cc_lock); in mt7603_mac_sta_poll()
480 dev->mphy.chan_state->cc_tx += total_airtime; in mt7603_mac_sta_poll()
481 spin_unlock_bh(&dev->mt76.cc_lock); in mt7603_mac_sta_poll()
493 wcid = rcu_dereference(dev->mt76.wcid[idx]); in mt7603_rx_get_wcid()
497 if (!wcid->sta) in mt7603_rx_get_wcid()
501 if (!sta->vif) in mt7603_rx_get_wcid()
504 return &sta->vif->sta.wcid; in mt7603_rx_get_wcid()
510 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt7603_mac_fill_rx()
513 __le32 *rxd = (__le32 *)skb->data; in mt7603_mac_fill_rx()
526 sband = (i & 1) ? &dev->mphy.sband_5g.sband : &dev->mphy.sband_2g.sband; in mt7603_mac_fill_rx()
530 status->wcid = mt7603_rx_get_wcid(dev, idx, unicast); in mt7603_mac_fill_rx()
532 status->band = sband->band; in mt7603_mac_fill_rx()
533 if (i < sband->n_channels) in mt7603_mac_fill_rx()
534 status->freq = sband->channels[i].center_freq; in mt7603_mac_fill_rx()
537 status->flag |= RX_FLAG_FAILED_FCS_CRC; in mt7603_mac_fill_rx()
540 status->flag |= RX_FLAG_MMIC_ERROR; in mt7603_mac_fill_rx()
544 status->flag |= RX_FLAG_ONLY_MONITOR; in mt7603_mac_fill_rx()
548 status->flag |= RX_FLAG_DECRYPTED; in mt7603_mac_fill_rx()
549 status->flag |= RX_FLAG_IV_STRIPPED; in mt7603_mac_fill_rx()
550 status->flag |= RX_FLAG_MMIC_STRIPPED | RX_FLAG_MIC_STRIPPED; in mt7603_mac_fill_rx()
556 return -EINVAL; in mt7603_mac_fill_rx()
558 if (!sband->channels) in mt7603_mac_fill_rx()
559 return -EINVAL; in mt7603_mac_fill_rx()
564 if ((u8 *)rxd - skb->data >= skb->len) in mt7603_mac_fill_rx()
565 return -EINVAL; in mt7603_mac_fill_rx()
570 if (status->flag & RX_FLAG_DECRYPTED) { in mt7603_mac_fill_rx()
582 status->iv[0] = data[5]; in mt7603_mac_fill_rx()
583 status->iv[1] = data[4]; in mt7603_mac_fill_rx()
584 status->iv[2] = data[3]; in mt7603_mac_fill_rx()
585 status->iv[3] = data[2]; in mt7603_mac_fill_rx()
586 status->iv[4] = data[1]; in mt7603_mac_fill_rx()
587 status->iv[5] = data[0]; in mt7603_mac_fill_rx()
595 if ((u8 *)rxd - skb->data >= skb->len) in mt7603_mac_fill_rx()
596 return -EINVAL; in mt7603_mac_fill_rx()
599 status->timestamp = le32_to_cpu(rxd[0]); in mt7603_mac_fill_rx()
600 status->flag |= RX_FLAG_MACTIME_START; in mt7603_mac_fill_rx()
604 status->flag |= RX_FLAG_AMPDU_DETAILS; in mt7603_mac_fill_rx()
606 /* all subframes of an A-MPDU have the same timestamp */ in mt7603_mac_fill_rx()
607 if (dev->rx_ampdu_ts != status->timestamp) { in mt7603_mac_fill_rx()
608 if (!++dev->ampdu_ref) in mt7603_mac_fill_rx()
609 dev->ampdu_ref++; in mt7603_mac_fill_rx()
611 dev->rx_ampdu_ts = status->timestamp; in mt7603_mac_fill_rx()
613 status->ampdu_ref = dev->ampdu_ref; in mt7603_mac_fill_rx()
617 if ((u8 *)rxd - skb->data >= skb->len) in mt7603_mac_fill_rx()
618 return -EINVAL; in mt7603_mac_fill_rx()
631 i = mt76_get_rate(&dev->mt76, sband, i, cck); in mt7603_mac_fill_rx()
635 status->encoding = RX_ENC_HT; in mt7603_mac_fill_rx()
637 return -EINVAL; in mt7603_mac_fill_rx()
640 return -EINVAL; in mt7603_mac_fill_rx()
644 status->enc_flags |= RX_ENC_FLAG_SHORT_GI; in mt7603_mac_fill_rx()
646 status->enc_flags |= RX_ENC_FLAG_LDPC; in mt7603_mac_fill_rx()
648 status->enc_flags |= RX_ENC_FLAG_STBC_MASK * in mt7603_mac_fill_rx()
651 status->rate_idx = i; in mt7603_mac_fill_rx()
653 status->chains = dev->mphy.antenna_mask; in mt7603_mac_fill_rx()
654 status->chain_signal[0] = FIELD_GET(MT_RXV4_IB_RSSI0, rxdg3) + in mt7603_mac_fill_rx()
655 dev->rssi_offset[0]; in mt7603_mac_fill_rx()
656 status->chain_signal[1] = FIELD_GET(MT_RXV4_IB_RSSI1, rxdg3) + in mt7603_mac_fill_rx()
657 dev->rssi_offset[1]; in mt7603_mac_fill_rx()
660 status->bw = RATE_INFO_BW_40; in mt7603_mac_fill_rx()
663 if ((u8 *)rxd - skb->data >= skb->len) in mt7603_mac_fill_rx()
664 return -EINVAL; in mt7603_mac_fill_rx()
666 return -EINVAL; in mt7603_mac_fill_rx()
669 skb_pull(skb, (u8 *)rxd - skb->data + 2 * remove_pad); in mt7603_mac_fill_rx()
677 hdr = (struct ieee80211_hdr *)skb->data; in mt7603_mac_fill_rx()
678 if (!status->wcid || !ieee80211_is_data_qos(hdr->frame_control)) in mt7603_mac_fill_rx()
681 status->aggr = unicast && in mt7603_mac_fill_rx()
682 !ieee80211_is_qos_nullfunc(hdr->frame_control); in mt7603_mac_fill_rx()
683 status->qos_ctl = *ieee80211_get_qos_ctl(hdr); in mt7603_mac_fill_rx()
684 status->seqno = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); in mt7603_mac_fill_rx()
697 if (rate->flags & IEEE80211_TX_RC_MCS) { in mt7603_mac_tx_rate_val()
698 rate_idx = rate->idx; in mt7603_mac_tx_rate_val()
699 nss = 1 + (rate->idx >> 3); in mt7603_mac_tx_rate_val()
701 if (rate->flags & IEEE80211_TX_RC_GREEN_FIELD) in mt7603_mac_tx_rate_val()
703 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) in mt7603_mac_tx_rate_val()
707 int band = dev->mphy.chandef.chan->band; in mt7603_mac_tx_rate_val()
711 r = &mt76_hw(dev)->wiphy->bands[band]->bitrates[rate->idx]; in mt7603_mac_tx_rate_val()
712 if (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) in mt7603_mac_tx_rate_val()
713 val = r->hw_value_short; in mt7603_mac_tx_rate_val()
715 val = r->hw_value; in mt7603_mac_tx_rate_val()
735 int wcid = sta->wcid.idx; in mt7603_wtbl_set_rates()
738 int n_rates = sta->n_rates; in mt7603_wtbl_set_rates()
750 rates[i] = rates[n_rates - 1]; in mt7603_wtbl_set_rates()
752 rateset = !(sta->rate_set_tsf & BIT(0)); in mt7603_wtbl_set_rates()
753 memcpy(sta->rateset[rateset].rates, rates, in mt7603_wtbl_set_rates()
754 sizeof(sta->rateset[rateset].rates)); in mt7603_wtbl_set_rates()
756 sta->rateset[rateset].probe_rate = *probe_rate; in mt7603_wtbl_set_rates()
757 ref = &sta->rateset[rateset].probe_rate; in mt7603_wtbl_set_rates()
759 sta->rateset[rateset].probe_rate.idx = -1; in mt7603_wtbl_set_rates()
760 ref = &sta->rateset[rateset].rates[0]; in mt7603_wtbl_set_rates()
763 rates = sta->rateset[rateset].rates; in mt7603_wtbl_set_rates()
764 for (i = 0; i < ARRAY_SIZE(sta->rateset[rateset].rates); i++) { in mt7603_wtbl_set_rates()
772 if ((ref->flags ^ rates[i].flags) & IEEE80211_TX_RC_SHORT_GI) in mt7603_wtbl_set_rates()
785 rates[i].idx--; in mt7603_wtbl_set_rates()
825 bw_idx ? bw_idx - 1 : 7); in mt7603_wtbl_set_rates()
846 sta->rate_set_tsf = (mt76_rr(dev, MT_LPON_UTTR0) & ~BIT(0)) | rateset; in mt7603_wtbl_set_rates()
853 if (!(sta->wcid.tx_info & MT_WCID_TX_INFO_SET)) in mt7603_wtbl_set_rates()
856 sta->rate_count = 2 * MT7603_RATE_RETRY * n_rates; in mt7603_wtbl_set_rates()
857 sta->wcid.tx_info |= MT_WCID_TX_INFO_SET; in mt7603_wtbl_set_rates()
867 if (key->keylen > 32) in mt7603_mac_get_key_info()
870 memcpy(key_data, key->key, key->keylen); in mt7603_mac_get_key_info()
872 switch (key->cipher) { in mt7603_mac_get_key_info()
879 memcpy(key_data + 16, key->key + 24, 8); in mt7603_mac_get_key_info()
880 memcpy(key_data + 24, key->key + 16, 8); in mt7603_mac_get_key_info()
899 return -EOPNOTSUPP; in mt7603_wtbl_set_key()
902 addr += key->keyidx * 16; in mt7603_wtbl_set_key()
911 mt76_rmw_field(dev, addr, MT_WTBL1_W0_KEY_IDX, key->keyidx); in mt7603_wtbl_set_key()
924 struct ieee80211_tx_rate *rate = &info->control.rates[0]; in mt7603_mac_write_txwi()
925 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in mt7603_mac_write_txwi()
926 struct ieee80211_bar *bar = (struct ieee80211_bar *)skb->data; in mt7603_mac_write_txwi()
927 struct ieee80211_vif *vif = info->control.vif; in mt7603_mac_write_txwi()
928 struct mt76_queue *q = dev->mphy.q_tx[qid]; in mt7603_mac_write_txwi()
934 u16 fc = le16_to_cpu(hdr->frame_control); in mt7603_mac_write_txwi()
941 mvif = (struct mt7603_vif *)vif->drv_priv; in mt7603_mac_write_txwi()
942 vif_idx = mvif->idx; in mt7603_mac_write_txwi()
948 struct mt7603_sta *msta = (struct mt7603_sta *)sta->drv_priv; in mt7603_mac_write_txwi()
950 tx_count = msta->rate_count; in mt7603_mac_write_txwi()
954 wlan_idx = wcid->idx; in mt7603_mac_write_txwi()
961 val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len + MT_TXD_SIZE) | in mt7603_mac_write_txwi()
962 FIELD_PREP(MT_TXD0_Q_IDX, q->hw_idx); in mt7603_mac_write_txwi()
968 skb->priority & IEEE80211_QOS_CTL_TID_MASK) | in mt7603_mac_write_txwi()
975 if (info->flags & IEEE80211_TX_CTL_NO_ACK) in mt7603_mac_write_txwi()
981 is_multicast_ether_addr(hdr->addr1)); in mt7603_mac_write_txwi()
984 if (!(info->flags & IEEE80211_TX_CTL_AMPDU)) in mt7603_mac_write_txwi()
995 if (rate->idx >= 0 && rate->count && in mt7603_mac_write_txwi()
996 !(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)) { in mt7603_mac_write_txwi()
997 bool stbc = info->flags & IEEE80211_TX_CTL_STBC; in mt7603_mac_write_txwi()
1007 if (rate->flags & IEEE80211_TX_RC_SHORT_GI) in mt7603_mac_write_txwi()
1010 if (!(rate->flags & IEEE80211_TX_RC_MCS)) in mt7603_mac_write_txwi()
1013 tx_count = rate->count; in mt7603_mac_write_txwi()
1023 if (ieee80211_is_data_qos(hdr->frame_control)) in mt7603_mac_write_txwi()
1024 seqno = le16_to_cpu(hdr->seq_ctrl); in mt7603_mac_write_txwi()
1025 else if (ieee80211_is_back_req(hdr->frame_control)) in mt7603_mac_write_txwi()
1026 seqno = le16_to_cpu(bar->start_seq_num); in mt7603_mac_write_txwi()
1035 u64 pn = atomic64_inc_return(&key->tx_pn); in mt7603_mac_write_txwi()
1054 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_info->skb); in mt7603_tx_prepare_skb()
1055 struct ieee80211_key_conf *key = info->control.hw_key; in mt7603_tx_prepare_skb()
1059 wcid = &dev->global_sta.wcid; in mt7603_tx_prepare_skb()
1062 msta = (struct mt7603_sta *)sta->drv_priv; in mt7603_tx_prepare_skb()
1064 if ((info->flags & (IEEE80211_TX_CTL_NO_PS_BUFFER | in mt7603_tx_prepare_skb()
1066 (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE)) in mt7603_tx_prepare_skb()
1069 mt76_tx_check_agg_ssn(sta, tx_info->skb); in mt7603_tx_prepare_skb()
1072 pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb); in mt7603_tx_prepare_skb()
1074 if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) { in mt7603_tx_prepare_skb()
1075 spin_lock_bh(&dev->mt76.lock); in mt7603_tx_prepare_skb()
1076 mt7603_wtbl_set_rates(dev, msta, &info->control.rates[0], in mt7603_tx_prepare_skb()
1077 msta->rates); in mt7603_tx_prepare_skb()
1078 msta->rate_probe = true; in mt7603_tx_prepare_skb()
1079 spin_unlock_bh(&dev->mt76.lock); in mt7603_tx_prepare_skb()
1082 mt7603_mac_write_txwi(dev, txwi_ptr, tx_info->skb, qid, wcid, in mt7603_tx_prepare_skb()
1109 fixed_rate = info->status.rates[0].count; in mt7603_fill_txs()
1110 probe = !!(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE); in mt7603_fill_txs()
1128 info->flags |= IEEE80211_TX_STAT_ACK; in mt7603_fill_txs()
1130 info->status.ampdu_len = 1; in mt7603_fill_txs()
1131 info->status.ampdu_ack_len = !!(info->flags & in mt7603_fill_txs()
1134 if (ampdu || (info->flags & IEEE80211_TX_CTL_AMPDU)) in mt7603_fill_txs()
1135 info->flags |= IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_CTL_AMPDU; in mt7603_fill_txs()
1137 first_idx = max_t(int, 0, last_idx - (count - 1) / MT7603_RATE_RETRY); in mt7603_fill_txs()
1140 info->status.rates[0].count = count; in mt7603_fill_txs()
1145 rate_set_tsf = READ_ONCE(sta->rate_set_tsf); in mt7603_fill_txs()
1146 rs_idx = !((u32)(le32_get_bits(txs_data[1], MT_TXS1_F0_TIMESTAMP) - in mt7603_fill_txs()
1149 rs = &sta->rateset[rs_idx]; in mt7603_fill_txs()
1151 if (!first_idx && rs->probe_rate.idx >= 0) { in mt7603_fill_txs()
1152 info->status.rates[0] = rs->probe_rate; in mt7603_fill_txs()
1154 spin_lock_bh(&dev->mt76.lock); in mt7603_fill_txs()
1155 if (sta->rate_probe) { in mt7603_fill_txs()
1157 sta->rates); in mt7603_fill_txs()
1158 sta->rate_probe = false; in mt7603_fill_txs()
1160 spin_unlock_bh(&dev->mt76.lock); in mt7603_fill_txs()
1162 info->status.rates[0] = rs->rates[first_idx / 2]; in mt7603_fill_txs()
1164 info->status.rates[0].count = 0; in mt7603_fill_txs()
1170 cur_rate = &rs->rates[idx / 2]; in mt7603_fill_txs()
1172 count -= cur_count; in mt7603_fill_txs()
1174 if (idx && (cur_rate->idx != info->status.rates[i].idx || in mt7603_fill_txs()
1175 cur_rate->flags != info->status.rates[i].flags)) { in mt7603_fill_txs()
1177 if (i == ARRAY_SIZE(info->status.rates)) { in mt7603_fill_txs()
1178 i--; in mt7603_fill_txs()
1182 info->status.rates[i] = *cur_rate; in mt7603_fill_txs()
1183 info->status.rates[i].count = 0; in mt7603_fill_txs()
1186 info->status.rates[i].count += cur_count; in mt7603_fill_txs()
1190 final_rate_flags = info->status.rates[i].flags; in mt7603_fill_txs()
1197 if (dev->mphy.chandef.chan->band == NL80211_BAND_5GHZ) in mt7603_fill_txs()
1198 sband = &dev->mphy.sband_5g.sband; in mt7603_fill_txs()
1200 sband = &dev->mphy.sband_2g.sband; in mt7603_fill_txs()
1202 final_rate = mt76_get_rate(&dev->mt76, sband, final_rate, in mt7603_fill_txs()
1217 info->status.rates[i].idx = final_rate; in mt7603_fill_txs()
1218 info->status.rates[i].flags = final_rate_flags; in mt7603_fill_txs()
1227 struct mt76_dev *mdev = &dev->mt76; in mt7603_mac_add_txs_skb()
1234 trace_mac_txdone(mdev, sta->wcid.idx, pid); in mt7603_mac_add_txs_skb()
1237 skb = mt76_tx_status_skb_get(mdev, &sta->wcid, pid, &list); in mt7603_mac_add_txs_skb()
1242 info->status.rates[0].count = 0; in mt7603_mac_add_txs_skb()
1243 info->status.rates[0].idx = -1; in mt7603_mac_add_txs_skb()
1274 wcid = rcu_dereference(dev->mt76.wcid[wcidx]); in mt7603_mac_add_txs()
1281 if (list_empty(&msta->wcid.poll_list)) { in mt7603_mac_add_txs()
1282 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7603_mac_add_txs()
1283 list_add_tail(&msta->wcid.poll_list, &dev->mt76.sta_poll_list); in mt7603_mac_add_txs()
1284 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7603_mac_add_txs()
1294 spin_lock_bh(&dev->mt76.rx_lock); in mt7603_mac_add_txs()
1296 spin_unlock_bh(&dev->mt76.rx_lock); in mt7603_mac_add_txs()
1306 struct sk_buff *skb = e->skb; in mt7603_tx_complete_skb()
1308 if (!e->txwi) { in mt7603_tx_complete_skb()
1313 dev->tx_hang_check = 0; in mt7603_tx_complete_skb()
1314 mt76_tx_complete_skb(mdev, e->wcid, skb); in mt7603_tx_complete_skb()
1329 if (!dev->reset_cause[RESET_CAUSE_RESET_FAILED]) in mt7603_pse_reset()
1338 dev->reset_cause[RESET_CAUSE_RESET_FAILED]++; in mt7603_pse_reset()
1341 dev->reset_cause[RESET_CAUSE_RESET_FAILED] = 0; in mt7603_pse_reset()
1345 if (dev->reset_cause[RESET_CAUSE_RESET_FAILED] >= 3) in mt7603_pse_reset()
1346 dev->reset_cause[RESET_CAUSE_RESET_FAILED] = 0; in mt7603_pse_reset()
1424 int beacon_int = dev->mt76.beacon_int; in mt7603_mac_watchdog_reset()
1425 u32 mask = dev->mt76.mmio.irqmask; in mt7603_mac_watchdog_reset()
1428 ieee80211_stop_queues(dev->mt76.hw); in mt7603_mac_watchdog_reset()
1429 set_bit(MT76_RESET, &dev->mphy.state); in mt7603_mac_watchdog_reset()
1432 mt76_txq_schedule_all(&dev->mphy); in mt7603_mac_watchdog_reset()
1434 mt76_worker_disable(&dev->mt76.tx_worker); in mt7603_mac_watchdog_reset()
1435 tasklet_disable(&dev->mt76.pre_tbtt_tasklet); in mt7603_mac_watchdog_reset()
1436 napi_disable(&dev->mt76.napi[0]); in mt7603_mac_watchdog_reset()
1437 napi_disable(&dev->mt76.napi[1]); in mt7603_mac_watchdog_reset()
1438 napi_disable(&dev->mt76.tx_napi); in mt7603_mac_watchdog_reset()
1440 mutex_lock(&dev->mt76.mutex); in mt7603_mac_watchdog_reset()
1442 mt7603_beacon_set_timer(dev, -1, 0); in mt7603_mac_watchdog_reset()
1444 if (dev->reset_cause[RESET_CAUSE_RESET_FAILED] || in mt7603_mac_watchdog_reset()
1445 dev->cur_reset_cause == RESET_CAUSE_RX_PSE_BUSY || in mt7603_mac_watchdog_reset()
1446 dev->cur_reset_cause == RESET_CAUSE_BEACON_STUCK || in mt7603_mac_watchdog_reset()
1447 dev->cur_reset_cause == RESET_CAUSE_TX_HANG) in mt7603_mac_watchdog_reset()
1450 if (dev->reset_cause[RESET_CAUSE_RESET_FAILED]) in mt7603_mac_watchdog_reset()
1466 mt76_queue_tx_cleanup(dev, dev->mt76.q_mcu[MT_MCUQ_WM], true); in mt7603_mac_watchdog_reset()
1468 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[i], true); in mt7603_mac_watchdog_reset()
1470 mt76_for_each_q_rx(&dev->mt76, i) { in mt7603_mac_watchdog_reset()
1474 mt76_tx_status_check(&dev->mt76, true); in mt7603_mac_watchdog_reset()
1483 clear_bit(MT76_RESET, &dev->mphy.state); in mt7603_mac_watchdog_reset()
1484 mutex_unlock(&dev->mt76.mutex); in mt7603_mac_watchdog_reset()
1486 mt76_worker_enable(&dev->mt76.tx_worker); in mt7603_mac_watchdog_reset()
1488 tasklet_enable(&dev->mt76.pre_tbtt_tasklet); in mt7603_mac_watchdog_reset()
1489 mt7603_beacon_set_timer(dev, -1, beacon_int); in mt7603_mac_watchdog_reset()
1492 napi_enable(&dev->mt76.tx_napi); in mt7603_mac_watchdog_reset()
1493 napi_schedule(&dev->mt76.tx_napi); in mt7603_mac_watchdog_reset()
1495 napi_enable(&dev->mt76.napi[0]); in mt7603_mac_watchdog_reset()
1496 napi_schedule(&dev->mt76.napi[0]); in mt7603_mac_watchdog_reset()
1498 napi_enable(&dev->mt76.napi[1]); in mt7603_mac_watchdog_reset()
1499 napi_schedule(&dev->mt76.napi[1]); in mt7603_mac_watchdog_reset()
1502 ieee80211_wake_queues(dev->mt76.hw); in mt7603_mac_watchdog_reset()
1503 mt76_txq_schedule_all(&dev->mphy); in mt7603_mac_watchdog_reset()
1552 q = dev->mphy.q_tx[i]; in mt7603_tx_hang()
1554 if (!q->queued) in mt7603_tx_hang()
1557 prev_dma_idx = dev->tx_dma_idx[i]; in mt7603_tx_hang()
1558 dma_idx = readl(&q->regs->dma_idx); in mt7603_tx_hang()
1559 dev->tx_dma_idx[i] = dma_idx; in mt7603_tx_hang()
1562 dma_idx != readl(&q->regs->cpu_idx)) in mt7603_tx_hang()
1594 if (dev->reset_test == cause + 1) { in mt7603_watchdog_check()
1595 dev->reset_test = 0; in mt7603_watchdog_check()
1611 dev->cur_reset_cause = cause; in mt7603_watchdog_check()
1612 dev->reset_cause[cause]++; in mt7603_watchdog_check()
1618 struct mt7603_dev *dev = container_of(mphy->dev, struct mt7603_dev, mt76); in mt7603_update_channel()
1621 state = mphy->chan_state; in mt7603_update_channel()
1622 state->cc_busy += mt76_rr(dev, MT_MIB_STAT_CCA); in mt7603_update_channel()
1630 if (val == dev->ed_strict_mode) in mt7603_edcca_set_strict()
1633 dev->ed_strict_mode = val; in mt7603_edcca_set_strict()
1636 if (!dev->ed_monitor) in mt7603_edcca_set_strict()
1641 if (dev->ed_monitor && !dev->ed_strict_mode) in mt7603_edcca_set_strict()
1649 dev->ed_monitor && !dev->ed_strict_mode); in mt7603_edcca_set_strict()
1661 if (!dev->ed_monitor) in mt7603_edcca_check()
1666 rssi0 -= 256; in mt7603_edcca_check()
1668 if (dev->mphy.antenna_mask & BIT(1)) { in mt7603_edcca_check()
1671 rssi1 -= 256; in mt7603_edcca_check()
1676 if (max(rssi0, rssi1) >= -40 && in mt7603_edcca_check()
1677 dev->ed_strong_signal < MT7603_EDCCA_BLOCK_TH) in mt7603_edcca_check()
1678 dev->ed_strong_signal++; in mt7603_edcca_check()
1679 else if (dev->ed_strong_signal > 0) in mt7603_edcca_check()
1680 dev->ed_strong_signal--; in mt7603_edcca_check()
1685 active = ktime_to_us(ktime_sub(cur_time, dev->ed_time)); in mt7603_edcca_check()
1686 dev->ed_time = cur_time; in mt7603_edcca_check()
1692 if (dev->ed_trigger < 0) in mt7603_edcca_check()
1693 dev->ed_trigger = 0; in mt7603_edcca_check()
1694 dev->ed_trigger++; in mt7603_edcca_check()
1696 if (dev->ed_trigger > 0) in mt7603_edcca_check()
1697 dev->ed_trigger = 0; in mt7603_edcca_check()
1698 dev->ed_trigger--; in mt7603_edcca_check()
1701 if (dev->ed_trigger > MT7603_EDCCA_BLOCK_TH || in mt7603_edcca_check()
1702 dev->ed_strong_signal < MT7603_EDCCA_BLOCK_TH / 2) { in mt7603_edcca_check()
1704 } else if (dev->ed_trigger < -MT7603_EDCCA_BLOCK_TH) { in mt7603_edcca_check()
1708 if (dev->ed_trigger > MT7603_EDCCA_BLOCK_TH) in mt7603_edcca_check()
1709 dev->ed_trigger = MT7603_EDCCA_BLOCK_TH; in mt7603_edcca_check()
1710 else if (dev->ed_trigger < -MT7603_EDCCA_BLOCK_TH) in mt7603_edcca_check()
1711 dev->ed_trigger = -MT7603_EDCCA_BLOCK_TH; in mt7603_edcca_check()
1724 u32 agc0 = dev->agc0, agc3 = dev->agc3; in mt7603_adjust_sensitivity()
1725 u32 adj; in mt7603_adjust_sensitivity() local
1727 if (!dev->sensitivity || dev->sensitivity < -100) { in mt7603_adjust_sensitivity()
1728 dev->sensitivity = 0; in mt7603_adjust_sensitivity()
1729 } else if (dev->sensitivity <= -84) { in mt7603_adjust_sensitivity()
1730 adj = 7 + (dev->sensitivity + 92) / 2; in mt7603_adjust_sensitivity()
1733 agc0 |= adj << 12; in mt7603_adjust_sensitivity()
1734 agc0 |= adj << 16; in mt7603_adjust_sensitivity()
1736 } else if (dev->sensitivity <= -72) { in mt7603_adjust_sensitivity()
1737 adj = 7 + (dev->sensitivity + 80) / 2; in mt7603_adjust_sensitivity()
1740 agc0 |= adj << 8; in mt7603_adjust_sensitivity()
1741 agc0 |= adj << 12; in mt7603_adjust_sensitivity()
1742 agc0 |= adj << 16; in mt7603_adjust_sensitivity()
1746 if (dev->sensitivity > -54) in mt7603_adjust_sensitivity()
1747 dev->sensitivity = -54; in mt7603_adjust_sensitivity()
1749 adj = 7 + (dev->sensitivity + 80) / 2; in mt7603_adjust_sensitivity()
1752 agc0 |= adj << 4; in mt7603_adjust_sensitivity()
1753 agc0 |= adj << 8; in mt7603_adjust_sensitivity()
1754 agc0 |= adj << 12; in mt7603_adjust_sensitivity()
1755 agc0 |= adj << 16; in mt7603_adjust_sensitivity()
1775 if (!dev->dynamic_sensitivity) in mt7603_false_cca_check()
1786 dev->false_cca_ofdm = pd_ofdm - mdrdy_ofdm; in mt7603_false_cca_check()
1787 dev->false_cca_cck = pd_cck - mdrdy_cck; in mt7603_false_cca_check()
1791 min_signal = mt76_get_min_avg_rssi(&dev->mt76, false); in mt7603_false_cca_check()
1793 dev->sensitivity = 0; in mt7603_false_cca_check()
1794 dev->last_cca_adj = jiffies; in mt7603_false_cca_check()
1798 min_signal -= 15; in mt7603_false_cca_check()
1800 false_cca = dev->false_cca_ofdm + dev->false_cca_cck; in mt7603_false_cca_check()
1802 dev->sensitivity < -100 + dev->sensitivity_limit) { in mt7603_false_cca_check()
1803 if (!dev->sensitivity) in mt7603_false_cca_check()
1804 dev->sensitivity = -92; in mt7603_false_cca_check()
1806 dev->sensitivity += 2; in mt7603_false_cca_check()
1807 dev->last_cca_adj = jiffies; in mt7603_false_cca_check()
1809 time_after(jiffies, dev->last_cca_adj + 10 * HZ)) { in mt7603_false_cca_check()
1810 dev->last_cca_adj = jiffies; in mt7603_false_cca_check()
1811 if (!dev->sensitivity) in mt7603_false_cca_check()
1814 dev->sensitivity -= 2; in mt7603_false_cca_check()
1817 if (dev->sensitivity && dev->sensitivity > min_signal) { in mt7603_false_cca_check()
1818 dev->sensitivity = min_signal; in mt7603_false_cca_check()
1819 dev->last_cca_adj = jiffies; in mt7603_false_cca_check()
1833 mt76_tx_status_check(&dev->mt76, false); in mt7603_mac_work()
1835 mutex_lock(&dev->mt76.mutex); in mt7603_mac_work()
1837 dev->mphy.mac_work_count++; in mt7603_mac_work()
1838 mt76_update_survey(&dev->mphy); in mt7603_mac_work()
1844 dev->mphy.aggr_stats[idx++] += val & 0xffff; in mt7603_mac_work()
1845 dev->mphy.aggr_stats[idx++] += val >> 16; in mt7603_mac_work()
1848 if (dev->mphy.mac_work_count == 10) in mt7603_mac_work()
1851 if (mt7603_watchdog_check(dev, &dev->rx_pse_check, in mt7603_mac_work()
1854 mt7603_watchdog_check(dev, &dev->beacon_check, in mt7603_mac_work()
1857 mt7603_watchdog_check(dev, &dev->tx_hang_check, in mt7603_mac_work()
1860 mt7603_watchdog_check(dev, &dev->tx_dma_check, in mt7603_mac_work()
1863 mt7603_watchdog_check(dev, &dev->rx_dma_check, in mt7603_mac_work()
1866 mt7603_watchdog_check(dev, &dev->mcu_hang, in mt7603_mac_work()
1869 dev->reset_cause[RESET_CAUSE_RESET_FAILED]) { in mt7603_mac_work()
1870 dev->beacon_check = 0; in mt7603_mac_work()
1871 dev->tx_dma_check = 0; in mt7603_mac_work()
1872 dev->tx_hang_check = 0; in mt7603_mac_work()
1873 dev->rx_dma_check = 0; in mt7603_mac_work()
1874 dev->rx_pse_check = 0; in mt7603_mac_work()
1875 dev->mcu_hang = 0; in mt7603_mac_work()
1876 dev->rx_dma_idx = ~0; in mt7603_mac_work()
1877 memset(dev->tx_dma_idx, 0xff, sizeof(dev->tx_dma_idx)); in mt7603_mac_work()
1879 dev->mphy.mac_work_count = 0; in mt7603_mac_work()
1882 if (dev->mphy.mac_work_count >= 10) in mt7603_mac_work()
1883 dev->mphy.mac_work_count = 0; in mt7603_mac_work()
1885 mutex_unlock(&dev->mt76.mutex); in mt7603_mac_work()
1890 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mphy.mac_work, in mt7603_mac_work()