Commit e87a3247 authored by Jacek Kalwas's avatar Jacek Kalwas Committed by Jim Harris
Browse files

nvme: add spdk_nvme_transport_id_usage util function



This change aims to help with maitanance by reducing the code
duplication. It should also help with the code readability as usage
opts are self explanatory. It should eventually help with having
correct description for new apps. Far almost all in-tree spdk apps
there were issues (see prev commit). It proves that current
copy/paste/adjust solution doesn't work well.

There is higher chance developer will make it right upfront or reviewer
will spot the inconsistency easier. By having correct app args
description end user experiance should be better.

Change-Id: I0a763672d5cecdc29946154a61c9a168853347ce
Signed-off-by: default avatarJacek Kalwas <jacek.kalwas@nutanix.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/25858


Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarKonrad Sztyber <ksztyber@nvidia.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarAnkit Kumar <ankit.kumar@samsung.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Community-CI: Mellanox Build Bot
parent e3a05e99
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@

#include "spdk/env.h"
#include "spdk/nvme.h"
#include "spdk_internal/nvme_util.h"
#include "spdk/queue.h"
#include "spdk/string.h"
#include "spdk/util.h"
@@ -108,14 +109,10 @@ usage(char *program_name)
{
	printf("%s options", program_name);
	printf("\n");
	printf("\t-r, --transport <fmt> Transport ID for NVMeoF discovery subsystem\n");
	printf("\t Format: 'key:value [key:value] ...'\n");
	printf("\t Keys:\n");
	printf("\t  trtype      Transport type (e.g. TCP, RDMA)\n");
	printf("\t  adrfam      Address family (e.g. IPv4, IPv6)\n");
	printf("\t  traddr      Transport address (e.g. 192.168.100.8)\n");
	printf("\t  trsvcid     Transport service identifier (e.g. 4420)\n");
	printf("\t Example: -r 'trtype:TCP adrfam:IPv4 traddr:192.168.100.8 trsvcid:4420'\n");
	spdk_nvme_transport_id_usage(stdout,
				     SPDK_NVME_TRID_USAGE_OPT_MANDATORY | SPDK_NVME_TRID_USAGE_OPT_LONGOPT |
				     SPDK_NVME_TRID_USAGE_OPT_NO_PCIE);
	printf("\t\tNote: Transport ID can be specified for NVMeoF discovery subsystem only.\n");
	printf("\t");
	spdk_log_usage(stdout, "-T");
#ifdef DEBUG
+2 −10
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include "spdk/endian.h"
#include "spdk/log.h"
#include "spdk/nvme.h"
#include "spdk_internal/nvme_util.h"
#include "spdk/vmd.h"
#include "spdk/nvme_ocssd.h"
#include "spdk/nvme_zns.h"
@@ -2730,16 +2731,7 @@ usage(const char *program_name)
	printf("%s [options]", program_name);
	printf("\n");
	printf("options:\n");
	printf("\t[-r trid    Transport ID for local PCIe NVMe or NVMeoF]\n");
	printf("\t   Format: 'key:value [key:value] ...'\n");
	printf("\t   Keys:\n");
	printf("\t    trtype      Transport type (e.g. RDMA)\n");
	printf("\t    adrfam      Address family (e.g. IPv4, IPv6)\n");
	printf("\t    traddr      Transport address (e.g. 192.168.100.8)\n");
	printf("\t    trsvcid     Transport service identifier (e.g. 4420)\n");
	printf("\t    subnqn      Subsystem NQN (default: %s)\n", SPDK_NVMF_DISCOVERY_NQN);
	printf("\t    hostnqn     Host NQN\n");
	printf("\t   Example: -r 'trtype:RDMA adrfam:IPv4 traddr:192.168.100.8 trsvcid:4420'\n");
	spdk_nvme_transport_id_usage(stdout, SPDK_NVME_TRID_USAGE_OPT_HOSTNQN);
	spdk_log_usage(stdout, "-L");
	printf("\t-i         shared memory group ID\n");
	printf("\t-p         core number in decimal to run this application which started from 0\n");
+4 −13
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include "spdk/env.h"
#include "spdk/fd.h"
#include "spdk/nvme.h"
#include "spdk_internal/nvme_util.h"
#include "spdk/vmd.h"
#include "spdk/queue.h"
#include "spdk/string.h"
@@ -1895,19 +1896,9 @@ usage(char *program_name)
	printf("\t-a, --warmup-time <sec> warmup time in seconds\n");
	printf("\t-c, --core-mask <mask> core mask for I/O submission/completion.\n");
	printf("\t\t(default: 1)\n");
	printf("\t[-r, --transport <fmt> Transport ID for local PCIe NVMe or NVMeoF]\n");
	printf("\t\t Format: 'key:value [key:value] ...'\n");
	printf("\t\t Keys:\n");
	printf("\t\t  trtype      Transport type (e.g. PCIe, RDMA)\n");
	printf("\t\t  adrfam      Address family (e.g. IPv4, IPv6)\n");
	printf("\t\t  traddr      Transport address (e.g. 0000:04:00.0 for PCIe or 192.168.100.8 for RDMA)\n");
	printf("\t\t  trsvcid     Transport service identifier (e.g. 4420)\n");
	printf("\t\t  subnqn      Subsystem NQN (default: %s)\n", SPDK_NVMF_DISCOVERY_NQN);
	printf("\t\t  ns          NVMe namespace ID (all active namespaces are used by default)\n");
	printf("\t\t  hostnqn     Host NQN\n");
	printf("\t\t Example: -r 'trtype:PCIe traddr:0000:04:00.0' for PCIe or\n");
	printf("\t\t          -r 'trtype:RDMA adrfam:IPv4 traddr:192.168.100.8 trsvcid:4420' for NVMeoF\n");
	printf("\t\t Note: can be specified multiple times to test multiple disks/targets.\n");
	spdk_nvme_transport_id_usage(stdout,
				     SPDK_NVME_TRID_USAGE_OPT_LONGOPT | SPDK_NVME_TRID_USAGE_OPT_MULTI | SPDK_NVME_TRID_USAGE_OPT_NS |
				     SPDK_NVME_TRID_USAGE_OPT_HOSTNQN);
	printf("\n");

	printf("==== ADVANCED OPTIONS ====\n\n");
+2 −12
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include "spdk/env.h"
#include "spdk/log.h"
#include "spdk/nvme.h"
#include "spdk_internal/nvme_util.h"
#include "spdk/queue.h"
#include "spdk/string.h"
#include "spdk/util.h"
@@ -552,18 +553,7 @@ usage(char *program_name)
	printf("\t[-t time in seconds]\n");
	printf("\t[-c core mask for I/O submission/completion.]\n");
	printf("\t\t(default: 1)\n");
	printf("\t[-r Transport ID for local PCIe NVMe or NVMeoF]\n");
	printf("\t Format: 'key:value [key:value] ...'\n");
	printf("\t Keys:\n");
	printf("\t  trtype      Transport type (e.g. PCIe, RDMA)\n");
	printf("\t  adrfam      Address family (e.g. IPv4, IPv6)\n");
	printf("\t  traddr      Transport address (e.g. 0000:04:00.0 for PCIe or 192.168.100.8 for RDMA)\n");
	printf("\t  trsvcid     Transport service identifier (e.g. 4420)\n");
	printf("\t  subnqn      Subsystem NQN (default: %s)\n", SPDK_NVMF_DISCOVERY_NQN);
	printf("\t  ns          NVMe namespace ID (all active namespaces are used by default)");
	printf("\t Example: -r 'trtype:PCIe traddr:0000:04:00.0' for PCIe or\n");
	printf("\t          -r 'trtype:RDMA adrfam:IPv4 traddr:192.168.100.8 trsvcid:4420' for NVMeoF\n");
	printf("\t\t Note: can be specified multiple times to test multiple disks/targets.\n");
	spdk_nvme_transport_id_usage(stdout, SPDK_NVME_TRID_USAGE_OPT_MULTI | SPDK_NVME_TRID_USAGE_OPT_NS);
	printf("\t[-s DPDK huge memory size in MB.]\n");
	printf("\t[-i shared memory group ID]\n");
	printf("\t[-a abort interval.]\n");
+2 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@

#include "spdk/log.h"
#include "spdk/nvme.h"
#include "spdk_internal/nvme_util.h"
#include "spdk/env.h"
#include "spdk/string.h"
#include "spdk/nvme_intel.h"
@@ -482,7 +483,7 @@ usage(char *program_name)
	printf("\t\t(0 - disabled; 1 - enabled)\n");
	printf("\t[-n subjected IOs for performance comparison]\n");
	printf("\t[-i shared memory group ID]\n");
	printf("\t[-r Transport ID for local PCIe NVMe or NVMeoF]\n");
	spdk_nvme_transport_id_usage(stdout, 0);
	printf("\t[-g use single file descriptor for DPDK memory segments]\n");
}

Loading