226
226
******************************************************************************/
228
static void iwl_rx_reply_alive(struct iwl_priv *priv,
229
struct iwl_rx_mem_buffer *rxb)
231
struct iwl_rx_packet *pkt = rxb_addr(rxb);
232
struct iwl_alive_resp *palive;
233
struct delayed_work *pwork;
235
palive = &pkt->u.alive_frame;
237
IWL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision "
239
palive->is_valid, palive->ver_type,
240
palive->ver_subtype);
242
if (palive->ver_subtype == INITIALIZE_SUBTYPE) {
243
IWL_DEBUG_INFO(priv, "Initialization Alive received.\n");
244
memcpy(&priv->card_alive_init,
246
sizeof(struct iwl_init_alive_resp));
247
pwork = &priv->init_alive_start;
249
IWL_DEBUG_INFO(priv, "Runtime Alive received.\n");
250
memcpy(&priv->card_alive, &pkt->u.alive_frame,
251
sizeof(struct iwl_alive_resp));
252
pwork = &priv->alive_start;
255
/* We delay the ALIVE response by 5ms to
256
* give the HW RF Kill time to activate... */
257
if (palive->is_valid == UCODE_VALID_OK)
258
queue_delayed_work(priv->workqueue, pwork,
259
msecs_to_jiffies(5));
261
IWL_WARN(priv, "%s uCode did not respond OK.\n",
262
(palive->ver_subtype == INITIALIZE_SUBTYPE) ?
265
* If fail to load init uCode,
266
* let's try to load the init uCode again.
267
* We should not get into this situation, but if it
268
* does happen, we should not move on and loading "runtime"
269
* without proper calibrate the device.
271
if (palive->ver_subtype == INITIALIZE_SUBTYPE)
272
priv->ucode_type = UCODE_NONE;
273
queue_work(priv->workqueue, &priv->restart);
277
228
static void iwl_rx_reply_error(struct iwl_priv *priv,
278
229
struct iwl_rx_mem_buffer *rxb)
499
430
static void iwl_recover_from_statistics(struct iwl_priv *priv,
500
struct iwl_rx_packet *pkt)
431
struct statistics_rx_phy *cur_ofdm,
432
struct statistics_rx_ht_phy *cur_ofdm_ht,
433
struct statistics_tx *tx,
502
const struct iwl_mod_params *mod_params = priv->cfg->mod_params;
503
436
unsigned int msecs;
506
438
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
510
441
msecs = jiffies_to_msecs(stamp - priv->rx_statistics_jiffies);
512
443
/* Only gather statistics and update time stamp when not associated */
513
444
if (!iwl_is_any_associated(priv))
516
447
/* Do not check/recover when do not have enough statistics data */
520
if (mod_params->ack_check && !iwl_good_ack_health(priv, pkt)) {
451
if (iwlagn_mod_params.ack_check && !iwl_good_ack_health(priv, tx)) {
521
452
IWL_ERR(priv, "low ack count detected, restart firmware\n");
522
453
if (!iwl_force_reset(priv, IWL_FW_RESET, false))
526
if (mod_params->plcp_check && !iwl_good_plcp_health(priv, pkt, msecs))
457
if (iwlagn_mod_params.plcp_check &&
458
!iwl_good_plcp_health(priv, cur_ofdm, cur_ofdm_ht, msecs))
527
459
iwl_force_reset(priv, IWL_RF_RESET, false);
530
if (iwl_bt_statistics(priv))
531
memcpy(&priv->_agn.statistics_bt, &pkt->u.stats_bt,
532
sizeof(priv->_agn.statistics_bt));
534
memcpy(&priv->_agn.statistics, &pkt->u.stats,
535
sizeof(priv->_agn.statistics));
537
priv->rx_statistics_jiffies = stamp;
540
462
/* Calculate noise level, based on measurements during network silence just
506
#ifdef CONFIG_IWLWIFI_DEBUGFS
587
508
* based on the assumption of all statistics counter are in DWORD
588
509
* FIXME: This function is for debugging, do not deal with
589
510
* the case of counters roll-over.
591
static void iwl_accumulative_statistics(struct iwl_priv *priv,
512
static void accum_stats(__le32 *prev, __le32 *cur, __le32 *delta,
513
__le32 *max_delta, __le32 *accum, int size)
594
#ifdef CONFIG_IWLWIFI_DEBUGFS
598
u32 *delta, *max_delta;
599
struct statistics_general_common *general, *accum_general;
600
struct statistics_tx *tx, *accum_tx;
602
if (iwl_bt_statistics(priv)) {
603
prev_stats = (__le32 *)&priv->_agn.statistics_bt;
604
accum_stats = (u32 *)&priv->_agn.accum_statistics_bt;
605
size = sizeof(struct iwl_bt_notif_statistics);
606
general = &priv->_agn.statistics_bt.general.common;
607
accum_general = &priv->_agn.accum_statistics_bt.general.common;
608
tx = &priv->_agn.statistics_bt.tx;
609
accum_tx = &priv->_agn.accum_statistics_bt.tx;
610
delta = (u32 *)&priv->_agn.delta_statistics_bt;
611
max_delta = (u32 *)&priv->_agn.max_delta_bt;
613
prev_stats = (__le32 *)&priv->_agn.statistics;
614
accum_stats = (u32 *)&priv->_agn.accum_statistics;
615
size = sizeof(struct iwl_notif_statistics);
616
general = &priv->_agn.statistics.general.common;
617
accum_general = &priv->_agn.accum_statistics.general.common;
618
tx = &priv->_agn.statistics.tx;
619
accum_tx = &priv->_agn.accum_statistics.tx;
620
delta = (u32 *)&priv->_agn.delta_statistics;
621
max_delta = (u32 *)&priv->_agn.max_delta;
623
for (i = sizeof(__le32); i < size;
624
i += sizeof(__le32), stats++, prev_stats++, delta++,
625
max_delta++, accum_stats++) {
626
if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) {
627
*delta = (le32_to_cpu(*stats) -
628
le32_to_cpu(*prev_stats));
629
*accum_stats += *delta;
630
if (*delta > *max_delta)
518
i < size / sizeof(__le32);
519
i++, prev++, cur++, delta++, max_delta++, accum++) {
520
if (le32_to_cpu(*cur) > le32_to_cpu(*prev)) {
521
*delta = cpu_to_le32(
522
le32_to_cpu(*cur) - le32_to_cpu(*prev));
523
le32_add_cpu(accum, le32_to_cpu(*delta));
524
if (le32_to_cpu(*delta) > le32_to_cpu(*max_delta))
631
525
*max_delta = *delta;
635
/* reset accumulative statistics for "no-counter" type statistics */
636
accum_general->temperature = general->temperature;
637
accum_general->temperature_m = general->temperature_m;
638
accum_general->ttl_timestamp = general->ttl_timestamp;
639
accum_tx->tx_power.ant_a = tx->tx_power.ant_a;
640
accum_tx->tx_power.ant_b = tx->tx_power.ant_b;
641
accum_tx->tx_power.ant_c = tx->tx_power.ant_c;
531
iwl_accumulative_statistics(struct iwl_priv *priv,
532
struct statistics_general_common *common,
533
struct statistics_rx_non_phy *rx_non_phy,
534
struct statistics_rx_phy *rx_ofdm,
535
struct statistics_rx_ht_phy *rx_ofdm_ht,
536
struct statistics_rx_phy *rx_cck,
537
struct statistics_tx *tx,
538
struct statistics_bt_activity *bt_activity)
540
#define ACCUM(_name) \
541
accum_stats((__le32 *)&priv->statistics._name, \
543
(__le32 *)&priv->delta_stats._name, \
544
(__le32 *)&priv->max_delta_stats._name, \
545
(__le32 *)&priv->accum_stats._name, \
560
iwl_accumulative_statistics(struct iwl_priv *priv,
561
struct statistics_general_common *common,
562
struct statistics_rx_non_phy *rx_non_phy,
563
struct statistics_rx_phy *rx_ofdm,
564
struct statistics_rx_ht_phy *rx_ofdm_ht,
565
struct statistics_rx_phy *rx_cck,
566
struct statistics_tx *tx,
567
struct statistics_bt_activity *bt_activity)
645
572
static void iwl_rx_statistics(struct iwl_priv *priv,
646
573
struct iwl_rx_mem_buffer *rxb)
575
unsigned long stamp = jiffies;
648
576
const int reg_recalib_period = 60;
650
578
struct iwl_rx_packet *pkt = rxb_addr(rxb);
652
if (iwl_bt_statistics(priv)) {
654
"Statistics notification received (%d vs %d).\n",
655
(int)sizeof(struct iwl_bt_notif_statistics),
656
le32_to_cpu(pkt->len_n_flags) &
657
FH_RSCSR_FRAME_SIZE_MSK);
659
change = ((priv->_agn.statistics_bt.general.common.temperature !=
660
pkt->u.stats_bt.general.common.temperature) ||
661
((priv->_agn.statistics_bt.flag &
662
STATISTICS_REPLY_FLG_HT40_MODE_MSK) !=
663
(pkt->u.stats_bt.flag &
664
STATISTICS_REPLY_FLG_HT40_MODE_MSK)));
666
iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats_bt);
579
u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
581
struct statistics_general_common *common;
582
struct statistics_rx_non_phy *rx_non_phy;
583
struct statistics_rx_phy *rx_ofdm;
584
struct statistics_rx_ht_phy *rx_ofdm_ht;
585
struct statistics_rx_phy *rx_cck;
586
struct statistics_tx *tx;
587
struct statistics_bt_activity *bt_activity;
589
len -= sizeof(struct iwl_cmd_header); /* skip header */
591
IWL_DEBUG_RX(priv, "Statistics notification received (%d bytes).\n",
594
if (len == sizeof(struct iwl_bt_notif_statistics)) {
595
struct iwl_bt_notif_statistics *stats;
596
stats = &pkt->u.stats_bt;
598
common = &stats->general.common;
599
rx_non_phy = &stats->rx.general.common;
600
rx_ofdm = &stats->rx.ofdm;
601
rx_ofdm_ht = &stats->rx.ofdm_ht;
602
rx_cck = &stats->rx.cck;
604
bt_activity = &stats->general.activity;
606
#ifdef CONFIG_IWLWIFI_DEBUGFS
607
/* handle this exception directly */
608
priv->statistics.num_bt_kills = stats->rx.general.num_bt_kills;
609
le32_add_cpu(&priv->statistics.accum_num_bt_kills,
610
le32_to_cpu(stats->rx.general.num_bt_kills));
612
} else if (len == sizeof(struct iwl_notif_statistics)) {
613
struct iwl_notif_statistics *stats;
614
stats = &pkt->u.stats;
616
common = &stats->general.common;
617
rx_non_phy = &stats->rx.general;
618
rx_ofdm = &stats->rx.ofdm;
619
rx_ofdm_ht = &stats->rx.ofdm_ht;
620
rx_cck = &stats->rx.cck;
669
"Statistics notification received (%d vs %d).\n",
670
(int)sizeof(struct iwl_notif_statistics),
671
le32_to_cpu(pkt->len_n_flags) &
672
FH_RSCSR_FRAME_SIZE_MSK);
674
change = ((priv->_agn.statistics.general.common.temperature !=
675
pkt->u.stats.general.common.temperature) ||
676
((priv->_agn.statistics.flag &
677
STATISTICS_REPLY_FLG_HT40_MODE_MSK) !=
679
STATISTICS_REPLY_FLG_HT40_MODE_MSK)));
681
iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats);
624
WARN_ONCE(1, "len %d doesn't match BT (%zu) or normal (%zu)\n",
625
len, sizeof(struct iwl_bt_notif_statistics),
626
sizeof(struct iwl_notif_statistics));
684
iwl_recover_from_statistics(priv, pkt);
630
change = common->temperature != priv->statistics.common.temperature ||
631
(*flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK) !=
632
(priv->statistics.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK);
634
iwl_accumulative_statistics(priv, common, rx_non_phy, rx_ofdm,
635
rx_ofdm_ht, rx_cck, tx, bt_activity);
637
iwl_recover_from_statistics(priv, rx_ofdm, rx_ofdm_ht, tx, stamp);
639
priv->statistics.flag = *flag;
640
memcpy(&priv->statistics.common, common, sizeof(*common));
641
memcpy(&priv->statistics.rx_non_phy, rx_non_phy, sizeof(*rx_non_phy));
642
memcpy(&priv->statistics.rx_ofdm, rx_ofdm, sizeof(*rx_ofdm));
643
memcpy(&priv->statistics.rx_ofdm_ht, rx_ofdm_ht, sizeof(*rx_ofdm_ht));
644
memcpy(&priv->statistics.rx_cck, rx_cck, sizeof(*rx_cck));
645
memcpy(&priv->statistics.tx, tx, sizeof(*tx));
646
#ifdef CONFIG_IWLWIFI_DEBUGFS
648
memcpy(&priv->statistics.bt_activity, bt_activity,
649
sizeof(*bt_activity));
652
priv->rx_statistics_jiffies = stamp;
686
654
set_bit(STATUS_STATISTICS, &priv->status);