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>
This commit is contained in:
committed by
John W. Linville
parent
466a19a003
commit
6198c387b2
@@ -451,82 +451,57 @@ static bool iwl_good_ack_health(struct iwl_priv *priv, struct iwl_rx_packet *pkt
|
|||||||
static bool iwl_good_plcp_health(struct iwl_priv *priv,
|
static bool iwl_good_plcp_health(struct iwl_priv *priv,
|
||||||
struct iwl_rx_packet *pkt)
|
struct iwl_rx_packet *pkt)
|
||||||
{
|
{
|
||||||
bool rc = true;
|
unsigned int msecs;
|
||||||
int combined_plcp_delta;
|
unsigned long stamp;
|
||||||
unsigned int plcp_msec;
|
int delta;
|
||||||
unsigned long plcp_received_jiffies;
|
int threshold = priv->cfg->base_params->plcp_delta_threshold;
|
||||||
|
|
||||||
if (priv->cfg->base_params->plcp_delta_threshold ==
|
if (threshold == IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE) {
|
||||||
IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE) {
|
|
||||||
IWL_DEBUG_RADIO(priv, "plcp_err check disabled\n");
|
IWL_DEBUG_RADIO(priv, "plcp_err check disabled\n");
|
||||||
return rc;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
stamp = jiffies;
|
||||||
* check for plcp_err and trigger radio reset if it exceeds
|
msecs = jiffies_to_msecs(stamp - priv->plcp_jiffies);
|
||||||
* the plcp error threshold plcp_delta.
|
priv->plcp_jiffies = stamp;
|
||||||
*/
|
|
||||||
plcp_received_jiffies = jiffies;
|
|
||||||
plcp_msec = jiffies_to_msecs((long) plcp_received_jiffies -
|
|
||||||
(long) priv->plcp_jiffies);
|
|
||||||
priv->plcp_jiffies = plcp_received_jiffies;
|
|
||||||
/*
|
|
||||||
* check to make sure plcp_msec is not 0 to prevent division
|
|
||||||
* by zero.
|
|
||||||
*/
|
|
||||||
if (plcp_msec) {
|
|
||||||
struct statistics_rx_phy *ofdm;
|
|
||||||
struct statistics_rx_ht_phy *ofdm_ht;
|
|
||||||
|
|
||||||
if (iwl_bt_statistics(priv)) {
|
if (msecs == 0)
|
||||||
ofdm = &pkt->u.stats_bt.rx.ofdm;
|
return true;
|
||||||
ofdm_ht = &pkt->u.stats_bt.rx.ofdm_ht;
|
|
||||||
combined_plcp_delta =
|
|
||||||
(le32_to_cpu(ofdm->plcp_err) -
|
|
||||||
le32_to_cpu(priv->_agn.statistics_bt.
|
|
||||||
rx.ofdm.plcp_err)) +
|
|
||||||
(le32_to_cpu(ofdm_ht->plcp_err) -
|
|
||||||
le32_to_cpu(priv->_agn.statistics_bt.
|
|
||||||
rx.ofdm_ht.plcp_err));
|
|
||||||
} else {
|
|
||||||
ofdm = &pkt->u.stats.rx.ofdm;
|
|
||||||
ofdm_ht = &pkt->u.stats.rx.ofdm_ht;
|
|
||||||
combined_plcp_delta =
|
|
||||||
(le32_to_cpu(ofdm->plcp_err) -
|
|
||||||
le32_to_cpu(priv->_agn.statistics.
|
|
||||||
rx.ofdm.plcp_err)) +
|
|
||||||
(le32_to_cpu(ofdm_ht->plcp_err) -
|
|
||||||
le32_to_cpu(priv->_agn.statistics.
|
|
||||||
rx.ofdm_ht.plcp_err));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((combined_plcp_delta > 0) &&
|
if (iwl_bt_statistics(priv)) {
|
||||||
((combined_plcp_delta * 100) / plcp_msec) >
|
struct statistics_rx_bt *cur, *old;
|
||||||
priv->cfg->base_params->plcp_delta_threshold) {
|
|
||||||
/*
|
|
||||||
* if plcp_err exceed the threshold,
|
|
||||||
* the following data is printed in csv format:
|
|
||||||
* Text: plcp_err exceeded %d,
|
|
||||||
* Received ofdm.plcp_err,
|
|
||||||
* Current ofdm.plcp_err,
|
|
||||||
* Received ofdm_ht.plcp_err,
|
|
||||||
* Current ofdm_ht.plcp_err,
|
|
||||||
* combined_plcp_delta,
|
|
||||||
* plcp_msec
|
|
||||||
*/
|
|
||||||
IWL_DEBUG_RADIO(priv, "plcp_err exceeded %u, "
|
|
||||||
"%u, %u, %u, %u, %d, %u mSecs\n",
|
|
||||||
priv->cfg->base_params->plcp_delta_threshold,
|
|
||||||
le32_to_cpu(ofdm->plcp_err),
|
|
||||||
le32_to_cpu(ofdm->plcp_err),
|
|
||||||
le32_to_cpu(ofdm_ht->plcp_err),
|
|
||||||
le32_to_cpu(ofdm_ht->plcp_err),
|
|
||||||
combined_plcp_delta, plcp_msec);
|
|
||||||
|
|
||||||
rc = false;
|
cur = &pkt->u.stats_bt.rx;
|
||||||
}
|
old = &priv->_agn.statistics_bt.rx;
|
||||||
|
|
||||||
|
delta = le32_to_cpu(cur->ofdm.plcp_err) -
|
||||||
|
le32_to_cpu(old->ofdm.plcp_err) +
|
||||||
|
le32_to_cpu(cur->ofdm_ht.plcp_err) -
|
||||||
|
le32_to_cpu(old->ofdm_ht.plcp_err);
|
||||||
|
} else {
|
||||||
|
struct statistics_rx *cur, *old;
|
||||||
|
|
||||||
|
cur = &pkt->u.stats.rx;
|
||||||
|
old = &priv->_agn.statistics.rx;
|
||||||
|
|
||||||
|
delta = le32_to_cpu(cur->ofdm.plcp_err) -
|
||||||
|
le32_to_cpu(old->ofdm.plcp_err) +
|
||||||
|
le32_to_cpu(cur->ofdm_ht.plcp_err) -
|
||||||
|
le32_to_cpu(old->ofdm_ht.plcp_err);
|
||||||
}
|
}
|
||||||
return rc;
|
|
||||||
|
/* Can be negative if firmware reseted statistics */
|
||||||
|
if (delta <= 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ((delta * 100 / msecs) > threshold) {
|
||||||
|
IWL_DEBUG_RADIO(priv,
|
||||||
|
"plcp health threshold %u delta %d msecs %u\n",
|
||||||
|
threshold, delta, msecs);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void iwl_recover_from_statistics(struct iwl_priv *priv,
|
static void iwl_recover_from_statistics(struct iwl_priv *priv,
|
||||||
|
Reference in New Issue
Block a user