public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Selvin Xavier <selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
To: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Selvin Xavier
	<selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
	Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
	Devesh Sharma
	<devesh.sharma-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
	Somnath Kotur
	<somnath.kotur-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
	Sriharsha Basavapatna
	<sriharsha.basavapatna-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Subject: [PATCH 26/28] bnxt_re: Support debugfs
Date: Sun,  4 Dec 2016 22:38:30 -0800	[thread overview]
Message-ID: <1480919912-1079-27-git-send-email-selvin.xavier@broadcom.com> (raw)
In-Reply-To: <1480919912-1079-1-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>

This patch exports some of the FW debug counters

Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Signed-off-by: Devesh Sharma <devesh.sharma-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Signed-off-by: Somnath Kotur <somnath.kotur-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Signed-off-by: Selvin Xavier <selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
---
 drivers/infiniband/hw/bnxtre/Makefile          |   2 +-
 drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.c | 136 +++++++++++++++++++++++++
 drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.h |  25 +++++
 drivers/infiniband/hw/bnxtre/bnxt_re_main.c    |   4 +
 4 files changed, 166 insertions(+), 1 deletion(-)
 create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.c
 create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.h

diff --git a/drivers/infiniband/hw/bnxtre/Makefile b/drivers/infiniband/hw/bnxtre/Makefile
index 71aa5a1..39df4f1 100644
--- a/drivers/infiniband/hw/bnxtre/Makefile
+++ b/drivers/infiniband/hw/bnxtre/Makefile
@@ -1,6 +1,6 @@
 
 ccflags-y := -Idrivers/net/ethernet/broadcom/bnxt
 obj-$(CONFIG_INFINIBAND_BNXTRE) += bnxt_re.o
-bnxt_re-y := bnxt_re_main.o bnxt_re_ib_verbs.o \
+bnxt_re-y := bnxt_re_main.o bnxt_re_ib_verbs.o bnxt_re_debugfs.o \
 	     bnxt_qplib_res.o bnxt_qplib_rcfw.o	\
 	     bnxt_qplib_sp.o bnxt_qplib_fp.o
