scsi: qla2xxx: Setup debugfs entries for remote ports
authorArun Easi <aeasi@marvell.com>
Fri, 4 Sep 2020 04:51:17 +0000 (21:51 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 22 Sep 2020 22:42:36 +0000 (18:42 -0400)
Create a base for adding remote port related entries in debugfs.

Link: https://lore.kernel.org/r/20200904045128.23631-3-njavali@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_dfs.c
drivers/scsi/qla2xxx/qla_gbl.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_target.c

index a165120..6d6d74e 100644 (file)
@@ -2544,6 +2544,8 @@ typedef struct fc_port {
        u8 last_login_state;
        u16 n2n_link_reset_cnt;
        u16 n2n_chip_reset;
+
+       struct dentry *dfs_rport_dir;
 } fc_port_t;
 
 enum {
@@ -4780,6 +4782,8 @@ typedef struct scsi_qla_host {
        uint16_t ql2xexchoffld;
        uint16_t ql2xiniexchg;
 
+       struct dentry *dfs_rport_root;
+
        struct purex_list {
                struct list_head head;
                spinlock_t lock;
index e62b211..3c4b9b5 100644 (file)
 static struct dentry *qla2x00_dfs_root;
 static atomic_t qla2x00_dfs_root_count;
 
+void
+qla2x00_dfs_create_rport(scsi_qla_host_t *vha, struct fc_port *fp)
+{
+       char wwn[32];
+
+       if (!vha->dfs_rport_root || fp->dfs_rport_dir)
+               return;
+
+       sprintf(wwn, "pn-%016llx", wwn_to_u64(fp->port_name));
+       fp->dfs_rport_dir = debugfs_create_dir(wwn, vha->dfs_rport_root);
+       if (!fp->dfs_rport_dir)
+               return;
+}
+
+void
+qla2x00_dfs_remove_rport(scsi_qla_host_t *vha, struct fc_port *fp)
+{
+       if (!vha->dfs_rport_root || !fp->dfs_rport_dir)
+               return;
+       debugfs_remove_recursive(fp->dfs_rport_dir);
+       fp->dfs_rport_dir = NULL;
+}
+
 static int
 qla2x00_dfs_tgt_sess_show(struct seq_file *s, void *unused)
 {
@@ -473,9 +496,21 @@ create_nodes:
        ha->tgt.dfs_tgt_sess = debugfs_create_file("tgt_sess",
                S_IRUSR, ha->dfs_dir, vha, &dfs_tgt_sess_ops);
 
-       if (IS_QLA27XX(ha) || IS_QLA83XX(ha) || IS_QLA28XX(ha))
+       if (IS_QLA27XX(ha) || IS_QLA83XX(ha) || IS_QLA28XX(ha)) {
                ha->tgt.dfs_naqp = debugfs_create_file("naqp",
                    0400, ha->dfs_dir, vha, &dfs_naqp_ops);
+               if (!ha->tgt.dfs_naqp) {
+                       ql_log(ql_log_warn, vha, 0xd011,
+                              "Unable to create debugFS naqp node.\n");
+                       goto out;
+               }
+       }
+       vha->dfs_rport_root = debugfs_create_dir("rports", ha->dfs_dir);
+       if (!vha->dfs_rport_root) {
+               ql_log(ql_log_warn, vha, 0xd012,
+                      "Unable to create debugFS rports node.\n");
+               goto out;
+       }
 out:
        return 0;
 }
@@ -515,6 +550,11 @@ qla2x00_dfs_remove(scsi_qla_host_t *vha)
                ha->dfs_fce = NULL;
        }
 
+       if (vha->dfs_rport_root) {
+               debugfs_remove_recursive(vha->dfs_rport_root);
+               vha->dfs_rport_root = NULL;
+       }
+
        if (ha->dfs_dir) {
                debugfs_remove(ha->dfs_dir);
                ha->dfs_dir = NULL;
index 0ced18f..36c210c 100644 (file)
@@ -935,6 +935,8 @@ void qlt_clr_qp_table(struct scsi_qla_host *vha);
 void qlt_set_mode(struct scsi_qla_host *);
 int qla2x00_set_data_rate(scsi_qla_host_t *vha, uint16_t mode);
 extern void qla24xx_process_purex_list(struct purex_list *);
+extern void qla2x00_dfs_create_rport(scsi_qla_host_t *vha, struct fc_port *fp);
+extern void qla2x00_dfs_remove_rport(scsi_qla_host_t *vha, struct fc_port *fp);
 
 /* nvme.c */
 void qla_nvme_unregister_remote_port(struct fc_port *fcport);
index 83a541d..5051888 100644 (file)
@@ -5496,6 +5496,8 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
 
        qla2x00_iidma_fcport(vha, fcport);
 
+       qla2x00_dfs_create_rport(vha, fcport);
+
        if (NVME_TARGET(vha->hw, fcport)) {
                qla_nvme_register_remote(vha, fcport);
                qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_COMPLETE);
index c339cae..1ef39a9 100644 (file)
@@ -1111,6 +1111,8 @@ void qlt_free_session_done(struct work_struct *work)
        spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
        sess->free_pending = 0;
 
+       qla2x00_dfs_remove_rport(vha, sess);
+
        ql_dbg(ql_dbg_disc, vha, 0xf001,
            "Unregistration of sess %p %8phC finished fcp_cnt %d\n",
                sess, sess->port_name, vha->fcport_count);