nvmf: support static CNTLID
SPDK NVMf subsystem supports dynamic controller model, for transports other fabrics, users should use static controller model. Change-Id: I364ea61a71b04d51932fd9e0e16f401a383ff67c Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10149 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
76159db955
commit
2a6c2c289c
@ -334,8 +334,8 @@ nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
|
||||
struct spdk_nvmf_fabric_connect_cmd *connect_cmd,
|
||||
struct spdk_nvmf_fabric_connect_data *connect_data)
|
||||
{
|
||||
struct spdk_nvmf_ctrlr *ctrlr;
|
||||
struct spdk_nvmf_transport *transport;
|
||||
struct spdk_nvmf_ctrlr *ctrlr;
|
||||
struct spdk_nvmf_transport *transport = req->qpair->transport;
|
||||
struct spdk_nvme_transport_id listen_trid = {};
|
||||
|
||||
ctrlr = calloc(1, sizeof(*ctrlr));
|
||||
@ -344,13 +344,18 @@ nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (spdk_nvme_trtype_is_fabrics(transport->ops->type)) {
|
||||
ctrlr->dynamic_ctrlr = true;
|
||||
} else {
|
||||
ctrlr->cntlid = connect_data->cntlid;
|
||||
}
|
||||
|
||||
STAILQ_INIT(&ctrlr->async_events);
|
||||
TAILQ_INIT(&ctrlr->log_head);
|
||||
ctrlr->subsys = subsystem;
|
||||
ctrlr->thread = req->qpair->group->thread;
|
||||
ctrlr->disconnect_in_progress = false;
|
||||
|
||||
transport = req->qpair->transport;
|
||||
ctrlr->qpair_mask = spdk_bit_array_create(transport->opts.max_qpairs_per_ctrlr);
|
||||
if (!ctrlr->qpair_mask) {
|
||||
SPDK_ERRLOG("Failed to allocate controller qpair mask\n");
|
||||
@ -743,7 +748,7 @@ _nvmf_ctrlr_connect(struct spdk_nvmf_request *req)
|
||||
if (cmd->qid == 0) {
|
||||
SPDK_DEBUGLOG(nvmf, "Connect Admin Queue for controller ID 0x%x\n", data->cntlid);
|
||||
|
||||
if (data->cntlid != 0xFFFF) {
|
||||
if (spdk_nvme_trtype_is_fabrics(transport->ops->type) && data->cntlid != 0xFFFF) {
|
||||
/* This NVMf target only supports dynamic mode. */
|
||||
SPDK_ERRLOG("The NVMf target only supports dynamic mode (CNTLID = 0x%x).\n", data->cntlid);
|
||||
SPDK_NVMF_INVALID_CONNECT_DATA(rsp, cntlid);
|
||||
|
@ -275,6 +275,7 @@ struct spdk_nvmf_ctrlr {
|
||||
/* valid only when disconnect_in_progress is true */
|
||||
bool disconnect_is_shn;
|
||||
bool acre_enabled;
|
||||
bool dynamic_ctrlr;
|
||||
|
||||
TAILQ_ENTRY(spdk_nvmf_ctrlr) link;
|
||||
};
|
||||
|
@ -1928,11 +1928,17 @@ nvmf_subsystem_gen_cntlid(struct spdk_nvmf_subsystem *subsystem)
|
||||
int
|
||||
nvmf_subsystem_add_ctrlr(struct spdk_nvmf_subsystem *subsystem, struct spdk_nvmf_ctrlr *ctrlr)
|
||||
{
|
||||
ctrlr->cntlid = nvmf_subsystem_gen_cntlid(subsystem);
|
||||
if (ctrlr->cntlid == 0xFFFF) {
|
||||
/* Unable to get a cntlid */
|
||||
SPDK_ERRLOG("Reached max simultaneous ctrlrs\n");
|
||||
return -EBUSY;
|
||||
|
||||
if (ctrlr->dynamic_ctrlr) {
|
||||
ctrlr->cntlid = nvmf_subsystem_gen_cntlid(subsystem);
|
||||
if (ctrlr->cntlid == 0xFFFF) {
|
||||
/* Unable to get a cntlid */
|
||||
SPDK_ERRLOG("Reached max simultaneous ctrlrs\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
} else if (nvmf_subsystem_get_ctrlr(subsystem, ctrlr->cntlid) != NULL) {
|
||||
SPDK_ERRLOG("Ctrlr with cntlid %u already exist\n", ctrlr->cntlid);
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
TAILQ_INSERT_TAIL(&subsystem->ctrlrs, ctrlr, link);
|
||||
|
@ -1471,6 +1471,7 @@ test_nvmf_subsystem_add_ctrlr(void)
|
||||
SPDK_CU_ASSERT_FATAL(subsystem != NULL);
|
||||
ctrlr.subsys = subsystem;
|
||||
|
||||
ctrlr.dynamic_ctrlr = true;
|
||||
rc = nvmf_subsystem_add_ctrlr(subsystem, &ctrlr);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(!TAILQ_EMPTY(&subsystem->ctrlrs));
|
||||
|
Loading…
Reference in New Issue
Block a user