aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2011-03-04 11:51:50 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-03-04 14:06:50 -0500
commit6198c387b25b528fd89a48bf67f0402d828ffa18 (patch)
treeab73f90cabb009fa34257c84132a5647be2e89e6
parent466a19a003f3b45a755bc85f967c21da947f9a00 (diff)
iwlwifi: cleanup iwl_good_plcp_health
Make iwl_good_plcp_health code easiest to read. 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>
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c115
1 files changed, 45 insertions, 70 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 8dc129499b90..a70f1eb08e5c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -451,82 +451,57 @@ static bool iwl_good_ack_health(struct iwl_priv *priv, struct iwl_rx_packet *pkt
451static bool iwl_good_plcp_health(struct iwl_priv *priv, 451static bool iwl_good_plcp_health(struct iwl_priv *priv,
452 struct iwl_rx_packet *pkt) 452 struct iwl_rx_packet *pkt)
453{ 453{
454 bool rc = true; 454 unsigned int msecs;
455 int combined_plcp_delta; 455 unsigned long stamp;
456 unsigned int plcp_msec; 456 int delta;
457 unsigned long plcp_received_jiffies; 457 int threshold = priv->cfg->base_params->plcp_delta_threshold;
458 458
459 if (priv->cfg->base_params->plcp_delta_threshold == 459 if (threshold == IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE) {
460 IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE) {
461 IWL_DEBUG_RADIO(priv, "plcp_err check disabled\n"); 460 IWL_DEBUG_RADIO(priv, "plcp_err check disabled\n");
462 return rc; 461 return true;
463 } 462 }
464 463
465 /* 464 stamp = jiffies;
466 * check for plcp_err and trigger radio reset if it exceeds 465 msecs = jiffies_to_msecs(stamp - priv->plcp_jiffies);
467 * the plcp error threshold plcp_delta. 466 priv->plcp_jiffies = stamp;
468 */
469 plcp_received_jiffies = jiffies;
470 plcp_msec = jiffies_to_msecs((long) plcp_received_jiffies -
471 (long) priv->plcp_jiffies);
472 priv->plcp_jiffies = plcp_received_jiffies;
473 /*
474 * check to make sure plcp_msec is not 0 to prevent division
475 * by zero.
476 */
477 if (plcp_msec) {
478 struct statistics_rx_phy *ofdm;
479 struct statistics_rx_ht_phy *ofdm_ht;
480
481 if (iwl_bt_statistics(priv)) {
482 ofdm = &pkt->u.stats_bt.rx.ofdm;
483 ofdm_ht = &pkt->u.stats_bt.rx.ofdm_ht;
484 combined_plcp_delta =
485 (le32_to_cpu(ofdm->plcp_err) -
486 le32_to_cpu(priv->_agn.statistics_bt.
487 rx.ofdm.plcp_err)) +
488 (le32_to_cpu(ofdm_ht->plcp_err) -
489 le32_to_cpu(priv->_agn.statistics_bt.
490 rx.ofdm_ht.plcp_err));
491 } else {
492 ofdm = &pkt->u.stats.rx.ofdm;
493 ofdm_ht = &pkt->u.stats.rx.ofdm_ht;
494 combined_plcp_delta =
495 (le32_to_cpu(ofdm->plcp_err) -
496 le32_to_cpu(priv->_agn.statistics.
497 rx.ofdm.plcp_err)) +
498 (le32_to_cpu(ofdm_ht->plcp_err) -
499 le32_to_cpu(priv->_agn.statistics.
500 rx.ofdm_ht.plcp_err));
501 }
502 467
503 if ((combined_plcp_delta > 0) && 468 if (msecs == 0)
504 ((combined_plcp_delta * 100) / plcp_msec) > 469 return true;
505 priv->cfg->base_params->plcp_delta_threshold) { 470
506 /* 471 if (iwl_bt_statistics(priv)) {
507 * if plcp_err exceed the threshold, 472 struct statistics_rx_bt *cur, *old;
508 * the following data is printed in csv format: 473
509 * Text: plcp_err exceeded %d, 474 cur = &pkt->u.stats_bt.rx;
510 * Received ofdm.plcp_err, 475 old = &priv->_agn.statistics_bt.rx;
511 * Current ofdm.plcp_err, 476
512 * Received ofdm_ht.plcp_err, 477 delta = le32_to_cpu(cur->ofdm.plcp_err) -
513 * Current ofdm_ht.plcp_err, 478 le32_to_cpu(old->ofdm.plcp_err) +
514 * combined_plcp_delta, 479 le32_to_cpu(cur->ofdm_ht.plcp_err) -
515 * plcp_msec 480 le32_to_cpu(old->ofdm_ht.plcp_err);
516 */ 481 } else {
517 IWL_DEBUG_RADIO(priv, "plcp_err exceeded %u, " 482 struct statistics_rx *cur, *old;
518 "%u, %u, %u, %u, %d, %u mSecs\n", 483
519 priv->cfg->base_params->plcp_delta_threshold, 484 cur = &pkt->u.stats.rx;
520 le32_to_cpu(ofdm->plcp_err), 485 old = &priv->_agn.statistics.rx;
521 le32_to_cpu(ofdm->plcp_err), 486
522 le32_to_cpu(ofdm_ht->plcp_err), 487 delta = le32_to_cpu(cur->ofdm.plcp_err) -
523 le32_to_cpu(ofdm_ht->plcp_err), 488 le32_to_cpu(old->ofdm.plcp_err) +
524 combined_plcp_delta, plcp_msec); 489 le32_to_cpu(cur->ofdm_ht.plcp_err) -
525 490 le32_to_cpu(old->ofdm_ht.plcp_err);
526 rc = false;
527 }
528 } 491 }
529 return rc; 492
493 /* Can be negative if firmware reseted statistics */
494 if (delta <= 0)
495 return true;
496
497 if ((delta * 100 / msecs) > threshold) {
498 IWL_DEBUG_RADIO(priv,
499 "plcp health threshold %u delta %d msecs %u\n",
500 threshold, delta, msecs);
501 return false;
502 }
503
504 return true;
530} 505}
531 506
532static void iwl_recover_from_statistics(struct iwl_priv *priv, 507static void iwl_recover_from_statistics(struct iwl_priv *priv,