scsi: scsi_transport_fc: nvme: display FC-NVMe port roles
authorHannes Reinecke <hare@suse.de>
Wed, 10 Apr 2019 14:16:19 +0000 (16:16 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Sat, 13 Apr 2019 00:09:34 +0000 (20:09 -0400)
Currently the FC-NVMe driver is leverating the SCSI FC transport class to
access the remote ports. Which means that all FC-NVMe remote ports will be
visible to the fc transport layer, but due to missing definitions the port
roles will always be 'unknown'.  This patch adds the missing definitions to
the fc transport class to that the port roles are correctly displayed.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Giridhar Malavali <gmalavali@marvell.com>
Reviewed-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/nvme/host/fc.c
drivers/scsi/lpfc/lpfc_hbadisc.c
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_mbx.c
drivers/scsi/scsi_transport_fc.c
include/linux/nvme-fc-driver.h
include/scsi/scsi_transport_fc.h

index f3b9d91ba0dfd30ba7c4c3f554e14ea860c389b7..31637f8ef22ea6e295907bbc38cc17200c5f3a06 100644 (file)
@@ -14,7 +14,7 @@
 #include "fabrics.h"
 #include <linux/nvme-fc-driver.h>
 #include <linux/nvme-fc.h>
-
+#include <scsi/scsi_transport_fc.h>
 
 /* *************************** Data Structures/Defines ****************** */
 
index 1e0767c93fe0353207b0fb0bee0ec19c5174068c..c43852f97f2530f4fe5bee4578960b449664777c 100644 (file)
@@ -4146,9 +4146,15 @@ lpfc_register_remote_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
        rdata->pnode = lpfc_nlp_get(ndlp);
 
        if (ndlp->nlp_type & NLP_FCP_TARGET)
-               rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET;
+               rport_ids.roles |= FC_PORT_ROLE_FCP_TARGET;
        if (ndlp->nlp_type & NLP_FCP_INITIATOR)
-               rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR;
+               rport_ids.roles |= FC_PORT_ROLE_FCP_INITIATOR;
+       if (ndlp->nlp_type & NLP_NVME_INITIATOR)
+               rport_ids.roles |= FC_PORT_ROLE_NVME_INITIATOR;
+       if (ndlp->nlp_type & NLP_NVME_TARGET)
+               rport_ids.roles |= FC_PORT_ROLE_NVME_TARGET;
+       if (ndlp->nlp_type & NLP_NVME_DISCOVERY)
+               rport_ids.roles |= FC_PORT_ROLE_NVME_DISCOVERY;
 
        if (rport_ids.roles !=  FC_RPORT_ROLE_UNKNOWN)
                fc_remote_port_rolechg(rport, rport_ids.roles);
index b7b0a3e0ecbc1543b179051fe070b6df733754ce..a6ca97bad392eb7c29b08faece2c8f7a276973e2 100644 (file)
@@ -2264,7 +2264,10 @@ typedef enum {
        FCT_BROADCAST,
        FCT_INITIATOR,
        FCT_TARGET,
-       FCT_NVME
+       FCT_NVME_INITIATOR = 0x10,
+       FCT_NVME_TARGET = 0x20,
+       FCT_NVME_DISCOVERY = 0x40,
+       FCT_NVME = 0xf0,
 } fc_port_type_t;
 
 enum qla_sess_deletion {
index 0ab697dea9061779c1483853bb45144fd233ad56..9a8e54832e9fa373c16bb3818f2f8c0ab56d349a 100644 (file)
@@ -5268,16 +5268,23 @@ qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport)
 
        rport->supported_classes = fcport->supported_classes;
 
-       rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
+       rport_ids.roles = FC_PORT_ROLE_UNKNOWN;
        if (fcport->port_type == FCT_INITIATOR)
-               rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR;
+               rport_ids.roles |= FC_PORT_ROLE_FCP_INITIATOR;
        if (fcport->port_type == FCT_TARGET)
-               rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET;
+               rport_ids.roles |= FC_PORT_ROLE_FCP_TARGET;
+       if (fcport->port_type & FCT_NVME_INITIATOR)
+               rport_ids.roles |= FC_PORT_ROLE_NVME_INITIATOR;
+       if (fcport->port_type & FCT_NVME_TARGET)
+               rport_ids.roles |= FC_PORT_ROLE_NVME_TARGET;
+       if (fcport->port_type & FCT_NVME_DISCOVERY)
+               rport_ids.roles |= FC_PORT_ROLE_NVME_DISCOVERY;
 
        ql_dbg(ql_dbg_disc, vha, 0x20ee,
            "%s %8phN. rport %p is %s mode\n",
            __func__, fcport->port_name, rport,
-           (fcport->port_type == FCT_TARGET) ? "tgt" : "ini");
+           (fcport->port_type == FCT_TARGET) ? "tgt" :
+           ((fcport->port_type & FCT_NVME) ? "nvme" :"ini"));
 
        fc_remote_port_rolechg(rport, rport_ids.roles);
 }
