From: Kalle Valo <kvalo@codeaurora.org>
To: Aloka Dixit <alokad@codeaurora.org>
Cc: linux-wireless@vger.kernel.org, ath11k@lists.infradead.org,
John Crispin <john@phrozen.org>
Subject: Re: [PATCH V5 2/2] ath11k: add debugfs for TWT debug calls
Date: Tue, 09 Mar 2021 12:59:25 +0200 [thread overview]
Message-ID: <87o8fszj76.fsf@codeaurora.org> (raw)
In-Reply-To: <20210222192651.1782-3-alokad@codeaurora.org> (Aloka Dixit's message of "Mon, 22 Feb 2021 11:26:51 -0800")
Aloka Dixit <alokad@codeaurora.org> writes:
> From: John Crispin <john@phrozen.org>
>
> New debugfs files to manually add/delete/pause/resume TWT
> dialogs for test/debug purposes.
>
> The debugfs files expect the following parameters
> (1) 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
>
> (2) Delete dialog
> echo '<Peer_MAC> <Dialog_ID>' >
> /sys/kernel/debug/ieee80211/phyX/netdev:wlanX/twt/del_dialog
>
> (3) Pause dialog
> echo '<Peer_MAC> <Dialog_ID>' >
> /sys/kernel/debug/ieee80211/phyX/netdev:wlanX/twt/pause_dialog
>
> (4) 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: John Crispin <john@phrozen.org>
> Co-developed-by: Aloka Dixit <alokad@codeaurora.org>
> Signed-off-by: Aloka Dixit <alokad@codeaurora.org>
[...]
> --- a/drivers/net/wireless/ath/ath11k/debug.c
> +++ b/drivers/net/wireless/ath/ath11k/debug.c
> @@ -104,3 +104,227 @@ void ath11k_dbg_dump(struct ath11k_base *ab,
> EXPORT_SYMBOL(ath11k_dbg_dump);
>
> #endif /* CONFIG_ATH11K_DEBUG */
> +
> +#ifdef CONFIG_ATH11K_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;
> +
> + if (arvif->ar->twt_enabled == 0) {
> + ath11k_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 = ath11k_wmi_send_twt_add_dialog_cmd(arvif->ar, ¶ms);
> + if (ret)
> + return ret;
> +
> + return 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;
> +
> + if (arvif->ar->twt_enabled == 0) {
> + ath11k_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 = ath11k_wmi_send_twt_del_dialog_cmd(arvif->ar, ¶ms);
> + if (ret)
> + return ret;
> +
> + return 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;
> +
> + if (arvif->ar->twt_enabled == 0) {
> + ath11k_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 = ath11k_wmi_send_twt_pause_dialog_cmd(arvif->ar, ¶ms);
> + if (ret)
> + return ret;
> +
> + return 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;
> +
> + if (arvif->ar->twt_enabled == 0) {
> + ath11k_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 = ath11k_wmi_send_twt_resume_dialog_cmd(arvif->ar, ¶ms);
> + if (ret)
> + return ret;
> +
> + return 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_add_interface(struct ath11k_vif *arvif)
> +{
> + if (arvif->vif->type == NL80211_IFTYPE_AP && !arvif->debugfs_twt) {
> + 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);
> + }
> +}
> +
> +void ath11k_debugfs_remove_interface(struct ath11k_vif *arvif)
> +{
> + debugfs_remove_recursive(arvif->debugfs_twt);
> + arvif->debugfs_twt = NULL;
> +}
> +
> +#endif /* CONFIG_ATH11K_DEBUGFS */
Shouldn't these functions be in debugfs.c?
> diff --git a/drivers/net/wireless/ath/ath11k/debug.h b/drivers/net/wireless/ath/ath11k/debug.h
> index 659a275e2eb3..2b41cefb68b5 100644
> --- a/drivers/net/wireless/ath/ath11k/debug.h
> +++ b/drivers/net/wireless/ath/ath11k/debug.h
> @@ -64,4 +64,17 @@ do { \
> __ath11k_dbg(ar, dbg_mask, fmt, ##__VA_ARGS__); \
> } while (0)
>
> +#ifdef CONFIG_ATH11K_DEBUGFS
> +void ath11k_debugfs_add_interface(struct ath11k_vif *arvif);
> +void ath11k_debugfs_remove_interface(struct ath11k_vif *arvif);
> +#else /* CONFIG_ATH11K_DEBUGFS */
> +static inline void ath11k_debugfs_add_interface(struct ath11k_vif *arvif)
> +{
> +}
> +
> +static inline void ath11k_debugfs_remove_interface(struct ath11k_vif *arvif)
> +{
> +}
> +#endif /* CONFIG_ATH11K_DEBUGFS */
And these in debugfs.h?
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
prev parent reply other threads:[~2021-03-09 11:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 19:26 [PATCH V5 0/2] WMI and debugfs calls for TWT dialogs Aloka Dixit
2021-02-22 19:26 ` [PATCH V5 1/2] ath11k: add WMI calls to manually add/del/pause/resume " Aloka Dixit
2021-03-09 10:50 ` Kalle Valo
2021-03-09 10:57 ` Kalle Valo
[not found] ` <20210309105025.72246C43462@smtp.codeaurora.org>
2021-03-10 18:42 ` Aloka Dixit
2021-03-11 6:01 ` Kalle Valo
2021-02-22 19:26 ` [PATCH V5 2/2] ath11k: add debugfs for TWT debug calls Aloka Dixit
2021-03-09 10:59 ` Kalle Valo [this message]
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=87o8fszj76.fsf@codeaurora.org \
--to=kvalo@codeaurora.org \
--cc=alokad@codeaurora.org \
--cc=ath11k@lists.infradead.org \
--cc=john@phrozen.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).