[dpdk-dev] [PATCH 45/50] net/liquidio: add support for Tx stats

Shijith Thotton shijith.thotton at caviumnetworks.com
Tue Feb 21 10:27:00 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 | 36 ++++++++++++++++++++++++++++++++++--
 drivers/net/liquidio/lio_rxtx.c   | 18 ++++++++++++++++--
 drivers/net/liquidio/lio_rxtx.h   |  3 +++
 drivers/net/liquidio/lio_struct.h | 15 +++++++++++++++
 4 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c
index 2bdba09..7e6277a 100644
--- a/drivers/net/liquidio/lio_ethdev.c
+++ b/drivers/net/liquidio/lio_ethdev.c
@@ -124,11 +124,32 @@
 {
 	struct lio_device *lio_dev = LIO_DEV(eth_dev);
 	struct lio_droq_stats *oq_stats;
+	struct lio_iq_stats *iq_stats;
+	struct lio_instr_queue *txq;
 	struct lio_droq *droq;
+	int i, iq_no, oq_no;
 	uint64_t bytes = 0;
 	uint64_t pkts = 0;
 	uint64_t drop = 0;
-	int i, oq_no;
+
+	for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
+		iq_no = lio_dev->linfo.txpciq[i].s.q_no;
+		txq = lio_dev->instr_queue[iq_no];
+		if (txq != NULL) {
+			iq_stats = &txq->stats;
+			pkts += iq_stats->tx_done;
+			drop += iq_stats->tx_dropped;
+			bytes += iq_stats->tx_tot_bytes;
+		}
+	}
+
+	stats->opackets = pkts;
+	stats->obytes = bytes;
+	stats->oerrors = drop;
+
+	pkts = 0;
+	drop = 0;
+	bytes = 0;
 
 	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
 		oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
@@ -152,8 +173,19 @@
 {
 	struct lio_device *lio_dev = LIO_DEV(eth_dev);
 	struct lio_droq_stats *oq_stats;
+	struct lio_iq_stats *iq_stats;
+	struct lio_instr_queue *txq;
 	struct lio_droq *droq;
-	int i, oq_no;
+	int i, iq_no, oq_no;
+
+	for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
+		iq_no = lio_dev->linfo.txpciq[i].s.q_no;
+		txq = lio_dev->instr_queue[iq_no];
+		if (txq != NULL) {
+			iq_stats = &txq->stats;
+			memset(iq_stats, 0, sizeof(struct lio_iq_stats));
+		}
+	}
 
 	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
 		oq_no = lio_dev->linfo.rxpciq[i].s.q_no;
diff --git a/drivers/net/liquidio/lio_rxtx.c b/drivers/net/liquidio/lio_rxtx.c
index 794db32..edd16c6 100644
--- a/drivers/net/liquidio/lio_rxtx.c
+++ b/drivers/net/liquidio/lio_rxtx.c
@@ -1113,8 +1113,10 @@
 
 		inst_processed = lio_process_iq_request_list(lio_dev, iq);
 
-		if (inst_processed)
+		if (inst_processed) {
 			rte_atomic64_sub(&iq->instr_pending, inst_processed);
+			iq->stats.instr_processed += inst_processed;
+		}
 
 		tot_inst_processed += inst_processed;
 		inst_processed = 0;
