DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Charles (Chas) Williams" <ciwillia@brocade.com>
To: <dev@dpdk.org>
Cc: <skhare@vmware.com>, Robert Shearman <rshearma@brocade.com>
Subject: [dpdk-dev] [PATCH v2 2/6] net/vmxnet3: Implement retrieval of extended stats
Date: Thu, 15 Jun 2017 08:16:09 -0400	[thread overview]
Message-ID: <1497528973-16330-3-git-send-email-ciwillia@brocade.com> (raw)
In-Reply-To: <1497528973-16330-1-git-send-email-ciwillia@brocade.com>

From: Robert Shearman <rshearma@brocade.com>

Implement xstats_get() to allow a number of driver-specific tx and rx
stats to be retrieved.

Signed-off-by: Robert Shearman <rshearma@brocade.com>
---
 drivers/net/vmxnet3/vmxnet3_ethdev.c | 113 +++++++++++++++++++++++++++++++++++
 1 file changed, 113 insertions(+)

diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index 1301f50..f5a9832 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -88,6 +88,11 @@ static int vmxnet3_dev_link_update(struct rte_eth_dev *dev,
 static void vmxnet3_hw_stats_save(struct vmxnet3_hw *hw);
 static void vmxnet3_dev_stats_get(struct rte_eth_dev *dev,
 				  struct rte_eth_stats *stats);
+static int vmxnet3_dev_xstats_get_names(struct rte_eth_dev *dev,
+					struct rte_eth_xstat_name *xstats,
+					unsigned int n);
+static int vmxnet3_dev_xstats_get(struct rte_eth_dev *dev,
+				  struct rte_eth_xstat *xstats, unsigned int n);
 static void vmxnet3_dev_info_get(struct rte_eth_dev *dev,
 				 struct rte_eth_dev_info *dev_info);
 static const uint32_t *
@@ -122,6 +127,8 @@ static const struct eth_dev_ops vmxnet3_eth_dev_ops = {
 	.allmulticast_disable = vmxnet3_dev_allmulticast_disable,
 	.link_update          = vmxnet3_dev_link_update,
 	.stats_get            = vmxnet3_dev_stats_get,
+	.xstats_get_names     = vmxnet3_dev_xstats_get_names,
+	.xstats_get           = vmxnet3_dev_xstats_get,
 	.mac_addr_set         = vmxnet3_mac_addr_set,
 	.dev_infos_get        = vmxnet3_dev_info_get,
 	.dev_supported_ptypes_get = vmxnet3_dev_supported_ptypes_get,
@@ -133,6 +140,27 @@ static const struct eth_dev_ops vmxnet3_eth_dev_ops = {
 	.tx_queue_release     = vmxnet3_dev_tx_queue_release,
 };
 
+struct vmxnet3_xstats_name_off {
+	char name[RTE_ETH_XSTATS_NAME_SIZE];
+	unsigned int offset;
+};
+
+/* tx_qX_ is prepended to the name string here */
+static const struct vmxnet3_xstats_name_off vmxnet3_txq_stat_strings[] = {
+	{"drop_total",         offsetof(struct vmxnet3_txq_stats, drop_total)},
+	{"drop_too_many_segs", offsetof(struct vmxnet3_txq_stats, drop_too_many_segs)},
+	{"drop_tso",           offsetof(struct vmxnet3_txq_stats, drop_tso)},
+	{"tx_ring_full",       offsetof(struct vmxnet3_txq_stats, tx_ring_full)},
+};
+
+/* rx_qX_ is prepended to the name string here */
+static const struct vmxnet3_xstats_name_off vmxnet3_rxq_stat_strings[] = {
+	{"drop_total",           offsetof(struct vmxnet3_rxq_stats, drop_total)},
+	{"drop_err",             offsetof(struct vmxnet3_rxq_stats, drop_err)},
+	{"drop_fcs",             offsetof(struct vmxnet3_rxq_stats, drop_fcs)},
+	{"rx_buf_alloc_failure", offsetof(struct vmxnet3_rxq_stats, rx_buf_alloc_failure)},
+};
+
 static const struct rte_memzone *
 gpa_zone_reserve(struct rte_eth_dev *dev, uint32_t size,
 		 const char *post_string, int socket_id,
@@ -882,6 +910,91 @@ vmxnet3_hw_stats_save(struct vmxnet3_hw *hw)
 		vmxnet3_hw_rx_stats_get(hw, i, &hw->saved_rx_stats[i]);
 }
 
+static int
+vmxnet3_dev_xstats_get_names(struct rte_eth_dev *dev,
+			     struct rte_eth_xstat_name *xstats_names,
+			     unsigned int n)
+{
+	unsigned int i, t, count = 0;
+	unsigned int nstats =
+		dev->data->nb_tx_queues * RTE_DIM(vmxnet3_txq_stat_strings) +
+		dev->data->nb_rx_queues * RTE_DIM(vmxnet3_rxq_stat_strings);
+
+	if (!xstats_names || n < nstats)
+		return nstats;
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		if (!dev->data->rx_queues[i])
+			continue;
+
+		for (t = 0; t < RTE_DIM(vmxnet3_rxq_stat_strings); t++) {
+			snprintf(xstats_names[count].name,
+				 sizeof(xstats_names[count].name),
+				 "rx_q%u_%s", i,
+				 vmxnet3_rxq_stat_strings[t].name);
+			count++;
+		}
+	}
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		if (!dev->data->tx_queues[i])
+			continue;
+
+		for (t = 0; t < RTE_DIM(vmxnet3_txq_stat_strings); t++) {
+			snprintf(xstats_names[count].name,
+				 sizeof(xstats_names[count].name),
+				 "tx_q%u_%s", i,
+				 vmxnet3_txq_stat_strings[t].name);
+			count++;
+		}
+	}
+
+	return count;
+}
+
+static int
+vmxnet3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
+		       unsigned int n)
+{
+	unsigned int i, t, count = 0;
+	unsigned int nstats =
+		dev->data->nb_tx_queues * RTE_DIM(vmxnet3_txq_stat_strings) +
+		dev->data->nb_rx_queues * RTE_DIM(vmxnet3_rxq_stat_strings);
+
+	if (n < nstats)
+		return nstats;
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		struct vmxnet3_rx_queue *rxq = dev->data->rx_queues[i];
+
+		if (rxq == NULL)
+			continue;
+
+		for (t = 0; t < RTE_DIM(vmxnet3_rxq_stat_strings); t++) {
+			xstats[count].value = *(uint64_t *)(((char *)&rxq->stats) +
+				vmxnet3_rxq_stat_strings[t].offset);
+			xstats[count].id = count;
+			count++;
+		}
+	}
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		struct vmxnet3_tx_queue *txq = dev->data->tx_queues[i];
+
+		if (txq == NULL)
+			continue;
+
+		for (t = 0; t < RTE_DIM(vmxnet3_txq_stat_strings); t++) {
+			xstats[count].value = *(uint64_t *)(((char *)&txq->stats) +
+				vmxnet3_txq_stat_strings[t].offset);
+			xstats[count].id = count;
+			count++;
+		}
+	}
+
+	return count;
+}
+
 static void
 vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
