@@ -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 {
@@ -104,6 +104,203 @@ 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)
{
@@ -133,6 +133,15 @@ 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);
@@ -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);
}
@@ -236,22 +236,22 @@ static int ath11k_wmi_cmd_send_nowait(struct ath11k_pdev_wmi *wmi, struct sk_buf
int ath11k_wmi_cmd_send(struct ath11k_pdev_wmi *wmi, struct sk_buff *skb,
u32 cmd_id)
{
- struct ath11k_wmi_base *wmi_sc = wmi->wmi_ab;
+ struct ath11k_wmi_base *wmi_ab = wmi->wmi_ab;
int ret = -EOPNOTSUPP;
might_sleep();
- wait_event_timeout(wmi_sc->tx_credits_wq, ({
+ wait_event_timeout(wmi_ab->tx_credits_wq, ({
ret = ath11k_wmi_cmd_send_nowait(wmi, skb, cmd_id);
- if (ret && test_bit(ATH11K_FLAG_CRASH_FLUSH, &wmi_sc->ab->dev_flags))
+ if (ret && test_bit(ATH11K_FLAG_CRASH_FLUSH, &wmi_ab->ab->dev_flags))
ret = -ESHUTDOWN;
(ret != -EAGAIN);
}), WMI_SEND_TIMEOUT_HZ);
if (ret == -EAGAIN)
- ath11k_warn(wmi_sc->ab, "wmi command %d timeout\n", cmd_id);
+ ath11k_warn(wmi_ab->ab, "wmi command %d timeout\n", cmd_id);
return ret;
}
@@ -505,10 +505,10 @@ static int ath11k_service_ready_event(struct ath11k_base *ab, struct sk_buff *sk
return 0;
}
-struct sk_buff *ath11k_wmi_alloc_skb(struct ath11k_wmi_base *wmi_sc, u32 len)
+struct sk_buff *ath11k_wmi_alloc_skb(struct ath11k_wmi_base *wmi_ab, u32 len)
{
struct sk_buff *skb;
- struct ath11k_base *ab = wmi_sc->ab;
+ struct ath11k_base *ab = wmi_ab->ab;
u32 round_len = roundup(len, 4);
skb = ath11k_htc_alloc_skb(ab, WMI_SKB_HEADROOM + round_len);
@@ -2587,14 +2587,14 @@ ath11k_wmi_send_twt_add_dialog_cmd(struct ath11k *ar,
struct wmi_twt_add_dialog_params *params)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
- struct ath11k_base *ab = wmi->wmi_sc->sc;
+ struct ath11k_base *ab = wmi->wmi_ab->ab;
struct wmi_twt_add_dialog_params_cmd *cmd;
struct sk_buff *skb;
int ret, len;
len = sizeof(*cmd);
- skb = ath11k_wmi_alloc_skb(wmi->wmi_sc, len);
+ skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
@@ -2634,14 +2634,14 @@ ath11k_wmi_send_twt_del_dialog_cmd(struct ath11k *ar,
struct wmi_twt_del_dialog_params *params)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
- struct ath11k_base *ab = wmi->wmi_sc->sc;
+ struct ath11k_base *ab = wmi->wmi_ab->ab;
struct wmi_twt_del_dialog_params_cmd *cmd;
struct sk_buff *skb;
int ret, len;
len = sizeof(*cmd);
- skb = ath11k_wmi_alloc_skb(wmi->wmi_sc, len);
+ skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
@@ -2668,14 +2668,14 @@ ath11k_wmi_send_twt_pause_dialog_cmd(struct ath11k *ar,
struct wmi_twt_pause_dialog_params *params)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
- struct ath11k_base *ab = wmi->wmi_sc->sc;
+ struct ath11k_base *ab = wmi->wmi_ab->ab;
struct wmi_twt_pause_dialog_params_cmd *cmd;
struct sk_buff *skb;
int ret, len;
len = sizeof(*cmd);
- skb = ath11k_wmi_alloc_skb(wmi->wmi_sc, len);
+ skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
@@ -2702,14 +2702,14 @@ ath11k_wmi_send_twt_resume_dialog_cmd(struct ath11k *ar,
struct wmi_twt_resume_dialog_params *params)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
- struct ath11k_base *ab = wmi->wmi_sc->sc;
+ struct ath11k_base *ab = wmi->wmi_ab->ab;
struct wmi_twt_resume_dialog_params_cmd *cmd;
struct sk_buff *skb;
int ret, len;
len = sizeof(*cmd);
- skb = ath11k_wmi_alloc_skb(wmi->wmi_sc, len);
+ skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
@@ -3008,7 +3008,7 @@ int ath11k_wmi_wait_for_unified_ready(struct ath11k_base *ab)
int ath11k_wmi_cmd_init(struct ath11k_base *ab)
{
- struct ath11k_wmi_base *wmi_sc = &ab->wmi_ab;
+ struct ath11k_wmi_base *wmi_ab = &ab->wmi_ab;
struct wmi_init_cmd_param init_param;
struct target_resource_config config;
@@ -3060,21 +3060,21 @@ int ath11k_wmi_cmd_init(struct ath11k_base *ab)
config.twt_ap_pdev_count = 2;
config.twt_ap_sta_count = 1000;
- memcpy(&wmi_sc->wlan_resource_config, &config, sizeof(config));
+ memcpy(&wmi_ab->wlan_resource_config, &config, sizeof(config));
- init_param.res_cfg = &wmi_sc->wlan_resource_config;
- init_param.num_mem_chunks = wmi_sc->num_mem_chunks;
- init_param.hw_mode_id = wmi_sc->preferred_hw_mode;
- init_param.mem_chunks = wmi_sc->mem_chunks;
+ init_param.res_cfg = &wmi_ab->wlan_resource_config;
+ init_param.num_mem_chunks = wmi_ab->num_mem_chunks;
+ init_param.hw_mode_id = wmi_ab->preferred_hw_mode;
+ init_param.mem_chunks = wmi_ab->mem_chunks;
- if (wmi_sc->preferred_hw_mode == WMI_HOST_HW_MODE_SINGLE)
+ if (wmi_ab->preferred_hw_mode == WMI_HOST_HW_MODE_SINGLE)
init_param.hw_mode_id = WMI_HOST_HW_MODE_MAX;
init_param.num_band_to_mac = ab->num_radios;
ath11k_fill_band_to_mac_param(ab, init_param.band_to_mac);
- return ath11k_init_cmd_send(&wmi_sc->wmi[0], &init_param);
+ return ath11k_init_cmd_send(&wmi_ab->wmi[0], &init_param);
}
static int ath11k_wmi_tlv_hw_mode_caps_parse(struct ath11k_base *soc,
These new debugfs files allow us to manually add/del/pause/resume TWT dialogs for test/debug purposes. Signed-off-by: John Crispin <john@phrozen.org> --- drivers/net/wireless/ath/ath11k/core.h | 1 + drivers/net/wireless/ath/ath11k/debug.c | 197 ++++++++++++++++++++++++ drivers/net/wireless/ath/ath11k/debug.h | 9 ++ drivers/net/wireless/ath/ath11k/mac.c | 4 + drivers/net/wireless/ath/ath11k/wmi.c | 44 +++--- 5 files changed, 233 insertions(+), 22 deletions(-)