1 // SPDX-License-Identifier: ISC
3 * Copyright (c) 2014-2017 Qualcomm Atheros, Inc.
4 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
5 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
13 static void ath10k_rx_stats_update_amsdu_subfrm(struct ath10k
*ar
,
14 struct ath10k_sta_tid_stats
*stats
,
18 stats
->rx_pkt_amsdu
[ATH10K_AMSDU_SUBFRM_NUM_1
]++;
19 else if (msdu_count
== 2)
20 stats
->rx_pkt_amsdu
[ATH10K_AMSDU_SUBFRM_NUM_2
]++;
21 else if (msdu_count
== 3)
22 stats
->rx_pkt_amsdu
[ATH10K_AMSDU_SUBFRM_NUM_3
]++;
23 else if (msdu_count
== 4)
24 stats
->rx_pkt_amsdu
[ATH10K_AMSDU_SUBFRM_NUM_4
]++;
25 else if (msdu_count
> 4)
26 stats
->rx_pkt_amsdu
[ATH10K_AMSDU_SUBFRM_NUM_MORE
]++;
29 static void ath10k_rx_stats_update_ampdu_subfrm(struct ath10k
*ar
,
30 struct ath10k_sta_tid_stats
*stats
,
34 stats
->rx_pkt_ampdu
[ATH10K_AMPDU_SUBFRM_NUM_10
]++;
35 else if (mpdu_count
<= 20)
36 stats
->rx_pkt_ampdu
[ATH10K_AMPDU_SUBFRM_NUM_20
]++;
37 else if (mpdu_count
<= 30)
38 stats
->rx_pkt_ampdu
[ATH10K_AMPDU_SUBFRM_NUM_30
]++;
39 else if (mpdu_count
<= 40)
40 stats
->rx_pkt_ampdu
[ATH10K_AMPDU_SUBFRM_NUM_40
]++;
41 else if (mpdu_count
<= 50)
42 stats
->rx_pkt_ampdu
[ATH10K_AMPDU_SUBFRM_NUM_50
]++;
43 else if (mpdu_count
<= 60)
44 stats
->rx_pkt_ampdu
[ATH10K_AMPDU_SUBFRM_NUM_60
]++;
45 else if (mpdu_count
> 60)
46 stats
->rx_pkt_ampdu
[ATH10K_AMPDU_SUBFRM_NUM_MORE
]++;
49 void ath10k_sta_update_rx_tid_stats_ampdu(struct ath10k
*ar
, u16 peer_id
, u8 tid
,
50 struct htt_rx_indication_mpdu_range
*ranges
,
53 struct ath10k_sta
*arsta
;
54 struct ath10k_peer
*peer
;
57 if (tid
> IEEE80211_NUM_TIDS
|| !(ar
->sta_tid_stats_mask
& BIT(tid
)))
61 spin_lock_bh(&ar
->data_lock
);
63 peer
= ath10k_peer_find_by_id(ar
, peer_id
);
64 if (!peer
|| !peer
->sta
)
67 arsta
= (struct ath10k_sta
*)peer
->sta
->drv_priv
;
69 for (i
= 0; i
< num_ranges
; i
++)
70 ath10k_rx_stats_update_ampdu_subfrm(ar
,
71 &arsta
->tid_stats
[tid
],
72 ranges
[i
].mpdu_count
);
75 spin_unlock_bh(&ar
->data_lock
);
79 void ath10k_sta_update_rx_tid_stats(struct ath10k
*ar
, u8
*first_hdr
,
80 unsigned long num_msdus
,
81 enum ath10k_pkt_rx_err err
,
82 unsigned long unchain_cnt
,
83 unsigned long drop_cnt
,
84 unsigned long drop_cnt_filter
,
85 unsigned long queued_msdus
)
87 struct ieee80211_sta
*sta
;
88 struct ath10k_sta
*arsta
;
89 struct ieee80211_hdr
*hdr
;
90 struct ath10k_sta_tid_stats
*stats
;
91 u8 tid
= IEEE80211_NUM_TIDS
;
92 bool non_data_frm
= false;
94 hdr
= (struct ieee80211_hdr
*)first_hdr
;
95 if (!ieee80211_is_data(hdr
->frame_control
))
98 if (ieee80211_is_data_qos(hdr
->frame_control
))
99 tid
= *ieee80211_get_qos_ctl(hdr
) & IEEE80211_QOS_CTL_TID_MASK
;
101 if (!(ar
->sta_tid_stats_mask
& BIT(tid
)) || non_data_frm
)
106 sta
= ieee80211_find_sta_by_ifaddr(ar
->hw
, hdr
->addr2
, NULL
);
110 arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
112 spin_lock_bh(&ar
->data_lock
);
113 stats
= &arsta
->tid_stats
[tid
];
114 stats
->rx_pkt_from_fw
+= num_msdus
;
115 stats
->rx_pkt_unchained
+= unchain_cnt
;
116 stats
->rx_pkt_drop_chained
+= drop_cnt
;
117 stats
->rx_pkt_drop_filter
+= drop_cnt_filter
;
118 if (err
!= ATH10K_PKT_RX_ERR_MAX
)
119 stats
->rx_pkt_err
[err
] += queued_msdus
;
120 stats
->rx_pkt_queued_for_mac
+= queued_msdus
;
121 ath10k_rx_stats_update_amsdu_subfrm(ar
, &arsta
->tid_stats
[tid
],
123 spin_unlock_bh(&ar
->data_lock
);
129 static void ath10k_sta_update_extd_stats_rx_duration(struct ath10k
*ar
,
130 struct ath10k_fw_stats
*stats
)
132 struct ath10k_fw_extd_stats_peer
*peer
;
133 struct ieee80211_sta
*sta
;
134 struct ath10k_sta
*arsta
;
137 list_for_each_entry(peer
, &stats
->peers_extd
, list
) {
138 sta
= ieee80211_find_sta_by_ifaddr(ar
->hw
, peer
->peer_macaddr
,
142 arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
143 arsta
->rx_duration
+= (u64
)peer
->rx_duration
;
148 static void ath10k_sta_update_stats_rx_duration(struct ath10k
*ar
,
149 struct ath10k_fw_stats
*stats
)
151 struct ath10k_fw_stats_peer
*peer
;
152 struct ieee80211_sta
*sta
;
153 struct ath10k_sta
*arsta
;
156 list_for_each_entry(peer
, &stats
->peers
, list
) {
157 sta
= ieee80211_find_sta_by_ifaddr(ar
->hw
, peer
->peer_macaddr
,
161 arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
162 arsta
->rx_duration
+= (u64
)peer
->rx_duration
;
167 void ath10k_sta_update_rx_duration(struct ath10k
*ar
,
168 struct ath10k_fw_stats
*stats
)
171 ath10k_sta_update_extd_stats_rx_duration(ar
, stats
);
173 ath10k_sta_update_stats_rx_duration(ar
, stats
);
176 static ssize_t
ath10k_dbg_sta_read_aggr_mode(struct file
*file
,
177 char __user
*user_buf
,
178 size_t count
, loff_t
*ppos
)
180 struct ieee80211_sta
*sta
= file
->private_data
;
181 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
182 struct ath10k
*ar
= arsta
->arvif
->ar
;
186 mutex_lock(&ar
->conf_mutex
);
187 len
= scnprintf(buf
, sizeof(buf
) - len
, "aggregation mode: %s\n",
188 (arsta
->aggr_mode
== ATH10K_DBG_AGGR_MODE_AUTO
) ?
190 mutex_unlock(&ar
->conf_mutex
);
192 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
195 static ssize_t
ath10k_dbg_sta_write_aggr_mode(struct file
*file
,
196 const char __user
*user_buf
,
197 size_t count
, loff_t
*ppos
)
199 struct ieee80211_sta
*sta
= file
->private_data
;
200 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
201 struct ath10k
*ar
= arsta
->arvif
->ar
;
205 if (kstrtouint_from_user(user_buf
, count
, 0, &aggr_mode
))
208 if (aggr_mode
>= ATH10K_DBG_AGGR_MODE_MAX
)
211 mutex_lock(&ar
->conf_mutex
);
212 if ((ar
->state
!= ATH10K_STATE_ON
) ||
213 (aggr_mode
== arsta
->aggr_mode
)) {
218 ret
= ath10k_wmi_addba_clear_resp(ar
, arsta
->arvif
->vdev_id
, sta
->addr
);
220 ath10k_warn(ar
, "failed to clear addba session ret: %d\n", ret
);
224 arsta
->aggr_mode
= aggr_mode
;
226 mutex_unlock(&ar
->conf_mutex
);
230 static const struct file_operations fops_aggr_mode
= {
231 .read
= ath10k_dbg_sta_read_aggr_mode
,
232 .write
= ath10k_dbg_sta_write_aggr_mode
,
234 .owner
= THIS_MODULE
,
235 .llseek
= default_llseek
,
238 static ssize_t
ath10k_dbg_sta_write_addba(struct file
*file
,
239 const char __user
*user_buf
,
240 size_t count
, loff_t
*ppos
)
242 struct ieee80211_sta
*sta
= file
->private_data
;
243 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
244 struct ath10k
*ar
= arsta
->arvif
->ar
;
249 ret
= simple_write_to_buffer(buf
, sizeof(buf
) - 1, ppos
,
254 ret
= sscanf(buf
, "%u %u", &tid
, &buf_size
);
258 /* Valid TID values are 0 through 15 */
259 if (tid
> HTT_DATA_TX_EXT_TID_MGMT
- 2)
262 mutex_lock(&ar
->conf_mutex
);
263 if ((ar
->state
!= ATH10K_STATE_ON
) ||
264 (arsta
->aggr_mode
!= ATH10K_DBG_AGGR_MODE_MANUAL
)) {
269 ret
= ath10k_wmi_addba_send(ar
, arsta
->arvif
->vdev_id
, sta
->addr
,
272 ath10k_warn(ar
, "failed to send addba request: vdev_id %u peer %pM tid %u buf_size %u\n",
273 arsta
->arvif
->vdev_id
, sta
->addr
, tid
, buf_size
);
278 mutex_unlock(&ar
->conf_mutex
);
282 static const struct file_operations fops_addba
= {
283 .write
= ath10k_dbg_sta_write_addba
,
285 .owner
= THIS_MODULE
,
286 .llseek
= default_llseek
,
289 static ssize_t
ath10k_dbg_sta_write_addba_resp(struct file
*file
,
290 const char __user
*user_buf
,
291 size_t count
, loff_t
*ppos
)
293 struct ieee80211_sta
*sta
= file
->private_data
;
294 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
295 struct ath10k
*ar
= arsta
->arvif
->ar
;
300 ret
= simple_write_to_buffer(buf
, sizeof(buf
) - 1, ppos
,
305 ret
= sscanf(buf
, "%u %u", &tid
, &status
);
309 /* Valid TID values are 0 through 15 */
310 if (tid
> HTT_DATA_TX_EXT_TID_MGMT
- 2)
313 mutex_lock(&ar
->conf_mutex
);
314 if ((ar
->state
!= ATH10K_STATE_ON
) ||
315 (arsta
->aggr_mode
!= ATH10K_DBG_AGGR_MODE_MANUAL
)) {
320 ret
= ath10k_wmi_addba_set_resp(ar
, arsta
->arvif
->vdev_id
, sta
->addr
,
323 ath10k_warn(ar
, "failed to send addba response: vdev_id %u peer %pM tid %u status%u\n",
324 arsta
->arvif
->vdev_id
, sta
->addr
, tid
, status
);
328 mutex_unlock(&ar
->conf_mutex
);
332 static const struct file_operations fops_addba_resp
= {
333 .write
= ath10k_dbg_sta_write_addba_resp
,
335 .owner
= THIS_MODULE
,
336 .llseek
= default_llseek
,
339 static ssize_t
ath10k_dbg_sta_write_delba(struct file
*file
,
340 const char __user
*user_buf
,
341 size_t count
, loff_t
*ppos
)
343 struct ieee80211_sta
*sta
= file
->private_data
;
344 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
345 struct ath10k
*ar
= arsta
->arvif
->ar
;
346 u32 tid
, initiator
, reason
;
350 ret
= simple_write_to_buffer(buf
, sizeof(buf
) - 1, ppos
,
355 ret
= sscanf(buf
, "%u %u %u", &tid
, &initiator
, &reason
);
359 /* Valid TID values are 0 through 15 */
360 if (tid
> HTT_DATA_TX_EXT_TID_MGMT
- 2)
363 mutex_lock(&ar
->conf_mutex
);
364 if ((ar
->state
!= ATH10K_STATE_ON
) ||
365 (arsta
->aggr_mode
!= ATH10K_DBG_AGGR_MODE_MANUAL
)) {
370 ret
= ath10k_wmi_delba_send(ar
, arsta
->arvif
->vdev_id
, sta
->addr
,
371 tid
, initiator
, reason
);
373 ath10k_warn(ar
, "failed to send delba: vdev_id %u peer %pM tid %u initiator %u reason %u\n",
374 arsta
->arvif
->vdev_id
, sta
->addr
, tid
, initiator
,
379 mutex_unlock(&ar
->conf_mutex
);
383 static const struct file_operations fops_delba
= {
384 .write
= ath10k_dbg_sta_write_delba
,
386 .owner
= THIS_MODULE
,
387 .llseek
= default_llseek
,
390 static ssize_t
ath10k_dbg_sta_read_peer_debug_trigger(struct file
*file
,
391 char __user
*user_buf
,
395 struct ieee80211_sta
*sta
= file
->private_data
;
396 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
397 struct ath10k
*ar
= arsta
->arvif
->ar
;
401 mutex_lock(&ar
->conf_mutex
);
402 len
= scnprintf(buf
, sizeof(buf
) - len
,
403 "Write 1 to once trigger the debug logs\n");
404 mutex_unlock(&ar
->conf_mutex
);
406 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
410 ath10k_dbg_sta_write_peer_debug_trigger(struct file
*file
,
411 const char __user
*user_buf
,
412 size_t count
, loff_t
*ppos
)
414 struct ieee80211_sta
*sta
= file
->private_data
;
415 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
416 struct ath10k
*ar
= arsta
->arvif
->ar
;
417 u8 peer_debug_trigger
;
420 if (kstrtou8_from_user(user_buf
, count
, 0, &peer_debug_trigger
))
423 if (peer_debug_trigger
!= 1)
426 mutex_lock(&ar
->conf_mutex
);
428 if (ar
->state
!= ATH10K_STATE_ON
) {
433 ret
= ath10k_wmi_peer_set_param(ar
, arsta
->arvif
->vdev_id
, sta
->addr
,
434 ar
->wmi
.peer_param
->debug
, peer_debug_trigger
);
436 ath10k_warn(ar
, "failed to set param to trigger peer tid logs for station ret: %d\n",
441 mutex_unlock(&ar
->conf_mutex
);
445 static const struct file_operations fops_peer_debug_trigger
= {
447 .read
= ath10k_dbg_sta_read_peer_debug_trigger
,
448 .write
= ath10k_dbg_sta_write_peer_debug_trigger
,
449 .owner
= THIS_MODULE
,
450 .llseek
= default_llseek
,
453 static ssize_t
ath10k_dbg_sta_read_peer_ps_state(struct file
*file
,
454 char __user
*user_buf
,
455 size_t count
, loff_t
*ppos
)
457 struct ieee80211_sta
*sta
= file
->private_data
;
458 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
459 struct ath10k
*ar
= arsta
->arvif
->ar
;
463 spin_lock_bh(&ar
->data_lock
);
465 len
= scnprintf(buf
, sizeof(buf
) - len
, "%d\n",
466 arsta
->peer_ps_state
);
468 spin_unlock_bh(&ar
->data_lock
);
470 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
473 static const struct file_operations fops_peer_ps_state
= {
475 .read
= ath10k_dbg_sta_read_peer_ps_state
,
476 .owner
= THIS_MODULE
,
477 .llseek
= default_llseek
,
480 static char *get_err_str(enum ath10k_pkt_rx_err i
)
483 case ATH10K_PKT_RX_ERR_FCS
:
485 case ATH10K_PKT_RX_ERR_TKIP
:
487 case ATH10K_PKT_RX_ERR_CRYPT
:
489 case ATH10K_PKT_RX_ERR_PEER_IDX_INVAL
:
490 return "peer_idx_inval";
491 case ATH10K_PKT_RX_ERR_MAX
:
498 static char *get_num_ampdu_subfrm_str(enum ath10k_ampdu_subfrm_num i
)
501 case ATH10K_AMPDU_SUBFRM_NUM_10
:
503 case ATH10K_AMPDU_SUBFRM_NUM_20
:
505 case ATH10K_AMPDU_SUBFRM_NUM_30
:
507 case ATH10K_AMPDU_SUBFRM_NUM_40
:
509 case ATH10K_AMPDU_SUBFRM_NUM_50
:
511 case ATH10K_AMPDU_SUBFRM_NUM_60
:
513 case ATH10K_AMPDU_SUBFRM_NUM_MORE
:
515 case ATH10K_AMPDU_SUBFRM_NUM_MAX
:
522 static char *get_num_amsdu_subfrm_str(enum ath10k_amsdu_subfrm_num i
)
525 case ATH10K_AMSDU_SUBFRM_NUM_1
:
527 case ATH10K_AMSDU_SUBFRM_NUM_2
:
529 case ATH10K_AMSDU_SUBFRM_NUM_3
:
531 case ATH10K_AMSDU_SUBFRM_NUM_4
:
533 case ATH10K_AMSDU_SUBFRM_NUM_MORE
:
535 case ATH10K_AMSDU_SUBFRM_NUM_MAX
:
542 #define PRINT_TID_STATS(_field, _tabs) \
545 for (j = 0; j <= IEEE80211_NUM_TIDS; j++) { \
546 if (ar->sta_tid_stats_mask & BIT(j)) { \
547 len += scnprintf(buf + len, buf_len - len, \
549 j, stats[j]._field); \
552 len += scnprintf(buf + len, \
553 buf_len - len, "\n"); \
554 len += scnprintf(buf + len, \
560 len += scnprintf(buf + len, buf_len - len, "\n"); \
563 static ssize_t
ath10k_dbg_sta_read_tid_stats(struct file
*file
,
564 char __user
*user_buf
,
565 size_t count
, loff_t
*ppos
)
567 struct ieee80211_sta
*sta
= file
->private_data
;
568 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
569 struct ath10k
*ar
= arsta
->arvif
->ar
;
570 struct ath10k_sta_tid_stats
*stats
= arsta
->tid_stats
;
571 size_t len
= 0, buf_len
= 1048 * IEEE80211_NUM_TIDS
;
576 buf
= kzalloc(buf_len
, GFP_KERNEL
);
580 mutex_lock(&ar
->conf_mutex
);
582 spin_lock_bh(&ar
->data_lock
);
584 len
+= scnprintf(buf
+ len
, buf_len
- len
,
585 "\n\t\tDriver Rx pkt stats per tid, ([tid] count)\n");
586 len
+= scnprintf(buf
+ len
, buf_len
- len
,
587 "\t\t------------------------------------------\n");
588 len
+= scnprintf(buf
+ len
, buf_len
- len
, "MSDUs from FW\t\t\t");
589 PRINT_TID_STATS(rx_pkt_from_fw
, "\t\t\t\t");
591 len
+= scnprintf(buf
+ len
, buf_len
- len
, "MSDUs unchained\t\t\t");
592 PRINT_TID_STATS(rx_pkt_unchained
, "\t\t\t\t");
594 len
+= scnprintf(buf
+ len
, buf_len
- len
,
595 "MSDUs locally dropped:chained\t");
596 PRINT_TID_STATS(rx_pkt_drop_chained
, "\t\t\t\t");
598 len
+= scnprintf(buf
+ len
, buf_len
- len
,
599 "MSDUs locally dropped:filtered\t");
600 PRINT_TID_STATS(rx_pkt_drop_filter
, "\t\t\t\t");
602 len
+= scnprintf(buf
+ len
, buf_len
- len
,
603 "MSDUs queued for mac80211\t");
604 PRINT_TID_STATS(rx_pkt_queued_for_mac
, "\t\t\t\t");
606 for (i
= 0; i
< ATH10K_PKT_RX_ERR_MAX
; i
++) {
607 len
+= scnprintf(buf
+ len
, buf_len
- len
,
608 "MSDUs with error:%s\t", get_err_str(i
));
609 PRINT_TID_STATS(rx_pkt_err
[i
], "\t\t\t\t");
612 len
+= scnprintf(buf
+ len
, buf_len
- len
, "\n");
613 for (i
= 0; i
< ATH10K_AMPDU_SUBFRM_NUM_MAX
; i
++) {
614 len
+= scnprintf(buf
+ len
, buf_len
- len
,
615 "A-MPDU num subframes %s\t",
616 get_num_ampdu_subfrm_str(i
));
617 PRINT_TID_STATS(rx_pkt_ampdu
[i
], "\t\t\t\t");
620 len
+= scnprintf(buf
+ len
, buf_len
- len
, "\n");
621 for (i
= 0; i
< ATH10K_AMSDU_SUBFRM_NUM_MAX
; i
++) {
622 len
+= scnprintf(buf
+ len
, buf_len
- len
,
623 "A-MSDU num subframes %s\t\t",
624 get_num_amsdu_subfrm_str(i
));
625 PRINT_TID_STATS(rx_pkt_amsdu
[i
], "\t\t\t\t");
628 spin_unlock_bh(&ar
->data_lock
);
630 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
634 mutex_unlock(&ar
->conf_mutex
);
639 static const struct file_operations fops_tid_stats_dump
= {
641 .read
= ath10k_dbg_sta_read_tid_stats
,
642 .owner
= THIS_MODULE
,
643 .llseek
= default_llseek
,
646 static ssize_t
ath10k_dbg_sta_dump_tx_stats(struct file
*file
,
647 char __user
*user_buf
,
648 size_t count
, loff_t
*ppos
)
650 struct ieee80211_sta
*sta
= file
->private_data
;
651 struct ath10k_sta
*arsta
= (struct ath10k_sta
*)sta
->drv_priv
;
652 struct ath10k
*ar
= arsta
->arvif
->ar
;
653 struct ath10k_htt_data_stats
*stats
;
654 const char *str_name
[ATH10K_STATS_TYPE_MAX
] = {"succ", "fail",
656 const char *str
[ATH10K_COUNTER_TYPE_MAX
] = {"bytes", "packets"};
657 int len
= 0, i
, j
, k
, retval
= 0;
658 const int size
= 16 * 4096;
661 buf
= kzalloc(size
, GFP_KERNEL
);
665 mutex_lock(&ar
->conf_mutex
);
667 if (!arsta
->tx_stats
) {
668 ath10k_warn(ar
, "failed to get tx stats");
669 mutex_unlock(&ar
->conf_mutex
);
674 spin_lock_bh(&ar
->data_lock
);
675 for (k
= 0; k
< ATH10K_STATS_TYPE_MAX
; k
++) {
676 for (j
= 0; j
< ATH10K_COUNTER_TYPE_MAX
; j
++) {
677 stats
= &arsta
->tx_stats
->stats
[k
];
678 len
+= scnprintf(buf
+ len
, size
- len
, "%s_%s\n",
681 len
+= scnprintf(buf
+ len
, size
- len
,
684 for (i
= 0; i
< ATH10K_VHT_MCS_NUM
; i
++)
685 len
+= scnprintf(buf
+ len
, size
- len
,
688 len
+= scnprintf(buf
+ len
, size
- len
, "\n");
689 len
+= scnprintf(buf
+ len
, size
- len
, " HT MCS %s\n",
691 for (i
= 0; i
< ATH10K_HT_MCS_NUM
; i
++)
692 len
+= scnprintf(buf
+ len
, size
- len
,
693 " %llu ", stats
->ht
[j
][i
]);
694 len
+= scnprintf(buf
+ len
, size
- len
, "\n");
695 len
+= scnprintf(buf
+ len
, size
- len
,
696 " BW %s (20,5,10,40,80,160 MHz)\n", str
[j
]);
697 len
+= scnprintf(buf
+ len
, size
- len
,
698 " %llu %llu %llu %llu %llu %llu\n",
699 stats
->bw
[j
][0], stats
->bw
[j
][1],
700 stats
->bw
[j
][2], stats
->bw
[j
][3],
701 stats
->bw
[j
][4], stats
->bw
[j
][5]);
702 len
+= scnprintf(buf
+ len
, size
- len
,
703 " NSS %s (1x1,2x2,3x3,4x4)\n", str
[j
]);
704 len
+= scnprintf(buf
+ len
, size
- len
,
705 " %llu %llu %llu %llu\n",
706 stats
->nss
[j
][0], stats
->nss
[j
][1],
707 stats
->nss
[j
][2], stats
->nss
[j
][3]);
708 len
+= scnprintf(buf
+ len
, size
- len
,
709 " GI %s (LGI,SGI)\n",
711 len
+= scnprintf(buf
+ len
, size
- len
, " %llu %llu\n",
712 stats
->gi
[j
][0], stats
->gi
[j
][1]);
713 len
+= scnprintf(buf
+ len
, size
- len
,
714 " legacy rate %s (1,2 ... Mbps)\n ",
716 for (i
= 0; i
< ATH10K_LEGACY_NUM
; i
++)
717 len
+= scnprintf(buf
+ len
, size
- len
, "%llu ",
718 stats
->legacy
[j
][i
]);
719 len
+= scnprintf(buf
+ len
, size
- len
, "\n");
720 len
+= scnprintf(buf
+ len
, size
- len
,
721 " Rate table %s (1,2 ... Mbps)\n ",
723 for (i
= 0; i
< ATH10K_RATE_TABLE_NUM
; i
++) {
724 len
+= scnprintf(buf
+ len
, size
- len
, "%llu ",
725 stats
->rate_table
[j
][i
]);
728 scnprintf(buf
+ len
, size
- len
, "\n ");
733 len
+= scnprintf(buf
+ len
, size
- len
,
734 "\nTX duration\n %llu usecs\n",
735 arsta
->tx_stats
->tx_duration
);
736 len
+= scnprintf(buf
+ len
, size
- len
,
737 "BA fails\n %llu\n", arsta
->tx_stats
->ba_fails
);
738 len
+= scnprintf(buf
+ len
, size
- len
,
739 "ack fails\n %llu\n", arsta
->tx_stats
->ack_fails
);
740 spin_unlock_bh(&ar
->data_lock
);
744 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
747 mutex_unlock(&ar
->conf_mutex
);
751 static const struct file_operations fops_tx_stats
= {
752 .read
= ath10k_dbg_sta_dump_tx_stats
,
754 .owner
= THIS_MODULE
,
755 .llseek
= default_llseek
,
758 void ath10k_sta_add_debugfs(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
759 struct ieee80211_sta
*sta
, struct dentry
*dir
)
761 struct ath10k
*ar
= hw
->priv
;
763 debugfs_create_file("aggr_mode", 0644, dir
, sta
, &fops_aggr_mode
);
764 debugfs_create_file("addba", 0200, dir
, sta
, &fops_addba
);
765 debugfs_create_file("addba_resp", 0200, dir
, sta
, &fops_addba_resp
);
766 debugfs_create_file("delba", 0200, dir
, sta
, &fops_delba
);
767 debugfs_create_file("peer_debug_trigger", 0600, dir
, sta
,
768 &fops_peer_debug_trigger
);
769 debugfs_create_file("dump_tid_stats", 0400, dir
, sta
,
770 &fops_tid_stats_dump
);
772 if (ath10k_peer_stats_enabled(ar
) &&
773 ath10k_debug_is_extd_tx_stats_enabled(ar
))
774 debugfs_create_file("tx_stats", 0400, dir
, sta
,
776 debugfs_create_file("peer_ps_state", 0400, dir
, sta
,
777 &fops_peer_ps_state
);