X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=test%2Ftest%2Ftest_distributor.c;h=98919ec0ccbb5501efe8f87c6ce39c55360de2f0;hb=9b848774a5dc7b79c2dc5921583366725f374f64;hp=7a3051353f7cabbb2925a61eccf37d679867fc69;hpb=c0de0eb82e40a6c97decffd5328bd2761b05f300;p=dpdk.git diff --git a/test/test/test_distributor.c b/test/test/test_distributor.c index 7a3051353f..98919ec0cc 100644 --- a/test/test/test_distributor.c +++ b/test/test/test_distributor.c @@ -1,34 +1,5 @@ -/*- - * BSD LICENSE - * - * Copyright(c) 2010-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) 2010-2017 Intel Corporation */ #include "test.h" @@ -112,7 +83,7 @@ handle_work(void *arg) /* do basic sanity testing of the distributor. This test tests the following: * - send 32 packets through distributor with the same tag and ensure they * all go to the one worker - * - send 32 packets throught the distributor with two different tags and + * - send 32 packets through the distributor with two different tags and * verify that they go equally to two different workers. * - send 32 packets with different tags through the distributors and * just verify we get all packets back. @@ -538,17 +509,25 @@ static int test_error_distributor_create_name(void) { struct rte_distributor *d = NULL; + struct rte_distributor *db = NULL; char *name = NULL; d = rte_distributor_create(name, rte_socket_id(), rte_lcore_count() - 1, - RTE_DIST_ALG_BURST); - + RTE_DIST_ALG_SINGLE); if (d != NULL || rte_errno != EINVAL) { printf("ERROR: No error on create() with NULL name param\n"); return -1; } + db = rte_distributor_create(name, rte_socket_id(), + rte_lcore_count() - 1, + RTE_DIST_ALG_BURST); + if (db != NULL || rte_errno != EINVAL) { + printf("ERROR: No error on create() with NULL param\n"); + return -1; + } + return 0; } @@ -556,15 +535,25 @@ int test_error_distributor_create_name(void) static int test_error_distributor_create_numworkers(void) { - struct rte_distributor *d = NULL; + struct rte_distributor *ds = NULL; + struct rte_distributor *db = NULL; - d = rte_distributor_create("test_numworkers", rte_socket_id(), + ds = rte_distributor_create("test_numworkers", rte_socket_id(), RTE_MAX_LCORE + 10, - RTE_DIST_ALG_BURST); - if (d != NULL || rte_errno != EINVAL) { + RTE_DIST_ALG_SINGLE); + if (ds != NULL || rte_errno != EINVAL) { printf("ERROR: No error on create() with num_workers > MAX\n"); return -1; } + + db = rte_distributor_create("test_numworkers", rte_socket_id(), + RTE_MAX_LCORE + 10, + RTE_DIST_ALG_BURST); + if (db != NULL || rte_errno != EINVAL) { + printf("ERROR: No error on create() num_workers > MAX\n"); + return -1; + } + return 0; } @@ -597,25 +586,42 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p) static int test_distributor(void) { - static struct rte_distributor *d; + static struct rte_distributor *ds; + static struct rte_distributor *db; + static struct rte_distributor *dist[2]; static struct rte_mempool *p; + int i; if (rte_lcore_count() < 2) { printf("ERROR: not enough cores to test distributor\n"); return -1; } - if (d == NULL) { - d = rte_distributor_create("Test_dist_burst", rte_socket_id(), + if (db == NULL) { + db = rte_distributor_create("Test_dist_burst", rte_socket_id(), rte_lcore_count() - 1, RTE_DIST_ALG_BURST); - if (d == NULL) { + if (db == NULL) { printf("Error creating burst distributor\n"); return -1; } } else { - rte_distributor_flush(d); - rte_distributor_clear_returns(d); + rte_distributor_flush(db); + rte_distributor_clear_returns(db); + } + + if (ds == NULL) { + ds = rte_distributor_create("Test_dist_single", + rte_socket_id(), + rte_lcore_count() - 1, + RTE_DIST_ALG_SINGLE); + if (ds == NULL) { + printf("Error creating single distributor\n"); + return -1; + } + } else { + rte_distributor_flush(ds); + rte_distributor_clear_returns(ds); } const unsigned nb_bufs = (511 * rte_lcore_count()) < BIG_BATCH ? @@ -629,37 +635,50 @@ test_distributor(void) } } - worker_params.dist = d; - sprintf(worker_params.name, "burst"); + dist[0] = ds; + dist[1] = db; - rte_eal_mp_remote_launch(handle_work, &worker_params, SKIP_MASTER); - if (sanity_test(&worker_params, p) < 0) - goto err; - quit_workers(&worker_params, p); + for (i = 0; i < 2; i++) { - rte_eal_mp_remote_launch(handle_work_with_free_mbufs, &worker_params, - SKIP_MASTER); - if (sanity_test_with_mbuf_alloc(&worker_params, p) < 0) - goto err; - quit_workers(&worker_params, p); + worker_params.dist = dist[i]; + if (i) + sprintf(worker_params.name, "burst"); + else + sprintf(worker_params.name, "single"); - if (rte_lcore_count() > 2) { - rte_eal_mp_remote_launch(handle_work_for_shutdown_test, - &worker_params, - SKIP_MASTER); - if (sanity_test_with_worker_shutdown(&worker_params, p) < 0) + rte_eal_mp_remote_launch(handle_work, + &worker_params, SKIP_MASTER); + if (sanity_test(&worker_params, p) < 0) goto err; quit_workers(&worker_params, p); - rte_eal_mp_remote_launch(handle_work_for_shutdown_test, - &worker_params, - SKIP_MASTER); - if (test_flush_with_worker_shutdown(&worker_params, p) < 0) + rte_eal_mp_remote_launch(handle_work_with_free_mbufs, + &worker_params, SKIP_MASTER); + if (sanity_test_with_mbuf_alloc(&worker_params, p) < 0) goto err; quit_workers(&worker_params, p); - } else { - printf("Not enough cores to run tests for worker shutdown\n"); + if (rte_lcore_count() > 2) { + rte_eal_mp_remote_launch(handle_work_for_shutdown_test, + &worker_params, + SKIP_MASTER); + if (sanity_test_with_worker_shutdown(&worker_params, + p) < 0) + goto err; + quit_workers(&worker_params, p); + + rte_eal_mp_remote_launch(handle_work_for_shutdown_test, + &worker_params, + SKIP_MASTER); + if (test_flush_with_worker_shutdown(&worker_params, + p) < 0) + goto err; + quit_workers(&worker_params, p); + + } else { + printf("Too few cores to run worker shutdown test\n"); + } + } if (test_error_distributor_create_numworkers() == -1 ||