From patchwork Wed May 10 16:25:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Chadd X-Patchwork-Id: 9720239 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 4C53260365 for ; Wed, 10 May 2017 16:26:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DC5520121 for ; Wed, 10 May 2017 16:26:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 328852860F; Wed, 10 May 2017 16:26:48 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B2E7320121 for ; Wed, 10 May 2017 16:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=fEoGZT7UEgpZBha7V3f/QzGJcjmihOvn5LRt1Etfn0Q=; b=ceF 6XuLQf4nBoAZH/ePB7eNNl7faF9TTji+98XCoI+lLrVSVyPcikiFT2CckcqJkvwITjMdYj/n8TUe1 Z3kHzITHKzl1xM5xwHRUCBV1f/lCYFZVctExpNj5W3JZhxFW6stifiurE9dLC8aJCUxgOWG4H+mPM R6sNBHj7fhuTzGxY7u51vkQp1p6yiW3A8ogJGqAPipY+0crml2cNWxY2NTblehyFK6Ivbo8VlrxA8 lq5TQINsnlqRJLe83NIE6U0bTlKvDAV1uhXytTGZe+XtQJmWKR3DNwVbwxyGfVIgaoRMrmEMlKGrZ A3+b3odiTaJscoJVH5d1G7rIzufrArw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d8URk-0000tZ-Gs; Wed, 10 May 2017 16:26:40 +0000 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d8URh-0000sP-5v for ath10k@lists.infradead.org; Wed, 10 May 2017 16:26:38 +0000 Received: by mail-pf0-x243.google.com with SMTP id v14so63691pfd.3 for ; Wed, 10 May 2017 09:26:16 -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; bh=t8KUsf3Ap8yblvF5FzecCpXj5zz+bVbdAn9rTXFQeZ0=; b=jpT8qRfmlNIWBzgVb9q/yFlNyr3UzdFXFeAHpCd4ssOcxpdOEPbQVSfOI+boVm1I0t cyS1J2cYyG0MbFEANTZghX27EYdse8e/IuEZjVOYoR/Q8Qi6o8uBvPcsjM8CwACJKNEN a1hAbyE0vA5LuuL8CRyWsaG4nAfTPE1YrgSpy1u9A8ML2jCVldmCHxvVRbu9rQf3QzMH mpHYtrEOuZEfxqf/JqPm0Hy1PQFMqVB4IbGhOvHD/lRVaVTJ9uRXOVg7OgmeyHo75Jmc kbMHUWNCwTIj3bkQUdWBjcJc4tbDmIKuibvex18mWDOTIOwncQJSA9ay5moq/pta2g36 pVag== 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; bh=t8KUsf3Ap8yblvF5FzecCpXj5zz+bVbdAn9rTXFQeZ0=; b=nvkZFOS5wG3NsFZ3sePUJ/thKJhcga1p2zB8SF0kN/wPZTxicqCiPBkRaFbN0ZylDW rakHSFGXhMyEZ5ODmMbmSpilShas34SlUCBK6VBAxA/m5QGZV3HiDBBOn9BnScOGInYE IPK1qhskoDLNNLcmYs+5orPAWOsmRCmNphvUD7zdRN3LqRWq3eSEa5r4QUu3UYBTFKnt pu3UT5vks12p4uRc5QYhm2tlFYf38S3uQ2spsx25iZE1REdnkBXfCmv8123bDE4WJMs5 4+wH65J8QgL1mYMpbaZTc6Vru+xRhw8kI0TEqvGFXiiJcDASN4t3masan4a1YAG8/gGd qJ2A== X-Gm-Message-State: AODbwcCtui9FNshW9QwGf5TGl2vVb8gtWY5SrU2if7wgGuGE8PK2A0h5 2acz+pYxv5ov0TYFXyk= X-Received: by 10.84.254.2 with SMTP id b2mr2296669plm.185.1494433576199; Wed, 10 May 2017 09:26:16 -0700 (PDT) Received: from localhost.localdomain (c-50-184-113-23.hsd1.ca.comcast.net. [50.184.113.23]) by smtp.gmail.com with ESMTPSA id g71sm6566958pfc.41.2017.05.10.09.26.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 May 2017 09:26:15 -0700 (PDT) From: Adrian Chadd To: Kalle Valo , ath10k@lists.infradead.org, linux-wireless@vger.kernel.org Subject: [PATCH] ath10k: add configurable debugging. Date: Wed, 10 May 2017 09:25:46 -0700 Message-Id: <20170510162546.15439-1-adrian@freebsd.org> X-Mailer: git-send-email 2.12.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170510_092637_248688_DB8B1A30 X-CRM114-Status: GOOD ( 13.86 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Adrian Chadd MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This adds a few configurable debugging options: * driver debugging and tracing is now configurable per device * driver debugging and tracing is now configurable at runtime * the debugging / tracing is not run at all (besides a mask check) unless the specific debugging bitmap field is configured. Signed-off-by: Adrian Chadd --- drivers/net/wireless/ath/ath10k/core.c | 2 + drivers/net/wireless/ath/ath10k/core.h | 2 + drivers/net/wireless/ath/ath10k/debug.c | 101 ++++++++++++++++++++++++++++---- drivers/net/wireless/ath/ath10k/debug.h | 44 +++++++++----- 4 files changed, 125 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index eea111d704c5..fcb068cb0248 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev, ar->hw_rev = hw_rev; ar->hif.ops = hif_ops; ar->hif.bus = bus; + ar->debug_mask = ath10k_debug_mask; + ar->trace_debug_mask = ath10k_debug_mask; switch (hw_rev) { case ATH10K_HW_QCA988X: diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index 8fc08a5043db..07e392a377d0 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -762,6 +762,8 @@ struct ath10k { struct device *dev; u8 mac_addr[ETH_ALEN]; + u32 debug_mask; + u32 trace_debug_mask; enum ath10k_hw_rev hw_rev; u16 dev_id; u32 chip_id; diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c index 389fcb7a9fd0..017360a26b40 100644 --- a/drivers/net/wireless/ath/ath10k/debug.c +++ b/drivers/net/wireless/ath/ath10k/debug.c @@ -2418,6 +2418,79 @@ int ath10k_debug_create(struct ath10k *ar) return 0; } +#ifdef CONFIG_ATH10K_DEBUGFS +static ssize_t ath10k_write_debug_mask(struct file *file, + const char __user *ubuf, + size_t count, loff_t *ppos) +{ + struct ath10k *ar = file->private_data; + int ret; + u32 val; + + if (kstrtou32_from_user(ubuf, count, 0, &val)) + return -EINVAL; + + ar->debug_mask = val; + ret = count; + + return ret; +} + +static ssize_t ath10k_read_debug_mask(struct file *file, char __user *ubuf, + size_t count, loff_t *ppos) +{ + char buf[32]; + struct ath10k *ar = file->private_data; + int len = 0; + + len = scnprintf(buf, sizeof(buf) - len, "0x%x\n", ar->debug_mask); + return simple_read_from_buffer(ubuf, count, ppos, buf, len); +} + +static const struct file_operations fops_debug_mask = { + .read = ath10k_read_debug_mask, + .write = ath10k_write_debug_mask, + .open = simple_open +}; + +static ssize_t ath10k_write_trace_debug_mask(struct file *file, + const char __user *ubuf, + size_t count, loff_t *ppos) +{ + struct ath10k *ar = file->private_data; + int ret; + u32 val; + + if (kstrtou32_from_user(ubuf, count, 0, &val)) + return -EINVAL; + + ar->trace_debug_mask = val; + ret = count; + + return ret; +} + +static ssize_t ath10k_read_trace_debug_mask(struct file *file, + char __user *ubuf, + size_t count, loff_t *ppos) +{ + char buf[32]; + struct ath10k *ar = file->private_data; + int len = 0; + + len = scnprintf(buf, sizeof(buf) - len, "0x%x\n", + ar->trace_debug_mask); + return simple_read_from_buffer(ubuf, count, ppos, buf, len); +} + +static const struct file_operations fops_trace_debug_mask = { + .read = ath10k_read_trace_debug_mask, + .write = ath10k_write_trace_debug_mask, + .open = simple_open +}; +#endif /* CONFIG_ATH10K_DEBUGFS */ + + void ath10k_debug_destroy(struct ath10k *ar) { vfree(ar->debug.fw_crash_data); @@ -2448,6 +2521,13 @@ int ath10k_debug_register(struct ath10k *ar) init_completion(&ar->debug.tpc_complete); init_completion(&ar->debug.fw_stats_complete); +#ifdef CONFIG_ATH10K_DEBUG + debugfs_create_file("debug", S_IRUSR, ar->debug.debugfs_phy, ar, + &fops_debug_mask); + debugfs_create_file("trace_debug", S_IRUSR, ar->debug.debugfs_phy, ar, + &fops_trace_debug_mask); +#endif + debugfs_create_file("fw_stats", 0400, ar->debug.debugfs_phy, ar, &fops_fw_stats); @@ -2536,7 +2616,7 @@ void ath10k_debug_unregister(struct ath10k *ar) #endif /* CONFIG_ATH10K_DEBUGFS */ #ifdef CONFIG_ATH10K_DEBUG -void ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask, +void _ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask, const char *fmt, ...) { struct va_format vaf; @@ -2547,16 +2627,16 @@ void ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask, vaf.fmt = fmt; vaf.va = &args; - if (ath10k_debug_mask & mask) + if (ar->debug_mask & mask) dev_printk(KERN_DEBUG, ar->dev, "%pV", &vaf); - - trace_ath10k_log_dbg(ar, mask, &vaf); + if (ar->trace_debug_mask & mask) + trace_ath10k_log_dbg(ar, mask, &vaf); va_end(args); } -EXPORT_SYMBOL(ath10k_dbg); +EXPORT_SYMBOL(_ath10k_dbg); -void ath10k_dbg_dump(struct ath10k *ar, +void _ath10k_dbg_dump(struct ath10k *ar, enum ath10k_debug_mask mask, const char *msg, const char *prefix, const void *buf, size_t len) @@ -2565,7 +2645,7 @@ void ath10k_dbg_dump(struct ath10k *ar, size_t linebuflen; const void *ptr; - if (ath10k_debug_mask & mask) { + if (ar->debug_mask & mask) { if (msg) ath10k_dbg(ar, mask, "%s\n", msg); @@ -2584,9 +2664,10 @@ void ath10k_dbg_dump(struct ath10k *ar, } /* tracing code doesn't like null strings :/ */ - trace_ath10k_log_dbg_dump(ar, msg ? msg : "", prefix ? prefix : "", - buf, len); + if (ar->trace_debug_mask & mask) + trace_ath10k_log_dbg_dump(ar, msg ? msg : "", prefix ? prefix : "", + buf, len); } -EXPORT_SYMBOL(ath10k_dbg_dump); +EXPORT_SYMBOL(_ath10k_dbg_dump); #endif /* CONFIG_ATH10K_DEBUG */ diff --git a/drivers/net/wireless/ath/ath10k/debug.h b/drivers/net/wireless/ath/ath10k/debug.h index 257d10985c6e..7bd461927029 100644 --- a/drivers/net/wireless/ath/ath10k/debug.h +++ b/drivers/net/wireless/ath/ath10k/debug.h @@ -200,27 +200,43 @@ void ath10k_sta_update_rx_duration(struct ath10k *ar, #endif /* CONFIG_MAC80211_DEBUGFS */ #ifdef CONFIG_ATH10K_DEBUG -__printf(3, 4) void ath10k_dbg(struct ath10k *ar, +static inline int +_ath10k_do_dbg(struct ath10k *ar, enum ath10k_debug_mask mask) +{ + if (ar->trace_debug_mask & mask) + return (1); + if (ar->debug_mask & mask) + return (1); + return (0); +} + +void _ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask, const char *fmt, ...); -void ath10k_dbg_dump(struct ath10k *ar, + +void _ath10k_dbg_dump(struct ath10k *ar, enum ath10k_debug_mask mask, const char *msg, const char *prefix, const void *buf, size_t len); + +#define ath10k_dbg(ar, mask, ...) \ + do { \ + if (_ath10k_do_dbg(ar, mask)) { \ + _ath10k_dbg((ar), (mask), __VA_ARGS__); \ + }; \ + } while (0) + +#define ath10k_dbg_dump(ar, mask, msg, pfx, buf, len) \ + do { \ + if (_ath10k_do_dbg(ar, mask)) { \ + _ath10k_dbg_dump((ar), (mask), (msg), (pfx), (buf), (len)); \ + }; \ + } while (0) + #else /* CONFIG_ATH10K_DEBUG */ -static inline int ath10k_dbg(struct ath10k *ar, - enum ath10k_debug_mask dbg_mask, - const char *fmt, ...) -{ - return 0; -} +#define ath10k_dbg(ar, mask, fmt, ...) +#define ath10k_dbg_dump(ar, mask, msg, pfx, buf, len) -static inline void ath10k_dbg_dump(struct ath10k *ar, - enum ath10k_debug_mask mask, - const char *msg, const char *prefix, - const void *buf, size_t len) -{ -} #endif /* CONFIG_ATH10K_DEBUG */ #endif /* _DEBUG_H_ */