1 // SPDX-License-Identifier: BSD-3-Clause-Clear
3 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
6 #include <linux/vmalloc.h>
12 #include "debug_htt_stats.h"
15 void ath11k_info(struct ath11k_base *ab, const char *fmt, ...)
17 struct va_format vaf = {
24 dev_info(ab->dev, "%pV", &vaf);
25 /* TODO: Trace the log */
29 void ath11k_err(struct ath11k_base *ab, const char *fmt, ...)
31 struct va_format vaf = {
38 dev_err(ab->dev, "%pV", &vaf);
39 /* TODO: Trace the log */
43 void ath11k_warn(struct ath11k_base *ab, const char *fmt, ...)
45 struct va_format vaf = {
52 dev_warn_ratelimited(ab->dev, "%pV", &vaf);
53 /* TODO: Trace the log */
57 #ifdef CONFIG_ATH11K_DEBUG
58 void __ath11k_dbg(struct ath11k_base *ab, enum ath11k_debug_mask mask,
69 if (ath11k_debug_mask & mask)
70 dev_printk(KERN_DEBUG, ab->dev, "%pV", &vaf);
77 void ath11k_dbg_dump(struct ath11k_base *ab,
78 enum ath11k_debug_mask mask,
79 const char *msg, const char *prefix,
80 const void *buf, size_t len)
86 if (ath11k_debug_mask & mask) {
88 __ath11k_dbg(ab, mask, "%s\n", msg);
90 for (ptr = buf; (ptr - buf) < len; ptr += 16) {
92 linebuflen += scnprintf(linebuf + linebuflen,
93 sizeof(linebuf) - linebuflen,
95 (prefix ? prefix : ""),
96 (unsigned int)(ptr - buf));
97 hex_dump_to_buffer(ptr, len - (ptr - buf), 16, 1,
99 sizeof(linebuf) - linebuflen, true);
100 dev_printk(KERN_DEBUG, ab->dev, "%s\n", linebuf);
107 #ifdef CONFIG_ATH11K_DEBUGFS
108 static void ath11k_fw_stats_pdevs_free(struct list_head *head)
110 struct ath11k_fw_stats_pdev *i, *tmp;
112 list_for_each_entry_safe(i, tmp, head, list) {
118 static void ath11k_fw_stats_vdevs_free(struct list_head *head)
120 struct ath11k_fw_stats_vdev *i, *tmp;
122 list_for_each_entry_safe(i, tmp, head, list) {
128 static void ath11k_fw_stats_bcn_free(struct list_head *head)
130 struct ath11k_fw_stats_bcn *i, *tmp;
132 list_for_each_entry_safe(i, tmp, head, list) {
138 static void ath11k_debug_fw_stats_reset(struct ath11k *ar)
140 spin_lock_bh(&ar->data_lock);
141 ar->debug.fw_stats_done = false;
142 ath11k_fw_stats_pdevs_free(&ar->debug.fw_stats.pdevs);
143 ath11k_fw_stats_vdevs_free(&ar->debug.fw_stats.vdevs);
144 spin_unlock_bh(&ar->data_lock);
147 void ath11k_debug_fw_stats_process(struct ath11k_base *ab, struct sk_buff *skb)
149 struct ath11k_fw_stats stats = {};
151 struct ath11k_pdev *pdev;
153 static unsigned int num_vdev, num_bcn;
154 size_t total_vdevs_started = 0;
157 INIT_LIST_HEAD(&stats.pdevs);
158 INIT_LIST_HEAD(&stats.vdevs);
159 INIT_LIST_HEAD(&stats.bcn);
161 ret = ath11k_wmi_pull_fw_stats(ab, skb, &stats);
163 ath11k_warn(ab, "failed to pull fw stats: %d\n", ret);
168 ar = ath11k_mac_get_ar_by_pdev_id(ab, stats.pdev_id);
171 ath11k_warn(ab, "failed to get ar for pdev_id %d: %d\n",
176 spin_lock_bh(&ar->data_lock);
178 if (stats.stats_id == WMI_REQUEST_PDEV_STAT) {
179 list_splice_tail_init(&stats.pdevs, &ar->debug.fw_stats.pdevs);
180 ar->debug.fw_stats_done = true;
184 if (stats.stats_id == WMI_REQUEST_VDEV_STAT) {
185 if (list_empty(&stats.vdevs)) {
186 ath11k_warn(ab, "empty vdev stats");
189 /* FW sends all the active VDEV stats irrespective of PDEV,
190 * hence limit until the count of all VDEVs started
192 for (i = 0; i < ab->num_radios; i++) {
193 pdev = rcu_dereference(ab->pdevs_active[i]);
194 if (pdev && pdev->ar)
195 total_vdevs_started += ar->num_started_vdevs;
198 is_end = ((++num_vdev) == total_vdevs_started);
200 list_splice_tail_init(&stats.vdevs,
201 &ar->debug.fw_stats.vdevs);
204 ar->debug.fw_stats_done = true;
210 if (stats.stats_id == WMI_REQUEST_BCN_STAT) {
211 if (list_empty(&stats.bcn)) {
212 ath11k_warn(ab, "empty bcn stats");
215 /* Mark end until we reached the count of all started VDEVs
218 is_end = ((++num_bcn) == ar->num_started_vdevs);
220 list_splice_tail_init(&stats.bcn,
221 &ar->debug.fw_stats.bcn);
224 ar->debug.fw_stats_done = true;
229 complete(&ar->debug.fw_stats_complete);
231 spin_unlock_bh(&ar->data_lock);
234 ath11k_fw_stats_pdevs_free(&stats.pdevs);
235 ath11k_fw_stats_vdevs_free(&stats.vdevs);
236 ath11k_fw_stats_bcn_free(&stats.bcn);
239 static int ath11k_debug_fw_stats_request(struct ath11k *ar,
240 struct stats_request_params *req_param)
242 struct ath11k_base *ab = ar->ab;
243 unsigned long timeout, time_left;
246 lockdep_assert_held(&ar->conf_mutex);
248 /* FW stats can get split when exceeding the stats data buffer limit.
249 * In that case, since there is no end marking for the back-to-back
250 * received 'update stats' event, we keep a 3 seconds timeout in case,
251 * fw_stats_done is not marked yet
253 timeout = jiffies + msecs_to_jiffies(3 * HZ);
255 ath11k_debug_fw_stats_reset(ar);
257 reinit_completion(&ar->debug.fw_stats_complete);
259 ret = ath11k_wmi_send_stats_request_cmd(ar, req_param);
262 ath11k_warn(ab, "could not request fw stats (%d)\n",
268 wait_for_completion_timeout(&ar->debug.fw_stats_complete,
274 if (time_after(jiffies, timeout))
277 spin_lock_bh(&ar->data_lock);
278 if (ar->debug.fw_stats_done) {
279 spin_unlock_bh(&ar->data_lock);
282 spin_unlock_bh(&ar->data_lock);
287 static int ath11k_open_pdev_stats(struct inode *inode, struct file *file)
289 struct ath11k *ar = inode->i_private;
290 struct ath11k_base *ab = ar->ab;
291 struct stats_request_params req_param;
295 mutex_lock(&ar->conf_mutex);
297 if (ar->state != ATH11K_STATE_ON) {
302 buf = vmalloc(ATH11K_FW_STATS_BUF_SIZE);
308 req_param.pdev_id = ar->pdev->pdev_id;
309 req_param.vdev_id = 0;
310 req_param.stats_id = WMI_REQUEST_PDEV_STAT;
312 ret = ath11k_debug_fw_stats_request(ar, &req_param);
314 ath11k_warn(ab, "failed to request fw pdev stats: %d\n", ret);
318 ath11k_wmi_fw_stats_fill(ar, &ar->debug.fw_stats, req_param.stats_id,
321 file->private_data = buf;
323 mutex_unlock(&ar->conf_mutex);
330 mutex_unlock(&ar->conf_mutex);
334 static int ath11k_release_pdev_stats(struct inode *inode, struct file *file)
336 vfree(file->private_data);
341 static ssize_t ath11k_read_pdev_stats(struct file *file,
342 char __user *user_buf,
343 size_t count, loff_t *ppos)
345 const char *buf = file->private_data;
346 size_t len = strlen(buf);
348 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
351 static const struct file_operations fops_pdev_stats = {
352 .open = ath11k_open_pdev_stats,
353 .release = ath11k_release_pdev_stats,
354 .read = ath11k_read_pdev_stats,
355 .owner = THIS_MODULE,
356 .llseek = default_llseek,
359 static int ath11k_open_vdev_stats(struct inode *inode, struct file *file)
361 struct ath11k *ar = inode->i_private;
362 struct stats_request_params req_param;
366 mutex_lock(&ar->conf_mutex);
368 if (ar->state != ATH11K_STATE_ON) {
373 buf = vmalloc(ATH11K_FW_STATS_BUF_SIZE);
379 req_param.pdev_id = ar->pdev->pdev_id;
380 /* VDEV stats is always sent for all active VDEVs from FW */
381 req_param.vdev_id = 0;
382 req_param.stats_id = WMI_REQUEST_VDEV_STAT;
384 ret = ath11k_debug_fw_stats_request(ar, &req_param);
386 ath11k_warn(ar->ab, "failed to request fw vdev stats: %d\n", ret);
390 ath11k_wmi_fw_stats_fill(ar, &ar->debug.fw_stats, req_param.stats_id,
393 file->private_data = buf;
395 mutex_unlock(&ar->conf_mutex);
402 mutex_unlock(&ar->conf_mutex);
406 static int ath11k_release_vdev_stats(struct inode *inode, struct file *file)
408 vfree(file->private_data);
413 static ssize_t ath11k_read_vdev_stats(struct file *file,
414 char __user *user_buf,
415 size_t count, loff_t *ppos)
417 const char *buf = file->private_data;
418 size_t len = strlen(buf);
420 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
423 static const struct file_operations fops_vdev_stats = {
424 .open = ath11k_open_vdev_stats,
425 .release = ath11k_release_vdev_stats,
426 .read = ath11k_read_vdev_stats,
427 .owner = THIS_MODULE,
428 .llseek = default_llseek,
431 static int ath11k_open_bcn_stats(struct inode *inode, struct file *file)
433 struct ath11k *ar = inode->i_private;
434 struct ath11k_vif *arvif;
435 struct stats_request_params req_param;
439 mutex_lock(&ar->conf_mutex);
441 if (ar->state != ATH11K_STATE_ON) {
446 buf = vmalloc(ATH11K_FW_STATS_BUF_SIZE);
452 req_param.stats_id = WMI_REQUEST_BCN_STAT;
453 req_param.pdev_id = ar->pdev->pdev_id;
455 /* loop all active VDEVs for bcn stats */
456 list_for_each_entry(arvif, &ar->arvifs, list) {
460 req_param.vdev_id = arvif->vdev_id;
461 ret = ath11k_debug_fw_stats_request(ar, &req_param);
463 ath11k_warn(ar->ab, "failed to request fw bcn stats: %d\n", ret);
468 ath11k_wmi_fw_stats_fill(ar, &ar->debug.fw_stats, req_param.stats_id,
471 /* since beacon stats request is looped for all active VDEVs, saved fw
472 * stats is not freed for each request until done for all active VDEVs
474 spin_lock_bh(&ar->data_lock);
475 ath11k_fw_stats_bcn_free(&ar->debug.fw_stats.bcn);
476 spin_unlock_bh(&ar->data_lock);
478 file->private_data = buf;
480 mutex_unlock(&ar->conf_mutex);
487 mutex_unlock(&ar->conf_mutex);
491 static int ath11k_release_bcn_stats(struct inode *inode, struct file *file)
493 vfree(file->private_data);
498 static ssize_t ath11k_read_bcn_stats(struct file *file,
499 char __user *user_buf,
500 size_t count, loff_t *ppos)
502 const char *buf = file->private_data;
503 size_t len = strlen(buf);
505 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
508 static const struct file_operations fops_bcn_stats = {
509 .open = ath11k_open_bcn_stats,
510 .release = ath11k_release_bcn_stats,
511 .read = ath11k_read_bcn_stats,
512 .owner = THIS_MODULE,
513 .llseek = default_llseek,
516 static ssize_t ath11k_read_simulate_fw_crash(struct file *file,
517 char __user *user_buf,
518 size_t count, loff_t *ppos)
521 "To simulate firmware crash write one of the keywords to this file:\n"
522 "`assert` - this will send WMI_FORCE_FW_HANG_CMDID to firmware to cause assert.\n"
523 "`hw-restart` - this will simply queue hw restart without fw/hw actually crashing.\n";
525 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
528 /* Simulate firmware crash:
529 * 'soft': Call wmi command causing firmware hang. This firmware hang is
530 * recoverable by warm firmware reset.
531 * 'hard': Force firmware crash by setting any vdev parameter for not allowed
532 * vdev id. This is hard firmware crash because it is recoverable only by cold
535 static ssize_t ath11k_write_simulate_fw_crash(struct file *file,
536 const char __user *user_buf,
537 size_t count, loff_t *ppos)
539 struct ath11k_base *ab = file->private_data;
540 struct ath11k_pdev *pdev;
541 struct ath11k *ar = ab->pdevs[0].ar;
544 int i, ret, radioup = 0;
546 for (i = 0; i < ab->num_radios; i++) {
547 pdev = &ab->pdevs[i];
549 if (ar && ar->state == ATH11K_STATE_ON) {
554 /* filter partial writes and invalid commands */
555 if (*ppos != 0 || count >= sizeof(buf) || count == 0)
558 rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
562 /* drop the possible '\n' from the end */
563 if (buf[*ppos - 1] == '\n')
564 buf[*ppos - 1] = '\0';
571 if (!strcmp(buf, "assert")) {
572 ath11k_info(ab, "simulating firmware assert crash\n");
573 ret = ath11k_wmi_force_fw_hang_cmd(ar,
574 ATH11K_WMI_FW_HANG_ASSERT_TYPE,
575 ATH11K_WMI_FW_HANG_DELAY);
582 ath11k_warn(ab, "failed to simulate firmware crash: %d\n", ret);
592 static const struct file_operations fops_simulate_fw_crash = {
593 .read = ath11k_read_simulate_fw_crash,
594 .write = ath11k_write_simulate_fw_crash,
596 .owner = THIS_MODULE,
597 .llseek = default_llseek,
600 static ssize_t ath11k_write_enable_extd_tx_stats(struct file *file,
601 const char __user *ubuf,
602 size_t count, loff_t *ppos)
604 struct ath11k *ar = file->private_data;
608 if (kstrtouint_from_user(ubuf, count, 0, &filter))
611 mutex_lock(&ar->conf_mutex);
613 if (ar->state != ATH11K_STATE_ON) {
618 if (filter == ar->debug.extd_tx_stats) {
623 ar->debug.extd_tx_stats = filter;
627 mutex_unlock(&ar->conf_mutex);
631 static ssize_t ath11k_read_enable_extd_tx_stats(struct file *file,
633 size_t count, loff_t *ppos)
637 struct ath11k *ar = file->private_data;
640 mutex_lock(&ar->conf_mutex);
641 len = scnprintf(buf, sizeof(buf) - len, "%08x\n",
642 ar->debug.extd_tx_stats);
643 mutex_unlock(&ar->conf_mutex);
645 return simple_read_from_buffer(ubuf, count, ppos, buf, len);
648 static const struct file_operations fops_extd_tx_stats = {
649 .read = ath11k_read_enable_extd_tx_stats,
650 .write = ath11k_write_enable_extd_tx_stats,
654 static ssize_t ath11k_write_extd_rx_stats(struct file *file,
655 const char __user *ubuf,
656 size_t count, loff_t *ppos)
658 struct ath11k *ar = file->private_data;
659 struct htt_rx_ring_tlv_filter tlv_filter = {0};
660 u32 enable, rx_filter = 0, ring_id;
663 if (kstrtouint_from_user(ubuf, count, 0, &enable))
666 mutex_lock(&ar->conf_mutex);
668 if (ar->state != ATH11K_STATE_ON) {
678 if (enable == ar->debug.extd_rx_stats) {
684 rx_filter = HTT_RX_FILTER_TLV_FLAGS_MPDU_START;
685 rx_filter |= HTT_RX_FILTER_TLV_FLAGS_PPDU_START;
686 rx_filter |= HTT_RX_FILTER_TLV_FLAGS_PPDU_END;
687 rx_filter |= HTT_RX_FILTER_TLV_FLAGS_PPDU_END_USER_STATS;
688 rx_filter |= HTT_RX_FILTER_TLV_FLAGS_PPDU_END_USER_STATS_EXT;
689 rx_filter |= HTT_RX_FILTER_TLV_FLAGS_PPDU_END_STATUS_DONE;
691 tlv_filter.rx_filter = rx_filter;
692 tlv_filter.pkt_filter_flags0 = HTT_RX_FP_MGMT_FILTER_FLAGS0;
693 tlv_filter.pkt_filter_flags1 = HTT_RX_FP_MGMT_FILTER_FLAGS1;
694 tlv_filter.pkt_filter_flags2 = HTT_RX_FP_CTRL_FILTER_FLASG2;
695 tlv_filter.pkt_filter_flags3 = HTT_RX_FP_CTRL_FILTER_FLASG3 |
696 HTT_RX_FP_DATA_FILTER_FLASG3;
698 tlv_filter = ath11k_mac_mon_status_filter_default;
701 ar->debug.rx_filter = tlv_filter.rx_filter;
703 ring_id = ar->dp.rx_mon_status_refill_ring.refill_buf_ring.ring_id;
704 ret = ath11k_dp_tx_htt_rx_filter_setup(ar->ab, ring_id, ar->dp.mac_id,
705 HAL_RXDMA_MONITOR_STATUS,
706 DP_RX_BUFFER_SIZE, &tlv_filter);
709 ath11k_warn(ar->ab, "failed to set rx filter for monitor status ring\n");
713 ar->debug.extd_rx_stats = enable;
716 mutex_unlock(&ar->conf_mutex);
720 static ssize_t ath11k_read_extd_rx_stats(struct file *file,
722 size_t count, loff_t *ppos)
724 struct ath11k *ar = file->private_data;
728 mutex_lock(&ar->conf_mutex);
729 len = scnprintf(buf, sizeof(buf) - len, "%d\n",
730 ar->debug.extd_rx_stats);
731 mutex_unlock(&ar->conf_mutex);
733 return simple_read_from_buffer(ubuf, count, ppos, buf, len);
736 static const struct file_operations fops_extd_rx_stats = {
737 .read = ath11k_read_extd_rx_stats,
738 .write = ath11k_write_extd_rx_stats,
742 static ssize_t ath11k_debug_dump_soc_rx_stats(struct file *file,
743 char __user *user_buf,
744 size_t count, loff_t *ppos)
746 struct ath11k_base *ab = file->private_data;
747 struct ath11k_soc_dp_rx_stats *soc_stats = &ab->soc_stats;
748 int len = 0, i, retval;
749 const int size = 4096;
750 static const char *rxdma_err[HAL_REO_ENTR_RING_RXDMA_ECODE_MAX] = {
751 "Overflow", "MPDU len", "FCS", "Decrypt", "TKIP MIC",
752 "Unencrypt", "MSDU len", "MSDU limit", "WiFi parse",
753 "AMSDU parse", "SA timeout", "DA timeout",
754 "Flow timeout", "Flush req"};
755 static const char *reo_err[HAL_REO_DEST_RING_ERROR_CODE_MAX] = {
756 "Desc addr zero", "Desc inval", "AMPDU in non BA",
757 "Non BA dup", "BA dup", "Frame 2k jump", "BAR 2k jump",
758 "Frame OOR", "BAR OOR", "No BA session",
759 "Frame SN equal SSN", "PN check fail", "2k err",
760 "PN err", "Desc blocked"};
764 buf = kzalloc(size, GFP_KERNEL);
768 len += scnprintf(buf + len, size - len, "SOC RX STATS:\n\n");
769 len += scnprintf(buf + len, size - len, "err ring pkts: %u\n",
770 soc_stats->err_ring_pkts);
771 len += scnprintf(buf + len, size - len, "Invalid RBM: %u\n\n",
772 soc_stats->invalid_rbm);
773 len += scnprintf(buf + len, size - len, "RXDMA errors:\n");
774 for (i = 0; i < HAL_REO_ENTR_RING_RXDMA_ECODE_MAX; i++)
775 len += scnprintf(buf + len, size - len, "%s: %u\n",
776 rxdma_err[i], soc_stats->rxdma_error[i]);
778 len += scnprintf(buf + len, size - len, "\nREO errors:\n");
779 for (i = 0; i < HAL_REO_DEST_RING_ERROR_CODE_MAX; i++)
780 len += scnprintf(buf + len, size - len, "%s: %u\n",
781 reo_err[i], soc_stats->reo_error[i]);
783 len += scnprintf(buf + len, size - len, "\nHAL REO errors:\n");
784 len += scnprintf(buf + len, size - len,
785 "ring0: %u\nring1: %u\nring2: %u\nring3: %u\n",
786 soc_stats->hal_reo_error[0],
787 soc_stats->hal_reo_error[1],
788 soc_stats->hal_reo_error[2],
789 soc_stats->hal_reo_error[3]);
793 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
799 static const struct file_operations fops_soc_rx_stats = {
800 .read = ath11k_debug_dump_soc_rx_stats,
802 .owner = THIS_MODULE,
803 .llseek = default_llseek,
806 int ath11k_debug_pdev_create(struct ath11k_base *ab)
808 if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags))
811 ab->debugfs_soc = debugfs_create_dir(ab->hw_params.name, ab->debugfs_ath11k);
813 if (IS_ERR_OR_NULL(ab->debugfs_soc)) {
814 if (IS_ERR(ab->debugfs_soc))
815 return PTR_ERR(ab->debugfs_soc);
819 debugfs_create_file("simulate_fw_crash", 0600, ab->debugfs_soc, ab,
820 &fops_simulate_fw_crash);
822 debugfs_create_file("soc_rx_stats", 0600, ab->debugfs_soc, ab,
828 void ath11k_debug_pdev_destroy(struct ath11k_base *ab)
830 debugfs_remove_recursive(ab->debugfs_ath11k);
831 ab->debugfs_ath11k = NULL;
834 int ath11k_debug_soc_create(struct ath11k_base *ab)
836 ab->debugfs_ath11k = debugfs_create_dir("ath11k", NULL);
838 if (IS_ERR_OR_NULL(ab->debugfs_ath11k)) {
839 if (IS_ERR(ab->debugfs_ath11k))
840 return PTR_ERR(ab->debugfs_ath11k);
847 void ath11k_debug_soc_destroy(struct ath11k_base *ab)
849 debugfs_remove_recursive(ab->debugfs_soc);
850 ab->debugfs_soc = NULL;
853 void ath11k_debug_fw_stats_init(struct ath11k *ar)
855 struct dentry *fwstats_dir = debugfs_create_dir("fw_stats",
856 ar->debug.debugfs_pdev);
858 ar->debug.fw_stats.debugfs_fwstats = fwstats_dir;
860 /* all stats debugfs files created are under "fw_stats" directory
863 debugfs_create_file("pdev_stats", 0600, fwstats_dir, ar,
865 debugfs_create_file("vdev_stats", 0600, fwstats_dir, ar,
867 debugfs_create_file("beacon_stats", 0600, fwstats_dir, ar,
870 INIT_LIST_HEAD(&ar->debug.fw_stats.pdevs);
871 INIT_LIST_HEAD(&ar->debug.fw_stats.vdevs);
872 INIT_LIST_HEAD(&ar->debug.fw_stats.bcn);
874 init_completion(&ar->debug.fw_stats_complete);
877 static ssize_t ath11k_write_pktlog_filter(struct file *file,
878 const char __user *ubuf,
879 size_t count, loff_t *ppos)
881 struct ath11k *ar = file->private_data;
882 struct htt_rx_ring_tlv_filter tlv_filter = {0};
883 u32 rx_filter = 0, ring_id, filter, mode;
888 mutex_lock(&ar->conf_mutex);
889 if (ar->state != ATH11K_STATE_ON) {
894 rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
901 ret = sscanf(buf, "0x%x %u", &filter, &mode);
908 ret = ath11k_wmi_pdev_pktlog_enable(ar, filter);
911 "failed to enable pktlog filter %x: %d\n",
912 ar->debug.pktlog_filter, ret);
916 ret = ath11k_wmi_pdev_pktlog_disable(ar);
918 ath11k_warn(ar->ab, "failed to disable pktlog: %d\n", ret);
923 #define HTT_RX_FILTER_TLV_LITE_MODE \
924 (HTT_RX_FILTER_TLV_FLAGS_PPDU_START | \
925 HTT_RX_FILTER_TLV_FLAGS_PPDU_END | \
926 HTT_RX_FILTER_TLV_FLAGS_PPDU_END_USER_STATS | \
927 HTT_RX_FILTER_TLV_FLAGS_PPDU_END_USER_STATS_EXT | \
928 HTT_RX_FILTER_TLV_FLAGS_PPDU_END_STATUS_DONE | \
929 HTT_RX_FILTER_TLV_FLAGS_MPDU_START)
931 if (mode == ATH11K_PKTLOG_MODE_FULL) {
932 rx_filter = HTT_RX_FILTER_TLV_LITE_MODE |
933 HTT_RX_FILTER_TLV_FLAGS_MSDU_START |
934 HTT_RX_FILTER_TLV_FLAGS_MSDU_END |
935 HTT_RX_FILTER_TLV_FLAGS_MPDU_END |
936 HTT_RX_FILTER_TLV_FLAGS_PACKET_HEADER |
937 HTT_RX_FILTER_TLV_FLAGS_ATTENTION;
938 } else if (mode == ATH11K_PKTLOG_MODE_LITE) {
939 ret = ath11k_dp_tx_htt_h2t_ppdu_stats_req(ar,
940 HTT_PPDU_STATS_TAG_PKTLOG);
942 ath11k_err(ar->ab, "failed to enable pktlog lite: %d\n", ret);
946 rx_filter = HTT_RX_FILTER_TLV_LITE_MODE;
948 ret = ath11k_dp_tx_htt_h2t_ppdu_stats_req(ar,
949 HTT_PPDU_STATS_TAG_DEFAULT);
951 ath11k_err(ar->ab, "failed to send htt ppdu stats req: %d\n",
957 tlv_filter.rx_filter = rx_filter;
959 tlv_filter.pkt_filter_flags0 = HTT_RX_FP_MGMT_FILTER_FLAGS0;
960 tlv_filter.pkt_filter_flags1 = HTT_RX_FP_MGMT_FILTER_FLAGS1;
961 tlv_filter.pkt_filter_flags2 = HTT_RX_FP_CTRL_FILTER_FLASG2;
962 tlv_filter.pkt_filter_flags3 = HTT_RX_FP_CTRL_FILTER_FLASG3 |
963 HTT_RX_FP_DATA_FILTER_FLASG3;
966 ring_id = ar->dp.rx_mon_status_refill_ring.refill_buf_ring.ring_id;
967 ret = ath11k_dp_tx_htt_rx_filter_setup(ar->ab, ring_id, ar->dp.mac_id,
968 HAL_RXDMA_MONITOR_STATUS,
969 DP_RX_BUFFER_SIZE, &tlv_filter);
971 ath11k_warn(ar->ab, "failed to set rx filter for monitor status ring\n");
975 ath11k_dbg(ar->ab, ATH11K_DBG_WMI, "pktlog filter %d mode %s\n",
976 filter, ((mode == ATH11K_PKTLOG_MODE_FULL) ? "full" : "lite"));
978 ar->debug.pktlog_filter = filter;
979 ar->debug.pktlog_mode = mode;
983 mutex_unlock(&ar->conf_mutex);
987 static ssize_t ath11k_read_pktlog_filter(struct file *file,
989 size_t count, loff_t *ppos)
993 struct ath11k *ar = file->private_data;
996 mutex_lock(&ar->conf_mutex);
997 len = scnprintf(buf, sizeof(buf) - len, "%08x %08x\n",
998 ar->debug.pktlog_filter,
999 ar->debug.pktlog_mode);
1000 mutex_unlock(&ar->conf_mutex);
1002 return simple_read_from_buffer(ubuf, count, ppos, buf, len);
1005 static const struct file_operations fops_pktlog_filter = {
1006 .read = ath11k_read_pktlog_filter,
1007 .write = ath11k_write_pktlog_filter,
1011 static ssize_t ath11k_write_simulate_radar(struct file *file,
1012 const char __user *user_buf,
1013 size_t count, loff_t *ppos)
1015 struct ath11k *ar = file->private_data;
1018 ret = ath11k_wmi_simulate_radar(ar);
1025 static const struct file_operations fops_simulate_radar = {
1026 .write = ath11k_write_simulate_radar,
1030 int ath11k_debug_register(struct ath11k *ar)
1032 struct ath11k_base *ab = ar->ab;
1034 char buf[100] = {0};
1036 snprintf(pdev_name, sizeof(pdev_name), "%s%d", "mac", ar->pdev_idx);
1038 ar->debug.debugfs_pdev = debugfs_create_dir(pdev_name, ab->debugfs_soc);
1040 if (IS_ERR_OR_NULL(ar->debug.debugfs_pdev)) {
1041 if (IS_ERR(ar->debug.debugfs_pdev))
1042 return PTR_ERR(ar->debug.debugfs_pdev);
1047 /* Create a symlink under ieee80211/phy* */
1048 snprintf(buf, 100, "../../ath11k/%pd2", ar->debug.debugfs_pdev);
1049 debugfs_create_symlink("ath11k", ar->hw->wiphy->debugfsdir, buf);
1051 ath11k_debug_htt_stats_init(ar);
1053 ath11k_debug_fw_stats_init(ar);
1055 debugfs_create_file("ext_tx_stats", 0644,
1056 ar->debug.debugfs_pdev, ar,
1057 &fops_extd_tx_stats);
1058 debugfs_create_file("ext_rx_stats", 0644,
1059 ar->debug.debugfs_pdev, ar,
1060 &fops_extd_rx_stats);
1061 debugfs_create_file("pktlog_filter", 0644,
1062 ar->debug.debugfs_pdev, ar,
1063 &fops_pktlog_filter);
1065 if (ar->hw->wiphy->bands[NL80211_BAND_5GHZ]) {
1066 debugfs_create_file("dfs_simulate_radar", 0200,
1067 ar->debug.debugfs_pdev, ar,
1068 &fops_simulate_radar);
1069 debugfs_create_bool("dfs_block_radar_events", 0200,
1070 ar->debug.debugfs_pdev,
1071 &ar->dfs_block_radar_events);
1077 void ath11k_debug_unregister(struct ath11k *ar)
1080 #endif /* CONFIG_ATH11K_DEBUGFS */