nvmf: consolidate CC reset and shutdown
nvmf_ctrlr_cc_shn_done() and nvmf_ctrlr_cc_reset_done() are almost same, so consolidate them together by adding a flag. Change-Id: Ib7714d31a40f9d8d344ec2630c083c5d76dac8a1 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9907 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
20627a1a36
commit
0119293b74
@ -931,7 +931,7 @@ nvmf_ctrlr_association_remove(void *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nvmf_ctrlr_cc_shn_done(struct spdk_io_channel_iter *i, int status)
|
nvmf_ctrlr_cc_reset_shn_done(struct spdk_io_channel_iter *i, int status)
|
||||||
{
|
{
|
||||||
struct spdk_nvmf_ctrlr *ctrlr = spdk_io_channel_iter_get_ctx(i);
|
struct spdk_nvmf_ctrlr *ctrlr = spdk_io_channel_iter_get_ctx(i);
|
||||||
|
|
||||||
@ -940,34 +940,14 @@ nvmf_ctrlr_cc_shn_done(struct spdk_io_channel_iter *i, int status)
|
|||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrlr->vcprop.csts.bits.shst = SPDK_NVME_SHST_COMPLETE;
|
if (ctrlr->disconnect_is_shn) {
|
||||||
|
ctrlr->vcprop.csts.bits.shst = SPDK_NVME_SHST_COMPLETE;
|
||||||
/* After CC.EN transitions to 0 (due to shutdown or reset), the association
|
ctrlr->disconnect_is_shn = false;
|
||||||
* between the host and controller shall be preserved for at least 2 minutes */
|
} else {
|
||||||
if (ctrlr->association_timer) {
|
/* Only a subset of the registers are cleared out on a reset */
|
||||||
SPDK_DEBUGLOG(nvmf, "Association timer already set\n");
|
ctrlr->vcprop.cc.raw = 0;
|
||||||
nvmf_ctrlr_stop_association_timer(ctrlr);
|
ctrlr->vcprop.csts.raw = 0;
|
||||||
}
|
}
|
||||||
if (ctrlr->association_timeout) {
|
|
||||||
ctrlr->association_timer = SPDK_POLLER_REGISTER(nvmf_ctrlr_association_remove, ctrlr,
|
|
||||||
ctrlr->association_timeout * 1000);
|
|
||||||
}
|
|
||||||
ctrlr->disconnect_in_progress = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
nvmf_ctrlr_cc_reset_done(struct spdk_io_channel_iter *i, int status)
|
|
||||||
{
|
|
||||||
struct spdk_nvmf_ctrlr *ctrlr = spdk_io_channel_iter_get_ctx(i);
|
|
||||||
|
|
||||||
if (status < 0) {
|
|
||||||
SPDK_ERRLOG("Fail to disconnect io ctrlr qpairs\n");
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only a subset of the registers are cleared out on a reset */
|
|
||||||
ctrlr->vcprop.cc.raw = 0;
|
|
||||||
ctrlr->vcprop.csts.raw = 0;
|
|
||||||
|
|
||||||
/* After CC.EN transitions to 0 (due to shutdown or reset), the association
|
/* After CC.EN transitions to 0 (due to shutdown or reset), the association
|
||||||
* between the host and controller shall be preserved for at least 2 minutes */
|
* between the host and controller shall be preserved for at least 2 minutes */
|
||||||
@ -1031,12 +1011,18 @@ nvmf_prop_set_cc(struct spdk_nvmf_ctrlr *ctrlr, uint32_t value)
|
|||||||
ctrlr->vcprop.csts.bits.rdy = 1;
|
ctrlr->vcprop.csts.bits.rdy = 1;
|
||||||
} else {
|
} else {
|
||||||
SPDK_DEBUGLOG(nvmf, "Property Set CC Disable!\n");
|
SPDK_DEBUGLOG(nvmf, "Property Set CC Disable!\n");
|
||||||
|
if (ctrlr->disconnect_in_progress) {
|
||||||
|
SPDK_DEBUGLOG(nvmf, "Disconnect in progress\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ctrlr->vcprop.cc.bits.en = 0;
|
ctrlr->vcprop.cc.bits.en = 0;
|
||||||
ctrlr->disconnect_in_progress = true;
|
ctrlr->disconnect_in_progress = true;
|
||||||
|
ctrlr->disconnect_is_shn = false;
|
||||||
spdk_for_each_channel(ctrlr->subsys->tgt,
|
spdk_for_each_channel(ctrlr->subsys->tgt,
|
||||||
nvmf_ctrlr_disconnect_io_qpairs_on_pg,
|
nvmf_ctrlr_disconnect_io_qpairs_on_pg,
|
||||||
ctrlr,
|
ctrlr,
|
||||||
nvmf_ctrlr_cc_reset_done);
|
nvmf_ctrlr_cc_reset_shn_done);
|
||||||
}
|
}
|
||||||
diff.bits.en = 0;
|
diff.bits.en = 0;
|
||||||
}
|
}
|
||||||
@ -1046,12 +1032,18 @@ nvmf_prop_set_cc(struct spdk_nvmf_ctrlr *ctrlr, uint32_t value)
|
|||||||
cc.bits.shn == SPDK_NVME_SHN_ABRUPT) {
|
cc.bits.shn == SPDK_NVME_SHN_ABRUPT) {
|
||||||
SPDK_DEBUGLOG(nvmf, "Property Set CC Shutdown %u%ub!\n",
|
SPDK_DEBUGLOG(nvmf, "Property Set CC Shutdown %u%ub!\n",
|
||||||
cc.bits.shn >> 1, cc.bits.shn & 1);
|
cc.bits.shn >> 1, cc.bits.shn & 1);
|
||||||
|
if (ctrlr->disconnect_in_progress) {
|
||||||
|
SPDK_DEBUGLOG(nvmf, "Disconnect in progress\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ctrlr->vcprop.cc.bits.shn = cc.bits.shn;
|
ctrlr->vcprop.cc.bits.shn = cc.bits.shn;
|
||||||
ctrlr->disconnect_in_progress = true;
|
ctrlr->disconnect_in_progress = true;
|
||||||
|
ctrlr->disconnect_is_shn = true;
|
||||||
spdk_for_each_channel(ctrlr->subsys->tgt,
|
spdk_for_each_channel(ctrlr->subsys->tgt,
|
||||||
nvmf_ctrlr_disconnect_io_qpairs_on_pg,
|
nvmf_ctrlr_disconnect_io_qpairs_on_pg,
|
||||||
ctrlr,
|
ctrlr,
|
||||||
nvmf_ctrlr_cc_shn_done);
|
nvmf_ctrlr_cc_reset_shn_done);
|
||||||
|
|
||||||
/* From the time a shutdown is initiated the controller shall disable
|
/* From the time a shutdown is initiated the controller shall disable
|
||||||
* Keep Alive timer */
|
* Keep Alive timer */
|
||||||
|
@ -269,6 +269,8 @@ struct spdk_nvmf_ctrlr {
|
|||||||
bool dif_insert_or_strip;
|
bool dif_insert_or_strip;
|
||||||
bool in_destruct;
|
bool in_destruct;
|
||||||
bool disconnect_in_progress;
|
bool disconnect_in_progress;
|
||||||
|
/* valid only when disconnect_in_progress is true */
|
||||||
|
bool disconnect_is_shn;
|
||||||
bool acre_enabled;
|
bool acre_enabled;
|
||||||
|
|
||||||
TAILQ_ENTRY(spdk_nvmf_ctrlr) link;
|
TAILQ_ENTRY(spdk_nvmf_ctrlr) link;
|
||||||
|
Loading…
Reference in New Issue
Block a user