From f7f1a496df6420c9d7011a6fa9dadb1981567866 Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@openwrt.org>
Date: Sun, 9 Mar 2014 10:31:05 +0000
Subject: [PATCH] ath9k: improve ANI debugfs file

Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 39849
---
 .../mac80211/patches/300-pending_work.patch   | 84 ++++++++++++++++++-
 .../patches/500-ath9k_eeprom_debugfs.patch    |  4 +-
 .../patches/512-ath9k_channelbw_debugfs.patch |  4 +-
 .../patches/530-ath9k_extra_leds.patch        |  4 +-
 .../patches/542-ath9k_debugfs_diag.patch      |  4 +-
 5 files changed, 91 insertions(+), 9 deletions(-)

diff --git a/package/kernel/mac80211/patches/300-pending_work.patch b/package/kernel/mac80211/patches/300-pending_work.patch
index 8b044d2a54..15c04cd6aa 100644
--- a/package/kernel/mac80211/patches/300-pending_work.patch
+++ b/package/kernel/mac80211/patches/300-pending_work.patch
@@ -1,3 +1,13 @@
+commit 8d804f1af11e4e058b1e8453327777d73a585cb8
+Author: Felix Fietkau <nbd@openwrt.org>
+Date:   Sun Mar 9 11:25:43 2014 +0100
+
+    ath9k: clean up and enhance ANI debugfs file
+    
+    Unify scnprintf calls and include the current OFDM/CCK immunity level.
+    
+    Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+
 commit 22e298b5a3a8a49e33805d4e351965123dede35b
 Author: Felix Fietkau <nbd@openwrt.org>
 Date:   Sun Mar 9 10:58:47 2014 +0100
@@ -3577,7 +3587,79 @@ Date:   Thu Jan 23 20:06:34 2014 +0100
  		schedule_delayed_work(&reg_timeout, msecs_to_jiffies(3142));
 --- a/drivers/net/wireless/ath/ath9k/debug.c
 +++ b/drivers/net/wireless/ath/ath9k/debug.c
