app/eventdev: modify setup to support ethdev
[dpdk.git] / app / test-eventdev / test_perf_common.c
index e77b472..a9710b2 100644 (file)
@@ -1,33 +1,5 @@
-/*
- *   BSD LICENSE
- *
- *   Copyright (C) Cavium, Inc 2017.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in
- *       the documentation and/or other materials provided with the
- *       distribution.
- *     * Neither the name of Cavium, Inc nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017 Cavium, Inc
  */
 
 #include "test_perf_common.h"
@@ -88,6 +60,17 @@ perf_producer(void *arg)
        return 0;
 }
 
+static int
+perf_producer_wrapper(void *arg)
+{
+       struct prod_data *p  = arg;
+       struct test_perf *t = p->t;
+       /* Launch the producer function only in case of synthetic producer. */
+       if (t->opt->prod_type == EVT_PROD_TYPE_SYNT)
+               return perf_producer(arg);
+       return 0;
+}
+
 static inline uint64_t
 processed_pkts(struct test_perf *t)
 {
@@ -142,8 +125,8 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
                if (!(opt->plcores[lcore_id]))
                        continue;
 
-               ret = rte_eal_remote_launch(perf_producer, &t->prod[port_idx],
-                                        lcore_id);
+               ret = rte_eal_remote_launch(perf_producer_wrapper,
+                               &t->prod[port_idx], lcore_id);
                if (ret) {
                        evt_err("failed to launch perf_producer %d", lcore_id);
                        return ret;
@@ -193,14 +176,17 @@ perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
                        fflush(stdout);
 
                        if (remaining <= 0) {
-                               t->done = true;
                                t->result = EVT_TEST_SUCCESS;
-                               rte_smp_wmb();
-                               break;
+                               if (opt->prod_type == EVT_PROD_TYPE_SYNT) {
+                                       t->done = true;
+                                       rte_smp_wmb();
+                                       break;
+                               }
                        }
                }
 
-               if (new_cycles - dead_lock_cycles > dead_lock_sample) {
+               if (new_cycles - dead_lock_cycles > dead_lock_sample &&
+                               opt->prod_type == EVT_PROD_TYPE_SYNT) {
                        remaining = t->outstand_pkts - processed_pkts(t);
                        if (dead_lock_remaining == remaining) {
                                rte_event_dev_dump(opt->dev_id, stdout);
@@ -287,8 +273,10 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
 {
        unsigned int lcores;
 
-       /* N producer + N worker + 1 master */
-       lcores = 3;
+       /* N producer + N worker + 1 master when producer cores are used
+        * Else N worker + 1 master when Rx adapter is used
+        */
+       lcores = opt->prod_type == EVT_PROD_TYPE_SYNT ? 3 : 2;
 
        if (rte_lcore_count() < lcores) {
                evt_err("test need minimum %d lcores", lcores);
@@ -313,18 +301,21 @@ perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
                return -1;
        }
 
-       /* Validate producer lcores */
-       if (evt_lcores_has_overlap(opt->plcores, rte_get_master_lcore())) {
-               evt_err("producer lcores overlaps with master lcore");
-               return -1;
-       }
-       if (evt_has_disabled_lcore(opt->plcores)) {
-               evt_err("one or more producer lcores are not enabled");
-               return -1;
-       }
-       if (!evt_has_active_lcore(opt->plcores)) {
-               evt_err("minimum one producer is required");
-               return -1;
+       if (opt->prod_type == EVT_PROD_TYPE_SYNT) {
+               /* Validate producer lcores */
+               if (evt_lcores_has_overlap(opt->plcores,
+                                       rte_get_master_lcore())) {
+                       evt_err("producer lcores overlaps with master lcore");
+                       return -1;
+               }
+               if (evt_has_disabled_lcore(opt->plcores)) {
+                       evt_err("one or more producer lcores are not enabled");
+                       return -1;
+               }
+               if (!evt_has_active_lcore(opt->plcores)) {
+                       evt_err("minimum one producer is required");
+                       return -1;
+               }
        }
 
        if (evt_has_invalid_stage(opt))
@@ -369,6 +360,7 @@ perf_opt_dump(struct evt_options *opt, uint8_t nb_queues)
        evt_dump("nb_evdev_queues", "%d", nb_queues);
        evt_dump_queue_priority(opt);
        evt_dump_sched_type_list(opt);
+       evt_dump_producer_type(opt);
 }
 
 void