app/testeventdev: add perf basic functions
authorJerin Jacob <jerin.jacob@caviumnetworks.com>
Tue, 4 Jul 2017 04:53:15 +0000 (10:23 +0530)
committerJerin Jacob <jerin.jacob@caviumnetworks.com>
Fri, 7 Jul 2017 07:34:17 +0000 (09:34 +0200)
add functions to create mempool, destroy mempool and print the test result.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
app/test-eventdev/test_perf_common.c
app/test-eventdev/test_perf_common.h

index d95eb62..a44f2df 100644 (file)
 
 #include "test_perf_common.h"
 
+int
+perf_test_result(struct evt_test *test, struct evt_options *opt)
+{
+       RTE_SET_USED(opt);
+       struct test_perf *t = evt_test_priv(test);
+
+       return t->result;
+}
+
+void
+perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt)
+{
+       RTE_SET_USED(test);
+
+       rte_event_dev_stop(opt->dev_id);
+       rte_event_dev_close(opt->dev_id);
+}
+
+static inline void
+perf_elt_init(struct rte_mempool *mp, void *arg __rte_unused,
+           void *obj, unsigned i __rte_unused)
+{
+       memset(obj, 0, mp->elt_size);
+}
+
+int
+perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
+{
+       struct test_perf *t = evt_test_priv(test);
+
+       t->pool = rte_mempool_create(test->name, /* mempool name */
+                               opt->pool_sz, /* number of elements*/
+                               sizeof(struct perf_elt), /* element size*/
+                               512, /* cache size*/
+                               0, NULL, NULL,
+                               perf_elt_init, /* obj constructor */
+                               NULL, opt->socket_id, 0); /* flags */
+       if (t->pool == NULL) {
+               evt_err("failed to create mempool");
+               return -ENOMEM;
+       }
+
+       return 0;
+}
+
+void
+perf_mempool_destroy(struct evt_test *test, struct evt_options *opt)
+{
+       RTE_SET_USED(opt);
+       struct test_perf *t = evt_test_priv(test);
+
+       rte_mempool_free(t->pool);
+}
 
 int
 perf_test_setup(struct evt_test *test, struct evt_options *opt)
index ab5c082..442ec99 100644 (file)
@@ -82,7 +82,15 @@ struct test_perf {
        uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
 } __rte_cache_aligned;
 
+struct perf_elt {
+       uint64_t timestamp;
+} __rte_cache_aligned;
+
+int perf_test_result(struct evt_test *test, struct evt_options *opt);
 int perf_test_setup(struct evt_test *test, struct evt_options *opt);
+int perf_mempool_setup(struct evt_test *test, struct evt_options *opt);
 void perf_test_destroy(struct evt_test *test, struct evt_options *opt);
+void perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt);
+void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
 
 #endif /* _TEST_PERF_COMMON_ */