From: Kuba Kozak <kubax.kozak@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 v6 2/5] ethdev: added new function for xstats ID
Date: Thu, 13 Apr 2017 16:59:25 +0200 [thread overview]
Message-ID: <1492095568-20993-3-git-send-email-kubax.kozak@intel.com> (raw)
In-Reply-To: <1492095568-20993-1-git-send-email-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 | 21 ++++++++++++++++
lib/librte_ether/rte_ether_version.map | 1 +
4 files changed, 68 insertions(+)
diff --git a/doc/guides/rel_notes/release_17_05.rst b/doc/guides/rel_notes/release_17_05.rst
index 5b77226..dae4261 100644
--- a/doc/guides/rel_notes/release_17_05.rst
+++ b/doc/guides/rel_notes/release_17_05.rst
@@ -423,6 +423,8 @@ API Changes
* Added new functions ``rte_eth_xstats_get_all`` and ``rte_eth_xstats_get_names_all to provide backward compatibility for
``rte_eth_xstats_get`` and ``rte_eth_xstats_get_names``
+ * 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 0adc1d0..ef30883 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1476,6 +1476,50 @@ struct rte_eth_dev *
}
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 -1;
+ }
+
+ if (!xstat_name) {
+ RTE_PMD_DEBUG_TRACE("Error: xstat_name pointer is NULL\n");
+ return -1;
+ }
+
+ /* Get count */
+ cnt_xstats = rte_eth_xstats_get_names(port_id, NULL, 0, NULL);
+ if (cnt_xstats < 0) {
+ RTE_PMD_DEBUG_TRACE("Error: Cannot get count of xstats\n");
+ return -1;
+ }
+
+ /* Get id-name lookup table */
+ struct rte_eth_xstat_name xstats_names[cnt_xstats];
+
+ if (cnt_xstats != rte_eth_xstats_get_names(
+ 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_v1607(uint8_t port_id,
struct rte_eth_xstat_name *xstats_names,
unsigned int size)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 8c94b88..058c435 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2346,6 +2346,27 @@ int rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
*/
void rte_eth_stats_reset(uint8_t port_id);
+
+/**
+ * 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);
+
/**
* Retrieve all extended statistics of an Ethernet device.
*
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index a404434..7c41617 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -161,6 +161,7 @@ DPDK_17.05 {
rte_eth_find_next;
rte_eth_xstats_get;
rte_eth_xstats_get_all;
+ rte_eth_xstats_get_id_by_name;
rte_eth_xstats_get_names;
rte_eth_xstats_get_names_all;
--
1.9.1
next prev parent reply other threads:[~2017-04-13 13:02 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-30 21:50 [dpdk-dev] [PATCH v2 0/5] Extended xstats API in ethdev library to allow grouping of stats Michal Jastrzebski
2017-03-30 21:50 ` [dpdk-dev] [PATCH v2 1/5] add new xstats API retrieving by id Michal Jastrzebski
2017-04-03 12:09 ` [dpdk-dev] [PATCH v3 0/3] Extended xstats API in ethdev library to allow grouping of stats Jacek Piasecki
2017-04-03 12:09 ` [dpdk-dev] [PATCH v3 1/3] add new xstats API retrieving by id Jacek Piasecki
2017-04-03 12:37 ` Van Haaren, Harry
2017-04-04 15:03 ` Thomas Monjalon
2017-04-04 15:45 ` Van Haaren, Harry
2017-04-04 16:18 ` Thomas Monjalon
2017-04-10 17:59 ` [dpdk-dev] [PATCH v4 0/3] Extended xstats API in ethdev library to allow grouping of stats Jacek Piasecki
2017-04-10 17:59 ` [dpdk-dev] [PATCH v4 1/3] ethdev: new xstats API add retrieving by ID Jacek Piasecki
2017-04-11 16:37 ` [dpdk-dev] [PATCH v5 0/3] Extended xstats API in ethdev library to allow grouping of stats Michal Jastrzebski
2017-04-11 16:37 ` [dpdk-dev] [PATCH v5 1/3] ethdev: new xstats API add retrieving by ID Michal Jastrzebski
2017-04-12 8:56 ` Van Haaren, Harry
2017-04-12 17:10 ` Thomas Monjalon
2017-04-13 10:52 ` Mcnamara, John
2017-04-13 14:59 ` [dpdk-dev] [PATCH v6 0/5] Extended xstats API in ethdev library to allow grouping of stats Kuba Kozak
2017-04-13 14:59 ` [dpdk-dev] [PATCH v6 1/5] ethdev: new xstats API add retrieving by ID Kuba Kozak
2017-04-13 16:23 ` Van Haaren, Harry
2017-04-13 14:59 ` Kuba Kozak [this message]
2017-04-13 16:23 ` [dpdk-dev] [PATCH v6 2/5] ethdev: added new function for xstats ID Van Haaren, Harry
2017-04-13 14:59 ` [dpdk-dev] [PATCH v6 3/5] proc-info: add support for new xstats API Kuba Kozak
2017-04-13 16:23 ` Van Haaren, Harry
2017-04-13 14:59 ` [dpdk-dev] [PATCH v6 4/5] net/e1000: new xstats API add ID support for e1000 Kuba Kozak
2017-04-13 16:23 ` Van Haaren, Harry
2017-04-13 14:59 ` [dpdk-dev] [PATCH v6 5/5] net/ixgbe: new xstats API add ID support for ixgbe Kuba Kozak
2017-04-13 16:23 ` Van Haaren, Harry
2017-04-13 16:21 ` [dpdk-dev] [PATCH v6 0/5] Extended xstats API in ethdev library to allow grouping of stats Van Haaren, Harry
2017-04-20 20:31 ` Thomas Monjalon
2017-04-24 12:32 ` Olivier Matz
2017-04-24 12:41 ` Thomas Monjalon
2017-04-24 15:49 ` Mcnamara, John
2017-04-25 22:49 ` Roger B Melton
2017-04-11 16:37 ` [dpdk-dev] [PATCH v5 2/3] net/e1000: new xstats API add ID support for e1000 Michal Jastrzebski
2017-04-12 8:56 ` Van Haaren, Harry
2017-04-11 16:37 ` [dpdk-dev] [PATCH v5 3/3] net/ixgbe: new xstats API add ID support for ixgbe Michal Jastrzebski
2017-04-12 8:56 ` Van Haaren, Harry
2017-04-10 17:59 ` [dpdk-dev] [PATCH v4 2/3] net/e1000: new xstats API add ID support for e1000 Jacek Piasecki
2017-04-10 17:59 ` [dpdk-dev] [PATCH v4 3/3] net/ixgbe: new xstats API add ID support for ixgbe Jacek Piasecki
2017-04-03 12:09 ` [dpdk-dev] [PATCH v3 2/3] add new xstats API id support for e1000 Jacek Piasecki
2017-04-03 12:38 ` Van Haaren, Harry
2017-04-03 12:09 ` [dpdk-dev] [PATCH v3 3/3] add new xstats API id support for ixgbe Jacek Piasecki
2017-04-03 12:38 ` Van Haaren, Harry
2017-03-30 21:50 ` [dpdk-dev] [PATCH v2 2/5] add new xstats API id support for e1000 Michal Jastrzebski
2017-03-30 22:06 ` [dpdk-dev] [PATCH v2 3/5] add new xstats API id support for ixgbe Michal Jastrzebski
2017-03-30 22:22 ` [dpdk-dev] [PATCH v2 4/5] add support for new xstats API retrieving by id Michal Jastrzebski
2017-03-30 22:23 ` [dpdk-dev] [PATCH v2 5/5] " Michal Jastrzebski
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=1492095568-20993-3-git-send-email-kubax.kozak@intel.com \
--to=kubax.kozak@intel.com \
--cc=deepak.k.jain@intel.com \
--cc=dev@dpdk.org \
--cc=harry.van.haaren@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).