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 1A7CEA00C2; Fri, 24 Apr 2020 15:05:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 25E4B1D44A; Fri, 24 Apr 2020 15:02:37 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 213FC1C217 for ; Fri, 24 Apr 2020 15:02:25 +0200 (CEST) IronPort-SDR: G1kFBG3RehWb3i4kQOiiNhu8St+mt/R1NPxACdmZBIubxdKg/t+PfTwmlPtJgr3qVNDrIxGCp+ fPbNTv7QJLpQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 06:02:25 -0700 IronPort-SDR: DUmAHWHQzmEmwHbspq9SEnyjbXa2xYGnioprwWz5C0Btok4JMWiFIrhX2Ar4j18vjKUWd9DFIr vgCUpQxdQ2Ww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,311,1583222400"; d="scan'208";a="245228446" Received: from silpixa00399953.ir.intel.com (HELO silpixa00399953.ger.corp.intel.com) ([10.237.222.53]) by orsmga007.jf.intel.com with ESMTP; 24 Apr 2020 06:02:23 -0700 From: Ciara Power To: dev@dpdk.org, kevin.laatz@intel.com Cc: reshma.pattan@intel.com, jerinjacobk@gmail.com, david.marchand@redhat.com, keith.wiles@intel.com, mb@smartsharesystems.com, thomas@monjalon.net, Bruce Richardson , Ciara Power Date: Fri, 24 Apr 2020 13:41:58 +0100 Message-Id: <20200424124159.45989-18-ciara.power@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200424124159.45989-1-ciara.power@intel.com> References: <20200319171907.60891-1-ciara.power@intel.com> <20200424124159.45989-1-ciara.power@intel.com> Subject: [dpdk-dev] [PATCH v4 17/18] 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.v2 {"version": "DPDK 20.05.0-rc0", "pid": 72662, "max_output_len": 16384} --> / {"/": ["/", "/eal/app_params", "/eal/params", "/ethdev/link_status", \ "/ethdev/list", "/ethdev/xstats", "/help", "/info", "/rawdev/list", \ "/rawdev/xstats"]} --> /eal/app_params {"/eal/app_params": ["-i"]} --> /eal/params {"/eal/params": ["./app/dpdk-testpmd"]} Signed-off-by: Bruce Richardson Signed-off-by: Ciara Power --- v4: Modified to use binary data formatting instead of JSON. v2: - Removed /eal/version command as /info replaces it. - Compile telemetry callbacks and include headers if not in Windows execution environment. --- lib/librte_eal/common/eal_common_options.c | 73 ++++++++++++++++++++++ lib/librte_eal/common/eal_options.h | 5 ++ lib/librte_eal/freebsd/eal.c | 3 + lib/librte_eal/linux/eal.c | 3 + 4 files changed, 84 insertions(+) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 8dfbd37723..a90169cbb0 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -29,6 +29,9 @@ #include #include #include +#ifndef RTE_EXEC_ENV_WINDOWS +#include +#endif #include "eal_internal_cfg.h" #include "eal_options.h" @@ -137,6 +140,76 @@ static int master_lcore_parsed; static int mem_parsed; static int core_parsed; +#ifndef RTE_EXEC_ENV_WINDOWS +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, + struct rte_tel_data *d) +{ + char **args; + int used = 0; + int i = 0; + + if (strcmp(cmd, EAL_PARAM_REQ) == 0) + args = eal_args; + else + args = eal_app_args; + + rte_tel_data_start_array(d, RTE_TEL_STRING_VAL); + if (args == NULL || args[0] == NULL) + return 0; + + for ( ; args[i] != NULL; i++) + used = rte_tel_data_add_array_string(d, args[i]); + return used; +} + +int +eal_save_args(int argc, char **argv) +{ + int i, j; + + rte_telemetry_register_cmd(EAL_PARAM_REQ, handle_eal_info_request, + "Returns EAL commandline parameters used. Takes no parameters"); + rte_telemetry_register_cmd(EAL_APP_PARAM_REQ, handle_eal_info_request, + "Returns app commandline parameters used. Takes no parameters"); + + /* 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 */ + + /* 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; + + return 0; +} +#endif + 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 238eb3e44e..02d4cd7b7d 100644 --- a/lib/librte_eal/common/eal_options.h +++ b/lib/librte_eal/common/eal_options.h @@ -5,6 +5,8 @@ #ifndef EAL_OPTIONS_H #define EAL_OPTIONS_H +#include + #include "getopt.h" enum { @@ -96,5 +98,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, + struct rte_tel_data *d); #endif /* EAL_OPTIONS_H */ diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c index 2379a94e8c..f681bc7a22 100644 --- a/lib/librte_eal/freebsd/eal.c +++ b/lib/librte_eal/freebsd/eal.c @@ -717,6 +717,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); diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index 9ff3b5f834..87728d2759 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -984,6 +984,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; -- 2.17.1