From: Shijith Thotton Date: Sat, 25 Mar 2017 06:24:52 +0000 (+0530) Subject: net/liquidio: support Tx stats X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=04006cc2d00ef2a7d50a15f67a5079e0d026c8cc;p=dpdk.git net/liquidio: support Tx stats 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 --- diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index adf0db2d32..2f3bb3de7d 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -124,11 +124,32 @@ lio_dev_stats_get(struct rte_eth_dev *eth_dev, { 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 @@ 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_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 adbd9905ba..470131c490 100644 --- a/drivers/net/liquidio/lio_rxtx.c +++ b/drivers/net/liquidio/lio_rxtx.c @@ -1113,8 +1113,10 @@ lio_flush_iq(struct lio_device *lio_dev, struct lio_instr_queue *iq) 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 @@ lio_flush_iq(struct lio_device *lio_dev, struct lio_instr_queue *iq) 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 @@ lio_send_command(struct lio_device *lio_dev, uint32_t iq_no, void *cmd, 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 @@ lio_dev_xmit_pkts(void *tx_queue, struct rte_mbuf **pkts, uint16_t nb_pkts) 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 @@ lio_dev_xmit_pkts(void *tx_queue, struct rte_mbuf **pkts, uint16_t nb_pkts) 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 @@ lio_dev_xmit_pkts(void *tx_queue, struct rte_mbuf **pkts, uint16_t nb_pkts) 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 @@ lio_dev_xmit_pkts(void *tx_queue, struct rte_mbuf **pkts, uint16_t nb_pkts) 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 6835430b22..d5aed6a7b5 100644 --- a/drivers/net/liquidio/lio_rxtx.h +++ b/drivers/net/liquidio/lio_rxtx.h @@ -670,6 +670,9 @@ void lio_setup_response_list(struct lio_device *lio_dev); */ 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 50d5e86350..26f803f99d 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;