From patchwork Fri Jul 21 04:24:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 9856037 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 225B0601C0 for ; Fri, 21 Jul 2017 04:25:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09DE128706 for ; Fri, 21 Jul 2017 04:25:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2F3328734; Fri, 21 Jul 2017 04:25:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEE9828744 for ; Fri, 21 Jul 2017 04:25:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750861AbdGUEZB (ORCPT ); Fri, 21 Jul 2017 00:25:01 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:36306 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750818AbdGUEY6 (ORCPT ); Fri, 21 Jul 2017 00:24:58 -0400 Received: by mail-oi0-f65.google.com with SMTP id c135so3403665oih.3 for ; Thu, 20 Jul 2017 21:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=0bo81jzPgPJ/6FSygeJ40TLCWIP5wBod1nkgDYxYmrs=; b=CrjiNOCwFqjaC6eA97e9AwdaU2c5MTeqrPxaMemp4LoRrzxZeS0/6xjkBs8XPE3brb mplgWWoQMrbHm3VEypeEGC0js9Y88wQuuZCDrft5O1eHLlpkcD01I0M/xAtqZMlkJtrO kfCDO1FL6x3iQ9TTmnnu+THOOOoYi9N4uLYgy4wGwfr/Cnf/KMQCt4Cbl+OceWSY1UwG A+PA1CjWHTr0CmV2MNzmHWJljJnHOyvmD0eEfjL9kJVLENGjb5YB60wFWTzeNijuxjd+ 6fiVhwwl6B8QSEImRWWYU/eU/C6tglVS4cNdd8ksQ+lr1QGTSqND3B0Ef7XP5nwk3OkB qqJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=0bo81jzPgPJ/6FSygeJ40TLCWIP5wBod1nkgDYxYmrs=; b=L2do/xoxL0GLyoeR24NorW1ysCjMO62+iq0uYQX1t466R0/gUhlsdRIJ7L8QxqEeUW NQwAttrJ61mEWZyxcK8m97DnMB+bYpgoNLbKPY1MPfZN+XU1bu+6GMKXufnhsix6GUGa lm+DXl68mJTtSA57T5p52/kYwRXBpRV1V6YISzBUs5D0h7HjCoDHC7DK4oSTVFmuhAI6 mx7E6JIIXJfFGv+IkwX+WfLahl45gvxRfN/EU1VHJCTIFJiVoI8fM3qG1/DjP1LgYPZf G9gwOV/i0nkjUjjFgy45WyGOtbuY2Ia4jmZTfEbd31LngGafsyyfqZtxj01+qe/lyjQF e4jA== X-Gm-Message-State: AIVw113aKLbfCoQH87ReY1qDP8n7h4Vs0kKCSmm8epzsk/dO7OHYW405 L9ZOoMFYtTVJiA== X-Received: by 10.202.245.7 with SMTP id t7mr971555oih.49.1500611098075; Thu, 20 Jul 2017 21:24:58 -0700 (PDT) Received: from linux-4v1g.suse (cpe-24-31-249-175.kc.res.rr.com. [24.31.249.175]) by smtp.gmail.com with ESMTPSA id s69sm1832947ois.15.2017.07.20.21.24.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Jul 2017 21:24:57 -0700 (PDT) From: Larry Finger To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, Ping-Ke Shih Subject: [PATCH 10/10] rtlwifi: Add phydm debug cmd to debugfs Date: Thu, 20 Jul 2017 23:24:40 -0500 Message-Id: <20170721042440.15839-11-Larry.Finger@lwfinger.net> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170721042440.15839-1-Larry.Finger@lwfinger.net> References: <20170721042440.15839-1-Larry.Finger@lwfinger.net> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ping-Ke Shih Add an entry to set phydm debug parameters Signed-off-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtlwifi/debug.c | 77 ++++++++++++++++++++++++++++ drivers/net/wireless/realtek/rtlwifi/wifi.h | 2 + 2 files changed, 79 insertions(+) diff --git a/drivers/net/wireless/realtek/rtlwifi/debug.c b/drivers/net/wireless/realtek/rtlwifi/debug.c index b44d4293b89e..1b8c1a3b666f 100644 --- a/drivers/net/wireless/realtek/rtlwifi/debug.c +++ b/drivers/net/wireless/realtek/rtlwifi/debug.c @@ -412,6 +412,75 @@ static const struct file_operations file_ops_write_reg = { .release = rtl_debugfs_close, }; +static ssize_t rtl_debugfs_phydm_cmd(struct file *filp, + const char __user *buffer, + size_t count, loff_t *loff) +{ + struct rtl_debgufs_priv *debugfs_priv = filp->private_data; + struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv; + + char tmp[64]; + + if (!rtlpriv->dbg.msg_buf) + return -ENOMEM; + + if (!rtlpriv->phydm.ops) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + tmp[count] = '\0'; + + rtlpriv->phydm.ops->phydm_debug_cmd(rtlpriv, tmp, count, + rtlpriv->dbg.msg_buf, + 80 * 25); + } + + return count; +} + +static int rtl_debug_get_phydm_cmd(struct seq_file *m, void *v) +{ + struct rtl_debgufs_priv *debugfs_priv = m->private; + struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv; + + if (rtlpriv->dbg.msg_buf) + seq_puts(m, rtlpriv->dbg.msg_buf); + + return 0; +} + +static int rtl_debugfs_open_rw(struct inode *inode, struct file *filp) +{ + if (filp->f_mode & FMODE_READ) + single_open(filp, rtl_debug_get_phydm_cmd, inode->i_private); + else + filp->private_data = inode->i_private; + + return 0; +} + +static int rtl_debugfs_close_rw(struct inode *inode, struct file *filp) +{ + if (filp->f_mode == FMODE_READ) + seq_release(inode, filp); + + return 0; +} + +static struct rtl_debgufs_priv rtl_debug_priv_phydm_cmd = { + .cb = NULL, + .cb_data = 0, +}; + +static const struct file_operations file_ops_phydm_cmd = { + .owner = THIS_MODULE, + .open = rtl_debugfs_open_rw, + .release = rtl_debugfs_close_rw, + .read = seq_read, + .llseek = seq_lseek, + .write = rtl_debugfs_phydm_cmd, +}; + #define RTL_DEBUGFS_ADD_CORE(name, mode, fopname) \ do { \ rtl_debug_priv_ ##name.rtlpriv = rtlpriv; \ @@ -427,6 +496,8 @@ static const struct file_operations file_ops_write_reg = { RTL_DEBUGFS_ADD_CORE(name, S_IFREG | 0444, common) #define RTL_DEBUGFS_ADD_W(name) \ RTL_DEBUGFS_ADD_CORE(name, S_IFREG | 0222, write_reg) +#define RTL_DEBUGFS_ADD_RW(name) \ + RTL_DEBUGFS_ADD_CORE(name, S_IFREG | 0666, phydm_cmd) void rtl_debug_add_one(struct ieee80211_hw *hw) { @@ -434,6 +505,8 @@ void rtl_debug_add_one(struct ieee80211_hw *hw) struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); struct dentry *parent; + rtlpriv->dbg.msg_buf = vzalloc(80 * 25); + snprintf(rtlpriv->dbg.debugfs_name, 18, "%02x-%02x-%02x-%02x-%02x-%02x", rtlefuse->dev_addr[0], rtlefuse->dev_addr[1], rtlefuse->dev_addr[2], rtlefuse->dev_addr[3], @@ -491,6 +564,8 @@ void rtl_debug_add_one(struct ieee80211_hw *hw) RTL_DEBUGFS_ADD(btcoex); RTL_DEBUGFS_ADD_W(write_reg); + + RTL_DEBUGFS_ADD_RW(phydm_cmd); } EXPORT_SYMBOL_GPL(rtl_debug_add_one); @@ -500,6 +575,8 @@ void rtl_debug_remove_one(struct ieee80211_hw *hw) debugfs_remove_recursive(rtlpriv->dbg.debugfs_dir); rtlpriv->dbg.debugfs_dir = NULL; + + vfree(rtlpriv->dbg.msg_buf); } EXPORT_SYMBOL_GPL(rtl_debug_remove_one); diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h index 92ce00819d2c..416c6f3a1ff3 100644 --- a/drivers/net/wireless/realtek/rtlwifi/wifi.h +++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h @@ -2395,6 +2395,8 @@ struct rtl_debug { /* add for debug */ struct dentry *debugfs_dir; char debugfs_name[20]; + + char *msg_buf; }; #define MIMO_PS_STATIC 0