From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shijith Thotton Subject: [PATCH v3 41/46] net/liquidio: add support for Tx stats Date: Sat, 25 Mar 2017 11:54:52 +0530 Message-ID: <1490423097-6797-42-git-send-email-shijith.thotton@caviumnetworks.com> References: <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> <1490423097-6797-1-git-send-email-shijith.thotton@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain Cc: dev@dpdk.org, Jerin Jacob , Derek Chickles , Venkat Koppula , Srisivasubramanian S , Mallesham Jatharakonda To: Ferruh Yigit Return-path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0053.outbound.protection.outlook.com [104.47.36.53]) by dpdk.org (Postfix) with ESMTP id F31ACD326 for ; Sat, 25 Mar 2017 07:29:01 +0100 (CET) In-Reply-To: <1490423097-6797-1-git-send-email-shijith.thotton@caviumnetworks.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Shijith Thotton Signed-off-by: Jerin Jacob Signed-off-by: Derek Chickles Signed-off-by: Venkat Koppula Signed-off-by: Srisivasubramanian S Signed-off-by: Mallesham Jatharakonda --- 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 adf0db2..2f3bb3d 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 adbd990..470131c 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 6835430..d5aed6a 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 50d5e86..26f803f 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