ath10k: add helper method to grab debug stats.
PATCH 1/2 ath10k: add helper method to grab debug stats.
From: Ben Greear <[email protected]>
It can be nice to update the firmware's stats while debugging other bits of the driver, so add helper method to do this.
--- drivers/net/wireless/ath/ath10k/debug.c | 26 +++++++++++++++++--------- drivers/net/wireless/ath/ath10k/debug.h | 3 +++ 2 files changed, 20 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath10k/debug.c +17 -9
@@ -371,6 +371,21 @@ void ath10k_debug_read_target_stats(struct ath10k *ar,complete (&ar->debug.event_stats_compl); } +int ath10k_refresh_peer_stats (struct ath10k *ar) +{ +int ret =ath10k_wmi_request_stats (ar,WMI_REQUEST_PEER_STAT ); +if (ret) { +ath10k_warn (ar,"could not request stats (%d)\n" , ret); +return ret; + } + + ret =wait_for_completion_timeout (&ar->debug.event_stats_compl,1 *HZ ); +if (ret <=0 ) +return ret; + +return 0 ; +} +static ssize_t ath10k_read_fw_stats (struct file *file,char __user *user_buf,size_t count,loff_t *ppos) {
@@ -379,7 +394,6 @@ static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf,char *buf =NULL ;unsigned int len =0 , buf_len =8000 ;ssize_t ret_cnt =0 ; -long left;int i;int ret;
@@ -394,14 +408,8 @@ static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf,if (!buf) goto exit; - ret =ath10k_wmi_request_stats (ar,WMI_REQUEST_PEER_STAT ); -if (ret) { -ath10k_warn (ar,"could not request stats (%d)\n" , ret); - goto exit; - } - - left =wait_for_completion_timeout (&ar->debug.event_stats_compl,1 *HZ ); -if (left <=0 ) + ret =ath10k_refresh_peer_stats (ar); +if (ret) goto exit;spin_lock_bh (&ar->data_lock);
drivers/net/wireless/ath/ath10k/debug.h +3 -0
@@ -142,4 +142,7 @@ static inline void ath10k_dbg_dump(struct ath10k *ar, { }#endif /* CONFIG_ATH10K_DEBUG */ + +int ath10k_refresh_peer_stats (struct ath10k *ar); +#endif /* _DEBUG_H_ */
Signature · 1 line
1.7.11.7
PATCH 2/2 ath10k: support ethtool stats.
From: Ben Greear <[email protected]>
Add support for reading firmware stats through the ethtool API. This may be easier for applications to manipulate compared to parsing a text based debugfs file.
--- drivers/net/wireless/ath/ath10k/core.h | 4 + drivers/net/wireless/ath/ath10k/debug.c | 143 ++++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/debug.h | 9 ++ drivers/net/wireless/ath/ath10k/mac.c | 5 ++ drivers/net/wireless/ath/ath10k/pci.c | 4 + 5 files changed, 165 insertions(+)
drivers/net/wireless/ath/ath10k/core.h +4 -0
@@ -544,6 +544,10 @@ struct ath10k {struct dfs_pattern_detector *dfs_detector; +u32 fw_crash_counter; +u32 fw_warm_reset_counter; +u32 fw_cold_reset_counter; +#ifdef CONFIG_ATH10K_DEBUGFS struct ath10k_debug debug;#endif
drivers/net/wireless/ath/ath10k/debug.c +143 -0
149 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/debug.h +9 -0
@@ -64,6 +64,15 @@ void ath10k_debug_dbglog_add(struct ath10k *ar, u8 *buffer, int len);#define ATH10K_DFS_STAT_INC (ar, c) (ar->debug.dfs_stats.c++) +void ath10k_get_et_strings (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +u32 sset,u8 *data); +int ath10k_get_et_sset_count (struct ieee80211_hw *hw, +struct ieee80211_vif *vif,int sset); +void ath10k_get_et_stats (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ethtool_stats *stats,u64 *data); +#else static inline int ath10k_debug_start (struct ath10k *ar) {
drivers/net/wireless/ath/ath10k/mac.c +5 -0
@@ -4468,6 +4468,11 @@ static const struct ieee80211_ops ath10k_ops = { .suspend = ath10k_suspend, .resume = ath10k_resume,#endif +#ifdef CONFIG_ATH10K_DEBUGFS + .get_et_sset_count = ath10k_get_et_sset_count, + .get_et_stats = ath10k_get_et_stats, + .get_et_strings = ath10k_get_et_strings, +#endif };#define RATETAB_ENT (_rate, _rateid, _flags) { \
drivers/net/wireless/ath/ath10k/pci.c +4 -0
@@ -986,6 +986,8 @@ static void ath10k_pci_fw_crashed_dump(struct ath10k *ar)spin_lock_bh (&ar->data_lock); + ar->fw_crash_counter++; + crash_data =ath10k_debug_get_new_fw_crash_data (ar);if (crash_data)
@@ -1671,6 +1673,7 @@ static int ath10k_pci_warm_reset(struct ath10k *ar)u32 val;ath10k_dbg (ar,ATH10K_DBG_BOOT ,"boot warm reset\n" ); + ar->fw_warm_reset_counter++;/* debug */ val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS +
@@ -2286,6 +2289,7 @@ static int ath10k_pci_cold_reset(struct ath10k *ar)u32 val;ath10k_dbg (ar,ATH10K_DBG_BOOT ,"boot cold reset\n" ); + ar->fw_cold_reset_counter++;/* Put Target, including PCIe, into RESET. */ val =ath10k_pci_reg_read32 (ar,SOC_GLOBAL_RESET_ADDRESS );
Signature · 1 line
1.7.11.7
Re: [PATCH 2/2] ath10k: support ethtool stats.
Quoted 5 lines · On 19 September 2014 20:17, <[email protected]> wrote:
From: Ben Greear <[email protected]>
Add support for reading firmware stats through the ethtool API. This may be easier for applications to manipulate compared to parsing a text based debugfs file.
You also seem to be adding fw crash and reset countes. It's probably worth including this in the commit log.
drivers/net/wireless/ath/ath10k/debug.c exit: · line 1044
Quoted 5 lines
drivers/net/wireless/ath/ath10k/debug.c +5
-0+#ifdef CONFIG_ATH10K_DEBUGFS +/* TODO: Would be nice to always support ethtool stats, would need to +* move the stats storage out of ath10k_debug, or always have ath10k_debug +* struct available.. +*/
I was actually wondering about moving ath10k_target_stats out of debug while doing some cleanups. Your patch can actually justify this kind of move.
[...]
Quoted 36 lines
drivers/net/wireless/ath/ath10k/debug.c +36
-0+ data[i++] = fw_stats->hw_reaped;/* ppdu reaped */ + data[i++] =0 ;/* tx bytes */ + data[i++] = fw_stats->htt_mpdus; + data[i++] =0 ;/* rx bytes */ + data[i++] = fw_stats->ch_noise_floor; + data[i++] = fw_stats->cycle_count; + data[i++] = fw_stats->phy_err_count; + data[i++] = fw_stats->rts_bad; + data[i++] = fw_stats->rts_good; + data[i++] = fw_stats->chan_tx_power; + data[i++] = fw_stats->fcs_bad; + data[i++] = fw_stats->no_beacons; + data[i++] = fw_stats->mpdu_enqued; + data[i++] = fw_stats->msdu_enqued; + data[i++] = fw_stats->wmm_drop; + data[i++] = fw_stats->local_enqued; + data[i++] = fw_stats->local_freed; + data[i++] = fw_stats->hw_queued; + data[i++] = fw_stats->hw_reaped; + data[i++] = fw_stats->underrun; + data[i++] = fw_stats->tx_abort; + data[i++] = fw_stats->mpdus_requed; + data[i++] = fw_stats->tx_ko; + data[i++] = fw_stats->data_rc; + data[i++] = fw_stats->sw_retry_failure; + data[i++] = fw_stats->illgl_rate_phy_err; + data[i++] = fw_stats->pdev_cont_xretry; + data[i++] = fw_stats->pdev_tx_timeout; + data[i++] = fw_stats->txop_ovf; + data[i++] = fw_stats->pdev_resets; + data[i++] = fw_stats->mid_ppdu_route_change; + data[i++] = fw_stats->status_rcvd; + data[i++] = fw_stats->r0_frags; + data[i++] = fw_stats->r1_frags; + data[i++] = fw_stats->r2_frags; + data[i++] = fw_stats->r3_frags;
drivers/net/wireless/ath/ath10k/debug.c exit: · line 1174
Quoted 10 lines
drivers/net/wireless/ath/ath10k/debug.c +10
-0+ data[i++] = fw_stats->htt_msdus; + data[i++] = fw_stats->htt_mpdus; + data[i++] = fw_stats->loc_msdus; + data[i++] = fw_stats->loc_mpdus; + data[i++] = fw_stats->phy_errs; + data[i++] = fw_stats->phy_err_drop; + data[i++] = fw_stats->mpdu_errs; + data[i++] = ar->fw_crash_counter; + data[i++] = ar->fw_warm_reset_counter; + data[i++] = ar->fw_cold_reset_counter;
fw_stats should be protected by ar->data_lock. See ath10k_read_fw_stats(). You could in theory report inconsistent stats.
Quoted 20 lines
drivers/net/wireless/ath/ath10k/pci.c +3
-0@@ -986,6 +986,8 @@ static void ath10k_pci_fw_crashed_dump(struct ath10k *ar)spin_lock_bh (&ar->data_lock); + ar->fw_crash_counter++; + crash_data =ath10k_debug_get_new_fw_crash_data (ar);if (crash_data)@@ -1671,6 +1673,7 @@ static int ath10k_pci_warm_reset(struct ath10k *ar)u32 val;ath10k_dbg (ar,ATH10K_DBG_BOOT ,"boot warm reset\n" ); + ar->fw_warm_reset_counter++;/* debug */ val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS +
drivers/net/wireless/ath/ath10k/pci.c static int ath10k_pci_cold_reset(struct ath10k *ar) · line 2295
Quoted 7 lines
drivers/net/wireless/ath/ath10k/pci.c +1
-0@@ -2286,6 +2289,7 @@ static int ath10k_pci_cold_reset(struct ath10k *ar)u32 val;ath10k_dbg (ar,ATH10K_DBG_BOOT ,"boot cold reset\n" ); + ar->fw_cold_reset_counter++;/* Put Target, including PCIe, into RESET. */ val =ath10k_pci_reg_read32 (ar,SOC_GLOBAL_RESET_ADDRESS );
Unprotected? I guess it's not terribly wrong since this is the only place it updates the values.
Michał