From: Shijith Thotton Date: Sat, 25 Mar 2017 06:24:51 +0000 (+0530) Subject: net/liquidio: support Rx stats X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=47abece26425595d6e7452eeb8640be91a42a3a7;hp=0b83930de29a639e9088ea51ff00df8b652b3f48;p=dpdk.git net/liquidio: support Rx 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/doc/guides/nics/features/liquidio.ini b/doc/guides/nics/features/liquidio.ini index 2d6a49eac1..319551561f 100644 --- a/doc/guides/nics/features/liquidio.ini +++ b/doc/guides/nics/features/liquidio.ini @@ -17,6 +17,7 @@ L3 checksum offload = Y L4 checksum offload = Y Inner L3 checksum = Y Inner L4 checksum = Y +Basic stats = Y Multiprocess aware = Y Linux UIO = Y Linux VFIO = Y diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index 3911864f45..adf0db2d32 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -117,6 +117,54 @@ lio_send_rx_ctrl_cmd(struct rte_eth_dev *eth_dev, int start_stop) 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) @@ -1390,6 +1438,8 @@ static const struct eth_dev_ops liovf_eth_dev_ops = { .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, .rx_queue_setup = lio_dev_rx_queue_setup, .rx_queue_release = lio_dev_rx_queue_release, diff --git a/drivers/net/liquidio/lio_rxtx.c b/drivers/net/liquidio/lio_rxtx.c index f1054572ba..adbd9905ba 100644 --- a/drivers/net/liquidio/lio_rxtx.c +++ b/drivers/net/liquidio/lio_rxtx.c @@ -115,6 +115,7 @@ lio_droq_setup_ring_buffers(struct lio_device *lio_dev, 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 @@ lio_droq_refill(struct lio_device *lio_dev, struct lio_droq *droq) /* 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 @@ lio_droq_fast_process_packet(struct lio_device *lio_dev, 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 c2293f7113..50d5e86350 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;