-- 
2.1.4

  parent reply	other threads:[~2017-06-15 12:17 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-19 17:55 [dpdk-dev] [PATCH 1/6] net/vmxnet3: retain counters on restart Charles (Chas) Williams
2017-05-19 17:55 ` [dpdk-dev] [PATCH 2/6] net/vmxnet3: Implement retrieval of extended stats Charles (Chas) Williams
2017-05-24  0:17   ` Shrikrishna Khare
2017-05-19 17:55 ` [dpdk-dev] [PATCH 3/6] net/vmxnet3: Generate link-state change notifications Charles (Chas) Williams
2017-05-19 17:55 ` [dpdk-dev] [PATCH 4/6] net/vmxnet3: Make vmxnet3_process_events less noisy Charles (Chas) Williams
2017-05-23 21:44   ` Shrikrishna Khare
2017-05-19 17:55 ` [dpdk-dev] [PATCH 5/6] net/vmxnet3: receive queue lockup and memleak Charles (Chas) Williams
2017-06-01 12:24   ` Charles (Chas) Williams
2017-05-24 21:09 ` [dpdk-dev] [PATCH 1/6] net/vmxnet3: retain counters on restart Shrikrishna Khare
2017-05-25 18:31   ` Nachi Prachanda
2017-05-25 20:27     ` Shrikrishna Khare
2017-05-25 22:08       ` Nachi Prachanda
2017-05-26 17:29         ` Shrikrishna Khare
2017-05-26 19:01           ` Nachi Prachanda
2017-05-26 17:31 ` Shrikrishna Khare
2017-06-15 12:16 ` [dpdk-dev] [PATCH V2 0/6] some local vmxnet3 patches Charles (Chas) Williams
2017-06-15 12:16   ` [dpdk-dev] [PATCH v2 1/6] net/vmxnet3: retain counters on restart Charles (Chas) Williams
2017-06-15 12:16   ` Charles (Chas) Williams [this message]
2017-06-21  1:42     ` [dpdk-dev] [PATCH v2 2/6] net/vmxnet3: Implement retrieval of extended stats Shrikrishna Khare
2017-06-15 12:16   ` [dpdk-dev] [PATCH v2 3/6] net/vmxnet3: Generate link-state change notifications Charles (Chas) Williams
2017-06-27 13:52     ` Ferruh Yigit
2017-06-15 12:16   ` [dpdk-dev] [PATCH v2 4/6] net/vmxnet3: Make vmxnet3_process_events less noisy Charles (Chas) Williams
2017-06-28 11:30   ` [dpdk-dev] [PATCH V2 0/6] some local vmxnet3 patches Ferruh Yigit
2017-06-28 12:52     ` Ferruh Yigit
2017-06-28 13:09       ` Charles (Chas) Williams
2017-06-28 17:15       ` Charles (Chas) Williams
2017-06-28 17:54         ` Ferruh Yigit
2017-06-15 12:17 ` [dpdk-dev] [PATCH v2 5/6] net/vmxnet3: receive queue memory leak Charles (Chas) Williams
2017-06-23 23:00   ` Shrikrishna Khare
2017-06-15 12:17 ` [dpdk-dev] [PATCH v2 6/6] net/vmxnet3: preserve configured MAC address Charles (Chas) Williams

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=1497528973-16330-3-git-send-email-ciwillia@brocade.com \
    --to=ciwillia@brocade.com \
    --cc=dev@dpdk.org \
    --cc=rshearma@brocade.com \
    --cc=skhare@vmware.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).