Jesse Keating 2f82dd
This patch is not upstream yet...
Jesse Keating 2f82dd
Jesse Keating 2f82dd
From 171e0b730fd471b8df0d138daf382b8f6835fb18 Mon Sep 17 00:00:00 2001
Jesse Keating 2f82dd
From: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Jesse Keating 2f82dd
Date: Thu, 4 Mar 2010 13:38:58 -0800
Jesse Keating 2f82dd
Subject: [PATCH 14/17] iwlwifi: move plcp check to separated function
Jesse Keating 2f82dd
Jesse Keating 2f82dd
Move the plcp error checking into stand alone function and pointed by ops
Jesse Keating 2f82dd
to accommodate devices not needing this recovery.
Jesse Keating 2f82dd
Jesse Keating 2f82dd
Signed-off-by: Trieu 'Andrew' Nguyen <trieux.t.nguyen@intel.com>
Jesse Keating 2f82dd
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Jesse Keating 2f82dd
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Jesse Keating 2f82dd
Jesse Keating 2f82dd
diff -up linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-1000.c.orig linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-1000.c
Jesse Keating 2f82dd
--- linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-1000.c.orig	2010-03-22 15:48:54.000000000 -0400
Jesse Keating 2f82dd
+++ linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-1000.c	2010-03-22 15:56:08.000000000 -0400
Jesse Keating 2f82dd
@@ -136,6 +136,7 @@ static struct iwl_lib_ops iwl1000_lib = 
Jesse Keating 2f82dd
 		.set_ct_kill = iwl1000_set_ct_threshold,
Jesse Keating 2f82dd
 	 },
Jesse Keating 2f82dd
 	.recover_from_tx_stall = iwl_bg_monitor_recover,
Jesse Keating 2f82dd
+	.recover_from_statistics = iwl_recover_from_statistics,
Jesse Keating 2f82dd
 };
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
 static struct iwl_ops iwl1000_ops = {
Jesse Keating 2f82dd
diff -up linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-4965.c.orig linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-4965.c
Jesse Keating 2f82dd
--- linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-4965.c.orig	2010-03-22 15:48:54.000000000 -0400
Jesse Keating 2f82dd
+++ linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-4965.c	2010-03-22 15:56:08.000000000 -0400
Jesse Keating 2f82dd
@@ -2340,6 +2340,7 @@ static struct iwl_lib_ops iwl4965_lib = 
Jesse Keating 2f82dd
 		.temperature = iwl4965_temperature_calib,
Jesse Keating 2f82dd
 		.set_ct_kill = iwl4965_set_ct_threshold,
Jesse Keating 2f82dd
 	},
Jesse Keating 2f82dd
+	.recover_from_statistics = iwl_recover_from_statistics,
Jesse Keating 2f82dd
 };
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
 static struct iwl_ops iwl4965_ops = {
Jesse Keating 2f82dd
diff -up linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-5000.c.orig linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-5000.c
Jesse Keating 2f82dd
--- linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-5000.c.orig	2010-03-22 15:48:54.000000000 -0400
Jesse Keating 2f82dd
+++ linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-5000.c	2010-03-22 15:56:08.000000000 -0400
Jesse Keating 2f82dd
@@ -1580,6 +1580,7 @@ struct iwl_lib_ops iwl5000_lib = {
Jesse Keating 2f82dd
 		.set_ct_kill = iwl5000_set_ct_threshold,
Jesse Keating 2f82dd
 	 },
Jesse Keating 2f82dd
 	.recover_from_tx_stall = iwl_bg_monitor_recover,
Jesse Keating 2f82dd
+	.recover_from_statistics = iwl_recover_from_statistics,
Jesse Keating 2f82dd
 };
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
 static struct iwl_lib_ops iwl5150_lib = {
Jesse Keating 2f82dd
@@ -1633,6 +1634,7 @@ static struct iwl_lib_ops iwl5150_lib = 
Jesse Keating 2f82dd
 		.set_ct_kill = iwl5150_set_ct_threshold,
Jesse Keating 2f82dd
 	 },
Jesse Keating 2f82dd
 	.recover_from_tx_stall = iwl_bg_monitor_recover,
Jesse Keating 2f82dd
+	.recover_from_statistics = iwl_recover_from_statistics,
Jesse Keating 2f82dd
 };
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
 struct iwl_ops iwl5000_ops = {
Jesse Keating 2f82dd
diff -up linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-6000.c.orig linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-6000.c
Jesse Keating 2f82dd
--- linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-6000.c.orig	2010-03-22 15:51:12.000000000 -0400
Jesse Keating 2f82dd
+++ linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-6000.c	2010-03-22 15:56:08.000000000 -0400
Jesse Keating 2f82dd
@@ -138,6 +138,7 @@ static struct iwl_lib_ops iwl6000_lib = 
Jesse Keating 2f82dd
 		.set_ct_kill = iwl6000_set_ct_threshold,
Jesse Keating 2f82dd
 	 },
