app/eventdev: add pipeline test setup and destroy
[dpdk.git] / app / test-eventdev / test_pipeline_common.c
1 /*
2  * SPDX-License-Identifier: BSD-3-Clause
3  * Copyright 2017 Cavium, Inc.
4  */
5
6 #include "test_pipeline_common.h"
7
8 int
9 pipeline_test_setup(struct evt_test *test, struct evt_options *opt)
10 {
11         void *test_pipeline;
12
13         test_pipeline = rte_zmalloc_socket(test->name,
14                         sizeof(struct test_pipeline), RTE_CACHE_LINE_SIZE,
15                         opt->socket_id);
16         if (test_pipeline  == NULL) {
17                 evt_err("failed to allocate test_pipeline memory");
18                 goto nomem;
19         }
20         test->test_priv = test_pipeline;
21
22         struct test_pipeline *t = evt_test_priv(test);
23
24         t->nb_workers = evt_nr_active_lcores(opt->wlcores);
25         t->outstand_pkts = opt->nb_pkts * evt_nr_active_lcores(opt->wlcores);
26         t->done = false;
27         t->nb_flows = opt->nb_flows;
28         t->result = EVT_TEST_FAILED;
29         t->opt = opt;
30         opt->prod_type = EVT_PROD_TYPE_ETH_RX_ADPTR;
31         memcpy(t->sched_type_list, opt->sched_type_list,
32                         sizeof(opt->sched_type_list));
33         return 0;
34 nomem:
35         return -ENOMEM;
36 }
37
38 void
39 pipeline_test_destroy(struct evt_test *test, struct evt_options *opt)
40 {
41         RTE_SET_USED(opt);
42
43         rte_free(test->test_priv);
44 }