2 * Copyright (c) 2014-2017 Qualcomm Atheros, Inc.
3 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 static void ath10k_rx_stats_update_amsdu_subfrm(struct ath10k *ar,
24 struct ath10k_sta_tid_stats *stats,
28 stats->rx_pkt_amsdu[ATH10K_AMSDU_SUBFRM_NUM_1]++;
29 else if (msdu_count == 2)
30 stats->rx_pkt_amsdu[ATH10K_AMSDU_SUBFRM_NUM_2]++;
31 else if (msdu_count == 3)
32 stats->rx_pkt_amsdu[ATH10K_AMSDU_SUBFRM_NUM_3]++;
33 else if (msdu_count == 4)
34 stats->rx_pkt_amsdu[ATH10K_AMSDU_SUBFRM_NUM_4]++;
35 else if (msdu_count > 4)
36 stats->rx_pkt_amsdu[ATH10K_AMSDU_SUBFRM_NUM_MORE]++;
39 static void ath10k_rx_stats_update_ampdu_subfrm(struct ath10k *ar,
40 struct ath10k_sta_tid_stats *stats,
44 stats->rx_pkt_ampdu[ATH10K_AMPDU_SUBFRM_NUM_10]++;
45 else if (mpdu_count <= 20)
46 stats->rx_pkt_ampdu[ATH10K_AMPDU_SUBFRM_NUM_20]++;
47 else if (mpdu_count <= 30)
48 stats->rx_pkt_ampdu[ATH10K_AMPDU_SUBFRM_NUM_30]++;
49 else if (mpdu_count <= 40)
50 stats->rx_pkt_ampdu[ATH10K_AMPDU_SUBFRM_NUM_40]++;
51 else if (mpdu_count <= 50)
52 stats->rx_pkt_ampdu[ATH10K_AMPDU_SUBFRM_NUM_50]++;
53 else if (mpdu_count <= 60)
54 stats->rx_pkt_ampdu[ATH10K_AMPDU_SUBFRM_NUM_60]++;
55 else if (mpdu_count > 60)
56 stats->rx_pkt_ampdu[ATH10K_AMPDU_SUBFRM_NUM_MORE]++;
59 void ath10k_sta_update_rx_tid_stats_ampdu(struct ath10k *ar, u16 peer_id, u8 tid,
60 struct htt_rx_indication_mpdu_range *ranges,
63 struct ath10k_sta *arsta;
64 struct ath10k_peer *peer;
67 if (tid > IEEE80211_NUM_TIDS || !(ar->sta_tid_stats_mask & BIT(tid)))
71 spin_lock_bh(&ar->data_lock);
73 peer = ath10k_peer_find_by_id(ar, peer_id);
74 if (!peer || !peer->sta)
77 arsta = (struct ath10k_sta *)peer->sta->drv_priv;
79 for (i = 0; i < num_ranges; i++)
80 ath10k_rx_stats_update_ampdu_subfrm(ar,
81 &arsta->tid_stats[tid],
82 ranges[i].mpdu_count);
85 spin_unlock_bh(&ar->data_lock);
89 void ath10k_sta_update_rx_tid_stats(struct ath10k *ar, u8 *first_hdr,
90 unsigned long num_msdus,
91 enum ath10k_pkt_rx_err err,
92 unsigned long unchain_cnt,
93 unsigned long drop_cnt,
94 unsigned long drop_cnt_filter,
95 unsigned long queued_msdus)
97 struct ieee80211_sta *sta;
98 struct ath10k_sta *arsta;
99 struct ieee80211_hdr *hdr;
100 struct ath10k_sta_tid_stats *stats;
101 u8 tid = IEEE80211_NUM_TIDS;
102 bool non_data_frm = false;
104 hdr = (struct ieee80211_hdr *)first_hdr;
105 if (!ieee80211_is_data(hdr->frame_control))
108 if (ieee80211_is_data_qos(hdr->frame_control))
109 tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
111 if (!(ar->sta_tid_stats_mask & BIT(tid)) || non_data_frm)
116 sta = ieee80211_find_sta_by_ifaddr(ar->hw, hdr->addr2, NULL);
120 arsta = (struct ath10k_sta *)sta->drv_priv;
122 spin_lock_bh(&ar->data_lock);
123 stats = &arsta->tid_stats[tid];
124 stats->rx_pkt_from_fw += num_msdus;
125 stats->rx_pkt_unchained += unchain_cnt;
126 stats->rx_pkt_drop_chained += drop_cnt;
127 stats->rx_pkt_drop_filter += drop_cnt_filter;
128 if (err != ATH10K_PKT_RX_ERR_MAX)
129 stats->rx_pkt_err[err] += queued_msdus;
130 stats->rx_pkt_queued_for_mac += queued_msdus;
131 ath10k_rx_stats_update_amsdu_subfrm(ar, &arsta->tid_stats[tid],
133 spin_unlock_bh(&ar->data_lock);
139 static void ath10k_sta_update_extd_stats_rx_duration(struct ath10k *ar,
140 struct ath10k_fw_stats *stats)
142 struct ath10k_fw_extd_stats_peer *peer;
143 struct ieee80211_sta *sta;
144 struct ath10k_sta *arsta;
147 list_for_each_entry(peer, &stats->peers_extd, list) {
148 sta = ieee80211_find_sta_by_ifaddr(ar->hw, peer->peer_macaddr,
152 arsta = (struct ath10k_sta *)sta->drv_priv;
153 arsta->rx_duration += (u64)peer->rx_duration;
158 static void ath10k_sta_update_stats_rx_duration(struct ath10k *ar,
159 struct ath10k_fw_stats *stats)
161 struct ath10k_fw_stats_peer *peer;
162 struct ieee80211_sta *sta;
163 struct ath10k_sta *arsta;
166 list_for_each_entry(peer, &stats->peers, list) {
167 sta = ieee80211_find_sta_by_ifaddr(ar->hw, peer->peer_macaddr,
171 arsta = (struct ath10k_sta *)sta->drv_priv;
172 arsta->rx_duration += (u64)peer->rx_duration;
177 void ath10k_sta_update_rx_duration(struct ath10k *ar,
178 struct ath10k_fw_stats *stats)
181 ath10k_sta_update_extd_stats_rx_duration(ar, stats);
183 ath10k_sta_update_stats_rx_duration(ar, stats);
186 static ssize_t ath10k_dbg_sta_read_aggr_mode(struct file *file,
187 char __user *user_buf,
188 size_t count, loff_t *ppos)
190 struct ieee80211_sta *sta = file->private_data;
191 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
192 struct ath10k *ar = arsta->arvif->ar;
196 mutex_lock(&ar->conf_mutex);
197 len = scnprintf(buf, sizeof(buf) - len, "aggregation mode: %s\n",
198 (arsta->aggr_mode == ATH10K_DBG_AGGR_MODE_AUTO) ?
200 mutex_unlock(&ar->conf_mutex);
202 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
205 static ssize_t ath10k_dbg_sta_write_aggr_mode(struct file *file,
206 const char __user *user_buf,
207 size_t count, loff_t *ppos)
209 struct ieee80211_sta *sta = file->private_data;
210 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
211 struct ath10k *ar = arsta->arvif->ar;
215 if (kstrtouint_from_user(user_buf, count, 0, &aggr_mode))
218 if (aggr_mode >= ATH10K_DBG_AGGR_MODE_MAX)
221 mutex_lock(&ar->conf_mutex);
222 if ((ar->state != ATH10K_STATE_ON) ||
223 (aggr_mode == arsta->aggr_mode)) {
228 ret = ath10k_wmi_addba_clear_resp(ar, arsta->arvif->vdev_id, sta->addr);
230 ath10k_warn(ar, "failed to clear addba session ret: %d\n", ret);
234 arsta->aggr_mode = aggr_mode;
236 mutex_unlock(&ar->conf_mutex);
240 static const struct file_operations fops_aggr_mode = {
241 .read = ath10k_dbg_sta_read_aggr_mode,
242 .write = ath10k_dbg_sta_write_aggr_mode,
244 .owner = THIS_MODULE,
245 .llseek = default_llseek,
248 static ssize_t ath10k_dbg_sta_write_addba(struct file *file,
249 const char __user *user_buf,
250 size_t count, loff_t *ppos)
252 struct ieee80211_sta *sta = file->private_data;
253 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
254 struct ath10k *ar = arsta->arvif->ar;
259 ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
264 ret = sscanf(buf, "%u %u", &tid, &buf_size);
268 /* Valid TID values are 0 through 15 */
269 if (tid > HTT_DATA_TX_EXT_TID_MGMT - 2)
272 mutex_lock(&ar->conf_mutex);
273 if ((ar->state != ATH10K_STATE_ON) ||
274 (arsta->aggr_mode != ATH10K_DBG_AGGR_MODE_MANUAL)) {
279 ret = ath10k_wmi_addba_send(ar, arsta->arvif->vdev_id, sta->addr,
282 ath10k_warn(ar, "failed to send addba request: vdev_id %u peer %pM tid %u buf_size %u\n",
283 arsta->arvif->vdev_id, sta->addr, tid, buf_size);
288 mutex_unlock(&ar->conf_mutex);
292 static const struct file_operations fops_addba = {
293 .write = ath10k_dbg_sta_write_addba,
295 .owner = THIS_MODULE,
296 .llseek = default_llseek,
299 static ssize_t ath10k_dbg_sta_write_addba_resp(struct file *file,
300 const char __user *user_buf,
301 size_t count, loff_t *ppos)
303 struct ieee80211_sta *sta = file->private_data;
304 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
305 struct ath10k *ar = arsta->arvif->ar;
310 ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
315 ret = sscanf(buf, "%u %u", &tid, &status);
319 /* Valid TID values are 0 through 15 */
320 if (tid > HTT_DATA_TX_EXT_TID_MGMT - 2)
323 mutex_lock(&ar->conf_mutex);
324 if ((ar->state != ATH10K_STATE_ON) ||
325 (arsta->aggr_mode != ATH10K_DBG_AGGR_MODE_MANUAL)) {
330 ret = ath10k_wmi_addba_set_resp(ar, arsta->arvif->vdev_id, sta->addr,
333 ath10k_warn(ar, "failed to send addba response: vdev_id %u peer %pM tid %u status%u\n",
334 arsta->arvif->vdev_id, sta->addr, tid, status);
338 mutex_unlock(&ar->conf_mutex);
342 static const struct file_operations fops_addba_resp = {
343 .write = ath10k_dbg_sta_write_addba_resp,
345 .owner = THIS_MODULE,
346 .llseek = default_llseek,
349 static ssize_t ath10k_dbg_sta_write_delba(struct file *file,
350 const char __user *user_buf,
351 size_t count, loff_t *ppos)
353 struct ieee80211_sta *sta = file->private_data;
354 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
355 struct ath10k *ar = arsta->arvif->ar;
356 u32 tid, initiator, reason;
360 ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
365 ret = sscanf(buf, "%u %u %u", &tid, &initiator, &reason);
369 /* Valid TID values are 0 through 15 */
370 if (tid > HTT_DATA_TX_EXT_TID_MGMT - 2)
373 mutex_lock(&ar->conf_mutex);
374 if ((ar->state != ATH10K_STATE_ON) ||
375 (arsta->aggr_mode != ATH10K_DBG_AGGR_MODE_MANUAL)) {
380 ret = ath10k_wmi_delba_send(ar, arsta->arvif->vdev_id, sta->addr,
381 tid, initiator, reason);
383 ath10k_warn(ar, "failed to send delba: vdev_id %u peer %pM tid %u initiator %u reason %u\n",
384 arsta->arvif->vdev_id, sta->addr, tid, initiator,
389 mutex_unlock(&ar->conf_mutex);
393 static const struct file_operations fops_delba = {
394 .write = ath10k_dbg_sta_write_delba,
396 .owner = THIS_MODULE,
397 .llseek = default_llseek,
400 static ssize_t ath10k_dbg_sta_read_peer_debug_trigger(struct file *file,
401 char __user *user_buf,
405 struct ieee80211_sta *sta = file->private_data;
406 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
407 struct ath10k *ar = arsta->arvif->ar;
411 mutex_lock(&ar->conf_mutex);
412 len = scnprintf(buf, sizeof(buf) - len,
413 "Write 1 to once trigger the debug logs\n");
414 mutex_unlock(&ar->conf_mutex);
416 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
420 ath10k_dbg_sta_write_peer_debug_trigger(struct file *file,
421 const char __user *user_buf,
422 size_t count, loff_t *ppos)
424 struct ieee80211_sta *sta = file->private_data;
425 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
426 struct ath10k *ar = arsta->arvif->ar;
427 u8 peer_debug_trigger;
430 if (kstrtou8_from_user(user_buf, count, 0, &peer_debug_trigger))
433 if (peer_debug_trigger != 1)
436 mutex_lock(&ar->conf_mutex);
438 if (ar->state != ATH10K_STATE_ON) {
443 ret = ath10k_wmi_peer_set_param(ar, arsta->arvif->vdev_id, sta->addr,
444 WMI_PEER_DEBUG, peer_debug_trigger);
446 ath10k_warn(ar, "failed to set param to trigger peer tid logs for station ret: %d\n",
451 mutex_unlock(&ar->conf_mutex);
455 static const struct file_operations fops_peer_debug_trigger = {
457 .read = ath10k_dbg_sta_read_peer_debug_trigger,
458 .write = ath10k_dbg_sta_write_peer_debug_trigger,
459 .owner = THIS_MODULE,
460 .llseek = default_llseek,
463 static ssize_t ath10k_dbg_sta_read_peer_ps_state(struct file *file,
464 char __user *user_buf,
465 size_t count, loff_t *ppos)
467 struct ieee80211_sta *sta = file->private_data;
468 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
469 struct ath10k *ar = arsta->arvif->ar;
473 spin_lock_bh(&ar->data_lock);
475 len = scnprintf(buf, sizeof(buf) - len, "%d\n",
476 arsta->peer_ps_state);
478 spin_unlock_bh(&ar->data_lock);
480 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
483 static const struct file_operations fops_peer_ps_state = {
485 .read = ath10k_dbg_sta_read_peer_ps_state,
486 .owner = THIS_MODULE,
487 .llseek = default_llseek,
490 static char *get_err_str(enum ath10k_pkt_rx_err i)
493 case ATH10K_PKT_RX_ERR_FCS:
495 case ATH10K_PKT_RX_ERR_TKIP:
497 case ATH10K_PKT_RX_ERR_CRYPT:
499 case ATH10K_PKT_RX_ERR_PEER_IDX_INVAL:
500 return "peer_idx_inval";
501 case ATH10K_PKT_RX_ERR_MAX:
508 static char *get_num_ampdu_subfrm_str(enum ath10k_ampdu_subfrm_num i)
511 case ATH10K_AMPDU_SUBFRM_NUM_10:
513 case ATH10K_AMPDU_SUBFRM_NUM_20:
515 case ATH10K_AMPDU_SUBFRM_NUM_30:
517 case ATH10K_AMPDU_SUBFRM_NUM_40:
519 case ATH10K_AMPDU_SUBFRM_NUM_50:
521 case ATH10K_AMPDU_SUBFRM_NUM_60:
523 case ATH10K_AMPDU_SUBFRM_NUM_MORE:
525 case ATH10K_AMPDU_SUBFRM_NUM_MAX:
532 static char *get_num_amsdu_subfrm_str(enum ath10k_amsdu_subfrm_num i)
535 case ATH10K_AMSDU_SUBFRM_NUM_1:
537 case ATH10K_AMSDU_SUBFRM_NUM_2:
539 case ATH10K_AMSDU_SUBFRM_NUM_3:
541 case ATH10K_AMSDU_SUBFRM_NUM_4:
543 case ATH10K_AMSDU_SUBFRM_NUM_MORE:
545 case ATH10K_AMSDU_SUBFRM_NUM_MAX:
552 #define PRINT_TID_STATS(_field, _tabs) \
555 for (j = 0; j <= IEEE80211_NUM_TIDS; j++) { \
556 if (ar->sta_tid_stats_mask & BIT(j)) { \
557 len += scnprintf(buf + len, buf_len - len, \
559 j, stats[j]._field); \
562 len += scnprintf(buf + len, \
563 buf_len - len, "\n"); \
564 len += scnprintf(buf + len, \
570 len += scnprintf(buf + len, buf_len - len, "\n"); \
573 static ssize_t ath10k_dbg_sta_read_tid_stats(struct file *file,
574 char __user *user_buf,
575 size_t count, loff_t *ppos)
577 struct ieee80211_sta *sta = file->private_data;
578 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
579 struct ath10k *ar = arsta->arvif->ar;
580 struct ath10k_sta_tid_stats *stats = arsta->tid_stats;
581 size_t len = 0, buf_len = 1048 * IEEE80211_NUM_TIDS;
586 buf = kzalloc(buf_len, GFP_KERNEL);
590 mutex_lock(&ar->conf_mutex);
592 spin_lock_bh(&ar->data_lock);
594 len += scnprintf(buf + len, buf_len - len,
595 "\n\t\tDriver Rx pkt stats per tid, ([tid] count)\n");
596 len += scnprintf(buf + len, buf_len - len,
597 "\t\t------------------------------------------\n");
598 len += scnprintf(buf + len, buf_len - len, "MSDUs from FW\t\t\t");
599 PRINT_TID_STATS(rx_pkt_from_fw, "\t\t\t\t");
601 len += scnprintf(buf + len, buf_len - len, "MSDUs unchained\t\t\t");
602 PRINT_TID_STATS(rx_pkt_unchained, "\t\t\t\t");
604 len += scnprintf(buf + len, buf_len - len,
605 "MSDUs locally dropped:chained\t");
606 PRINT_TID_STATS(rx_pkt_drop_chained, "\t\t\t\t");
608 len += scnprintf(buf + len, buf_len - len,
609 "MSDUs locally dropped:filtered\t");
610 PRINT_TID_STATS(rx_pkt_drop_filter, "\t\t\t\t");
612 len += scnprintf(buf + len, buf_len - len,
613 "MSDUs queued for mac80211\t");
614 PRINT_TID_STATS(rx_pkt_queued_for_mac, "\t\t\t\t");
616 for (i = 0; i < ATH10K_PKT_RX_ERR_MAX; i++) {
617 len += scnprintf(buf + len, buf_len - len,
618 "MSDUs with error:%s\t", get_err_str(i));
619 PRINT_TID_STATS(rx_pkt_err[i], "\t\t\t\t");
622 len += scnprintf(buf + len, buf_len - len, "\n");
623 for (i = 0; i < ATH10K_AMPDU_SUBFRM_NUM_MAX; i++) {
624 len += scnprintf(buf + len, buf_len - len,
625 "A-MPDU num subframes %s\t",
626 get_num_ampdu_subfrm_str(i));
627 PRINT_TID_STATS(rx_pkt_ampdu[i], "\t\t\t\t");
630 len += scnprintf(buf + len, buf_len - len, "\n");
631 for (i = 0; i < ATH10K_AMSDU_SUBFRM_NUM_MAX; i++) {
632 len += scnprintf(buf + len, buf_len - len,
633 "A-MSDU num subframes %s\t\t",
634 get_num_amsdu_subfrm_str(i));
635 PRINT_TID_STATS(rx_pkt_amsdu[i], "\t\t\t\t");
638 spin_unlock_bh(&ar->data_lock);
640 ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
644 mutex_unlock(&ar->conf_mutex);
649 static const struct file_operations fops_tid_stats_dump = {
651 .read = ath10k_dbg_sta_read_tid_stats,
652 .owner = THIS_MODULE,
653 .llseek = default_llseek,
656 static ssize_t ath10k_dbg_sta_dump_tx_stats(struct file *file,
657 char __user *user_buf,
658 size_t count, loff_t *ppos)
660 struct ieee80211_sta *sta = file->private_data;
661 struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
662 struct ath10k *ar = arsta->arvif->ar;
663 struct ath10k_htt_data_stats *stats;
664 const char *str_name[ATH10K_STATS_TYPE_MAX] = {"succ", "fail",
666 const char *str[ATH10K_COUNTER_TYPE_MAX] = {"bytes", "packets"};
667 int len = 0, i, j, k, retval = 0;
668 const int size = 16 * 4096;
671 buf = kzalloc(size, GFP_KERNEL);
675 mutex_lock(&ar->conf_mutex);
677 spin_lock_bh(&ar->data_lock);
678 for (k = 0; k < ATH10K_STATS_TYPE_MAX; k++) {
679 for (j = 0; j < ATH10K_COUNTER_TYPE_MAX; j++) {
680 stats = &arsta->tx_stats->stats[k];
681 len += scnprintf(buf + len, size - len, "%s_%s\n",
684 len += scnprintf(buf + len, size - len,
687 for (i = 0; i < ATH10K_VHT_MCS_NUM; i++)
688 len += scnprintf(buf + len, size - len,
691 len += scnprintf(buf + len, size - len, "\n");
692 len += scnprintf(buf + len, size - len, " HT MCS %s\n",
694 for (i = 0; i < ATH10K_HT_MCS_NUM; i++)
695 len += scnprintf(buf + len, size - len,
696 " %llu ", stats->ht[j][i]);
697 len += scnprintf(buf + len, size - len, "\n");
698 len += scnprintf(buf + len, size - len,
699 " BW %s (20,40,80,160 MHz)\n", str[j]);
700 len += scnprintf(buf + len, size - len,
701 " %llu %llu %llu %llu\n",
702 stats->bw[j][0], stats->bw[j][1],
703 stats->bw[j][2], stats->bw[j][3]);
704 len += scnprintf(buf + len, size - len,
705 " NSS %s (1x1,2x2,3x3,4x4)\n", str[j]);
706 len += scnprintf(buf + len, size - len,
707 " %llu %llu %llu %llu\n",
708 stats->nss[j][0], stats->nss[j][1],
709 stats->nss[j][2], stats->nss[j][3]);
710 len += scnprintf(buf + len, size - len,
711 " GI %s (LGI,SGI)\n",
713 len += scnprintf(buf + len, size - len, " %llu %llu\n",
714 stats->gi[j][0], stats->gi[j][1]);
715 len += scnprintf(buf + len, size - len,
716 " legacy rate %s (1,2 ... Mbps)\n ",
718 for (i = 0; i < ATH10K_LEGACY_NUM; i++)
719 len += scnprintf(buf + len, size - len, "%llu ",
720 stats->legacy[j][i]);
721 len += scnprintf(buf + len, size - len, "\n");
722 len += scnprintf(buf + len, size - len,
723 " Rate table %s (1,2 ... Mbps)\n ",
725 for (i = 0; i < ATH10K_RATE_TABLE_NUM; i++) {
726 len += scnprintf(buf + len, size - len, "%llu ",
727 stats->rate_table[j][i]);
730 scnprintf(buf + len, size - len, "\n ");
735 len += scnprintf(buf + len, size - len,
736 "\nTX duration\n %llu usecs\n",
737 arsta->tx_stats->tx_duration);
738 len += scnprintf(buf + len, size - len,
739 "BA fails\n %llu\n", arsta->tx_stats->ba_fails);
740 len += scnprintf(buf + len, size - len,
741 "ack fails\n %llu\n", arsta->tx_stats->ack_fails);
742 spin_unlock_bh(&ar->data_lock);
746 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
749 mutex_unlock(&ar->conf_mutex);
753 static const struct file_operations fops_tx_stats = {
754 .read = ath10k_dbg_sta_dump_tx_stats,
756 .owner = THIS_MODULE,
757 .llseek = default_llseek,
760 void ath10k_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
761 struct ieee80211_sta *sta, struct dentry *dir)
763 struct ath10k *ar = hw->priv;
765 debugfs_create_file("aggr_mode", 0644, dir, sta, &fops_aggr_mode);
766 debugfs_create_file("addba", 0200, dir, sta, &fops_addba);
767 debugfs_create_file("addba_resp", 0200, dir, sta, &fops_addba_resp);
768 debugfs_create_file("delba", 0200, dir, sta, &fops_delba);
769 debugfs_create_file("peer_debug_trigger", 0600, dir, sta,
770 &fops_peer_debug_trigger);
771 debugfs_create_file("dump_tid_stats", 0400, dir, sta,
772 &fops_tid_stats_dump);
774 if (ath10k_peer_stats_enabled(ar) &&
775 ath10k_debug_is_extd_tx_stats_enabled(ar))
776 debugfs_create_file("tx_stats", 0400, dir, sta,
778 debugfs_create_file("peer_ps_state", 0400, dir, sta,
779 &fops_peer_ps_state);