ethdev: update extending stats strings
authorHarry van Haaren <harry.van.haaren@intel.com>
Mon, 2 Nov 2015 10:18:59 +0000 (10:18 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 2 Nov 2015 23:07:15 +0000 (00:07 +0100)
Update the strings used for presenting stats to adhere
to the scheme previously presented. Updated xstats_get()
function to handle Q information only if xstats() is not
implemented in the PMD, providing the PMD with the needed
flexibility to expose its extended Q stats.

Add extended statistic section to the programmers
guide, poll mode driver section. This section describes
how the strings stats are formatted, and how the client
code can use this to gather information about the stat.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Maryam Tahhan <maryam.tahhan@intel.com>
doc/guides/prog_guide/poll_mode_drv.rst
doc/guides/rel_notes/release_2_2.rst
lib/librte_ether/rte_ethdev.c

index 8780ba3..7698692 100644 (file)
@@ -1,5 +1,5 @@
 ..  BSD LICENSE
-    Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+    Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
     All rights reserved.
 
     Redistribution and use in source and binary forms, with or without
@@ -294,3 +294,52 @@ Ethernet Device API
 ~~~~~~~~~~~~~~~~~~~
 
 The Ethernet device API exported by the Ethernet PMDs is described in the *DPDK API Reference*.
+
+Extended Statistics API
+~~~~~~~~~~~~~~~~~~~~~~~
+
+The extended statistics API allows each individual PMD to expose a unique set
+of statistics. The client of the API provides an array of
+``struct rte_eth_xstats`` type. Each ``struct rte_eth_xstats`` contains a
+string and value pair. The amount of xstats exposed, and position of the
+statistic in the array must remain constant during runtime.
+
+A naming scheme exists for the strings exposed to clients of the API. This is
+to allow scraping of the API for statistics of interest. The naming scheme uses
+strings split by a single underscore ``_``. The scheme is as follows:
+
+* direction
+* detail 1
+* detail 2
+* detail n
+* unit
+
+Examples of common statistics xstats strings, formatted to comply to the scheme
+proposed above:
+
+* ``rx_bytes``
+* ``rx_crc_errors``
+* ``tx_multicast_packets``
+
+The scheme, although quite simple, allows flexibility in presenting and reading
+information from the statistic strings. The following example illustrates the
+naming scheme:``rx_packets``. In this example, the string is split into two
+components. The first component ``rx`` indicates that the statistic is
+associated with the receive side of the NIC.  The second component ``packets``
+indicates that the unit of measure is packets.
+
+A more complicated example: ``tx_size_128_to_255_packets``. In this example,
+``tx`` indicates transmission, ``size``  is the first detail, ``128`` etc are
+more details, and ``packets`` indicates that this is a packet counter.
+
+Some additions in the metadata scheme are as follows:
+
+* If the first part does not match ``rx`` or ``tx``, the statistic does not
+  have an affinity with either receive of transmit.
+
+* If the first letter of the second part is ``q`` and this ``q`` is followed
+  by a number, this statistic is part of a specific queue.
+
+An example where queue numbers are used is as follows: ``tx_q7_bytes`` which
+indicates this statistic applies to queue number 7, and represents the number
+of transmitted bytes on that queue.
index 16209d2..f7dafa0 100644 (file)
@@ -4,6 +4,14 @@ DPDK Release 2.2
 New Features
 ------------
 
+* **Extended Statistics**
+
+  Define extended statistics naming scheme to store metadata in the name
+  string name of each statistic, refer to the Extended Statistics section
+  of the programmers guide. Implemented the extended stats API for these
+  PMDs:
+
+
 * **Added API in ethdev to retrieve RX/TX queue information.**
 
   *  Add the ability for the upper layer to query RX/TX queue information.
index 39f65bf..073ffe9 100644 (file)
@@ -137,27 +137,30 @@ struct rte_eth_xstats_name_off {
 };
 
 static const struct rte_eth_xstats_name_off rte_stats_strings[] = {
-       {"rx_packets", offsetof(struct rte_eth_stats, ipackets)},
-       {"tx_packets", offsetof(struct rte_eth_stats, opackets)},
-       {"rx_bytes", offsetof(struct rte_eth_stats, ibytes)},
-       {"tx_bytes", offsetof(struct rte_eth_stats, obytes)},
-       {"tx_errors", offsetof(struct rte_eth_stats, oerrors)},
+       {"rx_good_packets", offsetof(struct rte_eth_stats, ipackets)},
+       {"tx_good_packets", offsetof(struct rte_eth_stats, opackets)},
+       {"rx_good_bytes", offsetof(struct rte_eth_stats, ibytes)},
+       {"tx_good_bytes", offsetof(struct rte_eth_stats, obytes)},
        {"rx_errors", offsetof(struct rte_eth_stats, ierrors)},
-       {"alloc_rx_buff_failed", offsetof(struct rte_eth_stats, rx_nombuf)},
+       {"tx_errors", offsetof(struct rte_eth_stats, oerrors)},
+       {"rx_mbuf_allocation_errors", offsetof(struct rte_eth_stats,
+               rx_nombuf)},
 };
+
 #define RTE_NB_STATS (sizeof(rte_stats_strings) / sizeof(rte_stats_strings[0]))
 
 static const struct rte_eth_xstats_name_off rte_rxq_stats_strings[] = {
-       {"rx_packets", offsetof(struct rte_eth_stats, q_ipackets)},
-       {"rx_bytes", offsetof(struct rte_eth_stats, q_ibytes)},
+       {"packets", offsetof(struct rte_eth_stats, q_ipackets)},
+       {"bytes", offsetof(struct rte_eth_stats, q_ibytes)},
+       {"errors", offsetof(struct rte_eth_stats, q_errors)},
 };
+
 #define RTE_NB_RXQ_STATS (sizeof(rte_rxq_stats_strings) /      \
                sizeof(rte_rxq_stats_strings[0]))
 
 static const struct rte_eth_xstats_name_off rte_txq_stats_strings[] = {
-       {"tx_packets", offsetof(struct rte_eth_stats, q_opackets)},
-       {"tx_bytes", offsetof(struct rte_eth_stats, q_obytes)},
-       {"tx_errors", offsetof(struct rte_eth_stats, q_errors)},
+       {"packets", offsetof(struct rte_eth_stats, q_opackets)},
+       {"bytes", offsetof(struct rte_eth_stats, q_obytes)},
 };
 #define RTE_NB_TXQ_STATS (sizeof(rte_txq_stats_strings) /      \
                sizeof(rte_txq_stats_strings[0]))
