nvme/perf: allow multiple -r (transport ID) arguments
This allows the user to connect to multiple remote NVMe-oF targets or to specify multiple specific PCIe device addresses to test. Change-Id: I05b2072b8aa1480891b37b17b5207369344b617d Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
d63a30e39d
commit
f12e7085ec
@ -43,6 +43,7 @@
|
|||||||
#include "spdk/fd.h"
|
#include "spdk/fd.h"
|
||||||
#include "spdk/nvme.h"
|
#include "spdk/nvme.h"
|
||||||
#include "spdk/env.h"
|
#include "spdk/env.h"
|
||||||
|
#include "spdk/queue.h"
|
||||||
#include "spdk/string.h"
|
#include "spdk/string.h"
|
||||||
#include "spdk/nvme_intel.h"
|
#include "spdk/nvme_intel.h"
|
||||||
|
|
||||||
@ -149,7 +150,13 @@ static uint32_t g_max_completions;
|
|||||||
static int g_dpdk_mem;
|
static int g_dpdk_mem;
|
||||||
|
|
||||||
static const char *g_core_mask;
|
static const char *g_core_mask;
|
||||||
static char *g_nvmf_discover_info;
|
|
||||||
|
struct trid_entry {
|
||||||
|
struct spdk_nvme_transport_id trid;
|
||||||
|
TAILQ_ENTRY(trid_entry) tailq;
|
||||||
|
};
|
||||||
|
|
||||||
|
static TAILQ_HEAD(, trid_entry) g_trid_list = TAILQ_HEAD_INITIALIZER(g_trid_list);
|
||||||
|
|
||||||
static int g_aio_optind; /* Index of first AIO filename in argv */
|
static int g_aio_optind; /* Index of first AIO filename in argv */
|
||||||
|
|
||||||
@ -795,6 +802,42 @@ print_stats(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
unregister_trids(void)
|
||||||
|
{
|
||||||
|
struct trid_entry *trid_entry, *tmp;
|
||||||
|
|
||||||
|
TAILQ_FOREACH_SAFE(trid_entry, &g_trid_list, tailq, tmp) {
|
||||||
|
free(trid_entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
add_trid(const char *trid_str)
|
||||||
|
{
|
||||||
|
struct trid_entry *trid_entry;
|
||||||
|
struct spdk_nvme_transport_id *trid;
|
||||||
|
|
||||||
|
trid_entry = calloc(1, sizeof(*trid_entry));
|
||||||
|
if (trid_entry == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
trid = &trid_entry->trid;
|
||||||
|
memset(trid, 0, sizeof(*trid));
|
||||||
|
trid->trtype = SPDK_NVME_TRANSPORT_PCIE;
|
||||||
|
snprintf(trid->subnqn, sizeof(trid->subnqn), "%s", SPDK_NVMF_DISCOVERY_NQN);
|
||||||
|
|
||||||
|
if (spdk_nvme_transport_id_parse(trid, trid_str) != 0) {
|
||||||
|
fprintf(stderr, "Invalid transport ID format '%s'\n", trid_str);
|
||||||
|
free(trid_entry);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAILQ_INSERT_TAIL(&g_trid_list, trid_entry, tailq);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
parse_args(int argc, char **argv)
|
parse_args(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -829,7 +872,10 @@ parse_args(int argc, char **argv)
|
|||||||
g_queue_depth = atoi(optarg);
|
g_queue_depth = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
g_nvmf_discover_info = optarg;
|
if (add_trid(optarg)) {
|
||||||
|
usage(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
g_io_size_bytes = atoi(optarg);
|
g_io_size_bytes = atoi(optarg);
|
||||||
@ -917,6 +963,11 @@ parse_args(int argc, char **argv)
|
|||||||
g_is_random = 1;
|
g_is_random = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TAILQ_EMPTY(&g_trid_list)) {
|
||||||
|
/* If no transport IDs specified, default to enumerating all local PCIe devices */
|
||||||
|
add_trid("trtype:pcie");
|
||||||
|
}
|
||||||
|
|
||||||
g_aio_optind = optind;
|
g_aio_optind = optind;
|
||||||
optind = 1;
|
optind = 1;
|
||||||
return 0;
|
return 0;
|
||||||
@ -1046,25 +1097,15 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
|||||||
static int
|
static int
|
||||||
register_controllers(void)
|
register_controllers(void)
|
||||||
{
|
{
|
||||||
struct spdk_nvme_transport_id trid;
|
struct trid_entry *trid_entry;
|
||||||
|
|
||||||
printf("Initializing NVMe Controllers\n");
|
printf("Initializing NVMe Controllers\n");
|
||||||
|
|
||||||
if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) {
|
TAILQ_FOREACH(trid_entry, &g_trid_list, tailq) {
|
||||||
fprintf(stderr, "spdk_nvme_probe() failed\n");
|
if (spdk_nvme_probe(&trid_entry->trid, NULL, probe_cb, attach_cb, NULL) != 0) {
|
||||||
}
|
fprintf(stderr, "spdk_nvme_probe() failed for transport address '%s'\n",
|
||||||
|
trid_entry->trid.traddr);
|
||||||
if (g_nvmf_discover_info) {
|
return -1;
|
||||||
memset(&trid, 0, sizeof(trid));
|
|
||||||
snprintf(trid.subnqn, sizeof(trid.subnqn), "%s", SPDK_NVMF_DISCOVERY_NQN);
|
|
||||||
|
|
||||||
if (spdk_nvme_transport_id_parse(&trid, g_nvmf_discover_info) != 0) {
|
|
||||||
fprintf(stderr, "Invalid transport ID format\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (spdk_nvme_probe(&trid, NULL, probe_cb, attach_cb, NULL) != 0) {
|
|
||||||
fprintf(stderr, "spdk_nvme_probe() failed\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1254,6 +1295,7 @@ int main(int argc, char **argv)
|
|||||||
print_stats();
|
print_stats();
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
unregister_trids();
|
||||||
unregister_namespaces();
|
unregister_namespaces();
|
||||||
unregister_controllers();
|
unregister_controllers();
|
||||||
unregister_workers();
|
unregister_workers();
|
||||||
|
Loading…
Reference in New Issue
Block a user