[dpdk-dev] [PATCH 44/50] net/liquidio: add support for Rx stats

Shijith Thotton shijith.thotton at caviumnetworks.com
Tue Feb 21 10:26:59 CET 2017


Signed-off-by: Shijith Thotton <shijith.thotton at caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob at caviumnetworks.com>
Signed-off-by: Derek Chickles <derek.chickles at caviumnetworks.com>
Signed-off-by: Venkat Koppula <venkat.koppula at caviumnetworks.com>
Signed-off-by: Mallesham Jatharakonda <mjatharakonda at oneconvergence.com>
---
 drivers/net/liquidio/lio_ethdev.c | 50 +++++++++++++++++++++++++++++++++++++++
 drivers/net/liquidio/lio_rxtx.c   | 10 +++++++-
 drivers/net/liquidio/lio_struct.h | 34 ++++++++++++++++++++++++++
 3 files changed, 93 insertions(+), 1 deletion(-)

diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c
index 5f8f1c0..2bdba09 100644
--- a/drivers/net/liquidio/lio_ethdev.c
+++ b/drivers/net/liquidio/lio_ethdev.c
@@ -117,6 +117,54 @@
 	return 0;
 }
 
+/* Retrieve the device statistics (# packets in/out, # bytes in/out, etc */
+static void
+lio_dev_stats_get(struct rte_eth_dev *eth_dev,
+		  struct rte_eth_stats *stats)
+{
+	struct lio_device *lio_dev = LIO_DEV(eth_dev);
+	struct lio_droq_stats *oq_stats;
+	struct lio_droq *droq;
+	uint64_t bytes = 0;
+	uint64_t pkts = 0;
+	uint64_t drop = 0;
+	int i, oq_no;
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
+		oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
+		droq = lio_dev->droq[oq_no];
+		if (droq != NULL) {
+			oq_stats = &droq->stats;
+			pkts += oq_stats->rx_pkts_received;
+			drop += (oq_stats->rx_dropped +
+					oq_stats->dropped_toomany +
+					oq_stats->dropped_nomem);
+			bytes += oq_stats->rx_bytes_received;
+		}
+	}
+	stats->ibytes = bytes;
+	stats->ipackets = pkts;
+	stats->ierrors = drop;
+}
+
+static void
+lio_dev_stats_reset(struct rte_eth_dev *eth_dev)
+{
+	struct lio_device *lio_dev = LIO_DEV(eth_dev);
+	struct lio_droq_stats *oq_stats;
+	struct lio_droq *droq;
+	int i, oq_no;
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
+		oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
+		droq = lio_dev->droq[oq_no];
+		if (droq != NULL) {
+			oq_stats = &droq->stats;
+			memset(oq_stats, 0, sizeof(struct lio_droq_stats));
+		}
+	}
+}
+
 static void
 lio_dev_info_get(struct rte_eth_dev *eth_dev,
 		 struct rte_eth_dev_info *devinfo)
@@ -1391,6 +1439,8 @@ static int lio_dev_configure(struct rte_eth_dev *eth_dev)
 	.allmulticast_enable	= lio_dev_allmulticast_enable,
 	.allmulticast_disable	= lio_dev_allmulticast_disable,
 	.link_update		= lio_dev_link_update,
+	.stats_get		= lio_dev_stats_get,
+	.stats_reset		= lio_dev_stats_reset,
 	.dev_infos_get		= lio_dev_info_get,
 	.mtu_set		= lio_dev_change_vf_mtu,
 	.rx_queue_setup		= lio_dev_rx_queue_setup,
diff --git a/drivers/net/liquidio/lio_rxtx.c b/drivers/net/liquidio/lio_rxtx.c
index 9c587ef..794db32 100644
--- a/drivers/net/liquidio/lio_rxtx.c
+++ b/drivers/net/liquidio/lio_rxtx.c
@@ -115,6 +115,7 @@
 		buf = lio_recv_buffer_alloc(lio_dev, droq->q_no);
 		if (buf == NULL) {
 			lio_dev_err(lio_dev, "buffer alloc failed\n");
+			droq->stats.rx_alloc_failure++;
 			lio_droq_destroy_ring_buffers(droq);
 			return -ENOMEM;
 		}
@@ -410,8 +411,10 @@
 			/* If a buffer could not be allocated, no point in
 			 * continuing
 			 */
-			if (buf == NULL)
+			if (buf == NULL) {
+				droq->stats.rx_alloc_failure++;
 				break;
+			}
 
 			droq->recv_buf_list[droq->refill_idx].buffer = buf;
 		}
@@ -629,6 +632,11 @@
 	info->length = 0;
 	info->rh.rh64 = 0;
 
+	droq->stats.pkts_received++;
+	droq->stats.rx_pkts_received += data_pkts;
+	droq->stats.rx_bytes_received += data_total_len;
+	droq->stats.bytes_received += total_len;
+
 	return data_pkts;
 }
 
diff --git a/drivers/net/liquidio/lio_struct.h b/drivers/net/liquidio/lio_struct.h
index bdcc301..6788da1 100644
--- a/drivers/net/liquidio/lio_struct.h
+++ b/drivers/net/liquidio/lio_struct.h
@@ -56,6 +56,37 @@ struct lio_version {
 	uint16_t reserved;
 };
 
+/** Output Queue statistics. Each output queue has four stats fields. */
+struct lio_droq_stats {
+	/** Number of packets received in this queue. */
+	uint64_t pkts_received;
+
+	/** Bytes received by this queue. */
+	uint64_t bytes_received;
+
+	/** Packets dropped due to no memory available. */
+	uint64_t dropped_nomem;
+
+	/** Packets dropped due to large number of pkts to process. */
+	uint64_t dropped_toomany;
+
+	/** Number of packets  sent to stack from this queue. */
+	uint64_t rx_pkts_received;
+
+	/** Number of Bytes sent to stack from this queue. */
+	uint64_t rx_bytes_received;
+
+	/** Num of Packets dropped due to receive path failures. */
+	uint64_t rx_dropped;
+
+	/** Num of vxlan packets received; */
+	uint64_t rx_vxlan;
+
+	/** Num of failures of lio_recv_buffer_alloc() */
+	uint64_t rx_alloc_failure;
+
+};
+
 /** The Descriptor Ring Output Queue structure.
  *  This structure has all the information required to implement a
  *  DROQ.
@@ -117,6 +148,9 @@ struct lio_droq {
 	 */
 	void *pkts_sent_reg;
 
+	/** Statistics for this DROQ. */
+	struct lio_droq_stats stats;
+
 	/** DMA mapped address of the DROQ descriptor ring. */
 	size_t desc_ring_dma;
 
-- 
1.8.3.1



More information about the dev mailing list