2024-03-20 17:13:29

by Ramya Gnanasekar

[permalink] [raw]
Subject: [PATCH 0/2] wifi: ath12k: Add initial debugfs support in ath12k

The initial debugfs infra support in ath12k driver and create the
ath12k debugfs and soc-specific directories in /sys/kernel/debug/

Add support to simulate RADAR interference through debugfs

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

Ramasamy Kaliappan (1):
wifi: ath12k: Add initial debugfs support in ath12k

Ramya Gnanasekar (1):
wifi: ath12k: Add radar simulation debugfs support

drivers/net/wireless/ath/ath12k/Kconfig | 9 +++
drivers/net/wireless/ath/ath12k/Makefile | 1 +
drivers/net/wireless/ath/ath12k/core.c | 5 ++
drivers/net/wireless/ath/ath12k/core.h | 10 +++
drivers/net/wireless/ath/ath12k/debugfs.c | 89 +++++++++++++++++++++++
drivers/net/wireless/ath/ath12k/debugfs.h | 30 ++++++++
drivers/net/wireless/ath/ath12k/mac.c | 3 +
7 files changed, 147 insertions(+)
create mode 100644 drivers/net/wireless/ath/ath12k/debugfs.c
create mode 100644 drivers/net/wireless/ath/ath12k/debugfs.h

--
2.17.1


2024-03-20 17:13:36

by Ramya Gnanasekar

[permalink] [raw]
Subject: [PATCH 1/2] wifi: ath12k: Add initial debugfs support in ath12k

From: Ramasamy Kaliappan <[email protected]>

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 <[email protected]>
Signed-off-by: Ramya Gnanasekar <[email protected]>
---
drivers/net/wireless/ath/ath12k/Kconfig | 9 ++++
drivers/net/wireless/ath/ath12k/Makefile | 1 +
drivers/net/wireless/ath/ath12k/core.c | 5 ++
drivers/net/wireless/ath/ath12k/core.h | 10 ++++
drivers/net/wireless/ath/ath12k/debugfs.c | 61 +++++++++++++++++++++++
drivers/net/wireless/ath/ath12k/debugfs.h | 30 +++++++++++
drivers/net/wireless/ath/ath12k/mac.c | 3 ++
7 files changed, 119 insertions(+)
create mode 100644 drivers/net/wireless/ath/ath12k/debugfs.c
create mode 100644 drivers/net/wireless/ath/ath12k/debugfs.h

diff --git a/drivers/net/wireless/ath/ath12k/Kconfig b/drivers/net/wireless/ath/ath12k/Kconfig
index e135d2b1b61d..eceab9153e98 100644
--- a/drivers/net/wireless/ath/ath12k/Kconfig
+++ b/drivers/net/wireless/ath/ath12k/Kconfig
@@ -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
diff --git a/drivers/net/wireless/ath/ath12k/Makefile b/drivers/net/wireless/ath/ath12k/Makefile
index 71669f94ff75..7b8b3d7526c8 100644
--- a/drivers/net/wireless/ath/ath12k/Makefile
+++ b/drivers/net/wireless/ath/ath12k/Makefile
@@ -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
diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c
index 391b6fb2bd42..3ec67d831cbd 100644
--- a/drivers/net/wireless/ath/ath12k/core.c
+++ b/drivers/net/wireless/ath/ath12k/core.c
@@ -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);
}

diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index 97e5a0ccd233..ceb0451046bf 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -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
index 000000000000..65f3c8bf3f10
--- /dev/null
+++ b/drivers/net/wireless/ath/ath12k/debugfs.c
@@ -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
index 000000000000..a62f2a550b23
--- /dev/null
+++ b/drivers/net/wireless/ath/ath12k/debugfs.h
@@ -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_ */
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 52a5fb8b03e9..2df966723c44 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -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:
--
2.17.1


2024-03-20 17:15:17

by Ramya Gnanasekar

[permalink] [raw]
Subject: [PATCH 2/2] wifi: ath12k: Add radar simulation debugfs support

Create dfs_simulate_radar debugfs in ath12k debugfs directory.

Usage:
echo 1 > /sys/kernel/debug/ath12k/pci-0000:06:00.0/mac0/dfs_simulate_radar

This debugfs helps user to simulate RADAR interference in run time.

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

Signed-off-by: Ramya Gnanasekar <[email protected]>
---
drivers/net/wireless/ath/ath12k/debugfs.c | 29 +++++++++++++++++++++++
1 file changed, 29 insertions(+)

diff --git a/drivers/net/wireless/ath/ath12k/debugfs.c b/drivers/net/wireless/ath/ath12k/debugfs.c
index 65f3c8bf3f10..8d8ba951093b 100644
--- a/drivers/net/wireless/ath/ath12k/debugfs.c
+++ b/drivers/net/wireless/ath/ath12k/debugfs.c
@@ -7,6 +7,29 @@
#include "core.h"
#include "debugfs.h"

+static ssize_t ath12k_write_simulate_radar(struct file *file,
+ const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct ath12k *ar = file->private_data;
+ int ret;
+
+ mutex_lock(&ar->conf_mutex);
+ ret = ath12k_wmi_simulate_radar(ar);
+ if (ret)
+ goto exit;
+
+ ret = count;
+exit:
+ mutex_unlock(&ar->conf_mutex);
+ return ret;
+}
+
+static const struct file_operations fops_simulate_radar = {
+ .write = ath12k_write_simulate_radar,
+ .open = simple_open
+};
+
void ath12k_debugfs_soc_create(struct ath12k_base *ab)
{
bool dput_needed;
@@ -58,4 +81,10 @@ void ath12k_debugfs_register(struct ath12k *ar)
/* Create a symlink under ieee80211/phy* */
scnprintf(buf, sizeof(buf), "../../ath12k/%pd2", ar->debug.debugfs_pdev);
debugfs_create_symlink("ath12k", hw->wiphy->debugfsdir, buf);
+
+ if (ar->mac.sbands[NL80211_BAND_5GHZ].channels) {
+ debugfs_create_file("dfs_simulate_radar", 0200,
+ ar->debug.debugfs_pdev, ar,
+ &fops_simulate_radar);
+ }
}
--
2.34.1


2024-03-20 20:57:40

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 1/2] wifi: ath12k: Add initial debugfs support in ath12k

On 3/20/2024 10:13 AM, Ramya Gnanasekar wrote:
> From: Ramasamy Kaliappan <[email protected]>
>
> 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 <[email protected]>
> Signed-off-by: Ramya Gnanasekar <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-03-20 20:58:29

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 2/2] wifi: ath12k: Add radar simulation debugfs support

On 3/20/2024 10:13 AM, Ramya Gnanasekar wrote:
> Create dfs_simulate_radar debugfs in ath12k debugfs directory.
>
> Usage:
> echo 1 > /sys/kernel/debug/ath12k/pci-0000:06:00.0/mac0/dfs_simulate_radar
>
> This debugfs helps user to simulate RADAR interference in run time.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Ramya Gnanasekar <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-04-04 10:07:34

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 1/2] wifi: ath12k: Add initial debugfs support in ath12k

Ramya Gnanasekar <[email protected]> wrote:

> 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 <[email protected]>
> Signed-off-by: Ramya Gnanasekar <[email protected]>
> Acked-by: Jeff Johnson <[email protected]>
> Signed-off-by: Kalle Valo <[email protected]>

2 patches applied to ath-next branch of ath.git, thanks.

f8bde02a26b9 wifi: ath12k: initial debugfs support
f51d917b7330 wifi: ath12k: debugfs: radar simulation support

--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches