Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1764163ybh; Thu, 16 Jul 2020 23:50:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9sIHmC08vTfTVJC2mRSSQqggT+4FiIU7KB1gtSNpwDqfMntaA6RWX9luuouoW+HGgW5gL X-Received: by 2002:a17:906:ca4e:: with SMTP id jx14mr7638736ejb.544.1594968647054; Thu, 16 Jul 2020 23:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594968647; cv=none; d=google.com; s=arc-20160816; b=gUeHCpD7nhH/3LrZEPko1Kq+t0IulNup5liyyRsJRH90/KRjjEXLsj+Oo84CuAUKSk f+MxThTdGLcyWfKB050wf1QENyN1yJjwaQ5WIXvWkKTESr1vB1VC1nZGae+kwIrhO/pG gwsvLp/1IFbiYd/h9fUd41299lWDNfkY5RRORT5d6Asd6oBTPY0fEW4Op0hh4AwyQmfz WOAwmWH4/9J84GInu6mHvfSUItpIgDomrB+IFJWJ/69AgF13WmdiG0BpEPE7LfOQHYEO OlD3GW6S3SMn20exOKWv+4vfWltdenqsTd1AaxP9TCBCrl68txDoSrHAnYOOjqSh1B8n H6SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:authenticated-by; bh=ZSc3fFl25htqFQQKoaU7ldmkVSRMzIgFr6iY43iW+8w=; b=u4yQRqMrJoNwxTyRXqJ3hgrfLaHOovX63WTJLrIydClVz0fnpCEisaf101zIfuaXBm nG1G9eAr1w0JfPQXZ1c+MvoJOy/Jk6R/rhuxCBdf/BBaYxCphNDWe68uhURu6a+iqnDK mZ5gPQpcdCwKBpU9MfVNw8iy98euO0mteCjbebHnfV3/HBVhaC/vfkVbkxqbuqsm1HPL tbnmyWBzIN/aKfg8P/xaT8xCWVsnFyOuObJlg6XLFi04X0Zeg1yALswcvvXugNcY58ee NVcjl2vZtypTkPBRsopCzFBHBY6QpiEBqbBzgqU+0Vwgd4dUbarGkq/3MIi9DWGM/6Bk +LJA== ARC-Authentication-Results: i=1; mx.google.com; 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 g10si4912013ejf.312.2020.07.16.23.50.08; Thu, 16 Jul 2020 23:50:46 -0700 (PDT) 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; 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 S1726907AbgGQGuF (ORCPT + 99 others); Fri, 17 Jul 2020 02:50:05 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:55023 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726817AbgGQGuF (ORCPT ); Fri, 17 Jul 2020 02:50:05 -0400 Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.69 with qID 06H6o0N01028960, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexmb06.realtek.com.tw[172.21.6.99]) by rtits2.realtek.com.tw (8.15.2/2.66/5.86) with ESMTPS id 06H6o0N01028960 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 17 Jul 2020 14:50:01 +0800 Received: from RTEXMB04.realtek.com.tw (172.21.6.97) by RTEXMB06.realtek.com.tw (172.21.6.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Fri, 17 Jul 2020 14:50:00 +0800 Received: from localhost.localdomain (172.21.68.128) by RTEXMB04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Fri, 17 Jul 2020 14:50:00 +0800 From: To: CC: Subject: [PATCH 7/7] rtw88: add h2c command in debugfs Date: Fri, 17 Jul 2020 14:49:37 +0800 Message-ID: <20200717064937.27966-8-yhchuang@realtek.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200717064937.27966-1-yhchuang@realtek.com> References: <20200717064937.27966-1-yhchuang@realtek.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.21.68.128] X-ClientProxiedBy: RTEXMB02.realtek.com.tw (172.21.6.95) To RTEXMB04.realtek.com.tw (172.21.6.97) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Tzu-En Huang It's very useful to send H2C command for debug usage. Add an entry for sending H2C command to firmware. usage example: echo 42,00,00,43,02,00,00,00 > /sys/kernel/debug/ieee80211/phyX/rtw88 Signed-off-by: Tzu-En Huang Signed-off-by: Yan-Hsuan Chuang --- drivers/net/wireless/realtek/rtw88/debug.c | 30 ++++++++++++++++++++++ drivers/net/wireless/realtek/rtw88/fw.c | 5 ++++ drivers/net/wireless/realtek/rtw88/fw.h | 2 ++ 3 files changed, 37 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wireless/realtek/rtw88/debug.c index 09f04feb8fe1..f769c982cc91 100644 --- a/drivers/net/wireless/realtek/rtw88/debug.c +++ b/drivers/net/wireless/realtek/rtw88/debug.c @@ -344,6 +344,31 @@ static ssize_t rtw_debugfs_set_write_reg(struct file *filp, return count; } +static ssize_t rtw_debugfs_set_h2c(struct file *filp, + const char __user *buffer, + size_t count, loff_t *loff) +{ + struct rtw_debugfs_priv *debugfs_priv = filp->private_data; + struct rtw_dev *rtwdev = debugfs_priv->rtwdev; + char tmp[32 + 1]; + u8 param[8]; + int num; + + rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3); + + num = sscanf(tmp, "%hhx,%hhx,%hhx,%hhx,%hhx,%hhx,%hhx,%hhx", + ¶m[0], ¶m[1], ¶m[2], ¶m[3], + ¶m[4], ¶m[5], ¶m[6], ¶m[7]); + if (num != 8) { + rtw_info(rtwdev, "invalid H2C command format for debug\n"); + return -EINVAL; + } + + rtw_fw_h2c_cmd_dbg(rtwdev, param); + + return count; +} + static ssize_t rtw_debugfs_set_rf_write(struct file *filp, const char __user *buffer, size_t count, loff_t *loff) @@ -808,6 +833,10 @@ static struct rtw_debugfs_priv rtw_debug_priv_write_reg = { .cb_write = rtw_debugfs_set_write_reg, }; +static struct rtw_debugfs_priv rtw_debug_priv_h2c = { + .cb_write = rtw_debugfs_set_h2c, +}; + static struct rtw_debugfs_priv rtw_debug_priv_rf_write = { .cb_write = rtw_debugfs_set_rf_write, }; @@ -877,6 +906,7 @@ void rtw_debugfs_init(struct rtw_dev *rtwdev) rtw_debugfs_add_r(phy_info); rtw_debugfs_add_r(coex_info); rtw_debugfs_add_rw(coex_enable); + rtw_debugfs_add_w(h2c); rtw_debugfs_add_r(mac_0); rtw_debugfs_add_r(mac_1); rtw_debugfs_add_r(mac_2); diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c index c922b4bb8d72..63b00bc19000 100644 --- a/drivers/net/wireless/realtek/rtw88/fw.c +++ b/drivers/net/wireless/realtek/rtw88/fw.c @@ -253,6 +253,11 @@ static void rtw_fw_send_h2c_command(struct rtw_dev *rtwdev, spin_unlock(&rtwdev->h2c.lock); } +void rtw_fw_h2c_cmd_dbg(struct rtw_dev *rtwdev, u8 *h2c) +{ + rtw_fw_send_h2c_command(rtwdev, h2c); +} + static void rtw_fw_send_h2c_packet(struct rtw_dev *rtwdev, u8 *h2c_pkt) { int ret; diff --git a/drivers/net/wireless/realtek/rtw88/fw.h b/drivers/net/wireless/realtek/rtw88/fw.h index 470e1809645a..686dcd3bbda6 100644 --- a/drivers/net/wireless/realtek/rtw88/fw.h +++ b/drivers/net/wireless/realtek/rtw88/fw.h @@ -563,4 +563,6 @@ void rtw_fw_set_nlo_info(struct rtw_dev *rtwdev, bool enable); void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev, struct cfg80211_ssid *ssid); void rtw_fw_channel_switch(struct rtw_dev *rtwdev, bool enable); +void rtw_fw_h2c_cmd_dbg(struct rtw_dev *rtwdev, u8 *h2c); + #endif -- 2.17.1