From: John Crispin <john@phrozen.org>
To: Kalle Valo <kvalo@codeaurora.org>
Cc: linux-wireless@vger.kernel.org, ath11k@lists.infradead.org,
John Crispin <john@phrozen.org>
Subject: [PATCH V3 6/9] ath11k: add debugfs for TWT debug calls
Date: Fri, 13 Dec 2019 16:38:36 +0100 [thread overview]
Message-ID: <20191213153839.12372-7-john@phrozen.org> (raw)
In-Reply-To: <20191213153839.12372-1-john@phrozen.org>
These new debugfs files allow us to manually add/del/pause/resume TWT
dialogs for test/debug purposes.
The debugfs files expect the following parameters
add_dialog - mac dialog_id wake_intvl_us wake_intvl_mantis
wake_dura_us sp_offset_us twt_cmd flag_bcast
flag_trigger flag_flow_type flag_protection
del_dialog - mac dialog_id
pause_dialog - mac dialog_id
resume_dialog - mac dialog_id sp_offset_us next_twt_size
Signed-off-by: John Crispin <john@phrozen.org>
---
Changes in V2
* add a better patch description
drivers/net/wireless/ath/ath11k/core.h | 1 +
drivers/net/wireless/ath/ath11k/debug.c | 198 ++++++++++++++++++++++++
drivers/net/wireless/ath/ath11k/debug.h | 8 +
drivers/net/wireless/ath/ath11k/mac.c | 4 +
4 files changed, 211 insertions(+)
diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
index 25cdcf71d0c4..65d8684364dd 100644
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -216,6 +216,7 @@ struct ath11k_vif {
int num_legacy_stations;
int rtscts_prot_mode;
int txpower;
+ struct dentry *debugfs_twt;
};
struct ath11k_vif_iter {
diff --git a/drivers/net/wireless/ath/ath11k/debug.c b/drivers/net/wireless/ath/ath11k/debug.c
index c27fffd13a5d..2311e08d0889 100644
--- a/drivers/net/wireless/ath/ath11k/debug.c
+++ b/drivers/net/wireless/ath/ath11k/debug.c
@@ -104,6 +104,204 @@ void ath11k_dbg_dump(struct ath11k_base *ab,
#endif
+#ifdef CONFIG_MAC80211_DEBUGFS
+static ssize_t ath11k_write_twt_add_dialog(struct file *file,
+ const char __user *ubuf,
+ size_t count, loff_t *ppos)
+{
+ struct ath11k_vif *arvif = file->private_data;
+ struct wmi_twt_add_dialog_params params = { 0 };
+ u8 buf[128] = {0};
+ int ret;
+
+ 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 = ath11k_wmi_send_twt_add_dialog_cmd(arvif->ar, ¶ms);
+
+ return ret ? ret : count;
+}
+
+static ssize_t ath11k_write_twt_del_dialog(struct file *file,
+ const char __user *ubuf,
+ size_t count, loff_t *ppos)
+{
+ struct ath11k_vif *arvif = file->private_data;
+ struct wmi_twt_del_dialog_params params = { 0 };
+ u8 buf[64] = {0};
+ int ret;
+
+ 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 = ath11k_wmi_send_twt_del_dialog_cmd(arvif->ar, ¶ms);
+
+ return ret ? ret : count;
+}
+
+static ssize_t ath11k_write_twt_pause_dialog(struct file *file,
+ const char __user *ubuf,
+ size_t count, loff_t *ppos)
+{
+ struct ath11k_vif *arvif = file->private_data;
+ struct wmi_twt_pause_dialog_params params = { 0 };
+ u8 buf[64] = {0};
+ int ret;
+
+ 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 = ath11k_wmi_send_twt_pause_dialog_cmd(arvif->ar, ¶ms);
+
+ return ret ? ret : count;
+}
+
+static ssize_t ath11k_write_twt_resume_dialog(struct file *file,
+ const char __user *ubuf,
+ size_t count, loff_t *ppos)
+{
+ struct ath11k_vif *arvif = file->private_data;
+ struct wmi_twt_resume_dialog_params params = { 0 };
+ u8 buf[64] = {0};
+ int ret;
+
+ 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 = ath11k_wmi_send_twt_resume_dialog_cmd(arvif->ar, ¶ms);
+
+ return ret ? ret : count;
+}
+
+static const struct file_operations ath11k_fops_twt_add_dialog = {
+ .write = ath11k_write_twt_add_dialog,
+ .open = simple_open
+};
+
+static const struct file_operations ath11k_fops_twt_del_dialog = {
+ .write = ath11k_write_twt_del_dialog,
+ .open = simple_open
+};
+
+static const struct file_operations ath11k_fops_twt_pause_dialog = {
+ .write = ath11k_write_twt_pause_dialog,
+ .open = simple_open
+};
+
+static const struct file_operations ath11k_fops_twt_resume_dialog = {
+ .write = ath11k_write_twt_resume_dialog,
+ .open = simple_open
+};
+
+void ath11k_debugfs_twt(struct ath11k_vif *arvif, bool enable)
+{
+ if (!enable && arvif->debugfs_twt) {
+ debugfs_remove_recursive(arvif->debugfs_twt);
+ arvif->debugfs_twt = NULL;
+ return;
+ }
+
+ if (arvif->debugfs_twt)
+ return;
+
+ arvif->debugfs_twt = debugfs_create_dir("twt", arvif->vif->debugfs_dir);
+ if (IS_ERR_OR_NULL(arvif->debugfs_twt)) {
+ ath11k_warn(arvif->ar->ab,
+ "failed to create twt debugfs: %p\n",
+ arvif->debugfs_twt);
+ arvif->debugfs_twt = NULL;
+ return;
+ }
+
+ debugfs_create_file("add_dialog", 0200,
+ arvif->debugfs_twt, arvif,
+ &ath11k_fops_twt_add_dialog);
+
+ debugfs_create_file("del_dialog", 0200,
+ arvif->debugfs_twt, arvif,
+ &ath11k_fops_twt_del_dialog);
+
+ debugfs_create_file("pause_dialog", 0200,
+ arvif->debugfs_twt, arvif,
+ &ath11k_fops_twt_pause_dialog);
+
+ debugfs_create_file("resume_dialog", 0200,
+ arvif->debugfs_twt, arvif,
+ &ath11k_fops_twt_resume_dialog);
+}
+#endif
+
#ifdef CONFIG_ATH11K_DEBUGFS
static void ath11k_fw_stats_pdevs_free(struct list_head *head)
{
diff --git a/drivers/net/wireless/ath/ath11k/debug.h b/drivers/net/wireless/ath/ath11k/debug.h
index a317a7bdb9a2..805e30c07e14 100644
--- a/drivers/net/wireless/ath/ath11k/debug.h
+++ b/drivers/net/wireless/ath/ath11k/debug.h
@@ -133,6 +133,14 @@ static inline void ath11k_dbg_dump(struct ath11k_base *ab,
}
#endif /* CONFIG_ATH11K_DEBUG */
+#ifdef CONFIG_MAC80211_DEBUGFS
+void ath11k_debugfs_twt(struct ath11k_vif *arvif, bool enable);
+#else
+static inline void ath11k_debugfs_twt(struct ath11k_vif *arvif, bool enable)
+{
+}
+#endif
+
#ifdef CONFIG_ATH11K_DEBUGFS
int ath11k_debug_soc_create(struct ath11k_base *ab);
void ath11k_debug_soc_destroy(struct ath11k_base *ab);
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index a2c8a52b8621..6a8c1c3b8da2 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -1920,6 +1920,8 @@ static void ath11k_mac_op_bss_info_changed(struct ieee80211_hw *hw,
ath11k_wmi_send_twt_enable_cmd(ar, ar->pdev_idx);
else
ath11k_wmi_send_twt_disable_cmd(ar, ar->pdev_idx);
+ if (vif->type == NL80211_IFTYPE_AP)
+ ath11k_debugfs_twt(arvif, info->twt_requester);
}
if (changed & BSS_CHANGED_HE_OBSS_PD)
@@ -4217,6 +4219,8 @@ static void ath11k_mac_op_remove_interface(struct ieee80211_hw *hw,
/* TODO: recal traffic pause state based on the available vdevs */
+ debugfs_remove_recursive(arvif->debugfs_twt);
+ arvif->debugfs_twt = NULL;
mutex_unlock(&ar->conf_mutex);
}
--
2.20.1
next prev parent reply other threads:[~2019-12-13 20:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-13 15:38 [PATCH V3 0/9] ath11k: resend pending patches John Crispin
2019-12-13 15:38 ` [PATCH V3 1/9] ath11k: add wmi helper for turning STA PS on/off John Crispin
2019-12-18 17:28 ` Kalle Valo
2019-12-13 15:38 ` [PATCH V3 2/9] ath11k: disable PS for STA interfaces by default upon bringup John Crispin
2019-12-13 15:38 ` [PATCH V3 3/9] ath11k: drop memset when setting up a tx cmd desc John Crispin
2019-12-13 15:38 ` [PATCH V3 4/9] ath11k: rename ath11k_wmi_base instances from wmi_sc to wmi_ab John Crispin
2019-12-13 15:38 ` [PATCH V3 5/9] ath11k: add WMI calls to manually add/del/pause/resume TWT dialogs John Crispin
2019-12-18 11:14 ` Kalle Valo
2019-12-13 15:38 ` John Crispin [this message]
2019-12-18 11:32 ` [PATCH V3 6/9] ath11k: add debugfs for TWT debug calls Kalle Valo
2019-12-13 15:38 ` [PATCH V3 7/9] ath11k: move some tx_status parsing to debugfs code John Crispin
2019-12-18 11:38 ` Kalle Valo
2019-12-18 17:40 ` Kalle Valo
2019-12-13 15:38 ` [PATCH V3 8/9] ath11k: optimise ath11k_dp_tx_completion_handler John Crispin
2019-12-18 11:44 ` Kalle Valo
2019-12-13 15:38 ` [PATCH V3 9/9] ath11k: optimize ath11k_hal_tx_status_parse John Crispin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191213153839.12372-7-john@phrozen.org \
--to=john@phrozen.org \
--cc=ath11k@lists.infradead.org \
--cc=kvalo@codeaurora.org \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).