mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-12-23 20:31:59 +00:00
344 lines
9.6 KiB
Diff
344 lines
9.6 KiB
Diff
From 384ad0940bc6b5ae56a6097a75021ba9f85275f2 Mon Sep 17 00:00:00 2001
|
|
From: Aloka Dixit <quic_alokad@quicinc.com>
|
|
Date: Sun, 30 Jan 2022 19:10:43 -0800
|
|
Subject: [PATCH 2/2] ath12k: add debugfs for TWT debug calls
|
|
|
|
New debugfs files to manually add/delete/pause/resume TWT
|
|
dialogs for test/debug purposes.
|
|
|
|
The debugfs files expect the following parameters
|
|
- Add dialog
|
|
echo '<Peer_MAC> <Dialog_ID> <Wake_Interval_Usec> <Wake_Interval_Mantis>
|
|
<Wake_Duration_Usec> <First_SP_Offset> <TWT_Command>
|
|
<1:Broadcast /0:Individual> <1:Triggered / 0:Untriggered>
|
|
<1:Unannounced /0:Announced> <1:Protected / 0:Unprotected>' >
|
|
/sys/kernel/debug/ieee80211/phyX/netdev:wlanX/twt/add_dialog
|
|
|
|
Example (Non-triggered and un-announced):
|
|
echo '00:03:7F:20:13:52 1 102400 100 30720 20480 4 0 0 1 0' >
|
|
/sys/kernel/debug/ieee80211/phy0/netdev:wlan0/twt/add_dialog
|
|
|
|
- Delete dialog
|
|
echo '<Peer_MAC> <Dialog_ID>' >
|
|
/sys/kernel/debug/ieee80211/phyX/netdev:wlanX/twt/del_dialog
|
|
|
|
- Pause dialog
|
|
echo '<Peer_MAC> <Dialog_ID>' >
|
|
/sys/kernel/debug/ieee80211/phyX/netdev:wlanX/twt/pause_dialog
|
|
|
|
- Resume dialog
|
|
echo '<Peer_MAC> <Dialog_ID> <SP_Offset_Usec> <Next_TWT_Size>' >
|
|
/sys/kernel/debug/ieee80211/phyX/netdev:wlanX/twt/resume_dialog
|
|
|
|
Example:
|
|
echo '00:03:7F:20:13:52 1 2000000 3' >
|
|
/sys/kernel/debug/ieee80211/phy0/netdev:wlan0/twt/resume_dialog
|
|
|
|
Signed-off-by: Aloka Dixit <quic_alokad@quicinc.com>
|
|
---
|
|
drivers/net/wireless/ath/ath12k/core.h | 3 +
|
|
drivers/net/wireless/ath/ath12k/debugfs.c | 222 ++++++++++++++++++++++
|
|
drivers/net/wireless/ath/ath12k/debugfs.h | 14 +-
|
|
drivers/net/wireless/ath/ath12k/mac.c | 7 +
|
|
4 files changed, 245 insertions(+), 1 deletion(-)
|
|
|
|
--- a/drivers/net/wireless/ath/ath12k/core.h
|
|
+++ b/drivers/net/wireless/ath/ath12k/core.h
|
|
@@ -278,6 +278,9 @@ struct ath12k_vif {
|
|
u8 vdev_stats_id;
|
|
struct ath12k_fw_vdev_ol_stats vdev_stats;
|
|
u8 nontransmitting_vif_count;
|
|
+#ifdef CPTCFG_ATH12K_DEBUGFS
|
|
+ struct dentry *debugfs_twt;
|
|
+#endif /* CPTCFG_ATH12K_DEBUGFS */
|
|
};
|
|
|
|
struct ath12k_vif_iter {
|
|
--- a/drivers/net/wireless/ath/ath12k/debugfs.c
|
|
+++ b/drivers/net/wireless/ath/ath12k/debugfs.c
|
|
@@ -1340,3 +1340,225 @@ void ath12k_debugfs_destroy(void)
|
|
debugfs_remove_recursive(debugfs_ath12k);
|
|
debugfs_ath12k = NULL;
|
|
}
|
|
+
|
|
+static ssize_t ath12k_write_twt_add_dialog(struct file *file,
|
|
+ const char __user *ubuf,
|
|
+ size_t count, loff_t *ppos)
|
|
+{
|
|
+ struct ath12k_vif *arvif = file->private_data;
|
|
+ struct wmi_twt_add_dialog_params params = { 0 };
|
|
+ u8 buf[128] = {0};
|
|
+ int ret;
|
|
+
|
|
+ if (arvif->ar->twt_enabled == 0) {
|
|
+ ath12k_err(arvif->ar->ab, "twt support is not enabled\n");
|
|
+ return -EOPNOTSUPP;
|
|
+ }
|
|
+
|
|
+ ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
|
|
+ if (ret < 0)
|
|
+ return ret;
|
|
+
|
|
+ buf[ret] = '\0';
|
|
+ ret = sscanf(buf,
|
|
+ "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx %u %u %u %u %u %hhu %hhu %hhu %hhu %hhu",
|
|
+ ¶ms.peer_macaddr[0],
|
|
+ ¶ms.peer_macaddr[1],
|
|
+ ¶ms.peer_macaddr[2],
|
|
+ ¶ms.peer_macaddr[3],
|
|
+ ¶ms.peer_macaddr[4],
|
|
+ ¶ms.peer_macaddr[5],
|
|
+ ¶ms.dialog_id,
|
|
+ ¶ms.wake_intvl_us,
|
|
+ ¶ms.wake_intvl_mantis,
|
|
+ ¶ms.wake_dura_us,
|
|
+ ¶ms.sp_offset_us,
|
|
+ ¶ms.twt_cmd,
|
|
+ ¶ms.flag_bcast,
|
|
+ ¶ms.flag_trigger,
|
|
+ ¶ms.flag_flow_type,
|
|
+ ¶ms.flag_protection);
|
|
+ if (ret != 16)
|
|
+ return -EINVAL;
|
|
+
|
|
+ params.vdev_id = arvif->vdev_id;
|
|
+
|
|
+ ret = ath12k_wmi_send_twt_add_dialog_cmd(arvif->ar, ¶ms);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ return count;
|
|
+}
|
|
+
|
|
+static ssize_t ath12k_write_twt_del_dialog(struct file *file,
|
|
+ const char __user *ubuf,
|
|
+ size_t count, loff_t *ppos)
|
|
+{
|
|
+ struct ath12k_vif *arvif = file->private_data;
|
|
+ struct wmi_twt_del_dialog_params params = { 0 };
|
|
+ u8 buf[64] = {0};
|
|
+ int ret;
|
|
+
|
|
+ if (arvif->ar->twt_enabled == 0) {
|
|
+ ath12k_err(arvif->ar->ab, "twt support is not enabled\n");
|
|
+ return -EOPNOTSUPP;
|
|
+ }
|
|
+
|
|
+ ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
|
|
+ if (ret < 0)
|
|
+ return ret;
|
|
+
|
|
+ buf[ret] = '\0';
|
|
+ ret = sscanf(buf, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx %u",
|
|
+ ¶ms.peer_macaddr[0],
|
|
+ ¶ms.peer_macaddr[1],
|
|
+ ¶ms.peer_macaddr[2],
|
|
+ ¶ms.peer_macaddr[3],
|
|
+ ¶ms.peer_macaddr[4],
|
|
+ ¶ms.peer_macaddr[5],
|
|
+ ¶ms.dialog_id);
|
|
+ if (ret != 7)
|
|
+ return -EINVAL;
|
|
+
|
|
+ params.vdev_id = arvif->vdev_id;
|
|
+
|
|
+ ret = ath12k_wmi_send_twt_del_dialog_cmd(arvif->ar, ¶ms);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ return count;
|
|
+}
|
|
+
|
|
+static ssize_t ath12k_write_twt_pause_dialog(struct file *file,
|
|
+ const char __user *ubuf,
|
|
+ size_t count, loff_t *ppos)
|
|
+{
|
|
+ struct ath12k_vif *arvif = file->private_data;
|
|
+ struct wmi_twt_pause_dialog_params params = { 0 };
|
|
+ u8 buf[64] = {0};
|
|
+ int ret;
|
|
+
|
|
+ if (arvif->ar->twt_enabled == 0) {
|
|
+ ath12k_err(arvif->ar->ab, "twt support is not enabled\n");
|
|
+ return -EOPNOTSUPP;
|
|
+ }
|
|
+
|
|
+ ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
|
|
+ if (ret < 0)
|
|
+ return ret;
|
|
+
|
|
+ buf[ret] = '\0';
|
|
+ ret = sscanf(buf, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx %u",
|
|
+ ¶ms.peer_macaddr[0],
|
|
+ ¶ms.peer_macaddr[1],
|
|
+ ¶ms.peer_macaddr[2],
|
|
+ ¶ms.peer_macaddr[3],
|
|
+ ¶ms.peer_macaddr[4],
|
|
+ ¶ms.peer_macaddr[5],
|
|
+ ¶ms.dialog_id);
|
|
+ if (ret != 7)
|
|
+ return -EINVAL;
|
|
+
|
|
+ params.vdev_id = arvif->vdev_id;
|
|
+
|
|
+ ret = ath12k_wmi_send_twt_pause_dialog_cmd(arvif->ar, ¶ms);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ return count;
|
|
+}
|
|
+
|
|
+static ssize_t ath12k_write_twt_resume_dialog(struct file *file,
|
|
+ const char __user *ubuf,
|
|
+ size_t count, loff_t *ppos)
|
|
+{
|
|
+ struct ath12k_vif *arvif = file->private_data;
|
|
+ struct wmi_twt_resume_dialog_params params = { 0 };
|
|
+ u8 buf[64] = {0};
|
|
+ int ret;
|
|
+
|
|
+ if (arvif->ar->twt_enabled == 0) {
|
|
+ ath12k_err(arvif->ar->ab, "twt support is not enabled\n");
|
|
+ return -EOPNOTSUPP;
|
|
+ }
|
|
+
|
|
+ ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
|
|
+ if (ret < 0)
|
|
+ return ret;
|
|
+
|
|
+ buf[ret] = '\0';
|
|
+ ret = sscanf(buf, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx %u %u %u",
|
|
+ ¶ms.peer_macaddr[0],
|
|
+ ¶ms.peer_macaddr[1],
|
|
+ ¶ms.peer_macaddr[2],
|
|
+ ¶ms.peer_macaddr[3],
|
|
+ ¶ms.peer_macaddr[4],
|
|
+ ¶ms.peer_macaddr[5],
|
|
+ ¶ms.dialog_id,
|
|
+ ¶ms.sp_offset_us,
|
|
+ ¶ms.next_twt_size);
|
|
+ if (ret != 9)
|
|
+ return -EINVAL;
|
|
+
|
|
+ params.vdev_id = arvif->vdev_id;
|
|
+
|
|
+ ret = ath12k_wmi_send_twt_resume_dialog_cmd(arvif->ar, ¶ms);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ return count;
|
|
+}
|
|
+
|
|
+static const struct file_operations ath12k_fops_twt_add_dialog = {
|
|
+ .write = ath12k_write_twt_add_dialog,
|
|
+ .open = simple_open
|
|
+};
|
|
+
|
|
+static const struct file_operations ath12k_fops_twt_del_dialog = {
|
|
+ .write = ath12k_write_twt_del_dialog,
|
|
+ .open = simple_open
|
|
+};
|
|
+
|
|
+static const struct file_operations ath12k_fops_twt_pause_dialog = {
|
|
+ .write = ath12k_write_twt_pause_dialog,
|
|
+ .open = simple_open
|
|
+};
|
|
+
|
|
+static const struct file_operations ath12k_fops_twt_resume_dialog = {
|
|
+ .write = ath12k_write_twt_resume_dialog,
|
|
+ .open = simple_open
|
|
+};
|
|
+
|
|
+int ath12k_debugfs_add_interface(struct ath12k_vif *arvif)
|
|
+{
|
|
+ if (arvif->vif->type == NL80211_IFTYPE_AP && !arvif->debugfs_twt) {
|
|
+ arvif->debugfs_twt = debugfs_create_dir("twt",
|
|
+ arvif->vif->debugfs_dir);
|
|
+ if (!arvif->debugfs_twt || IS_ERR(arvif->debugfs_twt)) {
|
|
+ ath12k_warn(arvif->ar->ab,
|
|
+ "failed to create directory %p\n",
|
|
+ arvif->debugfs_twt);
|
|
+ arvif->debugfs_twt = NULL;
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ debugfs_create_file("add_dialog", 0200, arvif->debugfs_twt,
|
|
+ arvif, &ath12k_fops_twt_add_dialog);
|
|
+
|
|
+ debugfs_create_file("del_dialog", 0200, arvif->debugfs_twt,
|
|
+ arvif, &ath12k_fops_twt_del_dialog);
|
|
+
|
|
+ debugfs_create_file("pause_dialog", 0200, arvif->debugfs_twt,
|
|
+ arvif, &ath12k_fops_twt_pause_dialog);
|
|
+
|
|
+ debugfs_create_file("resume_dialog", 0200, arvif->debugfs_twt,
|
|
+ arvif, &ath12k_fops_twt_resume_dialog);
|
|
+ }
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+void ath12k_debugfs_remove_interface(struct ath12k_vif *arvif)
|
|
+{
|
|
+ debugfs_remove_recursive(arvif->debugfs_twt);
|
|
+ arvif->debugfs_twt = NULL;
|
|
+}
|
|
--- a/drivers/net/wireless/ath/ath12k/debugfs.h
|
|
+++ b/drivers/net/wireless/ath/ath12k/debugfs.h
|
|
@@ -150,6 +150,9 @@ static inline int ath12k_debugfs_rx_filt
|
|
return ar->debug.rx_filter;
|
|
}
|
|
|
|
+int ath12k_debugfs_add_interface(struct ath12k_vif *arvif);
|
|
+void ath12k_debugfs_remove_interface(struct ath12k_vif *arvif);
|
|
+
|
|
#else
|
|
static inline int ath12k_debugfs_create(void)
|
|
{
|
|
@@ -226,6 +229,15 @@ static inline int ath12k_debugfs_rx_filt
|
|
return 0;
|
|
}
|
|
|
|
-#endif /* CPTCFG_MAC80211_DEBUGFS*/
|
|
+static inline int ath12k_debugfs_add_interface(struct ath12k_vif *arvif)
|
|
+{
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static inline void ath12k_debugfs_remove_interface(struct ath12k_vif *arvif)
|
|
+{
|
|
+}
|
|
+
|
|
+#endif /* CPTCFG_ATH12K_DEBUGFS*/
|
|
|
|
#endif /* _ATH12K_DEBUGFS_H_ */
|
|
--- a/drivers/net/wireless/ath/ath12k/mac.c
|
|
+++ b/drivers/net/wireless/ath/ath12k/mac.c
|
|
@@ -6613,6 +6613,10 @@ static int ath12k_mac_op_add_interface(s
|
|
if (vif->type != NL80211_IFTYPE_MONITOR && ar->monitor_conf_enabled)
|
|
ath12k_mac_monitor_vdev_create(ar);
|
|
|
|
+ ret = ath12k_debugfs_add_interface(arvif);
|
|
+ if (ret)
|
|
+ goto err_peer_del;
|
|
+
|
|
mutex_unlock(&ar->conf_mutex);
|
|
|
|
return ret;
|
|
@@ -6648,6 +6652,7 @@ err_vdev_del:
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
err:
|
|
+ ath12k_debugfs_remove_interface(arvif);
|
|
mutex_unlock(&ar->conf_mutex);
|
|
|
|
return ret;
|
|
@@ -6748,6 +6753,8 @@ err_vdev_del:
|
|
ath12k_mac_txpower_recalc(ar);
|
|
clear_bit(ATH12K_FLAG_MONITOR_ENABLED, &ar->monitor_flags);
|
|
|
|
+ ath12k_debugfs_remove_interface(arvif);
|
|
+
|
|
/* TODO: recal traffic pause state based on the available vdevs */
|
|
|
|
mutex_unlock(&ar->conf_mutex);
|