]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
wifi: ath12k: initial debugfs support
authorRamasamy Kaliappan <quic_rkaliapp@quicinc.com>
Thu, 4 Apr 2024 06:35:58 +0000 (09:35 +0300)
committerKalle Valo <quic_kvalo@quicinc.com>
Thu, 4 Apr 2024 10:07:06 +0000 (13:07 +0300)
The initial debugfs infra bringup in ath12k driver and create the ath12k debugfs
and soc-specific directories in /sys/kernel/debug/

For each ath12k device, directory will be created in <bus>-<devname>
schema under ath12k root directory.

Example with one ath12k device:
/sys/kernel/debug/ath12k/pci-0000:06:00.0

ath12k
`-- pci-0000:06:00.0
    |-- mac0

To enable ath12k debugfs support (CONFIG_ATH12K_DEBUGFS=y)

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Ramasamy Kaliappan <quic_rkaliapp@quicinc.com>
Signed-off-by: Ramya Gnanasekar <quic_rgnanase@quicinc.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://msgid.link/20240320171305.655288-2-quic_rgnanase@quicinc.com
drivers/net/wireless/ath/ath12k/Kconfig
drivers/net/wireless/ath/ath12k/Makefile
drivers/net/wireless/ath/ath12k/core.c
drivers/net/wireless/ath/ath12k/core.h
drivers/net/wireless/ath/ath12k/debugfs.c [new file with mode: 0644]
drivers/net/wireless/ath/ath12k/debugfs.h [new file with mode: 0644]
drivers/net/wireless/ath/ath12k/mac.c

index e135d2b1b61d6675bb6d855e14c8952aa8a28770..eceab9153e98e8376a2831ca8d2dd2adee0f12d2 100644 (file)
@@ -24,6 +24,15 @@ config ATH12K_DEBUG
          If unsure, say Y to make it easier to debug problems. But if
          you want optimal performance choose N.
 
+config ATH12K_DEBUGFS
+       bool "QTI ath12k debugfs support"
+       depends on ATH12K && MAC80211_DEBUGFS
+       help
+         Enable ath12k debugfs support
+
+         If unsure, say Y to make it easier to debug problems. But if
+         you want optimal performance choose N.
+
 config ATH12K_TRACING
        bool "ath12k tracing support"
        depends on ATH12K && EVENT_TRACING
index 71669f94ff759b02ff799abcc6ec534a907f2d74..7b8b3d7526c84939ebf9c107f41b90b311f269d2 100644 (file)
@@ -23,6 +23,7 @@ ath12k-y += core.o \
            fw.o \
            p2p.o
 
+ath12k-$(CONFIG_ATH12K_DEBUGFS) += debugfs.o
 ath12k-$(CONFIG_ATH12K_TRACING) += trace.o
 
 # for tracing framework to find trace.h
index 391b6fb2bd42674423c153c11cc52a905ff6837a..3ec67d831cbd336300f22e32f59d3f1ec66d7847 100644 (file)
@@ -15,6 +15,7 @@
 #include "debug.h"
 #include "hif.h"
 #include "fw.h"
+#include "debugfs.h"
 
 unsigned int ath12k_debug_mask;
 module_param_named(debug_mask, ath12k_debug_mask, uint, 0644);
@@ -628,6 +629,8 @@ static int ath12k_core_soc_create(struct ath12k_base *ab)
                return ret;
        }
 
+       ath12k_debugfs_soc_create(ab);
+
        ret = ath12k_hif_power_up(ab);
        if (ret) {
                ath12k_err(ab, "failed to power up :%d\n", ret);
@@ -637,6 +640,7 @@ static int ath12k_core_soc_create(struct ath12k_base *ab)
        return 0;
 
 err_qmi_deinit:
+       ath12k_debugfs_soc_destroy(ab);
        ath12k_qmi_deinit_service(ab);
        return ret;
 }
@@ -645,6 +649,7 @@ static void ath12k_core_soc_destroy(struct ath12k_base *ab)
 {
        ath12k_dp_free(ab);
        ath12k_reg_free(ab);
+       ath12k_debugfs_soc_destroy(ab);
        ath12k_qmi_deinit_service(ab);
 }
 
index 97e5a0ccd2338f018b7e9a2aa485666db0a36e57..ceb0451046bf87f84be57bdb19546a2e94f5b788 100644 (file)
@@ -453,6 +453,10 @@ struct ath12k_fw_stats {
        struct list_head bcn;
 };
 
+struct ath12k_debug {
+       struct dentry *debugfs_pdev;
+};
+
 struct ath12k_per_peer_tx_stats {
        u32 succ_bytes;
        u32 retry_bytes;
@@ -592,6 +596,9 @@ struct ath12k {
        struct ath12k_per_peer_tx_stats cached_stats;
        u32 last_ppdu_id;
        u32 cached_ppdu_id;
+#ifdef CONFIG_ATH12K_DEBUGFS
+       struct ath12k_debug debug;
+#endif
 
        bool dfs_block_radar_events;
        bool monitor_conf_enabled;
@@ -782,6 +789,9 @@ struct ath12k_base {
        /* Current DFS Regulatory */
        enum ath12k_dfs_region dfs_region;
        struct ath12k_soc_dp_stats soc_stats;
+#ifdef CONFIG_ATH12K_DEBUGFS
+       struct dentry *debugfs_soc;
+#endif
 
        unsigned long dev_flags;
        struct completion driver_recovery;
diff --git a/drivers/net/wireless/ath/ath12k/debugfs.c b/drivers/net/wireless/ath/ath12k/debugfs.c
new file mode 100644 (file)
index 0000000..65f3c8b
--- /dev/null
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: BSD-3-Clause-Clear
+/*
+ * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#include "core.h"
+#include "debugfs.h"
+
+void ath12k_debugfs_soc_create(struct ath12k_base *ab)
+{
+       bool dput_needed;
+       char soc_name[64] = { 0 };
+       struct dentry *debugfs_ath12k;
+
+       debugfs_ath12k = debugfs_lookup("ath12k", NULL);
+       if (debugfs_ath12k) {
+               /* a dentry from lookup() needs dput() after we don't use it */
+               dput_needed = true;
+       } else {
+               debugfs_ath12k = debugfs_create_dir("ath12k", NULL);
+               if (IS_ERR_OR_NULL(debugfs_ath12k))
+                       return;
+               dput_needed = false;
+       }
+
+       scnprintf(soc_name, sizeof(soc_name), "%s-%s", ath12k_bus_str(ab->hif.bus),
+                 dev_name(ab->dev));
+
+       ab->debugfs_soc = debugfs_create_dir(soc_name, debugfs_ath12k);
+
+       if (dput_needed)
+               dput(debugfs_ath12k);
+}
+
+void ath12k_debugfs_soc_destroy(struct ath12k_base *ab)
+{
+       debugfs_remove_recursive(ab->debugfs_soc);
+       ab->debugfs_soc = NULL;
+       /* We are not removing ath12k directory on purpose, even if it
+        * would be empty. This simplifies the directory handling and it's
+        * a minor cosmetic issue to leave an empty ath12k directory to
+        * debugfs.
+        */
+}
+
+void ath12k_debugfs_register(struct ath12k *ar)
+{
+       struct ath12k_base *ab = ar->ab;
+       struct ieee80211_hw *hw = ar->ah->hw;
+       char pdev_name[5];
+       char buf[100] = {0};
+
+       scnprintf(pdev_name, sizeof(pdev_name), "%s%d", "mac", ar->pdev_idx);
+
+       ar->debug.debugfs_pdev = debugfs_create_dir(pdev_name, ab->debugfs_soc);
+
+       /* Create a symlink under ieee80211/phy* */
+       scnprintf(buf, sizeof(buf), "../../ath12k/%pd2", ar->debug.debugfs_pdev);
+       debugfs_create_symlink("ath12k", hw->wiphy->debugfsdir, buf);
+}
diff --git a/drivers/net/wireless/ath/ath12k/debugfs.h b/drivers/net/wireless/ath/ath12k/debugfs.h
new file mode 100644 (file)
index 0000000..a62f2a5
--- /dev/null
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: BSD-3-Clause-Clear */
+/*
+ * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#ifndef _ATH12K_DEBUGFS_H_
+#define _ATH12K_DEBUGFS_H_
+
+#ifdef CONFIG_ATH12K_DEBUGFS
+void ath12k_debugfs_soc_create(struct ath12k_base *ab);
+void ath12k_debugfs_soc_destroy(struct ath12k_base *ab);
+void ath12k_debugfs_register(struct ath12k *ar);
+
+#else
+static inline void ath12k_debugfs_soc_create(struct ath12k_base *ab)
+{
+}
+
+static inline void ath12k_debugfs_soc_destroy(struct ath12k_base *ab)
+{
+}
+
+static inline void ath12k_debugfs_register(struct ath12k *ar)
+{
+}
+
+#endif /* CONFIG_ATH12K_DEBUGFS */
+
+#endif /* _ATH12K_DEBUGFS_H_ */
index 52a5fb8b03e9a9715864a1ef5793d9735a28f79b..2df966723c44cd06dd603b714bd45ac3123c9b7b 100644 (file)
@@ -14,6 +14,7 @@
 #include "dp_tx.h"
 #include "dp_rx.h"
 #include "peer.h"
+#include "debugfs.h"
 
 #define CHAN2G(_channel, _freq, _flags) { \
        .band                   = NL80211_BAND_2GHZ, \
@@ -8105,6 +8106,8 @@ static int ath12k_mac_hw_register(struct ath12k_hw *ah)
                goto err_unregister_hw;
        }
 
+       ath12k_debugfs_register(ar);
+
        return 0;
 
 err_unregister_hw: