examples/lsvmd: list VMD devices

This example application only enumerated VMD devices but didn't do
anything else.  Now it goes over all PCI devices and prints those behind
the VMD.

Change-Id: I6134088e820a90c203200294540cb8174b1a492e
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471480
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Wojciech Malikowski <wojciech.malikowski@intel.com>
This commit is contained in:
Konrad Sztyber 2019-10-16 11:48:03 +02:00 committed by Jim Harris
parent 6caed6bac8
commit 4f011ef7c3

View File

@ -33,6 +33,7 @@
#include "spdk/stdinc.h" #include "spdk/stdinc.h"
#include "spdk/log.h" #include "spdk/log.h"
#include "spdk/env.h"
#include "spdk/vmd.h" #include "spdk/vmd.h"
struct spdk_pci_addr g_probe_addr; struct spdk_pci_addr g_probe_addr;
@ -68,8 +69,11 @@ parse_args(int argc, char **argv)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
struct spdk_env_opts opts; struct spdk_env_opts opts;
int rc = parse_args(argc, argv); struct spdk_pci_device *pci_device;
char addr_buf[128];
int rc;
rc = parse_args(argc, argv);
if (rc != 0) { if (rc != 0) {
return rc; return rc;
} }
@ -83,10 +87,22 @@ int main(int argc, char **argv)
} }
rc = spdk_vmd_init(); rc = spdk_vmd_init();
if (rc) { if (rc) {
SPDK_ERRLOG("No VMD Controllers found\n"); SPDK_ERRLOG("No VMD Controllers found\n");
} }
for (pci_device = spdk_pci_get_first_device(); pci_device != NULL;
pci_device = spdk_pci_get_next_device(pci_device)) {
if (strcmp(spdk_pci_device_get_type(pci_device), "vmd") == 0) {
rc = spdk_pci_addr_fmt(addr_buf, sizeof(addr_buf), &pci_device->addr);
if (rc != 0) {
fprintf(stderr, "Failed to format VMD's PCI address\n");
continue;
}
printf("%s\n", addr_buf);
}
}
return rc; return rc;
} }