From bf291ad88a70322730d7989f4663e5920bee1403 Mon Sep 17 00:00:00 2001 From: Jiri Prokes Date: Tue, 24 Oct 2017 06:17:16 -0700 Subject: [PATCH] Correction of tracing from child process - There was read 16kb from pipe but only less then 1kb was traced. Rest of trace data was lost. Added support for two EAL parameters: LogLevel - optional EAL paramenter which enable debug traces from rte libs If parameter is not used default trace level = 7 (INFO) is used LogLevel "8" - (DEBUG) can be set to collectd.conf into dpdkstat EAL section RteDriverLibPath - optional EAL parameter which enable loading of shared pmd driver libs. Param value can be full path to single pmd diriver lib or directory where pmd driver libs are located. E.g.: "/usr/lib/dpdk-pmd/librte_pmd_i40e.so" or "/usr/lib/dpdk-pmd" Signed-off-by: Jiri Prokes --- src/utils_dpdk.c | 29 +++++++++++++++++++++++++---- src/utils_dpdk.h | 2 ++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/utils_dpdk.c b/src/utils_dpdk.c index 77f596eb..55ff7bc4 100644 --- a/src/utils_dpdk.c +++ b/src/utils_dpdk.c @@ -44,8 +44,9 @@ #include "utils_dpdk.h" #define DPDK_DEFAULT_RTE_CONFIG "/var/run/.rte_config" -#define DPDK_EAL_ARGC 5 -#define DPDK_MAX_BUFFER_SIZE (4096 * 4) +#define DPDK_EAL_ARGC 10 +//Complete trace should fit into 1024 chars +#define DPDK_MAX_BUFFER_SIZE 896 #define DPDK_CDM_DEFAULT_TIMEOUT 10000 enum DPDK_HELPER_STATUS { @@ -185,6 +186,14 @@ int dpdk_helper_eal_config_parse(dpdk_helper_ctx_t *phc, oconfig_item_t *ci) { "/var/run/.%s_config", prefix); DEBUG("dpdk_common: EAL:File prefix %s", phc->eal_config.file_prefix); } + } else if (strcasecmp("LogLevel", child->key) == 0) { + status = cf_util_get_string_buffer(child, phc->eal_config.log_level, + sizeof(phc->eal_config.log_level)); + DEBUG("dpdk_common: EAL:LogLevel %s", phc->eal_config.log_level); + } else if (strcasecmp("RteDriverLibPath", child->key) == 0) { + status = cf_util_get_string_buffer(child, phc->eal_config.rte_driver_lib_path, + sizeof(phc->eal_config.rte_driver_lib_path)); + DEBUG("dpdk_common: EAL:RteDriverLibPath %s", phc->eal_config.rte_driver_lib_path); } else { ERROR("dpdk_common: Invalid '%s' configuration option", child->key); status = -EINVAL; @@ -493,6 +502,15 @@ static int dpdk_helper_eal_init(dpdk_helper_ctx_t *phc) { argp[argc++] = "--proc-type"; argp[argc++] = "secondary"; + if (strcasecmp(phc->eal_config.log_level, "") != 0) { + argp[argc++] = "--log-level"; + argp[argc++] = phc->eal_config.log_level; + } + if (strcasecmp(phc->eal_config.rte_driver_lib_path, "") != 0) { + argp[argc++] = "-d"; + argp[argc++] = phc->eal_config.rte_driver_lib_path; + } + assert(argc <= (DPDK_EAL_ARGC * 2 + 1)); int ret = rte_eal_init(argc, argp); @@ -697,6 +715,7 @@ static void dpdk_helper_check_pipe(dpdk_helper_ctx_t *phc) { .fd = phc->pipes[0], .events = POLLIN, }; int data_avail = poll(&fds, 1, 0); + DEBUG("%s:dpdk_helper_check_pipe: poll data_avail=%d", phc->shm_name, data_avail); if (data_avail < 0) { if (errno != EINTR || errno != EAGAIN) { char errbuf[ERR_BUF_SIZE]; @@ -705,10 +724,12 @@ static void dpdk_helper_check_pipe(dpdk_helper_ctx_t *phc) { } } while (data_avail) { - int nbytes = read(phc->pipes[0], buf, sizeof(buf)); + int nbytes = read(phc->pipes[0], buf, (sizeof(buf) - 1)); + DEBUG("%s:dpdk_helper_check_pipe: read nbytes=%d", phc->shm_name, nbytes); if (nbytes <= 0) break; - sstrncpy(out, buf, nbytes); + buf[nbytes] = '\n'; + sstrncpy(out, buf, (nbytes + 1)); DEBUG("%s: helper process:\n%s", phc->shm_name, out); } } diff --git a/src/utils_dpdk.h b/src/utils_dpdk.h index 23941dfc..e8d85357 100644 --- a/src/utils_dpdk.h +++ b/src/utils_dpdk.h @@ -51,6 +51,8 @@ struct dpdk_eal_config_s { char memory_channels[DATA_MAX_NAME_LEN]; char socket_memory[DATA_MAX_NAME_LEN]; char file_prefix[DATA_MAX_NAME_LEN]; + char log_level[DATA_MAX_NAME_LEN]; + char rte_driver_lib_path[DATA_MAX_NAME_LEN]; }; typedef struct dpdk_eal_config_s dpdk_eal_config_t; -- 2.30.2