@@ -1130,7 +1132,7 @@
 
 static int
 lio_send_command(struct lio_device *lio_dev, uint32_t iq_no, void *cmd,
-		 void *buf, uint32_t datasize __rte_unused, uint32_t reqtype)
+		 void *buf, uint32_t datasize, uint32_t reqtype)
 {
 	struct lio_instr_queue *iq = lio_dev->instr_queue[iq_no];
 	struct lio_iq_post_status st;
@@ -1141,7 +1143,13 @@
 
 	if (st.status != LIO_IQ_SEND_FAILED) {
 		lio_add_to_request_list(iq, st.index, buf, reqtype);
+		LIO_INCR_INSTRQUEUE_PKT_COUNT(lio_dev, iq_no, bytes_sent,
+					      datasize);
+		LIO_INCR_INSTRQUEUE_PKT_COUNT(lio_dev, iq_no, instr_posted, 1);
+
 		lio_ring_doorbell(lio_dev, iq);
+	} else {
+		LIO_INCR_INSTRQUEUE_PKT_COUNT(lio_dev, iq_no, instr_dropped, 1);
 	}
 
 	rte_spinlock_unlock(&iq->post_lock);
@@ -1667,6 +1675,7 @@ struct lio_soft_command *
 	struct lio_instr_queue *txq = tx_queue;
 	union lio_cmd_setup cmdsetup;
 	struct lio_device *lio_dev;
+	struct lio_iq_stats *stats;
 	struct lio_data_pkt ndata;
 	int i, processed = 0;
 	struct rte_mbuf *m;
@@ -1676,6 +1685,7 @@ struct lio_soft_command *
 
 	lio_dev = txq->lio_dev;
 	iq_no = txq->txpciq.s.q_no;
+	stats = &lio_dev->instr_queue[iq_no]->stats;
 
 	if (!lio_dev->intf_open || !lio_dev->linfo.link.s.link_up) {
 		PMD_TX_LOG(lio_dev, ERR, "Transmit failed link_status : %d\n",
@@ -1697,6 +1707,7 @@ struct lio_soft_command *
 
 		ndata.q_no = iq_no;
 		if (lio_iq_is_full(lio_dev, ndata.q_no)) {
+			stats->tx_iq_busy++;
 			if (lio_dev_cleanup_iq(lio_dev, iq_no)) {
 				PMD_TX_LOG(lio_dev, ERR,
 					   "Transmit failed iq:%d full\n",
@@ -1804,10 +1815,13 @@ struct lio_soft_command *
 			lio_dev_cleanup_iq(lio_dev, iq_no);
 		}
 
+		stats->tx_done++;
+		stats->tx_tot_bytes += pkt_len;
 		processed++;
 	}
 
 xmit_failed:
+	stats->tx_dropped += (nb_pkts - processed);
 
 	return processed;
 }
diff --git a/drivers/net/liquidio/lio_rxtx.h b/drivers/net/liquidio/lio_rxtx.h
index 655042d..6c024e1 100644
--- a/drivers/net/liquidio/lio_rxtx.h
+++ b/drivers/net/liquidio/lio_rxtx.h
@@ -670,6 +670,9 @@ enum {
  */
 int lio_process_ordered_list(struct lio_device *lio_dev);
 
+#define LIO_INCR_INSTRQUEUE_PKT_COUNT(lio_dev, iq_no, field, count)	\
+	(((lio_dev)->instr_queue[iq_no]->stats.field) += count)
+
 static inline void
 lio_swap_8B_data(uint64_t *data, uint32_t blocks)
 {
diff --git a/drivers/net/liquidio/lio_struct.h b/drivers/net/liquidio/lio_struct.h
index 6788da1..b1fca92 100644
--- a/drivers/net/liquidio/lio_struct.h
+++ b/drivers/net/liquidio/lio_struct.h
@@ -56,6 +56,18 @@ struct lio_version {
 	uint16_t reserved;
 };
 
+/** Input Queue statistics. Each input queue has four stats fields. */
+struct lio_iq_stats {
+	uint64_t instr_posted; /**< Instructions posted to this queue. */
+	uint64_t instr_processed; /**< Instructions processed in this queue. */
+	uint64_t instr_dropped; /**< Instructions that could not be processed */
+	uint64_t bytes_sent; /**< Bytes sent through this queue. */
+	uint64_t tx_done; /**< Num of packets sent to network. */
+	uint64_t tx_iq_busy; /**< Num of times this iq was found to be full. */
+	uint64_t tx_dropped; /**< Num of pkts dropped due to xmitpath errors. */
+	uint64_t tx_tot_bytes; /**< Total count of bytes sent to network. */
+};
+
 /** Output Queue statistics. Each output queue has four stats fields. */
 struct lio_droq_stats {
 	/** Number of packets received in this queue. */
@@ -319,6 +331,9 @@ struct lio_instr_queue {
 	/** Number of instructions pending to be posted to Octeon. */
 	uint32_t fill_cnt;
 
+	/** Statistics for this input queue. */
+	struct lio_iq_stats stats;
+
 	/** DMA mapped base address of the input descriptor ring. */
 	uint64_t base_addr_dma;
 
-- 
1.8.3.1



More information about the dev mailing list