From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 850AE4CC3 for ; Thu, 23 Aug 2018 14:08:36 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Aug 2018 05:08:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,278,1531810800"; d="scan'208";a="256613876" Received: from silpixa00399503.ir.intel.com ([10.237.222.102]) by fmsmga005.fm.intel.com with ESMTP; 23 Aug 2018 05:08:35 -0700 From: Ciara Power To: harry.van.haaren@intel.com, brian.archbold@intel.com, emma.kenny@intel.com, ciara.power@intel.com Cc: dev@dpdk.org Date: Thu, 23 Aug 2018 13:08:10 +0100 Message-Id: <1535026093-101872-9-git-send-email-ciara.power@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535026093-101872-1-git-send-email-ciara.power@intel.com> References: <1535026093-101872-1-git-send-email-ciara.power@intel.com> Subject: [dpdk-dev] [PATCH 08/11] telemetry: add vdev kvargs for selftest 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: , X-List-Received-Date: Thu, 23 Aug 2018 12:08:37 -0000 This patch adds functionality to run the selftest by passing in an argument to vdev, "selftest". To run the tests that were added in the previous patch, the argument "selftest=1" must be added to the vdev arguments. This will enable the user to run telemetry with or without tests, as required. Signed-off-by: Ciara Power Signed-off-by: Brian Archbold --- drivers/telemetry/telemetry/telemetry_driver.c | 50 ++++++++++++++++++++++---- lib/librte_telemetry/rte_telemetry.c | 35 +++++++++--------- lib/librte_telemetry/rte_telemetry.h | 8 ++++- lib/librte_telemetry/rte_telemetry_internal.h | 1 + 4 files changed, 70 insertions(+), 24 deletions(-) diff --git a/drivers/telemetry/telemetry/telemetry_driver.c b/drivers/telemetry/telemetry/telemetry_driver.c index 125a89c..a97c199 100644 --- a/drivers/telemetry/telemetry/telemetry_driver.c +++ b/drivers/telemetry/telemetry/telemetry_driver.c @@ -8,21 +8,57 @@ #include #include #include +#include + +#define SELFTEST_ARG "selftest" + +static int +assign_selftest(const char *key __rte_unused, const char *value, void *opaque) +{ + int *selftest = opaque; + *selftest = atoi(value); + return 0; +} static int telemetry_probe(struct rte_vdev_device *vdev) { + static const char *const args[] = { + SELFTEST_ARG + }; + + const char *params; int ret; + struct telemetry_args telemetry_args; + telemetry_args.selftest = 0; - RTE_SET_USED(vdev); - ret = rte_telemetry_selftest(); - if (ret < 0) { - printf("Error - Selftest failed\n"); - return -1; + params = rte_vdev_device_args(vdev); + if (params != NULL && params[0] != '\0') { + struct rte_kvargs *kvlist = rte_kvargs_parse(params, args); + + if (!kvlist) { + printf("Error - Could not create kvlist\n"); + } else { + ret = rte_kvargs_process(kvlist, SELFTEST_ARG, + assign_selftest, &telemetry_args.selftest); + if (ret != 0) { + printf("Error - Processing the arguments\n"); + rte_kvargs_free(kvlist); + return ret; + } + } + rte_kvargs_free(kvlist); + } + if (telemetry_args.selftest) { + ret = rte_telemetry_selftest(); + if (ret < 0) { + printf("Error - Selftest failed\n"); + return -1; + } + printf("Success - Selftest passed\n"); } - printf("Success - Selftest passed\n"); - ret = rte_telemetry_init(rte_socket_id()); + ret = rte_telemetry_init(rte_socket_id(), &telemetry_args); if (ret < 0) { printf("Error - Telemetry initialisation failed\n"); return -1; diff --git a/lib/librte_telemetry/rte_telemetry.c b/lib/librte_telemetry/rte_telemetry.c index ecf644b..1f7528d 100644 --- a/lib/librte_telemetry/rte_telemetry.c +++ b/lib/librte_telemetry/rte_telemetry.c @@ -666,18 +666,21 @@ rte_telemetry_initial_accept(struct telemetry_impl *telemetry) return -1; } telemetry->metrics_register_done = 1; - ret = rte_telemetry_socket_messaging_testing(telemetry->reg_index, - telemetry->server_fd); - if (ret < 0) - return -1; + if (telemetry->selftest) { + ret = + rte_telemetry_socket_messaging_testing(telemetry->reg_index, + telemetry->server_fd); + if (ret < 0) + return -1; - ret = rte_telemetry_parser_test(telemetry); - if (ret < 0) { - TELEMETRY_LOG_ERR("Error - Parser Tests Failed\n"); - return -1; + ret = rte_telemetry_parser_test(telemetry); + if (ret < 0) { + TELEMETRY_LOG_ERR("Error - Parser Tests Failed\n"); + return -1; + } + TELEMETRY_LOG_INFO("Success - All Parser Tests Passed\n"); + telemetry->selftest = 0; } - TELEMETRY_LOG_INFO("Success - All Parser Tests Passed\n"); - return 0; } @@ -856,7 +859,7 @@ rte_telemetry_create_socket(struct telemetry_impl *telemetry) } int32_t -rte_telemetry_init(uint32_t socket_id) +rte_telemetry_init(uint32_t socket_id, struct telemetry_args *args) { int ret; pthread_attr_t attr; @@ -873,7 +876,7 @@ rte_telemetry_init(uint32_t socket_id) TELEMETRY_LOG_ERR("Error - Memory could not be allocated\n"); return -ENOMEM; } - + static_telemetry->selftest = args->selftest; static_telemetry->socket_id = socket_id; rte_metrics_init(static_telemetry->socket_id); ret = rte_telemetry_create_socket(static_telemetry); @@ -1167,10 +1170,10 @@ rte_telemetry_selftest(void) const char *invalid_client_path = SELFTEST_INVALID_CLIENT; const char *valid_client_path = SELFTEST_VALID_CLIENT; int ret, sockfd; + struct telemetry_args args; + args.selftest = 0; - TELEMETRY_LOG_INFO("Selftest\n"); - - ret = rte_telemetry_init(rte_socket_id()); + ret = rte_telemetry_init(rte_socket_id(), &args); if (ret < 0) { TELEMETRY_LOG_ERR("Error - Valid initialisation test" " failed\n"); @@ -1178,7 +1181,7 @@ rte_telemetry_selftest(void) } TELEMETRY_LOG_INFO("Success - Valid initialisation test passed\n"); - ret = rte_telemetry_init(rte_socket_id()); + ret = rte_telemetry_init(rte_socket_id(), &args); if (ret != -EALREADY) { TELEMETRY_LOG_ERR("Error - Invalid initialisation test " "failed\n"); diff --git a/lib/librte_telemetry/rte_telemetry.h b/lib/librte_telemetry/rte_telemetry.h index 4f187b7..ac66595 100644 --- a/lib/librte_telemetry/rte_telemetry.h +++ b/lib/librte_telemetry/rte_telemetry.h @@ -7,12 +7,18 @@ #ifndef _RTE_TELEMETRY_H_ #define _RTE_TELEMETRY_H_ +typedef struct telemetry_args { + int selftest; +} telemetry_args; + /** * Get the telemetry_impl structure device pointer initialised. * * @param socket_id * Unsigned integer representing the socket id to be used * for the telemetry structure. + * @param args + * Struct containing arguments from telemetry_args * * @return * 0 on successful initialisation. @@ -24,7 +30,7 @@ * -EALREADY if Telemetry is already initialised. */ int32_t -rte_telemetry_init(uint32_t socket_id); +rte_telemetry_init(uint32_t socket_id, struct telemetry_args *args); /** * Clean up and free memory. diff --git a/lib/librte_telemetry/rte_telemetry_internal.h b/lib/librte_telemetry/rte_telemetry_internal.h index 3e21b79..3270711 100644 --- a/lib/librte_telemetry/rte_telemetry_internal.h +++ b/lib/librte_telemetry/rte_telemetry_internal.h @@ -41,6 +41,7 @@ typedef struct telemetry_impl { TAILQ_HEAD(, telemetry_client) client_list_head; struct telemetry_client *request_client; int register_fail_count; + int selftest; } telemetry_impl; int32_t -- 2.7.4