aboutsummaryrefslogtreecommitdiff
path: root/test/validation/api
diff options
context:
space:
mode:
Diffstat (limited to 'test/validation/api')
-rw-r--r--test/validation/api/atomic/atomic.c923
-rw-r--r--test/validation/api/crypto/odp_crypto_test_inp.c758
-rw-r--r--test/validation/api/ipsec/ipsec.c36
-rw-r--r--test/validation/api/ipsec/ipsec.h8
-rw-r--r--test/validation/api/ipsec/ipsec_test_in.c156
-rw-r--r--test/validation/api/ipsec/ipsec_test_out.c181
-rw-r--r--test/validation/api/packet/packet.c47
-rw-r--r--test/validation/api/pktio/pktio.c4
-rw-r--r--test/validation/api/pool/pool.c24
-rw-r--r--test/validation/api/queue/queue.c4
-rw-r--r--test/validation/api/random/Makefile.am1
-rw-r--r--test/validation/api/random/random.c436
-rw-r--r--test/validation/api/timer/timer.c74
-rw-r--r--test/validation/api/traffic_mngr/traffic_mngr.c319
14 files changed, 1868 insertions, 1103 deletions
diff --git a/test/validation/api/atomic/atomic.c b/test/validation/api/atomic/atomic.c
index 54bd5ee3e..d4b15cf32 100644
--- a/test/validation/api/atomic/atomic.c
+++ b/test/validation/api/atomic/atomic.c
@@ -1,4 +1,5 @@
/* Copyright (c) 2014-2018, Linaro Limited
+ * Copyright (c) 2021-2022 Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -11,14 +12,11 @@
#include <odp_cunit_common.h>
#include <unistd.h>
-#define VERBOSE 0
-#define MAX_ITERATIONS 1000
-
#define ADD_SUB_CNT 5
-#define CNT 50000
-#define U32_INIT_VAL (1UL << 28)
-#define U64_INIT_VAL (1ULL << 33)
+#define CNT 100000ULL
+#define U32_INIT_VAL (1UL << 31)
+#define U64_INIT_VAL (1ULL << 63)
#define U32_MAGIC 0xa23f65b2
#define U64_MAGIC 0xf2e1c5430cb6a52e
@@ -26,9 +24,8 @@
#define UNUSED __attribute__((__unused__))
-#define CHECK_MAX_MIN (1 << 0)
-#define CHECK_XCHG (1 << 2)
-#define CHECK_CAS_128 (1 << 4)
+#define min(a, b) (a < b ? a : b)
+#define max(a, b) (a > b ? a : b)
typedef __volatile uint32_t volatile_u32_t;
typedef __volatile uint64_t volatile_u64_t;
@@ -45,59 +42,27 @@ typedef struct {
odp_atomic_u32_t a32u_xchg;
uint32_t g_num_threads;
- uint32_t g_iterations;
- uint32_t g_verbose;
odp_barrier_t global_barrier;
} global_shared_mem_t;
-/* Per-thread memory */
-typedef struct {
- global_shared_mem_t *global_mem;
-
- int thread_id;
- int thread_core;
-
- volatile_u64_t delay_counter;
-} per_thread_mem_t;
-
static odp_shm_t global_shm;
static global_shared_mem_t *global_mem;
/* Initialise per-thread memory */
-static per_thread_mem_t *thread_init(void)
+static void thread_init(void)
{
global_shared_mem_t *global_mem;
- per_thread_mem_t *per_thread_mem;
odp_shm_t global_shm;
- uint32_t per_thread_mem_len;
-
- per_thread_mem_len = sizeof(per_thread_mem_t);
- per_thread_mem = malloc(per_thread_mem_len);
- memset(per_thread_mem, 0, per_thread_mem_len);
-
- per_thread_mem->delay_counter = 1;
-
- per_thread_mem->thread_id = odp_thread_id();
- per_thread_mem->thread_core = odp_cpu_id();
global_shm = odp_shm_lookup(GLOBAL_SHM_NAME);
global_mem = odp_shm_addr(global_shm);
CU_ASSERT_PTR_NOT_NULL(global_mem);
-
- per_thread_mem->global_mem = global_mem;
-
- return per_thread_mem;
-}
-
-static void thread_finalize(per_thread_mem_t *per_thread_mem)
-{
- free(per_thread_mem);
}
static void test_atomic_inc_32(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -107,7 +72,7 @@ static void test_atomic_inc_32(void)
static void test_atomic_inc_64(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -117,7 +82,7 @@ static void test_atomic_inc_64(void)
static void test_atomic_dec_32(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -127,7 +92,7 @@ static void test_atomic_dec_32(void)
static void test_atomic_dec_64(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -137,7 +102,7 @@ static void test_atomic_dec_64(void)
static void test_atomic_fetch_inc_32(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -147,7 +112,7 @@ static void test_atomic_fetch_inc_32(void)
static void test_atomic_fetch_inc_64(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -157,7 +122,7 @@ static void test_atomic_fetch_inc_64(void)
static void test_atomic_fetch_dec_32(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -167,7 +132,7 @@ static void test_atomic_fetch_dec_32(void)
static void test_atomic_fetch_dec_64(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -177,7 +142,7 @@ static void test_atomic_fetch_dec_64(void)
static void test_atomic_add_32(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -187,7 +152,7 @@ static void test_atomic_add_32(void)
static void test_atomic_add_64(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -197,7 +162,7 @@ static void test_atomic_add_64(void)
static void test_atomic_sub_32(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -207,7 +172,7 @@ static void test_atomic_sub_32(void)
static void test_atomic_sub_64(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -217,7 +182,7 @@ static void test_atomic_sub_64(void)
static void test_atomic_fetch_add_32(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -227,7 +192,7 @@ static void test_atomic_fetch_add_32(void)
static void test_atomic_fetch_add_64(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -237,7 +202,7 @@ static void test_atomic_fetch_add_64(void)
static void test_atomic_fetch_sub_32(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -247,7 +212,7 @@ static void test_atomic_fetch_sub_32(void)
static void test_atomic_fetch_sub_64(void)
{
- int i;
+ uint64_t i;
odp_barrier_wait(&global_mem->global_barrier);
@@ -257,7 +222,7 @@ static void test_atomic_fetch_sub_64(void)
static void test_atomic_min_32(void)
{
- int i;
+ uint64_t i;
uint32_t tmp;
odp_barrier_wait(&global_mem->global_barrier);
@@ -270,8 +235,7 @@ static void test_atomic_min_32(void)
static void test_atomic_min_64(void)
{
- int i;
- uint64_t tmp;
+ uint64_t i, tmp;
odp_barrier_wait(&global_mem->global_barrier);
@@ -283,7 +247,7 @@ static void test_atomic_min_64(void)
static void test_atomic_max_32(void)
{
- int i;
+ uint64_t i;
uint32_t tmp;
odp_barrier_wait(&global_mem->global_barrier);
@@ -296,8 +260,7 @@ static void test_atomic_max_32(void)
static void test_atomic_max_64(void)
{
- int i;
- uint64_t tmp;
+ uint64_t i, tmp;
odp_barrier_wait(&global_mem->global_barrier);
@@ -309,23 +272,111 @@ static void test_atomic_max_64(void)
static void test_atomic_cas_inc_32(void)
{
- int i;
- uint32_t old;
+ uint64_t i, old_mismatch = 0;
+ uint32_t old, old_old;
odp_atomic_u32_t *a32u = &global_mem->a32u;
odp_barrier_wait(&global_mem->global_barrier);
for (i = 0; i < CNT; i++) {
old = odp_atomic_load_u32(a32u);
+ old_old = old;
- while (odp_atomic_cas_u32(a32u, &old, old + 1) == 0)
- ;
+ while (odp_atomic_cas_u32(a32u, &old, old + 1) == 0) {
+ if (old == old_old)
+ old_mismatch++;
+
+ old_old = old;
+ }
+
+ if (old != old_old)
+ old_mismatch++;
+ }
+
+ CU_ASSERT(old_mismatch == 0);
+}
+
+static void test_atomic_cas_acq_inc_32(void)
+{
+ uint64_t i, old_mismatch = 0;
+ uint32_t old, old_old;
+ odp_atomic_u32_t *a32u = &global_mem->a32u;
+
+ odp_barrier_wait(&global_mem->global_barrier);
+
+ for (i = 0; i < CNT; i++) {
+ old = odp_atomic_load_u32(a32u);
+ old_old = old;
+
+ while (odp_atomic_cas_acq_u32(a32u, &old, old + 1) == 0) {
+ if (old == old_old)
+ old_mismatch++;
+
+ old_old = old;
+ }
+
+ if (old != old_old)
+ old_mismatch++;
+ }
+
+ CU_ASSERT(old_mismatch == 0);
+}
+
+static void test_atomic_cas_rel_inc_32(void)
+{
+ uint64_t i, old_mismatch = 0;
+ uint32_t old, old_old;
+ odp_atomic_u32_t *a32u = &global_mem->a32u;
+
+ odp_barrier_wait(&global_mem->global_barrier);
+
+ for (i = 0; i < CNT; i++) {
+ old = odp_atomic_load_u32(a32u);
+ old_old = old;
+
+ while (odp_atomic_cas_rel_u32(a32u, &old, old + 1) == 0) {
+ if (old == old_old)
+ old_mismatch++;
+
+ old_old = old;
+ }
+
+ if (old != old_old)
+ old_mismatch++;
+ }
+
+ CU_ASSERT(old_mismatch == 0);
+}
+
+static void test_atomic_cas_acq_rel_inc_32(void)
+{
+ uint64_t i, old_mismatch = 0;
+ uint32_t old, old_old;
+ odp_atomic_u32_t *a32u = &global_mem->a32u;
+
+ odp_barrier_wait(&global_mem->global_barrier);
+
+ for (i = 0; i < CNT; i++) {
+ old = odp_atomic_load_u32(a32u);
+ old_old = old;
+
+ while (odp_atomic_cas_acq_rel_u32(a32u, &old, old + 1) == 0) {
+ if (old == old_old)
+ old_mismatch++;
+
+ old_old = old;
+ }
+
+ if (old != old_old)
+ old_mismatch++;
}
+
+ CU_ASSERT(old_mismatch == 0);
}
static void test_atomic_cas_dec_32(void)
{
- int i;
+ uint64_t i;
uint32_t old;
odp_atomic_u32_t *a32u = &global_mem->a32u;
@@ -341,24 +392,107 @@ static void test_atomic_cas_dec_32(void)
static void test_atomic_cas_inc_64(void)
{
- int i;
- uint64_t old;
+ uint64_t i, old, old_old, old_mismatch = 0;
odp_atomic_u64_t *a64u = &global_mem->a64u;
odp_barrier_wait(&global_mem->global_barrier);
for (i = 0; i < CNT; i++) {
old = odp_atomic_load_u64(a64u);
+ old_old = old;
- while (odp_atomic_cas_u64(a64u, &old, old + 1) == 0)
- ;
+ while (odp_atomic_cas_u64(a64u, &old, old + 1) == 0) {
+ if (old == old_old)
+ old_mismatch++;
+
+ old_old = old;
+ }
+
+ if (old != old_old)
+ old_mismatch++;
+ }
+
+ CU_ASSERT(old_mismatch == 0);
+}
+
+static void test_atomic_cas_acq_inc_64(void)
+{
+ uint64_t i, old, old_old, old_mismatch = 0;
+ odp_atomic_u64_t *a64u = &global_mem->a64u;
+
+ odp_barrier_wait(&global_mem->global_barrier);
+
+ for (i = 0; i < CNT; i++) {
+ old = odp_atomic_load_u64(a64u);
+ old_old = old;
+
+ while (odp_atomic_cas_acq_u64(a64u, &old, old + 1) == 0) {
+ if (old == old_old)
+ old_mismatch++;
+
+ old_old = old;
+ }
+
+ if (old != old_old)
+ old_mismatch++;
+ }
+
+ CU_ASSERT(old_mismatch == 0);
+}
+
+static void test_atomic_cas_rel_inc_64(void)
+{
+ uint64_t i, old, old_old, old_mismatch = 0;
+ odp_atomic_u64_t *a64u = &global_mem->a64u;
+
+ odp_barrier_wait(&global_mem->global_barrier);
+
+ for (i = 0; i < CNT; i++) {
+ old = odp_atomic_load_u64(a64u);
+ old_old = old;
+
+ while (odp_atomic_cas_rel_u64(a64u, &old, old + 1) == 0) {
+ if (old == old_old)
+ old_mismatch++;
+
+ old_old = old;
+ }
+
+ if (old != old_old)
+ old_mismatch++;
+ }
+
+ CU_ASSERT(old_mismatch == 0);
+}
+
+static void test_atomic_cas_acq_rel_inc_64(void)
+{
+ uint64_t i, old, old_old, old_mismatch = 0;
+ odp_atomic_u64_t *a64u = &global_mem->a64u;
+
+ odp_barrier_wait(&global_mem->global_barrier);
+
+ for (i = 0; i < CNT; i++) {
+ old = odp_atomic_load_u64(a64u);
+ old_old = old;
+
+ while (odp_atomic_cas_acq_rel_u64(a64u, &old, old + 1) == 0) {
+ if (old == old_old)
+ old_mismatch++;
+
+ old_old = old;
+ }
+
+ if (old != old_old)
+ old_mismatch++;
}
+
+ CU_ASSERT(old_mismatch == 0);
}
static void test_atomic_cas_dec_64(void)
{
- int i;
- uint64_t old;
+ uint64_t i, old;
odp_atomic_u64_t *a64u = &global_mem->a64u;
odp_barrier_wait(&global_mem->global_barrier);
@@ -371,55 +505,59 @@ static void test_atomic_cas_dec_64(void)
}
}
+#define BUF_SIZE (64 * 1024)
+
static void test_atomic_xchg_32(void)
{
uint32_t old, new;
- int i;
- odp_atomic_u32_t *a32u = &global_mem->a32u;
+ uint64_t i;
odp_atomic_u32_t *a32u_xchg = &global_mem->a32u_xchg;
+ uint8_t buf[BUF_SIZE];
+ uint64_t seed = odp_thread_id();
+ uint64_t count_old = 0, count_new = 0;
+
+ odp_random_test_data(buf, BUF_SIZE, &seed);
odp_barrier_wait(&global_mem->global_barrier);
for (i = 0; i < CNT; i++) {
- new = odp_atomic_fetch_inc_u32(a32u);
+ new = buf[i & (BUF_SIZE - 1)];
old = odp_atomic_xchg_u32(a32u_xchg, new);
-
- if (old & 0x1)
- odp_atomic_xchg_u32(a32u_xchg, 0);
- else
- odp_atomic_xchg_u32(a32u_xchg, 1);
+ count_old += old;
+ count_new += new;
}
- odp_atomic_sub_u32(a32u, CNT);
- odp_atomic_xchg_u32(a32u_xchg, U32_MAGIC);
+ odp_atomic_add_u32(a32u_xchg, count_old);
+ odp_atomic_sub_u32(a32u_xchg, count_new);
}
static void test_atomic_xchg_64(void)
{
uint64_t old, new;
- int i;
- odp_atomic_u64_t *a64u = &global_mem->a64u;
+ uint64_t i;
odp_atomic_u64_t *a64u_xchg = &global_mem->a64u_xchg;
+ uint8_t buf[BUF_SIZE];
+ uint64_t seed = odp_thread_id();
+ uint64_t count_old = 0, count_new = 0;
+
+ odp_random_test_data(buf, BUF_SIZE, &seed);
odp_barrier_wait(&global_mem->global_barrier);
for (i = 0; i < CNT; i++) {
- new = odp_atomic_fetch_inc_u64(a64u);
+ new = buf[i & (BUF_SIZE - 1)];
old = odp_atomic_xchg_u64(a64u_xchg, new);
-
- if (old & 0x1)
- odp_atomic_xchg_u64(a64u_xchg, 0);
- else
- odp_atomic_xchg_u64(a64u_xchg, 1);
+ count_old += old;
+ count_new += new;
}
- odp_atomic_sub_u64(a64u, CNT);
- odp_atomic_xchg_u64(a64u_xchg, U64_MAGIC);
+ odp_atomic_add_u64(a64u_xchg, count_old);
+ odp_atomic_sub_u64(a64u_xchg, count_new);
}
static void test_atomic_non_relaxed_32(void)
{
- int i;
+ uint64_t i;
uint32_t tmp;
odp_atomic_u32_t *a32u = &global_mem->a32u;
odp_atomic_u32_t *a32u_min = &global_mem->a32u_min;
@@ -447,17 +585,14 @@ static void test_atomic_non_relaxed_32(void)
;
tmp = odp_atomic_load_u32(a32u_xchg);
- /* finally set value for validation */
- while (odp_atomic_cas_acq_rel_u32(a32u_xchg, &tmp, U32_MAGIC)
- == 0)
+ while (odp_atomic_cas_acq_rel_u32(a32u_xchg, &tmp, tmp + 1) == 0)
;
}
}
static void test_atomic_non_relaxed_64(void)
{
- int i;
- uint64_t tmp;
+ uint64_t i, tmp;
odp_atomic_u64_t *a64u = &global_mem->a64u;
odp_atomic_u64_t *a64u_min = &global_mem->a64u_min;
odp_atomic_u64_t *a64u_max = &global_mem->a64u_max;
@@ -484,16 +619,15 @@ static void test_atomic_non_relaxed_64(void)
;
tmp = odp_atomic_load_u64(a64u_xchg);
- /* finally set value for validation */
- while (odp_atomic_cas_acq_rel_u64(a64u_xchg, &tmp, U64_MAGIC)
- == 0)
+ while (odp_atomic_cas_acq_rel_u64(a64u_xchg, &tmp, tmp + 1) == 0)
;
}
}
static void test_atomic_relaxed_128(void)
{
- int i, ret;
+ int ret;
+ uint64_t i;
odp_u128_t old, new;
odp_atomic_u128_t *a128u = &global_mem->a128u;
@@ -514,7 +648,8 @@ static void test_atomic_relaxed_128(void)
static void test_atomic_non_relaxed_128_acq(void)
{
- int i, ret;
+ int ret;
+ uint64_t i;
odp_u128_t old, new;
odp_atomic_u128_t *a128u = &global_mem->a128u;
@@ -535,7 +670,8 @@ static void test_atomic_non_relaxed_128_acq(void)
static void test_atomic_non_relaxed_128_rel(void)
{
- int i, ret;
+ int ret;
+ uint64_t i;
odp_u128_t old, new;
odp_atomic_u128_t *a128u = &global_mem->a128u;
@@ -556,7 +692,8 @@ static void test_atomic_non_relaxed_128_rel(void)
static void test_atomic_non_relaxed_128_acq_rel(void)
{
- int i, ret;
+ int ret;
+ uint64_t i;
odp_u128_t old, new;
odp_atomic_u128_t *a128u = &global_mem->a128u;
@@ -623,6 +760,42 @@ static void test_atomic_fetch_add_sub_64(void)
test_atomic_fetch_sub_64();
}
+static void test_atomic_inc_add_32(void)
+{
+ test_atomic_inc_32();
+ test_atomic_fetch_inc_32();
+ test_atomic_add_32();
+ test_atomic_fetch_add_32();
+ test_atomic_cas_inc_32();
+}
+
+static void test_atomic_inc_add_64(void)
+{
+ test_atomic_inc_64();
+ test_atomic_fetch_inc_64();
+ test_atomic_add_64();
+ test_atomic_fetch_add_64();
+ test_atomic_cas_inc_64();
+}
+
+static void test_atomic_dec_sub_32(void)
+{
+ test_atomic_dec_32();
+ test_atomic_fetch_dec_32();
+ test_atomic_sub_32();
+ test_atomic_fetch_sub_32();
+ test_atomic_cas_dec_32();
+}
+
+static void test_atomic_dec_sub_64(void)
+{
+ test_atomic_dec_64();
+ test_atomic_fetch_dec_64();
+ test_atomic_sub_64();
+ test_atomic_fetch_sub_64();
+ test_atomic_cas_dec_64();
+}
+
static void test_atomic_max_min_32(void)
{
test_atomic_max_32();
@@ -691,39 +864,105 @@ static void test_atomic_store(void)
odp_atomic_store_u128(&global_mem->a128u, a128u_tmp);
}
-static void test_atomic_validate(int check)
+static void test_atomic_validate_init_val_32_64(void)
{
CU_ASSERT(U32_INIT_VAL == odp_atomic_load_u32(&global_mem->a32u));
CU_ASSERT(U64_INIT_VAL == odp_atomic_load_u64(&global_mem->a64u));
+}
- odp_u128_t a128u_tmp;
+static void test_atomic_validate_init_val_128(void)
+{
+ odp_u128_t a128u = odp_atomic_load_u128(&global_mem->a128u);
- a128u_tmp = odp_atomic_load_u128(&global_mem->a128u);
+ CU_ASSERT(U64_INIT_VAL == a128u.u64[0]);
+ CU_ASSERT(U64_INIT_VAL == a128u.u64[1]);
+}
- if (check & CHECK_CAS_128) {
- uint64_t iterations = 0;
+static void test_atomic_validate_init_val(void)
+{
+ test_atomic_validate_init_val_32_64();
+ test_atomic_validate_init_val_128();
+}
- iterations = a128u_tmp.u64[0] - a128u_tmp.u64[1];
- CU_ASSERT(iterations == 4 * CNT * global_mem->g_num_threads);
- } else {
- CU_ASSERT(U64_INIT_VAL == a128u_tmp.u64[0]);
- CU_ASSERT(U64_INIT_VAL == a128u_tmp.u64[1]);
- }
+static void test_atomic_validate_inc_add(void)
+{
+ test_atomic_validate_init_val_128();
- if (check & CHECK_MAX_MIN) {
- CU_ASSERT(odp_atomic_load_u32(&global_mem->a32u_max) >
- odp_atomic_load_u32(&global_mem->a32u_min));
+ /* Two increment tests, one cas increment test and two add tests. */
+ const uint64_t total_count = CNT * (3 + 2 * ADD_SUB_CNT) * global_mem->g_num_threads;
+ const uint32_t a32u = U32_INIT_VAL + total_count;
- CU_ASSERT(odp_atomic_load_u64(&global_mem->a64u_max) >
- odp_atomic_load_u64(&global_mem->a64u_min));
- }
+ CU_ASSERT(a32u == odp_atomic_load_u32(&global_mem->a32u));
+ CU_ASSERT(U64_INIT_VAL + total_count == odp_atomic_load_u64(&global_mem->a64u));
+}
- if (check & CHECK_XCHG) {
- CU_ASSERT(odp_atomic_load_u32(&global_mem->a32u_xchg) ==
- U32_MAGIC);
- CU_ASSERT(odp_atomic_load_u64(&global_mem->a64u_xchg) ==
- U64_MAGIC);
- }
+static void test_atomic_validate_dec_sub(void)
+{
+ test_atomic_validate_init_val_128();
+
+ /* Two decrement tests, one cas decrement test and two sub tests. */
+ const uint64_t total_count = CNT * (3 + 2 * ADD_SUB_CNT) * global_mem->g_num_threads;
+ const uint32_t a32u = U32_INIT_VAL - total_count;
+
+ CU_ASSERT(a32u == odp_atomic_load_u32(&global_mem->a32u));
+ CU_ASSERT(U64_INIT_VAL - total_count == odp_atomic_load_u64(&global_mem->a64u));
+}
+
+static void test_atomic_validate_cas_inc_dec(void)
+{
+ test_atomic_validate_init_val_32_64();
+
+ odp_u128_t a128u = odp_atomic_load_u128(&global_mem->a128u);
+ const uint64_t iterations = a128u.u64[0] - a128u.u64[1];
+
+ CU_ASSERT(iterations == 4 * CNT * global_mem->g_num_threads);
+}
+
+static void test_atomic_validate_max_min(void)
+{
+ test_atomic_validate_init_val();
+
+ const uint64_t total_count = CNT * global_mem->g_num_threads;
+ /*
+ * Max is the result of fetch_inc, so the final max value is total_count - 1. In
+ * a long test, counter may overflow, in which case max is saturated at
+ * UINT32_MAX, and min at 0.
+ */
+ const uint32_t a32u_max = min(U32_INIT_VAL + total_count - 1, UINT32_MAX);
+ const uint32_t a32u_min = U32_INIT_VAL + total_count - 1 > UINT32_MAX ? 0 : U32_INIT_VAL;
+
+ CU_ASSERT(odp_atomic_load_u32(&global_mem->a32u_max) == a32u_max);
+ CU_ASSERT(odp_atomic_load_u32(&global_mem->a32u_min) == a32u_min);
+ CU_ASSERT(odp_atomic_load_u64(&global_mem->a64u_max) == U64_INIT_VAL + total_count - 1);
+ CU_ASSERT(odp_atomic_load_u64(&global_mem->a64u_min) == U64_INIT_VAL);
+}
+
+static void test_atomic_validate_xchg(void)
+{
+ test_atomic_validate_init_val();
+
+ CU_ASSERT(odp_atomic_load_u32(&global_mem->a32u_xchg) == U32_INIT_VAL);
+ CU_ASSERT(odp_atomic_load_u64(&global_mem->a64u_xchg) == U64_INIT_VAL);
+}
+
+static void test_atomic_validate_non_relaxed(void)
+{
+ test_atomic_validate_init_val();
+
+ const uint64_t total_count = CNT * global_mem->g_num_threads;
+ /* 3 increments per round. */
+ const uint32_t a32u = U32_INIT_VAL + 3 * total_count;
+ /* 1 increment per round. */
+ const uint32_t a32u_max = U32_INIT_VAL + total_count;
+ const uint32_t a32u_min = U32_INIT_VAL - total_count;
+
+ CU_ASSERT(odp_atomic_load_u32(&global_mem->a32u_xchg) == a32u);
+ CU_ASSERT(odp_atomic_load_u64(&global_mem->a64u_xchg) == U64_INIT_VAL + 3 * total_count);
+
+ CU_ASSERT(odp_atomic_load_u32(&global_mem->a32u_max) == a32u_max);
+ CU_ASSERT(odp_atomic_load_u32(&global_mem->a32u_min) == a32u_min);
+ CU_ASSERT(odp_atomic_load_u64(&global_mem->a64u_max) == U64_INIT_VAL + total_count);
+ CU_ASSERT(odp_atomic_load_u64(&global_mem->a64u_min) == U64_INIT_VAL - total_count);
}
static int atomic_init(odp_instance_t *inst)
@@ -762,8 +1001,6 @@ static int atomic_init(odp_instance_t *inst)
memset(global_mem, 0, sizeof(global_shared_mem_t));
global_mem->g_num_threads = MAX_WORKERS;
- global_mem->g_iterations = MAX_ITERATIONS;
- global_mem->g_verbose = VERBOSE;
workers_count = odp_cpumask_default_worker(&mask, 0);
@@ -810,121 +1047,238 @@ static int atomic_term(odp_instance_t inst)
}
/* Atomic tests */
-static int test_atomic_inc_dec_thread(void *arg UNUSED)
+
+static int test_atomic_inc_thread(void *arg UNUSED)
+{
+ thread_init();
+ test_atomic_inc_32();
+ test_atomic_inc_64();
+
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_dec_thread(void *arg UNUSED)
{
- per_thread_mem_t *per_thread_mem;
+ thread_init();
+ test_atomic_dec_32();
+ test_atomic_dec_64();
- per_thread_mem = thread_init();
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_add_thread(void *arg UNUSED)
+{
+ thread_init();
+ test_atomic_add_32();
+ test_atomic_add_64();
+
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_sub_thread(void *arg UNUSED)
+{
+ thread_init();
+ test_atomic_sub_32();
+ test_atomic_sub_64();
+
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_fetch_inc_thread(void *arg UNUSED)
+{
+ thread_init();
+ test_atomic_fetch_inc_32();
+ test_atomic_fetch_inc_64();
+
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_fetch_dec_thread(void *arg UNUSED)
+{
+ thread_init();
+ test_atomic_fetch_dec_32();
+ test_atomic_fetch_dec_64();
+
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_fetch_add_thread(void *arg UNUSED)
+{
+ thread_init();
+ test_atomic_fetch_add_32();
+ test_atomic_fetch_add_64();
+
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_fetch_sub_thread(void *arg UNUSED)
+{
+ thread_init();
+ test_atomic_fetch_sub_32();
+ test_atomic_fetch_sub_64();
+
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_max_thread(void *arg UNUSED)
+{
+ thread_init();
+ test_atomic_max_32();
+ test_atomic_max_64();
+
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_min_thread(void *arg UNUSED)
+{
+ thread_init();
+ test_atomic_min_32();
+ test_atomic_min_64();
+
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_cas_thread(void *arg UNUSED)
+{
+ thread_init();
+ test_atomic_cas_inc_32();
+ test_atomic_cas_inc_64();
+ test_atomic_relaxed_128();
+
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_cas_acq_thread(void *arg UNUSED)
+{
+ thread_init();
+ test_atomic_cas_acq_inc_32();
+ test_atomic_cas_acq_inc_64();
+ test_atomic_non_relaxed_128_acq();
+
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_cas_rel_thread(void *arg UNUSED)
+{
+ thread_init();
+ test_atomic_cas_rel_inc_32();
+ test_atomic_cas_rel_inc_64();
+ test_atomic_non_relaxed_128_rel();
+
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_cas_acq_rel_thread(void *arg UNUSED)
+{
+ thread_init();
+ test_atomic_cas_acq_rel_inc_32();
+ test_atomic_cas_acq_rel_inc_64();
+ test_atomic_non_relaxed_128_acq_rel();
+
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_inc_dec_thread(void *arg UNUSED)
+{
+ thread_init();
test_atomic_inc_dec_32();
test_atomic_inc_dec_64();
- thread_finalize(per_thread_mem);
-
return CU_get_number_of_failures();
}
static int test_atomic_add_sub_thread(void *arg UNUSED)
{
- per_thread_mem_t *per_thread_mem;
-
- per_thread_mem = thread_init();
+ thread_init();
test_atomic_add_sub_32();
test_atomic_add_sub_64();
- thread_finalize(per_thread_mem);
-
return CU_get_number_of_failures();
}
static int test_atomic_fetch_inc_dec_thread(void *arg UNUSED)
{
- per_thread_mem_t *per_thread_mem;
-
- per_thread_mem = thread_init();
+ thread_init();
test_atomic_fetch_inc_dec_32();
test_atomic_fetch_inc_dec_64();
- thread_finalize(per_thread_mem);
-
return CU_get_number_of_failures();
}
static int test_atomic_fetch_add_sub_thread(void *arg UNUSED)
{
- per_thread_mem_t *per_thread_mem;
-
- per_thread_mem = thread_init();
+ thread_init();
test_atomic_fetch_add_sub_32();
test_atomic_fetch_add_sub_64();
- thread_finalize(per_thread_mem);
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_inc_add_thread(void *arg UNUSED)
+{
+ thread_init();
+ test_atomic_inc_add_32();
+ test_atomic_inc_add_64();
return CU_get_number_of_failures();
}
-static int test_atomic_max_min_thread(void *arg UNUSED)
+static int test_atomic_dec_sub_thread(void *arg UNUSED)
{
- per_thread_mem_t *per_thread_mem;
+ thread_init();
+ test_atomic_dec_sub_32();
+ test_atomic_dec_sub_64();
- per_thread_mem = thread_init();
+ return CU_get_number_of_failures();
+}
+
+static int test_atomic_max_min_thread(void *arg UNUSED)
+{
+ thread_init();
test_atomic_max_min_32();
test_atomic_max_min_64();
- thread_finalize(per_thread_mem);
-
return CU_get_number_of_failures();
}
static int test_atomic_cas_inc_dec_thread(void *arg UNUSED)
{
- per_thread_mem_t *per_thread_mem;
-
- per_thread_mem = thread_init();
+ thread_init();
test_atomic_cas_inc_dec_32();
test_atomic_cas_inc_dec_64();
test_atomic_cas_inc_128();
- thread_finalize(per_thread_mem);
-
return CU_get_number_of_failures();
}
static int test_atomic_xchg_thread(void *arg UNUSED)
{
- per_thread_mem_t *per_thread_mem;
-
- per_thread_mem = thread_init();
+ thread_init();
test_atomic_xchg_32();
test_atomic_xchg_64();
- thread_finalize(per_thread_mem);
-
return CU_get_number_of_failures();
}
static int test_atomic_non_relaxed_thread(void *arg UNUSED)
{
- per_thread_mem_t *per_thread_mem;
-
- per_thread_mem = thread_init();
+ thread_init();
test_atomic_non_relaxed_32();
test_atomic_non_relaxed_64();
- thread_finalize(per_thread_mem);
-
return CU_get_number_of_failures();
}
-static void test_atomic_functional(int func_ptr(void *), int check)
+static void test_atomic_functional(int test_fn(void *), void validate_fn(void))
{
pthrd_arg arg;
arg.numthrds = global_mem->g_num_threads;
test_atomic_init();
test_atomic_store();
- odp_cunit_thread_create(func_ptr, &arg);
+ odp_cunit_thread_create(test_fn, &arg);
odp_cunit_thread_exit(&arg);
- test_atomic_validate(check);
+ validate_fn();
}
static void test_atomic_op_lock_free_set(void)
@@ -1077,45 +1431,231 @@ static void test_atomic_op_lock_free_128(void)
}
}
+static void atomic_test_atomic_init(void)
+{
+ uint64_t i;
+ odp_atomic_u128_t *a128u = &global_mem->a128u;
+
+ for (i = 0; i < CNT; i++) {
+ odp_u128_t a128u_tmp;
+
+ odp_atomic_init_u32(&global_mem->a32u, i);
+ odp_atomic_init_u64(&global_mem->a64u, i);
+ odp_atomic_init_u32(&global_mem->a32u_min, i);
+ odp_atomic_init_u32(&global_mem->a32u_max, i);
+ odp_atomic_init_u64(&global_mem->a64u_min, i);
+ odp_atomic_init_u64(&global_mem->a64u_max, i);
+ odp_atomic_init_u32(&global_mem->a32u_xchg, i);
+ odp_atomic_init_u64(&global_mem->a64u_xchg, i);
+
+ a128u_tmp.u64[0] = i;
+ a128u_tmp.u64[1] = i;
+ odp_atomic_init_u128(&global_mem->a128u, a128u_tmp);
+
+ CU_ASSERT(odp_atomic_load_u32(&global_mem->a32u) == i);
+ CU_ASSERT(odp_atomic_load_u64(&global_mem->a64u) == i);
+ CU_ASSERT(odp_atomic_load_u32(&global_mem->a32u_min) == i);
+ CU_ASSERT(odp_atomic_load_u32(&global_mem->a32u_max) == i);
+ CU_ASSERT(odp_atomic_load_u64(&global_mem->a64u_min) == i);
+ CU_ASSERT(odp_atomic_load_u64(&global_mem->a64u_max) == i);
+ CU_ASSERT(odp_atomic_load_u32(&global_mem->a32u_xchg) == i);
+ CU_ASSERT(odp_atomic_load_u64(&global_mem->a64u_xchg) == i);
+
+ a128u_tmp = odp_atomic_load_u128(a128u);
+ CU_ASSERT(a128u_tmp.u64[0] == i);
+ CU_ASSERT(a128u_tmp.u64[1] == i);
+ }
+}
+
+static void test_atomic_validate_inc(void)
+{
+ const uint64_t total_count = CNT * global_mem->g_num_threads;
+ const uint32_t a32u = U32_INIT_VAL + total_count;
+
+ CU_ASSERT(a32u == odp_atomic_load_u32(&global_mem->a32u));
+ CU_ASSERT(U64_INIT_VAL + total_count == odp_atomic_load_u64(&global_mem->a64u));
+}
+
+static void atomic_test_atomic_inc(void)
+{
+ test_atomic_functional(test_atomic_inc_thread, test_atomic_validate_inc);
+}
+
+static void test_atomic_validate_dec(void)
+{
+ const uint64_t total_count = CNT * global_mem->g_num_threads;
+ const uint32_t a32u = U32_INIT_VAL - total_count;
+
+ CU_ASSERT(a32u == odp_atomic_load_u32(&global_mem->a32u));
+ CU_ASSERT(U64_INIT_VAL - total_count == odp_atomic_load_u64(&global_mem->a64u));
+}
+
+static void atomic_test_atomic_dec(void)
+{
+ test_atomic_functional(test_atomic_dec_thread, test_atomic_validate_dec);
+}
+
+static void test_atomic_validate_add(void)
+{
+ const uint64_t total_count = CNT * ADD_SUB_CNT * global_mem->g_num_threads;
+ const uint32_t a32u = U32_INIT_VAL + total_count;
+
+ CU_ASSERT(a32u == odp_atomic_load_u32(&global_mem->a32u));
+ CU_ASSERT(U64_INIT_VAL + total_count == odp_atomic_load_u64(&global_mem->a64u));
+}
+
+static void atomic_test_atomic_add(void)
+{
+ test_atomic_functional(test_atomic_add_thread, test_atomic_validate_add);
+}
+
+static void test_atomic_validate_sub(void)
+{
+ const uint64_t total_count = CNT * ADD_SUB_CNT * global_mem->g_num_threads;
+ const uint32_t a32u = U32_INIT_VAL - total_count;
+
+ CU_ASSERT(a32u == odp_atomic_load_u32(&global_mem->a32u));
+ CU_ASSERT(U64_INIT_VAL - total_count == odp_atomic_load_u64(&global_mem->a64u));
+}
+
+static void atomic_test_atomic_sub(void)
+{
+ test_atomic_functional(test_atomic_sub_thread, test_atomic_validate_sub);
+}
+
+static void atomic_test_atomic_fetch_inc(void)
+{
+ test_atomic_functional(test_atomic_fetch_inc_thread, test_atomic_validate_inc);
+}
+
+static void atomic_test_atomic_fetch_dec(void)
+{
+ test_atomic_functional(test_atomic_fetch_dec_thread, test_atomic_validate_dec);
+}
+
+static void atomic_test_atomic_fetch_add(void)
+{
+ test_atomic_functional(test_atomic_fetch_add_thread, test_atomic_validate_add);
+}
+
+static void atomic_test_atomic_fetch_sub(void)
+{
+ test_atomic_functional(test_atomic_fetch_sub_thread, test_atomic_validate_sub);
+}
+
+static void test_atomic_validate_max(void)
+{
+ const uint64_t total_count = CNT * global_mem->g_num_threads - 1;
+ /* In a long test, counter may overflow, in which case max is saturated at UINT32_MAX. */
+ const uint32_t a32u_max = min(U32_INIT_VAL + total_count, UINT32_MAX);
+
+ CU_ASSERT(a32u_max == odp_atomic_load_u32(&global_mem->a32u_max));
+ CU_ASSERT(U64_INIT_VAL + total_count == odp_atomic_load_u64(&global_mem->a64u_max));
+}
+
+static void atomic_test_atomic_max(void)
+{
+ test_atomic_functional(test_atomic_max_thread, test_atomic_validate_max);
+}
+
+static void test_atomic_validate_min(void)
+{
+ const uint64_t total_count = CNT * global_mem->g_num_threads - 1;
+ /* In a long test, counter may underflow, in which case min is saturated at 0. */
+ const uint32_t a32u_min = max((int64_t)U32_INIT_VAL - (int64_t)total_count, 0);
+
+ CU_ASSERT(a32u_min == odp_atomic_load_u32(&global_mem->a32u_min));
+ CU_ASSERT(U64_INIT_VAL - total_count == odp_atomic_load_u64(&global_mem->a64u_min));
+}
+
+static void atomic_test_atomic_min(void)
+{
+ test_atomic_functional(test_atomic_min_thread, test_atomic_validate_min);
+}
+
+static void test_atomic_validate_cas_128(void)
+{
+ odp_u128_t a128u = odp_atomic_load_u128(&global_mem->a128u);
+ const uint64_t iterations = a128u.u64[0] - a128u.u64[1];
+
+ CU_ASSERT(iterations == CNT * global_mem->g_num_threads);
+}
+
+static void test_atomic_validate_cas(void)
+{
+ test_atomic_validate_inc();
+ test_atomic_validate_cas_128();
+}
+
+static void atomic_test_atomic_cas(void)
+{
+ test_atomic_functional(test_atomic_cas_thread, test_atomic_validate_cas);
+}
+
+static void atomic_test_atomic_cas_acq(void)
+{
+ test_atomic_functional(test_atomic_cas_acq_thread, test_atomic_validate_cas);
+}
+
+static void atomic_test_atomic_cas_rel(void)
+{
+ test_atomic_functional(test_atomic_cas_rel_thread, test_atomic_validate_cas);
+}
+
+static void atomic_test_atomic_cas_acq_rel(void)
+{
+ test_atomic_functional(test_atomic_cas_acq_rel_thread, test_atomic_validate_cas);
+}
+
static void atomic_test_atomic_inc_dec(void)
{
- test_atomic_functional(test_atomic_inc_dec_thread, 0);
+ test_atomic_functional(test_atomic_inc_dec_thread, test_atomic_validate_init_val);
}
static void atomic_test_atomic_add_sub(void)
{
- test_atomic_functional(test_atomic_add_sub_thread, 0);
+ test_atomic_functional(test_atomic_add_sub_thread, test_atomic_validate_init_val);
}
static void atomic_test_atomic_fetch_inc_dec(void)
{
- test_atomic_functional(test_atomic_fetch_inc_dec_thread, 0);
+ test_atomic_functional(test_atomic_fetch_inc_dec_thread, test_atomic_validate_init_val);
}
static void atomic_test_atomic_fetch_add_sub(void)
{
- test_atomic_functional(test_atomic_fetch_add_sub_thread, 0);
+ test_atomic_functional(test_atomic_fetch_add_sub_thread, test_atomic_validate_init_val);
+}
+
+static void atomic_test_atomic_inc_add(void)
+{
+ test_atomic_functional(test_atomic_inc_add_thread, test_atomic_validate_inc_add);
+}
+
+static void atomic_test_atomic_dec_sub(void)
+{
+ test_atomic_functional(test_atomic_dec_sub_thread, test_atomic_validate_dec_sub);
}
static void atomic_test_atomic_max_min(void)
{
- test_atomic_functional(test_atomic_max_min_thread, CHECK_MAX_MIN);
+ test_atomic_functional(test_atomic_max_min_thread, test_atomic_validate_max_min);
}
static void atomic_test_atomic_cas_inc_dec(void)
{
- test_atomic_functional(test_atomic_cas_inc_dec_thread, CHECK_CAS_128);
+ test_atomic_functional(test_atomic_cas_inc_dec_thread, test_atomic_validate_cas_inc_dec);
}
static void atomic_test_atomic_xchg(void)
{
- test_atomic_functional(test_atomic_xchg_thread, CHECK_XCHG);
+ test_atomic_functional(test_atomic_xchg_thread, test_atomic_validate_xchg);
}
static void atomic_test_atomic_non_relaxed(void)
{
test_atomic_functional(test_atomic_non_relaxed_thread,
- CHECK_MAX_MIN | CHECK_XCHG);
+ test_atomic_validate_non_relaxed);
}
static void atomic_test_atomic_op_lock_free(void)
@@ -1126,10 +1666,27 @@ static void atomic_test_atomic_op_lock_free(void)
}
odp_testinfo_t atomic_suite_atomic[] = {
+ ODP_TEST_INFO(atomic_test_atomic_init),
+ ODP_TEST_INFO(atomic_test_atomic_inc),
+ ODP_TEST_INFO(atomic_test_atomic_dec),
+ ODP_TEST_INFO(atomic_test_atomic_add),
+ ODP_TEST_INFO(atomic_test_atomic_sub),
+ ODP_TEST_INFO(atomic_test_atomic_fetch_inc),
+ ODP_TEST_INFO(atomic_test_atomic_fetch_dec),
+ ODP_TEST_INFO(atomic_test_atomic_fetch_add),
+ ODP_TEST_INFO(atomic_test_atomic_fetch_sub),
+ ODP_TEST_INFO(atomic_test_atomic_max),
+ ODP_TEST_INFO(atomic_test_atomic_min),
+ ODP_TEST_INFO(atomic_test_atomic_cas),
+ ODP_TEST_INFO(atomic_test_atomic_cas_acq),
+ ODP_TEST_INFO(atomic_test_atomic_cas_rel),
+ ODP_TEST_INFO(atomic_test_atomic_cas_acq_rel),
ODP_TEST_INFO(atomic_test_atomic_inc_dec),
ODP_TEST_INFO(atomic_test_atomic_add_sub),
ODP_TEST_INFO(atomic_test_atomic_fetch_inc_dec),
ODP_TEST_INFO(atomic_test_atomic_fetch_add_sub),
+ ODP_TEST_INFO(atomic_test_atomic_inc_add),
+ ODP_TEST_INFO(atomic_test_atomic_dec_sub),
ODP_TEST_INFO(atomic_test_atomic_max_min),
ODP_TEST_INFO(atomic_test_atomic_cas_inc_dec),
ODP_TEST_INFO(atomic_test_atomic_xchg),
diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c
index f620d44a8..dcdca1e28 100644
--- a/test/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/validation/api/crypto/odp_crypto_test_inp.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
@@ -26,6 +26,31 @@ struct suite_context_s {
static struct suite_context_s suite_context;
+static void test_default_values(void)
+{
+ odp_crypto_session_param_t param;
+
+ memset(&param, 0x55, sizeof(param));
+ odp_crypto_session_param_init(&param);
+
+ CU_ASSERT_EQUAL(param.op, ODP_CRYPTO_OP_ENCODE);
+ CU_ASSERT_EQUAL(param.auth_cipher_text, false);
+ CU_ASSERT_EQUAL(param.pref_mode, ODP_CRYPTO_SYNC);
+ CU_ASSERT_EQUAL(param.op_mode, ODP_CRYPTO_SYNC);
+ CU_ASSERT_EQUAL(param.cipher_alg, ODP_CIPHER_ALG_NULL);
+ CU_ASSERT_EQUAL(param.cipher_iv_len, 0);
+ CU_ASSERT_EQUAL(param.auth_alg, ODP_AUTH_ALG_NULL);
+ CU_ASSERT_EQUAL(param.auth_iv_len, 0);
+ CU_ASSERT_EQUAL(param.auth_aad_len, 0);
+
+#if ODP_DEPRECATED_API
+ CU_ASSERT_EQUAL(param.cipher_iv.data, NULL);
+ CU_ASSERT_EQUAL(param.cipher_iv.length, 0);
+ CU_ASSERT_EQUAL(param.auth_iv.data, NULL);
+ CU_ASSERT_EQUAL(param.auth_iv.length, 0);
+#endif
+}
+
static int packet_cmp_mem_bits(odp_packet_t pkt, uint32_t offset,
uint8_t *s, uint32_t len)
{
@@ -581,6 +606,12 @@ static void alg_test_execute(const alg_test_param_t *param)
}
}
+typedef enum {
+ PACKET_IV,
+ OLD_PACKET_IV,
+ OLD_SESSION_IV,
+} iv_test_mode_t;
+
/* Basic algorithm run function for async inplace mode.
* Creates a session from input parameters and runs one operation
* on input_vec. Checks the output of the crypto operation against
@@ -594,7 +625,7 @@ static void alg_test(odp_crypto_op_t op,
odp_cipher_alg_t cipher_alg,
odp_auth_alg_t auth_alg,
crypto_test_reference_t *ref,
- odp_bool_t ovr_iv,
+ iv_test_mode_t iv_mode,
odp_bool_t bit_mode)
{
unsigned int initial_num_failures = CU_get_number_of_failures();
@@ -607,8 +638,6 @@ static void alg_test(odp_crypto_op_t op,
odp_crypto_session_param_t ses_params;
uint8_t cipher_key_data[ref->cipher_key_length];
uint8_t auth_key_data[ref->auth_key_length];
- uint8_t cipher_iv_data[ref->cipher_iv_length];
- uint8_t auth_iv_data[ref->auth_iv_length];
odp_crypto_key_t cipher_key = {
.data = cipher_key_data,
.length = ref->cipher_key_length
@@ -617,22 +646,27 @@ static void alg_test(odp_crypto_op_t op,
.data = auth_key_data,
.length = ref->auth_key_length
};
+ alg_test_param_t test_param;
+#if ODP_DEPRECATED_API
+ uint8_t cipher_iv_data[ref->cipher_iv_length];
+ uint8_t auth_iv_data[ref->auth_iv_length];
odp_crypto_iv_t cipher_iv = {
- .data = ovr_iv ? NULL : cipher_iv_data,
.length = ref->cipher_iv_length
};
odp_crypto_iv_t auth_iv = {
- .data = ovr_iv ? NULL : auth_iv_data,
.length = ref->auth_iv_length
};
- alg_test_param_t test_param;
- memcpy(cipher_key_data, ref->cipher_key, ref->cipher_key_length);
- memcpy(auth_key_data, ref->auth_key, ref->auth_key_length);
- if (!ovr_iv) {
+ if (iv_mode == OLD_SESSION_IV) {
memcpy(cipher_iv_data, ref->cipher_iv, ref->cipher_iv_length);
memcpy(auth_iv_data, ref->auth_iv, ref->auth_iv_length);
+ cipher_iv.data = cipher_iv_data;
+ auth_iv.data = auth_iv_data;
}
+#endif
+
+ memcpy(cipher_key_data, ref->cipher_key, ref->cipher_key_length);
+ memcpy(auth_key_data, ref->auth_key, ref->auth_key_length);
/* Create a crypto session */
odp_crypto_session_param_init(&ses_params);
@@ -645,15 +679,41 @@ static void alg_test(odp_crypto_op_t op,
ses_params.compl_queue = suite_context.queue;
ses_params.output_pool = suite_context.pool;
ses_params.cipher_key = cipher_key;
- ses_params.cipher_iv = cipher_iv;
- ses_params.auth_iv = auth_iv;
+ if (iv_mode == PACKET_IV) {
+ ses_params.cipher_iv_len = ref->cipher_iv_length;
+ ses_params.auth_iv_len = ref->auth_iv_length;
+ } else {
+#if ODP_DEPRECATED_API
+ ses_params.cipher_iv = cipher_iv;
+ ses_params.auth_iv = auth_iv;
+#endif
+ }
ses_params.auth_key = auth_key;
ses_params.auth_digest_len = ref->digest_length;
ses_params.auth_aad_len = ref->aad_length;
rc = odp_crypto_session_create(&ses_params, &session, &status);
+ /*
+ * 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) {
+ printf("\n Unsupported algorithm combination: %s, %s\n",
+ cipher_alg_name(cipher_alg),
+ auth_alg_name(auth_alg));
+ return;
+ }
+ /*
+ * We do not allow ODP_CRYPTO_SES_ERR_ALG_ORDER since we do
+ * not combine individual non-null crypto and auth algorithms
+ * with each other in the tests. Both orders should work when
+ * only one algorithm is used (i.e. the other one is null).
+ *
+ * We do not allow ODP_CRYPTO_SES_ERR_PARAMS until needed for
+ * some ODP implementation.
+ */
CU_ASSERT_FATAL(!rc);
- CU_ASSERT(status == ODP_CRYPTO_SES_CREATE_ERR_NONE);
+ CU_ASSERT(status == ODP_CRYPTO_SES_ERR_NONE);
CU_ASSERT(odp_crypto_session_to_u64(session) !=
odp_crypto_session_to_u64(ODP_CRYPTO_SESSION_INVALID));
@@ -663,8 +723,10 @@ static void alg_test(odp_crypto_op_t op,
*/
memset(cipher_key_data, 0, sizeof(cipher_key_data));
memset(auth_key_data, 0, sizeof(auth_key_data));
+#if ODP_DEPRECATED_API
memset(cipher_iv_data, 0, sizeof(cipher_iv_data));
memset(auth_iv_data, 0, sizeof(auth_iv_data));
+#endif
memset(&ses_params, 0, sizeof(ses_params));
memset(&test_param, 0, sizeof(test_param));
@@ -672,7 +734,7 @@ static void alg_test(odp_crypto_op_t op,
test_param.op = op;
test_param.auth_alg = auth_alg;
test_param.ref = ref;
- test_param.override_iv = ovr_iv;
+ test_param.override_iv = (iv_mode != OLD_SESSION_IV);
test_param.bit_mode = bit_mode;
alg_test_execute(&test_param);
@@ -717,10 +779,8 @@ static void check_alg(odp_crypto_op_t op,
odp_auth_alg_t auth_alg,
crypto_test_reference_t *ref,
size_t count,
- odp_bool_t ovr_iv,
odp_bool_t bit_mode)
{
- odp_crypto_capability_t capa;
int rc, i;
int cipher_num = odp_crypto_cipher_capability(cipher_alg, NULL, 0);
int auth_num = odp_crypto_auth_capability(auth_alg, NULL, 0);
@@ -738,134 +798,6 @@ static void check_alg(odp_crypto_op_t op,
odp_bool_t cipher_tested[cipher_num];
odp_bool_t auth_tested[auth_num];
- rc = odp_crypto_capability(&capa);
- CU_ASSERT(!rc);
-
- if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
- !(capa.ciphers.bit.trides_cbc))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_3DES_ECB &&
- !(capa.ciphers.bit.trides_ecb))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
- !(capa.ciphers.bit.aes_cbc))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_AES_CTR &&
- !(capa.ciphers.bit.aes_ctr))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_AES_ECB &&
- !(capa.ciphers.bit.aes_ecb))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_AES_CFB128 &&
- !(capa.ciphers.bit.aes_cfb128))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_AES_XTS &&
- !(capa.ciphers.bit.aes_xts))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
- !(capa.ciphers.bit.aes_gcm))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_AES_CCM &&
- !(capa.ciphers.bit.aes_ccm))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_CHACHA20_POLY1305 &&
- !(capa.ciphers.bit.chacha20_poly1305))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_KASUMI_F8 &&
- !(capa.ciphers.bit.kasumi_f8))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_SNOW3G_UEA2 &&
- !(capa.ciphers.bit.snow3g_uea2))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_AES_EEA2 &&
- !(capa.ciphers.bit.aes_eea2))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_ZUC_EEA3 &&
- !(capa.ciphers.bit.zuc_eea3))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_DES &&
- !(capa.ciphers.bit.des))
- rc = -1;
- if (cipher_alg == ODP_CIPHER_ALG_NULL &&
- !(capa.ciphers.bit.null))
- rc = -1;
-
- CU_ASSERT(!rc);
- CU_ASSERT((~capa.ciphers.all_bits & capa.hw_ciphers.all_bits) == 0);
-
- if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
- !(capa.auths.bit.aes_gcm))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_AES_GMAC &&
- !(capa.auths.bit.aes_gmac))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_AES_CMAC &&
- !(capa.auths.bit.aes_cmac))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_AES_CCM &&
- !(capa.auths.bit.aes_ccm))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_CHACHA20_POLY1305 &&
- !(capa.auths.bit.chacha20_poly1305))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_KASUMI_F9 &&
- !(capa.auths.bit.kasumi_f9))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_SNOW3G_UIA2 &&
- !(capa.auths.bit.snow3g_uia2))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_AES_EIA2 &&
- !(capa.auths.bit.aes_eia2))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_ZUC_EIA3 &&
- !(capa.auths.bit.zuc_eia3))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_MD5_HMAC &&
- !(capa.auths.bit.md5_hmac))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_NULL &&
- !(capa.auths.bit.null))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_SHA1_HMAC &&
- !(capa.auths.bit.sha1_hmac))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_SHA224_HMAC &&
- !(capa.auths.bit.sha224_hmac))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_SHA256_HMAC &&
- !(capa.auths.bit.sha256_hmac))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_SHA384_HMAC &&
- !(capa.auths.bit.sha384_hmac))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_SHA512_HMAC &&
- !(capa.auths.bit.sha512_hmac))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_AES_XCBC_MAC &&
- !(capa.auths.bit.aes_xcbc_mac))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_MD5 &&
- !(capa.auths.bit.md5))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_SHA1 &&
- !(capa.auths.bit.sha1))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_SHA224 &&
- !(capa.auths.bit.sha224))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_SHA256 &&
- !(capa.auths.bit.sha256))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_SHA384 &&
- !(capa.auths.bit.sha384))
- rc = -1;
- if (auth_alg == ODP_AUTH_ALG_SHA512 &&
- !(capa.auths.bit.sha512))
- rc = -1;
-
- CU_ASSERT(!rc);
- CU_ASSERT((~capa.auths.all_bits & capa.hw_auths.all_bits) == 0);
-
rc = odp_crypto_cipher_capability(cipher_alg, cipher_capa, cipher_num);
CU_ASSERT_FATAL(rc == cipher_num);
@@ -926,7 +858,18 @@ static void check_alg(odp_crypto_op_t op,
continue;
}
- alg_test(op, cipher_alg, auth_alg, &ref[idx], ovr_iv, bit_mode);
+ /* test with per-packet IV */
+ alg_test(op, cipher_alg, auth_alg, &ref[idx],
+ PACKET_IV, bit_mode);
+#if ODP_DEPRECATED_API
+ /* test with per-packet IV using the old API*/
+ alg_test(op, cipher_alg, auth_alg, &ref[idx],
+ OLD_PACKET_IV, bit_mode);
+
+ /* test with per-session IV */
+ alg_test(op, cipher_alg, auth_alg, &ref[idx],
+ OLD_SESSION_IV, bit_mode);
+#endif
cipher_tested[cipher_idx] = true;
auth_tested[auth_idx] = true;
@@ -1169,6 +1112,19 @@ static int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth)
return ODP_TEST_ACTIVE;
}
+static void test_capability(void)
+{
+ odp_crypto_capability_t capa = {.max_sessions = 1};
+ int rc;
+
+ rc = odp_crypto_capability(&capa);
+ CU_ASSERT(!rc);
+ if (capa.max_sessions > 0)
+ CU_ASSERT(capa.sync_mode || capa.async_mode);
+ CU_ASSERT((~capa.ciphers.all_bits & capa.hw_ciphers.all_bits) == 0);
+ CU_ASSERT((~capa.auths.all_bits & capa.hw_auths.all_bits) == 0);
+}
+
static int check_alg_null(void)
{
return check_alg_support(ODP_CIPHER_ALG_NULL, ODP_AUTH_ALG_NULL);
@@ -1182,7 +1138,6 @@ static void crypto_test_enc_alg_null(void)
ODP_AUTH_ALG_NULL,
null_reference,
ARRAY_SIZE(null_reference),
- false,
false);
}
@@ -1193,7 +1148,6 @@ static void crypto_test_dec_alg_null(void)
ODP_AUTH_ALG_NULL,
null_reference,
ARRAY_SIZE(null_reference),
- false,
false);
}
@@ -1209,18 +1163,6 @@ static void crypto_test_enc_alg_3des_cbc(void)
ODP_AUTH_ALG_NULL,
tdes_cbc_reference,
ARRAY_SIZE(tdes_cbc_reference),
- false,
- false);
-}
-
-static void crypto_test_enc_alg_3des_cbc_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_3DES_CBC,
- ODP_AUTH_ALG_NULL,
- tdes_cbc_reference,
- ARRAY_SIZE(tdes_cbc_reference),
- true,
false);
}
@@ -1231,18 +1173,6 @@ static void crypto_test_dec_alg_3des_cbc(void)
ODP_AUTH_ALG_NULL,
tdes_cbc_reference,
ARRAY_SIZE(tdes_cbc_reference),
- false,
- false);
-}
-
-static void crypto_test_dec_alg_3des_cbc_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_3DES_CBC,
- ODP_AUTH_ALG_NULL,
- tdes_cbc_reference,
- ARRAY_SIZE(tdes_cbc_reference),
- true,
false);
}
@@ -1258,7 +1188,6 @@ static void crypto_test_enc_alg_3des_ecb(void)
ODP_AUTH_ALG_NULL,
tdes_ecb_reference,
ARRAY_SIZE(tdes_ecb_reference),
- false,
false);
}
@@ -1269,7 +1198,6 @@ static void crypto_test_dec_alg_3des_ecb(void)
ODP_AUTH_ALG_NULL,
tdes_ecb_reference,
ARRAY_SIZE(tdes_ecb_reference),
- false,
false);
}
@@ -1286,18 +1214,6 @@ static void crypto_test_enc_alg_chacha20_poly1305(void)
ODP_AUTH_ALG_CHACHA20_POLY1305,
chacha20_poly1305_reference,
ARRAY_SIZE(chacha20_poly1305_reference),
- false,
- false);
-}
-
-static void crypto_test_enc_alg_chacha20_poly1305_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_CHACHA20_POLY1305,
- ODP_AUTH_ALG_CHACHA20_POLY1305,
- chacha20_poly1305_reference,
- ARRAY_SIZE(chacha20_poly1305_reference),
- true,
false);
}
@@ -1308,18 +1224,6 @@ static void crypto_test_dec_alg_chacha20_poly1305(void)
ODP_AUTH_ALG_CHACHA20_POLY1305,
chacha20_poly1305_reference,
ARRAY_SIZE(chacha20_poly1305_reference),
- false,
- false);
-}
-
-static void crypto_test_dec_alg_chacha20_poly1305_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_CHACHA20_POLY1305,
- ODP_AUTH_ALG_CHACHA20_POLY1305,
- chacha20_poly1305_reference,
- ARRAY_SIZE(chacha20_poly1305_reference),
- true,
false);
}
@@ -1335,18 +1239,6 @@ static void crypto_test_enc_alg_aes_gcm(void)
ODP_AUTH_ALG_AES_GCM,
aes_gcm_reference,
ARRAY_SIZE(aes_gcm_reference),
- false,
- false);
-}
-
-static void crypto_test_enc_alg_aes_gcm_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_AES_GCM,
- ODP_AUTH_ALG_AES_GCM,
- aes_gcm_reference,
- ARRAY_SIZE(aes_gcm_reference),
- true,
false);
}
@@ -1357,18 +1249,6 @@ static void crypto_test_dec_alg_aes_gcm(void)
ODP_AUTH_ALG_AES_GCM,
aes_gcm_reference,
ARRAY_SIZE(aes_gcm_reference),
- false,
- false);
-}
-
-static void crypto_test_dec_alg_aes_gcm_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_AES_GCM,
- ODP_AUTH_ALG_AES_GCM,
- aes_gcm_reference,
- ARRAY_SIZE(aes_gcm_reference),
- true,
false);
}
@@ -1384,18 +1264,6 @@ static void crypto_test_enc_alg_aes_ccm(void)
ODP_AUTH_ALG_AES_CCM,
aes_ccm_reference,
ARRAY_SIZE(aes_ccm_reference),
- false,
- false);
-}
-
-static void crypto_test_enc_alg_aes_ccm_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_AES_CCM,
- ODP_AUTH_ALG_AES_CCM,
- aes_ccm_reference,
- ARRAY_SIZE(aes_ccm_reference),
- true,
false);
}
@@ -1406,18 +1274,6 @@ static void crypto_test_dec_alg_aes_ccm(void)
ODP_AUTH_ALG_AES_CCM,
aes_ccm_reference,
ARRAY_SIZE(aes_ccm_reference),
- false,
- false);
-}
-
-static void crypto_test_dec_alg_aes_ccm_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_AES_CCM,
- ODP_AUTH_ALG_AES_CCM,
- aes_ccm_reference,
- ARRAY_SIZE(aes_ccm_reference),
- true,
false);
}
@@ -1433,18 +1289,6 @@ static void crypto_test_enc_alg_aes_cbc(void)
ODP_AUTH_ALG_NULL,
aes_cbc_reference,
ARRAY_SIZE(aes_cbc_reference),
- false,
- false);
-}
-
-static void crypto_test_enc_alg_aes_cbc_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_AES_CBC,
- ODP_AUTH_ALG_NULL,
- aes_cbc_reference,
- ARRAY_SIZE(aes_cbc_reference),
- true,
false);
}
@@ -1455,18 +1299,6 @@ static void crypto_test_dec_alg_aes_cbc(void)
ODP_AUTH_ALG_NULL,
aes_cbc_reference,
ARRAY_SIZE(aes_cbc_reference),
- false,
- false);
-}
-
-static void crypto_test_dec_alg_aes_cbc_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_AES_CBC,
- ODP_AUTH_ALG_NULL,
- aes_cbc_reference,
- ARRAY_SIZE(aes_cbc_reference),
- true,
false);
}
@@ -1482,18 +1314,6 @@ static void crypto_test_enc_alg_aes_ctr(void)
ODP_AUTH_ALG_NULL,
aes_ctr_reference,
ARRAY_SIZE(aes_ctr_reference),
- false,
- false);
-}
-
-static void crypto_test_enc_alg_aes_ctr_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_AES_CTR,
- ODP_AUTH_ALG_NULL,
- aes_ctr_reference,
- ARRAY_SIZE(aes_ctr_reference),
- true,
false);
}
@@ -1504,18 +1324,6 @@ static void crypto_test_dec_alg_aes_ctr(void)
ODP_AUTH_ALG_NULL,
aes_ctr_reference,
ARRAY_SIZE(aes_ctr_reference),
- false,
- false);
-}
-
-static void crypto_test_dec_alg_aes_ctr_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_AES_CTR,
- ODP_AUTH_ALG_NULL,
- aes_ctr_reference,
- ARRAY_SIZE(aes_ctr_reference),
- true,
false);
}
@@ -1531,7 +1339,6 @@ static void crypto_test_enc_alg_aes_ecb(void)
ODP_AUTH_ALG_NULL,
aes_ecb_reference,
ARRAY_SIZE(aes_ecb_reference),
- false,
false);
}
@@ -1542,7 +1349,6 @@ static void crypto_test_dec_alg_aes_ecb(void)
ODP_AUTH_ALG_NULL,
aes_ecb_reference,
ARRAY_SIZE(aes_ecb_reference),
- false,
false);
}
@@ -1558,18 +1364,6 @@ static void crypto_test_enc_alg_aes_cfb128(void)
ODP_AUTH_ALG_NULL,
aes_cfb128_reference,
ARRAY_SIZE(aes_cfb128_reference),
- false,
- false);
-}
-
-static void crypto_test_enc_alg_aes_cfb128_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_AES_CFB128,
- ODP_AUTH_ALG_NULL,
- aes_cfb128_reference,
- ARRAY_SIZE(aes_cfb128_reference),
- true,
false);
}
@@ -1580,18 +1374,6 @@ static void crypto_test_dec_alg_aes_cfb128(void)
ODP_AUTH_ALG_NULL,
aes_cfb128_reference,
ARRAY_SIZE(aes_cfb128_reference),
- false,
- false);
-}
-
-static void crypto_test_dec_alg_aes_cfb128_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_AES_CFB128,
- ODP_AUTH_ALG_NULL,
- aes_cfb128_reference,
- ARRAY_SIZE(aes_cfb128_reference),
- true,
false);
}
@@ -1607,18 +1389,6 @@ static void crypto_test_enc_alg_aes_xts(void)
ODP_AUTH_ALG_NULL,
aes_xts_reference,
ARRAY_SIZE(aes_xts_reference),
- false,
- false);
-}
-
-static void crypto_test_enc_alg_aes_xts_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_AES_XTS,
- ODP_AUTH_ALG_NULL,
- aes_xts_reference,
- ARRAY_SIZE(aes_xts_reference),
- true,
false);
}
@@ -1629,18 +1399,6 @@ static void crypto_test_dec_alg_aes_xts(void)
ODP_AUTH_ALG_NULL,
aes_xts_reference,
ARRAY_SIZE(aes_xts_reference),
- false,
- false);
-}
-
-static void crypto_test_dec_alg_aes_xts_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_AES_XTS,
- ODP_AUTH_ALG_NULL,
- aes_xts_reference,
- ARRAY_SIZE(aes_xts_reference),
- true,
false);
}
@@ -1656,18 +1414,6 @@ static void crypto_test_enc_alg_kasumi_f8(void)
ODP_AUTH_ALG_NULL,
kasumi_f8_reference,
ARRAY_SIZE(kasumi_f8_reference),
- false,
- true);
-}
-
-static void crypto_test_enc_alg_kasumi_f8_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_KASUMI_F8,
- ODP_AUTH_ALG_NULL,
- kasumi_f8_reference,
- ARRAY_SIZE(kasumi_f8_reference),
- true,
true);
}
@@ -1678,18 +1424,6 @@ static void crypto_test_dec_alg_kasumi_f8(void)
ODP_AUTH_ALG_NULL,
kasumi_f8_reference,
ARRAY_SIZE(kasumi_f8_reference),
- false,
- true);
-}
-
-static void crypto_test_dec_alg_kasumi_f8_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_KASUMI_F8,
- ODP_AUTH_ALG_NULL,
- kasumi_f8_reference,
- ARRAY_SIZE(kasumi_f8_reference),
- true,
true);
}
@@ -1705,18 +1439,6 @@ static void crypto_test_enc_alg_snow3g_uea2(void)
ODP_AUTH_ALG_NULL,
snow3g_uea2_reference,
ARRAY_SIZE(snow3g_uea2_reference),
- false,
- true);
-}
-
-static void crypto_test_enc_alg_snow3g_uea2_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_SNOW3G_UEA2,
- ODP_AUTH_ALG_NULL,
- snow3g_uea2_reference,
- ARRAY_SIZE(snow3g_uea2_reference),
- true,
true);
}
@@ -1727,18 +1449,6 @@ static void crypto_test_dec_alg_snow3g_uea2(void)
ODP_AUTH_ALG_NULL,
snow3g_uea2_reference,
ARRAY_SIZE(snow3g_uea2_reference),
- false,
- true);
-}
-
-static void crypto_test_dec_alg_snow3g_uea2_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_SNOW3G_UEA2,
- ODP_AUTH_ALG_NULL,
- snow3g_uea2_reference,
- ARRAY_SIZE(snow3g_uea2_reference),
- true,
true);
}
@@ -1755,18 +1465,6 @@ static void crypto_test_enc_alg_aes_eea2(void)
ODP_AUTH_ALG_NULL,
aes_eea2_reference,
ARRAY_SIZE(aes_eea2_reference),
- false,
- true);
-}
-
-static void crypto_test_enc_alg_aes_eea2_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_AES_EEA2,
- ODP_AUTH_ALG_NULL,
- aes_eea2_reference,
- ARRAY_SIZE(aes_eea2_reference),
- true,
true);
}
@@ -1777,18 +1475,6 @@ static void crypto_test_dec_alg_aes_eea2(void)
ODP_AUTH_ALG_NULL,
aes_eea2_reference,
ARRAY_SIZE(aes_eea2_reference),
- false,
- true);
-}
-
-static void crypto_test_dec_alg_aes_eea2_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_AES_EEA2,
- ODP_AUTH_ALG_NULL,
- aes_eea2_reference,
- ARRAY_SIZE(aes_eea2_reference),
- true,
true);
}
@@ -1804,18 +1490,6 @@ static void crypto_test_enc_alg_zuc_eea3(void)
ODP_AUTH_ALG_NULL,
zuc_eea3_reference,
ARRAY_SIZE(zuc_eea3_reference),
- false,
- true);
-}
-
-static void crypto_test_enc_alg_zuc_eea3_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_ZUC_EEA3,
- ODP_AUTH_ALG_NULL,
- zuc_eea3_reference,
- ARRAY_SIZE(zuc_eea3_reference),
- true,
true);
}
@@ -1826,18 +1500,6 @@ static void crypto_test_dec_alg_zuc_eea3(void)
ODP_AUTH_ALG_NULL,
zuc_eea3_reference,
ARRAY_SIZE(zuc_eea3_reference),
- false,
- true);
-}
-
-static void crypto_test_dec_alg_zuc_eea3_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_ZUC_EEA3,
- ODP_AUTH_ALG_NULL,
- zuc_eea3_reference,
- ARRAY_SIZE(zuc_eea3_reference),
- true,
true);
}
@@ -1853,7 +1515,6 @@ static void crypto_test_gen_alg_hmac_md5(void)
ODP_AUTH_ALG_MD5_HMAC,
hmac_md5_reference,
ARRAY_SIZE(hmac_md5_reference),
- false,
false);
}
@@ -1864,7 +1525,6 @@ static void crypto_test_check_alg_hmac_md5(void)
ODP_AUTH_ALG_MD5_HMAC,
hmac_md5_reference,
ARRAY_SIZE(hmac_md5_reference),
- false,
false);
}
@@ -1880,7 +1540,6 @@ static void crypto_test_gen_alg_hmac_sha1(void)
ODP_AUTH_ALG_SHA1_HMAC,
hmac_sha1_reference,
ARRAY_SIZE(hmac_sha1_reference),
- false,
false);
}
@@ -1891,7 +1550,6 @@ static void crypto_test_check_alg_hmac_sha1(void)
ODP_AUTH_ALG_SHA1_HMAC,
hmac_sha1_reference,
ARRAY_SIZE(hmac_sha1_reference),
- false,
false);
}
@@ -1907,7 +1565,6 @@ static void crypto_test_gen_alg_hmac_sha224(void)
ODP_AUTH_ALG_SHA224_HMAC,
hmac_sha224_reference,
ARRAY_SIZE(hmac_sha224_reference),
- false,
false);
}
@@ -1918,7 +1575,6 @@ static void crypto_test_check_alg_hmac_sha224(void)
ODP_AUTH_ALG_SHA224_HMAC,
hmac_sha224_reference,
ARRAY_SIZE(hmac_sha224_reference),
- false,
false);
}
@@ -1934,7 +1590,6 @@ static void crypto_test_gen_alg_hmac_sha256(void)
ODP_AUTH_ALG_SHA256_HMAC,
hmac_sha256_reference,
ARRAY_SIZE(hmac_sha256_reference),
- false,
false);
}
@@ -1945,7 +1600,6 @@ static void crypto_test_check_alg_hmac_sha256(void)
ODP_AUTH_ALG_SHA256_HMAC,
hmac_sha256_reference,
ARRAY_SIZE(hmac_sha256_reference),
- false,
false);
}
@@ -1961,7 +1615,6 @@ static void crypto_test_gen_alg_hmac_sha384(void)
ODP_AUTH_ALG_SHA384_HMAC,
hmac_sha384_reference,
ARRAY_SIZE(hmac_sha384_reference),
- false,
false);
}
@@ -1972,7 +1625,6 @@ static void crypto_test_check_alg_hmac_sha384(void)
ODP_AUTH_ALG_SHA384_HMAC,
hmac_sha384_reference,
ARRAY_SIZE(hmac_sha384_reference),
- false,
false);
}
@@ -1988,7 +1640,6 @@ static void crypto_test_gen_alg_hmac_sha512(void)
ODP_AUTH_ALG_SHA512_HMAC,
hmac_sha512_reference,
ARRAY_SIZE(hmac_sha512_reference),
- false,
false);
}
@@ -1999,7 +1650,6 @@ static void crypto_test_check_alg_hmac_sha512(void)
ODP_AUTH_ALG_SHA512_HMAC,
hmac_sha512_reference,
ARRAY_SIZE(hmac_sha512_reference),
- false,
false);
}
@@ -2016,7 +1666,6 @@ static void crypto_test_gen_alg_aes_xcbc(void)
ODP_AUTH_ALG_AES_XCBC_MAC,
aes_xcbc_reference,
ARRAY_SIZE(aes_xcbc_reference),
- false,
false);
}
@@ -2027,7 +1676,6 @@ static void crypto_test_check_alg_aes_xcbc(void)
ODP_AUTH_ALG_AES_XCBC_MAC,
aes_xcbc_reference,
ARRAY_SIZE(aes_xcbc_reference),
- false,
false);
}
@@ -2043,18 +1691,6 @@ static void crypto_test_gen_alg_aes_gmac(void)
ODP_AUTH_ALG_AES_GMAC,
aes_gmac_reference,
ARRAY_SIZE(aes_gmac_reference),
- false,
- false);
-}
-
-static void crypto_test_gen_alg_aes_gmac_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_AES_GMAC,
- aes_gmac_reference,
- ARRAY_SIZE(aes_gmac_reference),
- true,
false);
}
@@ -2065,18 +1701,6 @@ static void crypto_test_check_alg_aes_gmac(void)
ODP_AUTH_ALG_AES_GMAC,
aes_gmac_reference,
ARRAY_SIZE(aes_gmac_reference),
- false,
- false);
-}
-
-static void crypto_test_check_alg_aes_gmac_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_AES_GMAC,
- aes_gmac_reference,
- ARRAY_SIZE(aes_gmac_reference),
- false,
false);
}
@@ -2092,7 +1716,6 @@ static void crypto_test_gen_alg_aes_cmac(void)
ODP_AUTH_ALG_AES_CMAC,
aes_cmac_reference,
ARRAY_SIZE(aes_cmac_reference),
- false,
false);
}
@@ -2103,7 +1726,6 @@ static void crypto_test_check_alg_aes_cmac(void)
ODP_AUTH_ALG_AES_CMAC,
aes_cmac_reference,
ARRAY_SIZE(aes_cmac_reference),
- false,
false);
}
@@ -2119,18 +1741,6 @@ static void crypto_test_gen_alg_kasumi_f9(void)
ODP_AUTH_ALG_KASUMI_F9,
kasumi_f9_reference,
ARRAY_SIZE(kasumi_f9_reference),
- false,
- true);
-}
-
-static void crypto_test_gen_alg_kasumi_f9_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_KASUMI_F9,
- kasumi_f9_reference,
- ARRAY_SIZE(kasumi_f9_reference),
- true,
true);
}
@@ -2141,18 +1751,6 @@ static void crypto_test_check_alg_kasumi_f9(void)
ODP_AUTH_ALG_KASUMI_F9,
kasumi_f9_reference,
ARRAY_SIZE(kasumi_f9_reference),
- false,
- true);
-}
-
-static void crypto_test_check_alg_kasumi_f9_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_KASUMI_F9,
- kasumi_f9_reference,
- ARRAY_SIZE(kasumi_f9_reference),
- true,
true);
}
@@ -2168,18 +1766,6 @@ static void crypto_test_gen_alg_snow3g_uia2(void)
ODP_AUTH_ALG_SNOW3G_UIA2,
snow3g_uia2_reference,
ARRAY_SIZE(snow3g_uia2_reference),
- false,
- true);
-}
-
-static void crypto_test_gen_alg_snow3g_uia2_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SNOW3G_UIA2,
- snow3g_uia2_reference,
- ARRAY_SIZE(snow3g_uia2_reference),
- true,
true);
}
@@ -2190,18 +1776,6 @@ static void crypto_test_check_alg_snow3g_uia2(void)
ODP_AUTH_ALG_SNOW3G_UIA2,
snow3g_uia2_reference,
ARRAY_SIZE(snow3g_uia2_reference),
- false,
- true);
-}
-
-static void crypto_test_check_alg_snow3g_uia2_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SNOW3G_UIA2,
- snow3g_uia2_reference,
- ARRAY_SIZE(snow3g_uia2_reference),
- true,
true);
}
@@ -2218,18 +1792,6 @@ static void crypto_test_gen_alg_aes_eia2(void)
ODP_AUTH_ALG_AES_EIA2,
aes_eia2_reference,
ARRAY_SIZE(aes_eia2_reference),
- false,
- true);
-}
-
-static void crypto_test_gen_alg_aes_eia2_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_AES_EIA2,
- aes_eia2_reference,
- ARRAY_SIZE(aes_eia2_reference),
- true,
true);
}
@@ -2240,18 +1802,6 @@ static void crypto_test_check_alg_aes_eia2(void)
ODP_AUTH_ALG_AES_EIA2,
aes_eia2_reference,
ARRAY_SIZE(aes_eia2_reference),
- false,
- true);
-}
-
-static void crypto_test_check_alg_aes_eia2_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_AES_EIA2,
- aes_eia2_reference,
- ARRAY_SIZE(aes_eia2_reference),
- true,
true);
}
@@ -2267,18 +1817,6 @@ static void crypto_test_gen_alg_zuc_eia3(void)
ODP_AUTH_ALG_ZUC_EIA3,
zuc_eia3_reference,
ARRAY_SIZE(zuc_eia3_reference),
- false,
- true);
-}
-
-static void crypto_test_gen_alg_zuc_eia3_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_ZUC_EIA3,
- zuc_eia3_reference,
- ARRAY_SIZE(zuc_eia3_reference),
- true,
true);
}
@@ -2289,18 +1827,6 @@ static void crypto_test_check_alg_zuc_eia3(void)
ODP_AUTH_ALG_ZUC_EIA3,
zuc_eia3_reference,
ARRAY_SIZE(zuc_eia3_reference),
- false,
- true);
-}
-
-static void crypto_test_check_alg_zuc_eia3_ovr_iv(void)
-{
- check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_ZUC_EIA3,
- zuc_eia3_reference,
- ARRAY_SIZE(zuc_eia3_reference),
- true,
true);
}
@@ -2316,7 +1842,6 @@ static void crypto_test_gen_alg_md5(void)
ODP_AUTH_ALG_MD5,
md5_reference,
ARRAY_SIZE(md5_reference),
- false,
false);
}
@@ -2327,7 +1852,6 @@ static void crypto_test_check_alg_md5(void)
ODP_AUTH_ALG_MD5,
md5_reference,
ARRAY_SIZE(md5_reference),
- false,
false);
}
@@ -2343,7 +1867,6 @@ static void crypto_test_gen_alg_sha1(void)
ODP_AUTH_ALG_SHA1,
sha1_reference,
ARRAY_SIZE(sha1_reference),
- false,
false);
}
@@ -2354,7 +1877,6 @@ static void crypto_test_check_alg_sha1(void)
ODP_AUTH_ALG_SHA1,
sha1_reference,
ARRAY_SIZE(sha1_reference),
- false,
false);
}
@@ -2370,7 +1892,6 @@ static void crypto_test_gen_alg_sha224(void)
ODP_AUTH_ALG_SHA224,
sha224_reference,
ARRAY_SIZE(sha224_reference),
- false,
false);
}
@@ -2381,7 +1902,6 @@ static void crypto_test_check_alg_sha224(void)
ODP_AUTH_ALG_SHA224,
sha224_reference,
ARRAY_SIZE(sha224_reference),
- false,
false);
}
@@ -2397,7 +1917,6 @@ static void crypto_test_gen_alg_sha256(void)
ODP_AUTH_ALG_SHA256,
sha256_reference,
ARRAY_SIZE(sha256_reference),
- false,
false);
}
@@ -2408,7 +1927,6 @@ static void crypto_test_check_alg_sha256(void)
ODP_AUTH_ALG_SHA256,
sha256_reference,
ARRAY_SIZE(sha256_reference),
- false,
false);
}
@@ -2424,7 +1942,6 @@ static void crypto_test_gen_alg_sha384(void)
ODP_AUTH_ALG_SHA384,
sha384_reference,
ARRAY_SIZE(sha384_reference),
- false,
false);
}
@@ -2435,7 +1952,6 @@ static void crypto_test_check_alg_sha384(void)
ODP_AUTH_ALG_SHA384,
sha384_reference,
ARRAY_SIZE(sha384_reference),
- false,
false);
}
@@ -2451,7 +1967,6 @@ static void crypto_test_gen_alg_sha512(void)
ODP_AUTH_ALG_SHA512,
sha512_reference,
ARRAY_SIZE(sha512_reference),
- false,
false);
}
@@ -2462,7 +1977,6 @@ static void crypto_test_check_alg_sha512(void)
ODP_AUTH_ALG_SHA512,
sha512_reference,
ARRAY_SIZE(sha512_reference),
- false,
false);
}
@@ -2619,6 +2133,8 @@ static int crypto_suite_term(void)
}
odp_testinfo_t crypto_suite[] = {
+ ODP_TEST_INFO(test_capability),
+ ODP_TEST_INFO(test_default_values),
ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_null,
check_alg_null),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_null,
@@ -2627,10 +2143,6 @@ odp_testinfo_t crypto_suite[] = {
check_alg_3des_cbc),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_3des_cbc,
check_alg_3des_cbc),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_3des_cbc_ovr_iv,
- check_alg_3des_cbc),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_3des_cbc_ovr_iv,
- check_alg_3des_cbc),
ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_3des_ecb,
check_alg_3des_ecb),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_3des_ecb,
@@ -2639,18 +2151,10 @@ odp_testinfo_t crypto_suite[] = {
check_alg_aes_cbc),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_cbc,
check_alg_aes_cbc),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_cbc_ovr_iv,
- check_alg_aes_cbc),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_cbc_ovr_iv,
- check_alg_aes_cbc),
ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_ctr,
check_alg_aes_ctr),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_ctr,
check_alg_aes_ctr),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_ctr_ovr_iv,
- check_alg_aes_ctr),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_ctr_ovr_iv,
- check_alg_aes_ctr),
ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_ecb,
check_alg_aes_ecb),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_ecb,
@@ -2659,74 +2163,38 @@ odp_testinfo_t crypto_suite[] = {
check_alg_aes_cfb128),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_cfb128,
check_alg_aes_cfb128),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_cfb128_ovr_iv,
- check_alg_aes_cfb128),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_cfb128_ovr_iv,
- check_alg_aes_cfb128),
ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_xts,
check_alg_aes_xts),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_xts,
check_alg_aes_xts),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_xts_ovr_iv,
- check_alg_aes_xts),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_xts_ovr_iv,
- check_alg_aes_xts),
ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_kasumi_f8,
check_alg_kasumi_f8),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_kasumi_f8,
check_alg_kasumi_f8),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_kasumi_f8_ovr_iv,
- check_alg_kasumi_f8),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_kasumi_f8_ovr_iv,
- check_alg_kasumi_f8),
ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_snow3g_uea2,
check_alg_snow3g_uea2),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_snow3g_uea2,
check_alg_snow3g_uea2),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_snow3g_uea2_ovr_iv,
- check_alg_snow3g_uea2),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_snow3g_uea2_ovr_iv,
- check_alg_snow3g_uea2),
ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_eea2,
check_alg_aes_eea2),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_eea2,
check_alg_aes_eea2),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_eea2_ovr_iv,
- check_alg_aes_eea2),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_eea2_ovr_iv,
- check_alg_aes_eea2),
ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_zuc_eea3,
check_alg_zuc_eea3),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_zuc_eea3,
check_alg_zuc_eea3),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_zuc_eea3_ovr_iv,
- check_alg_zuc_eea3),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_zuc_eea3_ovr_iv,
- check_alg_zuc_eea3),
ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_gcm,
check_alg_aes_gcm),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_gcm_ovr_iv,
- check_alg_aes_gcm),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_gcm,
check_alg_aes_gcm),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_gcm_ovr_iv,
- check_alg_aes_gcm),
ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_ccm,
check_alg_aes_ccm),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_ccm_ovr_iv,
- check_alg_aes_ccm),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_ccm,
check_alg_aes_ccm),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_ccm_ovr_iv,
- check_alg_aes_ccm),
ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_chacha20_poly1305,
check_alg_chacha20_poly1305),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_chacha20_poly1305_ovr_iv,
- check_alg_chacha20_poly1305),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_chacha20_poly1305,
check_alg_chacha20_poly1305),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_chacha20_poly1305_ovr_iv,
- check_alg_chacha20_poly1305),
ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_hmac_md5,
check_alg_hmac_md5),
ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_hmac_md5,
@@ -2757,12 +2225,8 @@ odp_testinfo_t crypto_suite[] = {
check_alg_aes_xcbc),
ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_aes_gmac,
check_alg_aes_gmac),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_aes_gmac_ovr_iv,
- check_alg_aes_gmac),
ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_aes_gmac,
check_alg_aes_gmac),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_aes_gmac_ovr_iv,
- check_alg_aes_gmac),
ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_aes_cmac,
check_alg_aes_cmac),
ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_aes_cmac,
@@ -2771,34 +2235,18 @@ odp_testinfo_t crypto_suite[] = {
check_alg_kasumi_f9),
ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_kasumi_f9,
check_alg_kasumi_f9),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_kasumi_f9_ovr_iv,
- check_alg_kasumi_f9),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_kasumi_f9_ovr_iv,
- check_alg_kasumi_f9),
ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_snow3g_uia2,
check_alg_snow3g_uia2),
ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_snow3g_uia2,
check_alg_snow3g_uia2),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_snow3g_uia2_ovr_iv,
- check_alg_snow3g_uia2),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_snow3g_uia2_ovr_iv,
- check_alg_snow3g_uia2),
ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_aes_eia2,
check_alg_aes_eia2),
ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_aes_eia2,
check_alg_aes_eia2),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_aes_eia2_ovr_iv,
- check_alg_aes_eia2),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_aes_eia2_ovr_iv,
- check_alg_aes_eia2),
ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_zuc_eia3,
check_alg_zuc_eia3),
ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_zuc_eia3,
check_alg_zuc_eia3),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_zuc_eia3_ovr_iv,
- check_alg_zuc_eia3),
- ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_zuc_eia3_ovr_iv,
- check_alg_zuc_eia3),
ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_md5,
check_alg_md5),
ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_md5,
diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c
index cd1824fb1..32318e356 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -267,34 +267,12 @@ int ipsec_check_ah_aes_gmac_128(void)
return ipsec_check_ah(ODP_AUTH_ALG_AES_GMAC, 128);
}
-int ipsec_check_ah_aes_gmac_192(void)
-{
- return ipsec_check_ah(ODP_AUTH_ALG_AES_GMAC, 192);
-}
-
-int ipsec_check_ah_aes_gmac_256(void)
-{
- return ipsec_check_ah(ODP_AUTH_ALG_AES_GMAC, 256);
-}
-
int ipsec_check_esp_null_aes_gmac_128(void)
{
return ipsec_check_esp(ODP_CIPHER_ALG_NULL, 0,
ODP_AUTH_ALG_AES_GMAC, 128);
}
-int ipsec_check_esp_null_aes_gmac_192(void)
-{
- return ipsec_check_esp(ODP_CIPHER_ALG_NULL, 0,
- ODP_AUTH_ALG_AES_GMAC, 192);
-}
-
-int ipsec_check_esp_null_aes_gmac_256(void)
-{
- return ipsec_check_esp(ODP_CIPHER_ALG_NULL, 0,
- ODP_AUTH_ALG_AES_GMAC, 256);
-}
-
int ipsec_check_esp_chacha20_poly1305(void)
{
return ipsec_check_esp(ODP_CIPHER_ALG_CHACHA20_POLY1305, 256,
@@ -336,8 +314,8 @@ int ipsec_check_esp_null_aes_xcbc(void)
}
void ipsec_sa_param_fill(odp_ipsec_sa_param_t *param,
- odp_bool_t in,
- odp_bool_t ah,
+ odp_ipsec_dir_t dir,
+ odp_ipsec_protocol_t proto,
uint32_t spi,
odp_ipsec_tunnel_param_t *tun,
odp_cipher_alg_t cipher_alg,
@@ -348,18 +326,16 @@ void ipsec_sa_param_fill(odp_ipsec_sa_param_t *param,
const odp_crypto_key_t *auth_key_extra)
{
odp_ipsec_sa_param_init(param);
- param->dir = in ? ODP_IPSEC_DIR_INBOUND :
- ODP_IPSEC_DIR_OUTBOUND;
- if (in) {
+ param->dir = dir;
+ if (dir == ODP_IPSEC_DIR_INBOUND) {
param->inbound.lookup_mode = ODP_IPSEC_LOOKUP_SPI;
param->inbound.antireplay_ws = capa.max_antireplay_ws;
}
- param->proto = ah ? ODP_IPSEC_AH :
- ODP_IPSEC_ESP;
+ param->proto = proto;
if (tun) {
param->mode = ODP_IPSEC_MODE_TUNNEL;
- if (!in)
+ if (dir == ODP_IPSEC_DIR_OUTBOUND)
param->outbound.tunnel = *tun;
} else {
param->mode = ODP_IPSEC_MODE_TRANSPORT;
diff --git a/test/validation/api/ipsec/ipsec.h b/test/validation/api/ipsec/ipsec.h
index cbb533913..a2bb478a3 100644
--- a/test/validation/api/ipsec/ipsec.h
+++ b/test/validation/api/ipsec/ipsec.h
@@ -105,8 +105,8 @@ typedef struct {
} ipsec_test_part;
void ipsec_sa_param_fill(odp_ipsec_sa_param_t *param,
- odp_bool_t in,
- odp_bool_t ah,
+ odp_ipsec_dir_t dir,
+ odp_ipsec_protocol_t proto,
uint32_t spi,
odp_ipsec_tunnel_param_t *tun,
odp_cipher_alg_t cipher_alg,
@@ -145,11 +145,7 @@ int ipsec_check_esp_aes_ctr_128_null(void);
int ipsec_check_esp_aes_gcm_128(void);
int ipsec_check_esp_aes_gcm_256(void);
int ipsec_check_ah_aes_gmac_128(void);
-int ipsec_check_ah_aes_gmac_192(void);
-int ipsec_check_ah_aes_gmac_256(void);
int ipsec_check_esp_null_aes_gmac_128(void);
-int ipsec_check_esp_null_aes_gmac_192(void);
-int ipsec_check_esp_null_aes_gmac_256(void);
int ipsec_check_esp_chacha20_poly1305(void);
int ipsec_check_test_sa_update_seq_num(void);
int ipsec_check_esp_aes_gcm_128_reass_ipv4(void);
diff --git a/test/validation/api/ipsec/ipsec_test_in.c b/test/validation/api/ipsec/ipsec_test_in.c
index 508d7aaa5..e72c01c94 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -55,7 +55,7 @@ static void test_in_ipv4_ah_sha256(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, true, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -90,7 +90,7 @@ static void test_in_ipv4_ah_sha256_tun_ipv4(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, true, 123, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -125,7 +125,7 @@ static void test_in_ipv4_ah_sha256_tun_ipv6(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, true, 123, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -157,7 +157,7 @@ static void test_in_ipv4_ah_sha256_tun_ipv4_notun(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, true, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -190,7 +190,7 @@ static void test_in_ipv4_esp_null_sha256(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -222,7 +222,7 @@ static void test_in_ipv4_esp_aes_cbc_null(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_AES_CBC, &key_a5_128,
ODP_AUTH_ALG_NULL, NULL,
NULL, NULL);
@@ -254,7 +254,7 @@ static void test_in_ipv4_esp_aes_cbc_sha1(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_AES_CBC, &key_a5_128,
ODP_AUTH_ALG_SHA1_HMAC, &key_5a_160,
NULL, NULL);
@@ -286,7 +286,7 @@ static void test_in_ipv4_esp_aes_cbc_sha256(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_AES_CBC, &key_a5_128,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -318,7 +318,7 @@ static void test_in_ipv4_esp_aes_cbc_sha384(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_AES_CBC, &key_a5_128,
ODP_AUTH_ALG_SHA384_HMAC, &key_5a_384,
NULL, NULL);
@@ -350,7 +350,7 @@ static void test_in_ipv4_esp_aes_cbc_sha512(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_AES_CBC, &key_a5_128,
ODP_AUTH_ALG_SHA512_HMAC, &key_5a_512,
NULL, NULL);
@@ -382,7 +382,7 @@ static void test_in_ipv4_esp_aes_ctr_null(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_AES_CTR, &key_a5_128,
ODP_AUTH_ALG_NULL, NULL,
&key_mcgrew_gcm_salt_3, NULL);
@@ -414,7 +414,7 @@ static void test_in_ipv4_ah_sha256_lookup(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, true, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -449,7 +449,7 @@ static void test_in_ipv4_esp_null_sha256_lookup(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -487,7 +487,7 @@ static void test_in_ipv4_esp_null_sha256_tun_ipv4(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, false, 123, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -522,7 +522,7 @@ static void test_in_ipv4_esp_null_sha256_tun_ipv6(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, false, 123, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -554,7 +554,7 @@ static void test_in_ipv4_esp_udp_null_sha256(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -587,7 +587,7 @@ static void test_in_ipv4_esp_udp_null_sha256_lookup(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -623,7 +623,7 @@ static void test_in_ipv4_ah_sha256_noreplay(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, true, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -674,7 +674,7 @@ static void test_in_ipv4_ah_sha256_replay(void)
memset(&test_repl, 0, sizeof(ipsec_test_part));
ipsec_sa_param_fill(&param,
- true, true, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -726,7 +726,7 @@ static void test_in_ipv4_esp_null_sha256_noreplay(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -777,7 +777,7 @@ static void test_in_ipv4_esp_null_sha256_replay(void)
memset(&test_repl, 0, sizeof(ipsec_test_part));
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -837,7 +837,7 @@ static void test_in_ipv4_ah_esp_pkt(void)
return;
ipsec_sa_param_fill(&param,
- true, true, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -869,7 +869,7 @@ static void test_in_ipv4_esp_ah_pkt(void)
return;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -896,7 +896,7 @@ static void test_in_ipv4_ah_esp_pkt_lookup(void)
memset(&test, 0, sizeof(ipsec_test_part));
ipsec_sa_param_fill(&param,
- true, true, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -924,7 +924,7 @@ static void test_in_ipv4_esp_ah_pkt_lookup(void)
memset(&test, 0, sizeof(ipsec_test_part));
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -952,7 +952,7 @@ static void test_in_ipv4_ah_sha256_bad1(void)
memset(&test, 0, sizeof(ipsec_test_part));
ipsec_sa_param_fill(&param,
- true, true, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -979,7 +979,7 @@ static void test_in_ipv4_ah_sha256_bad2(void)
memset(&test, 0, sizeof(ipsec_test_part));
ipsec_sa_param_fill(&param,
- true, true, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1006,7 +1006,7 @@ static void test_in_ipv4_esp_null_sha256_bad1(void)
memset(&test, 0, sizeof(ipsec_test_part));
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1030,7 +1030,7 @@ static void test_in_ipv4_rfc3602_5_esp(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 0x4321, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 0x4321, NULL,
ODP_CIPHER_ALG_AES_CBC, &key_rfc3602,
ODP_AUTH_ALG_NULL, NULL,
NULL, NULL);
@@ -1062,7 +1062,7 @@ static void test_in_ipv4_rfc3602_6_esp(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 0x4321, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 0x4321, NULL,
ODP_CIPHER_ALG_AES_CBC, &key_rfc3602,
ODP_AUTH_ALG_NULL, NULL,
NULL, NULL);
@@ -1097,7 +1097,8 @@ static void test_in_ipv4_rfc3602_7_esp(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, false, 0x8765, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 0x8765, &tunnel,
ODP_CIPHER_ALG_AES_CBC, &key_rfc3602_2,
ODP_AUTH_ALG_NULL, NULL,
NULL, NULL);
@@ -1132,7 +1133,8 @@ static void test_in_ipv4_rfc3602_8_esp(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, false, 0x8765, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 0x8765, &tunnel,
ODP_CIPHER_ALG_AES_CBC, &key_rfc3602_2,
ODP_AUTH_ALG_NULL, NULL,
NULL, NULL);
@@ -1167,7 +1169,8 @@ static void test_in_ipv4_mcgrew_gcm_2_esp(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, false, 0xa5f8, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 0xa5f8, &tunnel,
ODP_CIPHER_ALG_AES_GCM, &key_mcgrew_gcm_2,
ODP_AUTH_ALG_AES_GCM, NULL,
&key_mcgrew_gcm_salt_2, NULL);
@@ -1202,7 +1205,8 @@ static void test_in_ipv4_mcgrew_gcm_3_esp(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, false, 0x4a2cbfe3, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 0x4a2cbfe3, &tunnel,
ODP_CIPHER_ALG_AES_GCM, &key_mcgrew_gcm_3,
ODP_AUTH_ALG_AES_GCM, NULL,
&key_mcgrew_gcm_salt_3, NULL);
@@ -1237,7 +1241,8 @@ static void test_in_ipv4_mcgrew_gcm_4_esp(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, false, 0x00000000, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 0x00000000, &tunnel,
ODP_CIPHER_ALG_AES_GCM, &key_mcgrew_gcm_4,
ODP_AUTH_ALG_AES_GCM, NULL,
&key_mcgrew_gcm_salt_4, NULL);
@@ -1277,7 +1282,8 @@ static void test_in_ipv4_mcgrew_gcm_12_esp(void)
return;
ipsec_sa_param_fill(&param,
- true, false, 0x335467ae, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 0x335467ae, &tunnel,
ODP_CIPHER_ALG_AES_GCM, &key_mcgrew_gcm_12,
ODP_AUTH_ALG_AES_GCM, NULL,
&key_mcgrew_gcm_salt_12, NULL);
@@ -1309,7 +1315,8 @@ static void test_in_ipv4_mcgrew_gcm_12_esp_notun(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 0x335467ae, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 0x335467ae, NULL,
ODP_CIPHER_ALG_AES_GCM, &key_mcgrew_gcm_12,
ODP_AUTH_ALG_AES_GCM, NULL,
&key_mcgrew_gcm_salt_12, NULL);
@@ -1344,7 +1351,8 @@ static void test_in_ipv4_mcgrew_gcm_15_esp(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, false, 0x00004321, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 0x00004321, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_AES_GMAC, &key_mcgrew_gcm_15,
NULL, &key_mcgrew_gcm_salt_15);
@@ -1379,7 +1387,8 @@ static void test_in_ipv4_rfc7634_chacha(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, false, 0x01020304, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 0x01020304, &tunnel,
ODP_CIPHER_ALG_CHACHA20_POLY1305, &key_rfc7634,
ODP_AUTH_ALG_CHACHA20_POLY1305, NULL,
&key_rfc7634_salt, NULL);
@@ -1411,7 +1420,7 @@ static void test_in_ipv4_ah_aes_gmac_128(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, true, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_AES_GMAC, &key_a5_128,
NULL, &key_mcgrew_gcm_salt_2);
@@ -1443,7 +1452,7 @@ static void test_in_ipv4_esp_null_aes_gmac_128(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_AES_GMAC, &key_a5_128,
NULL, &key_mcgrew_gcm_salt_2);
@@ -1475,7 +1484,7 @@ static void test_in_ipv6_ah_sha256(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, true, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1510,7 +1519,7 @@ static void test_in_ipv6_ah_sha256_tun_ipv4(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, true, 123, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1545,7 +1554,7 @@ static void test_in_ipv6_ah_sha256_tun_ipv6(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, true, 123, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_AH, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1577,7 +1586,7 @@ static void test_in_ipv6_esp_null_sha256(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1612,7 +1621,7 @@ static void test_in_ipv6_esp_null_sha256_tun_ipv4(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, false, 123, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1647,7 +1656,7 @@ static void test_in_ipv6_esp_null_sha256_tun_ipv6(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, false, 123, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1679,7 +1688,7 @@ static void test_in_ipv6_esp_udp_null_sha256(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1712,7 +1721,7 @@ static void test_in_ipv6_esp_udp_null_sha256_lookup(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1753,7 +1762,7 @@ static void test_ipsec_sa_print(void)
odp_ipsec_sa_t in_sa;
ipsec_sa_param_fill(&param_in,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_AES_CBC, &key_a5_128,
ODP_AUTH_ALG_SHA1_HMAC, &key_5a_160,
NULL, NULL);
@@ -1918,7 +1927,6 @@ static void test_in_ipv4_esp_reass_success(void)
uint32_t src = IPV4ADDR(10, 0, 11, 2);
uint32_t dst = IPV4ADDR(10, 0, 22, 2);
odp_ipsec_sa_t out_sa, in_sa;
- odp_ipsec_capability_t capa;
memset(&in_tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
memset(&out_tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
@@ -1927,16 +1935,16 @@ static void test_in_ipv4_esp_reass_success(void)
out_tunnel.ipv4.src_addr = &src;
out_tunnel.ipv4.dst_addr = &dst;
- CU_ASSERT(odp_ipsec_capability(&capa) == 0);
-
ipsec_sa_param_fill(&param_out,
- false, false, 0x4a2cbfe7, &out_tunnel,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP,
+ 0x4a2cbfe7, &out_tunnel,
ODP_CIPHER_ALG_AES_GCM, &key_mcgrew_gcm_4,
ODP_AUTH_ALG_AES_GCM, NULL,
&key_mcgrew_gcm_salt_4, NULL);
ipsec_sa_param_fill(&param_in,
- true, false, 0x4a2cbfe7, &in_tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 0x4a2cbfe7, &in_tunnel,
ODP_CIPHER_ALG_AES_GCM, &key_mcgrew_gcm_4,
ODP_AUTH_ALG_AES_GCM, NULL,
&key_mcgrew_gcm_salt_4, NULL);
@@ -1974,7 +1982,6 @@ static void test_in_ipv4_esp_reass_incomp(void)
uint32_t src = IPV4ADDR(10, 0, 11, 2);
uint32_t dst = IPV4ADDR(10, 0, 22, 2);
odp_ipsec_sa_t out_sa, in_sa;
- odp_ipsec_capability_t capa;
memset(&in_tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
memset(&out_tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
@@ -1983,16 +1990,16 @@ static void test_in_ipv4_esp_reass_incomp(void)
out_tunnel.ipv4.src_addr = &src;
out_tunnel.ipv4.dst_addr = &dst;
- CU_ASSERT(odp_ipsec_capability(&capa) == 0);
-
ipsec_sa_param_fill(&param_out,
- false, false, 0x4a2cbfe7, &out_tunnel,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP,
+ 0x4a2cbfe7, &out_tunnel,
ODP_CIPHER_ALG_AES_GCM, &key_mcgrew_gcm_4,
ODP_AUTH_ALG_AES_GCM, NULL,
&key_mcgrew_gcm_salt_4, NULL);
ipsec_sa_param_fill(&param_in,
- true, false, 0x4a2cbfe7, &in_tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 0x4a2cbfe7, &in_tunnel,
ODP_CIPHER_ALG_AES_GCM, &key_mcgrew_gcm_4,
ODP_AUTH_ALG_AES_GCM, NULL,
&key_mcgrew_gcm_salt_4, NULL);
@@ -2102,7 +2109,6 @@ static void test_in_ipv6_esp_reass_success(void)
odp_ipsec_tunnel_param_t in_tunnel, out_tunnel;
odp_ipsec_sa_param_t param_in, param_out;
odp_ipsec_sa_t out_sa, in_sa;
- odp_ipsec_capability_t capa;
uint8_t src[16] = {
0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
0x02, 0x11, 0x43, 0xff, 0xfe, 0x4a, 0xd7, 0x0a,
@@ -2119,16 +2125,16 @@ static void test_in_ipv6_esp_reass_success(void)
out_tunnel.ipv6.dst_addr = &dst;
out_tunnel.ipv6.hlimit = 64;
- CU_ASSERT(odp_ipsec_capability(&capa) == 0);
-
ipsec_sa_param_fill(&param_out,
- false, false, 0x4a2cbfe7, &out_tunnel,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP,
+ 0x4a2cbfe7, &out_tunnel,
ODP_CIPHER_ALG_AES_GCM, &key_mcgrew_gcm_4,
ODP_AUTH_ALG_AES_GCM, NULL,
&key_mcgrew_gcm_salt_4, NULL);
ipsec_sa_param_fill(&param_in,
- true, false, 0x4a2cbfe7, &in_tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 0x4a2cbfe7, &in_tunnel,
ODP_CIPHER_ALG_AES_GCM, &key_mcgrew_gcm_4,
ODP_AUTH_ALG_AES_GCM, NULL,
&key_mcgrew_gcm_salt_4, NULL);
@@ -2163,7 +2169,6 @@ static void test_in_ipv6_esp_reass_incomp(void)
odp_ipsec_tunnel_param_t in_tunnel, out_tunnel;
odp_ipsec_sa_param_t param_in, param_out;
odp_ipsec_sa_t out_sa, in_sa;
- odp_ipsec_capability_t capa;
uint8_t src[16] = {
0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
0x02, 0x11, 0x43, 0xff, 0xfe, 0x4a, 0xd7, 0x0a,
@@ -2179,16 +2184,16 @@ static void test_in_ipv6_esp_reass_incomp(void)
out_tunnel.ipv6.src_addr = &src;
out_tunnel.ipv6.dst_addr = &dst;
- CU_ASSERT(odp_ipsec_capability(&capa) == 0);
-
ipsec_sa_param_fill(&param_out,
- false, false, 0x4a2cbfe7, &out_tunnel,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP,
+ 0x4a2cbfe7, &out_tunnel,
ODP_CIPHER_ALG_AES_GCM, &key_mcgrew_gcm_4,
ODP_AUTH_ALG_AES_GCM, NULL,
&key_mcgrew_gcm_salt_4, NULL);
ipsec_sa_param_fill(&param_in,
- true, false, 0x4a2cbfe7, &in_tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 0x4a2cbfe7, &in_tunnel,
ODP_CIPHER_ALG_AES_GCM, &key_mcgrew_gcm_4,
ODP_AUTH_ALG_AES_GCM, NULL,
&key_mcgrew_gcm_salt_4, NULL);
@@ -2218,7 +2223,8 @@ static void test_in_ipv4_null_aes_xcbc_esp(void)
memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t));
ipsec_sa_param_fill(&param,
- true, false, 0x100, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 0x100, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_AES_XCBC_MAC, &key_auth_aes_xcbc_128,
NULL, NULL);
@@ -2245,15 +2251,7 @@ static void test_in_ipv4_null_aes_xcbc_esp(void)
ipsec_sa_destroy(sa);
}
-static void ipsec_test_capability(void)
-{
- odp_ipsec_capability_t capa;
-
- CU_ASSERT(odp_ipsec_capability(&capa) == 0);
-}
-
odp_testinfo_t ipsec_in_suite[] = {
- ODP_TEST_INFO(ipsec_test_capability),
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_rfc3602_5_esp,
ipsec_check_esp_aes_cbc_128_null),
ODP_TEST_INFO_CONDITIONAL(test_in_ipv4_rfc3602_6_esp,
diff --git a/test/validation/api/ipsec/ipsec_test_out.c b/test/validation/api/ipsec/ipsec_test_out.c
index 799988c38..4e3230844 100644
--- a/test/validation/api/ipsec/ipsec_test_out.c
+++ b/test/validation/api/ipsec/ipsec_test_out.c
@@ -25,6 +25,8 @@ typedef struct {
enum ipsec_test_stats stats;
} ipsec_test_flags;
+static void test_out_in_all(const ipsec_test_flags *flags);
+
struct cipher_param {
const char *name;
odp_cipher_alg_t algo;
@@ -72,6 +74,16 @@ static struct auth_param auths[] = {
ALG(ODP_AUTH_ALG_AES_XCBC_MAC, &key_5a_128, NULL)
};
+/*
+ * Integrity algorithms that can be used in AH but not in ESP as
+ * individual algorithms (combined with a cipher).
+ */
+static struct auth_param ah_auths[] = {
+ ALG(ODP_AUTH_ALG_AES_GMAC, &key_a5_128, &key_mcgrew_gcm_salt_2),
+ ALG(ODP_AUTH_ALG_AES_GMAC, &key_a5_192, &key_mcgrew_gcm_salt_2),
+ ALG(ODP_AUTH_ALG_AES_GMAC, &key_a5_256, &key_mcgrew_gcm_salt_2),
+};
+
struct cipher_auth_comb_param {
struct cipher_param cipher;
struct auth_param auth;
@@ -126,7 +138,7 @@ static void test_out_ipv4_ah_sha256(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- false, true, 123, NULL,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -165,7 +177,7 @@ static void test_out_ipv4_ah_sha256_tun_ipv4(void)
tunnel.ipv4.ttl = 64;
ipsec_sa_param_fill(&param,
- false, true, 123, &tunnel,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_AH, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -210,7 +222,7 @@ static void test_out_ipv4_ah_sha256_tun_ipv6(void)
tunnel.ipv6.hlimit = 64;
ipsec_sa_param_fill(&param,
- false, true, 123, &tunnel,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_AH, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -240,7 +252,7 @@ static void test_out_ipv4_esp_null_sha256(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- false, false, 123, NULL,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -279,7 +291,7 @@ static void test_out_ipv4_esp_null_sha256_tun_ipv4(void)
tunnel.ipv4.ttl = 64;
ipsec_sa_param_fill(&param,
- false, false, 123, &tunnel,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -325,7 +337,7 @@ static void test_out_ipv4_esp_null_sha256_tun_ipv6(void)
tunnel.ipv6.hlimit = 64;
ipsec_sa_param_fill(&param,
- false, false, 123, &tunnel,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -483,6 +495,7 @@ static void test_out_in_common(const ipsec_test_flags *flags,
};
odp_ipsec_sa_param_t param;
odp_ipsec_stats_t stats;
+ odp_ipsec_protocol_t proto = flags->ah ? ODP_IPSEC_AH : ODP_IPSEC_ESP;
odp_ipsec_sa_t sa_out;
odp_ipsec_sa_t sa_in;
odp_proto_l3_type_t out_l3_type = ODP_PROTO_L3_TYPE_IPV4;
@@ -514,7 +527,7 @@ static void test_out_in_common(const ipsec_test_flags *flags,
}
ipsec_sa_param_fill(&param,
- false, flags->ah, 123, tun_ptr,
+ ODP_IPSEC_DIR_OUTBOUND, proto, 123, tun_ptr,
cipher, cipher_key,
auth, auth_key,
cipher_key_extra, auth_key_extra);
@@ -527,7 +540,7 @@ static void test_out_in_common(const ipsec_test_flags *flags,
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa_out);
ipsec_sa_param_fill(&param,
- true, flags->ah, 123, tun_ptr,
+ ODP_IPSEC_DIR_INBOUND, proto, 123, tun_ptr,
cipher, cipher_key,
auth, auth_key,
cipher_key_extra, auth_key_extra);
@@ -665,21 +678,22 @@ static void test_esp_out_in(struct cipher_param *cipher,
cipher->key_extra, auth->key_extra);
}
-static void test_esp_out_in_all(ipsec_test_flags *flags)
+static void test_esp_out_in_all(const ipsec_test_flags *flags_in)
{
uint32_t c;
uint32_t a;
+ ipsec_test_flags flags = *flags_in;
- flags->ah = false;
+ flags.ah = false;
for (c = 0; c < ARRAY_SIZE(ciphers); c++)
for (a = 0; a < ARRAY_SIZE(auths); a++)
- test_esp_out_in(&ciphers[c], &auths[a], flags);
+ test_esp_out_in(&ciphers[c], &auths[a], &flags);
for (c = 0; c < ARRAY_SIZE(cipher_auth_comb); c++)
test_esp_out_in(&cipher_auth_comb[c].cipher,
&cipher_auth_comb[c].auth,
- flags);
+ &flags);
}
/*
@@ -703,25 +717,26 @@ static int is_out_mode_inline(void)
return suite_context.outbound_op_mode == ODP_IPSEC_OP_MODE_INLINE;
}
-static void test_esp_out_in_all_hdr_in_packet(void)
+static void test_inline_hdr_in_packet(void)
{
ipsec_test_flags flags = {
.part_flags.inline_hdr_in_packet = true,
};
- test_esp_out_in_all(&flags);
+ test_out_in_all(&flags);
}
-static void test_ah_out_in(struct auth_param *auth)
+static void test_ah_out_in(struct auth_param *auth,
+ const ipsec_test_flags *flags_in)
{
int auth_keylen = auth->key ? 8 * auth->key->length : 0;
- ipsec_test_flags flags;
+ ipsec_test_flags flags = *flags_in;
if (ipsec_check_ah(auth->algo, auth_keylen) != ODP_TEST_ACTIVE)
return;
- printf("\n %s (keylen %d) ", auth->name, auth_keylen);
+ if (flags.display_algo)
+ printf("\n %s (keylen %d) ", auth->name, auth_keylen);
- memset(&flags, 0, sizeof(flags));
flags.ah = true;
test_out_in_common(&flags, ODP_CIPHER_ALG_NULL, NULL,
@@ -729,22 +744,41 @@ static void test_ah_out_in(struct auth_param *auth)
NULL, auth->key_extra);
}
-static void test_ah_out_in_all(void)
+static void test_ah_out_in_all(const ipsec_test_flags *flags)
{
uint32_t a;
for (a = 0; a < ARRAY_SIZE(auths); a++)
- test_ah_out_in(&auths[a]);
+ test_ah_out_in(&auths[a], flags);
+ for (a = 0; a < ARRAY_SIZE(ah_auths); a++)
+ test_ah_out_in(&ah_auths[a], flags);
+}
+
+static void test_ah_out_in_all_basic(void)
+{
+ ipsec_test_flags flags;
+
+ memset(&flags, 0, sizeof(flags));
+ flags.display_algo = true;
+
+ test_ah_out_in_all(&flags);
+
printf("\n ");
}
+static void test_out_in_all(const ipsec_test_flags *flags)
+{
+ test_esp_out_in_all(flags);
+ test_ah_out_in_all(flags);
+}
+
static void test_out_ipv4_esp_udp_null_sha256(void)
{
odp_ipsec_sa_param_t param;
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- false, false, 123, NULL,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -769,42 +803,6 @@ static void test_out_ipv4_esp_udp_null_sha256(void)
ipsec_sa_destroy(sa);
}
-static void test_out_ipv4_ah_aes_gmac_128(void)
-{
- ipsec_test_flags flags;
-
- memset(&flags, 0, sizeof(flags));
- flags.ah = true;
-
- test_out_in_common(&flags, ODP_CIPHER_ALG_NULL, NULL,
- ODP_AUTH_ALG_AES_GMAC, &key_a5_128,
- NULL, &key_mcgrew_gcm_salt_2);
-}
-
-static void test_out_ipv4_ah_aes_gmac_192(void)
-{
- ipsec_test_flags flags;
-
- memset(&flags, 0, sizeof(flags));
- flags.ah = true;
-
- test_out_in_common(&flags, ODP_CIPHER_ALG_NULL, NULL,
- ODP_AUTH_ALG_AES_GMAC, &key_a5_192,
- NULL, &key_mcgrew_gcm_salt_2);
-}
-
-static void test_out_ipv4_ah_aes_gmac_256(void)
-{
- ipsec_test_flags flags;
-
- memset(&flags, 0, sizeof(flags));
- flags.ah = true;
-
- test_out_in_common(&flags, ODP_CIPHER_ALG_NULL, NULL,
- ODP_AUTH_ALG_AES_GMAC, &key_a5_256,
- NULL, &key_mcgrew_gcm_salt_2);
-}
-
static void test_out_ipv4_ah_sha256_frag_check(void)
{
odp_ipsec_sa_param_t param;
@@ -816,7 +814,7 @@ static void test_out_ipv4_ah_sha256_frag_check(void)
memset(&test2, 0, sizeof(ipsec_test_part));
ipsec_sa_param_fill(&param,
- false, true, 123, NULL,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -856,7 +854,7 @@ static void test_out_ipv4_ah_sha256_frag_check_2(void)
memset(&test, 0, sizeof(ipsec_test_part));
ipsec_sa_param_fill(&param,
- false, true, 123, NULL,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -903,7 +901,7 @@ static void test_out_ipv4_esp_null_sha256_frag_check(void)
memset(&test2, 0, sizeof(ipsec_test_part));
ipsec_sa_param_fill(&param,
- false, false, 123, NULL,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -944,7 +942,7 @@ static void test_out_ipv4_esp_null_sha256_frag_check_2(void)
memset(&test, 0, sizeof(ipsec_test_part));
ipsec_sa_param_fill(&param,
- false, false, 123, NULL,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -987,7 +985,7 @@ static void test_out_ipv6_ah_sha256(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- false, true, 123, NULL,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_AH, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1026,7 +1024,7 @@ static void test_out_ipv6_ah_sha256_tun_ipv4(void)
tunnel.ipv4.ttl = 64;
ipsec_sa_param_fill(&param,
- false, true, 123, &tunnel,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_AH, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1071,7 +1069,7 @@ static void test_out_ipv6_ah_sha256_tun_ipv6(void)
tunnel.ipv6.hlimit = 64;
ipsec_sa_param_fill(&param,
- false, true, 123, &tunnel,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_AH, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1101,7 +1099,7 @@ static void test_out_ipv6_esp_null_sha256(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- false, false, 123, NULL,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1140,7 +1138,7 @@ static void test_out_ipv6_esp_null_sha256_tun_ipv4(void)
tunnel.ipv4.ttl = 64;
ipsec_sa_param_fill(&param,
- false, false, 123, &tunnel,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1186,7 +1184,7 @@ static void test_out_ipv6_esp_null_sha256_tun_ipv6(void)
tunnel.ipv6.hlimit = 64;
ipsec_sa_param_fill(&param,
- false, false, 123, &tunnel,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1217,7 +1215,7 @@ static void test_out_ipv6_esp_udp_null_sha256(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- false, false, 123, NULL,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1265,7 +1263,7 @@ static void test_out_dummy_esp_null_sha256_tun(odp_ipsec_tunnel_param_t tunnel)
return;
ipsec_sa_param_fill(&param,
- false, false, 123, &tunnel,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1275,7 +1273,7 @@ static void test_out_dummy_esp_null_sha256_tun(odp_ipsec_tunnel_param_t tunnel)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
ipsec_sa_param_fill(&param,
- true, false, 123, &tunnel,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1353,7 +1351,7 @@ static void test_out_ipv4_udp_esp_null_sha256(void)
odp_ipsec_sa_t sa;
ipsec_sa_param_fill(&param,
- false, false, 123, NULL,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
NULL, NULL);
@@ -1394,7 +1392,8 @@ static void test_out_ipv4_null_aes_xcbc(void)
tunnel.ipv4.ttl = 64;
ipsec_sa_param_fill(&param,
- false, false, 0x100, &tunnel,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP,
+ 0x100, &tunnel,
ODP_CIPHER_ALG_NULL, NULL,
ODP_AUTH_ALG_AES_XCBC_MAC, &key_auth_aes_xcbc_128,
NULL, NULL);
@@ -1431,12 +1430,9 @@ static void test_sa_info(void)
odp_ipsec_sa_param_t param_in;
odp_ipsec_sa_info_t info_out;
odp_ipsec_sa_info_t info_in;
- odp_ipsec_capability_t capa;
odp_ipsec_sa_t sa_out;
odp_ipsec_sa_t sa_in;
- CU_ASSERT_EQUAL(0, odp_ipsec_capability(&capa));
-
memset(&tunnel_out, 0, sizeof(tunnel_out));
memset(&tunnel_in, 0, sizeof(tunnel_in));
@@ -1445,7 +1441,8 @@ static void test_sa_info(void)
tunnel_out.ipv4.dst_addr = &dst;
ipsec_sa_param_fill(&param_out,
- false, false, 123, &tunnel_out,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP,
+ 123, &tunnel_out,
ODP_CIPHER_ALG_AES_CBC, &key_a5_128,
ODP_AUTH_ALG_SHA1_HMAC, &key_5a_160,
NULL, NULL);
@@ -1455,7 +1452,8 @@ static void test_sa_info(void)
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa_out);
ipsec_sa_param_fill(&param_in,
- true, false, 123, &tunnel_in,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ 123, &tunnel_in,
ODP_CIPHER_ALG_AES_CBC, &key_a5_128,
ODP_AUTH_ALG_SHA1_HMAC, &key_5a_160,
NULL, NULL);
@@ -1557,7 +1555,7 @@ static void test_sa_info(void)
* mode SA and ODP_IPSEC_DSTADD_SPI lookup mode.
*/
ipsec_sa_param_fill(&param_in,
- true, false, 123, NULL,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, NULL,
ODP_CIPHER_ALG_AES_CBC, &key_a5_128,
ODP_AUTH_ALG_SHA1_HMAC, &key_5a_160,
NULL, NULL);
@@ -1588,7 +1586,7 @@ static void test_test_sa_update_seq_num(void)
flags.display_algo = true;
flags.part_flags.test_sa_seq_num = true;
- test_esp_out_in_all(&flags);
+ test_out_in_all(&flags);
printf("\n ");
}
@@ -1664,15 +1662,15 @@ static void test_ipsec_stats(void)
printf("\n Stats : success");
flags.stats = IPSEC_TEST_STATS_SUCCESS;
- test_esp_out_in_all(&flags);
+ test_out_in_all(&flags);
printf("\n Stats : proto err");
flags.stats = IPSEC_TEST_STATS_PROTO_ERR;
- test_esp_out_in_all(&flags);
+ test_out_in_all(&flags);
printf("\n Stats : auth err");
flags.stats = IPSEC_TEST_STATS_AUTH_ERR;
- test_esp_out_in_all(&flags);
+ test_out_in_all(&flags);
printf("\n ");
}
@@ -1793,7 +1791,8 @@ static void test_max_num_sa(void)
tun_dst = 0x0a800000 + n;
ipsec_sa_param_fill(&param,
- false, false, spi_start + n, &tun,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP,
+ spi_start + n, &tun,
ODP_CIPHER_ALG_AES_CBC, &cipher_key,
ODP_AUTH_ALG_SHA1_HMAC, &auth_key,
NULL, NULL);
@@ -1801,7 +1800,8 @@ static void test_max_num_sa(void)
CU_ASSERT_FATAL(sa_out[n] != ODP_IPSEC_SA_INVALID);
ipsec_sa_param_fill(&param,
- true, false, spi_start + n, &tun,
+ ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
+ spi_start + n, &tun,
ODP_CIPHER_ALG_AES_CBC, &cipher_key,
ODP_AUTH_ALG_SHA1_HMAC, &auth_key,
NULL, NULL);
@@ -1820,7 +1820,8 @@ static void test_max_num_sa(void)
tun_dst = 0x0a800000 + n;
ipsec_sa_param_fill(&param,
- false, false, spi_start + n, &tun,
+ ODP_IPSEC_DIR_OUTBOUND, ODP_IPSEC_ESP,
+ spi_start + n, &tun,
ODP_CIPHER_ALG_AES_CBC, &cipher_key,
ODP_AUTH_ALG_SHA1_HMAC, &auth_key,
NULL, NULL);
@@ -1860,12 +1861,6 @@ odp_testinfo_t ipsec_out_suite[] = {
ipsec_check_esp_null_sha256),
ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_udp_null_sha256,
ipsec_check_esp_null_sha256),
- ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_ah_aes_gmac_128,
- ipsec_check_ah_aes_gmac_128),
- ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_ah_aes_gmac_192,
- ipsec_check_ah_aes_gmac_192),
- ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_ah_aes_gmac_256,
- ipsec_check_ah_aes_gmac_256),
ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_ah_sha256_frag_check,
ipsec_check_ah_sha256),
ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_ah_sha256_frag_check_2,
@@ -1901,9 +1896,9 @@ odp_testinfo_t ipsec_out_suite[] = {
ODP_TEST_INFO_CONDITIONAL(test_test_sa_update_seq_num,
ipsec_check_test_sa_update_seq_num),
ODP_TEST_INFO(test_esp_out_in_all_basic),
- ODP_TEST_INFO_CONDITIONAL(test_esp_out_in_all_hdr_in_packet,
+ ODP_TEST_INFO_CONDITIONAL(test_inline_hdr_in_packet,
is_out_mode_inline),
- ODP_TEST_INFO(test_ah_out_in_all),
+ ODP_TEST_INFO(test_ah_out_in_all_basic),
ODP_TEST_INFO(test_ipsec_stats),
ODP_TEST_INFO(test_udp_encap),
ODP_TEST_INFO_CONDITIONAL(test_max_num_sa,
diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c
index f638ddd8c..1ddff1ae1 100644
--- a/test/validation/api/packet/packet.c
+++ b/test/validation/api/packet/packet.c
@@ -3265,6 +3265,52 @@ static void packet_test_max_pools(void)
CU_ASSERT(odp_pool_destroy(pool[i]) == 0);
}
+static void packet_test_user_area(void)
+{
+ odp_pool_param_t param;
+ odp_packet_t pkt;
+ odp_pool_t pool;
+
+ memcpy(&param, &default_param, sizeof(odp_pool_param_t));
+
+ param.pkt.uarea_size = 0;
+ pool = odp_pool_create("zero_uarea", &param);
+ CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+ pkt = odp_packet_alloc(pool, param.pkt.len);
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+ CU_ASSERT(odp_packet_user_area(pkt) == NULL);
+ CU_ASSERT(odp_packet_user_area_size(pkt) == 0);
+ odp_packet_free(pkt);
+ CU_ASSERT(odp_pool_destroy(pool) == 0);
+
+ param.pkt.uarea_size = 1;
+ pool = odp_pool_create("one_uarea", &param);
+ CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+ pkt = odp_packet_alloc(pool, param.pkt.len);
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+ CU_ASSERT_FATAL(odp_packet_user_area(pkt) != NULL);
+ CU_ASSERT(odp_packet_user_area_size(pkt) == 1);
+ *(char *)odp_packet_user_area(pkt) = 0;
+ CU_ASSERT_FATAL(odp_packet_is_valid(pkt) == 1);
+ odp_packet_free(pkt);
+ CU_ASSERT(odp_pool_destroy(pool) == 0);
+
+ if (pool_capa.pkt.max_uarea_size)
+ param.pkt.uarea_size = pool_capa.pkt.max_uarea_size;
+ else
+ param.pkt.uarea_size = 512;
+ pool = odp_pool_create("max_uarea", &param);
+ CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+ pkt = odp_packet_alloc(pool, param.pkt.len);
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+ CU_ASSERT_FATAL(odp_packet_user_area(pkt) != NULL);
+ CU_ASSERT(odp_packet_user_area_size(pkt) == param.pkt.uarea_size);
+ memset(odp_packet_user_area(pkt), 0, param.pkt.uarea_size);
+ CU_ASSERT_FATAL(odp_packet_is_valid(pkt) == 1);
+ odp_packet_free(pkt);
+ CU_ASSERT(odp_pool_destroy(pool) == 0);
+}
+
static int packet_parse_suite_init(void)
{
int num_test_pkt, i;
@@ -4254,6 +4300,7 @@ odp_testinfo_t packet_suite[] = {
ODP_TEST_INFO(packet_test_offset),
ODP_TEST_INFO(packet_test_ref),
ODP_TEST_INFO(packet_test_max_pools),
+ ODP_TEST_INFO(packet_test_user_area),
ODP_TEST_INFO_NULL,
};
diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c
index 10a2297ef..dbb6f5371 100644
--- a/test/validation/api/pktio/pktio.c
+++ b/test/validation/api/pktio/pktio.c
@@ -4139,7 +4139,9 @@ static int create_pool(const char *iface, int num)
odp_pool_param_init(&params);
set_pool_len(&params, &pool_capa);
- params.pkt.num = PKT_BUF_NUM;
+ /* Allocate enough buffers taking into consideration core starvation
+ * due to caching */
+ params.pkt.num = PKT_BUF_NUM + params.pkt.cache_size;
params.type = ODP_POOL_PACKET;
snprintf(pool_name, sizeof(pool_name), "pkt_pool_%s_%d",
diff --git a/test/validation/api/pool/pool.c b/test/validation/api/pool/pool.c
index 866f93020..8dad89d81 100644
--- a/test/validation/api/pool/pool.c
+++ b/test/validation/api/pool/pool.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2014-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
@@ -42,6 +42,27 @@ 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)
+{
+ odp_pool_param_t param;
+
+ odp_pool_param_init(&param);
+
+ CU_ASSERT(param.buf.cache_size >= global_pool_capa.buf.min_cache_size &&
+ param.buf.cache_size <= global_pool_capa.buf.max_cache_size);
+
+ CU_ASSERT(param.pkt.max_num == 0);
+ CU_ASSERT(param.pkt.num_subparam == 0);
+ CU_ASSERT(param.pkt.cache_size >= global_pool_capa.pkt.min_cache_size &&
+ param.pkt.cache_size <= global_pool_capa.pkt.max_cache_size);
+
+ CU_ASSERT(param.tmo.cache_size >= global_pool_capa.tmo.min_cache_size &&
+ param.tmo.cache_size <= global_pool_capa.tmo.max_cache_size);
+
+ CU_ASSERT(param.vector.cache_size >= global_pool_capa.vector.min_cache_size &&
+ param.vector.cache_size <= global_pool_capa.vector.max_cache_size);
+}
+
static void pool_create_destroy(odp_pool_param_t *param)
{
odp_pool_t pool;
@@ -1737,6 +1758,7 @@ static int check_pool_ext_segment_support(void)
}
odp_testinfo_t pool_suite[] = {
+ ODP_TEST_INFO(pool_test_param_init),
ODP_TEST_INFO(pool_test_create_destroy_buffer),
ODP_TEST_INFO(pool_test_create_destroy_packet),
ODP_TEST_INFO(pool_test_create_destroy_timeout),
diff --git a/test/validation/api/queue/queue.c b/test/validation/api/queue/queue.c
index 7b39da433..ec6863628 100644
--- a/test/validation/api/queue/queue.c
+++ b/test/validation/api/queue/queue.c
@@ -84,7 +84,9 @@ static int queue_suite_init(void)
odp_pool_param_init(&params);
params.buf.size = 4;
- params.buf.num = MAX_NUM_EVENT;
+ /* Allocate enough buffers taking into consideration core starvation
+ * due to caching */
+ params.buf.num = MAX_NUM_EVENT + params.buf.cache_size;
params.type = ODP_POOL_BUFFER;
pool = odp_pool_create("msg_pool", &params);
diff --git a/test/validation/api/random/Makefile.am b/test/validation/api/random/Makefile.am
index e24ce0af7..743ecf1ff 100644
--- a/test/validation/api/random/Makefile.am
+++ b/test/validation/api/random/Makefile.am
@@ -2,3 +2,4 @@ include ../Makefile.inc
test_PROGRAMS = random_main
random_main_SOURCES = random.c
+LDADD += -lm
diff --git a/test/validation/api/random/random.c b/test/validation/api/random/random.c
index 481ceb303..97e367678 100644
--- a/test/validation/api/random/random.c
+++ b/test/validation/api/random/random.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
@@ -7,7 +8,7 @@
#include <odp_api.h>
#include <odp_cunit_common.h>
-static void random_test_get_size(void)
+static void random_test_get_size(odp_random_kind_t kind)
{
/* odp_random_data may fail to return data on every call (i.e. lack of
* entropy). Therefore loop with some sane loop timeout value. Note that
@@ -24,7 +25,7 @@ static void random_test_get_size(void)
do {
ret = odp_random_data(buf + bytes, sizeof(buf) - bytes,
- ODP_RANDOM_BASIC);
+ kind);
bytes += ret;
if (ret < 0 || bytes >= sizeof(buf))
break;
@@ -36,6 +37,21 @@ static void random_test_get_size(void)
CU_ASSERT(bytes == (int32_t)sizeof(buf));
}
+static void random_test_get_size_basic(void)
+{
+ random_test_get_size(ODP_RANDOM_BASIC);
+}
+
+static void random_test_get_size_crypto(void)
+{
+ random_test_get_size(ODP_RANDOM_CRYPTO);
+}
+
+static void random_test_get_size_true(void)
+{
+ random_test_get_size(ODP_RANDOM_TRUE);
+}
+
static void random_test_kind(void)
{
int32_t rc;
@@ -80,10 +96,424 @@ static void random_test_repeat(void)
CU_ASSERT(memcmp(buf1, buf2, sizeof(buf1)) == 0);
}
+static void random_data(uint8_t *buf, uint32_t len, odp_random_kind_t kind)
+{
+ static uint64_t seed;
+
+ switch (kind) {
+ case ODP_RANDOM_BASIC:
+ case ODP_RANDOM_CRYPTO:
+ case ODP_RANDOM_TRUE:
+ for (uint32_t i = 0; i < len;) {
+ int32_t r = odp_random_data(buf + i, len - i, kind);
+
+ CU_ASSERT_FATAL(r >= 0);
+ i += r;
+ }
+ break;
+ default:
+ CU_ASSERT_FATAL(odp_random_test_data(buf, len, &seed) ==
+ (int32_t)len);
+ }
+}
+
+static void random_test_align_and_overflow(odp_random_kind_t kind)
+{
+ uint8_t ODP_ALIGNED_CACHE buf[64];
+
+ for (int align = 8; align < 16; align++) {
+ for (int len = 1; len <= 16; len++) {
+ memset(buf, 1, sizeof(buf));
+ random_data(buf + align, len, kind);
+ CU_ASSERT(buf[align - 1] == 1);
+ CU_ASSERT(buf[align + len] == 1);
+ }
+ }
+}
+
+static void random_test_align_and_overflow_test(void)
+{
+ random_test_align_and_overflow(-1);
+}
+
+static void random_test_align_and_overflow_basic(void)
+{
+ random_test_align_and_overflow(ODP_RANDOM_BASIC);
+}
+
+static void random_test_align_and_overflow_crypto(void)
+{
+ random_test_align_and_overflow(ODP_RANDOM_CRYPTO);
+}
+
+static void random_test_align_and_overflow_true(void)
+{
+ random_test_align_and_overflow(ODP_RANDOM_TRUE);
+}
+
+/*
+ * Randomness tests
+ *
+ * The purpose of the following tests is to check that random data looks random.
+ * Some of the tests are based on [1].
+ *
+ * [1] Special Publication 800-22 revision 1a: A Statistical Test Suite for
+ * Random and Pseudorandom Number Generators for Cryptographic Applications
+ * National Institute of Standards and Technology (NIST), April 2010
+ * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-22r1a.pdf
+ */
+
+/*
+ * Alpha for P-value tests. This does not affect the tests that use a
+ * precomputed critical value.
+ */
+static const double alpha = 0.00000001;
+
+static uint32_t random_bits(int n, odp_random_kind_t kind)
+{
+ static uint8_t buf[32 * 1024];
+ const int size = sizeof(buf);
+ static int cur_n;
+ static odp_random_kind_t cur_kind;
+ static int bit;
+ uint32_t r = 0;
+
+ if (n != cur_n || kind != cur_kind) {
+ cur_n = n;
+ cur_kind = kind;
+ bit = size * 8;
+ }
+
+ for (int i = 0; i < n; ) {
+ if (bit >= size * 8) {
+ random_data(buf, size, kind);
+ bit = 0;
+ }
+ if (n - i >= 8 && !(bit & 7)) {
+ /* Full byte. */
+ r <<= 8;
+ r |= buf[bit / 8];
+ bit += 8;
+ i += 8;
+ continue;
+ }
+ /* Single bit. */
+ r <<= 1;
+ r |= (buf[bit / 8] >> (7 - (bit & 7))) & 1;
+ bit++;
+ i++;
+ }
+
+ return r;
+}
+
+static const char *res_str(int pass)
+{
+ return pass ? "pass" : "FAIL";
+}
+
+/*
+ * Pearson's chi-squared goodness-of-fit test for uniform distribution. The test
+ * is run with multiple different bit block lengths. The null hypothesis is that
+ * each possible bit pattern is equally likely. If the chi-squared statistic is
+ * equal to or larger than the critical value, we conclude that the data is
+ * biased.
+ */
+static void random_test_frequency(odp_random_kind_t kind)
+{
+ /* Mean number of hits per cell. */
+ const uint32_t expected = 50;
+
+ /* From LibreOffice CHISQ.INV.RT(0.00000001; df). */
+ const double critical[] = {
+ 32.8413, 40.1300, 50.8129, 68.0293,
+ 97.0285, 147.463, 237.614, 402.685,
+ 711.187, 1297.50, 2426.64, 4623.37,
+ 8929.74, 17419.3, 34224.0, 67587.1,
+ };
+
+ printf("\n\n");
+
+ for (int bits = 1; bits <= 8; bits++) {
+ const uint32_t cells = 1 << bits;
+ const uint64_t num = expected * cells;
+ uint64_t f[256] = { 0 };
+
+ for (uint64_t i = 0; i < num; i++)
+ f[random_bits(bits, kind)]++;
+
+ double chisq = 0, crit = critical[bits - 1];
+
+ for (uint64_t i = 0; i < cells; i++) {
+ double dif = (double)f[i] - expected;
+
+ chisq += dif * dif / expected;
+ }
+
+ printf("bits %d ; chisq %g ; df %u ; crit %g ; %s\n",
+ bits, chisq, cells - 1, crit, res_str(chisq < crit));
+
+ CU_ASSERT(chisq < crit);
+ }
+
+ printf("\n");
+}
+
+static void random_test_frequency_crypto(void)
+{
+ random_test_frequency(ODP_RANDOM_CRYPTO);
+}
+
+static void random_test_frequency_true(void)
+{
+ random_test_frequency(ODP_RANDOM_TRUE);
+}
+
+/*
+ * Pearson's chi-squared test for independence. The null hypothesis is that the
+ * values of different bytes are independent. If the chi-squared statistic is
+ * equal to or greater than the critical value, we conclude that the bytes in
+ * the byte pairs selected from the data are not independent.
+ */
+static void random_test_independence(odp_random_kind_t kind)
+{
+ /* Mean number of hits per cell. */
+ const uint32_t expected = 100;
+
+ /* LibreOffice CHISQ.INV.RT(0.00000001; 255*255) */
+ const double critical = 67069.2;
+
+ printf("\n\n");
+ printf("critical value: %g\n", critical);
+
+ for (int lag = 1; lag <= 8; lag++) {
+ const uint32_t cells = 256 * 256;
+ const uint64_t num = expected * cells;
+ const int size = 32 * 1024;
+ int pos = size;
+ uint8_t buf[size];
+ uint64_t freq[256][256] = { { 0 } };
+ uint32_t row[256] = { 0 }, col[256] = { 0 };
+
+ for (uint64_t i = 0; i < num; i++) {
+ if (pos + lag >= size) {
+ random_data(buf, size, kind);
+ pos = 0;
+ }
+
+ uint8_t r = buf[pos], c = buf[pos + lag];
+
+ freq[r][c]++;
+ row[r]++;
+ col[c]++;
+ pos++;
+ }
+
+ double chisq = 0;
+
+ for (int i = 0; i < 256; i++) {
+ for (int j = 0; j < 256; j++) {
+ double expected =
+ (double)row[i] * (double)col[j] / (double)num;
+ double diff =
+ (double)freq[i][j] - expected;
+ chisq += diff * diff / expected;
+ }
+ }
+
+ printf("lag %d ; chisq %g ; %s\n",
+ lag, chisq, res_str(chisq < critical));
+
+ CU_ASSERT(chisq < critical);
+ }
+
+ printf("\n");
+}
+
+static void random_test_independence_crypto(void)
+{
+ random_test_independence(ODP_RANDOM_CRYPTO);
+}
+
+/*
+ * Sec. 2.3 Runs Test [1]. The test is run with several different n values. A
+ * few long runs may go unnoticed if n is large, while longer period
+ * non-randomness may go unnoticed if n is small.
+ */
+static void random_test_runs(odp_random_kind_t kind)
+{
+ printf("\n\n");
+ printf("alpha: %g\n", alpha);
+
+ for (int n = 128; n <= 1024 * 1024; n *= 2) {
+ double pi, P_value;
+ int bit = random_bits(1, kind);
+ uint64_t ones = bit, V = 1;
+
+ for (int i = 1; i < n; i++) {
+ int prev_bit = bit;
+
+ bit = random_bits(1, kind);
+ ones += bit;
+ V += (bit != prev_bit);
+ }
+
+ pi = (double)ones / n;
+
+ /*
+ * Skip the prerequisite frequency test (Sec. 2.3.4
+ * step (2)), since it's effectively the same as
+ * random_test_frequency() with bits = 1.
+ */
+
+ P_value = erfc(fabs(V - 2 * n * pi * (1 - pi)) /
+ (2 * sqrt(2 * n) * pi * (1 - pi)));
+ printf("n %d ; pi %g ; V %" PRIu64 " ; P_value %g ; %s\n",
+ n, pi, V, P_value, res_str(P_value >= alpha));
+
+ CU_ASSERT(P_value >= alpha);
+ }
+
+ printf("\n");
+}
+
+static void random_test_runs_crypto(void)
+{
+ random_test_runs(ODP_RANDOM_CRYPTO);
+}
+
+static void random_test_runs_true(void)
+{
+ random_test_runs(ODP_RANDOM_TRUE);
+}
+
+static int mx_bit(uint32_t *m, int r, int c)
+{
+ return (m[r] >> c) & 1;
+}
+
+static int mx_rank(uint32_t *m, int rows, int cols)
+{
+ int rank = 0;
+
+ for (int r = 0, c = 0; r < rows && c < cols; ) {
+ int swapped = r;
+
+ if (!mx_bit(m, r, c)) {
+ for (int sr = r + 1; sr < rows; sr++) {
+ if (mx_bit(m, sr, c)) {
+ uint32_t t = m[r];
+
+ m[r] = m[sr];
+ m[sr] = t;
+ swapped = sr;
+ break;
+ }
+ }
+ if (!mx_bit(m, r, c)) {
+ c++;
+ continue;
+ }
+ }
+
+ rank++;
+
+ for (int sr = swapped + 1; sr < rows; sr++) {
+ if (mx_bit(m, sr, c))
+ m[sr] ^= m[r];
+ }
+
+ r++;
+ }
+
+ return rank;
+}
+
+/*
+ * Sec. 2.5 Binary Matrix Rank Test [1].
+ */
+static void random_test_matrix_rank(odp_random_kind_t kind)
+{
+ const int N = 100; /* [1] recommends at least 38. */
+ const double p[3] = { 0.2888, 0.5776, 0.1336 };
+
+ printf("\n\n");
+ printf("alpha: %g\n", alpha);
+ printf("N: %d\n", N);
+
+ int F[3] = { 0 };
+
+ for (int i = 0; i < N; i++) {
+ uint32_t mx[32];
+
+ random_data((uint8_t *)mx, sizeof(mx), kind);
+
+ switch (mx_rank(mx, 32, 32)) {
+ case 32:
+ F[0]++;
+ break;
+ case 31:
+ F[1]++;
+ break;
+ default:
+ F[2]++;
+ }
+ }
+
+ double chisq, P_value;
+
+ chisq = pow(F[0] - p[0] * N, 2) / (p[0] * N) +
+ pow(F[1] - p[1] * N, 2) / (p[1] * N) +
+ pow(F[2] - p[2] * N, 2) / (p[2] * N);
+ P_value = exp(-chisq / 2);
+
+ printf("P_value %g ; %s\n", P_value, res_str(P_value >= alpha));
+
+ CU_ASSERT(P_value >= alpha);
+}
+
+static void random_test_matrix_rank_crypto(void)
+{
+ random_test_matrix_rank(ODP_RANDOM_CRYPTO);
+}
+
+static void random_test_matrix_rank_true(void)
+{
+ random_test_matrix_rank(ODP_RANDOM_TRUE);
+}
+
+static int check_kind_basic(void)
+{
+ return odp_random_max_kind() >= ODP_RANDOM_BASIC;
+}
+
+static int check_kind_crypto(void)
+{
+ return odp_random_max_kind() >= ODP_RANDOM_CRYPTO;
+}
+
+static int check_kind_true(void)
+{
+ return odp_random_max_kind() >= ODP_RANDOM_TRUE;
+}
+
odp_testinfo_t random_suite[] = {
- ODP_TEST_INFO(random_test_get_size),
+ ODP_TEST_INFO_CONDITIONAL(random_test_get_size_basic, check_kind_basic),
+ ODP_TEST_INFO_CONDITIONAL(random_test_get_size_crypto, check_kind_crypto),
+ ODP_TEST_INFO_CONDITIONAL(random_test_get_size_true, check_kind_true),
ODP_TEST_INFO(random_test_kind),
ODP_TEST_INFO(random_test_repeat),
+ ODP_TEST_INFO(random_test_align_and_overflow_test),
+ ODP_TEST_INFO_CONDITIONAL(random_test_align_and_overflow_basic, check_kind_basic),
+ ODP_TEST_INFO_CONDITIONAL(random_test_align_and_overflow_crypto, check_kind_crypto),
+ ODP_TEST_INFO_CONDITIONAL(random_test_align_and_overflow_true, check_kind_true),
+ ODP_TEST_INFO_CONDITIONAL(random_test_frequency_crypto, check_kind_crypto),
+ ODP_TEST_INFO_CONDITIONAL(random_test_frequency_true, check_kind_true),
+ ODP_TEST_INFO_CONDITIONAL(random_test_independence_crypto, check_kind_crypto),
+ ODP_TEST_INFO_CONDITIONAL(random_test_runs_crypto, check_kind_crypto),
+ ODP_TEST_INFO_CONDITIONAL(random_test_runs_true, check_kind_true),
+ ODP_TEST_INFO_CONDITIONAL(random_test_matrix_rank_crypto, check_kind_crypto),
+ ODP_TEST_INFO_CONDITIONAL(random_test_matrix_rank_true, check_kind_true),
ODP_TEST_INFO_NULL,
};
diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c
index 09dcd8c95..20d36bff7 100644
--- a/test/validation/api/timer/timer.c
+++ b/test/validation/api/timer/timer.c
@@ -19,6 +19,8 @@
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#define MAX_TIMER_POOLS 1024
+
/* Timeout range in milliseconds (ms) */
#define RANGE_MS 2000
@@ -478,6 +480,77 @@ static void timer_pool_create_destroy(void)
CU_ASSERT(odp_queue_destroy(queue) == 0);
}
+static void timer_pool_create_max(void)
+{
+ odp_timer_capability_t capa;
+ odp_timer_pool_param_t tp_param;
+ odp_queue_param_t queue_param;
+ odp_queue_t queue;
+ uint32_t i;
+ int ret;
+ uint64_t tmo_ns = ODP_TIME_SEC_IN_NS;
+ uint64_t res_ns = ODP_TIME_SEC_IN_NS / 10;
+
+ memset(&capa, 0, sizeof(capa));
+ ret = odp_timer_capability(ODP_CLOCK_DEFAULT, &capa);
+ CU_ASSERT_FATAL(ret == 0);
+
+ uint32_t num = capa.max_pools;
+
+ if (num > MAX_TIMER_POOLS)
+ num = MAX_TIMER_POOLS;
+
+ odp_timer_pool_t tp[num];
+ odp_timer_t timer[num];
+
+ if (capa.max_tmo.max_tmo < tmo_ns) {
+ tmo_ns = capa.max_tmo.max_tmo;
+ res_ns = capa.max_tmo.res_ns;
+ }
+
+ odp_queue_param_init(&queue_param);
+
+ if (capa.queue_type_sched)
+ queue_param.type = ODP_QUEUE_TYPE_SCHED;
+
+ queue = odp_queue_create("timer_queue", &queue_param);
+ CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);
+
+ odp_timer_pool_param_init(&tp_param);
+
+ tp_param.res_ns = res_ns;
+ tp_param.min_tmo = tmo_ns / 2;
+ tp_param.max_tmo = tmo_ns;
+ tp_param.num_timers = 1;
+
+ for (i = 0; i < num; i++) {
+ tp[i] = odp_timer_pool_create("test_max", &tp_param);
+ if (tp[i] == ODP_TIMER_POOL_INVALID)
+ ODPH_ERR("Timer pool create failed: %u / %u\n", i, num);
+
+ CU_ASSERT_FATAL(tp[i] != ODP_TIMER_POOL_INVALID);
+ }
+
+ odp_timer_pool_start();
+
+ for (i = 0; i < num; i++) {
+ timer[i] = odp_timer_alloc(tp[i], queue, USER_PTR);
+
+ if (timer[i] == ODP_TIMER_INVALID)
+ ODPH_ERR("Timer alloc failed: %u / %u\n", i, num);
+
+ CU_ASSERT_FATAL(timer[i] != ODP_TIMER_INVALID);
+ }
+
+ for (i = 0; i < num; i++)
+ CU_ASSERT(odp_timer_free(timer[i]) == ODP_EVENT_INVALID);
+
+ for (i = 0; i < num; i++)
+ odp_timer_pool_destroy(tp[i]);
+
+ CU_ASSERT(odp_queue_destroy(queue) == 0);
+}
+
static void timer_pool_max_res(void)
{
odp_timer_capability_t capa;
@@ -1836,6 +1909,7 @@ odp_testinfo_t timer_suite[] = {
ODP_TEST_INFO(timer_test_timeout_pool_alloc),
ODP_TEST_INFO(timer_test_timeout_pool_free),
ODP_TEST_INFO(timer_pool_create_destroy),
+ ODP_TEST_INFO(timer_pool_create_max),
ODP_TEST_INFO(timer_pool_max_res),
ODP_TEST_INFO(timer_pool_tick_info),
ODP_TEST_INFO_CONDITIONAL(timer_test_tmo_event_plain,
diff --git a/test/validation/api/traffic_mngr/traffic_mngr.c b/test/validation/api/traffic_mngr/traffic_mngr.c
index 0899272ba..2c1e79819 100644
--- a/test/validation/api/traffic_mngr/traffic_mngr.c
+++ b/test/validation/api/traffic_mngr/traffic_mngr.c
@@ -1,4 +1,6 @@
/* Copyright (c) 2015-2018, Linaro Limited
+ * Copyright (c) 2022, Marvell
+ * Copyright (c) 2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -336,6 +338,11 @@ static uint32_t cpu_tcp_seq_num;
static int8_t suite_inactive;
+static uint64_t tm_shaper_min_rate;
+static uint64_t tm_shaper_max_rate;
+static uint32_t tm_shaper_min_burst;
+static uint32_t tm_shaper_max_burst;
+
static void busy_wait(uint64_t nanoseconds)
{
odp_time_t start_time, end_time;
@@ -382,6 +389,18 @@ static odp_bool_t approx_eq64(uint64_t val, uint64_t correct)
return false;
}
+static uint64_t
+clamp_rate(uint64_t rate)
+{
+ return MIN(MAX(rate, tm_shaper_min_rate), tm_shaper_max_rate);
+}
+
+static uint32_t
+clamp_burst(uint32_t burst)
+{
+ return MIN(MAX(burst, tm_shaper_min_burst), tm_shaper_max_burst);
+}
+
static int test_overall_capabilities(void)
{
odp_tm_level_capabilities_t *per_level;
@@ -443,6 +462,18 @@ static int test_overall_capabilities(void)
CU_ASSERT(per_level->max_priority != 0);
return -1;
}
+
+ if (per_level->tm_node_shaper_supported) {
+ CU_ASSERT(per_level->max_burst > 0);
+ CU_ASSERT(per_level->min_rate > 0);
+ CU_ASSERT(per_level->max_rate > 0);
+ }
+
+ if (per_level->tm_node_shaper_packet_mode) {
+ CU_ASSERT(per_level->max_burst_packets > 0);
+ CU_ASSERT(per_level->min_rate_packets > 0);
+ CU_ASSERT(per_level->max_rate_packets > 0);
+ }
}
/* At least one pkt priority mode needs to be supported */
@@ -1150,10 +1181,12 @@ static uint32_t send_pkts(odp_tm_queue_t tm_queue, uint32_t num_pkts)
xmt_pkt_desc = &xmt_pkt_descs[xmt_pkt_idx];
/* Alternate calling with odp_tm_enq and odp_tm_enq_with_cnt */
- if ((idx & 1) == 0)
+ if ((idx & 1) == 0) {
rc = odp_tm_enq(tm_queue, odp_pkt);
- else
+ CU_ASSERT(rc <= 0);
+ } else {
rc = odp_tm_enq_with_cnt(tm_queue, odp_pkt);
+ }
xmt_pkt_desc->xmt_idx = xmt_pkt_idx;
if (0 <= rc) {
@@ -2257,13 +2290,39 @@ static int traffic_mngr_suite_init(void)
if (egress_capa.max_levels < NUM_LEVELS)
goto skip_tests;
+ tm_shaper_min_rate = egress_capa.per_level[0].min_rate;
+ tm_shaper_max_rate = egress_capa.per_level[0].max_rate;
+ tm_shaper_min_burst = egress_capa.per_level[0].min_burst;
+ tm_shaper_max_burst = egress_capa.per_level[0].max_burst;
+
for (j = 0; j < NUM_LEVELS; j++) {
+ odp_tm_level_capabilities_t *per_level =
+ &egress_capa.per_level[j];
+
/* Per node fanin */
- if (egress_capa.per_level[j].max_fanin_per_node <
- FANIN_RATIO)
+ if (per_level->max_fanin_per_node < FANIN_RATIO)
break;
+
+ if (j == 0)
+ continue;
+
+ if (per_level->min_rate > tm_shaper_min_rate)
+ tm_shaper_min_rate = per_level->min_rate;
+
+ if (per_level->min_burst > tm_shaper_min_burst)
+ tm_shaper_min_burst = per_level->min_burst;
+
+ if (per_level->max_rate < tm_shaper_max_rate)
+ tm_shaper_max_rate = per_level->max_rate;
+
+ if (per_level->max_burst < tm_shaper_max_burst)
+ tm_shaper_max_burst = per_level->max_burst;
}
+ if (tm_shaper_min_rate > tm_shaper_max_rate ||
+ tm_shaper_min_burst > tm_shaper_max_burst)
+ goto skip_tests;
+
if (j != NUM_LEVELS)
goto skip_tests;
@@ -2345,16 +2404,16 @@ static void check_shaper_profile(char *shaper_name, uint32_t shaper_idx)
rc = odp_tm_shaper_params_read(profile, &shaper_params);
CU_ASSERT(rc == 0);
CU_ASSERT(approx_eq64(shaper_params.commit_rate,
- shaper_idx * MIN_COMMIT_BW));
+ clamp_rate(shaper_idx * MIN_COMMIT_BW)));
CU_ASSERT(approx_eq64(shaper_params.peak_rate,
- shaper_idx * MIN_PEAK_BW));
+ clamp_rate(shaper_idx * MIN_PEAK_BW)));
CU_ASSERT(approx_eq32(shaper_params.commit_burst,
- shaper_idx * MIN_COMMIT_BURST));
+ clamp_burst(shaper_idx * MIN_COMMIT_BURST)));
CU_ASSERT(approx_eq32(shaper_params.peak_burst,
- shaper_idx * MIN_PEAK_BURST));
+ clamp_burst(shaper_idx * MIN_PEAK_BURST)));
CU_ASSERT(shaper_params.shaper_len_adjust == SHAPER_LEN_ADJ);
- CU_ASSERT(shaper_params.dual_rate == 0);
+ CU_ASSERT(shaper_params.dual_rate == true);
}
static void traffic_mngr_test_shaper_profile(void)
@@ -2366,15 +2425,15 @@ static void traffic_mngr_test_shaper_profile(void)
odp_tm_shaper_params_init(&shaper_params);
shaper_params.shaper_len_adjust = SHAPER_LEN_ADJ;
- shaper_params.dual_rate = 0;
+ shaper_params.dual_rate = true;
for (idx = 1; idx <= NUM_SHAPER_TEST_PROFILES; idx++) {
snprintf(shaper_name, sizeof(shaper_name),
"shaper_profile_%" PRIu32, idx);
- shaper_params.commit_rate = idx * MIN_COMMIT_BW;
- shaper_params.peak_rate = idx * MIN_PEAK_BW;
- shaper_params.commit_burst = idx * MIN_COMMIT_BURST;
- shaper_params.peak_burst = idx * MIN_PEAK_BURST;
+ shaper_params.commit_rate = clamp_rate(idx * MIN_COMMIT_BW);
+ shaper_params.peak_rate = clamp_rate(idx * MIN_PEAK_BW);
+ shaper_params.commit_burst = clamp_burst(idx * MIN_COMMIT_BURST);
+ shaper_params.peak_burst = clamp_burst(idx * MIN_PEAK_BURST);
profile = odp_tm_shaper_create(shaper_name, &shaper_params);
CU_ASSERT_FATAL(profile != ODP_TM_INVALID);
@@ -2615,14 +2674,17 @@ static void traffic_mngr_test_wred_profile(void)
static int set_shaper(const char *node_name,
const char *shaper_name,
- const uint64_t commit_bps,
- const uint64_t commit_burst_in_bits)
+ uint64_t commit_bps,
+ uint64_t commit_burst_in_bits)
{
odp_tm_shaper_params_t shaper_params;
odp_tm_shaper_t shaper_profile;
odp_tm_node_t tm_node;
int rc;
+ commit_bps = clamp_rate(commit_bps);
+ commit_burst_in_bits = clamp_burst(commit_burst_in_bits);
+
tm_node = find_tm_node(0, node_name);
if (tm_node == ODP_TM_INVALID) {
ODPH_ERR("find_tm_node(%s) failed\n", node_name);
@@ -2645,6 +2707,11 @@ static int set_shaper(const char *node_name,
CU_ASSERT_FATAL(odp_tm_stop(odp_tm_systems[0]) == 0);
}
+ if (!shaper_name) {
+ shaper_profile = ODP_TM_INVALID;
+ goto skip_profile;
+ }
+
/* First see if a shaper profile already exists with this name, in
* which case we use that profile, else create a new one. */
shaper_profile = odp_tm_shaper_lookup(shaper_name);
@@ -2657,6 +2724,7 @@ static int set_shaper(const char *node_name,
num_shaper_profiles++;
}
+skip_profile:
rc = odp_tm_node_shaper_config(tm_node, shaper_profile);
if (!dynamic_shaper_update) {
@@ -2686,6 +2754,14 @@ static int traffic_mngr_check_shaper(void)
return ODP_TEST_INACTIVE;
}
+ /* This test needs 1 Mbps, 4 Mbps, 10 Mpbs, 40 Mbps, 100 Mbps */
+ if ((tm_shaper_min_rate > 100 * MBPS) || (tm_shaper_max_rate < 1 * MBPS))
+ return ODP_TEST_INACTIVE;
+
+ /* All the subtests run with burst of 10000 bits */
+ if ((tm_shaper_min_burst > 10000) || tm_shaper_max_burst < 10000)
+ return ODP_TEST_INACTIVE;
+
return ODP_TEST_ACTIVE;
}
@@ -2701,6 +2777,15 @@ static int traffic_mngr_check_scheduler(void)
return ODP_TEST_INACTIVE;
}
+ /* Scheduler test test_sched_queue_priority() depends on rate of
+ * 64 Kbps and burst of 5600.
+ */
+ if ((tm_shaper_min_rate > 64 * 1000) ||
+ (tm_shaper_max_rate < 64 * 1000) ||
+ (tm_shaper_min_burst > 5600) ||
+ (tm_shaper_max_burst < 5600))
+ return ODP_TEST_INACTIVE;
+
return ODP_TEST_ACTIVE;
}
@@ -2813,7 +2898,7 @@ static int test_shaper_bw(const char *shaper_name,
}
/* Disable the shaper, so as to get the pkts out quicker. */
- set_shaper(node_name, shaper_name, 0, 0);
+ set_shaper(node_name, NULL, 0, 0);
flush_leftover_pkts(odp_tm_systems[0], rcv_pktin);
CU_ASSERT(odp_tm_is_idle(odp_tm_systems[0]));
return ret_code;
@@ -2949,7 +3034,7 @@ static int test_sched_queue_priority(const char *shaper_name,
* start/stop.
*/
if (dynamic_shaper_update)
- set_shaper(node_name, shaper_name, 0, 0);
+ set_shaper(node_name, NULL, 0, 0);
num_rcv_pkts = receive_pkts(odp_tm_systems[0], rcv_pktin,
pkt_cnt + 4, 64 * 1000);
@@ -2968,7 +3053,7 @@ static int test_sched_queue_priority(const char *shaper_name,
CU_ASSERT(pkts_in_order == pkt_cnt);
/* Disable shaper in case it is still enabled */
- set_shaper(node_name, shaper_name, 0, 0);
+ set_shaper(node_name, NULL, 0, 0);
flush_leftover_pkts(odp_tm_systems[0], rcv_pktin);
CU_ASSERT(odp_tm_is_idle(odp_tm_systems[0]));
return 0;
@@ -3062,7 +3147,7 @@ static int test_sched_node_priority(const char *shaper_name,
* start/stop.
*/
if (dynamic_shaper_update)
- set_shaper(node_name, shaper_name, 0, 0);
+ set_shaper(node_name, NULL, 0, 0);
num_rcv_pkts = receive_pkts(odp_tm_systems[0], rcv_pktin,
pkts_sent, 64 * 1000);
@@ -3075,7 +3160,7 @@ static int test_sched_node_priority(const char *shaper_name,
CU_ASSERT(pkts_in_order == total_pkt_cnt);
/* Disable shaper in case it is still enabled */
- set_shaper(node_name, shaper_name, 0, 0);
+ set_shaper(node_name, NULL, 0, 0);
flush_leftover_pkts(odp_tm_systems[0], rcv_pktin);
CU_ASSERT(odp_tm_is_idle(odp_tm_systems[0]));
return 0;
@@ -3162,7 +3247,7 @@ static int test_sched_wfq(const char *sched_base_name,
* start/stop.
*/
if (dynamic_shaper_update)
- set_shaper(node_name, shaper_name, 0, 0);
+ set_shaper(node_name, NULL, 0, 0);
num_rcv_pkts = receive_pkts(odp_tm_systems[0], rcv_pktin,
pkt_cnt + 4, 64 * 1000);
@@ -3175,7 +3260,7 @@ static int test_sched_wfq(const char *sched_base_name,
}
/* Disable shaper in case it is still enabled */
- set_shaper(node_name, shaper_name, 0, 0);
+ set_shaper(node_name, NULL, 0, 0);
flush_leftover_pkts(odp_tm_systems[0], rcv_pktin);
CU_ASSERT(odp_tm_is_idle(odp_tm_systems[0]));
return 0;
@@ -3279,7 +3364,7 @@ static int test_threshold(const char *threshold_name,
1 * GBPS);
/* Disable the shaper, so as to get the pkts out quicker. */
- set_shaper(node_name, shaper_name, 0, 0);
+ set_shaper(node_name, NULL, 0, 0);
flush_leftover_pkts(odp_tm_systems[0], rcv_pktin);
CU_ASSERT(odp_tm_is_idle(odp_tm_systems[0]));
@@ -3438,7 +3523,7 @@ static int test_byte_wred(const char *wred_name,
* start/stop.
*/
if (dynamic_shaper_update)
- set_shaper(node_name, shaper_name, 0, 0);
+ set_shaper(node_name, NULL, 0, 0);
num_rcv_pkts = receive_pkts(odp_tm_systems[0], rcv_pktin,
num_fill_pkts + pkts_sent, 64 * 1000);
@@ -3450,7 +3535,7 @@ static int test_byte_wred(const char *wred_name,
return -1;
/* Disable shaper in case it is still enabled */
- set_shaper(node_name, shaper_name, 0, 0);
+ set_shaper(node_name, NULL, 0, 0);
flush_leftover_pkts(odp_tm_systems[0], rcv_pktin);
CU_ASSERT(odp_tm_is_idle(odp_tm_systems[0]));
@@ -3531,7 +3616,7 @@ static int test_pkt_wred(const char *wred_name,
* start/stop.
*/
if (dynamic_shaper_update)
- set_shaper(node_name, shaper_name, 0, 0);
+ set_shaper(node_name, NULL, 0, 0);
ret = receive_pkts(odp_tm_systems[0], rcv_pktin,
num_fill_pkts + pkts_sent, 64 * 1000);
@@ -3547,7 +3632,7 @@ static int test_pkt_wred(const char *wred_name,
return -1;
/* Disable shaper in case it is still enabled */
- set_shaper(node_name, shaper_name, 0, 0);
+ set_shaper(node_name, NULL, 0, 0);
flush_leftover_pkts(odp_tm_systems[0], rcv_pktin);
CU_ASSERT(odp_tm_is_idle(odp_tm_systems[0]));
@@ -3622,7 +3707,7 @@ static int test_query_functions(const char *shaper_name,
CU_ASSERT(expected_byte_cnt < query_info.total_byte_cnt);
/* Disable the shaper, so as to get the pkts out quicker. */
- set_shaper(node_name, shaper_name, 0, 0);
+ set_shaper(node_name, NULL, 0, 0);
num_rcv_pkts = receive_pkts(odp_tm_systems[0], rcv_pktin, num_pkts,
commit_bps);
@@ -4166,6 +4251,83 @@ static int test_fanin_info(const char *node_name)
return walk_tree_backwards(node_desc->node);
}
+static void traffic_mngr_test_default_values(void)
+{
+ odp_tm_requirements_t req;
+ odp_tm_shaper_params_t shaper;
+ odp_tm_sched_params_t sched;
+ odp_tm_threshold_params_t threshold;
+ odp_tm_wred_params_t wred;
+ odp_tm_node_params_t node;
+ odp_tm_queue_params_t queue;
+ int n;
+
+ memset(&req, 0xff, sizeof(req));
+ odp_tm_requirements_init(&req);
+ CU_ASSERT_EQUAL(req.num_levels, 0);
+ CU_ASSERT(!req.tm_queue_shaper_needed);
+ CU_ASSERT(!req.tm_queue_wred_needed);
+ CU_ASSERT(!req.tm_queue_dual_slope_needed);
+ CU_ASSERT(!req.tm_queue_threshold_needed);
+ CU_ASSERT(!req.vlan_marking_needed);
+ CU_ASSERT(!req.ecn_marking_needed);
+ CU_ASSERT(!req.drop_prec_marking_needed);
+ for (n = 0; n < ODP_NUM_PACKET_COLORS; n++)
+ CU_ASSERT(!req.marking_colors_needed[n]);
+ CU_ASSERT_EQUAL(req.pkt_prio_mode, ODP_TM_PKT_PRIO_MODE_PRESERVE);
+ for (n = 0; n < ODP_TM_MAX_LEVELS; n++) {
+ odp_tm_level_requirements_t *l_req = &req.per_level[n];
+
+ CU_ASSERT(!l_req->tm_node_shaper_needed);
+ CU_ASSERT(!l_req->tm_node_wred_needed);
+ CU_ASSERT(!l_req->tm_node_dual_slope_needed);
+ CU_ASSERT(!l_req->fair_queuing_needed);
+ CU_ASSERT(!l_req->weights_needed);
+ CU_ASSERT(!l_req->tm_node_threshold_needed);
+ }
+
+ memset(&shaper, 0xff, sizeof(shaper));
+ odp_tm_shaper_params_init(&shaper);
+ CU_ASSERT_EQUAL(shaper.shaper_len_adjust, 0);
+ CU_ASSERT(!shaper.dual_rate);
+ CU_ASSERT(!shaper.packet_mode);
+
+ memset(&sched, 0xff, sizeof(sched));
+ odp_tm_sched_params_init(&sched);
+ 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));
+ odp_tm_threshold_params_init(&threshold);
+ CU_ASSERT(!threshold.enable_max_pkts);
+ CU_ASSERT(!threshold.enable_max_bytes);
+
+ memset(&wred, 0xff, sizeof(wred));
+ odp_tm_wred_params_init(&wred);
+ CU_ASSERT(!wred.enable_wred);
+ CU_ASSERT(!wred.use_byte_fullness);
+
+ memset(&node, 0xff, 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));
+ odp_tm_queue_params_init(&queue);
+ CU_ASSERT_EQUAL(queue.shaper_profile, ODP_TM_INVALID);
+ CU_ASSERT_EQUAL(queue.threshold_profile, ODP_TM_INVALID);
+ for (n = 0; n < ODP_NUM_PACKET_COLORS; n++)
+ 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_capabilities(void)
{
CU_ASSERT(test_overall_capabilities() == 0);
@@ -4180,26 +4342,45 @@ static void traffic_mngr_test_tm_create(void)
static void traffic_mngr_test_shaper(void)
{
- CU_ASSERT(!odp_cunit_ret(test_shaper_bw("bw1",
- "node_1_1_1",
- 0,
- MBPS * 1)));
- CU_ASSERT(!odp_cunit_ret(test_shaper_bw("bw4",
- "node_1_1_1",
- 1,
- 4 * MBPS)));
- CU_ASSERT(!odp_cunit_ret(test_shaper_bw("bw10",
- "node_1_1_1",
- 2,
- 10 * MBPS)));
- CU_ASSERT(!odp_cunit_ret(test_shaper_bw("bw40",
- "node_1_1_1",
- 3,
- 40 * MBPS)));
- CU_ASSERT(!odp_cunit_ret(test_shaper_bw("bw100",
- "node_1_1_2",
- 0,
- 100 * MBPS)));
+ if ((tm_shaper_min_rate <= 1 * MBPS) &&
+ (tm_shaper_max_rate >= 1 * MBPS)) {
+ CU_ASSERT(!odp_cunit_ret(test_shaper_bw("bw1",
+ "node_1_1_1",
+ 0,
+ MBPS * 1)));
+ }
+
+ if ((tm_shaper_min_rate <= 4 * MBPS) &&
+ (tm_shaper_max_rate >= 4 * MBPS)) {
+ CU_ASSERT(!odp_cunit_ret(test_shaper_bw("bw4",
+ "node_1_1_1",
+ 1,
+ 4 * MBPS)));
+ }
+
+ if ((tm_shaper_min_rate <= 10 * MBPS) &&
+ (tm_shaper_max_rate >= 10 * MBPS)) {
+ CU_ASSERT(!odp_cunit_ret(test_shaper_bw("bw10",
+ "node_1_1_1",
+ 2,
+ 10 * MBPS)));
+ }
+
+ if ((tm_shaper_min_rate <= 40 * MBPS) &&
+ (tm_shaper_max_rate >= 40 * MBPS)) {
+ CU_ASSERT(!odp_cunit_ret(test_shaper_bw("bw40",
+ "node_1_1_1",
+ 3,
+ 40 * MBPS)));
+ }
+
+ if ((tm_shaper_min_rate <= 100 * MBPS) &&
+ (tm_shaper_max_rate >= 100 * MBPS)) {
+ CU_ASSERT(!odp_cunit_ret(test_shaper_bw("bw100",
+ "node_1_1_2",
+ 0,
+ 100 * MBPS)));
+ }
}
static void traffic_mngr_test_scheduler(void)
@@ -4318,6 +4499,34 @@ static int traffic_mngr_check_wred(void)
return ODP_TEST_ACTIVE;
}
+static int traffic_mngr_check_byte_wred(void)
+{
+ /* Check if wred is part of created odp_tm_t capabilities */
+ if (!tm_capabilities.tm_queue_wred_supported)
+ return ODP_TEST_INACTIVE;
+
+ if ((tm_shaper_min_rate > 64 * 1000) ||
+ (tm_shaper_max_rate < 64 * 1000) ||
+ (tm_shaper_min_burst > 8 * PKT_BUF_SIZE) ||
+ (tm_shaper_max_burst < 8 * PKT_BUF_SIZE))
+ return ODP_TEST_INACTIVE;
+ return ODP_TEST_ACTIVE;
+}
+
+static int traffic_mngr_check_pkt_wred(void)
+{
+ /* Check if wred is part of created odp_tm_t capabilities */
+ if (!tm_capabilities.tm_queue_wred_supported)
+ return ODP_TEST_INACTIVE;
+
+ if ((tm_shaper_min_rate > 64 * 1000) ||
+ (tm_shaper_max_rate < 64 * 1000) ||
+ (tm_shaper_min_burst > 1000) ||
+ (tm_shaper_max_burst < 1000))
+ return ODP_TEST_INACTIVE;
+ return ODP_TEST_ACTIVE;
+}
+
static void traffic_mngr_test_byte_wred(void)
{
CU_ASSERT(test_byte_wred("byte_wred_30G", "byte_bw_30G",
@@ -4378,6 +4587,13 @@ static int traffic_mngr_check_query(void)
if ((tm_capabilities.tm_queue_query_flags & query_flags) != query_flags)
return ODP_TEST_INACTIVE;
+ /* This test uses 64 Kbps rate and a 1000 bit burst size */
+ if (tm_shaper_min_rate > 64 * 1000 ||
+ tm_shaper_max_rate < 64 * 1000 ||
+ tm_shaper_min_burst > 1000 ||
+ tm_shaper_max_burst < 1000)
+ return ODP_TEST_INACTIVE;
+
return ODP_TEST_ACTIVE;
}
@@ -4454,6 +4670,7 @@ static void traffic_mngr_test_destroy(void)
}
odp_testinfo_t traffic_mngr_suite[] = {
+ ODP_TEST_INFO(traffic_mngr_test_default_values),
ODP_TEST_INFO(traffic_mngr_test_capabilities),
ODP_TEST_INFO(traffic_mngr_test_tm_create),
ODP_TEST_INFO(traffic_mngr_test_shaper_profile),
@@ -4469,9 +4686,9 @@ odp_testinfo_t traffic_mngr_suite[] = {
ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_thresholds,
traffic_mngr_check_thresholds),
ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_byte_wred,
- traffic_mngr_check_wred),
+ traffic_mngr_check_byte_wred),
ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_pkt_wred,
- traffic_mngr_check_wred),
+ traffic_mngr_check_pkt_wred),
ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_query,
traffic_mngr_check_query),
ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_queue_stats,