nvme/deallocated_value: add vfio-user transport support

Change-Id: I1a87d9245ba8a4f4e01d510cae4a318fa3323ca2
Signed-off-by: Mao Jiang <maox.jiang@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10257
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Mao Jiang 2021-12-02 05:25:20 +00:00 committed by Tomasz Zawadzki
parent 5d926c48ea
commit 6fbaa11534
3 changed files with 84 additions and 3 deletions

View File

@ -33,8 +33,10 @@
#include "spdk/stdinc.h"
#include "spdk/log.h"
#include "spdk/nvme.h"
#include "spdk/env.h"
#include "spdk/string.h"
#define NUM_BLOCKS 100
@ -69,9 +71,81 @@ struct deallocate_context {
};
static struct ns_entry *g_namespaces = NULL;
static struct spdk_nvme_transport_id g_trid = {};
static void cleanup(struct deallocate_context *context);
static void
usage(const char *program_name)
{
printf("%s [options]", program_name);
printf("\t\n");
printf("options:\n");
printf("\t[-d DPDK huge memory size in MB]\n");
printf("\t[-g use single file descriptor for DPDK memory segments]\n");
printf("\t[-i shared memory group ID]\n");
printf("\t[-r remote NVMe over Fabrics target address]\n");
#ifdef DEBUG
printf("\t[-L enable debug logging]\n");
#else
printf("\t[-L enable debug logging (flag disabled, must reconfigure with --enable-debug)\n");
#endif
spdk_log_usage(stdout, "\t\t-L");
}
static int
parse_args(int argc, char **argv, struct spdk_env_opts *env_opts)
{
int op, rc;
spdk_nvme_trid_populate_transport(&g_trid, SPDK_NVME_TRANSPORT_PCIE);
snprintf(g_trid.subnqn, sizeof(g_trid.subnqn), "%s", SPDK_NVMF_DISCOVERY_NQN);
while ((op = getopt(argc, argv, "d:gi:r:L:")) != -1) {
switch (op) {
case 'd':
env_opts->mem_size = spdk_strtol(optarg, 10);
if (env_opts->mem_size < 0) {
fprintf(stderr, "Invalid DPDK memory size\n");
return env_opts->mem_size;
}
break;
case 'g':
env_opts->hugepage_single_segments = true;
break;
case 'i':
env_opts->shm_id = spdk_strtol(optarg, 10);
if (env_opts->shm_id < 0) {
fprintf(stderr, "Invalid shared memory ID\n");
return env_opts->shm_id;
}
break;
case 'r':
if (spdk_nvme_transport_id_parse(&g_trid, optarg) != 0) {
fprintf(stderr, "Error parsing transport address\n");
return 1;
}
break;
case 'L':
rc = spdk_log_set_flag(optarg);
if (rc < 0) {
fprintf(stderr, "unknown flag\n");
usage(argv[0]);
exit(EXIT_FAILURE);
}
#ifdef DEBUG
spdk_log_set_print_level(SPDK_LOG_DEBUG);
#endif
break;
default:
usage(argv[0]);
return 1;
}
}
return 0;
}
static void
fill_random(char *buf, size_t num_bytes)
{
@ -422,8 +496,12 @@ int main(int argc, char **argv)
struct spdk_env_opts opts;
spdk_env_opts_init(&opts);
rc = parse_args(argc, argv, &opts);
if (rc != 0) {
return rc;
}
opts.name = "deallocate_test";
opts.shm_id = 0;
if (spdk_env_init(&opts) < 0) {
fprintf(stderr, "Unable to initialize SPDK env\n");
return 1;
@ -431,7 +509,7 @@ int main(int argc, char **argv)
printf("Initializing NVMe Controllers\n");
rc = spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL);
rc = spdk_nvme_probe(&g_trid, NULL, probe_cb, attach_cb, NULL);
if (rc != 0) {
fprintf(stderr, "spdk_nvme_probe() failed\n");
return 1;

View File

@ -117,7 +117,7 @@ run_test "nvme_reset" $testdir/reset/reset -q 64 -w write -s 4096 -t 5
run_test "nvme_identify" nvme_identify
run_test "nvme_perf" nvme_perf
run_test "nvme_hello_world" $SPDK_EXAMPLE_DIR/hello_world -i 0
run_test "nvme_deallocated_value" $testdir/deallocated_value/deallocated_value
run_test "nvme_deallocated_value" $testdir/deallocated_value/deallocated_value -i 0
run_test "nvme_sgl" $testdir/sgl/sgl
run_test "nvme_e2edp" $testdir/e2edp/nvme_dp
run_test "nvme_reserve" $testdir/reserve/reserve

View File

@ -2,6 +2,7 @@
testdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $testdir/../../..)
nvmeappdir=$(readlink -f $rootdir/test/nvme)
source $rootdir/test/common/autotest_common.sh
source $rootdir/test/nvmf/common.sh
@ -53,6 +54,8 @@ for i in $(seq 1 $NUM_DEVICES); do
sleep 1
$SPDK_EXAMPLE_DIR/hello_world -d 256 -g -r "trtype:$TEST_TRANSPORT traddr:$test_traddr subnqn:$test_subnqn"
sleep 1
$nvmeappdir/deallocated_value/deallocated_value -g -d 256 -r "trtype:$TEST_TRANSPORT traddr:$test_traddr subnqn:$test_subnqn"
sleep 1
done
killprocess $nvmfpid