New upstream version 18.02
[deb_dpdk.git] / drivers / event / sw / sw_evdev_selftest.c
similarity index 96%
rename from test/test/test_eventdev_sw.c
rename to drivers/event/sw/sw_evdev_selftest.c
index f524b6f..78d30e0 100644 (file)
@@ -1,34 +1,5 @@
-/*-
- *   BSD LICENSE
- *
- *   Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
- *   All rights reserved.
- *
- *   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 Intel Corporation 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) 2016-2017 Intel Corporation
  */
 
 #include <stdio.h>
@@ -52,7 +23,7 @@
 #include <rte_service_component.h>
 #include <rte_bus_vdev.h>
 
-#include "test.h"
+#include "sw_evdev.h"
 
 #define MAX_PORTS 16
 #define MAX_QIDS 16
@@ -200,6 +171,7 @@ create_ports(struct test *t, int num_ports)
                        .new_event_threshold = 1024,
                        .dequeue_depth = 32,
                        .enqueue_depth = 64,
+                       .disable_implicit_release = 0,
        };
        if (num_ports > MAX_PORTS)
                return -1;
@@ -923,8 +895,8 @@ xstats_tests(struct test *t)
        ret = rte_event_dev_xstats_names_get(evdev,
                                        RTE_EVENT_DEV_XSTATS_QUEUE,
                                        0, xstats_names, ids, XSTATS_MAX);
