DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 00/11] Port XStats
@ 2015-09-29 14:32 Harry van Haaren
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 01/11] doc: add extended statistics notes Harry van Haaren
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Harry van Haaren @ 2015-09-29 14:32 UTC (permalink / raw)
  To: dev

This patchset adds an implementation of the xstats_get() and xstats_reset() API to the following PMDs: virtio, igb, igbvf, ixgbe, ixgbevf, i40e, i40evf and fm10k.

The xstats API allows DPDK apps to gain access to extended statistics from each port on a NIC. These statistics are structured as per a scheme detailed in the patch for the doc/prog_guide.

Harry van Haaren (11):
      doc: add extended statistics notes
      doc: add extended statistics to prog_guide
      ethdev: update xstats_get() strings and Q handling
      virtio: add xstats() implementation
      igb: add xstats() implementation
      igbvf: add xstats() implementation
      ixgbe: update statistic strings to scheme
      ixgbevf: add xstats() functions to VF
      i40e: add xstats() implementation
      i40evf: add xstats() implementation
      fm10k: add xstats() implementation

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 01/11] doc: add extended statistics notes
  2015-09-29 14:32 [dpdk-dev] [PATCH 00/11] Port XStats Harry van Haaren
@ 2015-09-29 14:32 ` Harry van Haaren
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 02/11] doc: add extended statistics to prog_guide Harry van Haaren
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Harry van Haaren @ 2015-09-29 14:32 UTC (permalink / raw)
  To: dev

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 doc/guides/rel_notes/release_2_2.rst | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/doc/guides/rel_notes/release_2_2.rst b/doc/guides/rel_notes/release_2_2.rst
index 9a70dae..35f26d5 100644
--- a/doc/guides/rel_notes/release_2_2.rst
+++ b/doc/guides/rel_notes/release_2_2.rst
@@ -4,6 +4,18 @@ DPDK Release 2.2
 New Features
 ------------
 
+* **Extended Statistics**
+
+  Define extended statistics naming scheme to store metadata in the name
+  string name of each statistic. Implemented the extended stats API for
+  these PMDs:
+
+  * igb
+  * igbvf
+  * i40e
+  * i40evf
+  * fm10k
+  * virtio
 
 Resolved Issues
 ---------------
-- 
1.9.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 02/11] doc: add extended statistics to prog_guide
  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 ` Harry van Haaren
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 03/11] ethdev: update xstats_get() strings and Q handling Harry van Haaren
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Harry van Haaren @ 2015-09-29 14:32 UTC (permalink / raw)
  To: dev

Add extended statistic section to the programmers
guide, poll mode driver section. This section describes
how the strings stats are formatted, and how the client
code can use this to gather information about the stat.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 doc/guides/prog_guide/poll_mode_drv.rst | 42 +++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/doc/guides/prog_guide/poll_mode_drv.rst b/doc/guides/prog_guide/poll_mode_drv.rst
index 8780ba3..436e42a 100644
--- a/doc/guides/prog_guide/poll_mode_drv.rst
+++ b/doc/guides/prog_guide/poll_mode_drv.rst
@@ -294,3 +294,45 @@ Ethernet Device API
 ~~~~~~~~~~~~~~~~~~~
 
 The Ethernet device API exported by the Ethernet PMDs is described in the *DPDK API Reference*.
