nvme: pass opts and probe_info to nvme_attach()
Let the transport access the controller options during ctrlr_construct(). Change-Id: I83590c111e75c843685dd9315f0f08416168356d Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
02a142abee
commit
ba16e46349
@ -47,11 +47,14 @@ struct nvme_driver *g_spdk_nvme_driver = &_g_nvme_driver;
|
||||
int32_t spdk_nvme_retry_count;
|
||||
|
||||
struct spdk_nvme_ctrlr *
|
||||
nvme_attach(enum spdk_nvme_transport transport, void *devhandle)
|
||||
nvme_attach(enum spdk_nvme_transport transport,
|
||||
const struct spdk_nvme_ctrlr_opts *opts,
|
||||
const struct spdk_nvme_probe_info *probe_info,
|
||||
void *devhandle)
|
||||
{
|
||||
struct spdk_nvme_ctrlr *ctrlr;
|
||||
|
||||
ctrlr = nvme_transport_ctrlr_construct(transport, devhandle);
|
||||
ctrlr = nvme_transport_ctrlr_construct(transport, opts, probe_info, devhandle);
|
||||
|
||||
return ctrlr;
|
||||
}
|
||||
@ -238,15 +241,12 @@ nvme_probe_one(enum spdk_nvme_transport transport, spdk_nvme_probe_cb probe_cb,
|
||||
spdk_nvme_ctrlr_opts_set_defaults(&opts);
|
||||
|
||||
if (probe_cb(cb_ctx, probe_info, &opts)) {
|
||||
ctrlr = nvme_attach(transport, devhandle);
|
||||
ctrlr = nvme_attach(transport, &opts, probe_info, devhandle);
|
||||
if (ctrlr == NULL) {
|
||||
SPDK_ERRLOG("nvme_attach() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctrlr->opts = opts;
|
||||
ctrlr->probe_info = *probe_info;
|
||||
|
||||
TAILQ_INSERT_TAIL(&g_spdk_nvme_driver->init_ctrlrs, ctrlr, tailq);
|
||||
}
|
||||
|
||||
|
@ -536,11 +536,15 @@ int nvme_mutex_init_recursive_shared(pthread_mutex_t *mtx);
|
||||
bool nvme_completion_is_retry(const struct spdk_nvme_cpl *cpl);
|
||||
void nvme_qpair_print_command(struct spdk_nvme_qpair *qpair, struct spdk_nvme_cmd *cmd);
|
||||
void nvme_qpair_print_completion(struct spdk_nvme_qpair *qpair, struct spdk_nvme_cpl *cpl);
|
||||
struct spdk_nvme_ctrlr *nvme_attach(enum spdk_nvme_transport transport, void *devhandle);
|
||||
struct spdk_nvme_ctrlr *nvme_attach(enum spdk_nvme_transport transport,
|
||||
const struct spdk_nvme_ctrlr_opts *opts,
|
||||
const struct spdk_nvme_probe_info *probe_info,
|
||||
void *devhandle);
|
||||
|
||||
/* Transport specific functions */
|
||||
#define DECLARE_TRANSPORT(name) \
|
||||
struct spdk_nvme_ctrlr *nvme_ ## name ## _ctrlr_construct(enum spdk_nvme_transport transport, void *devhandle); \
|
||||
struct spdk_nvme_ctrlr *nvme_ ## name ## _ctrlr_construct(enum spdk_nvme_transport transport, const struct spdk_nvme_ctrlr_opts *opts, \
|
||||
const struct spdk_nvme_probe_info *probe_info, void *devhandle); \
|
||||
int nvme_ ## name ## _ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr); \
|
||||
int nvme_ ## name ## _ctrlr_scan(enum spdk_nvme_transport transport, spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle); \
|
||||
int nvme_ ## name ## _ctrlr_enable(struct spdk_nvme_ctrlr *ctrlr); \
|
||||
|
@ -554,6 +554,8 @@ nvme_pcie_ctrlr_scan(enum spdk_nvme_transport transport,
|
||||
}
|
||||
|
||||
struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(enum spdk_nvme_transport transport,
|
||||
const struct spdk_nvme_ctrlr_opts *opts,
|
||||
const struct spdk_nvme_probe_info *probe_info,
|
||||
void *devhandle)
|
||||
{
|
||||
struct spdk_pci_device *pci_dev = devhandle;
|
||||
@ -571,6 +573,8 @@ struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(enum spdk_nvme_transport trans
|
||||
pctrlr->is_remapped = false;
|
||||
pctrlr->ctrlr.transport = SPDK_NVME_TRANSPORT_PCIE;
|
||||
pctrlr->devhandle = devhandle;
|
||||
pctrlr->ctrlr.opts = *opts;
|
||||
pctrlr->ctrlr.probe_info = *probe_info;
|
||||
|
||||
rc = nvme_pcie_ctrlr_allocate_bars(pctrlr);
|
||||
if (rc != 0) {
|
||||
|
@ -1077,6 +1077,7 @@ nvme_rdma_ctrlr_scan(enum spdk_nvme_transport transport,
|
||||
{
|
||||
struct spdk_nvme_discover_info *discover_info = devhandle;
|
||||
struct spdk_nvme_probe_info probe_info;
|
||||
struct spdk_nvme_ctrlr_opts discovery_opts;
|
||||
struct spdk_nvme_ctrlr *discovery_ctrlr;
|
||||
struct spdk_nvmf_discovery_log_page *log_page;
|
||||
union spdk_nvme_cc_register cc;
|
||||
@ -1084,13 +1085,15 @@ nvme_rdma_ctrlr_scan(enum spdk_nvme_transport transport,
|
||||
int rc;
|
||||
uint32_t i;
|
||||
|
||||
spdk_nvme_ctrlr_opts_set_defaults(&discovery_opts);
|
||||
|
||||
probe_info.trtype = (uint8_t)transport;
|
||||
snprintf(probe_info.nqn, sizeof(probe_info.nqn), "%s", discover_info->nqn);
|
||||
snprintf(probe_info.traddr, sizeof(probe_info.traddr), "%s", discover_info->traddr);
|
||||
snprintf(probe_info.trsvcid, sizeof(probe_info.trsvcid), "%s", discover_info->trsvcid);
|
||||
|
||||
memset(buffer, 0x0, 4096);
|
||||
discovery_ctrlr = nvme_attach(transport, &probe_info);
|
||||
discovery_ctrlr = nvme_attach(transport, &discovery_opts, &probe_info, NULL);
|
||||
if (discovery_ctrlr == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@ -1155,7 +1158,7 @@ nvme_rdma_ctrlr_scan(enum spdk_nvme_transport transport,
|
||||
SPDK_TRACELOG(SPDK_TRACE_DEBUG, "nqn=%s, trtype=%u, traddr=%s, trsvcid=%s\n", probe_info.nqn,
|
||||
probe_info.trtype, probe_info.traddr, probe_info.trsvcid);
|
||||
/* Todo: need to differentiate the NVMe over fabrics to avoid duplicated connection */
|
||||
nvme_probe_one(entry->trtype, probe_cb, cb_ctx, &probe_info, &probe_info);
|
||||
nvme_probe_one(entry->trtype, probe_cb, cb_ctx, &probe_info, NULL);
|
||||
}
|
||||
|
||||
nvme_ctrlr_destruct(discovery_ctrlr);
|
||||
@ -1163,19 +1166,14 @@ nvme_rdma_ctrlr_scan(enum spdk_nvme_transport transport,
|
||||
}
|
||||
|
||||
struct spdk_nvme_ctrlr *nvme_rdma_ctrlr_construct(enum spdk_nvme_transport transport,
|
||||
const struct spdk_nvme_ctrlr_opts *opts,
|
||||
const struct spdk_nvme_probe_info *probe_info,
|
||||
void *devhandle)
|
||||
{
|
||||
struct nvme_rdma_ctrlr *rctrlr;
|
||||
struct spdk_nvme_probe_info *probe_info;
|
||||
union spdk_nvme_cap_register cap;
|
||||
int rc;
|
||||
|
||||
if (!devhandle) {
|
||||
SPDK_ERRLOG("devhandle is NULL\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
probe_info = devhandle;
|
||||
rctrlr = calloc(1, sizeof(struct nvme_rdma_ctrlr));
|
||||
if (rctrlr == NULL) {
|
||||
SPDK_ERRLOG("could not allocate ctrlr\n");
|
||||
@ -1183,6 +1181,7 @@ struct spdk_nvme_ctrlr *nvme_rdma_ctrlr_construct(enum spdk_nvme_transport trans
|
||||
}
|
||||
|
||||
rctrlr->ctrlr.transport = SPDK_NVME_TRANSPORT_RDMA;
|
||||
rctrlr->ctrlr.opts = *opts;
|
||||
rctrlr->ctrlr.probe_info = *probe_info;
|
||||
|
||||
rc = nvme_ctrlr_construct(&rctrlr->ctrlr);
|
||||
|
@ -85,9 +85,11 @@ spdk_nvme_transport_available(enum spdk_nvmf_trtype trtype)
|
||||
}
|
||||
|
||||
struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(enum spdk_nvme_transport transport,
|
||||
const struct spdk_nvme_ctrlr_opts *opts,
|
||||
const struct spdk_nvme_probe_info *probe_info,
|
||||
void *devhandle)
|
||||
{
|
||||
NVME_TRANSPORT_CALL(transport, ctrlr_construct, (transport, devhandle));
|
||||
NVME_TRANSPORT_CALL(transport, ctrlr_construct, (transport, opts, probe_info, devhandle));
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -64,6 +64,8 @@ spdk_nvme_transport_available(enum spdk_nvmf_trtype trtype)
|
||||
}
|
||||
|
||||
struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(enum spdk_nvme_transport transport,
|
||||
const struct spdk_nvme_ctrlr_opts *opts,
|
||||
const struct spdk_nvme_probe_info *probe_info,
|
||||
void *devhandle)
|
||||
{
|
||||
return NULL;
|
||||
|
@ -62,6 +62,8 @@ struct spdk_nvme_registers g_ut_nvme_regs = {};
|
||||
__thread int nvme_thread_ioq_index = -1;
|
||||
|
||||
struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(enum spdk_nvme_transport transport,
|
||||
const struct spdk_nvme_ctrlr_opts *opts,
|
||||
const struct spdk_nvme_probe_info *probe_info,
|
||||
void *devhandle)
|
||||
{
|
||||
return NULL;
|
||||
|
@ -63,6 +63,8 @@ spdk_nvme_transport_available(enum spdk_nvmf_trtype trtype)
|
||||
}
|
||||
|
||||
struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(enum spdk_nvme_transport transport,
|
||||
const struct spdk_nvme_ctrlr_opts *opts,
|
||||
const struct spdk_nvme_probe_info *probe_info,
|
||||
void *devhandle)
|
||||
{
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user