net/liquidio: support Rx stats
authorShijith Thotton <shijith.thotton@caviumnetworks.com>
Sat, 25 Mar 2017 06:24:51 +0000 (11:54 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 4 Apr 2017 16:59:49 +0000 (18:59 +0200)
Signed-off-by: Shijith Thotton <shijith.thotton@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Signed-off-by: Derek Chickles <derek.chickles@caviumnetworks.com>
Signed-off-by: Venkat Koppula <venkat.koppula@caviumnetworks.com>
Signed-off-by: Srisivasubramanian S <ssrinivasan@caviumnetworks.com>
Signed-off-by: Mallesham Jatharakonda <mjatharakonda@oneconvergence.com>
doc/guides/nics/features/liquidio.ini
drivers/net/liquidio/lio_ethdev.c
drivers/net/liquidio/lio_rxtx.c
drivers/net/liquidio/lio_struct.h

index 2d6a49e..3195515 100644 (file)
@@ -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
index 3911864..adf0db2 100644 (file)
@@ -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,
index f105457..adbd990 100644 (file)
@@ -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;
 }
 
index c2293f7..50d5e86 100644 (file)
@@ -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;