Jesse Keating 2f82dd
 	.recover_from_tx_stall = iwl_bg_monitor_recover,
Jesse Keating 2f82dd
+	.recover_from_statistics = iwl_recover_from_statistics,
Jesse Keating 2f82dd
 };
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
 static struct iwl_hcmd_utils_ops iwl6000_hcmd_utils = {
Jesse Keating 2f82dd
diff -up linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-core.h.orig linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-core.h
Jesse Keating 2f82dd
--- linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-core.h.orig	2010-03-22 15:48:54.000000000 -0400
Jesse Keating 2f82dd
+++ linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-core.h	2010-03-22 15:56:08.000000000 -0400
Jesse Keating 2f82dd
@@ -185,6 +185,9 @@ struct iwl_lib_ops {
Jesse Keating 2f82dd
 	struct iwl_temp_ops temp_ops;
Jesse Keating 2f82dd
 	/* recover from tx queue stall */
Jesse Keating 2f82dd
 	void (*recover_from_tx_stall)(unsigned long data);
Jesse Keating 2f82dd
+	/* recover from errors showed in statistics */
Jesse Keating 2f82dd
+	void (*recover_from_statistics)(struct iwl_priv *priv,
Jesse Keating 2f82dd
+					struct iwl_rx_packet *pkt);
Jesse Keating 2f82dd
 };
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
 struct iwl_ops {
Jesse Keating 2f82dd
@@ -398,6 +401,8 @@ int iwl_tx_queue_reclaim(struct iwl_priv
Jesse Keating 2f82dd
 /* Handlers */
Jesse Keating 2f82dd
 void iwl_rx_missed_beacon_notif(struct iwl_priv *priv,
Jesse Keating 2f82dd
 			       struct iwl_rx_mem_buffer *rxb);
Jesse Keating 2f82dd
+void iwl_recover_from_statistics(struct iwl_priv *priv,
Jesse Keating 2f82dd
+				 struct iwl_rx_packet *pkt);
Jesse Keating 2f82dd
 void iwl_rx_statistics(struct iwl_priv *priv,
Jesse Keating 2f82dd
 			      struct iwl_rx_mem_buffer *rxb);
Jesse Keating 2f82dd
 void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb);
Jesse Keating 2f82dd
diff -up linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-rx.c.orig linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-rx.c
Jesse Keating 2f82dd
--- linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-rx.c.orig	2010-03-22 15:24:28.000000000 -0400
Jesse Keating 2f82dd
+++ linux-2.6.32.noarch/drivers/net/wireless/iwlwifi/iwl-rx.c	2010-03-22 16:02:35.000000000 -0400
Jesse Keating 2f82dd
@@ -551,25 +551,18 @@ static void iwl_rx_calc_noise(struct iwl
Jesse Keating 2f82dd
 #define REG_RECALIB_PERIOD (60)
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
 #define PLCP_MSG "plcp_err exceeded %u, %u, %u, %u, %u, %d, %u mSecs\n"
Jesse Keating 2f82dd
-void iwl_rx_statistics(struct iwl_priv *priv,
Jesse Keating 2f82dd
-			      struct iwl_rx_mem_buffer *rxb)
Jesse Keating 2f82dd
+/*
Jesse Keating 2f82dd
+ * This function checks for plcp error.
Jesse Keating 2f82dd
+ * - When the plcp error is exceeding the thresholds, it will reset the radio
Jesse Keating 2f82dd
+ * to improve the throughput.
Jesse Keating 2f82dd
+ */
Jesse Keating 2f82dd
+void iwl_recover_from_statistics(struct iwl_priv *priv,
Jesse Keating 2f82dd
+					struct iwl_rx_packet *pkt)
Jesse Keating 2f82dd
 {
Jesse Keating 2f82dd
-	int change;
Jesse Keating 2f82dd
-	struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
Jesse Keating 2f82dd
 	int combined_plcp_delta;
Jesse Keating 2f82dd
 	unsigned int plcp_msec;
Jesse Keating 2f82dd
 	unsigned long plcp_received_jiffies;
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
-	IWL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n",
Jesse Keating 2f82dd
-		     (int)sizeof(priv->statistics),
Jesse Keating 2f82dd
-		     le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK);
Jesse Keating 2f82dd
-
Jesse Keating 2f82dd
-	change = ((priv->statistics.general.temperature !=
Jesse Keating 2f82dd
-		   pkt->u.stats.general.temperature) ||
Jesse Keating 2f82dd
-		  ((priv->statistics.flag &
Jesse Keating 2f82dd
-		    STATISTICS_REPLY_FLG_HT40_MODE_MSK) !=
Jesse Keating 2f82dd
-		   (pkt->u.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK)));
Jesse Keating 2f82dd
-
Jesse Keating 2f82dd
 	/*
Jesse Keating 2f82dd
 	 * check for plcp_err and trigger radio reset if it exceeds
Jesse Keating 2f82dd
 	 * the plcp error threshold plcp_delta.
Jesse Keating 2f82dd
@@ -590,11 +583,11 @@ void iwl_rx_statistics(struct iwl_priv *
Jesse Keating 2f82dd
 			le32_to_cpu(priv->statistics.rx.ofdm_ht.plcp_err));
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
 		if ((combined_plcp_delta > 0) &&
Jesse Keating 2f82dd
-			((combined_plcp_delta * 100) / plcp_msec) >
Jesse Keating 2f82dd
+		    ((combined_plcp_delta * 100) / plcp_msec) >
Jesse Keating 2f82dd
 			priv->cfg->plcp_delta_threshold) {
Jesse Keating 2f82dd
 			/*
Jesse Keating 2f82dd
-			 * if plcp_err exceed the threshold, the following
Jesse Keating 2f82dd
-			 * data is printed in csv format:
Jesse Keating 2f82dd
+			 * if plcp_err exceed the threshold,
Jesse Keating 2f82dd
+			 * the following data is printed in csv format:
Jesse Keating 2f82dd
 			 *    Text: plcp_err exceeded %d,
Jesse Keating 2f82dd
 			 *    Received ofdm.plcp_err,
Jesse Keating 2f82dd
 			 *    Current ofdm.plcp_err,
Jesse Keating 2f82dd
@@ -609,9 +602,8 @@ void iwl_rx_statistics(struct iwl_priv *
Jesse Keating 2f82dd
 				le32_to_cpu(priv->statistics.rx.ofdm.plcp_err),
Jesse Keating 2f82dd
 				le32_to_cpu(pkt->u.stats.rx.ofdm_ht.plcp_err),
Jesse Keating 2f82dd
 				le32_to_cpu(
Jesse Keating 2f82dd
-					priv->statistics.rx.ofdm_ht.plcp_err),
Jesse Keating 2f82dd
+				  priv->statistics.rx.ofdm_ht.plcp_err),
Jesse Keating 2f82dd
 				combined_plcp_delta, plcp_msec);
Jesse Keating 2f82dd
-
Jesse Keating 2f82dd
 			/*
Jesse Keating 2f82dd
 			 * Reset the RF radio due to the high plcp
Jesse Keating 2f82dd
 			 * error rate
Jesse Keating 2f82dd
@@ -619,6 +611,28 @@ void iwl_rx_statistics(struct iwl_priv *
Jesse Keating 2f82dd
 			iwl_force_reset(priv, IWL_RF_RESET);
Jesse Keating 2f82dd
 		}
Jesse Keating 2f82dd
 	}
Jesse Keating 2f82dd
+}
Jesse Keating 2f82dd
+EXPORT_SYMBOL(iwl_recover_from_statistics);
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+void iwl_rx_statistics(struct iwl_priv *priv,
Jesse Keating 2f82dd
+			      struct iwl_rx_mem_buffer *rxb)
Jesse Keating 2f82dd
+{
Jesse Keating 2f82dd
+	int change;
Jesse Keating 2f82dd
+	struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+	IWL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n",
Jesse Keating 2f82dd
+		     (int)sizeof(priv->statistics),
Jesse Keating 2f82dd
+		     le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK);
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+	change = ((priv->statistics.general.temperature !=
Jesse Keating 2f82dd
+		   pkt->u.stats.general.temperature) ||
Jesse Keating 2f82dd
+		  ((priv->statistics.flag &
Jesse Keating 2f82dd
+		    STATISTICS_REPLY_FLG_HT40_MODE_MSK) !=
Jesse Keating 2f82dd
+		   (pkt->u.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK)));
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+	if (priv->cfg->ops->lib->recover_from_statistics)
Jesse Keating 2f82dd
+		priv->cfg->ops->lib->recover_from_statistics(priv, pkt);
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
 	memcpy(&priv->statistics, &pkt->u.stats, sizeof(priv->statistics));
Jesse Keating 2f82dd