Auto-Merge pull request #2505 from jiriproX/dpdkstat_enh
authorcollectd bot <32910397+collectd-bot@users.noreply.github.com>
Wed, 25 Oct 2017 18:09:09 +0000 (20:09 +0200)
committerGitHub <noreply@github.com>
Wed, 25 Oct 2017 18:09:09 +0000 (20:09 +0200)
Automatically merged due to "Automerge" label

src/collectd.conf.in
src/collectd.conf.pod
src/utils_dpdk.c
src/utils_dpdk.h

index 261abdf..2051f38 100644 (file)
 #    Coremask "0x2"
 #    MemoryChannels "4"
 #    FilePrefix "rte"
+#    LogLevel "7"
+#    RteDriverLibPath "/usr/lib/dpdk-pmd"
 #  </EAL>
 #  SharedMemObj "dpdk_collectd_stats_0"
 #  EnabledPortMask 0xffff
index cf76e63..97d184a 100644 (file)
@@ -2572,6 +2572,8 @@ B<Synopsis:>
      MemoryChannels "4"
      FilePrefix "rte"
      SocketMemory "1024"
+     LogLevel "7"
+     RteDriverLibPath "/usr/lib/dpdk-pmd"
    </EAL>
    SharedMemObj "dpdk_collectd_stats_0"
    EnabledPortMask 0xffff
@@ -2604,6 +2606,20 @@ The prefix text used for hugepage filenames. The filename will be set to
 A string containing amount of Memory to allocate from hugepages on specific
 sockets in MB. This is an optional value.
 
+=item B<LogLevel> I<LogLevel_number>
+
+A string containing log level number. This parameter is optional.
+If parameter is not present then default value "7" - (INFO) is used.
+Value "8" - (DEBUG) can be set to enable debug traces.
+
+=item B<RteDriverLibPath> I<Path>
+
+A string containing path to shared pmd driver lib or path to directory,
+where shared pmd driver libs are available. This parameter is optional.
+This parameter enable loading of shared pmd driver libs from defined path.
+E.g.: "/usr/lib/dpdk-pmd/librte_pmd_i40e.so"
+or    "/usr/lib/dpdk-pmd"
+
 =back
 
 =over 3
index 77f596e..fbdcaf8 100644 (file)
 #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. Trace contain some headers
+// and text together with traced data from pipe. This is the reason why
+// we need to limit DPDK_MAX_BUFFER_SIZE value.
+#define DPDK_MAX_BUFFER_SIZE 896
 #define DPDK_CDM_DEFAULT_TIMEOUT 10000
 
 enum DPDK_HELPER_STATUS {
@@ -182,9 +185,19 @@ int dpdk_helper_eal_config_parse(dpdk_helper_ctx_t *phc, oconfig_item_t *ci) {
       status = cf_util_get_string_buffer(child, prefix, sizeof(prefix));
       if (status == 0) {
         snprintf(phc->eal_config.file_prefix, DATA_MAX_NAME_LEN,
-                  "/var/run/.%s_config", prefix);
+                 "/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 +506,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 +719,8 @@ 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 +729,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] = '\0';
+    sstrncpy(out, buf, sizeof(out));
     DEBUG("%s: helper process:\n%s", phc->shm_name, out);
   }
 }
index 23941df..f3b7e7f 100644 (file)
@@ -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[PATH_MAX];
 };
 typedef struct dpdk_eal_config_s dpdk_eal_config_t;