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 7DB19A04B5; Wed, 9 Sep 2020 22:55:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E2C751BE0C; Wed, 9 Sep 2020 22:55:12 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id EA6851B9B7 for ; Wed, 9 Sep 2020 22:55:10 +0200 (CEST) IronPort-SDR: gWdS0q0NDd6+aBAAB8aQBj8Vjot88Q9MH/JMsPKyqXeNQn5qkGqetDK/hPR774z41IpCXBUVON ZYwqOPZ2J6OA== X-IronPort-AV: E=McAfee;i="6000,8403,9739"; a="155880170" X-IronPort-AV: E=Sophos;i="5.76,410,1592895600"; d="scan'208";a="155880170" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2020 13:55:10 -0700 IronPort-SDR: DD8QqOqXPKCcTLocAhNMHvb3TcxD2jS/huI4xgF3N5U+f8KC+aF48R3A2E4OXLC9MUWnS3cgBl hdJ1DSs0qiXg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,410,1592895600"; d="scan'208";a="286342449" Received: from paamrpdk00.aw.intel.com (HELO localhost.localdomain) ([10.228.150.209]) by fmsmga008.fm.intel.com with ESMTP; 09 Sep 2020 13:55:09 -0700 From: "Chen, Mike Ximing" To: Jerin Jacob Cc: dev@dpdk.org, gage.eads@intel.com, sundar.vedantham@intel.com, ciara.power@intel.com, bruce.richardson@intel.com, Mike Ximing Chen Date: Wed, 9 Sep 2020 16:54:47 -0400 Message-Id: <20200909205447.29398-1-mike.ximing.chen@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] eventdev: support telemetry with xstats info 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" The telemetry library is connected with eventdev xstats and port link info. The following new telemetry commands are added: /eventdev/dev_list /eventdev/port_list,DevID /eventdev/queue_list,DevID /eventdev/dev_xstats,DevID /eventdev/port_xstats,DevID,PortID /eventdev/queue_xstats,DevID,PortID /eventdev/queue_links,DevID,PortID queue_links command displays a list of queues linked with a specified eventdev port and a service priority associated with each link. Signed-off-by: Mike Ximing Chen --- Depends-on: patch-76075 ("lib/telemetry: fix passing full params string to command") --- lib/librte_eventdev/meson.build | 1 + lib/librte_eventdev/rte_eventdev.c | 304 +++++++++++++++++++++++++++++ 2 files changed, 305 insertions(+) diff --git a/lib/librte_eventdev/meson.build b/lib/librte_eventdev/meson.build index d1f25ee5c..0adc2cd2f 100644 --- a/lib/librte_eventdev/meson.build +++ b/lib/librte_eventdev/meson.build @@ -27,3 +27,4 @@ headers = files('rte_eventdev.h', 'rte_event_crypto_adapter.h', 'rte_event_eth_tx_adapter.h') deps += ['ring', 'ethdev', 'hash', 'mempool', 'mbuf', 'timer', 'cryptodev'] +deps += ['telemetry'] diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index 82c177c73..6e201c475 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "rte_eventdev.h" #include "rte_eventdev_pmd.h" @@ -1424,3 +1425,306 @@ rte_event_pmd_release(struct rte_eventdev *eventdev) eventdev->data = NULL; return 0; } + + +static int +handle_dev_list(const char *cmd __rte_unused, + const char *params __rte_unused, + struct rte_tel_data *d) +{ + uint8_t dev_id; + int ndev = rte_event_dev_count(); + + if (ndev < 1) + return -1; + + rte_tel_data_start_array(d, RTE_TEL_INT_VAL); + for (dev_id = 0; dev_id < RTE_EVENT_MAX_DEVS; dev_id++) { + if (rte_eventdevs[dev_id].attached == + RTE_EVENTDEV_ATTACHED) + rte_tel_data_add_array_int(d, dev_id); + } + + return 0; +} + +static int +handle_port_list(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + int i; + uint8_t dev_id; + struct rte_eventdev *dev; + char *end_param; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -1; + + dev_id = strtoul(params, &end_param, 10); + if (*end_param != '\0') + RTE_EDEV_LOG_DEBUG( + "Extra parameters passed to eventdev telemetry command, ignoring"); + + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + dev = &rte_eventdevs[dev_id]; + + rte_tel_data_start_array(d, RTE_TEL_INT_VAL); + for (i = 0; i < dev->data->nb_ports; i++) + rte_tel_data_add_array_int(d, i); + + return 0; +} + +static int +handle_queue_list(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + int i; + uint8_t dev_id; + struct rte_eventdev *dev; + char *end_param; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -1; + + dev_id = strtoul(params, &end_param, 10); + if (*end_param != '\0') + RTE_EDEV_LOG_DEBUG( + "Extra parameters passed to eventdev telemetry command, ignoring"); + + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + dev = &rte_eventdevs[dev_id]; + + rte_tel_data_start_array(d, RTE_TEL_INT_VAL); + for (i = 0; i < dev->data->nb_queues; i++) + rte_tel_data_add_array_int(d, i); + + return 0; +} + +static int +handle_queue_links(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + int i, ret, port_id = 0; + char *end_param; + uint8_t dev_id; + uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV]; + uint8_t priorities[RTE_EVENT_MAX_QUEUES_PER_DEV]; + const char *p_param; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -1; + + /* Get dev ID from parameter string */ + dev_id = strtoul(params, &end_param, 10); + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + + p_param = strtok(end_param, ","); + if (p_param == NULL || strlen(p_param) == 0 || !isdigit(*p_param)) + return -1; + + port_id = strtoul(p_param, &end_param, 10); + p_param = strtok(NULL, "\0"); + if (*p_param != '\0') + RTE_EDEV_LOG_DEBUG( + "Extra parameters passed to eventdev telemetry command, ignoring"); + + ret = rte_event_port_links_get(dev_id, port_id, queues, priorities); + if (ret < 0) + return -1; + + rte_tel_data_start_dict(d); + for (i = 0; i < ret; i++) { + char qid_name[32]; + + snprintf(qid_name, 31, "qid_%u", queues[i]); + rte_tel_data_add_dict_u64(d, qid_name, priorities[i]); + } + + return 0; +} + +static int +eventdev_build_telemetry_data(int dev_id, + enum rte_event_dev_xstats_mode mode, + int port_queue_id, + struct rte_tel_data *d) +{ + struct rte_event_dev_xstats_name *xstat_names; + unsigned int *ids; + uint64_t *values; + int i, ret, num_xstats; + + num_xstats = rte_event_dev_xstats_names_get(dev_id, + mode, + port_queue_id, + NULL, + NULL, + 0); + + if (num_xstats < 0) + return -1; + + /* use one malloc for names */ + xstat_names = malloc((sizeof(struct rte_event_dev_xstats_name)) + * num_xstats); + if (xstat_names == NULL) + return -1; + + ids = malloc((sizeof(unsigned int)) * num_xstats); + if (ids == NULL) { + free(xstat_names); + return -1; + } + + values = malloc((sizeof(uint64_t)) * num_xstats); + if (values == NULL) { + free(xstat_names); + free(ids); + return -1; + } + + ret = rte_event_dev_xstats_names_get(dev_id, mode, port_queue_id, + xstat_names, ids, num_xstats); + if (ret < 0 || ret > num_xstats) { + free(xstat_names); + free(ids); + free(values); + return -1; + } + + ret = rte_event_dev_xstats_get(dev_id, mode, port_queue_id, + ids, values, num_xstats); + if (ret < 0 || ret > num_xstats) { + free(xstat_names); + free(ids); + free(values); + return -1; + } + + rte_tel_data_start_dict(d); + for (i = 0; i < num_xstats; i++) + rte_tel_data_add_dict_u64(d, xstat_names[i].name, + values[i]); + + free(xstat_names); + free(ids); + free(values); + return 0; +} + +static int +handle_dev_xstats(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + int dev_id; + enum rte_event_dev_xstats_mode mode; + char *end_param; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -1; + + /* Get dev ID from parameter string */ + dev_id = strtoul(params, &end_param, 10); + if (*end_param != '\0') + RTE_EDEV_LOG_DEBUG( + "Extra parameters passed to eventdev telemetry command, ignoring"); + + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + + mode = RTE_EVENT_DEV_XSTATS_DEVICE; + return eventdev_build_telemetry_data(dev_id, mode, 0, d); +} + +static int +handle_port_xstats(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + int dev_id; + int port_queue_id = 0; + enum rte_event_dev_xstats_mode mode; + char *end_param; + const char *p_param; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -1; + + /* Get dev ID from parameter string */ + dev_id = strtoul(params, &end_param, 10); + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + + p_param = strtok(end_param, ","); + mode = RTE_EVENT_DEV_XSTATS_PORT; + + if (p_param == NULL || strlen(p_param) == 0 || !isdigit(*p_param)) + return -1; + + port_queue_id = strtoul(p_param, &end_param, 10); + + p_param = strtok(NULL, "\0"); + if (*p_param != '\0') + RTE_EDEV_LOG_DEBUG( + "Extra parameters passed to eventdev telemetry command, ignoring"); + + return eventdev_build_telemetry_data(dev_id, mode, port_queue_id, d); +} + +static int +handle_queue_xstats(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + int dev_id; + int port_queue_id = 0; + enum rte_event_dev_xstats_mode mode; + char *end_param; + const char *p_param; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -1; + + /* Get dev ID from parameter string */ + dev_id = strtoul(params, &end_param, 10); + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + + p_param = strtok(end_param, ","); + mode = RTE_EVENT_DEV_XSTATS_QUEUE; + + if (p_param == NULL || strlen(p_param) == 0 || !isdigit(*p_param)) + return -1; + + port_queue_id = strtoul(p_param, &end_param, 10); + + p_param = strtok(NULL, "\0"); + if (*p_param != '\0') + RTE_EDEV_LOG_DEBUG( + "Extra parameters passed to eventdev telemetry command, ignoring"); + + return eventdev_build_telemetry_data(dev_id, mode, port_queue_id, d); +} + +RTE_INIT(eventdev_init_telemetry) +{ + rte_telemetry_register_cmd("/eventdev/dev_list", handle_dev_list, + "Returns list of available eventdevs. Takes no parameters"); + rte_telemetry_register_cmd("/eventdev/port_list", handle_port_list, + "Returns list of available ports. Parameter: DevID"); + rte_telemetry_register_cmd("/eventdev/queue_list", handle_queue_list, + "Returns list of available queues. Parameter: DevID"); + + rte_telemetry_register_cmd("/eventdev/dev_xstats", handle_dev_xstats, + "Returns stats for an eventdev. Parameter: DevID"); + rte_telemetry_register_cmd("/eventdev/port_xstats", handle_port_xstats, + "Returns stats for an eventdev port. Params: DevID,PortID"); + rte_telemetry_register_cmd("/eventdev/queue_xstats", + handle_queue_xstats, + "Returns stats for an eventdev queue. Params: DevID,QueueID"); + rte_telemetry_register_cmd("/eventdev/queue_links", handle_queue_links, + "Returns links for an eventdev port. Params: DevID,QueueID"); +} -- 2.17.1