From: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
To: dev@dpdk.org
Cc: harry.van.haaren@intel.com, deepak.k.jain@intel.com,
Kuba Kozak <kubax.kozak@intel.com>
Subject: [dpdk-dev] [PATCH v1 3/6] ethdev: get xstats ID by name
Date: Thu, 27 Apr 2017 16:42:37 +0200 [thread overview]
Message-ID: <20170427144240.10188-4-michalx.k.jastrzebski@intel.com> (raw)
In-Reply-To: <20170427144240.10188-1-michalx.k.jastrzebski@intel.com>
From: Kuba Kozak <kubax.kozak@intel.com>
Introduced new function: rte_eth_xstats_get_id_by_name
to retrieve xstats ids by its names.
doc: added release note
Signed-off-by: Kuba Kozak <kubax.kozak@intel.com>
---
doc/guides/rel_notes/release_17_05.rst | 2 ++
lib/librte_ether/rte_ethdev.c | 44 ++++++++++++++++++++++++++++++++++
lib/librte_ether/rte_ethdev.h | 20 ++++++++++++++++
lib/librte_ether/rte_ether_version.map | 1 +
4 files changed, 67 insertions(+)
diff --git a/doc/guides/rel_notes/release_17_05.rst b/doc/guides/rel_notes/release_17_05.rst
index 12d6b49..2e1463f 100644
--- a/doc/guides/rel_notes/release_17_05.rst
+++ b/doc/guides/rel_notes/release_17_05.rst
@@ -454,6 +454,8 @@ API Changes
* Added new functions ``rte_eth_xstats_get_by_id`` and ``rte_eth_xstats_get_names_by_id``
+ * Added new function ``rte_eth_xstats_get_id_by_name``
+
ABI Changes
-----------
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 331d2e3..8aa6331 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1382,6 +1382,50 @@ get_xstats_count(uint8_t port_id)
}
int
+rte_eth_xstats_get_id_by_name(uint8_t port_id, const char *xstat_name,
+ uint64_t *id)
+{
+ int cnt_xstats, idx_xstat;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+ if (!id) {
+ RTE_PMD_DEBUG_TRACE("Error: id pointer is NULL\n");
+ return -ENOMEM;
+ }
+
+ if (!xstat_name) {
+ RTE_PMD_DEBUG_TRACE("Error: xstat_name pointer is NULL\n");
+ return -ENOMEM;
+ }
+
+ /* Get count */
+ cnt_xstats = rte_eth_xstats_get_names_by_id(port_id, NULL, 0, NULL);
+ if (cnt_xstats < 0) {
+ RTE_PMD_DEBUG_TRACE("Error: Cannot get count of xstats\n");
+ return -ENODEV;
+ }
+
+ /* Get id-name lookup table */
+ struct rte_eth_xstat_name xstats_names[cnt_xstats];
+
+ if (cnt_xstats != rte_eth_xstats_get_names_by_id(
+ port_id, xstats_names, cnt_xstats, NULL)) {
+ RTE_PMD_DEBUG_TRACE("Error: Cannot get xstats lookup\n");
+ return -1;
+ }
+
+ for (idx_xstat = 0; idx_xstat < cnt_xstats; idx_xstat++) {
+ if (!strcmp(xstats_names[idx_xstat].name, xstat_name)) {
+ *id = idx_xstat;
+ return 0;
+ };
+ }
+
+ return -EINVAL;
+}
+
+int
rte_eth_xstats_get_names_by_id(uint8_t port_id,
struct rte_eth_xstat_name *xstats_names, unsigned int size,
uint64_t *ids)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 8594416..782a6a8 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2389,6 +2389,26 @@ int rte_eth_xstats_get_by_id(uint8_t port_id, const uint64_t *ids,
uint64_t *values, unsigned int n);
/**
+ * Gets the ID of a statistic from its name.
+ *
+ * This function searches for the statistics using string compares, and
+ * as such should not be used on the fast-path. For fast-path retrieval of
+ * specific statistics, store the ID as provided in *id* from this function,
+ * and pass the ID to rte_eth_xstats_get()
+ *
+ * @param port_id The port to look up statistics from
+ * @param xstat_name The name of the statistic to return
+ * @param[out] id A pointer to an app-supplied uint64_t which should be
+ * set to the ID of the stat if the stat exists.
+ * @return
+ * 0 on success
+ * -ENODEV for invalid port_id,
+ * -EINVAL if the xstat_name doesn't exist in port_id
+ */
+int rte_eth_xstats_get_id_by_name(uint8_t port_id, const char *xstat_name,
+ uint64_t *id);
+
+/**
* Reset extended statistics of an Ethernet device.
*
* @param port_id
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index 1abd717..d6726bb 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -152,6 +152,7 @@ DPDK_17.05 {
rte_eth_dev_attach_secondary;
rte_eth_find_next;
rte_eth_xstats_get_by_id;
+ rte_eth_xstats_get_id_by_name;
rte_eth_xstats_get_names_by_id;
} DPDK_17.02;
--
2.7.4
next prev parent reply other threads:[~2017-04-27 14:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-27 14:42 [dpdk-dev] [PATCH v1 0/6] Extended xstats API in ethdev library to allow grouping of stats Michal Jastrzebski
2017-04-27 14:42 ` [dpdk-dev] [PATCH v1 1/6] ethdev: revert patches extending xstats API in ethdev Michal Jastrzebski
2017-04-28 11:09 ` Van Haaren, Harry
2017-04-27 14:42 ` [dpdk-dev] [PATCH v1 2/6] ethdev: retrieve xstats by ID Michal Jastrzebski
2017-04-28 11:09 ` Van Haaren, Harry
2017-04-27 14:42 ` Michal Jastrzebski [this message]
2017-04-28 11:10 ` [dpdk-dev] [PATCH v1 3/6] ethdev: get xstats ID by name Van Haaren, Harry
2017-04-27 14:42 ` [dpdk-dev] [PATCH v1 4/6] app/proc-info: support xstats by ID and " Michal Jastrzebski
2017-04-28 11:10 ` Van Haaren, Harry
2017-04-27 14:42 ` [dpdk-dev] [PATCH v1 5/6] net/e1000: support xstats by ID Michal Jastrzebski
2017-04-28 11:10 ` Van Haaren, Harry
2017-04-27 14:42 ` [dpdk-dev] [PATCH v1 6/6] net/ixgbe: " Michal Jastrzebski
2017-04-28 11:10 ` Van Haaren, Harry
2017-05-01 21:34 ` [dpdk-dev] [PATCH v1 0/6] Extended xstats API in ethdev library to allow grouping of stats Thomas Monjalon
2017-05-01 21:49 ` Thomas Monjalon
2017-05-01 21:50 ` 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=20170427144240.10188-4-michalx.k.jastrzebski@intel.com \
--to=michalx.k.jastrzebski@intel.com \
--cc=deepak.k.jain@intel.com \
--cc=dev@dpdk.org \
--cc=harry.van.haaren@intel.com \
--cc=kubax.kozak@intel.com \
/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).