From 37c0a02e1c695c1597a6383454af2c0e2e548b9e Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Tue, 15 Oct 2019 07:36:04 -0700 Subject: [PATCH] env_dpdk: make spdk_env_init return real errnos The header file already says it returns negative errnos, but the env_dpdk implementation was just returning -1 on failure. Signed-off-by: Jim Harris Change-Id: Ie2236f83094672548327dba945b33e3f28fee338 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471421 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Tomasz Zawadzki --- lib/env_dpdk/init.c | 20 +++++++++++++------- lib/env_dpdk/memory.c | 4 ++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/env_dpdk/init.c b/lib/env_dpdk/init.c index b193182c3..49f9a8566 100644 --- a/lib/env_dpdk/init.c +++ b/lib/env_dpdk/init.c @@ -40,6 +40,7 @@ #include #include +#include #define SPDK_ENV_DPDK_DEFAULT_NAME "spdk" #define SPDK_ENV_DPDK_DEFAULT_SHM_ID -1 @@ -389,15 +390,20 @@ spdk_build_eal_cmdline(const struct spdk_env_opts *opts) int spdk_env_dpdk_post_init(void) { + int rc; + spdk_pci_init(); - if (spdk_mem_map_init() < 0) { + rc = spdk_mem_map_init(); + if (rc < 0) { fprintf(stderr, "Failed to allocate mem_map\n"); - return -1; + return rc; } - if (spdk_vtophys_init() < 0) { + + rc = spdk_vtophys_init(); + if (rc < 0) { fprintf(stderr, "Failed to initialize vtophys\n"); - return -1; + return rc; } return 0; @@ -423,7 +429,7 @@ spdk_env_init(const struct spdk_env_opts *opts) rc = spdk_build_eal_cmdline(opts); if (rc < 0) { fprintf(stderr, "Invalid arguments to initialize DPDK\n"); - return -1; + return -EINVAL; } printf("Starting %s / %s initialization...\n", SPDK_VERSION_STRING, rte_version()); @@ -440,7 +446,7 @@ spdk_env_init(const struct spdk_env_opts *opts) dpdk_args = calloc(g_eal_cmdline_argcount, sizeof(char *)); if (dpdk_args == NULL) { fprintf(stderr, "Failed to allocate dpdk_args\n"); - return -1; + return -ENOMEM; } memcpy(dpdk_args, g_eal_cmdline, sizeof(char *) * g_eal_cmdline_argcount); @@ -454,7 +460,7 @@ spdk_env_init(const struct spdk_env_opts *opts) if (rc < 0) { fprintf(stderr, "Failed to initialize DPDK\n"); - return -1; + return -rte_errno; } if (opts->shm_id < 0 && !opts->hugepage_single_segments) { diff --git a/lib/env_dpdk/memory.c b/lib/env_dpdk/memory.c index 73fe8ae2a..33e56fcc1 100644 --- a/lib/env_dpdk/memory.c +++ b/lib/env_dpdk/memory.c @@ -739,7 +739,7 @@ spdk_mem_map_init(void) g_mem_reg_map = spdk_mem_map_alloc(0, NULL, NULL); if (g_mem_reg_map == NULL) { DEBUG_PRINT("memory registration map allocation failed\n"); - return -1; + return -ENOMEM; } /* @@ -1348,7 +1348,7 @@ spdk_vtophys_init(void) g_vtophys_map = spdk_mem_map_alloc(SPDK_VTOPHYS_ERROR, &vtophys_map_ops, NULL); if (g_vtophys_map == NULL) { DEBUG_PRINT("vtophys map allocation failed\n"); - return -1; + return -ENOMEM; } return 0; }