diff --git a/drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.c b/drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.c
new file mode 100644
index 0000000..a80a241
--- /dev/null
+++ b/drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.c
@@ -0,0 +1,136 @@
+
+/* Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2014-2016 Broadcom Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation.
+ *
+ */
+
+/*
+ * Description: DebugFS specifics
+ */
+
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+#include <linux/netdevice.h>
+
+#include <rdma/ib_verbs.h>
+#include "bnxt_re_hsi.h"
+#include "bnxt_ulp.h"
+#include "bnxt_qplib_res.h"
+#include "bnxt_qplib_sp.h"
+#include "bnxt_qplib_fp.h"
+#include "bnxt_qplib_rcfw.h"
+
+#include "bnxt_re.h"
+#include "bnxt_re_debugfs.h"
+
+static struct dentry *bnxt_re_debugfs_root;
+static struct dentry *bnxt_re_debugfs_info;
+
+static ssize_t bnxt_re_debugfs_clear(struct file *fil, const char __user *u,
+				     size_t size, loff_t *off)
+{
+	return size;
+}
+
+static int bnxt_re_debugfs_show(struct seq_file *s, void *unused)
+{
+	struct bnxt_re_dev *rdev;
+
+	seq_puts(s, "bnxt_re debug info:\n");
+
+	mutex_lock(&bnxt_re_dev_lock);
+	list_for_each_entry(rdev, &bnxt_re_dev_list, list) {
+		struct ctx_hw_stats *stats = rdev->qplib_ctx.stats.dma;
+
+		seq_printf(s, "=====[ IBDEV %s ]=============================\n",
+			   rdev->ibdev.name);
+		if (rdev->netdev)
+			seq_printf(s, "\tlink state: %s\n",
+				   test_bit(__LINK_STATE_START,
+					    &rdev->netdev->state) ?
+				   (test_bit(__LINK_STATE_NOCARRIER,
+					     &rdev->netdev->state) ?
+				    "DOWN" : "UP") : "DOWN");
+		seq_printf(s, "\tMax QP: 0x%x\n", rdev->dev_attr.max_qp);
+		seq_printf(s, "\tMax SRQ: 0x%x\n", rdev->dev_attr.max_srq);
+		seq_printf(s, "\tMax CQ: 0x%x\n", rdev->dev_attr.max_cq);
+		seq_printf(s, "\tMax MR: 0x%x\n", rdev->dev_attr.max_mr);
+		seq_printf(s, "\tMax MW: 0x%x\n", rdev->dev_attr.max_mw);
+
+		seq_printf(s, "\tActive QP: %d\n",
+			   atomic_read(&rdev->qp_count));
+		seq_printf(s, "\tActive SRQ: %d\n",
+			   atomic_read(&rdev->srq_count));
+		seq_printf(s, "\tActive CQ: %d\n",
+			   atomic_read(&rdev->cq_count));
+		seq_printf(s, "\tActive MR: %d\n",
+			   atomic_read(&rdev->mr_count));
+		seq_printf(s, "\tActive MW: %d\n",
+			   atomic_read(&rdev->mw_count));
+		seq_printf(s, "\tRx Pkts: %lld\n",
+			   stats ? stats->rx_ucast_pkts : 0);
+		seq_printf(s, "\tRx Bytes: %lld\n",
+			   stats ? stats->rx_ucast_bytes : 0);
+		seq_printf(s, "\tTx Pkts: %lld\n",
+			   stats ? stats->tx_ucast_pkts : 0);
+		seq_printf(s, "\tTx Bytes: %lld\n",
+			   stats ? stats->tx_ucast_bytes : 0);
+		seq_printf(s, "\tRecoverable Errors: %lld\n",
+			   stats ? stats->tx_bcast_pkts : 0);
+		seq_puts(s, "\n");
+	}
+	mutex_unlock(&bnxt_re_dev_lock);
+	return 0;
+}
+
+static int bnxt_re_debugfs_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, bnxt_re_debugfs_show, NULL);
+}
+
+static int bnxt_re_debugfs_release(struct inode *inode, struct file *file)
+{
+	return single_release(inode, file);
+}
+
+static const struct file_operations bnxt_re_dbg_ops = {
+	.owner		= THIS_MODULE,
+	.open		= bnxt_re_debugfs_open,
+	.read		= seq_read,
+	.write		= bnxt_re_debugfs_clear,
+	.llseek		= seq_lseek,
+	.release	= bnxt_re_debugfs_release,
+};
+
+void bnxt_re_debugfs_remove(void)
+{
+	debugfs_remove_recursive(bnxt_re_debugfs_root);
+	bnxt_re_debugfs_root = NULL;
+}
+
+void bnxt_re_debugfs_init(void)
+{
+	bnxt_re_debugfs_root = debugfs_create_dir(ROCE_DRV_MODULE_NAME, NULL);
+	if (IS_ERR_OR_NULL(bnxt_re_debugfs_root)) {
+		dev_dbg(NULL, "%s: Unable to create debugfs root directory ",
+			ROCE_DRV_MODULE_NAME);
+		dev_dbg(NULL, "with err 0x%lx", PTR_ERR(bnxt_re_debugfs_root));
+		return;
+	}
+	bnxt_re_debugfs_info = debugfs_create_file("info", 0400,
+						   bnxt_re_debugfs_root, NULL,
+						   &bnxt_re_dbg_ops);
+	if (IS_ERR_OR_NULL(bnxt_re_debugfs_info)) {
+		dev_dbg(NULL, "%s: Unable to create debugfs info node ",
+			ROCE_DRV_MODULE_NAME);
+		dev_dbg(NULL, "with err 0x%lx", PTR_ERR(bnxt_re_debugfs_info));
+		bnxt_re_debugfs_remove();
+	}
+}
diff --git a/drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.h b/drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.h
new file mode 100644
index 0000000..4089fa5
--- /dev/null
+++ b/drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.h
@@ -0,0 +1,25 @@
+
+/* Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2014-2016 Broadcom Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation.
+ *
+ */
+
+/*
+ * Description: DebugFS header
+ */
+
+#ifndef __BNXT_RE_DEBUGFS__
+#define __BNXT_RE_DEBUGFS__
+
+extern struct list_head bnxt_re_dev_list;
+extern struct mutex bnxt_re_dev_lock;
+
+void bnxt_re_debugfs_init(void);
+void bnxt_re_debugfs_remove(void);
+
+#endif
diff --git a/drivers/infiniband/hw/bnxtre/bnxt_re_main.c b/drivers/infiniband/hw/bnxtre/bnxt_re_main.c
index ab70d23..67b6a80 100644
--- a/drivers/infiniband/hw/bnxtre/bnxt_re_main.c
+++ b/drivers/infiniband/hw/bnxtre/bnxt_re_main.c
@@ -34,6 +34,7 @@
 #include "bnxt_qplib_fp.h"
 #include "bnxt_qplib_rcfw.h"
 #include "bnxt_re.h"
