From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6759AA0583; Thu, 19 Mar 2020 18:37:57 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5D6401C116; Thu, 19 Mar 2020 18:35:19 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 170401C10D for ; Thu, 19 Mar 2020 18:35:17 +0100 (CET) IronPort-SDR: 1AOGyXua16ojn6xx+tOAu8Ju5z2GBpq27KV0mdRBz+zwrI4zvcEcjEHAIXkGz3Dx0kaTS5TsuS ny6tm5sZDN7Q== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Mar 2020 10:35:17 -0700 IronPort-SDR: OazyGZVBF71YT0fF04766aCZeZ37nRB+CjmnnrQ/r2us0vU9lQsO7AHK1ogw+LEvm1DeZmSWFj cCQ/BBpEO7Jw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,572,1574150400"; d="scan'208";a="391872779" Received: from silpixa00399953.ir.intel.com (HELO silpixa00399953.ger.corp.intel.com) ([10.237.222.53]) by orsmga004.jf.intel.com with ESMTP; 19 Mar 2020 10:35:14 -0700 From: Ciara Power To: kevin.laatz@intel.com Cc: dev@dpdk.org, reshma.pattan@intel.com, Bruce Richardson , Ciara Power Date: Thu, 19 Mar 2020 17:19:07 +0000 Message-Id: <20200319171907.60891-13-ciara.power@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200319171907.60891-1-ciara.power@intel.com> References: <20200319171907.60891-1-ciara.power@intel.com> Subject: [dpdk-dev] [PATCH 12/12] eal: add eal telemetry callbacks X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Bruce Richardson EAL now registers commands to provide some basic info from EAL. Example: Connecting to /var/run/dpdk/rte/dpdk_telemetry.66307 --> / {"/": ["/", "/eal/app_params", "/eal/params", "/eal/version", "/ethdev/list", "/ethdev/stats", "/rawdev/list", "/rawdev/stats"]} --> /eal/app_params {"/eal/app_params": ["-i"]} --> /eal/params {"/eal/params": ["./app/dpdk-testpmd", "--telemetry"]} --> /eal/version {"/eal/version": "DPDK 20.05.0-rc0"} Signed-off-by: Bruce Richardson Signed-off-by: Ciara Power --- lib/librte_eal/common/eal_common_options.c | 70 ++++++++++++++++++++++ lib/librte_eal/common/eal_options.h | 3 + lib/librte_eal/freebsd/eal/eal.c | 5 ++ lib/librte_eal/linux/eal/eal.c | 5 ++ 4 files changed, 83 insertions(+) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 386566b3d..78cd1f825 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "eal_internal_cfg.h" #include "eal_options.h" @@ -132,6 +133,75 @@ static int master_lcore_parsed; static int mem_parsed; static int core_parsed; +static char **eal_args; +static char **eal_app_args; + +#define EAL_PARAM_REQ "/eal/params" +#define EAL_APP_PARAM_REQ "/eal/app_params" + +/* callback handler for telemetry library to report out EAL flags */ +int +handle_eal_info_request(const char *cmd, const char *params __rte_unused, + char *buffer, int buf_len) +{ + char **args; + int used = 0; + int i = 0; + + if (strcmp(cmd, EAL_PARAM_REQ) == 0) + args = eal_args; + else if (strcmp(cmd, EAL_APP_PARAM_REQ) == 0) + args = eal_app_args; + else /* version */ + return snprintf(buffer, buf_len, "\"%s\"", rte_version()); + + if (args == NULL || args[0] == NULL) + return snprintf(buffer, buf_len, "[]"); /* empty list */ + + used = strlcpy(buffer, "[", buf_len); + while (args[i] != NULL) + used += snprintf(buffer + used, buf_len - used, "\"%s\",", + args[i++]); + buffer[used - 1] = ']'; + return used; +} + +int +eal_save_args(int argc, char **argv) +{ + int i, j; + + /* clone argv to report out later. We overprovision, but + * this does not waste huge amounts of memory + */ + eal_args = calloc(argc + 1, sizeof(*eal_args)); + if (eal_args == NULL) + return -1; + + for (i = 0; i < argc; i++) { + eal_args[i] = strdup(argv[i]); + if (strcmp(argv[i], "--") == 0) + break; + } + eal_args[i++] = NULL; /* always finish with NULL */ + rte_telemetry_register_cmd(EAL_PARAM_REQ, handle_eal_info_request); + + /* allow reporting of any app args we know about too */ + if (i == argc) + return 0; + + eal_app_args = calloc(argc - i + 1, sizeof(*eal_args)); + if (eal_app_args == NULL) + return -1; + + for (j = 0; i < argc; j++, i++) + eal_app_args[j] = strdup(argv[i]); + eal_app_args[j] = NULL; + rte_telemetry_register_cmd(EAL_APP_PARAM_REQ, handle_eal_info_request); + + return 0; +} + static int eal_option_device_add(enum rte_devtype type, const char *optarg) { diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h index 225ad4bb5..5373e9f5e 100644 --- a/lib/librte_eal/common/eal_options.h +++ b/lib/librte_eal/common/eal_options.h @@ -88,5 +88,8 @@ int eal_check_common_options(struct internal_config *internal_cfg); void eal_common_usage(void); enum rte_proc_type_t eal_proc_type_detect(void); int eal_plugins_init(void); +int eal_save_args(int argc, char **argv); +int handle_eal_info_request(const char *cmd, const char *params __rte_unused, + char *buffer, int buf_len); #endif /* EAL_OPTIONS_H */ diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c index 54acafc31..e18bf59f9 100644 --- a/lib/librte_eal/freebsd/eal/eal.c +++ b/lib/librte_eal/freebsd/eal/eal.c @@ -725,6 +725,9 @@ rte_eal_init(int argc, char **argv) eal_reset_internal_config(&internal_config); + /* clone argv to report out later in telemetry */ + eal_save_args(argc, argv); + /* set log level as early as possible */ eal_log_level_parse(argc, argv); @@ -960,6 +963,8 @@ rte_eal_init(int argc, char **argv) rte_eal_init_alert(error_str); return -1; } + rte_telemetry_register_cmd("/eal/version", + handle_eal_info_request); } eal_mcfg_complete(); diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c index 8eeffe9aa..a68b66a1e 100644 --- a/lib/librte_eal/linux/eal/eal.c +++ b/lib/librte_eal/linux/eal/eal.c @@ -992,6 +992,9 @@ rte_eal_init(int argc, char **argv) /* set log level as early as possible */ eal_log_level_parse(argc, argv); + /* clone argv to report out later in telemetry */ + eal_save_args(argc, argv); + if (rte_eal_cpu_init() < 0) { rte_eal_init_alert("Cannot detect lcores."); rte_errno = ENOTSUP; @@ -1299,6 +1302,8 @@ rte_eal_init(int argc, char **argv) rte_eal_init_alert(error_str); return -1; } + rte_telemetry_register_cmd("/eal/version", + handle_eal_info_request); } eal_mcfg_complete(); -- 2.17.1