From: Remy Horton <remy.horton@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [RFC PATCH v2 1/3] rte: change xstats to use integer keys
Date: Fri, 6 May 2016 12:11:12 +0100 [thread overview]
Message-ID: <1462533074-1994-2-git-send-email-remy.horton@intel.com> (raw)
In-Reply-To: <1462533074-1994-1-git-send-email-remy.horton@intel.com>
Signed-off-by: Remy Horton <remy.horton@intel.com>
---
lib/librte_ether/rte_ethdev.c | 100 ++++++++++++++++++++++++++++++++++++------
lib/librte_ether/rte_ethdev.h | 55 +++++++++++++++++++++++
2 files changed, 142 insertions(+), 13 deletions(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index a31018e..29ba12c 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -112,7 +112,6 @@ static const struct rte_eth_xstats_name_off rte_txq_stats_strings[] = {
#define RTE_NB_TXQ_STATS (sizeof(rte_txq_stats_strings) / \
sizeof(rte_txq_stats_strings[0]))
-
/**
* The user application callback description.
*
@@ -1507,6 +1506,87 @@ rte_eth_stats_reset(uint8_t port_id)
dev->data->rx_mbuf_alloc_failed = 0;
}
+int
+rte_eth_xstats_count(uint8_t port_id)
+{
+ struct rte_eth_dev *dev;
+ int count;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+ dev = &rte_eth_devices[port_id];
+ if (dev->dev_ops->xstats_names != NULL) {
+ count = (*dev->dev_ops->xstats_names)(dev, NULL, 0);
+ if (count < 0)
+ return count;
+ } else
+ count = 0;
+ count += RTE_NB_STATS;
+ count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS;
+ count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS;
+ return count;
+}
+
+int
+rte_eth_xstats_names(uint8_t port_id, struct rte_eth_xstats_name *ptr_names,
+ unsigned limit)
+{
+ struct rte_eth_dev *dev;
+ int cnt_used_entries;
+ int cnt_expected_entries;
+ uint32_t idx, id_queue;
+
+ if (ptr_names == NULL)
+ return -EINVAL;
+ cnt_expected_entries = rte_eth_xstats_count(port_id);
+ if (cnt_expected_entries < 0)
+ return cnt_expected_entries;
+ if ((int)limit < cnt_expected_entries)
+ return -ERANGE;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+ dev = &rte_eth_devices[port_id];
+ if (dev->dev_ops->xstats_names != NULL) {
+ cnt_used_entries = (*dev->dev_ops->xstats_names)(
+ dev, ptr_names, limit);
+ if (cnt_used_entries < 0)
+ return cnt_used_entries;
+ } else
+ /* Driver itself does not support extended stats, but
+ * still have basic stats.
+ */
+ cnt_used_entries = 0;
+
+ for (idx = 0; idx < RTE_NB_STATS; idx++) {
+ ptr_names[cnt_used_entries].id = cnt_used_entries;
+ snprintf(ptr_names[cnt_used_entries].name,
+ sizeof(ptr_names[0].name),
+ "%s", rte_stats_strings[idx].name);
+ cnt_used_entries++;
+ }
+ for (id_queue = 0; id_queue < dev->data->nb_rx_queues; id_queue++) {
+ for (idx = 0; idx < RTE_NB_RXQ_STATS; idx++) {
+ ptr_names[cnt_used_entries].id = cnt_used_entries;
+ snprintf(ptr_names[cnt_used_entries].name,
+ sizeof(ptr_names[0].name),
+ "rx_q%u%s",
+ id_queue, rte_rxq_stats_strings[idx].name);
+ cnt_used_entries++;
+ }
+
+ }
+ for (id_queue = 0; id_queue < dev->data->nb_tx_queues; id_queue++) {
+ for (idx = 0; idx < RTE_NB_TXQ_STATS; idx++) {
+ ptr_names[cnt_used_entries].id = cnt_used_entries;
+ snprintf(ptr_names[cnt_used_entries].name,
+ sizeof(ptr_names[0].name),
+ "tx_q%u%s",
+ id_queue, rte_txq_stats_strings[idx].name);
+ cnt_used_entries++;
+ }
+ }
+ return cnt_used_entries;
+}
+
/* retrieve ethdev extended statistics */
int
rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
@@ -1551,8 +1631,8 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
stats_ptr = RTE_PTR_ADD(ð_stats,
rte_stats_strings[i].offset);
val = *stats_ptr;
- snprintf(xstats[count].name, sizeof(xstats[count].name),
- "%s", rte_stats_strings[i].name);
+ xstats[count].name[0] = '\0';
+ xstats[count].id = count + xcount;
xstats[count++].value = val;
}
@@ -1563,9 +1643,8 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
rte_rxq_stats_strings[i].offset +
q * sizeof(uint64_t));
val = *stats_ptr;
- snprintf(xstats[count].name, sizeof(xstats[count].name),
- "rx_q%u_%s", q,
- rte_rxq_stats_strings[i].name);
+ xstats[count].name[0] = '\0';
+ xstats[count].id = count + xcount;
xstats[count++].value = val;
}
}
@@ -1577,9 +1656,8 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
rte_txq_stats_strings[i].offset +
q * sizeof(uint64_t));
val = *stats_ptr;
- snprintf(xstats[count].name, sizeof(xstats[count].name),
- "tx_q%u_%s", q,
- rte_txq_stats_strings[i].name);
+ xstats[count].name[0] = '\0';
+ xstats[count].id = count + xcount;
xstats[count++].value = val;
}
}
@@ -1621,7 +1699,6 @@ set_queue_stats_mapping(uint8_t port_id, uint16_t queue_id, uint8_t stat_idx,
(dev, queue_id, stat_idx, is_rx);
}
-
int
rte_eth_dev_set_tx_queue_stats_mapping(uint8_t port_id, uint16_t tx_queue_id,
uint8_t stat_idx)
@@ -1630,7 +1707,6 @@ rte_eth_dev_set_tx_queue_stats_mapping(uint8_t port_id, uint16_t tx_queue_id,
STAT_QMAP_TX);
}
-
int
rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
uint8_t stat_idx)
@@ -1639,7 +1715,6 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
STAT_QMAP_RX);
}
-
void
rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
{
@@ -1699,7 +1774,6 @@ rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr)
ether_addr_copy(&dev->data->mac_addrs[0], mac_addr);
}
-
int
rte_eth_dev_get_mtu(uint8_t port_id, uint16_t *mtu)
{
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 022733e..eaeb703 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -941,10 +941,23 @@ struct rte_eth_txq_info {
* structure.
*/
struct rte_eth_xstats {
+ /* FIXME: Remove name[] once remaining drivers converted */
char name[RTE_ETH_XSTATS_NAME_SIZE];
+ uint64_t id;
uint64_t value;
};
+/**
+ * A name-key lookup element for extended statistics.
+ *
+ * This structure is used to map between names and ID numbers
+ * for extended ethernet statistics.
+ */
+struct rte_eth_xstats_name {
+ char name[RTE_ETH_XSTATS_NAME_SIZE];
+ uint64_t id;
+};
+
#define ETH_DCB_NUM_TCS 8
#define ETH_MAX_VMDQ_POOL 64
@@ -1080,6 +1093,13 @@ typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev,
typedef void (*eth_xstats_reset_t)(struct rte_eth_dev *dev);
/**< @internal Reset extended stats of an Ethernet device. */
+typedef int (*eth_xstats_names_t)(struct rte_eth_dev *dev,
+ struct rte_eth_xstats_name *ptr_names, unsigned limit);
+/**< @internal Get names of extended stats of an Ethernet device. */
+
+typedef int (*eth_xstats_count_t)(struct rte_eth_dev *dev);
+/**< @internal Get count of extended stats of an Ethernet device. */
+
typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev,
uint16_t queue_id,
uint8_t stat_idx,
@@ -1427,6 +1447,10 @@ struct eth_dev_ops {
eth_stats_reset_t stats_reset; /**< Reset generic device statistics. */
eth_xstats_get_t xstats_get; /**< Get extended device statistics. */
eth_xstats_reset_t xstats_reset; /**< Reset extended device statistics. */
+ eth_xstats_names_t xstats_names;
+ /**< Get names of extended statistics. */
+ eth_xstats_count_t xstats_count;
+ /**< Get number of extended statistics. */
eth_queue_stats_mapping_set_t queue_stats_mapping_set;
/**< Configure per queue stat counter mapping. */
eth_dev_infos_get_t dev_infos_get; /**< Get device info. */
@@ -2279,6 +2303,37 @@ int rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats);
void rte_eth_stats_reset(uint8_t port_id);
/**
+ * Retrieve names of extended statistics of an Ethernet device.
+ *
+ * Names within ptr_strings will be aligned to RTE_ETH_XSTATS_NAME_SIZE and
+ * will be listed in ascending mapping order.
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ * @param ptr_names
+ * Block of memory to insert names into. Must be at least limit in size.
+ * @param limit
+ * Capacity of ptr_strings (number of names).
+ * @return
+ * If successful, number of statistics; negative on error.
+ */
+int rte_eth_xstats_names(uint8_t port_id, struct rte_eth_xstats_name *ptr_names,
+ unsigned limit);
+
+/**
+ * Retrieve number of extended statistics of an Ethernet device.
+ *
+ * Names within ptr_strings will be aligned to RTE_ETH_XSTATS_NAME_SIZE and
+ * will be listed in ascending mapping order.
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ * @return
+ * If successful, number of statistics; negative on error.
+ */
+int rte_eth_xstats_count(uint8_t port_id);
+
+/**
* Retrieve extended statistics of an Ethernet device.
*
* @param port_id
--
2.5.5
next prev parent reply other threads:[~2016-05-06 11:11 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-15 14:44 [dpdk-dev] [RFC PATCH v1 0/3] Remove string operations from xstats Remy Horton
2016-04-15 14:44 ` [dpdk-dev] [RFC PATCH v1 1/3] rte: change xstats to use integer keys Remy Horton
2016-04-29 13:17 ` David Harton (dharton)
2016-04-15 14:44 ` [dpdk-dev] [RFC PATCH v1 2/3] drivers/net/ixgbe: change xstats to use integers Remy Horton
2016-04-29 13:43 ` David Harton (dharton)
2016-05-03 12:22 ` Remy Horton
2016-05-03 13:40 ` David Harton (dharton)
2016-04-15 14:44 ` [dpdk-dev] [RFC PATCH v1 3/3] examples/ethtool: add xstats display command Remy Horton
2016-04-20 16:03 ` [dpdk-dev] [RFC PATCH v1 0/3] Remove string operations from xstats David Harton (dharton)
2016-04-20 16:49 ` Mcnamara, John
2016-04-22 15:04 ` David Harton (dharton)
2016-04-28 14:56 ` Tahhan, Maryam
2016-04-28 15:58 ` David Harton (dharton)
2016-04-29 10:21 ` Remy Horton
2016-04-29 12:15 ` David Harton (dharton)
2016-04-29 12:52 ` David Harton (dharton)
2016-05-06 11:11 ` [dpdk-dev] [RFC PATCH v2 " Remy Horton
2016-05-06 11:11 ` Remy Horton [this message]
2016-05-09 13:59 ` [dpdk-dev] [RFC PATCH v2 1/3] rte: change xstats to use integer keys David Harton (dharton)
2016-05-10 8:58 ` Remy Horton
2016-05-12 16:17 ` Thomas Monjalon
2016-05-16 10:47 ` Tahhan, Maryam
2016-05-18 8:31 ` Tahhan, Maryam
2016-05-18 8:45 ` Remy Horton
2016-05-06 11:11 ` [dpdk-dev] [RFC PATCH v2 2/3] drivers/net/ixgbe: change xstats to use integer id Remy Horton
2016-05-09 14:06 ` David Harton (dharton)
2016-05-18 8:41 ` Tahhan, Maryam
2016-05-06 11:11 ` [dpdk-dev] [RFC PATCH v2 3/3] examples/ethtool: add xstats display command Remy Horton
2016-05-09 14:08 ` David Harton (dharton)
2016-05-18 8:42 ` Tahhan, Maryam
2016-05-16 10:42 ` [dpdk-dev] [RFC PATCH v2 0/3] Remove string operations from xstats Tahhan, Maryam
2016-05-18 10:12 ` Remy Horton
2016-05-30 10:48 ` [dpdk-dev] [PATCH v3 00/10] " Remy Horton
2016-05-30 10:48 ` [dpdk-dev] [PATCH v3 01/10] rte: change xstats to use integer ids Remy Horton
2016-06-08 9:37 ` Thomas Monjalon
2016-06-08 11:16 ` Remy Horton
2016-06-08 12:22 ` Thomas Monjalon
2016-05-30 10:48 ` [dpdk-dev] [PATCH v3 02/10] drivers/net/ixgbe: " Remy Horton
2016-05-30 10:48 ` [dpdk-dev] [PATCH v3 03/10] drivers/net/e1000: " Remy Horton
2016-05-30 10:48 ` [dpdk-dev] [PATCH v3 04/10] drivers/net/fm10k: " Remy Horton
2016-05-30 10:48 ` [dpdk-dev] [PATCH v3 05/10] drivers/net/i40e: " Remy Horton
2016-05-30 10:48 ` [dpdk-dev] [PATCH v3 06/10] drivers/net/virtio: " Remy Horton
2016-05-30 10:48 ` [dpdk-dev] [PATCH v3 07/10] app/test-pmd: " Remy Horton
2016-05-30 10:48 ` [dpdk-dev] [PATCH v3 08/10] app/proc_info: " Remy Horton
2016-05-30 10:48 ` [dpdk-dev] [PATCH v3 09/10] remove name field from struct rte_eth_xstats Remy Horton
2016-06-08 12:23 ` Thomas Monjalon
2016-05-30 10:48 ` [dpdk-dev] [PATCH v3 10/10] doc: update xstats documentation Remy Horton
2016-06-09 8:48 ` Mcnamara, John
2016-06-06 12:45 ` [dpdk-dev] [PATCH v3 00/10] Remove string operations from xstats David Harton (dharton)
2016-06-13 15:51 ` [dpdk-dev] [PATCH v4 0/8] " Remy Horton
2016-06-13 15:51 ` [dpdk-dev] [PATCH v4 1/8] rte: change xstats to use integer ids Remy Horton
2016-06-15 9:19 ` Thomas Monjalon
2016-06-13 15:51 ` [dpdk-dev] [PATCH v4 2/8] drivers/net/ixgbe: " Remy Horton
2016-06-13 15:51 ` [dpdk-dev] [PATCH v4 3/8] drivers/net/e1000: " Remy Horton
2016-06-13 15:51 ` [dpdk-dev] [PATCH v4 4/8] drivers/net/fm10k: " Remy Horton
2016-06-13 15:51 ` [dpdk-dev] [PATCH v4 5/8] drivers/net/i40e: " Remy Horton
2016-06-13 15:51 ` [dpdk-dev] [PATCH v4 6/8] drivers/net/virtio: " Remy Horton
2016-06-13 15:52 ` [dpdk-dev] [PATCH v4 7/8] rte: change xstats usage to new API Remy Horton
2016-06-15 9:13 ` Thomas Monjalon
2016-06-13 15:52 ` [dpdk-dev] [PATCH v4 8/8] doc: update xstats documentation Remy Horton
2016-06-14 14:06 ` Mcnamara, John
2016-06-15 15:25 ` [dpdk-dev] [PATCH v5 0/7] Remove string operations from xstats Remy Horton
2016-06-15 15:25 ` [dpdk-dev] [PATCH v5 1/7] rte: change xstats to use integer ids Remy Horton
2016-06-15 15:25 ` [dpdk-dev] [PATCH v5 2/7] drivers/net/ixgbe: " Remy Horton
2016-06-15 15:25 ` [dpdk-dev] [PATCH v5 3/7] drivers/net/e1000: " Remy Horton
2016-06-15 15:25 ` [dpdk-dev] [PATCH v5 4/7] drivers/net/fm10k: " Remy Horton
2016-06-15 15:25 ` [dpdk-dev] [PATCH v5 5/7] drivers/net/i40e: " Remy Horton
2016-06-15 15:25 ` [dpdk-dev] [PATCH v5 6/7] drivers/net/virtio: " Remy Horton
2016-06-20 10:43 ` Yuanhan Liu
2016-06-15 15:25 ` [dpdk-dev] [PATCH v5 7/7] rte: change xstats usage to new API Remy Horton
2016-06-16 16:02 ` [dpdk-dev] [PATCH v5 0/7] Remove string operations from xstats 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=1462533074-1994-2-git-send-email-remy.horton@intel.com \
--to=remy.horton@intel.com \
--cc=dev@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).