Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753634AbbHEPou (ORCPT ); Wed, 5 Aug 2015 11:44:50 -0400 Received: from mail-bl2on0102.outbound.protection.outlook.com ([65.55.169.102]:22944 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752411AbbHEPn5 (ORCPT ); Wed, 5 Aug 2015 11:43:57 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; From: Madalin Bucur To: CC: , , , , , , , , , Madalin Bucur Subject: [v2 8/9] dpaa_eth: add debugfs entries Date: Wed, 5 Aug 2015 18:41:28 +0300 Message-ID: <1438789289-16304-9-git-send-email-madalin.bucur@freescale.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1438789289-16304-1-git-send-email-madalin.bucur@freescale.com> References: <1438789289-16304-1-git-send-email-madalin.bucur@freescale.com> Reply-To: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD004;1:33XMQmG82v4n6wwIGBOJoTVD/nmhOkYjlclu94ixU2dmr+/iyjVBe1G19F9N9Mip/M7WCCqVRbvM18ZzakvemxbWBM09maU04nvM8rdMzd/t0JI5JZDzgDfI9tt3PAK5rfg05eKxiiI7Dnlv9GVFLdqjkI0WiCCG2FxFbaCPdJVPzJpp8hYte6c17RmAPKacL0/m7X8NKoZz0lIp0yPe7RPZFY38xeSKlc2afQuu1JzAFUNKKgJOfZfPjCgnQaXmcJBwBQ+VqH/ibKGv8cNdsAxmbnZYs6rfDMaBTO/zNYQcCwls6l9zj6etZeLQ5ycMfUNFXjfXpmH3H/Z6vEUj8w== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(50226001)(81156007)(19580395003)(36756003)(68736005)(19580405001)(77096005)(64706001)(4001540100001)(105606002)(97736004)(106466001)(5001830100001)(5001860100001)(5003940100001)(47776003)(104016003)(85426001)(229853001)(50986999)(76176999)(43066003)(2950100001)(62966003)(53806999)(48376002)(50466002)(110136002)(2351001)(77156002)(6806004)(107886002)(46102003)(189998001)(5001960100002)(33646002)(87936001)(86362001)(2004002)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR03MB507;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB507;2:UN7uIzr9Xo9PvK59848vXKOaidRvvN2q7k4U+5ystH+R95BSz1IHBRFve2aAHMYo4S4ko7BRlZ70czlYjmF7Vv2+BfEW0SRPZj/K4QesKS4aZaTVhNPedMndGMtlZ06x8zKikeNqaRgv4FhIgCTgiHvhtVRP8hhuZqmfa0RhDwY=;3:YUKOOxpxqLV8FnmuKwLAW4UuSoEhdFrCf3DNvK+IgSJ8cnwGXgE54NPHAgx6QgAv2hSWtBcABm6x9JIaFDOlt9J3Y3VLx7wIWrldmjvt5DozzUkArWPJ6LV7FFIkQ9t1Du2ZDlu2RJJnXnuGj2nURM1bTLhKHU7f9iXoKVYdgR707TZHu82kOCetToJGKS1kSr1m0lG4Dc4RtwMrAPKX2JpPd0UEzystA3IUQj8RkaM=;25:nS/YHMx+XrDUKI7SWegRz6F98DAiL2/P2vVkw1Nq/oio9nLeWjCRqYXux23tDhXgaJnkkeW4AxrDLyMgqq676cDf2eP5e7RY4Ql9bnsn8LZyfApvo12TjMp6yCOSbCRqyHSD7HQURYqsTzskBCI5dJo7IkT3ul8ExkDpr3/FBpDmYGZJ8grNXtQUviJthvXpc3nIoj8VtcMgd/xTcMUajxOl5nDQ2mIwYxFv/Qnf56SNf+6Q5vK4aNtqDEa5FhREyXsU7ewyCXN9MbQ6VBuhoA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB507; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB507;20:I7Yqkr60EkpvJGlDTzIzZ5C7EFI2LbrnkkyQfh8ntSBjiUvHq58SN0f5oDxVroyun2+qqBRA48Z22V5iCjUKqMcUevz0kbPJFPgnoJQWCWnRmL1ss3W/Q4K/Wf25FXyTP4gX7O/WqfU3KyZqktaZXf5YlUMSMZHwunZvPL5J8K+UagbBpn1RCm1PK2zXBKqciEOm8z2jmS85+RwyT1ZS3xWlltqjGJ0diRUS52lfiU9L8JJAuMH8kG7I/g8Mc18btPrcd9HdfqV3418oD9IynPXdQMWR1QgEYGwDlbJ+XY1AL0/oR2rlR4HORWf9cNcMA0H7WVVFtKIRC/9qh7l+rjjIZIj0UJIF82LRB135mcw=;4:6YyYLxtVCkzK7evt38vBGrzT/h+xW93FT70DAxejTL9Sb1nNqXAOTRhSHfQiay+T19S9t2M/Q0bvisAIta+za05VkBm66zYa3sYlyq6hrb0htEUtPbNKWwNLfPobL+8wYSOUxrOiTWGrXpWTAzoCIqV0KCUJdVgnc5G7x7SCXeDeT3KXoYcdWEvqPPag0UT66v7OnEASX/JiwmZxaW3yWeO9w+qJqB3TPMSlgREjaHHlbOHo9cmW9TuIIpISpTZEvp+Wsqd5rumHHbxz8S9O51WfmAjDP0Pae1MgJAnwJCA= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BY2PR03MB507;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB507; X-Forefront-PRVS: 06592CCE58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR03MB507;23:v9cUDQJ3JUmBOJ2JMjFfnhVMRQPpDAZv3kMqQiAXuu?= =?us-ascii?Q?oUCeo6FX3UmCbs6ZLQ9tgT09U09VjDDqth198cTxWT3AT3/K3dmhnkF7jQcc?= =?us-ascii?Q?Fb+N9wGcbVjrop32EOhJbrcqzUWMhkgFI6YrHbaVOxbSPvjHQjLLL1nWQ8yi?= =?us-ascii?Q?fGVphUGPZBKqgmhVZgnwcY9SDu73N4b/nr44s3kB5cWdCWZ0ZTtmqc98Iti5?= =?us-ascii?Q?T5gfvYXOPnBk5bWbUYZ7vX2T0BPOSCK2cQo+VJi+TZMzYmyKlgiBQNYkxeuJ?= =?us-ascii?Q?eRvIp1zdXaO20bHoIxCQ9UgA6pbbWRApXbjoSDxow58dV/7c5sJbYRu+IaJM?= =?us-ascii?Q?jJwkK9TaC1rUiV4rVfcKCrjnbUNtLoSdyN9FVlvZg0dPC8x4LqczXXIZC7VX?= =?us-ascii?Q?ecOfeqT4PUj0eAgnmhnr4Lr/UFuo+v4Qx04REw6xa9OwpqnfyYy3ntRjMtRd?= =?us-ascii?Q?1ZUxAqGa9SUIp+Z4FmcVZ64gdOXoEVV4wgMFT3uVjEn/YFUi4Kl2G7wlYA17?= =?us-ascii?Q?ezDmA22MXYWJEHVQmiJbPXXGG/OrwafSVI6BeXB36vB2H1Ink1wvD9AAtLPY?= =?us-ascii?Q?ECo20/0oEqHhW3hlp7PS80MOHMTzzHWUg8vNSYFwGfKMSihNDURpbIm5eTE/?= =?us-ascii?Q?i8xJtnSF4hexlBsm/sUb88R9D+Y9IlAy+ze3nvbunx6Fyaz9AWrE+Jn3vJ6Z?= =?us-ascii?Q?76PrKEU97571GuPhJ0NXUK9YWsjUyOa+o1rsYY6wYgtGkvlDE3sJwYbCgDfy?= =?us-ascii?Q?cfbdU/abkRlQlFhjiBE6g3fx+LCQx40z7lBqcl0LPolmz6iY+8vk/2U8czvJ?= =?us-ascii?Q?3+fc+msoIsYhg9c3SBIi4pEqqGa4cbUvUI2u8RuTXfSUNbWx8sDKB9qBrihu?= =?us-ascii?Q?b6iWp5LwLYDCIj5TVqbHNsrkD8a9ZhE+5bHvCfi497WxRhjCb9TtJ4hCj+ew?= =?us-ascii?Q?A/hx0TtoArEbvUpmv4+AaFO5ozuqjpWhAex9Tv4JWjrsFInDAYv5Hsm14cMt?= =?us-ascii?Q?kb1+jflMS3m7yBYyv2jVJ6AyUDuFaCTXWbQ7vucaVUOtLDpKN0EFI7B/1P9q?= =?us-ascii?Q?NeXilrPGCx0SgTcHacKI7+4Y7dDRJdv5eBN74N9kskrKpS5Rfftp1R7mv+iX?= =?us-ascii?Q?YGHkLTjkCrfAo9jpivZTLrvj+COmLY/uV82z5bGGSF3/PwWysu7ParzPNcUq?= =?us-ascii?Q?Es5eEjwg5tOHk=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB507;5:knYuIjUhSPnKQngFeczMunSh0mASsXxA05oUHvs/jYiEvzVeKshURNzIG/Xgsz0/br3dguGcWUaJTF1MDDgtu+HQ/7GJ+i4fd8tn8WM9r+MTvso8aEQ0v/fNPJ1DmhpeHFiqJrTfV6IOH5XTSkFdiQ==;24:fevSWb2ZkVV0xWyfXMVlDXL5RjBIIJdpQcFFybPkyY5AD/FuPcrGKP9s0uv0GaufYXGDftLZY845+sXwbW8N87+ypLI7Hv4hgEjT9f+F4CQ=;20:QEiHE2Fz/ZWm9NesPkLjs5aY72UioCA6YgY+ARTbu6IthZmUxW6vovOEER9GirfRP6jf3b57xsl7rZA3WNZbtQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2015 15:43:52.2268 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB507 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 16493 Lines: 454 Export per CPU counters through debugfs. Signed-off-by: Madalin Bucur --- drivers/net/ethernet/freescale/dpaa/Kconfig | 7 + drivers/net/ethernet/freescale/dpaa/Makefile | 3 + drivers/net/ethernet/freescale/dpaa/dpaa_debugfs.c | 272 +++++++++++++++++++++ drivers/net/ethernet/freescale/dpaa/dpaa_debugfs.h | 43 ++++ drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 11 + .../net/ethernet/freescale/dpaa/dpaa_eth_common.c | 17 ++ 6 files changed, 353 insertions(+) create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_debugfs.c create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_debugfs.h diff --git a/drivers/net/ethernet/freescale/dpaa/Kconfig b/drivers/net/ethernet/freescale/dpaa/Kconfig index 6147403..98c6328 100644 --- a/drivers/net/ethernet/freescale/dpaa/Kconfig +++ b/drivers/net/ethernet/freescale/dpaa/Kconfig @@ -53,4 +53,11 @@ config FSL_DPAA_INGRESS_CS_THRESHOLD The size in bytes of the ingress tail-drop threshold on FMan ports. Traffic piling up above this value will be rejected by QMan and discarded by FMan. +config FSL_DPAA_ETH_DEBUGFS + bool "DPAA Ethernet debugfs interface" + depends on DEBUG_FS + default y + ---help--- + This option compiles debugfs code for the DPAA Ethernet driver. + endif # FSL_DPAA_ETH diff --git a/drivers/net/ethernet/freescale/dpaa/Makefile b/drivers/net/ethernet/freescale/dpaa/Makefile index 3a276d5..3427de4 100644 --- a/drivers/net/ethernet/freescale/dpaa/Makefile +++ b/drivers/net/ethernet/freescale/dpaa/Makefile @@ -11,3 +11,6 @@ ccflags-y += -I$(FMAN)/flib obj-$(CONFIG_FSL_DPAA_ETH) += fsl_dpa.o fsl_dpa-objs += dpaa_eth.o dpaa_eth_sg.o dpaa_eth_common.o dpaa_ethtool.o dpaa_eth_sysfs.o +ifeq ($(CONFIG_FSL_DPAA_ETH_DEBUGFS),y) +fsl_dpa-objs += dpaa_debugfs.o +endif diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_debugfs.c b/drivers/net/ethernet/freescale/dpaa/dpaa_debugfs.c new file mode 100644 index 0000000..bd426f0 --- /dev/null +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_debugfs.c @@ -0,0 +1,272 @@ +/* Copyright 2008 - 2015 Freescale Semiconductor Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Freescale Semiconductor nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include "dpaa_debugfs.h" +#include "dpaa_eth.h" + +#define DPA_DEBUGFS_DESCRIPTION "FSL DPAA Ethernet debugfs entries" +#define DPA_ETH_DEBUGFS_ROOT "fsl_dpa" + +static int dpa_debugfs_open(struct inode *inode, struct file *file); + +static struct dentry *dpa_debugfs_root; +static const struct file_operations dpa_debugfs_fops = { + .open = dpa_debugfs_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int dpa_debugfs_show(struct seq_file *file, void *offset) +{ + int i; + struct dpa_priv_s *priv; + struct dpa_percpu_priv_s *percpu_priv, total; + struct dpa_bp *dpa_bp; + unsigned int dpa_bp_count = 0; + unsigned int count_total = 0; + struct qm_mcr_querycgr query_cgr; + + BUG_ON(!offset); + + priv = netdev_priv((struct net_device *)file->private); + + dpa_bp = priv->dpa_bp; + + memset(&total, 0, sizeof(total)); + + /* "Standard" counters */ + seq_printf(file, "\nDPA counters for %s:\n", priv->net_dev->name); + seq_puts(file, "CPU irqs rx tx recycle "); + seq_puts(file, "confirm tx sg tx err rx err bp count\n"); + + for_each_online_cpu(i) { + percpu_priv = per_cpu_ptr(priv->percpu_priv, i); + + if (dpa_bp->percpu_count) + dpa_bp_count = *(per_cpu_ptr(dpa_bp->percpu_count, i)); + + total.in_interrupt += percpu_priv->in_interrupt; + total.stats.rx_packets += percpu_priv->stats.rx_packets; + total.stats.tx_packets += percpu_priv->stats.tx_packets; + total.tx_confirm += percpu_priv->tx_confirm; + total.tx_frag_skbuffs += percpu_priv->tx_frag_skbuffs; + total.stats.tx_errors += percpu_priv->stats.tx_errors; + total.stats.rx_errors += percpu_priv->stats.rx_errors; + count_total += dpa_bp_count; + + seq_printf(file, " %hu %8llu %8llu %8llu ", + i, + percpu_priv->in_interrupt, + percpu_priv->stats.rx_packets, + percpu_priv->stats.tx_packets); + seq_printf(file, "%8llu %8llu %8llu %8llu %8d\n", + percpu_priv->tx_confirm, + percpu_priv->tx_frag_skbuffs, + percpu_priv->stats.tx_errors, + percpu_priv->stats.rx_errors, + dpa_bp_count); + } + seq_printf(file, "Total %8llu %8llu %8llu ", + total.in_interrupt, + total.stats.rx_packets, + total.stats.tx_packets); + seq_printf(file, "%8llu %8llu %8llu %8llu %8d\n", + total.tx_confirm, + total.tx_frag_skbuffs, + total.stats.tx_errors, + total.stats.rx_errors, + count_total); + + /* Congestion stats */ + seq_puts(file, "\nDevice congestion stats:\n"); + seq_printf(file, "Device has been congested for %d ms.\n", + jiffies_to_msecs(priv->cgr_data.congested_jiffies)); + + if (qman_query_cgr(&priv->cgr_data.cgr, &query_cgr) != 0) { + seq_printf(file, "CGR id %d - failed to query values\n", + priv->cgr_data.cgr.cgrid); + } else { + seq_printf(file, "CGR id %d avg count: %llu\n", + priv->cgr_data.cgr.cgrid, + qm_mcr_querycgr_a_get64(&query_cgr)); + seq_printf(file, "Device entered congestion %u times. ", + priv->cgr_data.cgr_congested_count); + seq_printf(file, "Current congestion state is: %s.\n", + query_cgr.cgr.cs ? "congested" : "not congested"); + /* Reset congestion stats (like QMan CGR API does) */ + priv->cgr_data.congested_jiffies = 0; + priv->cgr_data.cgr_congested_count = 0; + } + + /* Rx Errors demultiplexing */ + seq_puts(file, "\nDPA RX Errors:\nCPU dma err phys err"); + seq_puts(file, " size err hdr err csum err\n"); + for_each_online_cpu(i) { + percpu_priv = per_cpu_ptr(priv->percpu_priv, i); + + total.rx_errors.dme += percpu_priv->rx_errors.dme; + total.rx_errors.fpe += percpu_priv->rx_errors.fpe; + total.rx_errors.fse += percpu_priv->rx_errors.fse; + total.rx_errors.phe += percpu_priv->rx_errors.phe; + + seq_printf(file, " %hu %8llu %8llu ", + i, + percpu_priv->rx_errors.dme, + percpu_priv->rx_errors.fpe); + seq_printf(file, "%8llu %8llu\n", + percpu_priv->rx_errors.fse, + percpu_priv->rx_errors.phe); + } + seq_printf(file, "Total %8llu %8llu %8llu %8llu\n", + total.rx_errors.dme, + total.rx_errors.fpe, + total.rx_errors.fse, + total.rx_errors.phe); + + /* ERN demultiplexing */ + seq_puts(file, "\nDPA ERN counters:\n CPU cg_td wred "); + seq_puts(file, "err_cond early_w late_w fq_td fq_ret"); + seq_puts(file, " orp_z\n"); + for_each_online_cpu(i) { + percpu_priv = per_cpu_ptr(priv->percpu_priv, i); + + total.ern_cnt.cg_tdrop += percpu_priv->ern_cnt.cg_tdrop; + total.ern_cnt.wred += percpu_priv->ern_cnt.wred; + total.ern_cnt.err_cond += percpu_priv->ern_cnt.err_cond; + total.ern_cnt.early_window += percpu_priv->ern_cnt.early_window; + total.ern_cnt.late_window += percpu_priv->ern_cnt.late_window; + total.ern_cnt.fq_tdrop += percpu_priv->ern_cnt.fq_tdrop; + total.ern_cnt.fq_retired += percpu_priv->ern_cnt.fq_retired; + total.ern_cnt.orp_zero += percpu_priv->ern_cnt.orp_zero; + + seq_printf(file, " %hu %8llu %8llu %8llu %8llu ", + i, + percpu_priv->ern_cnt.cg_tdrop, + percpu_priv->ern_cnt.wred, + percpu_priv->ern_cnt.err_cond, + percpu_priv->ern_cnt.early_window); + seq_printf(file, "%8llu %8llu %8llu %8llu\n", + percpu_priv->ern_cnt.late_window, + percpu_priv->ern_cnt.fq_tdrop, + percpu_priv->ern_cnt.fq_retired, + percpu_priv->ern_cnt.orp_zero); + } + seq_printf(file, "Total %8llu %8llu %8llu %8llu ", + total.ern_cnt.cg_tdrop, + total.ern_cnt.wred, + total.ern_cnt.err_cond, + total.ern_cnt.early_window); + seq_printf(file, "%8llu %8llu %8llu %8llu\n", + total.ern_cnt.late_window, + total.ern_cnt.fq_tdrop, + total.ern_cnt.fq_retired, + total.ern_cnt.orp_zero); + + return 0; +} + +static int dpa_debugfs_open(struct inode *inode, struct file *file) +{ + int err; + const struct net_device *net_dev; + struct dpa_priv_s *priv; + + err = single_open(file, dpa_debugfs_show, inode->i_private); + if (err < 0) { + net_dev = (struct net_device *)inode->i_private; + priv = (struct dpa_priv_s *)netdev_priv(net_dev); + + netif_err(priv, drv, net_dev, "single_open() = %d\n", err); + } + return err; +} + +int dpa_netdev_debugfs_create(struct net_device *net_dev) +{ + struct dpa_priv_s *priv = netdev_priv(net_dev); + + if (!dpa_debugfs_root) { + pr_err("Error, root debugfs missing, possible module ordering issue"); + return -ENOMEM; + } + + priv->debugfs_file = debugfs_create_file(net_dev->name, + S_IRUGO, + dpa_debugfs_root, + net_dev, + &dpa_debugfs_fops); + if (!priv->debugfs_file) { + netdev_err(net_dev, "debugfs_create_file(%s/%s/%s)", + powerpc_debugfs_root->d_iname, + dpa_debugfs_root->d_iname, + net_dev->name); + + return -ENOMEM; + } + + return 0; +} + +void dpa_netdev_debugfs_remove(struct net_device *net_dev) +{ + struct dpa_priv_s *priv = netdev_priv(net_dev); + + debugfs_remove(priv->debugfs_file); +} + +int __init dpa_debugfs_module_init(void) +{ + int err = 0; + + pr_info(DPA_DEBUGFS_DESCRIPTION "\n"); + + dpa_debugfs_root = debugfs_create_dir(DPA_ETH_DEBUGFS_ROOT, + powerpc_debugfs_root); + if (!dpa_debugfs_root) { + err = -ENOMEM; + pr_err("Error, debugfs_create_dir(%s/" DPA_ETH_DEBUGFS_ROOT + ") = %d\n", + powerpc_debugfs_root->d_iname, err); + } + + return err; +} + +void __exit dpa_debugfs_module_exit(void) +{ + debugfs_remove(dpa_debugfs_root); +} diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_debugfs.h b/drivers/net/ethernet/freescale/dpaa/dpaa_debugfs.h new file mode 100644 index 0000000..c4c6582 --- /dev/null +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_debugfs.h @@ -0,0 +1,43 @@ +/* Copyright 2008-2015 Freescale Semiconductor Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Freescale Semiconductor nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DPAA_DEBUGFS_H_ +#define DPAA_DEBUGFS_H_ + +#include +#include + +int dpa_netdev_debugfs_create(struct net_device *net_dev); +void dpa_netdev_debugfs_remove(struct net_device *net_dev); +int __init dpa_debugfs_module_init(void); +void __exit dpa_debugfs_module_exit(void); + +#endif /* DPAA_DEBUGFS_H_ */ diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 008562b..ea25bf1 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -57,6 +57,9 @@ #include "mac.h" #include "dpaa_eth.h" #include "dpaa_eth_common.h" +#ifdef CONFIG_FSL_DPAA_ETH_DEBUGFS +#include "dpaa_debugfs.h" +#endif /* CONFIG_FSL_DPAA_ETH_DEBUGFS */ #define DPA_NAPI_WEIGHT 64 @@ -809,6 +812,10 @@ static int __init dpa_load(void) pr_info(DPA_DESCRIPTION "\n"); +#ifdef CONFIG_FSL_DPAA_ETH_DEBUGFS + dpa_debugfs_module_init(); +#endif /* CONFIG_FSL_DPAA_ETH_DEBUGFS */ + /* initialise dpaa_eth mirror values */ dpa_rx_extra_headroom = fm_get_rx_extra_headroom(); dpa_max_frm = fm_get_max_frm(); @@ -825,6 +832,10 @@ static void __exit dpa_unload(void) { platform_driver_unregister(&dpa_driver); +#ifdef CONFIG_FSL_DPAA_ETH_DEBUGFS + dpa_debugfs_module_exit(); +#endif /* CONFIG_FSL_DPAA_ETH_DEBUGFS */ + /* Only one channel is used and needs to be relased after all * interfaces are removed */ diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c index 459132b..7243f31 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c @@ -43,6 +43,9 @@ #include #include "dpaa_eth.h" #include "dpaa_eth_common.h" +#ifdef CONFIG_FSL_DPAA_ETH_DEBUGFS +#include "dpaa_debugfs.h" +#endif /* CONFIG_FSL_DPAA_ETH_DEBUGFS */ #include "mac.h" /* Size in bytes of the FQ taildrop threshold */ @@ -95,6 +98,15 @@ int dpa_netdev_init(struct net_device *net_dev, return err; } +#ifdef CONFIG_FSL_DPAA_ETH_DEBUGFS + /* create debugfs entry for this net_device */ + err = dpa_netdev_debugfs_create(net_dev); + if (err) { + unregister_netdev(net_dev); + return err; + } +#endif /* CONFIG_FSL_DPAA_ETH_DEBUGFS */ + return 0; } @@ -298,6 +310,11 @@ int dpa_remove(struct platform_device *pdev) if (priv->buf_layout) devm_kfree(dev, priv->buf_layout); +#ifdef CONFIG_FSL_DPAA_ETH_DEBUGFS + /* remove debugfs entry for this net_device */ + dpa_netdev_debugfs_remove(net_dev); +#endif /* CONFIG_FSL_DPAA_ETH_DEBUGFS */ + free_netdev(net_dev); return err; -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/