diff options
author | Matias Elo <matias.elo@nokia.com> | 2022-06-30 16:51:26 +0300 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2022-06-30 16:51:26 +0300 |
commit | 82e9e506aafdc19ce069e9ae24013780e510d3dc (patch) | |
tree | 486d330973b9fa2dc5c43e442a3961b440e194e9 /test | |
parent | 58fe883d5e43dc315d4751433f73c5d8ed7e5ba7 (diff) | |
parent | 345263691c7e4a21dd24fecb4e387493c1f28854 (diff) |
Merge tag 'v1.37.1.0' of https://github.com/OpenDataPlane/odp into odp-dpdk
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/common/test_packet_ipv4.h | 50 | ||||
-rw-r--r-- | test/validation/api/classification/odp_classification_basic.c | 13 | ||||
-rw-r--r-- | test/validation/api/crypto/odp_crypto_test_inp.c | 43 | ||||
-rw-r--r-- | test/validation/api/dma/dma.c | 41 | ||||
-rw-r--r-- | test/validation/api/init/init_main.c | 19 | ||||
-rw-r--r-- | test/validation/api/ipsec/ipsec_test_out.c | 15 | ||||
-rw-r--r-- | test/validation/api/pktio/lso.c | 189 | ||||
-rw-r--r-- | test/validation/api/pktio/pktio.c | 16 | ||||
-rw-r--r-- | test/validation/api/pool/pool.c | 98 | ||||
-rw-r--r-- | test/validation/api/queue/queue.c | 90 | ||||
-rw-r--r-- | test/validation/api/scheduler/scheduler.c | 150 | ||||
-rw-r--r-- | test/validation/api/stash/stash.c | 12 | ||||
-rw-r--r-- | test/validation/api/timer/timer.c | 10 | ||||
-rw-r--r-- | test/validation/api/traffic_mngr/traffic_mngr.c | 31 |
14 files changed, 665 insertions, 112 deletions
diff --git a/test/common/test_packet_ipv4.h b/test/common/test_packet_ipv4.h index 2bccf7b5f..8dd98d60d 100644 --- a/test/common/test_packet_ipv4.h +++ b/test/common/test_packet_ipv4.h @@ -1,5 +1,5 @@ /* Copyright (c) 2017-2018, Linaro Limited - * Copyright (c) 2021, Nokia + * Copyright (c) 2021-2022, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -212,6 +212,54 @@ static const uint8_t test_packet_ipv4_rr_nop_icmp[] = { 0x00, 0x00 }; +/* Ethernet/IPv4/UDP packet. Ethernet frame length 325 bytes (+ CRC). + * - source IP addr: 192.168.1.2 + * - destination IP addr: 192.168.1.1 + */ +static const uint8_t test_packet_ipv4_udp_325[] = { + 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x04, 0x00, 0x08, 0x00, 0x45, 0x00, + 0x01, 0x37, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11, + 0xF6, 0x62, 0xC0, 0xA8, 0x01, 0x02, 0xC0, 0xA8, + 0x01, 0x01, 0x00, 0x3F, 0x00, 0x3F, 0x01, 0x23, + 0x02, 0xED, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, + 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, + 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, + 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, + 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, + 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, + 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, + 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, + 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, + 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, + 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, + 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, + 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, + 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, + 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, + 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, + 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, + 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, + 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, + 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, + 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, + 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, + 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, + 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, + 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, + 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, + 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, + 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, + 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, + 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, + 0xFE, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, + 0x16, 0x17, 0x18, 0x19, 0x1A +}; + /* Ethernet/IPv4/UDP packet. Ethernet frame length 1500 bytes (+ CRC). */ static const uint8_t test_packet_ipv4_udp_1500[] = { 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, diff --git a/test/validation/api/classification/odp_classification_basic.c b/test/validation/api/classification/odp_classification_basic.c index fb5ec4ed0..4fecba1e2 100644 --- a/test/validation/api/classification/odp_classification_basic.c +++ b/test/validation/api/classification/odp_classification_basic.c @@ -1,4 +1,5 @@ /* Copyright (c) 2015-2018, Linaro Limited + * Copyright (c) 2021-2022, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -10,23 +11,29 @@ #define PMR_SET_NUM 5 -static void classification_test_default_values(void) +static void test_defaults(uint8_t fill) { odp_cls_cos_param_t cos_param; odp_pmr_param_t pmr_param; - memset(&cos_param, 0x55, sizeof(cos_param)); + memset(&cos_param, fill, sizeof(cos_param)); odp_cls_cos_param_init(&cos_param); CU_ASSERT_EQUAL(cos_param.num_queue, 1); CU_ASSERT_EQUAL(cos_param.red.enable, false); CU_ASSERT_EQUAL(cos_param.bp.enable, false); CU_ASSERT_EQUAL(cos_param.vector.enable, false); - memset(&pmr_param, 0x55, sizeof(pmr_param)); + memset(&pmr_param, fill, sizeof(pmr_param)); odp_cls_pmr_param_init(&pmr_param); CU_ASSERT_EQUAL(pmr_param.range_term, false); } +static void classification_test_default_values(void) +{ + test_defaults(0); + test_defaults(0xff); +} + static void classification_test_create_cos(void) { odp_cos_t cos; diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index e3eff88b9..0112bf27a 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -28,11 +28,11 @@ struct suite_context_s { static struct suite_context_s suite_context; -static void test_default_values(void) +static void test_defaults(uint8_t fill) { odp_crypto_session_param_t param; - memset(¶m, 0x55, sizeof(param)); + memset(¶m, fill, sizeof(param)); odp_crypto_session_param_init(¶m); CU_ASSERT_EQUAL(param.op, ODP_CRYPTO_OP_ENCODE); @@ -55,6 +55,12 @@ static void test_default_values(void) #endif } +static void test_default_values(void) +{ + test_defaults(0); + test_defaults(0xff); +} + static int packet_cmp_mem_bits(odp_packet_t pkt, uint32_t offset, uint8_t *s, uint32_t len) { @@ -689,7 +695,8 @@ static odp_crypto_session_t session_create(odp_crypto_op_t op, * In some cases an individual algorithm cannot be used alone, * i.e. with the null cipher/auth algorithm. */ - if (rc == ODP_CRYPTO_SES_ERR_ALG_COMBO) { + if (rc < 0 && + status == ODP_CRYPTO_SES_ERR_ALG_COMBO) { printf("\n Unsupported algorithm combination: %s, %s\n", cipher_alg_name(cipher_alg), auth_alg_name(auth_alg)); @@ -1177,11 +1184,11 @@ static void test_capability(void) * operation with hash_result_offset outside the auth_range and by * copying the hash in the ciphertext packet. */ -static void create_hash_test_reference(odp_auth_alg_t auth, - const odp_crypto_auth_capability_t *capa, - crypto_test_reference_t *ref, - uint32_t digest_offset, - uint8_t digest_fill_byte) +static int create_hash_test_reference(odp_auth_alg_t auth, + const odp_crypto_auth_capability_t *capa, + crypto_test_reference_t *ref, + uint32_t digest_offset, + uint8_t digest_fill) { odp_crypto_session_t session; int rc; @@ -1209,7 +1216,7 @@ static void create_hash_test_reference(odp_auth_alg_t auth, fill_with_pattern(ref->auth_iv, ref->auth_iv_length); fill_with_pattern(ref->plaintext, auth_bytes); - memset(ref->plaintext + digest_offset, digest_fill_byte, ref->digest_length); + memset(ref->plaintext + digest_offset, digest_fill, ref->digest_length); pkt = odp_packet_alloc(suite_context.pool, auth_bytes + ref->digest_length); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); @@ -1219,12 +1226,12 @@ static void create_hash_test_reference(odp_auth_alg_t auth, session = session_create(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_NULL, auth, ref, PACKET_IV, HASH_NO_OVERLAP); + if (session == ODP_CRYPTO_SESSION_INVALID) + return -1; - if (crypto_op(pkt, &ok, session, - ref->cipher_iv, ref->auth_iv, - &cipher_range, &auth_range, - ref->aad, enc_digest_offset)) - return; + rc = crypto_op(pkt, &ok, session, ref->cipher_iv, ref->auth_iv, + &cipher_range, &auth_range, ref->aad, enc_digest_offset); + CU_ASSERT(rc == 0); CU_ASSERT(ok); rc = odp_crypto_session_destroy(session); @@ -1245,6 +1252,8 @@ static void create_hash_test_reference(odp_auth_alg_t auth, CU_ASSERT(rc == 0); odp_packet_free(pkt); + + return 0; } static void test_auth_hash_in_auth_range(odp_auth_alg_t auth, @@ -1257,7 +1266,8 @@ static void test_auth_hash_in_auth_range(odp_auth_alg_t auth, * Create test packets with auth hash in the authenticated range and * zeroes in the hash location in the plaintext packet. */ - create_hash_test_reference(auth, capa, &ref, digest_offset, 0); + if (create_hash_test_reference(auth, capa, &ref, digest_offset, 0)) + return; /* * Decode the ciphertext packet. @@ -1279,7 +1289,8 @@ static void test_auth_hash_in_auth_range(odp_auth_alg_t auth, * Create test packets with auth hash in the authenticated range and * ones in the hash location in the plaintext packet. */ - create_hash_test_reference(auth, capa, &ref, digest_offset, 1); + if (create_hash_test_reference(auth, capa, &ref, digest_offset, 1)) + return; /* * Encode the plaintext packet. diff --git a/test/validation/api/dma/dma.c b/test/validation/api/dma/dma.c index 4df81ca7a..8eb75b172 100644 --- a/test/validation/api/dma/dma.c +++ b/test/validation/api/dma/dma.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021, Nokia +/* Copyright (c) 2021-2022, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -199,33 +199,43 @@ static void test_dma_capability(void) } } -static void test_dma_param(void) +static void test_dma_param(uint8_t fill) { odp_dma_param_t dma_param; odp_dma_transfer_param_t trs_param; odp_dma_compl_param_t compl_param; odp_dma_pool_param_t dma_pool_param; + memset(&dma_param, fill, sizeof(dma_param)); odp_dma_param_init(&dma_param); CU_ASSERT(dma_param.direction == ODP_DMA_MAIN_TO_MAIN); CU_ASSERT(dma_param.type == ODP_DMA_TYPE_COPY); CU_ASSERT(dma_param.mt_mode == ODP_DMA_MT_SAFE); CU_ASSERT(dma_param.order == ODP_DMA_ORDER_NONE); + memset(&trs_param, fill, sizeof(trs_param)); odp_dma_transfer_param_init(&trs_param); CU_ASSERT(trs_param.src_format == ODP_DMA_FORMAT_ADDR); CU_ASSERT(trs_param.dst_format == ODP_DMA_FORMAT_ADDR); CU_ASSERT(trs_param.num_src == 1); CU_ASSERT(trs_param.num_dst == 1); + memset(&compl_param, fill, sizeof(compl_param)); odp_dma_compl_param_init(&compl_param); CU_ASSERT(compl_param.user_ptr == NULL); + memset(&dma_pool_param, fill, sizeof(dma_pool_param)); odp_dma_pool_param_init(&dma_pool_param); CU_ASSERT(dma_pool_param.cache_size <= global.dma_capa.pool.max_cache_size); CU_ASSERT(dma_pool_param.cache_size >= global.dma_capa.pool.min_cache_size); } +static void test_dma_param_init(void) +{ + test_dma_param(0); + test_dma_param(0xff); +} + static void test_dma_debug(void) { odp_dma_param_t dma_param; @@ -284,6 +294,30 @@ static void test_dma_compl_pool(void) odp_dma_compl_free(compl); } +static void test_dma_compl_pool_same_name(void) +{ + odp_dma_pool_param_t dma_pool_param; + odp_pool_t pool, pool_a, pool_b; + const char *name = COMPL_POOL_NAME; + + pool_a = global.compl_pool; + + pool = odp_pool_lookup(name); + CU_ASSERT(pool == pool_a); + + odp_dma_pool_param_init(&dma_pool_param); + dma_pool_param.num = NUM_COMPL; + + /* Second pool with the same name */ + pool_b = odp_dma_pool_create(name, &dma_pool_param); + CU_ASSERT_FATAL(pool_b != ODP_POOL_INVALID); + + pool = odp_pool_lookup(name); + CU_ASSERT(pool == pool_a || pool == pool_b); + + CU_ASSERT_FATAL(odp_pool_destroy(pool_b) == 0); +} + static void init_source(uint8_t *src, uint32_t len) { uint32_t i; @@ -1139,9 +1173,10 @@ static void test_dma_multi_pkt_to_pkt_event(void) odp_testinfo_t dma_suite[] = { ODP_TEST_INFO(test_dma_capability), - ODP_TEST_INFO_CONDITIONAL(test_dma_param, check_sync), + ODP_TEST_INFO_CONDITIONAL(test_dma_param_init, check_sync), ODP_TEST_INFO_CONDITIONAL(test_dma_debug, check_sync), ODP_TEST_INFO_CONDITIONAL(test_dma_compl_pool, check_event), + ODP_TEST_INFO_CONDITIONAL(test_dma_compl_pool_same_name, check_event), ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_sync, check_sync), ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_sync_mtrs, check_sync), ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_sync_mseg, check_sync), diff --git a/test/validation/api/init/init_main.c b/test/validation/api/init/init_main.c index f1716db25..f8fd96aeb 100644 --- a/test/validation/api/init/init_main.c +++ b/test/validation/api/init/init_main.c @@ -1,5 +1,5 @@ /* Copyright (c) 2015-2018, Linaro Limited - * Copyright (c) 2019-2021, Nokia + * Copyright (c) 2019-2022, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -48,6 +48,22 @@ static int my_log_thread_func(odp_log_level_t level, const char *fmt, ...) return 0; } +static void test_param_init(uint8_t fill) +{ + odp_init_t param; + + memset(¶m, fill, sizeof(param)); + odp_init_param_init(¶m); + CU_ASSERT(param.mem_model == ODP_MEM_MODEL_THREAD); + CU_ASSERT(param.shm.max_memory == 0); +} + +static void init_test_param_init(void) +{ + test_param_init(0); + test_param_init(0xff); +} + static void init_test_defaults(void) { int ret; @@ -226,6 +242,7 @@ static void init_test_feature_disabled(void) } odp_testinfo_t testinfo[] = { + ODP_TEST_INFO(init_test_param_init), ODP_TEST_INFO(init_test_defaults), ODP_TEST_INFO(init_test_abort), ODP_TEST_INFO(init_test_log), diff --git a/test/validation/api/ipsec/ipsec_test_out.c b/test/validation/api/ipsec/ipsec_test_out.c index 4e3230844..9604e65e8 100644 --- a/test/validation/api/ipsec/ipsec_test_out.c +++ b/test/validation/api/ipsec/ipsec_test_out.c @@ -1,6 +1,6 @@ /* Copyright (c) 2017-2018, Linaro Limited * Copyright (c) 2020, Marvell - * Copyright (c) 2020-2021, Nokia + * Copyright (c) 2020-2022, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -1598,14 +1598,12 @@ static void ipsec_test_capability(void) CU_ASSERT(odp_ipsec_capability(&capa) == 0); } -static void ipsec_test_default_values(void) +static void test_defaults(uint8_t fill) { odp_ipsec_config_t config; odp_ipsec_sa_param_t sa_param; - memset(&config, 0x55, sizeof(config)); - memset(&sa_param, 0x55, sizeof(sa_param)); - + memset(&config, fill, sizeof(config)); odp_ipsec_config_init(&config); CU_ASSERT(config.inbound.lookup.min_spi == 0); CU_ASSERT(config.inbound.lookup.max_spi == UINT32_MAX); @@ -1623,6 +1621,7 @@ static void ipsec_test_default_values(void) CU_ASSERT(!config.stats_en); CU_ASSERT(!config.vector.enable); + memset(&sa_param, fill, sizeof(sa_param)); odp_ipsec_sa_param_init(&sa_param); CU_ASSERT(sa_param.proto == ODP_IPSEC_ESP); CU_ASSERT(sa_param.crypto.cipher_alg == ODP_CIPHER_ALG_NULL); @@ -1654,6 +1653,12 @@ static void ipsec_test_default_values(void) CU_ASSERT(sa_param.outbound.frag_mode == ODP_IPSEC_FRAG_DISABLED); } +static void ipsec_test_default_values(void) +{ + test_defaults(0); + test_defaults(0xff); +} + static void test_ipsec_stats(void) { ipsec_test_flags flags; diff --git a/test/validation/api/pktio/lso.c b/test/validation/api/pktio/lso.c index bde94816e..3e033ee8b 100644 --- a/test/validation/api/pktio/lso.c +++ b/test/validation/api/pktio/lso.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2020, Nokia +/* Copyright (c) 2020-2022, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -20,10 +20,6 @@ /* Maximum number of segments test is prepared to receive per outgoing packet */ #define MAX_NUM_SEG 256 -/* Max payload bytes per LSO segment */ -#define CUSTOM_MAX_PAYLOAD 288 -#define IPV4_MAX_PAYLOAD 700 - /* Pktio interface info */ typedef struct { @@ -59,6 +55,8 @@ odp_pool_t lso_pool = ODP_POOL_INVALID; /* Check test packet size */ ODP_STATIC_ASSERT(sizeof(test_packet_ipv4_udp_1500) == 1500, "error: size is not 1500"); +ODP_STATIC_ASSERT(sizeof(test_packet_ipv4_udp_325) == 325, "error: size is not 325"); +ODP_STATIC_ASSERT(sizeof(test_packet_custom_eth_1) == 723, "error: size is not 723"); static inline void wait_linkup(odp_pktio_t pktio) { @@ -465,11 +463,14 @@ static int check_lso_custom(void) return ODP_TEST_ACTIVE; } -static int check_lso_custom_restart(void) +static int check_lso_custom_segs(uint32_t num) { if (check_lso_custom() == ODP_TEST_INACTIVE) return ODP_TEST_INACTIVE; + if (num > pktio_a->capa.lso.max_segments) + return ODP_TEST_INACTIVE; + if (disable_restart && num_starts > 0) return ODP_TEST_INACTIVE; @@ -479,6 +480,21 @@ static int check_lso_custom_restart(void) return ODP_TEST_ACTIVE; } +static int check_lso_custom_segs_1(void) +{ + return check_lso_custom_segs(1); +} + +static int check_lso_custom_segs_2(void) +{ + return check_lso_custom_segs(2); +} + +static int check_lso_custom_segs_3(void) +{ + return check_lso_custom_segs(3); +} + static int check_lso_ipv4(void) { if (pktio_a->capa.lso.max_profiles == 0 || pktio_a->capa.lso.max_profiles_per_pktio == 0) @@ -490,11 +506,14 @@ static int check_lso_ipv4(void) return ODP_TEST_ACTIVE; } -static int check_lso_ipv4_restart(void) +static int check_lso_ipv4_segs(uint32_t num) { if (check_lso_ipv4() == ODP_TEST_INACTIVE) return ODP_TEST_INACTIVE; + if (num > pktio_a->capa.lso.max_segments) + return ODP_TEST_INACTIVE; + if (disable_restart && num_starts > 0) return ODP_TEST_INACTIVE; @@ -503,6 +522,21 @@ static int check_lso_ipv4_restart(void) return ODP_TEST_ACTIVE; } +static int check_lso_ipv4_segs_1(void) +{ + return check_lso_ipv4_segs(1); +} + +static int check_lso_ipv4_segs_2(void) +{ + return check_lso_ipv4_segs(2); +} + +static int check_lso_ipv4_segs_3(void) +{ + return check_lso_ipv4_segs(3); +} + static void lso_capability(void) { /* LSO not supported when max_profiles is zero */ @@ -620,7 +654,8 @@ static void test_lso_request_clear(odp_lso_profile_t lso_profile, const uint8_t odp_packet_free(pkt); } -static void lso_send_custom_eth(int use_opt) +static void lso_send_custom_eth(const uint8_t *test_packet, uint32_t pkt_len, uint32_t max_payload, + int use_opt) { int i, ret, num; odp_lso_profile_param_t param; @@ -632,9 +667,7 @@ static void lso_send_custom_eth(int use_opt) uint32_t hdr_len = 22; /* Offset to "segment number" field */ uint32_t segnum_offset = 16; - uint32_t pkt_len = sizeof(test_packet_custom_eth_1); uint32_t sent_payload = pkt_len - hdr_len; - uint32_t max_payload = CUSTOM_MAX_PAYLOAD; odp_lso_profile_param_init(¶m); param.lso_proto = ODP_LSO_PROTO_CUSTOM; @@ -648,10 +681,10 @@ static void lso_send_custom_eth(int use_opt) CU_ASSERT_FATAL(start_interfaces() == 0); - test_lso_request_clear(profile, test_packet_custom_eth_1, pkt_len, hdr_len, max_payload); + test_lso_request_clear(profile, test_packet, pkt_len, hdr_len, max_payload); - ret = send_packets(profile, pktio_a, pktio_b, test_packet_custom_eth_1, - pkt_len, hdr_len, max_payload, 0, use_opt); + ret = send_packets(profile, pktio_a, pktio_b, test_packet, pkt_len, hdr_len, + max_payload, 0, use_opt); CU_ASSERT_FATAL(ret == 0); ODPH_DBG("\n Sent payload length: %u bytes\n", sent_payload); @@ -686,7 +719,7 @@ static void lso_send_custom_eth(int use_opt) ODPH_DBG(" LSO segment[%u] payload: %u bytes\n", segnum, payload_len); - CU_ASSERT(payload_len <= CUSTOM_MAX_PAYLOAD); + CU_ASSERT(payload_len <= max_payload); if (compare_data(pkt_out[i], hdr_len, test_packet_custom_eth_1 + offset, payload_len) >= 0) { @@ -710,17 +743,51 @@ static void lso_send_custom_eth(int use_opt) CU_ASSERT_FATAL(odp_lso_profile_destroy(profile) == 0); } -static void lso_send_custom_eth_use_pkt_meta(void) +static void lso_send_custom_eth_723(uint32_t max_payload, int use_opt) { - lso_send_custom_eth(0); + uint32_t pkt_len = sizeof(test_packet_custom_eth_1); + + if (max_payload > pktio_a->capa.lso.max_payload_len) + max_payload = pktio_a->capa.lso.max_payload_len; + + lso_send_custom_eth(test_packet_custom_eth_1, pkt_len, max_payload, use_opt); +} + +/* No segmentation needed: packet size 723 bytes, LSO segment payload 800 bytes */ +static void lso_send_custom_eth_723_800_pkt_meta(void) +{ + lso_send_custom_eth_723(800, 0); } -static void lso_send_custom_eth_use_opt(void) +static void lso_send_custom_eth_723_800_opt(void) { - lso_send_custom_eth(1); + lso_send_custom_eth_723(800, 1); } -static void lso_send_ipv4(int use_opt) +/* At least 2 segments: packet size 723 bytes, LSO segment payload 500 bytes */ +static void lso_send_custom_eth_723_500_pkt_meta(void) +{ + lso_send_custom_eth_723(500, 0); +} + +static void lso_send_custom_eth_723_500_opt(void) +{ + lso_send_custom_eth_723(500, 1); +} + +/* At least 3 segments: packet size 723 bytes, LSO segment payload 288 bytes */ +static void lso_send_custom_eth_723_288_pkt_meta(void) +{ + lso_send_custom_eth_723(288, 0); +} + +static void lso_send_custom_eth_723_288_opt(void) +{ + lso_send_custom_eth_723(288, 1); +} + +static void lso_send_ipv4(const uint8_t *test_packet, uint32_t pkt_len, uint32_t max_payload, + int use_opt) { int i, ret, num; odp_lso_profile_param_t param; @@ -729,9 +796,7 @@ static void lso_send_ipv4(int use_opt) odp_packet_t packet[MAX_NUM_SEG]; /* Ethernet 14B + IPv4 header 20B */ uint32_t hdr_len = 34; - uint32_t pkt_len = sizeof(test_packet_ipv4_udp_1500); uint32_t sent_payload = pkt_len - hdr_len; - uint32_t max_payload = IPV4_MAX_PAYLOAD; odp_lso_profile_param_init(¶m); param.lso_proto = ODP_LSO_PROTO_IPV4; @@ -741,10 +806,10 @@ static void lso_send_ipv4(int use_opt) CU_ASSERT_FATAL(start_interfaces() == 0); - test_lso_request_clear(profile, test_packet_ipv4_udp_1500, pkt_len, hdr_len, max_payload); + test_lso_request_clear(profile, test_packet, pkt_len, hdr_len, max_payload); - ret = send_packets(profile, pktio_a, pktio_b, test_packet_ipv4_udp_1500, - pkt_len, hdr_len, max_payload, 14, use_opt); + ret = send_packets(profile, pktio_a, pktio_b, test_packet, pkt_len, + hdr_len, max_payload, 14, use_opt); CU_ASSERT_FATAL(ret == 0); ODPH_DBG("\n Sent payload length: %u bytes\n", sent_payload); @@ -773,12 +838,13 @@ static void lso_send_ipv4(int use_opt) ODPH_DBG(" LSO segment[%i] payload: %u bytes\n", i, payload_len); - CU_ASSERT(odp_packet_has_ipfrag(packet[i])); CU_ASSERT(odp_packet_has_error(packet[i]) == 0); - CU_ASSERT(payload_len <= IPV4_MAX_PAYLOAD); + CU_ASSERT(payload_len <= max_payload); - if (compare_data(packet[i], hdr_len, - test_packet_ipv4_udp_1500 + offset, payload_len) >= 0) { + if (pkt_len > max_payload) + CU_ASSERT(odp_packet_has_ipfrag(packet[i])); + + if (compare_data(packet[i], hdr_len, test_packet + offset, payload_len) >= 0) { ODPH_ERR(" Payload compare failed at offset %u\n", offset); CU_FAIL("Payload compare failed\n"); } @@ -799,23 +865,74 @@ static void lso_send_ipv4(int use_opt) CU_ASSERT_FATAL(odp_lso_profile_destroy(profile) == 0); } -static void lso_send_ipv4_use_pkt_meta(void) +static void lso_send_ipv4_udp_325(uint32_t max_payload, int use_opt) +{ + uint32_t pkt_len = sizeof(test_packet_ipv4_udp_325); + + if (max_payload > pktio_a->capa.lso.max_payload_len) + max_payload = pktio_a->capa.lso.max_payload_len; + + lso_send_ipv4(test_packet_ipv4_udp_325, pkt_len, max_payload, use_opt); +} + +static void lso_send_ipv4_udp_1500(uint32_t max_payload, int use_opt) +{ + uint32_t pkt_len = sizeof(test_packet_ipv4_udp_1500); + + if (max_payload > pktio_a->capa.lso.max_payload_len) + max_payload = pktio_a->capa.lso.max_payload_len; + + lso_send_ipv4(test_packet_ipv4_udp_1500, pkt_len, max_payload, use_opt); +} + +/* No segmentation needed: packet size 325 bytes, LSO segment payload 700 bytes */ +static void lso_send_ipv4_325_700_pkt_meta(void) +{ + lso_send_ipv4_udp_325(700, 0); +} + +static void lso_send_ipv4_325_700_opt(void) +{ + lso_send_ipv4_udp_325(700, 1); +} + +/* At least 2 segments: packet size 1500 bytes, LSO segment payload 1000 bytes */ +static void lso_send_ipv4_1500_1000_pkt_meta(void) +{ + lso_send_ipv4_udp_1500(1000, 0); +} + +static void lso_send_ipv4_1500_1000_opt(void) +{ + lso_send_ipv4_udp_1500(1000, 1); +} + +/* At least 3 segments: packet size 1500 bytes, LSO segment payload 700 bytes */ +static void lso_send_ipv4_1500_700_pkt_meta(void) { - lso_send_ipv4(0); + lso_send_ipv4_udp_1500(700, 0); } -static void lso_send_ipv4_use_opt(void) +static void lso_send_ipv4_1500_700_opt(void) { - lso_send_ipv4(1); + lso_send_ipv4_udp_1500(700, 1); } odp_testinfo_t lso_suite[] = { ODP_TEST_INFO(lso_capability), ODP_TEST_INFO_CONDITIONAL(lso_create_ipv4_profile, check_lso_ipv4), ODP_TEST_INFO_CONDITIONAL(lso_create_custom_profile, check_lso_custom), - ODP_TEST_INFO_CONDITIONAL(lso_send_ipv4_use_pkt_meta, check_lso_ipv4_restart), - ODP_TEST_INFO_CONDITIONAL(lso_send_ipv4_use_opt, check_lso_ipv4_restart), - ODP_TEST_INFO_CONDITIONAL(lso_send_custom_eth_use_pkt_meta, check_lso_custom_restart), - ODP_TEST_INFO_CONDITIONAL(lso_send_custom_eth_use_opt, check_lso_custom_restart), + ODP_TEST_INFO_CONDITIONAL(lso_send_ipv4_325_700_pkt_meta, check_lso_ipv4_segs_1), + ODP_TEST_INFO_CONDITIONAL(lso_send_ipv4_325_700_opt, check_lso_ipv4_segs_1), + ODP_TEST_INFO_CONDITIONAL(lso_send_ipv4_1500_1000_pkt_meta, check_lso_ipv4_segs_2), + ODP_TEST_INFO_CONDITIONAL(lso_send_ipv4_1500_1000_opt, check_lso_ipv4_segs_2), + ODP_TEST_INFO_CONDITIONAL(lso_send_ipv4_1500_700_pkt_meta, check_lso_ipv4_segs_3), + ODP_TEST_INFO_CONDITIONAL(lso_send_ipv4_1500_700_opt, check_lso_ipv4_segs_3), + ODP_TEST_INFO_CONDITIONAL(lso_send_custom_eth_723_800_pkt_meta, check_lso_custom_segs_1), + ODP_TEST_INFO_CONDITIONAL(lso_send_custom_eth_723_800_opt, check_lso_custom_segs_1), + ODP_TEST_INFO_CONDITIONAL(lso_send_custom_eth_723_500_pkt_meta, check_lso_custom_segs_2), + ODP_TEST_INFO_CONDITIONAL(lso_send_custom_eth_723_500_opt, check_lso_custom_segs_2), + ODP_TEST_INFO_CONDITIONAL(lso_send_custom_eth_723_288_pkt_meta, check_lso_custom_segs_3), + ODP_TEST_INFO_CONDITIONAL(lso_send_custom_eth_723_288_opt, check_lso_custom_segs_3), ODP_TEST_INFO_NULL }; diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c index d3ce41a2c..9a33fd983 100644 --- a/test/validation/api/pktio/pktio.c +++ b/test/validation/api/pktio/pktio.c @@ -1578,19 +1578,19 @@ static void pktio_test_mac(void) CU_ASSERT(0 == ret); } -static void pktio_test_default_values(void) +static void test_defaults(uint8_t fill) { odp_pktio_param_t pktio_p; odp_pktin_queue_param_t qp_in; odp_pktout_queue_param_t qp_out; odp_pktio_config_t pktio_conf; - memset(&pktio_p, 0x55, sizeof(pktio_p)); + memset(&pktio_p, fill, sizeof(pktio_p)); odp_pktio_param_init(&pktio_p); CU_ASSERT_EQUAL(pktio_p.in_mode, ODP_PKTIN_MODE_DIRECT); CU_ASSERT_EQUAL(pktio_p.out_mode, ODP_PKTOUT_MODE_DIRECT); - memset(&qp_in, 0x55, sizeof(qp_in)); + memset(&qp_in, fill, sizeof(qp_in)); odp_pktin_queue_param_init(&qp_in); CU_ASSERT_EQUAL(qp_in.op_mode, ODP_PKTIO_OP_MT); CU_ASSERT_EQUAL(qp_in.classifier_enable, 0); @@ -1609,13 +1609,13 @@ static void pktio_test_default_values(void) CU_ASSERT_EQUAL(qp_in.queue_param_ovr, NULL); CU_ASSERT_EQUAL(qp_in.vector.enable, false); - memset(&qp_out, 0x55, sizeof(qp_out)); + memset(&qp_out, fill, sizeof(qp_out)); odp_pktout_queue_param_init(&qp_out); CU_ASSERT_EQUAL(qp_out.op_mode, ODP_PKTIO_OP_MT); CU_ASSERT_EQUAL(qp_out.num_queues, 1); CU_ASSERT_EQUAL(qp_out.queue_size[0], 0); - memset(&pktio_conf, 0x55, sizeof(pktio_conf)); + memset(&pktio_conf, fill, sizeof(pktio_conf)); odp_pktio_config_init(&pktio_conf); CU_ASSERT_EQUAL(pktio_conf.pktin.all_bits, 0); CU_ASSERT_EQUAL(pktio_conf.pktout.all_bits, 0); @@ -1630,6 +1630,12 @@ static void pktio_test_default_values(void) CU_ASSERT_EQUAL(pktio_conf.reassembly.max_num_frags, 2); } +static void pktio_test_default_values(void) +{ + test_defaults(0); + test_defaults(0xff); +} + static void pktio_test_open(void) { odp_pktio_t pktio; diff --git a/test/validation/api/pool/pool.c b/test/validation/api/pool/pool.c index 8dad89d81..3befe4939 100644 --- a/test/validation/api/pool/pool.c +++ b/test/validation/api/pool/pool.c @@ -42,10 +42,11 @@ static odp_pool_capability_t global_pool_capa; static odp_pool_param_t default_pool_param; static odp_pool_ext_capability_t global_pool_ext_capa; -static void pool_test_param_init(void) +static void test_param_init(uint8_t fill) { odp_pool_param_t param; + memset(¶m, fill, sizeof(param)); odp_pool_param_init(¶m); CU_ASSERT(param.buf.cache_size >= global_pool_capa.buf.min_cache_size && @@ -63,6 +64,12 @@ static void pool_test_param_init(void) param.vector.cache_size <= global_pool_capa.vector.max_cache_size); } +static void pool_test_param_init(void) +{ + test_param_init(0); + test_param_init(0xff); +} + static void pool_create_destroy(odp_pool_param_t *param) { odp_pool_t pool; @@ -166,6 +173,79 @@ static void pool_test_lookup_info_print(void) CU_ASSERT(odp_pool_destroy(pool) == 0); } +static void pool_test_same_name(const odp_pool_param_t *param) +{ + odp_pool_t pool, pool_a, pool_b; + const char *name = "same_name"; + + pool_a = odp_pool_create(name, param); + CU_ASSERT_FATAL(pool_a != ODP_POOL_INVALID); + + pool = odp_pool_lookup(name); + CU_ASSERT(pool == pool_a); + + /* Second pool with the same name */ + pool_b = odp_pool_create(name, param); + CU_ASSERT_FATAL(pool_b != ODP_POOL_INVALID); + + pool = odp_pool_lookup(name); + CU_ASSERT(pool == pool_a || pool == pool_b); + + CU_ASSERT(odp_pool_destroy(pool_a) == 0); + CU_ASSERT(odp_pool_destroy(pool_b) == 0); +} + +static void pool_test_same_name_buf(void) +{ + odp_pool_param_t param; + + odp_pool_param_init(¶m); + + param.type = ODP_POOL_BUFFER; + param.buf.size = BUF_SIZE; + param.buf.num = BUF_NUM; + + pool_test_same_name(¶m); +} + +static void pool_test_same_name_pkt(void) +{ + odp_pool_param_t param; + + odp_pool_param_init(¶m); + + param.type = ODP_POOL_PACKET; + param.pkt.len = PKT_LEN; + param.pkt.num = PKT_NUM; + + pool_test_same_name(¶m); +} + +static void pool_test_same_name_tmo(void) +{ + odp_pool_param_t param; + + odp_pool_param_init(¶m); + + param.type = ODP_POOL_TIMEOUT; + param.tmo.num = TMO_NUM; + + pool_test_same_name(¶m); +} + +static void pool_test_same_name_vec(void) +{ + odp_pool_param_t param; + + odp_pool_param_init(¶m); + + param.type = ODP_POOL_VECTOR; + param.vector.num = 10; + param.vector.max_size = 2; + + pool_test_same_name(¶m); +} + static void alloc_buffer(uint32_t cache_size) { odp_pool_t pool; @@ -1291,13 +1371,13 @@ static void test_packet_pool_ext_capa(void) CU_ASSERT(capa.pkt.max_headroom_size > 0); CU_ASSERT(capa.pkt.max_headroom_size >= capa.pkt.max_headroom); CU_ASSERT(capa.pkt.max_segs_per_pkt > 0); - CU_ASSERT(capa.pkt.max_uarea_size > 0); } -static void test_packet_pool_ext_param_init(void) +static void test_ext_param_init(uint8_t fill) { odp_pool_ext_param_t param; + memset(¶m, fill, sizeof(param)); odp_pool_ext_param_init(ODP_POOL_PACKET, ¶m); CU_ASSERT(param.type == ODP_POOL_PACKET); @@ -1308,6 +1388,12 @@ static void test_packet_pool_ext_param_init(void) CU_ASSERT(param.pkt.uarea_size == 0); } +static void test_packet_pool_ext_param_init(void) +{ + test_ext_param_init(0); + test_ext_param_init(0xff); +} + static void test_packet_pool_ext_create(void) { odp_pool_t pool; @@ -1763,6 +1849,11 @@ odp_testinfo_t pool_suite[] = { ODP_TEST_INFO(pool_test_create_destroy_packet), ODP_TEST_INFO(pool_test_create_destroy_timeout), ODP_TEST_INFO(pool_test_create_destroy_vector), + ODP_TEST_INFO(pool_test_lookup_info_print), + ODP_TEST_INFO(pool_test_same_name_buf), + ODP_TEST_INFO(pool_test_same_name_pkt), + ODP_TEST_INFO(pool_test_same_name_tmo), + ODP_TEST_INFO(pool_test_same_name_vec), ODP_TEST_INFO(pool_test_alloc_buffer), ODP_TEST_INFO(pool_test_alloc_buffer_min_cache), ODP_TEST_INFO(pool_test_alloc_buffer_max_cache), @@ -1777,7 +1868,6 @@ odp_testinfo_t pool_suite[] = { ODP_TEST_INFO(pool_test_alloc_timeout_min_cache), ODP_TEST_INFO(pool_test_alloc_timeout_max_cache), ODP_TEST_INFO(pool_test_info_packet), - ODP_TEST_INFO(pool_test_lookup_info_print), ODP_TEST_INFO(pool_test_info_data_range), ODP_TEST_INFO(pool_test_buf_max_num), ODP_TEST_INFO(pool_test_pkt_max_num), diff --git a/test/validation/api/queue/queue.c b/test/validation/api/queue/queue.c index ec6863628..cd5e030d3 100644 --- a/test/validation/api/queue/queue.c +++ b/test/validation/api/queue/queue.c @@ -1,5 +1,5 @@ /* Copyright (c) 2014-2018, Linaro Limited - * Copyright (c) 2021, Nokia + * Copyright (c) 2021-2022, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -134,6 +134,32 @@ static void queue_test_capa(void) CU_ASSERT(capa.max_queues >= capa.plain.waitfree.max_num); } +static void test_defaults(uint8_t fill) +{ + odp_queue_param_t param; + + memset(¶m, fill, sizeof(param)); + odp_queue_param_init(¶m); + CU_ASSERT(param.type == ODP_QUEUE_TYPE_PLAIN); + CU_ASSERT(param.enq_mode == ODP_QUEUE_OP_MT); + CU_ASSERT(param.deq_mode == ODP_QUEUE_OP_MT); + CU_ASSERT(param.sched.prio == odp_schedule_default_prio()); + CU_ASSERT(param.sched.sync == ODP_SCHED_SYNC_PARALLEL); + CU_ASSERT(param.sched.group == ODP_SCHED_GROUP_ALL); + CU_ASSERT(param.sched.lock_count == 0); + CU_ASSERT(param.order == ODP_QUEUE_ORDER_KEEP); + CU_ASSERT(param.nonblocking == ODP_BLOCKING); + CU_ASSERT(param.context == NULL); + CU_ASSERT(param.context_len == 0); + CU_ASSERT(param.size == 0); +} + +static void queue_test_param_init(void) +{ + test_defaults(0); + test_defaults(0xff); +} + static void queue_test_max_plain(void) { odp_queue_capability_t capa; @@ -607,20 +633,7 @@ static void queue_test_param(void) odp_queue_param_t qparams; odp_buffer_t enbuf; - /* Defaults */ odp_queue_param_init(&qparams); - CU_ASSERT(qparams.type == ODP_QUEUE_TYPE_PLAIN); - CU_ASSERT(qparams.enq_mode == ODP_QUEUE_OP_MT); - CU_ASSERT(qparams.deq_mode == ODP_QUEUE_OP_MT); - CU_ASSERT(qparams.sched.prio == odp_schedule_default_prio()); - CU_ASSERT(qparams.sched.sync == ODP_SCHED_SYNC_PARALLEL); - CU_ASSERT(qparams.sched.group == ODP_SCHED_GROUP_ALL); - CU_ASSERT(qparams.sched.lock_count == 0); - CU_ASSERT(qparams.order == ODP_QUEUE_ORDER_KEEP); - CU_ASSERT(qparams.nonblocking == ODP_BLOCKING); - CU_ASSERT(qparams.context == NULL); - CU_ASSERT(qparams.context_len == 0); - CU_ASSERT(qparams.size == 0); /* Schedule type queue */ qparams.type = ODP_QUEUE_TYPE_SCHED; @@ -714,6 +727,44 @@ static void queue_test_param(void) CU_ASSERT(odp_queue_destroy(queue) == 0); } +static void queue_test_same_name(int sched) +{ + odp_queue_t queue, queue_a, queue_b; + odp_queue_param_t param; + const char *name = "same_name"; + + odp_queue_param_init(¶m); + + if (sched) + param.type = ODP_QUEUE_TYPE_SCHED; + + queue_a = odp_queue_create(name, ¶m); + CU_ASSERT_FATAL(queue_a != ODP_QUEUE_INVALID); + + queue = odp_queue_lookup(name); + CU_ASSERT(queue == queue_a); + + /* Second queue with the same name */ + queue_b = odp_queue_create(name, ¶m); + CU_ASSERT_FATAL(queue_b != ODP_QUEUE_INVALID); + + queue = odp_queue_lookup(name); + CU_ASSERT(queue == queue_a || queue == queue_b); + + CU_ASSERT_FATAL(odp_queue_destroy(queue_a) == 0); + CU_ASSERT_FATAL(odp_queue_destroy(queue_b) == 0); +} + +static void queue_test_same_name_plain(void) +{ + queue_test_same_name(0); +} + +static void queue_test_same_name_sched(void) +{ + queue_test_same_name(1); +} + static void queue_test_info(void) { odp_queue_t q_plain, q_order; @@ -756,6 +807,10 @@ static void queue_test_info(void) CU_ASSERT(strcmp(nq_plain, info.name) == 0); CU_ASSERT(info.param.type == ODP_QUEUE_TYPE_PLAIN); CU_ASSERT(info.param.type == odp_queue_type(q_plain)); + CU_ASSERT(info.param.enq_mode == ODP_QUEUE_OP_MT); + CU_ASSERT(info.param.deq_mode == ODP_QUEUE_OP_MT); + CU_ASSERT(info.param.order == ODP_QUEUE_ORDER_KEEP); + CU_ASSERT(info.param.nonblocking == ODP_BLOCKING); ctx = info.param.context; /* 'char' context ptr */ CU_ASSERT(ctx == q_plain_ctx); CU_ASSERT(info.param.context == odp_queue_context(q_plain)); @@ -766,6 +821,10 @@ static void queue_test_info(void) CU_ASSERT(strcmp(nq_order, info.name) == 0); CU_ASSERT(info.param.type == ODP_QUEUE_TYPE_SCHED); CU_ASSERT(info.param.type == odp_queue_type(q_order)); + CU_ASSERT(info.param.enq_mode == ODP_QUEUE_OP_MT); + CU_ASSERT(info.param.deq_mode == ODP_QUEUE_OP_DISABLED); + CU_ASSERT(info.param.order == ODP_QUEUE_ORDER_KEEP); + CU_ASSERT(info.param.nonblocking == ODP_BLOCKING); ctx = info.param.context; /* 'char' context ptr */ CU_ASSERT(ctx == q_order_ctx); CU_ASSERT(info.param.context == odp_queue_context(q_order)); @@ -985,6 +1044,7 @@ static void queue_test_mt_plain_nonblock_lf(void) odp_testinfo_t queue_suite[] = { ODP_TEST_INFO(queue_test_capa), + ODP_TEST_INFO(queue_test_param_init), ODP_TEST_INFO(queue_test_mode), ODP_TEST_INFO(queue_test_max_plain), ODP_TEST_INFO(queue_test_burst), @@ -1004,6 +1064,8 @@ odp_testinfo_t queue_suite[] = { ODP_TEST_INFO(queue_test_pair_lf_mpsc), ODP_TEST_INFO(queue_test_pair_lf_spsc), ODP_TEST_INFO(queue_test_param), + ODP_TEST_INFO(queue_test_same_name_plain), + ODP_TEST_INFO(queue_test_same_name_sched), ODP_TEST_INFO(queue_test_info), ODP_TEST_INFO(queue_test_mt_plain_block), ODP_TEST_INFO(queue_test_mt_plain_nonblock_lf), diff --git a/test/validation/api/scheduler/scheduler.c b/test/validation/api/scheduler/scheduler.c index 490ac9fea..a9c94f5a8 100644 --- a/test/validation/api/scheduler/scheduler.c +++ b/test/validation/api/scheduler/scheduler.c @@ -89,6 +89,10 @@ typedef struct { odp_queue_t sched; odp_queue_t plain; } sched_and_plain_q; + struct { + odp_atomic_u32_t helper_ready; + odp_atomic_u32_t helper_active; + } order_wait; } test_globals_t; typedef struct { @@ -145,10 +149,11 @@ static void release_context(odp_schedule_sync_t sync) odp_schedule_release_ordered(); } -static void scheduler_test_init(void) +static void test_init(uint8_t fill) { odp_schedule_config_t default_config; + memset(&default_config, fill, sizeof(default_config)); odp_schedule_config_init(&default_config); CU_ASSERT(default_config.max_flow_id == 0); @@ -158,6 +163,12 @@ static void scheduler_test_init(void) CU_ASSERT(default_config.sched_group.worker); } +static void scheduler_test_init(void) +{ + test_init(0); + test_init(0xff); +} + static void scheduler_test_capa(void) { odp_schedule_capability_t sched_capa; @@ -2316,13 +2327,10 @@ static void enqueue_event(odp_queue_t queue) static void scheduler_test_order_wait_1_thread(void) { - odp_schedule_capability_t sched_capa; odp_queue_param_t queue_param; odp_queue_t queue; odp_event_t ev; - CU_ASSERT(!odp_schedule_capability(&sched_capa)); - sched_queue_param_init(&queue_param); queue_param.sched.sync = ODP_SCHED_SYNC_ORDERED; queue = odp_queue_create("ordered queue", &queue_param); @@ -2336,8 +2344,6 @@ static void scheduler_test_order_wait_1_thread(void) CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); odp_event_free(ev); - /* Fail build if the capability field does not exist */ - printf(" (capa=%d) ", sched_capa.order_wait); /* Check that order wait does not get stuck or crash */ odp_schedule_order_wait(); @@ -2348,6 +2354,137 @@ static void scheduler_test_order_wait_1_thread(void) CU_ASSERT(odp_queue_destroy(queue) == 0); } +static int order_wait_helper(void *arg ODP_UNUSED) +{ + odp_event_t ev; + + ev = odp_schedule(NULL, odp_schedule_wait_time(ODP_TIME_SEC_IN_NS)); + + if (ev != ODP_EVENT_INVALID) { + odp_event_free(ev); + + odp_atomic_store_rel_u32(&globals->order_wait.helper_active, 1); + odp_atomic_store_rel_u32(&globals->order_wait.helper_ready, 1); + + /* Wait that the main thread can attempt to overtake us */ + odp_time_wait_ns(ODP_TIME_SEC_IN_NS); + + odp_atomic_store_rel_u32(&globals->order_wait.helper_active, 0); + } + + /* We are not interested in further events */ + odp_schedule_pause(); + /* Release context */ + while ((ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT)) + != ODP_EVENT_INVALID) { + /* We got an event that was meant for the main thread */ + odp_event_free(ev); + } + + return 0; +} + +static void scheduler_test_order_wait_2_threads(void) +{ + odp_schedule_capability_t sched_capa; + odp_queue_param_t queue_param; + odp_queue_t queue; + pthrd_arg thr_arg = {.numthrds = 1}; + int ret; + odp_time_t start; + odp_event_t ev; + + CU_ASSERT(!odp_schedule_capability(&sched_capa)); + + sched_queue_param_init(&queue_param); + queue_param.sched.sync = ODP_SCHED_SYNC_ORDERED; + queue = odp_queue_create("ordered queue", &queue_param); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + CU_ASSERT_FATAL(odp_queue_type(queue) == ODP_QUEUE_TYPE_SCHED); + CU_ASSERT_FATAL(odp_queue_sched_type(queue) == ODP_SCHED_SYNC_ORDERED); + + odp_atomic_init_u32(&globals->order_wait.helper_ready, 0); + odp_atomic_init_u32(&globals->order_wait.helper_active, 0); + + ret = odp_cunit_thread_create(order_wait_helper, &thr_arg); + CU_ASSERT_FATAL(ret == thr_arg.numthrds); + + /* Send an event to the helper thread */ + enqueue_event(queue); + + /* Wait that the helper thread gets the event */ + start = odp_time_local(); + while (!odp_atomic_load_acq_u32(&globals->order_wait.helper_ready)) { + odp_time_t now = odp_time_local(); + + if (odp_time_diff_ns(now, start) > ODP_TIME_SEC_IN_NS) { + CU_FAIL("Timeout waiting for helper\n"); + break; + } + } + + /* Try to send an event to ourselves */ + enqueue_event(queue); + /* + * If ordered queues are implemented as atomic queues, the schedule + * call here will not return anything until the helper thread has + * released the scheduling context of the first event. So we have + * to wait long enough before giving up. + */ + ev = odp_schedule(NULL, odp_schedule_wait_time(2 * ODP_TIME_SEC_IN_NS)); + if (ev == ODP_EVENT_INVALID) { + /* Helper thread got the event. Give up. */ + printf("SKIPPED..."); + goto out; + } + odp_event_free(ev); + + /* + * We are now in an ordered scheduling context and behind the helper + * thread in source queue order if the helper thread has not released + * the scheuduling context. + */ + + if (!odp_atomic_load_acq_u32(&globals->order_wait.helper_active)) { + /* + * Helper thread has released the context already. + * We cannot test order wait fully. + */ + printf("reduced test..."); + } + + /* + * The function we are testing: Wait until there are no scheduling + * contexts that precede ours. + */ + odp_schedule_order_wait(); + + /* + * If order wait is supported, we are now first in the source queue + * order, so the helper thread must have released its context. + */ + if (sched_capa.order_wait) + CU_ASSERT(!odp_atomic_load_acq_u32(&globals->order_wait.helper_active)); + + /* Release the context */ + ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT); + CU_ASSERT(ev == ODP_EVENT_INVALID); + +out: + CU_ASSERT(odp_cunit_thread_exit(&thr_arg) == 0); + CU_ASSERT(odp_queue_destroy(queue) == 0); +} + +static int check_2_workers(void) +{ + if (globals->num_workers < 2) { + printf("\nTest: scheduler_test_order_wait_2_threads: SKIPPED\n"); + return ODP_TEST_INACTIVE; + } + + return ODP_TEST_ACTIVE; +} + static int sched_and_plain_thread(void *arg) { odp_event_t ev1, ev2; @@ -3278,6 +3415,7 @@ odp_testinfo_t scheduler_basic_suite[] = { ODP_TEST_INFO(scheduler_test_pause_enqueue), ODP_TEST_INFO(scheduler_test_ordered_lock), ODP_TEST_INFO(scheduler_test_order_wait_1_thread), + ODP_TEST_INFO_CONDITIONAL(scheduler_test_order_wait_2_threads, check_2_workers), ODP_TEST_INFO_CONDITIONAL(scheduler_test_flow_aware, check_flow_aware_support), ODP_TEST_INFO(scheduler_test_parallel), diff --git a/test/validation/api/stash/stash.c b/test/validation/api/stash/stash.c index 49da49dfd..4057156c7 100644 --- a/test/validation/api/stash/stash.c +++ b/test/validation/api/stash/stash.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2020-2021, Nokia +/* Copyright (c) 2020-2022, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -129,11 +129,11 @@ static void stash_capability(void) } } -static void stash_param_defaults(void) +static void param_defaults(uint8_t fill) { odp_stash_param_t param; - memset(¶m, 0xff, sizeof(odp_stash_param_t)); + memset(¶m, fill, sizeof(param)); odp_stash_param_init(¶m); CU_ASSERT(param.type == ODP_STASH_TYPE_DEFAULT); CU_ASSERT(param.put_mode == ODP_STASH_OP_MT); @@ -141,6 +141,12 @@ static void stash_param_defaults(void) CU_ASSERT(param.cache_size == 0); } +static void stash_param_defaults(void) +{ + param_defaults(0); + param_defaults(0xff); +} + static void stash_create_u64(void) { odp_stash_t stash, lookup; diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index ccfbf5558..00ef13c89 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -331,11 +331,11 @@ static void timer_test_capa(void) } } -static void timer_test_param_init(void) +static void test_param_init(uint8_t fill) { odp_timer_pool_param_t tp_param; - memset(&tp_param, 0x55, sizeof(odp_timer_pool_param_t)); + memset(&tp_param, fill, sizeof(tp_param)); odp_timer_pool_param_init(&tp_param); CU_ASSERT(tp_param.res_ns == 0); @@ -350,6 +350,12 @@ static void timer_test_param_init(void) CU_ASSERT(tp_param.periodic.base_freq_hz.denom == 0); } +static void timer_test_param_init(void) +{ + test_param_init(0); + test_param_init(0xff); +} + static void timer_test_timeout_pool_alloc(void) { odp_pool_t pool; diff --git a/test/validation/api/traffic_mngr/traffic_mngr.c b/test/validation/api/traffic_mngr/traffic_mngr.c index 65f91192c..0679e215c 100644 --- a/test/validation/api/traffic_mngr/traffic_mngr.c +++ b/test/validation/api/traffic_mngr/traffic_mngr.c @@ -471,7 +471,8 @@ static int test_overall_capabilities(void) return -1; } - if (per_level->tm_node_shaper_supported) { + if (per_level->tm_node_shaper_supported || + per_level->tm_node_rate_limiter_supported) { CU_ASSERT(per_level->max_burst > 0); CU_ASSERT(per_level->min_rate > 0); CU_ASSERT(per_level->max_rate > 0); @@ -1852,7 +1853,8 @@ set_reqs_based_on_capas(odp_tm_requirements_t *req) req->marking_colors_needed[color] = true; } - if (tm_capabilities.tm_queue_shaper_supported) + if (tm_capabilities.tm_queue_shaper_supported || + tm_capabilities.tm_queue_rate_limiter_supported) req->tm_queue_shaper_needed = true; /* We can use any packet priority mode since it does not affect @@ -4451,7 +4453,7 @@ static void test_packet_aging(uint64_t tmo_ns, uint32_t pkt_len, odp_bool_t is_d CU_ASSERT(odp_tm_is_idle(odp_tm_systems[0])); } -static void traffic_mngr_test_default_values(void) +static void test_defaults(uint8_t fill) { odp_tm_requirements_t req; odp_tm_shaper_params_t shaper; @@ -4462,7 +4464,7 @@ static void traffic_mngr_test_default_values(void) odp_tm_queue_params_t queue; int n; - memset(&req, 0xff, sizeof(req)); + memset(&req, fill, sizeof(req)); odp_tm_requirements_init(&req); CU_ASSERT_EQUAL(req.num_levels, 0); CU_ASSERT(!req.tm_queue_shaper_needed); @@ -4486,8 +4488,9 @@ static void traffic_mngr_test_default_values(void) CU_ASSERT(!l_req->tm_node_threshold_needed); } - memset(&shaper, 0xff, sizeof(shaper)); + memset(&shaper, fill, sizeof(shaper)); odp_tm_shaper_params_init(&shaper); + CU_ASSERT(shaper.packet_mode == ODP_TM_SHAPER_RATE_SHAPE); CU_ASSERT_EQUAL(shaper.shaper_len_adjust, 0); CU_ASSERT(!shaper.dual_rate); CU_ASSERT(!shaper.packet_mode); @@ -4497,24 +4500,24 @@ static void traffic_mngr_test_default_values(void) for (n = 0; n < ODP_TM_MAX_PRIORITIES; n++) CU_ASSERT_EQUAL(sched.sched_modes[n], ODP_TM_BYTE_BASED_WEIGHTS); - memset(&threshold, 0xff, sizeof(threshold)); + memset(&threshold, fill, sizeof(threshold)); odp_tm_threshold_params_init(&threshold); CU_ASSERT(!threshold.enable_max_pkts); CU_ASSERT(!threshold.enable_max_bytes); - memset(&wred, 0xff, sizeof(wred)); + memset(&wred, fill, sizeof(wred)); odp_tm_wred_params_init(&wred); CU_ASSERT(!wred.enable_wred); CU_ASSERT(!wred.use_byte_fullness); - memset(&node, 0xff, sizeof(node)); + memset(&node, fill, sizeof(node)); odp_tm_node_params_init(&node); CU_ASSERT_EQUAL(node.shaper_profile, ODP_TM_INVALID); CU_ASSERT_EQUAL(node.threshold_profile, ODP_TM_INVALID); for (n = 0; n < ODP_NUM_PACKET_COLORS; n++) CU_ASSERT_EQUAL(node.wred_profile[n], ODP_TM_INVALID); - memset(&queue, 0xff, sizeof(queue)); + memset(&queue, fill, sizeof(queue)); odp_tm_queue_params_init(&queue); CU_ASSERT_EQUAL(queue.shaper_profile, ODP_TM_INVALID); CU_ASSERT_EQUAL(queue.threshold_profile, ODP_TM_INVALID); @@ -4522,10 +4525,12 @@ static void traffic_mngr_test_default_values(void) CU_ASSERT_EQUAL(queue.wred_profile[n], ODP_TM_INVALID); CU_ASSERT_EQUAL(queue.priority, 0); CU_ASSERT(queue.ordered_enqueue); - /* re-check ordered_enqueue to notice if it is not set at all */ - memset(&queue, 0, sizeof(queue)); - odp_tm_queue_params_init(&queue); - CU_ASSERT(queue.ordered_enqueue); +} + +static void traffic_mngr_test_default_values(void) +{ + test_defaults(0); + test_defaults(0xff); } static void traffic_mngr_test_capabilities(void) |