Update the host work loop and target state-machine helpers to process NVMe targets in addition to SCSI targets.
Check both protocol-specific target lists when determining whether there is initialization or logout work pending, and extend the query, target init, and target delete phases to dispatch work for NVMe targets using the same common state-machine callbacks. This allows the existing discovery and login state machine to drive NVMe/FC targets through query, login, and deletion without duplicating the control flow. Signed-off-by: Tyrel Datwyler <[email protected]> --- drivers/scsi/ibmvscsi/ibmvfc-core.c | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c index 13e513bfd0a8..9a6a885aa57e 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c @@ -5692,6 +5692,11 @@ static int ibmvfc_dev_init_to_do(struct ibmvfc_host *vhost) tgt->action == IBMVFC_TGT_ACTION_INIT_WAIT) return 1; } + list_for_each_entry(tgt, &vhost->nvme_scrqs.targets, queue) { + if (tgt->action == IBMVFC_TGT_ACTION_INIT || + tgt->action == IBMVFC_TGT_ACTION_INIT_WAIT) + return 1; + } return 0; } @@ -5712,6 +5717,11 @@ static int ibmvfc_dev_logo_to_do(struct ibmvfc_host *vhost) tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT) return 1; } + list_for_each_entry(tgt, &vhost->nvme_scrqs.targets, queue) { + if (tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT || + tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT) + return 1; + } return 0; } @@ -5740,9 +5750,15 @@ static int __ibmvfc_work_to_do(struct ibmvfc_host *vhost) list_for_each_entry(tgt, &vhost->scsi_scrqs.targets, queue) if (tgt->action == IBMVFC_TGT_ACTION_INIT) return 1; + list_for_each_entry(tgt, &vhost->nvme_scrqs.targets, queue) + if (tgt->action == IBMVFC_TGT_ACTION_INIT) + return 1; list_for_each_entry(tgt, &vhost->scsi_scrqs.targets, queue) if (tgt->action == IBMVFC_TGT_ACTION_INIT_WAIT) return 0; + list_for_each_entry(tgt, &vhost->nvme_scrqs.targets, queue) + if (tgt->action == IBMVFC_TGT_ACTION_INIT_WAIT) + return 0; return 1; case IBMVFC_HOST_ACTION_TGT_DEL: case IBMVFC_HOST_ACTION_TGT_DEL_FAILED: @@ -5751,9 +5767,15 @@ static int __ibmvfc_work_to_do(struct ibmvfc_host *vhost) list_for_each_entry(tgt, &vhost->scsi_scrqs.targets, queue) if (tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT) return 1; + list_for_each_entry(tgt, &vhost->nvme_scrqs.targets, queue) + if (tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT) + return 1; list_for_each_entry(tgt, &vhost->scsi_scrqs.targets, queue) if (tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT) return 0; + list_for_each_entry(tgt, &vhost->nvme_scrqs.targets, queue) + if (tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT) + return 0; return 1; case IBMVFC_HOST_ACTION_LOGO: case IBMVFC_HOST_ACTION_INIT: @@ -5941,6 +5963,8 @@ static void ibmvfc_do_work(struct ibmvfc_host *vhost) case IBMVFC_HOST_ACTION_QUERY: list_for_each_entry(tgt, &vhost->scsi_scrqs.targets, queue) ibmvfc_init_tgt(tgt, ibmvfc_tgt_query_target); + list_for_each_entry(tgt, &vhost->nvme_scrqs.targets, queue) + ibmvfc_init_tgt(tgt, ibmvfc_tgt_query_target); ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_QUERY_TGTS); break; case IBMVFC_HOST_ACTION_QUERY_TGTS: @@ -5950,6 +5974,12 @@ static void ibmvfc_do_work(struct ibmvfc_host *vhost) break; } } + list_for_each_entry(tgt, &vhost->nvme_scrqs.targets, queue) { + if (tgt->action == IBMVFC_TGT_ACTION_INIT) { + tgt->job_step(tgt); + break; + } + } if (!ibmvfc_dev_init_to_do(vhost)) ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_TGT_DEL); @@ -5962,6 +5992,12 @@ static void ibmvfc_do_work(struct ibmvfc_host *vhost) break; } } + list_for_each_entry(tgt, &vhost->nvme_scrqs.targets, queue) { + if (tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT) { + tgt->job_step(tgt); + break; + } + } if (ibmvfc_dev_logo_to_do(vhost)) { spin_unlock_irqrestore(vhost->host->host_lock, flags); @@ -6049,6 +6085,12 @@ static void ibmvfc_do_work(struct ibmvfc_host *vhost) break; } } + list_for_each_entry(tgt, &vhost->nvme_scrqs.targets, queue) { + if (tgt->action == IBMVFC_TGT_ACTION_INIT) { + tgt->job_step(tgt); + break; + } + } if (!ibmvfc_dev_init_to_do(vhost)) ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_TGT_DEL_FAILED); -- 2.54.0