-       if (ret != 17) {
-               printf("%d: expected 17 stats, got return %d\n", __LINE__, ret);
+       if (ret != 16) {
+               printf("%d: expected 16 stats, got return %d\n", __LINE__, ret);
                return -1;
        }
 
@@ -940,8 +912,8 @@ xstats_tests(struct test *t)
        ret = rte_event_dev_xstats_get(evdev,
                                        RTE_EVENT_DEV_XSTATS_QUEUE,
                                        0, ids, values, ret);
-       if (ret != 17) {
-               printf("%d: expected 17 stats, got return %d\n", __LINE__, ret);
+       if (ret != 16) {
+               printf("%d: expected 16 stats, got return %d\n", __LINE__, ret);
                return -1;
        }
 
@@ -1103,7 +1075,6 @@ xstats_tests(struct test *t)
                3 /* tx */,
                0 /* drop */,
                3 /* inflights */,
-               512 /* iq size */,
                0, 0, 0, 0, /* iq 0, 1, 2, 3 used */
                /* QID-to-Port: pinned_flows, packets */
                0, 0,
@@ -1134,7 +1105,6 @@ xstats_tests(struct test *t)
                0 /* tx */,
                0 /* drop */,
                3 /* inflight */,
-               512 /* iq size */,
                0, 0, 0, 0, /* 4 iq used */
                /* QID-to-Port: pinned_flows, packets */
                0, 0,
@@ -1256,6 +1226,7 @@ port_reconfig_credits(struct test *t)
                                .new_event_threshold = 128,
                                .dequeue_depth = 32,
                                .enqueue_depth = 64,
+                               .disable_implicit_release = 0,
                };
                if (rte_event_port_setup(evdev, 0, &port_conf) < 0) {
                        printf("%d Error setting up port\n", __LINE__);
@@ -1345,6 +1316,7 @@ port_single_lb_reconfig(struct test *t)
                .new_event_threshold = 128,
                .dequeue_depth = 32,
                .enqueue_depth = 64,
+               .disable_implicit_release = 0,
        };
        if (rte_event_port_setup(evdev, 0, &port_conf) < 0) {
                printf("%d Error setting up port\n", __LINE__);
@@ -1686,7 +1658,7 @@ xstats_id_reset_tests(struct test *t)
                goto fail;
 
 /* num queue stats */
-#define NUM_Q_STATS 17
+#define NUM_Q_STATS 16
 /* queue offset from start of the devices whole xstats.
  * This will break every time we add a statistic to a device/port/queue
  */
@@ -1711,7 +1683,6 @@ xstats_id_reset_tests(struct test *t)
                "qid_0_tx",
                "qid_0_drop",
                "qid_0_inflight",
-               "qid_0_iq_size",
                "qid_0_iq_0_used",
                "qid_0_iq_1_used",
                "qid_0_iq_2_used",
@@ -1730,7 +1701,6 @@ xstats_id_reset_tests(struct test *t)
                7, /* tx */
                0, /* drop */
                7, /* inflight */
-               512, /* iq size */
                0, /* iq 0 used */
                0, /* iq 1 used */
                0, /* iq 2 used */
@@ -1746,7 +1716,6 @@ xstats_id_reset_tests(struct test *t)
                0, /* tx */
                0, /* drop */
                7, /* inflight */
-               512, /* iq size */
                0, /* iq 0 used */
                0, /* iq 1 used */
                0, /* iq 2 used */
@@ -2940,7 +2909,7 @@ worker_loopback_producer_fn(void *arg)
 }
 
 static int
-worker_loopback(struct test *t)
+worker_loopback(struct test *t, uint8_t disable_implicit_release)
 {
        /* use a single producer core, and a worker core to see what happens
         * if the worker loops packets back multiple times
@@ -2966,6 +2935,7 @@ worker_loopback(struct test *t)
         * only be initialized once - and this needs to be set for multiple runs
         */
        conf.new_event_threshold = 512;
+       conf.disable_implicit_release = disable_implicit_release;
 
        if (rte_event_port_setup(evdev, 0, &conf) < 0) {
                printf("Error setting up RX port\n");
@@ -3043,36 +3013,39 @@ worker_loopback(struct test *t)
 
 static struct rte_mempool *eventdev_func_mempool;
 
-static int
+int
 test_sw_eventdev(void)
 {
-       struct test *t = malloc(sizeof(struct test));
+       struct test *t;
        int ret;
 
+       t = malloc(sizeof(struct test));
+       if (t == NULL)
+               return -1;
        /* manually initialize the op, older gcc's complain on static
         * initialization of struct elements that are a bitfield.
         */
        release_ev.op = RTE_EVENT_OP_RELEASE;
 
-       const char *eventdev_name = "event_sw0";
+       const char *eventdev_name = "event_sw";
        evdev = rte_event_dev_get_dev_id(eventdev_name);
        if (evdev < 0) {
                printf("%d: Eventdev %s not found - creating.\n",
                                __LINE__, eventdev_name);
                if (rte_vdev_init(eventdev_name, NULL) < 0) {
                        printf("Error creating eventdev\n");
-                       return -1;
+                       goto test_fail;
                }
                evdev = rte_event_dev_get_dev_id(eventdev_name);
                if (evdev < 0) {
                        printf("Error finding newly created eventdev\n");
-                       return -1;
+                       goto test_fail;
                }
        }
 
        if (rte_event_dev_service_id_get(evdev, &t->service_id) < 0) {
                printf("Failed to get service ID for software event dev\n");
-               return -1;
+               goto test_fail;
        }
 
        rte_service_runstate_set(t->service_id, 1);
@@ -3089,7 +3062,7 @@ test_sw_eventdev(void)
                                rte_socket_id());
                if (!eventdev_func_mempool) {
                        printf("ERROR creating mempool\n");
-                       return -1;
+                       goto test_fail;
                }
        }
        t->mbuf_pool = eventdev_func_mempool;
@@ -3097,165 +3070,176 @@ test_sw_eventdev(void)
        ret = test_single_directed_packet(t);
        if (ret != 0) {
                printf("ERROR - Single Directed Packet test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Directed Forward Credit test...\n");
        ret = test_directed_forward_credits(t);
        if (ret != 0) {
                printf("ERROR - Directed Forward Credit test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Single Load Balanced Packet test...\n");
        ret = single_packet(t);
        if (ret != 0) {
                printf("ERROR - Single Packet test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Unordered Basic test...\n");
        ret = unordered_basic(t);
        if (ret != 0) {
                printf("ERROR -  Unordered Basic test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Ordered Basic test...\n");
        ret = ordered_basic(t);
        if (ret != 0) {
                printf("ERROR -  Ordered Basic test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Burst Packets test...\n");
        ret = burst_packets(t);
        if (ret != 0) {
                printf("ERROR - Burst Packets test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Load Balancing test...\n");
        ret = load_balancing(t);
        if (ret != 0) {
                printf("ERROR - Load Balancing test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Prioritized Directed test...\n");
        ret = test_priority_directed(t);
        if (ret != 0) {
                printf("ERROR - Prioritized Directed test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Prioritized Atomic test...\n");
        ret = test_priority_atomic(t);
        if (ret != 0) {
                printf("ERROR - Prioritized Atomic test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
 
        printf("*** Running Prioritized Ordered test...\n");
        ret = test_priority_ordered(t);
        if (ret != 0) {
                printf("ERROR - Prioritized Ordered test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Prioritized Unordered test...\n");
        ret = test_priority_unordered(t);
        if (ret != 0) {
                printf("ERROR - Prioritized Unordered test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Invalid QID test...\n");
        ret = invalid_qid(t);
        if (ret != 0) {
                printf("ERROR - Invalid QID test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Load Balancing History test...\n");
        ret = load_balancing_history(t);
        if (ret != 0) {
                printf("ERROR - Load Balancing History test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Inflight Count test...\n");
        ret = inflight_counts(t);
        if (ret != 0) {
                printf("ERROR - Inflight Count test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Abuse Inflights test...\n");
        ret = abuse_inflights(t);
        if (ret != 0) {
                printf("ERROR - Abuse Inflights test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running XStats test...\n");
        ret = xstats_tests(t);
        if (ret != 0) {
                printf("ERROR - XStats test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running XStats ID Reset test...\n");
        ret = xstats_id_reset_tests(t);
        if (ret != 0) {
                printf("ERROR - XStats ID Reset test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running XStats Brute Force test...\n");
        ret = xstats_brute_force(t);
        if (ret != 0) {
                printf("ERROR - XStats Brute Force test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running XStats ID Abuse test...\n");
        ret = xstats_id_abuse_tests(t);
        if (ret != 0) {
                printf("ERROR - XStats ID Abuse test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running QID Priority test...\n");
        ret = qid_priorities(t);
        if (ret != 0) {
                printf("ERROR - QID Priority test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Ordered Reconfigure test...\n");
        ret = ordered_reconfigure(t);
        if (ret != 0) {
                printf("ERROR - Ordered Reconfigure test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Port LB Single Reconfig test...\n");
        ret = port_single_lb_reconfig(t);
        if (ret != 0) {
                printf("ERROR - Port LB Single Reconfig test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Port Reconfig Credits test...\n");
        ret = port_reconfig_credits(t);
        if (ret != 0) {
                printf("ERROR - Port Reconfig Credits Reset test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        printf("*** Running Head-of-line-blocking test...\n");
        ret = holb(t);
        if (ret != 0) {
                printf("ERROR - Head-of-line-blocking test FAILED.\n");
-               return ret;
+               goto test_fail;
        }
        if (rte_lcore_count() >= 3) {
                printf("*** Running Worker loopback test...\n");
-               ret = worker_loopback(t);
+               ret = worker_loopback(t, 0);
                if (ret != 0) {
                        printf("ERROR - Worker loopback test FAILED.\n");
                        return ret;
                }
+
+               printf("*** Running Worker loopback test (implicit release disabled)...\n");
+               ret = worker_loopback(t, 1);
+               if (ret != 0) {
+                       printf("ERROR - Worker loopback test FAILED.\n");
+                       goto test_fail;
+               }
        } else {
-               printf("### Not enough cores for worker loopback test.\n");
-               printf("### Need at least 3 cores for test.\n");
+               printf("### Not enough cores for worker loopback tests.\n");
+               printf("### Need at least 3 cores for the tests.\n");
        }
+
        /*
         * Free test instance, leaving mempool initialized, and a pointer to it
         * in static eventdev_func_mempool, as it is re-used on re-runs
         */
        free(t);
 
+       printf("SW Eventdev Selftest Successful.\n");
        return 0;
+test_fail:
+       free(t);
+       printf("SW Eventdev Selftest Failed.\n");
+       return -1;
 }
-
-REGISTER_TEST_COMMAND(eventdev_sw_autotest, test_sw_eventdev);