aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2022-03-01 13:56:00 +0200
committerGitHub <noreply@github.com>2022-03-01 13:56:00 +0200
commit6c96e7253082bdc5b3a6a6f39a1ced8200a39ee0 (patch)
tree908bd33aff383744a8cc18e4f8374c22ed61c46c
parent09a1f287c7956b36db8b3320a45e10a22058c269 (diff)
parent4c9bd497c64a8dada64e205c57c6db7dddacb1ec (diff)
Merge ODP v1.34.0.0v1.34.0.0_DPDK_19.11
Merge ODP linux-generic v1.34.0.0 into linux-dpdk.
-rw-r--r--CHANGELOG54
-rw-r--r--configure.ac5
-rw-r--r--doc/process-guide/faq.adoc6
-rw-r--r--doc/users-guide/users-guide-crypto.adoc7
-rw-r--r--example/classifier/odp_classifier.c35
-rw-r--r--example/ipfragreass/Makefile.am2
-rw-r--r--example/ipfragreass/odp_ipfragreass.c10
-rw-r--r--example/ipfragreass/odp_ipfragreass_atomics.h55
-rw-r--r--example/ipfragreass/odp_ipfragreass_atomics_arm.h130
-rw-r--r--example/ipfragreass/odp_ipfragreass_helpers.h6
-rw-r--r--example/ipfragreass/odp_ipfragreass_reassemble.c38
-rw-r--r--example/ipfragreass/odp_ipfragreass_reassemble.h40
-rw-r--r--example/ipsec_crypto/odp_ipsec.c30
-rw-r--r--example/ipsec_crypto/odp_ipsec_cache.c18
-rw-r--r--example/ipsec_crypto/odp_ipsec_cache.h1
-rw-r--r--example/ipsec_crypto/odp_ipsec_misc.h1
-rw-r--r--example/timer/odp_timer_accuracy.c25
-rw-r--r--example/traffic_mgmt/odp_traffic_mgmt.c95
-rw-r--r--include/Makefile.am47
-rw-r--r--include/odp/api/abi-default/traffic_mngr.h15
-rw-r--r--include/odp/api/spec/crypto.h189
-rw-r--r--include/odp/api/spec/random.h2
-rw-r--r--include/odp/api/spec/traffic_mngr.h130
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/align.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/atomic.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/barrier.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/buffer.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/byteorder.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/classification.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/comp.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/cpu.h24
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/cpumask.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/crypto.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/debug.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/dma_types.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/errno.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/event.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/hash.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/init.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/ipsec.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/packet.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/packet_flags.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/packet_io.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/packet_types.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/pool.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/proto_stats.h5
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/proto_stats_types.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/queue.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/queue_types.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/rwlock.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/rwlock_recursive.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/schedule.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/schedule_types.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/shared_memory.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/spinlock.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/spinlock_recursive.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/stash.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/std.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/std_types.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/sync.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/thread.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/thrmask.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/ticketlock.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/time.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/timer_types.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/traffic_mngr.h7
-rw-r--r--include/odp/arch/mips64-linux/odp/api/abi/version.h7
-rw-r--r--platform/linux-dpdk/Makefile.am24
l---------platform/linux-dpdk/arch/aarch64/odp_random.h1
-rw-r--r--platform/linux-dpdk/arch/mips64/odp/api/abi/cpu.h26
l---------platform/linux-dpdk/arch/mips64/odp/api/abi/cpu_inlines.h1
l---------platform/linux-dpdk/arch/mips64/odp_sysinfo_parse.c1
-rw-r--r--platform/linux-dpdk/include/odp_event_internal.h8
-rw-r--r--platform/linux-dpdk/include/odp_packet_internal.h8
-rw-r--r--platform/linux-dpdk/include/odp_timer_internal.h54
-rw-r--r--platform/linux-dpdk/odp_crypto.c96
-rw-r--r--platform/linux-dpdk/odp_packet.c8
-rw-r--r--platform/linux-dpdk/odp_pool.c19
-rw-r--r--platform/linux-dpdk/odp_shared_memory.c11
-rw-r--r--platform/linux-dpdk/odp_system_info.c9
-rw-r--r--platform/linux-generic/Makefile.am22
-rw-r--r--platform/linux-generic/arch/aarch64/odp_random.h166
-rw-r--r--platform/linux-generic/arch/mips64/odp/api/abi/cpu.h27
-rw-r--r--platform/linux-generic/arch/mips64/odp/api/abi/cpu_inlines.h56
-rw-r--r--platform/linux-generic/arch/mips64/odp_sysinfo_parse.c73
-rw-r--r--platform/linux-generic/include/odp_event_internal.h21
-rw-r--r--platform/linux-generic/include/odp_packet_internal.h12
-rw-r--r--platform/linux-generic/include/odp_pool_internal.h10
-rw-r--r--platform/linux-generic/include/odp_timer_internal.h5
-rw-r--r--platform/linux-generic/include/odp_traffic_mngr_internal.h1
-rw-r--r--platform/linux-generic/odp_buffer.c4
-rw-r--r--platform/linux-generic/odp_crypto_openssl.c152
-rw-r--r--platform/linux-generic/odp_ipsec_sad.c8
-rw-r--r--platform/linux-generic/odp_packet.c93
-rw-r--r--platform/linux-generic/odp_pool.c21
-rw-r--r--platform/linux-generic/odp_random_std.c94
-rw-r--r--platform/linux-generic/odp_schedule_basic.c33
-rw-r--r--platform/linux-generic/odp_shared_memory.c11
-rw-r--r--platform/linux-generic/odp_system_info.c9
-rw-r--r--platform/linux-generic/odp_timer.c154
-rw-r--r--platform/linux-generic/odp_traffic_mngr.c75
-rw-r--r--platform/linux-generic/pktio/socket.c2
-rw-r--r--test/performance/.gitignore1
-rw-r--r--test/performance/Makefile.am7
-rw-r--r--test/performance/odp_crypto.c52
-rw-r--r--test/performance/odp_dma_perf.c1106
-rwxr-xr-xtest/performance/odp_dma_perf_run.sh100
-rw-r--r--test/performance/odp_lock_perf.c84
-rw-r--r--test/performance/odp_pktio_ordered.c56
-rw-r--r--test/performance/odp_random.c32
-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
124 files changed, 4459 insertions, 2529 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 3a2f8a049..a6edaefe7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,57 @@
+== OpenDataPlane (1.34.0.0)
+
+=== Backward incompatible API changes
+==== Crypto
+* Specify that hash result field is not cleared in hash generation in encode
+sessions. Applications can do the clearing if needed if the hash result lies
+within the authenticated range.
+* Specify that the hash result field is left to an undefined value after
+verification.
+* Add a new session parameter
+`odp_crypto_session_param_t.hash_result_in_auth_range` to indicate if the hash
+result location may overlap the authenticated range. Leaving the flag unset may
+enable optimizations in the implementation.
+* Define new fields for cipher and auth IV lengths in the session parameter
+structure `odp_crypto_session_param_t`. Deprecated the old fields for cipher and
+auth IV lengths.
+* Deprecate the mechanism of configuring initialization vectors in sessions
+since reusing the same IV with the same key is almost always wrong. Require that
+IV is provided for each packet in the operation parameters.
+
+==== Traffic Manager
+* Add capabilities to `odp_tm_level_capabilities_t` for platforms to express
+shaper rate and burst min and max limits.
+* Remove support for min and max shaper rate via platform defined macros
+`ODP_TM_MIN_SHAPER_BW` and `ODP_TM_MAX_SHAPER_BW`. Min and Max shaper bandwidths
+can be read from TM per level capabilities (`odp_tm_level_capabilities_t`).
+
+=== Backward compatible API changes
+==== Crypto
+* Clarify that in case of AEAD algorithms the `odp_crypto_op_param_t.auth_range`
+parameter is not used, except with AES-GMAC.
+* Clarify `ODP_AUTH_ALG_AES_GMAC` API text to not sound as if ODP did not use
+AAD as defined in the GMAC algorithm specification.
+* Make the names of session creation errors (`odp_crypto_ses_create_err_t`) a
+bit shorter but retain the old names for backward compatibility.
+* Add crypto session creation error codes (`odp_crypto_ses_create_err_t`) for
+cases where the requested combination of algorithms, order of algorithms or
+other combination of creation parameters is not supported.
+
+==== Random
+* Explicitly state that the same series of `odp_random_test_data()` calls is
+required to generate the same data.
+
+==== Traffic Manager
+* Clarify that peak rate and peak burst are ignored when dual rate is set to
+false in `odp_tm_shaper_params_t`, indicating that the single rate is commit
+rate.
+* Define the default values for many parameters to be set by various init
+functions.
+
+=== ABI changes
+* Removed mips64 architecture support. MIPS devices may still use ODP by
+utilizing the generic default architecture.
+
== OpenDataPlane (1.33.0.0)
=== Backward incompatible API changes
diff --git a/configure.ac b/configure.ac
index d02c6624a..2a2598ebd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@ AC_PREREQ([2.5])
# ODP API version
##########################################################################
m4_define([odpapi_generation_version], [1])
-m4_define([odpapi_major_version], [33])
+m4_define([odpapi_major_version], [34])
m4_define([odpapi_minor_version], [0])
m4_define([odpapi_point_version], [0])
m4_define([odpapi_version],
@@ -207,7 +207,6 @@ AC_SUBST([archincludedir])
AS_CASE([$host],
[x86*], [ARCH_DIR=x86],
[i686*], [ARCH_DIR=x86],
- [mips64*], [ARCH_DIR=mips64],
[powerpc*], [ARCH_DIR=powerpc],
[aarch64*], [ARCH_DIR=aarch64],
[arm*], [ARCH_DIR=arm],
@@ -221,7 +220,6 @@ AC_SUBST([ARCH_DIR])
AS_CASE([$host],
[x86*], [ARCH_ABI=x86_64-linux],
[i686*], [ARCH_ABI=x86_32-linux],
- [mips64*], [ARCH_ABI=mips64-linux],
[powerpc*], [ARCH_ABI=power64-linux],
[aarch64*], [ARCH_ABI=arm64-linux],
[arm*], [ARCH_ABI=arm32-linux],
@@ -355,7 +353,6 @@ AM_CONDITIONAL([helper_cli], [test x$helper_cli = xyes ])
AM_CONDITIONAL([ARCH_IS_ARM], [test "x${ARCH_DIR}" = "xarm"])
AM_CONDITIONAL([ARCH_IS_AARCH64], [test "x${ARCH_DIR}" = "xaarch64"])
AM_CONDITIONAL([ARCH_IS_DEFAULT], [test "x${ARCH_DIR}" = "xdefault"])
-AM_CONDITIONAL([ARCH_IS_MIPS64], [test "x${ARCH_DIR}" = "xmips64"])
AM_CONDITIONAL([ARCH_IS_POWERPC], [test "x${ARCH_DIR}" = "xpowerpc"])
AM_CONDITIONAL([ARCH_IS_X86], [test "x${ARCH_DIR}" = "xx86"])
AM_CONDITIONAL([ARCH_IS_X86_32], [test "x${ARCH_ABI}" = "xx86_32-linux"])
diff --git a/doc/process-guide/faq.adoc b/doc/process-guide/faq.adoc
index 8f0c263e1..cbdd05757 100644
--- a/doc/process-guide/faq.adoc
+++ b/doc/process-guide/faq.adoc
@@ -27,7 +27,7 @@ in the nuances of any target platform.
At the same time, ODP is also a set of implementations of these APIs that are
optimized for each platform that supports ODP. Implementations of ODP currently
exist for a wide range of platforms spanning diverse instruction set
-architectures including ARM, MIPS, Power, x86, as well as proprietary SoC
+architectures including ARM, Power, x86, as well as proprietary SoC
architectures, and include both general-purpose servers as well as specialized
networking SoCs.
@@ -150,8 +150,8 @@ advantage of vendor extensions that have not yet been standardized.
== What platforms does ODP support?
-To date, ODP is running on seven different network platforms that span five
-different processing architectures (ARMv7, ARMv8, MIPS64, Power, and x86),
+To date, ODP is running on several different network platforms that span four
+different processing architectures (ARMv7, ARMv8, Power, and x86),
offering both application portability and accelerated performance tailored to
each platform. Other implementations are under development by both LNG member
companies and other companies participating in the project.
diff --git a/doc/users-guide/users-guide-crypto.adoc b/doc/users-guide/users-guide-crypto.adoc
index b44402adf..6393a5e78 100644
--- a/doc/users-guide/users-guide-crypto.adoc
+++ b/doc/users-guide/users-guide-crypto.adoc
@@ -33,7 +33,7 @@ order of cipher and hashing can be controlled by the `auth_cipher_text`
session parameter.
Other Session parameters include algorithms, keys, initialization vector
-(optional), encode or decode, output queue for async mode and output packet
+lengths, encode or decode, output queue for async mode and output packet
pool for allocation of an output packet if required.
The parameters that describe the characteristics of a crypto session are
@@ -72,8 +72,9 @@ notification is expected. In the case of an async operation, the `posted`
output parameter will be set to true.
The operation arguments specify for each packet the areas that are to be
-encrypted or decrypted and authenticated. Also, there is an option of overriding
-the initialization vector specified in session parameters.
+encrypted or decrypted and authenticated. The parameters include also
+pointers to cipher and authentication initialization vectors as needed,
+depending on the initialization vector lengths specified at session creation.
An operation can be executed in in-place, out-of-place or new buffer mode.
In in-place mode output packet is same as the input packet.
diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c
index 2c36fce0e..d22c9a7df 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2019-2020, Nokia
- * Copyright (C) 2020, Marvell
+ * Copyright (c) 2019-2021, Nokia
+ * Copyright (c) 2020, Marvell
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -892,6 +892,10 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
len = strlen(optarg);
len++;
pmr_str = malloc(len);
+ if (pmr_str == NULL) {
+ ODPH_ERR("Memory allocation failed\n");
+ return -1;
+ }
strcpy(pmr_str, optarg);
/* PMR TERM */
@@ -899,7 +903,7 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
token = strtok(pmr_str, ":");
if (convert_str_to_pmr_enum(token, &term)) {
ODPH_ERR("Invalid ODP_PMR_TERM string\n");
- exit(EXIT_FAILURE);
+ goto error;
}
stats[policy_count].rule.term = term;
stats[policy_count].rule.offset = 0;
@@ -952,7 +956,7 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
if (odph_ipv4_addr_parse(&ip_addr, token)) {
ODPH_ERR("Bad IP address\n");
- exit(EXIT_FAILURE);
+ goto error;
}
u32 = odp_cpu_to_be_32(ip_addr);
@@ -982,7 +986,7 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
if (odph_eth_addr_parse(&mac, token)) {
ODPH_ERR("Invalid MAC address. Use format 11-22-33-44-55-66.\n");
- exit(EXIT_FAILURE);
+ goto error;
}
memcpy(stats[policy_count].rule.value_be, mac.addr, ODPH_ETHADDR_LEN);
@@ -993,7 +997,7 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
mask_sz = parse_custom(token, stats[policy_count].rule.mask_be, ODPH_ETHADDR_LEN);
if (mask_sz != ODPH_ETHADDR_LEN) {
ODPH_ERR("Invalid mask. Provide mask without 0x prefix.\n");
- return -1;
+ goto error;
}
break;
case ODP_PMR_CUSTOM_FRAME:
@@ -1005,7 +1009,7 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
offset = strtoul(token, NULL, 0);
stats[policy_count].rule.offset = offset;
if (errno)
- return -1;
+ goto error;
token = strtok(NULL, ":");
strncpy(stats[policy_count].value, token,
@@ -1015,7 +1019,7 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
MAX_VAL_SIZE);
stats[policy_count].rule.val_sz = val_sz;
if (val_sz <= 0)
- return -1;
+ goto error;
token = strtok(NULL, ":");
strncpy(stats[policy_count].mask, token,
@@ -1024,11 +1028,10 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
stats[policy_count].rule.mask_be,
MAX_VAL_SIZE);
if (mask_sz != val_sz)
- return -1;
+ goto error;
break;
default:
- usage();
- exit(EXIT_FAILURE);
+ goto error;
}
/* Optional source CoS name and name of this CoS
@@ -1036,7 +1039,7 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
cos0 = strtok(NULL, ":");
cos1 = strtok(NULL, ":");
if (cos0 == NULL)
- return -1;
+ goto error;
if (cos1) {
stats[policy_count].has_src_cos = 1;
@@ -1052,6 +1055,10 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
appl_args->policy_count++;
free(pmr_str);
return 0;
+
+error:
+ free(pmr_str);
+ return -1;
}
static int parse_policy_ci_pass_count(appl_args_t *appl_args, char *optarg)
@@ -1075,6 +1082,10 @@ static int parse_policy_ci_pass_count(appl_args_t *appl_args, char *optarg)
len = strlen(optarg);
len++;
count_str = malloc(len);
+ if (count_str == NULL) {
+ ODPH_ERR("Memory allocation failed\n");
+ return -1;
+ }
strcpy(count_str, optarg);
token = strtok(count_str, ":");
diff --git a/example/ipfragreass/Makefile.am b/example/ipfragreass/Makefile.am
index 2cd61a39e..f9180ea93 100644
--- a/example/ipfragreass/Makefile.am
+++ b/example/ipfragreass/Makefile.am
@@ -8,8 +8,6 @@ odp_ipfragreass_SOURCES = odp_ipfragreass.c \
odp_ipfragreass_fragment.c \
odp_ipfragreass_helpers.c \
odp_ipfragreass_reassemble.c \
- odp_ipfragreass_atomics.h \
- odp_ipfragreass_atomics_arm.h \
odp_ipfragreass_fragment.h \
odp_ipfragreass_helpers.h \
odp_ipfragreass_ip.h \
diff --git a/example/ipfragreass/odp_ipfragreass.c b/example/ipfragreass/odp_ipfragreass.c
index 828f11002..db5779915 100644
--- a/example/ipfragreass/odp_ipfragreass.c
+++ b/example/ipfragreass/odp_ipfragreass.c
@@ -51,7 +51,7 @@ static struct ODP_ALIGNED_CACHE {
} thread_stats[MAX_WORKERS];
/** Shared hash map structure for reassembly */
-static union fraglist *fraglists;
+static odp_atomic_u128_t *fraglists;
/** Barrier for synchronising reassembly worker threads */
static odp_barrier_t barrier;
@@ -74,6 +74,7 @@ static void init(odp_instance_t *instance, odp_pool_t *fragment_pool,
odp_queue_param_t frag_queue_params;
odp_queue_param_t reass_queue_params;
char cpumask_str[ODP_CPUMASK_STR_SIZE];
+ union fraglist init_data;
srand(seed);
printf("= Seed: %d\n", seed);
@@ -103,7 +104,8 @@ static void init(odp_instance_t *instance, odp_pool_t *fragment_pool,
}
/* Reserve (and initialise) shared memory for reassembly fraglists */
- *shm = odp_shm_reserve("fraglists", FRAGLISTS * sizeof(union fraglist),
+ *shm = odp_shm_reserve("fraglists",
+ FRAGLISTS * sizeof(odp_atomic_u128_t),
ODP_CACHE_LINE_SIZE, 0);
if (*shm == ODP_SHM_INVALID) {
fprintf(stderr, "ERROR: odp_shm_reserve\n");
@@ -114,8 +116,10 @@ static void init(odp_instance_t *instance, odp_pool_t *fragment_pool,
fprintf(stderr, "ERROR: odp_shm_addr\n");
exit(1);
}
+
+ init_fraglist(&init_data);
for (i = 0; i < FRAGLISTS; ++i)
- init_fraglist(&fraglists[i]);
+ odp_atomic_init_u128(&fraglists[i], init_data.raw);
/* Create a queue for holding fragments */
odp_queue_param_init(&frag_queue_params);
diff --git a/example/ipfragreass/odp_ipfragreass_atomics.h b/example/ipfragreass/odp_ipfragreass_atomics.h
deleted file mode 100644
index 743a004e2..000000000
--- a/example/ipfragreass/odp_ipfragreass_atomics.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef ODP_FRAGREASS_PP_ATOMICS_H_
-#define ODP_FRAGREASS_PP_ATOMICS_H_
-
-#if __SIZEOF_POINTER__ == 4
-/**
- * A wrapper function to perform a 64-bit "strong" atomic compare and swap
- * (CAS) operation. This generic version of the function is used if an
- * architecture-specific (e.g. lockless) variant is not specified.
- *
- * @param var The location at which the CAS should take place
- * @param exp A pointer to the expected value
- * @param neu A pointer to the new value to be written on success
- * @param mo_success The memory order on success
- * @param mo_failure The memory order on failure
- *
- * @return Whether the operation succeeded
- */
-static inline bool atomic_strong_cas_dblptr(uint64_t *var, uint64_t *exp,
- uint64_t neu, int mo_success,
- int mo_failure)
-{
- return __atomic_compare_exchange_n(var, exp, neu, 0, mo_success,
- mo_failure);
-}
-#elif __SIZEOF_POINTER__ == 8
-/**
- * A wrapper function to perform a 128-bit "strong" atomic compare and swap
- * (CAS) operation. This generic version of the function is used if an
- * architecture-specific (e.g. lockless) variant is not specified.
- *
- * @param var The location at which the CAS should take place
- * @param exp A pointer to the expected value
- * @param neu A pointer to the new value to be written on success
- * @param mo_success The memory order on success
- * @param mo_failure The memory order on failure
- *
- * @return Whether the operation succeeded
- */
-__extension__ static inline bool atomic_strong_cas_dblptr(__int128 *var,
- __int128 *exp,
- __int128 neu,
- int mo_success,
- int mo_failure)
-{
- return __atomic_compare_exchange_n(var, exp, neu, 0, mo_success,
- mo_failure);
-}
-#endif
-#endif
diff --git a/example/ipfragreass/odp_ipfragreass_atomics_arm.h b/example/ipfragreass/odp_ipfragreass_atomics_arm.h
deleted file mode 100644
index 4bea45f9e..000000000
--- a/example/ipfragreass/odp_ipfragreass_atomics_arm.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef ODP_FRAGREASS_PP_ATOMICS_ARM_H_
-#define ODP_FRAGREASS_PP_ATOMICS_ARM_H_
-
-#include <odp_api.h>
-
-#if __SIZEOF_POINTER__ == 8 && defined(__aarch64__)
-
-__extension__ typedef __int128 _int128_t;
-
-static inline _int128_t lld(_int128_t *var, int mo)
-{
- _int128_t old;
- uint64_t lo, hi;
-
- if (mo == __ATOMIC_ACQUIRE)
- __asm__ volatile("ldaxp %0, %1, [%2]" : "=&r" (lo), "=&r" (hi)
- : "r" (var) : "memory");
- else /* mo == __ATOMIC_RELAXED */
- __asm__ volatile("ldxp %0, %1, [%2]" : "=&r" (lo), "=&r" (hi)
- : "r" (var) : );
- old = hi;
- old <<= 64;
- old |= lo;
-
- return old;
-
-}
-
-static inline uint32_t scd(_int128_t *var, _int128_t neu, int mo)
-{
- uint32_t ret;
- uint64_t lo = neu, hi = neu >> 64;
-
- if (mo == __ATOMIC_RELEASE)
- __asm__ volatile("stlxp %w0, %1, %2, [%3]" : "=&r" (ret)
- : "r" (lo), "r" (hi), "r" (var) : "memory");
- else /* mo == __ATOMIC_RELAXED */
- __asm__ volatile("stxp %w0, %1, %2, [%3]" : "=&r" (ret)
- : "r" (lo), "r" (hi), "r" (var) : "memory");
- return ret;
-}
-
-static inline bool atomic_strong_cas_dblptr(_int128_t *var, _int128_t *exp,
- _int128_t neu, int mo_success,
- int mo_failure ODP_UNUSED)
-{
- register _int128_t old;
- register _int128_t expected = *exp;
- int ll_mo, sc_mo;
-
- ll_mo = (mo_success != __ATOMIC_RELAXED &&
- mo_success != __ATOMIC_RELEASE) ? __ATOMIC_ACQUIRE
- : __ATOMIC_RELAXED;
- sc_mo = (mo_success == __ATOMIC_RELEASE ||
- mo_success == __ATOMIC_ACQ_REL ||
- mo_success == __ATOMIC_SEQ_CST) ? __ATOMIC_RELEASE
- : __ATOMIC_RELAXED;
-
- /*
- * To prevent spurious failures and ensure atomicity, we must write some
- * value back -- whether it's the value we wanted to write, or the value
- * that is currently there. Repeat until we perform a successful write.
- */
- do {
- old = lld(var, ll_mo);
- } while (scd(var, old == expected ? neu : old, sc_mo));
-
- *exp = old;
- return (old == expected);
-}
-#elif __SIZEOF_POINTER__ == 4 && defined(__ARM_ARCH) && __ARM_ARCH == 7
-static inline uint64_t lld(uint64_t *var, int mo)
-{
- uint64_t old;
-
- __asm__ volatile("ldrexd %0, %H0, [%1]" : "=&r" (old) : "r" (var) : );
- if (mo == __ATOMIC_ACQUIRE)
- __asm__ volatile("dmb ish" ::: "memory");
- return old;
-}
-
-static inline uint32_t scd(uint64_t *var, uint64_t neu, int mo)
-{
- uint32_t ret;
-
- if (mo == __ATOMIC_RELEASE)
- __asm__ volatile("dmb ish" ::: "memory");
- __asm__ volatile("strexd %0, %1, %H1, [%2]" : "=&r" (ret)
- : "r" (neu), "r" (var) : );
- return ret;
-}
-
-static inline bool atomic_strong_cas_dblptr(uint64_t *var, uint64_t *exp,
- uint64_t neu, int mo_success,
- int mo_failure ODP_UNUSED)
-{
- register uint64_t old;
- register uint64_t expected = *exp;
- int ll_mo, sc_mo;
-
- ll_mo = (mo_success != __ATOMIC_RELAXED &&
- mo_success != __ATOMIC_RELEASE) ? __ATOMIC_ACQUIRE
- : __ATOMIC_RELAXED;
- sc_mo = (mo_success == __ATOMIC_RELEASE ||
- mo_success == __ATOMIC_ACQ_REL ||
- mo_success == __ATOMIC_SEQ_CST) ? __ATOMIC_RELEASE
- : __ATOMIC_RELAXED;
-
- /*
- * To prevent spurious failures and ensure atomicity, we must write some
- * value back -- whether it's the value we wanted to write, or the value
- * that is currently there. Repeat until we perform a successful write.
- */
- do {
- old = lld(var, ll_mo);
- } while (scd(var, old == expected ? neu : old, sc_mo));
-
- *exp = old;
- return (old == expected);
-}
-#else
-#include "odp_ipfragreass_atomics.h"
-#endif
-#endif
diff --git a/example/ipfragreass/odp_ipfragreass_helpers.h b/example/ipfragreass/odp_ipfragreass_helpers.h
index 3678b7db6..af47e326c 100644
--- a/example/ipfragreass/odp_ipfragreass_helpers.h
+++ b/example/ipfragreass/odp_ipfragreass_helpers.h
@@ -9,12 +9,6 @@
#include <odp/helper/ip.h>
-#if defined(__ARM_ARCH)
-#include "odp_ipfragreass_atomics_arm.h"
-#else
-#include "odp_ipfragreass_atomics.h"
-#endif
-
/**
* Generate a random IPv4 UDP packet from the specified parameters
*
diff --git a/example/ipfragreass/odp_ipfragreass_reassemble.c b/example/ipfragreass/odp_ipfragreass_reassemble.c
index fba900f7a..57e0f375a 100644
--- a/example/ipfragreass/odp_ipfragreass_reassemble.c
+++ b/example/ipfragreass/odp_ipfragreass_reassemble.c
@@ -4,6 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <odp_api.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
@@ -382,7 +384,7 @@ static void sort_fraglist(union fraglist *fl, struct flts now)
*
* @return The number of packets reassembled and sent to the output queue
*/
-static int add_fraglist_to_fraglist(union fraglist *fl, union fraglist frags,
+static int add_fraglist_to_fraglist(odp_atomic_u128_t *fl, union fraglist frags,
struct packet *frags_head, struct flts now,
odp_queue_t out, odp_bool_t dont_assemble)
{
@@ -401,8 +403,7 @@ redo:;
struct flts oldfl_earliest;
struct flts frags_earliest;
- __atomic_load(&fl->half[0], &oldfl.half[0], __ATOMIC_RELAXED);
- __atomic_load(&fl->half[1], &oldfl.half[1], __ATOMIC_RELAXED);
+ oldfl.raw = odp_atomic_load_u128(fl);
/*
* If we're updating a non-empty fraglist, we should always attempt
@@ -435,9 +436,7 @@ redo:;
* yet. If not, just write out our changes and move on.
*/
if (newfl.part_len < newfl.whole_len || dont_assemble) {
- if (!atomic_strong_cas_dblptr(&fl->raw, &oldfl.raw, newfl.raw,
- __ATOMIC_RELEASE,
- __ATOMIC_RELAXED)) {
+ if (!odp_atomic_cas_rel_u128(fl, &oldfl.raw, newfl.raw)) {
/* Failed to add this fragment? Try again. */
set_prev_packet(frags_head, NULL);
goto redo;
@@ -456,8 +455,7 @@ redo:;
* otherwise we'll update the slot with our changes later.
*/
init_fraglist(&nullfl);
- if (!atomic_strong_cas_dblptr(&fl->raw, &oldfl.raw, nullfl.raw,
- __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
+ if (!odp_atomic_cas_acq_u128(fl, &oldfl.raw, nullfl.raw)) {
/* Failed to take this fraglist? Try again. */
set_prev_packet(frags_head, NULL);
goto redo;
@@ -560,7 +558,7 @@ redo:;
*
* @return The number of packets reassembled and sent to the output
*/
-static int add_frag_to_fraglist(union fraglist *fl, struct packet *frag,
+static int add_frag_to_fraglist(odp_atomic_u128_t *fl, struct packet *frag,
uint16_t frag_payload_len,
uint16_t frag_reass_payload_len,
odp_queue_t out)
@@ -586,7 +584,7 @@ static int add_frag_to_fraglist(union fraglist *fl, struct packet *frag,
* @param out The queue to which reassembled packets should be written
* @param force Whether all flows in the fraglist should be considered stale
*/
-static void remove_stale_flows(union fraglist *fl, union fraglist oldfl,
+static void remove_stale_flows(odp_atomic_u128_t *fl, union fraglist oldfl,
struct flts timestamp_now, odp_queue_t out,
odp_bool_t force)
{
@@ -685,7 +683,7 @@ static void remove_stale_flows(union fraglist *fl, union fraglist oldfl,
* @param out The queue to which reassembled packets should be written
* @param force Whether all flows in the fraglist should be considered stale
*/
-static void garbage_collect_fraglist(union fraglist *fl, odp_queue_t out,
+static void garbage_collect_fraglist(odp_atomic_u128_t *fl, odp_queue_t out,
odp_bool_t force)
{
uint64_t time_now;
@@ -698,8 +696,9 @@ static void garbage_collect_fraglist(union fraglist *fl, odp_queue_t out,
do {
time_now = odp_time_to_ns(odp_time_global());
timestamp_now.t = time_now / TS_RES_NS;
- __atomic_load(&fl->half[0], &oldfl.half[0], __ATOMIC_RELAXED);
- __atomic_load(&fl->half[1], &oldfl.half[1], __ATOMIC_RELAXED);
+
+ oldfl.raw = odp_atomic_load_u128(fl);
+
elapsed.t = timestamp_now.t - oldfl.earliest;
if (oldfl.tail == NULL ||
@@ -712,11 +711,8 @@ static void garbage_collect_fraglist(union fraglist *fl, odp_queue_t out,
union fraglist nullfl;
init_fraglist(&nullfl);
- success = atomic_strong_cas_dblptr(&fl->raw, &oldfl.raw,
- nullfl.raw,
- __ATOMIC_ACQUIRE,
- __ATOMIC_RELAXED);
-
+ success = odp_atomic_cas_acq_u128(fl, &oldfl.raw,
+ nullfl.raw);
if (success)
remove_stale_flows(fl, oldfl, timestamp_now,
out, force);
@@ -724,7 +720,7 @@ static void garbage_collect_fraglist(union fraglist *fl, odp_queue_t out,
} while (!success);
}
-int reassemble_ipv4_packets(union fraglist *fraglists, int num_fraglists,
+int reassemble_ipv4_packets(odp_atomic_u128_t *fraglists, int num_fraglists,
struct packet *fragments, int num_fragments,
odp_queue_t out)
{
@@ -737,7 +733,7 @@ int reassemble_ipv4_packets(union fraglist *fraglists, int num_fraglists,
uint16_t frag_payload_len;
uint16_t frag_reass_payload_len;
uint32_t key;
- union fraglist *fl;
+ odp_atomic_u128_t *fl;
int status;
frag = fragments[i];
@@ -767,7 +763,7 @@ int reassemble_ipv4_packets(union fraglist *fraglists, int num_fraglists,
return packets_reassembled;
}
-void garbage_collect_fraglists(union fraglist *fraglists, int num_fraglists,
+void garbage_collect_fraglists(odp_atomic_u128_t *fraglists, int num_fraglists,
odp_queue_t out, odp_bool_t destroy_all)
{
int i;
diff --git a/example/ipfragreass/odp_ipfragreass_reassemble.h b/example/ipfragreass/odp_ipfragreass_reassemble.h
index e0e132b6c..1fb71284e 100644
--- a/example/ipfragreass/odp_ipfragreass_reassemble.h
+++ b/example/ipfragreass/odp_ipfragreass_reassemble.h
@@ -7,13 +7,13 @@
#ifndef ODP_FRAGREASS_PP_REASSEMBLE_H_
#define ODP_FRAGREASS_PP_REASSEMBLE_H_
+#include <odp_api.h>
#include <odp/helper/ip.h>
#include "odp_ipfragreass_ip.h"
#include "odp_ipfragreass_helpers.h"
-ODP_STATIC_ASSERT((__SIZEOF_POINTER__ == 4 || __SIZEOF_POINTER__ == 8),
- "ODPREASS_PTR__SIZE_ERROR");
+ODP_STATIC_ASSERT(__SIZEOF_POINTER__ <= 8, "ODP_REASS_PTR__SIZE_ERROR");
/**
* The time in nanoseconds after reception of the earliest fragment that a
@@ -22,41 +22,25 @@ ODP_STATIC_ASSERT((__SIZEOF_POINTER__ == 4 || __SIZEOF_POINTER__ == 8),
#define FLOW_TIMEOUT_NS 15000000000ULL
/** Convert nanoseconds into a unit for packet.arrival */
-#if __SIZEOF_POINTER__ == 4
-#define TS_RES_NS ((uint64_t)5000000000) /**< ns -> 5s */
-#elif __SIZEOF_POINTER__ == 8
#define TS_RES_NS ((uint64_t)1000000) /**< ns -> 1ms */
-#endif
/**
* The maximum value of the packet.arrival field.
*/
-#if __SIZEOF_POINTER__ == 4
-#define EARLIEST_MAX 15
-#elif __SIZEOF_POINTER__ == 8
#define EARLIEST_MAX UINT32_MAX
-#endif
/**
* The time in packet.arrival ticks that indications of the time "now" are
* permitted to be off by.
*/
-#if __SIZEOF_POINTER__ == 4
-#define TS_NOW_TOLERANCE 1
-#elif __SIZEOF_POINTER__ == 8
#define TS_NOW_TOLERANCE 5000
-#endif
/**
* The timestamp format used for fragments. Sadly, this has to be a structure
* as we may need a bit field.
*/
struct flts {
-#if __SIZEOF_POINTER__ == 4
- uint8_t t:4;
-#elif __SIZEOF_POINTER__ == 8
uint32_t t;
-#endif
};
/**
@@ -81,11 +65,7 @@ union fraglist {
* The timestamp of the earliest arriving fragment in this
* fraglist
*/
-#if __SIZEOF_POINTER__ == 4
- uint32_t earliest:4;
-#elif __SIZEOF_POINTER__ == 8
uint32_t earliest;
-#endif
/**
* The sum of the payloads of the fragments in this list
@@ -116,17 +96,7 @@ union fraglist {
struct packet *tail;
};
-#if __SIZEOF_POINTER__ == 4
- struct {
- uint32_t half[2];
- };
- uint64_t raw;
-#elif __SIZEOF_POINTER__ == 8
- struct {
- uint64_t half[2];
- };
- __extension__ __int128 raw;
-#endif
+ odp_u128_t raw;
};
/**
@@ -193,7 +163,7 @@ static inline void set_prev_packet(struct packet *packet, struct packet *prev)
*
* @return The number of packets successfully reassembled and written to "out"
*/
-int reassemble_ipv4_packets(union fraglist *fraglists, int num_fraglists,
+int reassemble_ipv4_packets(odp_atomic_u128_t *fraglists, int num_fraglists,
struct packet *fragments, int num_fragments,
odp_queue_t out);
@@ -205,7 +175,7 @@ int reassemble_ipv4_packets(union fraglist *fraglists, int num_fraglists,
* @param out The queue to which reassembled packets should be written
* @param destroy_all Whether all encountered flows should be cleaned up
*/
-void garbage_collect_fraglists(union fraglist *fraglists, int num_fraglists,
+void garbage_collect_fraglists(odp_atomic_u128_t *fraglists, int num_fraglists,
odp_queue_t out, odp_bool_t destroy_all);
#endif
diff --git a/example/ipsec_crypto/odp_ipsec.c b/example/ipsec_crypto/odp_ipsec.c
index 9fec94620..c6a64399f 100644
--- a/example/ipsec_crypto/odp_ipsec.c
+++ b/example/ipsec_crypto/odp_ipsec.c
@@ -1,4 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
+ * Copyright (c) 2021, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -772,6 +773,20 @@ pkt_disposition_e do_ipsec_in_finish(odp_packet_t pkt,
return PKT_CONTINUE;
}
+static int generate_iv(uint8_t *buf, uint32_t size)
+{
+ uint32_t n = 0;
+ int32_t ret;
+
+ while (n < size) {
+ ret = odp_random_data(buf + n, size - n, ODP_RANDOM_CRYPTO);
+ if (ret < 0)
+ return 1;
+ n += ret;
+ }
+ return 0;
+}
+
/**
* Packet Processing - Output IPsec packet classification
*
@@ -859,7 +874,9 @@ pkt_disposition_e do_ipsec_out_classify(odp_packet_t pkt,
trl_len = encrypt_len - ip_data_len;
esp->spi = odp_cpu_to_be_32(entry->esp.spi);
- memcpy(esp + 1, entry->state.iv, entry->esp.iv_len);
+ if (generate_iv(esp->iv, entry->esp.iv_len))
+ return PKT_DROP;
+ params.cipher_iv_ptr = esp->iv;
esp_t = (odph_esptrl_t *)(ip_data + encrypt_len) - 1;
esp_t->pad_len = trl_len - sizeof(*esp_t);
@@ -957,20 +974,9 @@ pkt_disposition_e do_ipsec_out_seq(odp_packet_t *pkt,
}
if (ctx->ipsec.tun_hdr_offset) {
odph_ipv4hdr_t *ip;
- int ret;
ip = (odph_ipv4hdr_t *)(ctx->ipsec.tun_hdr_offset + buf);
ip->id = odp_cpu_to_be_16((*ctx->ipsec.tun_hdr_id)++);
- if (!ip->id) {
- /* re-init tunnel hdr id */
- ret = odp_random_data((uint8_t *)ctx->ipsec.tun_hdr_id,
- sizeof(*ctx->ipsec.tun_hdr_id),
- 1);
- if (ret != sizeof(*ctx->ipsec.tun_hdr_id)) {
- ODPH_ERR("Error: Not enough random data\n");
- exit(EXIT_FAILURE);
- }
- }
}
out_pkt = entry->in_place ? *pkt : ODP_PACKET_INVALID;
diff --git a/example/ipsec_crypto/odp_ipsec_cache.c b/example/ipsec_crypto/odp_ipsec_cache.c
index 044538c59..e4cd5142a 100644
--- a/example/ipsec_crypto/odp_ipsec_cache.c
+++ b/example/ipsec_crypto/odp_ipsec_cache.c
@@ -95,13 +95,11 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,
params.cipher_alg = cipher_sa->alg.u.cipher;
params.cipher_key.data = cipher_sa->key.data;
params.cipher_key.length = cipher_sa->key.length;
- params.cipher_iv.data = entry->state.iv;
- params.cipher_iv.length = cipher_sa->iv_len;
+ params.cipher_iv_len = cipher_sa->iv_len;
mode = cipher_sa->mode;
} else {
params.cipher_alg = ODP_CIPHER_ALG_NULL;
- params.cipher_iv.data = NULL;
- params.cipher_iv.length = 0;
+ params.cipher_iv_len = 0;
}
/* Auth */
@@ -111,23 +109,15 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,
params.auth_key.length = auth_sa->key.length;
params.auth_digest_len = auth_sa->icv_len;
mode = auth_sa->mode;
+ params.hash_result_in_auth_range = true;
} else {
params.auth_alg = ODP_AUTH_ALG_NULL;
}
- /* Generate an IV */
- if (params.cipher_iv.length) {
- int32_t size = params.cipher_iv.length;
-
- int32_t ret = odp_random_data(params.cipher_iv.data, size, 1);
- if (ret != size)
- return -1;
- }
-
/* Synchronous session create for now */
if (odp_crypto_session_create(&params, &session, &ses_create_rc))
return -1;
- if (ODP_CRYPTO_SES_CREATE_ERR_NONE != ses_create_rc)
+ if (ODP_CRYPTO_SES_ERR_NONE != ses_create_rc)
return -1;
/* Copy remainder */
diff --git a/example/ipsec_crypto/odp_ipsec_cache.h b/example/ipsec_crypto/odp_ipsec_cache.h
index 1523778ff..be31ca72c 100644
--- a/example/ipsec_crypto/odp_ipsec_cache.h
+++ b/example/ipsec_crypto/odp_ipsec_cache.h
@@ -57,7 +57,6 @@ typedef struct ipsec_cache_entry_s {
odp_crypto_session_t session; /**< Crypto session handle */
uint32_t esp_seq; /**< ESP TX sequence number */
uint32_t ah_seq; /**< AH TX sequence number */
- uint8_t iv[MAX_IV_LEN]; /**< ESP IV storage */
odp_u16be_t tun_hdr_id; /**< Tunnel header IP ID */
} state;
} ipsec_cache_entry_t;
diff --git a/example/ipsec_crypto/odp_ipsec_misc.h b/example/ipsec_crypto/odp_ipsec_misc.h
index 4f50f27ec..6186a2369 100644
--- a/example/ipsec_crypto/odp_ipsec_misc.h
+++ b/example/ipsec_crypto/odp_ipsec_misc.h
@@ -24,7 +24,6 @@ extern "C" {
#define MAX_DB 32 /**< maximum number of data base entries */
#define MAX_LOOPBACK 10 /**< maximum number of loop back interfaces */
#define MAX_STRING 32 /**< maximum string length */
-#define MAX_IV_LEN 32 /**< Maximum IV length in bytes */
#define KEY_BITS_3DES 192 /**< 3DES cipher key length in bits */
#define KEY_BITS_MD5_96 128 /**< MD5_96 auth key length in bits */
diff --git a/example/timer/odp_timer_accuracy.c b/example/timer/odp_timer_accuracy.c
index 9318e1090..b9a0cf585 100644
--- a/example/timer/odp_timer_accuracy.c
+++ b/example/timer/odp_timer_accuracy.c
@@ -1,10 +1,11 @@
/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2019-2021, Nokia
+ * Copyright (c) 2019-2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
@@ -717,15 +718,6 @@ int main(int argc, char *argv[])
if (parse_options(argc, argv, &test_global))
return -1;
- if (test_global.opt.output) {
- test_global.file = fopen(test_global.filename, "w");
- if (test_global.file == NULL) {
- printf("Failed to open file: %s\n",
- test_global.filename);
- return -1;
- }
- }
-
/* List features not to be used (may optimize performance) */
odp_init_param_init(&init);
init.not_used.feat.cls = 1;
@@ -759,6 +751,7 @@ int main(int argc, char *argv[])
if (test_global.timer_ctx == NULL) {
printf("Timer context table calloc failed.\n");
+ ret = -1;
goto quit;
}
@@ -767,11 +760,20 @@ int main(int argc, char *argv[])
void *addr;
uint64_t size = test_global.tot_timers * sizeof(test_log_t);
+ test_global.file = fopen(test_global.filename, "w");
+ if (test_global.file == NULL) {
+ printf("Failed to open output file %s: %s\n",
+ test_global.filename, strerror(errno));
+ ret = -1;
+ goto quit;
+ }
+
shm = odp_shm_reserve("timer_accuracy_log", size,
sizeof(test_log_t), 0);
if (shm == ODP_SHM_INVALID) {
printf("Test log alloc failed.\n");
+ ret = -1;
goto quit;
}
@@ -781,7 +783,8 @@ int main(int argc, char *argv[])
test_global.log_shm = shm;
}
- if (start_timers(&test_global))
+ ret = start_timers(&test_global);
+ if (ret)
goto quit;
run_test(&test_global);
diff --git a/example/traffic_mgmt/odp_traffic_mgmt.c b/example/traffic_mgmt/odp_traffic_mgmt.c
index c82c1d5b2..689cac2ae 100644
--- a/example/traffic_mgmt/odp_traffic_mgmt.c
+++ b/example/traffic_mgmt/odp_traffic_mgmt.c
@@ -1,6 +1,7 @@
/* Copyright 2015 EZchip Semiconductor Ltd. All Rights Reserved.
*
* Copyright (c) 2015-2018, Linaro Limited
+ * Copyright (c) 2022, Marvell
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -106,7 +107,7 @@ static profile_params_set_t COS0_PROFILE_PARAMS = {
.shaper_params = {
.commit_rate = 1 * MBPS, .commit_burst = 100000,
.peak_rate = 4 * MBPS, .peak_burst = 200000,
- .dual_rate = FALSE, .shaper_len_adjust = 20
+ .dual_rate = TRUE, .shaper_len_adjust = 20
},
.threshold_params = {
@@ -148,7 +149,7 @@ static profile_params_set_t COS1_PROFILE_PARAMS = {
.shaper_params = {
.commit_rate = 500 * KBPS, .commit_burst = 50000,
.peak_rate = 1500 * KBPS, .peak_burst = 150000,
- .dual_rate = FALSE, .shaper_len_adjust = 20
+ .dual_rate = TRUE, .shaper_len_adjust = 20
},
.threshold_params = {
@@ -190,7 +191,7 @@ static profile_params_set_t COS2_PROFILE_PARAMS = {
.shaper_params = {
.commit_rate = 200 * KBPS, .commit_burst = 20000,
.peak_rate = 400 * KBPS, .peak_burst = 40000,
- .dual_rate = FALSE, .shaper_len_adjust = 20
+ .dual_rate = TRUE, .shaper_len_adjust = 20
},
.threshold_params = {
@@ -293,6 +294,39 @@ static uint8_t g_print_tm_stats = TRUE;
static void tester_egress_fcn(odp_packet_t odp_pkt);
+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 uint64_t
+clamp_rate(uint64_t rate)
+{
+ uint64_t val = MIN(MAX(rate, tm_shaper_min_rate), tm_shaper_max_rate);
+
+ if (!rate)
+ return 0;
+
+ if (val != rate)
+ printf("INFO: Clamped shaper rate from %" PRIu64 " bps"
+ " to %" PRIu64 " bps\n", rate, val);
+ return val;
+}
+
+static uint32_t
+clamp_burst(uint32_t burst)
+{
+ uint32_t val = MIN(MAX(burst, tm_shaper_min_burst), tm_shaper_max_burst);
+
+ if (!burst)
+ return 0;
+
+ if (val != burst)
+ printf("INFO: Clamped shaper burst from %" PRIu32 "bits to %" PRIu32 "bits\n",
+ burst, val);
+ return val;
+}
+
/* Returns the number of errors encountered. */
static uint32_t create_profile_set(profile_params_set_t *profile_params_set,
@@ -317,10 +351,14 @@ static uint32_t create_profile_set(profile_params_set_t *profile_params_set,
odp_tm_shaper_params_init(&shaper_params);
shaper = &profile_params_set->shaper_params;
- shaper_params.commit_rate = shaper->commit_rate * shaper_scale;
- shaper_params.peak_rate = shaper->peak_rate * shaper_scale;
- shaper_params.commit_burst = shaper->commit_burst * shaper_scale;
- shaper_params.peak_burst = shaper->peak_burst * shaper_scale;
+ shaper_params.commit_rate = clamp_rate(shaper->commit_rate *
+ shaper_scale);
+ shaper_params.peak_rate = clamp_rate(shaper->peak_rate *
+ shaper_scale);
+ shaper_params.commit_burst = clamp_burst(shaper->commit_burst *
+ shaper_scale);
+ shaper_params.peak_burst = clamp_burst(shaper->peak_burst *
+ shaper_scale);
shaper_params.dual_rate = shaper->dual_rate;
shaper_params.shaper_len_adjust = shaper->shaper_len_adjust;
profile_set->shaper_profile = odp_tm_shaper_create(name,
@@ -550,6 +588,7 @@ static int create_and_config_tm(void)
{
odp_tm_level_requirements_t *per_level;
odp_tm_requirements_t requirements;
+ odp_tm_capabilities_t tm_capa;
odp_tm_egress_t egress;
uint32_t level, err_cnt;
@@ -579,6 +618,44 @@ static int create_and_config_tm(void)
egress.egress_fcn = tester_egress_fcn;
odp_tm_test = odp_tm_create("TM test", &requirements, &egress);
+ if (odp_tm_test == ODP_TM_INVALID) {
+ printf("Error: failed to create TM\n");
+ return -1;
+ }
+
+ if (odp_tm_capability(odp_tm_test, &tm_capa) != 0) {
+ printf("Error: failed to get tm capability");
+ return -1;
+ }
+
+ tm_shaper_min_rate = tm_capa.per_level[0].min_rate;
+ tm_shaper_max_rate = tm_capa.per_level[0].max_rate;
+ tm_shaper_min_burst = tm_capa.per_level[0].min_burst;
+ tm_shaper_max_burst = tm_capa.per_level[0].max_burst;
+
+ for (level = 1; level < tm_capa.max_levels; level++) {
+ odp_tm_level_capabilities_t *per_level =
+ &tm_capa.per_level[level];
+
+ 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) {
+ printf("Error: No shaper rate supported by all TM levels");
+ return -1;
+ }
+
err_cnt = init_profile_sets();
if (err_cnt != 0)
printf("%s init_profile_sets encountered %" PRIu32 " errors\n",
@@ -873,7 +950,9 @@ int main(int argc, char *argv[])
if (process_cmd_line_options(argc, argv) < 0)
return -1;
- create_and_config_tm();
+ rc = create_and_config_tm();
+ if (rc != 0)
+ return rc;
/* Start TM */
rc = odp_tm_start(odp_tm_test);
diff --git a/include/Makefile.am b/include/Makefile.am
index 6865b08aa..d47765831 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -320,53 +320,6 @@ odpapiabiarchinclude_HEADERS = \
odp/arch/default-linux/odp/api/abi/traffic_mngr.h \
odp/arch/default-linux/odp/api/abi/version.h
endif
-if ARCH_IS_MIPS64
-odpapiabiarchinclude_HEADERS = \
- odp/arch/mips64-linux/odp/api/abi/align.h \
- odp/arch/mips64-linux/odp/api/abi/atomic.h \
- odp/arch/mips64-linux/odp/api/abi/barrier.h \
- odp/arch/mips64-linux/odp/api/abi/buffer.h \
- odp/arch/mips64-linux/odp/api/abi/byteorder.h \
- odp/arch/mips64-linux/odp/api/abi/classification.h \
- odp/arch/mips64-linux/odp/api/abi/comp.h \
- odp/arch/mips64-linux/odp/api/abi/cpu.h \
- odp/arch/mips64-linux/odp/api/abi/cpumask.h \
- odp/arch/mips64-linux/odp/api/abi/crypto.h \
- odp/arch/mips64-linux/odp/api/abi/debug.h \
- odp/arch/mips64-linux/odp/api/abi/dma_types.h \
- odp/arch/mips64-linux/odp/api/abi/errno.h \
- odp/arch/mips64-linux/odp/api/abi/event.h \
- odp/arch/mips64-linux/odp/api/abi/hash.h \
- odp/arch/mips64-linux/odp/api/abi/init.h \
- odp/arch/mips64-linux/odp/api/abi/ipsec.h \
- odp/arch/mips64-linux/odp/api/abi/packet.h \
- odp/arch/mips64-linux/odp/api/abi/packet_types.h \
- odp/arch/mips64-linux/odp/api/abi/packet_flags.h \
- odp/arch/mips64-linux/odp/api/abi/packet_io.h \
- odp/arch/mips64-linux/odp/api/abi/pool.h \
- odp/arch/mips64-linux/odp/api/abi/proto_stats.h \
- odp/arch/mips64-linux/odp/api/abi/proto_stats_types.h \
- odp/arch/mips64-linux/odp/api/abi/queue.h \
- odp/arch/mips64-linux/odp/api/abi/queue_types.h \
- odp/arch/mips64-linux/odp/api/abi/rwlock.h \
- odp/arch/mips64-linux/odp/api/abi/rwlock_recursive.h \
- odp/arch/mips64-linux/odp/api/abi/schedule.h \
- odp/arch/mips64-linux/odp/api/abi/schedule_types.h \
- odp/arch/mips64-linux/odp/api/abi/shared_memory.h \
- odp/arch/mips64-linux/odp/api/abi/spinlock.h \
- odp/arch/mips64-linux/odp/api/abi/spinlock_recursive.h \
- odp/arch/mips64-linux/odp/api/abi/stash.h \
- odp/arch/mips64-linux/odp/api/abi/std.h \
- odp/arch/mips64-linux/odp/api/abi/std_types.h \
- odp/arch/mips64-linux/odp/api/abi/sync.h \
- odp/arch/mips64-linux/odp/api/abi/thread.h \
- odp/arch/mips64-linux/odp/api/abi/thrmask.h \
- odp/arch/mips64-linux/odp/api/abi/ticketlock.h \
- odp/arch/mips64-linux/odp/api/abi/time.h \
- odp/arch/mips64-linux/odp/api/abi/timer_types.h \
- odp/arch/mips64-linux/odp/api/abi/traffic_mngr.h \
- odp/arch/mips64-linux/odp/api/abi/version.h
-endif
if ARCH_IS_POWERPC
odpapiabiarchinclude_HEADERS = \
odp/arch/power64-linux/odp/api/abi/align.h \
diff --git a/include/odp/api/abi-default/traffic_mngr.h b/include/odp/api/abi-default/traffic_mngr.h
index 155123304..06dc6c3c7 100644
--- a/include/odp/api/abi-default/traffic_mngr.h
+++ b/include/odp/api/abi-default/traffic_mngr.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2015-2018, Linaro Limited
+ * Copyright (c) 2022, Marvell
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -75,20 +76,6 @@ extern "C" {
*/
#define ODP_TM_MAX_TM_NODE_FANIN (4 * 1024)
-/** The ODP_TM_MIN_SHAPER_BW constant is the smallest amount of bandwidth that
- * can a shaper's peak or commit rate can be set to. It is in units of
- * 1000 bytes/second so that it and the ODP_TM_MAX_SHAPER_BW can both fit in
- * 32 bits.
- */
-#define ODP_TM_MIN_SHAPER_BW 1
-
-/** The ODP_TM_MAX_SHAPER_BW constant is the largest amound of bandwidth that
- * any shaper's peak or commit rate can be set to. It is in units of
- * 1000 bytes/second so that it and the ODP_TM_MIN_SHAPER_BW can both fit in
- * 32 bits.
- */
-#define ODP_TM_MAX_SHAPER_BW 12500000
-
/** The ODP_NUM_SHAPER_COLORS constant just counts the number of enumeration
* values defined in the odp_tm_shaper_color_t type.
*/
diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
index d3e3c9a07..3d65c0e05 100644
--- a/include/odp/api/spec/crypto.h
+++ b/include/odp/api/spec/crypto.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2014-2018, Linaro Limited
+ * Copyright (c) 2021-2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -232,12 +233,14 @@ typedef enum {
* cipher.
*
* NIST and RFC specifications of GMAC refer to all data to be
- * authenticated as AAD. In constrast to that, ODP API specifies
- * the bulk of authenticated data to be located in packet payload for
- * all authentication algorithms. Thus GMAC operation authenticates
- * only packet payload and AAD is not used. GMAC needs
- * an initialization vector, which can be passed via session (auth_iv)
- * or packet (auth_iv_ptr) level parameters.
+ * authenticated as AAD. In ODP the data to be authenticated, i.e.
+ * AAD, is ODP packet data and specified using the auth_range
+ * parameter. The aad_length and aad_ptr parameters, which would
+ * require the data to be contiguous in memory, are ignored with
+ * AES-GMAC.
+ *
+ * GMAC needs an initialization vector, which can be passed via
+ * session (auth_iv) or packet (auth_iv_ptr) level parameters.
*/
ODP_AUTH_ALG_AES_GMAC,
@@ -524,15 +527,25 @@ typedef struct odp_crypto_key {
/**
* Crypto API IV structure
+ *
+ * @deprecated
*/
typedef struct odp_crypto_iv {
- /** IV data */
+ /** IV data
+ *
+ * Ignored when length is zero. Null value indicates that an
+ * IV will be provided for each packet through the crypto
+ * operation parameters. In that case the per-operation
+ * IV parameter must always point to a valid IV.
+ *
+ * Default value is NULL.
+ */
uint8_t *data;
- /** IV length in bytes */
+ /** IV length in bytes. Default value is zero. */
uint32_t length;
-} odp_crypto_iv_t;
+} ODP_DEPRECATE(odp_crypto_iv_t);
/**
* Crypto API data range specifier
@@ -559,6 +572,9 @@ typedef struct odp_crypto_session_param_t {
* after the cipher operation else before. When decoding, TRUE
* indicates the reverse order of operation.
*
+ * The value is ignored with authenticated encryption algorithms
+ * such as AES-GCM.
+ *
* true: Authenticate cipher text
* false: Authenticate plain text
*
@@ -566,6 +582,16 @@ typedef struct odp_crypto_session_param_t {
*/
odp_bool_t auth_cipher_text;
+ /** Hash result location may overlap authentication range
+ *
+ * This flag indicates that the hash result location may (but is
+ * not required to) overlap authentication range. Setting this
+ * flag may reduce performance.
+ *
+ * Default value is false.
+ */
+ odp_bool_t hash_result_in_auth_range;
+
/** Preferred sync vs. async for odp_crypto_operation()
*
* The default value is ODP_CRYPTO_SYNC.
@@ -595,13 +621,31 @@ typedef struct odp_crypto_session_param_t {
*/
odp_crypto_key_t cipher_key;
- /** Cipher Initialization Vector (IV) */
+ /** Cipher Initialization Vector (IV)
+ *
+ * Unless using the deprecated API, this specifies the length of
+ * the IV only. The actual IV must then be provided in per-packet
+ * parameters of crypto operations.
+ */
union {
+#if ODP_DEPRECATED_API
/** @deprecated Use cipher_iv */
odp_crypto_iv_t ODP_DEPRECATE(iv);
/** Cipher Initialization Vector (IV) */
- odp_crypto_iv_t cipher_iv;
+ odp_crypto_iv_t ODP_DEPRECATE(cipher_iv);
+#endif
+ /** Cipher IV length */
+ struct {
+#if ODP_DEPRECATED_API
+ /** Unused padding field */
+ uint8_t *dummy_padding_0;
+#endif
+ /** Length of cipher initialization vector.
+ * Default value is zero.
+ */
+ uint32_t cipher_iv_len;
+ };
};
/** Authentication algorithm
@@ -627,8 +671,28 @@ typedef struct odp_crypto_session_param_t {
*/
odp_crypto_key_t auth_key;
- /** Authentication Initialization Vector (IV) */
- odp_crypto_iv_t auth_iv;
+ /** Authentication Initialization Vector (IV)
+ *
+ * Unless using the deprecated API, this specifies the length of
+ * the IV only. The actual IV must then be provided in per-packet
+ * parameters of crypto operations.
+ */
+ union {
+#if ODP_DEPRECATED_API
+ odp_crypto_iv_t ODP_DEPRECATE(auth_iv);
+#endif
+ /** Authentication IV length */
+ struct {
+#if ODP_DEPRECATED_API
+ /** Unused padding field */
+ uint8_t *dummy_padding_1;
+#endif
+ /** Length of authentication initialization vector.
+ * Default value is zero.
+ */
+ uint32_t auth_iv_len;
+ };
+ };
/** Authentication digest length in bytes
*
@@ -697,24 +761,30 @@ typedef struct odp_crypto_op_param_t {
*/
odp_packet_t out_pkt;
- /** Override session IV pointer for cipher */
+ /** IV pointer for cipher */
union {
/** @deprecated use cipher_iv_ptr */
uint8_t *ODP_DEPRECATE(override_iv_ptr);
- /** Override session IV pointer for cipher */
+ /** IV pointer for cipher */
uint8_t *cipher_iv_ptr;
};
- /** Override session authentication IV pointer */
+ /** Authentication IV pointer */
uint8_t *auth_iv_ptr;
/** Offset from start of packet for hash result
*
- * Specifies the offset where the hash result is to be stored. In case
- * of decode sessions, input hash values will be read from this offset,
- * and overwritten with hash results. If this offset lies within
- * specified 'auth_range', implementation will mute this field before
- * calculating the hash result.
+ * In case of decode sessions, the expected hash will be read from
+ * this offset and compared with the calculated hash. After the
+ * operation the hash bytes will have undefined values.
+ *
+ * In case of encode sessions the calculated hash will be stored in
+ * this offset.
+ *
+ * If the hash_result_in_auth_range session parameter is true,
+ * the hash result location may overlap auth_range. In that case
+ * the result location will be zeroed in decode sessions before
+ * hash calculation. Zeroing is not done in encode sessions.
*/
uint32_t hash_result_offset;
@@ -723,10 +793,18 @@ typedef struct odp_crypto_op_param_t {
*/
uint8_t *aad_ptr;
- /** Data range to apply cipher */
+ /** Data range to be ciphered */
odp_packet_data_range_t cipher_range;
- /** Data range to authenticate */
+ /** Data range to be authenticated
+ *
+ * The value is ignored with authenticated encryption algorithms,
+ * such as AES-GCM, which authenticate data in the cipher range
+ * and the AAD.
+ *
+ * As a special case AES-GMAC uses this field instead of aad_ptr
+ * for the data bytes to be authenticated.
+ */
odp_packet_data_range_t auth_range;
} odp_crypto_op_param_t;
@@ -741,24 +819,30 @@ typedef struct odp_crypto_packet_op_param_t {
/** Session handle from creation */
odp_crypto_session_t session;
- /** Override session IV pointer for cipher */
+ /** IV pointer for cipher */
union {
/** @deprecated use cipher_iv_ptr */
uint8_t *ODP_DEPRECATE(override_iv_ptr);
- /** Override session IV pointer for cipher */
+ /** IV pointer for cipher */
uint8_t *cipher_iv_ptr;
};
- /** Override session IV pointer for authentication */
+ /** IV pointer for authentication */
uint8_t *auth_iv_ptr;
/** Offset from start of packet for hash result
*
- * Specifies the offset where the hash result is to be stored. In case
- * of decode sessions, input hash values will be read from this offset,
- * and overwritten with hash results. If this offset lies within
- * specified 'auth_range', implementation will mute this field before
- * calculating the hash result.
+ * In case of decode sessions, the expected hash will be read from
+ * this offset and compared with the calculated hash. After the
+ * operation the hash bytes will have undefined values.
+ *
+ * In case of encode sessions the calculated hash will be stored in
+ * this offset.
+ *
+ * If the hash_result_not_in_auth_range session parameter is false,
+ * the hash result location may overlap auth_range. In that case the
+ * result location will be zeroed in decode sessions before hash
+ * calculation. Zeroing is not done in encode sessions.
*/
uint32_t hash_result_offset;
@@ -780,15 +864,50 @@ typedef struct odp_crypto_packet_op_param_t {
*/
typedef enum {
/** Session created */
- ODP_CRYPTO_SES_CREATE_ERR_NONE,
+ ODP_CRYPTO_SES_ERR_NONE,
/** Creation failed, no resources */
- ODP_CRYPTO_SES_CREATE_ERR_ENOMEM,
+ ODP_CRYPTO_SES_ERR_ENOMEM,
/** Creation failed, bad cipher params */
- ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER,
+ ODP_CRYPTO_SES_ERR_CIPHER,
/** Creation failed, bad auth params */
- ODP_CRYPTO_SES_CREATE_ERR_INV_AUTH,
+ ODP_CRYPTO_SES_ERR_AUTH,
+
+ /** Unsupported combination of algorithms
+ *
+ * The combination of cipher and auth algorithms with their
+ * specific parameters is not supported even if the algorithms
+ * appear in capabilities and are supported in combination with
+ * other algorithms or other algorithm specific parameters.
+ */
+ ODP_CRYPTO_SES_ERR_ALG_COMBO,
+
+ /** Unsupported order of cipher and auth
+ *
+ * The requested mutual order of ciphering and authentication
+ * is not supported with the chosen individual cipher and
+ * authentication algorithms.
+ */
+ ODP_CRYPTO_SES_ERR_ALG_ORDER,
+
+ /** Unsupported combination of session creation parameters
+ *
+ * The combination of provided session creation parameters is not
+ * supported. This error can occur when there are limitations that
+ * are not expressible through crypto capabilities or other error
+ * status values.
+ */
+ ODP_CRYPTO_SES_ERR_PARAMS,
} odp_crypto_ses_create_err_t;
+/** This synonym for backward compatibility will be deprecated later */
+#define ODP_CRYPTO_SES_CREATE_ERR_NONE ODP_CRYPTO_SES_ERR_NONE
+/** This synonym for backward compatibility will be deprecated later */
+#define ODP_CRYPTO_SES_CREATE_ERR_ENOMEM ODP_CRYPTO_SES_ERR_ENOMEM
+/** This synonym for backward compatibility will be deprecated later */
+#define ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER ODP_CRYPTO_SES_ERR_CIPHER
+/** This synonym for backward compatibility will be deprecated later */
+#define ODP_CRYPTO_SES_CREATE_ERR_INV_AUTH ODP_CRYPTO_SES_ERR_AUTH
+
/**
* Crypto API algorithm return code
*/
diff --git a/include/odp/api/spec/random.h b/include/odp/api/spec/random.h
index 3cd297249..f6c2b8fe4 100644
--- a/include/odp/api/spec/random.h
+++ b/include/odp/api/spec/random.h
@@ -85,7 +85,7 @@ int32_t odp_random_data(uint8_t *buf, uint32_t len, odp_random_kind_t kind);
* For testing purposes it is often useful to generate "random" sequences that
* are repeatable. This is accomplished by supplying a seed value that is used
* for pseudo-random data generation. The caller-provided seed value is
- * updated for each call to continue the sequence. Restarting a series of
+ * updated for each call to continue the sequence. Restarting the same series of
* calls with the same initial seed value will generate the same sequence of
* random test data.
*
diff --git a/include/odp/api/spec/traffic_mngr.h b/include/odp/api/spec/traffic_mngr.h
index 57c11c486..ca35bb4aa 100644
--- a/include/odp/api/spec/traffic_mngr.h
+++ b/include/odp/api/spec/traffic_mngr.h
@@ -1,5 +1,6 @@
/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
+ * Copyright (c) 2021-2022, Nokia
+ * Copyright (c) 2022, Marvell
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -97,18 +98,6 @@ extern "C" {
*/
/**
- * @def ODP_TM_MIN_SHAPER_BW
- * The lowest amount of bandwidth that any shaper's peak or commit rate can
- * be set to. It is in units of 1000 bytes/second.
- */
-
-/**
- * @def ODP_TM_MAX_SHAPER_BW
- * The largest amount of bandwidth that any shaper's peak or commit rate can
- * be set to. It is in units of 1000 bytes/second.
- */
-
-/**
* @def ODP_NUM_SHAPER_COLORS
* The number of enumeration values defined in the odp_tm_shaper_color_t type.
*/
@@ -278,6 +267,54 @@ typedef struct {
* of the weights allowed at this level. */
uint32_t max_weight;
+ /** Minimum allowed value for odp_tm_shaper_params_t::commit_burst and
+ * odp_tm_shaper_params_t::peak_burst when
+ * odp_tm_shaper_params_t::packet_mode is true.
+ */
+ uint32_t min_burst_packets;
+
+ /** Maximum allowed value fand odp_tm_shaper_params_t::commit_burst and
+ * odp_tm_shaper_params_t::peak_burst when
+ * odp_tm_shaper_params_t::packet_mode is true.
+ */
+ uint32_t max_burst_packets;
+
+ /** Minimum allowed value for odp_tm_shaper_params_t::commit_rate and
+ * odp_tm_shaper_params_t::peak_rate when
+ * odp_tm_shaper_params_t::packet_mode is true.
+ */
+ uint64_t min_rate_packets;
+
+ /** Maximum allowed value for odp_tm_shaper_params_t::commit_rate and
+ * odp_tm_shaper_params_t::peak_rate when
+ * odp_tm_shaper_params_t::packet_mode is true.
+ */
+ uint64_t max_rate_packets;
+
+ /** Minimum allowed value for odp_tm_shaper_params_t::commit_burst and
+ * odp_tm_shaper_params_t::peak_burst when
+ * odp_tm_shaper_params_t::packet_mode is false.
+ */
+ uint32_t min_burst;
+
+ /** Maximum allowed value for odp_tm_shaper_params_t::commit_burst and
+ * odp_tm_shaper_params_t::peak_burst when
+ * odp_tm_shaper_params_t::packet_mode is false.
+ */
+ uint32_t max_burst;
+
+ /** Minimum allowed value for odp_tm_shaper_params_t::commit_rate and
+ * odp_tm_shaper_params_t::peak_rate when
+ * odp_tm_shaper_params_t::packet_mode is false.
+ */
+ uint64_t min_rate;
+
+ /** Maximum allowed value for odp_tm_shaper_params_t::commit_rate and
+ * odp_tm_shaper_params_t::peak_rate when
+ * odp_tm_shaper_params_t::packet_mode is false.
+ */
+ uint64_t max_rate;
+
/** tm_node_shaper_supported indicates that the tm_nodes at this level
* all support TM shaping, */
odp_bool_t tm_node_shaper_supported;
@@ -518,7 +555,8 @@ typedef struct {
*
* The odp_tm_level_requirements_t record is used to describe the requirements
* that might vary based upon the tm_node level. It is always used as
- * part of the odp_tm_requirements record. */
+ * part of the odp_tm_requirements record. The default value of all boolean
+ * fields is false. */
typedef struct {
/** max_num_tm_nodes specifies the maximum number of tm_nodes required
* at this level. */
@@ -578,7 +616,10 @@ typedef struct {
/** TM Requirements Record.
*
* The odp_tm_requirements_t record type is used to describe the minimum
- * set of features and limits to be actually used by the application. */
+ * set of features and limits to be actually used by the application.
+ *
+ * The default value of all boolean fields is false.
+ **/
typedef struct {
/** max_tm_queues specifies the maximum number of tm_queues that will
* be used for this TM System. */
@@ -586,7 +627,8 @@ typedef struct {
/** num_levels specifies that number of levels of hierarchical
* scheduling that will be used. This is a count of the tm_node
- * stages and does not include tm_queues or tm_egress objects. */
+ * stages and does not include tm_queues or tm_egress objects.
+ * The default value is 0. */
uint8_t num_levels;
/** tm_queue_shaper_needed indicates that the tm_queues are expected
@@ -673,7 +715,7 @@ typedef struct {
};
} odp_tm_egress_t;
-/** Initialize Requirements record.
+/** Initialize Requirements record fields to their default values.
*
* odp_tm_requirements_init() must be called to initialize any
* odp_tm_requirements_t record before it is first used or assigned to.
@@ -1026,6 +1068,7 @@ typedef struct {
/** The peak information rate for this shaper profile. The units for
* this integer is in bits per second when packet_mode is
* not TRUE while in packets per second when packet mode is TRUE.
+ * This field is ignored when dual_rate is FALSE.
*/
union {
/**< @deprecated Use peak_rate instead */
@@ -1042,7 +1085,9 @@ typedef struct {
/** The peak burst tolerance for this shaper profile. The units for
* this field in bits when packet_mode is not TRUE and packets
* when packet_mode is TRUE. This value sets an upper limit for the
- * size of the peakCnt. */
+ * size of the peakCnt.
+ * This field is ignored when dual_rate is FALSE.
+ */
uint32_t peak_burst;
/** The shaper_len_adjust is a value between -128 and 127 which is
@@ -1055,25 +1100,30 @@ typedef struct {
* would be the value 20 (8 + 12), but in same cases can be as low as
* 9 (4 + 5).
* This field is ignored when packet_mode is TRUE.
- */
+ *
+ * The default value is 0. */
int8_t shaper_len_adjust;
/** If dual_rate is TRUE it indicates the desire for the
* implementation to use dual rate shaping for packets associated with
* this profile. The precise semantics of dual rate shaping are
* implementation specific, but in any case require a non-zero set of
- * both commit and peak parameters. */
+ * both commit and peak parameters.
+ *
+ * The default value is false. */
odp_bool_t dual_rate;
/** If packet_mode is TRUE it indicates that shaper should work
* in packet mode ignoring lengths of packet and hence shaping
* traffic in packet's per second as opposed to bits per second.
- */
+ *
+ * The default value is false. */
odp_bool_t packet_mode;
} odp_tm_shaper_params_t;
/** odp_tm_shaper_params_init() must be called to initialize any
* odp_tm_shaper_params_t record before it is first used or assigned to.
+ * The parameters are initialized to their default values.
*
* @param params A pointer to an odp_tm_shaper_params_t record which
* is to be initialized.
@@ -1170,7 +1220,8 @@ typedef enum {
*/
typedef struct {
/** sched_modes indicates whether weighted scheduling should be used
- * or not - on a priority basis. */
+ * or not - on a priority basis.
+ * The default value is ODP_TM_BYTE_BASED_WEIGHTS for all priorities */
odp_tm_sched_mode_t sched_modes[ODP_TM_MAX_PRIORITIES];
/** In the case that sched_modes for a given strict priority level
@@ -1185,6 +1236,7 @@ typedef struct {
/** odp_tm_sched_params_init() must be called to initialize any
* odp_tm_sched_params_t record before it is first used or assigned to.
+ * The parameters are initialized to their default values.
*
* @param params A pointer to an odp_tm_sched_params_t record which
* is to be initialized.
@@ -1268,12 +1320,17 @@ odp_tm_sched_t odp_tm_sched_lookup(const char *name);
typedef struct {
uint64_t max_pkts; /**< max pkt cnt for this threshold profile */
uint64_t max_bytes; /**< max byte cnt for this threshold profile */
- odp_bool_t enable_max_pkts; /**< TRUE if max_pkts is valid */
- odp_bool_t enable_max_bytes; /**< TRUE if max_bytes is valid */
+
+ /** TRUE if max_pkts is valid. The default value is false. */
+ odp_bool_t enable_max_pkts;
+
+ /** TRUE if max_bytes is valid. The default value is false. */
+ odp_bool_t enable_max_bytes;
} odp_tm_threshold_params_t;
/** odp_tm_threshold_params_init() must be called to initialize any
* odp_tm_threshold_params_t record before it is first used or assigned to.
+ * The parameters are initialized to their default values.
*
* @param params A pointer to an odp_tm_threshold_params_t record which
* is to be initialized.
@@ -1397,7 +1454,7 @@ typedef struct {
/** When enable_wred is false, all tm_queues and tm_nodes that are
* attached to this profile will not take part in a Random Early
- * Detection algorithm. */
+ * Detection algorithm. The default value is false. */
odp_bool_t enable_wred;
/** When use_byte_fullness is true then WRED will use queue memory
@@ -1405,12 +1462,13 @@ typedef struct {
* is false, WRED will use the queue length (i.e. the number of
* packets in the queue) as the fullness criterion. Often will be set
* to true for WRED profiles applied to tm_queues and set to false for
- * WRED profiles applied to tm_nodes. */
+ * WRED profiles applied to tm_nodes. The default value is false. */
odp_bool_t use_byte_fullness;
} odp_tm_wred_params_t;
/** odp_tm_wred_params_init() must be called to initialize any
* odp_tm_wred_params_t record before it is first used or assigned to.
+ * The parameters are initialized to their default values.
*
* @param params A pointer to an odp_tm_wred_params_t record which
* is to be initialized.
@@ -1504,17 +1562,19 @@ typedef struct {
/** The shaper profile to be associated with this tm_node. Can be
* ODP_TM_INVALID and can also be set and changed post-creation via
- * odp_tm_node_shaper_config(); */
+ * odp_tm_node_shaper_config(); The default value is ODP_TM_INVALID. */
odp_tm_shaper_t shaper_profile;
/** The threshold profile to be used in setting the max queue fullness
* for WRED and/or tail drop? Can be ODP_TM_INVALID and can also be
- * set and changed post-creation via odp_tm_node_threshold_config(). */
+ * set and changed post-creation via odp_tm_node_threshold_config().
+ * The default value is ODP_TM_INVALID. */
odp_tm_threshold_t threshold_profile;
/** The WRED profile(s) to be associated with this tm_node. Any or
* all array elements can be ODP_TM_INVALID and can also be set and
- * changed post-creation via odp_tm_node_wred_config(). */
+ * changed post-creation via odp_tm_node_wred_config().
+ * The default value is ODP_TM_INVALID for every color. */
odp_tm_wred_t wred_profile[ODP_NUM_PACKET_COLORS];
/** The level (or tm_node stage) sets the level for this tm_node It
@@ -1543,6 +1603,7 @@ typedef struct {
/** odp_tm_node_params_init() must be called to initialize any
* odp_tm_node_params_t record before it is first used or assigned to.
+ * The parameters are initialized to their default values.
*
* @param params A pointer to an odp_tm_node_params_t record which
* is to be initialized.
@@ -1688,23 +1749,25 @@ typedef struct {
/** The shaper profile to be associated with this tm_queue. Can be
* ODP_TM_INVALID and can also be set and changed post-creation via
- * odp_tm_queue_shaper_config(). */
+ * odp_tm_queue_shaper_config(). The default value is ODP_TM_INVALID. */
odp_tm_shaper_t shaper_profile;
/** The threshold profile to be used in setting the max queue fullness
* for WRED and/or tail drop? Can be ODP_TM_INVALID and can also be
- * set and changed post-creation via odp_tm_queue_threshold_config(). */
+ * set and changed post-creation via odp_tm_queue_threshold_config().
+ * The default value is ODP_TM_INVALID. */
odp_tm_threshold_t threshold_profile;
/** The WRED profile(s) to be associated with this tm_queue. Any or
* all array elements can be ODP_TM_INVALID and can also be set and
- * changed post-creation via odp_tm_queue_wred_config(). */
+ * changed post-creation via odp_tm_queue_wred_config().
+ * The default value is ODP_TM_INVALID for every color. */
odp_tm_wred_t wred_profile[ODP_NUM_PACKET_COLORS];
/** The strict priority level assigned to packets in this tm_queue -
* in other words all packets associated with a given tm_queue MUST
* have the same single strict priority level and this level must be
- * in the range 0..max_priority. */
+ * in the range 0..max_priority. The default value is 0. */
uint8_t priority;
/** Maintain original packet order of the source queue when enqueuing
@@ -1716,6 +1779,7 @@ typedef struct {
/** odp_tm_queue_params_init() must be called to initialize any
* odp_tm_queue_params_t record before it is first used or assigned to.
+ * The parameters are initialized to their default values.
*
* @param params A pointer to an odp_tm_queue_params_t record which
* is to be initialized.
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/align.h b/include/odp/arch/mips64-linux/odp/api/abi/align.h
deleted file mode 100644
index 7fa343078..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/align.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/align.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/atomic.h b/include/odp/arch/mips64-linux/odp/api/abi/atomic.h
deleted file mode 100644
index da89426c7..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/atomic.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/atomic.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/barrier.h b/include/odp/arch/mips64-linux/odp/api/abi/barrier.h
deleted file mode 100644
index 56b64b81d..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/barrier.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/barrier.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/buffer.h b/include/odp/arch/mips64-linux/odp/api/abi/buffer.h
deleted file mode 100644
index 217ed4a93..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/buffer.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/buffer.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/byteorder.h b/include/odp/arch/mips64-linux/odp/api/abi/byteorder.h
deleted file mode 100644
index eb383cd33..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/byteorder.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/byteorder.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/classification.h b/include/odp/arch/mips64-linux/odp/api/abi/classification.h
deleted file mode 100644
index 732eb27e0..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/classification.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/classification.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/comp.h b/include/odp/arch/mips64-linux/odp/api/abi/comp.h
deleted file mode 100644
index a8f6439f4..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/comp.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/comp.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/cpu.h b/include/odp/arch/mips64-linux/odp/api/abi/cpu.h
deleted file mode 100644
index 6e2573a74..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/cpu.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef ODP_API_ABI_CPU_H_
-#define ODP_API_ABI_CPU_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined __OCTEON__
-#define ODP_CACHE_LINE_SIZE 128
-#else
-#error Please add support for your arch in abi/cpu.h
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/cpumask.h b/include/odp/arch/mips64-linux/odp/api/abi/cpumask.h
deleted file mode 100644
index c64bf2a69..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/cpumask.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/cpumask.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/crypto.h b/include/odp/arch/mips64-linux/odp/api/abi/crypto.h
deleted file mode 100644
index 386384285..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/crypto.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/crypto.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/debug.h b/include/odp/arch/mips64-linux/odp/api/abi/debug.h
deleted file mode 100644
index 97d028d51..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/debug.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/debug.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/dma_types.h b/include/odp/arch/mips64-linux/odp/api/abi/dma_types.h
deleted file mode 100644
index 76ccd895d..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/dma_types.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/dma_types.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/errno.h b/include/odp/arch/mips64-linux/odp/api/abi/errno.h
deleted file mode 100644
index 69de49a0b..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/errno.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2020, Marvell
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/errno.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/event.h b/include/odp/arch/mips64-linux/odp/api/abi/event.h
deleted file mode 100644
index 408433ad8..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/event.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/event.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/hash.h b/include/odp/arch/mips64-linux/odp/api/abi/hash.h
deleted file mode 100644
index c9fb1976c..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/hash.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2020, Marvell
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/hash.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/init.h b/include/odp/arch/mips64-linux/odp/api/abi/init.h
deleted file mode 100644
index 7ad523fde..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/init.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/init.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/ipsec.h b/include/odp/arch/mips64-linux/odp/api/abi/ipsec.h
deleted file mode 100644
index 13151beeb..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/ipsec.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/ipsec.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/packet.h b/include/odp/arch/mips64-linux/odp/api/abi/packet.h
deleted file mode 100644
index be8809aed..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/packet.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/packet.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/packet_flags.h b/include/odp/arch/mips64-linux/odp/api/abi/packet_flags.h
deleted file mode 100644
index 2ff0e0016..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/packet_flags.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/packet_flags.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/packet_io.h b/include/odp/arch/mips64-linux/odp/api/abi/packet_io.h
deleted file mode 100644
index ec02e3a2b..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/packet_io.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/packet_io.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/packet_types.h b/include/odp/arch/mips64-linux/odp/api/abi/packet_types.h
deleted file mode 100644
index c92ffd684..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/packet_types.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/packet_types.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/pool.h b/include/odp/arch/mips64-linux/odp/api/abi/pool.h
deleted file mode 100644
index 3b1f21d97..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/pool.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/pool.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/proto_stats.h b/include/odp/arch/mips64-linux/odp/api/abi/proto_stats.h
deleted file mode 100644
index 81108faa5..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/proto_stats.h
+++ /dev/null
@@ -1,5 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(C) 2021 Marvell.
- */
-
-#include <odp/api/abi-default/proto_stats.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/proto_stats_types.h b/include/odp/arch/mips64-linux/odp/api/abi/proto_stats_types.h
deleted file mode 100644
index 1cb6128b6..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/proto_stats_types.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/proto_stats_types.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/queue.h b/include/odp/arch/mips64-linux/odp/api/abi/queue.h
deleted file mode 100644
index 53f046f80..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/queue.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/queue.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/queue_types.h b/include/odp/arch/mips64-linux/odp/api/abi/queue_types.h
deleted file mode 100644
index 51837734a..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/queue_types.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/queue_types.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/rwlock.h b/include/odp/arch/mips64-linux/odp/api/abi/rwlock.h
deleted file mode 100644
index 96dbc9b83..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/rwlock.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/rwlock.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/rwlock_recursive.h b/include/odp/arch/mips64-linux/odp/api/abi/rwlock_recursive.h
deleted file mode 100644
index 14c964c9d..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/rwlock_recursive.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/rwlock_recursive.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/schedule.h b/include/odp/arch/mips64-linux/odp/api/abi/schedule.h
deleted file mode 100644
index 748c6aa8a..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/schedule.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/schedule.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/schedule_types.h b/include/odp/arch/mips64-linux/odp/api/abi/schedule_types.h
deleted file mode 100644
index d5164ff79..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/schedule_types.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/schedule_types.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/shared_memory.h b/include/odp/arch/mips64-linux/odp/api/abi/shared_memory.h
deleted file mode 100644
index 784170abe..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/shared_memory.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/shared_memory.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/spinlock.h b/include/odp/arch/mips64-linux/odp/api/abi/spinlock.h
deleted file mode 100644
index fbfbce5cc..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/spinlock.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/spinlock.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/spinlock_recursive.h b/include/odp/arch/mips64-linux/odp/api/abi/spinlock_recursive.h
deleted file mode 100644
index cc93b6acb..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/spinlock_recursive.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/spinlock_recursive.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/stash.h b/include/odp/arch/mips64-linux/odp/api/abi/stash.h
deleted file mode 100644
index d98413dea..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/stash.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2020, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/stash.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/std.h b/include/odp/arch/mips64-linux/odp/api/abi/std.h
deleted file mode 100644
index a7243c4d4..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/std.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/std.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/std_types.h b/include/odp/arch/mips64-linux/odp/api/abi/std_types.h
deleted file mode 100644
index 594e6f9dd..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/std_types.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/std_types.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/sync.h b/include/odp/arch/mips64-linux/odp/api/abi/sync.h
deleted file mode 100644
index 37b03bcd9..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/sync.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/sync.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/thread.h b/include/odp/arch/mips64-linux/odp/api/abi/thread.h
deleted file mode 100644
index be44ad8aa..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/thread.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/thread.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/thrmask.h b/include/odp/arch/mips64-linux/odp/api/abi/thrmask.h
deleted file mode 100644
index ab05cd83f..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/thrmask.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/thrmask.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/ticketlock.h b/include/odp/arch/mips64-linux/odp/api/abi/ticketlock.h
deleted file mode 100644
index 0750f7e72..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/ticketlock.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/ticketlock.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/time.h b/include/odp/arch/mips64-linux/odp/api/abi/time.h
deleted file mode 100644
index a86a526dc..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/time.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/time.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/timer_types.h b/include/odp/arch/mips64-linux/odp/api/abi/timer_types.h
deleted file mode 100644
index cd384c2bc..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/timer_types.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/timer_types.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/traffic_mngr.h b/include/odp/arch/mips64-linux/odp/api/abi/traffic_mngr.h
deleted file mode 100644
index 0e6bc7982..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/traffic_mngr.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/traffic_mngr.h>
diff --git a/include/odp/arch/mips64-linux/odp/api/abi/version.h b/include/odp/arch/mips64-linux/odp/api/abi/version.h
deleted file mode 100644
index 429d4f3fa..000000000
--- a/include/odp/arch/mips64-linux/odp/api/abi/version.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp/api/abi-default/version.h>
diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am
index 2f257044e..789fbced6 100644
--- a/platform/linux-dpdk/Makefile.am
+++ b/platform/linux-dpdk/Makefile.am
@@ -144,7 +144,7 @@ noinst_HEADERS = \
${top_srcdir}/platform/linux-generic/include/odp_sysinfo_internal.h \
include/odp_shm_internal.h \
include/odp_thread_internal.h \
- ${top_srcdir}/platform/linux-generic/include/odp_timer_internal.h \
+ include/odp_timer_internal.h \
${top_srcdir}/platform/linux-generic/include/odp_timer_wheel_internal.h \
${top_srcdir}/platform/linux-generic/include/odp_traffic_mngr_internal.h \
include/odp_event_vector_internal.h \
@@ -292,7 +292,7 @@ noinst_HEADERS += arch/aarch64/odp_atomic.h \
arch/aarch64/cpu_flags.h \
arch/aarch64/odp_cpu_idling.h \
arch/aarch64/odp_llsc.h \
- arch/default/odp_random.h
+ arch/aarch64/odp_random.h
endif
if ARCH_IS_DEFAULT
__LIB__libodp_dpdk_la_SOURCES += arch/default/odp_atomic.c \
@@ -315,26 +315,6 @@ noinst_HEADERS += arch/default/odp_atomic.h \
arch/default/odp_cpu_idling.h \
arch/default/odp_random.h
endif
-if ARCH_IS_MIPS64
-__LIB__libodp_dpdk_la_SOURCES += arch/default/odp_atomic.c \
- arch/default/odp_global_time.c \
- arch/default/odp_hash_crc32.c \
- arch/default/odp_random.c \
- arch/mips64/odp_sysinfo_parse.c
-odpapiabiarchinclude_HEADERS += arch/default/odp/api/abi/cpu_time.h \
- arch/default/odp/api/abi/hash_crc32.h
-if !ODP_ABI_COMPAT
-odpapiabiarchinclude_HEADERS += arch/default/odp/api/abi/atomic_generic.h \
- arch/default/odp/api/abi/atomic_inlines.h \
- arch/default/odp/api/abi/cpu_generic.h \
- arch/mips64/odp/api/abi/cpu_inlines.h \
- arch/mips64/odp/api/abi/cpu.h
-endif
-noinst_HEADERS += arch/default/odp_atomic.h \
- arch/default/odp_cpu.h \
- arch/default/odp_cpu_idling.h \
- arch/default/odp_random.h
-endif
if ARCH_IS_POWERPC
__LIB__libodp_dpdk_la_SOURCES += arch/default/odp_atomic.c \
arch/default/odp_cpu_cycles.c \
diff --git a/platform/linux-dpdk/arch/aarch64/odp_random.h b/platform/linux-dpdk/arch/aarch64/odp_random.h
new file mode 120000
index 000000000..892ad529c
--- /dev/null
+++ b/platform/linux-dpdk/arch/aarch64/odp_random.h
@@ -0,0 +1 @@
+../../../linux-generic/arch/aarch64/odp_random.h \ No newline at end of file
diff --git a/platform/linux-dpdk/arch/mips64/odp/api/abi/cpu.h b/platform/linux-dpdk/arch/mips64/odp/api/abi/cpu.h
deleted file mode 100644
index 6644a1ed3..000000000
--- a/platform/linux-dpdk/arch/mips64/odp/api/abi/cpu.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef ODP_API_ABI_CPU_H_
-#define ODP_API_ABI_CPU_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <rte_common.h>
-
-#define ODP_CACHE_LINE_SIZE RTE_CACHE_LINE_SIZE
-
-/* Inlined functions for non-ABI compat mode */
-#include <odp/api/plat/cpu_inlines.h>
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/platform/linux-dpdk/arch/mips64/odp/api/abi/cpu_inlines.h b/platform/linux-dpdk/arch/mips64/odp/api/abi/cpu_inlines.h
deleted file mode 120000
index 873e0681f..000000000
--- a/platform/linux-dpdk/arch/mips64/odp/api/abi/cpu_inlines.h
+++ /dev/null
@@ -1 +0,0 @@
-../../../../../../linux-generic/arch/mips64/odp/api/abi/cpu_inlines.h \ No newline at end of file
diff --git a/platform/linux-dpdk/arch/mips64/odp_sysinfo_parse.c b/platform/linux-dpdk/arch/mips64/odp_sysinfo_parse.c
deleted file mode 120000
index 794300475..000000000
--- a/platform/linux-dpdk/arch/mips64/odp_sysinfo_parse.c
+++ /dev/null
@@ -1 +0,0 @@
-../../../linux-generic/arch/mips64/odp_sysinfo_parse.c \ No newline at end of file
diff --git a/platform/linux-dpdk/include/odp_event_internal.h b/platform/linux-dpdk/include/odp_event_internal.h
index 9221def98..b3ce6c795 100644
--- a/platform/linux-dpdk/include/odp_event_internal.h
+++ b/platform/linux-dpdk/include/odp_event_internal.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2021, Nokia
+/* Copyright (c) 2021-2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -54,15 +54,9 @@ typedef struct _odp_event_hdr_t {
/* --- Mostly read only data --- */
- /* User pointer */
- const void *user_ptr;
-
/* Pool pointer */
void *pool_ptr;
- /* User area pointer */
- void *uarea_addr;
-
} _odp_event_hdr_t;
static inline odp_event_t _odp_event_from_hdr(_odp_event_hdr_t *hdr)
diff --git a/platform/linux-dpdk/include/odp_packet_internal.h b/platform/linux-dpdk/include/odp_packet_internal.h
index a3e806f54..bda9b6c98 100644
--- a/platform/linux-dpdk/include/odp_packet_internal.h
+++ b/platform/linux-dpdk/include/odp_packet_internal.h
@@ -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
@@ -126,6 +126,12 @@ typedef struct odp_packet_hdr_t {
/* Classifier destination queue */
odp_queue_t dst_queue;
+ /* User area pointer */
+ void *uarea_addr;
+
+ /* User context pointer */
+ const void *user_ptr;
+
/* Classifier mark */
uint16_t cls_mark;
diff --git a/platform/linux-dpdk/include/odp_timer_internal.h b/platform/linux-dpdk/include/odp_timer_internal.h
new file mode 100644
index 000000000..2e8487689
--- /dev/null
+++ b/platform/linux-dpdk/include/odp_timer_internal.h
@@ -0,0 +1,54 @@
+/* Copyright (c) 2014-2018, Linaro Limited
+ * Copyright (c) 2021-2022, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP timeout descriptor - implementation internal
+ */
+
+#ifndef ODP_TIMER_INTERNAL_H_
+#define ODP_TIMER_INTERNAL_H_
+
+#include <odp/api/align.h>
+#include <odp/api/debug.h>
+#include <odp/api/timer.h>
+
+#include <odp_event_internal.h>
+#include <odp_global_data.h>
+#include <odp_pool_internal.h>
+
+/**
+ * Internal Timeout header
+ */
+typedef struct ODP_ALIGNED_CACHE odp_timeout_hdr_t {
+ /* Common event header */
+ _odp_event_hdr_t event_hdr;
+
+ /* Requested expiration time */
+ uint64_t expiration;
+
+ /* User ptr inherited from parent timer */
+ const void *user_ptr;
+
+ /* Parent timer */
+ odp_timer_t timer;
+
+} odp_timeout_hdr_t;
+
+/* A larger decrement value should be used after receiving events compared to
+ * an 'empty' call. */
+void _odp_timer_run_inline(int dec);
+
+/* Static inline wrapper to minimize modification of schedulers. */
+static inline void timer_run(int dec)
+{
+ if (odp_global_rw->inline_timers)
+ _odp_timer_run_inline(dec);
+}
+
+#endif
diff --git a/platform/linux-dpdk/odp_crypto.c b/platform/linux-dpdk/odp_crypto.c
index 02c06be0e..818993acc 100644
--- a/platform/linux-dpdk/odp_crypto.c
+++ b/platform/linux-dpdk/odp_crypto.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2018-2021, Nokia
+ * Copyright (c) 2018-2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -70,8 +70,10 @@ typedef struct crypto_session_entry_s {
} flags;
uint16_t cdev_nb_qpairs;
uint8_t cdev_id;
+#if ODP_DEPRECATED_API
uint8_t cipher_iv_data[MAX_IV_LENGTH];
uint8_t auth_iv_data[MAX_IV_LENGTH];
+#endif
} crypto_session_entry_t;
typedef struct crypto_global_s {
@@ -1332,7 +1334,7 @@ static int crypto_fill_cipher_xform(struct rte_crypto_sym_xform *cipher_xform,
"cipher key"))
return -1;
cipher_xform->cipher.iv.offset = IV_OFFSET;
- cipher_xform->cipher.iv.length = param->cipher_iv.length;
+ cipher_xform->cipher.iv.length = param->cipher_iv_len;
/* Derive order */
if (ODP_CRYPTO_OP_ENCODE == param->op)
@@ -1365,7 +1367,7 @@ static int crypto_fill_auth_xform(struct rte_crypto_sym_xform *auth_xform,
return -1;
auth_xform->auth.iv.offset = IV_OFFSET + MAX_IV_LENGTH;
- auth_xform->auth.iv.length = param->auth_iv.length;
+ auth_xform->auth.iv.length = param->auth_iv_len;
if (ODP_CRYPTO_OP_ENCODE == param->op)
auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
@@ -1391,7 +1393,7 @@ static int crypto_fill_aead_xform(struct rte_crypto_sym_xform *aead_xform,
return -1;
aead_xform->aead.iv.offset = IV_OFFSET;
- aead_xform->aead.iv.length = param->cipher_iv.length;
+ aead_xform->aead.iv.length = param->cipher_iv_len;
aead_xform->aead.aad_length = param->auth_aad_len;
if (aead_xform->aead.aad_length > PACKET_AAD_MAX) {
@@ -1439,14 +1441,14 @@ int odp_crypto_session_create(const odp_crypto_session_param_t *param,
ODP_ERR("Crypto is disabled\n");
/* Dummy output to avoid compiler warning about uninitialized
* variables */
- *status = ODP_CRYPTO_SES_CREATE_ERR_ENOMEM;
+ *status = ODP_CRYPTO_SES_ERR_ENOMEM;
*session_out = ODP_CRYPTO_SESSION_INVALID;
return -1;
}
if (rte_cryptodev_count() == 0) {
ODP_ERR("No crypto devices available\n");
- *status = ODP_CRYPTO_SES_CREATE_ERR_ENOMEM;
+ *status = ODP_CRYPTO_SES_ERR_ENOMEM;
goto err;
}
@@ -1454,7 +1456,7 @@ int odp_crypto_session_create(const odp_crypto_session_param_t *param,
session = alloc_session();
if (session == NULL) {
ODP_ERR("Failed to allocate a session session");
- *status = ODP_CRYPTO_SES_CREATE_ERR_ENOMEM;
+ *status = ODP_CRYPTO_SES_ERR_ENOMEM;
goto err;
}
@@ -1481,7 +1483,7 @@ int odp_crypto_session_create(const odp_crypto_session_param_t *param,
if (cipher_is_aead(param->cipher_alg)) {
if (crypto_fill_aead_xform(&cipher_xform, &session->p) < 0) {
- *status = ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER;
+ *status = ODP_CRYPTO_SES_ERR_CIPHER;
goto err;
}
@@ -1493,12 +1495,12 @@ int odp_crypto_session_create(const odp_crypto_session_param_t *param,
odp_bool_t do_cipher_first;
if (crypto_fill_cipher_xform(&cipher_xform, &session->p) < 0) {
- *status = ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER;
+ *status = ODP_CRYPTO_SES_ERR_CIPHER;
goto err;
}
if (crypto_fill_auth_xform(&auth_xform, &session->p) < 0) {
- *status = ODP_CRYPTO_SES_CREATE_ERR_INV_AUTH;
+ *status = ODP_CRYPTO_SES_ERR_AUTH;
goto err;
}
@@ -1534,7 +1536,7 @@ int odp_crypto_session_create(const odp_crypto_session_param_t *param,
}
if (rc) {
ODP_ERR("Couldn't find a crypto device");
- *status = ODP_CRYPTO_SES_CREATE_ERR_ENOMEM;
+ *status = ODP_CRYPTO_SES_ERR_ENOMEM;
goto err;
}
@@ -1544,7 +1546,7 @@ int odp_crypto_session_create(const odp_crypto_session_param_t *param,
/* Setup session */
rte_session = rte_cryptodev_sym_session_create(sess_mp);
if (rte_session == NULL) {
- *status = ODP_CRYPTO_SES_CREATE_ERR_ENOMEM;
+ *status = ODP_CRYPTO_SES_ERR_ENOMEM;
goto err;
}
@@ -1552,7 +1554,7 @@ int odp_crypto_session_create(const odp_crypto_session_param_t *param,
first_xform, sess_mp) < 0) {
/* remove the crypto_session_entry_t */
rte_cryptodev_sym_session_free(rte_session);
- *status = ODP_CRYPTO_SES_CREATE_ERR_ENOMEM;
+ *status = ODP_CRYPTO_SES_ERR_ENOMEM;
goto err;
}
@@ -1567,6 +1569,7 @@ out_null:
session->cdev_id = cdev_id;
session->cipher_xform = cipher_xform;
session->auth_xform = auth_xform;
+#if ODP_DEPRECATED_API
if (param->cipher_iv.data)
memcpy(session->cipher_iv_data,
param->cipher_iv.data,
@@ -1575,10 +1578,10 @@ out_null:
memcpy(session->auth_iv_data,
param->auth_iv.data,
param->auth_iv.length);
-
+#endif
/* We're happy */
*session_out = (intptr_t)session;
- *status = ODP_CRYPTO_SES_CREATE_ERR_NONE;
+ *status = ODP_CRYPTO_SES_ERR_NONE;
return 0;
@@ -1738,12 +1741,14 @@ static uint8_t *crypto_prepare_digest(crypto_session_entry_t *session,
uint8_t *data;
odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
- if (verify)
+ if (verify) {
odp_packet_copy_to_mem(pkt, param->hash_result_offset,
session->p.auth_digest_len,
pkt_hdr->crypto_digest_buf);
- _odp_packet_set_data(pkt, param->hash_result_offset, 0,
- session->p.auth_digest_len);
+ if (odp_unlikely(session->p.hash_result_in_auth_range))
+ _odp_packet_set_data(pkt, param->hash_result_offset, 0,
+ session->p.auth_digest_len);
+ }
data = pkt_hdr->crypto_digest_buf;
mb = &pkt_hdr->event_hdr.mb;
*phys_addr =
@@ -1756,9 +1761,7 @@ static uint8_t *crypto_prepare_digest(crypto_session_entry_t *session,
static void crypto_fill_aead_param(crypto_session_entry_t *session,
odp_packet_t pkt,
const odp_crypto_packet_op_param_t *param,
- struct rte_crypto_op *op,
- odp_crypto_alg_err_t *rc_cipher,
- odp_crypto_alg_err_t *rc_auth ODP_UNUSED)
+ struct rte_crypto_op *op)
{
odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
struct rte_crypto_sym_xform *aead_xform;
@@ -1792,6 +1795,7 @@ static void crypto_fill_aead_param(crypto_session_entry_t *session,
iv_ptr++;
}
+#if ODP_DEPRECATED_API
if (param->cipher_iv_ptr)
memcpy(iv_ptr,
param->cipher_iv_ptr,
@@ -1800,8 +1804,12 @@ static void crypto_fill_aead_param(crypto_session_entry_t *session,
memcpy(iv_ptr,
session->cipher_iv_data,
aead_xform->aead.iv.length);
- else if (aead_xform->aead.iv.length != 0)
- *rc_cipher = ODP_CRYPTO_ALG_ERR_IV_INVALID;
+ else
+ ODP_ASSERT(aead_xform->aead.iv.length == 0);
+#else
+ ODP_ASSERT(aead_xform->aead.iv.length == 0 || param->cipher_iv_ptr != NULL);
+ memcpy(iv_ptr, param->cipher_iv_ptr, aead_xform->aead.iv.length);
+#endif
op->sym->aead.data.offset = param->cipher_range.offset;
op->sym->aead.data.length = param->cipher_range.length;
@@ -1810,12 +1818,11 @@ static void crypto_fill_aead_param(crypto_session_entry_t *session,
static void crypto_fill_sym_param(crypto_session_entry_t *session,
odp_packet_t pkt,
const odp_crypto_packet_op_param_t *param,
- struct rte_crypto_op *op,
- odp_crypto_alg_err_t *rc_cipher,
- odp_crypto_alg_err_t *rc_auth)
+ struct rte_crypto_op *op)
{
struct rte_crypto_sym_xform *cipher_xform;
struct rte_crypto_sym_xform *auth_xform;
+ uint8_t *iv_ptr;
cipher_xform = &session->cipher_xform;
auth_xform = &session->auth_xform;
@@ -1831,43 +1838,47 @@ static void crypto_fill_sym_param(crypto_session_entry_t *session,
&op->sym->auth.digest.phys_addr);
}
+#if ODP_DEPRECATED_API
if (param->cipher_iv_ptr) {
- uint8_t *iv_ptr;
-
iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET);
memcpy(iv_ptr,
param->cipher_iv_ptr,
cipher_xform->cipher.iv.length);
} else if (session->p.cipher_iv.data) {
- uint8_t *iv_ptr;
-
iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET);
memcpy(iv_ptr,
session->cipher_iv_data,
cipher_xform->cipher.iv.length);
- } else if (cipher_xform->cipher.iv.length != 0) {
- *rc_cipher = ODP_CRYPTO_ALG_ERR_IV_INVALID;
+ } else {
+ ODP_ASSERT(cipher_xform->cipher.iv.length == 0);
}
if (param->auth_iv_ptr) {
- uint8_t *iv_ptr;
-
iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
IV_OFFSET + MAX_IV_LENGTH);
memcpy(iv_ptr,
param->auth_iv_ptr,
auth_xform->auth.iv.length);
} else if (session->p.auth_iv.data) {
- uint8_t *iv_ptr;
-
iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
IV_OFFSET + MAX_IV_LENGTH);
memcpy(iv_ptr,
session->auth_iv_data,
auth_xform->auth.iv.length);
- } else if (auth_xform->auth.iv.length != 0) {
- *rc_auth = ODP_CRYPTO_ALG_ERR_IV_INVALID;
+ } else {
+ ODP_ASSERT(auth_xform->auth.iv.length == 0);
}
+#else
+ ODP_ASSERT(cipher_xform->cipher.iv.length == 0 || param->cipher_iv_ptr != NULL);
+ ODP_ASSERT(auth_xform->auth.iv.length == 0 || param->auth_iv_ptr != NULL);
+ iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET);
+ memcpy(iv_ptr, param->cipher_iv_ptr, cipher_xform->cipher.iv.length);
+
+ if (odp_unlikely(auth_xform->auth.iv.length > 0)) {
+ iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET + MAX_IV_LENGTH);
+ memcpy(iv_ptr, param->auth_iv_ptr, auth_xform->auth.iv.length);
+ }
+#endif
op->sym->cipher.data.offset = param->cipher_range.offset;
op->sym->cipher.data.length = param->cipher_range.length;
@@ -1986,11 +1997,9 @@ int odp_crypto_int(odp_packet_t pkt_in,
goto out;
if (cipher_is_aead(session->p.cipher_alg))
- crypto_fill_aead_param(session, out_pkt, param, op,
- &rc_cipher, &rc_auth);
+ crypto_fill_aead_param(session, out_pkt, param, op);
else
- crypto_fill_sym_param(session, out_pkt, param, op,
- &rc_cipher, &rc_auth);
+ crypto_fill_sym_param(session, out_pkt, param, op);
if (odp_likely(rc_cipher == ODP_CRYPTO_ALG_ERR_NONE &&
rc_auth == ODP_CRYPTO_ALG_ERR_NONE)) {
@@ -2073,7 +2082,8 @@ int odp_crypto_int(odp_packet_t pkt_in,
result_ok = false;
}
- if (session->p.auth_digest_len != 0 &&
+ if (session->p.op == ODP_CRYPTO_OP_ENCODE &&
+ session->p.auth_digest_len != 0 &&
op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
odp_packet_hdr_t *pkt_hdr = packet_hdr(out_pkt);
diff --git a/platform/linux-dpdk/odp_packet.c b/platform/linux-dpdk/odp_packet.c
index 339d2d8fc..88ba446f8 100644
--- a/platform/linux-dpdk/odp_packet.c
+++ b/platform/linux-dpdk/odp_packet.c
@@ -44,7 +44,7 @@ const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = {
.mb = offsetof(odp_packet_hdr_t, event_hdr.mb),
.pool = offsetof(odp_packet_hdr_t, event_hdr.pool_ptr),
.input = offsetof(odp_packet_hdr_t, input),
- .user_ptr = offsetof(odp_packet_hdr_t, event_hdr.user_ptr),
+ .user_ptr = offsetof(odp_packet_hdr_t, user_ptr),
.l2_offset = offsetof(odp_packet_hdr_t, p.l2_offset),
.l3_offset = offsetof(odp_packet_hdr_t, p.l3_offset),
.l4_offset = offsetof(odp_packet_hdr_t, p.l4_offset),
@@ -57,7 +57,7 @@ const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = {
.pkt_len = offsetof(odp_packet_hdr_t, event_hdr.mb.pkt_len),
.seg_len = offsetof(odp_packet_hdr_t, event_hdr.mb.data_len),
.nb_segs = offsetof(odp_packet_hdr_t, event_hdr.mb.nb_segs),
- .user_area = offsetof(odp_packet_hdr_t, event_hdr.uarea_addr),
+ .user_area = offsetof(odp_packet_hdr_t, uarea_addr),
.rss = offsetof(odp_packet_hdr_t, event_hdr.mb.hash.rss),
.ol_flags = offsetof(odp_packet_hdr_t, event_hdr.mb.ol_flags),
.rss_flag = PKT_RX_RSS_HASH
@@ -593,7 +593,7 @@ void odp_packet_user_ptr_set(odp_packet_t pkt, const void *ptr)
return;
}
- pkt_hdr->event_hdr.user_ptr = ptr;
+ pkt_hdr->user_ptr = ptr;
pkt_hdr->p.flags.user_ptr_set = 1;
}
@@ -1227,8 +1227,8 @@ int _odp_packet_copy_md_to_packet(odp_packet_t srcpkt, odp_packet_t dstpkt)
dsthdr->dst_queue = srchdr->dst_queue;
dsthdr->cos = srchdr->cos;
dsthdr->cls_mark = srchdr->cls_mark;
+ dsthdr->user_ptr = srchdr->user_ptr;
- dsthdr->event_hdr.user_ptr = srchdr->event_hdr.user_ptr;
dsthdr->event_hdr.mb.port = srchdr->event_hdr.mb.port;
dsthdr->event_hdr.mb.ol_flags = srchdr->event_hdr.mb.ol_flags;
dsthdr->event_hdr.mb.packet_type = srchdr->event_hdr.mb.packet_type;
diff --git a/platform/linux-dpdk/odp_pool.c b/platform/linux-dpdk/odp_pool.c
index 318e0071a..dfe7c1737 100644
--- a/platform/linux-dpdk/odp_pool.c
+++ b/platform/linux-dpdk/odp_pool.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2021, Nokia
+ * Copyright (c) 2019-2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -59,6 +59,9 @@
/* Define a practical limit for contiguous memory allocations */
#define MAX_SIZE (10 * 1024 * 1024)
+/* Maximum packet user area size */
+#define MAX_UAREA_SIZE 2048
+
/* The pool table ptr - resides in shared memory */
pool_global_t *_odp_pool_glb;
@@ -269,7 +272,7 @@ int odp_pool_capability(odp_pool_capability_t *capa)
capa->pkt.max_segs_per_pkt = PKT_MAX_SEGS;
capa->pkt.min_seg_len = CONFIG_PACKET_SEG_LEN_MIN;
capa->pkt.max_seg_len = CONFIG_PACKET_MAX_SEG_LEN;
- capa->pkt.max_uarea_size = MAX_SIZE;
+ capa->pkt.max_uarea_size = MAX_UAREA_SIZE;
capa->pkt.min_cache_size = 0;
capa->pkt.max_cache_size = RTE_MEMPOOL_CACHE_MAX_SIZE;
capa->pkt.stats.all = supported_stats.all;
@@ -362,8 +365,14 @@ odp_dpdk_mbuf_ctor(struct rte_mempool *mp,
event_hdr->pool_ptr = mb_ctor_arg->pool;
event_hdr->type = mb_ctor_arg->type;
event_hdr->event_type = mb_ctor_arg->event_type;
- event_hdr->uarea_addr = mb_ctor_arg->pool->uarea_base_addr +
- i * mb_ctor_arg->pool->uarea_size;
+
+ /* Initialize packet metadata */
+ if (mb_ctor_arg->type == ODP_POOL_PACKET) {
+ odp_packet_hdr_t *pkt_hdr = (odp_packet_hdr_t *)raw_mbuf;
+
+ pkt_hdr->uarea_addr = mb_ctor_arg->pool->uarea_base_addr +
+ i * mb_ctor_arg->pool->uarea_size;
+ }
/* Initialize event vector metadata */
if (mb_ctor_arg->type == ODP_POOL_VECTOR) {
@@ -1152,7 +1161,7 @@ int odp_pool_ext_capability(odp_pool_type_t type,
capa->pkt.max_headroom = RTE_PKTMBUF_HEADROOM;
capa->pkt.max_headroom_size = RTE_PKTMBUF_HEADROOM;
capa->pkt.max_segs_per_pkt = PKT_MAX_SEGS;
- capa->pkt.max_uarea_size = MAX_SIZE;
+ capa->pkt.max_uarea_size = MAX_UAREA_SIZE;
return 0;
}
diff --git a/platform/linux-dpdk/odp_shared_memory.c b/platform/linux-dpdk/odp_shared_memory.c
index c18c9acca..f3a217341 100644
--- a/platform/linux-dpdk/odp_shared_memory.c
+++ b/platform/linux-dpdk/odp_shared_memory.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
+ * Copyright (c) 2021-2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -8,6 +8,7 @@
#include <odp_posix_extensions.h>
#include <odp/api/debug.h>
+#include <odp/api/deprecated.h>
#include <odp/api/plat/strong_types.h>
#include <odp/api/shared_memory.h>
#include <odp/api/spinlock.h>
@@ -28,7 +29,13 @@
#include <rte_memzone.h>
/* Supported ODP_SHM_* flags */
-#define SUPPORTED_SHM_FLAGS (ODP_SHM_SW_ONLY | ODP_SHM_EXPORT | ODP_SHM_HP)
+#if ODP_DEPRECATED_API
+ #define DEPRECATED_SHM_FLAGS (ODP_SHM_SW_ONLY)
+#else
+ #define DEPRECATED_SHM_FLAGS 0
+#endif
+
+#define SUPPORTED_SHM_FLAGS (ODP_SHM_EXPORT | ODP_SHM_HP | DEPRECATED_SHM_FLAGS)
#define SHM_MAX_ALIGN (0x80000000)
#define SHM_BLOCK_NAME "%" PRIu64 "-%d-%s"
diff --git a/platform/linux-dpdk/odp_system_info.c b/platform/linux-dpdk/odp_system_info.c
index 1529cd8ea..c506dbc1e 100644
--- a/platform/linux-dpdk/odp_system_info.c
+++ b/platform/linux-dpdk/odp_system_info.c
@@ -398,7 +398,14 @@ uint64_t odp_sys_huge_page_size(void)
static int pagesz_compare(const void *pagesz1, const void *pagesz2)
{
- return (*(const uint64_t *)pagesz1 - *(const uint64_t *)pagesz2);
+ const uint64_t val1 = *(const uint64_t *)pagesz1;
+ const uint64_t val2 = *(const uint64_t *)pagesz2;
+
+ if (val1 < val2)
+ return -1;
+ if (val1 > val2)
+ return 1;
+ return 0;
}
int odp_sys_huge_page_size_all(uint64_t size[], int num)
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 64245801e..07f1f462b 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -321,7 +321,7 @@ noinst_HEADERS += arch/aarch64/odp_atomic.h \
arch/aarch64/cpu_flags.h \
arch/aarch64/odp_cpu_idling.h \
arch/aarch64/odp_llsc.h \
- arch/default/odp_random.h
+ arch/aarch64/odp_random.h
endif
if ARCH_IS_DEFAULT
__LIB__libodp_linux_la_SOURCES += arch/default/odp_atomic.c \
@@ -344,26 +344,6 @@ noinst_HEADERS += arch/default/odp_atomic.h \
arch/default/odp_cpu_idling.h \
arch/default/odp_random.h
endif
-if ARCH_IS_MIPS64
-__LIB__libodp_linux_la_SOURCES += arch/default/odp_atomic.c \
- arch/default/odp_global_time.c \
- arch/default/odp_hash_crc32.c \
- arch/default/odp_random.c \
- arch/mips64/odp_sysinfo_parse.c
-odpapiabiarchinclude_HEADERS += arch/default/odp/api/abi/cpu_time.h \
- arch/default/odp/api/abi/hash_crc32.h
-if !ODP_ABI_COMPAT
-odpapiabiarchinclude_HEADERS += arch/default/odp/api/abi/atomic_generic.h \
- arch/default/odp/api/abi/atomic_inlines.h \
- arch/default/odp/api/abi/cpu_generic.h \
- arch/mips64/odp/api/abi/cpu_inlines.h \
- arch/mips64/odp/api/abi/cpu.h
-endif
-noinst_HEADERS += arch/default/odp_atomic.h \
- arch/default/odp_cpu.h \
- arch/default/odp_cpu_idling.h \
- arch/default/odp_random.h
-endif
if ARCH_IS_POWERPC
__LIB__libodp_linux_la_SOURCES += arch/default/odp_atomic.c \
arch/default/odp_cpu_cycles.c \
diff --git a/platform/linux-generic/arch/aarch64/odp_random.h b/platform/linux-generic/arch/aarch64/odp_random.h
new file mode 100644
index 000000000..023e6c455
--- /dev/null
+++ b/platform/linux-generic/arch/aarch64/odp_random.h
@@ -0,0 +1,166 @@
+/* Copyright (c) 2021, ARM Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_AARCH64_RANDOM_H_
+#define ODP_AARCH64_RANDOM_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp/api/spec/random.h>
+#include <odp/autoheader_internal.h>
+
+#include <stdint.h>
+
+odp_random_kind_t _odp_random_max_kind_generic(void);
+int32_t _odp_random_true_data_generic(uint8_t *buf, uint32_t len);
+int32_t _odp_random_crypto_data_generic(uint8_t *buf, uint32_t len);
+
+#ifdef __ARM_FEATURE_RNG
+
+#if __ARM_FEATURE_UNALIGNED != 1
+#error This implementation requires unaligned access
+#endif
+
+static inline int _odp_random_max_kind(void)
+{
+ return ODP_RANDOM_TRUE;
+}
+
+static inline int _odp_rndr(uint64_t *v)
+{
+ int pass;
+
+ /* Return a 64-bit random number which is reseeded from the True Random
+ * Number source. If the hardware returns a genuine random number,
+ * PSTATE.NZCV is set to 0b0000. The NZCV condition flag is checked via
+ * the CSET instruction. If the hardware cannot return a genuine random
+ * number in a reasonable period of time, PSTATE.NZCV is set to 0b0100
+ * and the data value returned is 0. */
+ __asm__ volatile("mrs %0, s3_3_c2_c4_0\n\t"
+ "cset %w[pass], ne"
+ : "=r" (*v), [pass] "=r" (pass)
+ :
+ : "cc");
+
+ return pass;
+}
+
+static inline int _odp_rndrrs(uint64_t *v)
+{
+ int pass;
+
+ /* Return a 64-bit random number which is reseeded from the True Random
+ * Number source immediately before the read of the random number.
+ * If the hardware returns a genuine random number, PSTATE.NZCV is
+ * set to 0b0000. The NZCV condition flag is checked via the CSET
+ * instruction. If the hardware cannot return a genuine random number
+ * in a reasonable period of time, PSTATE.NZCV is set to 0b0100 and the
+ * data value returned is 0. */
+ __asm__ volatile("mrs %0, s3_3_c2_c4_1\n\t"
+ "cset %w[pass], ne"
+ : "=r" (*v), [pass] "=r" (pass)
+ :
+ : "cc");
+
+ return pass;
+}
+
+static inline int32_t _odp_random_crypto_data(uint8_t *buf, uint32_t len)
+{
+ uint64_t temp;
+
+ for (uint32_t i = 0; i < len / 8; i++) {
+ while (!_odp_rndr(&temp))
+ ;
+
+ *(uint64_t *)(uintptr_t)buf = temp;
+ buf += 8;
+ }
+
+ if (len & 7) {
+ while (!_odp_rndr(&temp))
+ ;
+
+ if (len & 4) {
+ *(uint32_t *)(uintptr_t)buf = temp & 0xffffffff;
+ temp >>= 32;
+ buf += 4;
+ }
+
+ if (len & 2) {
+ *(uint16_t *)(uintptr_t)buf = temp & 0xffff;
+ temp >>= 16;
+ buf += 2;
+ }
+
+ if (len & 1)
+ *buf = temp & 0xff;
+ }
+
+ return len;
+}
+
+static inline int32_t _odp_random_true_data(uint8_t *buf, uint32_t len)
+{
+ uint64_t temp;
+
+ for (uint32_t i = 0; i < len / 8; i++) {
+ while (!_odp_rndrrs(&temp))
+ ;
+
+ *(uint64_t *)(uintptr_t)buf = temp;
+ buf += 8;
+ }
+
+ if (len & 7) {
+ while (!_odp_rndrrs(&temp))
+ ;
+
+ if (len & 4) {
+ *(uint32_t *)(uintptr_t)buf = temp & 0xffffffff;
+ temp >>= 32;
+ buf += 4;
+ }
+
+ if (len & 2) {
+ *(uint16_t *)(uintptr_t)buf = temp & 0xffff;
+ temp >>= 16;
+ buf += 2;
+ }
+
+ if (len & 1)
+ *buf = temp & 0xff;
+ }
+
+ return len;
+}
+
+#else
+
+static inline int _odp_random_max_kind(void)
+{
+ return _odp_random_max_kind_generic();
+}
+
+static inline int32_t _odp_random_crypto_data(uint8_t *buf, uint32_t len)
+{
+ return _odp_random_crypto_data_generic(buf, len);
+}
+
+static inline int32_t _odp_random_true_data(uint8_t *buf, uint32_t len)
+{
+ return _odp_random_true_data_generic(buf, len);
+}
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-generic/arch/mips64/odp/api/abi/cpu.h b/platform/linux-generic/arch/mips64/odp/api/abi/cpu.h
deleted file mode 100644
index a6ce523d0..000000000
--- a/platform/linux-generic/arch/mips64/odp/api/abi/cpu.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef ODP_API_ABI_CPU_H_
-#define ODP_API_ABI_CPU_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined __OCTEON__
-#define ODP_CACHE_LINE_SIZE 128
-#else
-#error Please add support for your arch in cpu_arch.h
-#endif
-
-/* Inlined functions for non-ABI compat mode */
-#include <odp/api/plat/cpu_inlines.h>
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/platform/linux-generic/arch/mips64/odp/api/abi/cpu_inlines.h b/platform/linux-generic/arch/mips64/odp/api/abi/cpu_inlines.h
deleted file mode 100644
index d3a424432..000000000
--- a/platform/linux-generic/arch/mips64/odp/api/abi/cpu_inlines.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef ODP_ARCH_CPU_INLINES_H_
-#define ODP_ARCH_CPU_INLINES_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdint.h>
-
-static inline void _odp_cpu_pause(void)
-{
- __asm__ __volatile__ ("nop");
- __asm__ __volatile__ ("nop");
- __asm__ __volatile__ ("nop");
- __asm__ __volatile__ ("nop");
-}
-
-uint64_t _odp_cpu_cycles(void)
-{
- #define CVMX_TMP_STR(x) CVMX_TMP_STR2(x)
- #define CVMX_TMP_STR2(x) #x
- uint64_t cycle;
-
- __asm__ __volatile__ ("rdhwr %[rt],$" CVMX_TMP_STR(31) :
- [rt] "=d" (cycle) : : "memory");
-
- return cycle;
-}
-
-uint64_t _odp_cpu_cycles_max(void)
-{
- return UINT64_MAX;
-}
-
-uint64_t _odp_cpu_cycles_resolution(void)
-{
- return 1;
-}
-
-int _odp_cpu_cycles_init_global(void)
-{
- return 0;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
deleted file mode 100644
index 897637516..000000000
--- a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp_global_data.h>
-#include <odp_sysinfo_internal.h>
-#include <string.h>
-
-int _odp_cpuinfo_parser(FILE *file, system_info_t *sysinfo)
-{
- char str[1024];
- char *pos;
- double mhz = 0.0;
- uint64_t hz;
- int model = 0;
- int count = 2;
- int id = 0;
-
- sysinfo->cpu_arch = ODP_CPU_ARCH_MIPS;
- sysinfo->cpu_isa_sw.mips = ODP_CPU_ARCH_MIPS_UNKNOWN;
- sysinfo->cpu_isa_hw.mips = ODP_CPU_ARCH_MIPS_UNKNOWN;
-
- strcpy(sysinfo->cpu_arch_str, "mips64");
- while (fgets(str, sizeof(str), file) != NULL && id < CONFIG_NUM_CPU_IDS) {
- if (!mhz) {
- pos = strstr(str, "BogoMIPS");
-
- if (pos)
- if (sscanf(pos, "BogoMIPS : %lf", &mhz) == 1) {
- /* bogomips seems to be 2x freq */
- hz = (uint64_t)(mhz * 1000000.0 / 2.0);
- sysinfo->cpu_hz_max[id] = hz;
- count--;
- }
- }
-
- if (!model) {
- pos = strstr(str, "cpu model");
-
- if (pos) {
- int len;
-
- pos = strchr(str, ':');
- strncpy(sysinfo->model_str[id], pos + 2,
- MODEL_STR_SIZE - 1);
- len = strlen(sysinfo->model_str[id]);
- sysinfo->model_str[id][len - 1] = 0;
- model = 1;
- count--;
- }
- }
-
- if (count == 0) {
- mhz = 0.0;
- model = 0;
- count = 2;
- id++;
- }
- }
-
- return 0;
-}
-
-void _odp_sys_info_print_arch(void)
-{
-}
-
-uint64_t odp_cpu_arch_hz_current(int id ODP_UNUSED)
-{
- return odp_global_ro.system_info.default_cpu_hz;
-}
diff --git a/platform/linux-generic/include/odp_event_internal.h b/platform/linux-generic/include/odp_event_internal.h
index fa7e5f354..92f201b01 100644
--- a/platform/linux-generic/include/odp_event_internal.h
+++ b/platform/linux-generic/include/odp_event_internal.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2021, Nokia
+/* Copyright (c) 2021-2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -17,21 +17,21 @@
extern "C" {
#endif
-#include <odp/api/atomic.h>
#include <odp/api/debug.h>
#include <odp/api/event.h>
#include <odp/api/std_types.h>
#include <odp_config_internal.h>
-typedef union buffer_index_t {
+/* Combined pool and event index */
+typedef union _odp_event_index_t {
uint32_t u32;
struct {
uint32_t pool :8;
- uint32_t buffer :24;
+ uint32_t event :24;
};
-} buffer_index_t;
+} _odp_event_index_t;
/* Check that pool index fit into bit field */
ODP_STATIC_ASSERT(ODP_CONFIG_POOLS <= (0xFF + 1), "TOO_MANY_POOLS");
@@ -51,19 +51,12 @@ typedef struct _odp_event_hdr_t {
void *pool_ptr;
/* --- Mostly read only data --- */
- const void *user_ptr;
/* Initial buffer tail pointer */
uint8_t *buf_end;
- /* User area pointer */
- void *uarea_addr;
-
- /* Combined pool and buffer index */
- buffer_index_t index;
-
- /* Reference count */
- odp_atomic_u32_t ref_cnt;
+ /* Combined pool and event index */
+ _odp_event_index_t index;
/* Pool type */
int8_t type;
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index 7c9b7735e..a230c3b76 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2021, Nokia
+ * Copyright (c) 2019-2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -19,6 +19,7 @@ extern "C" {
#endif
#include <odp/api/align.h>
+#include <odp/api/atomic.h>
#include <odp/api/debug.h>
#include <odp/api/packet.h>
#include <odp/api/plat/packet_inline_types.h>
@@ -117,9 +118,18 @@ typedef struct ODP_ALIGNED_CACHE odp_packet_hdr_t {
/* Classifier destination queue */
odp_queue_t dst_queue;
+ /* Reference count */
+ odp_atomic_u32_t ref_cnt;
+
/* Flow hash value */
uint32_t flow_hash;
+ /* User area pointer */
+ void *uarea_addr;
+
+ /* User context pointer */
+ const void *user_ptr;
+
/* Classifier mark */
uint16_t cls_mark;
diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h
index c9bae7142..4c9f9a9ce 100644
--- a/platform/linux-generic/include/odp_pool_internal.h
+++ b/platform/linux-generic/include/odp_pool_internal.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2021, Nokia
+ * Copyright (c) 2019-2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -159,16 +159,16 @@ static inline _odp_event_hdr_t *event_hdr_from_index(pool_t *pool,
static inline _odp_event_hdr_t *_odp_event_hdr_from_index_u32(uint32_t u32)
{
- buffer_index_t index;
- uint32_t pool_idx, buffer_idx;
+ _odp_event_index_t index;
+ uint32_t pool_idx, event_idx;
pool_t *pool;
index.u32 = u32;
pool_idx = index.pool;
- buffer_idx = index.buffer;
+ event_idx = index.event;
pool = pool_entry(pool_idx);
- return event_hdr_from_index(pool, buffer_idx);
+ return event_hdr_from_index(pool, event_idx);
}
odp_event_t _odp_event_alloc(pool_t *pool);
diff --git a/platform/linux-generic/include/odp_timer_internal.h b/platform/linux-generic/include/odp_timer_internal.h
index 2a7173d29..b83591446 100644
--- a/platform/linux-generic/include/odp_timer_internal.h
+++ b/platform/linux-generic/include/odp_timer_internal.h
@@ -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
@@ -40,6 +40,9 @@ typedef struct ODP_ALIGNED_CACHE odp_timeout_hdr_t {
} odp_timeout_hdr_t;
+ODP_STATIC_ASSERT(sizeof(odp_timeout_hdr_t) <= ODP_CACHE_LINE_SIZE,
+ "TIMEOUT_HDR_SIZE_ERROR");
+
/* A larger decrement value should be used after receiving events compared to
* an 'empty' call. */
void _odp_timer_run_inline(int dec);
diff --git a/platform/linux-generic/include/odp_traffic_mngr_internal.h b/platform/linux-generic/include/odp_traffic_mngr_internal.h
index a54847319..2b5e47637 100644
--- a/platform/linux-generic/include/odp_traffic_mngr_internal.h
+++ b/platform/linux-generic/include/odp_traffic_mngr_internal.h
@@ -286,7 +286,6 @@ struct tm_queue_obj_s {
uint8_t blocked_cnt;
odp_bool_t ordered_enqueue;
tm_status_t status;
- odp_queue_t queue;
/* Statistics for odp_tm_queue_stats_t */
struct {
odp_atomic_u64_t discards;
diff --git a/platform/linux-generic/odp_buffer.c b/platform/linux-generic/odp_buffer.c
index 0e606017f..f9f67a2e4 100644
--- a/platform/linux-generic/odp_buffer.c
+++ b/platform/linux-generic/odp_buffer.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019, Nokia
+ * Copyright (c) 2019-2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -51,7 +51,7 @@ void odp_buffer_print(odp_buffer_t buf)
len += snprintf(&str[len], n - len, "Buffer\n------\n");
len += snprintf(&str[len], n - len, " pool index %u\n", hdr->event_hdr.index.pool);
- len += snprintf(&str[len], n - len, " buffer index %u\n", hdr->event_hdr.index.buffer);
+ len += snprintf(&str[len], n - len, " buffer index %u\n", hdr->event_hdr.index.event);
len += snprintf(&str[len], n - len, " addr %p\n",
(void *)hdr->event_hdr.base_data);
len += snprintf(&str[len], n - len, " size %u\n", odp_buffer_size(buf));
diff --git a/platform/linux-generic/odp_crypto_openssl.c b/platform/linux-generic/odp_crypto_openssl.c
index 6e702acab..19b57f502 100644
--- a/platform/linux-generic/odp_crypto_openssl.c
+++ b/platform/linux-generic/odp_crypto_openssl.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
@@ -212,8 +212,10 @@ struct odp_crypto_generic_session_t {
odp_bool_t do_cipher_first;
struct {
+#if ODP_DEPRECATED_API
/* Copy of session IV data */
uint8_t iv_data[EVP_MAX_IV_LENGTH];
+#endif
uint8_t key_data[EVP_MAX_KEY_LENGTH];
const EVP_CIPHER *evp_cipher;
@@ -223,7 +225,9 @@ struct odp_crypto_generic_session_t {
struct {
uint8_t key[EVP_MAX_KEY_LENGTH];
+#if ODP_DEPRECATED_API
uint8_t iv_data[EVP_MAX_IV_LENGTH];
+#endif
union {
const EVP_MD *evp_md;
const EVP_CIPHER *evp_cipher;
@@ -509,8 +513,8 @@ auth_xcbcmac_check(odp_packet_t pkt,
odp_packet_copy_to_mem(pkt, param->hash_result_offset,
bytes, hash_in);
- _odp_packet_set_data(pkt, param->hash_result_offset,
- 0, bytes);
+ if (odp_unlikely(session->p.hash_result_in_auth_range))
+ _odp_packet_set_data(pkt, param->hash_result_offset, 0, bytes);
/* Hash it */
packet_aes_xcbc_mac(pkt, param, session, hash_out);
@@ -591,8 +595,8 @@ odp_crypto_alg_err_t auth_hmac_check(odp_packet_t pkt,
odp_packet_copy_to_mem(pkt, param->hash_result_offset,
bytes, hash_in);
- _odp_packet_set_data(pkt, param->hash_result_offset,
- 0, bytes);
+ if (odp_unlikely(session->p.hash_result_in_auth_range))
+ _odp_packet_set_data(pkt, param->hash_result_offset, 0, bytes);
/* Hash it */
packet_hmac(pkt, param, session, hash_out);
@@ -678,8 +682,8 @@ odp_crypto_alg_err_t auth_cmac_check(odp_packet_t pkt,
odp_packet_copy_to_mem(pkt, param->hash_result_offset,
bytes, hash_in);
- _odp_packet_set_data(pkt, param->hash_result_offset,
- 0, bytes);
+ if (odp_unlikely(session->p.hash_result_in_auth_range))
+ _odp_packet_set_data(pkt, param->hash_result_offset, 0, bytes);
/* Hash it */
packet_cmac(pkt, param, session, hash_out);
@@ -704,19 +708,24 @@ int packet_cmac_eia2(odp_packet_t pkt,
uint32_t len = (param->auth_range.length + 7) / 8;
size_t outlen;
+#if ODP_DEPRECATED_API
if (param->auth_iv_ptr)
iv_ptr = param->auth_iv_ptr;
else if (session->p.auth_iv.data)
iv_ptr = session->auth.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+#else
+ iv_ptr = param->auth_iv_ptr;
+ ODP_ASSERT(session->p.auth_iv_len == 0 || iv_ptr != NULL);
+#endif
ODP_ASSERT(offset + len <= odp_packet_len(pkt));
/* Reinitialize CMAC calculation without resetting the key */
CMAC_Init(ctx, NULL, 0, NULL, NULL);
- CMAC_Update(ctx, iv_ptr, session->p.auth_iv.length);
+ CMAC_Update(ctx, iv_ptr, session->p.auth_iv_len);
while (len > 0) {
uint32_t seglen = 0; /* GCC */
@@ -772,8 +781,8 @@ odp_crypto_alg_err_t auth_cmac_eia2_check(odp_packet_t pkt,
odp_packet_copy_to_mem(pkt, param->hash_result_offset,
bytes, hash_in);
- _odp_packet_set_data(pkt, param->hash_result_offset,
- 0, bytes);
+ if (odp_unlikely(session->p.hash_result_in_auth_range))
+ _odp_packet_set_data(pkt, param->hash_result_offset, 0, bytes);
/* Hash it */
ret = packet_cmac_eia2(pkt, param, session, hash_out);
@@ -851,8 +860,8 @@ odp_crypto_alg_err_t auth_digest_check(odp_packet_t pkt,
odp_packet_copy_to_mem(pkt, param->hash_result_offset,
bytes, hash_in);
- _odp_packet_set_data(pkt, param->hash_result_offset,
- 0, bytes);
+ if (odp_unlikely(session->p.hash_result_in_auth_range))
+ _odp_packet_set_data(pkt, param->hash_result_offset, 0, bytes);
/* Hash it */
packet_digest(pkt, param, session, hash_out);
@@ -1060,12 +1069,17 @@ odp_crypto_alg_err_t cipher_encrypt(odp_packet_t pkt,
void *iv_ptr;
int ret;
+#if ODP_DEPRECATED_API
if (param->cipher_iv_ptr)
iv_ptr = param->cipher_iv_ptr;
else if (session->p.cipher_iv.data)
iv_ptr = session->cipher.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+#else
+ iv_ptr = param->cipher_iv_ptr;
+ ODP_ASSERT(session->p.cipher_iv_len == 0 || iv_ptr != NULL);
+#endif
EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr);
@@ -1094,12 +1108,17 @@ odp_crypto_alg_err_t cipher_decrypt(odp_packet_t pkt,
void *iv_ptr;
int ret;
+#if ODP_DEPRECATED_API
if (param->cipher_iv_ptr)
iv_ptr = param->cipher_iv_ptr;
else if (session->p.cipher_iv.data)
iv_ptr = session->cipher.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+#else
+ iv_ptr = param->cipher_iv_ptr;
+ ODP_ASSERT(session->p.cipher_iv_len == 0 || iv_ptr != NULL);
+#endif
EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr);
@@ -1119,7 +1138,7 @@ static int process_cipher_param(odp_crypto_generic_session_t *session,
/* Verify IV len is correct */
if ((uint32_t)EVP_CIPHER_iv_length(cipher) !=
- session->p.cipher_iv.length)
+ session->p.cipher_iv_len)
return -1;
session->cipher.evp_cipher = cipher;
@@ -1157,13 +1176,17 @@ odp_crypto_alg_err_t cipher_encrypt_bits(odp_packet_t pkt,
/* Range offset is in bits in bit mode but must be divisible by 8. */
offset = param->cipher_range.offset / 8;
+#if ODP_DEPRECATED_API
if (param->cipher_iv_ptr)
iv_ptr = param->cipher_iv_ptr;
else if (session->p.cipher_iv.data)
iv_ptr = session->cipher.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
-
+#else
+ iv_ptr = param->cipher_iv_ptr;
+ ODP_ASSERT(session->p.cipher_iv_len == 0 || iv_ptr != NULL);
+#endif
EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr);
odp_packet_copy_to_mem(pkt, offset, in_len, data);
@@ -1197,13 +1220,17 @@ odp_crypto_alg_err_t cipher_decrypt_bits(odp_packet_t pkt,
/* Range offset is in bits in bit mode but must be divisible by 8. */
offset = param->cipher_range.offset / 8;
+#if ODP_DEPRECATED_API
if (param->cipher_iv_ptr)
iv_ptr = param->cipher_iv_ptr;
else if (session->p.cipher_iv.data)
iv_ptr = session->cipher.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
-
+#else
+ iv_ptr = param->cipher_iv_ptr;
+ ODP_ASSERT(session->p.cipher_iv_len == 0 || iv_ptr != NULL);
+#endif
EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr);
odp_packet_copy_to_mem(pkt, offset, in_len, data);
@@ -1229,7 +1256,7 @@ static int process_cipher_param_bits(odp_crypto_generic_session_t *session,
/* Verify IV len is correct */
if ((uint32_t)EVP_CIPHER_iv_length(cipher) !=
- session->p.cipher_iv.length)
+ session->p.cipher_iv_len)
return -1;
session->cipher.evp_cipher = cipher;
@@ -1257,7 +1284,7 @@ aes_gcm_encrypt_init(odp_crypto_generic_session_t *session)
EVP_EncryptInit_ex(ctx, session->cipher.evp_cipher, NULL,
session->cipher.key_data, NULL);
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN,
- session->p.cipher_iv.length, NULL);
+ session->p.cipher_iv_len, NULL);
EVP_CIPHER_CTX_set_padding(ctx, 0);
}
@@ -1274,12 +1301,17 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_packet_t pkt,
uint8_t block[EVP_MAX_MD_SIZE];
int ret;
+#if ODP_DEPRECATED_API
if (param->cipher_iv_ptr)
iv_ptr = param->cipher_iv_ptr;
else if (session->p.cipher_iv.data)
iv_ptr = session->cipher.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+#else
+ iv_ptr = param->cipher_iv_ptr;
+ ODP_ASSERT(session->p.cipher_iv_len == 0 || iv_ptr != NULL);
+#endif
EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr);
@@ -1307,7 +1339,7 @@ aes_gcm_decrypt_init(odp_crypto_generic_session_t *session)
EVP_DecryptInit_ex(ctx, session->cipher.evp_cipher, NULL,
session->cipher.key_data, NULL);
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN,
- session->p.cipher_iv.length, NULL);
+ session->p.cipher_iv_len, NULL);
EVP_CIPHER_CTX_set_padding(ctx, 0);
}
@@ -1324,12 +1356,17 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_packet_t pkt,
uint8_t block[EVP_MAX_MD_SIZE];
int ret;
+#if ODP_DEPRECATED_API
if (param->cipher_iv_ptr)
iv_ptr = param->cipher_iv_ptr;
else if (session->p.cipher_iv.data)
iv_ptr = session->cipher.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+#else
+ iv_ptr = param->cipher_iv_ptr;
+ ODP_ASSERT(session->p.cipher_iv_len == 0 || iv_ptr != NULL);
+#endif
EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr);
@@ -1358,7 +1395,7 @@ static int process_aes_gcm_param(odp_crypto_generic_session_t *session,
return -1;
/* Verify IV len is correct */
- if (12 != session->p.cipher_iv.length)
+ if (12 != session->p.cipher_iv_len)
return -1;
memcpy(session->cipher.key_data, session->p.cipher_key.data,
@@ -1386,7 +1423,7 @@ aes_gmac_gen_init(odp_crypto_generic_session_t *session)
EVP_EncryptInit_ex(ctx, session->auth.evp_cipher, NULL,
session->auth.key, NULL);
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN,
- session->p.auth_iv.length, NULL);
+ session->p.auth_iv_len, NULL);
EVP_CIPHER_CTX_set_padding(ctx, 0);
}
@@ -1400,12 +1437,17 @@ odp_crypto_alg_err_t aes_gmac_gen(odp_packet_t pkt,
uint8_t block[EVP_MAX_MD_SIZE];
int ret;
+#if ODP_DEPRECATED_API
if (param->auth_iv_ptr)
iv_ptr = param->auth_iv_ptr;
else if (session->p.auth_iv.data)
iv_ptr = session->auth.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+#else
+ iv_ptr = param->auth_iv_ptr;
+ ODP_ASSERT(session->p.auth_iv_len == 0 || iv_ptr != NULL);
+#endif
EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr);
@@ -1428,7 +1470,7 @@ aes_gmac_check_init(odp_crypto_generic_session_t *session)
EVP_DecryptInit_ex(ctx, session->auth.evp_cipher, NULL,
session->auth.key, NULL);
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN,
- session->p.auth_iv.length, NULL);
+ session->p.auth_iv_len, NULL);
EVP_CIPHER_CTX_set_padding(ctx, 0);
}
@@ -1442,12 +1484,17 @@ odp_crypto_alg_err_t aes_gmac_check(odp_packet_t pkt,
uint8_t block[EVP_MAX_MD_SIZE];
int ret;
+#if ODP_DEPRECATED_API
if (param->auth_iv_ptr)
iv_ptr = param->auth_iv_ptr;
else if (session->p.auth_iv.data)
iv_ptr = session->auth.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+#else
+ iv_ptr = param->auth_iv_ptr;
+ ODP_ASSERT(session->p.auth_iv_len == 0 || iv_ptr != NULL);
+#endif
EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr);
@@ -1455,8 +1502,9 @@ odp_crypto_alg_err_t aes_gmac_check(odp_packet_t pkt,
session->p.auth_digest_len, block);
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG,
session->p.auth_digest_len, block);
- _odp_packet_set_data(pkt, param->hash_result_offset,
- 0, session->p.auth_digest_len);
+ if (odp_unlikely(session->p.hash_result_in_auth_range))
+ _odp_packet_set_data(pkt, param->hash_result_offset,
+ 0, session->p.auth_digest_len);
ret = internal_aad(ctx, pkt, param, false);
@@ -1473,7 +1521,7 @@ static int process_aes_gmac_param(odp_crypto_generic_session_t *session,
return -1;
/* Verify IV len is correct */
- if (12 != session->p.auth_iv.length)
+ if (12 != session->p.auth_iv_len)
return -1;
memcpy(session->auth.key, session->p.auth_key.data,
@@ -1501,7 +1549,7 @@ aes_ccm_encrypt_init(odp_crypto_generic_session_t *session)
EVP_EncryptInit_ex(ctx, session->cipher.evp_cipher, NULL,
NULL, NULL);
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_IVLEN,
- session->p.cipher_iv.length, NULL);
+ session->p.cipher_iv_len, NULL);
EVP_CIPHER_CTX_set_padding(ctx, 0);
}
@@ -1521,12 +1569,17 @@ odp_crypto_alg_err_t aes_ccm_encrypt(odp_packet_t pkt,
uint8_t block[EVP_MAX_MD_SIZE];
int ret;
+#if ODP_DEPRECATED_API
if (param->cipher_iv_ptr)
iv_ptr = param->cipher_iv_ptr;
else if (session->p.cipher_iv.data)
iv_ptr = session->cipher.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+#else
+ iv_ptr = param->cipher_iv_ptr;
+ ODP_ASSERT(session->p.cipher_iv_len == 0 || iv_ptr != NULL);
+#endif
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_TAG,
session->p.auth_digest_len, NULL);
@@ -1568,7 +1621,7 @@ aes_ccm_decrypt_init(odp_crypto_generic_session_t *session)
EVP_DecryptInit_ex(ctx, session->cipher.evp_cipher, NULL,
session->cipher.key_data, NULL);
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN,
- session->p.cipher_iv.length, NULL);
+ session->p.cipher_iv_len, NULL);
EVP_CIPHER_CTX_set_padding(ctx, 0);
}
@@ -1588,12 +1641,17 @@ odp_crypto_alg_err_t aes_ccm_decrypt(odp_packet_t pkt,
uint8_t block[EVP_MAX_MD_SIZE];
int ret;
+#if ODP_DEPRECATED_API
if (param->cipher_iv_ptr)
iv_ptr = param->cipher_iv_ptr;
else if (session->p.cipher_iv.data)
iv_ptr = session->cipher.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+#else
+ iv_ptr = param->cipher_iv_ptr;
+ ODP_ASSERT(session->p.cipher_iv_len == 0 || iv_ptr != NULL);
+#endif
odp_packet_copy_to_mem(pkt, param->hash_result_offset,
session->p.auth_digest_len, block);
@@ -1633,8 +1691,8 @@ static int process_aes_ccm_param(odp_crypto_generic_session_t *session,
return -1;
/* Verify IV len is correct */
- if (11 != session->p.cipher_iv.length &&
- 13 != session->p.cipher_iv.length)
+ if (11 != session->p.cipher_iv_len &&
+ 13 != session->p.cipher_iv_len)
return -1;
memcpy(session->cipher.key_data, session->p.cipher_key.data,
@@ -1667,12 +1725,17 @@ odp_crypto_alg_err_t xts_encrypt(odp_packet_t pkt,
uint8_t data[in_len];
int ret;
+#if ODP_DEPRECATED_API
if (param->cipher_iv_ptr)
iv_ptr = param->cipher_iv_ptr;
else if (session->p.cipher_iv.data)
iv_ptr = session->cipher.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+#else
+ iv_ptr = param->cipher_iv_ptr;
+ ODP_ASSERT(session->p.cipher_iv_len == 0 || iv_ptr != NULL);
+#endif
EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr);
@@ -1704,12 +1767,17 @@ odp_crypto_alg_err_t xts_decrypt(odp_packet_t pkt,
uint8_t data[in_len];
int ret;
+#if ODP_DEPRECATED_API
if (param->cipher_iv_ptr)
iv_ptr = param->cipher_iv_ptr;
else if (session->p.cipher_iv.data)
iv_ptr = session->cipher.iv_data;
else
return ODP_CRYPTO_ALG_ERR_IV_INVALID;
+#else
+ iv_ptr = param->cipher_iv_ptr;
+ ODP_ASSERT(session->p.cipher_iv_len == 0 || iv_ptr != NULL);
+#endif
EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr);
@@ -1738,7 +1806,7 @@ static int process_xts_param(odp_crypto_generic_session_t *session,
/* Verify IV len is correct */
if ((uint32_t)EVP_CIPHER_iv_length(cipher) !=
- session->p.cipher_iv.length)
+ session->p.cipher_iv_len)
return -1;
session->cipher.evp_cipher = cipher;
@@ -1762,7 +1830,7 @@ static int process_auth_hmac_param(odp_crypto_generic_session_t *session,
const EVP_MD *evp_md)
{
/* Verify IV len is correct */
- if (0 != session->p.auth_iv.length)
+ if (0 != session->p.auth_iv_len)
return -1;
/* Set function */
@@ -1793,7 +1861,7 @@ static int process_auth_cmac_param(odp_crypto_generic_session_t *session,
session->p.auth_key.length)
return -1;
- if (0 != session->p.auth_iv.length)
+ if (0 != session->p.auth_iv_len)
return -1;
/* Set function */
@@ -1826,7 +1894,7 @@ static int process_auth_cmac_eia2_param(odp_crypto_generic_session_t *session,
return -1;
/* Verify IV len is correct */
- if (8 != session->p.auth_iv.length)
+ if (8 != session->p.auth_iv_len)
return -1;
/* Set function */
@@ -2125,7 +2193,7 @@ odp_crypto_session_create(const odp_crypto_session_param_t *param,
ODP_ERR("Crypto is disabled\n");
/* Dummy output to avoid compiler warning about uninitialized
* variables */
- *status = ODP_CRYPTO_SES_CREATE_ERR_ENOMEM;
+ *status = ODP_CRYPTO_SES_ERR_ENOMEM;
*session_out = ODP_CRYPTO_SESSION_INVALID;
return -1;
}
@@ -2133,25 +2201,26 @@ odp_crypto_session_create(const odp_crypto_session_param_t *param,
/* Allocate memory for this session */
session = alloc_session();
if (NULL == session) {
- *status = ODP_CRYPTO_SES_CREATE_ERR_ENOMEM;
+ *status = ODP_CRYPTO_SES_ERR_ENOMEM;
goto err;
}
/* Copy parameters */
session->p = *param;
- if (session->p.cipher_iv.length > EVP_MAX_IV_LENGTH) {
+ if (session->p.cipher_iv_len > EVP_MAX_IV_LENGTH) {
ODP_DBG("Maximum IV length exceeded\n");
- *status = ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER;
+ *status = ODP_CRYPTO_SES_ERR_CIPHER;
goto err;
}
- if (session->p.auth_iv.length > EVP_MAX_IV_LENGTH) {
+ if (session->p.auth_iv_len > EVP_MAX_IV_LENGTH) {
ODP_DBG("Maximum auth IV length exceeded\n");
- *status = ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER;
+ *status = ODP_CRYPTO_SES_ERR_CIPHER;
goto err;
}
+#if ODP_DEPRECATED_API
/* Copy IV data */
if (session->p.cipher_iv.data)
memcpy(session->cipher.iv_data, session->p.cipher_iv.data,
@@ -2160,6 +2229,7 @@ odp_crypto_session_create(const odp_crypto_session_param_t *param,
if (session->p.auth_iv.data)
memcpy(session->auth.iv_data, session->p.auth_iv.data,
session->p.auth_iv.length);
+#endif
/* Derive order */
if (ODP_CRYPTO_OP_ENCODE == param->op)
@@ -2303,7 +2373,7 @@ odp_crypto_session_create(const odp_crypto_session_param_t *param,
/* Check result */
if (rc) {
- *status = ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER;
+ *status = ODP_CRYPTO_SES_ERR_CIPHER;
goto err;
}
@@ -2446,13 +2516,13 @@ odp_crypto_session_create(const odp_crypto_session_param_t *param,
/* Check result */
if (rc) {
- *status = ODP_CRYPTO_SES_CREATE_ERR_INV_AUTH;
+ *status = ODP_CRYPTO_SES_ERR_AUTH;
goto err;
}
/* We're happy */
*session_out = (intptr_t)session;
- *status = ODP_CRYPTO_SES_CREATE_ERR_NONE;
+ *status = ODP_CRYPTO_SES_ERR_NONE;
return 0;
err:
diff --git a/platform/linux-generic/odp_ipsec_sad.c b/platform/linux-generic/odp_ipsec_sad.c
index 50f2bb360..23da4b2d1 100644
--- a/platform/linux-generic/odp_ipsec_sad.c
+++ b/platform/linux-generic/odp_ipsec_sad.c
@@ -624,6 +624,8 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param)
ODP_CRYPTO_OP_DECODE :
ODP_CRYPTO_OP_ENCODE;
crypto_param.auth_cipher_text = 1;
+ if (param->proto == ODP_IPSEC_AH)
+ crypto_param.hash_result_in_auth_range = 1;
crypto_param.op_mode = ODP_CRYPTO_SYNC;
crypto_param.compl_queue = ODP_QUEUE_INVALID;
@@ -634,7 +636,7 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param)
crypto_param.auth_alg = param->crypto.auth_alg;
crypto_param.auth_key = param->crypto.auth_key;
- crypto_param.cipher_iv.length =
+ crypto_param.cipher_iv_len =
_odp_ipsec_cipher_iv_len(crypto_param.cipher_alg);
crypto_param.auth_digest_len =
@@ -644,7 +646,7 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param)
param->crypto.icv_len != crypto_param.auth_digest_len)
goto error;
- if ((uint32_t)-1 == crypto_param.cipher_iv.length ||
+ if ((uint32_t)-1 == crypto_param.cipher_iv_len ||
(uint32_t)-1 == crypto_param.auth_digest_len)
goto error;
@@ -729,7 +731,7 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param)
ipsec_sa->use_counter_iv = 1;
ipsec_sa->esp_iv_len = 8;
ipsec_sa->esp_pad_mask = esp_block_len_to_mask(1);
- crypto_param.auth_iv.length = 12;
+ crypto_param.auth_iv_len = 12;
ipsec_sa->salt_length = 4;
salt_param = &param->crypto.auth_key_extra;
break;
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index a15508ca2..2ad86ee99 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2021, Nokia
+ * Copyright (c) 2019-2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -50,8 +50,8 @@ const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = {
.pool = offsetof(odp_packet_hdr_t, event_hdr.pool_ptr),
.input = offsetof(odp_packet_hdr_t, input),
.seg_count = offsetof(odp_packet_hdr_t, seg_count),
- .user_ptr = offsetof(odp_packet_hdr_t, event_hdr.user_ptr),
- .user_area = offsetof(odp_packet_hdr_t, event_hdr.uarea_addr),
+ .user_ptr = offsetof(odp_packet_hdr_t, user_ptr),
+ .user_area = offsetof(odp_packet_hdr_t, uarea_addr),
.l2_offset = offsetof(odp_packet_hdr_t, p.l2_offset),
.l3_offset = offsetof(odp_packet_hdr_t, p.l3_offset),
.l4_offset = offsetof(odp_packet_hdr_t, p.l4_offset),
@@ -193,9 +193,8 @@ static inline void packet_seg_copy_md(odp_packet_hdr_t *dst,
if (src->p.flags.payload_off)
dst->payload_offset = src->payload_offset;
- /* event header side packet metadata */
- dst->event_hdr.user_ptr = src->event_hdr.user_ptr;
- dst->event_hdr.uarea_addr = src->event_hdr.uarea_addr;
+ dst->user_ptr = src->user_ptr;
+ dst->uarea_addr = src->uarea_addr;
/* segmentation data is not copied:
* seg_next
@@ -325,7 +324,7 @@ static inline void link_segments(odp_packet_hdr_t *pkt_hdr[], int num)
uint32_t prev_ref;
odp_atomic_u32_t *ref_cnt;
- ref_cnt = &pkt_hdr[cur]->event_hdr.ref_cnt;
+ ref_cnt = &pkt_hdr[cur]->ref_cnt;
prev_ref = odp_atomic_fetch_inc_u32(ref_cnt);
ODP_ASSERT(prev_ref == 0);
@@ -361,7 +360,7 @@ static inline void init_segments(odp_packet_hdr_t *pkt_hdr[], int num)
if (ODP_DEBUG == 1) {
uint32_t prev_ref =
- odp_atomic_fetch_inc_u32(&hdr->event_hdr.ref_cnt);
+ odp_atomic_fetch_inc_u32(&hdr->ref_cnt);
ODP_ASSERT(prev_ref == 0);
}
@@ -474,25 +473,25 @@ static inline odp_packet_hdr_t *add_segments(odp_packet_hdr_t *pkt_hdr,
return pkt_hdr;
}
-static inline void segment_ref_inc(_odp_event_hdr_t *event_hdr)
+static inline void segment_ref_inc(odp_packet_hdr_t *seg_hdr)
{
- uint32_t ref_cnt = odp_atomic_load_u32(&event_hdr->ref_cnt);
+ uint32_t ref_cnt = odp_atomic_load_u32(&seg_hdr->ref_cnt);
/* First count increment after alloc */
if (odp_likely(ref_cnt == 0))
- odp_atomic_store_u32(&event_hdr->ref_cnt, 2);
+ odp_atomic_store_u32(&seg_hdr->ref_cnt, 2);
else
- odp_atomic_inc_u32(&event_hdr->ref_cnt);
+ odp_atomic_inc_u32(&seg_hdr->ref_cnt);
}
-static inline uint32_t segment_ref_dec(_odp_event_hdr_t *event_hdr)
+static inline uint32_t segment_ref_dec(odp_packet_hdr_t *seg_hdr)
{
- return odp_atomic_fetch_dec_u32(&event_hdr->ref_cnt);
+ return odp_atomic_fetch_dec_u32(&seg_hdr->ref_cnt);
}
-static inline uint32_t segment_ref(_odp_event_hdr_t *event_hdr)
+static inline uint32_t segment_ref(odp_packet_hdr_t *seg_hdr)
{
- return odp_atomic_load_u32(&event_hdr->ref_cnt);
+ return odp_atomic_load_u32(&seg_hdr->ref_cnt);
}
static inline int is_multi_ref(uint32_t ref_cnt)
@@ -500,7 +499,7 @@ static inline int is_multi_ref(uint32_t ref_cnt)
return (ref_cnt > 1);
}
-static inline void packet_free_multi(_odp_event_hdr_t *hdr[], int num)
+static inline void packet_free_multi(odp_packet_hdr_t *hdr[], int num)
{
int i;
uint32_t ref_cnt;
@@ -527,21 +526,21 @@ static inline void packet_free_multi(_odp_event_hdr_t *hdr[], int num)
num -= num_ref;
if (odp_likely(num))
- _odp_event_free_multi(hdr, num);
+ _odp_event_free_multi((_odp_event_hdr_t **)(uintptr_t)hdr, num);
}
static inline void free_all_segments(odp_packet_hdr_t *pkt_hdr, int num)
{
int i;
- _odp_event_hdr_t *event_hdr[num];
+ odp_packet_hdr_t *pkt_hdrs[num];
odp_packet_hdr_t *seg_hdr = pkt_hdr;
for (i = 0; i < num; i++) {
- event_hdr[i] = &seg_hdr->event_hdr;
+ pkt_hdrs[i] = seg_hdr;
seg_hdr = seg_hdr->seg_next;
}
- packet_free_multi(event_hdr, num);
+ packet_free_multi(pkt_hdrs, num);
}
static inline odp_packet_hdr_t *free_segments(odp_packet_hdr_t *pkt_hdr,
@@ -553,14 +552,14 @@ static inline odp_packet_hdr_t *free_segments(odp_packet_hdr_t *pkt_hdr,
int num_remain = pkt_hdr->seg_count - num;
odp_packet_hdr_t *hdr = pkt_hdr;
odp_packet_hdr_t *last_hdr = packet_last_seg(pkt_hdr);
- _odp_event_hdr_t *event_hdr[num];
+ odp_packet_hdr_t *pkt_hdrs[num];
if (head) {
odp_packet_hdr_t *new_hdr;
for (i = 0; i < num; i++) {
seg_hdr = packet_seg_step(&hdr);
- event_hdr[i] = &seg_hdr->event_hdr;
+ pkt_hdrs[i] = seg_hdr;
}
/* The first remaining header is the new packet descriptor.
@@ -584,7 +583,7 @@ static inline odp_packet_hdr_t *free_segments(odp_packet_hdr_t *pkt_hdr,
pkt_hdr = new_hdr;
- packet_free_multi(event_hdr, num);
+ packet_free_multi(pkt_hdrs, num);
} else {
/* Free last 'num' bufs.
* First, find the last remaining header. */
@@ -595,10 +594,10 @@ static inline odp_packet_hdr_t *free_segments(odp_packet_hdr_t *pkt_hdr,
for (i = 0; i < num; i++) {
seg_hdr = packet_seg_step(&hdr);
- event_hdr[i] = &seg_hdr->event_hdr;
+ pkt_hdrs[i] = seg_hdr;
}
- packet_free_multi(event_hdr, num);
+ packet_free_multi(pkt_hdrs, num);
/* Head segment remains, no need to copy or update majority
* of the metadata. */
@@ -731,20 +730,17 @@ void odp_packet_free(odp_packet_t pkt)
odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
int num_seg = pkt_hdr->seg_count;
- ODP_ASSERT(segment_ref(&pkt_hdr->event_hdr) > 0);
+ ODP_ASSERT(segment_ref(pkt_hdr) > 0);
- if (odp_likely(num_seg == 1)) {
- _odp_event_hdr_t *event_hdr = &pkt_hdr->event_hdr;
-
- packet_free_multi(&event_hdr, 1);
- } else {
+ if (odp_likely(num_seg == 1))
+ packet_free_multi(&pkt_hdr, 1);
+ else
free_all_segments(pkt_hdr, num_seg);
- }
}
void odp_packet_free_multi(const odp_packet_t pkt[], int num)
{
- _odp_event_hdr_t *event_hdr[num];
+ odp_packet_hdr_t *pkt_hdrs[num];
int i;
int num_freed = 0;
@@ -752,7 +748,7 @@ void odp_packet_free_multi(const odp_packet_t pkt[], int num)
odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt[i]);
int num_seg = pkt_hdr->seg_count;
- ODP_ASSERT(segment_ref(&pkt_hdr->event_hdr) > 0);
+ ODP_ASSERT(segment_ref(pkt_hdr) > 0);
if (odp_unlikely(num_seg > 1)) {
free_all_segments(pkt_hdr, num_seg);
@@ -760,11 +756,11 @@ void odp_packet_free_multi(const odp_packet_t pkt[], int num)
continue;
}
- event_hdr[i - num_freed] = &pkt_hdr->event_hdr;
+ pkt_hdrs[i - num_freed] = pkt_hdr;
}
if (odp_likely(num - num_freed))
- packet_free_multi(event_hdr, num - num_freed);
+ packet_free_multi(pkt_hdrs, num - num_freed);
}
void odp_packet_free_sp(const odp_packet_t pkt[], int num)
@@ -1076,7 +1072,7 @@ void odp_packet_user_ptr_set(odp_packet_t pkt, const void *ptr)
return;
}
- pkt_hdr->event_hdr.user_ptr = ptr;
+ pkt_hdr->user_ptr = ptr;
pkt_hdr->p.flags.user_ptr_set = 1;
}
@@ -1577,7 +1573,7 @@ void odp_packet_print(odp_packet_t pkt)
len += snprintf(&str[len], n - len, "Packet\n------\n");
len += snprintf(&str[len], n - len, " pool index %u\n", hdr->event_hdr.index.pool);
- len += snprintf(&str[len], n - len, " buf index %u\n", hdr->event_hdr.index.buffer);
+ len += snprintf(&str[len], n - len, " buf index %u\n", hdr->event_hdr.index.event);
len += snprintf(&str[len], n - len, " ev subtype %i\n", hdr->subtype);
len += snprintf(&str[len], n - len, " input_flags 0x%" PRIx64 "\n",
hdr->p.input_flags.all);
@@ -1614,7 +1610,6 @@ void odp_packet_print(odp_packet_t pkt)
for (int seg_idx = 0; seg != ODP_PACKET_SEG_INVALID; seg_idx++) {
odp_packet_hdr_t *seg_hdr = packet_seg_to_hdr(seg);
- _odp_event_hdr_t *event_hdr = &seg_hdr->event_hdr;
char seg_str[max_len];
int str_len;
@@ -1624,7 +1619,7 @@ void odp_packet_print(odp_packet_t pkt)
seg_idx,
odp_packet_seg_data_len(pkt, seg),
odp_packet_seg_data(pkt, seg),
- segment_ref(event_hdr));
+ segment_ref(seg_hdr));
/* Prevent print buffer overflow */
if (n - len - str_len < 10) {
@@ -1657,7 +1652,7 @@ void odp_packet_print_data(odp_packet_t pkt, uint32_t offset,
" pool index %" PRIu32 "\n", pool->pool_idx);
len += snprintf(&str[len], n - len,
" buf index %" PRIu32 "\n",
- hdr->event_hdr.index.buffer);
+ hdr->event_hdr.index.event);
len += snprintf(&str[len], n - len,
" seg_count %" PRIu16 "\n", hdr->seg_count);
len += snprintf(&str[len], n - len,
@@ -1753,10 +1748,9 @@ int _odp_packet_copy_md_to_packet(odp_packet_t srcpkt, odp_packet_t dstpkt)
dsthdr->dst_queue = srchdr->dst_queue;
dsthdr->cos = srchdr->cos;
dsthdr->cls_mark = srchdr->cls_mark;
- dsthdr->event_hdr.user_ptr = srchdr->event_hdr.user_ptr;
- if (dsthdr->event_hdr.uarea_addr != NULL &&
- srchdr->event_hdr.uarea_addr != NULL) {
- memcpy(dsthdr->event_hdr.uarea_addr, srchdr->event_hdr.uarea_addr,
+ dsthdr->user_ptr = srchdr->user_ptr;
+ if (dsthdr->uarea_addr != NULL && srchdr->uarea_addr != NULL) {
+ memcpy(dsthdr->uarea_addr, srchdr->uarea_addr,
dst_uarea_size <= src_uarea_size ? dst_uarea_size :
src_uarea_size);
}
@@ -2778,7 +2772,7 @@ odp_packet_t odp_packet_ref_static(odp_packet_t pkt)
odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
while (pkt_hdr != NULL) {
- segment_ref_inc(&pkt_hdr->event_hdr);
+ segment_ref_inc(pkt_hdr);
pkt_hdr = pkt_hdr->seg_next;
}
@@ -2834,14 +2828,11 @@ odp_packet_t odp_packet_ref_pkt(odp_packet_t pkt, uint32_t offset,
int odp_packet_has_ref(odp_packet_t pkt)
{
- _odp_event_hdr_t *event_hdr;
odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
uint32_t ref_cnt;
while (pkt_hdr != NULL) {
- event_hdr = &pkt_hdr->event_hdr;
-
- ref_cnt = segment_ref(event_hdr);
+ ref_cnt = segment_ref(pkt_hdr);
if (is_multi_ref(ref_cnt))
return 1;
diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index ca696fc96..cca2d55f0 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2021, Nokia
+ * Copyright (c) 2019-2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -47,6 +47,9 @@
/* Define a practical limit for contiguous memory allocations */
#define MAX_SIZE (10 * 1024 * 1024)
+/* Maximum packet user area size */
+#define MAX_UAREA_SIZE 2048
+
ODP_STATIC_ASSERT(CONFIG_PACKET_SEG_LEN_MIN >= 256,
"ODP Segment size must be a minimum of 256 bytes");
@@ -419,7 +422,7 @@ static pool_t *reserve_pool(uint32_t shmflags, uint8_t pool_ext, uint32_t num)
return NULL;
}
-static void init_event_hdr(pool_t *pool, _odp_event_hdr_t *event_hdr, uint32_t buf_index,
+static void init_event_hdr(pool_t *pool, _odp_event_hdr_t *event_hdr, uint32_t event_index,
uint32_t hdr_len, uint8_t *data_ptr, void *uarea)
{
odp_pool_type_t type = pool->type;
@@ -429,12 +432,10 @@ static void init_event_hdr(pool_t *pool, _odp_event_hdr_t *event_hdr, uint32_t b
/* Initialize common event metadata */
event_hdr->index.u32 = 0;
event_hdr->index.pool = pool->pool_idx;
- event_hdr->index.buffer = buf_index;
+ event_hdr->index.event = event_index;
event_hdr->type = type;
event_hdr->event_type = type;
event_hdr->pool_ptr = pool;
- event_hdr->uarea_addr = uarea;
- odp_atomic_init_u32(&event_hdr->ref_cnt, 0);
/* Store base values for fast init */
if (type == ODP_POOL_BUFFER || type == ODP_POOL_PACKET) {
@@ -446,10 +447,14 @@ static void init_event_hdr(pool_t *pool, _odp_event_hdr_t *event_hdr, uint32_t b
if (type == ODP_POOL_PACKET) {
odp_packet_hdr_t *pkt_hdr = (void *)event_hdr;
+ pkt_hdr->user_ptr = NULL;
+ pkt_hdr->uarea_addr = uarea;
pkt_hdr->seg_data = data_ptr;
pkt_hdr->seg_len = pool->seg_len;
pkt_hdr->seg_count = 1;
pkt_hdr->seg_next = NULL;
+
+ odp_atomic_init_u32(&pkt_hdr->ref_cnt, 0);
}
/* Initialize event vector metadata */
@@ -1388,7 +1393,7 @@ int odp_pool_capability(odp_pool_capability_t *capa)
capa->pkt.max_segs_per_pkt = PKT_MAX_SEGS;
capa->pkt.min_seg_len = CONFIG_PACKET_SEG_LEN_MIN;
capa->pkt.max_seg_len = max_seg_len;
- capa->pkt.max_uarea_size = MAX_SIZE;
+ capa->pkt.max_uarea_size = MAX_UAREA_SIZE;
capa->pkt.min_cache_size = 0;
capa->pkt.max_cache_size = CONFIG_POOL_CACHE_MAX_SIZE;
capa->pkt.stats.all = supported_stats.all;
@@ -1634,7 +1639,7 @@ int _odp_event_is_valid(odp_event_t event)
if (pool != event_hdr->pool_ptr)
return 0;
- if (event_hdr->index.buffer >= (pool->num + pool->skipped_blocks))
+ if (event_hdr->index.event >= (pool->num + pool->skipped_blocks))
return 0;
return 1;
@@ -1682,7 +1687,7 @@ int odp_pool_ext_capability(odp_pool_type_t type, odp_pool_ext_capability_t *cap
capa->pkt.max_headroom = CONFIG_PACKET_HEADROOM;
capa->pkt.max_headroom_size = CONFIG_PACKET_HEADROOM;
capa->pkt.max_segs_per_pkt = PKT_MAX_SEGS;
- capa->pkt.max_uarea_size = MAX_SIZE;
+ capa->pkt.max_uarea_size = MAX_UAREA_SIZE;
return 0;
}
diff --git a/platform/linux-generic/odp_random_std.c b/platform/linux-generic/odp_random_std.c
index 3afd049f4..50cd773f2 100644
--- a/platform/linux-generic/odp_random_std.c
+++ b/platform/linux-generic/odp_random_std.c
@@ -4,52 +4,88 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp_posix_extensions.h>
-#include <stdint.h>
-#include <stdlib.h>
#include <odp/api/byteorder.h>
#include <odp/api/cpu.h>
#include <odp/api/debug.h>
#include <odp_init_internal.h>
#include <odp_random_std_internal.h>
+#include <odp_cpu.h>
+#include <stdint.h>
#include <time.h>
-/* Assume at least two rand bytes are available and RAND_MAX is power of two - 1 */
-ODP_STATIC_ASSERT(RAND_MAX >= UINT16_MAX, "RAND_MAX too small");
-ODP_STATIC_ASSERT((RAND_MAX & (RAND_MAX + 1ULL)) == 0, "RAND_MAX not power of two - 1");
+/*
+ * Xorshift64*, adapted from [1], and modified to return only the high 32 bits.
+ *
+ * [1] An experimental exploration of Marsaglia's xorshift generators, scrambled
+ * Sebastiano Vigna, July 2016.
+ * http://vigna.di.unimi.it/ftp/papers/xorshift.pdf
+ */
+static inline uint32_t xorshift64s32(uint64_t *x)
+{
+ /* The variable x should be initialized to a nonzero seed. [1] */
+ if (!*x)
+ /*
+ * 2^64 / phi. As far away as possible from any small integer
+ * fractions, which the caller might be likely to use for the
+ * next seed after 0.
+ */
+ *x = 11400714819323198485ull;
-static int32_t _random_data(uint8_t *buf, uint32_t len, uint32_t *seed)
+ *x ^= *x >> 12; /* a */
+ *x ^= *x << 25; /* b */
+ *x ^= *x >> 27; /* c */
+ return (*x * 2685821657736338717ull) >> 32;
+}
+
+static int32_t _random_data(uint8_t *buf, uint32_t len, uint64_t *seed)
{
- union {
- uint32_t rand_word;
- uint8_t rand_byte[4];
- } u;
- uint32_t i = 0, j, k;
-
- while (i < len) {
- u.rand_word = rand_r(seed);
-
- /* Use two least significant bytes */
- j = ODP_LITTLE_ENDIAN ? 0 : 2;
- for (k = 0; k < 2 && i < len; i++, j++, k++)
- *buf++ = u.rand_byte[j];
+ const uint32_t ret = len;
+
+ if (!_ODP_UNALIGNED && ((uintptr_t)buf & 3) && len) {
+ uint32_t r = xorshift64s32(seed);
+
+ if ((uintptr_t)buf & 1) {
+ *(uint8_t *)(uintptr_t)buf = r & 0xff;
+ r >>= 8;
+ buf += 1;
+ len -= 1;
+ }
+
+ if (((uintptr_t)buf & 2) && len >= 2) {
+ *(uint16_t *)(uintptr_t)buf = r & 0xffff;
+ buf += 2;
+ len -= 2;
+ }
+ }
+
+ for (uint32_t i = 0; i < len / 4; i++) {
+ *(uint32_t *)(uintptr_t)buf = xorshift64s32(seed);
+ buf += 4;
}
- return len;
+ if (len & 3) {
+ uint32_t r = xorshift64s32(seed);
+
+ if (len & 2) {
+ *(uint16_t *)(uintptr_t)buf = r & 0xffff;
+ r >>= 16;
+ buf += 2;
+ }
+
+ if (len & 1)
+ *(uint8_t *)(uintptr_t)buf = r & 0xff;
+ }
+
+ return ret;
}
int32_t _odp_random_std_test_data(uint8_t *buf, uint32_t len, uint64_t *seed)
{
- uint32_t seed32 = (*seed) & 0xffffffff;
-
- _random_data(buf, len, &seed32);
-
- *seed = seed32;
- return len;
+ return _random_data(buf, len, seed);
}
-static __thread uint32_t this_seed;
+static __thread uint64_t this_seed;
int32_t _odp_random_std_data(uint8_t *buf, uint32_t len)
{
@@ -59,7 +95,7 @@ int32_t _odp_random_std_data(uint8_t *buf, uint32_t len)
int _odp_random_std_init_local(void)
{
this_seed = time(NULL);
- this_seed ^= odp_cpu_id() << 16;
+ this_seed ^= (uint64_t)odp_cpu_id() << 32;
return 0;
}
diff --git a/platform/linux-generic/odp_schedule_basic.c b/platform/linux-generic/odp_schedule_basic.c
index 0761def57..3b22a5bb6 100644
--- a/platform/linux-generic/odp_schedule_basic.c
+++ b/platform/linux-generic/odp_schedule_basic.c
@@ -137,23 +137,24 @@ typedef union {
ODP_STATIC_ASSERT(sizeof(lock_called_t) == sizeof(uint32_t),
"Lock_called_values_do_not_fit_in_uint32");
+/* Shuffled values from 0 to 127 */
static uint8_t sched_random_u8[] = {
- 0x64, 0xe3, 0x64, 0x0a, 0x0a, 0x5b, 0x7e, 0xd7,
- 0x43, 0xb7, 0x90, 0x71, 0x76, 0x17, 0x8e, 0x3f,
- 0x17, 0x60, 0x7e, 0xfd, 0x99, 0xe3, 0xab, 0x06,
- 0x77, 0xf9, 0x45, 0x17, 0x2f, 0x81, 0x9e, 0x7b,
- 0x20, 0x1b, 0x36, 0x75, 0x69, 0xc5, 0x69, 0x27,
- 0x7a, 0xf6, 0x3f, 0x63, 0x2c, 0x3f, 0x1b, 0xeb,
- 0x12, 0xe1, 0x6f, 0xd4, 0xd9, 0x14, 0x97, 0xa6,
- 0x2a, 0xe5, 0xb0, 0x45, 0x27, 0xa6, 0x48, 0xbc,
- 0x2b, 0xec, 0xd8, 0xda, 0x55, 0xef, 0x15, 0xce,
- 0xf8, 0xc2, 0x1e, 0xc8, 0x16, 0x6c, 0xf0, 0x4f,
- 0x1a, 0xc7, 0x50, 0x9e, 0x0b, 0xa5, 0xe9, 0xf3,
- 0x28, 0x79, 0x2e, 0x18, 0xb0, 0xb4, 0xac, 0xce,
- 0x67, 0x04, 0x52, 0x98, 0xce, 0x8c, 0x05, 0x87,
- 0xab, 0xc8, 0x94, 0x7e, 0x46, 0x63, 0x60, 0x8d,
- 0x3d, 0x8f, 0x14, 0x85, 0x1e, 0x92, 0xd2, 0x40,
- 0x2d, 0x42, 0xfe, 0xf1, 0xc2, 0xb6, 0x03, 0x43
+ 0x5B, 0x56, 0x21, 0x28, 0x77, 0x2C, 0x7E, 0x10,
+ 0x29, 0x73, 0x39, 0x74, 0x60, 0x2B, 0x2D, 0x3E,
+ 0x6C, 0x4C, 0x1B, 0x79, 0x14, 0x76, 0x7B, 0x5A,
+ 0x4F, 0x3B, 0x0B, 0x16, 0x66, 0x0D, 0x05, 0x27,
+ 0x3F, 0x7F, 0x67, 0x3C, 0x41, 0x6F, 0x4E, 0x7A,
+ 0x04, 0x26, 0x11, 0x7C, 0x43, 0x38, 0x30, 0x2A,
+ 0x03, 0x22, 0x17, 0x75, 0x08, 0x71, 0x6D, 0x6B,
+ 0x0A, 0x4B, 0x52, 0x1D, 0x63, 0x59, 0x1C, 0x50,
+ 0x15, 0x1A, 0x64, 0x42, 0x47, 0x62, 0x1F, 0x37,
+ 0x46, 0x5D, 0x19, 0x35, 0x78, 0x68, 0x57, 0x7D,
+ 0x3A, 0x31, 0x4A, 0x45, 0x09, 0x49, 0x00, 0x01,
+ 0x65, 0x13, 0x48, 0x70, 0x5E, 0x69, 0x36, 0x58,
+ 0x1E, 0x5C, 0x23, 0x12, 0x18, 0x25, 0x55, 0x32,
+ 0x33, 0x61, 0x2F, 0x02, 0x06, 0x53, 0x24, 0x6E,
+ 0x2E, 0x5F, 0x54, 0x6A, 0x20, 0x07, 0x0F, 0x51,
+ 0x3D, 0x34, 0x44, 0x0C, 0x4D, 0x40, 0x72, 0x0E
};
ODP_STATIC_ASSERT(sizeof(sched_random_u8) == RANDOM_TBL_SIZE, "Bad_random_table_size");
diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c
index 424d32ccf..74e5c9864 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -8,6 +8,7 @@
#include <odp_config_internal.h>
#include <odp_debug_internal.h>
#include <odp/api/debug.h>
+#include <odp/api/deprecated.h>
#include <odp/api/std_types.h>
#include <odp/api/shared_memory.h>
#include <odp/api/plat/strong_types.h>
@@ -17,8 +18,14 @@
#include <string.h>
/* Supported ODP_SHM_* flags */
-#define SUPPORTED_SHM_FLAGS (ODP_SHM_SW_ONLY | ODP_SHM_PROC | ODP_SHM_SINGLE_VA | ODP_SHM_EXPORT | \
- ODP_SHM_HP | ODP_SHM_NO_HP)
+#if ODP_DEPRECATED_API
+ #define DEPRECATED_SHM_FLAGS (ODP_SHM_SW_ONLY)
+#else
+ #define DEPRECATED_SHM_FLAGS 0
+#endif
+
+#define SUPPORTED_SHM_FLAGS (ODP_SHM_PROC | ODP_SHM_SINGLE_VA | ODP_SHM_EXPORT | \
+ ODP_SHM_HP | ODP_SHM_NO_HP | DEPRECATED_SHM_FLAGS)
static inline uint32_t from_handle(odp_shm_t shm)
{
diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c
index 1e4f775e1..5665a3ece 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -471,7 +471,14 @@ uint64_t odp_sys_huge_page_size(void)
static int pagesz_compare(const void *pagesz1, const void *pagesz2)
{
- return (*(const uint64_t *)pagesz1 - *(const uint64_t *)pagesz2);
+ const uint64_t val1 = *(const uint64_t *)pagesz1;
+ const uint64_t val2 = *(const uint64_t *)pagesz2;
+
+ if (val1 < val2)
+ return -1;
+ if (val1 > val2)
+ return 1;
+ return 0;
}
int odp_sys_huge_page_size_all(uint64_t size[], int num)
diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c
index cd98fcc7d..e6bcbbace 100644
--- a/platform/linux-generic/odp_timer.c
+++ b/platform/linux-generic/odp_timer.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2021, Nokia
+ * Copyright (c) 2019-2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -71,6 +71,9 @@
/* Max inline timer resolution */
#define MAX_INLINE_RES_NS 500
+/* Timer pool may be reused after this period */
+#define TIMER_POOL_REUSE_NS ODP_TIME_SEC_IN_NS
+
/* Mutual exclusion in the absence of CAS16 */
#ifndef ODP_ATOMIC_U128
#define NUM_LOCKS 1024
@@ -129,7 +132,6 @@ typedef struct timer_pool_s {
uint32_t tp_idx;/* Index into timer_pool array */
odp_timer_pool_param_t param;
char name[ODP_TIMER_POOL_NAME_LEN];
- odp_shm_t shm;
timer_t timerid;
int notify_overrun;
int owner;
@@ -157,6 +159,8 @@ typedef struct timer_global_t {
uint64_t poll_interval_nsec;
int num_timer_pools;
uint8_t timer_pool_used[MAX_TIMER_POOLS];
+ odp_time_t destroy_time[MAX_TIMER_POOLS];
+ odp_shm_t tp_shm[MAX_TIMER_POOLS];
timer_pool_t *timer_pool[MAX_TIMER_POOLS];
#ifndef ODP_ATOMIC_U128
/* Multiple locks per cache line! */
@@ -285,11 +289,17 @@ static odp_timer_pool_t timer_pool_new(const char *name,
size_t sz0, sz1, sz2;
uint64_t tp_size;
uint64_t res_ns, nsec_per_scan;
+ odp_shm_t shm;
+ timer_pool_t *tp;
+ odp_time_t diff, time;
+ odp_time_t max_diff = ODP_TIME_NULL;
uint32_t flags = 0;
if (odp_global_ro.shm_single_va)
flags |= ODP_SHM_SINGLE_VA;
+ time = odp_time_global();
+
odp_ticketlock_lock(&timer_global->lock);
if (timer_global->num_timer_pools >= MAX_TIMER_POOLS) {
@@ -298,31 +308,59 @@ static odp_timer_pool_t timer_pool_new(const char *name,
return ODP_TIMER_POOL_INVALID;
}
+ /* Find timer pool that has not been used for a while, or is used least recently.
+ * This ensures that inline scan of an old timer pool has completed and its memory
+ * can be freed. */
+ tp_idx = -1;
for (i = 0; i < MAX_TIMER_POOLS; i++) {
if (timer_global->timer_pool_used[i] == 0) {
- timer_global->timer_pool_used[i] = 1;
- break;
+ diff = odp_time_diff(time, timer_global->destroy_time[i]);
+
+ if (odp_time_to_ns(diff) > TIMER_POOL_REUSE_NS) {
+ tp_idx = i;
+ break;
+ }
+
+ if (odp_time_cmp(diff, max_diff) > 0) {
+ max_diff = diff;
+ tp_idx = i;
+ }
}
}
- tp_idx = i;
+ if (tp_idx < 0) {
+ odp_ticketlock_unlock(&timer_global->lock);
+ ODP_DBG("Did not find free timer pool\n");
+ return ODP_TIMER_POOL_INVALID;
+ }
+
+ shm = timer_global->tp_shm[tp_idx];
+ timer_global->timer_pool_used[tp_idx] = 1;
timer_global->num_timer_pools++;
odp_ticketlock_unlock(&timer_global->lock);
+ /* Free memory of previously destroyed timer pool */
+ if (shm != ODP_SHM_INVALID) {
+ if (odp_shm_free(shm)) {
+ ODP_ERR("Failed to free shared memory: tp_idx %i\n", tp_idx);
+ goto error;
+ }
+ }
+
sz0 = ROUNDUP_CACHE_LINE(sizeof(timer_pool_t));
sz1 = ROUNDUP_CACHE_LINE(sizeof(tick_buf_t) * param->num_timers);
- sz2 = ROUNDUP_CACHE_LINE(sizeof(_odp_timer_t) *
- param->num_timers);
+ sz2 = ROUNDUP_CACHE_LINE(sizeof(_odp_timer_t) * param->num_timers);
tp_size = sz0 + sz1 + sz2;
- odp_shm_t shm = odp_shm_reserve(name, tp_size, ODP_CACHE_LINE_SIZE,
- flags);
- if (odp_unlikely(shm == ODP_SHM_INVALID))
- ODP_ABORT("%s: timer pool shm-alloc(%zuKB) failed\n",
- name, (sz0 + sz1 + sz2) / 1024);
- timer_pool_t *tp = (timer_pool_t *)odp_shm_addr(shm);
+ shm = odp_shm_reserve(name, tp_size, ODP_CACHE_LINE_SIZE, flags);
+ if (odp_unlikely(shm == ODP_SHM_INVALID)) {
+ ODP_ERR("Timer pool shm reserve failed %" PRIu64 "kB\n", tp_size / 1024);
+ goto error;
+ }
+
+ tp = (timer_pool_t *)odp_shm_addr(shm);
memset(tp, 0, tp_size);
if (param->res_ns)
@@ -346,7 +384,7 @@ static odp_timer_pool_t timer_pool_new(const char *name,
strncpy(tp->name, name, ODP_TIMER_POOL_NAME_LEN - 1);
tp->name[ODP_TIMER_POOL_NAME_LEN - 1] = 0;
}
- tp->shm = shm;
+
tp->param = *param;
tp->param.res_ns = res_ns;
tp->min_rel_tck = odp_timer_ns_to_tick(timer_pool_to_hdl(tp),
@@ -382,8 +420,11 @@ static odp_timer_pool_t timer_pool_new(const char *name,
tp->start_time = odp_time_global();
odp_ticketlock_lock(&timer_global->lock);
+
/* Inline timer scan may find the timer pool after this */
+ odp_mb_release();
timer_global->timer_pool[tp_idx] = tp;
+ timer_global->tp_shm[tp_idx] = shm;
if (timer_global->num_timer_pools == 1)
odp_global_rw->inline_timers = timer_global->use_inline_timers;
@@ -395,20 +436,25 @@ static odp_timer_pool_t timer_pool_new(const char *name,
odp_time_global_from_ns(nsec_per_scan);
}
+ /* Update the highest index for inline timer scan */
+ if (tp_idx > timer_global->highest_tp_idx)
+ timer_global->highest_tp_idx = tp_idx;
+
odp_ticketlock_unlock(&timer_global->lock);
- if (!odp_global_rw->inline_timers) {
- if (tp->param.clk_src == ODP_CLOCK_DEFAULT)
- itimer_init(tp);
- } else {
- /* Update the highest index for inline timer scan */
- odp_ticketlock_lock(&timer_global->lock);
- if (tp_idx > timer_global->highest_tp_idx)
- timer_global->highest_tp_idx = tp_idx;
- odp_ticketlock_unlock(&timer_global->lock);
- }
+ if (!odp_global_rw->inline_timers)
+ itimer_init(tp);
return timer_pool_to_hdl(tp);
+
+error:
+ odp_ticketlock_lock(&timer_global->lock);
+ timer_global->tp_shm[tp_idx] = shm;
+ timer_global->timer_pool_used[tp_idx] = 0;
+ timer_global->num_timer_pools--;
+ odp_ticketlock_unlock(&timer_global->lock);
+
+ return ODP_TIMER_POOL_INVALID;
}
static void block_sigalarm(void)
@@ -433,16 +479,14 @@ static void stop_timer_thread(timer_pool_t *tp)
static void odp_timer_pool_del(timer_pool_t *tp)
{
- int rc, highest;
- odp_shm_t shm;
+ int highest;
+ uint32_t tp_idx = tp->tp_idx;
odp_spinlock_lock(&tp->lock);
if (!odp_global_rw->inline_timers) {
/* Stop POSIX itimer signals */
- if (tp->param.clk_src == ODP_CLOCK_DEFAULT)
- itimer_fini(tp);
-
+ itimer_fini(tp);
stop_timer_thread(tp);
}
@@ -456,10 +500,10 @@ static void odp_timer_pool_del(timer_pool_t *tp)
odp_spinlock_unlock(&tp->lock);
odp_ticketlock_lock(&timer_global->lock);
- shm = tp->shm;
- timer_global->timer_pool[tp->tp_idx] = NULL;
- timer_global->timer_pool_used[tp->tp_idx] = 0;
+ timer_global->timer_pool[tp_idx] = NULL;
+ timer_global->timer_pool_used[tp_idx] = 0;
timer_global->num_timer_pools--;
+ timer_global->destroy_time[tp_idx] = odp_time_global();
highest = -1;
@@ -477,11 +521,6 @@ static void odp_timer_pool_del(timer_pool_t *tp)
timer_global->highest_tp_idx = highest;
odp_ticketlock_unlock(&timer_global->lock);
-
- rc = odp_shm_free(shm);
-
- if (rc != 0)
- ODP_ABORT("Failed to free shared memory (%d)\n", rc);
}
static inline odp_timer_t timer_alloc(timer_pool_t *tp, odp_queue_t queue, const void *user_ptr)
@@ -943,10 +982,10 @@ static inline void timer_pool_scan_inline(int num, odp_time_t now)
if (odp_atomic_cas_u64(&tp->cur_tick, &old_tick, new_tick)) {
if (tp->notify_overrun && diff > 1) {
if (old_tick == 0) {
- ODP_ERR("Timer pool (%s) missed %" PRIi64 " scans in start up\n",
+ ODP_DBG("Timer pool (%s) missed %" PRIi64 " scans in start up\n",
tp->name, diff - 1);
} else {
- ODP_ERR("Timer pool (%s) resolution too high: missed %" PRIi64 " scans\n",
+ ODP_DBG("Timer pool (%s) resolution too high: %" PRIi64 " scans missed\n",
tp->name, diff - 1);
tp->notify_overrun = 0;
}
@@ -1002,7 +1041,7 @@ static inline void timer_run_posix(timer_pool_t *tp)
if (tp->notify_overrun) {
overrun = timer_getoverrun(tp->timerid);
if (overrun) {
- ODP_ERR("\n\t%d ticks overrun on timer pool \"%s\", timer resolution too high\n",
+ ODP_DBG("\n\t%d ticks overrun on timer pool \"%s\", timer resolution too high\n",
overrun, tp->name);
tp->notify_overrun = 0;
}
@@ -1278,6 +1317,11 @@ odp_timer_pool_t odp_timer_pool_create(const char *name,
return ODP_TIMER_POOL_INVALID;
}
+ if (param->clk_src != ODP_CLOCK_DEFAULT) {
+ ODP_ERR("Only ODP_CLOCK_DEFAULT supported. Requested %i.\n", param->clk_src);
+ return ODP_TIMER_POOL_INVALID;
+ }
+
if ((param->res_ns && param->res_hz) ||
(param->res_ns == 0 && param->res_hz == 0)) {
_odp_errno = EINVAL;
@@ -1596,7 +1640,9 @@ void odp_timeout_print(odp_timeout_t tmo)
int _odp_timer_init_global(const odp_init_t *params)
{
odp_shm_t shm;
+ odp_time_t time;
const char *conf_str;
+ uint32_t i;
int val = 0;
if (params && params->not_used.feat.timer) {
@@ -1621,9 +1667,13 @@ int _odp_timer_init_global(const odp_init_t *params)
timer_global->highest_res_ns = MAX_INLINE_RES_NS;
timer_global->highest_tp_idx = -1;
-#ifndef ODP_ATOMIC_U128
- uint32_t i;
+ time = odp_time_global();
+ for (i = 0; i < MAX_TIMER_POOLS; i++) {
+ timer_global->destroy_time[i] = time;
+ timer_global->tp_shm[i] = ODP_SHM_INVALID;
+ }
+#ifndef ODP_ATOMIC_U128
for (i = 0; i < NUM_LOCKS; i++)
_odp_atomic_flag_clear(&timer_global->locks[i]);
#else
@@ -1676,8 +1726,24 @@ error:
int _odp_timer_term_global(void)
{
- if (timer_global && odp_shm_free(timer_global->shm)) {
- ODP_ERR("Shm free failed for odp_timer\n");
+ odp_shm_t shm;
+ int i;
+
+ if (timer_global == NULL)
+ return 0;
+
+ for (i = 0; i < MAX_TIMER_POOLS; i++) {
+ shm = timer_global->tp_shm[i];
+ if (shm != ODP_SHM_INVALID) {
+ if (odp_shm_free(shm)) {
+ ODP_ERR("Shm free failed for timer pool %i\n", i);
+ return -1;
+ }
+ }
+ }
+
+ if (odp_shm_free(timer_global->shm)) {
+ ODP_ERR("Shm free failed for timer_global\n");
return -1;
}
diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c
index e9e6822a1..119be7fba 100644
--- a/platform/linux-generic/odp_traffic_mngr.c
+++ b/platform/linux-generic/odp_traffic_mngr.c
@@ -1,6 +1,7 @@
/* Copyright 2015 EZchip Semiconductor Ltd. All Rights Reserved.
*
* Copyright (c) 2015-2018, Linaro Limited
+ * Copyright (c) 2022, Marvell
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -49,6 +50,10 @@ static const pkt_desc_t EMPTY_PKT_DESC = { .word = 0 };
#define MAX_PRIORITIES ODP_TM_MAX_PRIORITIES
#define NUM_SHAPER_COLORS ODP_NUM_SHAPER_COLORS
+/* Shaper BW limits in bits/sec */
+#define TM_MIN_SHAPER_BW 8000ULL
+#define TM_MAX_SHAPER_BW (100ULL * 1000ULL * 1000ULL * 1000ULL)
+
static const tm_prop_t basic_prop_tbl[MAX_PRIORITIES][NUM_SHAPER_COLORS] = {
[0] = {
[ODP_TM_SHAPER_GREEN] = { 0, DECR_BOTH },
@@ -167,24 +172,6 @@ static inline tm_node_obj_t *tm_nobj_from_index(uint32_t node_id)
return &tm_glb->node_obj.obj[node_id];
}
-static int queue_tm_reenq(odp_queue_t queue, _odp_event_hdr_t *event_hdr)
-{
- odp_tm_queue_t tm_queue = MAKE_ODP_TM_QUEUE(odp_queue_context(queue));
- odp_packet_t pkt = packet_from_event_hdr(event_hdr);
-
- return odp_tm_enq(tm_queue, pkt);
-}
-
-static int queue_tm_reenq_multi(odp_queue_t queue, _odp_event_hdr_t *event[],
- int num)
-{
- (void)queue;
- (void)event;
- (void)num;
- ODP_ABORT("Invalid call to queue_tm_reenq_multi()\n");
- return 0;
-}
-
static tm_queue_obj_t *get_tm_queue_obj(tm_system_t *tm_system,
pkt_desc_t *pkt_desc)
{
@@ -632,7 +619,7 @@ static void tm_shaper_params_cvt_to(const odp_tm_shaper_params_t *shaper_params,
commit_burst = (int64_t)shaper_params->commit_burst;
peak_rate = tm_bps_to_rate(shaper_params->peak_rate);
- if ((shaper_params->peak_rate == 0) || (peak_rate == 0)) {
+ if ((!shaper_params->dual_rate) || (peak_rate == 0)) {
peak_rate = 0;
max_peak_time_delta = 0;
peak_burst = 0;
@@ -829,7 +816,7 @@ static void update_shaper_elapsed_time(tm_system_t *tm_system,
shaper_obj->commit_cnt = (int64_t)MIN(max_commit, commit + commit_inc);
- if (shaper_params->peak_rate != 0) {
+ if (shaper_params->dual_rate) {
peak = shaper_obj->peak_cnt;
max_peak = shaper_params->max_peak;
if (shaper_params->max_peak_time_delta <= time_delta)
@@ -860,7 +847,7 @@ static uint64_t time_till_not_red(tm_shaper_params_t *shaper_params,
min_time_delay =
MAX(shaper_obj->shaper_params->min_time_delta, UINT64_C(256));
commit_delay = MAX(commit_delay, min_time_delay);
- if (shaper_params->peak_rate == 0)
+ if (!shaper_params->dual_rate)
return commit_delay;
peak_delay = 0;
@@ -1064,7 +1051,7 @@ static odp_bool_t rm_pkt_from_shaper(tm_system_t *tm_system,
(shaper_action == DECR_COMMIT))
shaper_obj->commit_cnt -= tkn_count;
- if (shaper_params->peak_rate != 0)
+ if (shaper_params->dual_rate)
if ((shaper_action == DECR_BOTH) ||
(shaper_action == DECR_PEAK))
shaper_obj->peak_cnt -= tkn_count;
@@ -1096,7 +1083,7 @@ static odp_bool_t run_shaper(tm_system_t *tm_system,
if (shaper_params->enabled) {
if (0 < shaper_obj->commit_cnt)
shaper_color = ODP_TM_SHAPER_GREEN;
- else if (shaper_params->peak_rate == 0)
+ else if (!shaper_params->dual_rate)
shaper_color = ODP_TM_SHAPER_RED;
else if (shaper_obj->peak_cnt <= 0)
shaper_color = ODP_TM_SHAPER_RED;
@@ -2608,6 +2595,10 @@ static int tm_capabilities(odp_tm_capabilities_t capabilities[],
per_level_cap->max_priority = ODP_TM_MAX_PRIORITIES - 1;
per_level_cap->min_weight = ODP_TM_MIN_SCHED_WEIGHT;
per_level_cap->max_weight = ODP_TM_MAX_SCHED_WEIGHT;
+ per_level_cap->min_burst = 0;
+ per_level_cap->max_burst = UINT32_MAX;
+ per_level_cap->min_rate = TM_MIN_SHAPER_BW;
+ per_level_cap->max_rate = TM_MAX_SHAPER_BW;
per_level_cap->tm_node_shaper_supported = true;
per_level_cap->tm_node_wred_supported = true;
@@ -2730,6 +2721,10 @@ static void tm_system_capabilities_set(odp_tm_capabilities_t *cap_ptr,
per_level_cap->max_priority = max_priority;
per_level_cap->min_weight = min_weight;
per_level_cap->max_weight = max_weight;
+ per_level_cap->min_burst = 0;
+ per_level_cap->max_burst = UINT32_MAX;
+ per_level_cap->min_rate = TM_MIN_SHAPER_BW;
+ per_level_cap->max_rate = TM_MAX_SHAPER_BW;
per_level_cap->tm_node_shaper_supported = shaper_supported;
per_level_cap->tm_node_wred_supported = wred_supported;
@@ -3923,6 +3918,7 @@ int odp_tm_node_shaper_config(odp_tm_node_t tm_node,
{
tm_node_obj_t *tm_node_obj;
tm_system_t *tm_system;
+ odp_bool_t sync_needed;
tm_node_obj = GET_TM_NODE_OBJ(tm_node);
if (!tm_node_obj)
@@ -3933,8 +3929,13 @@ int odp_tm_node_shaper_config(odp_tm_node_t tm_node,
return -1;
odp_ticketlock_lock(&tm_glb->profile_lock);
+ sync_needed = tm_glb->main_loop_running;
+ if (sync_needed)
+ signal_request();
tm_shaper_config_set(tm_system, shaper_profile,
&tm_node_obj->shaper_obj);
+ if (sync_needed)
+ signal_request_done();
odp_ticketlock_unlock(&tm_glb->profile_lock);
return 0;
}
@@ -4052,7 +4053,6 @@ odp_tm_queue_t odp_tm_queue_create(odp_tm_t odp_tm,
_odp_int_pkt_queue_t _odp_int_pkt_queue;
tm_queue_obj_t *queue_obj;
odp_tm_queue_t odp_tm_queue = ODP_TM_INVALID;
- odp_queue_t queue;
odp_tm_wred_t wred_profile;
tm_system_t *tm_system;
uint32_t color;
@@ -4090,25 +4090,6 @@ odp_tm_queue_t odp_tm_queue_create(odp_tm_t odp_tm,
odp_atomic_init_u64(&queue_obj->stats.errors, 0);
odp_atomic_init_u64(&queue_obj->stats.packets, 0);
- queue = odp_queue_create(NULL, NULL);
- if (queue == ODP_QUEUE_INVALID) {
- odp_tm_queue = ODP_TM_INVALID;
- continue;
- }
-
- queue_obj->queue = queue;
- if (odp_queue_context_set(queue, queue_obj, sizeof(tm_queue_obj_t))) {
- ODP_ERR("Queue context set failed\n");
- if (odp_queue_destroy(queue))
- ODP_ERR("Queue destroy failed\n");
-
- odp_tm_queue = ODP_TM_INVALID;
- break;
- }
-
- _odp_queue_fn->set_enq_deq_fn(queue, queue_tm_reenq,
- queue_tm_reenq_multi, NULL, NULL);
-
tm_system->queue_num_tbl[queue_obj->queue_num - 1] = queue_obj;
odp_ticketlock_lock(&tm_system->tm_system_lock);
@@ -4169,8 +4150,6 @@ int odp_tm_queue_destroy(odp_tm_queue_t tm_queue)
odp_ticketlock_lock(&tm_system->tm_system_lock);
tm_system->queue_num_tbl[tm_queue_obj->queue_num - 1] = NULL;
- odp_queue_destroy(tm_queue_obj->queue);
-
odp_ticketlock_lock(&tm_glb->queue_obj.lock);
_odp_pkt_queue_destroy(tm_system->_odp_int_queue_pool,
tm_queue_obj->_odp_int_pkt_queue);
@@ -4485,6 +4464,7 @@ int odp_tm_enq(odp_tm_queue_t tm_queue, odp_packet_t pkt)
{
tm_queue_obj_t *tm_queue_obj;
tm_system_t *tm_system;
+ int rc;
tm_queue_obj = GET_TM_QUEUE_OBJ(tm_queue);
if (!tm_queue_obj)
@@ -4497,7 +4477,10 @@ int odp_tm_enq(odp_tm_queue_t tm_queue, odp_packet_t pkt)
if (odp_atomic_load_u64(&tm_system->destroying))
return -1;
- return tm_enqueue(tm_system, tm_queue_obj, pkt);
+ rc = tm_enqueue(tm_system, tm_queue_obj, pkt);
+ if (rc < 0)
+ return rc;
+ return 0;
}
int odp_tm_enq_with_cnt(odp_tm_queue_t tm_queue, odp_packet_t pkt)
diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c
index 291ee543f..0bd7a21c4 100644
--- a/platform/linux-generic/pktio/socket.c
+++ b/platform/linux-generic/pktio/socket.c
@@ -608,7 +608,7 @@ static int sock_init_global(void)
disable_pktio = 1;
} else {
ODP_PRINT("PKTIO: initialized socket mmsg,"
- "use export ODP_PKTIO_DISABLE_SOCKET_MMSG=1 to disable.\n");
+ " use export ODP_PKTIO_DISABLE_SOCKET_MMSG=1 to disable.\n");
}
return 0;
}
diff --git a/test/performance/.gitignore b/test/performance/.gitignore
index 7952530a3..6a891a146 100644
--- a/test/performance/.gitignore
+++ b/test/performance/.gitignore
@@ -6,6 +6,7 @@ odp_bench_packet
odp_cpu_bench
odp_crc
odp_crypto
+odp_dma_perf
odp_ipsec
odp_l2fwd
odp_lock_perf
diff --git a/test/performance/Makefile.am b/test/performance/Makefile.am
index b6dbbd82e..2a87424f1 100644
--- a/test/performance/Makefile.am
+++ b/test/performance/Makefile.am
@@ -15,7 +15,8 @@ EXECUTABLES = odp_atomic_perf \
odp_queue_perf \
odp_random
-COMPILE_ONLY = odp_l2fwd \
+COMPILE_ONLY = odp_dma_perf \
+ odp_l2fwd \
odp_packet_gen \
odp_pktio_ordered \
odp_sched_latency \
@@ -24,7 +25,8 @@ COMPILE_ONLY = odp_l2fwd \
odp_scheduling \
odp_timer_perf
-TESTSCRIPTS = odp_l2fwd_run.sh \
+TESTSCRIPTS = odp_dma_perf_run.sh \
+ odp_l2fwd_run.sh \
odp_packet_gen_run.sh \
odp_sched_latency_run.sh \
odp_sched_perf_run.sh \
@@ -49,6 +51,7 @@ odp_bench_packet_SOURCES = odp_bench_packet.c
odp_cpu_bench_SOURCES = odp_cpu_bench.c
odp_crc_SOURCES = odp_crc.c
odp_crypto_SOURCES = odp_crypto.c
+odp_dma_perf_SOURCES = odp_dma_perf.c
odp_ipsec_SOURCES = odp_ipsec.c
odp_lock_perf_SOURCES = odp_lock_perf.c
odp_mem_perf_SOURCES = odp_mem_perf.c
diff --git a/test/performance/odp_crypto.c b/test/performance/odp_crypto.c
index 341782630..d9acfb31e 100644
--- a/test/performance/odp_crypto.c
+++ b/test/performance/odp_crypto.c
@@ -219,10 +219,7 @@ static crypto_alg_config_t algs_config[] = {
.data = test_key24,
.length = sizeof(test_key24)
},
- .cipher_iv = {
- .data = test_iv,
- .length = 8,
- },
+ .cipher_iv_len = 8,
.auth_alg = ODP_AUTH_ALG_NULL
},
},
@@ -234,10 +231,7 @@ static crypto_alg_config_t algs_config[] = {
.data = test_key24,
.length = sizeof(test_key24)
},
- .cipher_iv = {
- .data = test_iv,
- .length = 8,
- },
+ .cipher_iv_len = 8,
.auth_alg = ODP_AUTH_ALG_MD5_HMAC,
.auth_key = {
.data = test_key16,
@@ -266,10 +260,7 @@ static crypto_alg_config_t algs_config[] = {
.data = test_key16,
.length = sizeof(test_key16)
},
- .cipher_iv = {
- .data = test_iv,
- .length = 16,
- },
+ .cipher_iv_len = 16,
.auth_alg = ODP_AUTH_ALG_NULL
},
},
@@ -281,10 +272,7 @@ static crypto_alg_config_t algs_config[] = {
.data = test_key16,
.length = sizeof(test_key16)
},
- .cipher_iv = {
- .data = test_iv,
- .length = 16,
- },
+ .cipher_iv_len = 16,
.auth_alg = ODP_AUTH_ALG_SHA1_HMAC,
.auth_key = {
.data = test_key20,
@@ -313,10 +301,7 @@ static crypto_alg_config_t algs_config[] = {
.data = test_key16,
.length = sizeof(test_key16)
},
- .cipher_iv = {
- .data = test_iv,
- .length = 16,
- },
+ .cipher_iv_len = 16,
.auth_alg = ODP_AUTH_ALG_NULL
},
},
@@ -328,10 +313,7 @@ static crypto_alg_config_t algs_config[] = {
.data = test_key16,
.length = sizeof(test_key16)
},
- .cipher_iv = {
- .data = test_iv,
- .length = 16,
- },
+ .cipher_iv_len = 16,
.auth_alg = ODP_AUTH_ALG_SHA1_HMAC,
.auth_key = {
.data = test_key20,
@@ -373,10 +355,7 @@ static crypto_alg_config_t algs_config[] = {
.data = test_key16,
.length = sizeof(test_key16)
},
- .auth_iv = {
- .data = test_iv,
- .length = 12,
- },
+ .auth_iv_len = 12,
.auth_digest_len = 16,
},
},
@@ -388,10 +367,7 @@ static crypto_alg_config_t algs_config[] = {
.data = test_key16,
.length = sizeof(test_key16)
},
- .cipher_iv = {
- .data = test_iv,
- .length = 12,
- },
+ .cipher_iv_len = 12,
.auth_alg = ODP_AUTH_ALG_AES_GCM,
.auth_digest_len = 16,
},
@@ -404,10 +380,7 @@ static crypto_alg_config_t algs_config[] = {
.data = test_key16,
.length = sizeof(test_key16)
},
- .cipher_iv = {
- .data = test_iv,
- .length = 11,
- },
+ .cipher_iv_len = 11,
.auth_alg = ODP_AUTH_ALG_AES_CCM,
.auth_digest_len = 16,
},
@@ -420,10 +393,7 @@ static crypto_alg_config_t algs_config[] = {
.data = test_key32,
.length = sizeof(test_key32)
},
- .cipher_iv = {
- .data = test_iv,
- .length = 12,
- },
+ .cipher_iv_len = 12,
.auth_alg = ODP_AUTH_ALG_CHACHA20_POLY1305,
.auth_digest_len = 16,
},
@@ -725,6 +695,8 @@ run_measure_one(crypto_args_t *cargs,
/* Initialize parameters block */
memset(&params, 0, sizeof(params));
params.session = *session;
+ params.cipher_iv_ptr = test_iv;
+ params.auth_iv_ptr = test_iv;
params.cipher_range.offset = 0;
params.cipher_range.length = payload_length;
diff --git a/test/performance/odp_dma_perf.c b/test/performance/odp_dma_perf.c
new file mode 100644
index 000000000..26397bf49
--- /dev/null
+++ b/test/performance/odp_dma_perf.c
@@ -0,0 +1,1106 @@
+/* Copyright (c) 2021-2022, Nokia
+ *
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include <odp_api.h>
+#include <odp/helper/odph_api.h>
+
+#define EXIT_NOT_SUP 2
+
+#define DEFAULT_SEG_SIZE 1024U
+#define ROUNDS 1000000
+#define COMPL_DELIMITER ","
+/* For now, a static maximum amount of input segments */
+#define MAX_NUM_IN_SEGS 64
+#define SHM_SRC "odp_dma_perf_shm_src"
+#define SHM_DST "odp_dma_perf_shm_dst"
+
+#define TRS_TYPE_SYNC 0
+#define TRS_TYPE_ASYNC 1
+
+#define GRN_ALL 0
+#define GRN_IND 1
+
+#define TYPE_PKT 0
+#define TYPE_MEM 1
+
+#define COMPL_MODE_POLL 0
+#define COMPL_MODE_EVENT 1
+
+#define GIGAS 1000000000
+#define MEGAS 1000000
+#define KILOS 1000
+
+typedef struct test_config_t {
+ int trs_type;
+ int trs_grn;
+ int num_in_seg;
+ uint32_t seg_size;
+ int seg_type;
+ int num_rounds;
+ int dma_rounds;
+
+ struct {
+ int num_modes;
+ uint32_t compl_mask;
+ int modes[MAX_NUM_IN_SEGS];
+ } compl_modes;
+
+ struct {
+ odp_pool_t pool;
+ odp_queue_t compl_q;
+ odp_dma_t handle;
+ odp_dma_seg_t dst_seg;
+ odp_dma_seg_t src_seg[MAX_NUM_IN_SEGS];
+ } dma_config;
+
+ union {
+ struct {
+ odp_shm_t shm_src;
+ odp_shm_t shm_dst;
+ void *src;
+ void *dst;
+ };
+
+ struct {
+ odp_pool_t pool;
+ odp_packet_t pkts[MAX_NUM_IN_SEGS + 1];
+ };
+ } seg_config;
+
+ struct {
+ int (*setup_fn)(struct test_config_t *config);
+ void (*trs_base_fn)(struct test_config_t *config,
+ odp_dma_transfer_param_t *trs_params, uint32_t *trs_lengths);
+ void (*trs_dyn_fn)(struct test_config_t *config, uint32_t offset, uint32_t len);
+ int (*verify_fn)(const struct test_config_t *config);
+ void (*free_fn)(struct test_config_t *config);
+ int (*run_fn)(struct test_config_t *config);
+ } test_case_api;
+} test_config_t;
+
+typedef struct compl_wait_entry_t {
+ int type;
+ odp_dma_transfer_id_t id;
+} compl_wait_entry_t;
+
+static const int compl_mode_map[] = { ODP_DMA_COMPL_POLL, ODP_DMA_COMPL_EVENT };
+
+static void set_option_defaults(test_config_t *config)
+{
+ memset(config, 0, sizeof(*config));
+ config->num_in_seg = 1;
+ config->seg_size = DEFAULT_SEG_SIZE;
+ config->num_rounds = ROUNDS;
+ config->compl_modes.compl_mask = ODP_DMA_COMPL_SYNC;
+}
+
+static void parse_completion_modes(test_config_t *config, const char *optarg)
+{
+ char *tmp_str = strdup(optarg);
+ char *tmp = strtok(tmp_str, COMPL_DELIMITER);
+ int mode;
+ uint32_t i = 0U;
+
+ config->compl_modes.num_modes = 0;
+
+ if (tmp == NULL) {
+ free(tmp_str);
+ return;
+ }
+
+ while (tmp) {
+ mode = atoi(tmp);
+ config->compl_modes.modes[i] = mode;
+ config->compl_modes.compl_mask |= compl_mode_map[mode];
+ ++i;
+ ++config->compl_modes.num_modes;
+ tmp = strtok(NULL, COMPL_DELIMITER);
+ }
+
+ free(tmp_str);
+}
+
+static void print_usage(void)
+{
+ printf("\n"
+ "DMA performance test. Transfers a set of source segments to a single destination\n"
+ "segment.\n"
+ "\n"
+ "Examples:\n"
+ " odp_dma_perf\n"
+ " odp_dma_perf -t 0 -g 1 -i 2\n"
+ " odp_dma_perf -t 1 -g 1 -i 4 -m 0,0,0,0\n"
+ " odp_dma_perf -t 1 -g 1 -i 7 -m 0,0,0,0,0,0,1 -T 1 -r 1000 -s 2048\n"
+ "\n"
+ "Usage: odp_dma_perf [options]\n"
+ "\n"
+ " -t, --trs_type Transfer type for test data. Synchronous by default.\n"
+ " Types:\n"
+ " 0: synchronous\n"
+ " 1: asynchronous\n"
+ " -g, --trs_grn Transfer granularity for source segments. All\n"
+ " segments are sent in one transfer by default.\n"
+ " Options:\n"
+ " 0: all segments in a single transfer\n"
+ " 1: individual transfers for segments\n"
+ " -i, --num_in_seg Number of input segments to transfer. 1 by\n"
+ " default. Maximum supported amount is %d.\n"
+ " -s, --in_seg_size Segment size for all input segments in bytes. 1024\n"
+ " bytes by default. Maximum allowed destination\n"
+ " segment size may limit this choice.\n"
+ " -T, --in_seg_type Input segment data type. Packet by default.\n"
+ " Types:\n"
+ " 0: packet\n"
+ " 1: memory\n"
+ " -m, --compl_modes Completion mode(s) for transfers delimited by a\n"
+ " comma. Only applicable in asynchronous mode.\n"
+ " Modes:\n"
+ " 0: poll\n"
+ " 1: event\n"
+ " -r, --num_rounds Number of times to run the test scenario. %d by\n"
+ " default.\n"
+ " -h, --help This help.\n"
+ "\n",
+ MAX_NUM_IN_SEGS, ROUNDS);
+}
+
+static int check_completion_modes(test_config_t *config)
+{
+ if (config->trs_type == TRS_TYPE_SYNC)
+ return 0;
+
+ if (config->compl_modes.num_modes > MAX_NUM_IN_SEGS)
+ return -1;
+
+ if (config->trs_grn == GRN_IND &&
+ config->num_in_seg != config->compl_modes.num_modes)
+ return -1;
+
+ if (config->trs_grn == GRN_ALL &&
+ config->compl_modes.num_modes != 1)
+ return -1;
+
+ for (int i = 0; i < config->compl_modes.num_modes; ++i) {
+ if (config->compl_modes.modes[i] != COMPL_MODE_POLL &&
+ config->compl_modes.modes[i] != COMPL_MODE_EVENT)
+ return -1;
+
+ config->compl_modes.modes[i] = compl_mode_map[config->compl_modes.modes[i]];
+ }
+
+ return 0;
+}
+
+static int check_options(test_config_t *config)
+{
+ if (config->trs_type != TRS_TYPE_SYNC &&
+ config->trs_type != TRS_TYPE_ASYNC) {
+ ODPH_ERR("Invalid transfer type: %d.\n", config->trs_type);
+ return -1;
+ }
+
+ if (config->trs_grn != GRN_ALL && config->trs_grn != GRN_IND) {
+ ODPH_ERR("Invalid granularity: %d.\n", config->trs_grn);
+ return -1;
+ }
+
+ config->dma_rounds = config->trs_grn == GRN_IND ? config->num_in_seg : 1;
+
+ if (config->num_in_seg < 1 || config->num_in_seg > MAX_NUM_IN_SEGS) {
+ ODPH_ERR("Invalid number of input segments: %d.\n", config->num_in_seg);
+ return -1;
+ }
+
+ if (config->seg_type != TYPE_PKT && config->seg_type != TYPE_MEM) {
+ ODPH_ERR("Invalid input segment type: %d.\n", config->seg_type);
+ return -1;
+ }
+
+ if (check_completion_modes(config)) {
+ ODPH_ERR("Invalid completion modes.\n");
+ return -1;
+ }
+
+ if (config->num_rounds < 1) {
+ ODPH_ERR("Invalid number of rounds: %d.\n", config->num_rounds);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int parse_options(int argc, char **argv, test_config_t *config)
+{
+ int opt, long_index;
+
+ static const struct option longopts[] = {
+ { "trs_type", required_argument, NULL, 't' },
+ { "trs_grn", required_argument, NULL, 'g' },
+ { "num_in_seg", required_argument, NULL, 'i' },
+ { "in_seg_size", required_argument, NULL, 's' },
+ { "in_seg_type", required_argument, NULL, 'T' },
+ { "compl_modes", required_argument, NULL, 'm' },
+ { "num_rounds", required_argument, NULL, 'r' },
+ { "help", no_argument, NULL, 'h' },
+ { NULL, 0, NULL, 0 }
+ };
+
+ static const char *shortopts = "t:g:i:s:T:m:r:h";
+
+ set_option_defaults(config);
+
+ while (1) {
+ opt = getopt_long(argc, argv, shortopts, longopts, &long_index);
+
+ if (opt == -1)
+ break;
+
+ switch (opt) {
+ case 't':
+ config->trs_type = atoi(optarg);
+ break;
+ case 'g':
+ config->trs_grn = atoi(optarg);
+ break;
+ case 'i':
+ config->num_in_seg = atoi(optarg);
+ break;
+ case 's':
+ config->seg_size = atoi(optarg);
+ break;
+ case 'T':
+ config->seg_type = atoi(optarg);
+ break;
+ case 'm':
+ parse_completion_modes(config, optarg);
+ break;
+ case 'r':
+ config->num_rounds = atoi(optarg);
+ break;
+ case 'h':
+ default:
+ print_usage();
+ return -1;
+ }
+ }
+
+ if (check_options(config))
+ return -1;
+
+ return 0;
+}
+
+static int check_shm_capabilities(const test_config_t *config)
+{
+ odp_shm_capability_t capa;
+
+ if (odp_shm_capability(&capa)) {
+ ODPH_ERR("Error querying SHM capabilities.\n");
+ return -1;
+ }
+
+ if (capa.max_blocks < 2U) {
+ ODPH_ERR("Unsupported amount of SHM blocks.\n");
+ return -1;
+ }
+
+ if (capa.max_size != 0U && config->num_in_seg * config->seg_size > capa.max_size) {
+ ODPH_ERR("Unsupported total SHM block size.\n");
+ return -1;
+ }
+
+ if (capa.max_align != 0U && capa.max_align < ODP_CACHE_LINE_SIZE) {
+ ODPH_ERR("Unsupported SHM block alignment size.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int check_dma_capabilities(const test_config_t *config)
+{
+ odp_dma_capability_t capa;
+ const int is_event = config->compl_modes.compl_mask & ODP_DMA_COMPL_EVENT;
+ uint32_t event_compl_count = 0U;
+
+ if (odp_dma_capability(&capa)) {
+ ODPH_ERR("Error querying DMA capabilities.\n");
+ return -1;
+ }
+
+ if (capa.max_sessions == 0U) {
+ ODPH_ERR("DMA not supported.\n");
+ return -1;
+ }
+
+ if (config->trs_type == TRS_TYPE_ASYNC) {
+ if ((config->compl_modes.compl_mask & ODP_DMA_COMPL_POLL) &&
+ (capa.compl_mode_mask & ODP_DMA_COMPL_POLL) == 0U) {
+ ODPH_ERR("Unsupported DMA completion mode, poll.\n");
+ return -1;
+ }
+
+ if (is_event && (capa.compl_mode_mask & ODP_DMA_COMPL_EVENT) == 0U) {
+ ODPH_ERR("Unsupported DMA completion mode, event.\n");
+ return -1;
+ }
+
+ if (is_event && capa.queue_type_sched == 0) {
+ ODPH_ERR("Unsupported DMA queueing type.\n");
+ return -1;
+ }
+
+ if (config->trs_grn == GRN_IND) {
+ if ((uint32_t)config->num_in_seg > capa.max_transfers) {
+ ODPH_ERR("Unsupported amount of in-flight DMA transfers.\n");
+ return -1;
+ }
+
+ for (int i = 0; i < config->compl_modes.num_modes; ++i)
+ if (config->compl_modes.modes[i] == ODP_DMA_COMPL_EVENT)
+ ++event_compl_count;
+
+ if (event_compl_count > capa.pool.max_num) {
+ ODPH_ERR("Unsupported amount of completion events.\n");
+ return -1;
+ }
+ }
+ }
+
+ if (config->trs_grn == GRN_ALL) {
+ if ((uint32_t)config->num_in_seg > capa.max_src_segs) {
+ ODPH_ERR("Unsupported amount of DMA source segments.\n");
+ return -1;
+ }
+
+ if (config->num_in_seg + 1U > capa.max_segs) {
+ ODPH_ERR("Unsupported total amount of DMA segments.\n");
+ return -1;
+ }
+ }
+
+ if (config->trs_grn == GRN_IND && capa.max_segs < 2U) {
+ ODPH_ERR("Unsupported total amount of DMA segments.\n");
+ return -1;
+ }
+
+ if (config->num_in_seg * config->seg_size > capa.max_seg_len) {
+ ODPH_ERR("Unsupported total DMA segment size.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int check_capabilities(const test_config_t *config)
+{
+ return check_shm_capabilities(config) ||
+ check_dma_capabilities(config);
+}
+
+static int configure_packets(test_config_t *config)
+{
+ odp_pool_param_t param;
+
+ for (int i = 0; i < config->num_in_seg + 1; ++i)
+ config->seg_config.pkts[i] = ODP_PACKET_INVALID;
+
+ odp_pool_param_init(&param);
+ param.type = ODP_POOL_PACKET;
+ /* Configured amount of input segments and one output segment */
+ param.pkt.num = config->num_in_seg + 1U;
+ param.pkt.len = config->num_in_seg * config->seg_size;
+ config->seg_config.pool = odp_pool_create("odp_dma_perf_packets", &param);
+
+ if (config->seg_config.pool == ODP_POOL_INVALID) {
+ ODPH_ERR("Error creating packet pool.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int allocate_packets(test_config_t *config)
+{
+ for (int i = 0; i < config->num_in_seg; ++i) {
+ config->seg_config.pkts[i] = odp_packet_alloc(config->seg_config.pool,
+ config->seg_size);
+
+ if (config->seg_config.pkts[i] == ODP_PACKET_INVALID) {
+ ODPH_ERR("Error allocating input test packets.\n");
+ return -1;
+ }
+ }
+
+ config->seg_config.pkts[config->num_in_seg] =
+ odp_packet_alloc(config->seg_config.pool, config->num_in_seg * config->seg_size);
+
+ if (config->seg_config.pkts[config->num_in_seg] == ODP_PACKET_INVALID) {
+ ODPH_ERR("Error allocating output test packet.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int populate_packets(test_config_t *config)
+{
+ for (int i = 0; i < config->num_in_seg; ++i) {
+ uint8_t data[odp_packet_len(config->seg_config.pkts[i])];
+
+ memset(data, i + 1, sizeof(data));
+
+ if (odp_packet_copy_from_mem(config->seg_config.pkts[i], 0U, sizeof(data), data))
+ return -1;
+ }
+
+ return 0;
+}
+
+static int setup_packet_segments(test_config_t *config)
+{
+ return configure_packets(config) ||
+ allocate_packets(config) ||
+ populate_packets(config);
+}
+
+static void configure_packet_dma_transfer_base(test_config_t *config,
+ odp_dma_transfer_param_t trs_params[],
+ uint32_t trs_lengths[])
+{
+ memset(trs_lengths, 0, sizeof(*trs_lengths) * config->dma_rounds);
+
+ for (int i = 0; i < config->num_in_seg; ++i) {
+ config->dma_config.src_seg[i].packet = config->seg_config.pkts[i];
+ config->dma_config.src_seg[i].offset = 0U;
+ config->dma_config.src_seg[i].len = odp_packet_len(config->seg_config.pkts[i]);
+ }
+
+ config->dma_config.dst_seg.packet = config->seg_config.pkts[config->num_in_seg];
+
+ for (int i = 0; i < config->dma_rounds; ++i) {
+ odp_dma_transfer_param_init(&trs_params[i]);
+ trs_params[i].src_format = ODP_DMA_FORMAT_PACKET;
+ trs_params[i].dst_format = ODP_DMA_FORMAT_PACKET;
+ trs_params[i].num_src = config->trs_grn == GRN_IND ? 1 : config->num_in_seg;
+ trs_params[i].num_dst = 1U;
+ trs_params[i].src_seg = &config->dma_config.src_seg[i];
+ trs_params[i].dst_seg = &config->dma_config.dst_seg;
+ trs_lengths[i] = config->trs_grn == GRN_IND ?
+ config->dma_config.src_seg[i].len :
+ config->num_in_seg * config->seg_size;
+ }
+}
+
+static inline void configure_packet_dma_transfer_dynamic(test_config_t *config, uint32_t offset,
+ uint32_t len)
+{
+ config->dma_config.dst_seg.offset = offset;
+ config->dma_config.dst_seg.len = len;
+}
+
+static int verify_packet_transfer(const test_config_t *config)
+{
+ uint32_t len, offset = 0U;
+
+ for (int i = 0; i < config->num_in_seg; ++i) {
+ len = odp_packet_len(config->seg_config.pkts[i]);
+ uint8_t src_data[len];
+ uint8_t dst_data[len];
+
+ if (odp_packet_copy_to_mem(config->seg_config.pkts[i], 0U, len, src_data) ||
+ odp_packet_copy_to_mem(config->seg_config.pkts[config->num_in_seg], offset,
+ len, dst_data)) {
+ ODPH_ERR("Error verifying DMA transfer.\n");
+ return -1;
+ }
+
+ if (memcmp(src_data, dst_data, len)) {
+ ODPH_ERR("Error in DMA transfer, source and destination data do not match.\n");
+ return -1;
+ }
+
+ offset += len;
+ }
+
+ return 0;
+}
+
+static void free_packets(test_config_t *config)
+{
+ /* Configured amount of input segments and one output segment */
+ for (int i = 0; i < config->num_in_seg + 1; ++i)
+ if (config->seg_config.pkts[i] != ODP_PACKET_INVALID)
+ odp_packet_free(config->seg_config.pkts[i]);
+
+ if (config->seg_config.pool != ODP_POOL_INVALID)
+ (void)odp_pool_destroy(config->seg_config.pool);
+}
+
+static int allocate_memory(test_config_t *config)
+{
+ const uint64_t size = config->num_in_seg * (uint64_t)config->seg_size;
+
+ config->seg_config.shm_src = ODP_SHM_INVALID;
+ config->seg_config.shm_dst = ODP_SHM_INVALID;
+ config->seg_config.src = NULL;
+ config->seg_config.dst = NULL;
+
+ config->seg_config.shm_src = odp_shm_reserve(SHM_SRC, size, ODP_CACHE_LINE_SIZE, 0);
+ config->seg_config.shm_dst = odp_shm_reserve(SHM_DST, size, ODP_CACHE_LINE_SIZE, 0);
+
+ if (config->seg_config.shm_src == ODP_SHM_INVALID ||
+ config->seg_config.shm_dst == ODP_SHM_INVALID) {
+ ODPH_ERR("Error allocating SHM block.\n");
+ return -1;
+ }
+
+ config->seg_config.src = odp_shm_addr(config->seg_config.shm_src);
+ config->seg_config.dst = odp_shm_addr(config->seg_config.shm_dst);
+
+ if (config->seg_config.src == NULL || config->seg_config.dst == NULL) {
+ ODPH_ERR("Error resolving SHM block address.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int populate_memory(test_config_t *config)
+{
+ uint8_t val;
+ uint8_t *addr;
+
+ for (int i = 0; i < config->num_in_seg; ++i) {
+ val = 0U;
+ addr = (uint8_t *)config->seg_config.src + i * config->seg_size;
+
+ for (uint32_t i = 0U; i < config->seg_size; ++i)
+ addr[i] = val++;
+ }
+
+ return 0;
+}
+
+static int setup_memory_segments(test_config_t *config)
+{
+ return allocate_memory(config) ||
+ populate_memory(config);
+}
+
+static void configure_address_dma_transfer_base(test_config_t *config,
+ odp_dma_transfer_param_t trs_params[],
+ uint32_t trs_lengths[])
+{
+ memset(trs_lengths, 0, sizeof(*trs_lengths) * config->dma_rounds);
+
+ for (int i = 0; i < config->num_in_seg; ++i) {
+ config->dma_config.src_seg[i].addr =
+ (uint8_t *)config->seg_config.src + i * config->seg_size;
+ config->dma_config.src_seg[i].len = config->seg_size;
+ }
+
+ config->dma_config.dst_seg.addr = config->seg_config.dst;
+
+ for (int i = 0; i < config->dma_rounds; ++i) {
+ odp_dma_transfer_param_init(&trs_params[i]);
+ trs_params[i].src_format = ODP_DMA_FORMAT_ADDR;
+ trs_params[i].dst_format = ODP_DMA_FORMAT_ADDR;
+ trs_params[i].num_src = config->trs_grn == GRN_IND ? 1 : config->num_in_seg;
+ trs_params[i].num_dst = 1U;
+ trs_params[i].src_seg = &config->dma_config.src_seg[i];
+ trs_params[i].dst_seg = &config->dma_config.dst_seg;
+ trs_lengths[i] = config->trs_grn == GRN_IND ?
+ config->dma_config.src_seg[i].len :
+ config->num_in_seg * config->seg_size;
+ }
+}
+
+static inline void configure_address_dma_transfer_dynamic(test_config_t *config, uint32_t offset,
+ uint32_t len)
+{
+ config->dma_config.dst_seg.addr = (uint8_t *)config->seg_config.dst + offset;
+ config->dma_config.dst_seg.len = len;
+}
+
+static int verify_memory_transfer(const test_config_t *config)
+{
+ if (memcmp(config->seg_config.src, config->seg_config.dst,
+ config->num_in_seg * config->seg_size)) {
+ ODPH_ERR("Error in DMA transfer, source and destination data do not match.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static void free_memory(test_config_t *config)
+{
+ if (config->seg_config.shm_src != ODP_SHM_INVALID)
+ (void)odp_shm_free(config->seg_config.shm_src);
+
+ if (config->seg_config.shm_dst != ODP_SHM_INVALID)
+ (void)odp_shm_free(config->seg_config.shm_dst);
+}
+
+static void print_humanised_speed(uint64_t speed)
+{
+ if (speed > GIGAS)
+ printf("%.2f GB/s\n", (double)speed / GIGAS);
+ else if (speed > MEGAS)
+ printf("%.2f MB/s\n", (double)speed / MEGAS);
+ else if (speed > KILOS)
+ printf("%.2f KB/s\n", (double)speed / KILOS);
+ else
+ printf("%" PRIu64 " B/s\n", speed);
+}
+
+static void print_results(const test_config_t *config, uint64_t time)
+{
+ const int is_sync = config->trs_type == TRS_TYPE_SYNC;
+ const uint64_t avg_time = time / config->num_rounds;
+ uint64_t avg_speed = 0U;
+
+ printf("\n"
+ "=============================================\n\n"
+ "DMA transfer test done\n\n"
+ " mode: %s\n"
+ " granularity: %s\n"
+ " input segment count: %d\n"
+ " segment size: %u\n"
+ " segment type: %s\n",
+ is_sync ? "synchronous" : "asynchronous",
+ config->trs_grn == GRN_IND ? "individual" : "all",
+ config->num_in_seg, config->seg_size,
+ config->seg_type == TYPE_PKT ? "packet" : "memory");
+
+ if (!is_sync) {
+ printf(" completion modes in order: ");
+
+ for (int i = 0; i < config->compl_modes.num_modes; ++i)
+ printf("%s", config->compl_modes.modes[i] == ODP_DMA_COMPL_POLL ?
+ "poll " : "event ");
+
+ printf("\n");
+ }
+
+ if (avg_time > 0U)
+ avg_speed = config->num_in_seg * config->seg_size * ODP_TIME_SEC_IN_NS / avg_time;
+
+ printf(" rounds run: %d\n"
+ " average time per transfer: %" PRIu64 " ns\n"
+ " average transfer speed: ",
+ config->num_rounds, avg_time);
+ print_humanised_speed(avg_speed);
+ printf("\n=============================================\n");
+}
+
+static int run_dma_sync(test_config_t *config)
+{
+ odp_dma_transfer_param_t trs_params[config->dma_rounds];
+ uint32_t trs_lengths[config->dma_rounds];
+ odp_time_t start, end;
+ uint32_t num_rounds = config->num_rounds, offset;
+
+ config->test_case_api.trs_base_fn(config, trs_params, trs_lengths);
+ start = odp_time_local_strict();
+
+ while (num_rounds--) {
+ offset = 0U;
+
+ for (int i = 0; i < config->dma_rounds; ++i) {
+ config->test_case_api.trs_dyn_fn(config, offset, trs_lengths[i]);
+
+ if (odp_dma_transfer(config->dma_config.handle, &trs_params[i], NULL)
+ <= 0) {
+ ODPH_ERR("Error starting a sync DMA transfer.\n");
+ return -1;
+ }
+
+ offset += trs_lengths[i];
+ }
+ }
+
+ end = odp_time_local_strict();
+ print_results(config, odp_time_diff_ns(end, start));
+ return 0;
+}
+
+static int configure_dma_event_completion(test_config_t *config)
+{
+ int ret;
+ odp_dma_pool_param_t pool_param;
+ odp_queue_param_t queue_param;
+
+ config->dma_config.pool = ODP_POOL_INVALID;
+ config->dma_config.compl_q = ODP_QUEUE_INVALID;
+
+ ret = odp_schedule_config(NULL);
+
+ if (ret < 0) {
+ ODPH_ERR("Error configuring scheduler.\n");
+ return -1;
+ }
+
+ odp_dma_pool_param_init(&pool_param);
+ pool_param.num = config->num_in_seg;
+ config->dma_config.pool = odp_dma_pool_create("odp_dma_perf_events", &pool_param);
+
+ if (config->dma_config.pool == ODP_POOL_INVALID) {
+ ODPH_ERR("Error creating DMA event completion pool.\n");
+ return -1;
+ }
+
+ odp_queue_param_init(&queue_param);
+ queue_param.type = ODP_QUEUE_TYPE_SCHED;
+ queue_param.sched.sync = ODP_SCHED_SYNC_PARALLEL;
+ queue_param.sched.prio = odp_schedule_default_prio();
+ queue_param.sched.group = ODP_SCHED_GROUP_ALL;
+ config->dma_config.compl_q = odp_queue_create("odp_dma_perf_queue", &queue_param);
+
+ if (config->dma_config.compl_q == ODP_QUEUE_INVALID) {
+ ODPH_ERR("Error creating DMA completion queue.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int configure_dma_completion_params(test_config_t *config,
+ odp_dma_compl_param_t compl_params[])
+{
+ odp_dma_compl_t compl_ev;
+
+ for (int i = 0; i < config->dma_rounds; ++i)
+ odp_dma_compl_param_init(&compl_params[i]);
+
+ for (int i = 0; i < config->dma_rounds; ++i) {
+ if (config->compl_modes.modes[i] == ODP_DMA_COMPL_EVENT) {
+ compl_params[i].compl_mode = ODP_DMA_COMPL_EVENT;
+ compl_ev = odp_dma_compl_alloc(config->dma_config.pool);
+
+ if (compl_ev == ODP_DMA_COMPL_INVALID) {
+ ODPH_ERR("Error creating DMA completion event.\n");
+ return -1;
+ }
+
+ compl_params[i].event = odp_dma_compl_to_event(compl_ev);
+ compl_params[i].queue = config->dma_config.compl_q;
+ } else if (config->compl_modes.modes[i] == ODP_DMA_COMPL_POLL) {
+ compl_params[i].compl_mode = ODP_DMA_COMPL_POLL;
+ compl_params[i].transfer_id =
+ odp_dma_transfer_id_alloc(config->dma_config.handle);
+
+ if (compl_params[i].transfer_id == ODP_DMA_TRANSFER_ID_INVALID) {
+ ODPH_ERR("Error creating DMA transfer ID.\n");
+ return -1;
+ }
+ }
+
+ compl_params[i].user_ptr = NULL;
+ }
+
+ return 0;
+}
+
+static void build_wait_list(const test_config_t *config, odp_dma_compl_param_t compl_params[],
+ compl_wait_entry_t list[])
+{
+ int last_ev_idx, has_events = 0;
+
+ memset(list, 0, sizeof(*list) * config->dma_rounds);
+
+ for (int i = 0, j = 0, k = 0; i < config->dma_rounds; ++i) {
+ if (config->compl_modes.modes[i] == ODP_DMA_COMPL_EVENT) {
+ compl_wait_entry_t entry = { .type = ODP_DMA_COMPL_EVENT };
+
+ list[j] = entry;
+ ++j;
+
+ for (; k < i; ++k) {
+ entry.type = ODP_DMA_COMPL_POLL;
+ entry.id = compl_params[k].transfer_id;
+ list[j++] = entry;
+ }
+
+ ++k;
+ last_ev_idx = i;
+ has_events = 1;
+ }
+ }
+
+ last_ev_idx = has_events ? last_ev_idx + 1 : 0;
+
+ for (int i = last_ev_idx; i < config->dma_rounds; ++i) {
+ compl_wait_entry_t entry = { .type = ODP_DMA_COMPL_POLL,
+ .id = compl_params[i].transfer_id };
+ list[i] = entry;
+ }
+}
+
+static inline int wait_dma_transfers_ready(test_config_t *config, compl_wait_entry_t list[])
+{
+ odp_event_t ev;
+ const uint64_t wait_time = odp_schedule_wait_time(ODP_TIME_SEC_IN_NS * 5U);
+ int done = 0;
+
+ for (int i = 0; i < config->dma_rounds; ++i) {
+ if (list[i].type == ODP_DMA_COMPL_EVENT) {
+ ev = odp_schedule(NULL, wait_time);
+
+ if (ev == ODP_EVENT_INVALID) {
+ ODPH_ERR("Error waiting event completion.\n");
+ return -1;
+ }
+ } else {
+ while (1) {
+ done = odp_dma_transfer_done(config->dma_config.handle, list[i].id,
+ NULL);
+
+ if (done > 0)
+ break;
+
+ if (done == 0)
+ continue;
+
+ ODPH_ERR("Error waiting poll completion.\n");
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+static void free_dma_completion_events(test_config_t *config, odp_dma_compl_param_t compl_params[])
+{
+ for (int i = 0; i < config->dma_rounds; ++i)
+ if (config->compl_modes.modes[i] == ODP_DMA_COMPL_EVENT &&
+ compl_params[i].event != ODP_EVENT_INVALID)
+ odp_dma_compl_free(odp_dma_compl_from_event(compl_params[i].event));
+}
+
+static void free_dma_transfer_ids(test_config_t *config, odp_dma_compl_param_t compl_params[])
+{
+ for (int i = 0; i < config->dma_rounds; ++i)
+ if (config->compl_modes.modes[i] == ODP_DMA_COMPL_POLL &&
+ compl_params[i].transfer_id != ODP_DMA_TRANSFER_ID_INVALID)
+ odp_dma_transfer_id_free(config->dma_config.handle,
+ compl_params[i].transfer_id);
+}
+
+static int run_dma_async_transfer(test_config_t *config)
+{
+ odp_dma_transfer_param_t trs_params[config->dma_rounds];
+ uint32_t trs_lengths[config->dma_rounds];
+ odp_dma_compl_param_t compl_params[config->dma_rounds];
+ int ret = 0;
+ compl_wait_entry_t compl_wait_list[config->dma_rounds];
+ odp_time_t start, end;
+ uint32_t num_rounds = config->num_rounds, offset;
+
+ config->test_case_api.trs_base_fn(config, trs_params, trs_lengths);
+
+ if (configure_dma_completion_params(config, compl_params)) {
+ ret = -1;
+ goto out_compl_evs;
+ }
+
+ build_wait_list(config, compl_params, compl_wait_list);
+ start = odp_time_local_strict();
+
+ while (num_rounds--) {
+ offset = 0U;
+
+ for (int i = 0; i < config->dma_rounds; ++i) {
+ config->test_case_api.trs_dyn_fn(config, offset, trs_lengths[i]);
+
+ if (odp_dma_transfer_start(config->dma_config.handle, &trs_params[i],
+ &compl_params[i]) <= 0) {
+ ODPH_ERR("Error starting an async DMA transfer.\n");
+ ret = -1;
+ goto out_trs_ids;
+ }
+
+ offset += trs_lengths[i];
+ }
+
+ if (wait_dma_transfers_ready(config, compl_wait_list)) {
+ ODPH_ERR("Error finishing an async DMA transfer.\n");
+ ret = -1;
+ goto out_trs_ids;
+ }
+ }
+
+ end = odp_time_local_strict();
+ print_results(config, odp_time_diff_ns(end, start));
+
+out_compl_evs:
+ free_dma_completion_events(config, compl_params);
+
+out_trs_ids:
+ free_dma_transfer_ids(config, compl_params);
+ return ret;
+}
+
+static void free_dma_event_completion(test_config_t *config)
+{
+ if (config->dma_config.compl_q != ODP_QUEUE_INVALID)
+ (void)odp_queue_destroy(config->dma_config.compl_q);
+
+ if (config->dma_config.pool != ODP_POOL_INVALID)
+ (void)odp_pool_destroy(config->dma_config.pool);
+}
+
+static int run_dma_async(test_config_t *config)
+{
+ const int is_event_compl = config->compl_modes.compl_mask & ODP_DMA_COMPL_EVENT;
+ int ret = 0;
+
+ if (is_event_compl)
+ if (configure_dma_event_completion(config)) {
+ ret = -1;
+ goto out;
+ }
+
+ if (run_dma_async_transfer(config))
+ ret = -1;
+
+out:
+ if (is_event_compl)
+ free_dma_event_completion(config);
+
+ return ret;
+}
+
+static void setup_test_case_api(test_config_t *config)
+{
+ switch (config->seg_type) {
+ case TYPE_PKT:
+ config->test_case_api.setup_fn = setup_packet_segments;
+ config->test_case_api.trs_base_fn = configure_packet_dma_transfer_base;
+ config->test_case_api.trs_dyn_fn = configure_packet_dma_transfer_dynamic;
+ config->test_case_api.verify_fn = verify_packet_transfer;
+ config->test_case_api.free_fn = free_packets;
+ break;
+ case TYPE_MEM:
+ config->test_case_api.setup_fn = setup_memory_segments;
+ config->test_case_api.trs_base_fn = configure_address_dma_transfer_base;
+ config->test_case_api.trs_dyn_fn = configure_address_dma_transfer_dynamic;
+ config->test_case_api.verify_fn = verify_memory_transfer;
+ config->test_case_api.free_fn = free_memory;
+ break;
+ default:
+ break;
+ }
+
+ config->test_case_api.run_fn = config->trs_type == TRS_TYPE_SYNC ?
+ run_dma_sync :
+ run_dma_async;
+}
+
+static int configure_dma_session(test_config_t *config)
+{
+ const odp_dma_param_t params = { .direction = ODP_DMA_MAIN_TO_MAIN,
+ .type = ODP_DMA_TYPE_COPY,
+ .compl_mode_mask = config->compl_modes.compl_mask,
+ .mt_mode = ODP_DMA_MT_SERIAL,
+ .order = ODP_DMA_ORDER_NONE };
+
+ config->dma_config.handle = odp_dma_create("odp_dma_perf", &params);
+
+ if (config->dma_config.handle == ODP_DMA_INVALID) {
+ ODPH_ERR("Error creating DMA session.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static void free_dma_session(test_config_t *config)
+{
+ if (config->dma_config.handle != ODP_DMA_INVALID)
+ (void)odp_dma_destroy(config->dma_config.handle);
+}
+
+int main(int argc, char **argv)
+{
+ odph_helper_options_t odph_opts;
+ test_config_t test_config;
+ odp_instance_t odp_instance;
+ int ret = EXIT_SUCCESS;
+
+ argc = odph_parse_options(argc, argv);
+
+ if (odph_options(&odph_opts)) {
+ ODPH_ERR("Error while reading ODP helper options, exiting.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (parse_options(argc, argv, &test_config))
+ exit(EXIT_FAILURE);
+
+ if (odp_init_global(&odp_instance, NULL, NULL)) {
+ ODPH_ERR("ODP global init failed, exiting.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (odp_init_local(odp_instance, ODP_THREAD_CONTROL)) {
+ ODPH_ERR("ODP local init failed, exiting.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (check_capabilities(&test_config)) {
+ ODPH_ERR("Unsupported scenario attempted, exiting.\n");
+ ret = EXIT_NOT_SUP;
+ goto out_odp;
+ }
+
+ setup_test_case_api(&test_config);
+
+ if (configure_dma_session(&test_config)) {
+ ret = EXIT_FAILURE;
+ goto out_dma;
+ }
+
+ if (test_config.test_case_api.setup_fn(&test_config)) {
+ ret = EXIT_FAILURE;
+ goto out_test_case;
+ }
+
+ if (test_config.test_case_api.run_fn(&test_config) ||
+ test_config.test_case_api.verify_fn(&test_config))
+ ret = EXIT_FAILURE;
+
+out_test_case:
+ test_config.test_case_api.free_fn(&test_config);
+
+out_dma:
+ free_dma_session(&test_config);
+
+out_odp:
+ if (odp_term_local()) {
+ ODPH_ERR("ODP local terminate failed, exiting.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (odp_term_global(odp_instance)) {
+ ODPH_ERR("ODP global terminate failed, exiting.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ return ret;
+}
diff --git a/test/performance/odp_dma_perf_run.sh b/test/performance/odp_dma_perf_run.sh
new file mode 100755
index 000000000..dc314d400
--- /dev/null
+++ b/test/performance/odp_dma_perf_run.sh
@@ -0,0 +1,100 @@
+#!/bin/sh
+#
+# Copyright (c) 2022, Nokia
+# All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+TEST_DIR="${TEST_DIR:-$(dirname $0)}"
+BIN_NAME=odp_dma_perf
+SEG_SIZE=1024
+ROUNDS=1000
+TESTS_RUN=0
+
+check_result()
+{
+ if [ $1 -eq 0 ]; then
+ TESTS_RUN=`expr $TESTS_RUN + 1`
+ elif [ $1 -eq 1 ]; then
+ echo "Test FAILED, exiting"
+ exit 1
+ else
+ echo "Test SKIPPED"
+ fi
+}
+
+echo "odp_dma_perf: synchronous transfer 1"
+echo "===================================="
+
+${TEST_DIR}/${BIN_NAME}${EXEEXT} -t 0 -g 0 -i 6 -s $SEG_SIZE -T 0 -r $ROUNDS
+
+check_result $?
+
+echo "odp_dma_perf: synchronous transfer 2"
+echo "===================================="
+
+${TEST_DIR}/${BIN_NAME}${EXEEXT} -t 0 -g 1 -i 6 -s $SEG_SIZE -T 0 -r $ROUNDS
+
+check_result $?
+
+echo "odp_dma_perf: synchronous transfer 3"
+echo "===================================="
+
+${TEST_DIR}/${BIN_NAME}${EXEEXT} -t 0 -g 0 -i 6 -s $SEG_SIZE -T 1 -r $ROUNDS
+
+check_result $?
+
+echo "odp_dma_perf: synchronous transfer 4"
+echo "===================================="
+
+${TEST_DIR}/${BIN_NAME}${EXEEXT} -t 0 -g 1 -i 6 -s $SEG_SIZE -T 1 -r $ROUNDS
+
+check_result $?
+
+echo "odp_dma_perf: asynchronous transfer 1"
+echo "====================================="
+
+${TEST_DIR}/${BIN_NAME}${EXEEXT} -t 1 -g 0 -i 6 -s $SEG_SIZE -T 0 -m 0 -r $ROUNDS
+
+check_result $?
+
+echo "odp_dma_perf: asynchronous transfer 2"
+echo "====================================="
+
+${TEST_DIR}/${BIN_NAME}${EXEEXT} -t 1 -g 1 -i 6 -s $SEG_SIZE -T 0 -m 0,0,0,0,0,0 -r $ROUNDS
+
+check_result $?
+
+echo "odp_dma_perf: asynchronous transfer 3"
+echo "====================================="
+
+${TEST_DIR}/${BIN_NAME}${EXEEXT} -t 1 -g 1 -i 6 -s $SEG_SIZE -T 0 -m 0,0,0,0,0,1 -r $ROUNDS
+
+check_result $?
+
+echo "odp_dma_perf: asynchronous transfer 4"
+echo "====================================="
+
+${TEST_DIR}/${BIN_NAME}${EXEEXT} -t 1 -g 0 -i 6 -s $SEG_SIZE -T 1 -m 0 -r $ROUNDS
+
+check_result $?
+
+echo "odp_dma_perf: asynchronous transfer 5"
+echo "====================================="
+
+${TEST_DIR}/${BIN_NAME}${EXEEXT} -t 1 -g 1 -i 6 -s $SEG_SIZE -T 1 -m 0,0,0,0,0,0 -r $ROUNDS
+
+check_result $?
+
+echo "odp_dma_perf: asynchronous transfer 6"
+echo "====================================="
+
+${TEST_DIR}/${BIN_NAME}${EXEEXT} -t 1 -g 1 -i 6 -s $SEG_SIZE -T 1 -m 0,0,0,0,0,1 -r $ROUNDS
+
+check_result $?
+
+if [ $TESTS_RUN -eq 0 ]; then
+ exit 77
+fi
+
+exit 0
diff --git a/test/performance/odp_lock_perf.c b/test/performance/odp_lock_perf.c
index dfc814657..e1c0c039e 100644
--- a/test/performance/odp_lock_perf.c
+++ b/test/performance/odp_lock_perf.c
@@ -23,6 +23,12 @@
#define TEST_INFO(name, test, validate) { name, test, validate }
+typedef enum repeat_t {
+ REPEAT_NO,
+ REPEAT_UNTIL_FAIL,
+ REPEAT_FOREVER,
+} repeat_t;
+
typedef enum place_t {
PLACE_PACK,
PLACE_SEPARATE,
@@ -34,6 +40,7 @@ typedef struct test_options_t {
uint32_t num_cpu;
uint32_t type;
uint64_t num_round;
+ repeat_t repeat;
uint32_t num_counter;
place_t place;
} test_options_t;
@@ -43,6 +50,7 @@ static test_options_t test_options_def = {
.num_cpu = 0,
.type = 0,
.num_round = 100000,
+ .repeat = REPEAT_NO,
.num_counter = 2,
.place = 2,
};
@@ -201,13 +209,18 @@ static inline void test_ticketlock(test_global_t *g, uint64_t **counter,
static inline int validate_generic(test_global_t *g, uint64_t **counter,
uint32_t num_counter)
{
+ int status = 0;
uint64_t total = (uint64_t)g->test_options.num_cpu * g->test_options.num_round;
- for (uint32_t i = 0; i < num_counter; i++)
- if (*counter[i] != total)
- return 1;
+ for (uint32_t i = 0; i < num_counter; i++) {
+ if (*counter[i] != total) {
+ status = 1;
+ ODPH_ERR("Error: Counter %d value %" PRIu64 " expected %" PRIu64 "\n",
+ i, *counter[i], total);
+ }
+ }
- return 0;
+ return status;
}
static void print_usage(void)
@@ -225,6 +238,10 @@ static void print_usage(void)
" 4: odp_rwlock_recursive_t\n"
" 5: odp_ticketlock_t\n"
" -r, --num_round Number of rounds (default %" PRIu64 ")\n"
+ " -e, --repeat Repeat the tests (default %u)\n"
+ " 0: no repeat, run the tests once\n"
+ " 1: repeat until failure\n"
+ " 2: repeat forever\n"
" -o, --num_counter Number of counters (default %u)\n"
" -p, --place Counter placement (default %d)\n"
" 0: pack to same cache line with lock\n"
@@ -233,8 +250,8 @@ static void print_usage(void)
" -h, --help This help\n"
"\n",
DEFAULT_MAX_WORKERS, test_options_def.type,
- test_options_def.num_round, test_options_def.num_counter,
- test_options_def.place);
+ test_options_def.num_round, test_options_def.repeat,
+ test_options_def.num_counter, test_options_def.place);
}
static void print_info(test_options_t *test_options)
@@ -243,6 +260,7 @@ static void print_info(test_options_t *test_options)
printf(" num cpu %u\n", test_options->num_cpu);
printf(" type %u\n", test_options->type);
printf(" num rounds %" PRIu64 "\n", test_options->num_round);
+ printf(" repeat %u\n", test_options->repeat);
printf(" num counters %u\n", test_options->num_counter);
printf(" place %u\n", test_options->place);
printf("\n\n");
@@ -258,13 +276,14 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options)
{ "num_cpu", required_argument, NULL, 'c' },
{ "type", required_argument, NULL, 't' },
{ "num_round", required_argument, NULL, 'r' },
+ { "repeat", required_argument, NULL, 'e' },
{ "num_counter", required_argument, NULL, 'o' },
{ "place", required_argument, NULL, 'p' },
{ "help", no_argument, NULL, 'h' },
{ NULL, 0, NULL, 0 }
};
- static const char *shortopts = "+c:t:r:o:p:h";
+ static const char *shortopts = "+c:t:r:e:o:p:h";
*test_options = test_options_def;
@@ -284,6 +303,9 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options)
case 'r':
test_options->num_round = atoll(optarg);
break;
+ case 'e':
+ test_options->repeat = atoi(optarg);
+ break;
case 'o':
test_options->num_counter = atoi(optarg);
break;
@@ -614,34 +636,40 @@ int main(int argc, char **argv)
/* Loop all test cases */
num_tests = sizeof(test_suite) / sizeof(test_suite[0]);
- for (i = 0; i < num_tests; i++) {
- if (test_options.type && test_options.type != (uint32_t)i + 1)
- continue;
+ while (1) {
+ for (i = 0; i < num_tests; i++) {
+ if (test_options.type && test_options.type != (uint32_t)i + 1)
+ continue;
- test_global->cur_type = i;
+ test_global->cur_type = i;
- /* Initialize test variables */
- if (init_test(test_global, test_suite[i].name)) {
- ODPH_ERR("Failed to initialize test.\n");
- exit(EXIT_FAILURE);
- }
+ /* Initialize test variables */
+ if (init_test(test_global, test_suite[i].name)) {
+ ODPH_ERR("Failed to initialize test.\n");
+ exit(EXIT_FAILURE);
+ }
- /* Start workers */
- if (start_workers(test_global, instance, test_suite[i].test_fn))
- exit(EXIT_FAILURE);
+ /* Start workers */
+ if (start_workers(test_global, instance, test_suite[i].test_fn))
+ exit(EXIT_FAILURE);
- /* Wait workers to exit */
- odph_thread_join(test_global->thread_tbl,
- test_global->test_options.num_cpu);
+ /* Wait workers to exit */
+ odph_thread_join(test_global->thread_tbl,
+ test_global->test_options.num_cpu);
- print_stat(test_global);
+ print_stat(test_global);
- /* Validate test results */
- if (validate_results(test_global, test_suite[i].validate_fn)) {
- ODPH_ERR("Test %s result validation failed.\n",
- test_suite[i].name);
- exit(EXIT_FAILURE);
+ /* Validate test results */
+ if (validate_results(test_global, test_suite[i].validate_fn)) {
+ ODPH_ERR("Test %s result validation failed.\n",
+ test_suite[i].name);
+ if (test_options.repeat != REPEAT_FOREVER)
+ exit(EXIT_FAILURE);
+ }
}
+
+ if (test_options.repeat == REPEAT_NO)
+ break;
}
if (odp_shm_free(shm)) {
diff --git a/test/performance/odp_pktio_ordered.c b/test/performance/odp_pktio_ordered.c
index e35386d52..9a4e3013f 100644
--- a/test/performance/odp_pktio_ordered.c
+++ b/test/performance/odp_pktio_ordered.c
@@ -140,6 +140,7 @@ typedef struct {
int time; /**< Time in seconds to run. */
int accuracy; /**< Statistics print interval */
char *if_str; /**< Storage for interface names */
+ int promisc_mode; /**< Promiscuous mode enabled */
} appl_args_t;
/**
@@ -611,6 +612,20 @@ static int create_pktio(const char *dev, int idx, int num_rx, int num_tx,
config.parser.layer = ODP_PROTO_LAYER_L2;
odp_pktio_config(pktio, &config);
+ if (gbl_args->appl.promisc_mode) {
+ if (!capa.set_op.op.promisc_mode) {
+ ODPH_ERR("Error: promisc mode set not supported %s\n",
+ dev);
+ return -1;
+ }
+
+ /* Enable promisc mode */
+ if (odp_pktio_promisc_mode_set(pktio, true)) {
+ ODPH_ERR("Error: promisc mode enable failed %s\n", dev);
+ return -1;
+ }
+ }
+
odp_pktin_queue_param_init(&pktin_param);
odp_pktout_queue_param_init(&pktout_param);
@@ -823,6 +838,7 @@ static void usage(char *progname)
" -a, --accuracy <number> Statistics print interval in seconds\n"
" (default is 1 second).\n"
" -d, --dst_addr Destination addresses (comma-separated, no spaces)\n"
+ " -P, --promisc_mode Enable promiscuous mode.\n"
" -h, --help Display help and exit.\n\n"
"\n", NO_PATH(progname), NO_PATH(progname), MAX_PKTIOS
);
@@ -853,11 +869,12 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
{"num_rx_q", required_argument, NULL, 'r'},
{"num_flows", required_argument, NULL, 'f'},
{"extra_input", required_argument, NULL, 'e'},
+ {"promisc_mode", no_argument, NULL, 'P'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};
- static const char *shortopts = "+c:t:a:i:m:d:r:f:e:h";
+ static const char *shortopts = "+c:t:a:i:m:d:r:f:e:Ph";
appl_args->time = 0; /* loop forever if time to run is 0 */
appl_args->accuracy = DEF_STATS_INT;
@@ -865,6 +882,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
appl_args->num_rx_q = DEF_NUM_RX_QUEUES;
appl_args->num_flows = DEF_NUM_FLOWS;
appl_args->extra_rounds = DEF_EXTRA_ROUNDS;
+ appl_args->promisc_mode = 0;
while (1) {
opt = getopt_long(argc, argv, shortopts, longopts, &long_index);
@@ -978,6 +996,9 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
case 'e':
appl_args->extra_rounds = atoi(optarg);
break;
+ case 'P':
+ appl_args->promisc_mode = 1;
+ break;
case 'h':
usage(argv[0]);
exit(EXIT_SUCCESS);
@@ -1018,14 +1039,24 @@ static void print_info(char *progname, appl_args_t *appl_args)
odp_sys_info_print();
- printf("Running ODP appl: \"%s\"\n"
- "-----------------\n"
- "IF-count: %i\n"
- "Using IFs: ",
+ printf("%s options\n"
+ "-------------------------\n"
+ "IF-count: %i\n"
+ "Using IFs: ",
progname, appl_args->if_count);
for (i = 0; i < appl_args->if_count; ++i)
printf(" %s", appl_args->if_names[i]);
- printf("\n\n");
+ printf("\n"
+ "Input queues: %d\n"
+ "Mode: %s\n"
+ "Flows: %d\n"
+ "Extra rounds: %d\n"
+ "Promisc mode: %s\n", appl_args->num_rx_q,
+ (appl_args->in_mode == SCHED_ATOMIC) ? "PKTIN_SCHED_ATOMIC" :
+ (appl_args->in_mode == SCHED_PARALLEL ? "PKTIN_SCHED_PARALLEL" :
+ "PKTIN_SCHED_ORDERED"), appl_args->num_flows,
+ appl_args->extra_rounds, appl_args->promisc_mode ?
+ "enabled" : "disabled");
fflush(NULL);
}
@@ -1069,7 +1100,6 @@ int main(int argc, char *argv[])
int if_count;
int ret;
int num_workers;
- int in_mode;
uint32_t queue_size, pool_size;
/* Let helper collect its own arguments (e.g. --odph_proc) */
@@ -1263,18 +1293,6 @@ int main(int argc, char *argv[])
}
}
- in_mode = gbl_args->appl.in_mode;
- printf("\nApplication parameters\n"
- "----------------------\n"
- "Input queues: %d\n"
- "Mode: %s\n"
- "Flows: %d\n"
- "Extra rounds: %d\n\n", gbl_args->appl.num_rx_q,
- (in_mode == SCHED_ATOMIC) ? "PKTIN_SCHED_ATOMIC" :
- (in_mode == SCHED_PARALLEL ? "PKTIN_SCHED_PARALLEL" :
- "PKTIN_SCHED_ORDERED"), gbl_args->appl.num_flows,
- gbl_args->appl.extra_rounds);
-
memset(thread_tbl, 0, sizeof(thread_tbl));
stats = gbl_args->stats;
diff --git a/test/performance/odp_random.c b/test/performance/odp_random.c
index 7083349ff..622a58c65 100644
--- a/test/performance/odp_random.c
+++ b/test/performance/odp_random.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2021, Nokia
+/* Copyright (c) 2021-2022, Nokia
*
* All rights reserved.
*
@@ -40,7 +40,7 @@ static void print_usage(void)
" -t, --threads Number of worker threads (default %u)\n"
" -s, --size Size of buffer in bytes (default %u)\n"
" -r, --rounds Number of test rounds (default %u)\n"
- " Rounded down to nearest multiple of 8\n"
+ " Divided by 100 for ODP_RANDOM_TRUE\n"
" -h, --help This help\n"
"\n",
options_def.num_threads, options_def.size, options_def.rounds);
@@ -116,6 +116,16 @@ static test_shm_t *shm_lookup(void)
return shm;
}
+static uint32_t type_rounds(odp_random_kind_t type)
+{
+ switch (type) {
+ case ODP_RANDOM_TRUE:
+ return options.rounds / 100;
+ default:
+ return options.rounds;
+ }
+}
+
static int test_random(void *p)
{
(void)p;
@@ -124,6 +134,7 @@ static int test_random(void *p)
const unsigned long page = ODP_PAGE_SIZE;
odp_time_t start;
uint64_t nsec;
+ uint32_t rounds;
test_shm_t *shm = shm_lookup();
if (!shm) {
@@ -131,6 +142,8 @@ static int test_random(void *p)
exit(EXIT_FAILURE);
}
+ rounds = type_rounds(shm->type);
+
/* One extra page for alignment. */
buf = (uint8_t *)malloc(options.size + page);
@@ -145,7 +158,7 @@ static int test_random(void *p)
odp_barrier_wait(&shm->barrier);
start = odp_time_local();
- for (uint32_t i = 0; i < options.rounds; i++) {
+ for (uint32_t i = 0; i < rounds; i++) {
uint32_t pos = 0;
while (pos < options.size) {
@@ -178,6 +191,7 @@ static int test_random_test(void *p)
odp_time_t start;
uint64_t nsec;
uint64_t seed = 0;
+ uint32_t rounds;
test_shm_t *shm = shm_lookup();
if (!shm) {
@@ -185,6 +199,8 @@ static int test_random_test(void *p)
exit(EXIT_FAILURE);
}
+ rounds = type_rounds(shm->type);
+
/* One extra page for alignment. */
buf = (uint8_t *)malloc(options.size + page);
@@ -199,7 +215,7 @@ static int test_random_test(void *p)
odp_barrier_wait(&shm->barrier);
start = odp_time_local();
- for (uint32_t i = 0; i < options.rounds; i++) {
+ for (uint32_t i = 0; i < rounds; i++) {
uint32_t pos = 0;
while (pos < options.size) {
@@ -288,11 +304,13 @@ static void test_type(odp_instance_t instance, test_shm_t *shm,
printf("odp_random_test_data\n");
}
+ uint32_t rounds = type_rounds(type);
+
printf("--------------------\n");
printf("threads: %d size: %u B rounds: %u ", options.num_threads,
- options.size, options.rounds);
+ options.size, rounds);
mb = (uint64_t)options.num_threads * (uint64_t)options.size *
- (uint64_t)options.rounds;
+ (uint64_t)rounds;
mb /= MB;
seconds = (double)nsec / (double)ODP_TIME_SEC_IN_NS;
printf("MB: %.3f seconds: %.3f ", mb, seconds);
@@ -336,7 +354,7 @@ int main(int argc, char **argv)
test_shm_t *shm = NULL;
odp_shm_t shm_hdl = odp_shm_reserve(shm_name, sizeof(test_shm_t), 64,
- ODP_SHM_SW_ONLY);
+ 0);
if (shm_hdl != ODP_SHM_INVALID)
shm = (test_shm_t *)odp_shm_addr(shm_hdl);
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,