Skip to contentSkip to conversation

ath9k: Use macro to decrease code when priting recv stats.

PATCH New greearb-my8/[email protected] 3 participants 5 messages Apr 12, 2012 – Apr 17, 2012 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ath9k: Use macro to decrease code when priting recv stats.

From: Ben Greear <greearb-my8/[email protected]>

This hides some repetitive code, and will help if the column widths ever need to change.

---
:100644 100644 04edce9... 78f2962... M drivers/net/wireless/ath/ath9k/debug.c

 drivers/net/wireless/ath/ath9k/debug.c |   72 +++++++++++---------------------
 1 files changed, 24 insertions(+), 48 deletions(-)
drivers/net/wireless/ath/ath9k/debug.c +24 -48
index 04edce9..78f2962 100644
@@ -881,6 +881,13 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
 	len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \
 			sc->debug.stats.rxstats.phy_err_stats[p]);
 
+#define RXS_ERR(s, e)					    \
+	do {						    \
+		len += snprintf(buf + len, size - len,	    \
+				"%22s : %10u\n", s,	    \
+				sc->debug.stats.rxstats.e); \
+	} while (0)
+
 	struct ath_softc *sc = file->private_data;
 	char *buf;
 	unsigned int len = 0, size = 1600;
@@ -890,42 +897,18 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
 	if (buf == NULL)
 		return -ENOMEM;
 
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "CRC ERR",
-			sc->debug.stats.rxstats.crc_err);
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "DECRYPT CRC ERR",
-			sc->debug.stats.rxstats.decrypt_crc_err);
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "PHY ERR",
-			sc->debug.stats.rxstats.phy_err);
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "MIC ERR",
-			sc->debug.stats.rxstats.mic_err);
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "PRE-DELIM CRC ERR",
-			sc->debug.stats.rxstats.pre_delim_crc_err);
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "POST-DELIM CRC ERR",
-			sc->debug.stats.rxstats.post_delim_crc_err);
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "DECRYPT BUSY ERR",
-			sc->debug.stats.rxstats.decrypt_busy_err);
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "RX-LENGTH-ERR",
-			sc->debug.stats.rxstats.rx_len_err);
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "RX-OOM-ERR",
-			sc->debug.stats.rxstats.rx_oom_err);
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "RX-RATE-ERR",
-			sc->debug.stats.rxstats.rx_rate_err);
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "RX-DROP-RXFLUSH",
-			sc->debug.stats.rxstats.rx_drop_rxflush);
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "RX-TOO-MANY-FRAGS",
-			sc->debug.stats.rxstats.rx_too_many_frags_err);
+	RXS_ERR("CRC ERR", crc_err);
+	RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err);
+	RXS_ERR("PHY ERR", phy_err);
+	RXS_ERR("MIC ERR", mic_err);
+	RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err);
+	RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err);
+	RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err);
+	RXS_ERR("RX-LENGTH-ERR", rx_len_err);
+	RXS_ERR("RX-OOM-ERR", rx_oom_err);
+	RXS_ERR("RX-RATE-ERR", rx_rate_err);
+	RXS_ERR("RX-DROP-RXFLUSH", rx_drop_rxflush);
+	RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err);
 
 	PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN);
 	PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING);
@@ -954,18 +937,10 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
 	PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
 	PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL);
 
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "RX-Pkts-All",
-			sc->debug.stats.rxstats.rx_pkts_all);
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "RX-Bytes-All",
-			sc->debug.stats.rxstats.rx_bytes_all);
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "RX-Beacons",
-			sc->debug.stats.rxstats.rx_beacons);
-	len += snprintf(buf + len, size - len,
-			"%22s : %10u\n", "RX-Frags",
-			sc->debug.stats.rxstats.rx_frags);
+	RXS_ERR("RX-Pkts-All", rx_pkts_all);
+	RXS_ERR("RX-Bytes-All", rx_bytes_all);
+	RXS_ERR("RX-Beacons", rx_beacons);
+	RXS_ERR("RX-Frags", rx_frags);
 
 	if (len > size)
 		len = size;
@@ -975,6 +950,7 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
 
 	return retval;
 
+#undef RXS_ERR
 #undef PHY_ERR
 }
 
Signature · 6 lines
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

PATCH 2/2 ath9k: Gather and report IRQ sync_cause errors.

From: Ben Greear <[email protected]>

Report all defined sync_cause errors in debugfs
to aid with debugging.

Use a macro to print out the interrupts file contents to decrease code duplication.

