Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[linux-2.6-block.git] / drivers / scsi / lpfc / lpfc_nvme.c
index 39514d4c279db8a3ccc0164cd9b67c370877d235..946642cee3df768799fd8c4c0724d86709a17f15 100644 (file)
@@ -2412,6 +2412,50 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
 #endif
 }
 
+/**
+ * lpfc_nvme_rescan_port - Check to see if we should rescan this remoteport
+ *
+ * If the ndlp represents an NVME Target, that we are logged into,
+ * ping the NVME FC Transport layer to initiate a device rescan
+ * on this remote NPort.
+ */
+void
+lpfc_nvme_rescan_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
+{
+#if (IS_ENABLED(CONFIG_NVME_FC))
+       struct lpfc_nvme_rport *rport;
+       struct nvme_fc_remote_port *remoteport;
+
+       rport = ndlp->nrport;
+
+       lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
+                        "6170 Rescan NPort DID x%06x type x%x "
+                        "state x%x rport %p\n",
+                        ndlp->nlp_DID, ndlp->nlp_type, ndlp->nlp_state, rport);
+       if (!rport)
+               goto input_err;
+       remoteport = rport->remoteport;
+       if (!remoteport)
+               goto input_err;
+
+       /* Only rescan if we are an NVME target in the MAPPED state */
+       if (remoteport->port_role & FC_PORT_ROLE_NVME_DISCOVERY &&
+           ndlp->nlp_state == NLP_STE_MAPPED_NODE) {
+               nvme_fc_rescan_remoteport(remoteport);
+
+               lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_DISC,
+                                "6172 NVME rescanned DID x%06x "
+                                "port_state x%x\n",
+                                ndlp->nlp_DID, remoteport->port_state);
+       }
+       return;
+input_err:
+       lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_DISC,
+                        "6169 State error: lport %p, rport%p FCID x%06x\n",
+                        vport->localport, ndlp->rport, ndlp->nlp_DID);
+#endif
+}
+
 /* lpfc_nvme_unregister_port - unbind the DID and port_role from this rport.
  *
  * There is no notion of Devloss or rport recovery from the current