DPDK patches and discussions
 help / color / mirror / Atom feed
From: Harry van Haaren <harry.van.haaren@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 08/11] ixgbevf: add xstats() functions to VF
Date: Tue, 29 Sep 2015 15:32:52 +0100	[thread overview]
Message-ID: <1443537175-13809-9-git-send-email-harry.van.haaren@intel.com> (raw)
In-Reply-To: <1443537175-13809-1-git-send-email-harry.van.haaren@intel.com>

Add xstats() functions and stat strings as necessary to ixgbevf PMD.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 51 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 49 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 198d96e..f6d3814 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -149,6 +149,8 @@ static void ixgbe_dev_stats_get(struct rte_eth_dev *dev,
 				struct rte_eth_stats *stats);
 static int ixgbe_dev_xstats_get(struct rte_eth_dev *dev,
 				struct rte_eth_xstats *xstats, unsigned n);
+static int ixgbevf_dev_xstats_get(struct rte_eth_dev *dev,
+				  struct rte_eth_xstats *xstats, unsigned n);
 static void ixgbe_dev_stats_reset(struct rte_eth_dev *dev);
 static void ixgbe_dev_xstats_reset(struct rte_eth_dev *dev);
 static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
@@ -477,7 +479,9 @@ static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
 	.dev_stop             = ixgbevf_dev_stop,
 	.link_update          = ixgbe_dev_link_update,
 	.stats_get            = ixgbevf_dev_stats_get,
+	.xstats_get           = ixgbevf_dev_xstats_get,
 	.stats_reset          = ixgbevf_dev_stats_reset,
+	.xstats_reset         = ixgbevf_dev_stats_reset,
 	.dev_close            = ixgbevf_dev_close,
 	.dev_infos_get        = ixgbevf_dev_info_get,
 	.mtu_set              = ixgbevf_dev_set_mtu,
@@ -775,6 +779,13 @@ static const struct rte_ixgbe_xstats_name_off rte_ixgbe_stats_strings[] = {
 #define IXGBE_NB_XSTATS (sizeof(rte_ixgbe_stats_strings) /	\
 		sizeof(rte_ixgbe_stats_strings[0]))
 
+static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {
+	{"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)},
+};
+
+#define IXGBEVF_NB_XSTATS (sizeof(rte_ixgbevf_stats_strings) /	\
+		sizeof(rte_ixgbevf_stats_strings[0]))
+
 /**
  * Atomically reads the link status information from global
  * structure rte_eth_dev.
@@ -2521,7 +2532,7 @@ ixgbe_dev_xstats_reset(struct rte_eth_dev *dev)
 }
 
 static void
-ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+ixgbevf_update_stats(struct rte_eth_dev *dev)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats*)
@@ -2546,8 +2557,44 @@ ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	/* Rx Multicst Packet */
 	UPDATE_VF_STAT(IXGBE_VFMPRC,
 	    hw_stats->last_vfmprc, hw_stats->vfmprc);
+}
 
-	if (stats == NULL)
+static int
+ixgbevf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
+		       unsigned n)
+{
+	struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
+			IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
+	unsigned i;
+
+	if(n < IXGBEVF_NB_XSTATS)
+		return IXGBEVF_NB_XSTATS;
+
+	ixgbevf_update_stats(dev);
+
+	if (!xstats)
+		return 0;
+
+	/* Extended stats */
+	for (i = 0; i < IXGBEVF_NB_XSTATS; i++) {
+		snprintf(xstats[i].name, sizeof(xstats[i].name),
+			 "%s", rte_ixgbevf_stats_strings[i].name);
+		xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
+			rte_ixgbevf_stats_strings[i].offset);
+	}
+
+	return 0;
+}
+
+static void
+ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+	struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
+			  IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
+
+	ixgbevf_update_stats(dev);
+
+	if(stats == NULL)
 		return;
 
 	stats->ipackets = hw_stats->vfgprc;
-- 
1.9.1

  parent reply	other threads:[~2015-09-29 14:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-29 14:32 [dpdk-dev] [PATCH 00/11] Port XStats Harry van Haaren
2015-09-29 14:32 ` [dpdk-dev] [PATCH 01/11] doc: add extended statistics notes Harry van Haaren
2015-09-29 14:32 ` [dpdk-dev] [PATCH 02/11] doc: add extended statistics to prog_guide Harry van Haaren
2015-09-29 14:32 ` [dpdk-dev] [PATCH 03/11] ethdev: update xstats_get() strings and Q handling Harry van Haaren
2015-09-29 14:32 ` [dpdk-dev] [PATCH 04/11] virtio: add xstats() implementation Harry van Haaren
2015-09-29 14:32 ` [dpdk-dev] [PATCH 05/11] igb: " Harry van Haaren
2015-09-29 14:32 ` [dpdk-dev] [PATCH 06/11] igbvf: " Harry van Haaren
2015-09-29 14:32 ` [dpdk-dev] [PATCH 07/11] ixgbe: update statistic strings to scheme Harry van Haaren
2015-09-29 14:32 ` Harry van Haaren [this message]
2015-09-29 14:32 ` [dpdk-dev] [PATCH 09/11] i40e: add xstats() implementation Harry van Haaren
2015-09-29 14:32 ` [dpdk-dev] [PATCH 10/11] i40evf: " Harry van Haaren
2015-09-29 14:32 ` [dpdk-dev] [PATCH 11/11] fm10k: " Harry van Haaren

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=1443537175-13809-9-git-send-email-harry.van.haaren@intel.com \
    --to=harry.van.haaren@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).