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;
|
||||
void *cb_arg;
|
||||
pthread_mutex_t mtx;
|
||||
bool is_registered;
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
if (!ctx->is_registered) {
|
||||
ctx->is_registered = true;
|
||||
rte_eal_pci_register(&ctx->driver);
|
||||
}
|
||||
|
||||
ctx->cb_fn = enum_cb;
|
||||
ctx->cb_arg = enum_ctx;
|
||||
|
||||
@ -136,6 +141,11 @@ spdk_pci_enumerate(struct spdk_pci_enum_ctx *ctx,
|
||||
{
|
||||
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_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)
|
||||
.probe = spdk_pci_device_init,
|
||||
.remove = spdk_pci_device_fini,
|
||||
.driver.name = "spdk_ioat",
|
||||
#else
|
||||
.devinit = spdk_pci_device_init,
|
||||
.devuninit = spdk_pci_device_fini,
|
||||
@ -105,31 +106,9 @@ static struct spdk_pci_enum_ctx g_ioat_pci_drv = {
|
||||
.cb_fn = NULL,
|
||||
.cb_arg = NULL,
|
||||
.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
|
||||
spdk_pci_ioat_device_attach(spdk_pci_enum_cb enum_cb, void *enum_ctx,
|
||||
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)
|
||||
.probe = spdk_pci_device_init,
|
||||
.remove = spdk_pci_device_fini,
|
||||
.driver.name = "spdk_nvme",
|
||||
#else
|
||||
.devinit = spdk_pci_device_init,
|
||||
.devuninit = spdk_pci_device_fini,
|
||||
@ -67,31 +68,9 @@ static struct spdk_pci_enum_ctx g_nvme_pci_drv = {
|
||||
.cb_fn = NULL,
|
||||
.cb_arg = NULL,
|
||||
.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
|
||||
spdk_pci_nvme_device_attach(spdk_pci_enum_cb enum_cb,
|
||||
void *enum_ctx, struct spdk_pci_addr *pci_address)
|
||||
|
Loading…
Reference in New Issue
Block a user