Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3269661pxb; Tue, 19 Jan 2021 19:26:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/d6oIYrdHNqYUf7gV+Q19HpQlQmXj1WVQdrAIXkL+7il+vWjXINoTm0ywf6Rd6Oiy2PY9 X-Received: by 2002:a05:6402:60a:: with SMTP id n10mr5609870edv.230.1611113162626; Tue, 19 Jan 2021 19:26:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611113162; cv=none; d=google.com; s=arc-20160816; b=0Zn474Bc4cMGw0R/88gMKcWjSuOdR+R/xVPVC4go7Lwf0KSPp89/2crmn9iiHHHFA/ 5ZTHc+F+btpsYdmYmAyDL5WQ8y1ca7EGj1Ot3mcUGZw/a/pgRNPNmRdekCusQXQuBsIj +VQjq5x8zRJFgbFv/jAkIJJtx+HaQbZoQqS7y83ERfuevIO3ry0Kpp00CrdMMTlW3iIg xeFA3FYsmrOKBiR3F9if6P1SBHmR9lM2ifnKzTcMV1qLTUkqxM3JCaz7fCRvbxgtefs3 BqXdK+MTcrHu24oMut4dPBREXZJwzS1cpBJ6JzG5cu4Euu/Xt35xnkZhqMWSiXQvNjap 8Idw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:sender:dkim-signature; bh=zZhbbgN1aNaYMatzWLZZmW6596lnCtgrp5FcvjFMtQA=; b=GHg4E9luRjzft/bC8yEHghBQ17wq52JfP4PoUgZ10ZdiyZ9+rAT9MN8hP6lrTG2Ev9 l803Cj3/z4Tet/MDKkT0evdsWKuVOwZ39GMALE1r2Xu1hUufjZutSHrPKLHg1uC4NmmK Eg8f7IRH0P3xBxW7tsqTB6kbR/F5y+db+xSyHHsgMP4xz9guob3d6MO1qBu+wf5iZk4d v9GAFtSWke4hLqsnagU90v+9Sf8KTat9lYCXMecrqkfLHP4lhzONRdJCAjJ+TIi32GjP joSW96qZk/7q0kEqRHnTVVF7Eufdp7ewNsSFMhH9xi3gx2x2bo9i2aLu0y261tOqtbzx mFBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=Q82LyI8G; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jj17si258783ejc.372.2021.01.19.19.25.34; Tue, 19 Jan 2021 19:26:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=Q82LyI8G; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729858AbhATDXL (ORCPT + 99 others); Tue, 19 Jan 2021 22:23:11 -0500 Received: from m42-8.mailgun.net ([69.72.42.8]:30603 "EHLO m42-8.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728488AbhATCcO (ORCPT ); Tue, 19 Jan 2021 21:32:14 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1611109902; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=zZhbbgN1aNaYMatzWLZZmW6596lnCtgrp5FcvjFMtQA=; b=Q82LyI8G7DdeLZH5AcxXxcJsIb7YlzuseID57GEYVcGrC90OyeDcz62+5WZPJva8frE0PX72 0HGWSZWGXmXdKuaSDG76NRiDEmi6/W3k+jVD7t1QV6vWxmZmJ4SEoqOnXy2zRj48CT1P7mUy dg422MyfdP24rOU57CpZlLAuOn8= X-Mailgun-Sending-Ip: 69.72.42.8 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n03.prod.us-west-2.postgun.com with SMTP id 600795e17086580d32fcdfd1 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 20 Jan 2021 02:30:57 GMT Sender: alokad=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id B07DEC43462; Wed, 20 Jan 2021 02:30:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from alokad-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: alokad) by smtp.codeaurora.org (Postfix) with ESMTPSA id 93C6FC433C6; Wed, 20 Jan 2021 02:30:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 93C6FC433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=alokad@codeaurora.org From: Aloka Dixit To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, John Crispin , Aloka Dixit Subject: [PATCH V4 2/2] ath11k: add debugfs for TWT debug calls Date: Tue, 19 Jan 2021 18:30:48 -0800 Message-Id: <20210120023048.5016-3-alokad@codeaurora.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20210120023048.5016-1-alokad@codeaurora.org> References: <20210120023048.5016-1-alokad@codeaurora.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: John Crispin 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 Signed-off-by: Aloka Dixit --- Changes in V3 * Resolved compilation warnings * Rebased to latest git tree. Changes in V2 * add a better patch description drivers/net/wireless/ath/ath11k/core.h | 1 + drivers/net/wireless/ath/ath11k/debug.c | 199 ++++++++++++++++++++++++ drivers/net/wireless/ath/ath11k/debug.h | 8 + drivers/net/wireless/ath/ath11k/mac.c | 5 + 4 files changed, 213 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index 9db375b193de..dfb589978b97 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -239,6 +239,7 @@ struct ath11k_vif { bool rsnie_present; bool wpaie_present; struct ieee80211_chanctx_conf chanctx; + 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 c86de95fbdc5..a3db2bcef137 100644 --- a/drivers/net/wireless/ath/ath11k/debug.c +++ b/drivers/net/wireless/ath/ath11k/debug.c @@ -104,3 +104,202 @@ void ath11k_dbg_dump(struct ath11k_base *ab, EXPORT_SYMBOL(ath11k_dbg_dump); #endif /* CONFIG_ATH11K_DEBUG */ + +#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 diff --git a/drivers/net/wireless/ath/ath11k/debug.h b/drivers/net/wireless/ath/ath11k/debug.h index 659a275e2eb3..91e40bfdb5e7 100644 --- a/drivers/net/wireless/ath/ath11k/debug.h +++ b/drivers/net/wireless/ath/ath11k/debug.h @@ -64,4 +64,12 @@ do { \ __ath11k_dbg(ar, dbg_mask, fmt, ##__VA_ARGS__); \ } while (0) +#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 + #endif /* _ATH11K_DEBUG_H_ */ diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index c1608f64ea95..564cdf7a5331 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -2111,6 +2111,8 @@ static void ath11k_mac_op_bss_info_changed(struct ieee80211_hw *hw, ath11k_wmi_send_twt_enable_cmd(ar, ar->pdev->pdev_id); else ath11k_wmi_send_twt_disable_cmd(ar, ar->pdev->pdev_id); + if (vif->type == NL80211_IFTYPE_AP) + ath11k_debugfs_twt(arvif, info->twt_requester); } if (changed & BSS_CHANGED_HE_OBSS_PD) @@ -4735,6 +4737,9 @@ 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.25.0