+
+Extended Statistics API
+~~~~~~~~~~~~~~~~~~~~~~~
+
+The extended statistics API allows each individual PMD to expose a unique set
+of statistics. The client of the API provides an array of
+``struct rte_eth_xstats`` type. Each ``struct rte_eth_xstats`` contains a
+string and value pair. The amount of xstats exposed, and position of the
+statistic in the array must remain constant during runtime.
+
+A naming scheme exists for the strings exposed to clients of the API. This is
+to allow scraping of the API for statistics of interest. The naming scheme uses
+strings split by a single underscore ``_``. The scheme is as follows:
+
+* direction
+* detail 1
+* detail 2
+* detail n
+* unit
+
+The scheme, although quite simple, allows flexibility in presenting and reading
+information from the statistic strings. The following example illustrates the
+naming scheme:``rx_packets``. In this example, the string is split into two
+components. The first component ``rx`` indicates that the statistic is
+associated with the receive side of the NIC.  The second component ``packets``
+indicates that the unit of measure is packets.
+
+A more complicated example: ``tx_size_128_to_255_packets``. In this example,
+``tx`` indicates transmission, ``size``  is the first detail, ``128`` etc are
+more details, and ``packets`` indicates that this is a packet counter.
+
+Some additions in the metadata scheme are as follows:
+
+* If the first part does not match ``rx`` or ``tx``, the statistic does not
+  have an affinity with either recieve of transmit.
+
+* If the first letter of the second part is ``q`` and this ``q`` is followed
+  by a number, this statistic is part of a specific queue.
+
+An example where queue numbers are used is as follows: ``tx_q7_bytes`` which
+indicates this statistic applies to queue number 7, and represents the number
+of transmitted bytes on that queue.
-- 
1.9.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 03/11] ethdev: update xstats_get() strings and Q handling
  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 ` Harry van Haaren
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 04/11] virtio: add xstats() implementation Harry van Haaren
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Harry van Haaren @ 2015-09-29 14:32 UTC (permalink / raw)
  To: dev

Update the strings used for presenting stats to adhere
to the scheme previously presented. Updated xstats_get()
function to handle Q information only if xstats() is not
implemented in the PMD.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b309309..370f3ac 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -143,7 +143,7 @@ static const struct rte_eth_xstats_name_off rte_stats_strings[] = {
 	{"tx_bytes", offsetof(struct rte_eth_stats, obytes)},
 	{"tx_errors", offsetof(struct rte_eth_stats, oerrors)},
 	{"rx_errors", offsetof(struct rte_eth_stats, ierrors)},
-	{"alloc_rx_buff_failed", offsetof(struct rte_eth_stats, rx_nombuf)},
+	{"rx_no_mbufs_avail_errors", offsetof(struct rte_eth_stats, rx_nombuf)},
 };
 #define RTE_NB_STATS (sizeof(rte_stats_strings) / sizeof(rte_stats_strings[0]))
 
@@ -1666,8 +1666,6 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
 
 	/* Return generic statistics */
 	count = RTE_NB_STATS;
-	count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS;
-	count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS;
 
 	/* implemented by the driver */
 	if (dev->dev_ops->xstats_get != NULL) {
@@ -1679,6 +1677,9 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
 
 		if (xcount < 0)
 			return xcount;
+	} else {
+		count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS;
+		count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS;
 	}
 
 	if (n < count + xcount)
@@ -1698,6 +1699,10 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
 		xstats[count++].value = val;
 	}
 
+	/* if xstats_get() is implemented by the PMD, the Q stats are done */
+	if (dev->dev_ops->xstats_get != NULL)
+		return count + xcount;
+
 	/* per-rxq stats */
 	for (q = 0; q < dev->data->nb_rx_queues; q++) {
 		for (i = 0; i < RTE_NB_RXQ_STATS; i++) {
@@ -1706,7 +1711,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
 					q * sizeof(uint64_t));
 			val = *stats_ptr;
 			snprintf(xstats[count].name, sizeof(xstats[count].name),
-				"rx_queue_%u_%s", q,
+				"rx_q%u_%s", q,
 				rte_rxq_stats_strings[i].name);
 			xstats[count++].value = val;
 		}
@@ -1720,7 +1725,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
 					q * sizeof(uint64_t));
 			val = *stats_ptr;
 			snprintf(xstats[count].name, sizeof(xstats[count].name),
-				"tx_queue_%u_%s", q,
+				"tx_q%u_%s", q,
 				rte_txq_stats_strings[i].name);
 			xstats[count++].value = val;
 		}
-- 
1.9.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 04/11] virtio: add xstats() implementation
  2015-09-29 14:32 [dpdk-dev] [PATCH 00/11] Port XStats Harry van Haaren
                   ` (2 preceding siblings ...)
  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 ` Harry van Haaren
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 05/11] igb: " Harry van Haaren
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Harry van Haaren @ 2015-09-29 14:32 UTC (permalink / raw)
  To: dev

Add xstats() functions and statistic strings to virtio PMD.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 86 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 84 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 465d3cd..165ad97 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -80,7 +80,10 @@ static int virtio_dev_link_update(struct rte_eth_dev *dev,
 static void virtio_set_hwaddr(struct virtio_hw *hw);
 static void virtio_get_hwaddr(struct virtio_hw *hw);
 
-static void virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);
+static void virtio_dev_stats_get(struct rte_eth_dev *dev,
+				 struct rte_eth_stats *stats);
+static int virtio_dev_xstats_get(struct rte_eth_dev *dev,
+				 struct rte_eth_xstats *xstats, unsigned n);
 static void virtio_dev_stats_reset(struct rte_eth_dev *dev);
 static void virtio_dev_free_mbufs(struct rte_eth_dev *dev);
 static int virtio_vlan_filter_set(struct rte_eth_dev *dev,
@@ -109,6 +112,21 @@ static const struct rte_pci_id pci_id_virtio_map[] = {
 { .vendor_id = 0, /* sentinel */ },
 };
 
+struct rte_virtio_xstats_name_off {
+	char name[RTE_ETH_XSTATS_NAME_SIZE];
+	unsigned offset;
+};
+
+/* [rt]x_qX_ is prepended to the name string here */
+static const struct rte_virtio_xstats_name_off rte_virtio_q_stat_strings[] = {
+	{"packets", offsetof(struct virtqueue, packets)},
+	{"bytes", offsetof(struct virtqueue, bytes)},
+	{"errors", offsetof(struct virtqueue, errors)},
+};
+
+#define VIRTIO_NB_Q_XSTATS (sizeof(rte_virtio_q_stat_strings) / \
+			    sizeof(rte_virtio_q_stat_strings[0]))
+
 static int
 virtio_send_command(struct virtqueue *vq, struct virtio_pmd_ctrl *ctrl,
 		int *dlen, int pkt_num)
@@ -568,7 +586,9 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 
 	.dev_infos_get           = virtio_dev_info_get,
 	.stats_get               = virtio_dev_stats_get,
+	.xstats_get              = virtio_dev_xstats_get,
 	.stats_reset             = virtio_dev_stats_reset,
+	.xstats_reset            = virtio_dev_stats_reset,
 	.link_update             = virtio_dev_link_update,
 	.rx_queue_setup          = virtio_dev_rx_queue_setup,
 	.rx_queue_release        = virtio_dev_rx_queue_release,
@@ -623,7 +643,7 @@ virtio_dev_atomic_write_link_status(struct rte_eth_dev *dev,
 }
 
 static void
-virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+virtio_update_stats(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
 	unsigned i;
 
@@ -660,6 +680,68 @@ virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
 }
 
+static int
+virtio_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
+		      unsigned n)
+{
+	unsigned i;
+	unsigned count = 0;
+
+	// TODO: what about global stats? mbuf_alloc_failed?
+	unsigned nstats = dev->data->nb_tx_queues * VIRTIO_NB_Q_XSTATS +
+		dev->data->nb_rx_queues * VIRTIO_NB_Q_XSTATS;
+
+	if(n < nstats)
+		return nstats;
+
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		struct virtqueue *rxvq = dev->data->rx_queues[i];
+
+		if(rxvq == NULL)
+			continue;
+
+		unsigned t;
+
+		for(t = 0; t < VIRTIO_NB_Q_XSTATS; t++) {
+			snprintf(xstats[count].name, sizeof(xstats[count].name),
+				 "rx_q%u_%s", i,
+				 rte_virtio_q_stat_strings[t].name);
+			xstats[count].value = *(uint64_t *)(((char *)rxvq) +
+				rte_virtio_q_stat_strings[t].offset);
+			count++;
+		}
+	}
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		struct virtqueue *txvq = dev->data->tx_queues[i];
+
+		// TODO: Concider returning 0 value instead of skipping?
+		// TODO: Is it possible to have NULL queues? ie check necessary?
+		if(txvq == NULL)
+			continue;
+
+		unsigned t;
+
+		for(t = 0; t < VIRTIO_NB_Q_XSTATS; t++) {
+			snprintf(xstats[count].name, sizeof(xstats[count].name),
+				 "tx_q%u_%s", i,
+				 rte_virtio_q_stat_strings[t].name);
+			xstats[count].value = *(uint64_t *)(((char *)txvq) +
+				rte_virtio_q_stat_strings[t].offset);
+			count++;
+		}
+	}
+
+	return count;
+}
+
+static void
+virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+	virtio_update_stats(dev, stats);
+}
+
 static void
 virtio_dev_stats_reset(struct rte_eth_dev *dev)
 {
-- 
1.9.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 05/11] igb: add xstats() implementation
  2015-09-29 14:32 [dpdk-dev] [PATCH 00/11] Port XStats Harry van Haaren
                   ` (3 preceding siblings ...)
  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
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 06/11] igbvf: " Harry van Haaren
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Harry van Haaren @ 2015-09-29 14:32 UTC (permalink / raw)
  To: dev

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 06/11] igbvf: add xstats() implementation
  2015-09-29 14:32 [dpdk-dev] [PATCH 00/11] Port XStats Harry van Haaren
                   ` (4 preceding siblings ...)
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 05/11] igb: " Harry van Haaren
@ 2015-09-29 14:32 ` Harry van Haaren
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 07/11] ixgbe: update statistic strings to scheme Harry van Haaren
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Harry van Haaren @ 2015-09-29 14:32 UTC (permalink / raw)
  To: dev

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 07/11] ixgbe: update statistic strings to scheme
  2015-09-29 14:32 [dpdk-dev] [PATCH 00/11] Port XStats Harry van Haaren
                   ` (5 preceding siblings ...)
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 06/11] igbvf: " Harry van Haaren
@ 2015-09-29 14:32 ` Harry van Haaren
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 08/11] ixgbevf: add xstats() functions to VF Harry van Haaren
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Harry van Haaren @ 2015-09-29 14:32 UTC (permalink / raw)
  To: dev

