diff options
author | Stanislaw Gruszka <sgruszka@redhat.com> | 2011-02-28 08:33:17 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-02-28 14:11:36 -0500 |
commit | 67289941d80f18fd8239e350e015a4b84878412b (patch) | |
tree | acc5e98bfdc1f1fcf19ac0bc7698fa6f581cc5a6 /drivers/net/wireless/iwlwifi/iwl-rx.c | |
parent | ad6e82a5348e494c0023d77fa55933f23b55711c (diff) |
iwlwifi: move remaining iwl-agn-rx.c code into iwl-rx.c
There is no need to have separate iwl-agn-rx.c file after iwlegacy
split.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-rx.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-rx.c | 226 |
1 files changed, 224 insertions, 2 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c index feee76181ac5..566e2d979ce3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-rx.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include "iwl-sta.h" | 37 | #include "iwl-sta.h" |
38 | #include "iwl-io.h" | 38 | #include "iwl-io.h" |
39 | #include "iwl-helpers.h" | 39 | #include "iwl-helpers.h" |
40 | #include "iwl-agn-calib.h" | ||
40 | /************************** RX-FUNCTIONS ****************************/ | 41 | /************************** RX-FUNCTIONS ****************************/ |
41 | /* | 42 | /* |
42 | * Rx theory of operation | 43 | * Rx theory of operation |
@@ -210,7 +211,6 @@ err_bd: | |||
210 | return -ENOMEM; | 211 | return -ENOMEM; |
211 | } | 212 | } |
212 | 213 | ||
213 | |||
214 | void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv, | 214 | void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv, |
215 | struct iwl_rx_mem_buffer *rxb) | 215 | struct iwl_rx_mem_buffer *rxb) |
216 | { | 216 | { |
@@ -378,7 +378,7 @@ static bool iwl_good_plcp_health(struct iwl_priv *priv, struct iwl_rx_packet *pk | |||
378 | return rc; | 378 | return rc; |
379 | } | 379 | } |
380 | 380 | ||
381 | void iwl_recover_from_statistics(struct iwl_priv *priv, struct iwl_rx_packet *pkt) | 381 | static void iwl_recover_from_statistics(struct iwl_priv *priv, struct iwl_rx_packet *pkt) |
382 | { | 382 | { |
383 | const struct iwl_mod_params *mod_params = priv->cfg->mod_params; | 383 | const struct iwl_mod_params *mod_params = priv->cfg->mod_params; |
384 | 384 | ||
@@ -396,6 +396,228 @@ void iwl_recover_from_statistics(struct iwl_priv *priv, struct iwl_rx_packet *pk | |||
396 | iwl_force_reset(priv, IWL_RF_RESET, false); | 396 | iwl_force_reset(priv, IWL_RF_RESET, false); |
397 | } | 397 | } |
398 | 398 | ||
399 | /* Calculate noise level, based on measurements during network silence just | ||
400 | * before arriving beacon. This measurement can be done only if we know | ||
401 | * exactly when to expect beacons, therefore only when we're associated. */ | ||
402 | static void iwl_rx_calc_noise(struct iwl_priv *priv) | ||
403 | { | ||
404 | struct statistics_rx_non_phy *rx_info; | ||
405 | int num_active_rx = 0; | ||
406 | int total_silence = 0; | ||
407 | int bcn_silence_a, bcn_silence_b, bcn_silence_c; | ||
408 | int last_rx_noise; | ||
409 | |||
410 | if (iwl_bt_statistics(priv)) | ||
411 | rx_info = &(priv->_agn.statistics_bt.rx.general.common); | ||
412 | else | ||
413 | rx_info = &(priv->_agn.statistics.rx.general); | ||
414 | bcn_silence_a = | ||
415 | le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; | ||
416 | bcn_silence_b = | ||
417 | le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; | ||
418 | bcn_silence_c = | ||
419 | le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; | ||
420 | |||
421 | if (bcn_silence_a) { | ||
422 | total_silence += bcn_silence_a; | ||
423 | num_active_rx++; | ||
424 | } | ||
425 | if (bcn_silence_b) { | ||
426 | total_silence += bcn_silence_b; | ||
427 | num_active_rx++; | ||
428 | } | ||
429 | if (bcn_silence_c) { | ||
430 | total_silence += bcn_silence_c; | ||
431 | num_active_rx++; | ||
432 | } | ||
433 | |||
434 | /* Average among active antennas */ | ||
435 | if (num_active_rx) | ||
436 | last_rx_noise = (total_silence / num_active_rx) - 107; | ||
437 | else | ||
438 | last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE; | ||
439 | |||
440 | IWL_DEBUG_CALIB(priv, "inband silence a %u, b %u, c %u, dBm %d\n", | ||
441 | bcn_silence_a, bcn_silence_b, bcn_silence_c, | ||
442 | last_rx_noise); | ||
443 | } | ||
444 | |||
445 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
446 | /* | ||
447 | * based on the assumption of all statistics counter are in DWORD | ||
448 | * FIXME: This function is for debugging, do not deal with | ||
449 | * the case of counters roll-over. | ||
450 | */ | ||
451 | static void iwl_accumulative_statistics(struct iwl_priv *priv, | ||
452 | __le32 *stats) | ||
453 | { | ||
454 | int i, size; | ||
455 | __le32 *prev_stats; | ||
456 | u32 *accum_stats; | ||
457 | u32 *delta, *max_delta; | ||
458 | struct statistics_general_common *general, *accum_general; | ||
459 | struct statistics_tx *tx, *accum_tx; | ||
460 | |||
461 | if (iwl_bt_statistics(priv)) { | ||
462 | prev_stats = (__le32 *)&priv->_agn.statistics_bt; | ||
463 | accum_stats = (u32 *)&priv->_agn.accum_statistics_bt; | ||
464 | size = sizeof(struct iwl_bt_notif_statistics); | ||
465 | general = &priv->_agn.statistics_bt.general.common; | ||
466 | accum_general = &priv->_agn.accum_statistics_bt.general.common; | ||
467 | tx = &priv->_agn.statistics_bt.tx; | ||
468 | accum_tx = &priv->_agn.accum_statistics_bt.tx; | ||
469 | delta = (u32 *)&priv->_agn.delta_statistics_bt; | ||
470 | max_delta = (u32 *)&priv->_agn.max_delta_bt; | ||
471 | } else { | ||
472 | prev_stats = (__le32 *)&priv->_agn.statistics; | ||
473 | accum_stats = (u32 *)&priv->_agn.accum_statistics; | ||
474 | size = sizeof(struct iwl_notif_statistics); | ||
475 | general = &priv->_agn.statistics.general.common; | ||
476 | accum_general = &priv->_agn.accum_statistics.general.common; | ||
477 | tx = &priv->_agn.statistics.tx; | ||
478 | accum_tx = &priv->_agn.accum_statistics.tx; | ||
479 | delta = (u32 *)&priv->_agn.delta_statistics; | ||
480 | max_delta = (u32 *)&priv->_agn.max_delta; | ||
481 | } | ||
482 | for (i = sizeof(__le32); i < size; | ||
483 | i += sizeof(__le32), stats++, prev_stats++, delta++, | ||
484 | max_delta++, accum_stats++) { | ||
485 | if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { | ||
486 | *delta = (le32_to_cpu(*stats) - | ||
487 | le32_to_cpu(*prev_stats)); | ||
488 | *accum_stats += *delta; | ||
489 | if (*delta > *max_delta) | ||
490 | *max_delta = *delta; | ||
491 | } | ||
492 | } | ||
493 | |||
494 | /* reset accumulative statistics for "no-counter" type statistics */ | ||
495 | accum_general->temperature = general->temperature; | ||
496 | accum_general->temperature_m = general->temperature_m; | ||
497 | accum_general->ttl_timestamp = general->ttl_timestamp; | ||
498 | accum_tx->tx_power.ant_a = tx->tx_power.ant_a; | ||
499 | accum_tx->tx_power.ant_b = tx->tx_power.ant_b; | ||
500 | accum_tx->tx_power.ant_c = tx->tx_power.ant_c; | ||
501 | } | ||
502 | #endif | ||
503 | |||
504 | #define REG_RECALIB_PERIOD (60) | ||
505 | |||
506 | void iwl_rx_statistics(struct iwl_priv *priv, | ||
507 | struct iwl_rx_mem_buffer *rxb) | ||
508 | { | ||
509 | int change; | ||
510 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | ||
511 | |||
512 | if (iwl_bt_statistics(priv)) { | ||
513 | IWL_DEBUG_RX(priv, | ||
514 | "Statistics notification received (%d vs %d).\n", | ||
515 | (int)sizeof(struct iwl_bt_notif_statistics), | ||
516 | le32_to_cpu(pkt->len_n_flags) & | ||
517 | FH_RSCSR_FRAME_SIZE_MSK); | ||
518 | |||
519 | change = ((priv->_agn.statistics_bt.general.common.temperature != | ||
520 | pkt->u.stats_bt.general.common.temperature) || | ||
521 | ((priv->_agn.statistics_bt.flag & | ||
522 | STATISTICS_REPLY_FLG_HT40_MODE_MSK) != | ||
523 | (pkt->u.stats_bt.flag & | ||
524 | STATISTICS_REPLY_FLG_HT40_MODE_MSK))); | ||
525 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
526 | iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats_bt); | ||
527 | #endif | ||
528 | |||
529 | } else { | ||
530 | IWL_DEBUG_RX(priv, | ||
531 | "Statistics notification received (%d vs %d).\n", | ||
532 | (int)sizeof(struct iwl_notif_statistics), | ||
533 | le32_to_cpu(pkt->len_n_flags) & | ||
534 | FH_RSCSR_FRAME_SIZE_MSK); | ||
535 | |||
536 | change = ((priv->_agn.statistics.general.common.temperature != | ||
537 | pkt->u.stats.general.common.temperature) || | ||
538 | ((priv->_agn.statistics.flag & | ||
539 | STATISTICS_REPLY_FLG_HT40_MODE_MSK) != | ||
540 | (pkt->u.stats.flag & | ||
541 | STATISTICS_REPLY_FLG_HT40_MODE_MSK))); | ||
542 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
543 | iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats); | ||
544 | #endif | ||
545 | |||
546 | } | ||
547 | |||
548 | iwl_recover_from_statistics(priv, pkt); | ||
549 | |||
550 | if (iwl_bt_statistics(priv)) | ||
551 | memcpy(&priv->_agn.statistics_bt, &pkt->u.stats_bt, | ||
552 | sizeof(priv->_agn.statistics_bt)); | ||
553 | else | ||
554 | memcpy(&priv->_agn.statistics, &pkt->u.stats, | ||
555 | sizeof(priv->_agn.statistics)); | ||
556 | |||
557 | set_bit(STATUS_STATISTICS, &priv->status); | ||
558 | |||
559 | /* Reschedule the statistics timer to occur in | ||
560 | * REG_RECALIB_PERIOD seconds to ensure we get a | ||
561 | * thermal update even if the uCode doesn't give | ||
562 | * us one */ | ||
563 | mod_timer(&priv->statistics_periodic, jiffies + | ||
564 | msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); | ||
565 | |||
566 | if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && | ||
567 | (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { | ||
568 | iwl_rx_calc_noise(priv); | ||
569 | queue_work(priv->workqueue, &priv->run_time_calib_work); | ||
570 | } | ||
571 | if (priv->cfg->ops->lib->temp_ops.temperature && change) | ||
572 | priv->cfg->ops->lib->temp_ops.temperature(priv); | ||
573 | } | ||
574 | |||
575 | void iwl_reply_statistics(struct iwl_priv *priv, | ||
576 | struct iwl_rx_mem_buffer *rxb) | ||
577 | { | ||
578 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | ||
579 | |||
580 | if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { | ||
581 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
582 | memset(&priv->_agn.accum_statistics, 0, | ||
583 | sizeof(struct iwl_notif_statistics)); | ||
584 | memset(&priv->_agn.delta_statistics, 0, | ||
585 | sizeof(struct iwl_notif_statistics)); | ||
586 | memset(&priv->_agn.max_delta, 0, | ||
587 | sizeof(struct iwl_notif_statistics)); | ||
588 | memset(&priv->_agn.accum_statistics_bt, 0, | ||
589 | sizeof(struct iwl_bt_notif_statistics)); | ||
590 | memset(&priv->_agn.delta_statistics_bt, 0, | ||
591 | sizeof(struct iwl_bt_notif_statistics)); | ||
592 | memset(&priv->_agn.max_delta_bt, 0, | ||
593 | sizeof(struct iwl_bt_notif_statistics)); | ||
594 | #endif | ||
595 | IWL_DEBUG_RX(priv, "Statistics have been cleared\n"); | ||
596 | } | ||
597 | iwl_rx_statistics(priv, rxb); | ||
598 | } | ||
599 | |||
600 | void iwl_rx_missed_beacon_notif(struct iwl_priv *priv, | ||
601 | struct iwl_rx_mem_buffer *rxb) | ||
602 | |||
603 | { | ||
604 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | ||
605 | struct iwl_missed_beacon_notif *missed_beacon; | ||
606 | |||
607 | missed_beacon = &pkt->u.missed_beacon; | ||
608 | if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > | ||
609 | priv->missed_beacon_threshold) { | ||
610 | IWL_DEBUG_CALIB(priv, | ||
611 | "missed bcn cnsq %d totl %d rcd %d expctd %d\n", | ||
612 | le32_to_cpu(missed_beacon->consecutive_missed_beacons), | ||
613 | le32_to_cpu(missed_beacon->total_missed_becons), | ||
614 | le32_to_cpu(missed_beacon->num_recvd_beacons), | ||
615 | le32_to_cpu(missed_beacon->num_expected_beacons)); | ||
616 | if (!test_bit(STATUS_SCANNING, &priv->status)) | ||
617 | iwl_init_sensitivity(priv); | ||
618 | } | ||
619 | } | ||
620 | |||
399 | /* | 621 | /* |
400 | * returns non-zero if packet should be dropped | 622 | * returns non-zero if packet should be dropped |
401 | */ | 623 | */ |