X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest%2Ftest_efd.c;h=2868712bb2b7d810000000afd23b149a4ceb5d00;hb=24ac604ef7469eb5773c2504b313dd00257f8df3;hp=d5c3bd9e75118bcdab82b51398c7e56d588ee205;hpb=0e925aef2779445ea5e61b528f33b45f55a3e671;p=dpdk.git diff --git a/app/test/test_efd.c b/app/test/test_efd.c index d5c3bd9e75..2868712bb2 100644 --- a/app/test/test_efd.c +++ b/app/test/test_efd.c @@ -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 @@ -44,6 +15,12 @@ #define EFD_TEST_KEY_LEN 8 #define TABLE_SIZE (1 << 21) #define ITERATIONS 3 + +#if RTE_EFD_VALUE_NUM_BITS == 32 +#define VALUE_BITMASK 0xffffffff +#else +#define VALUE_BITMASK ((1 << RTE_EFD_VALUE_NUM_BITS) - 1) +#endif static unsigned int test_socket_id; /* 5-tuple key type */ @@ -54,65 +31,63 @@ struct flow_key { uint16_t port_dst; uint8_t proto; } __attribute__((packed)); + +int efd_logtype_test; + +RTE_INIT(test_efd_init_log) +{ + efd_logtype_test = rte_log_register("test.efd"); +} + /* * Print out result of unit test efd operation. */ -#if defined(UNIT_TEST_EFD_VERBOSE) - static void print_key_info(const char *msg, const struct flow_key *key, efd_value_t val) { const uint8_t *p = (const uint8_t *) key; unsigned int i; - printf("%s key:0x", msg); + rte_log(RTE_LOG_DEBUG, efd_logtype_test, "%s key:0x", msg); for (i = 0; i < sizeof(struct flow_key); i++) - printf("%02X", p[i]); + rte_log(RTE_LOG_DEBUG, efd_logtype_test, "%02X", p[i]); - printf(" @ val %d\n", val); + rte_log(RTE_LOG_DEBUG, efd_logtype_test, " @ val %d\n", val); } -#else - -static void print_key_info(__attribute__((unused)) const char *msg, - __attribute__((unused)) const struct flow_key *key, - __attribute__((unused)) efd_value_t val) -{ -} -#endif /* Keys used by unit test functions */ static struct flow_key keys[5] = { { - .ip_src = IPv4(0x03, 0x02, 0x01, 0x00), - .ip_dst = IPv4(0x07, 0x06, 0x05, 0x04), + .ip_src = RTE_IPv4(0x03, 0x02, 0x01, 0x00), + .ip_dst = RTE_IPv4(0x07, 0x06, 0x05, 0x04), .port_src = 0x0908, .port_dst = 0x0b0a, .proto = 0x0c, }, { - .ip_src = IPv4(0x13, 0x12, 0x11, 0x10), - .ip_dst = IPv4(0x17, 0x16, 0x15, 0x14), + .ip_src = RTE_IPv4(0x13, 0x12, 0x11, 0x10), + .ip_dst = RTE_IPv4(0x17, 0x16, 0x15, 0x14), .port_src = 0x1918, .port_dst = 0x1b1a, .proto = 0x1c, }, { - .ip_src = IPv4(0x23, 0x22, 0x21, 0x20), - .ip_dst = IPv4(0x27, 0x26, 0x25, 0x24), + .ip_src = RTE_IPv4(0x23, 0x22, 0x21, 0x20), + .ip_dst = RTE_IPv4(0x27, 0x26, 0x25, 0x24), .port_src = 0x2928, .port_dst = 0x2b2a, .proto = 0x2c, }, { - .ip_src = IPv4(0x33, 0x32, 0x31, 0x30), - .ip_dst = IPv4(0x37, 0x36, 0x35, 0x34), + .ip_src = RTE_IPv4(0x33, 0x32, 0x31, 0x30), + .ip_dst = RTE_IPv4(0x37, 0x36, 0x35, 0x34), .port_src = 0x3938, .port_dst = 0x3b3a, .proto = 0x3c, }, { - .ip_src = IPv4(0x43, 0x42, 0x41, 0x40), - .ip_dst = IPv4(0x47, 0x46, 0x45, 0x44), + .ip_src = RTE_IPv4(0x43, 0x42, 0x41, 0x40), + .ip_dst = RTE_IPv4(0x47, 0x46, 0x45, 0x44), .port_src = 0x4948, .port_dst = 0x4b4a, .proto = 0x4c, @@ -154,7 +129,7 @@ static int test_add_delete(void) efd_get_all_sockets_bitmask(), test_socket_id); TEST_ASSERT_NOT_NULL(handle, "Error creating the EFD table\n"); - data[0] = mrand48() & ((1 << RTE_EFD_VALUE_NUM_BITS) - 1); + data[0] = mrand48() & VALUE_BITMASK; TEST_ASSERT_SUCCESS(rte_efd_update(handle, test_socket_id, &keys[0], data[0]), "Error inserting the key"); @@ -191,7 +166,7 @@ static int test_add_update_delete(void) printf("Entering %s\n", __func__); /* test with standard add/lookup/delete functions */ efd_value_t prev_value; - data[1] = mrand48() & ((1 << RTE_EFD_VALUE_NUM_BITS) - 1); + data[1] = mrand48() & VALUE_BITMASK; handle = rte_efd_create("test_add_update_delete", TABLE_SIZE, sizeof(struct flow_key), @@ -285,7 +260,7 @@ static int test_five_keys(void) /* Setup data */ for (i = 0; i < 5; i++) - data[i] = mrand48() & ((1 << RTE_EFD_VALUE_NUM_BITS) - 1); + data[i] = mrand48() & VALUE_BITMASK; /* Add */ for (i = 0; i < 5; i++) { @@ -300,7 +275,7 @@ static int test_five_keys(void) key_array[i] = &keys[i]; rte_efd_lookup_bulk(handle, test_socket_id, 5, - (const void **) (void *) &key_array, result); + (void *) &key_array, result); for (i = 0; i < 5; i++) { TEST_ASSERT_EQUAL(result[i], data[i],