Updated and add statistic strings as used by xstats_get().

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

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index ec2918c..198d96e 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -506,29 +506,270 @@ struct rte_ixgbe_xstats_name_off {
 };
 
 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_stats_strings[] = {
-	{"rx_illegal_byte_err", offsetof(struct ixgbe_hw_stats, errbc)},
-	{"rx_len_err", offsetof(struct ixgbe_hw_stats, rlec)},
-	{"rx_undersize_count", offsetof(struct ixgbe_hw_stats, ruc)},
-	{"rx_oversize_count", offsetof(struct ixgbe_hw_stats, roc)},
-	{"rx_fragment_count", offsetof(struct ixgbe_hw_stats, rfc)},
-	{"rx_jabber_count", offsetof(struct ixgbe_hw_stats, rjc)},
-	{"l3_l4_xsum_error", offsetof(struct ixgbe_hw_stats, xec)},
-	{"mac_local_fault", offsetof(struct ixgbe_hw_stats, mlfc)},
-	{"mac_remote_fault", offsetof(struct ixgbe_hw_stats, mrfc)},
-	{"mac_short_pkt_discard", offsetof(struct ixgbe_hw_stats, mspdc)},
-	{"fccrc_error", offsetof(struct ixgbe_hw_stats, fccrc)},
-	{"fcoe_drop", offsetof(struct ixgbe_hw_stats, fcoerpdc)},
-	{"fc_last_error", offsetof(struct ixgbe_hw_stats, fclast)},
-	{"rx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bprc)},
-	{"rx_phy_multicast_packets", offsetof(struct ixgbe_hw_stats, mprc)},
-	{"mgmt_pkts_dropped", offsetof(struct ixgbe_hw_stats, mngpdc)},
 	{"rx_crc_errors", offsetof(struct ixgbe_hw_stats, crcerrs)},
-	{"fdir_match", offsetof(struct ixgbe_hw_stats, fdirmatch)},
-	{"fdir_miss", offsetof(struct ixgbe_hw_stats, fdirmiss)},
+	{"rx_illegal_byte_errors", offsetof(struct ixgbe_hw_stats, illerrc)},
+	{"rx_error_bytes", offsetof(struct ixgbe_hw_stats, errbc)},
+	{"mac_local_faults", offsetof(struct ixgbe_hw_stats, mlfc)},
+	{"mac_remote_faults", offsetof(struct ixgbe_hw_stats, mrfc)},
+	{"rx_length_errors", offsetof(struct ixgbe_hw_stats, rlec)},
+	{"tx_xon_packets", offsetof(struct ixgbe_hw_stats, lxontxc)},
+	{"rx_xon_packets", offsetof(struct ixgbe_hw_stats, lxonrxc)},
+	{"tx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxofftxc)},
+	{"rx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxoffrxc)},
+	{"rx_size_64", offsetof(struct ixgbe_hw_stats, prc64)},
+	{"rx_size_65_to_127", offsetof(struct ixgbe_hw_stats, prc127)},
+	{"rx_size_128_to_255", offsetof(struct ixgbe_hw_stats, prc255)},
+	{"rx_size_256_to_511", offsetof(struct ixgbe_hw_stats, prc511)},
+	{"rx_size_512_to_1023", offsetof(struct ixgbe_hw_stats, prc1023)},
+	{"rx_size_1024_to_max", offsetof(struct ixgbe_hw_stats, prc1522)},
+	{"rx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bprc)},
+	{"rx_multicast_packets", offsetof(struct ixgbe_hw_stats, mprc)},
+	{"rx_fragment_errors", offsetof(struct ixgbe_hw_stats, rfc)},
+	{"rx_undersize_errors", offsetof(struct ixgbe_hw_stats, ruc)},
+	{"rx_oversize_errors", offsetof(struct ixgbe_hw_stats, roc)},
+	{"rx_jabber_errors", offsetof(struct ixgbe_hw_stats, rjc)},
+	{"rx_managment_packets", offsetof(struct ixgbe_hw_stats, mngprc)},
+	{"rx_managment_dropped", offsetof(struct ixgbe_hw_stats, mngpdc)},
+	{"tx_managment_packets", offsetof(struct ixgbe_hw_stats, mngptc)},
+	{"rx_total_bytes", offsetof(struct ixgbe_hw_stats, tor)},
+	{"rx_total_packets", offsetof(struct ixgbe_hw_stats, tpr)},
+	{"tx_total_bytes", offsetof(struct ixgbe_hw_stats, tpt)},
+	{"tx_size_64", offsetof(struct ixgbe_hw_stats, ptc64)},
+	{"tx_size_65_to_127", offsetof(struct ixgbe_hw_stats, ptc127)},
+	{"tx_size_128_to_255", offsetof(struct ixgbe_hw_stats, ptc255)},
+	{"tx_size_256_to_511", offsetof(struct ixgbe_hw_stats, ptc511)},
+	{"tx_size_512_to_1023", offsetof(struct ixgbe_hw_stats, ptc1023)},
+	{"tx_size_1024_to_max", offsetof(struct ixgbe_hw_stats, ptc1522)},
+	{"tx_multicast_packets", offsetof(struct ixgbe_hw_stats, mptc)},
+	{"tx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bptc)},
+	{"rx_mac_short_packet_discard", offsetof(struct ixgbe_hw_stats, mspdc)},
+	{"rx_l3_l4_xsum_error", offsetof(struct ixgbe_hw_stats, xec)},
+
+	{"flow_director_filter_added", offsetof(struct ixgbe_hw_stats,
+		fdirustat_add)},
+	{"flow_director_filter_removed", offsetof(struct ixgbe_hw_stats,
+		fdirustat_remove)},
+	{"flow_director_filter_add_errors", offsetof(struct ixgbe_hw_stats,
+		fdirfstat_fadd)},
+	{"flow_director_filter_remove_errors", offsetof(struct ixgbe_hw_stats,
+		fdirfstat_fremove)},
+	{"flow_director_matched", offsetof(struct ixgbe_hw_stats, fdirmatch)},
+	{"flow_director_missed", offsetof(struct ixgbe_hw_stats, fdirmiss)},
+
+	{"rx_fcoe_crc_errors", offsetof(struct ixgbe_hw_stats, fccrc)},
+	{"rx_fcoe_dropped", offsetof(struct ixgbe_hw_stats, fcoerpdc)},
+	{"rx_fcoe_no_mbufs_avail_errors", offsetof(struct ixgbe_hw_stats,
+		fclast)},
+	{"rx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeprc)},
+	{"tx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeptc)},
+	{"rx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwrc)},
+	{"tx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwtc)},
+	{"rx_fcoe_no_direct_data_placement", offsetof(struct ixgbe_hw_stats,
+		fcoe_noddp)},
+	{"rx_fcoe_no_direct_data_placement_ext_buff",
+		offsetof(struct ixgbe_hw_stats, fcoe_noddp_ext_buff)},
+
 	{"tx_flow_control_xon", offsetof(struct ixgbe_hw_stats, lxontxc)},
 	{"rx_flow_control_xon", offsetof(struct ixgbe_hw_stats, lxonrxc)},
 	{"tx_flow_control_xoff", offsetof(struct ixgbe_hw_stats, lxofftxc)},
 	{"rx_flow_control_xoff", offsetof(struct ixgbe_hw_stats, lxoffrxc)},
+	{"rx_total_missed_packets", offsetof(struct ixgbe_hw_stats, mpctotal)},
+
+	{"rx_q0_missed_packets", offsetof(struct ixgbe_hw_stats, mpc[0])},
+	{"rx_q1_missed_packets", offsetof(struct ixgbe_hw_stats, mpc[1])},
+	{"rx_q2_missed_packets", offsetof(struct ixgbe_hw_stats, mpc[2])},
+	{"rx_q3_missed_packets", offsetof(struct ixgbe_hw_stats, mpc[3])},
+	{"rx_q4_missed_packets", offsetof(struct ixgbe_hw_stats, mpc[4])},
+	{"rx_q5_missed_packets", offsetof(struct ixgbe_hw_stats, mpc[5])},
+	{"rx_q6_missed_packets", offsetof(struct ixgbe_hw_stats, mpc[6])},
+	{"rx_q7_missed_packets", offsetof(struct ixgbe_hw_stats, mpc[7])},
+
+	{"rx_q0_no_mbufs_avail_errors", offsetof(struct ixgbe_hw_stats,
+		rnbc[0])},
+	{"rx_q1_no_mbufs_avail_errors", offsetof(struct ixgbe_hw_stats,
+		rnbc[1])},
+	{"rx_q2_no_mbufs_avail_errors", offsetof(struct ixgbe_hw_stats,
+		rnbc[2])},
+	{"rx_q3_no_mbufs_avail_errors", offsetof(struct ixgbe_hw_stats,
+		rnbc[3])},
+	{"rx_q4_no_mbufs_avail_errors", offsetof(struct ixgbe_hw_stats,
+		rnbc[4])},
+	{"rx_q5_no_mbufs_avail_errors", offsetof(struct ixgbe_hw_stats,
+		rnbc[5])},
+	{"rx_q6_no_mbufs_avail_errors", offsetof(struct ixgbe_hw_stats,
+		rnbc[6])},
+	{"rx_q7_no_mbufs_avail_errors", offsetof(struct ixgbe_hw_stats,
+		rnbc[7])},
+
+	{"tx_q0_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxontxc[0])},
+	{"tx_q1_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxontxc[1])},
+	{"tx_q2_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxontxc[2])},
+	{"tx_q3_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxontxc[3])},
+	{"tx_q4_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxontxc[4])},
+	{"tx_q5_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxontxc[5])},
+	{"tx_q6_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxontxc[6])},
+	{"tx_q7_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxontxc[7])},
+
+	{"rx_q0_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxonrxc[0])},
+	{"rx_q1_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxonrxc[1])},
+	{"rx_q2_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxonrxc[2])},
+	{"rx_q3_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxonrxc[3])},
+	{"rx_q4_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxonrxc[4])},
+	{"rx_q5_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxonrxc[5])},
+	{"rx_q6_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxonrxc[6])},
+	{"rx_q7_xon_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxonrxc[7])},
+
+	{"tx_q0_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxofftxc[0])},
+	{"tx_q1_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxofftxc[1])},
+	{"tx_q2_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxofftxc[2])},
+	{"tx_q3_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxofftxc[3])},
+	{"tx_q4_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxofftxc[4])},
+	{"tx_q5_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxofftxc[5])},
+	{"tx_q6_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxofftxc[6])},
+	{"tx_q7_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxofftxc[7])},
+
+	{"rx_q0_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxoffrxc[0])},
+	{"rx_q1_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxoffrxc[1])},
+	{"rx_q2_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxoffrxc[2])},
+	{"rx_q3_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxoffrxc[3])},
+	{"rx_q4_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxoffrxc[4])},
+	{"rx_q5_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxoffrxc[5])},
+	{"rx_q6_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxoffrxc[6])},
+	{"rx_q7_xoff_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxoffrxc[7])},
+
+	{"xx_q0_xon_to_off_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxon2offc[0])},
+	{"xx_q1_xon_to_off_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxon2offc[1])},
+	{"xx_q2_xon_to_off_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxon2offc[2])},
+	{"xx_q3_xon_to_off_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxon2offc[3])},
+	{"xx_q4_xon_to_off_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxon2offc[4])},
+	{"xx_q5_xon_to_off_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxon2offc[5])},
+	{"xx_q6_xon_to_off_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxon2offc[6])},
+	{"xx_q7_xon_to_off_priority_packets", offsetof(struct ixgbe_hw_stats,
+		pxon2offc[7])},
+
+	{"rx_q0_packets", offsetof(struct ixgbe_hw_stats, qprc[0])},
+	{"rx_q1_packets", offsetof(struct ixgbe_hw_stats, qprc[1])},
+	{"rx_q2_packets", offsetof(struct ixgbe_hw_stats, qprc[2])},
+	{"rx_q3_packets", offsetof(struct ixgbe_hw_stats, qprc[3])},
+	{"rx_q4_packets", offsetof(struct ixgbe_hw_stats, qprc[4])},
+	{"rx_q5_packets", offsetof(struct ixgbe_hw_stats, qprc[5])},
+	{"rx_q6_packets", offsetof(struct ixgbe_hw_stats, qprc[6])},
+	{"rx_q7_packets", offsetof(struct ixgbe_hw_stats, qprc[7])},
+	{"rx_q8_packets", offsetof(struct ixgbe_hw_stats, qprc[8])},
+	{"rx_q9_packets", offsetof(struct ixgbe_hw_stats, qprc[9])},
+	{"rx_q10_packets", offsetof(struct ixgbe_hw_stats, qprc[10])},
+	{"rx_q11_packets", offsetof(struct ixgbe_hw_stats, qprc[11])},
+	{"rx_q12_packets", offsetof(struct ixgbe_hw_stats, qprc[12])},
+	{"rx_q13_packets", offsetof(struct ixgbe_hw_stats, qprc[13])},
+	{"rx_q14_packets", offsetof(struct ixgbe_hw_stats, qprc[14])},
+	{"rx_q15_packets", offsetof(struct ixgbe_hw_stats, qprc[15])},
+
+	{"tx_q0_packets", offsetof(struct ixgbe_hw_stats, qptc[0])},
+	{"tx_q1_packets", offsetof(struct ixgbe_hw_stats, qptc[1])},
+	{"tx_q2_packets", offsetof(struct ixgbe_hw_stats, qptc[2])},
+	{"tx_q3_packets", offsetof(struct ixgbe_hw_stats, qptc[3])},
+	{"tx_q4_packets", offsetof(struct ixgbe_hw_stats, qptc[4])},
+	{"tx_q5_packets", offsetof(struct ixgbe_hw_stats, qptc[5])},
+	{"tx_q6_packets", offsetof(struct ixgbe_hw_stats, qptc[6])},
+	{"tx_q7_packets", offsetof(struct ixgbe_hw_stats, qptc[7])},
+	{"tx_q8_packets", offsetof(struct ixgbe_hw_stats, qptc[8])},
+	{"tx_q9_packets", offsetof(struct ixgbe_hw_stats, qptc[9])},
+	{"tx_q10_packets", offsetof(struct ixgbe_hw_stats, qptc[10])},
+	{"tx_q11_packets", offsetof(struct ixgbe_hw_stats, qptc[11])},
+	{"tx_q12_packets", offsetof(struct ixgbe_hw_stats, qptc[12])},
+	{"tx_q13_packets", offsetof(struct ixgbe_hw_stats, qptc[13])},
+	{"tx_q14_packets", offsetof(struct ixgbe_hw_stats, qptc[14])},
+	{"tx_q15_packets", offsetof(struct ixgbe_hw_stats, qptc[15])},
+
+	{"rx_q0_bytes", offsetof(struct ixgbe_hw_stats, qbrc[0])},
+	{"rx_q1_bytes", offsetof(struct ixgbe_hw_stats, qbrc[1])},
+	{"rx_q2_bytes", offsetof(struct ixgbe_hw_stats, qbrc[2])},
+	{"rx_q3_bytes", offsetof(struct ixgbe_hw_stats, qbrc[3])},
+	{"rx_q4_bytes", offsetof(struct ixgbe_hw_stats, qbrc[4])},
+	{"rx_q5_bytes", offsetof(struct ixgbe_hw_stats, qbrc[5])},
+	{"rx_q6_bytes", offsetof(struct ixgbe_hw_stats, qbrc[6])},
+	{"rx_q7_bytes", offsetof(struct ixgbe_hw_stats, qbrc[7])},
+	{"rx_q8_bytes", offsetof(struct ixgbe_hw_stats, qbrc[8])},
+	{"rx_q9_bytes", offsetof(struct ixgbe_hw_stats, qbrc[9])},
+	{"rx_q10_bytes", offsetof(struct ixgbe_hw_stats, qbrc[10])},
+	{"rx_q11_bytes", offsetof(struct ixgbe_hw_stats, qbrc[11])},
+	{"rx_q12_bytes", offsetof(struct ixgbe_hw_stats, qbrc[12])},
+	{"rx_q13_bytes", offsetof(struct ixgbe_hw_stats, qbrc[13])},
+	{"rx_q14_bytes", offsetof(struct ixgbe_hw_stats, qbrc[14])},
+	{"rx_q15_bytes", offsetof(struct ixgbe_hw_stats, qbrc[15])},
+
+	{"tx_q0_bytes", offsetof(struct ixgbe_hw_stats, qbtc[0])},
+	{"tx_q1_bytes", offsetof(struct ixgbe_hw_stats, qbtc[1])},
+	{"tx_q2_bytes", offsetof(struct ixgbe_hw_stats, qbtc[2])},
+	{"tx_q3_bytes", offsetof(struct ixgbe_hw_stats, qbtc[3])},
+	{"tx_q4_bytes", offsetof(struct ixgbe_hw_stats, qbtc[4])},
+	{"tx_q5_bytes", offsetof(struct ixgbe_hw_stats, qbtc[5])},
+	{"tx_q6_bytes", offsetof(struct ixgbe_hw_stats, qbtc[6])},
+	{"tx_q7_bytes", offsetof(struct ixgbe_hw_stats, qbtc[7])},
+	{"tx_q8_bytes", offsetof(struct ixgbe_hw_stats, qbtc[8])},
+	{"tx_q9_bytes", offsetof(struct ixgbe_hw_stats, qbtc[9])},
+	{"tx_q10_bytes", offsetof(struct ixgbe_hw_stats, qbtc[10])},
+	{"tx_q11_bytes", offsetof(struct ixgbe_hw_stats, qbtc[11])},
+	{"tx_q12_bytes", offsetof(struct ixgbe_hw_stats, qbtc[12])},
+	{"tx_q13_bytes", offsetof(struct ixgbe_hw_stats, qbtc[13])},
+	{"tx_q14_bytes", offsetof(struct ixgbe_hw_stats, qbtc[14])},
+	{"tx_q15_bytes", offsetof(struct ixgbe_hw_stats, qbtc[15])},
+
+	{"rx_q0_dropped", offsetof(struct ixgbe_hw_stats, qprdc[0])},
+	{"rx_q1_dropped", offsetof(struct ixgbe_hw_stats, qprdc[1])},
+	{"rx_q2_dropped", offsetof(struct ixgbe_hw_stats, qprdc[2])},
+	{"rx_q3_dropped", offsetof(struct ixgbe_hw_stats, qprdc[3])},
+	{"rx_q4_dropped", offsetof(struct ixgbe_hw_stats, qprdc[4])},
+	{"rx_q5_dropped", offsetof(struct ixgbe_hw_stats, qprdc[5])},
+	{"rx_q6_dropped", offsetof(struct ixgbe_hw_stats, qprdc[6])},
+	{"rx_q7_dropped", offsetof(struct ixgbe_hw_stats, qprdc[7])},
+	{"rx_q8_dropped", offsetof(struct ixgbe_hw_stats, qprdc[8])},
+	{"rx_q9_dropped", offsetof(struct ixgbe_hw_stats, qprdc[9])},
+	{"rx_q10_dropped", offsetof(struct ixgbe_hw_stats, qprdc[10])},
+	{"rx_q11_dropped", offsetof(struct ixgbe_hw_stats, qprdc[11])},
+	{"rx_q12_dropped", offsetof(struct ixgbe_hw_stats, qprdc[12])},
+	{"rx_q13_dropped", offsetof(struct ixgbe_hw_stats, qprdc[13])},
+	{"rx_q14_dropped", offsetof(struct ixgbe_hw_stats, qprdc[14])},
+	{"rx_q15_dropped", offsetof(struct ixgbe_hw_stats, qprdc[15])},
 };
 
 #define IXGBE_NB_XSTATS (sizeof(rte_ixgbe_stats_strings) /	\
-- 
1.9.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 08/11] ixgbevf: add xstats() functions to VF
  2015-09-29 14:32 [dpdk-dev] [PATCH 00/11] Port XStats Harry van Haaren
                   ` (6 preceding siblings ...)
  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
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 09/11] i40e: add xstats() implementation Harry van Haaren
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Harry van Haaren @ 2015-09-29 14:32 UTC (permalink / raw)
  To: dev

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 09/11] i40e: add xstats() implementation
  2015-09-29 14:32 [dpdk-dev] [PATCH 00/11] Port XStats Harry van Haaren
                   ` (7 preceding siblings ...)
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 08/11] ixgbevf: add xstats() functions to VF Harry van Haaren
@ 2015-09-29 14:32 ` 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
  10 siblings, 0 replies; 12+ messages in thread
From: Harry van Haaren @ 2015-09-29 14:32 UTC (permalink / raw)
  To: dev

Add xstats functions to i40e PMD, allowing extended statistics
to be retrieved from the NIC and exposed to the DPDK.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 263 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 256 insertions(+), 7 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 2dd9fdc..d8474bb 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -127,7 +127,10 @@ static int i40e_dev_set_link_up(struct rte_eth_dev *dev);
 static int i40e_dev_set_link_down(struct rte_eth_dev *dev);
 static void i40e_dev_stats_get(struct rte_eth_dev *dev,
 			       struct rte_eth_stats *stats);
+static int i40e_dev_xstats_get(struct rte_eth_dev *dev,
+			       struct rte_eth_xstats *xstats, unsigned n);
 static void i40e_dev_stats_reset(struct rte_eth_dev *dev);
+static void i40e_dev_xstats_reset(struct rte_eth_dev *dev);
 static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
 					    uint16_t queue_id,
 					    uint8_t stat_idx,
@@ -232,6 +235,8 @@ static int i40e_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
 					   uint32_t flags);
 static int i40e_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 					   struct timespec *timestamp);
+static void i40e_read_stats_registers(struct i40e_pf *pf, struct i40e_hw *hw);
+
 
 static const struct rte_pci_id pci_id_i40e_map[] = {
 #define RTE_PCI_DEV_ID_DECL_I40E(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
@@ -252,7 +257,9 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.dev_set_link_down            = i40e_dev_set_link_down,
 	.link_update                  = i40e_dev_link_update,
 	.stats_get                    = i40e_dev_stats_get,
+	.xstats_get                   = i40e_dev_xstats_get,
 	.stats_reset                  = i40e_dev_stats_reset,
+	.xstats_reset                 = i40e_dev_xstats_reset,
 	.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
 	.dev_infos_get                = i40e_dev_info_get,
 	.vlan_filter_set              = i40e_vlan_filter_set,
@@ -291,6 +298,187 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.timesync_read_tx_timestamp   = i40e_timesync_read_tx_timestamp,
 };
 
+/* store statistics names and its offset in stats structure */
+struct rte_i40e_xstats_name_off {
+	char name[RTE_ETH_XSTATS_NAME_SIZE];
+	unsigned offset;
+};
+
+static const struct rte_i40e_xstats_name_off rte_i40e_stats_strings[] = {
+	{"rx_bytes", offsetof(struct i40e_eth_stats, rx_bytes)},
+	{"rx_unicast_packets", offsetof(struct i40e_eth_stats, rx_unicast)},
+	{"rx_multicast_packets", offsetof(struct i40e_eth_stats, rx_multicast)},
+	{"rx_broadcast_packets", offsetof(struct i40e_eth_stats, rx_broadcast)},
+	{"rx_dropped", offsetof(struct i40e_eth_stats, rx_discards)},
+	{"rx_unknown_protocol", offsetof(struct i40e_eth_stats,
+		rx_unknown_protocol)},
+	{"tx_bytes", offsetof(struct i40e_eth_stats, tx_bytes)},
+	{"tx_unicast", offsetof(struct i40e_eth_stats, tx_unicast)},
+	{"tx_multicast", offsetof(struct i40e_eth_stats, tx_multicast)},
+	{"tx_broadcast", offsetof(struct i40e_eth_stats, tx_broadcast)},
+	{"tx_dropped", offsetof(struct i40e_eth_stats, tx_discards)},
+	{"tx_errors", offsetof(struct i40e_eth_stats, tx_errors)},
+};
+
+static const struct rte_i40e_xstats_name_off rte_i40e_hw_port_strings[] = {
+	{"tx_link_down_dropped", offsetof(struct i40e_hw_port_stats,
+		tx_dropped_link_down)},
+	{"rx_crc_errors", offsetof(struct i40e_hw_port_stats, crc_errors)},
+	{"rx_illegal_bytes", offsetof(struct i40e_hw_port_stats,
+		illegal_bytes)},
+	{"rx_error_bytes", offsetof(struct i40e_hw_port_stats, error_bytes)},
+	{"mac_local_faults", offsetof(struct i40e_hw_port_stats,
+		mac_local_faults)},
+	{"mac_remote_faults", offsetof(struct i40e_hw_port_stats,
+		mac_remote_faults)},
+	{"rx_length_errors", offsetof(struct i40e_hw_port_stats,
+		rx_length_errors)},
+	{"tx_xon_packets", offsetof(struct i40e_hw_port_stats, link_xon_tx)},
+	{"rx_xon_packets", offsetof(struct i40e_hw_port_stats, link_xon_rx)},
+	{"tx_xoff_packets", offsetof(struct i40e_hw_port_stats, link_xoff_tx)},
+	{"rx_xoff_packets", offsetof(struct i40e_hw_port_stats, link_xoff_rx)},
+	{"rx_size_64", offsetof(struct i40e_hw_port_stats, rx_size_64)},
+	{"rx_size_65_to_127", offsetof(struct i40e_hw_port_stats, rx_size_127)},
+	{"rx_size_128_to_255", offsetof(struct i40e_hw_port_stats,
+		rx_size_255)},
+	{"rx_size_256_to_511", offsetof(struct i40e_hw_port_stats,
+		rx_size_511)},
+	{"rx_size_512_to_1023", offsetof(struct i40e_hw_port_stats,
+		rx_size_1023)},
+	{"rx_size_1024_to_1522", offsetof(struct i40e_hw_port_stats,
+		rx_size_1522)},
+	{"rx_size_1523_to_max", offsetof(struct i40e_hw_port_stats,
+		rx_size_big)},
+	{"rx_undersized_packets", offsetof(struct i40e_hw_port_stats,
+		rx_undersize)},
+	{"rx_oversize_packets", offsetof(struct i40e_hw_port_stats,
+		rx_oversize)},
+	{"rx_mac_short_dropped", offsetof(struct i40e_hw_port_stats,
+		mac_short_packet_dropped)},
+	{"rx_fragmented_packets", offsetof(struct i40e_hw_port_stats,
+		rx_fragments)},
+	{"rx_jabber_packets", offsetof(struct i40e_hw_port_stats, rx_jabber)},
+	{"tx_size_64", offsetof(struct i40e_hw_port_stats, tx_size_64)},
+	{"tx_size_65_to_127", offsetof(struct i40e_hw_port_stats,
+		tx_size_127)},
+	{"tx_size_128_to_255", offsetof(struct i40e_hw_port_stats,
+		tx_size_255)},
+	{"tx_size_256_to_511", offsetof(struct i40e_hw_port_stats,
+		tx_size_511)},
+	{"tx_size_512_to_1023", offsetof(struct i40e_hw_port_stats,
+		tx_size_1023)},
+	{"tx_size_1024_to_1522", offsetof(struct i40e_hw_port_stats,
+		tx_size_1522)},
+	{"tx_size_1523_to_max", offsetof(struct i40e_hw_port_stats,
+		tx_size_big)},
+	{"rx_fd_atr_match", offsetof(struct i40e_hw_port_stats, fd_atr_match)},
+	{"rx_fd_sb_match", offsetof(struct i40e_hw_port_stats, fd_sb_match)},
+	{"tx_low_power_idle_status", offsetof(struct i40e_hw_port_stats,
+		tx_lpi_status)},
+	{"rx_low_power_idle_status", offsetof(struct i40e_hw_port_stats,
+		rx_lpi_status)},
+	{"tx_low_power_idle_count", offsetof(struct i40e_hw_port_stats,
+		tx_lpi_count)},
+	{"rx_low_power_idle_count", offsetof(struct i40e_hw_port_stats,
+		rx_lpi_count)},
+
+	/* priority_xon_rx[8] */
+	{"tx_q0_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_tx[0])},
+	{"tx_q1_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_tx[1])},
+	{"tx_q2_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_tx[2])},
+	{"tx_q3_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_tx[3])},
+	{"tx_q4_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_tx[4])},
+	{"tx_q5_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_tx[5])},
+	{"tx_q6_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_tx[6])},
+	{"tx_q7_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_tx[7])},
+
+	/* priority_xon_rx[8] */
+	{"rx_q0_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_rx[0])},
+	{"rx_q1_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_rx[1])},
+	{"rx_q2_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_rx[2])},
+	{"rx_q3_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_rx[3])},
+	{"rx_q4_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_rx[4])},
+	{"rx_q5_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_rx[5])},
+	{"rx_q6_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_rx[6])},
+	{"rx_q7_xon_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xon_rx[7])},
+
+	/* priority_xoff_tx[8] */
+	{"tx_q0_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_tx[0])},
+	{"tx_q1_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_tx[1])},
+	{"tx_q2_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_tx[2])},
+	{"tx_q3_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_tx[3])},
+	{"tx_q4_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_tx[4])},
+	{"tx_q5_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_tx[5])},
+	{"tx_q6_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_tx[6])},
+	{"tx_q7_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_tx[7])},
+
+	/* priority_xoff_rx[8] */
+	{"rx_q0_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_rx[0])},
+	{"rx_q1_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_rx[1])},
+	{"rx_q2_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_rx[2])},
+	{"rx_q3_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_rx[3])},
+	{"rx_q4_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_rx[4])},
+	{"rx_q5_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_rx[5])},
+	{"rx_q6_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_rx[6])},
+	{"rx_q7_xoff_priority_packets", offsetof(struct i40e_hw_port_stats,
+		priority_xoff_rx[7])},
+
+	/* priority_xon_2_xoff[8] */
+	{"xx_q0_xon_to_xoff_priority_packets",
+		offsetof(struct i40e_hw_port_stats, priority_xon_2_xoff[0])},
+	{"xx_q1_xon_to_xoff_priority_packets",
+		offsetof(struct i40e_hw_port_stats, priority_xon_2_xoff[1])},
+	{"xx_q2_xon_to_xoff_priority_packets",
+		offsetof(struct i40e_hw_port_stats, priority_xon_2_xoff[2])},
+	{"xx_q3_xon_to_xoff_priority_packets",
+		offsetof(struct i40e_hw_port_stats, priority_xon_2_xoff[3])},
+	{"xx_q4_xon_to_xoff_priority_packets",
+		offsetof(struct i40e_hw_port_stats, priority_xon_2_xoff[4])},
+	{"xx_q5_xon_to_xoff_priority_packets",
+		offsetof(struct i40e_hw_port_stats, priority_xon_2_xoff[5])},
+	{"xx_q6_xon_to_xoff_priority_packets",
+		offsetof(struct i40e_hw_port_stats, priority_xon_2_xoff[6])},
+	{"xx_q7_xon_to_xoff_priority_packets",
+		offsetof(struct i40e_hw_port_stats, priority_xon_2_xoff[7])},
+};
+
+#define I40E_NB_ETH_XSTATS (sizeof(rte_i40e_stats_strings) / \
+		sizeof(rte_i40e_stats_strings[0]))
+#define I40E_NB_HW_PORT_XSTATS (sizeof(rte_i40e_hw_port_strings) / \
+		sizeof(rte_i40e_hw_port_strings[0]))
+#define I40E_NB_XSTATS (I40E_NB_ETH_XSTATS + I40E_NB_HW_PORT_XSTATS)
+
 static struct eth_driver rte_i40e_pmd = {
 	.pci_drv = {
 		.name = "rte_i40e_pmd",
@@ -1322,16 +1510,12 @@ i40e_update_vsi_stats(struct i40e_vsi *vsi)
 		    vsi->vsi_id);
 }
 
-/* Get all statistics of a port */
 static void
-i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+i40e_read_stats_registers(struct i40e_pf *pf, struct i40e_hw *hw)
 {
-	uint32_t i;
-	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
-	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	unsigned int i;
 	struct i40e_hw_port_stats *ns = &pf->stats; /* new stats */
 	struct i40e_hw_port_stats *os = &pf->stats_offset; /* old stats */
-
 	/* Get statistics of struct i40e_eth_stats */
 	i40e_stat_update_48(hw, I40E_GLPRT_GORCH(hw->port),
 			    I40E_GLPRT_GORCL(hw->port),
@@ -1508,8 +1692,21 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 
 	pf->offset_loaded = true;
 
-	if (pf->main_vsi)
+	if(pf->main_vsi)
 		i40e_update_vsi_stats(pf->main_vsi);
+}
+
+/* Get all statistics of a port */
+static void
+i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct i40e_hw_port_stats *ns = &pf->stats; /* new stats */
+	unsigned i;
+
+	/* call read registers - updates values, now write them to struct */
+	i40e_read_stats_registers(pf, hw);
 
 	stats->ipackets = ns->eth.rx_unicast + ns->eth.rx_multicast +
 						ns->eth.rx_broadcast;
@@ -1599,6 +1796,58 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	PMD_DRV_LOG(DEBUG, "***************** PF stats end ********************");
 }
 
+static void
+i40e_dev_xstats_reset(struct rte_eth_dev *dev)
+{
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct i40e_hw_port_stats *hw_stats = &pf->stats;
+
+	/* HW registers cleared on read */
+	i40e_dev_xstats_get(dev, NULL, I40E_NB_XSTATS);
+
+	/* reset software counters */
+	memset(hw_stats, 0, sizeof(*hw_stats));
+}
+
+static int
+i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
+		    unsigned n)
+{
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	unsigned i, count = 0;
+	struct i40e_hw_port_stats *hw_stats = &pf->stats;
+
+	if(n < I40E_NB_XSTATS)
+		return I40E_NB_XSTATS;
+
+	/* Reset */
+	if(xstats == NULL)
+		return 0;
+
+	i40e_read_stats_registers(pf, hw);
+
+	/* copy from i40e_eth_stats struct */
+	for(i = 0; i < I40E_NB_ETH_XSTATS; i++) {
+		snprintf(xstats[count].name, sizeof(xstats[count].name),
+			 "%s", rte_i40e_stats_strings[i].name);
+		xstats[count].value = *(uint64_t *)(((char *)&hw_stats->eth) +
+			rte_i40e_stats_strings[i].offset);
+		count++;
+	}
+
+	/* copy from i40e_hw_port struct */
+	for(i = 0; i < I40E_NB_HW_PORT_XSTATS; i++) {
+		snprintf(xstats[count].name, sizeof(xstats[count].name),
+			 "%s", rte_i40e_hw_port_strings[i].name);
+		xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
+				rte_i40e_hw_port_strings[i].offset);
+		count++;
+	}
+
+	return I40E_NB_XSTATS;
+}
+
 /* Reset the statistics */
 static void
 i40e_dev_stats_reset(struct rte_eth_dev *dev)
-- 
1.9.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 10/11] i40evf: add xstats() implementation
  2015-09-29 14:32 [dpdk-dev] [PATCH 00/11] Port XStats Harry van Haaren
                   ` (8 preceding siblings ...)
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 09/11] i40e: add xstats() implementation Harry van Haaren
@ 2015-09-29 14:32 ` Harry van Haaren
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 11/11] fm10k: " Harry van Haaren
  10 siblings, 0 replies; 12+ messages in thread
From: Harry van Haaren @ 2015-09-29 14:32 UTC (permalink / raw)
  To: dev

Add implementation of xstats() functions in i40evf PMD.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c | 77 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 74 insertions(+), 3 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index b694400..4ddd247 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -112,6 +112,8 @@ static int i40evf_dev_link_update(struct rte_eth_dev *dev,
 				  __rte_unused int wait_to_complete);
 static void i40evf_dev_stats_get(struct rte_eth_dev *dev,
 				struct rte_eth_stats *stats);
+static int i40evf_dev_xstats_get(struct rte_eth_dev *dev,
+				 struct rte_eth_xstats *xstats, unsigned n);
 static int i40evf_vlan_filter_set(struct rte_eth_dev *dev,
 				  uint16_t vlan_id, int on);
 static void i40evf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
@@ -148,6 +150,30 @@ static int i40evf_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_VFQF_HKEY_MAX_INDEX + 1];
 
+struct rte_i40evf_xstats_name_off {
+	char name[RTE_ETH_XSTATS_NAME_SIZE];
+	unsigned offset;
+};
+
+static const struct rte_i40evf_xstats_name_off rte_i40evf_stats_strings[] = {
+	{"rx_bytes", offsetof(struct i40e_eth_stats, rx_bytes)},
+	{"rx_unicast_packets", offsetof(struct i40e_eth_stats, rx_unicast)},
+	{"rx_multicast_packets", offsetof(struct i40e_eth_stats, rx_multicast)},
+	{"rx_broadcast_packets", offsetof(struct i40e_eth_stats, rx_broadcast)},
+	{"rx_dropped_packets", offsetof(struct i40e_eth_stats, rx_discards)},
+	{"rx_unknown_protocol_packets", offsetof(struct i40e_eth_stats,
+		rx_unknown_protocol)},
+	{"tx_bytes", offsetof(struct i40e_eth_stats, tx_bytes)},
+	{"tx_unicast_packets", offsetof(struct i40e_eth_stats, tx_bytes)},
+	{"tx_multicast_packets", offsetof(struct i40e_eth_stats, tx_bytes)},
+	{"tx_broadcast_packets", offsetof(struct i40e_eth_stats, tx_bytes)},
+	{"tx_dropped_packets", offsetof(struct i40e_eth_stats, tx_bytes)},
+	{"tx_error_packets", offsetof(struct i40e_eth_stats, tx_bytes)},
+};
+
+#define I40EVF_NB_XSTATS (sizeof(rte_i40evf_stats_strings) / \
+		sizeof(rte_i40evf_stats_strings[0]))
+
 static const struct eth_dev_ops i40evf_eth_dev_ops = {
 	.dev_configure        = i40evf_dev_configure,
 	.dev_start            = i40evf_dev_start,
@@ -158,6 +184,7 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = {
 	.allmulticast_disable = i40evf_dev_allmulticast_disable,
 	.link_update          = i40evf_dev_link_update,
 	.stats_get            = i40evf_dev_stats_get,
+	.xstats_get           = i40evf_dev_xstats_get,
 	.dev_close            = i40evf_dev_close,
 	.dev_infos_get        = i40evf_dev_info_get,
 	.vlan_filter_set      = i40evf_vlan_filter_set,
@@ -888,13 +915,13 @@ i40evf_del_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
 }
 
 static int
-i40evf_get_statics(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+i40evf_update_stats(struct rte_eth_dev *dev, struct i40e_eth_stats **pstats)
 {
 	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
 	struct i40e_virtchnl_queue_select q_stats;
-	struct i40e_eth_stats *pstats;
 	int err;
 	struct vf_cmd_info args;
+	RTE_SET_USED(pstats);
 
 	memset(&q_stats, 0, sizeof(q_stats));
 	q_stats.vsi_id = vf->vsi_res->vsi_id;
@@ -907,9 +934,23 @@ i40evf_get_statics(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	err = i40evf_execute_vf_cmd(dev, &args);
 	if (err) {
 		PMD_DRV_LOG(ERR, "fail to execute command OP_GET_STATS");
+		*pstats = NULL;
 		return err;
 	}
-	pstats = (struct i40e_eth_stats *)args.out_buffer;
+	*pstats = (struct i40e_eth_stats *)args.out_buffer;
+	return 0;
+}
+
+static int
+i40evf_get_statics(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+	int ret;
+	struct i40e_eth_stats *pstats = NULL;
+
+	ret = i40evf_update_stats(dev, &pstats);
+	if(ret != 0)
+		return 0;
+
 	stats->ipackets = pstats->rx_unicast + pstats->rx_multicast +
 						pstats->rx_broadcast;
 	stats->opackets = pstats->tx_broadcast + pstats->tx_multicast +
@@ -922,6 +963,36 @@ i40evf_get_statics(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	return 0;
 }
 
+static int i40evf_dev_xstats_get(struct rte_eth_dev *dev,
+				 struct rte_eth_xstats *xstats, unsigned n)
+{
+	RTE_SET_USED(xstats);
+	RTE_SET_USED(n);
+	int ret;
+	unsigned i;
+	struct i40e_eth_stats *pstats = NULL;
+
+	if(n < I40EVF_NB_XSTATS)
+		return I40EVF_NB_XSTATS;
+
+	ret = i40evf_update_stats(dev, &pstats);
+	if(ret != 0)
+		return 0;
+
+	if(!xstats)
+		return 0;
+
+	/* loop over xstats array and values from pstats */
+	for(i = 0; i < I40EVF_NB_XSTATS; i++) {
+		snprintf(xstats[i].name, sizeof(xstats[i].name),
+			 "%s", rte_i40evf_stats_strings[i].name);
+		xstats[i].value = *(uint64_t *)(((char *)pstats) +
+			rte_i40evf_stats_strings[i].offset);
+	}
+
+	return 0;
+}
+
 static int
 i40evf_add_vlan(struct rte_eth_dev *dev, uint16_t vlanid)
 {
-- 
1.9.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 11/11] fm10k: add xstats() implementation
  2015-09-29 14:32 [dpdk-dev] [PATCH 00/11] Port XStats Harry van Haaren
                   ` (9 preceding siblings ...)
  2015-09-29 14:32 ` [dpdk-dev] [PATCH 10/11] i40evf: " Harry van Haaren
@ 2015-09-29 14:32 ` Harry van Haaren
  10 siblings, 0 replies; 12+ messages in thread
From: Harry van Haaren @ 2015-09-29 14:32 UTC (permalink / raw)
  To: dev

Add xstats() functions and statistic strings.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 drivers/net/fm10k/fm10k_ethdev.c | 82 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index a69c990..5ef3553 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -68,6 +68,37 @@ fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev);
 static void fm10k_tx_queue_release(void *queue);
 static void fm10k_rx_queue_release(void *queue);
 
+struct rte_fm10k_xstats_name_off {
+	char name[RTE_ETH_XSTATS_NAME_SIZE];
+	unsigned offset;
+};
+
+struct rte_fm10k_xstats_name_off rte_fm10k_hw_stats_strings[] = {
+	{"completion_timeout_count", offsetof(struct fm10k_hw_stats, timeout)},
+	{"unsupported_requests_count", offsetof(struct fm10k_hw_stats, ur)},
+	{"completer_abort_count", offsetof(struct fm10k_hw_stats, ca)},
+	{"unsupported_message_count", offsetof(struct fm10k_hw_stats, um)},
+	{"checksum_error_count", offsetof(struct fm10k_hw_stats, xec)},
+	{"vlan_drops", offsetof(struct fm10k_hw_stats, vlan_drop)},
+	{"loopback_drops", offsetof(struct fm10k_hw_stats, loopback_drop)},
+	{"no_descriptor_drops", offsetof(struct fm10k_hw_stats, nodesc_drop)},
+};
+
+struct rte_fm10k_xstats_name_off rte_fm10k_hw_stats_q_strings[] = {
+	{"tx_q_bytes", offsetof(struct fm10k_hw_stats_q, tx_bytes)},
+	{"tx_q_packets", offsetof(struct fm10k_hw_stats_q, tx_packets)},
+	{"rx_q_bytes", offsetof(struct fm10k_hw_stats_q, rx_bytes)},
+	{"rx_q_packets", offsetof(struct fm10k_hw_stats_q, rx_packets)},
+	{"rx_q_dropped", offsetof(struct fm10k_hw_stats_q, rx_drops)},
+};
+
+#define FM10K_NB_HW_XSTATS (sizeof(rte_fm10k_hw_stats_strings) / \
+		sizeof(rte_fm10k_hw_stats_strings[0]))
+#define FM10K_NB_Q_XSTATS (sizeof(rte_fm10k_hw_stats_q_strings) / \
+		sizeof(rte_fm10k_hw_stats_q_strings[0]))
+#define FM10K_NB_XSTATS (FM10K_NB_HW_XSTATS + FM10K_NB_Q_XSTATS * \
+		FM10K_MAX_QUEUES_PF)
+
 static void
 fm10k_mbx_initlock(struct fm10k_hw *hw)
 {
@@ -867,6 +898,55 @@ fm10k_link_update(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+fm10k_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
+		 unsigned n)
+{
+	struct fm10k_hw_stats *hw_stats =
+		FM10K_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
+	unsigned i, q, count = 0;
+
+	if(n < FM10K_NB_XSTATS)
+		return FM10K_NB_XSTATS;
+
+	/* Global stats */
+	for(i = 0; i < FM10K_NB_HW_XSTATS; i++) {
+		snprintf(xstats[count].name, sizeof(xstats[count].name),
+			 "%s", rte_fm10k_hw_stats_strings[count].name);
+		xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
+			rte_fm10k_hw_stats_strings[count].offset);
+		count++;
+	}
+
+	/* PF queue stats */
+	for(q = 0; q < FM10K_MAX_QUEUES_PF; q++) {
+		for(i = 0; i < FM10K_NB_Q_XSTATS; i++) {
+			memcpy(xstats[count].name, rte_fm10k_hw_stats_q_strings,
+			       sizeof(char) * 4);
+			snprintf(&xstats[count].name[4],
+				 sizeof(xstats[count].name) - 4,
+				 "%d%s", q,
+				 &rte_fm10k_hw_stats_q_strings[i].name[4]);
+			xstats[count].value =
+				*(uint64_t *)(((char *)&hw_stats->q[q]) +
+				rte_fm10k_hw_stats_q_strings[i].offset);
+			count++;
+		}
+	}
+
+	/* Stats per queue */
+	for(q = 0; q < FM10K_MAX_QUEUES; q++) {
+		memcpy(xstats[count].name, rte_fm10k_hw_stats_q_strings[i].name,
+		       sizeof(char) * 4);
+		snprintf(&xstats[count].name[4], 36, "%d%s", q,
+			 &rte_fm10k_hw_stats_q_strings[i].name[4]);
+		count++;
+		/* TODO: more stats - do we want to present them this way? */
+	}
+
+	return FM10K_NB_XSTATS;
+}
+
 static void
 fm10k_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
@@ -2034,7 +2114,9 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
 	.allmulticast_enable    = fm10k_dev_allmulticast_enable,
 	.allmulticast_disable   = fm10k_dev_allmulticast_disable,
 	.stats_get		= fm10k_stats_get,
+	.xstats_get		= fm10k_xstats_get,
 	.stats_reset		= fm10k_stats_reset,
+	.xstats_reset		= fm10k_stats_reset,
 	.link_update		= fm10k_link_update,
 	.dev_infos_get		= fm10k_dev_infos_get,
 	.vlan_filter_set	= fm10k_vlan_filter_set,
-- 
1.9.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-09-29 14:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [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

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).