[v4,7/8] net/mvneta: add support for basic stats
diff mbox series

Message ID 1537369294-17099-8-git-send-email-amo@semihalf.com
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • Add Marvell NETA PMD
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Andrzej Ostruszka Sept. 19, 2018, 3:01 p.m. UTC
From: Zyta Szpak <zr@semihalf.com>

Add support for getting of basic statistics for the driver.

Signed-off-by: Yelena Krivosheev <yelena@marvell.com>
Signed-off-by: Natalie Samsonov <nsamsono@marvell.com>
Signed-off-by: Zyta Szpak <zr@semihalf.com>
---
 doc/guides/nics/features/mvneta.ini |  1 +
 doc/guides/nics/mvneta.rst          |  1 +
 drivers/net/mvneta/mvneta_ethdev.c  | 47 +++++++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+)

Patch
diff mbox series

diff --git a/doc/guides/nics/features/mvneta.ini b/doc/guides/nics/features/mvneta.ini
index 59c9c36..701eb03 100644
--- a/doc/guides/nics/features/mvneta.ini
+++ b/doc/guides/nics/features/mvneta.ini
@@ -14,5 +14,6 @@  CRC offload          = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Packet type parsing  = Y
+Basic stats          = Y
 ARMv8                = Y
 Usage doc            = Y
diff --git a/doc/guides/nics/mvneta.rst b/doc/guides/nics/mvneta.rst
index b21581b..5bcf3b6 100644
--- a/doc/guides/nics/mvneta.rst
+++ b/doc/guides/nics/mvneta.rst
@@ -38,6 +38,7 @@  Features of the MVNETA PMD are:
 - L3 checksum offload
 - L4 checksum offload
 - Packet type parsing
+- Basic stats
 
 
 Limitations
diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index fdd6eb0..3ea1dba 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -691,6 +691,52 @@  mvneta_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
 	return 0;
 }
 
+/**
+ * DPDK callback to get device statistics.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param stats
+ *   Stats structure output buffer.
+ *
+ * @return
+ *   0 on success, negative error value otherwise.
+ */
+static int
+mvneta_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+	struct mvneta_priv *priv = dev->data->dev_private;
+	struct neta_ppio_statistics ppio_stats;
+	unsigned int ret;
+
+	if (!priv->ppio)
+		return -EPERM;
+
+	ret = neta_ppio_get_statistics(priv->ppio, &ppio_stats);
+	if (unlikely(ret)) {
+		MVNETA_LOG(ERR, "Failed to update port statistics");
+		return ret;
+	}
+
+	stats->ipackets += ppio_stats.rx_packets +
+			ppio_stats.rx_broadcast_packets +
+			ppio_stats.rx_multicast_packets;
+	stats->opackets += ppio_stats.tx_packets +
+			ppio_stats.tx_broadcast_packets +
+			ppio_stats.tx_multicast_packets;
+	stats->ibytes += ppio_stats.rx_bytes;
+	stats->obytes += ppio_stats.tx_bytes;
+	stats->imissed += ppio_stats.rx_discard +
+			  ppio_stats.rx_overrun;
+
+	stats->ierrors = ppio_stats.rx_packets_err +
+			ppio_stats.rx_errors +
+			ppio_stats.rx_crc_error;
+	stats->oerrors = ppio_stats.tx_errors;
+
+	return 0;
+}
+
 static const struct eth_dev_ops mvneta_ops = {
 	.dev_configure = mvneta_dev_configure,
 	.dev_start = mvneta_dev_start,
@@ -705,6 +751,7 @@  static const struct eth_dev_ops mvneta_ops = {
 	.mac_addr_add = mvneta_mac_addr_add,
 	.mac_addr_set = mvneta_mac_addr_set,
 	.mtu_set = mvneta_mtu_set,
+	.stats_get = mvneta_stats_get,
 	.dev_infos_get = mvneta_dev_infos_get,
 	.dev_supported_ptypes_get = mvneta_dev_supported_ptypes_get,
 	.rxq_info_get = mvneta_rxq_info_get,