@@ -1480,8 +1483,6 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
 
        /* Return generic statistics */
        count = RTE_NB_STATS;
-       count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS;
-       count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS;
 
        /* implemented by the driver */
        if (dev->dev_ops->xstats_get != NULL) {
@@ -1493,6 +1494,9 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
 
                if (xcount < 0)
                        return xcount;
+       } else {
+               count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS;
+               count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS;
        }
 
        if (n < count + xcount)
@@ -1512,6 +1516,10 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
                xstats[count++].value = val;
        }
 
+       /* if xstats_get() is implemented by the PMD, the Q stats are done */
+       if (dev->dev_ops->xstats_get != NULL)
+               return count + xcount;
+
        /* per-rxq stats */
        for (q = 0; q < dev->data->nb_rx_queues; q++) {
                for (i = 0; i < RTE_NB_RXQ_STATS; i++) {
@@ -1520,7 +1528,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
                                        q * sizeof(uint64_t));
                        val = *stats_ptr;
                        snprintf(xstats[count].name, sizeof(xstats[count].name),
-                               "rx_queue_%u_%s", q,
+                               "rx_q%u_%s", q,
                                rte_rxq_stats_strings[i].name);
                        xstats[count++].value = val;
                }
@@ -1534,7 +1542,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
                                        q * sizeof(uint64_t));
                        val = *stats_ptr;
                        snprintf(xstats[count].name, sizeof(xstats[count].name),
-                               "tx_queue_%u_%s", q,
+                               "tx_q%u_%s", q,
                                rte_txq_stats_strings[i].name);
                        xstats[count++].value = val;
                }