index 9f2fb1028f614ebe263df7837e549d1429030b3a..21831ca03730c104b406d4a6bfb6ea74f5090685 100644 (file)
@@ -6387,7 +6387,13 @@ int __qla24xx_parse_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport,
        fcport->d_id.b.rsvd_1 = 0;
 
        if (fcport->fc4f_nvme) {
-               fcport->port_type = FCT_NVME;
+               fcport->port_type = 0;
+               if ((pd->prli_svc_param_word_3[0] & BIT_5) == 0)
+                       fcport->port_type |= FCT_NVME_INITIATOR;
+               if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0)
+                       fcport->port_type |= FCT_NVME_TARGET;
+               if ((pd->prli_svc_param_word_3[0] & BIT_3) == 0)
+                       fcport->port_type |= FCT_NVME_DISCOVERY;
        } else {
                /* If not target must be initiator or unknown type. */
                if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0)
index 14e510071046f0194e168ad542a3d0d3ff695493..d9e3cf3721f6bcb2c44fde0029672834e42b4986 100644 (file)
@@ -296,6 +296,9 @@ static const struct {
        { FC_PORT_ROLE_FCP_INITIATOR,           "FCP Initiator" },
        { FC_PORT_ROLE_IP_PORT,                 "IP Port" },
        { FC_PORT_ROLE_FCP_DUMMY_INITIATOR,     "FCP Dummy Initiator" },
+       { FC_PORT_ROLE_NVME_INITIATOR,          "NVMe Initiator" },
+       { FC_PORT_ROLE_NVME_TARGET,             "NVMe Target" },
+       { FC_PORT_ROLE_NVME_DISCOVERY,          "NVMe Discovery" },
 };
 fc_bitfield_name_search(port_roles, fc_port_role_names)
 
index 2bb349035431d0cebb6466e857525b15f6790fc4..c48e96436f563f0034cfaa897d7150a4a9692322 100644 (file)
 
 
 
-/* FC Port role bitmask - can merge with FC Port Roles in fc transport */
-#define FC_PORT_ROLE_NVME_INITIATOR    0x10
-#define FC_PORT_ROLE_NVME_TARGET       0x20
-#define FC_PORT_ROLE_NVME_DISCOVERY    0x40
-
-
 /**
  * struct nvme_fc_port_info - port-specific ids and FC connection-specific
  *                            data element used during NVME Host role
index 14e86afec5e4ea634c77bf67d68c551dc23ee692..b375c3303fe28d350a5b928b925b4851e31212a2 100644 (file)
@@ -165,6 +165,9 @@ enum fc_tgtid_binding_type  {
 #define FC_PORT_ROLE_FCP_INITIATOR             0x02
 #define FC_PORT_ROLE_IP_PORT                   0x04
 #define FC_PORT_ROLE_FCP_DUMMY_INITIATOR       0x08
+#define FC_PORT_ROLE_NVME_INITIATOR            0x10
+#define FC_PORT_ROLE_NVME_TARGET               0x20
+#define FC_PORT_ROLE_NVME_DISCOVERY            0x40
 
 /* The following are for compatibility */
 #define FC_RPORT_ROLE_UNKNOWN                  FC_PORT_ROLE_UNKNOWN