---
:100644 100644 aa2abaf... 8d78253... M drivers/net/wireless/ath/ath9k/ar9002_mac.c
:100644 100644 a66a13b... d9e0824... M drivers/net/wireless/ath/ath9k/ar9003_mac.c
:100644 100644 78f2962... fde700c... M drivers/net/wireless/ath/ath9k/debug.c
:100644 100644 17f6cc2... c34da09... M drivers/net/wireless/ath/ath9k/debug.h
:100644 100644 d1345a8... 61b2157... M drivers/net/wireless/ath/ath9k/hw.c
:100644 100644 aa1680a... fba99ef... M drivers/net/wireless/ath/ath9k/hw.h

 drivers/net/wireless/ath/ath9k/ar9002_mac.c |    1 +
 drivers/net/wireless/ath/ath9k/ar9003_mac.c |    2 +
 drivers/net/wireless/ath/ath9k/debug.c      |  116 +++++++++++++++------------
 drivers/net/wireless/ath/ath9k/debug.h      |   23 +++++
 drivers/net/wireless/ath/ath9k/hw.c         |   49 +++++++++++
 drivers/net/wireless/ath/ath9k/hw.h         |    6 ++
 6 files changed, 145 insertions(+), 52 deletions(-)
drivers/net/wireless/ath/ath9k/ar9002_mac.c +1 -0
index aa2abaf..8d78253 100644
@@ -136,6 +136,7 @@ static bool ar9002_hw_get_isr(struct ath_hw *ah, enum ath9k_int *masked)
 	}
 
 	if (sync_cause) {
+		ath9k_debug_sync_cause(common, sync_cause);
 		fatal_int =
 			(sync_cause &
 			 (AR_INTR_SYNC_HOST1_FATAL | AR_INTR_SYNC_HOST1_PERR))
drivers/net/wireless/ath/ath9k/ar9003_mac.c +2 -0
index a66a13b..d9e0824 100644
@@ -306,6 +306,8 @@ static bool ar9003_hw_get_isr(struct ath_hw *ah, enum ath9k_int *masked)
 		ar9003_mci_get_isr(ah, masked);
 
 	if (sync_cause) {
+		ath9k_debug_sync_cause(common, sync_cause);
+
 		if (sync_cause & AR_INTR_SYNC_RADM_CPL_TIMEOUT) {
 			REG_WRITE(ah, AR_RC, AR_RC_HOSTIF);
 			REG_WRITE(ah, AR_RC, 0);
drivers/net/wireless/ath/ath9k/debug.c +64 -52

127 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/debug.h +23 -0
index 17f6cc2..c34da09 100644
@@ -60,6 +60,7 @@ struct ath_buf;
  * @tsfoor: TSF out of range, indicates that the corrected TSF received
  * from a beacon differs from the PCU's internal TSF by more than a
  * (programmable) threshold
+ * @local_timeout: Internal bus timeout.
  */
 struct ath_interrupt_stats {
 	u32 total;
@@ -85,8 +86,30 @@ struct ath_interrupt_stats {
 	u32 dtim;
 	u32 bb_watchdog;
 	u32 tsfoor;
+
+	/* Sync-cause stats */
+	u32 sync_cause_all;
+	u32 sync_rtc_irq;
+	u32 sync_mac_irq;
+	u32 eeprom_illegal_access;
+	u32 apb_timeout;
+	u32 pci_mode_conflict;
+	u32 host1_fatal;
+	u32 host1_perr;
+	u32 trcv_fifo_perr;
+	u32 radm_cpl_ep;
+	u32 radm_cpl_dllp_abort;
+	u32 radm_cpl_tlp_abort;
+	u32 radm_cpl_ecrc_err;
+	u32 radm_cpl_timeout;
+	u32 local_timeout;
+	u32 pm_access;
+	u32 mac_awake;
+	u32 mac_asleep;
+	u32 mac_sleep_access;
 };
 
+
 /**
  * struct ath_tx_stats - Statistics about TX
  * @tx_pkts_all:  No. of total frames transmitted, including ones that
drivers/net/wireless/ath/ath9k/hw.c +49 -0

61 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/hw.h +6 -0
index aa1680a..fba99ef 100644
@@ -965,6 +965,12 @@ bool ath9k_hw_check_alive(struct ath_hw *ah);
 
 bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode);
 
+#ifdef CONFIG_ATH9K_DEBUGFS
+void ath9k_debug_sync_cause(struct ath_common *common, u32 sync_cause);
+#else
+static void ath9k_debug_sync_cause(struct ath_common *common, u32 sync_cause) {}
+#endif
+
 /* Generic hw timer primitives */
 struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah,
 					  void (*trigger)(void *),
Signature · 1 line
1.7.3.4
#3 lore raw

Re: [PATCH 2/2] ath9k: Gather and report IRQ sync_cause errors.

In reply to a message not in the archive
Quoted 7 lines

From: Ben Greear <greearb-my8/[email protected]>

Report all defined sync_cause errors in debugfs
to aid with debugging.

Use a macro to print out the interrupts file contents to decrease code duplication.

Now, that the patch is in wireless-testing, I have noticed a minor problem with it.

Quoted 3 lines

---

<...>

drivers/net/wireless/ath/ath9k/hw.h bool ath9k_hw_check_alive(struct ath_hw *ah); · line 971

Quoted 12 lines
drivers/net/wireless/ath/ath9k/hw.h +4 -0
index aa1680a..fba99ef 100644
@@ -965,6 +965,12 @@ bool ath9k_hw_check_alive(struct ath_hw *ah);
 
 bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode);
 
+#ifdef CONFIG_ATH9K_DEBUGFS
+void ath9k_debug_sync_cause(struct ath_common *common, u32 sync_cause);
+#else
+static void ath9k_debug_sync_cause(struct ath_common *common, u32 sync_cause) {}

Due to a missing 'inline' keyword, this causes a bunch of warnings if CONFIG_ATH9K_DEBUGFS is not enabled:

   CC [M]  drivers/net/wireless/ath/main.o
   CC [M]  drivers/net/wireless/ath/regd.o
   CC [M]  drivers/net/wireless/ath/hw.o
   CC [M]  drivers/net/wireless/ath/key.o
   LD [M]  drivers/net/wireless/ath/ath.o
   CC [M]  drivers/net/wireless/ath/ath9k/beacon.o

drivers/net/wireless/ath/ath9k/hw.h:962: warning: ‘ath9k_debug_sync_cause’
defined but not used
CC [M] drivers/net/wireless/ath/ath9k/gpio.o
drivers/net/wireless/ath/ath9k/hw.h:962: warning: ‘ath9k_debug_sync_cause’
defined but not used
CC [M] drivers/net/wireless/ath/ath9k/init.o
drivers/net/wireless/ath/ath9k/hw.h:962: warning: ‘ath9k_debug_sync_cause’
defined but not used
CC [M] drivers/net/wireless/ath/ath9k/main.o
drivers/net/wireless/ath/ath9k/hw.h:962: warning: ‘ath9k_debug_sync_cause’
defined but not used
CC [M] drivers/net/wireless/ath/ath9k/recv.o

-Gabor

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Re: [PATCH 2/2] ath9k: Gather and report IRQ sync_cause errors.

Quoted 9 lines · Gabor Juhos
Quoted 7 lines

From: Ben Greear<[email protected]>

Report all defined sync_cause errors in debugfs
to aid with debugging.

Use a macro to print out the interrupts file contents to decrease code duplication.

Now, that the patch is in wireless-testing, I have noticed a minor problem with it.

Thanks for the report.

I'll fix this shortly.

Thanks,
Ben

Quoted 16 lines

drivers/net/wireless/ath/ath9k/hw.h bool ath9k_hw_check_alive(struct ath_hw *ah); · line 971

Quoted 4 lines
drivers/net/wireless/ath/ath9k/hw.h +4 -0
+#ifdef CONFIG_ATH9K_DEBUGFS
+void ath9k_debug_sync_cause(struct ath_common *common, u32 sync_cause);
+#else
+static void ath9k_debug_sync_cause(struct ath_common *common, u32 sync_cause) {}

Due to a missing 'inline' keyword, this causes a bunch of warnings if CONFIG_ATH9K_DEBUGFS is not enabled:

    CC [M]  drivers/net/wireless/ath/main.o
    CC [M]  drivers/net/wireless/ath/regd.o
    CC [M]  drivers/net/wireless/ath/hw.o
    CC [M]  drivers/net/wireless/ath/key.o
    LD [M]  drivers/net/wireless/ath/ath.o
    CC [M]  drivers/net/wireless/ath/ath9k/beacon.o

drivers/net/wireless/ath/ath9k/hw.h:962: warning: ‘ath9k_debug_sync_cause’
defined but not used

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#6 lore raw

Re: [PATCH 2/2] ath9k: Gather and report IRQ sync_cause errors.

In reply to a message not in the archive

2012.04.17. 23:13 keltezéssel, Ben Greear írta:

Quoted 6 lines · Gabor Juhos
Quoted 5 lines
Quoted 5 lines

From: Ben Greear<[email protected]>

Report all defined sync_cause errors in debugfs
to aid with debugging.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Use a macro to print out the interrupts file contents to decrease code duplication.

Now, that the patch is in wireless-testing, I have noticed a minor problem with it.

Thanks for the report.

Np.

Quoted 1 line

I'll fix this shortly.

Thanks,
Gabor

Quoted 22 lines

Thanks,
Ben

Quoted 17 lines
Quoted 5 lines
drivers/net/wireless/ath/ath9k/hw.h +4 -0
+#ifdef CONFIG_ATH9K_DEBUGFS
+void ath9k_debug_sync_cause(struct ath_common *common, u32 sync_cause);
+#else
+static void ath9k_debug_sync_cause(struct ath_common *common, u32

sync_cause) {}

Due to a missing 'inline' keyword, this causes a bunch of warnings if CONFIG_ATH9K_DEBUGFS is not enabled:

    CC [M]  drivers/net/wireless/ath/main.o
    CC [M]  drivers/net/wireless/ath/regd.o
    CC [M]  drivers/net/wireless/ath/hw.o
    CC [M]  drivers/net/wireless/ath/key.o
    LD [M]  drivers/net/wireless/ath/ath.o
    CC [M]  drivers/net/wireless/ath/ath9k/beacon.o

drivers/net/wireless/ath/ath9k/hw.h:962: warning: ‘ath9k_debug_sync_cause’
defined but not used