nvme: nvme_transport_ctrlr_scan now takes a transport id
Simplify the arguments to nvme_transport_ctrlr_scan to take a transport id that identifies the discovery service (or NULL to scan PCIe). Further, separate scan into two functions - scan and attach. Scan is for scanning an entire bus, attach is for a specific device. Change-Id: I464f351a02a04bc5a45096dcf5dc8fc5ac489041 Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
72a45a5a4e
commit
d70ff832bf
@ -392,7 +392,7 @@ static int
|
||||
nvme_attach_one(void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb attach_cb,
|
||||
struct spdk_pci_addr *pci_address)
|
||||
{
|
||||
nvme_transport_ctrlr_scan(SPDK_NVME_TRANSPORT_PCIE, probe_cb, cb_ctx, NULL, pci_address);
|
||||
nvme_transport_ctrlr_attach(SPDK_NVME_TRANSPORT_PCIE, probe_cb, cb_ctx, pci_address);
|
||||
return nvme_init_controllers(cb_ctx, attach_cb);
|
||||
}
|
||||
|
||||
@ -402,7 +402,6 @@ _spdk_nvme_probe(const struct spdk_nvme_transport_id *trid, void *cb_ctx,
|
||||
spdk_nvme_remove_cb remove_cb)
|
||||
{
|
||||
int rc;
|
||||
enum spdk_nvme_transport_type trtype;
|
||||
struct spdk_nvme_ctrlr *ctrlr;
|
||||
|
||||
rc = nvme_driver_init();
|
||||
@ -419,19 +418,15 @@ _spdk_nvme_probe(const struct spdk_nvme_transport_id *trid, void *cb_ctx,
|
||||
}
|
||||
}
|
||||
|
||||
if (!trid) {
|
||||
trtype = SPDK_NVME_TRANSPORT_PCIE;
|
||||
} else {
|
||||
if (trid) {
|
||||
if (!spdk_nvme_transport_available(trid->trtype)) {
|
||||
SPDK_ERRLOG("NVMe over Fabrics trtype %u not available\n", trid->trtype);
|
||||
nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
trtype = trid->trtype;
|
||||
}
|
||||
|
||||
nvme_transport_ctrlr_scan(trtype, probe_cb, cb_ctx, (void *)trid, NULL);
|
||||
nvme_transport_ctrlr_scan(trid, probe_cb, cb_ctx);
|
||||
|
||||
if (!spdk_process_is_primary()) {
|
||||
TAILQ_FOREACH(ctrlr, &g_spdk_nvme_driver->attached_ctrlrs, tailq) {
|
||||
|
@ -558,7 +558,8 @@ void nvme_qpair_print_completion(struct spdk_nvme_qpair *qpair, struct spdk_nvme
|
||||
struct spdk_nvme_ctrlr *nvme_ ## name ## _ctrlr_construct(enum spdk_nvme_transport_type trtype, 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_type trtype, spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle, void *pci_address); \
|
||||
int nvme_ ## name ## _ctrlr_scan(const struct spdk_nvme_transport_id *trid, spdk_nvme_probe_cb probe_cb, void *cb_ctx); \
|
||||
int nvme_ ## name ## _ctrlr_attach(enum spdk_nvme_transport_type trtype, spdk_nvme_probe_cb probe_cb, void *cb_ctx, struct spdk_pci_addr *addr); \
|
||||
int nvme_ ## name ## _ctrlr_enable(struct spdk_nvme_ctrlr *ctrlr); \
|
||||
int nvme_ ## name ## _ctrlr_get_pci_id(struct spdk_nvme_ctrlr *ctrlr, struct spdk_pci_id *pci_id); \
|
||||
int nvme_ ## name ## _ctrlr_set_reg_4(struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, uint32_t value); \
|
||||
|
@ -552,20 +552,28 @@ pcie_nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
||||
}
|
||||
|
||||
int
|
||||
nvme_pcie_ctrlr_scan(enum spdk_nvme_transport_type trtype,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx,
|
||||
void *devhandle, void *pci_address)
|
||||
nvme_pcie_ctrlr_scan(const struct spdk_nvme_transport_id *trid,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx)
|
||||
{
|
||||
struct nvme_pcie_enum_ctx enum_ctx;
|
||||
|
||||
enum_ctx.probe_cb = probe_cb;
|
||||
enum_ctx.cb_ctx = cb_ctx;
|
||||
if (!pci_address) {
|
||||
return spdk_pci_nvme_enumerate(pcie_nvme_enum_cb, &enum_ctx);
|
||||
} else {
|
||||
return spdk_pci_nvme_device_attach(pcie_nvme_enum_cb, &enum_ctx,
|
||||
(struct spdk_pci_addr *)pci_address);
|
||||
}
|
||||
|
||||
return spdk_pci_nvme_enumerate(pcie_nvme_enum_cb, &enum_ctx);
|
||||
}
|
||||
|
||||
int
|
||||
nvme_pcie_ctrlr_attach(enum spdk_nvme_transport_type trtype,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx,
|
||||
struct spdk_pci_addr *pci_addr)
|
||||
{
|
||||
struct nvme_pcie_enum_ctx enum_ctx;
|
||||
|
||||
enum_ctx.probe_cb = probe_cb;
|
||||
enum_ctx.cb_ctx = cb_ctx;
|
||||
|
||||
return spdk_pci_nvme_device_attach(pcie_nvme_enum_cb, &enum_ctx, pci_addr);
|
||||
}
|
||||
|
||||
struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(enum spdk_nvme_transport_type trtype,
|
||||
|
@ -1051,11 +1051,9 @@ nvme_fabrics_get_log_discovery_page(struct spdk_nvme_ctrlr *ctrlr,
|
||||
|
||||
/* This function must only be called while holding g_spdk_nvme_driver->lock */
|
||||
int
|
||||
nvme_rdma_ctrlr_scan(enum spdk_nvme_transport_type trtype,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx,
|
||||
void *devhandle, void *pci_address)
|
||||
nvme_rdma_ctrlr_scan(const struct spdk_nvme_transport_id *trid,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx)
|
||||
{
|
||||
struct spdk_nvme_transport_id *trid = devhandle;
|
||||
struct spdk_nvme_probe_info probe_info;
|
||||
struct spdk_nvme_ctrlr_opts discovery_opts;
|
||||
struct spdk_nvme_ctrlr *discovery_ctrlr;
|
||||
@ -1069,13 +1067,14 @@ nvme_rdma_ctrlr_scan(enum spdk_nvme_transport_type trtype,
|
||||
/* For discovery_ctrlr set the timeout to 0 */
|
||||
discovery_opts.keep_alive_timeout_ms = 0;
|
||||
|
||||
probe_info.trid.trtype = (uint8_t)trtype;
|
||||
probe_info.trid.trtype = SPDK_NVME_TRANSPORT_RDMA;
|
||||
snprintf(probe_info.trid.subnqn, sizeof(probe_info.trid.subnqn), "%s", trid->subnqn);
|
||||
snprintf(probe_info.trid.traddr, sizeof(probe_info.trid.traddr), "%s", trid->traddr);
|
||||
snprintf(probe_info.trid.trsvcid, sizeof(probe_info.trid.trsvcid), "%s", trid->trsvcid);
|
||||
|
||||
memset(buffer, 0x0, 4096);
|
||||
discovery_ctrlr = nvme_rdma_ctrlr_construct(trtype, &discovery_opts, &probe_info, devhandle);
|
||||
discovery_ctrlr = nvme_rdma_ctrlr_construct(SPDK_NVME_TRANSPORT_RDMA, &discovery_opts, &probe_info,
|
||||
NULL);
|
||||
if (discovery_ctrlr == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@ -1150,6 +1149,15 @@ nvme_rdma_ctrlr_scan(enum spdk_nvme_transport_type trtype,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
nvme_rdma_ctrlr_attach(enum spdk_nvme_transport_type trtype,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx,
|
||||
struct spdk_pci_addr *addr)
|
||||
{
|
||||
/* Not implemented yet */
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct spdk_nvme_ctrlr *
|
||||
nvme_rdma_ctrlr_construct(enum spdk_nvme_transport_type trtype,
|
||||
const struct spdk_nvme_ctrlr_opts *opts,
|
||||
|
@ -91,11 +91,18 @@ struct spdk_nvme_ctrlr *
|
||||
}
|
||||
|
||||
int
|
||||
nvme_transport_ctrlr_scan(enum spdk_nvme_transport_type trtype,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx,
|
||||
void *devhandle, void *pci_address)
|
||||
nvme_transport_ctrlr_scan(const struct spdk_nvme_transport_id *trid,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx)
|
||||
{
|
||||
NVME_TRANSPORT_CALL(trtype, ctrlr_scan, (trtype, probe_cb, cb_ctx, devhandle, pci_address));
|
||||
NVME_TRANSPORT_CALL(trid->trtype, ctrlr_scan, (trid, probe_cb, cb_ctx));
|
||||
}
|
||||
|
||||
int
|
||||
nvme_transport_ctrlr_attach(enum spdk_nvme_transport_type trtype,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx,
|
||||
struct spdk_pci_addr *addr)
|
||||
{
|
||||
NVME_TRANSPORT_CALL(trtype, ctrlr_attach, (trtype, probe_cb, cb_ctx, addr));
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -71,9 +71,16 @@ struct spdk_nvme_ctrlr *
|
||||
}
|
||||
|
||||
int
|
||||
nvme_transport_ctrlr_scan(enum spdk_nvme_transport_type trtype,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx,
|
||||
void *devhandle, void *pci_address)
|
||||
nvme_transport_ctrlr_scan(const struct spdk_nvme_transport_id *trid,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
nvme_transport_ctrlr_attach(enum spdk_nvme_transport_type trtype,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx,
|
||||
struct spdk_pci_addr *addr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -194,9 +194,16 @@ nvme_ctrlr_get_ref_count(struct spdk_nvme_ctrlr *ctrlr)
|
||||
}
|
||||
|
||||
int
|
||||
nvme_transport_ctrlr_scan(enum spdk_nvme_transport_type trtype,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx,
|
||||
void *devhandle, void *pci_address)
|
||||
nvme_transport_ctrlr_scan(const struct spdk_nvme_transport_id *trid,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
nvme_transport_ctrlr_attach(enum spdk_nvme_transport_type trtype,
|
||||
spdk_nvme_probe_cb probe_cb, void *cb_ctx,
|
||||
struct spdk_pci_addr *addr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user