All of lore.kernel.org
 help / color / mirror / Atom feed
From: Himanshu Madhani <himanshu.madhani@cavium.com>
To: target-devel@vger.kernel.org, Bart.VanAssche@sandisk.com,
	nab@linux-iscsi.org
Cc: giridhar.malavali@cavium.com, linux-scsi@vger.kernel.org,
	himanshu.madhani@cavium.com
Subject: [PATCH v3 05/14] qla2xxx: Add DebugFS node to display Port Database
Date: Fri, 24 Feb 2017 13:37:34 -0800	[thread overview]
Message-ID: <1487972263-3795-6-git-send-email-himanshu.madhani@cavium.com> (raw)
In-Reply-To: <1487972263-3795-1-git-send-email-himanshu.madhani@cavium.com>

Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Giridhar Malavali <giridhar.malavali@cavium.com>
---
 drivers/scsi/qla2xxx/qla_def.h |  2 +
 drivers/scsi/qla2xxx/qla_dfs.c | 92 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 90 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 111861c..1fcd829 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -3278,6 +3278,8 @@ struct qlt_hw_data {
 	uint8_t tgt_node_name[WWN_SIZE];
 
 	struct dentry *dfs_tgt_sess;
+	struct dentry *dfs_tgt_port_database;
+
 	struct list_head q_full_list;
 	uint32_t num_pend_cmds;
 	uint32_t num_qfull_cmds_alloc;
diff --git a/drivers/scsi/qla2xxx/qla_dfs.c b/drivers/scsi/qla2xxx/qla_dfs.c
index b48cce6..0fb33e6 100644
--- a/drivers/scsi/qla2xxx/qla_dfs.c
+++ b/drivers/scsi/qla2xxx/qla_dfs.c
@@ -19,11 +19,11 @@
 	struct qla_hw_data *ha = vha->hw;
 	unsigned long flags;
 	struct fc_port *sess = NULL;
-	struct qla_tgt *tgt= vha->vha_tgt.qla_tgt;
+	struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
 
-	seq_printf(s, "%s\n",vha->host_str);
+	seq_printf(s, "%s\n", vha->host_str);
 	if (tgt) {
-		seq_printf(s, "Port ID   Port Name                Handle\n");
+		seq_puts(s, "Port ID   Port Name                Handle\n");
 
 		spin_lock_irqsave(&ha->tgt.sess_lock, flags);
 		list_for_each_entry(sess, &vha->vp_fcports, list)
@@ -44,7 +44,6 @@
 	return single_open(file, qla2x00_dfs_tgt_sess_show, vha);
 }
 
-
 static const struct file_operations dfs_tgt_sess_ops = {
 	.open		= qla2x00_dfs_tgt_sess_open,
 	.read		= seq_read,
@@ -53,6 +52,78 @@
 };
 
 static int
+qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused)
+{
+	scsi_qla_host_t *vha = s->private;
+	struct qla_hw_data *ha = vha->hw;
+	struct gid_list_info *gid_list;
+	dma_addr_t gid_list_dma;
+	fc_port_t fc_port;
+	char *id_iter;
+	int rc, i;
+	uint16_t entries, loop_id;
+	struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
+
+	seq_printf(s, "%s\n", vha->host_str);
+	if (tgt) {
+		gid_list = dma_alloc_coherent(&ha->pdev->dev,
+		    qla2x00_gid_list_size(ha),
+		    &gid_list_dma, GFP_KERNEL);
+		if (!gid_list) {
+			ql_dbg(ql_dbg_user, vha, 0x705c,
+			    "DMA allocation failed for %u\n",
+			     qla2x00_gid_list_size(ha));
+			return 0;
+		}
+
+		rc = qla24xx_gidlist_wait(vha, gid_list, gid_list_dma,
+		    &entries);
+		if (rc != QLA_SUCCESS)
+			goto out_free_id_list;
+
+		id_iter = (char *)gid_list;
+
+		seq_puts(s, "Port Name	Port ID 	Loop ID\n");
+
+		for (i = 0; i < entries; i++) {
+			struct gid_list_info *gid =
+			    (struct gid_list_info *)id_iter;
+			loop_id = le16_to_cpu(gid->loop_id);
+			memset(&fc_port, 0, sizeof(fc_port_t));
+
+			fc_port.loop_id = loop_id;
+
+			rc = qla24xx_gpdb_wait(vha, &fc_port, 0);
+			seq_printf(s, "%8phC  %02x%02x%02x  %d\n",
+				fc_port.port_name, fc_port.d_id.b.domain,
+				fc_port.d_id.b.area, fc_port.d_id.b.al_pa,
+				fc_port.loop_id);
+			id_iter += ha->gid_list_info_size;
+		}
+out_free_id_list:
+		dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha),
+		    gid_list, gid_list_dma);
+	}
+
+	return 0;
+}
+
+static int
+qla2x00_dfs_tgt_port_database_open(struct inode *inode, struct file *file)
+{
+	scsi_qla_host_t *vha = inode->i_private;
+
+	return single_open(file, qla2x00_dfs_tgt_port_database_show, vha);
+}
+
+static const struct file_operations dfs_tgt_port_database_ops = {
+	.open		= qla2x00_dfs_tgt_port_database_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+static int
 qla_dfs_fw_resource_cnt_show(struct seq_file *s, void *unused)
 {
 	struct scsi_qla_host *vha = s->private;
@@ -281,6 +352,14 @@
 		goto out;
 	}
 
+	ha->tgt.dfs_tgt_port_database = debugfs_create_file("tgt_port_database",
+	    S_IRUSR,  ha->dfs_dir, vha, &dfs_tgt_port_database_ops);
+	if (!ha->tgt.dfs_tgt_port_database) {
+		ql_log(ql_log_warn, vha, 0xffff,
+		    "Unable to create debugFS tgt_port_database node.\n");
+		goto out;
+	}
+
 	ha->dfs_fce = debugfs_create_file("fce", S_IRUSR, ha->dfs_dir, vha,
 	    &dfs_fce_ops);
 	if (!ha->dfs_fce) {
@@ -311,6 +390,11 @@
 		ha->tgt.dfs_tgt_sess = NULL;
 	}
 
+	if (ha->tgt.dfs_tgt_port_database) {
+		debugfs_remove(ha->tgt.dfs_tgt_port_database);
+		ha->tgt.dfs_tgt_port_database = NULL;
+	}
+
 	if (ha->dfs_fw_resource_cnt) {
 		debugfs_remove(ha->dfs_fw_resource_cnt);
 		ha->dfs_fw_resource_cnt = NULL;
-- 
1.8.3.1

  parent reply	other threads:[~2017-02-24 21:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-24 21:37 [PATCH v3 00/14] qla2xxx: Bug Fixes and updates for target Himanshu Madhani
2017-02-24 21:37 ` [PATCH v3 01/14] qla2xxx: Fix delayed response to command for loop mode/direct connect Himanshu Madhani
2017-02-24 21:37 ` [PATCH v3 02/14] qla2xxx: Allow relogin to proceed if remote login did not finish Himanshu Madhani
2017-02-24 21:37 ` [PATCH v3 03/14] qla2xxx: Allow vref count to timeout on vport delete Himanshu Madhani
2017-02-24 21:37 ` [PATCH v3 04/14] qla2xxx: Use IOCB interface to submit non-critical MBX Himanshu Madhani
2017-02-24 21:37 ` Himanshu Madhani [this message]
2017-02-24 21:37 ` [PATCH v3 06/14] qla2xxx: Improve T10-DIF/PI handling in driver Himanshu Madhani
2017-02-24 21:37 ` [PATCH v3 07/14] qla2xxx: Export DIF stats via debugfs Himanshu Madhani
2017-02-24 21:37 ` [PATCH v3 08/14] qla2xxx: Change scsi host lookup method Himanshu Madhani
2017-02-24 21:37 ` [PATCH v3 09/14] qla2xxx: Fix memory leak for abts processing Himanshu Madhani
2017-02-24 21:37 ` [PATCH v3 10/14] qla2xxx: Fix request queue corruption Himanshu Madhani
2017-02-24 21:37 ` [PATCH v3 11/14] qla2xxx: Fix inadequate lock protection for ABTS Himanshu Madhani
2017-02-24 21:37 ` [PATCH v3 12/14] qla2xxx: Add async new target notification Himanshu Madhani
2017-02-24 21:37 ` [PATCH v3 13/14] qla2xxx: Fix sess_lock & hardware_lock lock order problem Himanshu Madhani
2017-02-24 21:37 ` [PATCH v3 14/14] qla2xxx: Update driver version to 9.00.00.00-k Himanshu Madhani
2017-02-28 22:00 ` [PATCH v3 00/14] qla2xxx: Bug Fixes and updates for target Madhani, Himanshu
2017-02-28 22:09   ` Bart Van Assche
2017-02-28 22:13     ` Madhani, Himanshu
2017-03-02  7:24 ` Nicholas A. Bellinger
2017-03-06  0:43 ` Bart Van Assche
2017-03-06  5:05   ` Madhani, Himanshu
2017-03-08  7:34   ` Nicholas A. Bellinger
2017-03-08 15:20     ` Bart Van Assche
2017-03-08 18:30       ` Malavali, Giridhar
2017-03-09  3:42         ` Nicholas A. Bellinger
2017-03-09 21:08           ` Malavali, Giridhar
2017-03-09  3:38       ` Nicholas A. Bellinger

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=1487972263-3795-6-git-send-email-himanshu.madhani@cavium.com \
    --to=himanshu.madhani@cavium.com \
    --cc=Bart.VanAssche@sandisk.com \
    --cc=giridhar.malavali@cavium.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    --cc=target-devel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.