From: greearb@candelatech.com
To: ath10k@lists.infradead.org
Cc: linux-wireless@vger.kernel.org, Ben Greear <greearb@candelatech.com>
Subject: [PATCH 14/21] ath10k: Add tx/rx bytes, cycle counters to ethtool stats.
Date: Mon, 9 May 2016 16:11:08 -0700 [thread overview]
Message-ID: <1462835475-11079-15-git-send-email-greearb@candelatech.com> (raw)
In-Reply-To: <1462835475-11079-1-git-send-email-greearb@candelatech.com>
From: Ben Greear <greearb@candelatech.com>
The firmware does not offer tx/rx bytes counters, so just keep track of
it in the driver.
For the cycle counters:
Note these counters are since the chip reset, though the counters
wrap often. When cycle-counters counter overflows on
certain hardware, it will right shift all 4 of the
related registers to the right by one bit (basically,
divide by two). Since you have no idea what the others
were at when cycle-counter wrapped, you must simply
ignore any sample where cycle-counter wraps, and set
new baseline values to calculate diffs against next
time.
Hardware with this funny wrap logic will cause the
d_flags 'counter' to have bit 0x1 set, so that is how
user-space can know how to deal with this.
Signed-off-by: Ben Greear <greearb@candelatech.com>
---
drivers/net/wireless/ath/ath10k/core.h | 3 +++
drivers/net/wireless/ath/ath10k/debug.c | 22 +++++++++++++++++-----
drivers/net/wireless/ath/ath10k/htt_rx.c | 3 +++
drivers/net/wireless/ath/ath10k/htt_tx.c | 22 +++++++++++++++++-----
4 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index c4f649f..1a75e2e 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -466,6 +466,9 @@ struct ath10k_debug {
struct ath10k_dbglog_entry_storage dbglog_entry_data;
struct ath10k_fw_crash_data *fw_crash_data;
+
+ u64 tx_bytes; /* counter, firmware does not offer this stat */
+ u64 rx_bytes; /* counter, firmware does not offer this stat */
};
enum ath10k_state {
diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 54a2194..684a39d 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -1442,11 +1442,15 @@ exit:
/* This generally cooresponds to the debugfs fw_stats file */
static const char ath10k_gstrings_stats[][ETH_GSTRING_LEN] = {
"tx_pkts_nic",
- "tx_bytes_nic",
+ "tx_bytes_nic", /* from driver, firmware does not keep this stat. */
"rx_pkts_nic",
- "rx_bytes_nic",
+ "rx_bytes_nic", /* from driver, firmware does not keep this stat. */
"d_noise_floor",
- "d_cycle_count",
+ "d_cycle_count", /* this is duty cycle counter, basically channel-time. 88MHz clock */
+ "d_tx_cycle_count", /* tx cycle count */
+ "d_rx_cycle_count", /* rx cycle count */
+ "d_busy_count", /* Total channel busy time cycles (called 'clear' by firmware) */
+ "d_flags", /* 0x1: hw has shifted cycle-count wrap, see ath10k_hw_fill_survey_time */
"d_phy_error",
"d_rts_bad",
"d_rts_good",
@@ -1518,6 +1522,7 @@ void ath10k_debug_get_et_stats(struct ieee80211_hw *hw,
static const struct ath10k_fw_stats_pdev zero_stats = {};
const struct ath10k_fw_stats_pdev *pdev_stats;
int i = 0, ret;
+ u64 d_flags = 0;
mutex_lock(&ar->conf_mutex);
@@ -1541,12 +1546,19 @@ void ath10k_debug_get_et_stats(struct ieee80211_hw *hw,
spin_lock_bh(&ar->data_lock);
+ if (ar->hw_params.has_shifted_cc_wraparound)
+ d_flags |= 0x1;
+
data[i++] = pdev_stats->hw_reaped; /* ppdu reaped */
- data[i++] = 0; /* tx bytes */
+ data[i++] = ar->debug.tx_bytes;
data[i++] = pdev_stats->htt_mpdus;
- data[i++] = 0; /* rx bytes */
+ data[i++] = ar->debug.rx_bytes;
data[i++] = pdev_stats->ch_noise_floor;
data[i++] = pdev_stats->cycle_count;
+ data[i++] = pdev_stats->tx_frame_count;
+ data[i++] = pdev_stats->rx_frame_count;
+ data[i++] = pdev_stats->rx_clear_count; /* yes, this appears to actually be 'busy' count */
+ data[i++] = d_flags; /* give user-space a chance to decode cycle counters */
data[i++] = pdev_stats->phy_err_count;
data[i++] = pdev_stats->rts_bad;
data[i++] = pdev_stats->rts_good;
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
index cc979a4..47da904 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -1379,6 +1379,9 @@ static void ath10k_htt_rx_h_mpdu(struct ath10k *ar,
}
skb_queue_walk(amsdu, msdu) {
+#ifdef CONFIG_ATH10K_DEBUGFS
+ ar->debug.rx_bytes += msdu->len;
+#endif
ath10k_htt_rx_h_csum_offload(msdu);
ath10k_htt_rx_h_undecap(ar, msdu, status, first_hdr, enctype,
is_decrypted);
diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c
index 6269c61..06ec995 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -769,6 +769,7 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
int len = 0;
int msdu_id = -1;
int res;
+ int skb_len;
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data;
len += sizeof(cmd->hdr);
@@ -795,7 +796,8 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
goto err_free_msdu_id;
}
- skb_cb->paddr = dma_map_single(dev, msdu->data, msdu->len,
+ skb_len = msdu->len;
+ skb_cb->paddr = dma_map_single(dev, msdu->data, skb_len,
DMA_TO_DEVICE);
res = dma_mapping_error(dev, skb_cb->paddr);
if (res) {
@@ -809,16 +811,20 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_MGMT_TX;
cmd->mgmt_tx.msdu_paddr = __cpu_to_le32(ATH10K_SKB_CB(msdu)->paddr);
- cmd->mgmt_tx.len = __cpu_to_le32(msdu->len);
+ cmd->mgmt_tx.len = __cpu_to_le32(skb_len);
cmd->mgmt_tx.desc_id = __cpu_to_le32(msdu_id);
cmd->mgmt_tx.vdev_id = __cpu_to_le32(vdev_id);
memcpy(cmd->mgmt_tx.hdr, msdu->data,
- min_t(int, msdu->len, HTT_MGMT_FRM_HDR_DOWNLOAD_LEN));
+ min_t(int, skb_len, HTT_MGMT_FRM_HDR_DOWNLOAD_LEN));
res = ath10k_htc_send(&htt->ar->htc, htt->eid, txdesc);
if (res)
goto err_unmap_msdu;
+#ifdef CONFIG_ATH10K_DEBUGFS
+ ar->debug.tx_bytes += skb_len;
+#endif
+
return 0;
err_unmap_msdu:
@@ -852,6 +858,7 @@ int ath10k_htt_tx(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txmode,
u8 flags0 = 0;
u16 msdu_id, flags1 = 0;
u16 freq = 0;
+ int skb_len;
u32 frags_paddr = 0;
u32 txbuf_paddr;
struct htt_msdu_ext_desc *ext_desc = NULL;
@@ -990,13 +997,14 @@ int ath10k_htt_tx(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txmode,
__cpu_to_le32(HTT_INVALID_PEERID);
}
+ skb_len = msdu->len;
trace_ath10k_htt_tx(ar, msdu_id, msdu->len, vdev_id, tid);
ath10k_dbg(ar, ATH10K_DBG_HTT,
"htt tx flags0 %hhu flags1 %hu len %d id %hu frags_paddr %08x, msdu_paddr %08x vdev %hhu tid %hhu freq %hu\n",
- flags0, flags1, msdu->len, msdu_id, frags_paddr,
+ flags0, flags1, skb_len, msdu_id, frags_paddr,
(u32)skb_cb->paddr, vdev_id, tid, freq);
ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "htt tx msdu: ",
- msdu->data, msdu->len);
+ msdu->data, skb_len);
trace_ath10k_tx_hdr(ar, msdu->data, msdu->len);
trace_ath10k_tx_payload(ar, msdu->data, msdu->len);
@@ -1021,6 +1029,10 @@ int ath10k_htt_tx(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txmode,
if (res)
goto err_unmap_msdu;
+#ifdef CONFIG_ATH10K_DEBUGFS
+ ar->debug.tx_bytes += skb_len;
+#endif
+
return 0;
err_unmap_msdu:
--
2.4.3
next prev parent reply other threads:[~2016-05-09 23:11 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-09 23:10 [PATCH 00/21] ath10k patches, generic and CT firmware related greearb
2016-05-09 23:10 ` [PATCH 01/21] ath10k: Fix crash related to printing features greearb
2016-05-09 23:10 ` [PATCH 02/21] ath10k: fix typo in logging message greearb
2016-05-09 23:10 ` [PATCH 03/21] ath10k: Support setting debug mask from driver code greearb
2016-05-11 10:40 ` Michal Kazior
2016-05-11 15:10 ` Ben Greear
2016-05-09 23:10 ` [PATCH 04/21] ath10k: rate-limit packet tx errors greearb
2016-05-09 23:10 ` [PATCH 05/21] ath10k: save firmware debug log messages greearb
2016-05-09 23:11 ` [PATCH 06/21] ath10k: save firmware stacks upon firmware crash greearb
2016-05-09 23:11 ` [PATCH 07/21] ath10k: save firmware RAM and ROM BSS sections on crash greearb
2016-05-09 23:11 ` [PATCH 08/21] ath10k: make firmware text debug messages more verbose greearb
2016-05-09 23:11 ` [PATCH 09/21] ath10k: print fw debug messages in hex greearb
2016-05-09 23:11 ` [PATCH 10/21] ath10k: support logging ath10k_info as KERN_DEBUG greearb
2016-05-09 23:11 ` [PATCH 11/21] ath10k: add fw-powerup-fail to ethtool stats greearb
2016-05-09 23:11 ` [PATCH 12/21] ath10k: Support up to 64 vdevs greearb
2016-05-09 23:11 ` [PATCH 13/21] ath10k: Document cycle count related counters greearb
2016-05-11 10:24 ` Michal Kazior
2016-05-09 23:11 ` greearb [this message]
2016-05-09 23:11 ` [PATCH 15/21] ath10k: support CT firmware flag greearb
2016-05-10 7:20 ` Mohammed Shafi Shajakhan
2016-05-10 14:52 ` Ben Greear
2016-05-09 23:11 ` [PATCH 16/21] ath10k: Support 32+ stations greearb
2016-05-09 23:11 ` [PATCH 17/21] ath10k: Enable detecting failure to install key in firmware (CT) greearb
2016-05-09 23:11 ` [PATCH 18/21] ath10k: Note limitation on beaconing vdevs greearb
2016-05-09 23:11 ` [PATCH 19/21] ath10k: Enable adhoc mode for CT firmware greearb
2016-05-09 23:11 ` [PATCH 20/21] ath10k: read firmware crash over ioread32 if CE fails greearb
2016-05-09 23:11 ` [PATCH 21/21] ath10k: Read dbglog buffers over register ping-pong greearb
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462835475-11079-15-git-send-email-greearb@candelatech.com \
--to=greearb@candelatech.com \
--cc=ath10k@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).