From: Harry van Haaren <harry.van.haaren@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 05/11] igb: add xstats() implementation
Date: Tue, 29 Sep 2015 15:32:49 +0100 [thread overview]
Message-ID: <1443537175-13809-6-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_get() and xstats_reset() functions to igb
driver, and the neccessary strings to expose these
NIC statistics.
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
drivers/net/e1000/igb_ethdev.c | 126 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 122 insertions(+), 4 deletions(-)
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 848ef6e..01d17a9 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -96,7 +96,10 @@ static int eth_igb_link_update(struct rte_eth_dev *dev,
int wait_to_complete);
static void eth_igb_stats_get(struct rte_eth_dev *dev,
struct rte_eth_stats *rte_stats);
+static int eth_igb_xstats_get(struct rte_eth_dev *dev,
+ struct rte_eth_xstats *xstats, unsigned n);
static void eth_igb_stats_reset(struct rte_eth_dev *dev);
+static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
static void eth_igb_infos_get(struct rte_eth_dev *dev,
struct rte_eth_dev_info *dev_info);
static void eth_igbvf_infos_get(struct rte_eth_dev *dev,
@@ -292,7 +295,9 @@ static const struct eth_dev_ops eth_igb_ops = {
.allmulticast_disable = eth_igb_allmulticast_disable,
.link_update = eth_igb_link_update,
.stats_get = eth_igb_stats_get,
+ .xstats_get = eth_igb_xstats_get,
.stats_reset = eth_igb_stats_reset,
+ .xstats_reset = eth_igb_xstats_reset,
.dev_infos_get = eth_igb_infos_get,
.mtu_set = eth_igb_mtu_set,
.vlan_filter_set = eth_igb_vlan_filter_set,
@@ -354,6 +359,68 @@ static const struct eth_dev_ops igbvf_eth_dev_ops = {
.get_reg = igbvf_get_regs,
};
+/* store statistics names and its offset in stats structure */
+struct rte_igb_xstats_name_off {
+ char name[RTE_ETH_XSTATS_NAME_SIZE];
+ unsigned offset;
+};
+
+static const struct rte_igb_xstats_name_off rte_igb_stats_strings[] = {
+ {"rx_crc_errors", offsetof(struct e1000_hw_stats, crcerrs)},
+ {"rx_align_errors", offsetof(struct e1000_hw_stats, algnerrc)},
+ {"rx_symbol_errors", offsetof(struct e1000_hw_stats, symerrs)},
+ {"rx_errors", offsetof(struct e1000_hw_stats, rxerrc)},
+ {"rx_missed_packets", offsetof(struct e1000_hw_stats, mpc)},
+ {"tx_single_collisions", offsetof(struct e1000_hw_stats, scc)},
+ {"tx_excessive_collisions", offsetof(struct e1000_hw_stats, ecol)},
+ {"tx_multiple_collisions", offsetof(struct e1000_hw_stats, mcc)},
+ {"tx_late_collisions", offsetof(struct e1000_hw_stats, latecol)},
+ {"tx_total_collisions", offsetof(struct e1000_hw_stats, colc)},
+ {"tx_defers", offsetof(struct e1000_hw_stats, dc)},
+ {"tx_with_no_carrier_sense", offsetof(struct e1000_hw_stats, tncrs)},
+ {"rx_carrier_ext_errors", offsetof(struct e1000_hw_stats, cexterr)},
+ {"rx_length_errors", offsetof(struct e1000_hw_stats, rlec)},
+ {"rx_xon_packets", offsetof(struct e1000_hw_stats, xonrxc)},
+ {"tx_xon_packets", offsetof(struct e1000_hw_stats, xontxc)},
+ {"rx_xoff_packets", offsetof(struct e1000_hw_stats, xoffrxc)},
+ {"tx_xoff_packets", offsetof(struct e1000_hw_stats, xofftxc)},
+ {"rx_flow_control_unsupported", offsetof(struct e1000_hw_stats, fcruc)},
+ {"rx_size_64", offsetof(struct e1000_hw_stats, prc64)},
+ {"rx_size_65_to_127", offsetof(struct e1000_hw_stats, prc127)},
+ {"rx_size_128_to_255", offsetof(struct e1000_hw_stats, prc255)},
+ {"rx_size_256_to_511", offsetof(struct e1000_hw_stats, prc511)},
+ {"rx_size_512_to_1023", offsetof(struct e1000_hw_stats, prc1023)},
+ {"rx_size_1023_to_max", offsetof(struct e1000_hw_stats, prc1522)},
+ {"rx_broadcast_packets", offsetof(struct e1000_hw_stats, bprc)},
+ {"rx_multicast_packets", offsetof(struct e1000_hw_stats, mprc)},
+ {"rx_no_buffer_errors", offsetof(struct e1000_hw_stats, rnbc)},
+ {"rx_undersize_packets", offsetof(struct e1000_hw_stats, ruc)},
+ {"rx_fragment_packets", offsetof(struct e1000_hw_stats, rfc)},
+ {"rx_oversize_packets", offsetof(struct e1000_hw_stats, roc)},
+ {"rx_jabber_packets", offsetof(struct e1000_hw_stats, rjc)},
+ {"rx_management_packets", offsetof(struct e1000_hw_stats, mgprc)},
+ {"rx_management_dropped", offsetof(struct e1000_hw_stats, mgpdc)},
+ {"tx_management_packets", offsetof(struct e1000_hw_stats, mgptc)},
+ {"rx_total_bytes", offsetof(struct e1000_hw_stats, tor)},
+ {"tx_total_bytes", offsetof(struct e1000_hw_stats, tot)},
+ {"rx_total_packets", offsetof(struct e1000_hw_stats, tpr)},
+ {"tx_total_packets", offsetof(struct e1000_hw_stats, tpt)},
+ {"tx_size_64", offsetof(struct e1000_hw_stats, ptc64)},
+ {"tx_size_65_to_127", offsetof(struct e1000_hw_stats, ptc127)},
+ {"tx_size_128_to_255", offsetof(struct e1000_hw_stats, ptc255)},
+ {"tx_size_256_to_511", offsetof(struct e1000_hw_stats, ptc511)},
+ {"tx_size_512_to_1023", offsetof(struct e1000_hw_stats, ptc1023)},
+ {"tx_size_1023_to_max", offsetof(struct e1000_hw_stats, ptc1522)},
+ {"tx_multicast_packets", offsetof(struct e1000_hw_stats, mptc)},
+ {"tx_broadcast_packets", offsetof(struct e1000_hw_stats, bptc)},
+ {"tx_tso_packets", offsetof(struct e1000_hw_stats, tsctc)},
+ {"tx_tso_errors", offsetof(struct e1000_hw_stats, tsctfc)},
+ {"interrupt_assert_count", offsetof(struct e1000_hw_stats, iac)},
+};
+
+#define IGB_NB_XSTATS (sizeof(rte_igb_stats_strings) / \
+ sizeof(rte_igb_stats_strings[0]))
+
/**
* Atomically reads the link status information from global
* structure rte_eth_dev.
@@ -1257,11 +1324,8 @@ igb_hardware_init(struct e1000_hw *hw)
/* This function is based on igb_update_stats_counters() in igb/if_igb.c */
static void
-eth_igb_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats)
+igb_read_stats_registers(struct e1000_hw *hw, struct e1000_hw_stats *stats)
{
- struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- struct e1000_hw_stats *stats =
- E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
int pause_frames;
if(hw->phy.media_type == e1000_media_type_copper ||
@@ -1365,6 +1429,16 @@ eth_igb_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats)
stats->cexterr += E1000_READ_REG(hw, E1000_CEXTERR);
stats->tsctc += E1000_READ_REG(hw, E1000_TSCTC);
stats->tsctfc += E1000_READ_REG(hw, E1000_TSCTFC);
+}
+
+static void
+eth_igb_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_hw_stats *stats =
+ E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
+
+ igb_read_stats_registers(hw, stats);
if (rte_stats == NULL)
return;
@@ -1407,6 +1481,50 @@ eth_igb_stats_reset(struct rte_eth_dev *dev)
}
static void
+eth_igb_xstats_reset(struct rte_eth_dev *dev)
+{
+ struct e1000_hw_stats *stats =
+ E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
+
+ /* HW registers are cleared on read */
+ eth_igb_xstats_get(dev, NULL, IGB_NB_XSTATS);
+
+ /* Reset software totals */
+ memset(stats, 0, sizeof(*stats));
+}
+
+static int
+eth_igb_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_hw_stats *hw_stats =
+ E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
+ unsigned i;
+
+ if(n < IGB_NB_XSTATS)
+ return IGB_NB_XSTATS;
+
+ igb_read_stats_registers(hw, hw_stats);
+
+ /* If this is a reset xstats is NULL, and we have cleared the
+ * registers by reading them.
+ */
+ if (!xstats)
+ return 0;
+
+ /* Extended stats */
+ for (i = 0; i < IGB_NB_XSTATS; i++) {
+ snprintf(xstats[i].name, sizeof(xstats[i].name),
+ "%s", rte_igb_stats_strings[i].name);
+ xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
+ rte_igb_stats_strings[i].offset);
+ }
+
+ return IGB_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);
--
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 ` Harry van Haaren [this message]
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 ` [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-6-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).