Commit fa8f130c authored by Wey-Yi Guy's avatar Wey-Yi Guy Committed by Reinette Chatre

iwlwifi: code cleanup for connectivity recovery

Split the connectivity check and recovery routine into separated
functions based on the types
   1. iwl_good_ack_health() - check for ack count
   2. iwl_good_plcp_health() - check for plcp error

Based on the type of errors being detected, different recovery methods
will be used to bring the system back to normal operational state.

Because different NIC has different HW and uCode, the behavior is also
different; these functions thus now form part of the ops infrastructure,
so we can have more control on how to monitor and recover from error condition
case per device.
Signed-off-by: default avatarWey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: default avatarReinette Chatre <reinette.chatre@intel.com>
parent d5a0ffa3
...@@ -213,7 +213,8 @@ static struct iwl_lib_ops iwl1000_lib = { ...@@ -213,7 +213,8 @@ static struct iwl_lib_ops iwl1000_lib = {
}, },
.add_bcast_station = iwl_add_bcast_station, .add_bcast_station = iwl_add_bcast_station,
.recover_from_tx_stall = iwl_bg_monitor_recover, .recover_from_tx_stall = iwl_bg_monitor_recover,
.recover_from_statistics = iwl_recover_from_statistics, .check_plcp_health = iwl_good_plcp_health,
.check_ack_health = iwl_good_ack_health,
}; };
static const struct iwl_ops iwl1000_ops = { static const struct iwl_ops iwl1000_ops = {
......
...@@ -2221,7 +2221,7 @@ static struct iwl_lib_ops iwl4965_lib = { ...@@ -2221,7 +2221,7 @@ static struct iwl_lib_ops iwl4965_lib = {
.set_ct_kill = iwl4965_set_ct_threshold, .set_ct_kill = iwl4965_set_ct_threshold,
}, },
.add_bcast_station = iwl_add_bcast_station, .add_bcast_station = iwl_add_bcast_station,
.recover_from_statistics = iwl_recover_from_statistics, .check_plcp_health = iwl_good_plcp_health,
}; };
static const struct iwl_ops iwl4965_ops = { static const struct iwl_ops iwl4965_ops = {
......
...@@ -1500,7 +1500,8 @@ struct iwl_lib_ops iwl5000_lib = { ...@@ -1500,7 +1500,8 @@ struct iwl_lib_ops iwl5000_lib = {
}, },
.add_bcast_station = iwl_add_bcast_station, .add_bcast_station = iwl_add_bcast_station,
.recover_from_tx_stall = iwl_bg_monitor_recover, .recover_from_tx_stall = iwl_bg_monitor_recover,
.recover_from_statistics = iwl_recover_from_statistics, .check_plcp_health = iwl_good_plcp_health,
.check_ack_health = iwl_good_ack_health,
}; };
static struct iwl_lib_ops iwl5150_lib = { static struct iwl_lib_ops iwl5150_lib = {
...@@ -1556,7 +1557,8 @@ static struct iwl_lib_ops iwl5150_lib = { ...@@ -1556,7 +1557,8 @@ static struct iwl_lib_ops iwl5150_lib = {
}, },
.add_bcast_station = iwl_add_bcast_station, .add_bcast_station = iwl_add_bcast_station,
.recover_from_tx_stall = iwl_bg_monitor_recover, .recover_from_tx_stall = iwl_bg_monitor_recover,
.recover_from_statistics = iwl_recover_from_statistics, .check_plcp_health = iwl_good_plcp_health,
.check_ack_health = iwl_good_ack_health,
}; };
static const struct iwl_ops iwl5000_ops = { static const struct iwl_ops iwl5000_ops = {
......
...@@ -279,7 +279,8 @@ static struct iwl_lib_ops iwl6000_lib = { ...@@ -279,7 +279,8 @@ static struct iwl_lib_ops iwl6000_lib = {
}, },
.add_bcast_station = iwl_add_bcast_station, .add_bcast_station = iwl_add_bcast_station,
.recover_from_tx_stall = iwl_bg_monitor_recover, .recover_from_tx_stall = iwl_bg_monitor_recover,
.recover_from_statistics = iwl_recover_from_statistics, .check_plcp_health = iwl_good_plcp_health,
.check_ack_health = iwl_good_ack_health,
}; };
static const struct iwl_ops iwl6000_ops = { static const struct iwl_ops iwl6000_ops = {
...@@ -346,7 +347,8 @@ static struct iwl_lib_ops iwl6050_lib = { ...@@ -346,7 +347,8 @@ static struct iwl_lib_ops iwl6050_lib = {
}, },
.add_bcast_station = iwl_add_bcast_station, .add_bcast_station = iwl_add_bcast_station,
.recover_from_tx_stall = iwl_bg_monitor_recover, .recover_from_tx_stall = iwl_bg_monitor_recover,
.recover_from_statistics = iwl_recover_from_statistics, .check_plcp_health = iwl_good_plcp_health,
.check_ack_health = iwl_good_ack_health,
}; };
static const struct iwl_ops iwl6050_ops = { static const struct iwl_ops iwl6050_ops = {
......
...@@ -193,8 +193,11 @@ struct iwl_lib_ops { ...@@ -193,8 +193,11 @@ struct iwl_lib_ops {
void (*add_bcast_station)(struct iwl_priv *priv); void (*add_bcast_station)(struct iwl_priv *priv);
/* recover from tx queue stall */ /* recover from tx queue stall */
void (*recover_from_tx_stall)(unsigned long data); void (*recover_from_tx_stall)(unsigned long data);
/* recover from errors showed in statistics */ /* check for plcp health */
void (*recover_from_statistics)(struct iwl_priv *priv, bool (*check_plcp_health)(struct iwl_priv *priv,
struct iwl_rx_packet *pkt);
/* check for ack health */
bool (*check_ack_health)(struct iwl_priv *priv,
struct iwl_rx_packet *pkt); struct iwl_rx_packet *pkt);
}; };
...@@ -437,7 +440,9 @@ void iwl_rx_missed_beacon_notif(struct iwl_priv *priv, ...@@ -437,7 +440,9 @@ void iwl_rx_missed_beacon_notif(struct iwl_priv *priv,
struct iwl_rx_mem_buffer *rxb); struct iwl_rx_mem_buffer *rxb);
void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv, void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv,
struct iwl_rx_mem_buffer *rxb); struct iwl_rx_mem_buffer *rxb);
void iwl_recover_from_statistics(struct iwl_priv *priv, bool iwl_good_plcp_health(struct iwl_priv *priv,
struct iwl_rx_packet *pkt);
bool iwl_good_ack_health(struct iwl_priv *priv,
struct iwl_rx_packet *pkt); struct iwl_rx_packet *pkt);
void iwl_rx_statistics(struct iwl_priv *priv, void iwl_rx_statistics(struct iwl_priv *priv,
struct iwl_rx_mem_buffer *rxb); struct iwl_rx_mem_buffer *rxb);
......
...@@ -621,24 +621,18 @@ static void iwl_accumulative_statistics(struct iwl_priv *priv, ...@@ -621,24 +621,18 @@ static void iwl_accumulative_statistics(struct iwl_priv *priv,
#define BA_TIMEOUT_CNT (5) #define BA_TIMEOUT_CNT (5)
#define BA_TIMEOUT_MAX (16) #define BA_TIMEOUT_MAX (16)
#define PLCP_MSG "plcp_err exceeded %u, %u, %u, %u, %u, %d, %u mSecs\n" /**
/* * iwl_good_ack_health - checks for ACK count ratios, BA timeout retries.
* This function checks for plcp error, ACK count ratios, aggregated BA *
* timeout retries. * When the ACK count ratio is 0 and aggregated BA timeout retries exceeding
* - When the ACK count ratio is 0 and aggregated BA timeout retries is * the BA_TIMEOUT_MAX, reload firmware and bring system back to normal
* exceeding the BA_TIMEOUT_MAX, it will recover the failure by resetting * operation state.
* the firmware.
* - When the plcp error is exceeding the thresholds, it will reset the radio
* to improve the throughput.
*/ */
void iwl_recover_from_statistics(struct iwl_priv *priv, bool iwl_good_ack_health(struct iwl_priv *priv,
struct iwl_rx_packet *pkt) struct iwl_rx_packet *pkt)
{ {
int combined_plcp_delta; bool rc = true;
unsigned int plcp_msec; int actual_ack_cnt_delta, expected_ack_cnt_delta;
unsigned long plcp_received_jiffies;
int actual_ack_cnt_delta;
int expected_ack_cnt_delta;
int ba_timeout_delta; int ba_timeout_delta;
actual_ack_cnt_delta = actual_ack_cnt_delta =
...@@ -669,13 +663,27 @@ void iwl_recover_from_statistics(struct iwl_priv *priv, ...@@ -669,13 +663,27 @@ void iwl_recover_from_statistics(struct iwl_priv *priv,
#endif #endif
IWL_DEBUG_RADIO(priv, "agg ba_timeout delta = %d\n", IWL_DEBUG_RADIO(priv, "agg ba_timeout delta = %d\n",
ba_timeout_delta); ba_timeout_delta);
if ((actual_ack_cnt_delta == 0) && if (!actual_ack_cnt_delta &&
(ba_timeout_delta >= BA_TIMEOUT_MAX)) { (ba_timeout_delta >= BA_TIMEOUT_MAX))
IWL_DEBUG_RADIO(priv, rc = false;
"call iwl_force_reset(IWL_FW_RESET)\n");
iwl_force_reset(priv, IWL_FW_RESET);
}
} }
return rc;
}
EXPORT_SYMBOL(iwl_good_ack_health);
/**
* iwl_good_plcp_health - checks for plcp error.
*
* When the plcp error is exceeding the thresholds, reset the radio
* to improve the throughput.
*/
bool iwl_good_plcp_health(struct iwl_priv *priv,
struct iwl_rx_packet *pkt)
{
bool rc = true;
int combined_plcp_delta;
unsigned int plcp_msec;
unsigned long plcp_received_jiffies;
/* /*
* check for plcp_err and trigger radio reset if it exceeds * check for plcp_err and trigger radio reset if it exceeds
...@@ -710,7 +718,8 @@ void iwl_recover_from_statistics(struct iwl_priv *priv, ...@@ -710,7 +718,8 @@ void iwl_recover_from_statistics(struct iwl_priv *priv,
* combined_plcp_delta, * combined_plcp_delta,
* plcp_msec * plcp_msec
*/ */
IWL_DEBUG_RADIO(priv, PLCP_MSG, IWL_DEBUG_RADIO(priv, "plcp_err exceeded %u, "
"%u, %u, %u, %u, %d, %u mSecs\n",
priv->cfg->plcp_delta_threshold, priv->cfg->plcp_delta_threshold,
le32_to_cpu(pkt->u.stats.rx.ofdm.plcp_err), le32_to_cpu(pkt->u.stats.rx.ofdm.plcp_err),
le32_to_cpu(priv->statistics.rx.ofdm.plcp_err), le32_to_cpu(priv->statistics.rx.ofdm.plcp_err),
...@@ -718,15 +727,42 @@ void iwl_recover_from_statistics(struct iwl_priv *priv, ...@@ -718,15 +727,42 @@ void iwl_recover_from_statistics(struct iwl_priv *priv,
le32_to_cpu( le32_to_cpu(
priv->statistics.rx.ofdm_ht.plcp_err), priv->statistics.rx.ofdm_ht.plcp_err),
combined_plcp_delta, plcp_msec); combined_plcp_delta, plcp_msec);
/* rc = false;
* Reset the RF radio due to the high plcp }
* error rate }
*/ return rc;
iwl_force_reset(priv, IWL_RF_RESET); }
EXPORT_SYMBOL(iwl_good_plcp_health);
static void iwl_recover_from_statistics(struct iwl_priv *priv,
struct iwl_rx_packet *pkt)
{
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
return;
if (iwl_is_associated(priv)) {
if (priv->cfg->ops->lib->check_ack_health) {
if (!priv->cfg->ops->lib->check_ack_health(
priv, pkt)) {
/*
* low ack count detected
* restart Firmware
*/
IWL_ERR(priv, "low ack count detected, "
"restart firmware\n");
iwl_force_reset(priv, IWL_FW_RESET);
}
} else if (priv->cfg->ops->lib->check_plcp_health) {
if (!priv->cfg->ops->lib->check_plcp_health(
priv, pkt)) {
/*
* high plcp error detected
* reset Radio
*/
iwl_force_reset(priv, IWL_RF_RESET);
}
} }
} }
} }
EXPORT_SYMBOL(iwl_recover_from_statistics);
void iwl_rx_statistics(struct iwl_priv *priv, void iwl_rx_statistics(struct iwl_priv *priv,
struct iwl_rx_mem_buffer *rxb) struct iwl_rx_mem_buffer *rxb)
...@@ -748,8 +784,7 @@ void iwl_rx_statistics(struct iwl_priv *priv, ...@@ -748,8 +784,7 @@ void iwl_rx_statistics(struct iwl_priv *priv,
#ifdef CONFIG_IWLWIFI_DEBUG #ifdef CONFIG_IWLWIFI_DEBUG
iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats); iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats);
#endif #endif
if (priv->cfg->ops->lib->recover_from_statistics) iwl_recover_from_statistics(priv, pkt);
priv->cfg->ops->lib->recover_from_statistics(priv, pkt);
memcpy(&priv->statistics, &pkt->u.stats, sizeof(priv->statistics)); memcpy(&priv->statistics, &pkt->u.stats, sizeof(priv->statistics));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment