From: Bruce Richardson <bruce.richardson@intel.com>
To: Kevin Laatz <kevin.laatz@intel.com>
Cc: dev@dpdk.org, Bruce Richardson <bruce.richardson@intel.com>,
stable@dpdk.org
Subject: [dpdk-dev] [PATCH] telemetry: fix incorrect stat name to id mapping
Date: Thu, 28 Mar 2019 15:30:45 +0000 [thread overview]
Message-ID: <20190328153045.8178-1-bruce.richardson@intel.com> (raw)
Message-ID: <20190328153045.xoPQlpsU99xLsTcDVL2_xqwH_cc50y70bUQcXkdFI2Y@z> (raw)
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 <bruce.richardson@intel.com>
---
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
next reply other threads:[~2019-03-28 15:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-28 15:30 Bruce Richardson [this message]
2019-03-28 15:30 ` Bruce Richardson
2019-04-01 17:17 ` Laatz, Kevin
2019-04-01 17:17 ` Laatz, Kevin
2019-04-02 0:34 ` Thomas Monjalon
2019-04-02 0:34 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190328153045.8178-1-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=kevin.laatz@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).