From 4a3d5418c55e4be12528414610f98aaf80c70c4a Mon Sep 17 00:00:00 2001 From: Wojciech Malikowski Date: Mon, 3 Jun 2019 10:50:14 -0400 Subject: [PATCH] lib/vmd: Replace spdk_vmd_probe(bdf) with spdk_vmd_init() spdk_vmd_init() will attach all VMD devices that were unbinded from system. There is not need to specify VMD bdf in VMD public interface since it can be controlled by setup.sh script. Change-Id: Ifc45c32dc7e11b59429a41ddfdd596db30e27731 Signed-off-by: Wojciech Malikowski Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456631 Tested-by: SPDK CI Jenkins Reviewed-by: Darek Stojaczyk Reviewed-by: Shuhei Matsumoto --- examples/vmd/lsvmd/lsvmd.c | 7 +++---- include/spdk/vmd.h | 10 +++------- lib/vmd/vmd.c | 18 ++---------------- 3 files changed, 8 insertions(+), 27 deletions(-) diff --git a/examples/vmd/lsvmd/lsvmd.c b/examples/vmd/lsvmd/lsvmd.c index 0b7440911..c609715d9 100644 --- a/examples/vmd/lsvmd/lsvmd.c +++ b/examples/vmd/lsvmd/lsvmd.c @@ -62,9 +62,8 @@ parse_args(int argc, char **argv) int main(int argc, char **argv) { struct spdk_env_opts opts; - size_t vmd_cnt; - int rc = parse_args(argc, argv); + if (rc != 0) { return rc; } @@ -77,9 +76,9 @@ int main(int argc, char **argv) return 1; } - vmd_cnt = spdk_vmd_probe(&g_probe_addr); + rc = spdk_vmd_init(); - if (vmd_cnt == 0) { + if (rc) { SPDK_ERRLOG("No VMD Controllers found\n"); } diff --git a/include/spdk/vmd.h b/include/spdk/vmd.h index 6c68be026..5de5874c5 100644 --- a/include/spdk/vmd.h +++ b/include/spdk/vmd.h @@ -51,15 +51,11 @@ extern "C" { #define MAX_VMD_TARGET 24 /* - * Takes an input VMD D-BDF, probes it and attaches to it. The resulting vmd - * adapter is placed in a vmd container. If input BDF is NULL, then all VMD - * probed is consumed in the application VMD container list. + * Enumerate VMD devices and hook them into the spdk pci subsystem * - * \param vmd_bdf VMD BDF - * - * \return number of VMD devices available in the system + * \return 0 on success, -1 on failure */ -int spdk_vmd_probe(struct spdk_pci_addr *vmd_bdf); +int spdk_vmd_init(void); /* * Returns a list of nvme devices found on the given vmd pci BDF. diff --git a/lib/vmd/vmd.c b/lib/vmd/vmd.c index 83cc2053d..6669964c2 100644 --- a/lib/vmd/vmd.c +++ b/lib/vmd/vmd.c @@ -55,8 +55,6 @@ static unsigned char *device_type[] = { */ struct vmd_container { uint32_t count; - /* can target specific vmd or all vmd when null */ - struct spdk_pci_addr *vmd_target_addr; struct vmd_adapter vmd[MAX_VMD_SUPPORTED]; }; @@ -833,14 +831,6 @@ vmd_enum_cb(void *ctx, struct spdk_pci_device *pci_dev) struct vmd_container *vmd_c = ctx; size_t i; - /* - * If vmd target addr is NULL, then all spdk returned devices are consumed - */ - if (vmd_c->vmd_target_addr && - spdk_pci_addr_compare(&pci_dev->addr, vmd_c->vmd_target_addr)) { - return -1; - } - spdk_pci_device_cfg_read32(pci_dev, &cmd_reg, 4); cmd_reg |= 0x6; /* PCI bus master/memory enable. */ spdk_pci_device_cfg_write32(pci_dev, cmd_reg, 4); @@ -909,13 +899,9 @@ spdk_vmd_pci_device_list(struct spdk_pci_addr vmd_addr, struct spdk_pci_device * } int -spdk_vmd_probe(struct spdk_pci_addr *vmd_bdf) +spdk_vmd_init(void) { - g_vmd_container.vmd_target_addr = vmd_bdf; - spdk_pci_enumerate(spdk_pci_vmd_get_driver(), vmd_enum_cb, &g_vmd_container); - g_vmd_container.vmd_target_addr = NULL; - - return g_vmd_container.count; + return spdk_pci_enumerate(spdk_pci_vmd_get_driver(), vmd_enum_cb, &g_vmd_container); } SPDK_LOG_REGISTER_COMPONENT("vmd", SPDK_LOG_VMD)