Lines Matching +full:delta +full:- +full:x +full:- +full:threshold
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
6 * Copyright(c) 2018, 2020-2021 Intel Corporation
18 #include "iwl-trans.h"
19 #include "iwl-io.h"
34 struct iwl_error_resp *err_resp = (void *)pkt->data; in iwlagn_rx_reply_error()
36 IWL_ERR(priv, "Error Reply type 0x%08X cmd REPLY_ERROR (0x%02X) " in iwlagn_rx_reply_error()
37 "seq 0x%04X ser 0x%08X\n", in iwlagn_rx_reply_error()
38 le32_to_cpu(err_resp->error_type), in iwlagn_rx_reply_error()
39 err_resp->cmd_id, in iwlagn_rx_reply_error()
40 le16_to_cpu(err_resp->bad_cmd_seq_num), in iwlagn_rx_reply_error()
41 le32_to_cpu(err_resp->error_info)); in iwlagn_rx_reply_error()
47 struct iwl_csa_notification *csa = (void *)pkt->data; in iwlagn_rx_csa()
49 * MULTI-FIXME in iwlagn_rx_csa()
52 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; in iwlagn_rx_csa()
53 struct iwl_rxon_cmd *rxon = (void *)&ctx->active; in iwlagn_rx_csa()
55 if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) in iwlagn_rx_csa()
58 if (!le32_to_cpu(csa->status) && csa->channel == priv->switch_channel) { in iwlagn_rx_csa()
59 rxon->channel = csa->channel; in iwlagn_rx_csa()
60 ctx->staging.channel = csa->channel; in iwlagn_rx_csa()
62 le16_to_cpu(csa->channel)); in iwlagn_rx_csa()
66 le16_to_cpu(csa->channel)); in iwlagn_rx_csa()
76 struct iwl_spectrum_notification *report = (void *)pkt->data; in iwlagn_rx_spectrum_measure_notif()
78 if (!report->state) { in iwlagn_rx_spectrum_measure_notif()
84 memcpy(&priv->measure_report, report, sizeof(*report)); in iwlagn_rx_spectrum_measure_notif()
85 priv->measurement_status |= MEASUREMENT_READY; in iwlagn_rx_spectrum_measure_notif()
93 struct iwl_sleep_notification *sleep = (void *)pkt->data; in iwlagn_rx_pm_sleep_notif()
95 sleep->pm_sleep_mode, sleep->pm_wakeup_src); in iwlagn_rx_pm_sleep_notif()
106 iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->data, len); in iwlagn_rx_pm_debug_statistics_notif()
113 struct iwlagn_beacon_notif *beacon = (void *)pkt->data; in iwlagn_rx_beacon_notif()
115 u16 status = le16_to_cpu(beacon->beacon_notify_hdr.status.status); in iwlagn_rx_beacon_notif()
116 u8 rate = iwl_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); in iwlagn_rx_beacon_notif()
118 IWL_DEBUG_RX(priv, "beacon status %#x, retries:%d ibssmgr:%d " in iwlagn_rx_beacon_notif()
119 "tsf:0x%.8x%.8x rate:%d\n", in iwlagn_rx_beacon_notif()
121 beacon->beacon_notify_hdr.failure_frame, in iwlagn_rx_beacon_notif()
122 le32_to_cpu(beacon->ibss_mgr_status), in iwlagn_rx_beacon_notif()
123 le32_to_cpu(beacon->high_tsf), in iwlagn_rx_beacon_notif()
124 le32_to_cpu(beacon->low_tsf), rate); in iwlagn_rx_beacon_notif()
127 priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); in iwlagn_rx_beacon_notif()
131 * iwl_good_plcp_health - checks for plcp error.
141 int delta; in iwlagn_good_plcp_health() local
142 int threshold = priv->plcp_delta_threshold; in iwlagn_good_plcp_health() local
144 if (threshold == IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE) { in iwlagn_good_plcp_health()
149 delta = le32_to_cpu(cur_ofdm->plcp_err) - in iwlagn_good_plcp_health()
150 le32_to_cpu(priv->statistics.rx_ofdm.plcp_err) + in iwlagn_good_plcp_health()
151 le32_to_cpu(cur_ofdm_ht->plcp_err) - in iwlagn_good_plcp_health()
152 le32_to_cpu(priv->statistics.rx_ofdm_ht.plcp_err); in iwlagn_good_plcp_health()
155 if (delta <= 0) in iwlagn_good_plcp_health()
158 if ((delta * 100 / msecs) > threshold) { in iwlagn_good_plcp_health()
160 "plcp health threshold %u delta %d msecs %u\n", in iwlagn_good_plcp_health()
161 threshold, delta, msecs); in iwlagn_good_plcp_health()
172 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) in iwl_force_rf_reset()
173 return -EAGAIN; in iwl_force_rf_reset()
177 return -ENOLINK; in iwl_force_rf_reset()
180 rf_reset = &priv->rf_reset; in iwl_force_rf_reset()
181 rf_reset->reset_request_count++; in iwl_force_rf_reset()
182 if (!external && rf_reset->last_reset_jiffies && in iwl_force_rf_reset()
183 time_after(rf_reset->last_reset_jiffies + in iwl_force_rf_reset()
186 rf_reset->reset_reject_count++; in iwl_force_rf_reset()
187 return -EAGAIN; in iwl_force_rf_reset()
189 rf_reset->reset_success_count++; in iwl_force_rf_reset()
190 rf_reset->last_reset_jiffies = jiffies; in iwl_force_rf_reset()
215 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) in iwlagn_recover_from_statistics()
218 msecs = jiffies_to_msecs(stamp - priv->rx_statistics_jiffies); in iwlagn_recover_from_statistics()
243 rx_info = &priv->statistics.rx_non_phy; in iwlagn_rx_calc_noise()
246 le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; in iwlagn_rx_calc_noise()
248 le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; in iwlagn_rx_calc_noise()
250 le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; in iwlagn_rx_calc_noise()
267 last_rx_noise = (total_silence / num_active_rx) - 107; in iwlagn_rx_calc_noise()
280 * the case of counters roll-over.
282 static void accum_stats(__le32 *prev, __le32 *cur, __le32 *delta, in accum_stats() argument
289 i++, prev++, cur++, delta++, max_delta++, accum++) { in accum_stats()
291 *delta = cpu_to_le32( in accum_stats()
292 le32_to_cpu(*cur) - le32_to_cpu(*prev)); in accum_stats()
293 le32_add_cpu(accum, le32_to_cpu(*delta)); in accum_stats()
294 if (le32_to_cpu(*delta) > le32_to_cpu(*max_delta)) in accum_stats()
295 *max_delta = *delta; in accum_stats()
311 accum_stats((__le32 *)&priv->statistics._name, \ in iwlagn_accumulative_statistics()
313 (__le32 *)&priv->delta_stats._name, \ in iwlagn_accumulative_statistics()
314 (__le32 *)&priv->max_delta_stats._name, \ in iwlagn_accumulative_statistics()
315 (__le32 *)&priv->accum_stats._name, \ in iwlagn_accumulative_statistics()
362 spin_lock(&priv->statistics.lock); in iwlagn_rx_statistics()
366 stats = (void *)&pkt->data; in iwlagn_rx_statistics()
367 flag = &stats->flag; in iwlagn_rx_statistics()
368 common = &stats->general.common; in iwlagn_rx_statistics()
369 rx_non_phy = &stats->rx.general.common; in iwlagn_rx_statistics()
370 rx_ofdm = &stats->rx.ofdm; in iwlagn_rx_statistics()
371 rx_ofdm_ht = &stats->rx.ofdm_ht; in iwlagn_rx_statistics()
372 rx_cck = &stats->rx.cck; in iwlagn_rx_statistics()
373 tx = &stats->tx; in iwlagn_rx_statistics()
374 bt_activity = &stats->general.activity; in iwlagn_rx_statistics()
378 priv->statistics.num_bt_kills = stats->rx.general.num_bt_kills; in iwlagn_rx_statistics()
379 le32_add_cpu(&priv->statistics.accum_num_bt_kills, in iwlagn_rx_statistics()
380 le32_to_cpu(stats->rx.general.num_bt_kills)); in iwlagn_rx_statistics()
384 stats = (void *)&pkt->data; in iwlagn_rx_statistics()
385 flag = &stats->flag; in iwlagn_rx_statistics()
386 common = &stats->general.common; in iwlagn_rx_statistics()
387 rx_non_phy = &stats->rx.general; in iwlagn_rx_statistics()
388 rx_ofdm = &stats->rx.ofdm; in iwlagn_rx_statistics()
389 rx_ofdm_ht = &stats->rx.ofdm_ht; in iwlagn_rx_statistics()
390 rx_cck = &stats->rx.cck; in iwlagn_rx_statistics()
391 tx = &stats->tx; in iwlagn_rx_statistics()
397 spin_unlock(&priv->statistics.lock); in iwlagn_rx_statistics()
401 change = common->temperature != priv->statistics.common.temperature || in iwlagn_rx_statistics()
403 (priv->statistics.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK); in iwlagn_rx_statistics()
410 priv->statistics.flag = *flag; in iwlagn_rx_statistics()
411 memcpy(&priv->statistics.common, common, sizeof(*common)); in iwlagn_rx_statistics()
412 memcpy(&priv->statistics.rx_non_phy, rx_non_phy, sizeof(*rx_non_phy)); in iwlagn_rx_statistics()
413 memcpy(&priv->statistics.rx_ofdm, rx_ofdm, sizeof(*rx_ofdm)); in iwlagn_rx_statistics()
414 memcpy(&priv->statistics.rx_ofdm_ht, rx_ofdm_ht, sizeof(*rx_ofdm_ht)); in iwlagn_rx_statistics()
415 memcpy(&priv->statistics.rx_cck, rx_cck, sizeof(*rx_cck)); in iwlagn_rx_statistics()
416 memcpy(&priv->statistics.tx, tx, sizeof(*tx)); in iwlagn_rx_statistics()
419 memcpy(&priv->statistics.bt_activity, bt_activity, in iwlagn_rx_statistics()
423 priv->rx_statistics_jiffies = stamp; in iwlagn_rx_statistics()
425 set_bit(STATUS_STATISTICS, &priv->status); in iwlagn_rx_statistics()
431 mod_timer(&priv->statistics_periodic, jiffies + in iwlagn_rx_statistics()
434 if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && in iwlagn_rx_statistics()
435 (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { in iwlagn_rx_statistics()
437 queue_work(priv->workqueue, &priv->run_time_calib_work); in iwlagn_rx_statistics()
439 if (priv->lib->temperature && change) in iwlagn_rx_statistics()
440 priv->lib->temperature(priv); in iwlagn_rx_statistics()
442 spin_unlock(&priv->statistics.lock); in iwlagn_rx_statistics()
449 struct iwl_notif_statistics *stats = (void *)pkt->data; in iwlagn_rx_reply_statistics()
451 if (le32_to_cpu(stats->flag) & UCODE_STATISTICS_CLEAR_MSK) { in iwlagn_rx_reply_statistics()
453 memset(&priv->accum_stats, 0, in iwlagn_rx_reply_statistics()
454 sizeof(priv->accum_stats)); in iwlagn_rx_reply_statistics()
455 memset(&priv->delta_stats, 0, in iwlagn_rx_reply_statistics()
456 sizeof(priv->delta_stats)); in iwlagn_rx_reply_statistics()
457 memset(&priv->max_delta_stats, 0, in iwlagn_rx_reply_statistics()
458 sizeof(priv->max_delta_stats)); in iwlagn_rx_reply_statistics()
472 struct iwl_card_state_notif *card_state_notif = (void *)pkt->data; in iwlagn_rx_card_state_notif()
473 u32 flags = le32_to_cpu(card_state_notif->flags); in iwlagn_rx_card_state_notif()
474 unsigned long status = priv->status; in iwlagn_rx_card_state_notif()
485 iwl_write32(priv->trans, CSR_UCODE_DRV_GP1_SET, in iwlagn_rx_card_state_notif()
488 iwl_write_direct32(priv->trans, HBUS_TARG_MBX_C, in iwlagn_rx_card_state_notif()
492 iwl_write32(priv->trans, CSR_UCODE_DRV_GP1_CLR, in iwlagn_rx_card_state_notif()
494 iwl_write_direct32(priv->trans, HBUS_TARG_MBX_C, in iwlagn_rx_card_state_notif()
504 set_bit(STATUS_RF_KILL_HW, &priv->status); in iwlagn_rx_card_state_notif()
506 clear_bit(STATUS_RF_KILL_HW, &priv->status); in iwlagn_rx_card_state_notif()
513 test_bit(STATUS_RF_KILL_HW, &priv->status))) in iwlagn_rx_card_state_notif()
514 wiphy_rfkill_set_hw_state(priv->hw->wiphy, in iwlagn_rx_card_state_notif()
515 test_bit(STATUS_RF_KILL_HW, &priv->status)); in iwlagn_rx_card_state_notif()
523 struct iwl_missed_beacon_notif *missed_beacon = (void *)pkt->data; in iwlagn_rx_missed_beacon_notif()
525 if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > in iwlagn_rx_missed_beacon_notif()
526 priv->missed_beacon_threshold) { in iwlagn_rx_missed_beacon_notif()
529 le32_to_cpu(missed_beacon->consecutive_missed_beacons), in iwlagn_rx_missed_beacon_notif()
530 le32_to_cpu(missed_beacon->total_missed_becons), in iwlagn_rx_missed_beacon_notif()
531 le32_to_cpu(missed_beacon->num_recvd_beacons), in iwlagn_rx_missed_beacon_notif()
532 le32_to_cpu(missed_beacon->num_expected_beacons)); in iwlagn_rx_missed_beacon_notif()
533 if (!test_bit(STATUS_SCANNING, &priv->status)) in iwlagn_rx_missed_beacon_notif()
545 priv->last_phy_res_valid = true; in iwlagn_rx_reply_rx_phy()
546 priv->ampdu_ref++; in iwlagn_rx_reply_rx_phy()
547 memcpy(&priv->last_phy_res, pkt->data, in iwlagn_rx_reply_rx_phy()
552 * returns non-zero if packet should be dropped
559 u16 fc = le16_to_cpu(hdr->frame_control); in iwlagn_set_decrypted_flag()
565 if (priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags & in iwlagn_set_decrypted_flag()
572 IWL_DEBUG_RX(priv, "decrypt_res:0x%x\n", decrypt_res); in iwlagn_set_decrypted_flag()
587 return -1; in iwlagn_set_decrypted_flag()
594 stats->flag |= RX_FLAG_DECRYPTED; in iwlagn_set_decrypted_flag()
612 __le16 fc = hdr->frame_control; in iwlagn_pass_packet_to_mac80211()
617 if (unlikely(!priv->is_open)) { in iwlagn_pass_packet_to_mac80211()
636 /* If frame is small enough to fit in skb->head, pull it completely. in iwlagn_pass_packet_to_mac80211()
643 fraglen = len - hdrlen; in iwlagn_pass_packet_to_mac80211()
646 int offset = (void *)hdr + hdrlen - in iwlagn_pass_packet_to_mac80211()
650 fraglen, rxb->truesize); in iwlagn_pass_packet_to_mac80211()
660 if (unlikely(ieee80211_is_beacon(fc) && priv->passive_no_rx)) { in iwlagn_pass_packet_to_mac80211()
662 if (!ether_addr_equal(hdr->addr3, in iwlagn_pass_packet_to_mac80211()
663 ctx->active.bssid_addr)) in iwlagn_pass_packet_to_mac80211()
671 ieee80211_rx_napi(priv->hw, NULL, skb, priv->napi); in iwlagn_pass_packet_to_mac80211()
727 IWL_DEBUG_RX(priv, "decrypt_in:0x%x decrypt_out = 0x%x\n", in iwlagn_translate_rx_status()
741 (struct iwlagn_non_cfg_phy *)rx_resp->non_cfg_phy_buf; in iwlagn_calc_rssi()
745 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_AGC_IDX]); in iwlagn_calc_rssi()
754 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_RSSI_AB_IDX]); in iwlagn_calc_rssi()
759 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_RSSI_C_IDX]); in iwlagn_calc_rssi()
769 /* dBm = max_rssi dB - agc dB - constant. in iwlagn_calc_rssi()
771 return max_rssi - agc - IWLAGN_RSSI_OFFSET; in iwlagn_calc_rssi()
788 if (!priv->last_phy_res_valid) { in iwlagn_rx_reply_rx()
798 phy_res = &priv->last_phy_res; in iwlagn_rx_reply_rx()
799 amsdu = (struct iwl_rx_mpdu_res_start *)pkt->data; in iwlagn_rx_reply_rx()
800 header = (struct ieee80211_hdr *)(pkt->data + sizeof(*amsdu)); in iwlagn_rx_reply_rx()
801 len = le16_to_cpu(amsdu->byte_count); in iwlagn_rx_reply_rx()
808 rx_pkt_status = *(__le32 *)(pkt->data + sizeof(*amsdu) + len); in iwlagn_rx_reply_rx()
812 if ((unlikely(phy_res->cfg_phy_cnt > 20))) { in iwlagn_rx_reply_rx()
814 phy_res->cfg_phy_cnt); in iwlagn_rx_reply_rx()
820 IWL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n", in iwlagn_rx_reply_rx()
826 rate_n_flags = le32_to_cpu(phy_res->rate_n_flags); in iwlagn_rx_reply_rx()
829 rx_status.mactime = le64_to_cpu(phy_res->timestamp); in iwlagn_rx_reply_rx()
830 rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? in iwlagn_rx_reply_rx()
833 ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel), in iwlagn_rx_reply_rx()
843 priv->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); in iwlagn_rx_reply_rx()
865 (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) in iwlagn_rx_reply_rx()
869 if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) in iwlagn_rx_reply_rx()
872 if (phy_res->phy_flags & RX_RES_PHY_FLAGS_AGG_MSK) { in iwlagn_rx_reply_rx()
874 * We know which subframes of an A-MPDU belong in iwlagn_rx_reply_rx()
879 rx_status.ampdu_reference = priv->ampdu_ref; in iwlagn_rx_reply_rx()
903 struct iwl_wipan_noa_notification *noa_notif = (void *)pkt->data; in iwlagn_rx_noa_notification()
905 /* no condition -- we're in softirq */ in iwlagn_rx_noa_notification()
906 old_data = rcu_dereference_protected(priv->noa_data, true); in iwlagn_rx_noa_notification()
908 if (noa_notif->noa_active) { in iwlagn_rx_noa_notification()
909 u32 len = le16_to_cpu(noa_notif->noa_attribute.length); in iwlagn_rx_noa_notification()
920 new_data->length = len; in iwlagn_rx_noa_notification()
921 new_data->data[0] = WLAN_EID_VENDOR_SPECIFIC; in iwlagn_rx_noa_notification()
922 new_data->data[1] = len - 2; /* not counting EID, len */ in iwlagn_rx_noa_notification()
923 new_data->data[2] = (WLAN_OUI_WFA >> 16) & 0xff; in iwlagn_rx_noa_notification()
924 new_data->data[3] = (WLAN_OUI_WFA >> 8) & 0xff; in iwlagn_rx_noa_notification()
925 new_data->data[4] = (WLAN_OUI_WFA >> 0) & 0xff; in iwlagn_rx_noa_notification()
926 new_data->data[5] = WLAN_OUI_TYPE_WFA_P2P; in iwlagn_rx_noa_notification()
927 memcpy(&new_data->data[6], &noa_notif->noa_attribute, in iwlagn_rx_noa_notification()
933 rcu_assign_pointer(priv->noa_data, new_data); in iwlagn_rx_noa_notification()
940 * iwl_setup_rx_handlers - Initialize Rx handler callbacks
949 handlers = priv->rx_handlers; in iwl_setup_rx_handlers()
985 priv->rx_handlers[REPLY_TX] = iwlagn_rx_reply_tx; in iwl_setup_rx_handlers()
988 iwl_notification_wait_init(&priv->notif_wait); in iwl_setup_rx_handlers()
991 if (priv->lib->bt_params) in iwl_setup_rx_handlers()
1006 iwl_notification_wait_notify(&priv->notif_wait, pkt); in iwl_rx_dispatch()
1011 if (priv->rx_handlers[pkt->hdr.cmd]) { in iwl_rx_dispatch()
1012 priv->rx_handlers_stats[pkt->hdr.cmd]++; in iwl_rx_dispatch()
1013 priv->rx_handlers[pkt->hdr.cmd](priv, rxb); in iwl_rx_dispatch()
1016 IWL_DEBUG_RX(priv, "No handler needed for %s, 0x%02x\n", in iwl_rx_dispatch()
1017 iwl_get_cmd_string(priv->trans, in iwl_rx_dispatch()
1018 WIDE_ID(0, pkt->hdr.cmd)), in iwl_rx_dispatch()
1019 pkt->hdr.cmd); in iwl_rx_dispatch()