env: register PMDs on associated first probe
This avoids registering PMDs that are not used by a given application. For example, an app may wish to *not* use ioat - in this case, ioat PMD would not be registered with DPDK, and we would not waste time probing these devices when probing other devices like NVMe. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: If378e40bde9057c7808603aa1918bcfe80fa0e9d
This commit is contained in:
parent
a8bfa65ff2
commit
16bbcb3f36
@ -61,6 +61,7 @@ struct spdk_pci_enum_ctx {
|
|||||||
spdk_pci_enum_cb cb_fn;
|
spdk_pci_enum_cb cb_fn;
|
||||||
void *cb_arg;
|
void *cb_arg;
|
||||||
pthread_mutex_t mtx;
|
pthread_mutex_t mtx;
|
||||||
|
bool is_registered;
|
||||||
};
|
};
|
||||||
|
|
||||||
int spdk_pci_device_init(struct rte_pci_driver *driver, struct rte_pci_device *device);
|
int spdk_pci_device_init(struct rte_pci_driver *driver, struct rte_pci_device *device);
|
||||||
|
@ -108,6 +108,11 @@ spdk_pci_device_attach(struct spdk_pci_enum_ctx *ctx,
|
|||||||
|
|
||||||
pthread_mutex_lock(&ctx->mtx);
|
pthread_mutex_lock(&ctx->mtx);
|
||||||
|
|
||||||
|
if (!ctx->is_registered) {
|
||||||
|
ctx->is_registered = true;
|
||||||
|
rte_eal_pci_register(&ctx->driver);
|
||||||
|
}
|
||||||
|
|
||||||
ctx->cb_fn = enum_cb;
|
ctx->cb_fn = enum_cb;
|
||||||
ctx->cb_arg = enum_ctx;
|
ctx->cb_arg = enum_ctx;
|
||||||
|
|
||||||
@ -136,6 +141,11 @@ spdk_pci_enumerate(struct spdk_pci_enum_ctx *ctx,
|
|||||||
{
|
{
|
||||||
pthread_mutex_lock(&ctx->mtx);
|
pthread_mutex_lock(&ctx->mtx);
|
||||||
|
|
||||||
|
if (!ctx->is_registered) {
|
||||||
|
ctx->is_registered = true;
|
||||||
|
rte_eal_pci_register(&ctx->driver);
|
||||||
|
}
|
||||||
|
|
||||||
ctx->cb_fn = enum_cb;
|
ctx->cb_fn = enum_cb;
|
||||||
ctx->cb_arg = enum_ctx;
|
ctx->cb_arg = enum_ctx;
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ static struct spdk_pci_enum_ctx g_ioat_pci_drv = {
|
|||||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
||||||
.probe = spdk_pci_device_init,
|
.probe = spdk_pci_device_init,
|
||||||
.remove = spdk_pci_device_fini,
|
.remove = spdk_pci_device_fini,
|
||||||
|
.driver.name = "spdk_ioat",
|
||||||
#else
|
#else
|
||||||
.devinit = spdk_pci_device_init,
|
.devinit = spdk_pci_device_init,
|
||||||
.devuninit = spdk_pci_device_fini,
|
.devuninit = spdk_pci_device_fini,
|
||||||
@ -105,31 +106,9 @@ static struct spdk_pci_enum_ctx g_ioat_pci_drv = {
|
|||||||
.cb_fn = NULL,
|
.cb_fn = NULL,
|
||||||
.cb_arg = NULL,
|
.cb_arg = NULL,
|
||||||
.mtx = PTHREAD_MUTEX_INITIALIZER,
|
.mtx = PTHREAD_MUTEX_INITIALIZER,
|
||||||
|
.is_registered = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
|
||||||
RTE_PMD_REGISTER_PCI(spdk_ioat, g_ioat_pci_drv.driver);
|
|
||||||
#else
|
|
||||||
static int
|
|
||||||
spdk_ioat_drv_register(const char *name __rte_unused, const char *params __rte_unused)
|
|
||||||
{
|
|
||||||
rte_eal_pci_register(&g_ioat_pci_drv.driver);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct rte_driver g_ioat_drv = {
|
|
||||||
.type = PMD_PDEV,
|
|
||||||
.init = spdk_ioat_drv_register,
|
|
||||||
};
|
|
||||||
|
|
||||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 7, 0, 0)
|
|
||||||
PMD_REGISTER_DRIVER(g_ioat_drv, spdk_ioat);
|
|
||||||
#else
|
|
||||||
PMD_REGISTER_DRIVER(g_ioat_drv);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
spdk_pci_ioat_device_attach(spdk_pci_enum_cb enum_cb, void *enum_ctx,
|
spdk_pci_ioat_device_attach(spdk_pci_enum_cb enum_cb, void *enum_ctx,
|
||||||
struct spdk_pci_addr *pci_address)
|
struct spdk_pci_addr *pci_address)
|
||||||
|
@ -57,6 +57,7 @@ static struct spdk_pci_enum_ctx g_nvme_pci_drv = {
|
|||||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
||||||
.probe = spdk_pci_device_init,
|
.probe = spdk_pci_device_init,
|
||||||
.remove = spdk_pci_device_fini,
|
.remove = spdk_pci_device_fini,
|
||||||
|
.driver.name = "spdk_nvme",
|
||||||
#else
|
#else
|
||||||
.devinit = spdk_pci_device_init,
|
.devinit = spdk_pci_device_init,
|
||||||
.devuninit = spdk_pci_device_fini,
|
.devuninit = spdk_pci_device_fini,
|
||||||
@ -67,31 +68,9 @@ static struct spdk_pci_enum_ctx g_nvme_pci_drv = {
|
|||||||
.cb_fn = NULL,
|
.cb_fn = NULL,
|
||||||
.cb_arg = NULL,
|
.cb_arg = NULL,
|
||||||
.mtx = PTHREAD_MUTEX_INITIALIZER,
|
.mtx = PTHREAD_MUTEX_INITIALIZER,
|
||||||
|
.is_registered = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
|
||||||
RTE_PMD_REGISTER_PCI(spdk_nvme, g_nvme_pci_drv.driver);
|
|
||||||
#else
|
|
||||||
static int
|
|
||||||
spdk_nvme_drv_register(const char *name __rte_unused, const char *params __rte_unused)
|
|
||||||
{
|
|
||||||
rte_eal_pci_register(&g_nvme_pci_drv.driver);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct rte_driver g_nvme_drv = {
|
|
||||||
.type = PMD_PDEV,
|
|
||||||
.init = spdk_nvme_drv_register,
|
|
||||||
};
|
|
||||||
|
|
||||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 7, 0, 0)
|
|
||||||
PMD_REGISTER_DRIVER(g_nvme_drv, spdk_nvme);
|
|
||||||
#else
|
|
||||||
PMD_REGISTER_DRIVER(g_nvme_drv);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
spdk_pci_nvme_device_attach(spdk_pci_enum_cb enum_cb,
|
spdk_pci_nvme_device_attach(spdk_pci_enum_cb enum_cb,
|
||||||
void *enum_ctx, struct spdk_pci_addr *pci_address)
|
void *enum_ctx, struct spdk_pci_addr *pci_address)
|
||||||
|
Loading…
Reference in New Issue
Block a user