+#include "bnxt_re_debugfs.h"
 #include "bnxt_re_ib_verbs.h"
 #include "bnxt.h"
 static char version[] =
@@ -1252,6 +1253,7 @@ static int __init bnxt_re_mod_init(void)
 	if (!bnxt_re_wq)
 		return -ENOMEM;
 
+	bnxt_re_debugfs_init();
 	INIT_LIST_HEAD(&bnxt_re_dev_list);
 
 	rc = register_netdevice_notifier(&bnxt_re_netdev_notifier);
@@ -1263,6 +1265,7 @@ static int __init bnxt_re_mod_init(void)
 	return 0;
 
 err_netdev:
+	bnxt_re_debugfs_remove();
 	destroy_workqueue(bnxt_re_wq);
 
 	return rc;
@@ -1291,6 +1294,7 @@ static void __exit bnxt_re_mod_exit(void)
 	}
 
 	unregister_netdevice_notifier(&bnxt_re_netdev_notifier);
+	bnxt_re_debugfs_remove();
 	if (bnxt_re_wq)
 		destroy_workqueue(bnxt_re_wq);
 }
-- 
2.5.5

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-12-05  6:38 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-05  6:38 [PATCH 00/28] Broadcom RoCE Driver (bnxt_re) Selvin Xavier
2016-12-05  6:38 ` [PATCH 02/28] bnxt_en: Enable MSIX early in bnxt_init_one() Selvin Xavier
2016-12-05  6:38 ` [PATCH 03/28] bnxt_en: Move function reset to bnxt_init_one() Selvin Xavier
2016-12-05  6:38 ` [PATCH 04/28] bnxt_en: Improve completion ring allocation for VFs Selvin Xavier
2016-12-05  6:38 ` [PATCH 05/28] bnxt_en: Reserve RDMA resources by default Selvin Xavier
2016-12-05  6:38 ` [PATCH 07/28] bnxt_en: Add interface to support RDMA driver Selvin Xavier
     [not found] ` <1480919912-1079-1-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2016-12-05  6:38   ` [PATCH 01/28] bnxt_en: Add bnxt_set_max_func_irqs() Selvin Xavier
2016-12-05 16:47     ` David Miller
2016-12-05 17:10       ` Michael Chan
2016-12-05  6:38   ` [PATCH 06/28] bnxt_en: Refactor the driver registration function with firmware Selvin Xavier
2016-12-05  6:38   ` [PATCH 08/28] bnxt_re: Add bnxt_re RoCE driver files Selvin Xavier
     [not found]     ` <1480919912-1079-9-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2016-12-05 15:16       ` Doug Ledford
     [not found]         ` <09068db2-1a14-9fbb-074b-4cf000fbddfb-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-12-06  5:56           ` Selvin Xavier
2016-12-05  6:38   ` [PATCH 09/28] bnxt_re: Introducing autogenerated Host Software Interface(hsi) file Selvin Xavier
     [not found]     ` <1480919912-1079-10-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2016-12-07 22:32       ` Jonathan Toppins
     [not found]         ` <9d151718-c357-d1c4-bbe5-5265e6d2b6ca-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-12-08  9:45           ` Selvin Xavier
