From: Harry van Haaren <harry.van.haaren@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 06/11] igbvf: add xstats() implementation
Date: Tue, 29 Sep 2015 15:32:50 +0100 [thread overview]
Message-ID: <1443537175-13809-7-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 functionality to igbvf PMD, adding
necessary statistic strings.
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
drivers/net/e1000/igb_ethdev.c | 57 ++++++++++++++++++++++++++++++++++++++----
1 file changed, 52 insertions(+), 5 deletions(-)
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 01d17a9..89d1519 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -153,6 +153,7 @@ static void igbvf_dev_stop(struct rte_eth_dev *dev);
static void igbvf_dev_close(struct rte_eth_dev *dev);
static int eth_igbvf_link_update(struct e1000_hw *hw);
static void eth_igbvf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats);
+static int eth_igbvf_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats, unsigned n);
static void eth_igbvf_stats_reset(struct rte_eth_dev *dev);
static int igbvf_vlan_filter_set(struct rte_eth_dev *dev,
uint16_t vlan_id, int on);
@@ -346,6 +347,7 @@ static const struct eth_dev_ops igbvf_eth_dev_ops = {
.dev_close = igbvf_dev_close,
.link_update = eth_igb_link_update,
.stats_get = eth_igbvf_stats_get,
+ .xstats_get = eth_igbvf_xstats_get,
.stats_reset = eth_igbvf_stats_reset,
.vlan_filter_set = igbvf_vlan_filter_set,
.dev_infos_get = eth_igbvf_infos_get,
@@ -421,6 +423,17 @@ static const struct rte_igb_xstats_name_off rte_igb_stats_strings[] = {
#define IGB_NB_XSTATS (sizeof(rte_igb_stats_strings) / \
sizeof(rte_igb_stats_strings[0]))
+static const struct rte_igb_xstats_name_off rte_igbvf_stats_strings[] = {
+ {"rx_multicast_packets", offsetof(struct e1000_vf_stats, mprc)},
+ {"rx_good_loopback_packets", offsetof(struct e1000_vf_stats, gprlbc)},
+ {"tx_good_loopback_packets", offsetof(struct e1000_vf_stats, gptlbc)},
+ {"rx_good_loopback_bytes", offsetof(struct e1000_vf_stats, gorlbc)},
+ {"tx_good_loopback_bytes", offsetof(struct e1000_vf_stats, gotlbc)},
+};
+
+#define IGBVF_NB_XSTATS (sizeof(rte_igbvf_stats_strings) / \
+ sizeof(rte_igbvf_stats_strings[0]))
+
/**
* Atomically reads the link status information from global
* structure rte_eth_dev.
@@ -1525,12 +1538,8 @@ eth_igb_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
}
static void
-eth_igbvf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats)
+igbvf_read_stats_registers(struct e1000_hw *hw, struct e1000_vf_stats *hw_stats)
{
- struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- struct e1000_vf_stats *hw_stats = (struct e1000_vf_stats*)
- E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
-
/* Good Rx packets, include VF loopback */
UPDATE_VF_STAT(E1000_VFGPRC,
hw_stats->last_gprc, hw_stats->gprc);
@@ -1567,6 +1576,44 @@ eth_igbvf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats)
UPDATE_VF_STAT(E1000_VFGOTLBC,
hw_stats->last_gotlbc, hw_stats->gotlbc);
+}
+
+static int
+eth_igbvf_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
+ unsigned n )
+{
+ struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct e1000_vf_stats *hw_stats = (struct e1000_vf_stats*)
+ E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
+ unsigned i;
+
+ if( n < IGBVF_NB_XSTATS )
+ return IGBVF_NB_XSTATS;
+
+ igbvf_read_stats_registers(hw, hw_stats);
+
+ if(!xstats)
+ return 0;
+
+ for(i = 0; i < IGBVF_NB_XSTATS; i++) {
+ snprintf(xstats[i].name, sizeof(xstats[i].name), "%s",
+ rte_igbvf_stats_strings[i].name);
+ xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
+ rte_igbvf_stats_strings[i].offset);
+ }
+
+ return IGBVF_NB_XSTATS;
+}
+
+static void
+eth_igbvf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats)
+{
+ struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct e1000_vf_stats *hw_stats = (struct e1000_vf_stats*)
+ E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
+
+ igbvf_read_stats_registers(hw, hw_stats);
+
if (rte_stats == NULL)
return;
--
1.9.1
next prev 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 ` Harry van Haaren [this message]
2015-09-29 14:32 ` [dpdk-dev] [PATCH 07/11] ixgbe: update statistic strings to scheme Harry van Haaren
2015-09-29 14:32 ` [dpdk-dev] [PATCH 08/11] ixgbevf: add xstats() functions to VF Harry van Haaren
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-7-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).