-@@ -866,6 +866,12 @@ static ssize_t read_file_reset(struct fi
+@@ -138,43 +138,41 @@ static ssize_t read_file_ani(struct file
+ 	unsigned int len = 0, size = 1024;
+ 	ssize_t retval = 0;
+ 	char *buf;
++	int i;
++	struct {
++		const char *name;
++		unsigned int val;
++	} ani_info[] = {
++		{ "ANI RESET", ah->stats.ast_ani_reset },
++		{ "OFDM LEVEL", ah->ani.ofdmNoiseImmunityLevel },
++		{ "CCK LEVEL", ah->ani.cckNoiseImmunityLevel },
++		{ "SPUR UP", ah->stats.ast_ani_spurup },
++		{ "SPUR DOWN", ah->stats.ast_ani_spurup },
++		{ "OFDM WS-DET ON", ah->stats.ast_ani_ofdmon },
++		{ "OFDM WS-DET OFF", ah->stats.ast_ani_ofdmoff },
++		{ "MRC-CCK ON", ah->stats.ast_ani_ccklow },
++		{ "MRC-CCK OFF", ah->stats.ast_ani_cckhigh },
++		{ "FIR-STEP UP", ah->stats.ast_ani_stepup },
++		{ "FIR-STEP DOWN", ah->stats.ast_ani_stepdown },
++		{ "INV LISTENTIME", ah->stats.ast_ani_lneg_or_lzero },
++		{ "OFDM ERRORS", ah->stats.ast_ani_ofdmerrs },
++		{ "CCK ERRORS", ah->stats.ast_ani_cckerrs },
++	};
+ 
+ 	buf = kzalloc(size, GFP_KERNEL);
+ 	if (buf == NULL)
+ 		return -ENOMEM;
+ 
+-	if (common->disable_ani) {
+-		len += scnprintf(buf + len, size - len, "%s: %s\n",
+-				 "ANI", "DISABLED");
++	len += scnprintf(buf + len, size - len, "%15s: %s\n", "ANI",
++			 common->disable_ani ? "DISABLED" : "ENABLED");
++
++	if (common->disable_ani)
+ 		goto exit;
+-	}
+ 
+-	len += scnprintf(buf + len, size - len, "%15s: %s\n",
+-			 "ANI", "ENABLED");
+-	len += scnprintf(buf + len, size - len, "%15s: %u\n",
+-			 "ANI RESET", ah->stats.ast_ani_reset);
+-	len += scnprintf(buf + len, size - len, "%15s: %u\n",
+-			 "SPUR UP", ah->stats.ast_ani_spurup);
+-	len += scnprintf(buf + len, size - len, "%15s: %u\n",
+-			 "SPUR DOWN", ah->stats.ast_ani_spurup);
+-	len += scnprintf(buf + len, size - len, "%15s: %u\n",
+-			 "OFDM WS-DET ON", ah->stats.ast_ani_ofdmon);
+-	len += scnprintf(buf + len, size - len, "%15s: %u\n",
+-			 "OFDM WS-DET OFF", ah->stats.ast_ani_ofdmoff);
+-	len += scnprintf(buf + len, size - len, "%15s: %u\n",
+-			 "MRC-CCK ON", ah->stats.ast_ani_ccklow);
+-	len += scnprintf(buf + len, size - len, "%15s: %u\n",
+-			 "MRC-CCK OFF", ah->stats.ast_ani_cckhigh);
+-	len += scnprintf(buf + len, size - len, "%15s: %u\n",
+-			 "FIR-STEP UP", ah->stats.ast_ani_stepup);
+-	len += scnprintf(buf + len, size - len, "%15s: %u\n",
+-			 "FIR-STEP DOWN", ah->stats.ast_ani_stepdown);
+-	len += scnprintf(buf + len, size - len, "%15s: %u\n",
+-			 "INV LISTENTIME", ah->stats.ast_ani_lneg_or_lzero);
+-	len += scnprintf(buf + len, size - len, "%15s: %u\n",
+-			 "OFDM ERRORS", ah->stats.ast_ani_ofdmerrs);
+-	len += scnprintf(buf + len, size - len, "%15s: %u\n",
+-			 "CCK ERRORS", ah->stats.ast_ani_cckerrs);
++	for (i = 0; i < ARRAY_SIZE(ani_info); i++)
++		len += scnprintf(buf + len, size - len, "%15s: %u\n",
++				 ani_info[i].name, ani_info[i].val);
++
+ exit:
+ 	if (len > size)
+ 		len = size;
+@@ -866,6 +864,12 @@ static ssize_t read_file_reset(struct fi
  			 "%17s: %2d\n", "PLL RX Hang",
  			 sc->debug.stats.reset[RESET_TYPE_PLL_HANG]);
  	len += scnprintf(buf + len, sizeof(buf) - len,
diff --git a/package/kernel/mac80211/patches/500-ath9k_eeprom_debugfs.patch b/package/kernel/mac80211/patches/500-ath9k_eeprom_debugfs.patch
index 7159450850..664cf45175 100644
--- a/package/kernel/mac80211/patches/500-ath9k_eeprom_debugfs.patch
+++ b/package/kernel/mac80211/patches/500-ath9k_eeprom_debugfs.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/debug.c
 +++ b/drivers/net/wireless/ath/ath9k/debug.c
-@@ -1483,6 +1483,53 @@ void ath9k_deinit_debug(struct ath_softc
+@@ -1481,6 +1481,53 @@ void ath9k_deinit_debug(struct ath_softc
  	ath9k_spectral_deinit_debug(sc);
  }
  
@@ -54,7 +54,7 @@
  int ath9k_init_debug(struct ath_hw *ah)
  {
  	struct ath_common *common = ath9k_hw_common(ah);
-@@ -1502,6 +1549,8 @@ int ath9k_init_debug(struct ath_hw *ah)
+@@ -1500,6 +1547,8 @@ int ath9k_init_debug(struct ath_hw *ah)
  	ath9k_tx99_init_debug(sc);
  	ath9k_spectral_init_debug(sc);
  
diff --git a/package/kernel/mac80211/patches/512-ath9k_channelbw_debugfs.patch b/package/kernel/mac80211/patches/512-ath9k_channelbw_debugfs.patch
index 0b03e9310c..8f3cc03043 100644
--- a/package/kernel/mac80211/patches/512-ath9k_channelbw_debugfs.patch
+++ b/package/kernel/mac80211/patches/512-ath9k_channelbw_debugfs.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/debug.c
 +++ b/drivers/net/wireless/ath/ath9k/debug.c
-@@ -1530,6 +1530,52 @@ static const struct file_operations fops
+@@ -1528,6 +1528,52 @@ static const struct file_operations fops
  	.owner = THIS_MODULE
  };
  
@@ -53,7 +53,7 @@
  int ath9k_init_debug(struct ath_hw *ah)
  {
  	struct ath_common *common = ath9k_hw_common(ah);
-@@ -1551,6 +1597,8 @@ int ath9k_init_debug(struct ath_hw *ah)
+@@ -1549,6 +1595,8 @@ int ath9k_init_debug(struct ath_hw *ah)
  
  	debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
  			    &fops_eeprom);
diff --git a/package/kernel/mac80211/patches/530-ath9k_extra_leds.patch b/package/kernel/mac80211/patches/530-ath9k_extra_leds.patch
index 3a06caff1c..59f78d9dfa 100644
--- a/package/kernel/mac80211/patches/530-ath9k_extra_leds.patch
+++ b/package/kernel/mac80211/patches/530-ath9k_extra_leds.patch
@@ -173,7 +173,7 @@
  #endif
 --- a/drivers/net/wireless/ath/ath9k/debug.c
 +++ b/drivers/net/wireless/ath/ath9k/debug.c
-@@ -1575,6 +1575,61 @@ static const struct file_operations fops
+@@ -1573,6 +1573,61 @@ static const struct file_operations fops
  	.llseek = default_llseek,
  };
  
@@ -235,7 +235,7 @@
  
  int ath9k_init_debug(struct ath_hw *ah)
  {
-@@ -1599,6 +1654,10 @@ int ath9k_init_debug(struct ath_hw *ah)
+@@ -1597,6 +1652,10 @@ int ath9k_init_debug(struct ath_hw *ah)
  			    &fops_eeprom);
  	debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  			    sc, &fops_chanbw);
diff --git a/package/kernel/mac80211/patches/542-ath9k_debugfs_diag.patch b/package/kernel/mac80211/patches/542-ath9k_debugfs_diag.patch
index eefe5e7bdf..e1b6ff17e8 100644
--- a/package/kernel/mac80211/patches/542-ath9k_debugfs_diag.patch
+++ b/package/kernel/mac80211/patches/542-ath9k_debugfs_diag.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/debug.c
 +++ b/drivers/net/wireless/ath/ath9k/debug.c
-@@ -1631,6 +1631,50 @@ static const struct file_operations fops
+@@ -1629,6 +1629,50 @@ static const struct file_operations fops
  #endif
  
  
@@ -51,7 +51,7 @@
  int ath9k_init_debug(struct ath_hw *ah)
  {
  	struct ath_common *common = ath9k_hw_common(ah);
-@@ -1658,6 +1702,8 @@ int ath9k_init_debug(struct ath_hw *ah)
+@@ -1656,6 +1700,8 @@ int ath9k_init_debug(struct ath_hw *ah)
  	debugfs_create_file("gpio_led", S_IWUSR,
  			   sc->debug.debugfs_phy, sc, &fops_gpio_led);
  #endif
-- 
2.30.2