2016-12-05  6:38   ` [PATCH 10/28] bnxt_re: register with the NIC driver Selvin Xavier
     [not found]     ` <1480919912-1079-11-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2016-12-07 23:21       ` Jonathan Toppins
     [not found]         ` <ad3d577c-760f-c003-394a-d80efe96400c-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-12-08  9:42           ` Selvin Xavier
2016-12-05  6:38   ` [PATCH 11/28] bnxt_re: Enabling RoCE control path Selvin Xavier
     [not found]     ` <1480919912-1079-12-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2016-12-08 16:54       ` Jonathan Toppins
     [not found]         ` <973d0642-1d06-72d4-bbbd-d360663d287b-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-12-09 10:50           ` Selvin Xavier
2016-12-05  6:38   ` [PATCH 12/28] bnxt_re: Adding Notification Queue support Selvin Xavier
2016-12-05  6:38   ` [PATCH 13/28] bnxt_re: Support for PD, ucontext and mmap verbs Selvin Xavier
2016-12-05  6:38   ` [PATCH 14/28] bnxt_re: Support for query and modify device verbs Selvin Xavier
2016-12-05  6:38   ` [PATCH 15/28] bnxt_re: Adding support for port related verbs Selvin Xavier
2016-12-05  6:38   ` [PATCH 16/28] bnxt_re: Support for GID " Selvin Xavier
2016-12-05  6:38   ` [PATCH 17/28] bnxt_re: Support for CQ verbs Selvin Xavier
2016-12-05  6:38   ` [PATCH 18/28] bnxt_re: Support for AH verbs Selvin Xavier
2016-12-05  6:38   ` [PATCH 19/28] bnxt_re: Support memory registration verbs Selvin Xavier
2016-12-05  6:38   ` [PATCH 20/28] bnxt_re: Support QP verbs Selvin Xavier
2016-12-05  6:38   ` [PATCH 21/28] bnxt_re: Support post_send verb Selvin Xavier
2016-12-05  6:38   ` [PATCH 22/28] bnxt_re: Support post_recv Selvin Xavier
2016-12-05  6:38   ` [PATCH 23/28] bnxt_re: Support poll_cq verb Selvin Xavier
2016-12-05  6:38   ` [PATCH 24/28] bnxt_re: Handling dispatching of events to IB stack and cleanup during unload Selvin Xavier
2016-12-05  6:38   ` [PATCH 25/28] bnxt_re: Support for DCB Selvin Xavier
2016-12-05  6:38   ` Selvin Xavier [this message]
2016-12-05  6:38   ` [PATCH 27/28] bnxt_re: Set uverbs command mask Selvin Xavier
2016-12-05  6:38   ` [PATCH 28/28] bnxt_re: Add QP event handling Selvin Xavier
2016-12-05 15:17   ` [PATCH 00/28] Broadcom RoCE Driver (bnxt_re) Doug Ledford
     [not found]     ` <ee2b9e6f-de43-ab80-d2a7-d431e33c45ba-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-12-06  5:38       ` Selvin Xavier
2016-12-05 16:51   ` Jason Gunthorpe
     [not found]     ` <20161205165144.GB24852-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-12-06  6:01       ` Selvin Xavier
     [not found]         ` <CA+sbYW1sUrv8CBHScMjU7ozBm709-tiVWaynDQK_Dq3AqAfggA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-06 16:34           ` Jason Gunthorpe
     [not found]             ` <20161206163456.GB28066-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-12-07 11:33               ` Selvin Xavier
2016-12-07 23:33   ` Jonathan Toppins
     [not found]     ` <a909ae78-ed49-407a-29c7-b86729f356b8-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-12-08  9:38       ` Selvin Xavier
     [not found]         ` <CA+sbYW1P4MqsBF14d9ZK_VjV4edU2bh=sLNTVnGs9F3ojF6vWQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-08 21:08           ` Doug Ledford
     [not found]             ` <cd667d80-cc1b-c8df-07d1-a5e7b9f94c68-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-12-08 21:42               ` Jonathan Toppins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1480919912-1079-27-git-send-email-selvin.xavier@broadcom.com \
    --to=selvin.xavier-dy08kvg/lbpwk0htik3j/w@public.gmane.org \
    --cc=devesh.sharma-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=somnath.kotur-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=sriharsha.basavapatna-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox