New upstream version 17.08
[deb_dpdk.git] / drivers / event / sw / sw_evdev_xstats.c
index c7b1abe..8cb6d88 100644 (file)
@@ -30,9 +30,9 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <rte_event_ring.h>
 #include "sw_evdev.h"
 #include "iq_ring.h"
-#include "event_ring.h"
 
 enum xstats_type {
        /* common stats */
@@ -57,6 +57,7 @@ enum xstats_type {
        iq_used,
        /* qid port mapping specific */
        pinned,
+       pkts, /* note: qid-to-port pkts */
 };
 
 typedef uint64_t (*xstats_fn)(const struct sw_evdev *dev,
@@ -104,10 +105,10 @@ get_port_stat(const struct sw_evdev *sw, uint16_t obj_idx,
        case calls: return p->total_polls;
        case credits: return p->inflight_credits;
        case poll_return: return p->zero_polls;
-       case rx_used: return qe_ring_count(p->rx_worker_ring);
-       case rx_free: return qe_ring_free_count(p->rx_worker_ring);
-       case tx_used: return qe_ring_count(p->cq_worker_ring);
-       case tx_free: return qe_ring_free_count(p->cq_worker_ring);
+       case rx_used: return rte_event_ring_count(p->rx_worker_ring);
+       case rx_free: return rte_event_ring_free_count(p->rx_worker_ring);
+       case tx_used: return rte_event_ring_count(p->cq_worker_ring);
+       case tx_free: return rte_event_ring_free_count(p->cq_worker_ring);
        default: return -1;
        }
 }
@@ -179,6 +180,8 @@ get_qid_port_stat(const struct sw_evdev *sw, uint16_t obj_idx,
                        return pin;
                } while (0);
                break;
+       case pkts:
+               return qid->to_port[port];
        default: return -1;
        }
 }
@@ -246,8 +249,11 @@ sw_xstats_init(struct sw_evdev *sw)
        static const enum xstats_type qid_iq_types[] = { iq_used };
        /* reset allowed */
 
-       static const char * const qid_port_stats[] = { "pinned_flows" };
-       static const enum xstats_type qid_port_types[] = { pinned };
+       static const char * const qid_port_stats[] = { "pinned_flows",
+               "packets"
+       };
+       static const enum xstats_type qid_port_types[] = { pinned, pkts };
+       static const uint8_t qid_port_reset_allowed[] = {0, 1};
        /* reset allowed */
        /* ---- end of stat definitions ---- */
 
@@ -312,8 +318,9 @@ sw_xstats_init(struct sw_evdev *sw)
                                        port, port_stats[i]);
                }
 
-               for (bkt = 0; bkt < (sw->ports[port].cq_worker_ring->size >>
-                               SW_DEQ_STAT_BUCKET_SHIFT) + 1; bkt++) {
+               for (bkt = 0; bkt < (rte_event_ring_get_capacity(
+                               sw->ports[port].cq_worker_ring) >>
+                                       SW_DEQ_STAT_BUCKET_SHIFT) + 1; bkt++) {
                        for (i = 0; i < RTE_DIM(port_bucket_stats); i++) {
                                sw->xstats[stat] = (struct sw_xstats_entry){
                                        .fn = get_port_bucket_stat,
@@ -376,7 +383,8 @@ sw_xstats_init(struct sw_evdev *sw)
                                        .stat = qid_port_types[i],
                                        .mode = RTE_EVENT_DEV_XSTATS_QUEUE,
                                        .extra_arg = port,
-                                       .reset_allowed = 0,
+                                       .reset_allowed =
+                                               qid_port_reset_allowed[i],
                                };
                                snprintf(sname, sizeof(sname),
                                                "qid_%u_port_%u_%s",