From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 5CFC45688; Thu, 28 Mar 2019 16:30:59 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2019 08:30:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,280,1549958400"; d="scan'208";a="311182994" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.222.236]) by orsmga005.jf.intel.com with ESMTP; 28 Mar 2019 08:30:56 -0700 From: Bruce Richardson To: Kevin Laatz Cc: dev@dpdk.org, Bruce Richardson , stable@dpdk.org Date: Thu, 28 Mar 2019 15:30:45 +0000 Message-Id: <20190328153045.8178-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] telemetry: fix incorrect stat name to id mapping 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, 28 Mar 2019 15:31:00 -0000 If we have two NIC ports which have a different set of NIC stats we can end up having two different stats registered with xstats with the same name. [Since the stats are updated in bulk as a contiguous set, the second driver re-using the registration of the first is not possible.] This causes issues with the invalid stat for one driver being found due to a lookup by name which is unnecessary. Instead of getting stat names involved do the lookup by ID instead. CC: stable@dpdk.org Fixes: 1b756087db93 ("telemetry: add parser for client socket messages") Signed-off-by: Bruce Richardson --- lib/librte_telemetry/rte_telemetry_parser.c | 22 +++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/librte_telemetry/rte_telemetry_parser.c b/lib/librte_telemetry/rte_telemetry_parser.c index 03a58a2fd..9bc16eef4 100644 --- a/lib/librte_telemetry/rte_telemetry_parser.c +++ b/lib/librte_telemetry/rte_telemetry_parser.c @@ -256,7 +256,7 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry, int action, json_t *data) { int ret, num_metrics, i, p; - struct rte_metric_name *names; + struct rte_metric_value *values; uint64_t num_port_ids = 0; uint32_t port_ids[RTE_MAX_ETHPORTS]; @@ -281,7 +281,7 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry, return -1; } - num_metrics = rte_metrics_get_names(NULL, 0); + num_metrics = rte_metrics_get_values(0, NULL, 0); if (num_metrics < 0) { TELEMETRY_LOG_ERR("Cannot get metrics count"); @@ -300,8 +300,8 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry, return -1; } - names = malloc(sizeof(struct rte_metric_name) * num_metrics); - if (names == NULL) { + values = malloc(sizeof(struct rte_metric_value) * num_metrics); + if (values == NULL) { TELEMETRY_LOG_ERR("Cannot allocate memory"); ret = rte_telemetry_send_error_response(telemetry, -ENOMEM); @@ -310,7 +310,6 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry, return -1; } - const char *stat_names[num_metrics]; uint32_t stat_ids[num_metrics]; RTE_ETH_FOREACH_DEV(p) { @@ -328,16 +327,13 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry, goto fail; } - ret = rte_metrics_get_names(names, num_metrics); - for (i = 0; i < num_metrics; i++) - stat_names[i] = names[i].name; - - ret = rte_telemetry_stat_names_to_ids(telemetry, stat_names, stat_ids, - num_metrics); + ret = rte_metrics_get_values(port_ids[0], values, num_metrics); if (ret < 0) { - TELEMETRY_LOG_ERR("Could not convert stat names to IDs"); + TELEMETRY_LOG_ERR("Could not get stat values"); goto fail; } + for (i = 0; i < num_metrics; i++) + stat_ids[i] = values[i].key; ret = rte_telemetry_send_ports_stats_values(stat_ids, num_metrics, port_ids, num_port_ids, telemetry); @@ -349,7 +345,7 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry, return 0; fail: - free(names); + free(values); return -1; } -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id AC7FDA0679 for ; Thu, 28 Mar 2019 16:31:02 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 16D871B39B; Thu, 28 Mar 2019 16:31:01 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 5CFC45688; Thu, 28 Mar 2019 16:30:59 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2019 08:30:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,280,1549958400"; d="scan'208";a="311182994" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.222.236]) by orsmga005.jf.intel.com with ESMTP; 28 Mar 2019 08:30:56 -0700 From: Bruce Richardson To: Kevin Laatz Cc: dev@dpdk.org, Bruce Richardson , stable@dpdk.org Date: Thu, 28 Mar 2019 15:30:45 +0000 Message-Id: <20190328153045.8178-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] telemetry: fix incorrect stat name to id mapping 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190328153045.xoPQlpsU99xLsTcDVL2_xqwH_cc50y70bUQcXkdFI2Y@z> If we have two NIC ports which have a different set of NIC stats we can end up having two different stats registered with xstats with the same name. [Since the stats are updated in bulk as a contiguous set, the second driver re-using the registration of the first is not possible.] This causes issues with the invalid stat for one driver being found due to a lookup by name which is unnecessary. Instead of getting stat names involved do the lookup by ID instead. CC: stable@dpdk.org Fixes: 1b756087db93 ("telemetry: add parser for client socket messages") Signed-off-by: Bruce Richardson --- lib/librte_telemetry/rte_telemetry_parser.c | 22 +++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/librte_telemetry/rte_telemetry_parser.c b/lib/librte_telemetry/rte_telemetry_parser.c index 03a58a2fd..9bc16eef4 100644 --- a/lib/librte_telemetry/rte_telemetry_parser.c +++ b/lib/librte_telemetry/rte_telemetry_parser.c @@ -256,7 +256,7 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry, int action, json_t *data) { int ret, num_metrics, i, p; - struct rte_metric_name *names; + struct rte_metric_value *values; uint64_t num_port_ids = 0; uint32_t port_ids[RTE_MAX_ETHPORTS]; @@ -281,7 +281,7 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry, return -1; } - num_metrics = rte_metrics_get_names(NULL, 0); + num_metrics = rte_metrics_get_values(0, NULL, 0); if (num_metrics < 0) { TELEMETRY_LOG_ERR("Cannot get metrics count"); @@ -300,8 +300,8 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry, return -1; } - names = malloc(sizeof(struct rte_metric_name) * num_metrics); - if (names == NULL) { + values = malloc(sizeof(struct rte_metric_value) * num_metrics); + if (values == NULL) { TELEMETRY_LOG_ERR("Cannot allocate memory"); ret = rte_telemetry_send_error_response(telemetry, -ENOMEM); @@ -310,7 +310,6 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry, return -1; } - const char *stat_names[num_metrics]; uint32_t stat_ids[num_metrics]; RTE_ETH_FOREACH_DEV(p) { @@ -328,16 +327,13 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry, goto fail; } - ret = rte_metrics_get_names(names, num_metrics); - for (i = 0; i < num_metrics; i++) - stat_names[i] = names[i].name; - - ret = rte_telemetry_stat_names_to_ids(telemetry, stat_names, stat_ids, - num_metrics); + ret = rte_metrics_get_values(port_ids[0], values, num_metrics); if (ret < 0) { - TELEMETRY_LOG_ERR("Could not convert stat names to IDs"); + TELEMETRY_LOG_ERR("Could not get stat values"); goto fail; } + for (i = 0; i < num_metrics; i++) + stat_ids[i] = values[i].key; ret = rte_telemetry_send_ports_stats_values(stat_ids, num_metrics, port_ids, num_port_ids, telemetry); @@ -349,7 +345,7 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry, return 0; fail: - free(names); + free(values); return -1; } -- 2.20.1