aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2023-08-08 11:02:27 +0300
committerGitHub <noreply@github.com>2023-08-08 11:02:27 +0300
commitde97121a2e3afa072f7c51a0570f4b3bed0236c2 (patch)
tree1f34d2767951f54d11f0b9c8d48b0db04490d2c1
parent2b359fc1759726826cf4e2afddbd0b7e39fab4c7 (diff)
parent1200684b94bf18ae98ba63fb49e9cda546b4832a (diff)
Merge ODP v1.41.1.0v1.41.1.0_DPDK_22.11
Merge ODP linux-generic v1.41.1.0 into linux-dpdk.
-rw-r--r--.github/workflows/ci-pipeline-arm64.yml19
-rw-r--r--.github/workflows/ci-pipeline.yml17
-rw-r--r--CHANGELOG65
-rw-r--r--DEPENDENCIES50
-rw-r--r--configure.ac2
-rw-r--r--example/timer/odp_timer_accuracy.c57
-rw-r--r--example/timer/odp_timer_test.c4
-rw-r--r--helper/include/odp/helper/ipsec.h2
-rw-r--r--helper/ipsec.c42
-rw-r--r--include/Makefile.am9
-rw-r--r--include/odp/api/abi-default/packet_types.h50
-rw-r--r--include/odp/api/abi-default/time.h37
-rw-r--r--include/odp/api/abi-default/time_types.h49
-rw-r--r--include/odp/api/spec/classification.h27
-rw-r--r--include/odp/api/spec/comp.h4
-rw-r--r--include/odp/api/spec/dma.h21
-rw-r--r--include/odp/api/spec/dma_types.h17
-rw-r--r--include/odp/api/spec/event.h16
-rw-r--r--include/odp/api/spec/init.h56
-rw-r--r--include/odp/api/spec/packet.h100
-rw-r--r--include/odp/api/spec/packet_io.h14
-rw-r--r--include/odp/api/spec/packet_io_stats.h60
-rw-r--r--include/odp/api/spec/packet_io_types.h80
-rw-r--r--include/odp/api/spec/packet_types.h97
-rw-r--r--include/odp/api/spec/pool.h33
-rw-r--r--include/odp/api/spec/pool_types.h54
-rw-r--r--include/odp/api/spec/schedule.h7
-rw-r--r--include/odp/api/spec/shared_memory.h2
-rw-r--r--include/odp/api/spec/stash_types.h4
-rw-r--r--include/odp/api/spec/time.h33
-rw-r--r--include/odp/api/spec/time_types.h63
-rw-r--r--include/odp/api/spec/timer.h64
-rw-r--r--include/odp/api/spec/timer_types.h63
-rw-r--r--include/odp/api/spec/traffic_mngr.h10
-rw-r--r--include/odp/api/time.h1
-rw-r--r--include/odp/api/time_types.h28
-rw-r--r--include/odp/arch/arm32-linux/odp/api/abi/time_types.h7
-rw-r--r--include/odp/arch/arm64-linux/odp/api/abi/time_types.h7
-rw-r--r--include/odp/arch/default-linux/odp/api/abi/time_types.h7
-rw-r--r--include/odp/arch/power64-linux/odp/api/abi/time_types.h7
-rw-r--r--include/odp/arch/x86_32-linux/odp/api/abi/time_types.h7
-rw-r--r--include/odp/arch/x86_64-linux/odp/api/abi/time_types.h7
-rw-r--r--platform/linux-dpdk/Makefile.am1
l---------platform/linux-dpdk/include-abi/odp/api/abi/time_types.h1
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/packet_inline_types.h7
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/packet_inlines.h2
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/time_inlines.h7
-rw-r--r--platform/linux-dpdk/include/odp_event_internal.h3
-rw-r--r--platform/linux-dpdk/include/odp_packet_internal.h15
-rw-r--r--platform/linux-dpdk/include/odp_packet_io_internal.h1
-rw-r--r--platform/linux-dpdk/odp_init.c23
-rw-r--r--platform/linux-dpdk/odp_packet.c36
-rw-r--r--platform/linux-dpdk/odp_packet_dpdk.c128
-rw-r--r--platform/linux-dpdk/odp_pool.c60
-rw-r--r--platform/linux-dpdk/odp_timer.c93
-rw-r--r--platform/linux-generic/Makefile.am1
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/time.h4
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/time_types.h7
-rw-r--r--platform/linux-generic/include/odp/api/plat/event_inlines.h29
-rw-r--r--platform/linux-generic/include/odp/api/plat/packet_inline_types.h7
-rw-r--r--platform/linux-generic/include/odp/api/plat/packet_inlines.h2
-rw-r--r--platform/linux-generic/include/odp/api/plat/time_inlines.h4
-rw-r--r--platform/linux-generic/include/odp_classification_internal.h158
-rw-r--r--platform/linux-generic/include/odp_packet_io_internal.h1
-rw-r--r--platform/linux-generic/odp_dma.c15
-rw-r--r--platform/linux-generic/odp_init.c20
-rw-r--r--platform/linux-generic/odp_packet.c30
-rw-r--r--platform/linux-generic/odp_packet_io.c306
-rw-r--r--platform/linux-generic/odp_pool.c116
-rw-r--r--platform/linux-generic/odp_queue_lf.c2
-rw-r--r--platform/linux-generic/odp_timer.c137
-rw-r--r--platform/linux-generic/pktio/dpdk.c178
-rw-r--r--platform/linux-generic/pktio/ipc.c12
-rw-r--r--platform/linux-generic/pktio/loop.c30
-rw-r--r--platform/linux-generic/pktio/pcap.c25
-rw-r--r--platform/linux-generic/pktio/socket.c18
-rw-r--r--platform/linux-generic/pktio/socket_mmap.c28
-rw-r--r--platform/linux-generic/pktio/socket_xdp.c612
-rw-r--r--platform/linux-generic/pktio/tap.c22
-rw-r--r--platform/linux-generic/test/validation/api/shmem/shmem_odp2.c25
-rw-r--r--test/common/odp_cunit_common.c11
-rw-r--r--test/common/odp_cunit_common.h1
-rw-r--r--test/performance/.gitignore1
-rw-r--r--test/performance/Makefile.am2
-rw-r--r--test/performance/odp_bench_timer.c871
-rw-r--r--test/performance/odp_dma_perf.c2021
-rwxr-xr-xtest/performance/odp_dma_perf_run.sh65
-rw-r--r--test/performance/odp_ipsec.c2
-rw-r--r--test/performance/odp_ipsecfwd.c88
-rw-r--r--test/performance/odp_l2fwd.c18
-rw-r--r--test/performance/odp_sched_pktio.c4
-rw-r--r--test/performance/odp_timer_perf.c10
-rw-r--r--test/validation/api/Makefile.am1
-rw-r--r--test/validation/api/atomic/atomic.c14
-rw-r--r--test/validation/api/barrier/barrier.c14
-rw-r--r--test/validation/api/buffer/buffer.c13
-rw-r--r--test/validation/api/classification/odp_classification_tests.c2
-rw-r--r--test/validation/api/comp/comp.c30
-rw-r--r--test/validation/api/crypto/Makefile.am8
-rw-r--r--test/validation/api/crypto/crypto_op_test.c571
-rw-r--r--test/validation/api/crypto/crypto_op_test.h41
-rw-r--r--test/validation/api/crypto/odp_crypto_test_inp.c1247
-rw-r--r--test/validation/api/crypto/test_vector_defs.h3167
-rw-r--r--test/validation/api/crypto/test_vectors.h3046
-rw-r--r--test/validation/api/crypto/util.c310
-rw-r--r--test/validation/api/crypto/util.h50
-rw-r--r--test/validation/api/dma/dma.c273
-rw-r--r--test/validation/api/init/.gitignore1
-rw-r--r--test/validation/api/init/Makefile.am4
-rw-r--r--test/validation/api/init/init_main.c24
-rw-r--r--test/validation/api/ipsec/ipsec.c56
-rw-r--r--test/validation/api/lock/lock.c78
-rw-r--r--test/validation/api/packet/packet.c42
-rw-r--r--test/validation/api/pktio/parser.c39
-rw-r--r--test/validation/api/pktio/pktio.c188
-rw-r--r--test/validation/api/pool/pool.c97
-rw-r--r--test/validation/api/queue/queue.c13
-rw-r--r--test/validation/api/scheduler/scheduler.c42
-rw-r--r--test/validation/api/scheduler/scheduler_no_predef_groups.c4
-rw-r--r--test/validation/api/stash/stash.c4
-rw-r--r--test/validation/api/thread/thread.c14
-rw-r--r--test/validation/api/time/time.c263
-rw-r--r--test/validation/api/timer/timer.c268
123 files changed, 10166 insertions, 6317 deletions
diff --git a/.github/workflows/ci-pipeline-arm64.yml b/.github/workflows/ci-pipeline-arm64.yml
index 98f7cf9ac..b2a7ad042 100644
--- a/.github/workflows/ci-pipeline-arm64.yml
+++ b/.github/workflows/ci-pipeline-arm64.yml
@@ -91,6 +91,25 @@ jobs:
if: ${{ failure() }}
run: find . -name config.log -exec cat {} \;
+ Build_gcc_u23:
+ if: ${{ github.repository == 'OpenDataPlane/odp-dpdk' }}
+ runs-on: [self-hosted, ARM64]
+ env:
+ OS: ubuntu_23.04
+ strategy:
+ fail-fast: false
+ matrix:
+ cc_ver: [13]
+ conf: ['', '--enable-abi-compat']
+ steps:
+ - uses: OpenDataPlane/action-clean-up@main
+ - uses: actions/checkout@v3
+ - run: sudo docker run -i -v `pwd`:/odp --privileged --shm-size 8g -e CC="gcc-${{matrix.cc_ver}}" -e CXX="g++-${{matrix.cc_ver}}"
+ -e CONF="${{matrix.conf}}" $CONTAINER_NAMESPACE/odp-ci-${OS}-${ARCH}-native /odp/scripts/ci/build_${ARCH}.sh
+ - name: Failure log
+ if: ${{ failure() }}
+ run: find . -name config.log -exec cat {} \;
+
Build_out-of-tree:
if: ${{ github.repository == 'OpenDataPlane/odp-dpdk' }}
runs-on: [self-hosted, ARM64]
diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml
index ba41ba565..87b6d11bf 100644
--- a/.github/workflows/ci-pipeline.yml
+++ b/.github/workflows/ci-pipeline.yml
@@ -220,6 +220,23 @@ jobs:
if: ${{ failure() }}
run: find . -name config.log -exec cat {} \;
+ Build_gcc_u23:
+ runs-on: ubuntu-20.04
+ env:
+ OS: ubuntu_23.04
+ strategy:
+ fail-fast: false
+ matrix:
+ cc_ver: [13]
+ conf: ['', '--enable-abi-compat']
+ steps:
+ - uses: actions/checkout@v3
+ - run: sudo docker run -i -v `pwd`:/odp --privileged --shm-size 8g -e CC="gcc-${{matrix.cc_ver}}" -e CXX="g++-${{matrix.cc_ver}}"
+ -e CONF="${{matrix.conf}}" $CONTAINER_NAMESPACE/odp-ci-${OS}-${ARCH} /odp/scripts/ci/build_${ARCH}.sh
+ - name: Failure log
+ if: ${{ failure() }}
+ run: find . -name config.log -exec cat {} \;
+
Build_out-of-tree:
runs-on: ubuntu-20.04
steps:
diff --git a/CHANGELOG b/CHANGELOG
index f61f80a2c..76c28bb66 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,68 @@
+== OpenDataPlane (1.41.1.0)
+
+=== Backward compatible API changes
+==== DMA
+* Add `odp_dma_compl_user_area()` function which returns pointer to the user
+area configured with DMA completion event pool parameters.
+* Clarify that DMA session names don't need to be unique.
+
+==== Event
+* Add `odp_event_user_area()` function which returns a pointer to the user area
+associated with the event.
+
+==== Init
+* Add `odp_term_abnormal()` function that can be used to abnormally terminate
+an ODP application after a non-recoverable error. Depending on the
+implementation, this function may attempt to dump stack and other memory areas,
+clean up and stop HW operations and/or perform other actions helpful in
+postmortem analysis.
+
+==== Packet
+* Extend packet transmit completion (`odp_packet_tx_compl_request()`) with poll
+mode. When enabled, packet transmit completion status can be checked with
+`odp_packet_tx_compl_done()`.
+* Add `odp_packet_free_ctrl_set()` function for controlling packet output
+interface to not free a packet after transmitting it.
+* Add `odp_packet_free_ctrl()` function for reading packet's free control
+option value.
+
+==== Pool
+* Relax `odp_pool_stats()` specification to allow implementations to have some
+delay until pool statistics are updated.
+* Add new function `odp_pool_stats_selected()` for reading only selected pool
+statistic(s).
+
+==== Timer
+* Split `odp_timer_cancel()` failure reason into timing related and other
+failures.
+* Rename `odp_timer_set_t` to `odp_timer_retval_t` as it is used now for start,
+restart, and cancel operations. `odp_timer_set_t` remains as a typedef for
+backward compatibility.
+* Add `odp_timer_sample_ticks()` function that samples tick value of multiple
+timer pools simultaneously.
+* Allow implementation to place the first timer as close as it can to one period
+when starting a periodic timer with `first_tick` set to 0.
+* Clarify that periodic timer base frequency uses fractional numbers the same
+way as timer tick info (`odp_timer_tick_info_t`). Integer part specifies full
+hertz and fractional part specifies parts of a hertz.
+* Clarify that `odp_timer_periodic_capability()` call does not overwrite the
+base frequency value when 1 is returned.
+* Clarify that some implementations may support only certain periodic timer base
+frequencies and those depend on source clock frequency.
+
+=== Performance Tests
+==== bench_timer
+* Add new test application for measuring call latency of small functions in the
+timer API.
+
+==== dma_perf
+* Refactor DMA test application to support multiple worker threads. The number
+of in-flight transfers can be configured and workers will always try to keep
+that many transfers active through single or per-worker DMA session.
+
+==== ipsecfwd
+* Add support for running the application in process mode.
+
== OpenDataPlane (1.41.0.0)
=== Backward incompatible API changes
diff --git a/DEPENDENCIES b/DEPENDENCIES
index ba17d4992..7dbe86489 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -243,10 +243,8 @@ Prerequisites for building the OpenDataPlane (ODP) API
3.6 AF_XDP socket based packet I/O support (optional)
- Use AF_XDP socket for packet I/O. At the moment, only zero-copy variant is
- supported, requiring a kernel version 5.4 or higher. Additionally, if packet
- pools are to be shared between packet I/Os, kernel version of 5.10 or higher
- is required.
+ Use AF_XDP socket for packet I/O. A kernel version of 5.10 or higher is
+ required, older kernels may or may not work.
More information about XDP and AF_XDP can be found here:
https://www.kernel.org/doc/Documentation/networking/af_xdp.rst
@@ -256,7 +254,9 @@ Prerequisites for building the OpenDataPlane (ODP) API
combinations that would otherwise conform to reported capabilities.
Note that, currently, AF_XDP socket packet I/O cannot be instantiated if
- DPDK zero-copy is enabled.
+ DPDK zero-copy is enabled. Additionally, RSS hash key and flow hash
+ configuration is done based on the NIC/driver default values and should be
+ manually reconfigured with e.g. ethtool if changes are required.
3.6.1 AF_XDP socket packet I/O requirements
@@ -283,45 +283,27 @@ Prerequisites for building the OpenDataPlane (ODP) API
3.6.2 Build ODP with AF_XDP socket packet I/O support
After building and installing libxdp and libbpf, ODP can be configured to be
- built with AF_XDP support (pass PKG_CONFIG_PATH if needed).
+ built with AF_XDP support (modify PKG_CONFIG_PATH as needed).
$ ./configure --enable-xdp
-3.6.3 Running ODP with AF_XDP socket packet I/O
+3.6.3 Running ODP with AF_XDP socket packet I/O with Mellanox NICs
- AF_XDP socket packet I/Os bind to TRX-combined queues. Based on the packet
- prosessing needs, NIC(s) of the environment should be configured
- accordingly.
-
- $ ethtool -L <if name> combined <count>
-
- For example, with four (4) TRX queues, packet processing can be divided to
- four (4) processing cores.
-
- Additionally, with some NICs (e.g. Mellanox), when zero-copy XDP is in use,
- the queue configuration is adjusted by the NIC with additional queues on top
- of the configured amount of TRX queues which are then used as the actual
- queues. This will require additional forwarding rules as otherwise packets
- do not get forwarded to the zero-copy queues.
+ AF_XDP socket packet I/Os bind to NIC TRX-combined queues. Steering packets
+ to correct input sockets is configured via NIC RSS. With some NICs
+ (e.g. Mellanox), the driver queue configuration is adjusted by the NIC with
+ additional queues on top of the configured amount of TRX queues which are
+ then used as the actual queues. This will require additional forwarding
+ rules as RSS is not possible to be configured programmatically in this case.
+ Otherwise packets do not get forwarded to the correct queues.
For example:
ethtool -N <if name> flow-type ether dst <mac of if> action 5
Would forward Ethernet frames with a given destination address to queue 5,
- which should be one of the zero-copy queues, i.e. queue index on top of the
- amount configured with "ethtool -L" option.
-
- Which queues to bind to a given interface can be controlled with an
- environment variable when starting an ODP executable:
-
- $ ODP_PKTIO_XDP_PARAMS="<if name>:<queue index> <if name>:<queue index> ..." ./<odp executable> ...
-
- parameter being a string of interface-queue index pairs, where interface and
- queue are separated by a colon and pairs separated by a whitespace. The queue
- index dictates the starting queue in case of multiple TRX queues per packet
- I/O. If no environment variable is passed, zero (0) starting queue is chosen
- for all AF_XDP interfaces.
+ which would be the first actual queue in case 5 regular combined queues
+ were configured (zero-indexing).
4.0 Packages needed to build API tests
diff --git a/configure.ac b/configure.ac
index 6fcca50cf..c397338ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@ AC_PREREQ([2.5])
##########################################################################
m4_define([odp_version_generation], [1])
m4_define([odp_version_major], [41])
-m4_define([odp_version_minor], [0])
+m4_define([odp_version_minor], [1])
m4_define([odp_version_patch], [0])
m4_define([odp_version_api],
diff --git a/example/timer/odp_timer_accuracy.c b/example/timer/odp_timer_accuracy.c
index b8c42ef1e..2400a7bf8 100644
--- a/example/timer/odp_timer_accuracy.c
+++ b/example/timer/odp_timer_accuracy.c
@@ -30,6 +30,7 @@ typedef struct timer_ctx_t {
odp_event_t event;
uint64_t nsec;
uint64_t count;
+ uint64_t first_period;
} timer_ctx_t;
typedef struct {
@@ -45,6 +46,8 @@ typedef struct {
uint64_t nsec_after_max;
uint64_t nsec_after_max_idx;
+ int tmo_tick;
+ int64_t first_tmo_diff;
int64_t nsec_final;
uint64_t num_before;
@@ -653,7 +656,7 @@ static int start_timers(test_global_t *test_global)
num_tmo = 1;
for (i = 0; i < num_tmo; i++) {
- odp_timer_set_t retval;
+ odp_timer_retval_t retval;
for (j = 0; j < burst; j++) {
timer_ctx_t *ctx = &test_global->timer_ctx[idx];
@@ -671,6 +674,9 @@ static int start_timers(test_global_t *test_global)
ctx->nsec = start_ns + nsec;
ctx->count = 0;
+ ctx->first_period = start_tick +
+ odp_timer_ns_to_tick(timer_pool,
+ test_global->period_dbl + 0.5);
start_param.freq_multiplier = test_global->opt.multiplier;
start_param.first_tick = 0;
if (nsec)
@@ -803,6 +809,14 @@ static void print_stat(test_global_t *test_global)
print_nsec_error("min", stat->nsec_before_min, res_ns, stat->nsec_before_min_idx);
print_nsec_error("max", stat->nsec_before_max, res_ns, stat->nsec_before_max_idx);
print_nsec_error("ave", ave_before, res_ns, UINT64_MAX);
+
+ if (test_global->opt.mode == MODE_PERIODIC && !test_global->opt.offset_ns) {
+ printf(" first timeout difference to one period (nsec):\n");
+ printf(" %12" PRIi64 " / %.3fx resolution, based on %s\n",
+ stat->first_tmo_diff, (double)stat->first_tmo_diff / res_ns,
+ stat->tmo_tick ? "timeout tick" : "time");
+ }
+
printf(" final timeout error (nsec):\n");
printf(" %12" PRIi64 " / %.3fx resolution\n",
stat->nsec_final, (double)stat->nsec_final / res_ns);
@@ -858,6 +872,7 @@ static void run_test(test_global_t *test_global)
test_log_t *log = test_global->log;
enum mode_e mode = test_global->opt.mode;
double period_dbl = test_global->period_dbl;
+ odp_timer_pool_t tp = test_global->timer_pool;
num = 0;
next_tmo = 1;
@@ -873,16 +888,53 @@ static void run_test(test_global_t *test_global)
tmo = odp_timeout_from_event(ev);
ctx = odp_timeout_user_ptr(tmo);
tmo_ns = ctx->nsec;
+
if (mode == MODE_PERIODIC) {
+ if (!ctx->count && !test_global->opt.offset_ns) {
+ /*
+ * If first_tick is zero, the API allows the implementation to
+ * place the timer where it can, so we have to adjust our
+ * expectation of the timeout time.
+ */
+
+ uint64_t tmo_tick = odp_timeout_tick(tmo);
+
+ if (tmo_tick) {
+ /*
+ * Adjust by the difference between one period after start
+ * time and the timeout tick.
+ */
+ stat->tmo_tick = 1;
+ stat->first_tmo_diff =
+ (int64_t)odp_timer_tick_to_ns(tp, tmo_tick) -
+ (int64_t)odp_timer_tick_to_ns(tp, ctx->first_period);
+ tmo_ns += stat->first_tmo_diff;
+ } else {
+ /*
+ * Timeout tick is not provided, so the best we can do is
+ * to just take the current time as a baseline.
+ */
+ stat->first_tmo_diff = (int64_t)time_ns - (int64_t)tmo_ns;
+ tmo_ns = ctx->nsec = time_ns;
+ }
+
+ ctx->nsec = tmo_ns;
+ }
+
/* round to closest integer number */
tmo_ns += ctx->count * period_dbl + 0.5;
ctx->count++;
}
if (i == test_global->warmup_timers) {
+ int tmo_tick = stat->tmo_tick;
+ int64_t first_tmo_diff = stat->first_tmo_diff;
+
memset(stat, 0, sizeof(*stat));
stat->nsec_before_min = UINT64_MAX;
stat->nsec_after_min = UINT64_MAX;
+ stat->tmo_tick = tmo_tick;
+ stat->first_tmo_diff = first_tmo_diff;
}
stat->nsec_final = (int64_t)time_ns - (int64_t)tmo_ns;
@@ -928,9 +980,8 @@ static void run_test(test_global_t *test_global)
/* Reset timer for next period */
odp_timer_t tim;
uint64_t nsec, tick;
- odp_timer_set_t ret;
+ odp_timer_retval_t ret;
unsigned int j;
- odp_timer_pool_t tp = test_global->timer_pool;
unsigned int retries = test_global->opt.early_retry;
uint64_t start_ns = test_global->start_ns;
uint64_t period_ns = test_global->opt.period_ns;
diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index f298c9fe8..0e3fa7346 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -51,7 +51,7 @@ typedef struct {
} test_globals_t;
/** @private Timer set status ASCII strings */
-static const char *timerset2str(odp_timer_set_t val)
+static const char *timerset2str(odp_timer_retval_t val)
{
switch (val) {
case ODP_TIMER_SUCCESS:
@@ -120,7 +120,7 @@ static void test_abs_timeouts(int thr, test_globals_t *gbls)
while (1) {
int wait = 0;
odp_event_t ev;
- odp_timer_set_t rc;
+ odp_timer_retval_t rc;
odp_timer_start_t start_param;
if (ttp) {
diff --git a/helper/include/odp/helper/ipsec.h b/helper/include/odp/helper/ipsec.h
index b149ce9ff..197c7f7e8 100644
--- a/helper/include/odp/helper/ipsec.h
+++ b/helper/include/odp/helper/ipsec.h
@@ -88,7 +88,7 @@ ODP_STATIC_ASSERT(sizeof(odph_ahhdr_t) == ODPH_AHHDR_LEN,
* @retval 0 on success
* @retval <0 on failure
*/
-int odph_ipsec_alg_check(odp_ipsec_capability_t capa,
+int odph_ipsec_alg_check(const odp_ipsec_capability_t *capa,
odp_cipher_alg_t cipher_alg,
uint32_t cipher_key_len,
odp_auth_alg_t auth_alg,
diff --git a/helper/ipsec.c b/helper/ipsec.c
index 3b54bb07f..05f8b841a 100644
--- a/helper/ipsec.c
+++ b/helper/ipsec.c
@@ -58,7 +58,7 @@ uint32_t odph_ipsec_auth_icv_len_default(odp_auth_alg_t auth_alg)
return icv_len;
}
-int odph_ipsec_alg_check(odp_ipsec_capability_t capa,
+int odph_ipsec_alg_check(const odp_ipsec_capability_t *capa,
odp_cipher_alg_t cipher_alg,
uint32_t cipher_key_len,
odp_auth_alg_t auth_alg,
@@ -71,35 +71,35 @@ int odph_ipsec_alg_check(odp_ipsec_capability_t capa,
/* Check whether requested cipher algorithm is supported */
switch (cipher_alg) {
case ODP_CIPHER_ALG_NULL:
- if (!capa.ciphers.bit.null)
+ if (!capa->ciphers.bit.null)
return -1;
break;
case ODP_CIPHER_ALG_DES:
- if (!capa.ciphers.bit.des)
+ if (!capa->ciphers.bit.des)
return -1;
break;
case ODP_CIPHER_ALG_3DES_CBC:
- if (!capa.ciphers.bit.trides_cbc)
+ if (!capa->ciphers.bit.trides_cbc)
return -1;
break;
case ODP_CIPHER_ALG_AES_CBC:
- if (!capa.ciphers.bit.aes_cbc)
+ if (!capa->ciphers.bit.aes_cbc)
return -1;
break;
case ODP_CIPHER_ALG_AES_CTR:
- if (!capa.ciphers.bit.aes_ctr)
+ if (!capa->ciphers.bit.aes_ctr)
return -1;
break;
case ODP_CIPHER_ALG_AES_GCM:
- if (!capa.ciphers.bit.aes_gcm)
+ if (!capa->ciphers.bit.aes_gcm)
return -1;
break;
case ODP_CIPHER_ALG_AES_CCM:
- if (!capa.ciphers.bit.aes_ccm)
+ if (!capa->ciphers.bit.aes_ccm)
return -1;
break;
case ODP_CIPHER_ALG_CHACHA20_POLY1305:
- if (!capa.ciphers.bit.chacha20_poly1305)
+ if (!capa->ciphers.bit.chacha20_poly1305)
return -1;
break;
default:
@@ -110,51 +110,51 @@ int odph_ipsec_alg_check(odp_ipsec_capability_t capa,
/* Check whether requested auth algorithm is supported */
switch (auth_alg) {
case ODP_AUTH_ALG_NULL:
- if (!capa.auths.bit.null)
+ if (!capa->auths.bit.null)
return -1;
break;
case ODP_AUTH_ALG_MD5_HMAC:
- if (!capa.auths.bit.md5_hmac)
+ if (!capa->auths.bit.md5_hmac)
return -1;
break;
case ODP_AUTH_ALG_SHA1_HMAC:
- if (!capa.auths.bit.sha1_hmac)
+ if (!capa->auths.bit.sha1_hmac)
return -1;
break;
case ODP_AUTH_ALG_SHA256_HMAC:
- if (!capa.auths.bit.sha256_hmac)
+ if (!capa->auths.bit.sha256_hmac)
return -1;
break;
case ODP_AUTH_ALG_SHA384_HMAC:
- if (!capa.auths.bit.sha384_hmac)
+ if (!capa->auths.bit.sha384_hmac)
return -1;
break;
case ODP_AUTH_ALG_SHA512_HMAC:
- if (!capa.auths.bit.sha512_hmac)
+ if (!capa->auths.bit.sha512_hmac)
return -1;
break;
case ODP_AUTH_ALG_AES_XCBC_MAC:
- if (!capa.auths.bit.aes_xcbc_mac)
+ if (!capa->auths.bit.aes_xcbc_mac)
return -1;
break;
case ODP_AUTH_ALG_AES_GCM:
- if (!capa.auths.bit.aes_gcm)
+ if (!capa->auths.bit.aes_gcm)
return -1;
break;
case ODP_AUTH_ALG_AES_GMAC:
- if (!capa.auths.bit.aes_gmac)
+ if (!capa->auths.bit.aes_gmac)
return -1;
break;
case ODP_AUTH_ALG_AES_CCM:
- if (!capa.auths.bit.aes_ccm)
+ if (!capa->auths.bit.aes_ccm)
return -1;
break;
case ODP_AUTH_ALG_AES_CMAC:
- if (!capa.auths.bit.aes_cmac)
+ if (!capa->auths.bit.aes_cmac)
return -1;
break;
case ODP_AUTH_ALG_CHACHA20_POLY1305:
- if (!capa.auths.bit.chacha20_poly1305)
+ if (!capa->auths.bit.chacha20_poly1305)
return -1;
break;
default:
diff --git a/include/Makefile.am b/include/Makefile.am
index cc2f17ae2..81d0253e5 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -68,6 +68,7 @@ odpapiinclude_HEADERS = \
odp/api/thrmask.h \
odp/api/ticketlock.h \
odp/api/time.h \
+ odp/api/time_types.h \
odp/api/timer.h \
odp/api/timer_types.h \
odp/api/traffic_mngr.h \
@@ -134,6 +135,7 @@ odpapispecinclude_HEADERS = \
odp/api/spec/thrmask.h \
odp/api/spec/ticketlock.h \
odp/api/spec/time.h \
+ odp/api/spec/time_types.h \
odp/api/spec/timer.h \
odp/api/spec/timer_types.h \
odp/api/spec/traffic_mngr.h
@@ -193,6 +195,7 @@ odpapiabidefaultinclude_HEADERS = \
odp/api/abi-default/thrmask.h \
odp/api/abi-default/ticketlock.h \
odp/api/abi-default/time.h \
+ odp/api/abi-default/time_types.h \
odp/api/abi-default/timer.h \
odp/api/abi-default/timer_types.h \
odp/api/abi-default/traffic_mngr.h \
@@ -253,6 +256,7 @@ odpapiabiarchinclude_HEADERS = \
odp/arch/arm32-linux/odp/api/abi/thrmask.h \
odp/arch/arm32-linux/odp/api/abi/ticketlock.h \
odp/arch/arm32-linux/odp/api/abi/time.h \
+ odp/arch/arm32-linux/odp/api/abi/time_types.h \
odp/arch/arm32-linux/odp/api/abi/timer.h \
odp/arch/arm32-linux/odp/api/abi/timer_types.h \
odp/arch/arm32-linux/odp/api/abi/traffic_mngr.h \
@@ -309,6 +313,7 @@ odpapiabiarchinclude_HEADERS = \
odp/arch/arm64-linux/odp/api/abi/thrmask.h \
odp/arch/arm64-linux/odp/api/abi/ticketlock.h \
odp/arch/arm64-linux/odp/api/abi/time.h \
+ odp/arch/arm64-linux/odp/api/abi/time_types.h \
odp/arch/arm64-linux/odp/api/abi/timer.h \
odp/arch/arm64-linux/odp/api/abi/timer_types.h \
odp/arch/arm64-linux/odp/api/abi/traffic_mngr.h \
@@ -365,6 +370,7 @@ odpapiabiarchinclude_HEADERS = \
odp/arch/default-linux/odp/api/abi/thrmask.h \
odp/arch/default-linux/odp/api/abi/ticketlock.h \
odp/arch/default-linux/odp/api/abi/time.h \
+ odp/arch/default-linux/odp/api/abi/time_types.h \
odp/arch/default-linux/odp/api/abi/timer.h \
odp/arch/default-linux/odp/api/abi/timer_types.h \
odp/arch/default-linux/odp/api/abi/traffic_mngr.h \
@@ -421,6 +427,7 @@ odpapiabiarchinclude_HEADERS = \
odp/arch/power64-linux/odp/api/abi/thrmask.h \
odp/arch/power64-linux/odp/api/abi/ticketlock.h \
odp/arch/power64-linux/odp/api/abi/time.h \
+ odp/arch/power64-linux/odp/api/abi/time_types.h \
odp/arch/power64-linux/odp/api/abi/timer.h \
odp/arch/power64-linux/odp/api/abi/timer_types.h \
odp/arch/power64-linux/odp/api/abi/traffic_mngr.h \
@@ -477,6 +484,7 @@ odpapiabiarchinclude_HEADERS = \
odp/arch/x86_32-linux/odp/api/abi/thrmask.h \
odp/arch/x86_32-linux/odp/api/abi/ticketlock.h \
odp/arch/x86_32-linux/odp/api/abi/time.h \
+ odp/arch/x86_32-linux/odp/api/abi/time_types.h \
odp/arch/x86_32-linux/odp/api/abi/timer.h \
odp/arch/x86_32-linux/odp/api/abi/timer_types.h \
odp/arch/x86_32-linux/odp/api/abi/traffic_mngr.h \
@@ -533,6 +541,7 @@ odpapiabiarchinclude_HEADERS = \
odp/arch/x86_64-linux/odp/api/abi/thrmask.h \
odp/arch/x86_64-linux/odp/api/abi/ticketlock.h \
odp/arch/x86_64-linux/odp/api/abi/time.h \
+ odp/arch/x86_64-linux/odp/api/abi/time_types.h \
odp/arch/x86_64-linux/odp/api/abi/timer.h \
odp/arch/x86_64-linux/odp/api/abi/timer_types.h \
odp/arch/x86_64-linux/odp/api/abi/traffic_mngr.h \
diff --git a/include/odp/api/abi-default/packet_types.h b/include/odp/api/abi-default/packet_types.h
index 84f210b0e..73cfdcafa 100644
--- a/include/odp/api/abi-default/packet_types.h
+++ b/include/odp/api/abi-default/packet_types.h
@@ -70,55 +70,55 @@ typedef struct odp_packet_parse_result_flag_t {
/** Flags as a bitfield struct */
struct {
- /** @see odp_packet_has_error() */
+ /** See odp_packet_has_error() */
uint64_t has_error : 1;
- /** @see odp_packet_has_l2_error() */
+ /** See odp_packet_has_l2_error() */
uint64_t has_l2_error : 1;
- /** @see odp_packet_has_l3_error() */
+ /** See odp_packet_has_l3_error() */
uint64_t has_l3_error : 1;
- /** @see odp_packet_has_l4_error() */
+ /** See odp_packet_has_l4_error() */
uint64_t has_l4_error : 1;
- /** @see odp_packet_has_l2() */
+ /** See odp_packet_has_l2() */
uint64_t has_l2 : 1;
- /** @see odp_packet_has_l3() */
+ /** See odp_packet_has_l3() */
uint64_t has_l3 : 1;
- /** @see odp_packet_has_l4() */
+ /** See odp_packet_has_l4() */
uint64_t has_l4 : 1;
- /** @see odp_packet_has_eth() */
+ /** See odp_packet_has_eth() */
uint64_t has_eth : 1;
- /** @see odp_packet_has_eth_bcast() */
+ /** See odp_packet_has_eth_bcast() */
uint64_t has_eth_bcast : 1;
- /** @see odp_packet_has_eth_mcast() */
+ /** See odp_packet_has_eth_mcast() */
uint64_t has_eth_mcast : 1;
- /** @see odp_packet_has_jumbo() */
+ /** See odp_packet_has_jumbo() */
uint64_t has_jumbo : 1;
- /** @see odp_packet_has_vlan() */
+ /** See odp_packet_has_vlan() */
uint64_t has_vlan : 1;
- /** @see odp_packet_has_vlan_qinq() */
+ /** See odp_packet_has_vlan_qinq() */
uint64_t has_vlan_qinq : 1;
- /** @see odp_packet_has_arp() */
+ /** See odp_packet_has_arp() */
uint64_t has_arp : 1;
- /** @see odp_packet_has_ipv4() */
+ /** See odp_packet_has_ipv4() */
uint64_t has_ipv4 : 1;
- /** @see odp_packet_has_ipv6() */
+ /** See odp_packet_has_ipv6() */
uint64_t has_ipv6 : 1;
- /** @see odp_packet_has_ip_bcast() */
+ /** See odp_packet_has_ip_bcast() */
uint64_t has_ip_bcast : 1;
- /** @see odp_packet_has_ip_mcast() */
+ /** See odp_packet_has_ip_mcast() */
uint64_t has_ip_mcast : 1;
- /** @see odp_packet_has_ipfrag() */
+ /** See odp_packet_has_ipfrag() */
uint64_t has_ipfrag : 1;
- /** @see odp_packet_has_ipopt() */
+ /** See odp_packet_has_ipopt() */
uint64_t has_ipopt : 1;
- /** @see odp_packet_has_ipsec() */
+ /** See odp_packet_has_ipsec() */
uint64_t has_ipsec : 1;
- /** @see odp_packet_has_udp() */
+ /** See odp_packet_has_udp() */
uint64_t has_udp : 1;
- /** @see odp_packet_has_tcp() */
+ /** See odp_packet_has_tcp() */
uint64_t has_tcp : 1;
- /** @see odp_packet_has_sctp() */
+ /** See odp_packet_has_sctp() */
uint64_t has_sctp : 1;
- /** @see odp_packet_has_icmp() */
+ /** See odp_packet_has_icmp() */
uint64_t has_icmp : 1;
};
};
diff --git a/include/odp/api/abi-default/time.h b/include/odp/api/abi-default/time.h
index 94587371d..e601e6fd2 100644
--- a/include/odp/api/abi-default/time.h
+++ b/include/odp/api/abi-default/time.h
@@ -1,15 +1,9 @@
-/* Copyright (c) 2015-2018, Linaro Limited
+/* Copyright (c) 2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-/**
- * @file
- *
- * ODP time service
- */
-
#ifndef ODP_ABI_TIME_H_
#define ODP_ABI_TIME_H_
@@ -17,34 +11,7 @@
extern "C" {
#endif
-/** @addtogroup odp_time
- * @{
- **/
-
-/**
- * @internal Time structure used for both POSIX timespec and HW counter
- * implementations.
- */
-typedef struct odp_time_t {
- /** @internal Variant mappings for time type */
- union {
- /** @internal Used with generic 64 bit operations */
- uint64_t u64;
-
- /** @internal Nanoseconds */
- uint64_t nsec;
-
- /** @internal HW timer counter value */
- uint64_t count;
-
- };
-} odp_time_t;
-
-#define ODP_TIME_NULL ((odp_time_t){.u64 = 0})
-
-/**
- * @}
- */
+/* Empty header required due to the inline functions */
#ifdef __cplusplus
}
diff --git a/include/odp/api/abi-default/time_types.h b/include/odp/api/abi-default/time_types.h
new file mode 100644
index 000000000..4b7ec47eb
--- /dev/null
+++ b/include/odp/api/abi-default/time_types.h
@@ -0,0 +1,49 @@
+/* Copyright (c) 2015-2018, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_ABI_TIME_TYPES_H_
+#define ODP_ABI_TIME_TYPES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+/** @ingroup odp_time
+ * @{
+ **/
+
+/**
+ * @internal Time structure used for both POSIX timespec and HW counter
+ * implementations.
+ */
+typedef struct odp_time_t {
+ /** @internal Variant mappings for time type */
+ union {
+ /** @internal Used with generic 64 bit operations */
+ uint64_t u64;
+
+ /** @internal Nanoseconds */
+ uint64_t nsec;
+
+ /** @internal HW timer counter value */
+ uint64_t count;
+
+ };
+} odp_time_t;
+
+#define ODP_TIME_NULL ((odp_time_t){.u64 = 0})
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/odp/api/spec/classification.h b/include/odp/api/spec/classification.h
index 592ad1050..aefe2845a 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -274,7 +274,7 @@ typedef union odp_cls_pmr_terms_t {
* Packet Matching Rule parameter structure
*
* Match value/mask size and endianness are defined in PMR term documentation
- * (@see odp_cls_pmr_term_t). Most values and masks are passed in big
+ * (see odp_cls_pmr_term_t). Most values and masks are passed in big
* endian format without data alignment requirement. ODP_PMR_LEN is
* an exception to this (uint32_t in CPU endian).
*/
@@ -474,16 +474,16 @@ typedef struct odp_cls_stats_capability_t {
union {
/** Statistics counters in a bit field structure */
struct {
- /** @see odp_cls_cos_stats_t::octets */
+ /** See odp_cls_cos_stats_t::octets */
uint64_t octets : 1;
- /** @see odp_cls_cos_stats_t::packets */
+ /** See odp_cls_cos_stats_t::packets */
uint64_t packets : 1;
- /** @see odp_cls_cos_stats_t::discards */
+ /** See odp_cls_cos_stats_t::discards */
uint64_t discards : 1;
- /** @see odp_cls_cos_stats_t::errors */
+ /** See odp_cls_cos_stats_t::errors */
uint64_t errors : 1;
} counter;
@@ -502,16 +502,16 @@ typedef struct odp_cls_stats_capability_t {
union {
/** Statistics counters in a bit field structure */
struct {
- /** @see odp_cls_queue_stats_t::octets */
+ /** See odp_cls_queue_stats_t::octets */
uint64_t octets : 1;
- /** @see odp_cls_queue_stats_t::packets */
+ /** See odp_cls_queue_stats_t::packets */
uint64_t packets : 1;
- /** @see odp_cls_queue_stats_t::discards */
+ /** See odp_cls_queue_stats_t::discards */
uint64_t discards : 1;
- /** @see odp_cls_queue_stats_t::errors */
+ /** See odp_cls_queue_stats_t::errors */
uint64_t errors : 1;
} counter;
@@ -635,8 +635,9 @@ typedef struct odp_cls_cos_param {
odp_cos_action_t action;
/** Enable statistics. If true, counters are incremented when packets
- * are classified to the CoS. Default is false. @see
- * odp_cls_cos_stats().
+ * are classified to the CoS. Default is false.
+ *
+ * @see odp_cls_cos_stats()
*/
odp_bool_t stats_enable;
@@ -675,7 +676,7 @@ typedef struct odp_cls_cos_param {
/** Pool associated with CoS
*
* May be set to ODP_POOL_INVALID, in which case the default pool of
- * the originating packet input is used (@see odp_pktio_open()). If
+ * the originating packet input is used (see odp_pktio_open()). If
* there is no originating packet input (e.g. with lookaside IPsec),
* then this parameter must be set to a valid pool.
*
@@ -761,7 +762,7 @@ odp_queue_t odp_cls_hash_result(odp_cos_t cos, odp_packet_t packet);
*
* Before destroying a CoS, all the PMRs referring to the CoS (as a source or
* destination CoS) must be destroyed first. Also, the CoS must not be in use
- * as the default CoS in any pktio (@see odp_pktio_default_cos_set()) or as the
+ * as the default CoS in any pktio (see odp_pktio_default_cos_set()) or as the
* destination CoS of any IPsec SA.
*
* @param cos CoS handle
diff --git a/include/odp/api/spec/comp.h b/include/odp/api/spec/comp.h
index 39ecbfde4..a1f6f48fb 100644
--- a/include/odp/api/spec/comp.h
+++ b/include/odp/api/spec/comp.h
@@ -219,7 +219,7 @@ typedef struct odp_comp_alg_capability_t {
* that the percentage of output data produced might be greater
* than this value.
*
- * @see odp__percent_t
+ * @see odp_percent_t
*/
odp_percent_t compression_ratio;
} odp_comp_alg_capability_t;
@@ -257,7 +257,7 @@ typedef struct odp_comp_deflate_param {
*
* max_level - High quality compression
*
- * @see 'max_level' in odp_comp_alg_capability_t
+ * @see odp_comp_alg_capability_t::max_level
*/
uint32_t comp_level;
diff --git a/include/odp/api/spec/dma.h b/include/odp/api/spec/dma.h
index 6e911b227..658b31058 100644
--- a/include/odp/api/spec/dma.h
+++ b/include/odp/api/spec/dma.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2021-2022, Nokia
+/* Copyright (c) 2021-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -49,6 +49,10 @@ void odp_dma_param_init(odp_dma_param_t *param);
/**
* Create DMA session
*
+ * Create a DMA session according to the parameters. The use of session name is optional. Unique
+ * names are not required. However, odp_dma_lookup() returns only a single matching named session.
+ * Use odp_dma_param_init() to initialize parameters into their default values.
+ *
* @param name DMA session name or NULL. Maximum string length is ODP_DMA_NAME_LEN.
* @param param DMA session parameters
*
@@ -285,6 +289,19 @@ odp_event_t odp_dma_compl_to_event(odp_dma_compl_t dma_compl);
uint64_t odp_dma_compl_to_u64(odp_dma_compl_t dma_compl);
/**
+ * DMA completion event user area
+ *
+ * Returns pointer to the user area associated with the completion event. Size of the area is fixed
+ * and defined in completion event pool parameters.
+ *
+ * @param dma_compl DMA completion event handle
+ *
+ * @return Pointer to the user area of the completion event
+ * @retval NULL The completion event does not have user area
+ */
+void *odp_dma_compl_user_area(odp_dma_compl_t dma_compl);
+
+/**
* Allocate DMA completion event
*
* Allocates a DMA completion event from a pool. The pool must have been created with
@@ -332,7 +349,7 @@ void odp_dma_pool_param_init(odp_dma_pool_param_t *pool_param);
* The use of pool name is optional. Unique names are not required. However, odp_pool_lookup()
* returns only a single matching pool. Use odp_dma_pool_param_init() to initialize pool parameters
* into their default values. Parameters values must not exceed pool capabilities
- * (@see odp_dma_pool_capability_t)
+ * (odp_dma_pool_capability_t).
*
* @param name Name of the pool or NULL. Maximum string length is ODP_POOL_NAME_LEN.
* @param pool_param Pool parameters
diff --git a/include/odp/api/spec/dma_types.h b/include/odp/api/spec/dma_types.h
index caa51700b..26350e998 100644
--- a/include/odp/api/spec/dma_types.h
+++ b/include/odp/api/spec/dma_types.h
@@ -77,6 +77,9 @@ typedef struct odp_dma_pool_capability_t {
/** Maximum number of DMA completion events in a pool */
uint32_t max_num;
+ /** Maximum user area size in bytes */
+ uint32_t max_uarea_size;
+
/** Minimum size of thread local cache */
uint32_t min_cache_size;
@@ -94,6 +97,13 @@ typedef struct odp_dma_pool_param_t {
* Maximum value is defined by 'max_num' pool capability */
uint32_t num;
+ /** User area size in bytes
+ *
+ * Maximum value is defined by 'max_uarea_size' pool capability. Specify as 0 if no user
+ * area is needed. The default value is 0.
+ */
+ uint32_t uarea_size;
+
/** Maximum number of events cached locally per thread
*
* See odp_pool_param_t::cache_size documentation for details. Valid values range from
@@ -511,9 +521,8 @@ typedef struct odp_dma_compl_param_t {
/** User context pointer
*
- * User defined context pointer which is copied to transfer results
- * (@see odp_dma_result_t). The value does not need to represent a valid address
- * (any intptr_t value is allowed).
+ * User defined context pointer which is copied to transfer results (odp_dma_result_t). The
+ * value does not need to represent a valid address (any intptr_t value is allowed).
*
* The default value is NULL.
*/
@@ -533,7 +542,7 @@ typedef struct odp_dma_result_t {
/** User context pointer
*
* User defined context pointer value from transfer completion parameters
- * (@see odp_dma_compl_param_t). The default value is NULL.
+ * (odp_dma_compl_param_t). The default value is NULL.
*/
void *user_ptr;
diff --git a/include/odp/api/spec/event.h b/include/odp/api/spec/event.h
index c36d9cef1..9dc614329 100644
--- a/include/odp/api/spec/event.h
+++ b/include/odp/api/spec/event.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
+ * Copyright (c) 2022-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -80,6 +80,20 @@ int odp_event_type_multi(const odp_event_t event[], int num,
odp_event_type_t *type);
/**
+ * Event user area
+ *
+ * Returns pointer to the user area associated with the event. This maps to the
+ * user area of underlying event type (e.g. odp_packet_user_area() for packets).
+ * If the event does not have user area, NULL is returned.
+ *
+ * @param event Event handle
+ *
+ * @return Pointer to the user area of the event
+ * @retval NULL The event does not have user area
+ */
+void *odp_event_user_area(odp_event_t event);
+
+/**
* Filter and convert packet events
*
* Checks event type of all input events, converts all packet events and outputs
diff --git a/include/odp/api/spec/init.h b/include/odp/api/spec/init.h
index 69ca55767..c4f64d4fd 100644
--- a/include/odp/api/spec/init.h
+++ b/include/odp/api/spec/init.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2021, Nokia
+ * Copyright (c) 2019-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -33,6 +33,18 @@ extern "C" {
*/
/**
+ * Called from signal handler
+ */
+#define ODP_TERM_FROM_SIGH ((uint64_t)0x1)
+
+/**
+ * Last standard flag for abnormal terminate
+ *
+ * An implementation may use this for adding its own flags after the standard flags.
+ */
+#define ODP_TERM_LAST_FLAG ODP_TERM_FROM_SIGH
+
+/**
* ODP log level.
*/
typedef enum {
@@ -91,11 +103,12 @@ int odp_override_log(odp_log_level_t level, const char *fmt, ...);
* - By overriding the ODP implementation default abort function
* odp_override_abort().
*
- * @warning The latter option is less portable and GNU linker dependent
- * (utilizes function attribute "weak"). If both are defined, the odp_init_t
- * function pointer has priority over the override function.
+ * The latter option is less portable and GNU linker dependent (utilizes function
+ * attribute "weak"). If both are defined, the odp_init_t function pointer has
+ * priority over the override function.
*
- * @warning this function shall not return
+ * Note that no ODP calls should be called in the abort function and the function
+ * should not return.
*/
void odp_override_abort(void) ODP_NORETURN;
@@ -342,6 +355,39 @@ int odp_term_local(void);
int odp_term_global(odp_instance_t instance);
/**
+ * Abnormal ODP termination after a non-recoverable error
+ *
+ * Application may call this function to terminate an ODP instance after facing
+ * a non-recoverable error. Depending on the implementation, this function may
+ * attempt to dump stack and other memory areas, clean up and stop HW
+ * operations and/or perform other actions helpful in postmortem analysis.
+ * Depending on the nature of the error resulting in the abnormal termination,
+ * these actions may partially or completely fail. Flags (ODP_TERM_*) parameter
+ * can be used to control and data parameter can be used to pass additional
+ * flag-specific information to the termination process. Implementation
+ * specific flags with implementation specific data may also exist, see from
+ * implementation documentation how those should be utilized.
+ *
+ * Some coordination across threads is required when abnormally terminating, if
+ * other threads continue calling ODP functions during or after termination,
+ * their operation is most likely affected.
+ *
+ * When the function returns, the ODP instance has been destroyed either
+ * completely or partially. Application must not attempt to call any ODP
+ * functions during its remaining lifetime, but terminate as soon as feasible.
+ *
+ * @param instance Instance handle
+ * @param flags A bit mask of control flags (ODP_TERM_*), set to 0
+ * when no flags
+ * @param data Additional data, set to NULL when no additional data
+ *
+ * @retval 0 on all actions successfully performed
+ * @retval <0 on failure to perform all actions, implementation specific status
+ * code for debugging
+ */
+int odp_term_abnormal(odp_instance_t instance, uint64_t flags, void *data);
+
+/**
* Set thread specific log function
*
* By default, all ODP log writes use the global log function, which may be set
diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index 51c7a8e46..9f41edf1a 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2021-2022, Nokia
+ * Copyright (c) 2021-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -25,7 +25,7 @@ extern "C" {
#include <odp/api/pool_types.h>
#include <odp/api/proto_stats_types.h>
#include <odp/api/std_types.h>
-#include <odp/api/time.h>
+#include <odp/api/time_types.h>
/** @defgroup odp_packet ODP PACKET
* Packet event metadata and operations.
@@ -937,7 +937,7 @@ void *odp_packet_buf_head(odp_packet_buf_t pkt_buf);
/**
* Packet buffer size in bytes
*
- * Packet buffer size is calculated from the buffer head pointer (@see odp_packet_buf_head()).
+ * Packet buffer size is calculated from the buffer head pointer (see odp_packet_buf_head()).
* It contains all buffer level headroom, data, and tailroom. For a single segmented packet this is
* equivalent to odp_packet_buf_len().
*
@@ -994,7 +994,7 @@ void odp_packet_buf_data_set(odp_packet_buf_t pkt_buf, uint32_t data_offset, uin
* may be done only for packet buffers that are not part of any packet (i.e. buffers between
* odp_packet_disassemble() and odp_packet_reassemble() calls).
*
- * This call can be used only for packets of an external memory pool (@see odp_pool_ext_create()).
+ * This call can be used only for packets of an external memory pool (see odp_pool_ext_create()).
*
* @param pool Pool from which the packet buffer (disassembled packet) originate from
* @param head Head pointer
@@ -1008,12 +1008,12 @@ odp_packet_buf_t odp_packet_buf_from_head(odp_pool_t pool, void *head);
* Disassemble packet into packet buffers
*
* Breaks up a packet into a list of packet buffers. Outputs a packet buffer handle for each
- * segment of the packet (@see odp_packet_num_segs()). After a successful operation the packet
+ * segment of the packet (see odp_packet_num_segs()). After a successful operation the packet
* handle must not be referenced anymore. Packet buffers are reassembled into a new packet (or
* several new packets) with a later odp_packet_reassemble() call(s). All packet buffers must be
* reassembled into a packet and freed into the originating pool before the pool is destroyed.
*
- * This call can be used only for packets of an external memory pool (@see odp_pool_ext_create()).
+ * This call can be used only for packets of an external memory pool (see odp_pool_ext_create()).
*
* @param pkt Packet to be disassembled
* @param[out] pkt_buf Packet buffer handle array for output
@@ -1040,7 +1040,7 @@ uint32_t odp_packet_disassemble(odp_packet_t pkt, odp_packet_buf_t pkt_buf[], ui
* in the buffers. All other packet metadata are set to their default values. After a successful
* operation packet buffer handles must not be referenced anymore.
*
- * This call can be used only for packets of an external memory pool (@see odp_pool_ext_create()).
+ * This call can be used only for packets of an external memory pool (see odp_pool_ext_create()).
*
* @param pool Pool from which all packet buffers (disassembled packets) originate from
* @param pkt_buf Packet buffers to form a new packet
@@ -2054,19 +2054,21 @@ void odp_packet_aging_tmo_set(odp_packet_t pkt, uint64_t tmo_ns);
uint64_t odp_packet_aging_tmo(odp_packet_t pkt);
/**
- * Request Tx completion event.
+ * Request packet transmit completion
*
- * Enables or disables TX completion event request for the packet. When
- * enabled, an event of type ODP_EVENT_PACKET_TX_COMPL will be sent to the
- * destination queue based on the TX completion mode. The event is sent only
- * after pktio interface has finished processing the packet. A previously
- * enabled request can be disabled by setting the mode to
- * ODP_PACKET_TX_COMPL_DISABLED.
+ * Enables or disables packet transmit completion request for the packet. Completion may be
+ * requested either in event (#ODP_PACKET_TX_COMPL_EVENT) or poll (#ODP_PACKET_TX_COMPL_POLL) mode.
+ * When event mode is enabled, an event of type ODP_EVENT_PACKET_TX_COMPL will be sent to the
+ * destination queue to signal transmit completion. When poll mode is enabled,
+ * odp_packet_tx_compl_done() is used with the provided completion identifier to check the
+ * completion. In both cases, transmit completion is reported only after pktio interface has
+ * finished processing the packet.
*
- * TX completion event request is disabled by default.
+ * A previously enabled request can be disabled by setting the mode to ODP_PACKET_TX_COMPL_DISABLED.
+ * Transmit completion request is disabled by default.
*
* @param pkt Packet handle
- * @param opt Points to TX completion event generation options
+ * @param opt Packet transmit completion request options
*
* @retval 0 On success
* @retval <0 On failure
@@ -2074,16 +2076,49 @@ uint64_t odp_packet_aging_tmo(odp_packet_t pkt);
int odp_packet_tx_compl_request(odp_packet_t pkt, const odp_packet_tx_compl_opt_t *opt);
/**
- * Check if TX completion event is requested for the packet
+ * Check if packet transmit completion is requested
*
* @param pkt Packet handle
*
- * @retval non-zero TX completion event is requested
- * @retval 0 TX completion event is not requested
+ * @retval non-zero Transmit completion is requested
+ * @retval 0 Transmit completion is not requested
*/
int odp_packet_has_tx_compl_request(odp_packet_t pkt);
/**
+ * Set packet free control option
+ *
+ * This option enables application to control which packets are freed/not freed back into pool
+ * after ODP implementation has finished processing those. The option affects only packets that
+ * are transmitted directly through a packet output interface (also with LSO), i.e. packets
+ * transmitted through inline IPsec or TM are not affected.
+ *
+ * When the option is set to #ODP_PACKET_FREE_CTRL_DONT_FREE, packet output interface will not free
+ * the packet after transmit and application may reuse the packet as soon as its transmit is
+ * complete (see e.g. odp_packet_tx_compl_done()).
+ *
+ * The option must not be enabled on packets that have multiple references.
+ *
+ * Check packet IO interface capability free_ctrl.dont_free (odp_pktio_capability_t::dont_free) for
+ * the option support. When an interface does not support the option, it ignores the value.
+ *
+ * The default value is #ODP_PACKET_FREE_CTRL_DISABLED.
+ *
+ * @param pkt Packet handle
+ * @param ctrl Packet free control option value
+ */
+void odp_packet_free_ctrl_set(odp_packet_t pkt, odp_packet_free_ctrl_t ctrl);
+
+/**
+ * Returns packet free control option value
+ *
+ * @param pkt Packet handle
+ *
+ * @return The current value of the packet free control option
+ */
+odp_packet_free_ctrl_t odp_packet_free_ctrl(odp_packet_t pkt);
+
+/**
* Request packet proto stats.
*
* The statistics enabled in the proto stats object are updated for the packet in
@@ -2195,8 +2230,8 @@ void odp_packet_vector_free(odp_packet_vector_t pktv);
* the vector table.
*
* @note The maximum number of packets this vector can hold is defined by
- * odp_pool_param_t:vector:max_size. The return value of this function will not
- * be greater than odp_pool_param_t:vector:max_size
+ * odp_pool_param_t::vector::max_size. The return value of this function will not
+ * be greater than odp_pool_param_t::vector::max_size
*
* @note The pkt_tbl points to the packet vector table. Application can edit the
* packet handles in the table directly (up to odp_pool_param_t::vector::max_size).
@@ -2398,6 +2433,29 @@ void odp_packet_tx_compl_free(odp_packet_tx_compl_t tx_compl);
*/
void *odp_packet_tx_compl_user_ptr(odp_packet_tx_compl_t tx_compl);
+/**
+ * Check packet transmit completion
+ *
+ * Checks if a previously sent packet with a ODP_PACKET_TX_COMPL_POLL type transmit completion
+ * request (see odp_packet_tx_compl_opt_t) has been transmitted. The packet send function call
+ * clears completion identifier status, and 0 is returned while the transmit is in progress.
+ * When >0 is returned, transmit of the packet is complete and the completion identifier may be
+ * reused for another transmit.
+ *
+ * When transmit of a packet is complete, it indicates that transmit of other packets sent
+ * before the packet through the same queue have also completed.
+ *
+ * Returns initially 0 for all configured completion identifiers.
+ *
+ * @param pktio Packet IO interface that was used to send the packet
+ * @param compl_id Completion identifier that was used in the transmit completion request
+ *
+ * @retval >0 Packet transmit is complete
+ * @retval 0 Packet transmit is not complete
+ * @retval <0 Failed to read packet transmit status
+ */
+int odp_packet_tx_compl_done(odp_pktio_t pktio, uint32_t compl_id);
+
/*
*
* Debugging
diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h
index 602093764..54aa2214b 100644
--- a/include/odp/api/spec/packet_io.h
+++ b/include/odp/api/spec/packet_io.h
@@ -25,7 +25,7 @@ extern "C" {
#include <odp/api/packet_io_types.h>
#include <odp/api/queue_types.h>
#include <odp/api/reassembly.h>
-#include <odp/api/time.h>
+#include <odp/api/time_types.h>
/** @defgroup odp_packet_io ODP PACKET IO
* Packet IO interfaces.
@@ -452,9 +452,13 @@ uint64_t odp_pktin_wait_time(uint64_t nsec);
* the operation is optimized for single thread operation per queue and the same
* queue must not be accessed simultaneously from multiple threads.
*
- * A successful call returns the actual number of packets sent. If return value
- * is less than 'num', the remaining packets at the end of packets[] array
- * are not consumed, and the caller has to take care of them.
+ * A successful call returns the actual number of packets accepted for transmit. If return value
+ * is less than 'num', the remaining packets at the end of packets[] array are not consumed,
+ * and the caller has to take care of them. Transmitted packets are freed back into their
+ * originating pools by default. If interface supports #ODP_PACKET_FREE_CTRL_DONT_FREE
+ * option and it is set (odp_packet_free_ctrl_set()) in a packet, the packet is not freed
+ * but application owns it again after its transmit is complete. Application may use
+ * odp_packet_tx_compl_request() to request an indication when transmit of a packet is complete.
*
* Entire packet data is sent out (odp_packet_len() bytes of data, starting from
* odp_packet_data()). All other packet metadata is ignored unless otherwise
@@ -465,7 +469,7 @@ uint64_t odp_pktin_wait_time(uint64_t nsec);
* @param packets[] Array of packets to send
* @param num Number of packets to send
*
- * @return Number of packets sent
+ * @return Number of packets accepted for transmit
* @retval <0 on failure
*/
int odp_pktout_send(odp_pktout_queue_t queue, const odp_packet_t packets[],
diff --git a/include/odp/api/spec/packet_io_stats.h b/include/odp/api/spec/packet_io_stats.h
index 156a3a95e..bd3908867 100644
--- a/include/odp/api/spec/packet_io_stats.h
+++ b/include/odp/api/spec/packet_io_stats.h
@@ -101,16 +101,16 @@ typedef struct odp_pktio_stats_t {
* level statistics odp_pktio_stats_t for counter definitions.
*/
typedef struct odp_pktin_queue_stats_t {
- /** @see odp_pktio_stats_t::in_octets */
+ /** See odp_pktio_stats_t::in_octets */
uint64_t octets;
- /** @see odp_pktio_stats_t::in_packets */
+ /** See odp_pktio_stats_t::in_packets */
uint64_t packets;
- /** @see odp_pktio_stats_t::in_discards */
+ /** See odp_pktio_stats_t::in_discards */
uint64_t discards;
- /** @see odp_pktio_stats_t::in_errors */
+ /** See odp_pktio_stats_t::in_errors */
uint64_t errors;
} odp_pktin_queue_stats_t;
@@ -122,16 +122,16 @@ typedef struct odp_pktin_queue_stats_t {
* level statistics odp_pktio_stats_t for counter definitions.
*/
typedef struct odp_pktout_queue_stats_t {
- /** @see odp_pktio_stats_t::out_octets */
+ /** See odp_pktio_stats_t::out_octets */
uint64_t octets;
- /** @see odp_pktio_stats_t::out_packets */
+ /** See odp_pktio_stats_t::out_packets */
uint64_t packets;
- /** @see odp_pktio_stats_t::out_discards */
+ /** See odp_pktio_stats_t::out_discards */
uint64_t discards;
- /** @see odp_pktio_stats_t::out_errors */
+ /** See odp_pktio_stats_t::out_errors */
uint64_t errors;
} odp_pktout_queue_stats_t;
@@ -146,46 +146,46 @@ typedef struct odp_pktio_stats_capability_t {
union {
/** Statistics counters in a bit field structure */
struct {
- /** @see odp_pktio_stats_t::in_octets */
+ /** See odp_pktio_stats_t::in_octets */
uint64_t in_octets : 1;
- /** @see odp_pktio_stats_t::in_packets */
+ /** See odp_pktio_stats_t::in_packets */
uint64_t in_packets : 1;
- /** @see odp_pktio_stats_t::in_ucast_pkts */
+ /** See odp_pktio_stats_t::in_ucast_pkts */
uint64_t in_ucast_pkts : 1;
- /** @see odp_pktio_stats_t::in_mcast_pkts */
+ /** See odp_pktio_stats_t::in_mcast_pkts */
uint64_t in_mcast_pkts : 1;
- /** @see odp_pktio_stats_t::in_bcast_pkts */
+ /** See odp_pktio_stats_t::in_bcast_pkts */
uint64_t in_bcast_pkts : 1;
- /** @see odp_pktio_stats_t::in_discards */
+ /** See odp_pktio_stats_t::in_discards */
uint64_t in_discards : 1;
- /** @see odp_pktio_stats_t::in_errors */
+ /** See odp_pktio_stats_t::in_errors */
uint64_t in_errors : 1;
- /** @see odp_pktio_stats_t::out_octets */
+ /** See odp_pktio_stats_t::out_octets */
uint64_t out_octets : 1;
- /** @see odp_pktio_stats_t::out_packets */
+ /** See odp_pktio_stats_t::out_packets */
uint64_t out_packets : 1;
- /** @see odp_pktio_stats_t::out_ucast_pkts */
+ /** See odp_pktio_stats_t::out_ucast_pkts */
uint64_t out_ucast_pkts : 1;
- /** @see odp_pktio_stats_t::out_mcast_pkts */
+ /** See odp_pktio_stats_t::out_mcast_pkts */
uint64_t out_mcast_pkts : 1;
- /** @see odp_pktio_stats_t::out_bcast_pkts */
+ /** See odp_pktio_stats_t::out_bcast_pkts */
uint64_t out_bcast_pkts : 1;
- /** @see odp_pktio_stats_t::out_discards */
+ /** See odp_pktio_stats_t::out_discards */
uint64_t out_discards : 1;
- /** @see odp_pktio_stats_t::out_errors */
+ /** See odp_pktio_stats_t::out_errors */
uint64_t out_errors : 1;
} counter;
@@ -203,16 +203,16 @@ typedef struct odp_pktio_stats_capability_t {
union {
/** Statistics counters in a bit field structure */
struct {
- /** @see odp_pktin_queue_stats_t::octets */
+ /** See odp_pktin_queue_stats_t::octets */
uint64_t octets : 1;
- /** @see odp_pktin_queue_stats_t::packets */
+ /** See odp_pktin_queue_stats_t::packets */
uint64_t packets : 1;
- /** @see odp_pktin_queue_stats_t::discards */
+ /** See odp_pktin_queue_stats_t::discards */
uint64_t discards : 1;
- /** @see odp_pktin_queue_stats_t::errors */
+ /** See odp_pktin_queue_stats_t::errors */
uint64_t errors : 1;
} counter;
@@ -230,16 +230,16 @@ typedef struct odp_pktio_stats_capability_t {
union {
/** Statistics counters in a bit field structure */
struct {
- /** @see odp_pktout_queue_stats_t::octets */
+ /** See odp_pktout_queue_stats_t::octets */
uint64_t octets : 1;
- /** @see odp_pktout_queue_stats_t::packets */
+ /** See odp_pktout_queue_stats_t::packets */
uint64_t packets : 1;
- /** @see odp_pktout_queue_stats_t::discards */
+ /** See odp_pktout_queue_stats_t::discards */
uint64_t discards : 1;
- /** @see odp_pktout_queue_stats_t::errors */
+ /** See odp_pktout_queue_stats_t::errors */
uint64_t errors : 1;
} counter;
diff --git a/include/odp/api/spec/packet_io_types.h b/include/odp/api/spec/packet_io_types.h
index a46668c30..fcdf49eb4 100644
--- a/include/odp/api/spec/packet_io_types.h
+++ b/include/odp/api/spec/packet_io_types.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2020-2022, Nokia
+ * Copyright (c) 2020-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -523,12 +523,11 @@ typedef union odp_pktout_config_opt_t {
*/
uint64_t aging_ena : 1;
- /** Enable packet transmit completion event requests
- *
- * Use pktio capability tx_compl to check if TX completion events are supported.
+ /**
+ * For backwards compatibility, setting this flag is the same as setting
+ * tx_compl.mode_event in odp_pktio_config_t. The default value is zero.
*
- * 0: Application will not request packet TX completion events (default)
- * 1: Application may request packet TX completion events
+ * @deprecated Use odp_pktio_config_t::mode_event instead.
*/
uint64_t tx_compl_ena : 1;
@@ -635,8 +634,7 @@ typedef struct odp_pktio_config_t {
* * 0: Disable outbound IPSEC inline operation (default)
* * 1: Enable outbound IPSEC inline operation
*
- * @see odp_ipsec_config(), odp_ipsec_sa_create()
- * odp_ipsec_out_inline()
+ * @see odp_ipsec_config(), odp_ipsec_sa_create(), odp_ipsec_out_inline()
*/
odp_bool_t outbound_ipsec;
@@ -699,6 +697,45 @@ typedef struct odp_pktio_config_t {
} flow_control;
+ /**
+ * Packet transmit completion configuration
+ */
+ struct {
+ /**
+ * Enable packet transmit completion events
+ *
+ * Use pktio capability tx_compl to check if packet transmit completion mode
+ * #ODP_PACKET_TX_COMPL_EVENT is supported.
+ *
+ * 0: Application will not request ODP_PACKET_TX_COMPL_EVENT mode
+ * completion (default)
+ * 1: Application may request ODP_PACKET_TX_COMPL_EVENT mode completion
+ */
+ uint32_t mode_event : 1;
+
+ /**
+ * Enable packet transmit completion check through polling
+ *
+ * Use pktio capability tx_compl to check if packet transmit completion mode
+ * #ODP_PACKET_TX_COMPL_POLL is supported.
+ *
+ * 0: Application will not request ODP_PACKET_TX_COMPL_POLL mode
+ * completion (default)
+ * 1: Application may request ODP_PACKET_TX_COMPL_POLL mode completion
+ */
+ uint32_t mode_poll : 1;
+
+ /**
+ * Maximum completion index
+ *
+ * When ODP_PACKET_TX_COMPL_POLL mode is enabled, the maximum completion index
+ * value that application will use. The value must be between 0 and
+ * tx_compl.max_compl_id capability. The default value is zero.
+ */
+ uint32_t max_compl_id;
+
+ } tx_compl;
+
} odp_pktio_config_t;
/**
@@ -987,11 +1024,34 @@ typedef struct odp_pktio_capability_t {
*/
odp_bool_t queue_type_plain;
- /** ODP_PACKET_TX_COMPL_ALL supported */
- uint32_t mode_all:1;
+ /**
+ * For backwards compatibility, mode_all is synonym of mode_event.
+ *
+ * @deprecated Use mode_event instead.
+ */
+ uint32_t mode_all : 1;
+
+ /** Packet transmit completion mode ODP_PACKET_TX_COMPL_EVENT support */
+ uint32_t mode_event : 1;
+
+ /** Packet transmit completion mode ODP_PACKET_TX_COMPL_POLL support */
+ uint32_t mode_poll : 1;
+
+ /** Maximum supported completion ID value */
+ uint32_t max_compl_id;
} tx_compl;
+ /** Supported packet free control options */
+ struct {
+ /**
+ * Packet free control option #ODP_PACKET_FREE_CTRL_DONT_FREE support
+ * with odp_packet_free_ctrl_set().
+ */
+ uint32_t dont_free : 1;
+
+ } free_ctrl;
+
/** Packet input reassembly capability */
odp_reass_capability_t reassembly;
diff --git a/include/odp/api/spec/packet_types.h b/include/odp/api/spec/packet_types.h
index 1eba3506f..5114582ab 100644
--- a/include/odp/api/spec/packet_types.h
+++ b/include/odp/api/spec/packet_types.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
+ * Copyright (c) 2021-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -357,26 +357,26 @@ typedef struct odp_packet_parse_result_t {
/** Parse result flags */
odp_packet_parse_result_flag_t flag;
- /** @see odp_packet_len() */
+ /** See odp_packet_len() */
uint32_t packet_len;
- /** @see odp_packet_l2_offset() */
+ /** See odp_packet_l2_offset() */
uint32_t l2_offset;
- /** @see odp_packet_l3_offset() */
+ /** See odp_packet_l3_offset() */
uint32_t l3_offset;
- /** @see odp_packet_l4_offset() */
+ /** See odp_packet_l4_offset() */
uint32_t l4_offset;
- /** @see odp_packet_l3_chksum_status() */
+ /** See odp_packet_l3_chksum_status() */
odp_packet_chksum_status_t l3_chksum_status;
- /** @see odp_packet_l4_chksum_status() */
+ /** See odp_packet_l4_chksum_status() */
odp_packet_chksum_status_t l4_chksum_status;
- /** @see odp_packet_l2_type() */
+ /** See odp_packet_l2_type() */
odp_proto_l2_type_t l2_type;
- /** @see odp_packet_l3_type() */
+ /** See odp_packet_l3_type() */
odp_proto_l3_type_t l3_type;
- /** @see odp_packet_l4_type() */
+ /** See odp_packet_l4_type() */
odp_proto_l4_type_t l4_type;
} odp_packet_parse_result_t;
@@ -418,34 +418,87 @@ typedef struct odp_packet_lso_opt_t {
} odp_packet_lso_opt_t;
/**
- * Packet Tx completion mode
+ * Packet transmit completion mode
*/
typedef enum odp_packet_tx_compl_mode_t {
- /** Packet Tx completion event is disabled
+ /** Disable packet transmit completion */
+ ODP_PACKET_TX_COMPL_DISABLED = 0,
+
+ /**
+ * Enable packet transmit completion event
+ *
+ * A packet transmit completion event is sent for both transmitted and dropped packets.
+ */
+ ODP_PACKET_TX_COMPL_EVENT,
+
+ /**
+ * Enable packet transmit completion check through polling
*
- * When mode is disabled, all other fields of odp_packet_tx_compl_opt_t are ignored.
+ * Packet transmit completion status is updated for both transmitted and dropped packets.
*/
- ODP_PACKET_TX_COMPL_DISABLED,
- /** Packet Tx completion event is sent for all packets (both transmitted and dropped) */
- ODP_PACKET_TX_COMPL_ALL,
+ ODP_PACKET_TX_COMPL_POLL,
+
} odp_packet_tx_compl_mode_t;
/**
- * Tx completion request options
+ * For backwards compatibility, ODP_PACKET_TX_COMPL_ALL is synonym of ODP_PACKET_TX_COMPL_EVENT.
+ *
+ * @deprecated Use #ODP_PACKET_TX_COMPL_EVENT instead.
+ */
+#define ODP_PACKET_TX_COMPL_ALL ODP_PACKET_TX_COMPL_EVENT
+
+/**
+ * Packet transmit completion request options
*/
typedef struct odp_packet_tx_compl_opt_t {
- /** Queue handle
+ /**
+ * Packet transmit completion mode
*
- * Tx completion event will be posted to ODP queue identified by this handle.
+ * When completion mode is #ODP_PACKET_TX_COMPL_DISABLED, all other fields of this struct
+ * are ignored.
*/
- odp_queue_t queue;
-
- /** Packet Tx completion event mode */
odp_packet_tx_compl_mode_t mode;
+ /** Union of packet transmit completion destinations */
+ union {
+ /**
+ * Destination queue
+ *
+ * When completion mode is #ODP_PACKET_TX_COMPL_EVENT, a packet transmit completion
+ * event will be sent to this queue.
+ */
+ odp_queue_t queue;
+
+ /**
+ * Completion identifier
+ *
+ * When completion mode is #ODP_PACKET_TX_COMPL_POLL, a packet transmit completion
+ * status will be reported through this completion identifier. Application selects
+ * a value between 0 and tx_compl.max_compl_id in packet IO configuration options
+ * (see odp_pktio_config_t). Only single packet may be transmitted with the same
+ * identifier value at a time (through the same packet IO interface). A value may
+ * be reused for the next transmit only after transmit of the previous packet is
+ * complete. Multiple packets may have the same identifier value set as long as
+ * those packets are not transmitted simultaneously.
+ */
+ uint32_t compl_id;
+ };
+
} odp_packet_tx_compl_opt_t;
/**
+ * Packet free control option
+ */
+typedef enum odp_packet_free_ctrl_t {
+ /** Packet free control disabled */
+ ODP_PACKET_FREE_CTRL_DISABLED = 0,
+
+ /** Don't free packet after processing it */
+ ODP_PACKET_FREE_CTRL_DONT_FREE,
+
+} odp_packet_free_ctrl_t;
+
+/**
* Packet proto stats options
*/
typedef struct odp_packet_proto_stats_opt_t {
diff --git a/include/odp/api/spec/pool.h b/include/odp/api/spec/pool.h
index a72dcd3af..e51ce0b0d 100644
--- a/include/odp/api/spec/pool.h
+++ b/include/odp/api/spec/pool.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2020-2022, Nokia
+ * Copyright (c) 2020-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -156,10 +156,11 @@ unsigned int odp_pool_max_index(void);
int odp_pool_index(odp_pool_t pool);
/**
- * Get statistics for pool handle
+ * Get statistics for pool
*
- * Read the statistics counters enabled using odp_pool_stats_opt_t during pool
- * creation. The inactive counters are set to zero by the implementation.
+ * Read the statistics counters enabled using odp_pool_stats_opt_t during pool creation. The
+ * inactive counters are set to zero by the implementation. Depending on the implementation, there
+ * may be some delay until performed pool operations are visible in the statistics.
*
* A single call may read statistics from one to ODP_POOL_MAX_THREAD_STATS
* threads. Set 'stats.thread.first' and 'stats.thread.last' to select the
@@ -176,7 +177,29 @@ int odp_pool_index(odp_pool_t pool);
int odp_pool_stats(odp_pool_t pool, odp_pool_stats_t *stats);
/**
- * Reset statistics for pool handle
+ * Get selected pool statistics
+ *
+ * Read the selected counters given in odp_pool_stats_opt_t bit field structure. Only counters
+ * included in odp_pool_stats_selected_t can be read and the selected counters must have been
+ * enabled during pool creation. Values of the unselected counters are undefined. Depending on the
+ * implementation, there may be some delay until performed pool operations are visible in the
+ * statistics.
+ *
+ * Depending on the implementation, this function may have higher performance compared to
+ * odp_pool_stats(), as only the selected set of counters is read.
+ *
+ * @param pool Pool handle
+ * @param[out] stats Output buffer for counters
+ * @param opt Bit field for selecting the counters to be read
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_pool_stats_selected(odp_pool_t pool, odp_pool_stats_selected_t *stats,
+ const odp_pool_stats_opt_t *opt);
+
+/**
+ * Reset statistics for pool
*
* Reset all statistics counters to zero except: odp_pool_stats_t::available,
* odp_pool_stats_t::cache_available, odp_pool_stats_t::thread::cache_available
diff --git a/include/odp/api/spec/pool_types.h b/include/odp/api/spec/pool_types.h
index e9b1f9d52..cf1051a07 100644
--- a/include/odp/api/spec/pool_types.h
+++ b/include/odp/api/spec/pool_types.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2021-2022, Nokia
+/* Copyright (c) 2021-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -56,31 +56,31 @@ extern "C" {
typedef union odp_pool_stats_opt_t {
/** Option flags */
struct {
- /** @see odp_pool_stats_t::available */
+ /** See odp_pool_stats_t::available */
uint64_t available : 1;
- /** @see odp_pool_stats_t::alloc_ops */
+ /** See odp_pool_stats_t::alloc_ops */
uint64_t alloc_ops : 1;
- /** @see odp_pool_stats_t::alloc_fails */
+ /** See odp_pool_stats_t::alloc_fails */
uint64_t alloc_fails : 1;
- /** @see odp_pool_stats_t::free_ops */
+ /** See odp_pool_stats_t::free_ops */
uint64_t free_ops : 1;
- /** @see odp_pool_stats_t::total_ops */
+ /** See odp_pool_stats_t::total_ops */
uint64_t total_ops : 1;
- /** @see odp_pool_stats_t::cache_available */
+ /** See odp_pool_stats_t::cache_available */
uint64_t cache_available : 1;
- /** @see odp_pool_stats_t::cache_alloc_ops */
+ /** See odp_pool_stats_t::cache_alloc_ops */
uint64_t cache_alloc_ops : 1;
- /** @see odp_pool_stats_t::cache_free_ops */
+ /** See odp_pool_stats_t::cache_free_ops */
uint64_t cache_free_ops : 1;
- /** @see odp_pool_stats_t::thread::cache_available */
+ /** See odp_pool_stats_t::thread::cache_available */
uint64_t thread_cache_available : 1;
} bit;
@@ -148,6 +148,38 @@ typedef struct odp_pool_stats_t {
} odp_pool_stats_t;
/**
+ * Pool statistics counters
+ *
+ * Same as odp_pool_stats_t excluding per thread counters.
+ */
+typedef struct odp_pool_stats_selected_t {
+ /** See odp_pool_stats_t::available */
+ uint64_t available;
+
+ /** See odp_pool_stats_t::alloc_ops */
+ uint64_t alloc_ops;
+
+ /** See odp_pool_stats_t::alloc_fails */
+ uint64_t alloc_fails;
+
+ /** See odp_pool_stats_t::free_ops */
+ uint64_t free_ops;
+
+ /** See odp_pool_stats_t::total_ops */
+ uint64_t total_ops;
+
+ /** See odp_pool_stats_t::cache_available */
+ uint64_t cache_available;
+
+ /** See odp_pool_stats_t::cache_alloc_ops */
+ uint64_t cache_alloc_ops;
+
+ /** See odp_pool_stats_t::cache_free_ops */
+ uint64_t cache_free_ops;
+
+} odp_pool_stats_selected_t;
+
+/**
* Pool capabilities
*/
typedef struct odp_pool_capability_t {
@@ -449,7 +481,7 @@ typedef struct odp_pool_param_t {
/** Minimum packet data alignment in bytes.
*
* Valid values are powers of two. User allocated packets have
- * start of data (@see odp_packet_data()) aligned to this or
+ * start of data (see odp_packet_data()) aligned to this or
* a higher alignment (power of two value). This parameter
* does not apply to packets that ODP allocates internally
* (e.g. packets from packet input).
diff --git a/include/odp/api/spec/schedule.h b/include/odp/api/spec/schedule.h
index 417e5cb22..9aa898ccc 100644
--- a/include/odp/api/spec/schedule.h
+++ b/include/odp/api/spec/schedule.h
@@ -225,7 +225,7 @@ void odp_schedule_prefetch(int num);
* Maximum scheduling priority level
*
* This is the maximum value that can be set to 'prio' field in
- * odp_schedule_param_t (e.g. @see odp_queue_create()). Queues with a higher
+ * odp_schedule_param_t (e.g. odp_queue_create()). Queues with a higher
* priority value are served with higher priority than queues with a lower
* priority value.
*
@@ -237,7 +237,7 @@ int odp_schedule_max_prio(void);
* Minimum scheduling priority level
*
* This is the minimum value that can be set to 'prio' field in
- * odp_schedule_param_t (e.g. @see odp_queue_create()). Queues with a higher
+ * odp_schedule_param_t (e.g. odp_queue_create()). Queues with a higher
* priority value are served with higher priority than queues with a lower
* priority value.
*
@@ -249,7 +249,7 @@ int odp_schedule_min_prio(void);
* Default scheduling priority level
*
* This is the default value of 'prio' field in odp_schedule_param_t
- * (e.g. @see odp_queue_param_init()). The default value should be suitable for
+ * (e.g. odp_queue_param_init()). The default value should be suitable for
* an application that uses single priority level for all its queues (uses
* scheduler only for load balancing and synchronization). Typically,
* the default value is between minimum and maximum values, but with a few
@@ -534,6 +534,7 @@ void odp_schedule_order_lock_wait(uint32_t lock_index);
* an ordered scheduling context or if an ordered lock is being held.
*
* This functions does nothing if ordered wait is not supported.
+ *
* @see odp_schedule_capability()
*/
void odp_schedule_order_wait(void);
diff --git a/include/odp/api/spec/shared_memory.h b/include/odp/api/spec/shared_memory.h
index eebf288c9..52fbd7ae9 100644
--- a/include/odp/api/spec/shared_memory.h
+++ b/include/odp/api/spec/shared_memory.h
@@ -295,7 +295,7 @@ int odp_shm_info(odp_shm_t shm, odp_shm_info_t *info);
* SHM block segmentation information
*
* Retrieve information about each memory segment of an SHM block. SHM info call outputs the number
- * of memory segments (@see odp_shm_info_t.num_seg). A single segment info call may be used
+ * of memory segments (odp_shm_info_t::num_seg). A single segment info call may be used
* to request information for all the segments, or for a subset of those. Use 'index' and 'num'
* parameters to specify the segments. Segment indexing starts from zero and continues to
* odp_shm_info_t.num_seg - 1. Segment infos are written in virtual memory address order and
diff --git a/include/odp/api/spec/stash_types.h b/include/odp/api/spec/stash_types.h
index 30fff26c4..3e6e966be 100644
--- a/include/odp/api/spec/stash_types.h
+++ b/include/odp/api/spec/stash_types.h
@@ -106,10 +106,10 @@ typedef enum odp_stash_op_mode_t {
typedef union odp_stash_stats_opt_t {
/** Option flags */
struct {
- /** @see odp_stash_stats_t::count */
+ /** See odp_stash_stats_t::count */
uint64_t count : 1;
- /** @see odp_stash_stats_t::cache_count */
+ /** See odp_stash_stats_t::cache_count */
uint64_t cache_count : 1;
} bit;
diff --git a/include/odp/api/spec/time.h b/include/odp/api/spec/time.h
index c25338a51..f4496c4c7 100644
--- a/include/odp/api/spec/time.h
+++ b/include/odp/api/spec/time.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2020-2021, Nokia
+ * Copyright (c) 2020-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -19,39 +19,14 @@
extern "C" {
#endif
+#include <odp/api/std_types.h>
+#include <odp/api/time_types.h>
+
/** @defgroup odp_time ODP TIME
* Chip and CPU level wall clock time.
* @{
*/
-/** A microsecond in nanoseconds */
-#define ODP_TIME_USEC_IN_NS 1000ULL
-
-/** A millisecond in nanoseconds */
-#define ODP_TIME_MSEC_IN_NS 1000000ULL
-
-/** A second in nanoseconds */
-#define ODP_TIME_SEC_IN_NS 1000000000ULL
-
-/** A minute in nanoseconds */
-#define ODP_TIME_MIN_IN_NS 60000000000ULL
-
-/** An hour in nanoseconds */
-#define ODP_TIME_HOUR_IN_NS 3600000000000ULL
-
-/**
- * @typedef odp_time_t
- * ODP time stamp. Time stamp can represent a time stamp from local or global
- * time source. A local time stamp must not be shared between threads. API calls
- * work correctly only when all time stamps for input are from the same time
- * source.
- */
-
-/**
- * @def ODP_TIME_NULL
- * Zero time stamp
- */
-
/**
* Current local time
*
diff --git a/include/odp/api/spec/time_types.h b/include/odp/api/spec/time_types.h
new file mode 100644
index 000000000..9065b8004
--- /dev/null
+++ b/include/odp/api/spec/time_types.h
@@ -0,0 +1,63 @@
+/* Copyright (c) 2013-2018, Linaro Limited
+ * Copyright (c) 2020-2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP time
+ */
+
+#ifndef ODP_API_SPEC_TIME_TYPES_H_
+#define ODP_API_SPEC_TIME_TYPES_H_
+#include <odp/visibility_begin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @addtogroup odp_time
+ * @{
+ */
+
+/** A microsecond in nanoseconds */
+#define ODP_TIME_USEC_IN_NS 1000ULL
+
+/** A millisecond in nanoseconds */
+#define ODP_TIME_MSEC_IN_NS 1000000ULL
+
+/** A second in nanoseconds */
+#define ODP_TIME_SEC_IN_NS 1000000000ULL
+
+/** A minute in nanoseconds */
+#define ODP_TIME_MIN_IN_NS 60000000000ULL
+
+/** An hour in nanoseconds */
+#define ODP_TIME_HOUR_IN_NS 3600000000000ULL
+
+/**
+ * @typedef odp_time_t
+ * ODP time stamp. Time stamp can represent a time stamp from local or global
+ * time source. A local time stamp must not be shared between threads. API calls
+ * work correctly only when all time stamps for input are from the same time
+ * source.
+ */
+
+/**
+ * @def ODP_TIME_NULL
+ * Zero time stamp
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <odp/visibility_end.h>
+#endif
diff --git a/include/odp/api/spec/timer.h b/include/odp/api/spec/timer.h
index 7982e391b..bbb439692 100644
--- a/include/odp/api/spec/timer.h
+++ b/include/odp/api/spec/timer.h
@@ -75,11 +75,14 @@ int odp_timer_res_capability(odp_timer_clk_src_t clk_src,
* frequency multiplier and the minimum timeout resolution. If there is no requirement for timeout
* resolution, it is set to zero.
*
- * A successful call overwrites all 'capa' fields with the resulting values. Return value
- * is 1 when timer capability meets or exceeds all requested values. The call returns 0, when
- * the requested base frequency is not supported exactly, but capability meets or exceeds all other
- * requested values. In this case, the call overwrites 'base_freq_hz' with the closest supported
- * frequency.
+ * When the call returns success, 'capa' fields are overwritten in following ways. On return value
+ * of 1, timer supports the requested base frequency exactly, and meets or exceeds other requested
+ * values. The base frequency value is not modified, but other 'capa' fields are updated with
+ * resulting maximum capabilities.
+ *
+ * When the call returns 0, the requested base frequency is not supported exactly, but timer
+ * capabilities meet or exceed all other requested values. In this case, the call overwrites
+ * 'base_freq_hz' with the closest supported frequency and updates other 'capa' fields accordingly.
*
* Failure is returned when the requirements are not supported or the call fails otherwise.
*
@@ -115,8 +118,11 @@ void odp_timer_pool_param_init(odp_timer_pool_param_t *param);
* to initialize timer pool parameters into their default values.
*
* Periodic timer expiration frequency is a multiple of the timer pool base frequency
- * (odp_timer_pool_param_t::base_freq_hz). Use odp_timer_periodic_capability() to check
- * which base frequencies and multipliers are supported.
+ * (odp_timer_pool_param_t::base_freq_hz). Depending on implementation, the base frequency may need
+ * to be selected carefully with respect to the timer pool source clock frequency. Use
+ * odp_timer_periodic_capability() to check which base frequencies and multipliers are supported.
+ *
+ * The call returns failure when requested parameter values are not supported.
*
* @param name Name of the timer pool or NULL. Maximum string length is
* ODP_TIMER_POOL_NAME_LEN.
@@ -125,8 +131,7 @@ void odp_timer_pool_param_init(odp_timer_pool_param_t *param);
* @return Timer pool handle on success
* @retval ODP_TIMER_POOL_INVALID on failure
*/
-odp_timer_pool_t odp_timer_pool_create(const char *name,
- const odp_timer_pool_param_t *params);
+odp_timer_pool_t odp_timer_pool_create(const char *name, const odp_timer_pool_param_t *params);
/**
* Start a timer pool
@@ -186,6 +191,28 @@ uint64_t odp_timer_ns_to_tick(odp_timer_pool_t timer_pool, uint64_t ns);
uint64_t odp_timer_current_tick(odp_timer_pool_t timer_pool);
/**
+ * Sample tick values of timer pools
+ *
+ * Reads timer pool tick values simultaneously (or closely back-to-back) from all requested timer
+ * pools, and outputs those on success. Optionally, outputs corresponding source clock (HW) counter
+ * values, which are implementation specific and may be used for debugging. When a timer pool does
+ * not support reading of the source clock value, zero is written instead. Values are written into
+ * the output arrays in the same order which timer pools were defined. Nothing is written on
+ * failure.
+ *
+ * @param timer_pool Timer pools to sample
+ * @param[out] tick Tick value array for output (one element per timer pool)
+ * @param[out] clk_count Source clock counter value array for output (one element per
+ * timer pool), or NULL when counter values are not requested.
+ * @param num Number of timer pools to sample
+ *
+ * @retval 0 All requested timer pools sampled successfully
+ * @retval -1 Failure
+ */
+int odp_timer_sample_ticks(odp_timer_pool_t timer_pool[], uint64_t tick[], uint64_t clk_count[],
+ int num);
+
+/**
* Query timer pool configuration and current state
*
* @param timer_pool Timer pool
@@ -422,19 +449,22 @@ int ODP_DEPRECATE(odp_timer_set_rel)(odp_timer_t timer, uint64_t rel_tick, odp_e
/**
* Cancel a timer
*
- * Cancels a previously started single shot timer. A successful operation prevents timer
- * expiration and returns the timeout event back to application. Application may use or free
- * the event normally.
+ * Cancels a previously started single shot timer. A successful operation (#ODP_TIMER_SUCCESS)
+ * prevents timer expiration and returns the timeout event back to application. Application may
+ * use or free the event normally.
*
* When the timer is close to expire or has expired already, the call may not be able cancel it
- * anymore. In this case, the call returns failure and the timeout is delivered to the destination
- * queue.
+ * anymore. In this case, the call returns #ODP_TIMER_TOO_NEAR and the timeout is delivered to
+ * the destination queue.
*
* @param timer Timer
- * @param[out] tmo_ev Pointer to an event handle for output
+ * @param[out] tmo_ev Pointer to an event handle for output. Event handle is written only
+ * on success.
*
- * @retval 0 Success. Active timer cancelled, timeout returned in 'tmo_ev'
- * @retval <0 Failure. Timer inactive or already expired.
+ * @retval ODP_TIMER_SUCCESS Timer was cancelled successfully. Timeout event returned in 'tmo_ev'.
+ * @retval ODP_TIMER_TOO_NEAR Timer cannot be cancelled. Timer has expired already, or cannot be
+ * cancelled due to close expiration time.
+ * @retval ODP_TIMER_FAIL Other failure.
*/
int odp_timer_cancel(odp_timer_t timer, odp_event_t *tmo_ev);
diff --git a/include/odp/api/spec/timer_types.h b/include/odp/api/spec/timer_types.h
index fd23bdeca..f1e199352 100644
--- a/include/odp/api/spec/timer_types.h
+++ b/include/odp/api/spec/timer_types.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
+ * Copyright (c) 2019-2023, Nokia
*
* All rights reserved.
*
@@ -102,7 +102,15 @@ typedef struct {
* Periodic timer capability
*/
typedef struct {
- /** Periodic timer pool base frequency in hertz */
+ /**
+ * Periodic timer pool base frequency in hertz
+ *
+ * Base frequency is represented as a fractional number where the fraction part is always
+ * less than one. In other words, the integer part specifies whole hertz whereas
+ * the fraction part specifies parts of a hertz (if any). The fraction part does not
+ * need to be reduced to its lowest terms - e.g. 100.5 Hz may be represented as 100 1/2 Hz,
+ * 100 5/10 Hz, or 100 Hz with some other equivalent fraction part.
+ */
odp_fract_u64_t base_freq_hz;
/** Maximum base frequency multiplier */
@@ -358,7 +366,9 @@ typedef struct {
* Use odp_timer_periodic_capability() to check base frequency support,
* and resulting max_multiplier and resolution values.
*
- * The default value is zero.
+ * Fraction part of the value is always less than one, see
+ * odp_timer_periodic_capability_t::base_freq_hz for details. The default value
+ * is zero.
*
* An example with two timer frequencies:
* base_freq_hz.integer = 33333, .numer = 1, .denom = 3
@@ -477,9 +487,9 @@ typedef struct odp_timer_periodic_start_t {
/** First expiration time
*
* The first expiration time in absolute timer ticks. When zero, the first expiration time
- * is one period after the current time. After the first expiration, timer expiration
- * continues with the defined frequency. The tick value must be within one timer period
- * from the current time.
+ * is one period after the current time, or as close to that as the implementation can
+ * achieve. After the first expiration, timer expiration continues with the defined
+ * frequency. The tick value must be less than one timer period after the current time.
*/
uint64_t first_tick;
@@ -505,24 +515,49 @@ typedef struct odp_timer_periodic_start_t {
} odp_timer_periodic_start_t;
/**
- * Return values of timer set calls.
+ * Return values for timer start, restart and cancel calls
*/
typedef enum {
- /** Timer set operation succeeded */
+ /**
+ * Timer operation succeeded
+ *
+ * Timer start, restart and cancel operations may return this value.
+ */
ODP_TIMER_SUCCESS = 0,
- /** Timer set operation failed because expiration time is too near to
- * the current time. */
+ /**
+ * Timer operation failed, too near to the current time
+ *
+ * The operation failed because the requested time/timer has expired already, or is too
+ * near to the current time. Timer start, restart and cancel operations may return this
+ * value.
+ */
ODP_TIMER_TOO_NEAR = -1,
- /** Timer set operation failed because expiration time is too far from
- * the current time. */
+ /**
+ * Timer operation failed, too far from the current time
+ *
+ * The operation failed because the requested time is too far from the current time.
+ * Only timer start and restart operations may return this value.
+ */
ODP_TIMER_TOO_FAR = -2,
- /** Timer set operation failed */
+ /**
+ * Timer operation failed
+ *
+ * The operation failed due to some other reason than timing of the request. Timer start,
+ * restart and cancel operations may return this value.
+ */
ODP_TIMER_FAIL = -3
-} odp_timer_set_t;
+} odp_timer_retval_t;
+
+/**
+ * For backwards compatibility, odp_timer_set_t is synonym of odp_timer_retval_t
+ *
+ * @deprecated Use odp_timer_retval_t instead.
+ */
+typedef odp_timer_retval_t odp_timer_set_t;
#if ODP_DEPRECATED_API
/**
diff --git a/include/odp/api/spec/traffic_mngr.h b/include/odp/api/spec/traffic_mngr.h
index 9bd735a7a..2331cc133 100644
--- a/include/odp/api/spec/traffic_mngr.h
+++ b/include/odp/api/spec/traffic_mngr.h
@@ -206,19 +206,19 @@ typedef struct odp_tm_queue_stats_capability_t {
union {
/** Statistics counters in a bit field structure */
struct {
- /** @see odp_tm_queue_stats_t::octets */
+ /** See odp_tm_queue_stats_t::octets */
uint64_t octets : 1;
- /** @see odp_tm_queue_stats_t::packets */
+ /** See odp_tm_queue_stats_t::packets */
uint64_t packets : 1;
- /** @see odp_tm_queue_stats_t::discards */
+ /** See odp_tm_queue_stats_t::discards */
uint64_t discards : 1;
- /** @see odp_tm_queue_stats_t::discard_octets */
+ /** See odp_tm_queue_stats_t::discard_octets */
uint64_t discard_octets : 1;
- /** @see odp_tm_queue_stats_t::errors */
+ /** See odp_tm_queue_stats_t::errors */
uint64_t errors : 1;
} counter;
diff --git a/include/odp/api/time.h b/include/odp/api/time.h
index 125e9118b..fb550724d 100644
--- a/include/odp/api/time.h
+++ b/include/odp/api/time.h
@@ -17,7 +17,6 @@
extern "C" {
#endif
-#include <odp/api/std_types.h>
#include <odp/api/abi/time.h>
#include <odp/api/spec/time.h>
diff --git a/include/odp/api/time_types.h b/include/odp/api/time_types.h
new file mode 100644
index 000000000..f7281d456
--- /dev/null
+++ b/include/odp/api/time_types.h
@@ -0,0 +1,28 @@
+/* Copyright (c) 2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP time
+ */
+
+#ifndef ODP_API_TIME_TYPES_H_
+#define ODP_API_TIME_TYPES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp/api/abi/time_types.h>
+
+#include <odp/api/spec/time_types.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/odp/arch/arm32-linux/odp/api/abi/time_types.h b/include/odp/arch/arm32-linux/odp/api/abi/time_types.h
new file mode 100644
index 000000000..cba80f508
--- /dev/null
+++ b/include/odp/arch/arm32-linux/odp/api/abi/time_types.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp/api/abi-default/time_types.h>
diff --git a/include/odp/arch/arm64-linux/odp/api/abi/time_types.h b/include/odp/arch/arm64-linux/odp/api/abi/time_types.h
new file mode 100644
index 000000000..cba80f508
--- /dev/null
+++ b/include/odp/arch/arm64-linux/odp/api/abi/time_types.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp/api/abi-default/time_types.h>
diff --git a/include/odp/arch/default-linux/odp/api/abi/time_types.h b/include/odp/arch/default-linux/odp/api/abi/time_types.h
new file mode 100644
index 000000000..cba80f508
--- /dev/null
+++ b/include/odp/arch/default-linux/odp/api/abi/time_types.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp/api/abi-default/time_types.h>
diff --git a/include/odp/arch/power64-linux/odp/api/abi/time_types.h b/include/odp/arch/power64-linux/odp/api/abi/time_types.h
new file mode 100644
index 000000000..cba80f508
--- /dev/null
+++ b/include/odp/arch/power64-linux/odp/api/abi/time_types.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp/api/abi-default/time_types.h>
diff --git a/include/odp/arch/x86_32-linux/odp/api/abi/time_types.h b/include/odp/arch/x86_32-linux/odp/api/abi/time_types.h
new file mode 100644
index 000000000..cba80f508
--- /dev/null
+++ b/include/odp/arch/x86_32-linux/odp/api/abi/time_types.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp/api/abi-default/time_types.h>
diff --git a/include/odp/arch/x86_64-linux/odp/api/abi/time_types.h b/include/odp/arch/x86_64-linux/odp/api/abi/time_types.h
new file mode 100644
index 000000000..cba80f508
--- /dev/null
+++ b/include/odp/arch/x86_64-linux/odp/api/abi/time_types.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp/api/abi-default/time_types.h>
diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am
index 76e205212..252b34fb2 100644
--- a/platform/linux-dpdk/Makefile.am
+++ b/platform/linux-dpdk/Makefile.am
@@ -114,6 +114,7 @@ odpapiabiarchinclude_HEADERS += \
include-abi/odp/api/abi/thrmask.h \
include-abi/odp/api/abi/ticketlock.h \
include-abi/odp/api/abi/time.h \
+ include-abi/odp/api/abi/time_types.h \
include-abi/odp/api/abi/timer.h \
include-abi/odp/api/abi/timer_types.h \
include-abi/odp/api/abi/traffic_mngr.h \
diff --git a/platform/linux-dpdk/include-abi/odp/api/abi/time_types.h b/platform/linux-dpdk/include-abi/odp/api/abi/time_types.h
new file mode 120000
index 000000000..2f280c709
--- /dev/null
+++ b/platform/linux-dpdk/include-abi/odp/api/abi/time_types.h
@@ -0,0 +1 @@
+../../../../../linux-generic/include-abi/odp/api/abi/time_types.h \ No newline at end of file
diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_inline_types.h b/platform/linux-dpdk/include/odp/api/plat/packet_inline_types.h
index c6ede5d3a..5466ce58b 100644
--- a/platform/linux-dpdk/include/odp/api/plat/packet_inline_types.h
+++ b/platform/linux-dpdk/include/odp/api/plat/packet_inline_types.h
@@ -121,7 +121,7 @@ typedef union {
uint32_t all_flags;
struct {
- uint32_t reserved1: 6;
+ uint32_t reserved1: 5;
/*
* Init flags
@@ -140,6 +140,7 @@ typedef union {
uint32_t l4_chksum: 1; /* L4 chksum override */
uint32_t ts_set: 1; /* Set Tx timestamp */
uint32_t tx_compl: 1; /* Tx completion event requested */
+ uint32_t free_ctrl: 1; /* Don't free option */
uint32_t tx_aging: 1; /* Packet aging at Tx requested */
uint32_t shaper_len_adj: 8; /* Adjustment for traffic mgr */
@@ -157,8 +158,8 @@ typedef union {
/* Flag groups */
struct {
- uint32_t reserved2: 6;
- uint32_t other: 19; /* All other flags */
+ uint32_t reserved2: 5;
+ uint32_t other: 20; /* All other flags */
uint32_t error: 7; /* All error flags */
} all;
diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h b/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
index 4ae53c7b3..7b2764a05 100644
--- a/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
+++ b/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
@@ -22,7 +22,7 @@ extern "C" {
#include <odp/api/hints.h>
#include <odp/api/packet_types.h>
#include <odp/api/pool_types.h>
-#include <odp/api/time.h>
+#include <odp/api/time_types.h>
#include <odp/api/plat/debug_inlines.h>
#include <odp/api/plat/event_validation_external.h>
diff --git a/platform/linux-dpdk/include/odp/api/plat/time_inlines.h b/platform/linux-dpdk/include/odp/api/plat/time_inlines.h
index 0ab2b37c0..4b1320300 100644
--- a/platform/linux-dpdk/include/odp/api/plat/time_inlines.h
+++ b/platform/linux-dpdk/include/odp/api/plat/time_inlines.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2020-2022, Nokia
+ * Copyright (c) 2020-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -8,13 +8,14 @@
#ifndef ODP_PLAT_TIME_INLINES_H_
#define ODP_PLAT_TIME_INLINES_H_
-#include <stdint.h>
-
#include <odp/api/align.h>
#include <odp/api/hints.h>
+#include <odp/api/time_types.h>
#include <odp/api/abi/cpu_time.h>
+#include <stdint.h>
+
/** @cond _ODP_HIDE_FROM_DOXYGEN_ */
#define _ODP_TIMESPEC_SIZE 16
diff --git a/platform/linux-dpdk/include/odp_event_internal.h b/platform/linux-dpdk/include/odp_event_internal.h
index 6a707606a..cbe6d960b 100644
--- a/platform/linux-dpdk/include/odp_event_internal.h
+++ b/platform/linux-dpdk/include/odp_event_internal.h
@@ -46,6 +46,9 @@ typedef struct _odp_event_hdr_int_t {
/* Event type. Maybe different than pool type (crypto compl event) */
int8_t event_type;
+ /* Event subtype */
+ int8_t subtype;
+
/* Event flow id */
uint8_t flow_id;
diff --git a/platform/linux-dpdk/include/odp_packet_internal.h b/platform/linux-dpdk/include/odp_packet_internal.h
index df4f2318e..37729b8f5 100644
--- a/platform/linux-dpdk/include/odp_packet_internal.h
+++ b/platform/linux-dpdk/include/odp_packet_internal.h
@@ -124,8 +124,10 @@ typedef struct ODP_ALIGNED_CACHE odp_packet_hdr_t {
/* Common internal header */
_odp_event_hdr_int_t event_hdr;
+ /* Parser metadata */
packet_parser_t p;
+ /* Input interface */
odp_pktio_t input;
/* Timestamp value */
@@ -162,9 +164,6 @@ typedef struct ODP_ALIGNED_CACHE odp_packet_hdr_t {
/* LSO profile index */
uint8_t lso_profile_idx;
- /* Event subtype */
- int8_t subtype;
-
union {
/* Result for crypto packet op */
odp_crypto_packet_result_t crypto_op_result;
@@ -215,7 +214,7 @@ static inline struct rte_mbuf *pkt_to_mbuf(odp_packet_t pkt)
static inline void packet_subtype_set(odp_packet_t pkt, int ev)
{
- packet_hdr(pkt)->subtype = ev;
+ packet_hdr(pkt)->event_hdr.subtype = ev;
}
/**
@@ -231,9 +230,7 @@ static inline void packet_init(odp_packet_hdr_t *pkt_hdr, odp_pktio_t input)
pkt_hdr->p.l3_offset = ODP_PACKET_OFFSET_INVALID;
pkt_hdr->p.l4_offset = ODP_PACKET_OFFSET_INVALID;
- if (odp_unlikely(pkt_hdr->subtype != ODP_EVENT_PACKET_BASIC))
- pkt_hdr->subtype = ODP_EVENT_PACKET_BASIC;
-
+ pkt_hdr->event_hdr.subtype = ODP_EVENT_PACKET_BASIC;
pkt_hdr->input = input;
}
@@ -277,10 +274,10 @@ static inline void _odp_packet_copy_md(odp_packet_hdr_t *dst_hdr,
odp_packet_hdr_t *src_hdr,
odp_bool_t uarea_copy)
{
- const int8_t subtype = src_hdr->subtype;
+ const int8_t subtype = src_hdr->event_hdr.subtype;
dst_hdr->input = src_hdr->input;
- dst_hdr->subtype = subtype;
+ dst_hdr->event_hdr.subtype = subtype;
dst_hdr->dst_queue = src_hdr->dst_queue;
dst_hdr->cos = src_hdr->cos;
dst_hdr->cls_mark = src_hdr->cls_mark;
diff --git a/platform/linux-dpdk/include/odp_packet_io_internal.h b/platform/linux-dpdk/include/odp_packet_io_internal.h
index 2efa52b67..ac22cff99 100644
--- a/platform/linux-dpdk/include/odp_packet_io_internal.h
+++ b/platform/linux-dpdk/include/odp_packet_io_internal.h
@@ -23,6 +23,7 @@ extern "C" {
#include <odp/api/packet_io.h>
#include <odp/api/spinlock.h>
#include <odp/api/ticketlock.h>
+#include <odp/api/time.h>
#include <odp/api/plat/packet_io_inlines.h>
diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c
index d35c63692..c7ae1ea47 100644
--- a/platform/linux-dpdk/odp_init.c
+++ b/platform/linux-dpdk/odp_init.c
@@ -26,6 +26,7 @@
#include <inttypes.h>
#include <rte_config.h>
+#include <rte_debug.h>
#include <rte_eal.h>
#include <rte_string_fns.h>
@@ -872,6 +873,28 @@ int odp_term_local(void)
return term_local(ALL_INIT);
}
+int odp_term_abnormal(odp_instance_t instance, uint64_t flags, void *data ODP_UNUSED)
+{
+ rte_dump_stack();
+
+ if (flags & ODP_TERM_FROM_SIGH)
+ /* Called from signal handler, not safe to terminate with local/global,
+ * return with failure as not able to perform all actions */
+ return -1;
+
+ if (odp_term_local() < 0) {
+ _ODP_ERR("ODP local terminate failed.\n");
+ return -2;
+ }
+
+ if (odp_term_global(instance) < 0) {
+ _ODP_ERR("ODP global terminate failed.\n");
+ return -3;
+ }
+
+ return 0;
+}
+
void odp_log_thread_fn_set(odp_log_func_t func)
{
_odp_this_thread->log_fn = func;
diff --git a/platform/linux-dpdk/odp_packet.c b/platform/linux-dpdk/odp_packet.c
index 06c6c36ad..95149118e 100644
--- a/platform/linux-dpdk/odp_packet.c
+++ b/platform/linux-dpdk/odp_packet.c
@@ -64,7 +64,7 @@ const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = {
.timestamp = offsetof(odp_packet_hdr_t, timestamp),
.input_flags = offsetof(odp_packet_hdr_t, p.input_flags),
.flags = offsetof(odp_packet_hdr_t, p.flags),
- .subtype = offsetof(odp_packet_hdr_t, subtype),
+ .subtype = offsetof(odp_packet_hdr_t, event_hdr.subtype),
.cls_mark = offsetof(odp_packet_hdr_t, cls_mark),
.ipsec_ctx = offsetof(odp_packet_hdr_t, ipsec_ctx),
.crypto_op = offsetof(odp_packet_hdr_t, crypto_op_result),
@@ -1018,7 +1018,7 @@ void odp_packet_print(odp_packet_t pkt)
odp_packet_to_u64(pkt));
len += _odp_snprint(&str[len], n - len, " pool index %u\n", pool->pool_idx);
len += _odp_snprint(&str[len], n - len, " buf index %u\n", hdr->event_hdr.index);
- len += _odp_snprint(&str[len], n - len, " ev subtype %i\n", hdr->subtype);
+ len += _odp_snprint(&str[len], n - len, " ev subtype %i\n", hdr->event_hdr.subtype);
len += _odp_snprint(&str[len], n - len, " input_flags 0x%" PRIx64 "\n",
hdr->p.input_flags.all);
if (hdr->p.input_flags.all) {
@@ -1766,7 +1766,7 @@ int odp_packet_tx_compl_request(odp_packet_t pkt, const odp_packet_tx_compl_opt_
{
odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
- pkt_hdr->p.flags.tx_compl = opt->mode == ODP_PACKET_TX_COMPL_ALL ? 1 : 0;
+ pkt_hdr->p.flags.tx_compl = opt->mode == ODP_PACKET_TX_COMPL_EVENT ? 1 : 0;
pkt_hdr->dst_queue = opt->queue;
return 0;
@@ -1801,6 +1801,34 @@ void *odp_packet_tx_compl_user_ptr(odp_packet_tx_compl_t tx_compl)
return (void *)(uintptr_t)data->user_ptr;
}
+int odp_packet_tx_compl_done(odp_pktio_t pktio, uint32_t compl_id)
+{
+ (void)pktio;
+ (void)compl_id;
+
+ return -1;
+}
+
+void odp_packet_free_ctrl_set(odp_packet_t pkt, odp_packet_free_ctrl_t ctrl)
+{
+ odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
+
+ if (ctrl == ODP_PACKET_FREE_CTRL_DONT_FREE)
+ pkt_hdr->p.flags.free_ctrl = 1;
+ else
+ pkt_hdr->p.flags.free_ctrl = 0;
+}
+
+odp_packet_free_ctrl_t odp_packet_free_ctrl(odp_packet_t pkt)
+{
+ odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
+
+ if (pkt_hdr->p.flags.free_ctrl)
+ return ODP_PACKET_FREE_CTRL_DONT_FREE;
+
+ return ODP_PACKET_FREE_CTRL_DISABLED;
+}
+
odp_packet_reass_status_t odp_packet_reass_status(odp_packet_t pkt)
{
(void)pkt;
@@ -1903,7 +1931,7 @@ odp_packet_t odp_packet_reassemble(odp_pool_t pool_hdl,
pkt_hdr->mb.data_off = headroom;
/* Reset metadata */
- pkt_hdr->subtype = ODP_EVENT_PACKET_BASIC;
+ pkt_hdr->event_hdr.subtype = ODP_EVENT_PACKET_BASIC;
pkt_hdr->input = ODP_PKTIO_INVALID;
packet_parse_reset(pkt_hdr, 1);
diff --git a/platform/linux-dpdk/odp_packet_dpdk.c b/platform/linux-dpdk/odp_packet_dpdk.c
index 238f733cd..c4fa3f0b7 100644
--- a/platform/linux-dpdk/odp_packet_dpdk.c
+++ b/platform/linux-dpdk/odp_packet_dpdk.c
@@ -127,6 +127,9 @@ typedef struct {
typedef struct ODP_ALIGNED_CACHE {
/* --- Fast path data --- */
+ /* Function for mbuf to ODP packet conversion */
+ int (*mbuf_to_pkt_fn)(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[], uint16_t num);
+
/* DPDK port identifier */
uint16_t port_id;
struct {
@@ -187,6 +190,11 @@ extern void *pktio_entry_ptr[ODP_CONFIG_PKTIO_ENTRIES];
static uint32_t mtu_get_pkt_dpdk(pktio_entry_t *pktio_entry);
+static inline int input_pkts(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[], uint16_t num);
+
+static inline int input_pkts_minimal(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[],
+ uint16_t num);
+
uint16_t _odp_dpdk_pktio_port_id(pktio_entry_t *pktio_entry)
{
const pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry);
@@ -901,6 +909,12 @@ static int dpdk_start(pktio_entry_t *pktio_entry)
}
}
+ /* Use simpler function when packet parsing and classifying are not required */
+ if (pktio_entry->parse_layer == ODP_PROTO_LAYER_NONE)
+ pkt_dpdk->mbuf_to_pkt_fn = input_pkts_minimal;
+ else
+ pkt_dpdk->mbuf_to_pkt_fn = input_pkts;
+
/* Start device */
ret = rte_eth_dev_start(port_id);
if (ret < 0) {
@@ -929,19 +943,60 @@ static inline void prefetch_pkt(odp_packet_t pkt)
{
odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
- odp_prefetch(&pkt_hdr->p);
+ odp_prefetch_store(&pkt_hdr->p);
}
-static inline int input_pkts(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[], int num)
+/**
+ * Input packets when packet parsing and classifier are disabled
+ */
+static inline int input_pkts_minimal(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[],
+ uint16_t num)
{
uint16_t i;
- uint16_t num_pkts = 0;
- odp_pktin_config_opt_t pktin_cfg = pktio_entry->config.pktin;
- odp_pktio_t input = pktio_entry->handle;
odp_time_t ts_val;
odp_time_t *ts = NULL;
- uint16_t num_prefetch = RTE_MIN(num, NUM_RX_PREFETCH);
+ const uint8_t ts_ena = (pktio_entry->config.pktin.bit.ts_all ||
+ pktio_entry->config.pktin.bit.ts_ptp);
+ const odp_pktio_t input = pktio_entry->handle;
+ const uint16_t num_prefetch = RTE_MIN(num, NUM_RX_PREFETCH);
+
+ for (i = 0; i < num_prefetch; i++)
+ prefetch_pkt(pkt_table[i]);
+
+ if (ts_ena) {
+ ts_val = odp_time_global();
+ ts = &ts_val;
+ }
+
+ for (i = 0; i < num; ++i) {
+ odp_packet_t pkt = pkt_table[i];
+ odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
+
+ if (odp_likely(i + num_prefetch < num))
+ prefetch_pkt(pkt_table[i + num_prefetch]);
+
+ packet_init(pkt_hdr, input);
+
+ packet_set_ts(pkt_hdr, ts);
+ }
+
+ return num;
+}
+
+/**
+ * input packets when packet parsing is required
+ */
+static inline int input_pkts(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[], uint16_t num)
+{
+ uint16_t i;
+ uint16_t num_pkts = 0, num_cls = 0;
+ odp_time_t ts_val;
+ odp_time_t *ts = NULL;
+ const odp_pktin_config_opt_t pktin_cfg = pktio_entry->config.pktin;
+ const odp_pktio_t input = pktio_entry->handle;
const odp_proto_layer_t layer = pktio_entry->parse_layer;
+ const int cls_enabled = pktio_cls_enabled(pktio_entry);
+ const uint16_t num_prefetch = RTE_MIN(num, NUM_RX_PREFETCH);
for (i = 0; i < num_prefetch; i++)
prefetch_pkt(pkt_table[i]);
@@ -955,47 +1010,34 @@ static inline int input_pkts(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[
odp_packet_t pkt = pkt_table[i];
odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
struct rte_mbuf *mbuf = pkt_to_mbuf(pkt);
+ int ret;
if (odp_likely(i + num_prefetch < num))
prefetch_pkt(pkt_table[i + num_prefetch]);
packet_init(pkt_hdr, input);
- if (layer != ODP_PROTO_LAYER_NONE) {
- int ret;
-
- ret = _odp_dpdk_packet_parse_common(pkt_hdr,
- rte_pktmbuf_mtod(mbuf, uint8_t *),
- rte_pktmbuf_pkt_len(mbuf),
- rte_pktmbuf_data_len(mbuf),
- mbuf, layer, pktin_cfg);
- if (odp_unlikely(ret)) {
- odp_atomic_inc_u64(&pktio_entry->stats_extra.in_errors);
+ ret = _odp_dpdk_packet_parse_common(pkt_hdr,
+ rte_pktmbuf_mtod(mbuf, uint8_t *),
+ rte_pktmbuf_pkt_len(mbuf),
+ rte_pktmbuf_data_len(mbuf),
+ mbuf, layer, pktin_cfg);
+ if (odp_unlikely(ret)) {
+ odp_atomic_inc_u64(&pktio_entry->stats_extra.in_errors);
- if (ret < 0) {
- odp_packet_free(pkt);
- continue;
- }
+ if (ret < 0) {
+ odp_packet_free(pkt);
+ continue;
}
-
- if (odp_unlikely(num_pkts != i))
- pkt_table[num_pkts] = pkt;
}
+
packet_set_ts(pkt_hdr, ts);
odp_prefetch(rte_pktmbuf_mtod(mbuf, char *));
- num_pkts++;
- }
-
- if (pktio_cls_enabled(pktio_entry)) {
- int success = 0;
- for (i = 0; i < num_pkts; i++) {
- odp_packet_t pkt = pkt_table[i];
+ if (cls_enabled) {
odp_pool_t new_pool;
uint8_t *data = odp_packet_data(pkt);
- odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
- int ret;
ret = _odp_cls_classify_packet(pktio_entry, data, &new_pool, pkt_hdr);
if (odp_unlikely(ret)) {
@@ -1014,23 +1056,29 @@ static inline int input_pkts(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[
odp_atomic_inc_u64(&pktio_entry->stats_extra.in_discards);
continue;
}
- pkt_table[i] = new_pkt;
pkt = new_pkt;
}
- if (success != i)
- pkt_table[success] = pkt;
- ++success;
+ /* Enqueue packets directly to classifier destination queue */
+ pkt_table[num_cls++] = pkt;
+ num_cls = _odp_cls_enq(pkt_table, num_cls, (i + 1 == num));
+ } else {
+ pkt_table[num_pkts++] = pkt;
}
- num_pkts = success;
}
+ /* Enqueue remaining classified packets */
+ if (odp_unlikely(num_cls))
+ _odp_cls_enq(pkt_table, num_cls, true);
+
return num_pkts;
}
int _odp_input_pkts(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[], int num)
{
- return input_pkts(pktio_entry, pkt_table, num);
+ pkt_dpdk_t * const pkt_dpdk = pkt_priv(pktio_entry);
+
+ return pkt_dpdk->mbuf_to_pkt_fn(pktio_entry, pkt_table, num);
}
static int recv_pkt_dpdk(pktio_entry_t *pktio_entry, int index,
@@ -1071,10 +1119,10 @@ static int recv_pkt_dpdk(pktio_entry_t *pktio_entry, int index,
odp_ticketlock_unlock(&pkt_dpdk->rx_lock[index]);
/* Packets may also me received through eventdev, so don't add any
- * processing here. Instead, perform all processing in input_pkts()
+ * processing here. Instead, perform all processing in mbuf_to_pkt_fn()
* which is also called by eventdev. */
if (nb_rx)
- return input_pkts(pktio_entry, pkt_table, nb_rx);
+ return pkt_dpdk->mbuf_to_pkt_fn(pktio_entry, pkt_table, nb_rx);
return 0;
}
diff --git a/platform/linux-dpdk/odp_pool.c b/platform/linux-dpdk/odp_pool.c
index 9dd1a5ca2..83d75dd6c 100644
--- a/platform/linux-dpdk/odp_pool.c
+++ b/platform/linux-dpdk/odp_pool.c
@@ -823,6 +823,24 @@ int odp_buffer_alloc_multi(odp_pool_t pool_hdl, odp_buffer_t buf[], int num)
return _odp_event_alloc_multi(pool, (_odp_event_hdr_t **)buf, num);
}
+static const char *get_short_type_str(odp_pool_type_t type)
+{
+ switch (type) {
+ case ODP_POOL_BUFFER:
+ return "B";
+ case ODP_POOL_PACKET:
+ return "P";
+ case ODP_POOL_TIMEOUT:
+ return "T";
+ case ODP_POOL_VECTOR:
+ return "V";
+ case ODP_POOL_DMA_COMPL:
+ return "D";
+ default:
+ return "-";
+ }
+}
+
void odp_pool_print(odp_pool_t pool_hdl)
{
pool_t *pool = _odp_pool_entry(pool_hdl);
@@ -837,8 +855,7 @@ void odp_pool_print_all(void)
uint32_t elt_size, elt_len = 0;
uint8_t type, ext;
const int col_width = 24;
- const char *name;
- char type_c;
+ const char *name, *type_c;
_ODP_PRINT("\nList of all pools\n");
_ODP_PRINT("-----------------\n");
@@ -868,12 +885,9 @@ void odp_pool_print_all(void)
if (type == ODP_POOL_BUFFER || type == ODP_POOL_PACKET)
elt_len = elt_size;
- type_c = (type == ODP_POOL_BUFFER) ? 'B' :
- (type == ODP_POOL_PACKET) ? 'P' :
- (type == ODP_POOL_TIMEOUT) ? 'T' :
- (type == ODP_POOL_VECTOR) ? 'V' : '-';
+ type_c = get_short_type_str(pool->type_2);
- _ODP_PRINT("%4u %-*s %c %6" PRIu64 " %6" PRIu32 " %6" PRIu32 " %8" PRIu32 " "
+ _ODP_PRINT("%4u %-*s %s %6" PRIu64 " %6" PRIu32 " %6" PRIu32 " %8" PRIu32 " "
"%" PRIu8 "\n", index, col_width, name, type_c, available, tot,
cache_size, elt_len, ext);
}
@@ -913,6 +927,7 @@ int odp_pool_info(odp_pool_t pool_hdl, odp_pool_info_t *info)
} else if (pool->type_2 == ODP_POOL_DMA_COMPL) {
info->dma_pool_param.num = pool->params.buf.num;
+ info->dma_pool_param.uarea_size = pool->params.buf.uarea_size;
info->dma_pool_param.cache_size = pool->params.buf.cache_size;
} else {
@@ -1004,6 +1019,37 @@ int odp_pool_stats(odp_pool_t pool_hdl, odp_pool_stats_t *stats)
return 0;
}
+int odp_pool_stats_selected(odp_pool_t pool_hdl, odp_pool_stats_selected_t *stats,
+ const odp_pool_stats_opt_t *opt)
+{
+ pool_t *pool;
+
+ if (odp_unlikely(pool_hdl == ODP_POOL_INVALID)) {
+ _ODP_ERR("Invalid pool handle\n");
+ return -1;
+ }
+ if (odp_unlikely(stats == NULL)) {
+ _ODP_ERR("Output buffer NULL\n");
+ return -1;
+ }
+ if (odp_unlikely(opt == NULL)) {
+ _ODP_ERR("Pool counters NULL\n");
+ return -1;
+ }
+
+ pool = _odp_pool_entry(pool_hdl);
+
+ if (odp_unlikely(opt->all & ~pool->params.stats.all)) {
+ _ODP_ERR("Trying to read disabled counter\n");
+ return -1;
+ }
+
+ if (opt->bit.available)
+ stats->available = rte_mempool_avail_count(pool->rte_mempool);
+
+ return 0;
+}
+
int odp_pool_stats_reset(odp_pool_t pool_hdl ODP_UNUSED)
{
return 0;
diff --git a/platform/linux-dpdk/odp_timer.c b/platform/linux-dpdk/odp_timer.c
index 1021a96cd..4056018ae 100644
--- a/platform/linux-dpdk/odp_timer.c
+++ b/platform/linux-dpdk/odp_timer.c
@@ -93,6 +93,9 @@ ODP_STATIC_ASSERT(MAX_TIMERS < MAX_TIMER_RING_SIZE,
/* Maximum number of periodic timers per pool */
#define MAX_PERIODIC_TIMERS 100
+/* Periodic tick fractional part accumulator size */
+#define ACC_SIZE (1ull << 32)
+
typedef struct {
odp_ticketlock_t lock;
uint64_t tick;
@@ -102,8 +105,13 @@ typedef struct {
struct timer_pool_s *timer_pool;
int state;
uint32_t timer_idx;
+
/* Period of periodic timer in ticks, includes PERIODIC_CANCELLED flag. */
uint64_t periodic_ticks;
+ /* Periodic ticks fractional part. */
+ uint32_t periodic_ticks_frac;
+ /* Periodic ticks fractional part accumulator. */
+ uint32_t periodic_ticks_frac_acc;
struct rte_timer rte_timer;
@@ -509,14 +517,26 @@ int odp_timer_res_capability(odp_timer_clk_src_t clk_src,
}
if (res_capa->min_tmo) {
- _ODP_ERR("Only res_ns or max_tmo based quaries supported\n");
+ _ODP_ERR("Only res_ns or max_tmo based queries supported\n");
return -1;
}
if (res_capa->res_ns || res_capa->res_hz) {
+ if (res_capa->res_ns && res_capa->res_ns < MAX_RES_NS) {
+ _ODP_DBG("Timeout resolution capability (res_ns) exceeded\n");
+ return -1;
+ }
+ if (res_capa->res_hz && res_capa->res_hz > MAX_RES_HZ) {
+ _ODP_DBG("Timeout resolution capability (res_hz) exceeded\n");
+ return -1;
+ }
res_capa->min_tmo = min_tmo;
res_capa->max_tmo = MAX_TMO_NS;
} else { /* max_tmo */
+ if (res_capa->max_tmo > MAX_TMO_NS) {
+ _ODP_DBG("Maximum relative timeout capability (max_tmo) exceeded\n");
+ return -1;
+ }
res_capa->min_tmo = min_tmo;
res_capa->res_ns = MAX_RES_NS;
res_capa->res_hz = MAX_RES_HZ;
@@ -787,6 +807,35 @@ uint64_t odp_timer_current_tick(odp_timer_pool_t tp)
return rte_get_timer_cycles();
}
+int odp_timer_sample_ticks(odp_timer_pool_t tp[], uint64_t tick[], uint64_t clk_count[], int num)
+{
+ uint64_t now;
+ int i;
+
+ if (num <= 0 || num > MAX_TIMER_POOLS) {
+ _ODP_ERR("Bad number of timer pools: %i\n", num);
+ return -1;
+ }
+
+ for (i = 0; i < num; i++) {
+ if (odp_unlikely(tp[i] == ODP_TIMER_POOL_INVALID)) {
+ _ODP_ERR("Invalid timer pool\n");
+ return -1;
+ }
+ }
+
+ now = rte_get_timer_cycles();
+
+ for (i = 0; i < num; i++) {
+ tick[i] = now;
+
+ if (clk_count)
+ clk_count[i] = 0;
+ }
+
+ return 0;
+}
+
int odp_timer_pool_info(odp_timer_pool_t tp,
odp_timer_pool_info_t *info)
{
@@ -1065,6 +1114,7 @@ int odp_timer_periodic_start(odp_timer_t timer_hdl,
timer_pool_t *tp = timer->timer_pool;
uint64_t multiplier = start_param->freq_multiplier;
double freq = multiplier * tp->base_freq;
+ double period_ns_dbl;
int absolute;
int ret;
@@ -1083,13 +1133,18 @@ int odp_timer_periodic_start(odp_timer_t timer_hdl,
return ODP_TIMER_FAIL;
}
- period_ns = (uint64_t)((double)ODP_TIME_SEC_IN_NS / freq);
+ period_ns_dbl = (double)ODP_TIME_SEC_IN_NS / freq;
+ period_ns = period_ns_dbl;
+
if (period_ns == 0) {
_ODP_ERR("Too high periodic timer frequency: %f\n", freq);
return ODP_TIMER_FAIL;
}
timer->periodic_ticks = odp_timer_ns_to_tick(timer_pool_to_hdl(tp), period_ns);
+ timer->periodic_ticks_frac = (period_ns_dbl - period_ns) * ACC_SIZE;
+ timer->periodic_ticks_frac_acc = 0;
+
first_tick = timer->periodic_ticks;
absolute = 0;
@@ -1113,7 +1168,7 @@ int odp_timer_periodic_start(odp_timer_t timer_hdl,
int odp_timer_periodic_ack(odp_timer_t timer_hdl, odp_event_t tmo_ev)
{
- uint64_t abs_tick;
+ uint64_t abs_tick, acc;
odp_timeout_t tmo = odp_timeout_from_event(tmo_ev);
timer_entry_t *timer = timer_from_hdl(timer_hdl);
odp_timeout_hdr_t *timeout_hdr;
@@ -1129,6 +1184,15 @@ int odp_timer_periodic_ack(odp_timer_t timer_hdl, odp_event_t tmo_ev)
if (odp_unlikely(abs_tick == PERIODIC_CANCELLED))
return 2;
+ acc = (uint64_t)timer->periodic_ticks_frac_acc + (uint64_t)timer->periodic_ticks_frac;
+
+ if (acc >= ACC_SIZE) {
+ abs_tick++;
+ acc -= ACC_SIZE;
+ }
+
+ timer->periodic_ticks_frac_acc = acc;
+
timeout_hdr = timeout_to_hdr(tmo);
abs_tick += timeout_hdr->expiration;
timeout_hdr->expiration = abs_tick;
@@ -1156,14 +1220,19 @@ int odp_timer_cancel(odp_timer_t timer_hdl, odp_event_t *tmo_ev)
odp_ticketlock_lock(&timer->lock);
if (odp_unlikely(timer->state < TICKING)) {
+ int state = timer->state;
+
odp_ticketlock_unlock(&timer->lock);
- return -1;
+
+ if (state == EXPIRED)
+ return ODP_TIMER_TOO_NEAR;
+ return ODP_TIMER_FAIL;
}
if (odp_unlikely(timer_global->ops.stop(&timer->rte_timer))) {
/* Another core runs timer callback function. */
odp_ticketlock_unlock(&timer->lock);
- return -1;
+ return ODP_TIMER_TOO_NEAR;
}
*tmo_ev = timer->tmo_event;
@@ -1171,7 +1240,7 @@ int odp_timer_cancel(odp_timer_t timer_hdl, odp_event_t *tmo_ev)
timer->state = NOT_TICKING;
odp_ticketlock_unlock(&timer->lock);
- return 0;
+ return ODP_TIMER_SUCCESS;
}
int odp_timer_periodic_cancel(odp_timer_t timer_hdl)
@@ -1228,8 +1297,14 @@ uint64_t odp_timeout_to_u64(odp_timeout_t tmo)
int odp_timeout_fresh(odp_timeout_t tmo)
{
+ timer_entry_t *timer;
odp_timeout_hdr_t *timeout_hdr = timeout_to_hdr(tmo);
- timer_entry_t *timer = timer_from_hdl(timeout_hdr->timer);
+
+ /* Timeout not connected to a timer */
+ if (odp_unlikely(timeout_hdr->timer == ODP_TIMER_INVALID))
+ return 0;
+
+ timer = timer_from_hdl(timeout_hdr->timer);
if (timer->timer_pool->periodic)
return timer->periodic_ticks != PERIODIC_CANCELLED;
@@ -1240,6 +1315,7 @@ int odp_timeout_fresh(odp_timeout_t tmo)
odp_timeout_t odp_timeout_alloc(odp_pool_t pool_hdl)
{
+ odp_timeout_hdr_t *timeout_hdr;
odp_event_t event;
pool_t *pool;
@@ -1253,6 +1329,9 @@ odp_timeout_t odp_timeout_alloc(odp_pool_t pool_hdl)
if (odp_unlikely(event == ODP_EVENT_INVALID))
return ODP_TIMEOUT_INVALID;
+ timeout_hdr = timeout_to_hdr(odp_timeout_from_event(event));
+ timeout_hdr->timer = ODP_TIMER_INVALID;
+
return odp_timeout_from_event(event);
}
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 324507ee5..42760f579 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -115,6 +115,7 @@ odpapiabiarchinclude_HEADERS += \
include-abi/odp/api/abi/thrmask.h \
include-abi/odp/api/abi/ticketlock.h \
include-abi/odp/api/abi/time.h \
+ include-abi/odp/api/abi/time_types.h \
include-abi/odp/api/abi/timer.h \
include-abi/odp/api/abi/timer_types.h \
include-abi/odp/api/abi/traffic_mngr.h \
diff --git a/platform/linux-generic/include-abi/odp/api/abi/time.h b/platform/linux-generic/include-abi/odp/api/abi/time.h
index e80e57b18..62c7e2b67 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/time.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/time.h
@@ -4,7 +4,5 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp/api/abi-default/time.h>
-
-/* Inlined functions for non-ABI compat mode */
+/* Inlined API functions */
#include <odp/api/plat/time_inlines.h>
diff --git a/platform/linux-generic/include-abi/odp/api/abi/time_types.h b/platform/linux-generic/include-abi/odp/api/abi/time_types.h
new file mode 100644
index 000000000..cba80f508
--- /dev/null
+++ b/platform/linux-generic/include-abi/odp/api/abi/time_types.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp/api/abi-default/time_types.h>
diff --git a/platform/linux-generic/include/odp/api/plat/event_inlines.h b/platform/linux-generic/include/odp/api/plat/event_inlines.h
index 37c015b21..4e3368ff0 100644
--- a/platform/linux-generic/include/odp/api/plat/event_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/event_inlines.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2022, Nokia
+ * Copyright (c) 2022-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -8,11 +8,17 @@
#ifndef ODP_PLAT_EVENT_INLINES_H_
#define ODP_PLAT_EVENT_INLINES_H_
+#include <odp/api/buffer_types.h>
+#include <odp/api/dma.h>
#include <odp/api/event_types.h>
#include <odp/api/packet_types.h>
+#include <odp/api/timer_types.h>
+#include <odp/api/plat/buffer_inline_types.h>
#include <odp/api/plat/event_inline_types.h>
+#include <odp/api/plat/event_vector_inline_types.h>
#include <odp/api/plat/packet_inline_types.h>
+#include <odp/api/plat/timer_inline_types.h>
/** @cond _ODP_HIDE_FROM_DOXYGEN_ */
@@ -21,6 +27,7 @@
#define _ODP_INLINE static inline
#define odp_event_type __odp_event_type
#define odp_event_type_multi __odp_event_type_multi
+ #define odp_event_user_area __odp_event_user_area
#define odp_event_subtype __odp_event_subtype
#define odp_event_types __odp_event_types
#define odp_event_flow_id __odp_event_flow_id
@@ -59,6 +66,26 @@ _ODP_INLINE int odp_event_type_multi(const odp_event_t event[], int num,
return i;
}
+_ODP_INLINE void *odp_event_user_area(odp_event_t event)
+{
+ const odp_event_type_t type = __odp_event_type_get(event);
+
+ switch (type) {
+ case ODP_EVENT_BUFFER:
+ return _odp_buffer_get((odp_buffer_t)event, void *, uarea_addr);
+ case ODP_EVENT_PACKET:
+ return _odp_pkt_get((odp_packet_t)event, void *, user_area);
+ case ODP_EVENT_PACKET_VECTOR:
+ return _odp_event_vect_get((odp_packet_vector_t)event, void *, uarea_addr);
+ case ODP_EVENT_TIMEOUT:
+ return _odp_timeout_hdr_field((odp_timeout_t)event, void *, uarea_addr);
+ case ODP_EVENT_DMA_COMPL:
+ return odp_dma_compl_user_area((odp_dma_compl_t)event);
+ default:
+ return NULL;
+ }
+}
+
_ODP_INLINE odp_event_subtype_t odp_event_subtype(odp_event_t event)
{
if (__odp_event_type_get(event) != ODP_EVENT_PACKET)
diff --git a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
index 6773b73ad..5186efed0 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
@@ -123,7 +123,7 @@ typedef union {
uint32_t all_flags;
struct {
- uint32_t reserved1: 6;
+ uint32_t reserved1: 5;
/*
* Init flags
@@ -142,6 +142,7 @@ typedef union {
uint32_t l4_chksum: 1; /* L4 chksum override */
uint32_t ts_set: 1; /* Set Tx timestamp */
uint32_t tx_compl: 1; /* Tx completion event requested */
+ uint32_t free_ctrl: 1; /* Don't free option */
uint32_t tx_aging: 1; /* Packet aging at Tx requested */
uint32_t shaper_len_adj: 8; /* Adjustment for traffic mgr */
@@ -159,8 +160,8 @@ typedef union {
/* Flag groups */
struct {
- uint32_t reserved2: 6;
- uint32_t other: 19; /* All other flags */
+ uint32_t reserved2: 5;
+ uint32_t other: 20; /* All other flags */
uint32_t error: 7; /* All error flags */
} all;
diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h
index f03c88e10..960dbc5fc 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h
@@ -18,7 +18,7 @@
#include <odp/api/hints.h>
#include <odp/api/packet_types.h>
#include <odp/api/pool_types.h>
-#include <odp/api/time.h>
+#include <odp/api/time_types.h>
#include <odp/api/plat/debug_inlines.h>
#include <odp/api/plat/packet_io_inlines.h>
diff --git a/platform/linux-generic/include/odp/api/plat/time_inlines.h b/platform/linux-generic/include/odp/api/plat/time_inlines.h
index 2ffb94c66..f8f4bee89 100644
--- a/platform/linux-generic/include/odp/api/plat/time_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/time_inlines.h
@@ -8,12 +8,14 @@
#ifndef ODP_PLAT_TIME_INLINES_H_
#define ODP_PLAT_TIME_INLINES_H_
-#include <stdint.h>
#include <odp/api/align.h>
#include <odp/api/hints.h>
+#include <odp/api/time_types.h>
#include <odp/api/abi/cpu_time.h>
+#include <stdint.h>
+
/** @cond _ODP_HIDE_FROM_DOXYGEN_ */
#define _ODP_TIMESPEC_SIZE 16
diff --git a/platform/linux-generic/include/odp_classification_internal.h b/platform/linux-generic/include/odp_classification_internal.h
index c3ecf4079..7841e64fb 100644
--- a/platform/linux-generic/include/odp_classification_internal.h
+++ b/platform/linux-generic/include/odp_classification_internal.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
+ * Copyright (c) 2021-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -21,13 +21,20 @@ extern "C" {
#include <odp/api/atomic.h>
#include <odp/api/classification.h>
+#include <odp/api/event.h>
#include <odp/api/hints.h>
+#include <odp/api/packet.h>
+#include <odp/api/pool.h>
#include <odp/api/queue.h>
+#include <odp/api/std_types.h>
+
+#include <odp_debug_internal.h>
#include <odp_packet_internal.h>
-#include <odp/api/packet_io.h>
#include <odp_packet_io_internal.h>
#include <odp_classification_datamodel.h>
+#include <stdint.h>
+
extern cls_global_t *_odp_cls_global;
static inline cos_t *_odp_cos_entry_from_idx(uint32_t ndx)
@@ -72,6 +79,153 @@ static inline void _odp_cos_queue_stats_add(cos_t *cos, odp_queue_t queue,
odp_atomic_add_u64(&cos->queue_stats[queue_idx].discards, discards);
}
+static inline void _odp_cos_vector_enq(odp_queue_t queue, odp_event_t events[], uint32_t num,
+ cos_t *cos)
+{
+ odp_packet_vector_t pktv;
+ const odp_pool_t pool = cos->vector.pool;
+ const uint32_t max_size = cos->vector.max_size;
+ uint32_t num_enq;
+ int num_pktv = (num + max_size - 1) / max_size;
+ int ret;
+ int i;
+ odp_packet_vector_t pktv_tbl[num_pktv];
+ odp_event_t event_tbl[num_pktv];
+
+ for (i = 0; i < num_pktv; i++) {
+ pktv = odp_packet_vector_alloc(pool);
+ if (odp_unlikely(pktv == ODP_PACKET_VECTOR_INVALID))
+ break;
+ pktv_tbl[i] = pktv;
+ event_tbl[i] = odp_packet_vector_to_event(pktv);
+ }
+ if (odp_unlikely(i == 0)) {
+ odp_event_free_multi(events, num);
+ _odp_cos_queue_stats_add(cos, queue, 0, num);
+ return;
+ }
+ num_pktv = i;
+ num_enq = 0;
+ for (i = 0; i < num_pktv; i++) {
+ odp_packet_t *pkt_tbl;
+ int pktv_size = max_size;
+
+ pktv = pktv_tbl[i];
+
+ if (num_enq + max_size > num)
+ pktv_size = num - num_enq;
+
+ odp_packet_vector_tbl(pktv, &pkt_tbl);
+ odp_packet_from_event_multi(pkt_tbl, &events[num_enq], pktv_size);
+ odp_packet_vector_size_set(pktv, pktv_size);
+ num_enq += pktv_size;
+ }
+
+ ret = odp_queue_enq_multi(queue, event_tbl, num_pktv);
+ if (odp_likely(ret == num_pktv)) {
+ _odp_cos_queue_stats_add(cos, queue, num_enq, num - num_enq);
+ } else {
+ uint32_t enqueued;
+
+ if (ret < 0)
+ ret = 0;
+ enqueued = max_size * ret;
+ _odp_cos_queue_stats_add(cos, queue, enqueued, num - enqueued);
+ odp_event_free_multi(&event_tbl[ret], num_pktv - ret);
+ }
+}
+
+/**
+ * Enqueue packets into destination CoS
+ */
+static inline void _odp_cos_enq(uint16_t cos_id, odp_queue_t dst, odp_packet_t packets[], int num)
+{
+ _ODP_ASSERT(cos_id != CLS_COS_IDX_NONE);
+ _ODP_ASSERT(dst != ODP_QUEUE_INVALID);
+
+ cos_t *cos = _odp_cos_entry_from_idx(cos_id);
+
+ if (num < 2 || !cos->vector.enable) {
+ int ret = odp_queue_enq_multi(dst, (odp_event_t *)packets, num);
+
+ if (odp_unlikely(ret != num)) {
+ if (ret < 0)
+ ret = 0;
+
+ odp_packet_free_multi(&packets[ret], num - ret);
+ }
+ _odp_cos_queue_stats_add(cos, dst, ret, num - ret);
+ } else {
+ _odp_cos_vector_enq(dst, (odp_event_t *)packets, num, cos);
+ }
+}
+
+/**
+ * Enqueue all remaining packets in 'packets' array
+ */
+static inline void _odp_cls_enq_all(odp_packet_t packets[], int num)
+{
+ odp_packet_hdr_t *prev_hdr;
+ odp_packet_hdr_t *latest_hdr = packet_hdr(packets[num - 1]);
+
+ if (num < 2) {
+ _odp_cos_enq(latest_hdr->cos, latest_hdr->dst_queue, packets, 1);
+ return;
+ }
+
+ prev_hdr = packet_hdr(packets[num - 2]);
+
+ if (prev_hdr->dst_queue == latest_hdr->dst_queue && prev_hdr->cos == latest_hdr->cos) {
+ _odp_cos_enq(prev_hdr->cos, prev_hdr->dst_queue, packets, num);
+ } else {
+ _odp_cos_enq(prev_hdr->cos, prev_hdr->dst_queue, packets, num - 1);
+ _odp_cos_enq(latest_hdr->cos, latest_hdr->dst_queue, &packets[num - 1], 1);
+ }
+}
+
+/**
+ * Enqueue packets into classifier destination queue
+ *
+ * Called by pktio devices for each received packet when classifier has been enabled. Postpones the
+ * actual enqueue operation and stores packets in 'packets' array until destination queue or CoS
+ * change, or 'last' flag is set.
+ *
+ * @param[out] packets Packet array to be enqueued
+ * @param num Number of handles in 'packets' array
+ * @param last Enqueue all packets
+ *
+ * @return Number of packets remaining in 'packets' array
+ */
+static inline int _odp_cls_enq(odp_packet_t packets[], int num, odp_bool_t last)
+{
+ odp_packet_hdr_t *prev_hdr, *latest_hdr;
+
+ _ODP_ASSERT(num > 0);
+
+ if (last) {
+ _odp_cls_enq_all(packets, num);
+ return 0;
+ }
+
+ /* Only one packet, so postpone enqueue */
+ if (num < 2)
+ return num;
+
+ prev_hdr = packet_hdr(packets[num - 2]);
+ latest_hdr = packet_hdr(packets[num - 1]);
+
+ /* Postpone enqueue if destination queue and CoS have not changed */
+ if (prev_hdr->dst_queue == latest_hdr->dst_queue && prev_hdr->cos == latest_hdr->cos)
+ return num;
+
+ /* Perform previously postponed enqueue operation and move the last packet (different
+ * destination) in 'packets' array to be the first entry */
+ _odp_cos_enq(prev_hdr->cos, prev_hdr->dst_queue, packets, num - 1);
+ packets[0] = packets[num - 1];
+
+ return 1;
+}
+
/** Classification Internal function **/
/**
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h
index 9caf3c2e9..05dda9897 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -22,6 +22,7 @@ extern "C" {
#include <odp/api/packet_io.h>
#include <odp/api/spinlock.h>
#include <odp/api/ticketlock.h>
+#include <odp/api/time.h>
#include <odp/api/plat/packet_io_inlines.h>
diff --git a/platform/linux-generic/odp_dma.c b/platform/linux-generic/odp_dma.c
index cf426f104..fa45b3b02 100644
--- a/platform/linux-generic/odp_dma.c
+++ b/platform/linux-generic/odp_dma.c
@@ -101,6 +101,7 @@ int odp_dma_capability(odp_dma_capability_t *capa)
capa->pool.max_pools = _odp_dma_glb->pool_capa.buf.max_pools;
capa->pool.max_num = _odp_dma_glb->pool_capa.buf.max_num;
+ capa->pool.max_uarea_size = _odp_dma_glb->pool_capa.buf.max_uarea_size;
capa->pool.min_cache_size = _odp_dma_glb->pool_capa.buf.min_cache_size;
capa->pool.max_cache_size = _odp_dma_glb->pool_capa.buf.max_cache_size;
@@ -396,7 +397,7 @@ static inline int segment_pkt(segment_t seg[], int num_seg, const odp_dma_seg_t
offset += len;
num++;
- if (odp_unlikely(num >= MAX_SEGS)) {
+ if (odp_unlikely(num > MAX_SEGS)) {
_ODP_ERR("Too many packet segments\n");
return 0;
}
@@ -735,6 +736,7 @@ odp_pool_t odp_dma_pool_create(const char *name, const odp_dma_pool_param_t *dma
odp_pool_t pool;
odp_pool_param_t pool_param;
uint32_t num = dma_pool_param->num;
+ uint32_t uarea_size = dma_pool_param->uarea_size;
uint32_t cache_size = dma_pool_param->cache_size;
if (num > _odp_dma_glb->pool_capa.buf.max_num) {
@@ -742,6 +744,11 @@ odp_pool_t odp_dma_pool_create(const char *name, const odp_dma_pool_param_t *dma
return ODP_POOL_INVALID;
}
+ if (uarea_size > _odp_dma_glb->pool_capa.buf.max_uarea_size) {
+ _ODP_ERR("Bad uarea size: %u\n", uarea_size);
+ return ODP_POOL_INVALID;
+ }
+
if (cache_size < _odp_dma_glb->pool_capa.buf.min_cache_size ||
cache_size > _odp_dma_glb->pool_capa.buf.max_cache_size) {
_ODP_ERR("Bad cache size: %u\n", cache_size);
@@ -751,6 +758,7 @@ odp_pool_t odp_dma_pool_create(const char *name, const odp_dma_pool_param_t *dma
odp_pool_param_init(&pool_param);
pool_param.type = ODP_POOL_BUFFER;
pool_param.buf.num = num;
+ pool_param.buf.uarea_size = uarea_size;
pool_param.buf.cache_size = cache_size;
pool_param.buf.size = sizeof(odp_dma_result_t);
@@ -835,6 +843,11 @@ uint64_t odp_dma_compl_to_u64(odp_dma_compl_t dma_compl)
return (uint64_t)(uintptr_t)dma_compl;
}
+void *odp_dma_compl_user_area(odp_dma_compl_t dma_compl)
+{
+ return odp_buffer_user_area((odp_buffer_t)(uintptr_t)dma_compl);
+}
+
void odp_dma_print(odp_dma_t dma)
{
dma_session_t *session = dma_session_from_handle(dma);
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index bd27641aa..f1aae95bb 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -692,6 +692,26 @@ int odp_term_local(void)
return term_local(ALL_INIT);
}
+int odp_term_abnormal(odp_instance_t instance, uint64_t flags, void *data ODP_UNUSED)
+{
+ if (flags & ODP_TERM_FROM_SIGH)
+ /* Called from signal handler, not safe to terminate with local/global,
+ * return with failure as not able to perform all actions */
+ return -1;
+
+ if (odp_term_local() < 0) {
+ _ODP_ERR("ODP local terminate failed.\n");
+ return -2;
+ }
+
+ if (odp_term_global(instance) < 0) {
+ _ODP_ERR("ODP global terminate failed.\n");
+ return -3;
+ }
+
+ return 0;
+}
+
void odp_log_thread_fn_set(odp_log_func_t func)
{
_odp_this_thread->log_fn = func;
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 869713098..cabb9fed5 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2218,7 +2218,7 @@ int odp_packet_tx_compl_request(odp_packet_t pkt, const odp_packet_tx_compl_opt_
{
odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
- pkt_hdr->p.flags.tx_compl = opt->mode == ODP_PACKET_TX_COMPL_ALL ? 1 : 0;
+ pkt_hdr->p.flags.tx_compl = opt->mode == ODP_PACKET_TX_COMPL_EVENT ? 1 : 0;
pkt_hdr->dst_queue = opt->queue;
return 0;
@@ -2253,6 +2253,34 @@ void *odp_packet_tx_compl_user_ptr(odp_packet_tx_compl_t tx_compl)
return (void *)(uintptr_t)data->user_ptr;
}
+int odp_packet_tx_compl_done(odp_pktio_t pktio, uint32_t compl_id)
+{
+ (void)pktio;
+ (void)compl_id;
+
+ return -1;
+}
+
+void odp_packet_free_ctrl_set(odp_packet_t pkt, odp_packet_free_ctrl_t ctrl)
+{
+ odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
+
+ if (ctrl == ODP_PACKET_FREE_CTRL_DONT_FREE)
+ pkt_hdr->p.flags.free_ctrl = 1;
+ else
+ pkt_hdr->p.flags.free_ctrl = 0;
+}
+
+odp_packet_free_ctrl_t odp_packet_free_ctrl(odp_packet_t pkt)
+{
+ odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
+
+ if (pkt_hdr->p.flags.free_ctrl)
+ return ODP_PACKET_FREE_CTRL_DONT_FREE;
+
+ return ODP_PACKET_FREE_CTRL_DISABLED;
+}
+
odp_packet_reass_status_t
odp_packet_reass_status(odp_packet_t pkt)
{
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 988bb192f..c4cd87afc 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
+ * Copyright (c) 2019-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -610,7 +610,7 @@ int odp_pktio_config(odp_pktio_t hdl, const odp_pktio_config_t *config)
entry->config = *config;
entry->enabled.tx_ts = config->pktout.bit.ts_ena;
- entry->enabled.tx_compl = config->pktout.bit.tx_compl_ena;
+ entry->enabled.tx_compl = (config->pktout.bit.tx_compl_ena || config->tx_compl.mode_event);
if (entry->enabled.tx_compl)
if (configure_tx_event_compl(entry)) {
@@ -647,6 +647,13 @@ int odp_pktio_start(odp_pktio_t hdl)
_ODP_ERR("Already started\n");
return -1;
}
+
+ if (entry->state == PKTIO_STATE_STOP_PENDING) {
+ unlock_entry(entry);
+ _ODP_ERR("Scheduled pktio stop pending\n");
+ return -1;
+ }
+
entry->parse_layer = pktio_cls_enabled(entry) ?
ODP_PROTO_LAYER_ALL :
entry->config.parser.layer;
@@ -769,82 +776,6 @@ odp_pktio_t odp_pktio_lookup(const char *name)
return hdl;
}
-static void packet_vector_enq_cos(odp_queue_t queue, odp_event_t events[],
- uint32_t num, cos_t *cos_hdr)
-{
- odp_packet_vector_t pktv;
- odp_pool_t pool = cos_hdr->vector.pool;
- uint32_t max_size = cos_hdr->vector.max_size;
- uint32_t num_enq;
- int num_pktv = (num + max_size - 1) / max_size;
- int ret;
- int i;
- odp_packet_vector_t pktv_tbl[num_pktv];
- odp_event_t event_tbl[num_pktv];
-
- for (i = 0; i < num_pktv; i++) {
- pktv = odp_packet_vector_alloc(pool);
- if (odp_unlikely(pktv == ODP_PACKET_VECTOR_INVALID))
- break;
- pktv_tbl[i] = pktv;
- event_tbl[i] = odp_packet_vector_to_event(pktv);
- }
- if (odp_unlikely(i == 0)) {
- odp_event_free_multi(events, num);
- _odp_cos_queue_stats_add(cos_hdr, queue, 0, num);
- return;
- }
- num_pktv = i;
- num_enq = 0;
- for (i = 0; i < num_pktv; i++) {
- odp_packet_t *pkt_tbl;
- int pktv_size = max_size;
-
- pktv = pktv_tbl[i];
-
- if (num_enq + max_size > num)
- pktv_size = num - num_enq;
-
- odp_packet_vector_tbl(pktv, &pkt_tbl);
- odp_packet_from_event_multi(pkt_tbl, &events[num_enq], pktv_size);
- odp_packet_vector_size_set(pktv, pktv_size);
- num_enq += pktv_size;
- }
-
- ret = odp_queue_enq_multi(queue, event_tbl, num_pktv);
- if (odp_likely(ret == num_pktv)) {
- _odp_cos_queue_stats_add(cos_hdr, queue, num_enq, num - num_enq);
- } else {
- uint32_t enqueued;
-
- if (ret < 0)
- ret = 0;
- enqueued = max_size * ret;
- _odp_cos_queue_stats_add(cos_hdr, queue, enqueued, num - enqueued);
- odp_event_free_multi(&event_tbl[ret], num_pktv - ret);
- }
-}
-
-static void packet_vector_enq(odp_queue_t queue, odp_event_t events[],
- uint32_t num, odp_pool_t pool)
-{
- odp_packet_vector_t pktv;
- odp_packet_t *pkt_tbl;
-
- pktv = odp_packet_vector_alloc(pool);
- if (odp_unlikely(pktv == ODP_PACKET_VECTOR_INVALID)) {
- odp_event_free_multi(events, num);
- return;
- }
-
- odp_packet_vector_tbl(pktv, &pkt_tbl);
- odp_packet_from_event_multi(pkt_tbl, events, num);
- odp_packet_vector_size_set(pktv, num);
-
- if (odp_unlikely(odp_queue_enq(queue, odp_packet_vector_to_event(pktv))))
- odp_event_free(odp_packet_vector_to_event(pktv));
-}
-
static inline odp_packet_vector_t packet_vector_create(odp_packet_t packets[], uint32_t num,
odp_pool_t pool)
{
@@ -869,19 +800,9 @@ static inline odp_packet_vector_t packet_vector_create(odp_packet_t packets[], u
static inline int pktin_recv_buf(pktio_entry_t *entry, int pktin_index,
_odp_event_hdr_t *event_hdrs[], int num)
{
- odp_packet_t pkt;
- odp_packet_t packets[num];
- odp_packet_hdr_t *pkt_hdr;
+ const odp_bool_t vector_enabled = entry->in_queue[pktin_index].vector.enable;
odp_pool_t pool = ODP_POOL_INVALID;
- _odp_event_hdr_t *event_hdr;
- int i, pkts, num_rx, num_ev, num_dst;
- odp_queue_t cur_queue;
- odp_event_t ev[num];
- odp_queue_t dst[num];
- uint16_t cos[num];
- uint16_t cur_cos = 0;
- int dst_idx[num];
- odp_bool_t vector_enabled = entry->in_queue[pktin_index].vector.enable;
+ int num_rx;
if (vector_enabled) {
/* Make sure all packets will fit into a single packet vector */
@@ -890,102 +811,18 @@ static inline int pktin_recv_buf(pktio_entry_t *entry, int pktin_index,
pool = entry->in_queue[pktin_index].vector.pool;
}
- num_rx = 0;
- num_dst = 0;
- num_ev = 0;
-
- /* Some compilers need this dummy initialization */
- cur_queue = ODP_QUEUE_INVALID;
-
- pkts = entry->ops->recv(entry, pktin_index, packets, num);
-
- for (i = 0; i < pkts; i++) {
- pkt = packets[i];
- pkt_hdr = packet_hdr(pkt);
- event_hdr = packet_to_event_hdr(pkt);
-
- if (odp_unlikely(pkt_hdr->p.input_flags.dst_queue)) {
- /* Sort events for enqueue multi operation(s) based on CoS
- * and destination queue. */
- if (odp_unlikely(num_dst == 0)) {
- num_dst = 1;
- cur_queue = pkt_hdr->dst_queue;
- cur_cos = pkt_hdr->cos;
- dst[0] = cur_queue;
- cos[0] = cur_cos;
- dst_idx[0] = 0;
- }
-
- ev[num_ev] = odp_packet_to_event(pkt);
-
- if (cur_queue != pkt_hdr->dst_queue || cur_cos != pkt_hdr->cos) {
- cur_queue = pkt_hdr->dst_queue;
- cur_cos = pkt_hdr->cos;
- dst[num_dst] = cur_queue;
- cos[num_dst] = cur_cos;
- dst_idx[num_dst] = num_ev;
- num_dst++;
- }
-
- num_ev++;
- continue;
- }
- event_hdrs[num_rx++] = event_hdr;
- }
-
- /* Optimization for the common case */
- if (odp_likely(num_dst == 0)) {
- if (!vector_enabled || num_rx < 1)
- return num_rx;
-
- /* Create packet vector */
- odp_packet_vector_t pktv = packet_vector_create((odp_packet_t *)event_hdrs,
- num_rx, pool);
+ num_rx = entry->ops->recv(entry, pktin_index, (odp_packet_t *)event_hdrs, num);
- if (odp_unlikely(pktv == ODP_PACKET_VECTOR_INVALID))
- return 0;
+ if (!vector_enabled || num_rx < 2)
+ return num_rx;
- event_hdrs[0] = _odp_packet_vector_to_event_hdr(pktv);
- return 1;
- }
+ odp_packet_vector_t pktv = packet_vector_create((odp_packet_t *)event_hdrs, num_rx, pool);
- for (i = 0; i < num_dst; i++) {
- cos_t *cos_hdr = NULL;
- int num_enq, ret;
- int idx = dst_idx[i];
-
- if (i == (num_dst - 1))
- num_enq = num_ev - idx;
- else
- num_enq = dst_idx[i + 1] - idx;
-
- if (cos[i] != CLS_COS_IDX_NONE) {
- /* Packets from classifier */
- cos_hdr = _odp_cos_entry_from_idx(cos[i]);
-
- if (cos_hdr->vector.enable) {
- packet_vector_enq_cos(dst[i], &ev[idx], num_enq, cos_hdr);
- continue;
- }
- } else if (vector_enabled) {
- /* Packets from inline IPsec */
- packet_vector_enq(dst[i], &ev[idx], num_enq, pool);
- continue;
- }
-
- ret = odp_queue_enq_multi(dst[i], &ev[idx], num_enq);
-
- if (ret < 0)
- ret = 0;
-
- if (ret < num_enq)
- odp_event_free_multi(&ev[idx + ret], num_enq - ret);
+ if (odp_unlikely(pktv == ODP_PACKET_VECTOR_INVALID))
+ return 0;
- /* Update CoS statistics */
- if (cos[i] != CLS_COS_IDX_NONE)
- _odp_cos_queue_stats_add(cos_hdr, dst[i], ret, num_enq - ret);
- }
- return num_rx;
+ event_hdrs[0] = _odp_packet_vector_to_event_hdr(pktv);
+ return 1;
}
static inline int packet_vector_send(odp_pktout_queue_t pktout_queue, odp_event_t event)
@@ -1103,6 +940,9 @@ static _odp_event_hdr_t *pktin_dequeue(odp_queue_t queue)
if (_odp_queue_fn->orig_deq_multi(queue, &event_hdr, 1) == 1)
return event_hdr;
+ if (odp_unlikely(entry->state != PKTIO_STATE_STARTED))
+ return 0;
+
pkts = pktin_recv_buf(entry, pktin_index, hdr_tbl, QUEUE_MULTI_MAX);
if (pkts <= 0)
@@ -1148,7 +988,7 @@ static int pktin_deq_multi(odp_queue_t queue, _odp_event_hdr_t *event_hdr[],
/** queue already has number of requested buffers,
* do not do receive in that case.
*/
- if (nbr == num)
+ if (nbr == num || odp_unlikely(entry->state != PKTIO_STATE_STARTED))
return nbr;
pkts = pktin_recv_buf(entry, pktin_index, hdr_tbl, QUEUE_MULTI_MAX);
@@ -1725,74 +1565,68 @@ int _odp_pktio_term_global(void)
return ret;
}
-static
-int single_capability(odp_pktio_capability_t *capa)
-{
- memset(capa, 0, sizeof(odp_pktio_capability_t));
- capa->max_input_queues = 1;
- capa->max_output_queues = 1;
- capa->set_op.op.promisc_mode = 1;
-
- return 0;
-}
-
int odp_pktio_capability(odp_pktio_t pktio, odp_pktio_capability_t *capa)
{
pktio_entry_t *entry;
int ret;
+ uint32_t mtu;
entry = get_pktio_entry(pktio);
if (entry == NULL) {
- _ODP_DBG("pktio entry %" PRIuPTR " does not exist\n", (uintptr_t)pktio);
+ _ODP_ERR("pktio entry %" PRIuPTR " does not exist\n", (uintptr_t)pktio);
return -1;
}
- if (entry->ops->capability)
- ret = entry->ops->capability(entry, capa);
- else
- ret = single_capability(capa);
+ ret = entry->ops->capability(entry, capa);
- if (ret == 0) {
- uint32_t mtu = pktio_maxlen(pktio);
+ if (ret) {
+ _ODP_ERR("Driver specific capa query failed: %s\n", entry->name);
+ return -1;
+ }
- if (mtu == 0) {
- _ODP_DBG("MTU query failed: %s\n", entry->name);
- return -1;
- }
+ mtu = pktio_maxlen(pktio);
- /* The same parser is used for all pktios */
- capa->config.parser.layer = ODP_PROTO_LAYER_ALL;
- /* Header skip is not supported */
- capa->set_op.op.skip_offset = 0;
- /* Irrespective of whether we optimize the fast path or not,
- * we can report that it is supported.
- */
- capa->config.pktout.bit.no_packet_refs = 1;
-
- /* LSO implementation is common to all pktios */
- capa->lso.max_profiles = PKTIO_LSO_PROFILES;
- capa->lso.max_profiles_per_pktio = PKTIO_LSO_PROFILES;
- capa->lso.max_packet_segments = PKT_MAX_SEGS;
- capa->lso.max_segments = PKTIO_LSO_MAX_SEGMENTS;
- capa->lso.max_payload_len = mtu - PKTIO_LSO_MIN_PAYLOAD_OFFSET;
- capa->lso.max_payload_offset = PKTIO_LSO_MAX_PAYLOAD_OFFSET;
- capa->lso.max_num_custom = ODP_LSO_MAX_CUSTOM;
- capa->lso.proto.ipv4 = 1;
- capa->lso.proto.custom = 1;
- capa->lso.mod_op.add_segment_num = 1;
-
- capa->config.pktout.bit.tx_compl_ena = 1;
- capa->tx_compl.queue_type_sched = 1;
- capa->tx_compl.queue_type_plain = 1;
- capa->tx_compl.mode_all = 1;
-
- capa->config.pktout.bit.aging_ena = 1;
- capa->max_tx_aging_tmo_ns = MAX_TX_AGING_TMO_NS;
+ if (mtu == 0) {
+ _ODP_ERR("MTU query failed: %s\n", entry->name);
+ return -1;
}
+ /* The same parser is used for all pktios */
+ capa->config.parser.layer = ODP_PROTO_LAYER_ALL;
+ /* Header skip is not supported */
+ capa->set_op.op.skip_offset = 0;
+ /* Irrespective of whether we optimize the fast path or not,
+ * we can report that it is supported.
+ */
+ capa->config.pktout.bit.no_packet_refs = 1;
+
+ /* LSO implementation is common to all pktios */
+ capa->lso.max_profiles = PKTIO_LSO_PROFILES;
+ capa->lso.max_profiles_per_pktio = PKTIO_LSO_PROFILES;
+ capa->lso.max_packet_segments = PKT_MAX_SEGS;
+ capa->lso.max_segments = PKTIO_LSO_MAX_SEGMENTS;
+ capa->lso.max_payload_len = mtu - PKTIO_LSO_MIN_PAYLOAD_OFFSET;
+ capa->lso.max_payload_offset = PKTIO_LSO_MAX_PAYLOAD_OFFSET;
+ capa->lso.max_num_custom = ODP_LSO_MAX_CUSTOM;
+ capa->lso.proto.ipv4 = 1;
+ capa->lso.proto.custom = 1;
+ capa->lso.mod_op.add_segment_num = 1;
+
+ capa->config.pktout.bit.tx_compl_ena = 1;
+ capa->tx_compl.queue_type_sched = 1;
+ capa->tx_compl.queue_type_plain = 1;
+ capa->tx_compl.mode_all = 1;
+ capa->tx_compl.mode_event = 1;
+ capa->tx_compl.mode_poll = 0;
+ capa->tx_compl.max_compl_id = 0;
+ capa->free_ctrl.dont_free = 0;
+
+ capa->config.pktout.bit.aging_ena = 1;
+ capa->max_tx_aging_tmo_ns = MAX_TX_AGING_TMO_NS;
+
/* Packet vector generation is common for all pktio types */
- if (ret == 0 && (entry->param.in_mode == ODP_PKTIN_MODE_QUEUE ||
- entry->param.in_mode == ODP_PKTIN_MODE_SCHED)) {
+ if (entry->param.in_mode == ODP_PKTIN_MODE_QUEUE ||
+ entry->param.in_mode == ODP_PKTIN_MODE_SCHED) {
capa->vector.supported = ODP_SUPPORT_YES;
capa->vector.max_size = CONFIG_PACKET_VECTOR_MAX_SIZE;
capa->vector.min_size = 1;
@@ -1808,7 +1642,7 @@ int odp_pktio_capability(odp_pktio_t pktio, odp_pktio_capability_t *capa)
capa->flow_control.pause_tx = 0;
capa->flow_control.pfc_tx = 0;
- return ret;
+ return 0;
}
unsigned int odp_pktio_max_index(void)
diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index 59c007ee2..672b92c02 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -176,6 +176,16 @@ static inline int cache_available(pool_t *pool, odp_pool_stats_t *stats)
return 0;
}
+static inline uint64_t cache_total_available(pool_t *pool)
+{
+ uint64_t cached = 0;
+
+ for (int i = 0; i < ODP_THREAD_COUNT_MAX; i++)
+ cached += odp_atomic_load_u32(&pool->local_cache[i].cache_num);
+
+ return cached;
+}
+
static int read_config_file(pool_global_t *pool_glb)
{
uint32_t local_cache_size, burst_size, align;
@@ -1220,6 +1230,7 @@ int odp_pool_info(odp_pool_t pool_hdl, odp_pool_info_t *info)
} else if (pool->type_2 == ODP_POOL_DMA_COMPL) {
info->dma_pool_param.num = pool->params.buf.num;
+ info->dma_pool_param.uarea_size = pool->params.buf.uarea_size;
info->dma_pool_param.cache_size = pool->params.buf.cache_size;
} else {
@@ -1507,6 +1518,42 @@ int odp_pool_capability(odp_pool_capability_t *capa)
return 0;
}
+static const char *get_long_type_str(odp_pool_type_t type)
+{
+ switch (type) {
+ case ODP_POOL_BUFFER:
+ return "buffer";
+ case ODP_POOL_PACKET:
+ return "packet";
+ case ODP_POOL_TIMEOUT:
+ return "timeout";
+ case ODP_POOL_VECTOR:
+ return "vector";
+ case ODP_POOL_DMA_COMPL:
+ return "dma completion";
+ default:
+ return "unknown";
+ }
+}
+
+static const char *get_short_type_str(odp_pool_type_t type)
+{
+ switch (type) {
+ case ODP_POOL_BUFFER:
+ return "B";
+ case ODP_POOL_PACKET:
+ return "P";
+ case ODP_POOL_TIMEOUT:
+ return "T";
+ case ODP_POOL_VECTOR:
+ return "V";
+ case ODP_POOL_DMA_COMPL:
+ return "D";
+ default:
+ return "-";
+ }
+}
+
void odp_pool_print(odp_pool_t pool_hdl)
{
pool_t *pool;
@@ -1518,12 +1565,7 @@ void odp_pool_print(odp_pool_t pool_hdl)
_ODP_PRINT(" pool %" PRIu64 "\n",
odp_pool_to_u64(_odp_pool_handle(pool)));
_ODP_PRINT(" name %s\n", pool->name);
- _ODP_PRINT(" pool type %s\n",
- pool->type == ODP_POOL_BUFFER ? "buffer" :
- (pool->type == ODP_POOL_PACKET ? "packet" :
- (pool->type == ODP_POOL_TIMEOUT ? "timeout" :
- (pool->type == ODP_POOL_VECTOR ? "vector" :
- "unknown"))));
+ _ODP_PRINT(" pool type %s\n", get_long_type_str(pool->type_2));
_ODP_PRINT(" pool shm %" PRIu64 "\n", odp_shm_to_u64(pool->shm));
_ODP_PRINT(" user area shm %" PRIu64 "\n", odp_shm_to_u64(pool->uarea_shm));
_ODP_PRINT(" num %u\n", pool->num);
@@ -1554,8 +1596,7 @@ void odp_pool_print_all(void)
uint32_t buf_len = 0;
uint8_t type, ext;
const int col_width = 24;
- const char *name;
- char type_c;
+ const char *name, *type_c;
_ODP_PRINT("\nList of all pools\n");
_ODP_PRINT("-----------------\n");
@@ -1585,12 +1626,9 @@ void odp_pool_print_all(void)
if (type == ODP_POOL_BUFFER || type == ODP_POOL_PACKET)
buf_len = seg_len;
- type_c = (type == ODP_POOL_BUFFER) ? 'B' :
- (type == ODP_POOL_PACKET) ? 'P' :
- (type == ODP_POOL_TIMEOUT) ? 'T' :
- (type == ODP_POOL_VECTOR) ? 'V' : '-';
+ type_c = get_short_type_str(pool->type_2);
- _ODP_PRINT("%4u %-*s %c %6" PRIu64 " %6" PRIu32 " %6" PRIu32 " %8" PRIu32 " "
+ _ODP_PRINT("%4u %-*s %s %6" PRIu64 " %6" PRIu32 " %6" PRIu32 " %8" PRIu32 " "
"%" PRIu8 "\n", index, col_width, name, type_c, available, tot,
cache_size, buf_len, ext);
}
@@ -1673,6 +1711,58 @@ int odp_pool_stats(odp_pool_t pool_hdl, odp_pool_stats_t *stats)
return 0;
}
+int odp_pool_stats_selected(odp_pool_t pool_hdl, odp_pool_stats_selected_t *stats,
+ const odp_pool_stats_opt_t *opt)
+{
+ pool_t *pool;
+
+ if (odp_unlikely(pool_hdl == ODP_POOL_INVALID)) {
+ _ODP_ERR("Invalid pool handle\n");
+ return -1;
+ }
+ if (odp_unlikely(stats == NULL)) {
+ _ODP_ERR("Output buffer NULL\n");
+ return -1;
+ }
+ if (odp_unlikely(opt == NULL)) {
+ _ODP_ERR("Pool counters NULL\n");
+ return -1;
+ }
+
+ pool = _odp_pool_entry(pool_hdl);
+
+ if (odp_unlikely(opt->all & ~pool->params.stats.all)) {
+ _ODP_ERR("Trying to read disabled counter\n");
+ return -1;
+ }
+
+ if (opt->bit.available)
+ stats->available = ring_ptr_len(&pool->ring->hdr);
+
+ if (opt->bit.alloc_ops || opt->bit.total_ops)
+ stats->alloc_ops = odp_atomic_load_u64(&pool->stats.alloc_ops);
+
+ if (opt->bit.alloc_fails)
+ stats->alloc_fails = odp_atomic_load_u64(&pool->stats.alloc_fails);
+
+ if (opt->bit.free_ops || opt->bit.total_ops)
+ stats->free_ops = odp_atomic_load_u64(&pool->stats.free_ops);
+
+ if (opt->bit.total_ops)
+ stats->total_ops = stats->alloc_ops + stats->free_ops;
+
+ if (opt->bit.cache_available)
+ stats->cache_available = cache_total_available(pool);
+
+ if (opt->bit.cache_alloc_ops)
+ stats->cache_alloc_ops = odp_atomic_load_u64(&pool->stats.cache_alloc_ops);
+
+ if (opt->bit.cache_free_ops)
+ stats->cache_free_ops = odp_atomic_load_u64(&pool->stats.cache_free_ops);
+
+ return 0;
+}
+
int odp_pool_stats_reset(odp_pool_t pool_hdl)
{
pool_t *pool;
diff --git a/platform/linux-generic/odp_queue_lf.c b/platform/linux-generic/odp_queue_lf.c
index 9004402b8..7c9ba4013 100644
--- a/platform/linux-generic/odp_queue_lf.c
+++ b/platform/linux-generic/odp_queue_lf.c
@@ -176,7 +176,7 @@ static _odp_event_hdr_t *queue_lf_deq(odp_queue_t handle)
{
queue_entry_t *queue;
queue_lf_t *queue_lf;
- int i, j, i_lowest;
+ int i, j, i_lowest = 0;
int found;
ring_lf_node_t node_val, old_val, new_val;
ring_lf_node_t *node, *old;
diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c
index 18e1a7e23..8219c59a2 100644
--- a/platform/linux-generic/odp_timer.c
+++ b/platform/linux-generic/odp_timer.c
@@ -106,6 +106,8 @@
#define IDX2LOCK(tp, idx) (&(tp)->locks[(idx) % NUM_LOCKS])
#endif
+#define ACC_SIZE (1ull << 32)
+
#include <odp/visibility_begin.h>
/* Fill in timeout header field offsets for inline functions */
@@ -154,6 +156,12 @@ typedef struct {
/* Period of periodic timer in ticks (nanoseconds), includes PERIODIC_CANCELLED flag. */
uint64_t periodic_ticks;
+ /* Periodic ticks fractional part. */
+ uint32_t periodic_ticks_frac;
+
+ /* Periodic ticks fractional part accumulator. */
+ uint32_t periodic_ticks_frac_acc;
+
/* Used for free list of timers */
uint32_t next_free;
@@ -320,6 +328,22 @@ static void block_sigalarm(void)
sigprocmask(SIG_BLOCK, &sigset, NULL);
}
+static void posix_timer_stop(timer_pool_t *tp)
+{
+ int ret;
+
+ /* Stop POSIX timer signals */
+ if (timer_delete(tp->timerid) != 0)
+ _ODP_ABORT("timer_delete() returned error: %s\n", strerror(errno));
+
+ /* Stop the thread */
+ _ODP_DBG("stop\n");
+ tp->thr_exit = 1;
+ ret = pthread_join(tp->thr_pthread, NULL);
+ if (ret != 0)
+ _ODP_ABORT("Unable to join thread, err %d\n", ret);
+}
+
static void odp_timer_pool_del(timer_pool_t *tp)
{
int highest;
@@ -327,20 +351,8 @@ static void odp_timer_pool_del(timer_pool_t *tp)
odp_spinlock_lock(&tp->lock);
- if (!odp_global_rw->inline_timers) {
- int ret;
-
- /* Stop POSIX timer signals */
- if (timer_delete(tp->timerid) != 0)
- _ODP_ABORT("timer_delete() returned error %s\n", strerror(errno));
-
- /* Stop the thread */
- _ODP_DBG("stop\n");
- tp->thr_exit = 1;
- ret = pthread_join(tp->thr_pthread, NULL);
- if (ret != 0)
- _ODP_ABORT("unable to join thread, err %d\n", ret);
- }
+ if (!odp_global_rw->inline_timers)
+ posix_timer_stop(tp);
if (tp->num_alloc != 0) {
/* It's a programming error to attempt to destroy a */
@@ -1323,14 +1335,26 @@ int odp_timer_res_capability(odp_timer_clk_src_t clk_src,
}
if (res_capa->min_tmo) {
- _ODP_ERR("Only res_ns or max_tmo based quaries supported\n");
+ _ODP_ERR("Only res_ns or max_tmo based queries supported\n");
return -1;
}
if (res_capa->res_ns || res_capa->res_hz) {
+ if (res_capa->res_ns && res_capa->res_ns < timer_global->highest_res_ns) {
+ _ODP_DBG("Timeout resolution capability (res_ns) exceeded\n");
+ return -1;
+ }
+ if (res_capa->res_hz && res_capa->res_hz > timer_global->highest_res_hz) {
+ _ODP_DBG("Timeout resolution capability (res_hz) exceeded\n");
+ return -1;
+ }
res_capa->min_tmo = 0;
res_capa->max_tmo = MAX_TMO_NSEC;
} else { /* max_tmo */
+ if (res_capa->max_tmo > MAX_TMO_NSEC) {
+ _ODP_DBG("Maximum relative timeout capability (max_tmo) exceeded\n");
+ return -1;
+ }
res_capa->min_tmo = 0;
res_capa->res_ns = timer_global->highest_res_ns;
res_capa->res_hz = timer_global->highest_res_hz;
@@ -1429,6 +1453,39 @@ uint64_t odp_timer_current_tick(odp_timer_pool_t tpid)
return current_nsec(tp);
}
+int odp_timer_sample_ticks(odp_timer_pool_t timer_pool[], uint64_t tick[], uint64_t clk_count[],
+ int num)
+{
+ timer_pool_t *tp[MAX_TIMER_POOLS];
+ odp_time_t now;
+ int i;
+
+ if (num <= 0 || num > MAX_TIMER_POOLS) {
+ _ODP_ERR("Bad number of timer pools: %i\n", num);
+ return -1;
+ }
+
+ for (i = 0; i < num; i++) {
+ if (odp_unlikely(timer_pool[i] == ODP_TIMER_POOL_INVALID)) {
+ _ODP_ERR("Invalid timer pool\n");
+ return -1;
+ }
+
+ tp[i] = timer_pool_from_hdl(timer_pool[i]);
+ }
+
+ now = odp_time_global();
+
+ for (i = 0; i < num; i++) {
+ tick[i] = time_nsec(tp[i], now);
+
+ if (clk_count)
+ clk_count[i] = tick[i];
+ }
+
+ return 0;
+}
+
int odp_timer_pool_info(odp_timer_pool_t tpid, odp_timer_pool_info_t *tp_info)
{
timer_pool_t *tp;
@@ -1596,6 +1653,7 @@ int odp_timer_periodic_start(odp_timer_t timer, const odp_timer_periodic_start_t
_odp_timer_t *tim = &tp->timers[idx];
uint64_t multiplier = start_param->freq_multiplier;
double freq = multiplier * tp->base_freq;
+ double period_ns_dbl;
if (odp_unlikely(!tp->periodic)) {
_ODP_ERR("Not a periodic timer\n");
@@ -1612,7 +1670,9 @@ int odp_timer_periodic_start(odp_timer_t timer, const odp_timer_periodic_start_t
return ODP_TIMER_FAIL;
}
- period_ns = (uint64_t)((double)ODP_TIME_SEC_IN_NS / freq);
+ period_ns_dbl = (double)ODP_TIME_SEC_IN_NS / freq;
+ period_ns = period_ns_dbl;
+
if (period_ns == 0) {
_ODP_ERR("Too high periodic timer frequency: %f\n", freq);
return ODP_TIMER_FAIL;
@@ -1624,6 +1684,8 @@ int odp_timer_periodic_start(odp_timer_t timer, const odp_timer_periodic_start_t
}
tim->periodic_ticks = period_ns;
+ tim->periodic_ticks_frac = (period_ns_dbl - period_ns) * ACC_SIZE;
+ tim->periodic_ticks_frac_acc = 0;
abs_tick = start_param->first_tick;
if (abs_tick) {
@@ -1650,7 +1712,7 @@ int odp_timer_periodic_start(odp_timer_t timer, const odp_timer_periodic_start_t
int odp_timer_periodic_ack(odp_timer_t timer, odp_event_t tmo_ev)
{
- uint64_t abs_tick;
+ uint64_t abs_tick, acc;
odp_timeout_t tmo = odp_timeout_from_event(tmo_ev);
timer_pool_t *tp = handle_to_tp(timer);
uint32_t idx = handle_to_idx(timer, tp);
@@ -1668,6 +1730,14 @@ int odp_timer_periodic_ack(odp_timer_t timer, odp_event_t tmo_ev)
return 2;
}
+ acc = (uint64_t)tim->periodic_ticks_frac_acc + (uint64_t)tim->periodic_ticks_frac;
+
+ if (acc >= ACC_SIZE) {
+ abs_tick++;
+ acc -= ACC_SIZE;
+ }
+
+ tim->periodic_ticks_frac_acc = acc;
abs_tick += odp_timeout_tick(tmo);
if (!timer_reset(idx, abs_tick, &tmo_ev, tp))
@@ -1694,11 +1764,11 @@ int odp_timer_cancel(odp_timer_t hdl, odp_event_t *tmo_ev)
if (old_event != ODP_EVENT_INVALID) {
/* Active timer cancelled, timeout returned */
*tmo_ev = old_event;
- return 0;
+ return ODP_TIMER_SUCCESS;
}
/* Timer already expired, no timeout returned */
- return -1;
+ return ODP_TIMER_TOO_NEAR;
}
int odp_timer_periodic_cancel(odp_timer_t hdl)
@@ -1755,6 +1825,11 @@ int odp_timeout_fresh(odp_timeout_t tmo)
{
const odp_timeout_hdr_t *hdr = timeout_hdr(tmo);
odp_timer_t hdl = hdr->timer;
+
+ /* Timeout not connected to a timer */
+ if (odp_unlikely(hdl == ODP_TIMER_INVALID))
+ return 0;
+
timer_pool_t *tp = handle_to_tp(hdl);
uint32_t idx = handle_to_idx(hdl, tp);
tick_buf_t *tb = &tp->tick_buf[idx];
@@ -1767,6 +1842,7 @@ int odp_timeout_fresh(odp_timeout_t tmo)
odp_timeout_t odp_timeout_alloc(odp_pool_t pool_hdl)
{
+ odp_timeout_hdr_t *hdr;
odp_event_t event;
pool_t *pool;
@@ -1780,6 +1856,9 @@ odp_timeout_t odp_timeout_alloc(odp_pool_t pool_hdl)
if (odp_unlikely(event == ODP_EVENT_INVALID))
return ODP_TIMEOUT_INVALID;
+ hdr = timeout_hdr_from_event(event);
+ hdr->timer = ODP_TIMER_INVALID;
+
return odp_timeout_from_event(event);
}
@@ -1996,16 +2075,30 @@ int _odp_timer_term_global(void)
{
odp_shm_t shm;
int i;
+ int rc = 0;
if (timer_global == NULL)
return 0;
for (i = 0; i < MAX_TIMER_POOLS; i++) {
shm = timer_global->tp_shm[i];
+
+ if (timer_global->timer_pool_used[i]) {
+ _ODP_ERR("Not destroyed timer pool: %i\n", i);
+ rc = -1;
+
+ /* Prevent crash from timer thread */
+ if (!odp_global_rw->inline_timers) {
+ timer_pool_t *tp = timer_global->timer_pool[i];
+
+ if (tp != NULL)
+ posix_timer_stop(tp);
+ }
+ }
if (shm != ODP_SHM_INVALID) {
if (odp_shm_free(shm)) {
- _ODP_ERR("Shm free failed for timer pool %i\n", i);
- return -1;
+ _ODP_ERR("Shm free failed for timer pool: %i\n", i);
+ rc = -1;
}
}
}
@@ -2015,7 +2108,7 @@ int _odp_timer_term_global(void)
return -1;
}
- return 0;
+ return rc;
}
int _odp_timer_init_local(void)
diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c
index 67779e073..54c54ff10 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -160,6 +160,9 @@ typedef struct {
typedef struct ODP_ALIGNED_CACHE {
/* --- Fast path data --- */
+ /* Function for mbuf to ODP packet conversion */
+ int (*mbuf_to_pkt_fn)(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[],
+ struct rte_mbuf *mbuf_table[], uint16_t mbuf_num, odp_time_t *ts);
/* Packet output capabilities */
odp_pktout_config_opt_t pktout_capa;
/* DPDK port identifier */
@@ -667,6 +670,8 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry,
int i, j, num;
uint32_t max_len;
int nb_pkts = 0;
+ int nb_cls = 0;
+ const int cls_enabled = pktio_cls_enabled(pktio_entry);
pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry);
odp_pool_t pool = pkt_dpdk->pool;
odp_pktin_config_opt_t pktin_cfg = pktio_entry->config.pktin;
@@ -715,7 +720,7 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry,
continue;
}
- if (pktio_cls_enabled(pktio_entry)) {
+ if (cls_enabled) {
odp_pool_t new_pool;
ret = _odp_cls_classify_packet(pktio_entry, (const uint8_t *)data,
@@ -753,11 +758,21 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry,
packet_set_ts(pkt_hdr, ts);
- pkt_table[nb_pkts++] = pkt;
-
rte_pktmbuf_free(mbuf);
+
+ if (cls_enabled) {
+ /* Enqueue packets directly to classifier destination queue */
+ pkt_table[nb_cls++] = pkt;
+ nb_cls = _odp_cls_enq(pkt_table, nb_cls, (i + 1 == num));
+ } else {
+ pkt_table[nb_pkts++] = pkt;
+ }
}
+ /* Enqueue remaining classified packets */
+ if (odp_unlikely(nb_cls))
+ _odp_cls_enq(pkt_table, nb_cls, true);
+
return nb_pkts;
fail:
@@ -938,34 +953,37 @@ static inline void prefetch_pkt(struct rte_mbuf *mbuf)
odp_prefetch(data);
}
+/**
+ * Convert mbufs when packet parsing is required
+ */
static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry,
odp_packet_t pkt_table[],
struct rte_mbuf *mbuf_table[],
uint16_t mbuf_num, odp_time_t *ts)
{
- odp_packet_hdr_t *pkt_hdr;
- uint16_t pkt_len;
- uint8_t set_flow_hash;
- struct rte_mbuf *mbuf;
- void *data;
- int i, nb_pkts;
- odp_pktin_config_opt_t pktin_cfg;
- odp_pktio_t input;
pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry);
+ const uint8_t set_flow_hash = pkt_dpdk->flags.set_flow_hash;
+ const odp_pktio_t input = pktio_entry->handle;
+ const odp_pktin_config_opt_t pktin_cfg = pktio_entry->config.pktin;
const odp_proto_layer_t layer = pktio_entry->parse_layer;
+ const int cls_enabled = pktio_cls_enabled(pktio_entry);
+ int nb_cls = 0;
+ int nb_pkts = 0;
- prefetch_pkt(mbuf_table[0]);
+ _ODP_ASSERT(layer != ODP_PROTO_LAYER_NONE);
- nb_pkts = 0;
- set_flow_hash = pkt_dpdk->flags.set_flow_hash;
- pktin_cfg = pktio_entry->config.pktin;
- input = pktio_entry->handle;
+ prefetch_pkt(mbuf_table[0]);
if (odp_likely(mbuf_num > 1))
prefetch_pkt(mbuf_table[1]);
- for (i = 0; i < mbuf_num; i++) {
+ for (uint16_t i = 0; i < mbuf_num; i++) {
odp_packet_t pkt;
+ odp_packet_hdr_t *pkt_hdr;
+ struct rte_mbuf *mbuf;
+ void *data;
+ uint16_t pkt_len;
+ int ret;
if (odp_likely((i + 2) < mbuf_num))
prefetch_pkt(mbuf_table[i + 2]);
@@ -986,42 +1004,98 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry,
/* Init buffer segments. Currently, only single segment packets
* are supported. */
pkt_hdr->seg_data = data;
+ pkt_hdr->input = input;
- if (layer) {
- int ret;
+ if (set_flow_hash && (mbuf->ol_flags & RTE_MBUF_F_RX_RSS_HASH))
+ packet_set_flow_hash(pkt_hdr, mbuf->hash.rss);
- ret = _odp_dpdk_packet_parse_common(pkt_hdr, data, pkt_len, pkt_len,
- mbuf, layer, pktin_cfg);
- if (ret)
- odp_atomic_inc_u64(&pktio_entry->stats_extra.in_errors);
+ packet_set_ts(pkt_hdr, ts);
- if (ret < 0) {
+ ret = _odp_dpdk_packet_parse_common(pkt_hdr, data, pkt_len, pkt_len,
+ mbuf, layer, pktin_cfg);
+ if (ret)
+ odp_atomic_inc_u64(&pktio_entry->stats_extra.in_errors);
+
+ if (ret < 0) {
+ rte_pktmbuf_free(mbuf);
+ continue;
+ }
+
+ if (cls_enabled) {
+ odp_pool_t new_pool;
+
+ ret = _odp_cls_classify_packet(pktio_entry, (const uint8_t *)data,
+ &new_pool, pkt_hdr);
+ if (ret < 0)
+ odp_atomic_inc_u64(&pktio_entry->stats_extra.in_discards);
+
+ if (ret) {
rte_pktmbuf_free(mbuf);
continue;
}
- if (pktio_cls_enabled(pktio_entry)) {
- odp_pool_t new_pool;
+ if (odp_unlikely(_odp_pktio_packet_to_pool(&pkt, &pkt_hdr, new_pool))) {
+ rte_pktmbuf_free(mbuf);
+ odp_atomic_inc_u64(&pktio_entry->stats_extra.in_discards);
+ continue;
+ }
- ret = _odp_cls_classify_packet(pktio_entry, (const uint8_t *)data,
- &new_pool, pkt_hdr);
- if (ret < 0)
- odp_atomic_inc_u64(&pktio_entry->stats_extra.in_discards);
+ /* Enqueue packet directly to CoS destination queue */
+ pkt_table[nb_cls++] = pkt;
+ nb_cls = _odp_cls_enq(pkt_table, nb_cls, (i + 1 == mbuf_num));
+ } else {
+ pkt_table[nb_pkts++] = pkt;
+ }
+ }
- if (ret) {
- rte_pktmbuf_free(mbuf);
- continue;
- }
+ /* Enqueue remaining classified packets */
+ if (odp_unlikely(nb_cls))
+ _odp_cls_enq(pkt_table, nb_cls, true);
- if (odp_unlikely(_odp_pktio_packet_to_pool(
- &pkt, &pkt_hdr, new_pool))) {
- rte_pktmbuf_free(mbuf);
- odp_atomic_inc_u64(&pktio_entry->stats_extra.in_discards);
- continue;
- }
- }
+ return nb_pkts;
+}
+
+/**
+ * Convert mbufs when packet parsing and classifier are disabled
+ */
+static inline int mbuf_to_pkt_zero_minimal(pktio_entry_t *pktio_entry,
+ odp_packet_t pkt_table[], struct rte_mbuf *mbuf_table[],
+ uint16_t mbuf_num, odp_time_t *ts)
+{
+ pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry);
+ const uint8_t set_flow_hash = pkt_dpdk->flags.set_flow_hash;
+ const odp_pktio_t input = pktio_entry->handle;
+ uint16_t nb_pkts = 0;
+
+ _ODP_ASSERT(pktio_entry->parse_layer == ODP_PROTO_LAYER_NONE);
+
+ prefetch_pkt(mbuf_table[0]);
+
+ if (odp_likely(mbuf_num > 1))
+ prefetch_pkt(mbuf_table[1]);
+
+ for (int i = 0; i < mbuf_num; i++) {
+ odp_packet_hdr_t *pkt_hdr;
+ struct rte_mbuf *mbuf;
+ uint16_t pkt_len;
+
+ if (odp_likely((i + 2) < mbuf_num))
+ prefetch_pkt(mbuf_table[i + 2]);
+
+ mbuf = mbuf_table[i];
+ if (odp_unlikely(mbuf->nb_segs != 1)) {
+ _ODP_ERR("Segmented buffers not supported\n");
+ rte_pktmbuf_free(mbuf);
+ continue;
}
+ pkt_len = rte_pktmbuf_pkt_len(mbuf);
+ pkt_hdr = pkt_hdr_from_mbuf(mbuf);
+ packet_init(pkt_hdr, pkt_len);
+
+ /* Init buffer segments. Currently, only single segment packets
+ * are supported. */
+ pkt_hdr->seg_data = rte_pktmbuf_mtod(mbuf, uint8_t *);
pkt_hdr->input = input;
if (set_flow_hash && (mbuf->ol_flags & RTE_MBUF_F_RX_RSS_HASH))
@@ -1029,7 +1103,7 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry,
packet_set_ts(pkt_hdr, ts);
- pkt_table[nb_pkts++] = pkt;
+ pkt_table[nb_pkts++] = packet_handle(pkt_hdr);
}
return nb_pkts;
@@ -2033,6 +2107,18 @@ static int dpdk_start(pktio_entry_t *pktio_entry)
return -1;
}
}
+
+ if (_ODP_DPDK_ZERO_COPY) {
+ /* Use simpler function when packet parsing and classifying are not required */
+ if (pktio_entry->parse_layer == ODP_PROTO_LAYER_NONE)
+ pkt_dpdk->mbuf_to_pkt_fn = mbuf_to_pkt_zero_minimal;
+ else
+ pkt_dpdk->mbuf_to_pkt_fn = mbuf_to_pkt_zero;
+
+ } else {
+ pkt_dpdk->mbuf_to_pkt_fn = mbuf_to_pkt;
+ }
+
/* Start device */
ret = rte_eth_dev_start(port_id);
if (ret < 0) {
@@ -2110,12 +2196,8 @@ static int dpdk_recv(pktio_entry_t *pktio_entry, int index,
ts_val = odp_time_global();
ts = &ts_val;
}
- if (_ODP_DPDK_ZERO_COPY)
- nb_rx = mbuf_to_pkt_zero(pktio_entry, pkt_table,
- rx_mbufs, nb_rx, ts);
- else
- nb_rx = mbuf_to_pkt(pktio_entry, pkt_table, rx_mbufs,
- nb_rx, ts);
+
+ nb_rx = pkt_dpdk->mbuf_to_pkt_fn(pktio_entry, pkt_table, rx_mbufs, nb_rx, ts);
}
return nb_rx;
diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c
index 58b949402..01d25e11d 100644
--- a/platform/linux-generic/pktio/ipc.c
+++ b/platform/linux-generic/pktio/ipc.c
@@ -5,6 +5,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <odp/api/hints.h>
#include <odp/api/system_info.h>
#include <odp_debug_internal.h>
@@ -916,6 +917,16 @@ static int ipc_link_info(pktio_entry_t *pktio_entry, odp_pktio_link_info_t *info
return 0;
}
+static int ipc_capability(pktio_entry_t *pktio_entry ODP_UNUSED, odp_pktio_capability_t *capa)
+{
+ memset(capa, 0, sizeof(odp_pktio_capability_t));
+
+ capa->max_input_queues = 1;
+ capa->max_output_queues = 1;
+
+ return 0;
+}
+
static int ipc_close(pktio_entry_t *pktio_entry)
{
pkt_ipc_t *pktio_ipc = pkt_priv(pktio_entry);
@@ -965,6 +976,7 @@ const pktio_if_ops_t _odp_ipc_pktio_ops = {
.stop = ipc_stop,
.link_status = ipc_link_status,
.link_info = ipc_link_info,
+ .capability = ipc_capability,
.maxlen_get = ipc_mtu_get,
.promisc_mode_set = NULL,
.promisc_mode_get = NULL,
diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c
index f9c72db25..08459776b 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -251,12 +251,15 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index, odp_packet_t pkt
odp_queue_t queue = entry->queue;
stats_t *stats = &entry->stats;
_odp_event_hdr_t *hdr_tbl[QUEUE_MULTI_MAX];
+ odp_packet_t cls_tbl[QUEUE_MULTI_MAX];
odp_packet_hdr_t *pkt_hdr;
odp_packet_t pkt;
odp_time_t ts_val;
odp_time_t *ts = NULL;
int num_rx = 0;
int packets = 0;
+ int num_cls = 0;
+ const int cls_enabled = pktio_cls_enabled(pktio_entry);
uint32_t octets = 0;
const odp_proto_layer_t layer = pktio_entry->parse_layer;
const odp_pktin_config_opt_t opt = pktio_entry->config.pktin;
@@ -273,6 +276,7 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index, odp_packet_t pkt
for (i = 0; i < nbr; i++) {
uint32_t pkt_len;
+ int do_ipsec_enq = 0;
pkt = packet_from_event_hdr(hdr_tbl[i]);
pkt_len = odp_packet_len(pkt);
@@ -306,7 +310,7 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index, odp_packet_t pkt
continue;
}
- if (pktio_cls_enabled(pktio_entry)) {
+ if (cls_enabled) {
odp_pool_t new_pool;
ret = _odp_cls_classify_packet(pktio_entry, pkt_addr,
@@ -335,7 +339,7 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index, odp_packet_t pkt
if (pktio_entry->config.inbound_ipsec &&
!pkt_hdr->p.flags.ip_err &&
odp_packet_has_ipsec(pkt)) {
- _odp_ipsec_try_inline(&pkt);
+ do_ipsec_enq = !_odp_ipsec_try_inline(&pkt);
pkt_hdr = packet_hdr(pkt);
}
@@ -344,9 +348,29 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index, odp_packet_t pkt
packets++;
}
- pkts[num_rx++] = pkt;
+ if (do_ipsec_enq) {
+ if (odp_unlikely(odp_queue_enq(pkt_hdr->dst_queue,
+ odp_packet_to_event(pkt)))) {
+ odp_atomic_inc_u64(&stats->in_discards);
+ if (!pkt_hdr->p.flags.all.error) {
+ octets -= pkt_len;
+ packets--;
+ }
+ odp_packet_free(pkt);
+ }
+ } else if (cls_enabled) {
+ /* Enqueue packets directly to classifier destination queue */
+ cls_tbl[num_cls++] = pkt;
+ num_cls = _odp_cls_enq(cls_tbl, num_cls, (i + 1 == nbr));
+ } else {
+ pkts[num_rx++] = pkt;
+ }
}
+ /* Enqueue remaining classified packets */
+ if (odp_unlikely(num_cls))
+ _odp_cls_enq(cls_tbl, num_cls, true);
+
odp_atomic_add_u64(&stats->in_octets, octets);
odp_atomic_add_u64(&stats->in_packets, packets);
diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c
index 20b6ec179..6f68e95a1 100644
--- a/platform/linux-generic/pktio/pcap.c
+++ b/platform/linux-generic/pktio/pcap.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021-2022, Nokia
+ * Copyright (c) 2021-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -291,6 +291,9 @@ static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
odp_time_t *ts = NULL;
int packets = 0;
uint32_t octets = 0;
+ int num_pkts = 0;
+ int num_cls = 0;
+ const int cls_enabled = pktio_cls_enabled(pktio_entry);
uint16_t frame_offset = pktio_entry->pktin_frame_offset;
const odp_proto_layer_t layer = pktio_entry->parse_layer;
const odp_pktin_config_opt_t opt = pktio_entry->config.pktin;
@@ -304,7 +307,7 @@ static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
if (opt.bit.ts_all || opt.bit.ts_ptp)
ts = &ts_val;
- for (i = 0; i < num; ) {
+ for (i = 0; i < num; i++) {
int ret;
ret = pcap_next_ex(pcap->rx, &hdr, &data);
@@ -346,7 +349,7 @@ static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
continue;
}
- if (pktio_cls_enabled(pktio_entry)) {
+ if (cls_enabled) {
odp_pool_t new_pool;
ret = _odp_cls_classify_packet(pktio_entry, data,
@@ -376,17 +379,25 @@ static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
packets++;
}
- pkts[i] = pkt;
-
- i++;
+ /* Enqueue packets directly to classifier destination queue */
+ if (cls_enabled) {
+ pkts[num_cls++] = pkt;
+ num_cls = _odp_cls_enq(pkts, num_cls, (i + 1 == num));
+ } else {
+ pkts[num_pkts++] = pkt;
+ }
}
+ /* Enqueue remaining classified packets */
+ if (odp_unlikely(num_cls))
+ _odp_cls_enq(pkts, num_cls, true);
+
pktio_entry->stats.in_octets += octets;
pktio_entry->stats.in_packets += packets;
odp_ticketlock_unlock(&pktio_entry->rxl);
- return i;
+ return num_pkts;
}
static int _pcapif_dump_pkt(pkt_pcap_t *pcap, odp_packet_t pkt)
diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c
index 371831961..609a9351f 100644
--- a/platform/linux-generic/pktio/socket.c
+++ b/platform/linux-generic/pktio/socket.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2013-2022, Nokia Solutions and Networks
+ * Copyright (c) 2013-2023, Nokia Solutions and Networks
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -224,9 +224,11 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
struct mmsghdr msgvec[num];
struct iovec iovecs[num][PKT_MAX_SEGS];
int nb_rx = 0;
+ int nb_cls = 0;
int nb_pkts;
int recv_msgs;
int i;
+ const int cls_enabled = pktio_cls_enabled(pktio_entry);
uint16_t frame_offset = pktio_entry->pktin_frame_offset;
uint32_t alloc_len = pkt_sock->mtu + frame_offset;
const odp_proto_layer_t layer = pktio_entry->parse_layer;
@@ -296,7 +298,7 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
continue;
}
- if (pktio_cls_enabled(pktio_entry)) {
+ if (cls_enabled) {
odp_pool_t new_pool;
ret = _odp_cls_classify_packet(pktio_entry, base,
@@ -328,9 +330,19 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
pkt_hdr->input = pktio_entry->handle;
packet_set_ts(pkt_hdr, ts);
- pkt_table[nb_rx++] = pkt;
+ if (cls_enabled) {
+ /* Enqueue packets directly to classifier destination queue */
+ pkt_table[nb_cls++] = pkt;
+ nb_cls = _odp_cls_enq(pkt_table, nb_cls, (i + 1 == recv_msgs));
+ } else {
+ pkt_table[nb_rx++] = pkt;
+ }
}
+ /* Enqueue remaining classified packets */
+ if (odp_unlikely(nb_cls))
+ _odp_cls_enq(pkt_table, nb_cls, true);
+
/* Free unused pkt buffers */
if (i < nb_pkts)
odp_packet_free_multi(&pkt_table[i], nb_pkts - i);
diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c
index 0c04acd03..2ca150751 100644
--- a/platform/linux-generic/pktio/socket_mmap.c
+++ b/platform/linux-generic/pktio/socket_mmap.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2013-2022, Nokia Solutions and Networks
+ * Copyright (c) 2013-2023, Nokia Solutions and Networks
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -138,13 +138,15 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry,
{
odp_time_t ts_val;
odp_time_t *ts = NULL;
- unsigned frame_num, next_frame_num;
+ unsigned int frame_num, next_frame_num;
uint8_t *pkt_buf, *next_ptr;
int pkt_len;
uint32_t alloc_len;
struct ethhdr *eth_hdr;
- unsigned i;
- unsigned nb_rx;
+ unsigned int i;
+ unsigned int nb_rx = 0;
+ unsigned int nb_cls = 0;
+ const int cls_enabled = pktio_cls_enabled(pktio_entry);
struct ring *ring;
odp_pool_t pool = pkt_sock->pool;
uint16_t frame_offset = pktio_entry->pktin_frame_offset;
@@ -159,7 +161,7 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry,
frame_num = ring->frame_num;
next_ptr = ring->rd[frame_num].iov_base;
- for (i = 0, nb_rx = 0; i < num; i++) {
+ for (i = 0; i < num; i++) {
struct tpacket2_hdr *tp_hdr;
odp_packet_t pkt;
odp_packet_hdr_t *hdr;
@@ -276,7 +278,7 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry,
continue;
}
- if (pktio_cls_enabled(pktio_entry)) {
+ if (cls_enabled) {
odp_pool_t new_pool;
ret = _odp_cls_classify_packet(pktio_entry, pkt_buf,
@@ -308,11 +310,21 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry,
tp_hdr->tp_status = TP_STATUS_KERNEL;
frame_num = next_frame_num;
- pkt_table[nb_rx] = pkt;
- nb_rx++;
+ if (cls_enabled) {
+ /* Enqueue packets directly to classifier destination queue */
+ pkt_table[nb_cls++] = pkt;
+ nb_cls = _odp_cls_enq(pkt_table, nb_cls, (i + 1 == num));
+ } else {
+ pkt_table[nb_rx++] = pkt;
+ }
}
+ /* Enqueue remaining classified packets */
+ if (odp_unlikely(nb_cls))
+ _odp_cls_enq(pkt_table, nb_cls, true);
+
ring->frame_num = frame_num;
+
return nb_rx;
}
diff --git a/platform/linux-generic/pktio/socket_xdp.c b/platform/linux-generic/pktio/socket_xdp.c
index be79ca267..867483f76 100644
--- a/platform/linux-generic/pktio/socket_xdp.c
+++ b/platform/linux-generic/pktio/socket_xdp.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2022, Nokia
+/* Copyright (c) 2022-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -9,38 +9,42 @@
#ifdef _ODP_PKTIO_XDP
#include <odp_posix_extensions.h>
+#include <odp/api/cpu.h>
#include <odp/api/debug.h>
#include <odp/api/hints.h>
+#include <odp/api/packet_io_stats.h>
#include <odp/api/system_info.h>
#include <odp/api/ticketlock.h>
-#include <odp/api/packet_io_stats.h>
#include <odp_classification_internal.h>
#include <odp_debug_internal.h>
#include <odp_libconfig_internal.h>
#include <odp_macros_internal.h>
-#include <odp_packet_io_internal.h>
#include <odp_packet_internal.h>
+#include <odp_packet_io_internal.h>
#include <odp_parse_internal.h>
#include <odp_pool_internal.h>
#include <odp_socket_common.h>
-#include <string.h>
#include <errno.h>
-#include <sys/socket.h>
-#include <unistd.h>
-#include <poll.h>
-#include <sys/ioctl.h>
#include <linux/ethtool.h>
+#include <linux/if_xdp.h>
#include <linux/sockios.h>
#include <net/if.h>
-#include <linux/if_xdp.h>
+#include <poll.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <unistd.h>
#include <xdp/xsk.h>
#define NUM_DESCS_DEFAULT 1024U
#define MIN_FRAME_SIZE 2048U
+#define MAX_QUEUES (ODP_PKTIN_MAX_QUEUES > ODP_PKTOUT_MAX_QUEUES ? \
+ ODP_PKTIN_MAX_QUEUES : ODP_PKTOUT_MAX_QUEUES)
+
#define IF_DELIM " "
#define Q_DELIM ':'
#define CONF_BASE_STR "pktio_xdp"
@@ -63,6 +67,10 @@ static const char * const internal_stats_strs[] = {
#define MAX_INTERNAL_STATS _ODP_ARRAY_SIZE(internal_stats_strs)
+static const char * const shadow_q_driver_strs[] = {
+ "mlx",
+};
+
typedef struct {
uint64_t rx_dropped;
uint64_t rx_inv_descs;
@@ -94,9 +102,29 @@ typedef struct {
} xdp_umem_info_t;
typedef struct {
- xdp_sock_t qs[ODP_PKTOUT_MAX_QUEUES];
+ uint32_t rx;
+ uint32_t tx;
+ uint32_t other;
+ uint32_t combined;
+} drv_channels_t;
+
+typedef struct {
+ /* Queue counts for getting/setting driver's ethtool queue configuration. */
+ drv_channels_t drv_channels;
+ /* Packet I/O level requested input queue count. */
+ uint32_t num_in_conf_qs;
+ /* Packet I/O level requested output queue count. */
+ uint32_t num_out_conf_qs;
+ /* Actual internal queue count. */
+ uint32_t num_qs;
+ /* Length of driver's ethtool RSS indirection table. */
+ uint32_t drv_num_rss;
+} q_num_conf_t;
+
+typedef struct {
+ xdp_sock_t qs[MAX_QUEUES];
xdp_umem_info_t *umem_info;
- uint32_t num_q;
+ q_num_conf_t q_num_conf;
int pktio_idx;
int helper_sock;
uint32_t mtu;
@@ -104,6 +132,7 @@ typedef struct {
uint32_t bind_q;
odp_bool_t lockless_rx;
odp_bool_t lockless_tx;
+ odp_bool_t is_shadow_q;
} xdp_sock_info_t;
typedef struct {
@@ -137,13 +166,88 @@ static inline xdp_sock_info_t *pkt_priv(pktio_entry_t *pktio_entry)
return (xdp_sock_info_t *)(uintptr_t)(pktio_entry->pkt_priv);
}
+static odp_bool_t get_nic_queue_count(int fd, const char *devname, drv_channels_t *cur_channels)
+{
+ struct ethtool_channels channels;
+ struct ifreq ifr;
+ int ret;
+
+ memset(&channels, 0, sizeof(struct ethtool_channels));
+ channels.cmd = ETHTOOL_GCHANNELS;
+ snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", devname);
+ ifr.ifr_data = (char *)&channels;
+ ret = ioctl(fd, SIOCETHTOOL, &ifr);
+
+ if (ret == -1) {
+ _ODP_DBG("Unable to query NIC queue capabilities: %s\n", strerror(errno));
+ return false;
+ }
+
+ cur_channels->rx = channels.rx_count;
+ cur_channels->tx = channels.tx_count;
+ cur_channels->other = channels.other_count;
+ cur_channels->combined = channels.combined_count;
+
+ return true;
+}
+
+static odp_bool_t get_nic_rss_indir_count(int fd, const char *devname, uint32_t *drv_num_rss)
+{
+ struct ethtool_rxfh indir;
+ struct ifreq ifr;
+ int ret;
+
+ memset(&indir, 0, sizeof(struct ethtool_rxfh));
+ indir.cmd = ETHTOOL_GRSSH;
+ snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", devname);
+ ifr.ifr_data = (char *)&indir;
+ ret = ioctl(fd, SIOCETHTOOL, &ifr);
+
+ if (ret == -1) {
+ _ODP_DBG("Unable to query NIC RSS indirection table size: %s\n", strerror(errno));
+ return false;
+ }
+
+ *drv_num_rss = indir.indir_size;
+
+ return true;
+}
+
+static odp_bool_t is_shadow_q_driver(int fd, const char *devname)
+{
+ struct ethtool_drvinfo info;
+ struct ifreq ifr;
+ int ret;
+
+ memset(&info, 0, sizeof(struct ethtool_drvinfo));
+ info.cmd = ETHTOOL_GDRVINFO;
+ snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", devname);
+ ifr.ifr_data = (char *)&info;
+ ret = ioctl(fd, SIOCETHTOOL, &ifr);
+
+ if (ret == -1) {
+ _ODP_DBG("Unable to query NIC driver information: %s\n", strerror(errno));
+ return false;
+ }
+
+ for (uint32_t i = 0U; i < _ODP_ARRAY_SIZE(shadow_q_driver_strs); ++i) {
+ if (strstr(info.driver, shadow_q_driver_strs[i]) != NULL) {
+ _ODP_PRINT("Driver with XDP shadow queues in use: %s, manual RSS"
+ " configuration likely required\n", info.driver);
+ return true;
+ }
+ }
+
+ return false;
+}
+
static void parse_options(xdp_umem_info_t *umem_info)
{
if (!_odp_libconfig_lookup_ext_int(CONF_BASE_STR, NULL, RX_DESCS_STR,
&umem_info->num_rx_desc) ||
!_odp_libconfig_lookup_ext_int(CONF_BASE_STR, NULL, TX_DESCS_STR,
&umem_info->num_tx_desc)) {
- _ODP_ERR("Unable to parse xdp descriptor configuration, using defaults (%d).\n",
+ _ODP_ERR("Unable to parse xdp descriptor configuration, using defaults (%d)\n",
NUM_DESCS_DEFAULT);
goto defaults;
}
@@ -151,7 +255,7 @@ static void parse_options(xdp_umem_info_t *umem_info)
if (umem_info->num_rx_desc <= 0 || umem_info->num_tx_desc <= 0 ||
!_ODP_CHECK_IS_POWER2(umem_info->num_rx_desc) ||
!_ODP_CHECK_IS_POWER2(umem_info->num_tx_desc)) {
- _ODP_ERR("Invalid xdp descriptor configuration, using defaults (%d).\n",
+ _ODP_ERR("Invalid xdp descriptor configuration, using defaults (%d)\n",
NUM_DESCS_DEFAULT);
goto defaults;
}
@@ -163,150 +267,317 @@ defaults:
umem_info->num_tx_desc = NUM_DESCS_DEFAULT;
}
-static int umem_create(xdp_umem_info_t *umem_info, pool_t *pool)
+static int sock_xdp_open(odp_pktio_t pktio, pktio_entry_t *pktio_entry, const char *devname,
+ odp_pool_t pool_hdl)
+{
+ xdp_sock_info_t *priv;
+ pool_t *pool;
+ int ret;
+
+ if (disable_pktio)
+ return -1;
+
+ priv = pkt_priv(pktio_entry);
+ memset(priv, 0, sizeof(xdp_sock_info_t));
+ pool = _odp_pool_entry(pool_hdl);
+ priv->umem_info = (xdp_umem_info_t *)pool->mem_src_data;
+ priv->umem_info->pool = pool;
+ /* Mark transitory kernel-owned packets with the pktio index, so that they can be freed on
+ * close. */
+ priv->pktio_idx = 1 + odp_pktio_index(pktio);
+ /* Querying with ioctl() via AF_XDP socket doesn't seem to work, so
+ * create a helper socket for this. */
+ ret = socket(AF_INET, SOCK_DGRAM, 0);
+
+ if (ret == -1) {
+ _ODP_ERR("Error creating helper socket for xdp: %s\n", strerror(errno));
+ return -1;
+ }
+
+ priv->helper_sock = ret;
+ priv->mtu = _odp_mtu_get_fd(priv->helper_sock, devname);
+
+ if (priv->mtu == 0U)
+ goto mtu_err;
+
+ priv->max_mtu = pool->seg_len;
+
+ for (int i = 0; i < MAX_QUEUES; ++i) {
+ odp_ticketlock_init(&priv->qs[i].rx_lock);
+ odp_ticketlock_init(&priv->qs[i].tx_lock);
+ }
+
+ if (!get_nic_queue_count(priv->helper_sock, devname, &priv->q_num_conf.drv_channels) ||
+ !get_nic_rss_indir_count(priv->helper_sock, devname, &priv->q_num_conf.drv_num_rss))
+ _ODP_PRINT("Warning: Unable to query NIC queue count/RSS, manual cleanup"
+ " required\n");
+
+ priv->is_shadow_q = is_shadow_q_driver(priv->helper_sock, pktio_entry->name);
+ parse_options(priv->umem_info);
+ _ODP_DBG("Socket xdp interface (%s):\n", pktio_entry->name);
+ _ODP_DBG(" num_rx_desc: %d\n", priv->umem_info->num_rx_desc);
+ _ODP_DBG(" num_tx_desc: %d\n", priv->umem_info->num_tx_desc);
+
+ return 0;
+
+mtu_err:
+ close(priv->helper_sock);
+
+ return -1;
+}
+
+static odp_bool_t set_nic_queue_count(int fd, const char *devname, drv_channels_t *new_channels)
+{
+ struct ethtool_channels channels;
+ struct ifreq ifr;
+ int ret;
+
+ memset(&channels, 0, sizeof(struct ethtool_channels));
+ channels.cmd = ETHTOOL_SCHANNELS;
+ channels.rx_count = new_channels->rx;
+ channels.tx_count = new_channels->tx;
+ channels.other_count = new_channels->other;
+ channels.combined_count = new_channels->combined;
+ snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", devname);
+ ifr.ifr_data = (char *)&channels;
+ ret = ioctl(fd, SIOCETHTOOL, &ifr);
+
+ if (ret == -1) {
+ _ODP_DBG("Unable to set NIC queue count: %s\n", strerror(errno));
+ return false;
+ }
+
+ return true;
+}
+
+static odp_bool_t set_nic_rss_indir(int fd, const char *devname, struct ethtool_rxfh *indir)
+{
+ struct ifreq ifr;
+ int ret;
+
+ indir->cmd = ETHTOOL_SRSSH;
+ snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", devname);
+ ifr.ifr_data = (char *)indir;
+ ret = ioctl(fd, SIOCETHTOOL, &ifr);
+
+ if (ret == -1) {
+ _ODP_DBG("Unable to set NIC RSS indirection table: %s\n", strerror(errno));
+ return false;
+ }
+
+ return true;
+}
+
+static int sock_xdp_close(pktio_entry_t *pktio_entry)
+{
+ xdp_sock_info_t *priv = pkt_priv(pktio_entry);
+ struct ethtool_rxfh indir;
+
+ memset(&indir, 0, sizeof(struct ethtool_rxfh));
+
+ if (priv->q_num_conf.num_qs != 0U)
+ (void)set_nic_queue_count(priv->helper_sock, pktio_entry->name,
+ &priv->q_num_conf.drv_channels);
+
+ if (priv->q_num_conf.drv_num_rss != 0U && !priv->is_shadow_q)
+ (void)set_nic_rss_indir(priv->helper_sock, pktio_entry->name, &indir);
+
+ close(priv->helper_sock);
+
+ return 0;
+}
+
+static int umem_create(xdp_umem_info_t *umem_info)
{
struct xsk_umem_config cfg;
if (umem_info->ref_cnt++ > 0U)
return 0;
- parse_options(umem_info);
- umem_info->pool = pool;
/* Fill queue size is recommended to be >= HW RX ring size + AF_XDP RX
- * ring size, so use size twice the size of AF_XDP RX ring. */
+ * ring size, so use size twice the size of AF_XDP RX ring. */
cfg.fill_size = umem_info->num_rx_desc * 2U;
cfg.comp_size = umem_info->num_tx_desc;
- cfg.frame_size = pool->block_size;
- cfg.frame_headroom = sizeof(odp_packet_hdr_t) + pool->headroom;
+ cfg.frame_size = umem_info->pool->block_size;
+ cfg.frame_headroom = sizeof(odp_packet_hdr_t) + umem_info->pool->headroom;
cfg.flags = XDP_UMEM_UNALIGNED_CHUNK_FLAG;
- return xsk_umem__create(&umem_info->umem, pool->base_addr, pool->shm_size,
- &umem_info->fill_q, &umem_info->compl_q, &cfg);
+ return xsk_umem__create(&umem_info->umem, umem_info->pool->base_addr,
+ umem_info->pool->shm_size, &umem_info->fill_q, &umem_info->compl_q,
+ &cfg);
}
-static void umem_delete(xdp_umem_info_t *umem_info)
+static void fill_socket_config(struct xsk_socket_config *config, xdp_umem_info_t *umem_info)
{
- if (umem_info->ref_cnt-- != 1U)
- return;
-
- while (xsk_umem__delete(umem_info->umem) == -EBUSY)
- continue;
+ config->rx_size = umem_info->num_rx_desc * 2U;
+ config->tx_size = umem_info->num_tx_desc;
+ config->libxdp_flags = 0U;
+ config->xdp_flags = 0U;
+ config->bind_flags = XDP_ZEROCOPY;
}
-static uint32_t get_bind_queue_index(const char *devname)
+static odp_bool_t reserve_fill_queue_elements(xdp_sock_info_t *sock_info, xdp_sock_t *sock,
+ int num)
{
- const char *param = getenv("ODP_PKTIO_XDP_PARAMS");
- char *tmp_str;
- char *tmp;
- char *if_str;
- int idx = 0;
+ pool_t *pool;
+ odp_packet_t packets[num];
+ int count;
+ struct xsk_ring_prod *fill_q;
+ uint32_t start_idx;
+ int pktio_idx;
+ uint32_t block_size;
+ odp_packet_hdr_t *pkt_hdr;
+
+ pool = sock_info->umem_info->pool;
+ count = odp_packet_alloc_multi(_odp_pool_handle(pool), sock_info->mtu, packets, num);
+
+ if (count <= 0) {
+ ++sock->i_stats[RX_PKT_ALLOC_ERR];
+ return false;
+ }
- if (param == NULL)
- goto out;
+ fill_q = &sock->fill_q;
- tmp_str = strdup(param);
+ if (xsk_ring_prod__reserve(fill_q, count, &start_idx) == 0U) {
+ odp_packet_free_multi(packets, count);
+ ++sock->i_stats[RX_DESC_RSV_ERR];
+ return false;
+ }
- if (tmp_str == NULL)
- goto out;
+ pktio_idx = sock_info->pktio_idx;
+ block_size = pool->block_size;
- tmp = strtok(tmp_str, IF_DELIM);
+ for (int i = 0; i < count; ++i) {
+ pkt_hdr = packet_hdr(packets[i]);
+ pkt_hdr->ms_pktio_idx = pktio_idx;
+ *xsk_ring_prod__fill_addr(fill_q, start_idx++) =
+ pkt_hdr->event_hdr.index.event * block_size;
+ }
- if (tmp == NULL)
- goto out_str;
+ xsk_ring_prod__submit(&sock->fill_q, count);
- while (tmp) {
- if_str = strchr(tmp, Q_DELIM);
+ return true;
+}
- if (if_str != NULL && if_str != &tmp[strlen(tmp) - 1U]) {
- if (strncmp(devname, tmp, (uint64_t)(uintptr_t)(if_str - tmp)) == 0) {
- idx = _ODP_MAX(atoi(++if_str), 0);
- break;
- }
+static odp_bool_t create_sockets(xdp_sock_info_t *sock_info, const char *devname)
+{
+ struct xsk_socket_config config;
+ uint32_t bind_q, i;
+ struct xsk_umem *umem;
+ xdp_sock_t *sock;
+ int ret;
+
+ bind_q = sock_info->bind_q;
+ umem = sock_info->umem_info->umem;
+
+ for (i = 0U; i < sock_info->q_num_conf.num_qs;) {
+ sock = &sock_info->qs[i];
+ fill_socket_config(&config, sock_info->umem_info);
+ ret = xsk_socket__create_shared(&sock->xsk, devname, bind_q, umem, &sock->rx,
+ &sock->tx, &sock->fill_q, &sock->compl_q, &config);
+
+ if (ret) {
+ _ODP_ERR("Error creating xdp socket for bind queue %u: %d\n", bind_q, ret);
+ goto err;
+ }
+
+ ++i;
+
+ if (!reserve_fill_queue_elements(sock_info, sock, config.rx_size)) {
+ _ODP_ERR("Unable to reserve fill queue descriptors for queue: %u\n",
+ bind_q);
+ goto err;
}
- tmp = strtok(NULL, IF_DELIM);
+ ++bind_q;
}
-out_str:
- free(tmp_str);
+ /* Ring setup/clean up routines seem to be asynchronous with some drivers and might not be
+ * ready yet after xsk_socket__create_shared(). */
+ sleep(1U);
+
+ return true;
-out:
- return idx;
+err:
+ for (uint32_t j = 0U; j < i; ++j) {
+ xsk_socket__delete(sock_info->qs[j].xsk);
+ sock_info->qs[j].xsk = NULL;
+ }
+
+ return false;
}
-static int sock_xdp_open(odp_pktio_t pktio, pktio_entry_t *pktio_entry, const char *devname,
- odp_pool_t pool_hdl)
+static void umem_delete(xdp_umem_info_t *umem_info)
{
- xdp_sock_info_t *priv;
- pool_t *pool;
+ if (umem_info->ref_cnt-- != 1U)
+ return;
+
+ while (xsk_umem__delete(umem_info->umem) == -EBUSY)
+ continue;
+}
+
+static int sock_xdp_start(pktio_entry_t *pktio_entry)
+{
+ xdp_sock_info_t *priv = pkt_priv(pktio_entry);
int ret;
+ drv_channels_t channels = priv->q_num_conf.drv_channels;
+ struct ethtool_rxfh *indir = calloc(1U, sizeof(struct ethtool_rxfh)
+ + sizeof(((struct ethtool_rxfh *)0)->rss_config[0U])
+ * priv->q_num_conf.drv_num_rss);
- if (disable_pktio)
+ if (indir == NULL) {
+ _ODP_ERR("Error allocating NIC RSS table\n");
return -1;
+ }
- priv = pkt_priv(pktio_entry);
- memset(priv, 0, sizeof(xdp_sock_info_t));
- pool = _odp_pool_entry(pool_hdl);
- priv->umem_info = (xdp_umem_info_t *)pool->mem_src_data;
- ret = umem_create(priv->umem_info, pool);
+ ret = umem_create(priv->umem_info);
if (ret) {
_ODP_ERR("Error creating UMEM pool for xdp: %d\n", ret);
- return -1;
+ goto err;
}
- /* Mark transitory kernel-owned packets with the pktio index, so that they can be freed on
- * close. */
- priv->pktio_idx = 1 + odp_pktio_index(pktio);
- /* Querying with ioctl() via AF_XDP socket doesn't seem to work, so
- * create a helper socket for this. */
- ret = socket(AF_INET, SOCK_DGRAM, 0);
-
- if (ret == -1) {
- _ODP_ERR("Error creating helper socket for xdp: %s\n", strerror(errno));
- goto sock_err;
- }
+ priv->q_num_conf.num_qs = _ODP_MAX(priv->q_num_conf.num_in_conf_qs,
+ priv->q_num_conf.num_out_conf_qs);
+ priv->bind_q = priv->is_shadow_q ? priv->q_num_conf.num_qs : 0U;
+ channels.combined = priv->q_num_conf.num_qs;
- priv->helper_sock = ret;
- priv->mtu = _odp_mtu_get_fd(priv->helper_sock, devname);
+ if (!set_nic_queue_count(priv->helper_sock, pktio_entry->name, &channels))
+ _ODP_PRINT("Warning: Unable to configure NIC queue count, manual configuration"
+ " required\n");
- if (priv->mtu == 0U)
- goto mtu_err;
+ if (priv->q_num_conf.num_in_conf_qs > 0U && !priv->is_shadow_q) {
+ indir->indir_size = priv->q_num_conf.drv_num_rss;
- priv->max_mtu = pool->seg_len;
+ for (uint32_t i = 0U; i < indir->indir_size; ++i)
+ indir->rss_config[i] = (i % priv->q_num_conf.num_in_conf_qs);
- for (int i = 0; i < ODP_PKTOUT_MAX_QUEUES; ++i) {
- odp_ticketlock_init(&priv->qs[i].rx_lock);
- odp_ticketlock_init(&priv->qs[i].tx_lock);
+ if (!set_nic_rss_indir(priv->helper_sock, pktio_entry->name, indir))
+ _ODP_PRINT("Warning: Unable to configure NIC RSS, manual configuration"
+ " required\n");
}
- priv->bind_q = get_bind_queue_index(pktio_entry->name);
-
- _ODP_DBG("Socket xdp interface (%s):\n", pktio_entry->name);
- _ODP_DBG(" num_rx_desc: %d\n", priv->umem_info->num_rx_desc);
- _ODP_DBG(" num_tx_desc: %d\n", priv->umem_info->num_tx_desc);
- _ODP_DBG(" starting bind queue: %u\n", priv->bind_q);
+ if (!create_sockets(priv, pktio_entry->name))
+ goto sock_err;
return 0;
-mtu_err:
- close(priv->helper_sock);
-
sock_err:
umem_delete(priv->umem_info);
+err:
+ free(indir);
+
return -1;
}
-static int sock_xdp_close(pktio_entry_t *pktio_entry)
+static int sock_xdp_stop(pktio_entry_t *pktio_entry)
{
xdp_sock_info_t *priv = pkt_priv(pktio_entry);
pool_t *pool = priv->umem_info->pool;
odp_packet_hdr_t *pkt_hdr;
- close(priv->helper_sock);
-
- for (uint32_t i = 0U; i < priv->num_q; ++i) {
+ for (uint32_t i = 0U; i < priv->q_num_conf.num_qs; ++i) {
if (priv->qs[i].xsk != NULL) {
xsk_socket__delete(priv->qs[i].xsk);
priv->qs[i].xsk = NULL;
@@ -342,7 +613,7 @@ static int sock_xdp_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats)
memset(stats, 0, sizeof(odp_pktio_stats_t));
- for (uint32_t i = 0U; i < priv->num_q; ++i) {
+ for (uint32_t i = 0U; i < priv->q_num_conf.num_qs; ++i) {
sock = &priv->qs[i];
qi_stats = sock->qi_stats;
qo_stats = sock->qo_stats;
@@ -372,7 +643,7 @@ static int sock_xdp_stats_reset(pktio_entry_t *pktio_entry)
struct xdp_statistics xdp_stats;
socklen_t optlen = sizeof(struct xdp_statistics);
- for (uint32_t i = 0U; i < priv->num_q; ++i) {
+ for (uint32_t i = 0U; i < priv->q_num_conf.num_qs; ++i) {
sock = &priv->qs[i];
memset(&sock->qi_stats, 0, sizeof(odp_pktin_queue_stats_t));
memset(&sock->qo_stats, 0, sizeof(odp_pktout_queue_stats_t));
@@ -431,7 +702,7 @@ static int sock_xdp_extra_stat_info(pktio_entry_t *pktio_entry, odp_pktio_extra_
int num)
{
xdp_sock_info_t *priv = pkt_priv(pktio_entry);
- const int total_stats = MAX_INTERNAL_STATS * priv->num_q;
+ const int total_stats = MAX_INTERNAL_STATS * priv->q_num_conf.num_qs;
if (info != NULL && num > 0) {
for (int i = 0; i < _ODP_MIN(num, total_stats); ++i)
@@ -446,7 +717,7 @@ static int sock_xdp_extra_stat_info(pktio_entry_t *pktio_entry, odp_pktio_extra_
static int sock_xdp_extra_stats(pktio_entry_t *pktio_entry, uint64_t stats[], int num)
{
xdp_sock_info_t *priv = pkt_priv(pktio_entry);
- const int total_stats = MAX_INTERNAL_STATS * priv->num_q;
+ const int total_stats = MAX_INTERNAL_STATS * priv->q_num_conf.num_qs;
uint64_t *i_stats;
if (stats != NULL && num > 0) {
@@ -462,7 +733,7 @@ static int sock_xdp_extra_stats(pktio_entry_t *pktio_entry, uint64_t stats[], in
static int sock_xdp_extra_stat_counter(pktio_entry_t *pktio_entry, uint32_t id, uint64_t *stat)
{
xdp_sock_info_t *priv = pkt_priv(pktio_entry);
- const uint32_t total_stats = MAX_INTERNAL_STATS * priv->num_q;
+ const uint32_t total_stats = MAX_INTERNAL_STATS * priv->q_num_conf.num_qs;
if (id >= total_stats) {
_ODP_ERR("Invalid counter id: %u (allowed range: 0-%u)\n", id, total_stats - 1U);
@@ -506,6 +777,9 @@ static uint32_t process_received(pktio_entry_t *pktio_entry, xdp_sock_t *sock, p
uint64_t errors = 0U, octets = 0U;
odp_pktio_t pktio_hdl = pktio_entry->handle;
uint32_t num_rx = 0U;
+ uint32_t num_cls = 0U;
+ uint32_t num_pkts = 0U;
+ const int cls_enabled = pktio_cls_enabled(pktio_entry);
for (int i = 0; i < num; ++i) {
extract_data(xsk_ring_cons__rx_desc(rx, start_idx++), base_addr, &pkt_data);
@@ -527,7 +801,7 @@ static uint32_t process_received(pktio_entry_t *pktio_entry, xdp_sock_t *sock, p
continue;
}
- if (pktio_cls_enabled(pktio_entry)) {
+ if (cls_enabled) {
odp_pool_t new_pool;
ret = _odp_cls_classify_packet(pktio_entry, pkt_data.data,
@@ -546,60 +820,29 @@ static uint32_t process_received(pktio_entry_t *pktio_entry, xdp_sock_t *sock, p
}
pkt_data.pkt_hdr->input = pktio_hdl;
- packets[num_rx++] = pkt_data.pkt;
+ num_pkts++;
octets += pkt_data.len;
+
+ if (cls_enabled) {
+ /* Enqueue packets directly to classifier destination queue */
+ packets[num_cls++] = pkt_data.pkt;
+ num_cls = _odp_cls_enq(packets, num_cls, (i + 1 == num));
+ } else {
+ packets[num_rx++] = pkt_data.pkt;
+ }
}
+ /* Enqueue remaining classified packets */
+ if (odp_unlikely(num_cls))
+ _odp_cls_enq(packets, num_cls, true);
+
sock->qi_stats.octets += octets;
- sock->qi_stats.packets += num_rx;
+ sock->qi_stats.packets += num_pkts;
sock->qi_stats.errors += errors;
return num_rx;
}
-static odp_bool_t reserve_fill_queue_elements(xdp_sock_info_t *sock_info, xdp_sock_t *sock,
- int num)
-{
- pool_t *pool;
- odp_packet_t packets[num];
- int count;
- struct xsk_ring_prod *fill_q;
- uint32_t start_idx;
- int pktio_idx;
- uint32_t block_size;
- odp_packet_hdr_t *pkt_hdr;
-
- pool = sock_info->umem_info->pool;
- count = odp_packet_alloc_multi(_odp_pool_handle(pool), sock_info->mtu, packets, num);
-
- if (count <= 0) {
- ++sock->i_stats[RX_PKT_ALLOC_ERR];
- return false;
- }
-
- fill_q = &sock->fill_q;
-
- if (xsk_ring_prod__reserve(fill_q, count, &start_idx) == 0U) {
- odp_packet_free_multi(packets, count);
- ++sock->i_stats[RX_DESC_RSV_ERR];
- return false;
- }
-
- pktio_idx = sock_info->pktio_idx;
- block_size = pool->block_size;
-
- for (int i = 0; i < count; ++i) {
- pkt_hdr = packet_hdr(packets[i]);
- pkt_hdr->ms_pktio_idx = pktio_idx;
- *xsk_ring_prod__fill_addr(fill_q, start_idx++) =
- pkt_hdr->event_hdr.index.event * block_size;
- }
-
- xsk_ring_prod__submit(&sock->fill_q, count);
-
- return true;
-}
-
static int sock_xdp_recv(pktio_entry_t *pktio_entry, int index, odp_packet_t packets[], int num)
{
xdp_sock_info_t *priv;
@@ -608,6 +851,7 @@ static int sock_xdp_recv(pktio_entry_t *pktio_entry, int index, odp_packet_t pac
uint32_t start_idx = 0U, recvd, procd;
priv = pkt_priv(pktio_entry);
+ _ODP_ASSERT((uint32_t)index < priv->q_num_conf.num_in_conf_qs);
sock = &priv->qs[index];
if (!priv->lockless_rx)
@@ -719,6 +963,7 @@ static int sock_xdp_send(pktio_entry_t *pktio_entry, int index, const odp_packet
return 0;
priv = pkt_priv(pktio_entry);
+ _ODP_ASSERT((uint32_t)index < priv->q_num_conf.num_out_conf_qs);
sock = &priv->qs[index];
if (!priv->lockless_tx)
@@ -830,12 +1075,13 @@ static int sock_xdp_link_info(pktio_entry_t *pktio_entry, odp_pktio_link_info_t
pktio_entry->name, info);
}
-static int set_queue_capability(int fd, const char *devname, odp_pktio_capability_t *capa)
+static int get_nic_queue_capability(int fd, const char *devname, odp_pktio_capability_t *capa)
{
- struct ifreq ifr;
struct ethtool_channels channels;
- uint32_t max_channels;
+ struct ifreq ifr;
int ret;
+ const uint32_t cc = odp_cpu_count();
+ uint32_t max_channels;
memset(&channels, 0, sizeof(struct ethtool_channels));
channels.cmd = ETHTOOL_GCHANNELS;
@@ -845,16 +1091,16 @@ static int set_queue_capability(int fd, const char *devname, odp_pktio_capabilit
if (ret == -1 || channels.max_combined == 0U) {
if (ret == -1 && errno != EOPNOTSUPP) {
- _ODP_ERR("Unable to query NIC channel capabilities: %s\n", strerror(errno));
+ _ODP_ERR("Unable to query NIC queue capabilities: %s\n", strerror(errno));
return -1;
}
channels.max_combined = 1U;
}
- max_channels = _ODP_MIN((uint32_t)ODP_PKTOUT_MAX_QUEUES, channels.max_combined);
+ max_channels = _ODP_MIN(cc, channels.max_combined);
capa->max_input_queues = _ODP_MIN((uint32_t)ODP_PKTIN_MAX_QUEUES, max_channels);
- capa->max_output_queues = max_channels;
+ capa->max_output_queues = _ODP_MIN((uint32_t)ODP_PKTOUT_MAX_QUEUES, max_channels);
return 0;
}
@@ -865,7 +1111,7 @@ static int sock_xdp_capability(pktio_entry_t *pktio_entry, odp_pktio_capability_
memset(capa, 0, sizeof(odp_pktio_capability_t));
- if (set_queue_capability(priv->helper_sock, pktio_entry->name, capa))
+ if (get_nic_queue_capability(priv->helper_sock, pktio_entry->name, capa))
return -1;
capa->set_op.op.promisc_mode = 1U;
@@ -903,72 +1149,22 @@ static int sock_xdp_input_queues_config(pktio_entry_t *pktio_entry,
{
xdp_sock_info_t *priv = pkt_priv(pktio_entry);
+ priv->q_num_conf.num_in_conf_qs = param->num_queues;
priv->lockless_rx = pktio_entry->param.in_mode == ODP_PKTIN_MODE_SCHED ||
param->op_mode == ODP_PKTIO_OP_MT_UNSAFE;
return 0;
}
-static void fill_socket_config(struct xsk_socket_config *config, xdp_umem_info_t *umem_info)
-{
- config->rx_size = umem_info->num_rx_desc;
- config->tx_size = umem_info->num_tx_desc;
- config->libxdp_flags = 0U;
- config->xdp_flags = 0U;
- config->bind_flags = XDP_ZEROCOPY; /* TODO: XDP_COPY */
-}
-
static int sock_xdp_output_queues_config(pktio_entry_t *pktio_entry,
const odp_pktout_queue_param_t *param)
{
xdp_sock_info_t *priv = pkt_priv(pktio_entry);
- struct xsk_socket_config config;
- const char *devname = pktio_entry->name;
- uint32_t bind_q, i;
- struct xsk_umem *umem;
- xdp_sock_t *sock;
- int ret;
+ priv->q_num_conf.num_out_conf_qs = param->num_queues;
priv->lockless_tx = param->op_mode == ODP_PKTIO_OP_MT_UNSAFE;
- fill_socket_config(&config, priv->umem_info);
- bind_q = priv->bind_q;
- umem = priv->umem_info->umem;
-
- for (i = 0U; i < param->num_queues;) {
- sock = &priv->qs[i];
- ret = xsk_socket__create_shared(&sock->xsk, devname, bind_q, umem, &sock->rx,
- &sock->tx, &sock->fill_q, &sock->compl_q, &config);
-
- if (ret) {
- _ODP_ERR("Error creating xdp socket for bind queue %u: %d\n", bind_q, ret);
- goto err;
- }
-
- ++i;
-
- if (!reserve_fill_queue_elements(priv, sock, config.rx_size)) {
- _ODP_ERR("Unable to reserve fill queue descriptors for queue: %u.\n",
- bind_q);
- goto err;
- }
-
- ++bind_q;
- }
-
- priv->num_q = i;
- /* Ring setup/clean up routines seem to be asynchronous with some drivers and might not be
- * ready yet after xsk_socket__create_shared(). */
- sleep(1U);
return 0;
-
-err:
- for (uint32_t j = 0U; j < i; ++j) {
- xsk_socket__delete(priv->qs[j].xsk);
- priv->qs[j].xsk = NULL;
- }
-
- return -1;
}
const pktio_if_ops_t _odp_sock_xdp_pktio_ops = {
@@ -979,8 +1175,8 @@ const pktio_if_ops_t _odp_sock_xdp_pktio_ops = {
.term = NULL,
.open = sock_xdp_open,
.close = sock_xdp_close,
- .start = NULL,
- .stop = NULL,
+ .start = sock_xdp_start,
+ .stop = sock_xdp_stop,
.stats = sock_xdp_stats,
.stats_reset = sock_xdp_stats_reset,
.pktin_queue_stats = sock_xdp_pktin_queue_stats,
diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c
index 5f5b081c5..50d17e888 100644
--- a/platform/linux-generic/pktio/tap.c
+++ b/platform/linux-generic/pktio/tap.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2015, Ilya Maximets <i.maximets@samsung.com>
- * Copyright (c) 2021-2022, Nokia
+ * Copyright (c) 2021-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -331,6 +331,9 @@ static int tap_pktio_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
odp_time_t ts_val;
odp_time_t *ts = NULL;
int num_rx = 0;
+ int num_cls = 0;
+ const int cls_enabled = pktio_cls_enabled(pktio_entry);
+ odp_packet_t pkt;
odp_ticketlock_lock(&pktio_entry->rxl);
@@ -350,12 +353,23 @@ static int tap_pktio_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
break;
}
- pkts[num_rx] = pack_odp_pkt(pktio_entry, buf, retval, ts);
- if (pkts[num_rx] == ODP_PACKET_INVALID)
+ pkt = pack_odp_pkt(pktio_entry, buf, retval, ts);
+ if (pkt == ODP_PACKET_INVALID)
break;
- num_rx++;
+
+ if (cls_enabled) {
+ /* Enqueue packets directly to classifier destination queue */
+ pkts[num_cls++] = pkt;
+ num_cls = _odp_cls_enq(pkts, num_cls, (i + 1 == num));
+ } else {
+ pkts[num_rx++] = pkt;
+ }
}
+ /* Enqueue remaining classified packets */
+ if (odp_unlikely(num_cls))
+ _odp_cls_enq(pkts, num_cls, true);
+
odp_ticketlock_unlock(&pktio_entry->rxl);
return num_rx;
diff --git a/platform/linux-generic/test/validation/api/shmem/shmem_odp2.c b/platform/linux-generic/test/validation/api/shmem/shmem_odp2.c
index 4b7af3736..1f2637a6a 100644
--- a/platform/linux-generic/test/validation/api/shmem/shmem_odp2.c
+++ b/platform/linux-generic/test/validation/api/shmem/shmem_odp2.c
@@ -5,6 +5,8 @@
*/
#include <odp_api.h>
+#include <odp/helper/odph_api.h>
+
#include <linux/limits.h>
#include <sys/types.h>
#include <unistd.h>
@@ -33,11 +35,11 @@ int main(int argc, char *argv[])
/* odp init: */
if (0 != odp_init_global(&odp2, NULL, NULL)) {
- fprintf(stderr, "error: odp_init_global() failed.\n");
+ ODPH_ERR("odp_init_global() failed\n");
return 1;
}
if (0 != odp_init_local(odp2, ODP_THREAD_CONTROL)) {
- fprintf(stderr, "error: odp_init_local() failed.\n");
+ ODPH_ERR("odp_init_local() failed\n");
return 1;
}
@@ -46,8 +48,7 @@ int main(int argc, char *argv[])
* is given as first arg. In linux-generic ODP, this pid is actually
* the ODP instance */
if (argc != 2) {
- fprintf(stderr, "One single parameter expected, %d found.\n",
- argc);
+ ODPH_ERR("One single parameter expected, %d found\n", argc);
return 1;
}
odp1 = (odp_instance_t)atoi(argv[1]);
@@ -56,46 +57,46 @@ int main(int argc, char *argv[])
SHM_NAME, (int)odp1);
shm = odp_shm_import(SHM_NAME, odp1, SHM_NAME);
if (shm == ODP_SHM_INVALID) {
- fprintf(stderr, "error: odp_shm_lookup_external failed.\n");
+ ODPH_ERR("odp_shm_import() failed\n");
return 1;
}
/* check that the read size matches the allocated size (in other ODP):*/
if ((odp_shm_info(shm, &info)) ||
(info.size != sizeof(*test_shared_data))) {
- fprintf(stderr, "error: odp_shm_info failed.\n");
+ ODPH_ERR("odp_shm_info() failed\n");
return 1;
}
test_shared_data = odp_shm_addr(shm);
if (test_shared_data == NULL) {
- fprintf(stderr, "error: odp_shm_addr failed.\n");
+ ODPH_ERR("odp_shm_addr() failed\n");
return 1;
}
if (test_shared_data->foo != TEST_SHARE_FOO) {
- fprintf(stderr, "error: Invalid data TEST_SHARE_FOO.\n");
+ ODPH_ERR("Invalid data TEST_SHARE_FOO\n");
return 1;
}
if (test_shared_data->bar != TEST_SHARE_BAR) {
- fprintf(stderr, "error: Invalid data TEST_SHARE_BAR.\n");
+ ODPH_ERR("Invalid data TEST_SHARE_BAR\n");
return 1;
}
if (odp_shm_free(shm) != 0) {
- fprintf(stderr, "error: odp_shm_free() failed.\n");
+ ODPH_ERR("odp_shm_free() failed\n");
return 1;
}
/* odp term: */
if (0 != odp_term_local()) {
- fprintf(stderr, "error: odp_term_local() failed.\n");
+ ODPH_ERR("odp_term_local() failed\n");
return 1;
}
if (0 != odp_term_global(odp2)) {
- fprintf(stderr, "error: odp_term_global() failed.\n");
+ ODPH_ERR("odp_term_global() failed\n");
return 1;
}
diff --git a/test/common/odp_cunit_common.c b/test/common/odp_cunit_common.c
index 0f3b45b18..60746164c 100644
--- a/test/common/odp_cunit_common.c
+++ b/test/common/odp_cunit_common.c
@@ -32,7 +32,7 @@
#endif
/* Globals */
-static int allow_skip_result;
+static int running_in_ci;
static odph_thread_t thread_tbl[ODP_THREAD_COUNT_MAX];
static int threads_running;
static odp_instance_t instance;
@@ -720,7 +720,7 @@ int odp_cunit_parse_options(int argc, char *argv[])
control_thread = true;
if (env && !strcmp(env, "true")) {
- allow_skip_result = 1;
+ running_in_ci = 1;
ODPH_DBG("\nWARNING: test result can be used for code coverage only.\n"
"CI=true env variable is set!\n");
}
@@ -730,7 +730,12 @@ int odp_cunit_parse_options(int argc, char *argv[])
int odp_cunit_ret(int val)
{
- return allow_skip_result ? 0 : val;
+ return running_in_ci ? 0 : val;
+}
+
+int odp_cunit_ci(void)
+{
+ return running_in_ci;
}
int odp_cunit_ci_skip(const char *test_name)
diff --git a/test/common/odp_cunit_common.h b/test/common/odp_cunit_common.h
index 242747f0c..77822ee60 100644
--- a/test/common/odp_cunit_common.h
+++ b/test/common/odp_cunit_common.h
@@ -104,6 +104,7 @@ void odp_cunit_register_global_init(int (*func_init_ptr)(odp_instance_t *inst));
void odp_cunit_register_global_term(int (*func_term_ptr)(odp_instance_t inst));
int odp_cunit_ret(int val);
+int odp_cunit_ci(void);
int odp_cunit_print_inactive(void);
int odp_cunit_set_inactive(void);
diff --git a/test/performance/.gitignore b/test/performance/.gitignore
index b86699c91..087a163d8 100644
--- a/test/performance/.gitignore
+++ b/test/performance/.gitignore
@@ -5,6 +5,7 @@ odp_atomic_perf
odp_bench_buffer
odp_bench_misc
odp_bench_packet
+odp_bench_timer
odp_cpu_bench
odp_crc
odp_crypto
diff --git a/test/performance/Makefile.am b/test/performance/Makefile.am
index 9dc83fd22..67d57590a 100644
--- a/test/performance/Makefile.am
+++ b/test/performance/Makefile.am
@@ -6,6 +6,7 @@ EXECUTABLES = odp_atomic_perf \
odp_bench_buffer \
odp_bench_misc \
odp_bench_packet \
+ odp_bench_timer \
odp_crc \
odp_lock_perf \
odp_mem_perf \
@@ -60,6 +61,7 @@ odp_atomic_perf_SOURCES = odp_atomic_perf.c
odp_bench_buffer_SOURCES = odp_bench_buffer.c
odp_bench_misc_SOURCES = odp_bench_misc.c
odp_bench_packet_SOURCES = odp_bench_packet.c
+odp_bench_timer_SOURCES = odp_bench_timer.c
odp_cpu_bench_SOURCES = odp_cpu_bench.c
odp_crc_SOURCES = odp_crc.c
odp_crypto_SOURCES = odp_crypto.c
diff --git a/test/performance/odp_bench_timer.c b/test/performance/odp_bench_timer.c
new file mode 100644
index 000000000..918d19e5d
--- /dev/null
+++ b/test/performance/odp_bench_timer.c
@@ -0,0 +1,871 @@
+/* Copyright (c) 2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE /* Needed for sigaction */
+#endif
+
+#include <odp_api.h>
+#include <odp/helper/odph_api.h>
+
+#include <getopt.h>
+#include <inttypes.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+/* Number of API function calls per test case */
+#define REPEAT_COUNT 1000
+
+/* Default number of rounds per test case */
+#define ROUNDS 1000u
+
+/** User area size in bytes */
+#define UAREA_SIZE 8
+
+/** Timer duration in nsec */
+#define TIMER_NSEC 50000000
+
+#define BENCH_INFO(run, max, name) \
+ {#run, run, max, name}
+
+/* Run benchmark, returns >0 on success */
+typedef int (*bench_run_fn_t)(void);
+
+/* Benchmark data */
+typedef struct {
+ /* Default test name */
+ const char *name;
+
+ /* Test function to run */
+ bench_run_fn_t run;
+
+ /* Test specific limit for rounds (tuning for slow implementation) */
+ uint32_t max_rounds;
+
+ /* Override default test name */
+ const char *desc;
+
+} bench_info_t;
+
+typedef struct {
+ /* Command line options */
+ struct {
+ /* Clock source to be used */
+ int clk_src;
+
+ /* Measure time vs CPU cycles */
+ int time;
+
+ /* Benchmark index to run indefinitely */
+ int bench_idx;
+
+ /* Rounds per test case */
+ uint32_t rounds;
+
+ } opt;
+
+ odp_timer_pool_t timer_pool;
+ odp_timer_t timer;
+ odp_queue_t queue;
+ odp_pool_t pool;
+ odp_timeout_t timeout;
+ odp_event_t event;
+ uint64_t timer_nsec;
+ uint64_t tick;
+ uint64_t nsec;
+ double tick_hz;
+ int plain_queue;
+
+ /* Benchmark functions */
+ bench_info_t *bench;
+
+ /* Number of benchmark functions */
+ int num_bench;
+
+ /* Break worker loop if set to 1 */
+ odp_atomic_u32_t exit_thread;
+
+ /* Test case input / output data */
+ uint64_t a1[REPEAT_COUNT];
+ odp_event_t ev[REPEAT_COUNT];
+ odp_timeout_t tmo[REPEAT_COUNT];
+ odp_timer_t tim[REPEAT_COUNT];
+
+ /* Dummy result */
+ uint64_t dummy;
+
+ /* Benchmark run failed */
+ int bench_failed;
+
+ /* CPU mask as string */
+ char cpumask_str[ODP_CPUMASK_STR_SIZE];
+
+} gbl_args_t;
+
+static gbl_args_t *gbl_args;
+
+static void sig_handler(int signo ODP_UNUSED)
+{
+ if (gbl_args == NULL)
+ return;
+ odp_atomic_store_u32(&gbl_args->exit_thread, 1);
+}
+
+static int setup_sig_handler(void)
+{
+ struct sigaction action;
+
+ memset(&action, 0, sizeof(action));
+ action.sa_handler = sig_handler;
+
+ /* No additional signals blocked. By default, the signal which triggered
+ * the handler is blocked. */
+ if (sigemptyset(&action.sa_mask))
+ return -1;
+
+ if (sigaction(SIGINT, &action, NULL))
+ return -1;
+
+ return 0;
+}
+
+/* Run given benchmark indefinitely */
+static void run_indef(gbl_args_t *args, int idx)
+{
+ const char *desc;
+ const bench_info_t *bench = &args->bench[idx];
+
+ desc = bench->desc != NULL ? bench->desc : bench->name;
+
+ printf("Running odp_%s test indefinitely\n", desc);
+
+ while (!odp_atomic_load_u32(&gbl_args->exit_thread)) {
+ int ret;
+
+ ret = bench->run();
+
+ if (!ret)
+ ODPH_ABORT("Benchmark %s failed\n", desc);
+ }
+}
+
+static int run_benchmarks(void *arg)
+{
+ int i, j;
+ uint64_t c1, c2;
+ odp_time_t t1, t2;
+ gbl_args_t *args = arg;
+ const int meas_time = args->opt.time;
+
+ printf("\nAverage %s per function call\n", meas_time ? "time (nsec)" : "CPU cycles");
+ printf("-------------------------------------------------\n");
+
+ /* Run each test twice. Results from the first warm-up round are ignored. */
+ for (i = 0; i < 2; i++) {
+ uint64_t total = 0;
+ uint32_t round = 1;
+
+ for (j = 0; j < gbl_args->num_bench; round++) {
+ int ret;
+ const char *desc;
+ const bench_info_t *bench = &args->bench[j];
+ uint32_t max_rounds = args->opt.rounds;
+
+ if (bench->max_rounds && max_rounds > bench->max_rounds)
+ max_rounds = bench->max_rounds;
+
+ /* Run selected test indefinitely */
+ if (args->opt.bench_idx) {
+ if ((j + 1) != args->opt.bench_idx) {
+ j++;
+ continue;
+ }
+
+ run_indef(args, j);
+ return 0;
+ }
+
+ desc = bench->desc != NULL ? bench->desc : bench->name;
+
+ if (meas_time)
+ t1 = odp_time_local();
+ else
+ c1 = odp_cpu_cycles();
+
+ ret = bench->run();
+
+ if (meas_time)
+ t2 = odp_time_local();
+ else
+ c2 = odp_cpu_cycles();
+
+ if (!ret) {
+ ODPH_ERR("Benchmark odp_%s failed\n", desc);
+ args->bench_failed = -1;
+ return -1;
+ }
+
+ if (meas_time)
+ total += odp_time_diff_ns(t2, t1);
+ else
+ total += odp_cpu_cycles_diff(c2, c1);
+
+ for (i = 0; i < REPEAT_COUNT; i++)
+ args->dummy += args->a1[i];
+
+ if (round >= max_rounds) {
+ double result;
+
+ /* Each benchmark runs internally REPEAT_COUNT times. */
+ result = ((double)total) / (max_rounds * REPEAT_COUNT);
+
+ /* No print from warm-up round */
+ if (i > 0)
+ printf("[%02d] odp_%-26s: %12.2f\n", j + 1, desc, result);
+
+ j++;
+ total = 0;
+ round = 1;
+ }
+ }
+ }
+
+ /* Print dummy result to prevent compiler to optimize it away*/
+ printf("\n(dummy result: 0x%" PRIx64 ")\n\n", args->dummy);
+
+ return 0;
+}
+
+static int timer_current_tick(void)
+{
+ int i;
+ odp_timer_pool_t timer_pool = gbl_args->timer_pool;
+ uint64_t *a1 = gbl_args->a1;
+
+ for (i = 0; i < REPEAT_COUNT; i++)
+ a1[i] = odp_timer_current_tick(timer_pool);
+
+ return i;
+}
+
+static int timer_tick_to_ns(void)
+{
+ int i;
+ odp_timer_pool_t timer_pool = gbl_args->timer_pool;
+ uint64_t *a1 = gbl_args->a1;
+ uint64_t tick = gbl_args->tick;
+
+ for (i = 0; i < REPEAT_COUNT; i++)
+ a1[i] = odp_timer_tick_to_ns(timer_pool, tick);
+
+ return i;
+}
+
+static int timer_ns_to_tick(void)
+{
+ int i;
+ odp_timer_pool_t timer_pool = gbl_args->timer_pool;
+ uint64_t *a1 = gbl_args->a1;
+ uint64_t nsec = gbl_args->nsec;
+
+ for (i = 0; i < REPEAT_COUNT; i++)
+ a1[i] = odp_timer_ns_to_tick(timer_pool, nsec);
+
+ return i;
+}
+
+static int timeout_to_event(void)
+{
+ int i;
+ odp_event_t *ev = gbl_args->ev;
+ odp_timeout_t timeout = gbl_args->timeout;
+
+ for (i = 0; i < REPEAT_COUNT; i++)
+ ev[i] = odp_timeout_to_event(timeout);
+
+ gbl_args->dummy += odp_event_to_u64(ev[0]);
+
+ return i;
+}
+
+static int timeout_from_event(void)
+{
+ int i;
+ odp_event_t ev = gbl_args->event;
+ odp_timeout_t *tmo = gbl_args->tmo;
+
+ for (i = 0; i < REPEAT_COUNT; i++)
+ tmo[i] = odp_timeout_from_event(ev);
+
+ gbl_args->dummy += odp_timeout_to_u64(tmo[0]);
+
+ return i;
+}
+
+static int timeout_fresh(void)
+{
+ int i;
+ odp_timeout_t timeout = gbl_args->timeout;
+ uint64_t *a1 = gbl_args->a1;
+
+ for (i = 0; i < REPEAT_COUNT; i++)
+ a1[i] = odp_timeout_fresh(timeout);
+
+ return i;
+}
+
+static int timeout_timer(void)
+{
+ int i;
+ odp_timeout_t timeout = gbl_args->timeout;
+ odp_timer_t *tim = gbl_args->tim;
+
+ for (i = 0; i < REPEAT_COUNT; i++)
+ tim[i] = odp_timeout_timer(timeout);
+
+ gbl_args->dummy += odp_timer_to_u64(tim[0]);
+
+ return i;
+}
+
+static int timeout_tick(void)
+{
+ int i;
+ odp_timeout_t timeout = gbl_args->timeout;
+ uint64_t *a1 = gbl_args->a1;
+
+ for (i = 0; i < REPEAT_COUNT; i++)
+ a1[i] = odp_timeout_tick(timeout);
+
+ return i;
+}
+
+static int timeout_user_ptr(void)
+{
+ int i;
+ odp_timeout_t timeout = gbl_args->timeout;
+ uint64_t *a1 = gbl_args->a1;
+
+ for (i = 0; i < REPEAT_COUNT; i++)
+ a1[i] = (uintptr_t)odp_timeout_user_ptr(timeout);
+
+ return i;
+}
+
+static int timeout_user_area(void)
+{
+ int i;
+ odp_timeout_t timeout = gbl_args->timeout;
+ uint64_t *a1 = gbl_args->a1;
+
+ for (i = 0; i < REPEAT_COUNT; i++)
+ a1[i] = (uintptr_t)odp_timeout_user_area(timeout);
+
+ return i;
+}
+
+static int timeout_to_u64(void)
+{
+ int i;
+ odp_timeout_t timeout = gbl_args->timeout;
+ uint64_t *a1 = gbl_args->a1;
+
+ for (i = 0; i < REPEAT_COUNT; i++)
+ a1[i] = odp_timeout_to_u64(timeout);
+
+ return i;
+}
+
+static int timer_to_u64(void)
+{
+ int i;
+ odp_timer_t timer = gbl_args->timer;
+ uint64_t *a1 = gbl_args->a1;
+
+ for (i = 0; i < REPEAT_COUNT; i++)
+ a1[i] = odp_timer_to_u64(timer);
+
+ return i;
+}
+
+static int timer_pool_to_u64(void)
+{
+ int i;
+ odp_timer_pool_t tp = gbl_args->timer_pool;
+ uint64_t *a1 = gbl_args->a1;
+
+ for (i = 0; i < REPEAT_COUNT; i++)
+ a1[i] = odp_timer_pool_to_u64(tp);
+
+ return i;
+}
+
+bench_info_t test_suite[] = {
+ BENCH_INFO(timer_current_tick, 0, NULL),
+ BENCH_INFO(timer_tick_to_ns, 0, NULL),
+ BENCH_INFO(timer_ns_to_tick, 0, NULL),
+ BENCH_INFO(timeout_to_event, 0, NULL),
+ BENCH_INFO(timeout_from_event, 0, NULL),
+ BENCH_INFO(timeout_fresh, 0, NULL),
+ BENCH_INFO(timeout_timer, 0, NULL),
+ BENCH_INFO(timeout_tick, 0, NULL),
+ BENCH_INFO(timeout_user_ptr, 0, NULL),
+ BENCH_INFO(timeout_user_area, 0, NULL),
+ BENCH_INFO(timeout_to_u64, 0, NULL),
+ BENCH_INFO(timer_to_u64, 0, NULL),
+ BENCH_INFO(timer_pool_to_u64, 0, NULL),
+};
+
+/* Print usage information */
+static void usage(void)
+{
+ printf("\n"
+ "ODP timer API micro benchmarks\n"
+ "\n"
+ "Options:\n"
+ " -s, --clk_src Clock source select (default 0):\n"
+ " 0: ODP_CLOCK_DEFAULT\n"
+ " 1: ODP_CLOCK_SRC_1, ...\n"
+ " -t, --time <opt> Time measurement. 0: measure CPU cycles (default), 1: measure time\n"
+ " -i, --index <idx> Benchmark index to run indefinitely.\n"
+ " -r, --rounds <num> Run each test case 'num' times (default %u).\n"
+ " -h, --help Display help and exit.\n\n"
+ "\n", ROUNDS);
+}
+
+/* Parse command line arguments */
+static int parse_args(int argc, char *argv[])
+{
+ int opt;
+ int long_index;
+ static const struct option longopts[] = {
+ {"clk_src", required_argument, NULL, 's'},
+ {"time", required_argument, NULL, 't'},
+ {"index", required_argument, NULL, 'i'},
+ {"rounds", required_argument, NULL, 'r'},
+ {"help", no_argument, NULL, 'h'},
+ {NULL, 0, NULL, 0}
+ };
+
+ static const char *shortopts = "s:t:i:r:h";
+
+ gbl_args->opt.clk_src = ODP_CLOCK_DEFAULT;
+ gbl_args->opt.time = 0; /* Measure CPU cycles */
+ gbl_args->opt.bench_idx = 0; /* Run all benchmarks */
+ gbl_args->opt.rounds = ROUNDS;
+
+ while (1) {
+ opt = getopt_long(argc, argv, shortopts, longopts, &long_index);
+
+ if (opt == -1)
+ break; /* No more options */
+
+ switch (opt) {
+ case 's':
+ gbl_args->opt.clk_src = atoi(optarg);
+ break;
+ case 't':
+ gbl_args->opt.time = atoi(optarg);
+ break;
+ case 'i':
+ gbl_args->opt.bench_idx = atoi(optarg);
+ break;
+ case 'r':
+ gbl_args->opt.rounds = atoi(optarg);
+ break;
+ case 'h':
+ usage();
+ return 1;
+ default:
+ ODPH_ERR("Bad option. Use -h for help.\n");
+ return -1;
+ }
+ }
+
+ if (gbl_args->opt.rounds < 1) {
+ ODPH_ERR("Invalid test cycle repeat count: %u\n", gbl_args->opt.rounds);
+ return -1;
+ }
+
+ if (gbl_args->opt.bench_idx < 0 || gbl_args->opt.bench_idx > gbl_args->num_bench) {
+ ODPH_ERR("Bad bench index %i\n", gbl_args->opt.bench_idx);
+ return -1;
+ }
+
+ optind = 1; /* Reset 'extern optind' from the getopt lib */
+
+ return 0;
+}
+
+/* Print system and application info */
+static void print_info(void)
+{
+ odp_sys_info_print();
+
+ printf("\n"
+ "odp_bench_timer options\n"
+ "-----------------------\n");
+
+ printf("CPU mask: %s\n", gbl_args->cpumask_str);
+ printf("Clock source: %i\n", gbl_args->opt.clk_src);
+ printf("Measurement unit: %s\n", gbl_args->opt.time ? "nsec" : "CPU cycles");
+ printf("Test rounds: %u\n", gbl_args->opt.rounds);
+ printf("Timer duration: %" PRIu64 " nsec\n", gbl_args->timer_nsec);
+ printf("Timer tick freq: %.2f Hz\n", gbl_args->tick_hz);
+ printf("\n");
+}
+
+static int create_timer(void)
+{
+ odp_pool_capability_t pool_capa;
+ odp_timer_capability_t timer_capa;
+ odp_timer_clk_src_t clk_src;
+ odp_timer_pool_param_t tp_param;
+ odp_timer_pool_t tp;
+ odp_pool_t pool;
+ odp_pool_param_t pool_param;
+ odp_timeout_t tmo;
+ odp_queue_param_t queue_param;
+ odp_queue_t queue;
+ odp_timer_t timer;
+ uint64_t t1, t2, diff, tick1, tick2;
+
+ if (odp_pool_capability(&pool_capa)) {
+ ODPH_ERR("Pool capa failed\n");
+ return -1;
+ }
+
+ clk_src = gbl_args->opt.clk_src;
+ if (odp_timer_capability(clk_src, &timer_capa)) {
+ ODPH_ERR("Timer capa failed\n");
+ return -1;
+ }
+
+ odp_timer_pool_param_init(&tp_param);
+ tp_param.clk_src = clk_src;
+ tp_param.res_ns = timer_capa.max_res.res_ns;
+ tp_param.min_tmo = timer_capa.max_res.min_tmo;
+ tp_param.max_tmo = timer_capa.max_res.max_tmo;
+ tp_param.num_timers = 10;
+
+ tp = odp_timer_pool_create("bench_timer", &tp_param);
+
+ if (tp == ODP_TIMER_POOL_INVALID) {
+ ODPH_ERR("Timer pool create failed\n");
+ return -1;
+ }
+
+ gbl_args->timer_pool = tp;
+
+ odp_timer_pool_start();
+
+ gbl_args->timer_nsec = TIMER_NSEC;
+ if (TIMER_NSEC < tp_param.min_tmo)
+ gbl_args->timer_nsec = tp_param.min_tmo;
+ else if (TIMER_NSEC > tp_param.max_tmo)
+ gbl_args->timer_nsec = tp_param.max_tmo;
+
+ odp_pool_param_init(&pool_param);
+ pool_param.type = ODP_POOL_TIMEOUT;
+ pool_param.tmo.num = 10;
+ pool_param.tmo.uarea_size = UAREA_SIZE;
+ if (UAREA_SIZE > pool_capa.tmo.max_uarea_size)
+ pool_param.tmo.uarea_size = pool_capa.tmo.max_uarea_size;
+
+ pool = odp_pool_create("bench_timer", &pool_param);
+
+ if (pool == ODP_POOL_INVALID) {
+ ODPH_ERR("Timeout pool create failed\n");
+ return -1;
+ }
+
+ gbl_args->pool = pool;
+
+ tmo = odp_timeout_alloc(pool);
+
+ if (tmo == ODP_TIMEOUT_INVALID) {
+ ODPH_ERR("Timeout alloc failed\n");
+ return -1;
+ }
+
+ gbl_args->timeout = tmo;
+ gbl_args->tick = odp_timer_current_tick(tp);
+ gbl_args->nsec = odp_timer_tick_to_ns(tp, gbl_args->tick);
+
+ /* Measure timer tick frequency for test information */
+ t1 = odp_time_global_strict_ns();
+ tick1 = odp_timer_current_tick(tp);
+
+ odp_time_wait_ns(200 * ODP_TIME_MSEC_IN_NS);
+
+ tick2 = odp_timer_current_tick(tp);
+ t2 = odp_time_global_strict_ns();
+ diff = t2 - t1;
+
+ if (diff)
+ gbl_args->tick_hz = (tick2 - tick1) / ((double)diff / ODP_TIME_SEC_IN_NS);
+
+ odp_queue_param_init(&queue_param);
+ queue_param.type = ODP_QUEUE_TYPE_SCHED;
+ queue_param.sched.prio = odp_schedule_default_prio();
+ queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC;
+ queue_param.sched.group = ODP_SCHED_GROUP_ALL;
+
+ if (timer_capa.queue_type_sched == 0) {
+ queue_param.type = ODP_QUEUE_TYPE_PLAIN;
+ gbl_args->plain_queue = 1;
+ }
+
+ queue = odp_queue_create("bench_timer", &queue_param);
+ if (queue == ODP_QUEUE_INVALID) {
+ ODPH_ERR("Queue create failed\n");
+ return -1;
+ }
+
+ gbl_args->queue = queue;
+
+ timer = odp_timer_alloc(tp, queue, (void *)(uintptr_t)0xdeadbeef);
+ if (timer == ODP_TIMER_INVALID) {
+ ODPH_ERR("Timer alloc failed\n");
+ return -1;
+ }
+
+ gbl_args->timer = timer;
+
+ return 0;
+}
+
+static int wait_timer(void)
+{
+ odp_timer_start_t start_param;
+ odp_timer_t timer = gbl_args->timer;
+ odp_timer_pool_t tp = gbl_args->timer_pool;
+ uint64_t wait_nsec = 2 * gbl_args->timer_nsec;
+ uint64_t sched_wait = odp_schedule_wait_time(wait_nsec);
+ odp_event_t ev;
+ uint64_t start;
+
+ start_param.tick_type = ODP_TIMER_TICK_REL;
+ start_param.tick = odp_timer_ns_to_tick(tp, gbl_args->timer_nsec);
+ start_param.tmo_ev = odp_timeout_to_event(gbl_args->timeout);
+
+ if (odp_timer_start(timer, &start_param) != ODP_TIMER_SUCCESS) {
+ ODPH_ERR("Timer start failed\n");
+ return -1;
+ }
+
+ gbl_args->timeout = ODP_TIMEOUT_INVALID;
+ gbl_args->event = ODP_EVENT_INVALID;
+
+ /* Wait for timeout */
+ if (gbl_args->plain_queue) {
+ start = odp_time_global_ns();
+ while (1) {
+ ev = odp_queue_deq(gbl_args->queue);
+
+ if (ev != ODP_EVENT_INVALID)
+ break;
+
+ if ((odp_time_global_ns() - start) > wait_nsec) {
+ ODPH_ERR("Timeout event missing\n");
+ return -1;
+ }
+ }
+
+ gbl_args->event = ev;
+ } else {
+ ev = odp_schedule(NULL, sched_wait);
+
+ if (ev == ODP_EVENT_INVALID) {
+ ODPH_ERR("Timeout event missing\n");
+ return -1;
+ }
+
+ gbl_args->event = ev;
+
+ /* Free schedule context */
+ if (odp_schedule(NULL, ODP_SCHED_NO_WAIT) != ODP_EVENT_INVALID) {
+ ODPH_ERR("Extra timeout event\n");
+ return -1;
+ }
+ }
+
+ if (odp_event_type(gbl_args->event) != ODP_EVENT_TIMEOUT) {
+ ODPH_ERR("Bad event type\n");
+ return -1;
+ }
+
+ gbl_args->timeout = odp_timeout_from_event(gbl_args->event);
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ odph_helper_options_t helper_options;
+ odph_thread_t worker_thread;
+ odph_thread_common_param_t thr_common;
+ odph_thread_param_t thr_param;
+ int cpu, i;
+ odp_shm_t shm;
+ odp_cpumask_t cpumask, default_mask;
+ odp_instance_t instance;
+ odp_init_t init_param;
+ int ret = 0;
+
+ /* Let helper collect its own arguments (e.g. --odph_proc) */
+ argc = odph_parse_options(argc, argv);
+ if (odph_options(&helper_options)) {
+ ODPH_ERR("Reading ODP helper options failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ odp_init_param_init(&init_param);
+ init_param.mem_model = helper_options.mem_model;
+
+ /* Init ODP before calling anything else */
+ if (odp_init_global(&instance, &init_param, NULL)) {
+ ODPH_ERR("Global init failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* Init this thread */
+ if (odp_init_local(instance, ODP_THREAD_CONTROL)) {
+ ODPH_ERR("Local init failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (setup_sig_handler()) {
+ ODPH_ERR("Signal handler setup failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ odp_schedule_config(NULL);
+
+ /* Reserve memory for args from shared mem */
+ shm = odp_shm_reserve("shm_args", sizeof(gbl_args_t), ODP_CACHE_LINE_SIZE, 0);
+ if (shm == ODP_SHM_INVALID) {
+ ODPH_ERR("Shared mem reserve failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ gbl_args = odp_shm_addr(shm);
+ if (gbl_args == NULL) {
+ ODPH_ERR("Shared mem alloc failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ memset(gbl_args, 0, sizeof(gbl_args_t));
+ odp_atomic_init_u32(&gbl_args->exit_thread, 0);
+ gbl_args->timer_pool = ODP_TIMER_POOL_INVALID;
+ gbl_args->timer = ODP_TIMER_INVALID;
+ gbl_args->queue = ODP_QUEUE_INVALID;
+ gbl_args->pool = ODP_POOL_INVALID;
+ gbl_args->timeout = ODP_TIMEOUT_INVALID;
+
+ gbl_args->bench = test_suite;
+ gbl_args->num_bench = sizeof(test_suite) / sizeof(test_suite[0]);
+
+ for (i = 0; i < REPEAT_COUNT; i++) {
+ gbl_args->a1[i] = i;
+ gbl_args->ev[i] = ODP_EVENT_INVALID;
+ gbl_args->tmo[i] = ODP_TIMEOUT_INVALID;
+ gbl_args->tim[i] = ODP_TIMER_INVALID;
+ }
+
+ /* Parse and store the application arguments */
+ ret = parse_args(argc, argv);
+ if (ret)
+ goto exit;
+
+ /* Get default worker cpumask */
+ if (odp_cpumask_default_worker(&default_mask, 1) != 1) {
+ ODPH_ERR("Unable to allocate worker thread\n");
+ ret = -1;
+ goto exit;
+ }
+
+ (void)odp_cpumask_to_str(&default_mask, gbl_args->cpumask_str,
+ sizeof(gbl_args->cpumask_str));
+
+ /* Create timer and other resources */
+ ret = create_timer();
+ if (ret)
+ goto exit;
+
+ print_info();
+
+ /* Start one timer and wait for the timeout event. Timer expiration fills in
+ * timeout event metadata. */
+ ret = wait_timer();
+ if (ret)
+ goto exit;
+
+ memset(&worker_thread, 0, sizeof(odph_thread_t));
+
+ /* Create worker thread */
+ cpu = odp_cpumask_first(&default_mask);
+
+ odp_cpumask_zero(&cpumask);
+ odp_cpumask_set(&cpumask, cpu);
+
+ odph_thread_common_param_init(&thr_common);
+ thr_common.instance = instance;
+ thr_common.cpumask = &cpumask;
+ thr_common.share_param = 1;
+
+ odph_thread_param_init(&thr_param);
+ thr_param.start = run_benchmarks;
+ thr_param.arg = gbl_args;
+ thr_param.thr_type = ODP_THREAD_WORKER;
+
+ odph_thread_create(&worker_thread, &thr_common, &thr_param, 1);
+
+ odph_thread_join(&worker_thread, 1);
+
+ ret = gbl_args->bench_failed;
+
+exit:
+ if (gbl_args->timeout != ODP_TIMEOUT_INVALID)
+ odp_timeout_free(gbl_args->timeout);
+
+ if (gbl_args->pool != ODP_POOL_INVALID)
+ odp_pool_destroy(gbl_args->pool);
+
+ if (gbl_args->timer != ODP_TIMER_INVALID)
+ odp_timer_free(gbl_args->timer);
+
+ if (gbl_args->timer_pool != ODP_TIMER_POOL_INVALID)
+ odp_timer_pool_destroy(gbl_args->timer_pool);
+
+ if (gbl_args->queue != ODP_QUEUE_INVALID) {
+ if (odp_queue_destroy(gbl_args->queue)) {
+ ODPH_ERR("Queue destroy failed\n");
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ if (odp_shm_free(shm)) {
+ ODPH_ERR("Shared mem free failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (odp_term_local()) {
+ ODPH_ERR("Local term failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (odp_term_global(instance)) {
+ ODPH_ERR("Global term failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (ret < 0)
+ return EXIT_FAILURE;
+
+ return EXIT_SUCCESS;
+}
diff --git a/test/performance/odp_dma_perf.c b/test/performance/odp_dma_perf.c
index 62899f913..be23f27ca 100644
--- a/test/performance/odp_dma_perf.c
+++ b/test/performance/odp_dma_perf.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2021-2022, Nokia
+/* Copyright (c) 2021-2023, Nokia
*
* All rights reserved.
*
@@ -9,266 +9,515 @@
#define _GNU_SOURCE
#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <inttypes.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <stdint.h>
+#include <unistd.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 DEFAULT_WAIT_NS ODP_TIME_SEC_IN_NS
-#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 PROG_NAME "odp_dma_perf"
+
+enum {
+ SYNC = 0U,
+ ASYNC
+};
+
+enum {
+ PACKET = 0U,
+ MEMORY
+};
+
+enum {
+ POLL = 0U,
+ EVENT
+};
+
+enum {
+ SINGLE = 0U,
+ MANY
+};
+
+#define DEF_TRS_TYPE SYNC
+#define DEF_SEG_CNT 1U
+#define DEF_LEN 1024U
+#define DEF_SEG_TYPE PACKET
+#define DEF_MODE POLL
+#define DEF_INFLIGHT 1U
+#define DEF_TIME 10U
+#define DEF_WORKERS 1U
+#define DEF_POLICY SINGLE
+
+#define MAX_SEGS 1024U
+#define MAX_WORKERS 24
+
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define GIGAS 1000000000
#define MEGAS 1000000
#define KILOS 1000
-#define RETRIES 1000U
-
-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;
- uint64_t wait_ns;
-
- struct {
- int num_modes;
- uint32_t compl_mask;
- int modes[MAX_NUM_IN_SEGS];
- } compl_modes;
-
+typedef enum {
+ PRS_OK,
+ PRS_NOK,
+ PRS_TERM,
+ PRS_NOT_SUP
+} parse_result_t;
+
+typedef struct {
+ uint64_t completed;
+ uint64_t start_errs;
+ uint64_t poll_errs;
+ uint64_t scheduler_timeouts;
+ uint64_t transfer_errs;
+ uint64_t tot_tm;
+ uint64_t trs_tm;
+ uint64_t max_trs_tm;
+ uint64_t min_trs_tm;
+ uint64_t start_cc;
+ uint64_t max_start_cc;
+ uint64_t min_start_cc;
+ uint64_t wait_cc;
+ uint64_t max_wait_cc;
+ uint64_t min_wait_cc;
+ uint64_t trs_cc;
+ uint64_t max_trs_cc;
+ uint64_t min_trs_cc;
+ uint64_t start_cnt;
+ uint64_t wait_cnt;
+ uint64_t trs_poll_cnt;
+ uint64_t trs_cnt;
+} stats_t;
+
+typedef struct {
+ odp_dma_transfer_param_t trs_param;
+ odp_dma_compl_param_t compl_param;
+ odp_ticketlock_t lock;
+ uint64_t trs_start_tm;
+ uint64_t trs_start_cc;
+ uint64_t trs_poll_cnt;
+ odp_bool_t is_running;
+} trs_info_t;
+
+typedef struct ODP_ALIGNED_CACHE {
struct {
+ trs_info_t infos[MAX_SEGS];
+ odp_dma_seg_t src_seg[MAX_SEGS];
+ odp_dma_seg_t dst_seg[MAX_SEGS];
+ odp_dma_t handle;
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;
+ uint32_t num_in_segs;
+ uint32_t num_out_segs;
+ uint32_t src_seg_len;
+ uint32_t dst_seg_len;
+ uint32_t num_inflight;
+ uint8_t trs_type;
+ uint8_t compl_mode;
+ } dma;
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)
+ odp_packet_t src_pkt[MAX_SEGS];
+ odp_packet_t dst_pkt[MAX_SEGS];
+ odp_pool_t src_pool;
+ odp_pool_t dst_pool;
+ odp_shm_t src_shm;
+ odp_shm_t dst_shm;
+ void *src;
+ void *dst;
+ } seg;
+
+ odp_schedule_group_t grp;
+} sd_t;
+
+typedef struct prog_config_s prog_config_t;
+
+typedef struct ODP_ALIGNED_CACHE {
+ stats_t stats;
+ prog_config_t *prog_config;
+ sd_t *sd;
+} thread_config_t;
+
+typedef struct {
+ /* Configure DMA session specific resources. */
+ odp_bool_t (*session_cfg_fn)(sd_t *sd);
+ /* Setup transfer elements (memory/packet segments). */
+ odp_bool_t (*setup_fn)(sd_t *sd);
+ /* Configure DMA transfers (segment addresses etc.). */
+ void (*trs_fn)(sd_t *sd);
+ /* Configure transfer completion resources (transfer IDs, events etc.). */
+ odp_bool_t (*compl_fn)(sd_t *sd);
+ /* Initiate required initial transfers. */
+ odp_bool_t (*bootstrap_fn)(sd_t *sd);
+ /* Wait and handle finished transfer. */
+ void (*wait_fn)(sd_t *sd, stats_t *stats);
+ /* Handle all unfinished transfers after main test has been stopped. */
+ void (*drain_fn)(void);
+ /* Free any resources that might have been allocated during setup phase. */
+ void (*free_fn)(const sd_t *sd);
+} test_api_t;
+
+typedef struct prog_config_s {
+ odph_thread_t threads[MAX_WORKERS];
+ thread_config_t thread_config[MAX_WORKERS];
+ sd_t sds[MAX_WORKERS];
+ test_api_t api;
+ odp_atomic_u32_t is_running;
+ odp_instance_t odp_instance;
+ odp_barrier_t init_barrier;
+ odp_barrier_t term_barrier;
+ odp_dma_compl_mode_t compl_mode_mask;
+ odp_pool_t src_pool;
+ odp_pool_t dst_pool;
+ uint32_t num_in_segs;
+ uint32_t num_out_segs;
+ uint32_t src_seg_len;
+ uint32_t dst_seg_len;
+ uint32_t num_inflight;
+ uint32_t time_sec;
+ uint32_t num_sessions;
+ int num_workers;
+ uint8_t trs_type;
+ uint8_t seg_type;
+ uint8_t compl_mode;
+ uint8_t policy;
+} prog_config_t;
+
+static prog_config_t *prog_conf;
+
+static const int mode_map[] = { ODP_DMA_COMPL_POLL, ODP_DMA_COMPL_EVENT };
+
+static void terminate(int signal ODP_UNUSED)
{
- memset(config, 0, sizeof(*config));
- config->num_in_seg = 1;
- config->seg_size = DEFAULT_SEG_SIZE;
- config->num_rounds = ROUNDS;
- config->wait_ns = DEFAULT_WAIT_NS;
- config->compl_modes.compl_mask = ODP_DMA_COMPL_SYNC;
+ odp_atomic_store_u32(&prog_conf->is_running, 0U);
}
-static void parse_completion_modes(test_config_t *config, const char *optarg)
+static void init_config(prog_config_t *config)
{
- char *tmp_str = strdup(optarg);
- char *tmp;
- int mode;
- uint32_t i = 0U;
-
- config->compl_modes.num_modes = 0;
-
- if (tmp_str == NULL)
- return;
+ sd_t *sd;
+ trs_info_t *info;
+ stats_t *stats;
- tmp = strtok(tmp_str, COMPL_DELIMITER);
+ memset(config, 0, sizeof(*config));
+ config->compl_mode_mask |= ODP_DMA_COMPL_SYNC;
+ config->src_pool = ODP_POOL_INVALID;
+ config->dst_pool = ODP_POOL_INVALID;
+ config->num_in_segs = DEF_SEG_CNT;
+ config->num_out_segs = DEF_SEG_CNT;
+ config->src_seg_len = DEF_LEN;
+ config->num_inflight = DEF_INFLIGHT;
+ config->time_sec = DEF_TIME;
+ config->num_workers = DEF_WORKERS;
+ config->trs_type = DEF_TRS_TYPE;
+ config->seg_type = DEF_SEG_TYPE;
+ config->compl_mode = DEF_MODE;
+ config->policy = DEF_POLICY;
+
+ for (uint32_t i = 0U; i < MAX_WORKERS; ++i) {
+ sd = &config->sds[i];
+ stats = &config->thread_config[i].stats;
+ memset(sd, 0, sizeof(*sd));
+
+ for (uint32_t i = 0U; i < MAX_SEGS; ++i) {
+ info = &sd->dma.infos[i];
+ info->compl_param.transfer_id = ODP_DMA_TRANSFER_ID_INVALID;
+ info->compl_param.event = ODP_EVENT_INVALID;
+ info->compl_param.queue = ODP_QUEUE_INVALID;
+ odp_ticketlock_init(&info->lock);
+ sd->seg.src_pkt[i] = ODP_PACKET_INVALID;
+ sd->seg.dst_pkt[i] = ODP_PACKET_INVALID;
+ }
- 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);
+ sd->dma.handle = ODP_DMA_INVALID;
+ sd->dma.pool = ODP_POOL_INVALID;
+ sd->dma.compl_q = ODP_QUEUE_INVALID;
+ sd->seg.src_shm = ODP_SHM_INVALID;
+ sd->seg.dst_shm = ODP_SHM_INVALID;
+ sd->grp = ODP_SCHED_GROUP_INVALID;
+ stats->min_trs_tm = UINT64_MAX;
+ stats->min_start_cc = UINT64_MAX;
+ stats->min_wait_cc = UINT64_MAX;
+ stats->min_trs_cc = UINT64_MAX;
}
-
- 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"
+ "DMA performance test. Load DMA subsystem from several workers.\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"
+ " " PROG_NAME "\n"
+ " " PROG_NAME " -s 10240\n"
+ " " PROG_NAME " -t 0 -i 1 -o 1 -s 51200 -S 1 -f 64 -T 10\n"
+ " " PROG_NAME " -t 1 -i 10 -o 10 -s 4096 -S 0 -m 1 -f 10 -c 4 -p 1\n"
"\n"
- "Usage: odp_dma_perf [options]\n"
+ "Usage: " PROG_NAME " [options]\n"
"\n"
- " -t, --trs_type Transfer type for test data. Synchronous by default.\n"
+ " -t, --trs_type Transfer type for test data. %u 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"
+ " -i, --num_in_seg Number of input segments to transfer. 0 means the\n"
+ " maximum count supported by the implementation. %u by\n"
+ " default.\n"
+ " -o, --num_out_seg Number of output segments to transfer to. 0 means\n"
+ " the maximum count supported by the implementation.\n"
+ " %u by default.\n"
+ " -s, --in_seg_len Input segment length in bytes. 0 length means\n"
+ " maximum segment length supported by implementation.\n"
+ " The actual maximum might be limited by what type of\n"
+ " data is transferred (packet/memory).\n"
+ " %u by default.\n"
+ " -S, --in_seg_type Input segment data type. %u 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"
+ " -m, --compl_mode Completion mode for transfers. %u by default.\n"
" Modes:\n"
" 0: poll\n"
" 1: event\n"
- " -r, --num_rounds Number of times to run the test scenario. %d by\n"
+ " -f, --max_in_flight Max transfers in-flight per session. 0 means the\n"
+ " maximum supported by tester/implementation. %u by\n"
+ " default.\n"
+ " -T, --time_sec Time in seconds to run. 0 means infinite. %u by\n"
" default.\n"
- " -w, --wait_nsec Number of nanoseconds to wait for completion events.\n"
- " 1 second (1000000000) by default.\n"
+ " -c, --worker_count Amount of workers. %u by default.\n"
+ " -p, --policy DMA session policy. %u by default.\n"
+ " Policies:\n"
+ " 0: One session shared by workers\n"
+ " 1: One session per worker\n"
" -h, --help This help.\n"
- "\n",
- MAX_NUM_IN_SEGS, ROUNDS);
+ "\n", DEF_TRS_TYPE, DEF_SEG_CNT, DEF_SEG_CNT, DEF_LEN, DEF_SEG_TYPE, DEF_MODE,
+ DEF_INFLIGHT, DEF_TIME, DEF_WORKERS, DEF_POLICY);
}
-static int check_completion_modes(test_config_t *config)
+static parse_result_t check_options(prog_config_t *config)
{
- if (config->trs_type == TRS_TYPE_SYNC)
- return 0;
+ int max_workers;
+ odp_dma_capability_t dma_capa;
+ uint32_t num_sessions, max_seg_len, max_trs, max_in, max_out, max_segs;
+ odp_schedule_capability_t sched_capa;
+ odp_pool_capability_t pool_capa;
+ odp_shm_capability_t shm_capa;
+ uint64_t shm_size = 0U;
+
+ if (config->trs_type != SYNC && config->trs_type != ASYNC) {
+ ODPH_ERR("Invalid transfer type: %u\n", config->trs_type);
+ return PRS_NOK;
+ }
+
+ if (config->seg_type != PACKET && config->seg_type != MEMORY) {
+ ODPH_ERR("Invalid segment type: %u\n", config->seg_type);
+ return PRS_NOK;
+ }
+
+ max_workers = MIN(odp_thread_count_max() - 1, MAX_WORKERS);
- if (config->compl_modes.num_modes > MAX_NUM_IN_SEGS)
- return -1;
+ if (config->num_workers <= 0 || config->num_workers > max_workers) {
+ ODPH_ERR("Invalid thread count: %d (min: 1, max: %d)\n", config->num_workers,
+ max_workers);
+ return PRS_NOK;
+ }
- if (config->trs_grn == GRN_IND &&
- config->num_in_seg != config->compl_modes.num_modes)
- return -1;
+ if (config->policy != SINGLE && config->policy != MANY) {
+ ODPH_ERR("Invalid DMA session policy: %u\n", config->policy);
+ return PRS_NOK;
+ }
- if (config->trs_grn == GRN_ALL &&
- config->compl_modes.num_modes != 1)
- return -1;
+ if (odp_dma_capability(&dma_capa) < 0) {
+ ODPH_ERR("Error querying DMA capabilities\n");
+ return PRS_NOK;
+ }
- 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;
+ num_sessions = config->policy == SINGLE ? 1 : config->num_workers;
- config->compl_modes.modes[i] = compl_mode_map[config->compl_modes.modes[i]];
+ if (num_sessions > dma_capa.max_sessions) {
+ ODPH_ERR("Not enough DMA sessions supported: %u (max: %u)\n", num_sessions,
+ dma_capa.max_sessions);
+ return PRS_NOT_SUP;
}
- return 0;
-}
+ config->num_sessions = num_sessions;
-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->num_in_segs == 0U)
+ config->num_in_segs = dma_capa.max_src_segs;
+
+ if (config->num_out_segs == 0U)
+ config->num_out_segs = dma_capa.max_dst_segs;
+
+ if (config->num_in_segs > dma_capa.max_src_segs ||
+ config->num_out_segs > dma_capa.max_dst_segs ||
+ config->num_in_segs + config->num_out_segs > dma_capa.max_segs) {
+ ODPH_ERR("Unsupported segment count configuration, in: %u, out: %u (max in: %u, "
+ "max out: %u, max tot: %u)\n", config->num_in_segs, config->num_out_segs,
+ dma_capa.max_src_segs, dma_capa.max_dst_segs, dma_capa.max_segs);
+ return PRS_NOT_SUP;
}
- if (config->trs_grn != GRN_ALL && config->trs_grn != GRN_IND) {
- ODPH_ERR("Invalid granularity: %d.\n", config->trs_grn);
- return -1;
+ if (config->src_seg_len == 0U)
+ config->src_seg_len = dma_capa.max_seg_len;
+
+ config->dst_seg_len = config->src_seg_len * config->num_in_segs /
+ config->num_out_segs + config->src_seg_len *
+ config->num_in_segs % config->num_out_segs;
+
+ max_seg_len = MAX(config->src_seg_len, config->dst_seg_len);
+
+ if (max_seg_len > dma_capa.max_seg_len) {
+ ODPH_ERR("Unsupported total DMA segment length: %u (max: %u)\n", max_seg_len,
+ dma_capa.max_seg_len);
+ return PRS_NOT_SUP;
}
- config->dma_rounds = config->trs_grn == GRN_IND ? config->num_in_seg : 1;
+ if (config->trs_type == ASYNC) {
+ if (config->compl_mode != POLL && config->compl_mode != EVENT) {
+ ODPH_ERR("Invalid completion mode: %u\n", config->compl_mode);
+ return PRS_NOK;
+ }
+
+ if (config->compl_mode == POLL && (dma_capa.compl_mode_mask & ODP_DMA_COMPL_POLL)
+ == 0U) {
+ ODPH_ERR("Unsupported DMA completion mode, poll\n");
+ return PRS_NOT_SUP;
+ }
+
+ if (config->compl_mode == EVENT) {
+ if (config->num_sessions > dma_capa.pool.max_pools) {
+ ODPH_ERR("Unsupported amount of completion pools: %u (max: %u)\n",
+ config->num_sessions, dma_capa.pool.max_pools);
+ return PRS_NOT_SUP;
+ }
+
+ if ((dma_capa.compl_mode_mask & ODP_DMA_COMPL_EVENT) == 0U) {
+ ODPH_ERR("Unsupported DMA completion mode, event\n");
+ return PRS_NOT_SUP;
+ }
+
+ if (dma_capa.queue_type_sched == 0) {
+ ODPH_ERR("Unsupported DMA queueing type, scheduled\n");
+ return PRS_NOT_SUP;
+ }
+
+ if (config->num_inflight > dma_capa.pool.max_num) {
+ ODPH_ERR("Unsupported amount of completion events: %u (max: %u)\n",
+ config->num_inflight, dma_capa.pool.max_num);
+ return PRS_NOT_SUP;
+ }
+
+ if (odp_schedule_capability(&sched_capa) < 0) {
+ ODPH_ERR("Error querying scheduler capabilities\n");
+ return PRS_NOK;
+ }
+
+ if (config->num_sessions > sched_capa.max_groups - 3U) {
+ ODPH_ERR("Unsupported amount of scheduler groups: %u (max: %u)\n",
+ config->num_sessions, sched_capa.max_groups - 3U);
+ return PRS_NOT_SUP;
+ }
+ }
- 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;
+ config->compl_mode_mask |= mode_map[config->compl_mode];
}
- if (config->seg_type != TYPE_PKT && config->seg_type != TYPE_MEM) {
- ODPH_ERR("Invalid input segment type: %d.\n", config->seg_type);
- return -1;
+ max_trs = MIN(dma_capa.max_transfers, MAX_SEGS);
+
+ if (config->num_inflight == 0U)
+ config->num_inflight = max_trs;
+
+ if (config->num_inflight > max_trs) {
+ ODPH_ERR("Unsupported amount of in-flight DMA transfers: %u (max: %u)\n",
+ config->num_inflight, max_trs);
+ return PRS_NOT_SUP;
}
- if (check_completion_modes(config)) {
- ODPH_ERR("Invalid completion modes.\n");
- return -1;
+ max_in = config->num_in_segs * config->num_inflight;
+ max_out = config->num_out_segs * config->num_inflight;
+ max_segs = MAX(max_in, max_out);
+
+ if (max_segs > MAX_SEGS) {
+ ODPH_ERR("Unsupported input/output * inflight segment combination: %u (max: %u)\n",
+ max_segs, MAX_SEGS);
+ return PRS_NOT_SUP;
}
- if (config->num_rounds < 1) {
- ODPH_ERR("Invalid number of rounds: %d.\n", config->num_rounds);
- return -1;
+ if (config->seg_type == PACKET) {
+ if (odp_pool_capability(&pool_capa) < 0) {
+ ODPH_ERR("Error querying pool capabilities\n");
+ return PRS_NOK;
+ }
+
+ if (pool_capa.pkt.max_pools < 2U) {
+ ODPH_ERR("Unsupported amount of packet pools: 2 (max: %u)\n",
+ pool_capa.pkt.max_pools);
+ return PRS_NOT_SUP;
+ }
+
+ if (pool_capa.pkt.max_len != 0U && max_seg_len > pool_capa.pkt.max_len) {
+ ODPH_ERR("Unsupported packet size: %u (max: %u)\n", max_seg_len,
+ pool_capa.pkt.max_len);
+ return PRS_NOT_SUP;
+ }
+
+ if (pool_capa.pkt.max_num != 0U &&
+ max_segs * num_sessions > pool_capa.pkt.max_num) {
+ ODPH_ERR("Unsupported amount of packet pool elements: %u (max: %u)\n",
+ max_segs * num_sessions, pool_capa.pkt.max_num);
+ return PRS_NOT_SUP;
+ }
+ } else {
+ /* If SHM implementation capabilities are very puny, program will have already
+ * failed when reserving memory for global program configuration. */
+ if (odp_shm_capability(&shm_capa) < 0) {
+ ODPH_ERR("Error querying SHM capabilities\n");
+ return PRS_NOK;
+ }
+
+ /* One block for program configuration, one for source memory and one for
+ * destination memory. */
+ if (shm_capa.max_blocks < 3U) {
+ ODPH_ERR("Unsupported amount of SHM blocks: 3 (max: %u)\n",
+ shm_capa.max_blocks);
+ return PRS_NOT_SUP;
+ }
+
+ shm_size = (uint64_t)config->dst_seg_len * config->num_out_segs *
+ config->num_inflight;
+
+ if (shm_capa.max_size != 0U && shm_size > shm_capa.max_size) {
+ ODPH_ERR("Unsupported total SHM block size: %" PRIu64 ""
+ " (max: %" PRIu64 ")\n", shm_size, shm_capa.max_size);
+ return PRS_NOT_SUP;
+ }
}
- return 0;
+ return PRS_OK;
}
-static int parse_options(int argc, char **argv, test_config_t *config)
+static parse_result_t parse_options(int argc, char **argv, prog_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' },
- { "wait_nsec", required_argument, NULL, 'w' },
+ { "num_out_seg", required_argument, NULL, 'o' },
+ { "in_seg_len", required_argument, NULL, 's' },
+ { "in_seg_type", required_argument, NULL, 'S' },
+ { "compl_mode", required_argument, NULL, 'm' },
+ { "max_in_flight", required_argument, NULL, 'f'},
+ { "time_sec", required_argument, NULL, 'T' },
+ { "worker_count", required_argument, NULL, 'c' },
+ { "policy", required_argument, NULL, 'p' },
{ "help", no_argument, NULL, 'h' },
{ NULL, 0, NULL, 0 }
};
+ static const char *shortopts = "t:i:o:s:S:m:f:T:c:p:h";
- static const char *shortopts = "t:g:i:s:T:m:r:w:h";
-
- set_option_defaults(config);
+ init_config(config);
while (1) {
opt = getopt_long(argc, argv, shortopts, longopts, &long_index);
@@ -280,862 +529,1076 @@ static int parse_options(int argc, char **argv, test_config_t *config)
case 't':
config->trs_type = atoi(optarg);
break;
- case 'g':
- config->trs_grn = atoi(optarg);
- break;
case 'i':
- config->num_in_seg = atoi(optarg);
+ config->num_in_segs = atoi(optarg);
+ break;
+ case 'o':
+ config->num_out_segs = atoi(optarg);
break;
case 's':
- config->seg_size = atoi(optarg);
+ config->src_seg_len = atoi(optarg);
break;
- case 'T':
+ case 'S':
config->seg_type = atoi(optarg);
break;
case 'm':
- parse_completion_modes(config, optarg);
+ config->compl_mode = atoi(optarg);
break;
- case 'r':
- config->num_rounds = atoi(optarg);
+ case 'f':
+ config->num_inflight = atoi(optarg);
break;
- case 'w':
- config->wait_ns = atoll(optarg);
+ case 'T':
+ config->time_sec = atoi(optarg);
+ break;
+ case 'c':
+ config->num_workers = atoi(optarg);
+ break;
+ case 'p':
+ config->policy = atoi(optarg);
break;
case 'h':
+ print_usage();
+ return PRS_TERM;
+ case '?':
default:
print_usage();
- return -1;
+ return PRS_NOK;
}
}
- if (check_options(config))
- return -1;
-
- return 0;
+ return check_options(config);
}
-static int check_shm_capabilities(const test_config_t *config)
+static parse_result_t setup_program(int argc, char **argv, prog_config_t *config)
{
- odp_shm_capability_t capa;
-
- if (odp_shm_capability(&capa)) {
- ODPH_ERR("Error querying SHM capabilities.\n");
- return -1;
+ struct sigaction action = { .sa_handler = terminate };
+
+ if (sigemptyset(&action.sa_mask) == -1 || sigaddset(&action.sa_mask, SIGINT) == -1 ||
+ sigaddset(&action.sa_mask, SIGTERM) == -1 ||
+ sigaddset(&action.sa_mask, SIGHUP) == -1 || sigaction(SIGINT, &action, NULL) == -1 ||
+ sigaction(SIGTERM, &action, NULL) == -1 || sigaction(SIGHUP, &action, NULL) == -1) {
+ ODPH_ERR("Error installing signal handler\n");
+ return PRS_NOK;
}
- 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;
+ return parse_options(argc, argv, config);
}
-static int check_dma_capabilities(const test_config_t *config)
+static odp_pool_t get_src_packet_pool(void)
{
- 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;
- }
+ odp_pool_param_t param;
- if (config->num_in_seg * config->seg_size > capa.max_seg_len) {
- ODPH_ERR("Unsupported total DMA segment size.\n");
- return -1;
- }
+ if (prog_conf->src_pool != ODP_POOL_INVALID)
+ return prog_conf->src_pool;
- return 0;
-}
+ odp_pool_param_init(&param);
+ param.type = ODP_POOL_PACKET;
+ param.pkt.num = prog_conf->num_inflight * prog_conf->num_in_segs * prog_conf->num_sessions;
+ param.pkt.len = prog_conf->src_seg_len;
+ param.pkt.seg_len = prog_conf->src_seg_len;
+ prog_conf->src_pool = odp_pool_create(PROG_NAME "_src_pkts", &param);
-static int check_capabilities(const test_config_t *config)
-{
- return check_shm_capabilities(config) ||
- check_dma_capabilities(config);
+ return prog_conf->src_pool;
}
-static int configure_packets(test_config_t *config)
+static odp_pool_t get_dst_packet_pool(void)
{
odp_pool_param_t param;
- for (int i = 0; i < config->num_in_seg + 1; ++i)
- config->seg_config.pkts[i] = ODP_PACKET_INVALID;
+ if (prog_conf->dst_pool != ODP_POOL_INVALID)
+ return prog_conf->dst_pool;
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;
- }
+ param.pkt.num = prog_conf->num_inflight * prog_conf->num_out_segs *
+ prog_conf->num_sessions;
+ param.pkt.len = prog_conf->dst_seg_len;
+ param.pkt.seg_len = prog_conf->dst_seg_len;
+ prog_conf->dst_pool = odp_pool_create(PROG_NAME "_dst_pkts", &param);
- return 0;
+ return prog_conf->dst_pool;
}
-static int allocate_packets(test_config_t *config)
+static odp_bool_t configure_packets(sd_t *sd)
{
- 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);
+ sd->seg.src_pool = get_src_packet_pool();
- if (config->seg_config.pkts[i] == ODP_PACKET_INVALID) {
- ODPH_ERR("Error allocating input test packets.\n");
- return -1;
- }
+ if (sd->seg.src_pool == ODP_POOL_INVALID) {
+ ODPH_ERR("Error creating source packet pool\n");
+ return false;
}
- config->seg_config.pkts[config->num_in_seg] =
- odp_packet_alloc(config->seg_config.pool, config->num_in_seg * config->seg_size);
+ sd->seg.dst_pool = get_dst_packet_pool();
- if (config->seg_config.pkts[config->num_in_seg] == ODP_PACKET_INVALID) {
- ODPH_ERR("Error allocating output test packet.\n");
- return -1;
+ if (sd->seg.dst_pool == ODP_POOL_INVALID) {
+ ODPH_ERR("Error creating destination packet pool\n");
+ return false;
}
- return 0;
+ return true;
}
-static int populate_packets(test_config_t *config)
+static odp_bool_t allocate_packets(sd_t *sd)
{
- 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));
+ for (uint32_t i = 0U; i < sd->dma.num_inflight * sd->dma.num_in_segs; ++i) {
+ sd->seg.src_pkt[i] = odp_packet_alloc(sd->seg.src_pool, sd->dma.src_seg_len);
- if (odp_packet_copy_from_mem(config->seg_config.pkts[i], 0U, sizeof(data), data))
- return -1;
+ if (sd->seg.src_pkt[i] == ODP_PACKET_INVALID) {
+ ODPH_ERR("Error allocating source segment packets\n");
+ return false;
+ }
}
- return 0;
-}
+ for (uint32_t i = 0U; i < sd->dma.num_inflight * sd->dma.num_out_segs; ++i) {
+ sd->seg.dst_pkt[i] = odp_packet_alloc(sd->seg.dst_pool, sd->dma.dst_seg_len);
-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]);
+ if (sd->seg.dst_pkt[i] == ODP_PACKET_INVALID) {
+ ODPH_ERR("Error allocating destination segment packets\n");
+ return false;
+ }
}
- 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;
- }
+ return true;
}
-static inline void configure_packet_dma_transfer_dynamic(test_config_t *config, uint32_t offset,
- uint32_t len)
+static odp_bool_t setup_packet_segments(sd_t *sd)
{
- config->dma_config.dst_seg.offset = offset;
- config->dma_config.dst_seg.len = len;
+ return configure_packets(sd) && allocate_packets(sd);
}
-static int verify_packet_transfer(const test_config_t *config)
+static void configure_packet_dma_transfer(sd_t *sd)
{
- 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;
+ odp_dma_seg_t *start_src_seg, *start_dst_seg, *seg;
+ uint32_t k = 0U, z = 0U, len;
+ odp_packet_t pkt;
+ odp_dma_transfer_param_t *param;
+
+ for (uint32_t i = 0U; i < sd->dma.num_inflight; ++i) {
+ start_src_seg = &sd->dma.src_seg[k];
+ start_dst_seg = &sd->dma.dst_seg[z];
+
+ for (uint32_t j = 0U; j < sd->dma.num_in_segs; ++j, ++k) {
+ pkt = sd->seg.src_pkt[k];
+ seg = &start_src_seg[j];
+ seg->packet = pkt;
+ seg->offset = 0U;
+ seg->len = sd->dma.src_seg_len;
}
- if (memcmp(src_data, dst_data, len)) {
- ODPH_ERR("Error in DMA transfer, source and destination data do not match.\n");
- return -1;
+ len = sd->dma.num_in_segs * sd->dma.src_seg_len;
+
+ for (uint32_t j = 0U; j < sd->dma.num_out_segs; ++j, ++z) {
+ pkt = sd->seg.dst_pkt[z];
+ seg = &start_dst_seg[j];
+ seg->packet = pkt;
+ seg->offset = 0U;
+ seg->len = MIN(len, sd->dma.dst_seg_len);
+ len -= sd->dma.dst_seg_len;
}
- offset += len;
+ param = &sd->dma.infos[i].trs_param;
+ odp_dma_transfer_param_init(param);
+ param->src_format = ODP_DMA_FORMAT_PACKET;
+ param->dst_format = ODP_DMA_FORMAT_PACKET;
+ param->num_src = sd->dma.num_in_segs;
+ param->num_dst = sd->dma.num_out_segs;
+ param->src_seg = start_src_seg;
+ param->dst_seg = start_dst_seg;
}
-
- return 0;
}
-static void free_packets(test_config_t *config)
+static void free_packets(const sd_t *sd)
{
- /* 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]);
+ for (uint32_t i = 0U; i < sd->dma.num_inflight * sd->dma.num_in_segs; ++i) {
+ if (sd->seg.src_pkt[i] != ODP_PACKET_INVALID)
+ odp_packet_free(sd->seg.src_pkt[i]);
+ }
- if (config->seg_config.pool != ODP_POOL_INVALID)
- (void)odp_pool_destroy(config->seg_config.pool);
+ for (uint32_t i = 0U; i < sd->dma.num_inflight * sd->dma.num_out_segs; ++i) {
+ if (sd->seg.dst_pkt[i] != ODP_PACKET_INVALID)
+ odp_packet_free(sd->seg.dst_pkt[i]);
+ }
}
-static int allocate_memory(test_config_t *config)
+static odp_bool_t allocate_memory(sd_t *sd)
{
- const uint64_t size = config->num_in_seg * (uint64_t)config->seg_size;
+ const uint64_t num_segs = (uint64_t)sd->dma.num_in_segs * sd->dma.num_inflight;
- 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;
+ sd->seg.src_shm = odp_shm_reserve(PROG_NAME "_src_shm", sd->dma.src_seg_len * num_segs,
+ ODP_CACHE_LINE_SIZE, 0U);
+ sd->seg.dst_shm = odp_shm_reserve(PROG_NAME "_dst_shm", sd->dma.dst_seg_len * num_segs,
+ ODP_CACHE_LINE_SIZE, 0U);
- 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;
+ if (sd->seg.src_shm == ODP_SHM_INVALID || sd->seg.dst_shm == ODP_SHM_INVALID) {
+ ODPH_ERR("Error allocating SHM block\n");
+ return false;
}
- config->seg_config.src = odp_shm_addr(config->seg_config.shm_src);
- config->seg_config.dst = odp_shm_addr(config->seg_config.shm_dst);
+ sd->seg.src = odp_shm_addr(sd->seg.src_shm);
+ sd->seg.dst = odp_shm_addr(sd->seg.dst_shm);
- if (config->seg_config.src == NULL || config->seg_config.dst == NULL) {
- ODPH_ERR("Error resolving SHM block address.\n");
- return -1;
+ if (sd->seg.src == NULL || sd->seg.dst == NULL) {
+ ODPH_ERR("Error resolving SHM block address\n");
+ return false;
}
- return 0;
+ return true;
}
-static int populate_memory(test_config_t *config)
+static odp_bool_t setup_memory_segments(sd_t *sd)
{
- 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;
+ return allocate_memory(sd);
}
-static int setup_memory_segments(test_config_t *config)
+static void configure_address_dma_transfer(sd_t *sd)
{
- return allocate_memory(config) ||
- populate_memory(config);
-}
+ odp_dma_seg_t *start_src_seg, *start_dst_seg, *seg;
+ uint32_t k = 0U, z = 0U, len;
+ odp_dma_transfer_param_t *param;
+
+ for (uint32_t i = 0U; i < sd->dma.num_inflight; ++i) {
+ start_src_seg = &sd->dma.src_seg[k];
+ start_dst_seg = &sd->dma.dst_seg[z];
+
+ for (uint32_t j = 0U; j < sd->dma.num_in_segs; ++j, ++k) {
+ seg = &start_src_seg[j];
+ seg->addr = (uint8_t *)sd->seg.src + k * sd->dma.src_seg_len;
+ seg->len = sd->dma.src_seg_len;
+ }
-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);
+ len = sd->dma.num_in_segs * sd->dma.src_seg_len;
- 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;
- }
+ for (uint32_t j = 0U; j < sd->dma.num_out_segs; ++j, ++z) {
+ seg = &start_dst_seg[j];
+ seg->addr = (uint8_t *)sd->seg.dst + z * sd->dma.dst_seg_len;
+ seg->len = MIN(len, sd->dma.dst_seg_len);
+ len -= sd->dma.dst_seg_len;
+ }
- 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;
+ param = &sd->dma.infos[i].trs_param;
+ odp_dma_transfer_param_init(param);
+ param->src_format = ODP_DMA_FORMAT_ADDR;
+ param->dst_format = ODP_DMA_FORMAT_ADDR;
+ param->num_src = sd->dma.num_in_segs;
+ param->num_dst = sd->dma.num_out_segs;
+ param->src_seg = start_src_seg;
+ param->dst_seg = start_dst_seg;
}
}
-static inline void configure_address_dma_transfer_dynamic(test_config_t *config, uint32_t offset,
- uint32_t len)
+static void free_memory(const sd_t *sd)
{
- config->dma_config.dst_seg.addr = (uint8_t *)config->seg_config.dst + offset;
- config->dma_config.dst_seg.len = len;
+ if (sd->seg.src_shm != ODP_SHM_INVALID)
+ (void)odp_shm_free(sd->seg.src_shm);
+
+ if (sd->seg.dst_shm != ODP_SHM_INVALID)
+ (void)odp_shm_free(sd->seg.dst_shm);
}
-static int verify_memory_transfer(const test_config_t *config)
+static void run_transfer(odp_dma_t handle, trs_info_t *info, stats_t *stats)
{
- 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;
- }
+ uint64_t start_tm, end_tm, start_cc, end_cc, trs_tm, trs_cc, start_cc_diff;
+ odp_dma_result_t res;
+ int ret;
- return 0;
+ start_tm = odp_time_local_strict_ns();
+ start_cc = odp_cpu_cycles();
+ ret = odp_dma_transfer(handle, &info->trs_param, &res);
+ end_cc = odp_cpu_cycles();
+ end_tm = odp_time_local_strict_ns();
+
+ if (odp_unlikely(ret <= 0)) {
+ ++stats->start_errs;
+ } else {
+ trs_tm = end_tm - start_tm;
+ stats->max_trs_tm = MAX(trs_tm, stats->max_trs_tm);
+ stats->min_trs_tm = MIN(trs_tm, stats->min_trs_tm);
+ stats->trs_tm += trs_tm;
+ trs_cc = odp_cpu_cycles_diff(end_cc, start_cc);
+ stats->max_trs_cc = MAX(trs_cc, stats->max_trs_cc);
+ stats->min_trs_cc = MIN(trs_cc, stats->min_trs_cc);
+ stats->trs_cc += trs_cc;
+ ++stats->trs_cnt;
+ start_cc_diff = odp_cpu_cycles_diff(end_cc, start_cc);
+ stats->max_start_cc = MAX(start_cc_diff, stats->max_start_cc);
+ stats->min_start_cc = MIN(start_cc_diff, stats->min_start_cc);
+ stats->start_cc += start_cc_diff;
+ ++stats->start_cnt;
+
+ if (odp_unlikely(!res.success))
+ ++stats->transfer_errs;
+ else
+ ++stats->completed;
+ }
}
-static void free_memory(test_config_t *config)
+static void run_transfers_mt_unsafe(sd_t *sd, stats_t *stats)
{
- if (config->seg_config.shm_src != ODP_SHM_INVALID)
- (void)odp_shm_free(config->seg_config.shm_src);
+ const uint32_t count = sd->dma.num_inflight;
+ odp_dma_t handle = sd->dma.handle;
+ trs_info_t *infos = sd->dma.infos;
- if (config->seg_config.shm_dst != ODP_SHM_INVALID)
- (void)odp_shm_free(config->seg_config.shm_dst);
+ for (uint32_t i = 0U; i < count; ++i)
+ run_transfer(handle, &infos[i], stats);
}
-static void print_humanised_speed(uint64_t speed)
+static void run_transfers_mt_safe(sd_t *sd, stats_t *stats)
{
- 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);
+ const uint32_t count = sd->dma.num_inflight;
+ odp_dma_t handle = sd->dma.handle;
+ trs_info_t *infos = sd->dma.infos, *info;
+
+ for (uint32_t i = 0U; i < count; ++i) {
+ info = &infos[i];
+
+ if (odp_ticketlock_trylock(&info->lock)) {
+ run_transfer(handle, info, stats);
+ odp_ticketlock_unlock(&info->lock);
+ }
+ }
}
-static void print_results(const test_config_t *config, uint64_t time, uint32_t retries)
+static odp_bool_t configure_poll_compl(sd_t *sd)
{
- const int is_sync = config->trs_type == TRS_TYPE_SYNC;
- const uint64_t avg_time = time / config->num_rounds;
- uint64_t avg_speed = 0U;
+ odp_dma_compl_param_t *param;
- 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 ");
+ for (uint32_t i = 0U; i < sd->dma.num_inflight; ++i) {
+ param = &sd->dma.infos[i].compl_param;
- printf("\n");
- }
+ odp_dma_compl_param_init(param);
+ param->compl_mode = mode_map[sd->dma.compl_mode];
+ param->transfer_id = odp_dma_transfer_id_alloc(sd->dma.handle);
- if (avg_time > 0U)
- avg_speed = config->num_in_seg * config->seg_size * ODP_TIME_SEC_IN_NS / avg_time;
+ if (param->transfer_id == ODP_DMA_TRANSFER_ID_INVALID) {
+ ODPH_ERR("Error allocating transfer ID\n");
+ return false;
+ }
+ }
- 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(" retries with usec sleep: %u\n", retries);
- printf("\n=============================================\n");
+ return true;
}
-static int run_dma_sync(test_config_t *config)
+static void poll_transfer(odp_dma_t handle, trs_info_t *info, stats_t *stats)
{
- 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, retries = 0U;
- int done = 0;
+ uint64_t start_cc, end_cc, trs_tm, trs_cc, wait_cc, start_tm, start_cc_diff;
+ odp_dma_result_t res;
+ int ret;
- config->test_case_api.trs_base_fn(config, trs_params, trs_lengths);
- start = odp_time_local_strict();
+ if (info->is_running) {
+ start_cc = odp_cpu_cycles();
+ ret = odp_dma_transfer_done(handle, info->compl_param.transfer_id, &res);
+ end_cc = odp_cpu_cycles();
- while (num_rounds--) {
- offset = 0U;
+ if (odp_unlikely(ret < 0)) {
+ ++stats->poll_errs;
+ return;
+ }
- for (int i = 0; i < config->dma_rounds; ++i) {
- config->test_case_api.trs_dyn_fn(config, offset, trs_lengths[i]);
+ ++info->trs_poll_cnt;
+ wait_cc = odp_cpu_cycles_diff(end_cc, start_cc);
+ stats->max_wait_cc = MAX(wait_cc, stats->max_wait_cc);
+ stats->min_wait_cc = MIN(wait_cc, stats->min_wait_cc);
+ stats->wait_cc += wait_cc;
+ ++stats->wait_cnt;
+
+ if (ret == 0)
+ return;
+
+ trs_tm = odp_time_global_strict_ns() - info->trs_start_tm;
+ stats->max_trs_tm = MAX(trs_tm, stats->max_trs_tm);
+ stats->min_trs_tm = MIN(trs_tm, stats->min_trs_tm);
+ stats->trs_tm += trs_tm;
+ trs_cc = odp_cpu_cycles_diff(odp_cpu_cycles(), info->trs_start_cc);
+ stats->max_trs_cc = MAX(trs_cc, stats->max_trs_cc);
+ stats->min_trs_cc = MIN(trs_cc, stats->min_trs_cc);
+ stats->trs_cc += trs_cc;
+ stats->trs_poll_cnt += info->trs_poll_cnt;
+ ++stats->trs_cnt;
+
+ if (odp_unlikely(!res.success))
+ ++stats->transfer_errs;
+ else
+ ++stats->completed;
+
+ info->is_running = false;
+ } else {
+ start_tm = odp_time_global_strict_ns();
+ start_cc = odp_cpu_cycles();
+ ret = odp_dma_transfer_start(handle, &info->trs_param, &info->compl_param);
+ end_cc = odp_cpu_cycles();
+
+ if (odp_unlikely(ret <= 0)) {
+ ++stats->start_errs;
+ } else {
+ info->trs_start_tm = start_tm;
+ info->trs_start_cc = start_cc;
+ info->trs_poll_cnt = 0U;
+ start_cc_diff = odp_cpu_cycles_diff(end_cc, start_cc);
+ stats->max_start_cc = MAX(start_cc_diff, stats->max_start_cc);
+ stats->min_start_cc = MIN(start_cc_diff, stats->min_start_cc);
+ stats->start_cc += start_cc_diff;
+ ++stats->start_cnt;
+ info->is_running = true;
+ }
+ }
+}
- while (1) {
- done = odp_dma_transfer(config->dma_config.handle, &trs_params[i],
- NULL);
+static void poll_transfers_mt_unsafe(sd_t *sd, stats_t *stats)
+{
+ const uint32_t count = sd->dma.num_inflight;
+ odp_dma_t handle = sd->dma.handle;
+ trs_info_t *infos = sd->dma.infos;
- if (done > 0)
- break;
+ for (uint32_t i = 0U; i < count; ++i)
+ poll_transfer(handle, &infos[i], stats);
+}
- if (done == 0 && retries++ < RETRIES) {
- odp_time_wait_ns(1000U);
- continue;
- }
+static void poll_transfers_mt_safe(sd_t *sd, stats_t *stats)
+{
+ const uint32_t count = sd->dma.num_inflight;
+ odp_dma_t handle = sd->dma.handle;
+ trs_info_t *infos = sd->dma.infos, *info;
- ODPH_ERR("Error starting a sync DMA transfer.\n");
- return -1;
- }
+ for (uint32_t i = 0U; i < count; ++i) {
+ info = &infos[i];
- offset += trs_lengths[i];
+ if (odp_ticketlock_trylock(&info->lock)) {
+ poll_transfer(handle, info, stats);
+ odp_ticketlock_unlock(&info->lock);
}
}
-
- end = odp_time_local_strict();
- print_results(config, odp_time_diff_ns(end, start), retries);
- return 0;
}
-static int configure_dma_event_completion(test_config_t *config)
+static odp_bool_t configure_event_compl_session(sd_t *sd)
{
- int ret;
+ odp_thrmask_t zero;
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);
+ odp_thrmask_zero(&zero);
+ sd->grp = odp_schedule_group_create(PROG_NAME "_scd_grp", &zero);
- if (ret < 0) {
- ODPH_ERR("Error configuring scheduler.\n");
- return -1;
+ if (sd->grp == ODP_SCHED_GROUP_INVALID) {
+ ODPH_ERR("Error creating scheduler group for DMA session\n");
+ return false;
}
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);
+ pool_param.num = sd->dma.num_inflight;
+ sd->dma.pool = odp_dma_pool_create(PROG_NAME "_dma_evs", &pool_param);
- if (config->dma_config.pool == ODP_POOL_INVALID) {
- ODPH_ERR("Error creating DMA event completion pool.\n");
- return -1;
+ if (sd->dma.pool == ODP_POOL_INVALID) {
+ ODPH_ERR("Error creating DMA event completion pool\n");
+ return false;
}
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);
+ queue_param.sched.group = sd->grp;
+ sd->dma.compl_q = odp_queue_create(PROG_NAME, &queue_param);
- if (config->dma_config.compl_q == ODP_QUEUE_INVALID) {
- ODPH_ERR("Error creating DMA completion queue.\n");
- return -1;
+ if (sd->dma.compl_q == ODP_QUEUE_INVALID) {
+ ODPH_ERR("Error creating DMA completion queue\n");
+ return false;
}
- return 0;
+ return true;
}
-static int configure_dma_completion_params(test_config_t *config,
- odp_dma_compl_param_t compl_params[])
+static odp_bool_t configure_event_compl(sd_t *sd)
{
- odp_dma_compl_t compl_ev;
+ odp_dma_compl_param_t *param;
+ odp_dma_compl_t c_ev;
- for (int i = 0; i < config->dma_rounds; ++i)
- odp_dma_compl_param_init(&compl_params[i]);
+ for (uint32_t i = 0U; i < sd->dma.num_inflight; ++i) {
+ param = &sd->dma.infos[i].compl_param;
- 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);
+ odp_dma_compl_param_init(param);
+ param->compl_mode = mode_map[sd->dma.compl_mode];
+ c_ev = odp_dma_compl_alloc(sd->dma.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;
- }
+ if (c_ev == ODP_DMA_COMPL_INVALID) {
+ ODPH_ERR("Error allocating completion event\n");
+ return false;
}
- compl_params[i].user_ptr = NULL;
+ param->event = odp_dma_compl_to_event(c_ev);
+ param->queue = sd->dma.compl_q;
+ param->user_ptr = &sd->dma.infos[i];
}
- return 0;
+ return true;
}
-static void build_wait_list(const test_config_t *config, odp_dma_compl_param_t compl_params[],
- compl_wait_entry_t list[])
+static odp_bool_t start_initial_transfers(sd_t *sd)
{
- int last_ev_idx, has_events = 0;
+ uint64_t start_tm, start_cc;
+ trs_info_t *info;
+ int ret;
- memset(list, 0, sizeof(*list) * config->dma_rounds);
+ for (uint32_t i = 0U; i < sd->dma.num_inflight; ++i) {
+ info = &sd->dma.infos[i];
+ start_tm = odp_time_global_strict_ns();
+ start_cc = odp_cpu_cycles();
+ ret = odp_dma_transfer_start(sd->dma.handle, &info->trs_param, &info->compl_param);
- 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 };
+ if (ret <= 0) {
+ ODPH_ERR("Error starting DMA transfer\n");
+ return false;
+ }
- list[j] = entry;
- ++j;
+ info->trs_start_tm = start_tm;
+ info->trs_start_cc = start_cc;
+ }
- for (; k < i; ++k) {
- entry.type = ODP_DMA_COMPL_POLL;
- entry.id = compl_params[k].transfer_id;
- list[j++] = entry;
- }
+ return true;
+}
- ++k;
- last_ev_idx = i;
- has_events = 1;
- }
- }
+static void wait_compl_event(sd_t *sd, stats_t *stats)
+{
+ uint64_t start_cc, end_cc, wait_cc, trs_tm, trs_cc, start_tm, start_cc_diff;
+ odp_event_t ev;
+ odp_dma_result_t res;
+ trs_info_t *info;
+ int ret;
- last_ev_idx = has_events ? last_ev_idx + 1 : 0;
+ start_cc = odp_cpu_cycles();
+ ev = odp_schedule(NULL, odp_schedule_wait_time(ODP_TIME_SEC_IN_NS));
+ end_cc = odp_cpu_cycles();
- 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;
+ if (odp_unlikely(ev == ODP_EVENT_INVALID)) {
+ ++stats->scheduler_timeouts;
+ return;
+ }
+
+ odp_dma_compl_result(odp_dma_compl_from_event(ev), &res);
+ info = res.user_ptr;
+ trs_tm = odp_time_global_strict_ns() - info->trs_start_tm;
+ stats->max_trs_tm = MAX(trs_tm, stats->max_trs_tm);
+ stats->min_trs_tm = MIN(trs_tm, stats->min_trs_tm);
+ stats->trs_tm += trs_tm;
+ trs_cc = odp_cpu_cycles_diff(odp_cpu_cycles(), info->trs_start_cc);
+ stats->max_trs_cc = MAX(trs_cc, stats->max_trs_cc);
+ stats->min_trs_cc = MIN(trs_cc, stats->min_trs_cc);
+ stats->trs_cc += trs_cc;
+ ++stats->trs_cnt;
+ wait_cc = odp_cpu_cycles_diff(end_cc, start_cc);
+ stats->max_wait_cc = MAX(wait_cc, stats->max_wait_cc);
+ stats->min_wait_cc = MIN(wait_cc, stats->min_wait_cc);
+ stats->wait_cc += wait_cc;
+ ++stats->wait_cnt;
+
+ if (odp_unlikely(!res.success))
+ ++stats->transfer_errs;
+ else
+ ++stats->completed;
+
+ start_tm = odp_time_global_strict_ns();
+ start_cc = odp_cpu_cycles();
+ ret = odp_dma_transfer_start(sd->dma.handle, &info->trs_param, &info->compl_param);
+ end_cc = odp_cpu_cycles();
+
+ if (odp_unlikely(ret <= 0)) {
+ ++stats->start_errs;
+ } else {
+ info->trs_start_tm = start_tm;
+ info->trs_start_cc = start_cc;
+ start_cc_diff = odp_cpu_cycles_diff(end_cc, start_cc);
+ stats->max_start_cc = MAX(start_cc_diff, stats->max_start_cc);
+ stats->min_start_cc = MIN(start_cc_diff, stats->min_start_cc);
+ stats->start_cc += start_cc_diff;
+ ++stats->start_cnt;
}
}
-static inline int wait_dma_transfers_ready(test_config_t *config, compl_wait_entry_t list[])
+static void drain_compl_events(void)
{
odp_event_t ev;
- const uint64_t wait_time = odp_schedule_wait_time(config->wait_ns);
- uint64_t start, end;
- 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 {
- start = odp_time_local_ns();
- end = start + ODP_TIME_SEC_IN_NS;
- while (1) {
- done = odp_dma_transfer_done(config->dma_config.handle, list[i].id,
- NULL);
+ while (true) {
+ ev = odp_schedule(NULL, odp_schedule_wait_time(ODP_TIME_SEC_IN_NS));
- if (done > 0)
- break;
+ if (ev == ODP_EVENT_INVALID)
+ break;
+ }
+}
- if (done == 0 && odp_time_local_ns() < end)
- continue;
+static void setup_api(prog_config_t *config)
+{
+ if (config->seg_type == PACKET) {
+ config->api.setup_fn = setup_packet_segments;
+ config->api.trs_fn = configure_packet_dma_transfer;
+ config->api.free_fn = free_packets;
+ } else {
+ config->api.setup_fn = setup_memory_segments;
+ config->api.trs_fn = configure_address_dma_transfer;
+ config->api.free_fn = free_memory;
+ }
- ODPH_ERR("Error waiting poll completion.\n");
- return -1;
- }
+ if (config->trs_type == SYNC) {
+ config->api.compl_fn = NULL;
+ config->api.wait_fn = config->num_workers == 1 || config->policy == MANY ?
+ run_transfers_mt_unsafe : run_transfers_mt_safe;
+ config->api.drain_fn = NULL;
+ } else {
+ if (config->compl_mode == POLL) {
+ config->api.session_cfg_fn = NULL;
+ config->api.compl_fn = configure_poll_compl;
+ config->api.bootstrap_fn = NULL;
+ config->api.wait_fn = config->num_workers == 1 || config->policy == MANY ?
+ poll_transfers_mt_unsafe : poll_transfers_mt_safe;
+ config->api.drain_fn = NULL;
+ } else {
+ config->api.session_cfg_fn = configure_event_compl_session;
+ config->api.compl_fn = configure_event_compl;
+ config->api.bootstrap_fn = start_initial_transfers;
+ config->api.wait_fn = wait_compl_event;
+ config->api.drain_fn = drain_compl_events;
}
}
-
- return 0;
}
-static void free_dma_completion_events(test_config_t *config, odp_dma_compl_param_t compl_params[])
+static odp_bool_t setup_session_descriptors(prog_config_t *config)
{
- 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));
+ sd_t *sd;
+ const odp_dma_param_t dma_params = {
+ .direction = ODP_DMA_MAIN_TO_MAIN,
+ .type = ODP_DMA_TYPE_COPY,
+ .compl_mode_mask = config->compl_mode_mask,
+ .mt_mode = config->num_workers == 1 || config->policy == MANY ?
+ ODP_DMA_MT_SERIAL : ODP_DMA_MT_SAFE,
+ .order = ODP_DMA_ORDER_NONE };
+
+ for (uint32_t i = 0U; i < config->num_sessions; ++i) {
+ char name[ODP_DMA_NAME_LEN];
+
+ sd = &config->sds[i];
+ sd->dma.num_in_segs = config->num_in_segs;
+ sd->dma.num_out_segs = config->num_out_segs;
+ sd->dma.src_seg_len = config->src_seg_len;
+ sd->dma.dst_seg_len = config->dst_seg_len;
+ sd->dma.num_inflight = config->num_inflight;
+ sd->dma.trs_type = config->trs_type;
+ sd->dma.compl_mode = config->compl_mode;
+ snprintf(name, sizeof(name), PROG_NAME "_dma_%u", i);
+ sd->dma.handle = odp_dma_create(name, &dma_params);
+
+ if (sd->dma.handle == ODP_DMA_INVALID) {
+ ODPH_ERR("Error creating DMA session\n");
+ return false;
+ }
+
+ if (config->api.session_cfg_fn != NULL && !config->api.session_cfg_fn(sd))
+ return false;
+ }
+
+ return true;
}
-static void free_dma_transfer_ids(test_config_t *config, odp_dma_compl_param_t compl_params[])
+static odp_bool_t setup_data(prog_config_t *config)
{
- 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);
+ sd_t *sd;
+
+ for (uint32_t i = 0U; i < config->num_sessions; ++i) {
+ sd = &config->sds[i];
+
+ if (!config->api.setup_fn(sd))
+ return false;
+
+ config->api.trs_fn(sd);
+
+ if (config->api.compl_fn != NULL && !config->api.compl_fn(sd))
+ return false;
+ }
+
+ return true;
}
-static int run_dma_async_transfer(test_config_t *config)
+static int transfer(void *args)
{
- 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, started;
- compl_wait_entry_t compl_wait_list[config->dma_rounds];
- odp_time_t start, end;
- uint32_t num_rounds = config->num_rounds, offset, retries = 0U;
-
- 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;
+ thread_config_t *thr_config = args;
+ prog_config_t *prog_config = thr_config->prog_config;
+ sd_t *sd = thr_config->sd;
+ stats_t *stats = &thr_config->stats;
+ test_api_t *api = &prog_conf->api;
+ odp_thrmask_t mask;
+ uint64_t start_tm, end_tm;
+
+ odp_barrier_wait(&prog_config->init_barrier);
+
+ if (sd->grp != ODP_SCHED_GROUP_INVALID) {
+ odp_thrmask_zero(&mask);
+ odp_thrmask_set(&mask, odp_thread_id());
+
+ if (odp_schedule_group_join(sd->grp, &mask) < 0) {
+ ODPH_ERR("Error joining scheduler group\n");
+ goto out;
+ }
}
- build_wait_list(config, compl_params, compl_wait_list);
- start = odp_time_local_strict();
+ start_tm = odp_time_local_strict_ns();
- while (num_rounds--) {
- offset = 0U;
+ while (odp_atomic_load_u32(&prog_config->is_running))
+ api->wait_fn(sd, stats);
- for (int i = 0; i < config->dma_rounds; ++i) {
- config->test_case_api.trs_dyn_fn(config, offset, trs_lengths[i]);
+ end_tm = odp_time_local_strict_ns();
+ thr_config->stats.tot_tm = end_tm - start_tm;
- while (1) {
- started = odp_dma_transfer_start(config->dma_config.handle,
- &trs_params[i], &compl_params[i]);
+ if (api->drain_fn != NULL)
+ api->drain_fn();
- if (started > 0)
- break;
+out:
+ odp_barrier_wait(&prog_config->term_barrier);
- if (started == 0 && retries++ < RETRIES) {
- odp_time_wait_ns(1000U);
- continue;
- }
+ return 0;
+}
- ODPH_ERR("Error starting an async DMA transfer.\n");
- ret = -1;
- goto out_trs_ids;
- }
+static odp_bool_t setup_workers(prog_config_t *config)
+{
+ odp_cpumask_t cpumask;
+ int num_workers;
+ odph_thread_common_param_t thr_common;
+ odph_thread_param_t thr_params[config->num_workers], *thr_param;
+ thread_config_t *thr_config;
+ sd_t *sd;
+
+ /* Barrier init count for control and worker. */
+ odp_barrier_init(&config->init_barrier, config->num_workers + 1);
+ odp_barrier_init(&config->term_barrier, config->num_workers);
+ num_workers = odp_cpumask_default_worker(&cpumask, config->num_workers);
+ odph_thread_common_param_init(&thr_common);
+ thr_common.instance = config->odp_instance;
+ thr_common.cpumask = &cpumask;
+
+ for (int i = 0; i < config->num_workers; ++i) {
+ thr_param = &thr_params[i];
+ thr_config = &config->thread_config[i];
+ sd = config->policy == SINGLE ? &config->sds[0U] : &config->sds[i];
+
+ odph_thread_param_init(thr_param);
+ thr_param->start = transfer;
+ thr_param->thr_type = ODP_THREAD_WORKER;
+ thr_config->prog_config = config;
+ thr_config->sd = sd;
+ thr_param->arg = thr_config;
+ }
- offset += trs_lengths[i];
- }
+ num_workers = odph_thread_create(config->threads, &thr_common, thr_params, num_workers);
- if (wait_dma_transfers_ready(config, compl_wait_list)) {
- ODPH_ERR("Error finishing an async DMA transfer.\n");
- ret = -1;
- goto out_trs_ids;
- }
+ if (num_workers != config->num_workers) {
+ ODPH_ERR("Error configuring worker threads\n");
+ return false;
}
- end = odp_time_local_strict();
- print_results(config, odp_time_diff_ns(end, start), retries);
+ for (uint32_t i = 0U; i < config->num_sessions; ++i) {
+ if (config->api.bootstrap_fn != NULL && !config->api.bootstrap_fn(&config->sds[i]))
+ return false;
+ }
-out_compl_evs:
- free_dma_completion_events(config, compl_params);
+ odp_barrier_wait(&config->init_barrier);
-out_trs_ids:
- free_dma_transfer_ids(config, compl_params);
- return ret;
+ return true;
}
-static void free_dma_event_completion(test_config_t *config)
+static odp_bool_t setup_test(prog_config_t *config)
{
- if (config->dma_config.compl_q != ODP_QUEUE_INVALID)
- (void)odp_queue_destroy(config->dma_config.compl_q);
+ setup_api(config);
- if (config->dma_config.pool != ODP_POOL_INVALID)
- (void)odp_pool_destroy(config->dma_config.pool);
+ return setup_session_descriptors(config) && setup_data(config) && setup_workers(config);
}
-static int run_dma_async(test_config_t *config)
+static void stop_test(prog_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;
- }
+ (void)odph_thread_join(config->threads, config->num_workers);
+}
- if (run_dma_async_transfer(config))
- ret = -1;
+static void teardown_data(const sd_t *sd, void (*free_fn)(const sd_t *sd))
+{
+ const odp_dma_compl_param_t *compl_param;
-out:
- if (is_event_compl)
- free_dma_event_completion(config);
+ for (uint32_t i = 0U; i < MAX_SEGS; ++i) {
+ compl_param = &sd->dma.infos[i].compl_param;
- return ret;
-}
+ if (compl_param->transfer_id != ODP_DMA_TRANSFER_ID_INVALID)
+ odp_dma_transfer_id_free(sd->dma.handle, compl_param->transfer_id);
-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;
+ if (compl_param->event != ODP_EVENT_INVALID)
+ odp_event_free(compl_param->event);
}
- config->test_case_api.run_fn = config->trs_type == TRS_TYPE_SYNC ?
- run_dma_sync :
- run_dma_async;
+ free_fn(sd);
}
-static int configure_dma_session(test_config_t *config)
+static void teardown_test(prog_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 };
+ sd_t *sd;
+
+ for (uint32_t i = 0U; i < config->num_sessions; ++i) {
+ sd = &config->sds[i];
+ teardown_data(sd, config->api.free_fn);
- config->dma_config.handle = odp_dma_create("odp_dma_perf", &params);
+ if (sd->dma.compl_q != ODP_QUEUE_INVALID)
+ (void)odp_queue_destroy(sd->dma.compl_q);
- if (config->dma_config.handle == ODP_DMA_INVALID) {
- ODPH_ERR("Error creating DMA session.\n");
- return -1;
+ if (sd->dma.pool != ODP_POOL_INVALID)
+ (void)odp_pool_destroy(sd->dma.pool);
+
+ if (sd->grp != ODP_SCHED_GROUP_INVALID)
+ (void)odp_schedule_group_destroy(sd->grp);
+
+ if (sd->dma.handle != ODP_DMA_INVALID)
+ (void)odp_dma_destroy(sd->dma.handle);
}
- return 0;
+ if (config->src_pool != ODP_POOL_INVALID)
+ (void)odp_pool_destroy(config->src_pool);
+
+ if (config->dst_pool != ODP_POOL_INVALID)
+ (void)odp_pool_destroy(config->dst_pool);
}
-static void free_dma_session(test_config_t *config)
+static void print_humanised(uint64_t value, const char *type)
{
- if (config->dma_config.handle != ODP_DMA_INVALID)
- (void)odp_dma_destroy(config->dma_config.handle);
+ if (value > GIGAS)
+ printf("%.2f G%s\n", (double)value / GIGAS, type);
+ else if (value > MEGAS)
+ printf("%.2f M%s\n", (double)value / MEGAS, type);
+ else if (value > KILOS)
+ printf("%.2f K%s\n", (double)value / KILOS, type);
+ else
+ printf("%" PRIu64 " %s\n", value, type);
+}
+
+static void print_stats(const prog_config_t *config)
+{
+ const stats_t *stats;
+ uint64_t data_cnt = config->num_in_segs * config->src_seg_len, tot_completed = 0U,
+ tot_tm = 0U, tot_trs_tm = 0U, tot_trs_cc = 0U, tot_trs_cnt = 0U, tot_min_tm = UINT64_MAX,
+ tot_max_tm = 0U, tot_min_cc = UINT64_MAX, tot_max_cc = 0U, avg_start_cc, avg_wait_cc,
+ avg_tot_tm;
+
+ printf("\n======================\n\n"
+ "DMA performance test done\n\n"
+ " mode: %s\n"
+ " input segment count: %u\n"
+ " output segment count: %u\n"
+ " segment length: %u\n"
+ " segment type: %s\n"
+ " inflight count: %u\n"
+ " session policy: %s\n\n",
+ config->trs_type == SYNC ? "synchronous" : config->compl_mode == POLL ?
+ "asynchronous-poll" : "asynchronous-event", config->num_in_segs,
+ config->num_out_segs, config->src_seg_len,
+ config->seg_type == PACKET ? "packet" : "memory", config->num_inflight,
+ config->policy == SINGLE ? "shared" : "per-worker");
+
+ for (int i = 0; i < config->num_workers; ++i) {
+ stats = &config->thread_config[i].stats;
+ tot_completed += stats->completed;
+ tot_tm += stats->tot_tm;
+ tot_trs_tm += stats->trs_tm;
+ tot_trs_cc += stats->trs_cc;
+ tot_trs_cnt += stats->trs_cnt;
+ tot_min_tm = MIN(tot_min_tm, stats->min_trs_tm);
+ tot_max_tm = MAX(tot_max_tm, stats->max_trs_tm);
+ tot_min_cc = MIN(tot_min_cc, stats->min_trs_cc);
+ tot_max_cc = MAX(tot_max_cc, stats->max_trs_cc);
+
+ printf(" worker %d:\n", i);
+ printf(" successful transfers: %" PRIu64 "\n"
+ " start errors: %" PRIu64 "\n",
+ stats->completed, stats->start_errs);
+
+ if (config->trs_type == ASYNC) {
+ if (config->compl_mode == POLL)
+ printf(" poll errors: %" PRIu64 "\n",
+ stats->poll_errs);
+ else
+ printf(" scheduler timeouts: %" PRIu64 "\n",
+ stats->scheduler_timeouts);
+ }
+
+ printf(" transfer errors: %" PRIu64 "\n"
+ " run time: %" PRIu64 " ns\n",
+ stats->transfer_errs, stats->tot_tm);
+
+ if (config->policy == MANY) {
+ printf(" DMA session:\n"
+ " average time per transfer: %" PRIu64 " "
+ "(min: %" PRIu64 ", max: %" PRIu64 ") ns\n"
+ " average cycles per transfer: %" PRIu64 " "
+ "(min: %" PRIu64 ", max: %" PRIu64 ")\n"
+ " ops: ",
+ stats->trs_cnt > 0U ? stats->trs_tm / stats->trs_cnt : 0U,
+ stats->trs_cnt > 0U ? stats->min_trs_tm : 0U,
+ stats->trs_cnt > 0U ? stats->max_trs_tm : 0U,
+ stats->trs_cnt > 0U ? stats->trs_cc / stats->trs_cnt : 0U,
+ stats->trs_cnt > 0U ? stats->min_trs_cc : 0U,
+ stats->trs_cnt > 0U ? stats->max_trs_cc : 0U);
+ print_humanised(stats->completed / (stats->tot_tm / ODP_TIME_SEC_IN_NS),
+ "OPS");
+ printf(" speed: ");
+ print_humanised(stats->completed * data_cnt /
+ (stats->tot_tm / ODP_TIME_SEC_IN_NS), "B/s");
+ }
+
+ avg_start_cc = stats->start_cnt > 0U ? stats->start_cc / stats->start_cnt : 0U;
+ printf(" average cycles breakdown:\n");
+
+ if (config->trs_type == SYNC) {
+ printf(" odp_dma_transfer(): %" PRIu64 " "
+ "(min: %" PRIu64 ", max: %" PRIu64 ")\n", avg_start_cc,
+ avg_start_cc > 0U ? stats->min_start_cc : 0U,
+ avg_start_cc > 0U ? stats->max_start_cc : 0U);
+ } else {
+ printf(" odp_dma_transfer_start(): %" PRIu64 " "
+ "(min: %" PRIu64 ", max: %" PRIu64 ")\n", avg_start_cc,
+ avg_start_cc > 0U ? stats->min_start_cc : 0U,
+ avg_start_cc > 0U ? stats->max_start_cc : 0U);
+
+ avg_wait_cc = stats->wait_cnt > 0U ? stats->wait_cc / stats->wait_cnt : 0U;
+
+ if (config->compl_mode == POLL) {
+ printf(" odp_dma_transfer_done(): %" PRIu64 ""
+ " (min: %" PRIu64 ", max: %" PRIu64 ", x %" PRIu64 ""
+ " per transfer)\n", avg_wait_cc,
+ avg_wait_cc > 0U ? stats->min_wait_cc : 0U,
+ avg_wait_cc > 0U ? stats->max_wait_cc : 0U,
+ stats->trs_cnt > 0U ?
+ stats->trs_poll_cnt / stats->trs_cnt : 0U);
+ } else {
+ printf(" odp_schedule(): %" PRIu64 " "
+ " (min: %" PRIu64 ", max: %" PRIu64 ")\n", avg_wait_cc,
+ avg_wait_cc > 0U ? stats->min_wait_cc : 0U,
+ avg_wait_cc > 0U ? stats->max_wait_cc : 0U);
+ }
+ }
+
+ printf("\n");
+ }
+
+ avg_tot_tm = tot_tm / config->num_workers / ODP_TIME_SEC_IN_NS;
+ printf(" total:\n"
+ " average time per transfer: %" PRIu64 " (min: %" PRIu64
+ ", max: %" PRIu64 ") ns\n"
+ " average cycles per transfer: %" PRIu64 " (min: %" PRIu64
+ ", max: %" PRIu64 ")\n"
+ " ops: ",
+ tot_trs_cnt > 0U ? tot_trs_tm / tot_trs_cnt : 0U,
+ tot_trs_cnt > 0U ? tot_min_tm : 0U,
+ tot_trs_cnt > 0U ? tot_max_tm : 0U,
+ tot_trs_cnt > 0U ? tot_trs_cc / tot_trs_cnt : 0U,
+ tot_trs_cnt > 0U ? tot_min_cc : 0U,
+ tot_trs_cnt > 0U ? tot_max_cc : 0U);
+ print_humanised(avg_tot_tm > 0U ? tot_completed / avg_tot_tm : 0U, "OPS");
+ printf(" speed: ");
+ print_humanised(avg_tot_tm > 0U ? tot_completed * data_cnt / avg_tot_tm : 0U, "B/s");
+ printf("\n");
+ printf("======================\n");
}
int main(int argc, char **argv)
{
odph_helper_options_t odph_opts;
- test_config_t test_config;
+ odp_init_t init_param;
odp_instance_t odp_instance;
+ odp_shm_t shm_cfg = ODP_SHM_INVALID;
+ parse_result_t parse_res;
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");
+ ODPH_ERR("Error while reading ODP helper options, exiting\n");
exit(EXIT_FAILURE);
}
- if (parse_options(argc, argv, &test_config))
- exit(EXIT_FAILURE);
+ odp_init_param_init(&init_param);
+ init_param.mem_model = odph_opts.mem_model;
- if (odp_init_global(&odp_instance, NULL, NULL)) {
- ODPH_ERR("ODP global init failed, exiting.\n");
+ if (odp_init_global(&odp_instance, &init_param, 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");
+ 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;
+ shm_cfg = odp_shm_reserve(PROG_NAME "_cfg", sizeof(prog_config_t), ODP_CACHE_LINE_SIZE,
+ 0U);
+
+ if (shm_cfg == ODP_SHM_INVALID) {
+ ODPH_ERR("Error reserving shared memory\n");
+ ret = EXIT_FAILURE;
+ goto out;
}
- setup_test_case_api(&test_config);
+ prog_conf = odp_shm_addr(shm_cfg);
- if (configure_dma_session(&test_config)) {
+ if (prog_conf == NULL) {
+ ODPH_ERR("Error resolving shared memory address\n");
ret = EXIT_FAILURE;
- goto out_dma;
+ goto out;
}
- if (test_config.test_case_api.setup_fn(&test_config)) {
+ parse_res = setup_program(argc, argv, prog_conf);
+
+ if (parse_res == PRS_NOK) {
ret = EXIT_FAILURE;
- goto out_test_case;
+ goto out;
+ }
+
+ if (parse_res == PRS_TERM) {
+ ret = EXIT_SUCCESS;
+ goto out;
}
- if (test_config.test_case_api.run_fn(&test_config) ||
- test_config.test_case_api.verify_fn(&test_config))
+ if (parse_res == PRS_NOT_SUP) {
+ ret = EXIT_NOT_SUP;
+ goto out;
+ }
+
+ if (odp_schedule_config(NULL) < 0) {
+ ODPH_ERR("Error configuring scheduler\n");
ret = EXIT_FAILURE;
+ goto out;
+ }
-out_test_case:
- test_config.test_case_api.free_fn(&test_config);
+ prog_conf->odp_instance = odp_instance;
+ odp_atomic_init_u32(&prog_conf->is_running, 1U);
-out_dma:
- free_dma_session(&test_config);
+ if (!setup_test(prog_conf)) {
+ ret = EXIT_FAILURE;
+ goto out_test;
+ }
+
+ if (prog_conf->time_sec) {
+ sleep(prog_conf->time_sec);
+ odp_atomic_store_u32(&prog_conf->is_running, 0U);
+ }
+
+ stop_test(prog_conf);
+ print_stats(prog_conf);
+
+out_test:
+ /* Release all resources that have been allocated during 'setup_test()'. */
+ teardown_test(prog_conf);
+
+out:
+ if (shm_cfg != ODP_SHM_INVALID)
+ (void)odp_shm_free(shm_cfg);
-out_odp:
if (odp_term_local()) {
- ODPH_ERR("ODP local terminate failed, exiting.\n");
+ 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");
+ ODPH_ERR("ODP global terminate failed, exiting\n");
exit(EXIT_FAILURE);
}
diff --git a/test/performance/odp_dma_perf_run.sh b/test/performance/odp_dma_perf_run.sh
index dc314d400..37bc4382f 100755
--- a/test/performance/odp_dma_perf_run.sh
+++ b/test/performance/odp_dma_perf_run.sh
@@ -1,14 +1,16 @@
#!/bin/sh
#
-# Copyright (c) 2022, Nokia
+# Copyright (c) 2022-2023, 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
+SEGC=0
+SEGS=1024
+INFL=1
+TIME=1
TESTS_RUN=0
check_result()
@@ -23,73 +25,24 @@ check_result()
fi
}
-echo "odp_dma_perf: synchronous transfer 1"
+echo "odp_dma_perf: synchronous transfer"
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
+${TEST_DIR}/${BIN_NAME}${EXEEXT} -t 0 -i $SEGC -o $SEGC -s $SEGS -S 0 -f $INFL -T $TIME
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
+${TEST_DIR}/${BIN_NAME}${EXEEXT} -t 1 -i $SEGC -o $SEGC -s $SEGS -S 1 -m 0 -f $INFL -T $TIME
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
+${TEST_DIR}/${BIN_NAME}${EXEEXT} -t 1 -i $SEGC -o $SEGC -s $SEGS -S 1 -m 1 -f $INFL -T $TIME
check_result $?
diff --git a/test/performance/odp_ipsec.c b/test/performance/odp_ipsec.c
index 50e26b1c9..677e7762f 100644
--- a/test/performance/odp_ipsec.c
+++ b/test/performance/odp_ipsec.c
@@ -930,7 +930,7 @@ run_measure_one_config(ipsec_args_t *cargs,
return -1;
}
- rc = odph_ipsec_alg_check(capa, config->crypto.cipher_alg,
+ rc = odph_ipsec_alg_check(&capa, config->crypto.cipher_alg,
config->crypto.cipher_key.length,
config->crypto.auth_alg,
config->crypto.auth_key.length);
diff --git a/test/performance/odp_ipsecfwd.c b/test/performance/odp_ipsecfwd.c
index a6df747f3..16c745afa 100644
--- a/test/performance/odp_ipsecfwd.c
+++ b/test/performance/odp_ipsecfwd.c
@@ -135,6 +135,7 @@ typedef struct prog_config_s {
fwd_entry_t fwd_entries[MAX_FWDS];
odp_queue_t sa_qs[MAX_SA_QUEUES];
pktio_t pktios[MAX_IFS];
+ odp_atomic_u32_t is_running;
sa_config_t default_cfg;
ops_t ops;
char *conf_file;
@@ -181,7 +182,7 @@ typedef struct {
uint8_t q_idx;
} pkt_ifs_t;
-static exposed_alg_t exposed_algs[] = {
+static const exposed_alg_t exposed_algs[] = {
ALG_ENTRY(ODP_CIPHER_ALG_NULL, CIPHER_TYPE),
ALG_ENTRY(ODP_CIPHER_ALG_DES, CIPHER_TYPE),
ALG_ENTRY(ODP_CIPHER_ALG_3DES_CBC, CIPHER_TYPE),
@@ -208,9 +209,9 @@ static exposed_alg_t exposed_algs[] = {
/* SPIs for in and out directions */
static odp_ipsec_sa_t *spi_to_sa_map[2U][MAX_SPIS];
-static odp_atomic_u32_t is_running;
static const int ipsec_out_mark;
static __thread pkt_ifs_t ifs;
+static prog_config_t *prog_conf;
static void init_config(prog_config_t *config)
{
@@ -226,7 +227,7 @@ static void init_config(prog_config_t *config)
static void terminate(int signal ODP_UNUSED)
{
- odp_atomic_store_u32(&is_running, 0U);
+ odp_atomic_store_u32(&prog_conf->is_running, 0U);
}
static void parse_interfaces(prog_config_t *config, const char *optarg)
@@ -1109,9 +1110,10 @@ static void parse_inbound(config_setting_t *cfg, sa_config_t *config)
config->sa_param.inbound.lookup_mode = val;
if (config_setting_lookup_string(cs, "lookup_dst_addr", &val_str) == CONFIG_TRUE) {
- odph_ipv4_addr_parse(&config->lkp_dst_ip, val_str);
- config->lkp_dst_ip = odp_cpu_to_be_32(config->lkp_dst_ip);
- config->sa_param.inbound.lookup_param.dst_addr = &config->lkp_dst_ip;
+ if (odph_ipv4_addr_parse(&config->lkp_dst_ip, val_str) == 0) {
+ config->lkp_dst_ip = odp_cpu_to_be_32(config->lkp_dst_ip);
+ config->sa_param.inbound.lookup_param.dst_addr = &config->lkp_dst_ip;
+ }
}
if (config_setting_lookup_int(cs, "antireplay_ws", &val) == CONFIG_TRUE)
@@ -1134,15 +1136,17 @@ static void parse_outbound(config_setting_t *cfg, sa_config_t *config)
if (tunnel != NULL) {
if (config_setting_lookup_string(tunnel, "src_addr", &val_str) == CONFIG_TRUE) {
- odph_ipv4_addr_parse(&config->src_ip, val_str);
- config->src_ip = odp_cpu_to_be_32(config->src_ip);
- config->sa_param.outbound.tunnel.ipv4.src_addr = &config->src_ip;
+ if (odph_ipv4_addr_parse(&config->src_ip, val_str) == 0) {
+ config->src_ip = odp_cpu_to_be_32(config->src_ip);
+ config->sa_param.outbound.tunnel.ipv4.src_addr = &config->src_ip;
+ }
}
if (config_setting_lookup_string(tunnel, "dst_addr", &val_str) == CONFIG_TRUE) {
- odph_ipv4_addr_parse(&config->dst_ip, val_str);
- config->dst_ip = odp_cpu_to_be_32(config->dst_ip);
- config->sa_param.outbound.tunnel.ipv4.dst_addr = &config->dst_ip;
+ if (odph_ipv4_addr_parse(&config->dst_ip, val_str) == 0) {
+ config->dst_ip = odp_cpu_to_be_32(config->dst_ip);
+ config->sa_param.outbound.tunnel.ipv4.dst_addr = &config->dst_ip;
+ }
}
if (config_setting_lookup_int(tunnel, "dscp", &val) == CONFIG_TRUE)
@@ -1744,6 +1748,7 @@ static int process_packets(void *args)
int thr_idx = odp_thread_id();
odp_event_t evs[MAX_BURST], ev;
ops_t ops = config->prog_config->ops;
+ odp_atomic_u32_t *is_running = &config->prog_config->is_running;
uint32_t cnt;
odp_event_type_t type;
odp_event_subtype_t subtype;
@@ -1756,7 +1761,7 @@ static int process_packets(void *args)
config->thr_idx = thr_idx;
odp_barrier_wait(&config->prog_config->init_barrier);
- while (odp_atomic_load_u32(&is_running)) {
+ while (odp_atomic_load_u32(is_running)) {
int num_pkts_in = 0, num_pkts_ips = 0;
/* TODO: Add possibility to configure scheduler and ipsec enq/deq burst sizes. */
cnt = ops.rx(config, evs, MAX_BURST);
@@ -1943,12 +1948,24 @@ static void print_stats(const prog_config_t *config)
int main(int argc, char **argv)
{
+ odph_helper_options_t odph_opts;
+ odp_init_t init_param;
odp_instance_t odp_instance;
+ odp_shm_t shm_cfg = ODP_SHM_INVALID;
parse_result_t parse_res;
- prog_config_t config;
int ret = EXIT_SUCCESS;
- if (odp_init_global(&odp_instance, NULL, NULL) < 0) {
+ argc = odph_parse_options(argc, argv);
+
+ if (odph_options(&odph_opts) == -1) {
+ ODPH_ERR("Error while reading ODP helper options, exiting\n");
+ exit(EXIT_FAILURE);
+ }
+
+ odp_init_param_init(&init_param);
+ init_param.mem_model = odph_opts.mem_model;
+
+ if (odp_init_global(&odp_instance, &init_param, NULL) < 0) {
ODPH_ERR("ODP global init failed, exiting\n");
exit(EXIT_FAILURE);
}
@@ -1958,15 +1975,32 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
- init_config(&config);
+ shm_cfg = odp_shm_reserve(PROG_NAME "_cfg", sizeof(prog_config_t), ODP_CACHE_LINE_SIZE,
+ 0U);
- if (!config.is_dir_rx && odp_schedule_config(NULL) < 0) {
+ if (shm_cfg == ODP_SHM_INVALID) {
+ ODPH_ERR("Error reserving shared memory\n");
+ ret = EXIT_FAILURE;
+ goto out;
+ }
+
+ prog_conf = odp_shm_addr(shm_cfg);
+
+ if (prog_conf == NULL) {
+ ODPH_ERR("Error resolving shared memory address\n");
+ ret = EXIT_FAILURE;
+ goto out;
+ }
+
+ init_config(prog_conf);
+
+ if (!prog_conf->is_dir_rx && odp_schedule_config(NULL) < 0) {
ODPH_ERR("Error configuring scheduler\n");
ret = EXIT_FAILURE;
goto out_test;
}
- parse_res = setup_program(argc, argv, &config);
+ parse_res = setup_program(argc, argv, prog_conf);
if (parse_res == PRS_NOK) {
ret = EXIT_FAILURE;
@@ -1978,22 +2012,26 @@ int main(int argc, char **argv)
goto out_test;
}
- config.odp_instance = odp_instance;
- odp_atomic_init_u32(&is_running, 1U);
+ prog_conf->odp_instance = odp_instance;
+ odp_atomic_init_u32(&prog_conf->is_running, 1U);
- if (!setup_test(&config)) {
+ if (!setup_test(prog_conf)) {
ret = EXIT_FAILURE;
goto out_test;
}
- while (odp_atomic_load_u32(&is_running))
+ while (odp_atomic_load_u32(&prog_conf->is_running))
odp_cpu_pause();
- stop_test(&config);
- print_stats(&config);
+ stop_test(prog_conf);
+ print_stats(prog_conf);
out_test:
- teardown_test(&config);
+ teardown_test(prog_conf);
+
+out:
+ if (shm_cfg != ODP_SHM_INVALID)
+ (void)odp_shm_free(shm_cfg);
if (odp_term_local() < 0) {
ODPH_ERR("ODP local terminate failed, exiting\n");
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index ab36a4ebe..27b8d4821 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -1948,7 +1948,7 @@ static void create_groups(int num, odp_schedule_group_t *group)
}
}
-static int set_vector_pool_params(odp_pool_param_t *params, odp_pool_capability_t pool_capa)
+static int set_vector_pool_params(odp_pool_param_t *params, const odp_pool_capability_t *pool_capa)
{
uint32_t num_vec, vec_size;
@@ -1957,14 +1957,14 @@ static int set_vector_pool_params(odp_pool_param_t *params, odp_pool_capability_
else
vec_size = gbl_args->appl.vec_size;
- ODPH_ASSERT(pool_capa.vector.max_size > 0);
- if (vec_size > pool_capa.vector.max_size) {
+ ODPH_ASSERT(pool_capa->vector.max_size > 0);
+ if (vec_size > pool_capa->vector.max_size) {
if (gbl_args->appl.vec_size == 0) {
- vec_size = pool_capa.vector.max_size;
+ vec_size = pool_capa->vector.max_size;
printf("\nWarning: Vector size reduced to %u\n\n", vec_size);
} else {
ODPH_ERR("Vector size too big %u. Maximum is %u.\n",
- vec_size, pool_capa.vector.max_size);
+ vec_size, pool_capa->vector.max_size);
return -1;
}
}
@@ -1978,13 +1978,13 @@ static int set_vector_pool_params(odp_pool_param_t *params, odp_pool_capability_
num_vec = gbl_args->appl.num_vec;
}
- if (pool_capa.vector.max_num && num_vec > pool_capa.vector.max_num) {
+ if (pool_capa->vector.max_num && num_vec > pool_capa->vector.max_num) {
if (gbl_args->appl.num_vec == 0) {
- num_vec = pool_capa.vector.max_num;
+ num_vec = pool_capa->vector.max_num;
printf("\nWarning: number of vectors reduced to %u\n\n", num_vec);
} else {
ODPH_ERR("Too many vectors (%u) per pool. Maximum is %u.\n",
- num_vec, pool_capa.vector.max_num);
+ num_vec, pool_capa->vector.max_num);
return -1;
}
}
@@ -2197,7 +2197,7 @@ int main(int argc, char *argv[])
}
odp_pool_param_init(&params);
- if (set_vector_pool_params(&params, pool_capa))
+ if (set_vector_pool_params(&params, &pool_capa))
return -1;
gbl_args->vector_num = params.vector.num;
diff --git a/test/performance/odp_sched_pktio.c b/test/performance/odp_sched_pktio.c
index d82dce12f..1333e66e4 100644
--- a/test/performance/odp_sched_pktio.c
+++ b/test/performance/odp_sched_pktio.c
@@ -424,7 +424,7 @@ static int worker_thread_timers(void *arg)
odp_queue_t queue;
pktin_queue_context_t *queue_context;
odp_timer_t timer;
- odp_timer_set_t ret;
+ odp_timer_retval_t ret;
odp_timer_start_t start_param;
worker_arg_t *worker_arg = arg;
test_global_t *test_global = worker_arg->test_global_ptr;
@@ -1326,7 +1326,7 @@ static int start_timers(test_global_t *test_global)
int i, j;
odp_timeout_t timeout;
odp_timer_t timer;
- odp_timer_set_t ret;
+ odp_timer_retval_t ret;
odp_timer_start_t start_param;
uint64_t timeout_tick = test_global->timer.timeout_tick;
int num_pktio = test_global->opt.num_pktio;
diff --git a/test/performance/odp_timer_perf.c b/test/performance/odp_timer_perf.c
index 3df9a875f..a7d98e68f 100644
--- a/test/performance/odp_timer_perf.c
+++ b/test/performance/odp_timer_perf.c
@@ -644,7 +644,7 @@ static void cancel_timers(test_global_t *global, uint32_t worker_idx)
if (timer == ODP_TIMER_INVALID)
continue;
- if (odp_timer_cancel(timer, &ev) == 0)
+ if (odp_timer_cancel(timer, &ev) == ODP_TIMER_SUCCESS)
odp_event_free(ev);
}
}
@@ -753,8 +753,14 @@ static int set_cancel_mode_worker(void *arg)
status = odp_timer_cancel(timer, &ev);
num_cancel++;
- if (status < 0)
+ if (odp_unlikely(status == ODP_TIMER_TOO_NEAR)) {
continue;
+ } else if (odp_unlikely(status != ODP_TIMER_SUCCESS)) {
+ ODPH_ERR("Timer (%u/%u) cancel failed (ret %i)\n", i, j,
+ status);
+ ret = -1;
+ break;
+ }
start_param.tick_type = ODP_TIMER_TICK_ABS;
start_param.tick = tick + j * period_tick;
diff --git a/test/validation/api/Makefile.am b/test/validation/api/Makefile.am
index c08ff3d6e..ade387152 100644
--- a/test/validation/api/Makefile.am
+++ b/test/validation/api/Makefile.am
@@ -54,6 +54,7 @@ TESTS = \
init/init_feature_enabled$(EXEEXT) \
init/init_feature_disabled$(EXEEXT) \
init/init_test_param_init$(EXEEXT) \
+ init/init_test_term_abnormal$(EXEEXT) \
ipsec/ipsec_sync$(EXEEXT) \
ipsec/ipsec_async$(EXEEXT) \
ipsec/ipsec_inline_in$(EXEEXT) \
diff --git a/test/validation/api/atomic/atomic.c b/test/validation/api/atomic/atomic.c
index cbdd219fc..17d9dc82a 100644
--- a/test/validation/api/atomic/atomic.c
+++ b/test/validation/api/atomic/atomic.c
@@ -974,7 +974,7 @@ static int atomic_init(odp_instance_t *inst)
odph_helper_options_t helper_options;
if (odph_options(&helper_options)) {
- fprintf(stderr, "error: odph_options() failed.\n");
+ ODPH_ERR("odph_options() failed\n");
return -1;
}
@@ -982,18 +982,18 @@ static int atomic_init(odp_instance_t *inst)
init_param.mem_model = helper_options.mem_model;
if (0 != odp_init_global(inst, &init_param, NULL)) {
- fprintf(stderr, "error: odp_init_global() failed.\n");
+ ODPH_ERR("odp_init_global() failed\n");
return -1;
}
if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) {
- fprintf(stderr, "error: odp_init_local() failed.\n");
+ ODPH_ERR("odp_init_local() failed\n");
return -1;
}
global_shm = odp_shm_reserve(GLOBAL_SHM_NAME,
sizeof(global_shared_mem_t), 64, 0);
if (ODP_SHM_INVALID == global_shm) {
- fprintf(stderr, "Unable reserve memory for global_shm\n");
+ ODPH_ERR("Unable to reserve memory for global_shm\n");
return -1;
}
@@ -1029,17 +1029,17 @@ static int atomic_term(odp_instance_t inst)
shm = odp_shm_lookup(GLOBAL_SHM_NAME);
if (0 != odp_shm_free(shm)) {
- fprintf(stderr, "error: odp_shm_free() failed.\n");
+ ODPH_ERR("odp_shm_free() failed\n");
return -1;
}
if (0 != odp_term_local()) {
- fprintf(stderr, "error: odp_term_local() failed.\n");
+ ODPH_ERR("odp_term_local() failed\n");
return -1;
}
if (0 != odp_term_global(inst)) {
- fprintf(stderr, "error: odp_term_global() failed.\n");
+ ODPH_ERR("odp_term_global() failed\n");
return -1;
}
diff --git a/test/validation/api/barrier/barrier.c b/test/validation/api/barrier/barrier.c
index e0665b7cf..610b5db70 100644
--- a/test/validation/api/barrier/barrier.c
+++ b/test/validation/api/barrier/barrier.c
@@ -305,7 +305,7 @@ static int barrier_init(odp_instance_t *inst)
odph_helper_options_t helper_options;
if (odph_options(&helper_options)) {
- fprintf(stderr, "error: odph_options() failed.\n");
+ ODPH_ERR("odph_options() failed\n");
return -1;
}
@@ -313,18 +313,18 @@ static int barrier_init(odp_instance_t *inst)
init_param.mem_model = helper_options.mem_model;
if (0 != odp_init_global(inst, &init_param, NULL)) {
- fprintf(stderr, "error: odp_init_global() failed.\n");
+ ODPH_ERR("odp_init_global() failed\n");
return -1;
}
if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) {
- fprintf(stderr, "error: odp_init_local() failed.\n");
+ ODPH_ERR("odp_init_local() failed\n");
return -1;
}
global_shm = odp_shm_reserve(GLOBAL_SHM_NAME,
sizeof(global_shared_mem_t), 64, 0);
if (ODP_SHM_INVALID == global_shm) {
- fprintf(stderr, "Unable reserve memory for global_shm\n");
+ ODPH_ERR("Unable to reserve memory for global_shm\n");
return -1;
}
@@ -360,17 +360,17 @@ static int barrier_term(odp_instance_t inst)
shm = odp_shm_lookup(GLOBAL_SHM_NAME);
if (0 != odp_shm_free(shm)) {
- fprintf(stderr, "error: odp_shm_free() failed.\n");
+ ODPH_ERR("odp_shm_free() failed\n");
return -1;
}
if (0 != odp_term_local()) {
- fprintf(stderr, "error: odp_term_local() failed.\n");
+ ODPH_ERR("odp_term_local() failed\n");
return -1;
}
if (0 != odp_term_global(inst)) {
- fprintf(stderr, "error: odp_term_global() failed.\n");
+ ODPH_ERR("odp_term_global() failed\n");
return -1;
}
diff --git a/test/validation/api/buffer/buffer.c b/test/validation/api/buffer/buffer.c
index 2d9632342..ef26ea6e0 100644
--- a/test/validation/api/buffer/buffer.c
+++ b/test/validation/api/buffer/buffer.c
@@ -23,7 +23,7 @@ static int buffer_suite_init(void)
uint32_t size, num, align;
if (odp_pool_capability(&pool_capa)) {
- printf("pool capability failed\n");
+ ODPH_ERR("Pool capability failed\n");
return -1;
}
@@ -111,7 +111,7 @@ static void test_pool_alloc_free(const odp_pool_param_t *param)
wrong_align = true;
if (wrong_type || wrong_subtype || wrong_size || wrong_align) {
- printf("Buffer has error\n");
+ ODPH_ERR("Buffer has error\n");
odp_buffer_print(buffer[i]);
break;
}
@@ -200,7 +200,7 @@ static void test_pool_alloc_free_multi(const odp_pool_param_t *param)
wrong_align = true;
if (wrong_type || wrong_subtype || wrong_size || wrong_align) {
- printf("Buffer has error\n");
+ ODPH_ERR("Buffer has error\n");
odp_buffer_print(buffer[i]);
break;
}
@@ -351,7 +351,7 @@ static void test_pool_max_pools(odp_pool_param_t *param)
CU_ASSERT(num_pool == max_pools);
if (num_pool != max_pools)
- printf("Error: created only %u pools\n", num_pool);
+ ODPH_ERR("Created only %u pools\n", num_pool);
for (i = 0; i < num_pool; i++) {
buffer[i] = odp_buffer_alloc(pool[i]);
@@ -536,6 +536,8 @@ static void buffer_test_user_area(void)
CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
for (i = 0; i < num; i++) {
+ odp_event_t ev;
+
buffer[i] = odp_buffer_alloc(pool);
if (buffer[i] == ODP_BUFFER_INVALID)
@@ -546,6 +548,9 @@ static void buffer_test_user_area(void)
CU_ASSERT_FATAL(addr != NULL);
CU_ASSERT(prev != addr);
+ ev = odp_buffer_to_event(buffer[i]);
+ CU_ASSERT(odp_event_user_area(ev) == addr);
+
prev = addr;
memset(addr, 0, size);
}
diff --git a/test/validation/api/classification/odp_classification_tests.c b/test/validation/api/classification/odp_classification_tests.c
index 002beb2aa..84dfcf562 100644
--- a/test/validation/api/classification/odp_classification_tests.c
+++ b/test/validation/api/classification/odp_classification_tests.c
@@ -70,7 +70,7 @@ static int classification_suite_common_init(odp_bool_t enable_pktv)
ret = odp_pktio_capability(pktio_loop, &pktio_capa);
if (ret) {
- fprintf(stderr, "unable to get pktio capability.\n");
+ ODPH_ERR("Unable to get pktio capability\n");
return -1;
}
diff --git a/test/validation/api/comp/comp.c b/test/validation/api/comp/comp.c
index 88a61da95..cb771c989 100644
--- a/test/validation/api/comp/comp.c
+++ b/test/validation/api/comp/comp.c
@@ -5,6 +5,8 @@
*/
#include <odp_api.h>
+#include <odp/helper/odph_api.h>
+
#include <odp_cunit_common.h>
#include "test_vectors.h"
@@ -68,7 +70,7 @@ static int check_comp_alg_support(odp_comp_alg_t comp,
return ODP_TEST_INACTIVE;
break;
default:
- fprintf(stderr, "Unsupported compression algorithm\n");
+ ODPH_ERR("Unsupported compression algorithm\n");
return ODP_TEST_INACTIVE;
}
@@ -87,7 +89,7 @@ static int check_comp_alg_support(odp_comp_alg_t comp,
return ODP_TEST_INACTIVE;
break;
default:
- fprintf(stderr, "Unsupported hash algorithm\n");
+ ODPH_ERR("Unsupported hash algorithm\n");
return ODP_TEST_INACTIVE;
}
@@ -475,17 +477,17 @@ static int comp_init(odp_instance_t *inst)
odp_pool_capability_t pool_capa;
if (0 != odp_init_global(inst, NULL, NULL)) {
- fprintf(stderr, "error: odp_init_global() failed.\n");
+ ODPH_ERR("odp_init_global() failed\n");
return -1;
}
if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) {
- fprintf(stderr, "error: odp_init_local() failed.\n");
+ ODPH_ERR("odp_init_local() failed\n");
return -1;
}
if (odp_pool_capability(&pool_capa) < 0) {
- fprintf(stderr, "error: odp_pool_capability() failed.\n");
+ ODPH_ERR("odp_pool_capability() failed\n");
return -1;
}
@@ -497,20 +499,20 @@ static int comp_init(odp_instance_t *inst)
if (pool_capa.pkt.max_seg_len &&
TEST_PKT_LEN > pool_capa.pkt.max_seg_len) {
- fprintf(stderr, "Warning: small packet segment length\n");
+ ODPH_ERR("Warning: small packet segment length\n");
params.pkt.seg_len = pool_capa.pkt.max_seg_len;
}
pool = odp_pool_create(COMP_PACKET_POOL, &params);
if (ODP_POOL_INVALID == pool) {
- fprintf(stderr, "Packet pool creation failed.\n");
+ ODPH_ERR("Packet pool creation failed\n");
return -1;
}
/* Queue to store compression/decompression events */
out_queue = odp_queue_create(COMP_OUT_QUEUE, NULL);
if (ODP_QUEUE_INVALID == out_queue) {
- fprintf(stderr, "Comp outq creation failed.\n");
+ ODPH_ERR("Comp outq creation failed\n");
return -1;
}
@@ -525,26 +527,26 @@ static int comp_term(odp_instance_t inst)
out_queue = odp_queue_lookup(COMP_OUT_QUEUE);
if (ODP_QUEUE_INVALID != out_queue) {
if (odp_queue_destroy(out_queue))
- fprintf(stderr, "Comp outq destroy failed.\n");
+ ODPH_ERR("Comp outq destroy failed\n");
} else {
- fprintf(stderr, "Comp outq not found.\n");
+ ODPH_ERR("Comp outq not found\n");
}
pool = odp_pool_lookup(COMP_PACKET_POOL);
if (ODP_POOL_INVALID != pool) {
if (odp_pool_destroy(pool))
- fprintf(stderr, "Packet pool destroy failed.\n");
+ ODPH_ERR("Packet pool destroy failed\n");
} else {
- fprintf(stderr, "Packet pool not found.\n");
+ ODPH_ERR("Packet pool not found\n");
}
if (0 != odp_term_local()) {
- fprintf(stderr, "error: odp_term_local() failed.\n");
+ ODPH_ERR("odp_term_local() failed\n");
return -1;
}
if (0 != odp_term_global(inst)) {
- fprintf(stderr, "error: odp_term_global() failed.\n");
+ ODPH_ERR("odp_term_global() failed\n");
return -1;
}
diff --git a/test/validation/api/crypto/Makefile.am b/test/validation/api/crypto/Makefile.am
index e438ec8ca..ead21a336 100644
--- a/test/validation/api/crypto/Makefile.am
+++ b/test/validation/api/crypto/Makefile.am
@@ -3,6 +3,12 @@ include ../Makefile.inc
test_PROGRAMS = crypto_main
crypto_main_SOURCES = \
odp_crypto_test_inp.c \
+ crypto_op_test.c \
+ crypto_op_test.h \
test_vectors.h \
- test_vectors_len.h
+ test_vectors_len.h \
+ test_vector_defs.h \
+ util.h \
+ util.c
+
PRELDADD += $(LIBPACKET_COMMON)
diff --git a/test/validation/api/crypto/crypto_op_test.c b/test/validation/api/crypto/crypto_op_test.c
new file mode 100644
index 000000000..4ad333488
--- /dev/null
+++ b/test/validation/api/crypto/crypto_op_test.c
@@ -0,0 +1,571 @@
+/* Copyright (c) 2014-2018, Linaro Limited
+ * Copyright (c) 2021-2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <odp_api.h>
+#include <odp_cunit_common.h>
+#include <packet_common.h>
+#include "crypto_op_test.h"
+#include "util.h"
+
+#define MAX_FAILURE_PRINTS 20
+
+#define MAX_IGNORED_RANGES 3
+
+/*
+ * Output packet parts that we ignore since they have undefined values
+ */
+typedef struct ignore_t {
+ uint32_t byte_offset; /* offset to a byte which has bits to be ignored */
+ uint8_t byte_mask; /* mask of ignored bits in the byte */
+ struct {
+ uint32_t offset;
+ uint32_t length;
+ } ranges[MAX_IGNORED_RANGES]; /* byte ranges to be ignored */
+ uint32_t num_ranges;
+} ignore_t;
+
+/* Add room for bytes that are not included in ref->length */
+#define MAX_EXP_DATA_LEN (MAX_DATA_LEN + 200)
+
+/*
+ * Expected packet data
+ */
+typedef struct expected_t {
+ uint8_t data[MAX_EXP_DATA_LEN];
+ uint32_t len;
+ ignore_t ignore;
+} expected_t;
+
+int crypto_op(odp_packet_t pkt_in,
+ odp_packet_t *pkt_out,
+ odp_bool_t *ok,
+ const odp_crypto_packet_op_param_t *op_params,
+ odp_crypto_op_type_t op_type)
+{
+ int rc;
+ odp_event_t event;
+ odp_crypto_packet_result_t result;
+ odp_event_subtype_t subtype;
+ odp_packet_t orig_pkt_out;
+
+ if (op_type == ODP_CRYPTO_OP_TYPE_LEGACY)
+ *pkt_out = pkt_in;
+ else if (op_type == ODP_CRYPTO_OP_TYPE_BASIC)
+ *pkt_out = ODP_PACKET_INVALID;
+ orig_pkt_out = *pkt_out;
+
+ if (suite_context.op_mode == ODP_CRYPTO_SYNC) {
+ rc = odp_crypto_op(&pkt_in, pkt_out, op_params, 1);
+ if (rc <= 0) {
+ CU_FAIL("Failed odp_crypto_packet_op()");
+ goto fail;
+ }
+ } else {
+ odp_packet_t *out_param = pkt_out;
+
+ if (op_type == ODP_CRYPTO_OP_TYPE_BASIC)
+ out_param = NULL;
+
+ rc = odp_crypto_op_enq(&pkt_in, out_param, op_params, 1);
+ if (rc <= 0) {
+ CU_FAIL("Failed odp_crypto_op_enq()");
+ goto fail;
+ }
+
+ /* Get crypto completion event from compl_queue. */
+ CU_ASSERT_FATAL(NULL != suite_context.compl_queue_deq);
+ do {
+ event = suite_context.compl_queue_deq();
+ } while (event == ODP_EVENT_INVALID);
+
+ CU_ASSERT(ODP_EVENT_PACKET == odp_event_type(event));
+ CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == odp_event_subtype(event));
+ CU_ASSERT(ODP_EVENT_PACKET == odp_event_types(event, &subtype));
+ CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == subtype);
+
+ *pkt_out = odp_crypto_packet_from_event(event);
+ }
+
+ if (op_type != ODP_CRYPTO_OP_TYPE_BASIC)
+ CU_ASSERT(*pkt_out == orig_pkt_out);
+ CU_ASSERT(ODP_EVENT_PACKET ==
+ odp_event_type(odp_packet_to_event(*pkt_out)));
+ CU_ASSERT(ODP_EVENT_PACKET_CRYPTO ==
+ odp_event_subtype(odp_packet_to_event(*pkt_out)));
+ CU_ASSERT(ODP_EVENT_PACKET ==
+ odp_event_types(odp_packet_to_event(*pkt_out), &subtype));
+ CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == subtype);
+ CU_ASSERT(odp_packet_subtype(*pkt_out) == ODP_EVENT_PACKET_CRYPTO);
+
+ rc = odp_crypto_result(&result, *pkt_out);
+ if (rc < -1)
+ CU_FAIL("Failed odp_crypto_result()");
+ CU_ASSERT(rc == 0 || rc == -1);
+
+ if (op_type == ODP_CRYPTO_OP_TYPE_OOP &&
+ suite_context.op_mode == ODP_CRYPTO_ASYNC)
+ CU_ASSERT(result.pkt_in == pkt_in);
+
+ *ok = (rc == 0);
+
+#if ODP_DEPRECATED_API
+ CU_ASSERT(*ok == result.ok);
+#endif
+
+ return 0;
+fail:
+ odp_packet_free(pkt_in);
+ if (op_type == ODP_CRYPTO_OP_TYPE_OOP)
+ odp_packet_free(*pkt_out);
+ return -1;
+}
+
+/*
+ * Try to adjust packet so that the first segment holds 'first_seg_len' bytes
+ * of packet data (+ tailroom if first_seg_len is longer than the packet).
+ *
+ * If 'first_seg_len' is zero, do not try to add segments but make headroom
+ * zero.
+ *
+ * Packet data bytes are not preserved.
+ */
+static void adjust_segments(odp_packet_t *pkt, uint32_t first_seg_len)
+{
+ uint32_t shift;
+
+ shift = odp_packet_headroom(*pkt) + first_seg_len;
+
+ if (odp_packet_extend_head(pkt, shift, NULL, NULL) < 0) {
+ CU_FAIL("odp_packet_extend_head() failed\n");
+ return;
+ }
+ if (odp_packet_trunc_tail(pkt, shift, NULL, NULL) < 0) {
+ CU_FAIL("odp_packet_trunc_tail() failed\n");
+ return;
+ }
+ /*
+ * ODP API does not seem to guarantee that we ever have a multi-segment
+ * packet at this point, but we can print a message about it.
+ */
+ if (first_seg_len == 1 &&
+ first_seg_len != odp_packet_seg_len(*pkt))
+ printf("Could not create a segmented packet for testing.\n");
+}
+
+static void write_header_and_trailer(odp_packet_t pkt,
+ uint32_t header_len, uint32_t trailer_len)
+{
+ uint32_t trailer_offset = odp_packet_len(pkt) - trailer_len;
+ uint32_t max_len = header_len > trailer_len ? header_len : trailer_len;
+ uint8_t buffer[max_len];
+ int rc;
+
+ fill_with_pattern(buffer, sizeof(buffer));
+
+ rc = odp_packet_copy_from_mem(pkt, 0, header_len, buffer);
+ CU_ASSERT(rc == 0);
+ rc = odp_packet_copy_from_mem(pkt, trailer_offset, trailer_len, buffer);
+ CU_ASSERT(rc == 0);
+}
+
+static void prepare_crypto_ranges(const crypto_op_test_param_t *param,
+ odp_packet_data_range_t *cipher_range,
+ odp_packet_data_range_t *auth_range)
+{
+ odp_packet_data_range_t zero_range = {.offset = 0, .length = 0};
+ uint32_t c_scale = param->is_bit_mode_cipher ? 8 : 1;
+ uint32_t a_scale = param->is_bit_mode_auth ? 8 : 1;
+
+ *cipher_range = param->cipher_range;
+ *auth_range = param->auth_range;
+ cipher_range->offset += c_scale * param->header_len;
+ auth_range->offset += a_scale * param->header_len;
+
+ if (param->ref->cipher == ODP_CIPHER_ALG_NULL)
+ *cipher_range = zero_range;
+ if (param->ref->auth == ODP_AUTH_ALG_NULL)
+ *auth_range = zero_range;
+}
+
+static int prepare_input_packet(const crypto_op_test_param_t *param,
+ odp_packet_t *pkt_in)
+{
+ crypto_test_reference_t *ref = param->ref;
+ uint32_t reflength = ref_length_in_bytes(ref);
+ odp_packet_t pkt;
+ uint32_t digest_offset = param->digest_offset;
+ uint32_t pkt_len;
+
+ pkt_len = param->header_len + reflength + param->trailer_len;
+ if (param->digest_offset == param->header_len + reflength)
+ pkt_len += ref->digest_length;
+
+ pkt = odp_packet_alloc(suite_context.pool, pkt_len);
+
+ CU_ASSERT(pkt != ODP_PACKET_INVALID);
+ if (pkt == ODP_PACKET_INVALID)
+ return -1;
+
+ if (param->adjust_segmentation)
+ adjust_segments(&pkt, param->first_seg_len);
+
+ write_header_and_trailer(pkt, param->header_len, param->trailer_len);
+
+ if (param->op == ODP_CRYPTO_OP_ENCODE) {
+ odp_packet_copy_from_mem(pkt, param->header_len,
+ reflength, ref->plaintext);
+ } else {
+ odp_packet_copy_from_mem(pkt, param->header_len,
+ reflength, ref->ciphertext);
+ odp_packet_copy_from_mem(pkt, digest_offset,
+ ref->digest_length,
+ ref->digest);
+ if (param->wrong_digest) {
+ uint8_t byte = ~ref->digest[0];
+
+ odp_packet_copy_from_mem(pkt, digest_offset, 1, &byte);
+ }
+ }
+ *pkt_in = pkt;
+ return 0;
+}
+
+static void prepare_oop_output_packet(const crypto_op_test_param_t *param,
+ odp_packet_t *pkt_out,
+ uint32_t pkt_len)
+{
+ uint32_t reflength = ref_length_in_bytes(param->ref);
+ const uint32_t oop_extra_len = 5;
+ uint32_t trl_len;
+ uint32_t hdr_len;
+ uint32_t oop_len;
+
+ oop_len = pkt_len + param->oop_shift + oop_extra_len;
+ *pkt_out = odp_packet_alloc(suite_context.pool, oop_len);
+ CU_ASSERT_FATAL(*pkt_out != ODP_PACKET_INVALID);
+
+ uint8_t buf[oop_len];
+
+ memset(buf, 0x55, sizeof(buf));
+ odp_packet_copy_from_mem(*pkt_out, 0, sizeof(buf), buf);
+
+ hdr_len = param->header_len + param->oop_shift;
+ trl_len = oop_len - hdr_len - reflength;
+
+ write_header_and_trailer(*pkt_out, hdr_len, trl_len);
+
+ /* have different metadata than in the input packet */
+ memset(odp_packet_user_area(*pkt_out), 0xab,
+ odp_packet_user_area_size(*pkt_out));
+}
+
+static int is_packet_data_equal(odp_packet_t pkt_1, odp_packet_t pkt_2)
+{
+ uint32_t len = odp_packet_len(pkt_1);
+ uint8_t buf_1[len];
+ uint8_t buf_2[len];
+
+ if (len != odp_packet_len(pkt_2) ||
+ odp_packet_copy_to_mem(pkt_1, 0, len, buf_1) ||
+ odp_packet_copy_to_mem(pkt_2, 0, len, buf_2))
+ return 0;
+
+ return !memcmp(buf_1, buf_2, len);
+}
+
+static int is_in_range(uint32_t offs, uint32_t range_offs, uint32_t range_len)
+{
+ return offs >= range_offs && offs < range_offs + range_len;
+}
+
+static void add_ignored_range(ignore_t *ign, uint32_t offs, uint32_t len)
+{
+ if (len == 0)
+ return;
+ CU_ASSERT_FATAL(ign->num_ranges < MAX_IGNORED_RANGES);
+ ign->ranges[ign->num_ranges].offset = offs;
+ ign->ranges[ign->num_ranges].length = len;
+ ign->num_ranges++;
+}
+
+static void clear_ignored_data(const ignore_t *ign, uint8_t *data, uint32_t data_len)
+{
+ CU_ASSERT_FATAL(ign->byte_offset < data_len);
+ data[ign->byte_offset] &= ~ign->byte_mask;
+
+ for (uint32_t n = 0; n < ign->num_ranges; n++) {
+ uint32_t offset = ign->ranges[n].offset;
+ uint32_t length = ign->ranges[n].length;
+
+ CU_ASSERT(offset + length <= data_len);
+ memset(data + offset, 0, length);
+ }
+}
+
+static void prepare_ignore_info(const crypto_op_test_param_t *param,
+ uint32_t shift,
+ uint32_t cipher_offset,
+ uint32_t cipher_len,
+ uint32_t auth_offset,
+ uint32_t auth_len,
+ ignore_t *ignore)
+{
+ memset(ignore, 0, sizeof(*ignore));
+
+ /*
+ * Leftover bits in the last byte of the cipher range of bit mode
+ * ciphers have undefined values.
+ */
+ if (param->is_bit_mode_cipher &&
+ param->ref->cipher != ODP_CIPHER_ALG_NULL) {
+ uint8_t leftover_bits = ref_length_in_bits(param->ref) % 8;
+
+ ignore->byte_offset = cipher_offset + cipher_len - 1 + shift;
+ if (leftover_bits > 0)
+ ignore->byte_mask = ~(0xff << (8 - leftover_bits));
+ else
+ ignore->byte_mask = 0;
+ }
+
+ /*
+ * In decode sessions the bytes in the hash location have
+ * undefined values.
+ */
+ if (param->ref->auth != ODP_AUTH_ALG_NULL &&
+ param->op == ODP_CRYPTO_OP_DECODE) {
+ uint32_t offs = param->digest_offset;
+
+ if (param->op_type != ODP_CRYPTO_OP_TYPE_OOP ||
+ is_in_range(offs, cipher_offset, cipher_len) ||
+ is_in_range(offs, auth_offset, auth_len)) {
+ add_ignored_range(ignore,
+ param->digest_offset + shift,
+ param->ref->digest_length);
+ }
+ }
+
+ /* Decrypted bytes are undefined if authentication fails. */
+ if (param->op == ODP_CRYPTO_OP_DECODE &&
+ param->wrong_digest) {
+ add_ignored_range(ignore, cipher_offset + shift, cipher_len);
+ /* In OOP case, auth range may not get copied */
+ if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP)
+ add_ignored_range(ignore, auth_offset + shift, auth_len);
+ }
+}
+
+static void prepare_expected_data(const crypto_op_test_param_t *param,
+ const odp_packet_data_range_t *cipher_range,
+ const odp_packet_data_range_t *auth_range,
+ odp_packet_t pkt_in,
+ odp_packet_t pkt_out,
+ expected_t *ex)
+{
+ uint32_t digest_offset = param->digest_offset;
+ uint32_t cipher_offset = cipher_range->offset;
+ uint32_t cipher_len = cipher_range->length;
+ uint32_t auth_offset = auth_range->offset;
+ uint32_t auth_len = auth_range->length;
+ const int32_t shift = param->op_type == ODP_CRYPTO_OP_TYPE_OOP ? param->oop_shift : 0;
+ const odp_packet_t base_pkt = param->op_type == ODP_CRYPTO_OP_TYPE_OOP ? pkt_out : pkt_in;
+ int rc;
+ uint32_t cipher_offset_in_ref = param->cipher_range.offset;
+
+ if (param->op == ODP_CRYPTO_OP_ENCODE)
+ digest_offset += shift;
+
+ if (param->is_bit_mode_cipher) {
+ cipher_offset_in_ref /= 8;
+ cipher_offset /= 8;
+ cipher_len = (cipher_len + 7) / 8;
+ }
+ if (param->is_bit_mode_auth) {
+ auth_offset /= 8;
+ auth_len = (auth_len + 7) / 8;
+ }
+ if (param->ref->cipher == ODP_CIPHER_ALG_NULL)
+ cipher_len = 0;
+ if (param->ref->auth == ODP_AUTH_ALG_NULL ||
+ param->ref->auth == ODP_AUTH_ALG_AES_GCM ||
+ param->ref->auth == ODP_AUTH_ALG_AES_CCM ||
+ param->ref->auth == ODP_AUTH_ALG_CHACHA20_POLY1305) {
+ /* auth range is ignored with null and AEAD algorithms */
+ auth_len = 0;
+ }
+
+ /* copy all data from base packet */
+ ex->len = odp_packet_len(base_pkt);
+ CU_ASSERT_FATAL(ex->len <= sizeof(ex->data));
+ rc = odp_packet_copy_to_mem(base_pkt, 0, ex->len, ex->data);
+ CU_ASSERT(rc == 0);
+
+ if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP && auth_len > 0) {
+ /* copy auth range from input packet */
+ rc = odp_packet_copy_to_mem(pkt_in, auth_offset, auth_len,
+ ex->data + auth_offset + shift);
+ CU_ASSERT(rc == 0);
+ }
+
+ if (param->op == ODP_CRYPTO_OP_ENCODE) {
+ /* copy hash first */
+ memcpy(ex->data + digest_offset,
+ param->ref->digest,
+ param->ref->digest_length);
+ /*
+ * Copy ciphertext, possibly overwriting hash.
+ * The other order (hash overwriting some cipher
+ * text) does not work in any real use case anyway.
+ */
+ memcpy(ex->data + cipher_offset + shift,
+ param->ref->ciphertext + cipher_offset_in_ref,
+ cipher_len);
+ } else {
+ memcpy(ex->data + cipher_offset + shift,
+ param->ref->plaintext + cipher_offset_in_ref,
+ cipher_len);
+ }
+
+ prepare_ignore_info(param, shift,
+ cipher_offset, cipher_len,
+ auth_offset, auth_len,
+ &ex->ignore);
+}
+
+static void print_data(const char *title, uint8_t *data, uint32_t len)
+{
+ static uint64_t limit;
+
+ if (limit++ > MAX_FAILURE_PRINTS)
+ return;
+
+ printf("%s\n", title);
+ for (uint32_t n = 0; n < len ; n++) {
+ printf(" %02x", data[n]);
+ if ((n + 1) % 16 == 0)
+ printf("\n");
+ }
+ printf("\n");
+}
+
+static void check_output_packet_data(odp_packet_t pkt, expected_t *ex)
+{
+ int rc;
+ uint8_t pkt_data[ex->len];
+
+ CU_ASSERT(odp_packet_len(pkt) == ex->len);
+ rc = odp_packet_copy_to_mem(pkt, 0, ex->len, pkt_data);
+ CU_ASSERT(rc == 0);
+
+ clear_ignored_data(&ex->ignore, pkt_data, sizeof(pkt_data));
+ clear_ignored_data(&ex->ignore, ex->data, sizeof(ex->data));
+
+ if (memcmp(pkt_data, ex->data, ex->len)) {
+ CU_FAIL("packet data does not match expected data");
+ print_data("packet:", pkt_data, ex->len);
+ print_data("expected:", ex->data, ex->len);
+ }
+}
+
+void test_crypto_op(const crypto_op_test_param_t *param)
+{
+ odp_bool_t ok = false;
+ odp_packet_t pkt;
+ odp_packet_t pkt_copy = ODP_PACKET_INVALID;
+ odp_packet_t pkt_out = ODP_PACKET_INVALID;
+ test_packet_md_t md_in, md_out, md_out_orig;
+ expected_t expected;
+ odp_crypto_packet_op_param_t op_params = {
+ .session = param->session,
+ .cipher_iv_ptr = param->ref->cipher_iv,
+ .auth_iv_ptr = param->ref->auth_iv,
+ .hash_result_offset = param->digest_offset,
+ .aad_ptr = param->ref->aad,
+ .dst_offset_shift = param->oop_shift,
+ };
+
+ /*
+ * Test detection of wrong digest value in input packet
+ * only when decoding and using non-null auth algorithm.
+ */
+ if (param->wrong_digest &&
+ (param->ref->auth == ODP_AUTH_ALG_NULL ||
+ param->op == ODP_CRYPTO_OP_ENCODE))
+ return;
+
+ prepare_crypto_ranges(param, &op_params.cipher_range, &op_params.auth_range);
+ if (prepare_input_packet(param, &pkt))
+ return;
+
+ if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) {
+ prepare_oop_output_packet(param, &pkt_out, odp_packet_len(pkt));
+
+ pkt_copy = odp_packet_copy(pkt, suite_context.pool);
+ CU_ASSERT_FATAL(pkt_copy != ODP_PACKET_INVALID);
+ test_packet_get_md(pkt_out, &md_out_orig);
+ }
+
+ prepare_expected_data(param, &op_params.cipher_range, &op_params.auth_range,
+ pkt, pkt_out, &expected);
+
+ if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP &&
+ param->op == ODP_CRYPTO_OP_ENCODE) {
+ /*
+ * In this type of sessions digest offset is an offset to the output
+ * packet, so apply the shift.
+ */
+ op_params.hash_result_offset += param->oop_shift;
+ }
+
+ test_packet_set_md(pkt);
+ test_packet_get_md(pkt, &md_in);
+
+ if (crypto_op(pkt, &pkt_out, &ok, &op_params, param->op_type))
+ return;
+
+ test_packet_get_md(pkt_out, &md_out);
+
+ if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) {
+ test_packet_md_t md;
+
+ /* check that input packet has not changed */
+ CU_ASSERT(is_packet_data_equal(pkt, pkt_copy));
+ odp_packet_free(pkt_copy);
+ test_packet_get_md(pkt, &md);
+ CU_ASSERT(test_packet_is_md_equal(&md, &md_in));
+ odp_packet_free(pkt);
+
+ /* check that metadata of output packet has not changed */
+ CU_ASSERT(test_packet_is_md_equal(&md_out, &md_out_orig));
+ } else {
+ CU_ASSERT(test_packet_is_md_equal(&md_out, &md_in));
+ }
+
+ if (param->ref->cipher != ODP_CIPHER_ALG_NULL &&
+ param->ref->auth != ODP_AUTH_ALG_NULL &&
+ param->digest_offset >= op_params.cipher_range.offset &&
+ param->digest_offset < op_params.cipher_range.offset + op_params.cipher_range.length) {
+ /*
+ * Not all implementations support digest offset in cipher
+ * range, so allow crypto op failure without further checks
+ * in this case.
+ */
+ if (!ok)
+ goto out;
+ }
+
+ if (param->wrong_digest) {
+ CU_ASSERT(!ok);
+ } else {
+ CU_ASSERT(ok);
+ }
+
+ check_output_packet_data(pkt_out, &expected);
+out:
+ odp_packet_free(pkt_out);
+}
diff --git a/test/validation/api/crypto/crypto_op_test.h b/test/validation/api/crypto/crypto_op_test.h
new file mode 100644
index 000000000..4b2f66c47
--- /dev/null
+++ b/test/validation/api/crypto/crypto_op_test.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2021-2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef CRYPTO_OP_TEST_H
+#define CRYPTO_OP_TEST_H
+
+#include <odp_api.h>
+#include <stdint.h>
+#include "test_vectors.h"
+
+typedef struct crypto_op_test_param_t {
+ odp_crypto_session_t session;
+ odp_crypto_op_t op;
+ odp_crypto_op_type_t op_type;
+ int32_t oop_shift;
+ crypto_test_reference_t *ref;
+ odp_packet_data_range_t cipher_range;
+ odp_packet_data_range_t auth_range;
+ uint32_t digest_offset;
+ odp_bool_t is_bit_mode_cipher;
+ odp_bool_t is_bit_mode_auth;
+ odp_bool_t adjust_segmentation;
+ odp_bool_t wrong_digest;
+ uint32_t first_seg_len;
+ uint32_t header_len;
+ uint32_t trailer_len;
+} crypto_op_test_param_t;
+
+void test_crypto_op(const crypto_op_test_param_t *param);
+
+int crypto_op(odp_packet_t pkt_in,
+ odp_packet_t *pkt_out,
+ odp_bool_t *ok,
+ const odp_crypto_packet_op_param_t *op_params,
+ odp_crypto_op_type_t op_type);
+
+#endif
diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c
index c6a7767cc..d7e2bd16b 100644
--- a/test/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/validation/api/crypto/odp_crypto_test_inp.c
@@ -10,8 +10,10 @@
#include <odp_api.h>
#include <odp/helper/odph_api.h>
#include <odp_cunit_common.h>
-#include <packet_common.h>
#include "test_vectors.h"
+#include "test_vector_defs.h"
+#include "crypto_op_test.h"
+#include "util.h"
/*
* If nonzero, run time consuming tests too.
@@ -25,20 +27,6 @@ static int full_test;
#define PKT_POOL_LEN 1200 /* enough for a test packet and some headroom */
#define UAREA_SIZE 8
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-
-struct suite_context_s {
- odp_bool_t packet;
- odp_crypto_op_mode_t op_mode;
- odp_crypto_op_mode_t pref_mode;
- odp_pool_t pool;
- odp_queue_t queue;
- odp_queue_type_t q_type;
- odp_event_t (*compl_queue_deq)(void);
-};
-
-static struct suite_context_s suite_context;
-
static void test_defaults(uint8_t fill)
{
odp_crypto_session_param_t param;
@@ -63,733 +51,14 @@ static void test_default_values(void)
test_defaults(0xff);
}
-static const char *auth_alg_name(odp_auth_alg_t auth)
-{
- switch (auth) {
- case ODP_AUTH_ALG_NULL:
- return "ODP_AUTH_ALG_NULL";
- case ODP_AUTH_ALG_MD5_HMAC:
- return "ODP_AUTH_ALG_MD5_HMAC";
- case ODP_AUTH_ALG_SHA1_HMAC:
- return "ODP_AUTH_ALG_SHA1_HMAC";
- case ODP_AUTH_ALG_SHA224_HMAC:
- return "ODP_AUTH_ALG_SHA224_HMAC";
- case ODP_AUTH_ALG_SHA256_HMAC:
- return "ODP_AUTH_ALG_SHA256_HMAC";
- case ODP_AUTH_ALG_SHA384_HMAC:
- return "ODP_AUTH_ALG_SHA384_HMAC";
- case ODP_AUTH_ALG_SHA512_HMAC:
- return "ODP_AUTH_ALG_SHA512_HMAC";
- case ODP_AUTH_ALG_AES_XCBC_MAC:
- return "ODP_AUTH_ALG_AES_XCBC_MAC";
- case ODP_AUTH_ALG_AES_GCM:
- return "ODP_AUTH_ALG_AES_GCM";
- case ODP_AUTH_ALG_AES_GMAC:
- return "ODP_AUTH_ALG_AES_GMAC";
- case ODP_AUTH_ALG_AES_CCM:
- return "ODP_AUTH_ALG_AES_CCM";
- case ODP_AUTH_ALG_AES_CMAC:
- return "ODP_AUTH_ALG_AES_CMAC";
- case ODP_AUTH_ALG_CHACHA20_POLY1305:
- return "ODP_AUTH_ALG_CHACHA20_POLY1305";
- case ODP_AUTH_ALG_KASUMI_F9:
- return "ODP_AUTH_ALG_KASUMI_F9";
- case ODP_AUTH_ALG_SNOW3G_UIA2:
- return "ODP_AUTH_ALG_SNOW3G_UIA2";
- case ODP_AUTH_ALG_AES_EIA2:
- return "ODP_AUTH_ALG_AES_EIA2";
- case ODP_AUTH_ALG_ZUC_EIA3:
- return "ODP_AUTH_ALG_ZUC_EIA3";
- case ODP_AUTH_ALG_MD5:
- return "ODP_AUTH_ALG_MD5";
- case ODP_AUTH_ALG_SHA1:
- return "ODP_AUTH_ALG_SHA1";
- case ODP_AUTH_ALG_SHA224:
- return "ODP_AUTH_ALG_SHA224";
- case ODP_AUTH_ALG_SHA256:
- return "ODP_AUTH_ALG_SHA256";
- case ODP_AUTH_ALG_SHA384:
- return "ODP_AUTH_ALG_SHA384";
- case ODP_AUTH_ALG_SHA512:
- return "ODP_AUTH_ALG_SHA512";
- default:
- return "Unknown";
- }
-}
-
-static const char *cipher_alg_name(odp_cipher_alg_t cipher)
-{
- switch (cipher) {
- case ODP_CIPHER_ALG_NULL:
- return "ODP_CIPHER_ALG_NULL";
- case ODP_CIPHER_ALG_DES:
- return "ODP_CIPHER_ALG_DES";
- case ODP_CIPHER_ALG_3DES_CBC:
- return "ODP_CIPHER_ALG_3DES_CBC";
- case ODP_CIPHER_ALG_3DES_ECB:
- return "ODP_CIPHER_ALG_3DES_ECB";
- case ODP_CIPHER_ALG_AES_CBC:
- return "ODP_CIPHER_ALG_AES_CBC";
- case ODP_CIPHER_ALG_AES_CTR:
- return "ODP_CIPHER_ALG_AES_CTR";
- case ODP_CIPHER_ALG_AES_ECB:
- return "ODP_CIPHER_ALG_AES_ECB";
- case ODP_CIPHER_ALG_AES_CFB128:
- return "ODP_CIPHER_ALG_AES_CFB128";
- case ODP_CIPHER_ALG_AES_XTS:
- return "ODP_CIPHER_ALG_AES_XTS";
- case ODP_CIPHER_ALG_AES_GCM:
- return "ODP_CIPHER_ALG_AES_GCM";
- case ODP_CIPHER_ALG_AES_CCM:
- return "ODP_CIPHER_ALG_AES_CCM";
- case ODP_CIPHER_ALG_CHACHA20_POLY1305:
- return "ODP_CIPHER_ALG_CHACHA20_POLY1305";
- case ODP_CIPHER_ALG_KASUMI_F8:
- return "ODP_CIPHER_ALG_KASUMI_F8";
- case ODP_CIPHER_ALG_SNOW3G_UEA2:
- return "ODP_CIPHER_ALG_SNOW3G_UEA2";
- case ODP_CIPHER_ALG_AES_EEA2:
- return "ODP_CIPHER_ALG_AES_EEA2";
- case ODP_CIPHER_ALG_ZUC_EEA3:
- return "ODP_CIPHER_ALG_ZUC_EEA3";
- default:
- return "Unknown";
- }
-}
-
-static int alg_packet_op(odp_packet_t pkt_in,
- odp_packet_t *pkt_out,
- odp_bool_t *ok,
- odp_crypto_session_t session,
- odp_crypto_op_type_t op_type,
- int32_t oop_shift,
- uint8_t *cipher_iv_ptr,
- uint8_t *auth_iv_ptr,
- const odp_packet_data_range_t *cipher_range,
- const odp_packet_data_range_t *auth_range,
- uint8_t *aad,
- unsigned int hash_result_offset)
-{
- int rc;
- odp_event_t event;
- odp_crypto_packet_result_t result;
- odp_crypto_packet_op_param_t op_params;
- odp_event_subtype_t subtype;
- odp_packet_t orig_pkt_out;
-
- if (op_type == ODP_CRYPTO_OP_TYPE_LEGACY)
- *pkt_out = pkt_in;
- else if (op_type == ODP_CRYPTO_OP_TYPE_BASIC)
- *pkt_out = ODP_PACKET_INVALID;
- orig_pkt_out = *pkt_out;
-
- /* Prepare input/output params */
- memset(&op_params, 0, sizeof(op_params));
- op_params.session = session;
-
- op_params.cipher_range = *cipher_range;
- op_params.auth_range = *auth_range;
- op_params.dst_offset_shift = oop_shift;
- if (cipher_iv_ptr)
- op_params.cipher_iv_ptr = cipher_iv_ptr;
- if (auth_iv_ptr)
- op_params.auth_iv_ptr = auth_iv_ptr;
-
- op_params.aad_ptr = aad;
-
- op_params.hash_result_offset = hash_result_offset;
-
- if (suite_context.op_mode == ODP_CRYPTO_SYNC) {
- rc = odp_crypto_op(&pkt_in, pkt_out, &op_params, 1);
- if (rc <= 0) {
- CU_FAIL("Failed odp_crypto_packet_op()");
- return rc;
- }
- } else {
- odp_packet_t *out_param = pkt_out;
-
- if (op_type == ODP_CRYPTO_OP_TYPE_BASIC)
- out_param = NULL;
-
- rc = odp_crypto_op_enq(&pkt_in, out_param, &op_params, 1);
- if (rc <= 0) {
- CU_FAIL("Failed odp_crypto_op_enq()");
- return rc;
- }
-
- /* Get crypto completion event from compl_queue. */
- CU_ASSERT_FATAL(NULL != suite_context.compl_queue_deq);
- do {
- event = suite_context.compl_queue_deq();
- } while (event == ODP_EVENT_INVALID);
-
- CU_ASSERT(ODP_EVENT_PACKET == odp_event_type(event));
- CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == odp_event_subtype(event));
- CU_ASSERT(ODP_EVENT_PACKET == odp_event_types(event, &subtype));
- CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == subtype);
-
- *pkt_out = odp_crypto_packet_from_event(event);
- }
-
- if (op_type != ODP_CRYPTO_OP_TYPE_BASIC)
- CU_ASSERT(*pkt_out == orig_pkt_out);
- CU_ASSERT(ODP_EVENT_PACKET ==
- odp_event_type(odp_packet_to_event(*pkt_out)));
- CU_ASSERT(ODP_EVENT_PACKET_CRYPTO ==
- odp_event_subtype(odp_packet_to_event(*pkt_out)));
- CU_ASSERT(ODP_EVENT_PACKET ==
- odp_event_types(odp_packet_to_event(*pkt_out), &subtype));
- CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == subtype);
- CU_ASSERT(odp_packet_subtype(*pkt_out) == ODP_EVENT_PACKET_CRYPTO);
-
- rc = odp_crypto_result(&result, *pkt_out);
- if (rc < -1) {
- CU_FAIL("Failed odp_crypto_packet_result()");
- return rc;
- }
- CU_ASSERT(rc == 0 || rc == -1);
-
- if (op_type == ODP_CRYPTO_OP_TYPE_OOP &&
- suite_context.op_mode == ODP_CRYPTO_ASYNC)
- CU_ASSERT(result.pkt_in == pkt_in);
-
- *ok = (rc == 0);
-
-#if ODP_DEPRECATED_API
- CU_ASSERT(*ok == result.ok);
-#endif
-
- return 0;
-}
-
-static int crypto_op(odp_packet_t pkt_in,
- odp_packet_t *pkt_out,
- odp_bool_t *ok,
- odp_crypto_session_t session,
- odp_crypto_op_type_t op_type,
- int32_t oop_shift,
- uint8_t *cipher_iv,
- uint8_t *auth_iv,
- const odp_packet_data_range_t *cipher_range,
- const odp_packet_data_range_t *auth_range,
- uint8_t *aad,
- unsigned int hash_result_offset)
-{
- int rc;
-
- rc = alg_packet_op(pkt_in, pkt_out, ok, session,
- op_type, oop_shift,
- cipher_iv, auth_iv,
- cipher_range, auth_range,
- aad, hash_result_offset);
-
- if (rc < 0)
- odp_packet_free(pkt_in);
-
- return rc;
-}
-
-/*
- * Try to adjust packet so that the first segment holds 'first_seg_len' bytes
- * of packet data (+ tailroom if first_seg_len is longer than the packet).
- *
- * If 'first_seg_len' is zero, do not try to add segments but make headroom
- * zero.
- *
- * Packet data bytes are not preserved.
- */
-static void adjust_segments(odp_packet_t *pkt, uint32_t first_seg_len)
-{
- uint32_t shift;
-
- shift = odp_packet_headroom(*pkt) + first_seg_len;
-
- if (odp_packet_extend_head(pkt, shift, NULL, NULL) < 0) {
- CU_FAIL("odp_packet_extend_head() failed\n");
- return;
- }
- if (odp_packet_trunc_tail(pkt, shift, NULL, NULL) < 0) {
- CU_FAIL("odp_packet_trunc_tail() failed\n");
- return;
- }
- /*
- * ODP API does not seem to guarantee that we ever have a multi-segment
- * packet at this point, but we can print a message about it.
- */
- if (first_seg_len == 1 &&
- first_seg_len != odp_packet_seg_len(*pkt))
- printf("Could not create a segmented packet for testing.\n");
-}
-
-static void fill_with_pattern(uint8_t *buf, uint32_t len)
-{
- static uint8_t value;
-
- for (uint32_t n = 0; n < len; n++)
- buf[n] = value++;
-}
-
-static void write_header_and_trailer(odp_packet_t pkt,
- uint32_t header_len, uint32_t trailer_len)
-{
- uint32_t trailer_offset = odp_packet_len(pkt) - trailer_len;
- uint32_t max_len = header_len > trailer_len ? header_len : trailer_len;
- uint8_t buffer[max_len];
- int rc;
-
- fill_with_pattern(buffer, sizeof(buffer));
-
- rc = odp_packet_copy_from_mem(pkt, 0, header_len, buffer);
- CU_ASSERT(rc == 0);
- rc = odp_packet_copy_from_mem(pkt, trailer_offset, trailer_len, buffer);
- CU_ASSERT(rc == 0);
-}
-
-typedef struct alg_test_param_t {
- odp_crypto_session_t session;
- odp_crypto_op_t op;
- odp_crypto_op_type_t op_type;
- int32_t oop_shift;
- odp_cipher_alg_t cipher_alg;
- odp_auth_alg_t auth_alg;
- crypto_test_reference_t *ref;
- odp_packet_data_range_t cipher_range;
- odp_packet_data_range_t auth_range;
- uint32_t digest_offset;
- odp_bool_t is_bit_mode_cipher;
- odp_bool_t is_bit_mode_auth;
- odp_bool_t adjust_segmentation;
- odp_bool_t wrong_digest;
- uint32_t first_seg_len;
- uint32_t header_len;
- uint32_t trailer_len;
-} alg_test_param_t;
-
-static void prepare_crypto_ranges(const alg_test_param_t *param,
- odp_packet_data_range_t *cipher_range,
- odp_packet_data_range_t *auth_range)
-{
- odp_packet_data_range_t zero_range = {.offset = 0, .length = 0};
- uint32_t c_scale = param->is_bit_mode_cipher ? 8 : 1;
- uint32_t a_scale = param->is_bit_mode_auth ? 8 : 1;
-
- *cipher_range = param->cipher_range;
- *auth_range = param->auth_range;
- cipher_range->offset += c_scale * param->header_len;
- auth_range->offset += a_scale * param->header_len;
-
- if (param->cipher_alg == ODP_CIPHER_ALG_NULL)
- *cipher_range = zero_range;
- if (param->auth_alg == ODP_AUTH_ALG_NULL)
- *auth_range = zero_range;
-}
-
-static int prepare_input_packet(const alg_test_param_t *param,
- odp_packet_t *pkt_in)
-{
- crypto_test_reference_t *ref = param->ref;
- uint32_t reflength = ref_length_in_bytes(ref);
- odp_packet_t pkt;
- uint32_t digest_offset = param->digest_offset;
- uint32_t pkt_len;
-
- pkt_len = param->header_len + reflength + param->trailer_len;
- if (param->digest_offset == param->header_len + reflength)
- pkt_len += ref->digest_length;
-
- pkt = odp_packet_alloc(suite_context.pool, pkt_len);
-
- CU_ASSERT(pkt != ODP_PACKET_INVALID);
- if (pkt == ODP_PACKET_INVALID)
- return -1;
-
- if (param->adjust_segmentation)
- adjust_segments(&pkt, param->first_seg_len);
-
- write_header_and_trailer(pkt, param->header_len, param->trailer_len);
-
- if (param->op == ODP_CRYPTO_OP_ENCODE) {
- odp_packet_copy_from_mem(pkt, param->header_len,
- reflength, ref->plaintext);
- } else {
- odp_packet_copy_from_mem(pkt, param->header_len,
- reflength, ref->ciphertext);
- odp_packet_copy_from_mem(pkt, digest_offset,
- ref->digest_length,
- ref->digest);
- if (param->wrong_digest) {
- uint8_t byte = ~ref->digest[0];
-
- odp_packet_copy_from_mem(pkt, digest_offset, 1, &byte);
- }
- }
- *pkt_in = pkt;
- return 0;
-}
-
-static void prepare_oop_output_packet(const alg_test_param_t *param,
- odp_packet_t *pkt_out,
- uint32_t pkt_len)
+static void print_alg_test_param(const crypto_op_test_param_t *p)
{
- uint32_t reflength = ref_length_in_bytes(param->ref);
- const uint32_t oop_extra_len = 5;
- uint32_t trl_len;
- uint32_t hdr_len;
- uint32_t oop_len;
-
- oop_len = pkt_len + param->oop_shift + oop_extra_len;
- *pkt_out = odp_packet_alloc(suite_context.pool, oop_len);
- CU_ASSERT_FATAL(*pkt_out != ODP_PACKET_INVALID);
-
- uint8_t buf[oop_len];
-
- memset(buf, 0x55, sizeof(buf));
- odp_packet_copy_from_mem(*pkt_out, 0, sizeof(buf), buf);
-
- hdr_len = param->header_len + param->oop_shift;
- trl_len = oop_len - hdr_len - reflength;
-
- write_header_and_trailer(*pkt_out, hdr_len, trl_len);
-
- /* have different metadata than in the input packet */
- memset(odp_packet_user_area(*pkt_out), 0xab,
- odp_packet_user_area_size(*pkt_out));
-}
-
-static int is_packet_data_equal(odp_packet_t pkt_1, odp_packet_t pkt_2)
-{
- uint32_t len = odp_packet_len(pkt_1);
- uint8_t buf_1[len];
- uint8_t buf_2[len];
-
- if (len != odp_packet_len(pkt_2) ||
- odp_packet_copy_to_mem(pkt_1, 0, len, buf_1) ||
- odp_packet_copy_to_mem(pkt_2, 0, len, buf_2))
- return 0;
-
- return !memcmp(buf_1, buf_2, len);
-}
-
-static int is_in_range(uint32_t offs, uint32_t range_offs, uint32_t range_len)
-{
- return offs >= range_offs && offs < range_offs + range_len;
-}
-
-#define MAX_IGNORED_RANGES 3
-
-/*
- * Output packet parts that we ignore since they have undefined values
- */
-typedef struct ignore_t {
- uint32_t byte_offset; /* offset to a byte which has bits to be ignored */
- uint8_t byte_mask; /* mask of ignored bits in the byte */
- struct {
- uint32_t offset;
- uint32_t length;
- } ranges[MAX_IGNORED_RANGES]; /* byte ranges to be ignored */
- uint32_t num_ranges;
-} ignore_t;
-
-static void add_ignored_range(ignore_t *ign, uint32_t offs, uint32_t len)
-{
- if (len == 0)
- return;
- CU_ASSERT_FATAL(ign->num_ranges < MAX_IGNORED_RANGES);
- ign->ranges[ign->num_ranges].offset = offs;
- ign->ranges[ign->num_ranges].length = len;
- ign->num_ranges++;
-}
-
-static void clear_ignored_data(const ignore_t *ign, uint8_t *data, uint32_t data_len)
-{
- CU_ASSERT_FATAL(ign->byte_offset < data_len);
- data[ign->byte_offset] &= ~ign->byte_mask;
-
- for (uint32_t n = 0; n < ign->num_ranges; n++) {
- uint32_t offset = ign->ranges[n].offset;
- uint32_t length = ign->ranges[n].length;
-
- CU_ASSERT(offset + length <= data_len);
- memset(data + offset, 0, length);
- }
-}
-
-static void prepare_ignore_info(const alg_test_param_t *param,
- uint32_t shift,
- uint32_t cipher_offset,
- uint32_t cipher_len,
- uint32_t auth_offset,
- uint32_t auth_len,
- ignore_t *ignore)
-{
- memset(ignore, 0, sizeof(*ignore));
-
- /*
- * Leftover bits in the last byte of the cipher range of bit mode
- * ciphers have undefined values.
- */
- if (param->is_bit_mode_cipher &&
- param->cipher_alg != ODP_CIPHER_ALG_NULL) {
- uint8_t leftover_bits = ref_length_in_bits(param->ref) % 8;
-
- ignore->byte_offset = cipher_offset + cipher_len - 1 + shift;
- if (leftover_bits > 0)
- ignore->byte_mask = ~(0xff << (8 - leftover_bits));
- else
- ignore->byte_mask = 0;
- }
-
- /*
- * In decode sessions the bytes in the hash location have
- * undefined values.
- */
- if (param->auth_alg != ODP_AUTH_ALG_NULL &&
- param->op == ODP_CRYPTO_OP_DECODE) {
- uint32_t offs = param->digest_offset;
-
- if (param->op_type != ODP_CRYPTO_OP_TYPE_OOP ||
- is_in_range(offs, cipher_offset, cipher_len) ||
- is_in_range(offs, auth_offset, auth_len)) {
- add_ignored_range(ignore,
- param->digest_offset + shift,
- param->ref->digest_length);
- }
- }
-
- /* Decrypted bytes are undefined if authentication fails. */
- if (param->op == ODP_CRYPTO_OP_DECODE &&
- param->wrong_digest) {
- add_ignored_range(ignore, cipher_offset + shift, cipher_len);
- /* In OOP case, auth range may not get copied */
- if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP)
- add_ignored_range(ignore, auth_offset + shift, auth_len);
- }
-}
-
-/* Add room for bytes that are not included in ref->length */
-#define MAX_EXP_DATA_LEN (MAX_DATA_LEN + 200)
-
-/*
- * Expected packet data
- */
-typedef struct expected_t {
- uint8_t data[MAX_EXP_DATA_LEN];
- uint32_t len;
- ignore_t ignore;
-} expected_t;
-
-static void prepare_expected_data(const alg_test_param_t *param,
- const odp_packet_data_range_t *cipher_range,
- const odp_packet_data_range_t *auth_range,
- odp_packet_t pkt_in,
- odp_packet_t pkt_out,
- expected_t *ex)
-{
- uint32_t digest_offset = param->digest_offset;
- uint32_t cipher_offset = cipher_range->offset;
- uint32_t cipher_len = cipher_range->length;
- uint32_t auth_offset = auth_range->offset;
- uint32_t auth_len = auth_range->length;
- const int32_t shift = param->op_type == ODP_CRYPTO_OP_TYPE_OOP ? param->oop_shift : 0;
- const odp_packet_t base_pkt = param->op_type == ODP_CRYPTO_OP_TYPE_OOP ? pkt_out : pkt_in;
- int rc;
- uint32_t cipher_offset_in_ref = param->cipher_range.offset;
-
- if (param->op == ODP_CRYPTO_OP_ENCODE)
- digest_offset += shift;
-
- if (param->is_bit_mode_cipher) {
- cipher_offset_in_ref /= 8;
- cipher_offset /= 8;
- cipher_len = (cipher_len + 7) / 8;
- }
- if (param->is_bit_mode_auth) {
- auth_offset /= 8;
- auth_len = (auth_len + 7) / 8;
- }
- if (param->cipher_alg == ODP_CIPHER_ALG_NULL)
- cipher_len = 0;
- if (param->auth_alg == ODP_AUTH_ALG_NULL ||
- param->auth_alg == ODP_AUTH_ALG_AES_GCM ||
- param->auth_alg == ODP_AUTH_ALG_AES_CCM ||
- param->auth_alg == ODP_AUTH_ALG_CHACHA20_POLY1305) {
- /* auth range is ignored with null and AEAD algorithms */
- auth_len = 0;
- }
-
- /* copy all data from base packet */
- ex->len = odp_packet_len(base_pkt);
- CU_ASSERT_FATAL(ex->len <= sizeof(ex->data));
- rc = odp_packet_copy_to_mem(base_pkt, 0, ex->len, ex->data);
- CU_ASSERT(rc == 0);
-
- if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP && auth_len > 0) {
- /* copy auth range from input packet */
- rc = odp_packet_copy_to_mem(pkt_in, auth_offset, auth_len,
- ex->data + auth_offset + shift);
- CU_ASSERT(rc == 0);
- }
-
- if (param->op == ODP_CRYPTO_OP_ENCODE) {
- /* copy hash first */
- memcpy(ex->data + digest_offset,
- param->ref->digest,
- param->ref->digest_length);
- /*
- * Copy ciphertext, possibly overwriting hash.
- * The other order (hash overwriting some cipher
- * text) does not work in any real use case anyway.
- */
- memcpy(ex->data + cipher_offset + shift,
- param->ref->ciphertext + cipher_offset_in_ref,
- cipher_len);
- } else {
- memcpy(ex->data + cipher_offset + shift,
- param->ref->plaintext + cipher_offset_in_ref,
- cipher_len);
- }
-
- prepare_ignore_info(param, shift,
- cipher_offset, cipher_len,
- auth_offset, auth_len,
- &ex->ignore);
-}
-
-static void print_data(const char *title, uint8_t *data, uint32_t len)
-{
- static uint64_t limit;
-
- if (limit++ > MAX_FAILURE_PRINTS)
- return;
-
- printf("%s\n", title);
- for (uint32_t n = 0; n < len ; n++) {
- printf(" %02x", data[n]);
- if ((n + 1) % 16 == 0)
- printf("\n");
- }
- printf("\n");
-}
-
-static void check_output_packet_data(odp_packet_t pkt, expected_t *ex)
-{
- int rc;
- uint8_t pkt_data[ex->len];
-
- CU_ASSERT(odp_packet_len(pkt) == ex->len);
- rc = odp_packet_copy_to_mem(pkt, 0, ex->len, pkt_data);
- CU_ASSERT(rc == 0);
-
- clear_ignored_data(&ex->ignore, pkt_data, sizeof(pkt_data));
- clear_ignored_data(&ex->ignore, ex->data, sizeof(ex->data));
-
- if (memcmp(pkt_data, ex->data, ex->len)) {
- CU_FAIL("packet data does not match expected data");
- print_data("packet:", pkt_data, ex->len);
- print_data("expected:", ex->data, ex->len);
- }
-}
-
-static void alg_test_execute(const alg_test_param_t *param)
-{
- odp_bool_t ok = false;
- odp_packet_data_range_t cipher_range;
- odp_packet_data_range_t auth_range;
- odp_packet_t pkt;
- odp_packet_t pkt_copy = ODP_PACKET_INVALID;
- odp_packet_t pkt_out = ODP_PACKET_INVALID;
- uint32_t digest_offset = param->digest_offset;
- test_packet_md_t md_in, md_out, md_out_orig;
- expected_t expected;
-
- /*
- * Test detection of wrong digest value in input packet
- * only when decoding and using non-null auth algorithm.
- */
- if (param->wrong_digest &&
- (param->auth_alg == ODP_AUTH_ALG_NULL ||
- param->op == ODP_CRYPTO_OP_ENCODE))
- return;
-
- prepare_crypto_ranges(param, &cipher_range, &auth_range);
- if (prepare_input_packet(param, &pkt))
- return;
-
- if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) {
- prepare_oop_output_packet(param, &pkt_out, odp_packet_len(pkt));
-
- pkt_copy = odp_packet_copy(pkt, suite_context.pool);
- CU_ASSERT_FATAL(pkt_copy != ODP_PACKET_INVALID);
- test_packet_get_md(pkt_out, &md_out_orig);
- }
-
- prepare_expected_data(param, &cipher_range, &auth_range,
- pkt, pkt_out, &expected);
-
- if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP &&
- param->op == ODP_CRYPTO_OP_ENCODE) {
- /*
- * In this type of sessions digest offset is an offset to the output
- * packet, so apply the shift.
- */
- digest_offset += param->oop_shift;
- }
-
- test_packet_set_md(pkt);
- test_packet_get_md(pkt, &md_in);
-
- if (crypto_op(pkt, &pkt_out, &ok, param->session,
- param->op_type, param->oop_shift,
- param->ref->cipher_iv,
- param->ref->auth_iv,
- &cipher_range, &auth_range,
- param->ref->aad, digest_offset))
- return;
-
- test_packet_get_md(pkt_out, &md_out);
+ const char *cipher_mode = p->is_bit_mode_cipher ? "bit" : "byte";
- if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) {
- test_packet_md_t md;
- /* check that input packet has not changed */
- CU_ASSERT(is_packet_data_equal(pkt, pkt_copy));
- odp_packet_free(pkt_copy);
- test_packet_get_md(pkt, &md);
- CU_ASSERT(test_packet_is_md_equal(&md, &md_in));
- odp_packet_free(pkt);
- /* check that metadata of output packet has not changed */
- CU_ASSERT(test_packet_is_md_equal(&md_out, &md_out_orig));
- } else {
- CU_ASSERT(test_packet_is_md_equal(&md_out, &md_in));
- }
- if (param->cipher_alg != ODP_CIPHER_ALG_NULL &&
- param->auth_alg != ODP_AUTH_ALG_NULL &&
- param->digest_offset >= cipher_range.offset &&
- param->digest_offset < cipher_range.offset + cipher_range.length) {
- /*
- * Not all implementations support digest offset in cipher
- * range, so allow crypto op failure without further checks
- * in this case.
- */
- if (!ok)
- goto out;
- }
- if (param->wrong_digest) {
- CU_ASSERT(!ok);
- } else {
- CU_ASSERT(ok);
- }
- check_output_packet_data(pkt_out, &expected);
-out:
- odp_packet_free(pkt_out);
-}
-
-static void print_alg_test_param(const alg_test_param_t *p)
-{
- const char *cipher_mode = p->is_bit_mode_cipher ? "bit" : "byte";
const char *auth_mode = p->is_bit_mode_auth ? "bit" : "byte";
switch (p->op_type) {
@@ -805,13 +74,13 @@ static void print_alg_test_param(const alg_test_param_t *p)
}
printf("%s\n", p->op == ODP_CRYPTO_OP_ENCODE ? "encode" : "decode");
- printf("cipher: %s, %s mode\n", cipher_alg_name(p->cipher_alg), cipher_mode);
+ printf("cipher: %s, %s mode\n", cipher_alg_name(p->ref->cipher), cipher_mode);
printf(" key length: %d, iv length: %d\n",
p->ref->cipher_key_length, p->ref->cipher_iv_length);
printf(" range: offset %d, length %d\n",
p->cipher_range.offset, p->cipher_range.length);
- printf("auth: %s, %s mode\n", auth_alg_name(p->auth_alg), auth_mode);
+ printf("auth: %s, %s mode\n", auth_alg_name(p->ref->auth), auth_mode);
printf(" key length: %d, iv length: %d\n",
p->ref->auth_key_length, p->ref->auth_iv_length);
printf(" range: offset %d, length %d; aad length: %d\n",
@@ -828,12 +97,12 @@ static void print_alg_test_param(const alg_test_param_t *p)
printf("oop_shift: %d\n", p->oop_shift);
}
-static void alg_test_execute_and_print(alg_test_param_t *param)
+static void alg_test_execute_and_print(crypto_op_test_param_t *param)
{
static int print_limit = MAX_FAILURE_PRINTS;
unsigned int num = CU_get_number_of_failures();
- alg_test_execute(param);
+ test_crypto_op(param);
if (CU_get_number_of_failures() > num) {
if (print_limit > 0) {
@@ -847,7 +116,7 @@ static void alg_test_execute_and_print(alg_test_param_t *param)
}
}
-static void alg_test_op(alg_test_param_t *param)
+static void alg_test_op(crypto_op_test_param_t *param)
{
int32_t oop_shifts[] = {0, 3, 130, -10};
@@ -883,8 +152,6 @@ typedef enum {
static odp_crypto_session_t session_create(odp_crypto_op_t op,
odp_crypto_op_type_t op_type,
- odp_cipher_alg_t cipher_alg,
- odp_auth_alg_t auth_alg,
alg_order_t order,
crypto_test_reference_t *ref,
hash_test_mode_t hash_mode)
@@ -913,8 +180,8 @@ static odp_crypto_session_t session_create(odp_crypto_op_t op,
ses_params.op_type = op_type;
ses_params.auth_cipher_text = (order == AUTH_CIPHERTEXT);
ses_params.op_mode = suite_context.op_mode;
- ses_params.cipher_alg = cipher_alg;
- ses_params.auth_alg = auth_alg;
+ ses_params.cipher_alg = ref->cipher;
+ ses_params.auth_alg = ref->auth;
ses_params.compl_queue = suite_context.queue;
ses_params.output_pool = suite_context.pool;
ses_params.cipher_key = cipher_key;
@@ -930,8 +197,8 @@ static odp_crypto_session_t session_create(odp_crypto_op_t op,
if (!combo_warning_shown) {
combo_warning_shown = 1;
printf("\n Unsupported algorithm combination: %s, %s\n",
- cipher_alg_name(cipher_alg),
- auth_alg_name(auth_alg));
+ cipher_alg_name(ref->cipher),
+ auth_alg_name(ref->auth));
}
return ODP_CRYPTO_SESSION_INVALID;
}
@@ -944,8 +211,8 @@ static odp_crypto_session_t session_create(odp_crypto_op_t op,
if (rc < 0 && status == ODP_CRYPTO_SES_ERR_ALG_ORDER &&
ses_params.op_mode == ODP_CRYPTO_ASYNC) {
printf("\n Unsupported algorithm order: %s, %s, auth_cipher_text: %d\n",
- cipher_alg_name(cipher_alg),
- auth_alg_name(auth_alg),
+ cipher_alg_name(ref->cipher),
+ auth_alg_name(ref->auth),
ses_params.auth_cipher_text);
return ODP_CRYPTO_SESSION_INVALID;
}
@@ -977,8 +244,6 @@ static odp_crypto_session_t session_create(odp_crypto_op_t op,
static void alg_test_ses(odp_crypto_op_t op,
odp_crypto_op_type_t op_type,
- odp_cipher_alg_t cipher_alg,
- odp_auth_alg_t auth_alg,
alg_order_t order,
crypto_test_reference_t *ref,
odp_packet_data_range_t cipher_range,
@@ -994,13 +259,13 @@ static void alg_test_ses(odp_crypto_op_t op,
int rc;
uint32_t seg_len;
uint32_t max_shift;
- alg_test_param_t test_param;
+ crypto_op_test_param_t test_param;
if (digest_offset >= auth_range.offset &&
digest_offset < auth_range.offset + auth_range.length)
hash_mode = HASH_OVERLAP;
- session = session_create(op, op_type, cipher_alg, auth_alg, order, ref, hash_mode);
+ session = session_create(op, op_type, order, ref, hash_mode);
if (session == ODP_CRYPTO_SESSION_INVALID)
return;
@@ -1008,8 +273,6 @@ static void alg_test_ses(odp_crypto_op_t op,
test_param.session = session;
test_param.op = op;
test_param.op_type = op_type;
- test_param.cipher_alg = cipher_alg;
- test_param.auth_alg = auth_alg;
test_param.ref = ref;
test_param.cipher_range = cipher_range;
test_param.auth_range = auth_range;
@@ -1023,8 +286,8 @@ static void alg_test_ses(odp_crypto_op_t op,
seg_len = 0;
if (!full_test &&
- cipher_alg != ODP_CIPHER_ALG_NULL &&
- auth_alg != ODP_AUTH_ALG_NULL) {
+ ref->cipher != ODP_CIPHER_ALG_NULL &&
+ ref->auth != ODP_AUTH_ALG_NULL) {
/* run the loop body just once */
seg_len = max_shift / 2;
max_shift = seg_len;
@@ -1061,8 +324,6 @@ static void alg_test_ses(odp_crypto_op_t op,
}
static void alg_test(odp_crypto_op_t op,
- odp_cipher_alg_t cipher_alg,
- odp_auth_alg_t auth_alg,
alg_order_t order,
crypto_test_reference_t *ref,
odp_packet_data_range_t cipher_range,
@@ -1078,13 +339,8 @@ static void alg_test(odp_crypto_op_t op,
};
for (unsigned int n = 0; n < ARRAY_SIZE(op_types); n++) {
- if (!suite_context.packet &&
- op_types[n] != ODP_CRYPTO_OP_TYPE_LEGACY)
- continue;
alg_test_ses(op,
op_types[n],
- cipher_alg,
- auth_alg,
order,
ref,
cipher_range,
@@ -1109,12 +365,12 @@ static odp_bool_t aad_len_ok(const odp_crypto_auth_capability_t *capa, uint32_t
}
static void check_alg(odp_crypto_op_t op,
- odp_cipher_alg_t cipher_alg,
- odp_auth_alg_t auth_alg,
crypto_test_reference_t *ref,
size_t count)
{
int rc, i;
+ const odp_cipher_alg_t cipher_alg = ref->cipher;
+ const odp_auth_alg_t auth_alg = ref->auth;
int cipher_num = odp_crypto_cipher_capability(cipher_alg, NULL, 0);
int auth_num = odp_crypto_auth_capability(auth_alg, NULL, 0);
odp_bool_t cipher_ok = false;
@@ -1216,10 +472,10 @@ static void check_alg(odp_crypto_op_t op,
ref_length_in_bits(&ref[idx]) :
ref_length_in_bytes(&ref[idx]);
- alg_test(op, cipher_alg, auth_alg, AUTH_PLAINTEXT, &ref[idx],
+ alg_test(op, AUTH_PLAINTEXT, &ref[idx],
cipher_range, auth_range, digest_offs,
is_bit_mode_cipher, is_bit_mode_auth);
- alg_test(op, cipher_alg, auth_alg, AUTH_CIPHERTEXT, &ref[idx],
+ alg_test(op, AUTH_CIPHERTEXT, &ref[idx],
cipher_range, auth_range, digest_offs,
is_bit_mode_cipher, is_bit_mode_auth);
@@ -1254,214 +510,6 @@ static void check_alg(odp_crypto_op_t op,
CU_ASSERT(auth_ok);
}
-/**
- * Check if given cipher and authentication algorithms are supported
- *
- * @param cipher Cipher algorithm
- * @param auth Authentication algorithm
- *
- * @retval ODP_TEST_ACTIVE when both algorithms are supported
- * @retval ODP_TEST_INACTIVE when either algorithm is not supported
- */
-static int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth)
-{
- odp_crypto_capability_t capability;
-
- memset(&capability, 0, sizeof(odp_crypto_capability_t));
- if (odp_crypto_capability(&capability)) {
- fprintf(stderr, "odp_crypto_capability() failed\n");
- return ODP_TEST_INACTIVE;
- }
-
- if (suite_context.queue != ODP_QUEUE_INVALID) {
- if (suite_context.q_type == ODP_QUEUE_TYPE_PLAIN &&
- capability.queue_type_plain == 0)
- return ODP_TEST_INACTIVE;
- if (suite_context.q_type == ODP_QUEUE_TYPE_SCHED &&
- capability.queue_type_sched == 0)
- return ODP_TEST_INACTIVE;
- }
-
- if (suite_context.op_mode == ODP_CRYPTO_SYNC &&
- capability.sync_mode == ODP_SUPPORT_NO)
- return ODP_TEST_INACTIVE;
- if (suite_context.op_mode == ODP_CRYPTO_ASYNC &&
- capability.async_mode == ODP_SUPPORT_NO)
- return ODP_TEST_INACTIVE;
-
- /* Cipher algorithms */
- switch (cipher) {
- case ODP_CIPHER_ALG_NULL:
- if (!capability.ciphers.bit.null)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_DES:
- if (!capability.ciphers.bit.des)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_3DES_CBC:
- if (!capability.ciphers.bit.trides_cbc)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_3DES_ECB:
- if (!capability.ciphers.bit.trides_ecb)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_AES_CBC:
- if (!capability.ciphers.bit.aes_cbc)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_AES_CTR:
- if (!capability.ciphers.bit.aes_ctr)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_AES_ECB:
- if (!capability.ciphers.bit.aes_ecb)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_AES_CFB128:
- if (!capability.ciphers.bit.aes_cfb128)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_AES_XTS:
- if (!capability.ciphers.bit.aes_xts)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_AES_GCM:
- if (!capability.ciphers.bit.aes_gcm)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_AES_CCM:
- if (!capability.ciphers.bit.aes_ccm)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_CHACHA20_POLY1305:
- if (!capability.ciphers.bit.chacha20_poly1305)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_KASUMI_F8:
- if (!capability.ciphers.bit.kasumi_f8)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_SNOW3G_UEA2:
- if (!capability.ciphers.bit.snow3g_uea2)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_AES_EEA2:
- if (!capability.ciphers.bit.aes_eea2)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_CIPHER_ALG_ZUC_EEA3:
- if (!capability.ciphers.bit.zuc_eea3)
- return ODP_TEST_INACTIVE;
- break;
- default:
- fprintf(stderr, "Unsupported cipher algorithm\n");
- return ODP_TEST_INACTIVE;
- }
-
- /* Authentication algorithms */
- switch (auth) {
- case ODP_AUTH_ALG_NULL:
- if (!capability.auths.bit.null)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_MD5_HMAC:
- if (!capability.auths.bit.md5_hmac)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_SHA1_HMAC:
- if (!capability.auths.bit.sha1_hmac)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_SHA224_HMAC:
- if (!capability.auths.bit.sha224_hmac)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_SHA256_HMAC:
- if (!capability.auths.bit.sha256_hmac)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_SHA384_HMAC:
- if (!capability.auths.bit.sha384_hmac)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_SHA512_HMAC:
- if (!capability.auths.bit.sha512_hmac)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_AES_XCBC_MAC:
- if (!capability.auths.bit.aes_xcbc_mac)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_AES_GCM:
- if (!capability.auths.bit.aes_gcm)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_AES_GMAC:
- if (!capability.auths.bit.aes_gmac)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_AES_CCM:
- if (!capability.auths.bit.aes_ccm)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_AES_CMAC:
- if (!capability.auths.bit.aes_cmac)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_CHACHA20_POLY1305:
- if (!capability.auths.bit.chacha20_poly1305)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_KASUMI_F9:
- if (!capability.auths.bit.kasumi_f9)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_SNOW3G_UIA2:
- if (!capability.auths.bit.snow3g_uia2)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_AES_EIA2:
- if (!capability.auths.bit.aes_eia2)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_ZUC_EIA3:
- if (!capability.auths.bit.zuc_eia3)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_MD5:
- if (!capability.auths.bit.md5)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_SHA1:
- if (!capability.auths.bit.sha1)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_SHA224:
- if (!capability.auths.bit.sha224)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_SHA256:
- if (!capability.auths.bit.sha256)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_SHA384:
- if (!capability.auths.bit.sha384)
- return ODP_TEST_INACTIVE;
- break;
- case ODP_AUTH_ALG_SHA512:
- if (!capability.auths.bit.sha512)
- return ODP_TEST_INACTIVE;
- break;
- default:
- fprintf(stderr, "Unsupported authentication algorithm\n");
- return ODP_TEST_INACTIVE;
- }
-
- return ODP_TEST_ACTIVE;
-}
-
static void test_capability(void)
{
odp_crypto_capability_t capa = {.max_sessions = 1};
@@ -1495,15 +543,14 @@ static int create_hash_test_reference(odp_auth_alg_t auth,
odp_bool_t ok;
const uint32_t auth_bytes = 100;
uint32_t enc_digest_offset = auth_bytes;
- odp_packet_data_range_t cipher_range = {.offset = 0, .length = 0};
- odp_packet_data_range_t auth_range = {.offset = 0};
+ ref->cipher = ODP_CIPHER_ALG_NULL;
+ ref->auth = auth;
ref->auth_key_length = capa->key_len;
ref->auth_iv_length = capa->iv_len;
ref->digest_length = capa->digest_len;
ref->is_length_in_bits = false;
ref->length = auth_bytes;
- auth_range.length = capa->bit_mode ? auth_bytes * 8 : auth_bytes;
if (ref->auth_key_length > MAX_KEY_LEN ||
ref->auth_iv_length > MAX_IV_LEN ||
@@ -1525,15 +572,28 @@ static int create_hash_test_reference(odp_auth_alg_t auth,
session = session_create(ODP_CRYPTO_OP_ENCODE,
ODP_CRYPTO_OP_TYPE_LEGACY,
- ODP_CIPHER_ALG_NULL,
- auth, AUTH_PLAINTEXT, ref, HASH_NO_OVERLAP);
+ AUTH_PLAINTEXT, ref, HASH_NO_OVERLAP);
if (session == ODP_CRYPTO_SESSION_INVALID)
return -1;
- rc = crypto_op(pkt, &pkt, &ok, session, ODP_CRYPTO_OP_TYPE_LEGACY, 0,
- ref->cipher_iv, ref->auth_iv,
- &cipher_range, &auth_range, ref->aad, enc_digest_offset);
+ odp_crypto_packet_op_param_t op_params = {
+ .session = session,
+ .cipher_iv_ptr = ref->cipher_iv,
+ .auth_iv_ptr = ref->auth_iv,
+ .hash_result_offset = enc_digest_offset,
+ .aad_ptr = ref->aad,
+ .cipher_range = {.offset = 0, .length = 0},
+ .auth_range = { .offset = 0,
+ .length = capa->bit_mode ? auth_bytes * 8 : auth_bytes },
+ .dst_offset_shift = 0,
+ };
+ rc = crypto_op(pkt, &pkt, &ok, &op_params, ODP_CRYPTO_OP_TYPE_LEGACY);
+
CU_ASSERT(rc == 0);
+ if (rc) {
+ (void)odp_crypto_session_destroy(session);
+ return -1;
+ }
CU_ASSERT(ok);
rc = odp_crypto_session_destroy(session);
@@ -1590,8 +650,6 @@ static void test_auth_hash_in_auth_range(odp_auth_alg_t auth,
* hash bytes in the ciphertext packet before calculating the hash.
*/
alg_test(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- auth,
order,
&ref,
cipher_range, auth_range,
@@ -1619,8 +677,6 @@ static void test_auth_hash_in_auth_range(odp_auth_alg_t auth,
* the hash bytes in the plaintext packet before calculating the hash.
*/
alg_test(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- auth,
order,
&ref,
cipher_range, auth_range,
@@ -1700,8 +756,6 @@ static void test_auth_hashes_in_auth_range(void)
* Encode ref->plaintext and save result in ref->ciphertext.
*/
static int crypto_encode_ref(crypto_test_reference_t *ref,
- odp_cipher_alg_t cipher,
- odp_auth_alg_t auth,
odp_packet_data_range_t cipher_range,
odp_packet_data_range_t auth_range,
uint32_t hash_result_offset)
@@ -1720,8 +774,6 @@ static int crypto_encode_ref(crypto_test_reference_t *ref,
session = session_create(ODP_CRYPTO_OP_ENCODE,
ODP_CRYPTO_OP_TYPE_LEGACY,
- cipher,
- auth,
AUTH_PLAINTEXT,
ref,
HASH_OVERLAP);
@@ -1731,20 +783,31 @@ static int crypto_encode_ref(crypto_test_reference_t *ref,
return 1;
}
- if (cipher == ODP_CIPHER_ALG_NULL)
+ if (ref->cipher == ODP_CIPHER_ALG_NULL)
cipher_range = zero_range;
- if (auth == ODP_AUTH_ALG_NULL) {
+ if (ref->auth == ODP_AUTH_ALG_NULL) {
auth_range = zero_range;
hash_result_offset = 0;
}
CU_ASSERT_FATAL(hash_result_offset + ref->digest_length <= ref->length);
- rc = crypto_op(pkt, &pkt, &ok, session, ODP_CRYPTO_OP_TYPE_LEGACY, 0,
- ref->cipher_iv, ref->auth_iv,
- &cipher_range, &auth_range,
- ref->aad, hash_result_offset);
+ odp_crypto_packet_op_param_t op_params = {
+ .session = session,
+ .cipher_iv_ptr = ref->cipher_iv,
+ .auth_iv_ptr = ref->auth_iv,
+ .hash_result_offset = hash_result_offset,
+ .aad_ptr = ref->aad,
+ .cipher_range = cipher_range,
+ .auth_range = auth_range,
+ .dst_offset_shift = 0,
+ };
+ rc = crypto_op(pkt, &pkt, &ok, &op_params, ODP_CRYPTO_OP_TYPE_LEGACY);
CU_ASSERT(rc == 0);
+ if (rc) {
+ (void)odp_crypto_session_destroy(session);
+ return -1;
+ }
CU_ASSERT(ok);
rc = odp_crypto_session_destroy(session);
@@ -1780,8 +843,6 @@ static int create_combined_ref(const crypto_suite_t *suite,
crypto_test_reference_t ref_cipher_only;
crypto_test_reference_t ref_auth_only;
crypto_test_reference_t *first_ref, *second_ref;
- odp_auth_alg_t first_auth, second_auth;
- odp_cipher_alg_t first_cipher, second_cipher;
total_len = cipher_range->offset + cipher_range->length;
if (auth_range->offset + auth_range->length > total_len)
@@ -1789,6 +850,8 @@ static int create_combined_ref(const crypto_suite_t *suite,
if (digest_offset + suite->auth_capa->digest_len > total_len)
total_len = digest_offset + suite->auth_capa->digest_len;
+ ref->cipher = suite->cipher;
+ ref->auth = suite->auth;
ref->cipher_key_length = suite->cipher_capa->key_len;
ref->cipher_iv_length = suite->cipher_capa->iv_len;
ref->auth_key_length = suite->auth_capa->key_len;
@@ -1821,39 +884,31 @@ static int create_combined_ref(const crypto_suite_t *suite,
memset(ref->plaintext + digest_offset, 0, ref->digest_length);
ref_cipher_only = *ref;
+ ref_cipher_only.auth = ODP_AUTH_ALG_NULL;
ref_cipher_only.auth_key_length = 0;
ref_cipher_only.auth_iv_length = 0;
ref_cipher_only.aad_length = 0;
ref_cipher_only.digest_length = 0;
ref_auth_only = *ref;
+ ref_auth_only.cipher = ODP_CIPHER_ALG_NULL;
ref_auth_only.cipher_key_length = 0;
ref_auth_only.cipher_iv_length = 0;
if (suite->order == AUTH_CIPHERTEXT) {
first_ref = &ref_cipher_only;
- first_cipher = suite->cipher;
- first_auth = ODP_AUTH_ALG_NULL;
second_ref = &ref_auth_only;
- second_cipher = ODP_CIPHER_ALG_NULL;
- second_auth = suite->auth;
} else {
first_ref = &ref_auth_only;
- first_cipher = ODP_CIPHER_ALG_NULL;
- first_auth = suite->auth;
second_ref = &ref_cipher_only;
- second_cipher = suite->cipher;
- second_auth = ODP_AUTH_ALG_NULL;
}
rc = crypto_encode_ref(first_ref,
- first_cipher, first_auth,
*cipher_range, *auth_range,
digest_offset);
if (rc)
return 1;
memcpy(second_ref->plaintext, first_ref->ciphertext, ref->length);
rc = crypto_encode_ref(second_ref,
- second_cipher, second_auth,
*cipher_range, *auth_range,
digest_offset);
if (rc)
@@ -2135,8 +1190,6 @@ static void test_combo(const crypto_suite_t *suite,
return;
alg_test(ODP_CRYPTO_OP_ENCODE,
- suite->cipher,
- suite->auth,
suite->order,
&ref,
cipher_range, auth_range,
@@ -2145,8 +1198,6 @@ static void test_combo(const crypto_suite_t *suite,
suite->auth_capa->bit_mode);
alg_test(ODP_CRYPTO_OP_DECODE,
- suite->cipher,
- suite->auth,
suite->order,
&ref,
cipher_range, auth_range,
@@ -2238,8 +1289,6 @@ static int check_alg_null(void)
static void crypto_test_enc_alg_null(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_NULL,
null_reference,
ARRAY_SIZE(null_reference));
}
@@ -2247,8 +1296,6 @@ static void crypto_test_enc_alg_null(void)
static void crypto_test_dec_alg_null(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_NULL,
null_reference,
ARRAY_SIZE(null_reference));
}
@@ -2261,8 +1308,6 @@ static int check_alg_3des_cbc(void)
static void crypto_test_enc_alg_3des_cbc(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_3DES_CBC,
- ODP_AUTH_ALG_NULL,
tdes_cbc_reference,
ARRAY_SIZE(tdes_cbc_reference));
}
@@ -2270,8 +1315,6 @@ static void crypto_test_enc_alg_3des_cbc(void)
static void crypto_test_dec_alg_3des_cbc(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_3DES_CBC,
- ODP_AUTH_ALG_NULL,
tdes_cbc_reference,
ARRAY_SIZE(tdes_cbc_reference));
}
@@ -2284,8 +1327,6 @@ static int check_alg_3des_ecb(void)
static void crypto_test_enc_alg_3des_ecb(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_3DES_ECB,
- ODP_AUTH_ALG_NULL,
tdes_ecb_reference,
ARRAY_SIZE(tdes_ecb_reference));
}
@@ -2293,8 +1334,6 @@ static void crypto_test_enc_alg_3des_ecb(void)
static void crypto_test_dec_alg_3des_ecb(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_3DES_ECB,
- ODP_AUTH_ALG_NULL,
tdes_ecb_reference,
ARRAY_SIZE(tdes_ecb_reference));
}
@@ -2308,8 +1347,6 @@ static int check_alg_chacha20_poly1305(void)
static void crypto_test_enc_alg_chacha20_poly1305(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));
}
@@ -2317,8 +1354,6 @@ static void crypto_test_enc_alg_chacha20_poly1305(void)
static void crypto_test_dec_alg_chacha20_poly1305(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));
}
@@ -2331,8 +1366,6 @@ static int check_alg_aes_gcm(void)
static void crypto_test_enc_alg_aes_gcm(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));
}
@@ -2340,8 +1373,6 @@ static void crypto_test_enc_alg_aes_gcm(void)
static void crypto_test_dec_alg_aes_gcm(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));
}
@@ -2354,8 +1385,6 @@ static int check_alg_aes_ccm(void)
static void crypto_test_enc_alg_aes_ccm(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));
}
@@ -2363,8 +1392,6 @@ static void crypto_test_enc_alg_aes_ccm(void)
static void crypto_test_dec_alg_aes_ccm(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));
}
@@ -2377,8 +1404,6 @@ static int check_alg_aes_cbc(void)
static void crypto_test_enc_alg_aes_cbc(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_AES_CBC,
- ODP_AUTH_ALG_NULL,
aes_cbc_reference,
ARRAY_SIZE(aes_cbc_reference));
}
@@ -2386,8 +1411,6 @@ static void crypto_test_enc_alg_aes_cbc(void)
static void crypto_test_dec_alg_aes_cbc(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_AES_CBC,
- ODP_AUTH_ALG_NULL,
aes_cbc_reference,
ARRAY_SIZE(aes_cbc_reference));
}
@@ -2400,8 +1423,6 @@ static int check_alg_aes_ctr(void)
static void crypto_test_enc_alg_aes_ctr(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_AES_CTR,
- ODP_AUTH_ALG_NULL,
aes_ctr_reference,
ARRAY_SIZE(aes_ctr_reference));
}
@@ -2409,8 +1430,6 @@ static void crypto_test_enc_alg_aes_ctr(void)
static void crypto_test_dec_alg_aes_ctr(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_AES_CTR,
- ODP_AUTH_ALG_NULL,
aes_ctr_reference,
ARRAY_SIZE(aes_ctr_reference));
}
@@ -2423,8 +1442,6 @@ static int check_alg_aes_ecb(void)
static void crypto_test_enc_alg_aes_ecb(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_AES_ECB,
- ODP_AUTH_ALG_NULL,
aes_ecb_reference,
ARRAY_SIZE(aes_ecb_reference));
}
@@ -2432,8 +1449,6 @@ static void crypto_test_enc_alg_aes_ecb(void)
static void crypto_test_dec_alg_aes_ecb(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_AES_ECB,
- ODP_AUTH_ALG_NULL,
aes_ecb_reference,
ARRAY_SIZE(aes_ecb_reference));
}
@@ -2446,8 +1461,6 @@ static int check_alg_aes_cfb128(void)
static void crypto_test_enc_alg_aes_cfb128(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_AES_CFB128,
- ODP_AUTH_ALG_NULL,
aes_cfb128_reference,
ARRAY_SIZE(aes_cfb128_reference));
}
@@ -2455,8 +1468,6 @@ static void crypto_test_enc_alg_aes_cfb128(void)
static void crypto_test_dec_alg_aes_cfb128(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_AES_CFB128,
- ODP_AUTH_ALG_NULL,
aes_cfb128_reference,
ARRAY_SIZE(aes_cfb128_reference));
}
@@ -2469,8 +1480,6 @@ static int check_alg_aes_xts(void)
static void crypto_test_enc_alg_aes_xts(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_AES_XTS,
- ODP_AUTH_ALG_NULL,
aes_xts_reference,
ARRAY_SIZE(aes_xts_reference));
}
@@ -2478,8 +1487,6 @@ static void crypto_test_enc_alg_aes_xts(void)
static void crypto_test_dec_alg_aes_xts(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_AES_XTS,
- ODP_AUTH_ALG_NULL,
aes_xts_reference,
ARRAY_SIZE(aes_xts_reference));
}
@@ -2492,8 +1499,6 @@ static int check_alg_kasumi_f8(void)
static void crypto_test_enc_alg_kasumi_f8(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_KASUMI_F8,
- ODP_AUTH_ALG_NULL,
kasumi_f8_reference,
ARRAY_SIZE(kasumi_f8_reference));
}
@@ -2501,8 +1506,6 @@ static void crypto_test_enc_alg_kasumi_f8(void)
static void crypto_test_dec_alg_kasumi_f8(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_KASUMI_F8,
- ODP_AUTH_ALG_NULL,
kasumi_f8_reference,
ARRAY_SIZE(kasumi_f8_reference));
}
@@ -2515,8 +1518,6 @@ static int check_alg_snow3g_uea2(void)
static void crypto_test_enc_alg_snow3g_uea2(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_SNOW3G_UEA2,
- ODP_AUTH_ALG_NULL,
snow3g_uea2_reference,
ARRAY_SIZE(snow3g_uea2_reference));
}
@@ -2524,8 +1525,6 @@ static void crypto_test_enc_alg_snow3g_uea2(void)
static void crypto_test_dec_alg_snow3g_uea2(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_SNOW3G_UEA2,
- ODP_AUTH_ALG_NULL,
snow3g_uea2_reference,
ARRAY_SIZE(snow3g_uea2_reference));
}
@@ -2539,8 +1538,6 @@ static int check_alg_aes_eea2(void)
static void crypto_test_enc_alg_aes_eea2(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_AES_EEA2,
- ODP_AUTH_ALG_NULL,
aes_eea2_reference,
ARRAY_SIZE(aes_eea2_reference));
}
@@ -2548,8 +1545,6 @@ static void crypto_test_enc_alg_aes_eea2(void)
static void crypto_test_dec_alg_aes_eea2(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_AES_EEA2,
- ODP_AUTH_ALG_NULL,
aes_eea2_reference,
ARRAY_SIZE(aes_eea2_reference));
}
@@ -2562,8 +1557,6 @@ static int check_alg_zuc_eea3(void)
static void crypto_test_enc_alg_zuc_eea3(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_ZUC_EEA3,
- ODP_AUTH_ALG_NULL,
zuc_eea3_reference,
ARRAY_SIZE(zuc_eea3_reference));
}
@@ -2571,8 +1564,6 @@ static void crypto_test_enc_alg_zuc_eea3(void)
static void crypto_test_dec_alg_zuc_eea3(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_ZUC_EEA3,
- ODP_AUTH_ALG_NULL,
zuc_eea3_reference,
ARRAY_SIZE(zuc_eea3_reference));
}
@@ -2585,8 +1576,6 @@ static int check_alg_hmac_md5(void)
static void crypto_test_gen_alg_hmac_md5(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_MD5_HMAC,
hmac_md5_reference,
ARRAY_SIZE(hmac_md5_reference));
}
@@ -2594,8 +1583,6 @@ static void crypto_test_gen_alg_hmac_md5(void)
static void crypto_test_check_alg_hmac_md5(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_MD5_HMAC,
hmac_md5_reference,
ARRAY_SIZE(hmac_md5_reference));
}
@@ -2608,8 +1595,6 @@ static int check_alg_hmac_sha1(void)
static void crypto_test_gen_alg_hmac_sha1(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA1_HMAC,
hmac_sha1_reference,
ARRAY_SIZE(hmac_sha1_reference));
}
@@ -2617,8 +1602,6 @@ static void crypto_test_gen_alg_hmac_sha1(void)
static void crypto_test_check_alg_hmac_sha1(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA1_HMAC,
hmac_sha1_reference,
ARRAY_SIZE(hmac_sha1_reference));
}
@@ -2631,8 +1614,6 @@ static int check_alg_hmac_sha224(void)
static void crypto_test_gen_alg_hmac_sha224(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA224_HMAC,
hmac_sha224_reference,
ARRAY_SIZE(hmac_sha224_reference));
}
@@ -2640,8 +1621,6 @@ static void crypto_test_gen_alg_hmac_sha224(void)
static void crypto_test_check_alg_hmac_sha224(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA224_HMAC,
hmac_sha224_reference,
ARRAY_SIZE(hmac_sha224_reference));
}
@@ -2654,8 +1633,6 @@ static int check_alg_hmac_sha256(void)
static void crypto_test_gen_alg_hmac_sha256(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA256_HMAC,
hmac_sha256_reference,
ARRAY_SIZE(hmac_sha256_reference));
}
@@ -2663,8 +1640,6 @@ static void crypto_test_gen_alg_hmac_sha256(void)
static void crypto_test_check_alg_hmac_sha256(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA256_HMAC,
hmac_sha256_reference,
ARRAY_SIZE(hmac_sha256_reference));
}
@@ -2677,8 +1652,6 @@ static int check_alg_hmac_sha384(void)
static void crypto_test_gen_alg_hmac_sha384(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA384_HMAC,
hmac_sha384_reference,
ARRAY_SIZE(hmac_sha384_reference));
}
@@ -2686,8 +1659,6 @@ static void crypto_test_gen_alg_hmac_sha384(void)
static void crypto_test_check_alg_hmac_sha384(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA384_HMAC,
hmac_sha384_reference,
ARRAY_SIZE(hmac_sha384_reference));
}
@@ -2700,8 +1671,6 @@ static int check_alg_hmac_sha512(void)
static void crypto_test_gen_alg_hmac_sha512(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA512_HMAC,
hmac_sha512_reference,
ARRAY_SIZE(hmac_sha512_reference));
}
@@ -2709,8 +1678,6 @@ static void crypto_test_gen_alg_hmac_sha512(void)
static void crypto_test_check_alg_hmac_sha512(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA512_HMAC,
hmac_sha512_reference,
ARRAY_SIZE(hmac_sha512_reference));
}
@@ -2724,8 +1691,6 @@ static int check_alg_aes_xcbc(void)
static void crypto_test_gen_alg_aes_xcbc(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_AES_XCBC_MAC,
aes_xcbc_reference,
ARRAY_SIZE(aes_xcbc_reference));
}
@@ -2733,8 +1698,6 @@ static void crypto_test_gen_alg_aes_xcbc(void)
static void crypto_test_check_alg_aes_xcbc(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_AES_XCBC_MAC,
aes_xcbc_reference,
ARRAY_SIZE(aes_xcbc_reference));
}
@@ -2747,8 +1710,6 @@ static int check_alg_aes_gmac(void)
static void crypto_test_gen_alg_aes_gmac(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_AES_GMAC,
aes_gmac_reference,
ARRAY_SIZE(aes_gmac_reference));
}
@@ -2756,8 +1717,6 @@ static void crypto_test_gen_alg_aes_gmac(void)
static void crypto_test_check_alg_aes_gmac(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_AES_GMAC,
aes_gmac_reference,
ARRAY_SIZE(aes_gmac_reference));
}
@@ -2770,8 +1729,6 @@ static int check_alg_aes_cmac(void)
static void crypto_test_gen_alg_aes_cmac(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_AES_CMAC,
aes_cmac_reference,
ARRAY_SIZE(aes_cmac_reference));
}
@@ -2779,8 +1736,6 @@ static void crypto_test_gen_alg_aes_cmac(void)
static void crypto_test_check_alg_aes_cmac(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_AES_CMAC,
aes_cmac_reference,
ARRAY_SIZE(aes_cmac_reference));
}
@@ -2793,8 +1748,6 @@ static int check_alg_kasumi_f9(void)
static void crypto_test_gen_alg_kasumi_f9(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_KASUMI_F9,
kasumi_f9_reference,
ARRAY_SIZE(kasumi_f9_reference));
}
@@ -2802,8 +1755,6 @@ static void crypto_test_gen_alg_kasumi_f9(void)
static void crypto_test_check_alg_kasumi_f9(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_KASUMI_F9,
kasumi_f9_reference,
ARRAY_SIZE(kasumi_f9_reference));
}
@@ -2816,8 +1767,6 @@ static int check_alg_snow3g_uia2(void)
static void crypto_test_gen_alg_snow3g_uia2(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SNOW3G_UIA2,
snow3g_uia2_reference,
ARRAY_SIZE(snow3g_uia2_reference));
}
@@ -2825,8 +1774,6 @@ static void crypto_test_gen_alg_snow3g_uia2(void)
static void crypto_test_check_alg_snow3g_uia2(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SNOW3G_UIA2,
snow3g_uia2_reference,
ARRAY_SIZE(snow3g_uia2_reference));
}
@@ -2840,8 +1787,6 @@ static int check_alg_aes_eia2(void)
static void crypto_test_gen_alg_aes_eia2(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_AES_EIA2,
aes_eia2_reference,
ARRAY_SIZE(aes_eia2_reference));
}
@@ -2849,8 +1794,6 @@ static void crypto_test_gen_alg_aes_eia2(void)
static void crypto_test_check_alg_aes_eia2(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_AES_EIA2,
aes_eia2_reference,
ARRAY_SIZE(aes_eia2_reference));
}
@@ -2863,8 +1806,6 @@ static int check_alg_zuc_eia3(void)
static void crypto_test_gen_alg_zuc_eia3(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_ZUC_EIA3,
zuc_eia3_reference,
ARRAY_SIZE(zuc_eia3_reference));
}
@@ -2872,8 +1813,6 @@ static void crypto_test_gen_alg_zuc_eia3(void)
static void crypto_test_check_alg_zuc_eia3(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_ZUC_EIA3,
zuc_eia3_reference,
ARRAY_SIZE(zuc_eia3_reference));
}
@@ -2886,8 +1825,6 @@ static int check_alg_md5(void)
static void crypto_test_gen_alg_md5(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_MD5,
md5_reference,
ARRAY_SIZE(md5_reference));
}
@@ -2895,8 +1832,6 @@ static void crypto_test_gen_alg_md5(void)
static void crypto_test_check_alg_md5(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_MD5,
md5_reference,
ARRAY_SIZE(md5_reference));
}
@@ -2909,8 +1844,6 @@ static int check_alg_sha1(void)
static void crypto_test_gen_alg_sha1(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA1,
sha1_reference,
ARRAY_SIZE(sha1_reference));
}
@@ -2918,8 +1851,6 @@ static void crypto_test_gen_alg_sha1(void)
static void crypto_test_check_alg_sha1(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA1,
sha1_reference,
ARRAY_SIZE(sha1_reference));
}
@@ -2932,8 +1863,6 @@ static int check_alg_sha224(void)
static void crypto_test_gen_alg_sha224(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA224,
sha224_reference,
ARRAY_SIZE(sha224_reference));
}
@@ -2941,8 +1870,6 @@ static void crypto_test_gen_alg_sha224(void)
static void crypto_test_check_alg_sha224(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA224,
sha224_reference,
ARRAY_SIZE(sha224_reference));
}
@@ -2955,8 +1882,6 @@ static int check_alg_sha256(void)
static void crypto_test_gen_alg_sha256(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA256,
sha256_reference,
ARRAY_SIZE(sha256_reference));
}
@@ -2964,8 +1889,6 @@ static void crypto_test_gen_alg_sha256(void)
static void crypto_test_check_alg_sha256(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA256,
sha256_reference,
ARRAY_SIZE(sha256_reference));
}
@@ -2978,8 +1901,6 @@ static int check_alg_sha384(void)
static void crypto_test_gen_alg_sha384(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA384,
sha384_reference,
ARRAY_SIZE(sha384_reference));
}
@@ -2987,8 +1908,6 @@ static void crypto_test_gen_alg_sha384(void)
static void crypto_test_check_alg_sha384(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA384,
sha384_reference,
ARRAY_SIZE(sha384_reference));
}
@@ -3001,8 +1920,6 @@ static int check_alg_sha512(void)
static void crypto_test_gen_alg_sha512(void)
{
check_alg(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA512,
sha512_reference,
ARRAY_SIZE(sha512_reference));
}
@@ -3010,8 +1927,6 @@ static void crypto_test_gen_alg_sha512(void)
static void crypto_test_check_alg_sha512(void)
{
check_alg(ODP_CRYPTO_OP_DECODE,
- ODP_CIPHER_ALG_NULL,
- ODP_AUTH_ALG_SHA512,
sha512_reference,
ARRAY_SIZE(sha512_reference));
}
@@ -3068,7 +1983,7 @@ static int crypto_suite_packet_async_plain_init(void)
out_queue = plain_compl_queue_create();
if (ODP_QUEUE_INVALID == out_queue) {
- fprintf(stderr, "Crypto outq creation failed.\n");
+ ODPH_ERR("Crypto outq creation failed\n");
return -1;
}
suite_context.queue = out_queue;
@@ -3090,7 +2005,7 @@ static int crypto_suite_packet_async_sched_init(void)
out_queue = sched_compl_queue_create();
if (ODP_QUEUE_INVALID == out_queue) {
- fprintf(stderr, "Crypto outq creation failed.\n");
+ ODPH_ERR("Crypto outq creation failed\n");
return -1;
}
suite_context.queue = out_queue;
@@ -3104,9 +2019,9 @@ static int crypto_suite_term(void)
{
if (ODP_QUEUE_INVALID != suite_context.queue) {
if (odp_queue_destroy(suite_context.queue))
- fprintf(stderr, "Crypto outq destroy failed.\n");
+ ODPH_ERR("Crypto outq destroy failed\n");
} else {
- fprintf(stderr, "Crypto outq not found.\n");
+ ODPH_ERR("Crypto outq not found\n");
}
return odp_cunit_print_inactive();
@@ -3277,7 +2192,7 @@ static int crypto_init(odp_instance_t *inst)
odph_helper_options_t helper_options;
if (odph_options(&helper_options)) {
- fprintf(stderr, "error: odph_options() failed.\n");
+ ODPH_ERR("odph_options() failed\n");
return -1;
}
@@ -3285,23 +2200,23 @@ static int crypto_init(odp_instance_t *inst)
init_param.mem_model = helper_options.mem_model;
if (0 != odp_init_global(inst, &init_param, NULL)) {
- fprintf(stderr, "error: odp_init_global() failed.\n");
+ ODPH_ERR("odp_init_global() failed\n");
return -1;
}
if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) {
- fprintf(stderr, "error: odp_init_local() failed.\n");
+ ODPH_ERR("odp_init_local() failed\n");
return -1;
}
/* Configure the scheduler. */
if (odp_schedule_config(NULL)) {
- fprintf(stderr, "odp_schedule_config() failed.\n");
+ ODPH_ERR("odp_schedule_config() failed\n");
return -1;
}
if (odp_pool_capability(&pool_capa) < 0) {
- fprintf(stderr, "error: odp_pool_capability() failed.\n");
+ ODPH_ERR("odp_pool_capability() failed\n");
return -1;
}
@@ -3322,20 +2237,20 @@ static int crypto_init(odp_instance_t *inst)
if (pool_capa.pkt.max_seg_len &&
PKT_POOL_LEN > pool_capa.pkt.max_seg_len) {
- fprintf(stderr, "Warning: small packet segment length\n");
+ ODPH_ERR("Warning: small packet segment length\n");
params.pkt.seg_len = pool_capa.pkt.max_seg_len;
}
if (pool_capa.pkt.max_len &&
PKT_POOL_LEN > pool_capa.pkt.max_len) {
- fprintf(stderr, "Pool max packet length too small\n");
+ ODPH_ERR("Pool max packet length too small\n");
return -1;
}
pool = odp_pool_create("packet_pool", &params);
if (ODP_POOL_INVALID == pool) {
- fprintf(stderr, "Packet pool creation failed.\n");
+ ODPH_ERR("Packet pool creation failed\n");
return -1;
}
@@ -3349,18 +2264,18 @@ static int crypto_term(odp_instance_t inst)
pool = odp_pool_lookup("packet_pool");
if (ODP_POOL_INVALID != pool) {
if (odp_pool_destroy(pool))
- fprintf(stderr, "Packet pool destroy failed.\n");
+ ODPH_ERR("Packet pool destroy failed\n");
} else {
- fprintf(stderr, "Packet pool not found.\n");
+ ODPH_ERR("Packet pool not found\n");
}
if (0 != odp_term_local()) {
- fprintf(stderr, "error: odp_term_local() failed.\n");
+ ODPH_ERR("odp_term_local() failed\n");
return -1;
}
if (0 != odp_term_global(inst)) {
- fprintf(stderr, "error: odp_term_global() failed.\n");
+ ODPH_ERR("odp_term_global() failed\n");
return -1;
}
diff --git a/test/validation/api/crypto/test_vector_defs.h b/test/validation/api/crypto/test_vector_defs.h
new file mode 100644
index 000000000..46ae4e4e1
--- /dev/null
+++ b/test/validation/api/crypto/test_vector_defs.h
@@ -0,0 +1,3167 @@
+/* Copyright (c) 2014-2018, Linaro Limited
+ * Copyright (c) 2021-2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef TEST_VECTOR_DEFS_H
+#define TEST_VECTOR_DEFS_H
+
+#include <odp_api.h>
+#include "test_vectors.h"
+
+ODP_STATIC_ASSERT(ODP_CIPHER_ALG_NULL == 0, "null cipher is not the default");
+ODP_STATIC_ASSERT(ODP_AUTH_ALG_NULL == 0, "null auth is not the default");
+
+static crypto_test_reference_t null_reference[] = {
+ {
+ .length = 8,
+ .plaintext = { 0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56 },
+ .ciphertext = { 0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56 }
+ },
+ {
+ .length = 16,
+ .plaintext = { 0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87,
+ 0x6d, 0x8e, 0xa2, 0x30, 0x94, 0xea, 0x53, 0x09 },
+ .ciphertext = { 0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87,
+ 0x6d, 0x8e, 0xa2, 0x30, 0x94, 0xea, 0x53, 0x09 }
+ }
+};
+
+/* TDES-CBC reference vectors, according to
+ * "http://csrc.nist.gov/groups/STM/cavp/documents/des/DESMMT.pdf"
+ */
+static crypto_test_reference_t tdes_cbc_reference[] = {
+ {
+ .cipher = ODP_CIPHER_ALG_3DES_CBC,
+ .cipher_key_length = TDES_CBC_KEY_LEN,
+ .cipher_key = { 0x62, 0x7f, 0x46, 0x0e, 0x08, 0x10, 0x4a, 0x10,
+ 0x43, 0xcd, 0x26, 0x5d, 0x58, 0x40, 0xea, 0xf1,
+ 0x31, 0x3e, 0xdf, 0x97, 0xdf, 0x2a, 0x8a, 0x8c},
+ .cipher_iv_length = TDES_CBC_IV_LEN,
+ .cipher_iv = { 0x8e, 0x29, 0xf7, 0x5e, 0xa7, 0x7e, 0x54, 0x75 },
+ .length = 8,
+ .plaintext = { 0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56 },
+ .ciphertext = { 0xb2, 0x2b, 0x8d, 0x66, 0xde, 0x97, 0x06, 0x92 }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_3DES_CBC,
+ .cipher_key_length = TDES_CBC_KEY_LEN,
+ .cipher_key = { 0x37, 0xae, 0x5e, 0xbf, 0x46, 0xdf, 0xf2, 0xdc,
+ 0x07, 0x54, 0xb9, 0x4f, 0x31, 0xcb, 0xb3, 0x85,
+ 0x5e, 0x7f, 0xd3, 0x6d, 0xc8, 0x70, 0xbf, 0xae},
+ .cipher_iv_length = TDES_CBC_IV_LEN,
+ .cipher_iv = {0x3d, 0x1d, 0xe3, 0xcc, 0x13, 0x2e, 0x3b, 0x65 },
+ .length = 16,
+ .plaintext = { 0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87,
+ 0x6d, 0x8e, 0xa2, 0x30, 0x94, 0xea, 0x53, 0x09 },
+ .ciphertext = { 0x7b, 0x1f, 0x7c, 0x7e, 0x3b, 0x1c, 0x94, 0x8e,
+ 0xbd, 0x04, 0xa7, 0x5f, 0xfb, 0xa7, 0xd2, 0xf5 }
+ }
+};
+
+/*
+ * TDES-ECB reference vectors, according to
+ * CAVS 18.0 TECBMMT
+ */
+static crypto_test_reference_t tdes_ecb_reference[] = {
+ /* CAVS 18.0 TECBMMT2.rsp #0 */
+ {
+ .cipher = ODP_CIPHER_ALG_3DES_ECB,
+ .cipher_key_length = TDES_ECB_KEY_LEN,
+ .cipher_key = { 0x15, 0x1f, 0x10, 0x38, 0x3d, 0x6d, 0x19, 0x9b,
+ 0x4a, 0x76, 0x3b, 0xd5, 0x4a, 0x46, 0xa4, 0x45,
+ 0x15, 0x1f, 0x10, 0x38, 0x3d, 0x6d, 0x19, 0x9b},
+ .length = 8,
+ .plaintext = { 0xd8, 0xda, 0x89, 0x29, 0x88, 0x78, 0xed, 0x7d },
+ .ciphertext = { 0x89, 0x32, 0x1b, 0xa7, 0x5b, 0xa5, 0x45, 0xdb }
+ },
+ /* CAVS 18.0 TECBMMT2.rsp #2 */
+ {
+ .cipher = ODP_CIPHER_ALG_3DES_ECB,
+ .cipher_key_length = TDES_ECB_KEY_LEN,
+ .cipher_key = { 0xcd, 0x3d, 0x9b, 0xf7, 0x2f, 0x8c, 0x8a, 0xb5,
+ 0xfe, 0xe6, 0x73, 0x34, 0x31, 0x1c, 0xa4, 0x62,
+ 0xcd, 0x3d, 0x9b, 0xf7, 0x2f, 0x8c, 0x8a, 0xb5},
+ .length = 24,
+ .plaintext = { 0x2f, 0x2a, 0x36, 0x1c, 0x8e, 0x14, 0x5d, 0xc0,
+ 0xa7, 0x4a, 0x1b, 0xdb, 0x7c, 0xa9, 0x29, 0xc3,
+ 0x38, 0x14, 0x4d, 0x89, 0x13, 0x5b, 0x50, 0xa7 },
+ .ciphertext = { 0x7f, 0x1f, 0xd3, 0x2b, 0x36, 0x90, 0x05, 0x4b,
+ 0xfa, 0x1b, 0x17, 0x35, 0x15, 0x79, 0x33, 0x80,
+ 0x99, 0xff, 0xa8, 0x4f, 0xea, 0x16, 0x8c, 0x6b }
+ }
+};
+
+static crypto_test_reference_t aes_cbc_reference[] = {
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CBC,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
+ 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06},
+ .cipher_iv_length = AES_CBC_IV_LEN,
+ .cipher_iv = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
+ 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
+ .length = 16,
+ .plaintext = "Single block msg",
+ .ciphertext = { 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8,
+ 0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CBC,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
+ 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a},
+ .cipher_iv_length = AES_CBC_IV_LEN,
+ .cipher_iv = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
+ 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
+ .length = 32,
+ .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
+ .ciphertext = { 0xd2, 0x96, 0xcd, 0x94, 0xc2, 0xcc, 0xcf, 0x8a,
+ 0x3a, 0x86, 0x30, 0x28, 0xb5, 0xe1, 0xdc, 0x0a,
+ 0x75, 0x86, 0x60, 0x2d, 0x25, 0x3c, 0xff, 0xf9,
+ 0x1b, 0x82, 0x66, 0xbe, 0xa6, 0xd6, 0x1a, 0xb1 }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CBC,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0x6c, 0x3e, 0xa0, 0x47, 0x76, 0x30, 0xce, 0x21,
+ 0xa2, 0xce, 0x33, 0x4a, 0xa7, 0x46, 0xc2, 0xcd},
+ .cipher_iv_length = AES_CBC_IV_LEN,
+ .cipher_iv = { 0xc7, 0x82, 0xdc, 0x4c, 0x09, 0x8c, 0x66, 0xcb,
+ 0xd9, 0xcd, 0x27, 0xd8, 0x25, 0x68, 0x2c, 0x81 },
+ .length = 48,
+ .plaintext = "This is a 48-byte message (exactly 3 AES blocks)",
+ .ciphertext = { 0xd0, 0xa0, 0x2b, 0x38, 0x36, 0x45, 0x17, 0x53,
+ 0xd4, 0x93, 0x66, 0x5d, 0x33, 0xf0, 0xe8, 0x86,
+ 0x2d, 0xea, 0x54, 0xcd, 0xb2, 0x93, 0xab, 0xc7,
+ 0x50, 0x69, 0x39, 0x27, 0x67, 0x72, 0xf8, 0xd5,
+ 0x02, 0x1c, 0x19, 0x21, 0x6b, 0xad, 0x52, 0x5c,
+ 0x85, 0x79, 0x69, 0x5d, 0x83, 0xba, 0x26, 0x84 }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CBC,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0x56, 0xe4, 0x7a, 0x38, 0xc5, 0x59, 0x89, 0x74,
+ 0xbc, 0x46, 0x90, 0x3d, 0xba, 0x29, 0x03, 0x49},
+ .cipher_iv_length = AES_CBC_IV_LEN,
+ .cipher_iv = { 0x8c, 0xe8, 0x2e, 0xef, 0xbe, 0xa0, 0xda, 0x3c,
+ 0x44, 0x69, 0x9e, 0xd7, 0xdb, 0x51, 0xb7, 0xd9 },
+ .length = 64,
+ .plaintext = { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad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 0x23, 0x45, 0x67 },
+ .length = 32,
+ .plaintext = { 0x45, 0x00, 0x00, 0x28, 0xa4, 0xad, 0x40, 0x00,
+ 0x40, 0x06, 0x78, 0x80, 0x0a, 0x01, 0x03, 0x8f,
+ 0x0a, 0x01, 0x06, 0x12, 0x80, 0x23, 0x06, 0xb8,
+ 0xcb, 0x71, 0x26, 0x02, 0xdd, 0x6b, 0xb0, 0x3e },
+ .ciphertext = { 0x0d, 0xbe, 0x02, 0xda, 0x68, 0x9c, 0x8f, 0x30,
+ 0xce, 0x7c, 0x91, 0x7d, 0x41, 0x08, 0xf6, 0xf1,
+ 0x8e, 0x0d, 0x7f, 0x02, 0xb6, 0x80, 0x9a, 0x2d,
+ 0x53, 0x1c, 0xc6, 0x98, 0x85, 0xc3, 0x00, 0xe6},
+ },
+ /* NIST Special Publication 800-38A */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CBC,
+ .cipher_key_length = AES192_KEY_LEN,
+ .cipher_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52,
+ 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
+ 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b},
+ .cipher_iv_length = AES_CBC_IV_LEN,
+ .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+ .length = 64,
+ .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
+ 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
+ 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
+ 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
+ .ciphertext = { 0x4f, 0x02, 0x1d, 0xb2, 0x43, 0xbc, 0x63, 0x3d,
+ 0x71, 0x78, 0x18, 0x3a, 0x9f, 0xa0, 0x71, 0xe8,
+ 0xb4, 0xd9, 0xad, 0xa9, 0xad, 0x7d, 0xed, 0xf4,
+ 0xe5, 0xe7, 0x38, 0x76, 0x3f, 0x69, 0x14, 0x5a,
+ 0x57, 0x1b, 0x24, 0x20, 0x12, 0xfb, 0x7a, 0xe0,
+ 0x7f, 0xa9, 0xba, 0xac, 0x3d, 0xf1, 0x02, 0xe0,
+ 0x08, 0xb0, 0xe2, 0x79, 0x88, 0x59, 0x88, 0x81,
+ 0xd9, 0x20, 0xa9, 0xe6, 0x4f, 0x56, 0x15, 0xcd }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CBC,
+ .cipher_key_length = AES256_KEY_LEN,
+ .cipher_key = { 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23,
+ 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab,
+ 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23,
+ 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab},
+ .cipher_iv_length = AES_CBC_IV_LEN,
+ .cipher_iv = { 0x11, 0x22, 0x33, 0x44, 0x01, 0x02, 0x03, 0x04,
+ 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c },
+ .length = 48,
+ .plaintext = { 0x45, 0x00, 0x00, 0x30, 0x69, 0xa6, 0x40, 0x00,
+ 0x80, 0x06, 0x26, 0x90, 0xc0, 0xa8, 0x01, 0x02,
+ 0x93, 0x89, 0x15, 0x5e, 0x0a, 0x9e, 0x00, 0x8b,
+ 0x2d, 0xc5, 0x7e, 0xe0, 0x00, 0x00, 0x00, 0x00,
+ 0x70, 0x02, 0x40, 0x00, 0x20, 0xbf, 0x00, 0x00,
+ 0x02, 0x04, 0x05, 0xb4, 0x01, 0x01, 0x04, 0x02 },
+ .ciphertext = { 0x92, 0x1e, 0x2f, 0x37, 0x36, 0x3c, 0x45, 0xda,
+ 0xc9, 0x58, 0xb7, 0x07, 0x06, 0x56, 0x54, 0xc5,
+ 0x93, 0x46, 0x90, 0xb8, 0xcf, 0x0d, 0x4f, 0x79,
+ 0xf1, 0x32, 0xc2, 0xf7, 0x23, 0xb8, 0x83, 0x09,
+ 0xbc, 0x37, 0x1c, 0xeb, 0x95, 0x2c, 0x42, 0x7b,
+ 0x39, 0x10, 0xa8, 0x76, 0xfa, 0xbe, 0x91, 0xe9},
+ },
+ /* NIST Special Publication 800-38A */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CBC,
+ .cipher_key_length = AES256_KEY_LEN,
+ .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
+ 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
+ 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
+ 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4},
+ .cipher_iv_length = AES_CBC_IV_LEN,
+ .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+ .length = 64,
+ .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
+ 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
+ 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
+ 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
+ .ciphertext = { 0xf5, 0x8c, 0x4c, 0x04, 0xd6, 0xe5, 0xf1, 0xba,
+ 0x77, 0x9e, 0xab, 0xfb, 0x5f, 0x7b, 0xfb, 0xd6,
+ 0x9c, 0xfc, 0x4e, 0x96, 0x7e, 0xdb, 0x80, 0x8d,
+ 0x67, 0x9f, 0x77, 0x7b, 0xc6, 0x70, 0x2c, 0x7d,
+ 0x39, 0xf2, 0x33, 0x69, 0xa9, 0xd9, 0xba, 0xcf,
+ 0xa5, 0x30, 0xe2, 0x63, 0x04, 0x23, 0x14, 0x61,
+ 0xb2, 0xeb, 0x05, 0xe2, 0xc3, 0x9b, 0xe9, 0xfc,
+ 0xda, 0x6c, 0x19, 0x07, 0x8c, 0x6a, 0x9d, 0x1b }
+ }
+};
+
+static crypto_test_reference_t aes_ctr_reference[] = {
+ /* RFC3686 https://tools.ietf.org/html/rfc3686 */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CTR,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7,
+ 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63},
+ .cipher_iv_length = AES_CTR_IV_LEN,
+ .cipher_iv = { 0x00, 0x6C, 0xB6, 0xDB, 0xC0, 0x54, 0x3B, 0x59,
+ 0xDA, 0x48, 0xD9, 0x0B, 0x00, 0x00, 0x00, 0x01 },
+ .length = 32,
+ .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F },
+ .ciphertext = { 0x51, 0x04, 0xA1, 0x06, 0x16, 0x8A, 0x72, 0xD9,
+ 0x79, 0x0D, 0x41, 0xEE, 0x8E, 0xDA, 0xD3, 0x88,
+ 0xEB, 0x2E, 0x1E, 0xFC, 0x46, 0xDA, 0x57, 0xC8,
+ 0xFC, 0xE6, 0x30, 0xDF, 0x91, 0x41, 0xBE, 0x28}
+ },
+ /* NIST Special Publication 800-38A */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CTR,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c},
+ .cipher_iv_length = AES_CTR_IV_LEN,
+ .cipher_iv = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
+ .length = 64,
+ .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
+ 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
+ 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
+ 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
+ .ciphertext = { 0x87, 0x4d, 0x61, 0x91, 0xb6, 0x20, 0xe3, 0x26,
+ 0x1b, 0xef, 0x68, 0x64, 0x99, 0x0d, 0xb6, 0xce,
+ 0x98, 0x06, 0xf6, 0x6b, 0x79, 0x70, 0xfd, 0xff,
+ 0x86, 0x17, 0x18, 0x7b, 0xb9, 0xff, 0xfd, 0xff,
+ 0x5a, 0xe4, 0xdf, 0x3e, 0xdb, 0xd5, 0xd3, 0x5e,
+ 0x5b, 0x4f, 0x09, 0x02, 0x0d, 0xb0, 0x3e, 0xab,
+ 0x1e, 0x03, 0x1d, 0xda, 0x2f, 0xbe, 0x03, 0xd1,
+ 0x79, 0x21, 0x70, 0xa0, 0xf3, 0x00, 0x9c, 0xee }
+ },
+ /* Generated by Crypto++ 5.6.1 (715 bytes data)*/
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CTR,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c},
+ .cipher_iv_length = AES_CTR_IV_LEN,
+ .cipher_iv = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
+ .length = 715,
+ .plaintext = { 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f,
+ 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17,
+ 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac,
+ 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e,
+ 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4,
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x78, 0x67, 0x70,
+ 0xA8, 0x4E, 0xA1, 0xA0, 0x7C, 0xB6, 0xE1, 0xA9,
+ 0x90, 0x7D, 0x65, 0x1B, 0xBD, 0x0E, 0xFD, 0xEF,
+ 0x2A, 0xFF, 0xC3 }
+ },
+ /* RFC3686 https://tools.ietf.org/html/rfc3686 */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CTR,
+ .cipher_key_length = AES192_KEY_LEN,
+ .cipher_key = { 0x02, 0xBF, 0x39, 0x1E, 0xE8, 0xEC, 0xB1, 0x59,
+ 0xB9, 0x59, 0x61, 0x7B, 0x09, 0x65, 0x27, 0x9B,
+ 0xF5, 0x9B, 0x60, 0xA7, 0x86, 0xD3, 0xE0, 0xFE},
+ .cipher_iv_length = AES_CTR_IV_LEN,
+ .cipher_iv = { 0x00, 0x07, 0xBD, 0xFD, 0x5C, 0xBD, 0x60, 0x27,
+ 0x8D, 0xCC, 0x09, 0x12, 0x00, 0x00, 0x00, 0x01 },
+ .length = 36,
+ .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
+ 0x20, 0x21, 0x22, 0x23 },
+ .ciphertext = { 0x96, 0x89, 0x3F, 0xC5, 0x5E, 0x5C, 0x72, 0x2F,
+ 0x54, 0x0B, 0x7D, 0xD1, 0xDD, 0xF7, 0xE7, 0x58,
+ 0xD2, 0x88, 0xBC, 0x95, 0xC6, 0x91, 0x65, 0x88,
+ 0x45, 0x36, 0xC8, 0x11, 0x66, 0x2F, 0x21, 0x88,
+ 0xAB, 0xEE, 0x09, 0x35 }
+ },
+ /* NIST Special Publication 800-38A */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CTR,
+ .cipher_key_length = AES192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x98, 0x09, 0x58,
+ 0x5a, 0x97, 0xda, 0xec, 0x58, 0xc6, 0xb0, 0x50 }
+ },
+ /* RFC3686 https://tools.ietf.org/html/rfc3686 */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CTR,
+ .cipher_key_length = AES256_KEY_LEN,
+ .cipher_key = { 0xFF, 0x7A, 0x61, 0x7C, 0xE6, 0x91, 0x48, 0xE4,
+ 0xF1, 0x72, 0x6E, 0x2F, 0x43, 0x58, 0x1D, 0xE2,
+ 0xAA, 0x62, 0xD9, 0xF8, 0x05, 0x53, 0x2E, 0xDF,
+ 0xF1, 0xEE, 0xD6, 0x87, 0xFB, 0x54, 0x15, 0x3D},
+ .cipher_iv_length = AES_CTR_IV_LEN,
+ .cipher_iv = { 0x00, 0x1C, 0xC5, 0xB7, 0x51, 0xA5, 0x1D, 0x70,
+ 0xA1, 0xC1, 0x11, 0x48, 0x00, 0x00, 0x00, 0x01 },
+ .length = 36,
+ .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
+ 0x20, 0x21, 0x22, 0x23 },
+ .ciphertext = { 0xEB, 0x6C, 0x52, 0x82, 0x1D, 0x0B, 0xBB, 0xF7,
+ 0xCE, 0x75, 0x94, 0x46, 0x2A, 0xCA, 0x4F, 0xAA,
+ 0xB4, 0x07, 0xDF, 0x86, 0x65, 0x69, 0xFD, 0x07,
+ 0xF4, 0x8C, 0xC0, 0xB5, 0x83, 0xD6, 0x07, 0x1F,
+ 0x1E, 0xC0, 0xE6, 0xB8 },
+ },
+ /* NIST Special Publication 800-38A */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CTR,
+ .cipher_key_length = AES256_KEY_LEN,
+ .cipher_key =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9, 0xc5, 0x8d, 0xb6, 0x7a, 0xad, 0xa6,
+ 0x13, 0xc2, 0xdd, 0x08, 0x45, 0x79, 0x41, 0xa6 }
+ },
+};
+
+static crypto_test_reference_t aes_ecb_reference[] = {
+ /* NIST Special Publication 800-38A */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_ECB,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c},
+ .length = 64,
+ .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
+ 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
+ 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
+ 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10},
+ .ciphertext = { 0x3a, 0xd7, 0x7b, 0xb4, 0x0d, 0x7a, 0x36, 0x60,
+ 0xa8, 0x9e, 0xca, 0xf3, 0x24, 0x66, 0xef, 0x97,
+ 0xf5, 0xd3, 0xd5, 0x85, 0x03, 0xb9, 0x69, 0x9d,
+ 0xe7, 0x85, 0x89, 0x5a, 0x96, 0xfd, 0xba, 0xaf,
+ 0x43, 0xb1, 0xcd, 0x7f, 0x59, 0x8e, 0xce, 0x23,
+ 0x88, 0x1b, 0x00, 0xe3, 0xed, 0x03, 0x06, 0x88,
+ 0x7b, 0x0c, 0x78, 0x5e, 0x27, 0xe8, 0xad, 0x3f,
+ 0x82, 0x23, 0x20, 0x71, 0x04, 0x72, 0x5d, 0xd4 }
+ },
+ /* Generated by Crypto++ 5.6.1 (528 bytes) */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_ECB,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c},
+ .length = 528,
+ .plaintext = { 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f,
+ 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17,
+ 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac,
+ 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e,
+ 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4,
+ 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52,
+ 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b,
+ 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37,
+ 0x10, 0x00, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e,
+ 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,
+ 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e,
+ 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45,
+ 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3,
+ 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a,
+ 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf,
+ 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0x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 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
+ .ciphertext = { 0xbd, 0x33, 0x4f, 0x1d, 0x6e, 0x45, 0xf2, 0x5f,
+ 0xf7, 0x12, 0xa2, 0x14, 0x57, 0x1f, 0xa5, 0xcc,
+ 0x97, 0x41, 0x04, 0x84, 0x6d, 0x0a, 0xd3, 0xad,
+ 0x77, 0x34, 0xec, 0xb3, 0xec, 0xee, 0x4e, 0xef,
+ 0xef, 0x7a, 0xfd, 0x22, 0x70, 0xe2, 0xe6, 0x0a,
+ 0xdc, 0xe0, 0xba, 0x2f, 0xac, 0xe6, 0x44, 0x4e,
+ 0x9a, 0x4b, 0x41, 0xba, 0x73, 0x8d, 0x6c, 0x72,
+ 0xfb, 0x16, 0x69, 0x16, 0x03, 0xc1, 0x8e, 0x0e }
+ },
+ /* NIST Special Publication 800-38A */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_ECB,
+ .cipher_key_length = AES256_KEY_LEN,
+ .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
+ 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
+ 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
+ 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4},
+ .length = 64,
+ .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
+ 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
+ 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
+ 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
+ .ciphertext = { 0xf3, 0xee, 0xd1, 0xbd, 0xb5, 0xd2, 0xa0, 0x3c,
+ 0x06, 0x4b, 0x5a, 0x7e, 0x3d, 0xb1, 0x81, 0xf8,
+ 0x59, 0x1c, 0xcb, 0x10, 0xd4, 0x10, 0xed, 0x26,
+ 0xdc, 0x5b, 0xa7, 0x4a, 0x31, 0x36, 0x28, 0x70,
+ 0xb6, 0xed, 0x21, 0xb9, 0x9c, 0xa6, 0xf4, 0xf9,
+ 0xf1, 0x53, 0xe7, 0xb1, 0xbe, 0xaf, 0xed, 0x1d,
+ 0x23, 0x30, 0x4b, 0x7a, 0x39, 0xf9, 0xf3, 0xff,
+ 0x06, 0x7d, 0x8d, 0x8f, 0x9e, 0x24, 0xec, 0xc7}
+ }
+};
+
+static crypto_test_reference_t aes_cfb128_reference[] = {
+ /* NIST Special Publication 800-38A */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CFB128,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c},
+ .cipher_iv_length = AES_CFB128_IV_LEN,
+ .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+ .length = 64,
+ .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
+ 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
+ 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
+ 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10},
+ .ciphertext = { 0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20,
+ 0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a,
+ 0xc8, 0xa6, 0x45, 0x37, 0xa0, 0xb3, 0xa9, 0x3f,
+ 0xcd, 0xe3, 0xcd, 0xad, 0x9f, 0x1c, 0xe5, 0x8b,
+ 0x26, 0x75, 0x1f, 0x67, 0xa3, 0xcb, 0xb1, 0x40,
+ 0xb1, 0x80, 0x8c, 0xf1, 0x87, 0xa4, 0xf4, 0xdf,
+ 0xc0, 0x4b, 0x05, 0x35, 0x7c, 0x5d, 0x1c, 0x0e,
+ 0xea, 0xc4, 0xc6, 0x6f, 0x9f, 0xf7, 0xf2, 0xe6 }
+ },
+ /* NIST Special Publication 800-38A */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CFB128,
+ .cipher_key_length = AES192_KEY_LEN,
+ .cipher_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52,
+ 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
+ 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b},
+ .cipher_iv_length = AES_CFB128_IV_LEN,
+ .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+ .length = 64,
+ .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
+ 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
+ 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
+ 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
+ .ciphertext = { 0xcd, 0xc8, 0x0d, 0x6f, 0xdd, 0xf1, 0x8c, 0xab,
+ 0x34, 0xc2, 0x59, 0x09, 0xc9, 0x9a, 0x41, 0x74,
+ 0x67, 0xce, 0x7f, 0x7f, 0x81, 0x17, 0x36, 0x21,
+ 0x96, 0x1a, 0x2b, 0x70, 0x17, 0x1d, 0x3d, 0x7a,
+ 0x2e, 0x1e, 0x8a, 0x1d, 0xd5, 0x9b, 0x88, 0xb1,
+ 0xc8, 0xe6, 0x0f, 0xed, 0x1e, 0xfa, 0xc4, 0xc9,
+ 0xc0, 0x5f, 0x9f, 0x9c, 0xa9, 0x83, 0x4f, 0xa0,
+ 0x42, 0xae, 0x8f, 0xba, 0x58, 0x4b, 0x09, 0xff }
+ },
+ /* NIST Special Publication 800-38A */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CFB128,
+ .cipher_key_length = AES256_KEY_LEN,
+ .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
+ 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
+ 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
+ 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4},
+ .cipher_iv_length = AES_CFB128_IV_LEN,
+ .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+ .length = 64,
+ .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
+ 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
+ 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
+ 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
+ .ciphertext = { 0xdc, 0x7e, 0x84, 0xbf, 0xda, 0x79, 0x16, 0x4b,
+ 0x7e, 0xcd, 0x84, 0x86, 0x98, 0x5d, 0x38, 0x60,
+ 0x39, 0xff, 0xed, 0x14, 0x3b, 0x28, 0xb1, 0xc8,
+ 0x32, 0x11, 0x3c, 0x63, 0x31, 0xe5, 0x40, 0x7b,
+ 0xdf, 0x10, 0x13, 0x24, 0x15, 0xe5, 0x4b, 0x92,
+ 0xa1, 0x3e, 0xd0, 0xa8, 0x26, 0x7a, 0xe2, 0xf9,
+ 0x75, 0xa3, 0x85, 0x74, 0x1a, 0xb9, 0xce, 0xf8,
+ 0x20, 0x31, 0x62, 0x3d, 0x55, 0xb1, 0xe4, 0x71 }
+ }
+};
+
+static crypto_test_reference_t aes_xts_reference[] = {
+ /* CAVS 11.0 XTSGen information, #1 */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_XTS,
+ .cipher_key_length = AES128_XTS_KEY_LEN,
+ .cipher_key = { 0xa1, 0xb9, 0x0c, 0xba, 0x3f, 0x06, 0xac, 0x35,
+ 0x3b, 0x2c, 0x34, 0x38, 0x76, 0x08, 0x17, 0x62,
+ 0x09, 0x09, 0x23, 0x02, 0x6e, 0x91, 0x77, 0x18,
+ 0x15, 0xf2, 0x9d, 0xab, 0x01, 0x93, 0x2f, 0x2f},
+ .cipher_iv_length = AES_XTS_IV_LEN,
+ .cipher_iv = { 0x4f, 0xae, 0xf7, 0x11, 0x7c, 0xda, 0x59, 0xc6,
+ 0x6e, 0x4b, 0x92, 0x01, 0x3e, 0x76, 0x8a, 0xd5},
+ .length = 16,
+ .plaintext = { 0xeb, 0xab, 0xce, 0x95, 0xb1, 0x4d, 0x3c, 0x8d,
+ 0x6f, 0xb3, 0x50, 0x39, 0x07, 0x90, 0x31, 0x1c},
+ .ciphertext = { 0x77, 0x8a, 0xe8, 0xb4, 0x3c, 0xb9, 0x8d, 0x5a,
+ 0x82, 0x50, 0x81, 0xd5, 0xbe, 0x47, 0x1c, 0x63}
+ },
+ /* CAVS 11.0 XTSGen information, #101 */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_XTS,
+ .cipher_key_length = AES128_XTS_KEY_LEN,
+ .cipher_key = { 0xb7, 0xb9, 0x3f, 0x51, 0x6a, 0xef, 0x29, 0x5e,
+ 0xff, 0x3a, 0x29, 0xd8, 0x37, 0xcf, 0x1f, 0x13,
+ 0x53, 0x47, 0xe8, 0xa2, 0x1d, 0xae, 0x61, 0x6f,
+ 0xf5, 0x06, 0x2b, 0x2e, 0x8d, 0x78, 0xce, 0x5e},
+ .cipher_iv_length = AES_XTS_IV_LEN,
+ .cipher_iv = { 0x87, 0x3e, 0xde, 0xa6, 0x53, 0xb6, 0x43, 0xbd,
+ 0x8b, 0xcf, 0x51, 0x40, 0x31, 0x97, 0xed, 0x14},
+ .length = 32,
+ .plaintext = { 0x23, 0x6f, 0x8a, 0x5b, 0x58, 0xdd, 0x55, 0xf6,
+ 0x19, 0x4e, 0xd7, 0x0c, 0x4a, 0xc1, 0xa1, 0x7f,
+ 0x1f, 0xe6, 0x0e, 0xc9, 0xa6, 0xc4, 0x54, 0xd0,
+ 0x87, 0xcc, 0xb7, 0x7d, 0x6b, 0x63, 0x8c, 0x47},
+ .ciphertext = { 0x22, 0xe6, 0xa3, 0xc6, 0x37, 0x9d, 0xcf, 0x75,
+ 0x99, 0xb0, 0x52, 0xb5, 0xa7, 0x49, 0xc7, 0xf7,
+ 0x8a, 0xd8, 0xa1, 0x1b, 0x9f, 0x1a, 0xa9, 0x43,
+ 0x0c, 0xf3, 0xae, 0xf4, 0x45, 0x68, 0x2e, 0x19}
+ },
+ /* CAVS 11.0 XTSGen information, #227 TODO (Length 130 bits)*/
+ /* {
+ .cipher = ODP_CIPHER_ALG_AES_XTS,
+ .cipher_key_length = AES128_XTS_KEY_LEN,
+ .cipher_key = { 0xec, 0x14, 0xc0, 0xa3, 0xb7, 0x72, 0x58, 0x5c,
+ 0x15, 0xd4, 0xeb, 0x94, 0xe6, 0x9e, 0x2c, 0x55,
+ 0x80, 0xcf, 0x3a, 0x63, 0xc1, 0x7c, 0xe9, 0xda,
+ 0xd8, 0x2b, 0xb4, 0x54, 0xe3, 0x87, 0x90, 0x45},
+ .cipher_iv_length = AES_XTS_IV_LEN,
+ .cipher_iv = { 0x4a, 0x02, 0x87, 0xc2, 0x6e, 0xd2, 0x41, 0x26,
+ 0x5b, 0x3a, 0x42, 0xcd, 0xd1, 0x9c, 0xea, 0xe2},
+ .length = 17,
+ .plaintext = { 0x50, 0x82, 0x64, 0x75, 0x82, 0xc6, 0xe5, 0xa7,
+ 0x88, 0x73, 0x6f, 0xc5, 0x90, 0x5e, 0xa5, 0x65,
+ 0xc0 },
+ .ciphertext = { 0x04, 0x3a, 0xb9, 0xc0, 0x3d, 0x5b, 0x44, 0x13,
+ 0x1d, 0x3e, 0x6e, 0xb2, 0x57, 0x61, 0x89, 0xde,
+ 0x80 },
+ }, */
+ /* CAVS 11.0 XTSGen information, #1 */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_XTS,
+ .cipher_key_length = AES256_XTS_KEY_LEN,
+ .cipher_key = { 0x1e, 0xa6, 0x61, 0xc5, 0x8d, 0x94, 0x3a, 0x0e,
+ 0x48, 0x01, 0xe4, 0x2f, 0x4b, 0x09, 0x47, 0x14,
+ 0x9e, 0x7f, 0x9f, 0x8e, 0x3e, 0x68, 0xd0, 0xc7,
+ 0x50, 0x52, 0x10, 0xbd, 0x31, 0x1a, 0x0e, 0x7c,
+ 0xd6, 0xe1, 0x3f, 0xfd, 0xf2, 0x41, 0x8d, 0x8d,
+ 0x19, 0x11, 0xc0, 0x04, 0xcd, 0xa5, 0x8d, 0xa3,
+ 0xd6, 0x19, 0xb7, 0xe2, 0xb9, 0x14, 0x1e, 0x58,
+ 0x31, 0x8e, 0xea, 0x39, 0x2c, 0xf4, 0x1b, 0x08},
+ .cipher_iv_length = AES_XTS_IV_LEN,
+ .cipher_iv = { 0xad, 0xf8, 0xd9, 0x26, 0x27, 0x46, 0x4a, 0xd2,
+ 0xf0, 0x42, 0x8e, 0x84, 0xa9, 0xf8, 0x75, 0x64},
+ .length = 32,
+ .plaintext = { 0x2e, 0xed, 0xea, 0x52, 0xcd, 0x82, 0x15, 0xe1,
+ 0xac, 0xc6, 0x47, 0xe8, 0x10, 0xbb, 0xc3, 0x64,
+ 0x2e, 0x87, 0x28, 0x7f, 0x8d, 0x2e, 0x57, 0xe3,
+ 0x6c, 0x0a, 0x24, 0xfb, 0xc1, 0x2a, 0x20, 0x2e},
+ .ciphertext = { 0xcb, 0xaa, 0xd0, 0xe2, 0xf6, 0xce, 0xa3, 0xf5,
+ 0x0b, 0x37, 0xf9, 0x34, 0xd4, 0x6a, 0x9b, 0x13,
+ 0x0b, 0x9d, 0x54, 0xf0, 0x7e, 0x34, 0xf3, 0x6a,
+ 0xf7, 0x93, 0xe8, 0x6f, 0x73, 0xc6, 0xd7, 0xdb},
+ },
+ /* CAVS 11.0 XTSGen information, #110 */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_XTS,
+ .cipher_key_length = AES256_XTS_KEY_LEN,
+ .cipher_key = { 0x6b, 0x19, 0x84, 0xc2, 0x4e, 0x7e, 0xb6, 0x62,
+ 0x8e, 0x3a, 0x11, 0xc9, 0xcc, 0xd2, 0x59, 0x40,
+ 0x33, 0xa3, 0xa0, 0xd9, 0x01, 0x6e, 0xae, 0x65,
+ 0xc2, 0xf2, 0x4e, 0x09, 0xb9, 0xa6, 0x6e, 0x9f,
+ 0xe9, 0xd1, 0x63, 0xa5, 0x06, 0xdf, 0xbc, 0xcf,
+ 0x2d, 0x93, 0xe8, 0x99, 0x1e, 0x2f, 0xc5, 0x60,
+ 0xe1, 0x04, 0x35, 0xb8, 0x90, 0xb5, 0x88, 0x9a,
+ 0x50, 0x03, 0xe4, 0xbf, 0x81, 0x7d, 0xc3, 0xe0},
+ .cipher_iv_length = AES_XTS_IV_LEN,
+ .cipher_iv = { 0x6b, 0xb0, 0xd3, 0xae, 0x4f, 0xa8, 0x6e, 0x43,
+ 0x16, 0x19, 0xe4, 0x07, 0xd5, 0x9a, 0xd4, 0xf4},
+ .length = 48,
+ .plaintext = { 0x6a, 0x74, 0x1a, 0x94, 0x5b, 0xfb, 0xf0, 0xc6,
+ 0x7a, 0xfd, 0x43, 0xba, 0x1f, 0x84, 0x18, 0x16,
+ 0xc0, 0x99, 0x51, 0x58, 0x05, 0xd0, 0xfc, 0x1f,
+ 0x7d, 0xbf, 0x6d, 0xe9, 0x00, 0xe0, 0xaa, 0x7a,
+ 0x21, 0x9c, 0x88, 0x56, 0x32, 0x71, 0xb0, 0x09,
+ 0xd1, 0xac, 0x90, 0xeb, 0x7d, 0xc9, 0x97, 0x35},
+ .ciphertext = { 0xe4, 0x7b, 0xce, 0x29, 0x2b, 0xaa, 0x63, 0xbe,
+ 0xf3, 0x16, 0xf6, 0x80, 0xa5, 0xf4, 0x80, 0xa7,
+ 0xb8, 0x83, 0xdf, 0xab, 0x6e, 0xd5, 0xa5, 0x7f,
+ 0x7e, 0x29, 0xec, 0xb8, 0x9e, 0x35, 0x4a, 0x31,
+ 0xc9, 0xb1, 0x74, 0xc4, 0xab, 0xad, 0x6c, 0xba,
+ 0xba, 0xba, 0x19, 0x14, 0x0c, 0x46, 0x20, 0xa3},
+ },
+ /* CAVS 11.0 XTSGen information, #211 TODO: length 140 bits */
+ /* {
+ .cipher = ODP_CIPHER_ALG_AES_XTS,
+ .cipher_key_length = AES256_XTS_KEY_LEN,
+ .cipher_key = { 0x62, 0xc2, 0xe4, 0xf8, 0x52, 0xa9, 0x3e, 0xea,
+ 0x4a, 0x2f, 0x61, 0xe8, 0x67, 0x68, 0x14, 0xf4,
+ 0xa8, 0x0d, 0xc4, 0x7e, 0xe1, 0x81, 0x32, 0xc8,
+ 0x38, 0xbf, 0x89, 0xa6, 0x18, 0xfd, 0xb8, 0xe2,
+ 0x91, 0x3e, 0x2e, 0x5c, 0x32, 0x1b, 0x19, 0xea,
+ 0x04, 0xbb, 0xa6, 0x34, 0x7d, 0x22, 0x6f, 0x41,
+ 0xdb, 0xee, 0x88, 0x0d, 0x61, 0x67, 0xb8, 0xe1,
+ 0xe9, 0x17, 0xfa, 0xf0, 0x46, 0xf0, 0x87, 0x5e},
+ .cipher_iv_length = AES_XTS_IV_LEN,
+ .cipher_iv = { 0x53, 0x7e, 0xe3, 0xdc, 0x13, 0xce, 0x27, 0xa8,
+ 0xd3, 0x0e, 0x6e, 0x42, 0xb5, 0xb9, 0x96, 0xae},
+ .length = 18,
+ .plaintext = { 0x00, 0xc9, 0xeb, 0x87, 0x78, 0xe0, 0x3d, 0xdd,
+ 0x5f, 0x3d, 0xe8, 0xc1, 0x8b, 0x34, 0x8f, 0xac,
+ 0x9c, 0x30},
+ .ciphertext = { 0x9d, 0x4a, 0x08, 0xac, 0x0f, 0xb4, 0x4e, 0x90,
+ 0xd0, 0x5f, 0x62, 0x86, 0x19, 0x3f, 0x3a, 0xab,
+ 0xc2, 0x90},
+ } */
+};
+
+/* AES-GCM test vectors extracted from
+ * https://tools.ietf.org/html/draft-mcgrew-gcm-test-01#section-2
+ */
+static crypto_test_reference_t aes_gcm_reference[] = {
+ {
+ .cipher = ODP_CIPHER_ALG_AES_GCM,
+ .auth = ODP_AUTH_ALG_AES_GCM,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda,
+ 0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34},
+ .cipher_iv_length = AES_GCM_IV_LEN,
+ .cipher_iv = { 0x2e, 0x44, 0x3b, 0x68, 0x49, 0x56, 0xed, 0x7e,
+ 0x3b, 0x24, 0x4c, 0xfe },
+ .length = 72,
+ .plaintext = { 0x45, 0x00, 0x00, 0x48, 0x69, 0x9a, 0x00, 0x00,
+ 0x80, 0x11, 0x4d, 0xb7, 0xc0, 0xa8, 0x01, 0x02,
+ 0xc0, 0xa8, 0x01, 0x01, 0x0a, 0x9b, 0xf1, 0x56,
+ 0x38, 0xd3, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x5f, 0x73, 0x69,
+ 0x70, 0x04, 0x5f, 0x75, 0x64, 0x70, 0x03, 0x73,
+ 0x69, 0x70, 0x09, 0x63, 0x79, 0x62, 0x65, 0x72,
+ 0x63, 0x69, 0x74, 0x79, 0x02, 0x64, 0x6b, 0x00,
+ 0x00, 0x21, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01 },
+ .ciphertext = { 0xfe, 0xcf, 0x53, 0x7e, 0x72, 0x9d, 0x5b, 0x07,
+ 0xdc, 0x30, 0xdf, 0x52, 0x8d, 0xd2, 0x2b, 0x76,
+ 0x8d, 0x1b, 0x98, 0x73, 0x66, 0x96, 0xa6, 0xfd,
+ 0x34, 0x85, 0x09, 0xfa, 0x13, 0xce, 0xac, 0x34,
+ 0xcf, 0xa2, 0x43, 0x6f, 0x14, 0xa3, 0xf3, 0xcf,
+ 0x65, 0x92, 0x5b, 0xf1, 0xf4, 0xa1, 0x3c, 0x5d,
+ 0x15, 0xb2, 0x1e, 0x18, 0x84, 0xf5, 0xff, 0x62,
+ 0x47, 0xae, 0xab, 0xb7, 0x86, 0xb9, 0x3b, 0xce,
+ 0x61, 0xbc, 0x17, 0xd7, 0x68, 0xfd, 0x97, 0x32},
+ .aad_length = 12,
+ .aad = { 0x00, 0x00, 0x43, 0x21, 0x87, 0x65, 0x43, 0x21,
+ 0x00, 0x00, 0x00, 0x00 },
+ .digest_length = AES_GCM_DIGEST_LEN,
+ .digest = { 0x45, 0x90, 0x18, 0x14, 0x8f, 0x6c, 0xbe, 0x72,
+ 0x2f, 0xd0, 0x47, 0x96, 0x56, 0x2d, 0xfd, 0xb4 }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_AES_GCM,
+ .auth = ODP_AUTH_ALG_AES_GCM,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08},
+ .cipher_iv_length = AES_GCM_IV_LEN,
+ .cipher_iv = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
+ 0xde, 0xca, 0xf8, 0x88 },
+ .length = 64,
+ .plaintext = { 0x45, 0x00, 0x00, 0x3e, 0x69, 0x8f, 0x00, 0x00,
+ 0x80, 0x11, 0x4d, 0xcc, 0xc0, 0xa8, 0x01, 0x02,
+ 0xc0, 0xa8, 0x01, 0x01, 0x0a, 0x98, 0x00, 0x35,
+ 0x00, 0x2a, 0x23, 0x43, 0xb2, 0xd0, 0x01, 0x00,
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x73, 0x69, 0x70, 0x09, 0x63, 0x79, 0x62,
+ 0x65, 0x72, 0x63, 0x69, 0x74, 0x79, 0x02, 0x64,
+ 0x6b, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01 },
+ .ciphertext = { 0xde, 0xb2, 0x2c, 0xd9, 0xb0, 0x7c, 0x72, 0xc1,
+ 0x6e, 0x3a, 0x65, 0xbe, 0xeb, 0x8d, 0xf3, 0x04,
+ 0xa5, 0xa5, 0x89, 0x7d, 0x33, 0xae, 0x53, 0x0f,
+ 0x1b, 0xa7, 0x6d, 0x5d, 0x11, 0x4d, 0x2a, 0x5c,
+ 0x3d, 0xe8, 0x18, 0x27, 0xc1, 0x0e, 0x9a, 0x4f,
+ 0x51, 0x33, 0x0d, 0x0e, 0xec, 0x41, 0x66, 0x42,
+ 0xcf, 0xbb, 0x85, 0xa5, 0xb4, 0x7e, 0x48, 0xa4,
+ 0xec, 0x3b, 0x9b, 0xa9, 0x5d, 0x91, 0x8b, 0xd1},
+ .aad_length = 8,
+ .aad = { 0x00, 0x00, 0xa5, 0xf8, 0x00, 0x00, 0x00, 0x0a },
+ .digest_length = AES_GCM_DIGEST_LEN,
+ .digest = { 0x83, 0xb7, 0x0d, 0x3a, 0xa8, 0xbc, 0x6e, 0xe4,
+ 0xc3, 0x09, 0xe9, 0xd8, 0x5a, 0x41, 0xad, 0x4a }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_AES_GCM,
+ .auth = ODP_AUTH_ALG_AES_GCM,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ .cipher_iv_length = AES_GCM_IV_LEN,
+ .cipher_iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00 },
+ .length = 64,
+ .plaintext = { 0x45, 0x00, 0x00, 0x3c, 0x99, 0xc5, 0x00, 0x00,
+ 0x80, 0x01, 0xcb, 0x7a, 0x40, 0x67, 0x93, 0x18,
+ 0x01, 0x01, 0x01, 0x01, 0x08, 0x00, 0x07, 0x5c,
+ 0x02, 0x00, 0x44, 0x00, 0x61, 0x62, 0x63, 0x64,
+ 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
+ 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
+ 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65,
+ 0x66, 0x67, 0x68, 0x69, 0x01, 0x02, 0x02, 0x01 },
+ .ciphertext = { 0x46, 0x88, 0xda, 0xf2, 0xf9, 0x73, 0xa3, 0x92,
+ 0x73, 0x29, 0x09, 0xc3, 0x31, 0xd5, 0x6d, 0x60,
+ 0xf6, 0x94, 0xab, 0xaa, 0x41, 0x4b, 0x5e, 0x7f,
+ 0xf5, 0xfd, 0xcd, 0xff, 0xf5, 0xe9, 0xa2, 0x84,
+ 0x45, 0x64, 0x76, 0x49, 0x27, 0x19, 0xff, 0xb6,
+ 0x4d, 0xe7, 0xd9, 0xdc, 0xa1, 0xe1, 0xd8, 0x94,
+ 0xbc, 0x3b, 0xd5, 0x78, 0x73, 0xed, 0x4d, 0x18,
+ 0x1d, 0x19, 0xd4, 0xd5, 0xc8, 0xc1, 0x8a, 0xf3},
+ .aad_length = 8,
+ .aad = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
+ .digest_length = AES_GCM_DIGEST_LEN,
+ .digest = { 0xf8, 0x21, 0xd4, 0x96, 0xee, 0xb0, 0x96, 0xe9,
+ 0x8a, 0xd2, 0xb6, 0x9e, 0x47, 0x99, 0xc7, 0x1d }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_AES_GCM,
+ .auth = ODP_AUTH_ALG_AES_GCM,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0x3d, 0xe0, 0x98, 0x74, 0xb3, 0x88, 0xe6, 0x49,
+ 0x19, 0x88, 0xd0, 0xc3, 0x60, 0x7e, 0xae, 0x1f},
+ .cipher_iv_length = AES_GCM_IV_LEN,
+ .cipher_iv = { 0x57, 0x69, 0x0e, 0x43, 0x4e, 0x28, 0x00, 0x00,
+ 0xa2, 0xfc, 0xa1, 0xa3 },
+ .length = 28,
+ .plaintext = { 0x45, 0x00, 0x00, 0x1c, 0x42, 0xa2, 0x00, 0x00,
+ 0x80, 0x01, 0x44, 0x1f, 0x40, 0x67, 0x93, 0xb6,
+ 0xe0, 0x00, 0x00, 0x02, 0x0a, 0x00, 0xf5, 0xff,
+ 0x01, 0x02, 0x02, 0x01 },
+ .ciphertext = { 0xfb, 0xa2, 0xca, 0x84, 0x5e, 0x5d, 0xf9, 0xf0,
+ 0xf2, 0x2c, 0x3e, 0x6e, 0x86, 0xdd, 0x83, 0x1e,
+ 0x1f, 0xc6, 0x57, 0x92, 0xcd, 0x1a, 0xf9, 0x13,
+ 0x0e, 0x13, 0x79, 0xed },
+ .aad_length = 12,
+ .aad = { 0x42, 0xf6, 0x7e, 0x3f, 0x10, 0x10, 0x10, 0x10,
+ 0x10, 0x10, 0x10, 0x10 },
+ .digest_length = AES_GCM_DIGEST_LEN,
+ .digest = { 0x36, 0x9f, 0x07, 0x1f, 0x35, 0xe0, 0x34, 0xbe,
+ 0x95, 0xf1, 0x12, 0xe4, 0xe7, 0xd0, 0x5d, 0x35 }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_AES_GCM,
+ .auth = ODP_AUTH_ALG_AES_GCM,
+ .cipher_key_length = AES192_KEY_LEN,
+ .cipher_key = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c},
+ .cipher_iv_length = AES_GCM_IV_LEN,
+ .cipher_iv = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
+ 0xde, 0xca, 0xf8, 0x88 },
+ .length = 40,
+ .plaintext = { 0x45, 0x00, 0x00, 0x28, 0xa4, 0xad, 0x40, 0x00,
+ 0x40, 0x06, 0x78, 0x80, 0x0a, 0x01, 0x03, 0x8f,
+ 0x0a, 0x01, 0x06, 0x12, 0x80, 0x23, 0x06, 0xb8,
+ 0xcb, 0x71, 0x26, 0x02, 0xdd, 0x6b, 0xb0, 0x3e,
+ 0x50, 0x10, 0x16, 0xd0, 0x75, 0x68, 0x00, 0x01 },
+ .ciphertext = { 0xa5, 0xb1, 0xf8, 0x06, 0x60, 0x29, 0xae, 0xa4,
+ 0x0e, 0x59, 0x8b, 0x81, 0x22, 0xde, 0x02, 0x42,
+ 0x09, 0x38, 0xb3, 0xab, 0x33, 0xf8, 0x28, 0xe6,
+ 0x87, 0xb8, 0x85, 0x8b, 0x5b, 0xfb, 0xdb, 0xd0,
+ 0x31, 0x5b, 0x27, 0x45, 0x21, 0x44, 0xcc, 0x77},
+ .aad_length = 8,
+ .aad = { 0x00, 0x00, 0xa5, 0xf8, 0x00, 0x00, 0x00, 0x0a },
+ .digest_length = AES_GCM_DIGEST_LEN,
+ .digest = { 0x95, 0x45, 0x7b, 0x96, 0x52, 0x03, 0x7f, 0x53,
+ 0x18, 0x02, 0x7b, 0x5b, 0x4c, 0xd7, 0xa6, 0x36 }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_AES_GCM,
+ .auth = ODP_AUTH_ALG_AES_GCM,
+ .cipher_key_length = AES256_KEY_LEN,
+ .cipher_key = { 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23,
+ 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab,
+ 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23,
+ 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab},
+ .cipher_iv_length = AES_GCM_IV_LEN,
+ .cipher_iv = { 0x11, 0x22, 0x33, 0x44, 0x01, 0x02, 0x03, 0x04,
+ 0x05, 0x06, 0x07, 0x08 },
+ .length = 52,
+ .plaintext = { 0x45, 0x00, 0x00, 0x30, 0x69, 0xa6, 0x40, 0x00,
+ 0x80, 0x06, 0x26, 0x90, 0xc0, 0xa8, 0x01, 0x02,
+ 0x93, 0x89, 0x15, 0x5e, 0x0a, 0x9e, 0x00, 0x8b,
+ 0x2d, 0xc5, 0x7e, 0xe0, 0x00, 0x00, 0x00, 0x00,
+ 0x70, 0x02, 0x40, 0x00, 0x20, 0xbf, 0x00, 0x00,
+ 0x02, 0x04, 0x05, 0xb4, 0x01, 0x01, 0x04, 0x02,
+ 0x01, 0x02, 0x02, 0x01 },
+ .ciphertext = { 0xff, 0x42, 0x5c, 0x9b, 0x72, 0x45, 0x99, 0xdf,
+ 0x7a, 0x3b, 0xcd, 0x51, 0x01, 0x94, 0xe0, 0x0d,
+ 0x6a, 0x78, 0x10, 0x7f, 0x1b, 0x0b, 0x1c, 0xbf,
+ 0x06, 0xef, 0xae, 0x9d, 0x65, 0xa5, 0xd7, 0x63,
+ 0x74, 0x8a, 0x63, 0x79, 0x85, 0x77, 0x1d, 0x34,
+ 0x7f, 0x05, 0x45, 0x65, 0x9f, 0x14, 0xe9, 0x9d,
+ 0xef, 0x84, 0x2d, 0x8e },
+ .aad_length = 8,
+ .aad = { 0x4a, 0x2c, 0xbf, 0xe3, 0x00, 0x00, 0x00, 0x02 },
+ .digest_length = AES_GCM_DIGEST_LEN,
+ .digest = { 0xb3, 0x35, 0xf4, 0xee, 0xcf, 0xdb, 0xf8, 0x31,
+ 0x82, 0x4b, 0x4c, 0x49, 0x15, 0x95, 0x6c, 0x96 }
+ }
+};
+
+static crypto_test_reference_t aes_ccm_reference[] = {
+ /*
+ * AES-CCM reference from RFC 3610
+ */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CCM,
+ .auth = ODP_AUTH_ALG_AES_CCM,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf},
+ .cipher_iv_length = 13,
+ .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0,
+ 0xa1, 0xa2, 0xa3, 0xa4, 0xa5 },
+ .aad_length = 8,
+ .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
+ .length = 23,
+ .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e },
+ .ciphertext = { 0x58, 0x8c, 0x97, 0x9a, 0x61, 0xc6, 0x63, 0xd2,
+ 0xf0, 0x66, 0xd0, 0xc2, 0xc0, 0xf9, 0x89, 0x80,
+ 0x6d, 0x5f, 0x6b, 0x61, 0xda, 0xc3, 0x84 },
+ .digest_length = 8,
+ .digest = { 0x17, 0xe8, 0xd1, 0x2c, 0xfd, 0xf9, 0x26, 0xe0 }
+ },
+ /* The rest of test vectors are generated manually, no "interesting"
+ * vectors for use cases in RFC 3610 or SP 800-38C. */
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CCM,
+ .auth = ODP_AUTH_ALG_AES_CCM,
+ .cipher_key_length = AES192_KEY_LEN,
+ .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7},
+ .cipher_iv_length = 13,
+ .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0,
+ 0xa1, 0xa2, 0xa3, 0xa4, 0xa5 },
+ .aad_length = 8,
+ .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
+ .length = 23,
+ .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e },
+ .ciphertext = { 0x57, 0x9f, 0xb8, 0x6e, 0xdd, 0xb4, 0xa6, 0x4a,
+ 0xae, 0x5f, 0xe9, 0x6d, 0xbd, 0x75, 0x44, 0x05,
+ 0x33, 0xa9, 0xfc, 0x3a, 0x84, 0x57, 0x36 },
+ .digest_length = 8,
+ .digest = { 0x67, 0xae, 0xc8, 0x0a, 0xc5, 0x88, 0xab, 0x16 }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CCM,
+ .auth = ODP_AUTH_ALG_AES_CCM,
+ .cipher_key_length = AES256_KEY_LEN,
+ .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf},
+ .cipher_iv_length = 13,
+ .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0,
+ 0xa1, 0xa2, 0xa3, 0xa4, 0xa5 },
+ .aad_length = 8,
+ .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
+ .length = 23,
+ .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e },
+ .ciphertext = { 0x59, 0x61, 0x55, 0x10, 0xa7, 0xc4, 0x3b, 0xfb,
+ 0x12, 0x3d, 0x63, 0x6b, 0x46, 0x13, 0xc0, 0x3c,
+ 0x6c, 0xe2, 0x69, 0x07, 0x10, 0x2a, 0x3f },
+ .digest_length = 8,
+ .digest = { 0xb5, 0x57, 0x2a, 0x17, 0x2d, 0x49, 0x16, 0xd5 }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CCM,
+ .auth = ODP_AUTH_ALG_AES_CCM,
+ .cipher_key_length = AES128_KEY_LEN,
+ .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf},
+ .cipher_iv_length = 11,
+ .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0,
+ 0xa1, 0xa2, 0xa3 },
+ .aad_length = 8,
+ .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
+ .length = 23,
+ .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e },
+ .ciphertext = { 0xaa, 0x2d, 0x3e, 0xcb, 0xa6, 0x68, 0x63, 0x75,
+ 0x8f, 0x03, 0x01, 0x51, 0x16, 0xde, 0x30, 0xed,
+ 0x8a, 0xb5, 0x42, 0xdc, 0xfa, 0x72, 0xd0 },
+ .digest_length = 8,
+ .digest = { 0x63, 0xe7, 0x01, 0x5c, 0x69, 0xaf, 0xb4, 0x0c }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CCM,
+ .auth = ODP_AUTH_ALG_AES_CCM,
+ .cipher_key_length = AES192_KEY_LEN,
+ .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7},
+ .cipher_iv_length = 11,
+ .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0,
+ 0xa1, 0xa2, 0xa3 },
+ .aad_length = 8,
+ .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
+ .length = 23,
+ .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e },
+ .ciphertext = { 0xee, 0x99, 0x99, 0x1e, 0xc5, 0x8f, 0xd7, 0x7e,
+ 0x56, 0x71, 0x16, 0x39, 0x8e, 0xc4, 0x4f, 0xcc,
+ 0x14, 0x45, 0x57, 0x3e, 0x38, 0x76, 0x51 },
+ .digest_length = 8,
+ .digest = { 0x31, 0x29, 0x47, 0xa4, 0x6d, 0x76, 0x34, 0xb4 }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_AES_CCM,
+ .auth = ODP_AUTH_ALG_AES_CCM,
+ .cipher_key_length = AES256_KEY_LEN,
+ .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf},
+ .cipher_iv_length = 11,
+ .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0,
+ 0xa1, 0xa2, 0xa3 },
+ .aad_length = 8,
+ .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
+ .length = 23,
+ .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e },
+ .ciphertext = { 0xfa, 0x07, 0x47, 0x5c, 0xe8, 0xc9, 0x37, 0x88,
+ 0x54, 0x64, 0xb8, 0xc3, 0x85, 0xbb, 0x76, 0x0b,
+ 0xf2, 0xc2, 0x4c, 0x4e, 0x31, 0x16, 0x77 },
+ .digest_length = 8,
+ .digest = { 0x88, 0x56, 0x7e, 0x19, 0x84, 0x13, 0x29, 0xc4 }
+ },
+};
+
+static crypto_test_reference_t aes_gmac_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_AES_GMAC,
+ .auth_key_length = AES128_KEY_LEN,
+ .auth_key = { 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda,
+ 0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34},
+ .auth_iv_length = AES_GCM_IV_LEN,
+ .auth_iv = { 0x22, 0x43, 0x3c, 0x64, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00 },
+ .length = 68,
+ .plaintext = { 0x00, 0x00, 0x43, 0x21, 0x00, 0x00, 0x00, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x45, 0x00, 0x00, 0x30, 0xda, 0x3a, 0x00, 0x00,
+ 0x80, 0x01, 0xdf, 0x3b, 0xc0, 0xa8, 0x00, 0x05,
+ 0xc0, 0xa8, 0x00, 0x01, 0x08, 0x00, 0xc6, 0xcd,
+ 0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64,
+ 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
+ 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
+ 0x01, 0x02, 0x02, 0x01 },
+ .ciphertext = { 0x00, 0x00, 0x43, 0x21, 0x00, 0x00, 0x00, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x45, 0x00, 0x00, 0x30, 0xda, 0x3a, 0x00, 0x00,
+ 0x80, 0x01, 0xdf, 0x3b, 0xc0, 0xa8, 0x00, 0x05,
+ 0xc0, 0xa8, 0x00, 0x01, 0x08, 0x00, 0xc6, 0xcd,
+ 0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64,
+ 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
+ 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
+ 0x01, 0x02, 0x02, 0x01 },
+ .digest_length = AES_GCM_DIGEST_LEN,
+ .digest = { 0xf2, 0xa9, 0xa8, 0x36, 0xe1, 0x55, 0x10, 0x6a,
+ 0xa8, 0xdc, 0xd6, 0x18, 0xe4, 0x09, 0x9a, 0xaa }
+ },
+ /* AES192-GMAC from DPDK 17.02 */
+ {
+ .auth = ODP_AUTH_ALG_AES_GMAC,
+ .auth_key_length = AES192_KEY_LEN,
+ .auth_key = { 0xaa, 0x74, 0x0a, 0xbf, 0xad, 0xcd, 0xa7, 0x79,
+ 0x22, 0x0d, 0x3b, 0x40, 0x6c, 0x5d, 0x7e, 0xc0,
+ 0x9a, 0x77, 0xfe, 0x9d, 0x94, 0x10, 0x45, 0x39},
+ .auth_iv_length = AES_GCM_IV_LEN,
+ .auth_iv = { 0xab, 0x22, 0x65, 0xb4, 0xc1, 0x68, 0x95, 0x55,
+ 0x61, 0xf0, 0x43, 0x15 },
+ .length = 80,
+ .plaintext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10},
+ .ciphertext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10},
+ .digest_length = AES_GCM_DIGEST_LEN,
+ .digest = { 0xCF, 0x82, 0x80, 0x64, 0x02, 0x46, 0xF4, 0xFB,
+ 0x33, 0xAE, 0x1D, 0x90, 0xEA, 0x48, 0x83, 0xDB },
+ },
+ /* AES256-GMAC from DPDK 17.02 */
+ {
+ .auth = ODP_AUTH_ALG_AES_GMAC,
+ .auth_key_length = AES256_KEY_LEN,
+ .auth_key = { 0xb5, 0x48, 0xe4, 0x93, 0x4f, 0x5c, 0x64, 0xd3,
+ 0xc0, 0xf0, 0xb7, 0x8f, 0x7b, 0x4d, 0x88, 0x24,
+ 0xaa, 0xc4, 0x6b, 0x3c, 0x8d, 0x2c, 0xc3, 0x5e,
+ 0xe4, 0xbf, 0xb2, 0x54, 0xe4, 0xfc, 0xba, 0xf7},
+ .auth_iv_length = AES_GCM_IV_LEN,
+ .auth_iv = { 0x2e, 0xed, 0xe1, 0xdc, 0x64, 0x47, 0xc7, 0xaf,
+ 0xc4, 0x41, 0x53, 0x58 },
+ .length = 65,
+ .plaintext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02 },
+ .ciphertext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+ 0x01, 0x02 },
+ .digest_length = AES_GCM_DIGEST_LEN,
+ .digest = { 0x77, 0x46, 0x0D, 0x6F, 0xB1, 0x87, 0xDB, 0xA9,
+ 0x46, 0xAD, 0xCD, 0xFB, 0xB7, 0xF9, 0x13, 0xA1 },
+ }
+};
+
+/*
+ * Test vectors from SP800-38B / CSRC examples
+ * 12-byte vectors are just truncated 16-byte vectors
+ */
+static crypto_test_reference_t aes_cmac_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_AES_CMAC,
+ .auth_key_length = AES128_KEY_LEN,
+ .auth_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c },
+ .length = 16,
+ .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a},
+ .ciphertext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a
+ },
+ .digest_length = 16,
+ .digest = { 0x07, 0x0a, 0x16, 0xb4, 0x6b, 0x4d, 0x41, 0x44,
+ 0xf7, 0x9b, 0xdd, 0x9d, 0xd0, 0x4a, 0x28, 0x7c },
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = 12,
+ },
+ {
+ .auth = ODP_AUTH_ALG_AES_CMAC,
+ .auth_key_length = AES192_KEY_LEN,
+ .auth_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52,
+ 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
+ 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b },
+ .length = 16,
+ .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a},
+ .ciphertext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a
+ },
+ .digest_length = 16,
+ .digest = { 0x9e, 0x99, 0xa7, 0xbf, 0x31, 0xe7, 0x10, 0x90,
+ 0x06, 0x62, 0xf6, 0x5e, 0x61, 0x7c, 0x51, 0x84 },
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = 12,
+ },
+ {
+ .auth = ODP_AUTH_ALG_AES_CMAC,
+ .auth_key_length = AES256_KEY_LEN,
+ .auth_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
+ 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
+ 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
+ 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4 },
+ .length = 16,
+ .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a},
+ .ciphertext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a
+ },
+ .digest_length = 16,
+ .digest = { 0x28, 0xa7, 0x02, 0x3f, 0x45, 0x2e, 0x8f, 0x82,
+ 0xbd, 0x4b, 0xf2, 0x8d, 0x8c, 0x37, 0xc3, 0x5c },
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = 12,
+ },
+};
+
+/*
+ * Test vector from RFC 7539, sections 2.8.2, A.5
+ */
+static crypto_test_reference_t chacha20_poly1305_reference[] = {
+ {
+ .cipher = ODP_CIPHER_ALG_CHACHA20_POLY1305,
+ .auth = ODP_AUTH_ALG_CHACHA20_POLY1305,
+ .cipher_key_length = CHACHA20_POLY1305_KEY_LEN,
+ .cipher_key = { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f},
+ .cipher_iv_length = CHACHA20_POLY1305_IV_LEN,
+ .cipher_iv = { 0x07, 0x00, 0x00, 0x00, 0x40, 0x41, 0x42, 0x43,
+ 0x44, 0x45, 0x46, 0x47 },
+ .length = 114,
+ .plaintext = { 0x4c, 0x61, 0x64, 0x69, 0x65, 0x73, 0x20, 0x61,
+ 0x6e, 0x64, 0x20, 0x47, 0x65, 0x6e, 0x74, 0x6c,
+ 0x65, 0x6d, 0x65, 0x6e, 0x20, 0x6f, 0x66, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x63, 0x6c, 0x61, 0x73,
+ 0x73, 0x20, 0x6f, 0x66, 0x20, 0x27, 0x39, 0x39,
+ 0x3a, 0x20, 0x49, 0x66, 0x20, 0x49, 0x20, 0x63,
+ 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x6f, 0x66, 0x66,
+ 0x65, 0x72, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x6f,
+ 0x6e, 0x6c, 0x79, 0x20, 0x6f, 0x6e, 0x65, 0x20,
+ 0x74, 0x69, 0x70, 0x20, 0x66, 0x6f, 0x72, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x66, 0x75, 0x74, 0x75,
+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0x60, 0x06, 0x91 }
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_CHACHA20_POLY1305,
+ .auth = ODP_AUTH_ALG_CHACHA20_POLY1305,
+ .cipher_key_length = CHACHA20_POLY1305_KEY_LEN,
+ .cipher_key = { 0x1c, 0x92, 0x40, 0xa5, 0xeb, 0x55, 0xd3, 0x8a,
+ 0xf3, 0x33, 0x88, 0x86, 0x04, 0xf6, 0xb5, 0xf0,
+ 0x47, 0x39, 0x17, 0xc1, 0x40, 0x2b, 0x80, 0x09,
+ 0x9d, 0xca, 0x5c, 0xbc, 0x20, 0x70, 0x75, 0xc0},
+ .cipher_iv_length = CHACHA20_POLY1305_IV_LEN,
+ .cipher_iv = { 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04,
+ 0x05, 0x06, 0x07, 0x08 },
+ .length = 265,
+ .plaintext = { 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74,
+ 0x2d, 0x44, 0x72, 0x61, 0x66, 0x74, 0x73, 0x20,
+ 0x61, 0x72, 0x65, 0x20, 0x64, 0x72, 0x61, 0x66,
+ 0x74, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65,
+ 0x6e, 0x74, 0x73, 0x20, 0x76, 0x61, 0x6c, 0x69,
+ 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x61, 0x20,
+ 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x20,
+ 0x6f, 0x66, 0x20, 0x73, 0x69, 0x78, 0x20, 0x6d,
+ 0x6f, 0x6e, 0x74, 0x68, 0x73, 0x20, 0x61, 0x6e,
+ 0x64, 0x20, 0x6d, 0x61, 0x79, 0x20, 0x62, 0x65,
+ 0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64,
+ 0x2c, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63,
+ 0x65, 0x64, 0x2c, 0x20, 0x6f, 0x72, 0x20, 0x6f,
+ 0x62, 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, 0x64,
+ 0x20, 0x62, 0x79, 0x20, 0x6f, 0x74, 0x68, 0x65,
+ 0x72, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65,
+ 0x6e, 0x74, 0x73, 0x20, 0x61, 0x74, 0x20, 0x61,
+ 0x6e, 0x79, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x2e,
+ 0x20, 0x49, 0x74, 0x20, 0x69, 0x73, 0x20, 0x69,
+ 0x6e, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x70, 0x72,
+ 0x69, 0x61, 0x74, 0x65, 0x20, 0x74, 0x6f, 0x20,
+ 0x75, 0x73, 0x65, 0x20, 0x49, 0x6e, 0x74, 0x65,
+ 0x72, 0x6e, 0x65, 0x74, 0x2d, 0x44, 0x72, 0x61,
+ 0x66, 0x74, 0x73, 0x20, 0x61, 0x73, 0x20, 0x72,
+ 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65,
+ 0x20, 0x6d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61,
+ 0x6c, 0x20, 0x6f, 0x72, 0x20, 0x74, 0x6f, 0x20,
+ 0x63, 0x69, 0x74, 0x65, 0x20, 0x74, 0x68, 0x65,
+ 0x6d, 0x20, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x20,
+ 0x74, 0x68, 0x61, 0x6e, 0x20, 0x61, 0x73, 0x20,
+ 0x2f, 0xe2, 0x80, 0x9c, 0x77, 0x6f, 0x72, 0x6b,
+ 0x20, 0x69, 0x6e, 0x20, 0x70, 0x72, 0x6f, 0x67,
+ 0x72, 0x65, 0x73, 0x73, 0x2e, 0x2f, 0xe2, 0x80,
+ 0x9d },
+ .ciphertext = { 0x64, 0xa0, 0x86, 0x15, 0x75, 0x86, 0x1a, 0xf4,
+ 0x60, 0xf0, 0x62, 0xc7, 0x9b, 0xe6, 0x43, 0xbd,
+ 0x5e, 0x80, 0x5c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+ 0x0b, 0xb2, 0x31, 0x60, 0x53, 0xfa, 0x76, 0x99,
+ 0x19, 0x55, 0xeb, 0xd6, 0x31, 0x59, 0x43, 0x4e,
+ 0xce, 0xbb, 0x4e, 0x46, 0x6d, 0xae, 0x5a, 0x10,
+ 0x73, 0xa6, 0x72, 0x76, 0x27, 0x09, 0x7a, 0x10,
+ 0x49, 0xe6, 0x17, 0xd9, 0x1d, 0x36, 0x10, 0x94,
+ 0xfa, 0x68, 0xf0, 0xff, 0x77, 0x98, 0x71, 0x30,
+ 0x30, 0x5b, 0xea, 0xba, 0x2e, 0xda, 0x04, 0xdf,
+ 0x99, 0x7b, 0x71, 0x4d, 0x6c, 0x6f, 0x2c, 0x29,
+ 0xa6, 0xad, 0x5c, 0xb4, 0x02, 0x2b, 0x02, 0x70,
+ 0x9b },
+ .aad_length = 12,
+ .aad = { 0xf3, 0x33, 0x88, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x4e, 0x91 },
+ .digest_length = CHACHA20_POLY1305_CHECK_LEN,
+ .digest = { 0xee, 0xad, 0x9d, 0x67, 0x89, 0x0c, 0xbb, 0x22,
+ 0x39, 0x23, 0x36, 0xfe, 0xa1, 0x85, 0x1f, 0x38 }
+ },
+};
+
+static crypto_test_reference_t hmac_md5_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_MD5_HMAC,
+ .auth_key_length = HMAC_MD5_KEY_LEN,
+ .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b },
+ .length = 8,
+ /* "Hi There" */
+ .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+ .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+ .digest_length = HMAC_MD5_CHECK_LEN,
+ .digest = { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c,
+ 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d },
+
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = HMAC_MD5_96_CHECK_LEN,
+ },
+ {
+ .auth = ODP_AUTH_ALG_MD5_HMAC,
+ .auth_key_length = HMAC_MD5_KEY_LEN,
+ /* "Jefe" */
+ .auth_key = { 0x4a, 0x65, 0x66, 0x65 },
+ .length = 28,
+ /* what do ya want for nothing?*/
+ .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+ .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+ .digest_length = HMAC_MD5_CHECK_LEN,
+ .digest = { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03,
+ 0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38 },
+
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = HMAC_MD5_96_CHECK_LEN,
+ },
+ {
+ .auth = ODP_AUTH_ALG_MD5_HMAC,
+ .auth_key_length = HMAC_MD5_KEY_LEN,
+ .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa },
+ .length = 50,
+ .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd },
+ .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd },
+ .digest_length = HMAC_MD5_CHECK_LEN,
+ .digest = { 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88,
+ 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 }
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = HMAC_MD5_96_CHECK_LEN,
+ },
+};
+
+static crypto_test_reference_t hmac_sha1_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_SHA1_HMAC,
+ .auth_key_length = HMAC_SHA1_KEY_LEN,
+ .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b },
+ .length = 8,
+ /* "Hi There" */
+ .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+ .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+ .digest_length = HMAC_SHA1_CHECK_LEN,
+ .digest = { 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64,
+ 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e,
+ 0xf1, 0x46, 0xbe, 0x00 }
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = HMAC_SHA1_96_CHECK_LEN,
+ },
+ {
+ .auth = ODP_AUTH_ALG_SHA1_HMAC,
+ .auth_key_length = HMAC_SHA1_KEY_LEN,
+ /* "Jefe" */
+ .auth_key = { 0x4a, 0x65, 0x66, 0x65 },
+ .length = 28,
+ /* what do ya want for nothing?*/
+ .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+ .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+ .digest_length = HMAC_SHA1_CHECK_LEN,
+ .digest = { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2,
+ 0xd2, 0x74, 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c,
+ 0x25, 0x9a, 0x7c, 0x79 }
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = HMAC_SHA1_96_CHECK_LEN,
+ },
+ {
+ .auth = ODP_AUTH_ALG_S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est_length = HMAC_SHA1_96_CHECK_LEN,
+ },
+};
+
+static crypto_test_reference_t hmac_sha224_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_SHA224_HMAC,
+ .auth_key_length = HMAC_SHA224_KEY_LEN,
+ .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b },
+ .length = 8,
+ /* "Hi There" */
+ .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+ .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+ .digest_length = HMAC_SHA224_CHECK_LEN,
+ .digest = { 0x89, 0x6f, 0xb1, 0x12, 0x8a, 0xbb, 0xdf, 0x19,
+ 0x68, 0x32, 0x10, 0x7c, 0xd4, 0x9d, 0xf3, 0x3f,
+ 0x47, 0xb4, 0xb1, 0x16, 0x99, 0x12, 0xba, 0x4f,
+ 0x53, 0x68, 0x4b, 0x22 }
+ },
+ {
+ .auth = ODP_AUTH_ALG_SHA224_HMAC,
+ .auth_key_length = HMAC_SHA224_KEY_LEN,
+ /* "Jefe" */
+ .auth_key = { 0x4a, 0x65, 0x66, 0x65 },
+ .length = 28,
+ /* what do ya want for nothing?*/
+ .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+ .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0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, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd },
+ .digest_length = HMAC_SHA224_CHECK_LEN,
+ .digest = { 0x7f, 0xb3, 0xcb, 0x35, 0x88, 0xc6, 0xc1, 0xf6,
+ 0xff, 0xa9, 0x69, 0x4d, 0x7d, 0x6a, 0xd2, 0x64,
+ 0x93, 0x65, 0xb0, 0xc1, 0xf6, 0x5d, 0x69, 0xd1,
+ 0xec, 0x83, 0x33, 0xea }
+ }
+};
+
+static crypto_test_reference_t hmac_sha256_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_SHA256_HMAC,
+ .auth_key_length = HMAC_SHA256_KEY_LEN,
+ .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b },
+ .length = 8,
+ /* "Hi There" */
+ .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+ .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+ .digest_length = HMAC_SHA256_CHECK_LEN,
+ .digest = { 0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53,
+ 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b,
+ 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7,
+ 0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7 }
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = HMAC_SHA256_128_CHECK_LEN,
+ },
+ {
+ .auth = ODP_AUTH_ALG_SHA256_HMAC,
+ .auth_key_length = HMAC_SHA256_KEY_LEN,
+ /* "Jefe" */
+ .auth_key = { 0x4a, 0x65, 0x66, 0x65 },
+ .length = 28,
+ /* what do ya want for nothing?*/
+ .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+ .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+ .digest_length = HMAC_SHA256_CHECK_LEN,
+ .digest = { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
+ 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7,
+ 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83,
+ 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43 }
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = HMAC_SHA256_128_CHECK_LEN,
+ },
+ {
+ .auth = ODP_AUTH_ALG_SHA256_HMAC,
+ .auth_key_length = HMAC_SHA256_KEY_LEN,
+ .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa },
+ .length = 50,
+ .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd },
+ .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd },
+ .digest_length = HMAC_SHA256_CHECK_LEN,
+ .digest = { 0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46,
+ 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7,
+ 0x29, 0x59, 0x09, 0x8b, 0x3e, 0xf8, 0xc1, 0x22,
+ 0xd9, 0x63, 0x55, 0x14, 0xce, 0xd5, 0x65, 0xfe }
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = HMAC_SHA256_128_CHECK_LEN,
+ },
+};
+
+static crypto_test_reference_t hmac_sha384_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_SHA384_HMAC,
+ .auth_key_length = HMAC_SHA384_KEY_LEN,
+ .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b },
+ .length = 8,
+ /* "Hi There" */
+ .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+ .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+ .digest_length = HMAC_SHA384_CHECK_LEN,
+ .digest = { 0xaf, 0xd0, 0x39, 0x44, 0xd8, 0x48, 0x95, 0x62,
+ 0x6b, 0x08, 0x25, 0xf4, 0xab, 0x46, 0x90, 0x7f,
+ 0x15, 0xf9, 0xda, 0xdb, 0xe4, 0x10, 0x1e, 0xc6,
+ 0x82, 0xaa, 0x03, 0x4c, 0x7c, 0xeb, 0xc5, 0x9c,
+ 0xfa, 0xea, 0x9e, 0xa9, 0x07, 0x6e, 0xde, 0x7f,
+ 0x4a, 0xf1, 0x52, 0xe8, 0xb2, 0xfa, 0x9c, 0xb6 }
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = HMAC_SHA384_192_CHECK_LEN,
+ },
+ {
+ .auth = ODP_AUTH_ALG_SHA384_HMAC,
+ .auth_key_length = HMAC_SHA384_KEY_LEN,
+ /* "Jefe" */
+ .auth_key = { 0x4a, 0x65, 0x66, 0x65 },
+ .length = 28,
+ /* what do ya want for nothing?*/
+ .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+ .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+ .digest_length = HMAC_SHA384_CHECK_LEN,
+ .digest = { 0xaf, 0x45, 0xd2, 0xe3, 0x76, 0x48, 0x40, 0x31,
+ 0x61, 0x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xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd },
+ .digest_length = HMAC_SHA384_CHECK_LEN,
+ .digest = {0x88, 0x06, 0x26, 0x08, 0xd3, 0xe6, 0xad, 0x8a,
+ 0x0a, 0xa2, 0xac, 0xe0, 0x14, 0xc8, 0xa8, 0x6f,
+ 0x0a, 0xa6, 0x35, 0xd9, 0x47, 0xac, 0x9f, 0xeb,
+ 0xe8, 0x3e, 0xf4, 0xe5, 0x59, 0x66, 0x14, 0x4b,
+ 0x2a, 0x5a, 0xb3, 0x9d, 0xc1, 0x38, 0x14, 0xb9,
+ 0x4e, 0x3a, 0xb6, 0xe1, 0x01, 0xa3, 0x4f, 0x27 }
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = HMAC_SHA384_192_CHECK_LEN,
+ },
+};
+
+static crypto_test_reference_t hmac_sha512_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_SHA512_HMAC,
+ .auth_key_length = HMAC_SHA512_KEY_LEN,
+ .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b },
+ .length = 8,
+ /* "Hi There" */
+ .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+ .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
+ .digest_length = HMAC_SHA512_CHECK_LEN,
+ .digest = { 0x87, 0xaa, 0x7c, 0xde, 0xa5, 0xef, 0x61, 0x9d,
+ 0x4f, 0xf0, 0xb4, 0x24, 0x1a, 0x1d, 0x6c, 0xb0,
+ 0x23, 0x79, 0xf4, 0xe2, 0xce, 0x4e, 0xc2, 0x78,
+ 0x7a, 0xd0, 0xb3, 0x05, 0x45, 0xe1, 0x7c, 0xde,
+ 0xda, 0xa8, 0x33, 0xb7, 0xd6, 0xb8, 0xa7, 0x02,
+ 0x03, 0x8b, 0x27, 0x4e, 0xae, 0xa3, 0xf4, 0xe4,
+ 0xbe, 0x9d, 0x91, 0x4e, 0xeb, 0x61, 0xf1, 0x70,
+ 0x2e, 0x69, 0x6c, 0x20, 0x3a, 0x12, 0x68, 0x54 }
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = HMAC_SHA512_256_CHECK_LEN,
+ },
+ {
+ .auth = ODP_AUTH_ALG_SHA512_HMAC,
+ .auth_key_length = HMAC_SHA512_KEY_LEN,
+ /* "Jefe" */
+ .auth_key = { 0x4a, 0x65, 0x66, 0x65 },
+ .length = 28,
+ /* what do ya want for nothing?*/
+ .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+ .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f },
+ .digest_length = HMAC_SHA512_CHECK_LEN,
+ .digest = { 0x16, 0x4b, 0x7a, 0x7b, 0xfc, 0xf8, 0x19, 0xe2,
+ 0xe3, 0x95, 0xfb, 0xe7, 0x3b, 0x56, 0xe0, 0xa3,
+ 0x87, 0xbd, 0x64, 0x22, 0x2e, 0x83, 0x1f, 0xd6,
+ 0x10, 0x27, 0x0c, 0xd7, 0xea, 0x25, 0x05, 0x54,
+ 0x97, 0x58, 0xbf, 0x75, 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,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd },
+ .digest_length = HMAC_SHA512_CHECK_LEN,
+ .digest = { 0xfa, 0x73, 0xb0, 0x08, 0x9d, 0x56, 0xa2, 0x84,
+ 0xef, 0xb0, 0xf0, 0x75, 0x6c, 0x89, 0x0b, 0xe9,
+ 0xb1, 0xb5, 0xdb, 0xdd, 0x8e, 0xe8, 0x1a, 0x36,
+ 0x55, 0xf8, 0x3e, 0x33, 0xb2, 0x27, 0x9d, 0x39,
+ 0xbf, 0x3e, 0x84, 0x82, 0x79, 0xa7, 0x22, 0xc8,
+ 0x06, 0xb4, 0x85, 0xa4, 0x7e, 0x67, 0xc8, 0x07,
+ 0xb9, 0x46, 0xa3, 0x37, 0xbe, 0xe8, 0x94, 0x26,
+ 0x74, 0x27, 0x88, 0x59, 0xe1, 0x32, 0x92, 0xfb }
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = HMAC_SHA512_256_CHECK_LEN,
+ },
+};
+
+/*
+ * RFC 3566
+ */
+static crypto_test_reference_t aes_xcbc_reference[] = {
+ /* Test Case #1 */
+ {
+ .auth = ODP_AUTH_ALG_AES_XCBC_MAC,
+ .auth_key_length = AES_XCBC_MAC_KEY_LEN,
+ .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f},
+ .length = 0,
+ .digest_length = AES_XCBC_MAC_CHECK_LEN,
+ .digest = {0x75, 0xf0, 0x25, 0x1d, 0x52, 0x8a, 0xc0, 0x1c,
+ 0x45, 0x73, 0xdf, 0xd5, 0x84, 0xd7, 0x9f, 0x29}
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = AES_XCBC_MAC_96_CHECK_LEN,
+ },
+ /* Test Case #2 */
+ {
+ .auth = ODP_AUTH_ALG_AES_XCBC_MAC,
+ .auth_key_length = AES_XCBC_MAC_KEY_LEN,
+ .auth_key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+ .length = 3,
+ .plaintext = { 0x00, 0x01, 0x02 },
+ .ciphertext = { 0x00, 0x01, 0x02 },
+ .digest_length = AES_XCBC_MAC_CHECK_LEN,
+ .digest = { 0x5b, 0x37, 0x65, 0x80, 0xae, 0x2f, 0x19, 0xaf,
+ 0xe7, 0x21, 0x9c, 0xee, 0xf1, 0x72, 0x75, 0x6f }
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = AES_XCBC_MAC_96_CHECK_LEN,
+ },
+ /* Test Case #3 */
+ {
+ .auth = ODP_AUTH_ALG_AES_XCBC_MAC,
+ .auth_key_length = AES_XCBC_MAC_KEY_LEN,
+ .auth_key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+ .length = 16,
+ .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+ .ciphertext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+ .digest_length = AES_XCBC_MAC_CHECK_LEN,
+ .digest = { 0xd2, 0xa2, 0x46, 0xfa, 0x34, 0x9b, 0x68, 0xa7,
+ 0x99, 0x98, 0xa4, 0x39, 0x4f, 0xf7, 0xa2, 0x63 }
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = AES_XCBC_MAC_96_CHECK_LEN,
+ },
+ /* Test Case #4 */
+ {
+ .auth = ODP_AUTH_ALG_AES_XCBC_MAC,
+ .auth_key_length = AES_XCBC_MAC_KEY_LEN,
+ .auth_key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+ .length = 20,
+ .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13 },
+ .ciphertext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13 },
+ .digest_length = AES_XCBC_MAC_CHECK_LEN,
+ .digest = { 0x47, 0xf5, 0x1b, 0x45, 0x64, 0x96, 0x62, 0x15,
+ 0xb8, 0x98, 0x5c, 0x63, 0x05, 0x5e, 0xd3, 0x08 }
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = AES_XCBC_MAC_96_CHECK_LEN,
+ },
+ /* Test Case #5 */
+ {
+ .auth = ODP_AUTH_ALG_AES_XCBC_MAC,
+ .auth_key_length = AES_XCBC_MAC_KEY_LEN,
+ .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f},
+ .length = 32,
+ .plaintext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f},
+ .ciphertext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f},
+ .digest_length = AES_XCBC_MAC_CHECK_LEN,
+ .digest = {0xf5, 0x4f, 0x0e, 0xc8, 0xd2, 0xb9, 0xf3, 0xd3,
+ 0x68, 0x07, 0x73, 0x4b, 0xd5, 0x28, 0x3f, 0xd4}
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = AES_XCBC_MAC_96_CHECK_LEN,
+ },
+ /* Test Case #6 */
+ {
+ .auth = ODP_AUTH_ALG_AES_XCBC_MAC,
+ .auth_key_length = AES_XCBC_MAC_KEY_LEN,
+ .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f},
+ .length = 34,
+ .plaintext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21},
+ .ciphertext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21},
+ .digest_length = AES_XCBC_MAC_CHECK_LEN,
+ .digest = {0xbe, 0xcb, 0xb3, 0xbc, 0xcd, 0xb5, 0x18, 0xa3,
+ 0x06, 0x77, 0xd5, 0x48, 0x1f, 0xb6, 0xb4, 0xd8}
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = AES_XCBC_MAC_96_CHECK_LEN,
+ },
+ /* Test Case #7 */
+ {
+ .auth = ODP_AUTH_ALG_AES_XCBC_MAC,
+ .auth_key_length = AES_XCBC_MAC_KEY_LEN,
+ .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f},
+ .length = 1000,
+ /* Plaintext is 1000 zero bytes. No explicit init needed. */
+ .digest_length = AES_XCBC_MAC_CHECK_LEN,
+ .digest = {0xf0, 0xda, 0xfe, 0xe8, 0x95, 0xdb, 0x30, 0x25,
+ 0x37, 0x61, 0x10, 0x3b, 0x5d, 0x84, 0x52, 0x8f}
+ },
+ {
+ .copy_previous_vector = 1,
+ .digest_length = AES_XCBC_MAC_96_CHECK_LEN,
+ },
+};
+
+/*
+ * Kasumi F8 and F9 test vectors are taken from
+ * 3GPP TS 35.203 V9.0.0 (2009-12)
+ * 3rd Generation Partnership Project;
+ * Technical Specification Group Services and System Aspects;
+ * 3G Security;
+ * Specification of the 3GPP Confidentiality
+ * and Integrity Algorithms;
+ * Document 3: Implementors' Test Data
+ * (Release 9)
+ */
+static crypto_test_reference_t kasumi_f8_reference[] = {
+ {
+ .cipher = ODP_CIPHER_ALG_KASUMI_F8,
+ .cipher_key_length = KASUMI_F8_KEY_LEN,
+ .cipher_key = { 0x5a, 0xcb, 0x1d, 0x64, 0x4c, 0x0d, 0x51, 0x20,
+ 0x4e, 0xa5, 0xf1, 0x45, 0x10, 0x10, 0xd8, 0x52},
+ .cipher_iv_length = KASUMI_F8_IV_LEN,
+ .cipher_iv = { 0xfa, 0x55, 0x6b, 0x26, 0x1c, 0x00, 0x00, 0x00},
+ .length = 120, /* 15 bytes */
+ .is_length_in_bits = true,
+ .plaintext = { 0xad, 0x9c, 0x44, 0x1f, 0x89, 0x0b, 0x38, 0xc4,
+ 0x57, 0xa4, 0x9d, 0x42, 0x14, 0x07, 0xe8 },
+ .ciphertext = { 0x9b, 0xc9, 0x2c, 0xa8, 0x03, 0xc6, 0x7b, 0x28,
+ 0xa1, 0x1a, 0x4b, 0xee, 0x5a, 0x0c, 0x25 }
+ }
+};
+
+static crypto_test_reference_t kasumi_f9_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_KASUMI_F9,
+ .auth_key_length = KASUMI_F9_KEY_LEN,
+ .auth_key = { 0xc7, 0x36, 0xc6, 0xaa, 0xb2, 0x2b, 0xff, 0xf9,
+ 0x1e, 0x26, 0x98, 0xd2, 0xe2, 0x2a, 0xd5, 0x7e },
+ .auth_iv_length = KASUMI_F9_IV_LEN,
+ .auth_iv = { 0x14, 0x79, 0x3e, 0x41, 0x03, 0x97, 0xe8, 0xfd,
+ 0x01, },
+ .length = 384, /* 48 bytes */
+ .is_length_in_bits = true,
+ .plaintext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2,
+ 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1,
+ 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29,
+ 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0,
+ 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20,
+ 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09},
+ .ciphertext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2,
+ 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1,
+ 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29,
+ 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0,
+ 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20,
+ 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09},
+ .digest_length = KASUMI_F9_DIGEST_LEN,
+ .digest = { 0xdd, 0x7d, 0xfa, 0xdd },
+ }
+};
+
+/*
+ * Snow3G UEA2 & UIA2 test vectors are taken from
+ * Specification of the 3GPP Confidentiality and
+ * Integrity Algorithms UEA2 & UIA2
+ * Document 3: Implementors’ Test Data
+ * Version: 1.1
+ * Date: 25 th October 2012
+ */
+static crypto_test_reference_t snow3g_uea2_reference[] = {
+ {
+ .cipher = ODP_CIPHER_ALG_SNOW3G_UEA2,
+ .cipher_key_length = SNOW3G_UEA2_KEY_LEN,
+ .cipher_key = { 0x5a, 0xcb, 0x1d, 0x64, 0x4c, 0x0d, 0x51, 0x20,
+ 0x4e, 0xa5, 0xf1, 0x45, 0x10, 0x10, 0xd8, 0x52},
+ .cipher_iv_length = SNOW3G_UEA2_IV_LEN,
+ .cipher_iv = { 0xfa, 0x55, 0x6b, 0x26, 0x1c, 0x00, 0x00, 0x00,
+ 0xfa, 0x55, 0x6b, 0x26, 0x1c, 0x00, 0x00, 0x00},
+ .length = 120, /* 15 bytes */
+ .is_length_in_bits = true,
+ .plaintext = { 0xad, 0x9c, 0x44, 0x1f, 0x89, 0x0b, 0x38, 0xc4,
+ 0x57, 0xa4, 0x9d, 0x42, 0x14, 0x07, 0xe8 },
+ .ciphertext = { 0xba, 0x0f, 0x31, 0x30, 0x03, 0x34, 0xc5, 0x6b,
+ 0x52, 0xa7, 0x49, 0x7c, 0xba, 0xc0, 0x46 }
+ }
+};
+
+static crypto_test_reference_t snow3g_uia2_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_SNOW3G_UIA2,
+ .auth_key_length = SNOW3G_UIA2_KEY_LEN,
+ .auth_key = { 0xc7, 0x36, 0xc6, 0xaa, 0xb2, 0x2b, 0xff, 0xf9,
+ 0x1e, 0x26, 0x98, 0xd2, 0xe2, 0x2a, 0xd5, 0x7e},
+ .auth_iv_length = SNOW3G_UIA2_IV_LEN,
+ .auth_iv = { 0x14, 0x79, 0x3e, 0x41, 0x03, 0x97, 0xe8, 0xfd,
+ 0x94, 0x79, 0x3e, 0x41, 0x03, 0x97, 0x68, 0xfd },
+ .length = 384, /* 48 bytes */
+ .is_length_in_bits = true,
+ .plaintext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2,
+ 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1,
+ 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29,
+ 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0,
+ 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20,
+ 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09},
+ .ciphertext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2,
+ 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1,
+ 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29,
+ 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0,
+ 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20,
+ 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09},
+ .digest_length = SNOW3G_UIA2_DIGEST_LEN,
+ .digest = { 0x38, 0xb5, 0x54, 0xc0 }
+ }
+};
+
+/*
+ * AES EEA2 and AES EIA2 test vectors from
+ * Specification of the 3GPP Confidentiality and Integrity
+ * Algorithms 128-EEA2 & 128-EIA2
+ */
+static crypto_test_reference_t aes_eea2_reference[] = {
+ {
+ .cipher = ODP_CIPHER_ALG_AES_EEA2,
+ .cipher_key_length = AES_EEA2_KEY_LEN,
+ .cipher_key = { 0xD3, 0xC5, 0xD5, 0x92, 0x32, 0x7F, 0xB1, 0x1C,
+ 0x40, 0x35, 0xC6, 0x68, 0x0A, 0xF8, 0xC6, 0xD1},
+ .cipher_iv_length = AES_EEA2_IV_LEN,
+ .cipher_iv = { 0x39, 0x8a, 0x59, 0xb4, 0xac, },
+ .length = 253,
+ .is_length_in_bits = true,
+ .plaintext = { 0x98, 0x1B, 0xA6, 0x82, 0x4C, 0x1B, 0xFB, 0x1A,
+ 0xB4, 0x85, 0x47, 0x20, 0x29, 0xB7, 0x1D, 0x80,
+ 0x8C, 0xE3, 0x3E, 0x2C, 0xC3, 0xC0, 0xB5, 0xFC,
+ 0x1F, 0x3D, 0xE8, 0xA6, 0xDC, 0x66, 0xB1, 0xF0 },
+ .ciphertext = { 0xE9, 0xFE, 0xD8, 0xA6, 0x3D, 0x15, 0x53, 0x04,
+ 0xD7, 0x1D, 0xF2, 0x0B, 0xF3, 0xE8, 0x22, 0x14,
+ 0xB2, 0x0E, 0xD7, 0xDA, 0xD2, 0xF2, 0x33, 0xDC,
+ 0x3C, 0x22, 0xD7, 0xBD, 0xEE, 0xED, 0x8E, 0x78}
+ },
+ {
+ .cipher = ODP_CIPHER_ALG_AES_EEA2,
+ .cipher_key_length = AES_EEA2_KEY_LEN,
+ .cipher_key = { 0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC4, 0x40, 0xE0,
+ 0x95, 0x2C, 0x49, 0x10, 0x48, 0x05, 0xFF, 0x48},
+ .cipher_iv_length = AES_EEA2_IV_LEN,
+ .cipher_iv = { 0xc6, 0x75, 0xa6, 0x4b, 0x64, },
+ .length = 798,
+ .is_length_in_bits = true,
+ .plaintext = { 0x7E, 0xC6, 0x12, 0x72, 0x74, 0x3B, 0xF1, 0x61,
+ 0x47, 0x26, 0x44, 0x6A, 0x6C, 0x38, 0xCE, 0xD1,
+ 0x66, 0xF6, 0xCA, 0x76, 0xEB, 0x54, 0x30, 0x04,
+ 0x42, 0x86, 0x34, 0x6C, 0xEF, 0x13, 0x0F, 0x92,
+ 0x92, 0x2B, 0x03, 0x45, 0x0D, 0x3A, 0x99, 0x75,
+ 0xE5, 0xBD, 0x2E, 0xA0, 0xEB, 0x55, 0xAD, 0x8E,
+ 0x1B, 0x19, 0x9E, 0x3E, 0xC4, 0x31, 0x60, 0x20,
+ 0xE9, 0xA1, 0xB2, 0x85, 0xE7, 0x62, 0x79, 0x53,
+ 0x59, 0xB7, 0xBD, 0xFD, 0x39, 0xBE, 0xF4, 0xB2,
+ 0x48, 0x45, 0x83, 0xD5, 0xAF, 0xE0, 0x82, 0xAE,
+ 0xE6, 0x38, 0xBF, 0x5F, 0xD5, 0xA6, 0x06, 0x19,
+ 0x39, 0x01, 0xA0, 0x8F, 0x4A, 0xB4, 0x1A, 0xAB,
+ 0x9B, 0x13, 0x48, 0x80 },
+ .ciphertext = { 0x59, 0x61, 0x60, 0x53, 0x53, 0xC6, 0x4B, 0xDC,
+ 0xA1, 0x5B, 0x19, 0x5E, 0x28, 0x85, 0x53, 0xA9,
+ 0x10, 0x63, 0x25, 0x06, 0xD6, 0x20, 0x0A, 0xA7,
+ 0x90, 0xC4, 0xC8, 0x06, 0xC9, 0x99, 0x04, 0xCF,
+ 0x24, 0x45, 0xCC, 0x50, 0xBB, 0x1C, 0xF1, 0x68,
+ 0xA4, 0x96, 0x73, 0x73, 0x4E, 0x08, 0x1B, 0x57,
+ 0xE3, 0x24, 0xCE, 0x52, 0x59, 0xC0, 0xE7, 0x8D,
+ 0x4C, 0xD9, 0x7B, 0x87, 0x09, 0x76, 0x50, 0x3C,
+ 0x09, 0x43, 0xF2, 0xCB, 0x5A, 0xE8, 0xF0, 0x52,
+ 0xC7, 0xB7, 0xD3, 0x92, 0x23, 0x95, 0x87, 0xB8,
+ 0x95, 0x60, 0x86, 0xBC, 0xAB, 0x18, 0x83, 0x60,
+ 0x42, 0xE2, 0xE6, 0xCE, 0x42, 0x43, 0x2A, 0x17,
+ 0x10, 0x5C, 0x53, 0xD0 }
+ },
+};
+
+static crypto_test_reference_t aes_eia2_reference[] = {
+ /* 3GPP TS 33.401, C.2.1 */
+ {
+ .auth = ODP_AUTH_ALG_AES_EIA2,
+ .auth_key_length = AES_EIA2_KEY_LEN,
+ .auth_key = { 0x2b, 0xd6, 0x45, 0x9f, 0x82, 0xc5, 0xb3, 0x00,
+ 0x95, 0x2c, 0x49, 0x10, 0x48, 0x81, 0xff, 0x48 },
+ .auth_iv_length = AES_EIA2_IV_LEN,
+ .auth_iv = { 0x38, 0xa6, 0xf0, 0x56, 0xc0 },
+ .length = 58,
+ .is_length_in_bits = true,
+ .plaintext = { 0x33, 0x32, 0x34, 0x62, 0x63, 0x39, 0x38, 0x40 },
+ .ciphertext = { 0x33, 0x32, 0x34, 0x62, 0x63, 0x39, 0x38, 0x40 },
+ .digest_length = AES_EIA2_DIGEST_LEN,
+ .digest = { 0x11, 0x8c, 0x6e, 0xb8 }
+ },
+ /* 3GPP TS 33.401, C.2.2. */
+ {
+ .auth = ODP_AUTH_ALG_AES_EIA2,
+ .auth_key_length = AES_EIA2_KEY_LEN,
+ .auth_key = { 0xD3, 0xC5, 0xD5, 0x92, 0x32, 0x7F, 0xB1, 0x1C,
+ 0x40, 0x35, 0xC6, 0x68, 0x0A, 0xF8, 0xC6, 0xD1 },
+ .auth_iv_length = AES_EIA2_IV_LEN,
+ .auth_iv = { 0x39, 0x8a, 0x59, 0xb4, 0xd4, },
+ .length = 64, /* 8 bytes */
+ .is_length_in_bits = true,
+ .plaintext = { 0x48, 0x45, 0x83, 0xd5, 0xaf, 0xe0, 0x82, 0xae },
+ .ciphertext = { 0x48, 0x45, 0x83, 0xd5, 0xaf, 0xe0, 0x82, 0xae},
+ .digest_length = AES_EIA2_DIGEST_LEN,
+ .digest = { 0xb9, 0x37, 0x87, 0xe6 }
+ },
+ /* 3GPP TS 33.401, C.2.5 */
+ {
+ .auth = ODP_AUTH_ALG_AES_EIA2,
+ .auth_key_length = AES_EIA2_KEY_LEN,
+ .auth_key = { 0x83, 0xfd, 0x23, 0xa2, 0x44, 0xa7, 0x4c, 0xf3,
+ 0x58, 0xda, 0x30, 0x19, 0xf1, 0x72, 0x26, 0x35 },
+ .auth_iv_length = AES_EIA2_IV_LEN,
+ .auth_iv = { 0x36, 0xaf, 0x61, 0x44, 0x7c },
+ .length = 768, /* 96 bytes */
+ .is_length_in_bits = true,
+ .plaintext = { 0x35, 0xc6, 0x87, 0x16, 0x63, 0x3c, 0x66, 0xfb,
+ 0x75, 0x0c, 0x26, 0x68, 0x65, 0xd5, 0x3c, 0x11,
+ 0xea, 0x05, 0xb1, 0xe9, 0xfa, 0x49, 0xc8, 0x39,
+ 0x8d, 0x48, 0xe1, 0xef, 0xa5, 0x90, 0x9d, 0x39,
+ 0x47, 0x90, 0x28, 0x37, 0xf5, 0xae, 0x96, 0xd5,
+ 0xa0, 0x5b, 0xc8, 0xd6, 0x1c, 0xa8, 0xdb, 0xef,
+ 0x1b, 0x13, 0xa4, 0xb4, 0xab, 0xfe, 0x4f, 0xb1,
+ 0x00, 0x60, 0x45, 0xb6, 0x74, 0xbb, 0x54, 0x72,
+ 0x93, 0x04, 0xc3, 0x82, 0xbe, 0x53, 0xa5, 0xaf,
+ 0x05, 0x55, 0x61, 0x76, 0xf6, 0xea, 0xa2, 0xef,
+ 0x1d, 0x05, 0xe4, 0xb0, 0x83, 0x18, 0x1e, 0xe6,
+ 0x74, 0xcd, 0xa5, 0xa4, 0x85, 0xf7, 0x4d, 0x7a },
+ .ciphertext = { 0x35, 0xc6, 0x87, 0x16, 0x63, 0x3c, 0x66, 0xfb,
+ 0x75, 0x0c, 0x26, 0x68, 0x65, 0xd5, 0x3c, 0x11,
+ 0xea, 0x05, 0xb1, 0xe9, 0xfa, 0x49, 0xc8, 0x39,
+ 0x8d, 0x48, 0xe1, 0xef, 0xa5, 0x90, 0x9d, 0x39,
+ 0x47, 0x90, 0x28, 0x37, 0xf5, 0xae, 0x96, 0xd5,
+ 0xa0, 0x5b, 0xc8, 0xd6, 0x1c, 0xa8, 0xdb, 0xef,
+ 0x1b, 0x13, 0xa4, 0xb4, 0xab, 0xfe, 0x4f, 0xb1,
+ 0x00, 0x60, 0x45, 0xb6, 0x74, 0xbb, 0x54, 0x72,
+ 0x93, 0x04, 0xc3, 0x82, 0xbe, 0x53, 0xa5, 0xaf,
+ 0x05, 0x55, 0x61, 0x76, 0xf6, 0xea, 0xa2, 0xef,
+ 0x1d, 0x05, 0xe4, 0xb0, 0x83, 0x18, 0x1e, 0xe6,
+ 0x74, 0xcd, 0xa5, 0xa4, 0x85, 0xf7, 0x4d, 0x7a },
+ .digest_length = AES_EIA2_DIGEST_LEN,
+ .digest = { 0xe6, 0x57, 0xe1, 0x82 }
+ },
+};
+
+/*
+ * ZUC EEA3 and EIA3 test vectors from
+ * Specification of the 3GPP Confidentiality and Integrity
+ * Algorithms 128-EEA3 & 128-EIA3
+ * Document 3: Implementor’s Test Data
+ * Version: 1.1
+ * Date: 4 th Jan. 2011
+ */
+static crypto_test_reference_t zuc_eea3_reference[] = {
+ {
+ .cipher = ODP_CIPHER_ALG_ZUC_EEA3,
+ .cipher_key_length = ZUC_EEA3_KEY_LEN,
+ .cipher_key = { 0xe5, 0xbd, 0x3e, 0xa0, 0xeb, 0x55, 0xad, 0xe8,
+ 0x66, 0xc6, 0xac, 0x58, 0xbd, 0x54, 0x30, 0x2a},
+ .cipher_iv_length = ZUC_EEA3_IV_LEN,
+ .cipher_iv = { 0x00, 0x05, 0x68, 0x23, 0xc4, 0x00, 0x00, 0x00,
+ 0x00, 0x05, 0x68, 0x23, 0xc4, 0x00, 0x00, 0x00 },
+ .length = 800, /* 100 bytes */
+ .is_length_in_bits = true,
+ .plaintext = { 0x14, 0xa8, 0xef, 0x69, 0x3d, 0x67, 0x85, 0x07,
+ 0xbb, 0xe7, 0x27, 0x0a, 0x7f, 0x67, 0xff, 0x50,
+ 0x06, 0xc3, 0x52, 0x5b, 0x98, 0x07, 0xe4, 0x67,
+ 0xc4, 0xe5, 0x60, 0x00, 0xba, 0x33, 0x8f, 0x5d,
+ 0x42, 0x95, 0x59, 0x03, 0x67, 0x51, 0x82, 0x22,
+ 0x46, 0xc8, 0x0d, 0x3b, 0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N,
+ .cipher_key = { 0xf7, 0xb4, 0x04, 0x5a, 0x81, 0x5c, 0x1b, 0x01,
+ 0x82, 0xf9, 0xf4, 0x26, 0x80, 0xd4, 0x56, 0x26,
+ 0xd5, 0xf7, 0x4b, 0x68, 0x48, 0x6b, 0x92, 0x6a,
+ 0x34, 0x1f, 0x86, 0x66, 0x60, 0x0a, 0xfc, 0x57},
+ .cipher_iv_length = ZUC_EEA3_256_IV_LEN,
+ .cipher_iv = { 0x8e, 0x5d, 0xbc, 0x3f, 0xb9, 0xae, 0x66, 0xa3,
+ 0xb9, 0x5c, 0x12, 0x14, 0xdb, 0xc5, 0xbc, 0x18,
+ 0x48, 0x12, 0x09, 0x06, 0x25, 0x33, 0x2e, 0x12,
+ 0x12 },
+ .length = 1024,
+ .is_length_in_bits = true,
+ .plaintext = { 0x36, 0xdb, 0x63, 0x68, 0xb5, 0x1f, 0x4e, 0x92,
+ 0x46, 0x1f, 0xde, 0xdb, 0xc2, 0xec, 0xfa, 0x7e,
+ 0x49, 0x85, 0x77, 0xaa, 0x46, 0x98, 0x30, 0x2d,
+ 0x3b, 0xc4, 0x11, 0x24, 0x98, 0x20, 0xa9, 0xce,
+ 0xfb, 0x0d, 0x36, 0xb0, 0x2c, 0x85, 0x42, 0x72,
+ 0xa4, 0x21, 0x4e, 0x66, 0x0d, 0x48, 0xe4, 0x57,
+ 0xce, 0x5b, 0x01, 0x14, 0xf3, 0x31, 0x42, 0x2e,
+ 0xf5, 0x53, 0x52, 0x8d, 0x73, 0xfc, 0x5c, 0x6e,
+ 0x09, 0x92, 0x1e, 0x35, 0x17, 0x60, 0xa8, 0xbb,
+ 0x81, 0xf6, 0x21, 0x8f, 0x3e, 0x05, 0xe6, 0x0c,
+ 0x60, 0xe7, 0x21, 0x53, 0x18, 0x63, 0x81, 0x0d,
+ 0xb6, 0xd4, 0x9a, 0x29, 0xd0, 0xf6, 0x97, 0xd9,
+ 0x89, 0xb5, 0x0e, 0xa0, 0x15, 0xb6, 0x5c, 0x97,
+ 0xac, 0x7d, 0x26, 0xeb, 0x83, 0x0c, 0xf7, 0xe3,
+ 0xf3, 0x18, 0x37, 0x0b, 0x7b, 0xb8, 0x18, 0x31,
+ 0x8c, 0xb2, 0x5a, 0x5c, 0xa9, 0xf1, 0x35, 0x32 },
+ .ciphertext = { 0xa6, 0xe5, 0x71, 0x58, 0x5c, 0xcf, 0x5d, 0x0d,
+ 0x59, 0xb5, 0x51, 0xab, 0xf5, 0xfa, 0x31, 0xf9,
+ 0x8d, 0x4f, 0xf0, 0x3c, 0x7d, 0x61, 0x8d, 0x7a,
+ 0x6b, 0xcb, 0x2c, 0x79, 0xca, 0x99, 0x06, 0x6f,
+ 0xff, 0x5d, 0x12, 0x5f, 0x0e, 0x7a, 0x33, 0x6b,
+ 0x51, 0xbc, 0x58, 0x53, 0xff, 0xbd, 0x85, 0xc9,
+ 0xac, 0x5f, 0x33, 0xc2, 0xa2, 0xf1, 0x17, 0x7a,
+ 0xd9, 0x3f, 0x81, 0x82, 0x2f, 0x0a, 0xb0, 0xaf,
+ 0xb9, 0x19, 0x3b, 0xfa, 0xcd, 0xa4, 0x06, 0x81,
+ 0x2a, 0x7a, 0xbf, 0x2c, 0x07, 0xde, 0xc1, 0xa4,
+ 0x8c, 0x15, 0x85, 0x81, 0xa6, 0xd3, 0x73, 0x1c,
+ 0x29, 0x0b, 0xee, 0x3c, 0x57, 0xfa, 0x82, 0xad,
+ 0x6f, 0xe0, 0xa1, 0x54, 0x8d, 0xa4, 0x92, 0x29,
+ 0xf4, 0xfa, 0x6d, 0x01, 0xe3, 0x6c, 0xb9, 0x76,
+ 0x80, 0x53, 0xbb, 0x27, 0xb8, 0x18, 0x47, 0x6c,
+ 0xae, 0xb5, 0x44, 0x60, 0x43, 0x9d, 0xa7, 0x3f }
+ },
+ /* Privately generated test data */
+ {
+ .cipher = ODP_CIPHER_ALG_ZUC_EEA3,
+ .cipher_key_length = ZUC_EEA3_256_KEY_LEN,
+ .cipher_key = { 0x1d, 0x0f, 0x0e, 0x75, 0x86, 0xb3, 0xfc, 0x65,
+ 0x94, 0xbf, 0xaa, 0xa8, 0xf5, 0xd0, 0x0f, 0xe8,
+ 0x14, 0x7a, 0x96, 0x61, 0x15, 0x49, 0x79, 0x71,
+ 0x13, 0x82, 0xb4, 0xae, 0x34, 0x04, 0x75, 0x51 },
+ .cipher_iv_length = ZUC_EEA3_256_IV_LEN,
+ .cipher_iv = { 0x98, 0xcc, 0x89, 0x9f, 0xaf, 0x6d, 0x64, 0xb6,
+ 0xb1, 0xe8, 0x21, 0x72, 0xee, 0xb6, 0xcc, 0xe3,
+ 0xcf, 0x32, 0x28, 0x21, 0x21, 0x0d, 0x1e, 0x1c,
+ 0x34 },
+ .length = 1928,
+ .is_length_in_bits = true,
+ .plaintext = { 0xa4, 0xcb, 0x6e, 0x76, 0x99, 0xfb, 0x0c, 0xab,
+ 0x6d, 0x57, 0xb1, 0x69, 0xc0, 0x47, 0x80, 0x63,
+ 0x00, 0xe1, 0xf9, 0x51, 0x10, 0xbe, 0xc0, 0x0f,
+ 0x99, 0x62, 0x2d, 0x71, 0xca, 0x75, 0xa0, 0x6e,
+ 0x41, 0x0e, 0xe4, 0xda, 0x09, 0xf1, 0x86, 0x76,
+ 0x48, 0x37, 0xe0, 0x08, 0x7e, 0x60, 0x6c, 0x7f,
+ 0x41, 0x65, 0xd0, 0x51, 0x24, 0x91, 0x61, 0xbd,
+ 0xf3, 0x8e, 0x2e, 0xbd, 0x04, 0xce, 0x2b, 0x45,
+ 0xdc, 0x0f, 0x1f, 0xe5, 0x00, 0xa5, 0x5c, 0x48,
+ 0xdd, 0x3c, 0x51, 0x5b, 0x9c, 0xbd, 0xda, 0xde,
+ 0x22, 0xab, 0x2f, 0x46, 0x3c, 0x90, 0x03, 0x2f,
+ 0x1f, 0x31, 0xec, 0x23, 0xff, 0x17, 0x68, 0xdb,
+ 0x26, 0x87, 0xc1, 0x27, 0x2d, 0x1d, 0x6f, 0x0a,
+ 0x59, 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 0xf3, 0x12, 0x7f, 0x9f, 0x89, 0xcf, 0x48, 0x58,
+ 0x01, 0xeb, 0x98, 0x7c, 0x59, 0x11, 0x9f, 0x57,
+ 0x74, 0x5f, 0x70, 0x72, 0x74, 0xa4, 0x82, 0x3c,
+ 0x36, 0xe6, 0x31, 0x9e, 0xba, 0x7b, 0x53, 0xfc,
+ 0x56 }
+ },
+};
+
+static crypto_test_reference_t zuc_eia3_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_ZUC_EIA3,
+ .auth_key_length = ZUC_EIA3_KEY_LEN,
+ .auth_key = { 0xc9, 0xe6, 0xce, 0xc4, 0x60, 0x7c, 0x72, 0xdb,
+ 0x00, 0x0a, 0xef, 0xa8, 0x83, 0x85, 0xab, 0x0a },
+ .auth_iv_length = ZUC_EIA3_IV_LEN,
+ .auth_iv = { 0xa9, 0x40, 0x59, 0xda, 0x50, 0x00, 0x00, 0x00,
+ 0x29, 0x40, 0x59, 0xda, 0x50, 0x00, 0x80, 0x00 },
+ .length = 584, /* 73 bytes */
+ .is_length_in_bits = true,
+ .plaintext = { 0x98, 0x3b, 0x41, 0xd4, 0x7d, 0x78, 0x0c, 0x9e,
+ 0x1a, 0xd1, 0x1d, 0x7e, 0xb7, 0x03, 0x91, 0xb1,
+ 0xde, 0x0b, 0x35, 0xda, 0x2d, 0xc6, 0x2f, 0x83,
+ 0xe7, 0xb7, 0x8d, 0x63, 0x06, 0xca, 0x0e, 0xa0,
+ 0x7e, 0x94, 0x1b, 0x7b, 0xe9, 0x13, 0x48, 0xf9,
+ 0xfc, 0xb1, 0x70, 0xe2, 0x21, 0x7f, 0xec, 0xd9,
+ 0x7f, 0x9f, 0x68, 0xad, 0xb1, 0x6e, 0x5d, 0x7d,
+ 0x21, 0xe5, 0x69, 0xd2, 0x80, 0xed, 0x77, 0x5c,
+ 0xeb, 0xde, 0x3f, 0x40, 0x93, 0xc5, 0x38, 0x81,
+ 0x00, 0x00, 0x00, 0x00 },
+ .ciphertext = { 0x98, 0x3b, 0x41, 0xd4, 0x7d, 0x78, 0x0c, 0x9e,
+ 0x1a, 0xd1, 0x1d, 0x7e, 0xb7, 0x03, 0x91, 0xb1,
+ 0xde, 0x0b, 0x35, 0xda, 0x2d, 0xc6, 0x2f, 0x83,
+ 0xe7, 0xb7, 0x8d, 0x63, 0x06, 0xca, 0x0e, 0xa0,
+ 0x7e, 0x94, 0x1b, 0x7b, 0xe9, 0x13, 0x48, 0xf9,
+ 0xfc, 0xb1, 0x70, 0xe2, 0x21, 0x7f, 0xec, 0xd9,
+ 0x7f, 0x9f, 0x68, 0xad, 0xb1, 0x6e, 0x5d, 0x7d,
+ 0x21, 0xe5, 0x69, 0xd2, 0x80, 0xed, 0x77, 0x5c,
+ 0xeb, 0xde, 0x3f, 0x40, 0x93, 0xc5, 0x38, 0x81,
+ 0x00, 0x00, 0x00, 0x00 },
+ .digest_length = ZUC_EIA3_DIGEST_LEN,
+ .digest = { 0x24, 0xa8, 0x42, 0xb3 }
+ },
+ /* Privately generated test data */
+ {
+ .auth = ODP_AUTH_ALG_ZUC_EIA3,
+ .auth_key_length = ZUC_EIA3_256_KEY_LEN,
+ .auth_key = { 0xe3, 0x8e, 0xaf, 0x08, 0xde, 0x8c, 0x08, 0x41,
+ 0x7f, 0x2b, 0x97, 0x20, 0x10, 0x87, 0xc7, 0xf7,
+ 0xbe, 0x3c, 0xd2, 0x68, 0x80, 0x10, 0x1e, 0x71,
+ 0xfd, 0xb2, 0xbb, 0xad, 0x25, 0x0f, 0x06, 0x08 },
+ .auth_iv_length = ZUC_EIA3_256_IV_LEN,
+ .auth_iv = { 0xf5, 0x8d, 0x08, 0x26, 0x94, 0x14, 0xc7, 0x4d,
+ 0xf5, 0x7c, 0x9c, 0xaa, 0x45, 0x53, 0xfd, 0x85,
+ 0x23, 0x0b, 0x00, 0x0e, 0x26, 0x2b, 0x0f, 0x01,
+ 0x26 },
+ .length = 360,
+ .is_length_in_bits = true,
+ .plaintext = { 0x08, 0xba, 0x8d, 0xf1, 0xf8, 0x62, 0xa6, 0xaf,
+ 0xf9, 0x03, 0x88, 0x9c, 0xa3, 0x68, 0x6b, 0x87,
+ 0xb6, 0x92, 0xd1, 0x47, 0x3e, 0x54, 0xaf, 0x46,
+ 0x07, 0x8f, 0x89, 0xea, 0x26, 0x9d, 0x0e, 0x2f,
+ 0x57, 0x9b, 0x20, 0x4f, 0xfe, 0xc7, 0xfe, 0xf7,
+ 0xca, 0x86, 0x93, 0x6d, 0xee },
+ .ciphertext = { 0x08, 0xba, 0x8d, 0xf1, 0xf8, 0x62, 0xa6, 0xaf,
+ 0xf9, 0x03, 0x88, 0x9c, 0xa3, 0x68, 0x6b, 0x87,
+ 0xb6, 0x92, 0xd1, 0x47, 0x3e, 0x54, 0xaf, 0x46,
+ 0x07, 0x8f, 0x89, 0xea, 0x26, 0x9d, 0x0e, 0x2f,
+ 0x57, 0x9b, 0x20, 0x4f, 0xfe, 0xc7, 0xfe, 0xf7,
+ 0xca, 0x86, 0x93, 0x6d, 0xee },
+ .digest_length = ZUC_EIA3_DIGEST_LEN,
+ .digest = {0x58, 0x19, 0xab, 0xa5}
+ },
+ /* Privately generated test data */
+ {
+ .auth = ODP_AUTH_ALG_ZUC_EIA3,
+ .auth_key_length = ZUC_EIA3_256_KEY_LEN,
+ .auth_key = { 0x6a, 0x7e, 0x4c, 0x7e, 0x51, 0x25, 0xb3, 0x48,
+ 0x84, 0x53, 0x3a, 0x94, 0xfb, 0x31, 0x99, 0x90,
+ 0x32, 0x57, 0x44, 0xee, 0x9b, 0xbc, 0xe9, 0xe5,
+ 0x25, 0xcf, 0x08, 0xf5, 0xe9, 0xe2, 0x5e, 0x53 },
+ .auth_iv_length = ZUC_EIA3_256_IV_LEN,
+ .auth_iv = { 0x60, 0xaa, 0xd2, 0xb2, 0xd0, 0x85, 0xfa, 0x54,
+ 0xd8, 0x35, 0xe8, 0xd4, 0x66, 0x82, 0x64, 0x98,
+ 0xd9, 0x2a, 0x08, 0x1d, 0x35, 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 0xc3, 0x3e,
+ 0x05, 0xf1, 0xec, 0xd9, 0x67, 0x33, 0xb7, 0x99,
+ 0x50, 0xa3, 0xe3, 0x14, 0xd3, 0xd9, 0x34, 0xf7,
+ 0x5e, 0xa0, 0xf2, 0x10, 0xa8, 0xf6, 0x05, 0x94,
+ 0x01, 0xbe, 0xb4, 0xbc, 0x44, 0x78, 0xfa, 0x49,
+ 0x69, 0xe6, 0x23, 0xd0, 0x1a, 0xda, 0x69 },
+ .digest_length = ZUC_EIA3_DIGEST_LEN,
+ .digest = {0xd1, 0x1e, 0x33, 0xf6}
+ },
+};
+
+/*
+ * MD5 test vectors from RFC 1321
+ */
+static crypto_test_reference_t md5_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_MD5,
+ .length = 3,
+ .plaintext = { 0x61, 0x62, 0x63 },
+ .ciphertext = { 0x61, 0x62, 0x63 },
+ .digest_length = MD5_DIGEST_LEN,
+ .digest = { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0,
+ 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72}
+ },
+ {
+ .auth = ODP_AUTH_ALG_MD5,
+ .length = 62,
+ .plaintext = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
+ 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+ 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+ 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
+ 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
+ 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
+ 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33,
+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 },
+ .ciphertext = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
+ 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+ 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+ 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
+ 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
+ 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
+ 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33,
+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 },
+ .digest_length = MD5_DIGEST_LEN,
+ .digest = { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5,
+ 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f},
+ }
+};
+
+/*
+ * SHA test vectors from Crypto++
+ */
+static crypto_test_reference_t sha1_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_SHA1,
+ .length = 3,
+ .plaintext = { 0x61, 0x62, 0x63 },
+ .ciphertext = { 0x61, 0x62, 0x63 },
+ .digest_length = SHA1_DIGEST_LEN,
+ .digest = { 0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A,
+ 0xBA, 0x3E, 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C,
+ 0x9C, 0xD0, 0xD8, 0x9D},
+ },
+ {
+ .auth = ODP_AUTH_ALG_SHA1,
+ .length = 56,
+ .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65,
+ 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67,
+ 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69,
+ 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b,
+ 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d,
+ 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71},
+ .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65,
+ 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67,
+ 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69,
+ 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b,
+ 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d,
+ 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71},
+ .digest_length = SHA1_DIGEST_LEN,
+ .digest = { 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E,
+ 0xBA, 0xAE, 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5,
+ 0xE5, 0x46, 0x70, 0xF1},
+ }
+};
+
+static crypto_test_reference_t sha224_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_SHA224,
+ .length = 3,
+ .plaintext = { 0x61, 0x62, 0x63 },
+ .ciphertext = { 0x61, 0x62, 0x63 },
+ .digest_length = SHA224_DIGEST_LEN,
+ .digest = { 0x23, 0x09, 0x7d, 0x22, 0x34, 0x05, 0xd8, 0x22,
+ 0x86, 0x42, 0xa4, 0x77, 0xbd, 0xa2, 0x55, 0xb3,
+ 0x2a, 0xad, 0xbc, 0xe4, 0xbd, 0xa0, 0xb3, 0xf7,
+ 0xe3, 0x6c, 0x9d, 0xa7 },
+ },
+ {
+ .auth = ODP_AUTH_ALG_SHA224,
+ .length = 56,
+ .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65,
+ 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67,
+ 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69,
+ 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b,
+ 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d,
+ 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71},
+ .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65,
+ 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67,
+ 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69,
+ 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b,
+ 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d,
+ 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71},
+ .digest_length = SHA224_DIGEST_LEN,
+ .digest = { 0x75, 0x38, 0x8b, 0x16, 0x51, 0x27, 0x76, 0xcc,
+ 0x5d, 0xba, 0x5d, 0xa1, 0xfd, 0x89, 0x01, 0x50,
+ 0xb0, 0xc6, 0x45, 0x5c, 0xb4, 0xf5, 0x8b, 0x19,
+ 0x52, 0x52, 0x25, 0x25},
+ }
+};
+
+static crypto_test_reference_t sha256_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_SHA256,
+ .length = 3,
+ .plaintext = { 0x61, 0x62, 0x63 },
+ .ciphertext = { 0x61, 0x62, 0x63 },
+ .digest_length = SHA256_DIGEST_LEN,
+ .digest = { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
+ 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
+ 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
+ 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad},
+ },
+ {
+ .auth = ODP_AUTH_ALG_SHA256,
+ .length = 56,
+ .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65,
+ 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67,
+ 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69,
+ 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b,
+ 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d,
+ 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71},
+ .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65,
+ 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67,
+ 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69,
+ 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b,
+ 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d,
+ 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71},
+ .digest_length = SHA256_DIGEST_LEN,
+ .digest = { 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8,
+ 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39,
+ 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67,
+ 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1},
+ }
+};
+
+static crypto_test_reference_t sha384_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_SHA384,
+ .length = 3,
+ .plaintext = { 0x61, 0x62, 0x63 },
+ .ciphertext = { 0x61, 0x62, 0x63 },
+ .digest_length = SHA384_DIGEST_LEN,
+ .digest = { 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b,
+ 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07,
+ 0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63,
+ 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed,
+ 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23,
+ 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7},
+ },
+ {
+ .auth = ODP_AUTH_ALG_SHA384,
+ .length = 112,
+ .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+ 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+ 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
+ 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
+ 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
+ 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
+ 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
+ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+ 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71,
+ 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72,
+ 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73,
+ 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
+ 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75},
+ .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+ 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+ 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
+ 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
+ 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
+ 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
+ 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
+ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+ 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71,
+ 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72,
+ 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73,
+ 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
+ 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75},
+ .digest_length = SHA384_DIGEST_LEN,
+ .digest = { 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8,
+ 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47,
+ 0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2,
+ 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12,
+ 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9,
+ 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39},
+ }
+};
+
+static crypto_test_reference_t sha512_reference[] = {
+ {
+ .auth = ODP_AUTH_ALG_SHA512,
+ .length = 3,
+ .plaintext = { 0x61, 0x62, 0x63 },
+ .ciphertext = { 0x61, 0x62, 0x63 },
+ .digest_length = SHA512_DIGEST_LEN,
+ .digest = { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba,
+ 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31,
+ 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2,
+ 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a,
+ 0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8,
+ 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd,
+ 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e,
+ 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f},
+ },
+ {
+ .auth = ODP_AUTH_ALG_SHA512,
+ .length = 112,
+ .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+ 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+ 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
+ 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
+ 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
+ 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
+ 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
+ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+ 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71,
+ 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72,
+ 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73,
+ 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
+ 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75},
+ .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+ 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+ 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
+ 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
+ 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
+ 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
+ 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
+ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+ 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71,
+ 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72,
+ 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73,
+ 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
+ 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75},
+ .digest_length = SHA512_DIGEST_LEN,
+ .digest = { 0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda,
+ 0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f,
+ 0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1,
+ 0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18,
+ 0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4,
+ 0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a,
+ 0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54,
+ 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09},
+ }
+};
+
+#endif
diff --git a/test/validation/api/crypto/test_vectors.h b/test/validation/api/crypto/test_vectors.h
index b9a9c2f06..a38644246 100644
--- a/test/validation/api/crypto/test_vectors.h
+++ b/test/validation/api/crypto/test_vectors.h
@@ -1,17 +1,20 @@
/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2022, Nokia
+ * Copyright (c) 2021-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef _ODP_TEST_CRYPTO_VECTORS_H_
-#define _ODP_TEST_CRYPTO_VECTORS_H_
+#ifndef TEST_VECTORS_H
+#define TEST_VECTORS_H
+#include <odp_api.h>
#include "test_vectors_len.h"
typedef struct crypto_test_reference_s {
uint8_t copy_previous_vector; /* does not copy digest_length */
+ odp_cipher_alg_t cipher;
+ odp_auth_alg_t auth;
uint32_t cipher_key_length;
uint8_t cipher_key[MAX_KEY_LEN];
uint32_t auth_key_length;
@@ -30,6 +33,9 @@ typedef struct crypto_test_reference_s {
uint8_t digest[MAX_DIGEST_LEN];
} crypto_test_reference_t;
+ODP_STATIC_ASSERT(ODP_CIPHER_ALG_NULL == 0, "null cipher is not the default");
+ODP_STATIC_ASSERT(ODP_AUTH_ALG_NULL == 0, "null auth is not the default");
+
/*
* Return test data length in bytes, rounding up to full bytes.
*/
@@ -46,3039 +52,7 @@ static inline uint32_t ref_length_in_bits(const crypto_test_reference_t *ref)
return ref->is_length_in_bits ? ref->length : 8 * ref->length;
}
-static crypto_test_reference_t null_reference[] = {
- {
- .length = 8,
- .plaintext = { 0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56 },
- .ciphertext = { 0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56 }
- },
- {
- .length = 16,
- .plaintext = { 0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87,
- 0x6d, 0x8e, 0xa2, 0x30, 0x94, 0xea, 0x53, 0x09 },
- .ciphertext = { 0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87,
- 0x6d, 0x8e, 0xa2, 0x30, 0x94, 0xea, 0x53, 0x09 }
- }
-};
-
-/* TDES-CBC reference vectors, according to
- * "http://csrc.nist.gov/groups/STM/cavp/documents/des/DESMMT.pdf"
- */
-static crypto_test_reference_t tdes_cbc_reference[] = {
- {
- .cipher_key_length = TDES_CBC_KEY_LEN,
- .cipher_key = { 0x62, 0x7f, 0x46, 0x0e, 0x08, 0x10, 0x4a, 0x10,
- 0x43, 0xcd, 0x26, 0x5d, 0x58, 0x40, 0xea, 0xf1,
- 0x31, 0x3e, 0xdf, 0x97, 0xdf, 0x2a, 0x8a, 0x8c},
- .cipher_iv_length = TDES_CBC_IV_LEN,
- .cipher_iv = { 0x8e, 0x29, 0xf7, 0x5e, 0xa7, 0x7e, 0x54, 0x75 },
- .length = 8,
- .plaintext = { 0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56 },
- .ciphertext = { 0xb2, 0x2b, 0x8d, 0x66, 0xde, 0x97, 0x06, 0x92 }
- },
- {
- .cipher_key_length = TDES_CBC_KEY_LEN,
- .cipher_key = { 0x37, 0xae, 0x5e, 0xbf, 0x46, 0xdf, 0xf2, 0xdc,
- 0x07, 0x54, 0xb9, 0x4f, 0x31, 0xcb, 0xb3, 0x85,
- 0x5e, 0x7f, 0xd3, 0x6d, 0xc8, 0x70, 0xbf, 0xae},
- .cipher_iv_length = TDES_CBC_IV_LEN,
- .cipher_iv = {0x3d, 0x1d, 0xe3, 0xcc, 0x13, 0x2e, 0x3b, 0x65 },
- .length = 16,
- .plaintext = { 0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87,
- 0x6d, 0x8e, 0xa2, 0x30, 0x94, 0xea, 0x53, 0x09 },
- .ciphertext = { 0x7b, 0x1f, 0x7c, 0x7e, 0x3b, 0x1c, 0x94, 0x8e,
- 0xbd, 0x04, 0xa7, 0x5f, 0xfb, 0xa7, 0xd2, 0xf5 }
- }
-};
-
-/*
- * TDES-ECB reference vectors, according to
- * CAVS 18.0 TECBMMT
- */
-static crypto_test_reference_t tdes_ecb_reference[] = {
- /* CAVS 18.0 TECBMMT2.rsp #0 */
- {
- .cipher_key_length = TDES_ECB_KEY_LEN,
- .cipher_key = { 0x15, 0x1f, 0x10, 0x38, 0x3d, 0x6d, 0x19, 0x9b,
- 0x4a, 0x76, 0x3b, 0xd5, 0x4a, 0x46, 0xa4, 0x45,
- 0x15, 0x1f, 0x10, 0x38, 0x3d, 0x6d, 0x19, 0x9b},
- .length = 8,
- .plaintext = { 0xd8, 0xda, 0x89, 0x29, 0x88, 0x78, 0xed, 0x7d },
- .ciphertext = { 0x89, 0x32, 0x1b, 0xa7, 0x5b, 0xa5, 0x45, 0xdb }
- },
- /* CAVS 18.0 TECBMMT2.rsp #2 */
- {
- .cipher_key_length = TDES_ECB_KEY_LEN,
- .cipher_key = { 0xcd, 0x3d, 0x9b, 0xf7, 0x2f, 0x8c, 0x8a, 0xb5,
- 0xfe, 0xe6, 0x73, 0x34, 0x31, 0x1c, 0xa4, 0x62,
- 0xcd, 0x3d, 0x9b, 0xf7, 0x2f, 0x8c, 0x8a, 0xb5},
- .length = 24,
- .plaintext = { 0x2f, 0x2a, 0x36, 0x1c, 0x8e, 0x14, 0x5d, 0xc0,
- 0xa7, 0x4a, 0x1b, 0xdb, 0x7c, 0xa9, 0x29, 0xc3,
- 0x38, 0x14, 0x4d, 0x89, 0x13, 0x5b, 0x50, 0xa7 },
- .ciphertext = { 0x7f, 0x1f, 0xd3, 0x2b, 0x36, 0x90, 0x05, 0x4b,
- 0xfa, 0x1b, 0x17, 0x35, 0x15, 0x79, 0x33, 0x80,
- 0x99, 0xff, 0xa8, 0x4f, 0xea, 0x16, 0x8c, 0x6b }
- }
-};
-
-static crypto_test_reference_t aes_cbc_reference[] = {
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
- 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06},
- .cipher_iv_length = AES_CBC_IV_LEN,
- .cipher_iv = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
- 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
- .length = 16,
- .plaintext = "Single block msg",
- .ciphertext = { 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8,
- 0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a }
- },
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
- 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a},
- .cipher_iv_length = AES_CBC_IV_LEN,
- .cipher_iv = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
- 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
- .length = 32,
- .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
- .ciphertext = { 0xd2, 0x96, 0xcd, 0x94, 0xc2, 0xcc, 0xcf, 0x8a,
- 0x3a, 0x86, 0x30, 0x28, 0xb5, 0xe1, 0xdc, 0x0a,
- 0x75, 0x86, 0x60, 0x2d, 0x25, 0x3c, 0xff, 0xf9,
- 0x1b, 0x82, 0x66, 0xbe, 0xa6, 0xd6, 0x1a, 0xb1 }
- },
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0x6c, 0x3e, 0xa0, 0x47, 0x76, 0x30, 0xce, 0x21,
- 0xa2, 0xce, 0x33, 0x4a, 0xa7, 0x46, 0xc2, 0xcd},
- .cipher_iv_length = AES_CBC_IV_LEN,
- .cipher_iv = { 0xc7, 0x82, 0xdc, 0x4c, 0x09, 0x8c, 0x66, 0xcb,
- 0xd9, 0xcd, 0x27, 0xd8, 0x25, 0x68, 0x2c, 0x81 },
- .length = 48,
- .plaintext = "This is a 48-byte message (exactly 3 AES blocks)",
- .ciphertext = { 0xd0, 0xa0, 0x2b, 0x38, 0x36, 0x45, 0x17, 0x53,
- 0xd4, 0x93, 0x66, 0x5d, 0x33, 0xf0, 0xe8, 0x86,
- 0x2d, 0xea, 0x54, 0xcd, 0xb2, 0x93, 0xab, 0xc7,
- 0x50, 0x69, 0x39, 0x27, 0x67, 0x72, 0xf8, 0xd5,
- 0x02, 0x1c, 0x19, 0x21, 0x6b, 0xad, 0x52, 0x5c,
- 0x85, 0x79, 0x69, 0x5d, 0x83, 0xba, 0x26, 0x84 }
- },
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0x56, 0xe4, 0x7a, 0x38, 0xc5, 0x59, 0x89, 0x74,
- 0xbc, 0x46, 0x90, 0x3d, 0xba, 0x29, 0x03, 0x49},
- .cipher_iv_length = AES_CBC_IV_LEN,
- .cipher_iv = { 0x8c, 0xe8, 0x2e, 0xef, 0xbe, 0xa0, 0xda, 0x3c,
- 0x44, 0x69, 0x9e, 0xd7, 0xdb, 0x51, 0xb7, 0xd9 },
- .length = 64,
- .plaintext = { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
- 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
- 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
- 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
- 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
- 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
- 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf },
- .ciphertext = { 0xc3, 0x0e, 0x32, 0xff, 0xed, 0xc0, 0x77, 0x4e,
- 0x6a, 0xff, 0x6a, 0xf0, 0x86, 0x9f, 0x71, 0xaa,
- 0x0f, 0x3a, 0xf0, 0x7a, 0x9a, 0x31, 0xa9, 0xc6,
- 0x84, 0xdb, 0x20, 0x7e, 0xb0, 0xef, 0x8e, 0x4e,
- 0x35, 0x90, 0x7a, 0xa6, 0x32, 0xc3, 0xff, 0xdf,
- 0x86, 0x8b, 0xb7, 0xb2, 0x9d, 0x3d, 0x46, 0xad,
- 0x83, 0xce, 0x9f, 0x9a, 0x10, 0x2e, 0xe9, 0x9d,
- 0x49, 0xa5, 0x3e, 0x87, 0xf4, 0xc3, 0xda, 0x55 }
- },
- {
- .cipher_key_length = AES192_KEY_LEN,
- .cipher_key = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
- 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
- 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c},
- .cipher_iv_length = AES_CBC_IV_LEN,
- .cipher_iv = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
- 0xde, 0xca, 0xf8, 0x88, 0x01, 0x23, 0x45, 0x67 },
- .length = 32,
- .plaintext = { 0x45, 0x00, 0x00, 0x28, 0xa4, 0xad, 0x40, 0x00,
- 0x40, 0x06, 0x78, 0x80, 0x0a, 0x01, 0x03, 0x8f,
- 0x0a, 0x01, 0x06, 0x12, 0x80, 0x23, 0x06, 0xb8,
- 0xcb, 0x71, 0x26, 0x02, 0xdd, 0x6b, 0xb0, 0x3e },
- .ciphertext = { 0x0d, 0xbe, 0x02, 0xda, 0x68, 0x9c, 0x8f, 0x30,
- 0xce, 0x7c, 0x91, 0x7d, 0x41, 0x08, 0xf6, 0xf1,
- 0x8e, 0x0d, 0x7f, 0x02, 0xb6, 0x80, 0x9a, 0x2d,
- 0x53, 0x1c, 0xc6, 0x98, 0x85, 0xc3, 0x00, 0xe6},
- },
- /* NIST Special Publication 800-38A */
- {
- .cipher_key_length = AES192_KEY_LEN,
- .cipher_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52,
- 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
- 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b},
- .cipher_iv_length = AES_CBC_IV_LEN,
- .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
- .length = 64,
- .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
- 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
- 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
- 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
- 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
- 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
- 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
- .ciphertext = { 0x4f, 0x02, 0x1d, 0xb2, 0x43, 0xbc, 0x63, 0x3d,
- 0x71, 0x78, 0x18, 0x3a, 0x9f, 0xa0, 0x71, 0xe8,
- 0xb4, 0xd9, 0xad, 0xa9, 0xad, 0x7d, 0xed, 0xf4,
- 0xe5, 0xe7, 0x38, 0x76, 0x3f, 0x69, 0x14, 0x5a,
- 0x57, 0x1b, 0x24, 0x20, 0x12, 0xfb, 0x7a, 0xe0,
- 0x7f, 0xa9, 0xba, 0xac, 0x3d, 0xf1, 0x02, 0xe0,
- 0x08, 0xb0, 0xe2, 0x79, 0x88, 0x59, 0x88, 0x81,
- 0xd9, 0x20, 0xa9, 0xe6, 0x4f, 0x56, 0x15, 0xcd }
- },
- {
- .cipher_key_length = AES256_KEY_LEN,
- .cipher_key = { 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23,
- 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab,
- 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23,
- 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab},
- .cipher_iv_length = AES_CBC_IV_LEN,
- .cipher_iv = { 0x11, 0x22, 0x33, 0x44, 0x01, 0x02, 0x03, 0x04,
- 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c },
- .length = 48,
- .plaintext = { 0x45, 0x00, 0x00, 0x30, 0x69, 0xa6, 0x40, 0x00,
- 0x80, 0x06, 0x26, 0x90, 0xc0, 0xa8, 0x01, 0x02,
- 0x93, 0x89, 0x15, 0x5e, 0x0a, 0x9e, 0x00, 0x8b,
- 0x2d, 0xc5, 0x7e, 0xe0, 0x00, 0x00, 0x00, 0x00,
- 0x70, 0x02, 0x40, 0x00, 0x20, 0xbf, 0x00, 0x00,
- 0x02, 0x04, 0x05, 0xb4, 0x01, 0x01, 0x04, 0x02 },
- .ciphertext = { 0x92, 0x1e, 0x2f, 0x37, 0x36, 0x3c, 0x45, 0xda,
- 0xc9, 0x58, 0xb7, 0x07, 0x06, 0x56, 0x54, 0xc5,
- 0x93, 0x46, 0x90, 0xb8, 0xcf, 0x0d, 0x4f, 0x79,
- 0xf1, 0x32, 0xc2, 0xf7, 0x23, 0xb8, 0x83, 0x09,
- 0xbc, 0x37, 0x1c, 0xeb, 0x95, 0x2c, 0x42, 0x7b,
- 0x39, 0x10, 0xa8, 0x76, 0xfa, 0xbe, 0x91, 0xe9},
- },
- /* NIST Special Publication 800-38A */
- {
- .cipher_key_length = AES256_KEY_LEN,
- .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
- 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
- 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
- 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4},
- .cipher_iv_length = AES_CBC_IV_LEN,
- .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
- .length = 64,
- .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
- 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
- 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
- 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
- 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
- 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
- 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
- .ciphertext = { 0xf5, 0x8c, 0x4c, 0x04, 0xd6, 0xe5, 0xf1, 0xba,
- 0x77, 0x9e, 0xab, 0xfb, 0x5f, 0x7b, 0xfb, 0xd6,
- 0x9c, 0xfc, 0x4e, 0x96, 0x7e, 0xdb, 0x80, 0x8d,
- 0x67, 0x9f, 0x77, 0x7b, 0xc6, 0x70, 0x2c, 0x7d,
- 0x39, 0xf2, 0x33, 0x69, 0xa9, 0xd9, 0xba, 0xcf,
- 0xa5, 0x30, 0xe2, 0x63, 0x04, 0x23, 0x14, 0x61,
- 0xb2, 0xeb, 0x05, 0xe2, 0xc3, 0x9b, 0xe9, 0xfc,
- 0xda, 0x6c, 0x19, 0x07, 0x8c, 0x6a, 0x9d, 0x1b }
- }
-};
-
-static crypto_test_reference_t aes_ctr_reference[] = {
- /* RFC3686 https://tools.ietf.org/html/rfc3686 */
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7,
- 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63},
- .cipher_iv_length = AES_CTR_IV_LEN,
- .cipher_iv = { 0x00, 0x6C, 0xB6, 0xDB, 0xC0, 0x54, 0x3B, 0x59,
- 0xDA, 0x48, 0xD9, 0x0B, 0x00, 0x00, 0x00, 0x01 },
- .length = 32,
- .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F },
- .ciphertext = { 0x51, 0x04, 0xA1, 0x06, 0x16, 0x8A, 0x72, 0xD9,
- 0x79, 0x0D, 0x41, 0xEE, 0x8E, 0xDA, 0xD3, 0x88,
- 0xEB, 0x2E, 0x1E, 0xFC, 0x46, 0xDA, 0x57, 0xC8,
- 0xFC, 0xE6, 0x30, 0xDF, 0x91, 0x41, 0xBE, 0x28}
- },
- /* NIST Special Publication 800-38A */
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
- 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c},
- .cipher_iv_length = AES_CTR_IV_LEN,
- .cipher_iv = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
- .length = 64,
- .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
- 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
- 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
- 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
- 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
- 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
- 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
- .ciphertext = { 0x87, 0x4d, 0x61, 0x91, 0xb6, 0x20, 0xe3, 0x26,
- 0x1b, 0xef, 0x68, 0x64, 0x99, 0x0d, 0xb6, 0xce,
- 0x98, 0x06, 0xf6, 0x6b, 0x79, 0x70, 0xfd, 0xff,
- 0x86, 0x17, 0x18, 0x7b, 0xb9, 0xff, 0xfd, 0xff,
- 0x5a, 0xe4, 0xdf, 0x3e, 0xdb, 0xd5, 0xd3, 0x5e,
- 0x5b, 0x4f, 0x09, 0x02, 0x0d, 0xb0, 0x3e, 0xab,
- 0x1e, 0x03, 0x1d, 0xda, 0x2f, 0xbe, 0x03, 0xd1,
- 0x79, 0x21, 0x70, 0xa0, 0xf3, 0x00, 0x9c, 0xee }
- },
- /* Generated by Crypto++ 5.6.1 (715 bytes data)*/
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
- 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c},
- .cipher_iv_length = AES_CTR_IV_LEN,
- .cipher_iv = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
- .length = 715,
- .plaintext = { 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f,
- 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17,
- 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac,
- 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e,
- 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4,
- 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52,
- 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b,
- 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37,
- 0x10, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40,
- 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93,
- 0x17, 0x2a, 0xae, 0x2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x57, 0x37, 0x39, 0xD5, 0xD5, 0x08, 0xCC, 0x76,
- 0xB3, 0x89, 0x35, 0x9D, 0x2A, 0x0E, 0xCB, 0x5B,
- 0x7E, 0xE5, 0xFC, 0xB4, 0xC3, 0x15, 0x1D, 0x5A,
- 0xF7, 0xC7, 0x18, 0x19, 0xEA, 0x3D, 0xD5, 0xF3,
- 0x6C, 0x7B, 0x27, 0xE5, 0x51, 0xFD, 0x23, 0x73,
- 0xD0, 0x7F, 0xFD, 0xC7, 0x6A, 0x13, 0xFC, 0x4B,
- 0x10, 0xA6, 0xF2, 0x9A, 0x83, 0xD6, 0xF4, 0x65,
- 0xAC, 0xB6, 0x96, 0x06, 0x71, 0xEA, 0xCF, 0x21,
- 0xA3, 0xE1, 0xCB, 0x44, 0x11, 0xC4, 0xDA, 0xA0,
- 0xC2, 0xA8, 0x7D, 0xAE, 0xD2, 0x8A, 0xEE, 0x60,
- 0xB7, 0xEC, 0x02, 0x58, 0xA9, 0xAF, 0x12, 0x5F,
- 0x2D, 0xDC, 0x80, 0xB9, 0x87, 0x7E, 0xFE, 0x0F,
- 0x37, 0x2D, 0x9B, 0x83, 0x2C, 0x78, 0x67, 0x70,
- 0xA8, 0x4E, 0xA1, 0xA0, 0x7C, 0xB6, 0xE1, 0xA9,
- 0x90, 0x7D, 0x65, 0x1B, 0xBD, 0x0E, 0xFD, 0xEF,
- 0x2A, 0xFF, 0xC3 }
- },
- /* RFC3686 https://tools.ietf.org/html/rfc3686 */
- {
- .cipher_key_length = AES192_KEY_LEN,
- .cipher_key = { 0x02, 0xBF, 0x39, 0x1E, 0xE8, 0xEC, 0xB1, 0x59,
- 0xB9, 0x59, 0x61, 0x7B, 0x09, 0x65, 0x27, 0x9B,
- 0xF5, 0x9B, 0x60, 0xA7, 0x86, 0xD3, 0xE0, 0xFE},
- .cipher_iv_length = AES_CTR_IV_LEN,
- .cipher_iv = { 0x00, 0x07, 0xBD, 0xFD, 0x5C, 0xBD, 0x60, 0x27,
- 0x8D, 0xCC, 0x09, 0x12, 0x00, 0x00, 0x00, 0x01 },
- .length = 36,
- .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
- 0x20, 0x21, 0x22, 0x23 },
- .ciphertext = { 0x96, 0x89, 0x3F, 0xC5, 0x5E, 0x5C, 0x72, 0x2F,
- 0x54, 0x0B, 0x7D, 0xD1, 0xDD, 0xF7, 0xE7, 0x58,
- 0xD2, 0x88, 0xBC, 0x95, 0xC6, 0x91, 0x65, 0x88,
- 0x45, 0x36, 0xC8, 0x11, 0x66, 0x2F, 0x21, 0x88,
- 0xAB, 0xEE, 0x09, 0x35 }
- },
- /* NIST Special Publication 800-38A */
- {
- .cipher_key_length = AES192_KEY_LEN,
- .cipher_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52,
- 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
- 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b},
- .cipher_iv_length = AES_CTR_IV_LEN,
- .cipher_iv = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
- .length = 64,
- .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
- 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
- 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
- 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
- 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
- 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
- 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
- .ciphertext = { 0x1a, 0xbc, 0x93, 0x24, 0x17, 0x52, 0x1c, 0xa2,
- 0x4f, 0x2b, 0x04, 0x59, 0xfe, 0x7e, 0x6e, 0x0b,
- 0x09, 0x03, 0x39, 0xec, 0x0a, 0xa6, 0xfa, 0xef,
- 0xd5, 0xcc, 0xc2, 0xc6, 0xf4, 0xce, 0x8e, 0x94,
- 0x1e, 0x36, 0xb2, 0x6b, 0xd1, 0xeb, 0xc6, 0x70,
- 0xd1, 0xbd, 0x1d, 0x66, 0x56, 0x20, 0xab, 0xf7,
- 0x4f, 0x78, 0xa7, 0xf6, 0xd2, 0x98, 0x09, 0x58,
- 0x5a, 0x97, 0xda, 0xec, 0x58, 0xc6, 0xb0, 0x50 }
- },
- /* RFC3686 https://tools.ietf.org/html/rfc3686 */
- {
- .cipher_key_length = AES256_KEY_LEN,
- .cipher_key = { 0xFF, 0x7A, 0x61, 0x7C, 0xE6, 0x91, 0x48, 0xE4,
- 0xF1, 0x72, 0x6E, 0x2F, 0x43, 0x58, 0x1D, 0xE2,
- 0xAA, 0x62, 0xD9, 0xF8, 0x05, 0x53, 0x2E, 0xDF,
- 0xF1, 0xEE, 0xD6, 0x87, 0xFB, 0x54, 0x15, 0x3D},
- .cipher_iv_length = AES_CTR_IV_LEN,
- .cipher_iv = { 0x00, 0x1C, 0xC5, 0xB7, 0x51, 0xA5, 0x1D, 0x70,
- 0xA1, 0xC1, 0x11, 0x48, 0x00, 0x00, 0x00, 0x01 },
- .length = 36,
- .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
- 0x20, 0x21, 0x22, 0x23 },
- .ciphertext = { 0xEB, 0x6C, 0x52, 0x82, 0x1D, 0x0B, 0xBB, 0xF7,
- 0xCE, 0x75, 0x94, 0x46, 0x2A, 0xCA, 0x4F, 0xAA,
- 0xB4, 0x07, 0xDF, 0x86, 0x65, 0x69, 0xFD, 0x07,
- 0xF4, 0x8C, 0xC0, 0xB5, 0x83, 0xD6, 0x07, 0x1F,
- 0x1E, 0xC0, 0xE6, 0xB8 },
- },
- /* NIST Special Publication 800-38A */
- {
- .cipher_key_length = AES256_KEY_LEN,
- .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
- 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
- 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
- 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4},
- .cipher_iv_length = AES_CTR_IV_LEN,
- .cipher_iv = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
- .length = 64,
- .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
- 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
- 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
- 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
- 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
- 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
- 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
- .ciphertext = { 0x60, 0x1e, 0xc3, 0x13, 0x77, 0x57, 0x89, 0xa5,
- 0xb7, 0xa7, 0xf5, 0x04, 0xbb, 0xf3, 0xd2, 0x28,
- 0xf4, 0x43, 0xe3, 0xca, 0x4d, 0x62, 0xb5, 0x9a,
- 0xca, 0x84, 0xe9, 0x90, 0xca, 0xca, 0xf5, 0xc5,
- 0x2b, 0x09, 0x30, 0xda, 0xa2, 0x3d, 0xe9, 0x4c,
- 0xe8, 0x70, 0x17, 0xba, 0x2d, 0x84, 0x98, 0x8d,
- 0xdf, 0xc9, 0xc5, 0x8d, 0xb6, 0x7a, 0xad, 0xa6,
- 0x13, 0xc2, 0xdd, 0x08, 0x45, 0x79, 0x41, 0xa6 }
- },
-};
-
-static crypto_test_reference_t aes_ecb_reference[] = {
- /* NIST Special Publication 800-38A */
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
- 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c},
- .length = 64,
- .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
- 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
- 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
- 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
- 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
- 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
- 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10},
- .ciphertext = { 0x3a, 0xd7, 0x7b, 0xb4, 0x0d, 0x7a, 0x36, 0x60,
- 0xa8, 0x9e, 0xca, 0xf3, 0x24, 0x66, 0xef, 0x97,
- 0xf5, 0xd3, 0xd5, 0x85, 0x03, 0xb9, 0x69, 0x9d,
- 0xe7, 0x85, 0x89, 0x5a, 0x96, 0xfd, 0xba, 0xaf,
- 0x43, 0xb1, 0xcd, 0x7f, 0x59, 0x8e, 0xce, 0x23,
- 0x88, 0x1b, 0x00, 0xe3, 0xed, 0x03, 0x06, 0x88,
- 0x7b, 0x0c, 0x78, 0x5e, 0x27, 0xe8, 0xad, 0x3f,
- 0x82, 0x23, 0x20, 0x71, 0x04, 0x72, 0x5d, 0xd4 }
- },
- /* Generated by Crypto++ 5.6.1 (528 bytes) */
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
- 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c},
- .length = 528,
- .plaintext = { 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f,
- 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17,
- 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac,
- 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e,
- 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4,
- 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52,
- 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b,
- 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37,
- 0x10, 0x00, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e,
- 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73,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, 0xA2, 0x1B, 0xCA, 0xA2, 0x39,
- 0x1A, 0x9C, 0x20, 0x16, 0xAC, 0x3B, 0xC7, 0xCD,
- 0xF1, 0x43, 0x8E, 0xB6, 0xDD, 0x26, 0x69, 0x66,
- 0x44, 0x58, 0x3E, 0x2B, 0x0A, 0x0C, 0x68, 0x62,
- 0x9D, 0x73, 0x6F, 0x67, 0x23, 0xDF, 0x66, 0x85,
- 0x9C, 0xF8, 0x0B, 0x4E, 0x5B, 0x5C, 0x5B, 0xF0,
- 0x3F, 0x33, 0x4D, 0x65, 0xC4, 0x8D, 0xB3, 0xB2,
- 0x66, 0x0E, 0x2C, 0xE3, 0x3B, 0x51, 0x0F, 0xD6,
- 0x0C, 0x91, 0x2B, 0x85, 0xD1, 0x6A, 0xEE, 0x7C,
- 0xDB, 0xFD, 0xF6, 0x28, 0x5B, 0x0A, 0x77, 0xBA,
- 0xE0, 0x7D, 0x98, 0x7F, 0x9C, 0xE1, 0x72, 0xA5,
- 0x48, 0xE6, 0xBF, 0x0A, 0x30, 0xCF, 0x09, 0x9A,
- 0xA8, 0x2B, 0xE0, 0xA2, 0x5E, 0x0E, 0x89, 0x19 }
- },
- /* NIST Special Publication 800-38A */
- {
- .cipher_key_length = AES192_KEY_LEN,
- .cipher_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52,
- 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
- 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b},
- .length = 64,
- .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
- 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
- 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
- 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
- 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
- 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
- 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
- .ciphertext = { 0xbd, 0x33, 0x4f, 0x1d, 0x6e, 0x45, 0xf2, 0x5f,
- 0xf7, 0x12, 0xa2, 0x14, 0x57, 0x1f, 0xa5, 0xcc,
- 0x97, 0x41, 0x04, 0x84, 0x6d, 0x0a, 0xd3, 0xad,
- 0x77, 0x34, 0xec, 0xb3, 0xec, 0xee, 0x4e, 0xef,
- 0xef, 0x7a, 0xfd, 0x22, 0x70, 0xe2, 0xe6, 0x0a,
- 0xdc, 0xe0, 0xba, 0x2f, 0xac, 0xe6, 0x44, 0x4e,
- 0x9a, 0x4b, 0x41, 0xba, 0x73, 0x8d, 0x6c, 0x72,
- 0xfb, 0x16, 0x69, 0x16, 0x03, 0xc1, 0x8e, 0x0e }
- },
- /* NIST Special Publication 800-38A */
- {
- .cipher_key_length = AES256_KEY_LEN,
- .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
- 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
- 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
- 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4},
- .length = 64,
- .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
- 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
- 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
- 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
- 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
- 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
- 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
- .ciphertext = { 0xf3, 0xee, 0xd1, 0xbd, 0xb5, 0xd2, 0xa0, 0x3c,
- 0x06, 0x4b, 0x5a, 0x7e, 0x3d, 0xb1, 0x81, 0xf8,
- 0x59, 0x1c, 0xcb, 0x10, 0xd4, 0x10, 0xed, 0x26,
- 0xdc, 0x5b, 0xa7, 0x4a, 0x31, 0x36, 0x28, 0x70,
- 0xb6, 0xed, 0x21, 0xb9, 0x9c, 0xa6, 0xf4, 0xf9,
- 0xf1, 0x53, 0xe7, 0xb1, 0xbe, 0xaf, 0xed, 0x1d,
- 0x23, 0x30, 0x4b, 0x7a, 0x39, 0xf9, 0xf3, 0xff,
- 0x06, 0x7d, 0x8d, 0x8f, 0x9e, 0x24, 0xec, 0xc7}
- }
-};
-
-static crypto_test_reference_t aes_cfb128_reference[] = {
- /* NIST Special Publication 800-38A */
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
- 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c},
- .cipher_iv_length = AES_CFB128_IV_LEN,
- .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
- .length = 64,
- .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
- 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
- 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
- 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
- 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
- 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
- 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10},
- .ciphertext = { 0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20,
- 0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a,
- 0xc8, 0xa6, 0x45, 0x37, 0xa0, 0xb3, 0xa9, 0x3f,
- 0xcd, 0xe3, 0xcd, 0xad, 0x9f, 0x1c, 0xe5, 0x8b,
- 0x26, 0x75, 0x1f, 0x67, 0xa3, 0xcb, 0xb1, 0x40,
- 0xb1, 0x80, 0x8c, 0xf1, 0x87, 0xa4, 0xf4, 0xdf,
- 0xc0, 0x4b, 0x05, 0x35, 0x7c, 0x5d, 0x1c, 0x0e,
- 0xea, 0xc4, 0xc6, 0x6f, 0x9f, 0xf7, 0xf2, 0xe6 }
- },
- /* NIST Special Publication 800-38A */
- {
- .cipher_key_length = AES192_KEY_LEN,
- .cipher_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52,
- 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
- 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b},
- .cipher_iv_length = AES_CFB128_IV_LEN,
- .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
- .length = 64,
- .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
- 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
- 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
- 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
- 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
- 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
- 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
- .ciphertext = { 0xcd, 0xc8, 0x0d, 0x6f, 0xdd, 0xf1, 0x8c, 0xab,
- 0x34, 0xc2, 0x59, 0x09, 0xc9, 0x9a, 0x41, 0x74,
- 0x67, 0xce, 0x7f, 0x7f, 0x81, 0x17, 0x36, 0x21,
- 0x96, 0x1a, 0x2b, 0x70, 0x17, 0x1d, 0x3d, 0x7a,
- 0x2e, 0x1e, 0x8a, 0x1d, 0xd5, 0x9b, 0x88, 0xb1,
- 0xc8, 0xe6, 0x0f, 0xed, 0x1e, 0xfa, 0xc4, 0xc9,
- 0xc0, 0x5f, 0x9f, 0x9c, 0xa9, 0x83, 0x4f, 0xa0,
- 0x42, 0xae, 0x8f, 0xba, 0x58, 0x4b, 0x09, 0xff }
- },
- /* NIST Special Publication 800-38A */
- {
- .cipher_key_length = AES256_KEY_LEN,
- .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
- 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
- 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
- 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4},
- .cipher_iv_length = AES_CFB128_IV_LEN,
- .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
- .length = 64,
- .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
- 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
- 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
- 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
- 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
- 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
- 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
- .ciphertext = { 0xdc, 0x7e, 0x84, 0xbf, 0xda, 0x79, 0x16, 0x4b,
- 0x7e, 0xcd, 0x84, 0x86, 0x98, 0x5d, 0x38, 0x60,
- 0x39, 0xff, 0xed, 0x14, 0x3b, 0x28, 0xb1, 0xc8,
- 0x32, 0x11, 0x3c, 0x63, 0x31, 0xe5, 0x40, 0x7b,
- 0xdf, 0x10, 0x13, 0x24, 0x15, 0xe5, 0x4b, 0x92,
- 0xa1, 0x3e, 0xd0, 0xa8, 0x26, 0x7a, 0xe2, 0xf9,
- 0x75, 0xa3, 0x85, 0x74, 0x1a, 0xb9, 0xce, 0xf8,
- 0x20, 0x31, 0x62, 0x3d, 0x55, 0xb1, 0xe4, 0x71 }
- }
-};
-
-static crypto_test_reference_t aes_xts_reference[] = {
- /* CAVS 11.0 XTSGen information, #1 */
- {
- .cipher_key_length = AES128_XTS_KEY_LEN,
- .cipher_key = { 0xa1, 0xb9, 0x0c, 0xba, 0x3f, 0x06, 0xac, 0x35,
- 0x3b, 0x2c, 0x34, 0x38, 0x76, 0x08, 0x17, 0x62,
- 0x09, 0x09, 0x23, 0x02, 0x6e, 0x91, 0x77, 0x18,
- 0x15, 0xf2, 0x9d, 0xab, 0x01, 0x93, 0x2f, 0x2f},
- .cipher_iv_length = AES_XTS_IV_LEN,
- .cipher_iv = { 0x4f, 0xae, 0xf7, 0x11, 0x7c, 0xda, 0x59, 0xc6,
- 0x6e, 0x4b, 0x92, 0x01, 0x3e, 0x76, 0x8a, 0xd5},
- .length = 16,
- .plaintext = { 0xeb, 0xab, 0xce, 0x95, 0xb1, 0x4d, 0x3c, 0x8d,
- 0x6f, 0xb3, 0x50, 0x39, 0x07, 0x90, 0x31, 0x1c},
- .ciphertext = { 0x77, 0x8a, 0xe8, 0xb4, 0x3c, 0xb9, 0x8d, 0x5a,
- 0x82, 0x50, 0x81, 0xd5, 0xbe, 0x47, 0x1c, 0x63}
- },
- /* CAVS 11.0 XTSGen information, #101 */
- {
- .cipher_key_length = AES128_XTS_KEY_LEN,
- .cipher_key = { 0xb7, 0xb9, 0x3f, 0x51, 0x6a, 0xef, 0x29, 0x5e,
- 0xff, 0x3a, 0x29, 0xd8, 0x37, 0xcf, 0x1f, 0x13,
- 0x53, 0x47, 0xe8, 0xa2, 0x1d, 0xae, 0x61, 0x6f,
- 0xf5, 0x06, 0x2b, 0x2e, 0x8d, 0x78, 0xce, 0x5e},
- .cipher_iv_length = AES_XTS_IV_LEN,
- .cipher_iv = { 0x87, 0x3e, 0xde, 0xa6, 0x53, 0xb6, 0x43, 0xbd,
- 0x8b, 0xcf, 0x51, 0x40, 0x31, 0x97, 0xed, 0x14},
- .length = 32,
- .plaintext = { 0x23, 0x6f, 0x8a, 0x5b, 0x58, 0xdd, 0x55, 0xf6,
- 0x19, 0x4e, 0xd7, 0x0c, 0x4a, 0xc1, 0xa1, 0x7f,
- 0x1f, 0xe6, 0x0e, 0xc9, 0xa6, 0xc4, 0x54, 0xd0,
- 0x87, 0xcc, 0xb7, 0x7d, 0x6b, 0x63, 0x8c, 0x47},
- .ciphertext = { 0x22, 0xe6, 0xa3, 0xc6, 0x37, 0x9d, 0xcf, 0x75,
- 0x99, 0xb0, 0x52, 0xb5, 0xa7, 0x49, 0xc7, 0xf7,
- 0x8a, 0xd8, 0xa1, 0x1b, 0x9f, 0x1a, 0xa9, 0x43,
- 0x0c, 0xf3, 0xae, 0xf4, 0x45, 0x68, 0x2e, 0x19}
- },
- /* CAVS 11.0 XTSGen information, #227 TODO (Length 130 bits)*/
- /* {
- .cipher_key_length = AES128_XTS_KEY_LEN,
- .cipher_key = { 0xec, 0x14, 0xc0, 0xa3, 0xb7, 0x72, 0x58, 0x5c,
- 0x15, 0xd4, 0xeb, 0x94, 0xe6, 0x9e, 0x2c, 0x55,
- 0x80, 0xcf, 0x3a, 0x63, 0xc1, 0x7c, 0xe9, 0xda,
- 0xd8, 0x2b, 0xb4, 0x54, 0xe3, 0x87, 0x90, 0x45},
- .cipher_iv_length = AES_XTS_IV_LEN,
- .cipher_iv = { 0x4a, 0x02, 0x87, 0xc2, 0x6e, 0xd2, 0x41, 0x26,
- 0x5b, 0x3a, 0x42, 0xcd, 0xd1, 0x9c, 0xea, 0xe2},
- .length = 17,
- .plaintext = { 0x50, 0x82, 0x64, 0x75, 0x82, 0xc6, 0xe5, 0xa7,
- 0x88, 0x73, 0x6f, 0xc5, 0x90, 0x5e, 0xa5, 0x65,
- 0xc0 },
- .ciphertext = { 0x04, 0x3a, 0xb9, 0xc0, 0x3d, 0x5b, 0x44, 0x13,
- 0x1d, 0x3e, 0x6e, 0xb2, 0x57, 0x61, 0x89, 0xde,
- 0x80 },
- }, */
- /* CAVS 11.0 XTSGen information, #1 */
- {
- .cipher_key_length = AES256_XTS_KEY_LEN,
- .cipher_key = { 0x1e, 0xa6, 0x61, 0xc5, 0x8d, 0x94, 0x3a, 0x0e,
- 0x48, 0x01, 0xe4, 0x2f, 0x4b, 0x09, 0x47, 0x14,
- 0x9e, 0x7f, 0x9f, 0x8e, 0x3e, 0x68, 0xd0, 0xc7,
- 0x50, 0x52, 0x10, 0xbd, 0x31, 0x1a, 0x0e, 0x7c,
- 0xd6, 0xe1, 0x3f, 0xfd, 0xf2, 0x41, 0x8d, 0x8d,
- 0x19, 0x11, 0xc0, 0x04, 0xcd, 0xa5, 0x8d, 0xa3,
- 0xd6, 0x19, 0xb7, 0xe2, 0xb9, 0x14, 0x1e, 0x58,
- 0x31, 0x8e, 0xea, 0x39, 0x2c, 0xf4, 0x1b, 0x08},
- .cipher_iv_length = AES_XTS_IV_LEN,
- .cipher_iv = { 0xad, 0xf8, 0xd9, 0x26, 0x27, 0x46, 0x4a, 0xd2,
- 0xf0, 0x42, 0x8e, 0x84, 0xa9, 0xf8, 0x75, 0x64},
- .length = 32,
- .plaintext = { 0x2e, 0xed, 0xea, 0x52, 0xcd, 0x82, 0x15, 0xe1,
- 0xac, 0xc6, 0x47, 0xe8, 0x10, 0xbb, 0xc3, 0x64,
- 0x2e, 0x87, 0x28, 0x7f, 0x8d, 0x2e, 0x57, 0xe3,
- 0x6c, 0x0a, 0x24, 0xfb, 0xc1, 0x2a, 0x20, 0x2e},
- .ciphertext = { 0xcb, 0xaa, 0xd0, 0xe2, 0xf6, 0xce, 0xa3, 0xf5,
- 0x0b, 0x37, 0xf9, 0x34, 0xd4, 0x6a, 0x9b, 0x13,
- 0x0b, 0x9d, 0x54, 0xf0, 0x7e, 0x34, 0xf3, 0x6a,
- 0xf7, 0x93, 0xe8, 0x6f, 0x73, 0xc6, 0xd7, 0xdb},
- },
- /* CAVS 11.0 XTSGen information, #110 */
- {
- .cipher_key_length = AES256_XTS_KEY_LEN,
- .cipher_key = { 0x6b, 0x19, 0x84, 0xc2, 0x4e, 0x7e, 0xb6, 0x62,
- 0x8e, 0x3a, 0x11, 0xc9, 0xcc, 0xd2, 0x59, 0x40,
- 0x33, 0xa3, 0xa0, 0xd9, 0x01, 0x6e, 0xae, 0x65,
- 0xc2, 0xf2, 0x4e, 0x09, 0xb9, 0xa6, 0x6e, 0x9f,
- 0xe9, 0xd1, 0x63, 0xa5, 0x06, 0xdf, 0xbc, 0xcf,
- 0x2d, 0x93, 0xe8, 0x99, 0x1e, 0x2f, 0xc5, 0x60,
- 0xe1, 0x04, 0x35, 0xb8, 0x90, 0xb5, 0x88, 0x9a,
- 0x50, 0x03, 0xe4, 0xbf, 0x81, 0x7d, 0xc3, 0xe0},
- .cipher_iv_length = AES_XTS_IV_LEN,
- .cipher_iv = { 0x6b, 0xb0, 0xd3, 0xae, 0x4f, 0xa8, 0x6e, 0x43,
- 0x16, 0x19, 0xe4, 0x07, 0xd5, 0x9a, 0xd4, 0xf4},
- .length = 48,
- .plaintext = { 0x6a, 0x74, 0x1a, 0x94, 0x5b, 0xfb, 0xf0, 0xc6,
- 0x7a, 0xfd, 0x43, 0xba, 0x1f, 0x84, 0x18, 0x16,
- 0xc0, 0x99, 0x51, 0x58, 0x05, 0xd0, 0xfc, 0x1f,
- 0x7d, 0xbf, 0x6d, 0xe9, 0x00, 0xe0, 0xaa, 0x7a,
- 0x21, 0x9c, 0x88, 0x56, 0x32, 0x71, 0xb0, 0x09,
- 0xd1, 0xac, 0x90, 0xeb, 0x7d, 0xc9, 0x97, 0x35},
- .ciphertext = { 0xe4, 0x7b, 0xce, 0x29, 0x2b, 0xaa, 0x63, 0xbe,
- 0xf3, 0x16, 0xf6, 0x80, 0xa5, 0xf4, 0x80, 0xa7,
- 0xb8, 0x83, 0xdf, 0xab, 0x6e, 0xd5, 0xa5, 0x7f,
- 0x7e, 0x29, 0xec, 0xb8, 0x9e, 0x35, 0x4a, 0x31,
- 0xc9, 0xb1, 0x74, 0xc4, 0xab, 0xad, 0x6c, 0xba,
- 0xba, 0xba, 0x19, 0x14, 0x0c, 0x46, 0x20, 0xa3},
- },
- /* CAVS 11.0 XTSGen information, #211 TODO: length 140 bits */
- /* {
- .cipher_key_length = AES256_XTS_KEY_LEN,
- .cipher_key = { 0x62, 0xc2, 0xe4, 0xf8, 0x52, 0xa9, 0x3e, 0xea,
- 0x4a, 0x2f, 0x61, 0xe8, 0x67, 0x68, 0x14, 0xf4,
- 0xa8, 0x0d, 0xc4, 0x7e, 0xe1, 0x81, 0x32, 0xc8,
- 0x38, 0xbf, 0x89, 0xa6, 0x18, 0xfd, 0xb8, 0xe2,
- 0x91, 0x3e, 0x2e, 0x5c, 0x32, 0x1b, 0x19, 0xea,
- 0x04, 0xbb, 0xa6, 0x34, 0x7d, 0x22, 0x6f, 0x41,
- 0xdb, 0xee, 0x88, 0x0d, 0x61, 0x67, 0xb8, 0xe1,
- 0xe9, 0x17, 0xfa, 0xf0, 0x46, 0xf0, 0x87, 0x5e},
- .cipher_iv_length = AES_XTS_IV_LEN,
- .cipher_iv = { 0x53, 0x7e, 0xe3, 0xdc, 0x13, 0xce, 0x27, 0xa8,
- 0xd3, 0x0e, 0x6e, 0x42, 0xb5, 0xb9, 0x96, 0xae},
- .length = 18,
- .plaintext = { 0x00, 0xc9, 0xeb, 0x87, 0x78, 0xe0, 0x3d, 0xdd,
- 0x5f, 0x3d, 0xe8, 0xc1, 0x8b, 0x34, 0x8f, 0xac,
- 0x9c, 0x30},
- .ciphertext = { 0x9d, 0x4a, 0x08, 0xac, 0x0f, 0xb4, 0x4e, 0x90,
- 0xd0, 0x5f, 0x62, 0x86, 0x19, 0x3f, 0x3a, 0xab,
- 0xc2, 0x90},
- } */
-};
-
-/* AES-GCM test vectors extracted from
- * https://tools.ietf.org/html/draft-mcgrew-gcm-test-01#section-2
- */
-static crypto_test_reference_t aes_gcm_reference[] = {
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda,
- 0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34},
- .cipher_iv_length = AES_GCM_IV_LEN,
- .cipher_iv = { 0x2e, 0x44, 0x3b, 0x68, 0x49, 0x56, 0xed, 0x7e,
- 0x3b, 0x24, 0x4c, 0xfe },
- .length = 72,
- .plaintext = { 0x45, 0x00, 0x00, 0x48, 0x69, 0x9a, 0x00, 0x00,
- 0x80, 0x11, 0x4d, 0xb7, 0xc0, 0xa8, 0x01, 0x02,
- 0xc0, 0xa8, 0x01, 0x01, 0x0a, 0x9b, 0xf1, 0x56,
- 0x38, 0xd3, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x04, 0x5f, 0x73, 0x69,
- 0x70, 0x04, 0x5f, 0x75, 0x64, 0x70, 0x03, 0x73,
- 0x69, 0x70, 0x09, 0x63, 0x79, 0x62, 0x65, 0x72,
- 0x63, 0x69, 0x74, 0x79, 0x02, 0x64, 0x6b, 0x00,
- 0x00, 0x21, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01 },
- .ciphertext = { 0xfe, 0xcf, 0x53, 0x7e, 0x72, 0x9d, 0x5b, 0x07,
- 0xdc, 0x30, 0xdf, 0x52, 0x8d, 0xd2, 0x2b, 0x76,
- 0x8d, 0x1b, 0x98, 0x73, 0x66, 0x96, 0xa6, 0xfd,
- 0x34, 0x85, 0x09, 0xfa, 0x13, 0xce, 0xac, 0x34,
- 0xcf, 0xa2, 0x43, 0x6f, 0x14, 0xa3, 0xf3, 0xcf,
- 0x65, 0x92, 0x5b, 0xf1, 0xf4, 0xa1, 0x3c, 0x5d,
- 0x15, 0xb2, 0x1e, 0x18, 0x84, 0xf5, 0xff, 0x62,
- 0x47, 0xae, 0xab, 0xb7, 0x86, 0xb9, 0x3b, 0xce,
- 0x61, 0xbc, 0x17, 0xd7, 0x68, 0xfd, 0x97, 0x32},
- .aad_length = 12,
- .aad = { 0x00, 0x00, 0x43, 0x21, 0x87, 0x65, 0x43, 0x21,
- 0x00, 0x00, 0x00, 0x00 },
- .digest_length = AES_GCM_DIGEST_LEN,
- .digest = { 0x45, 0x90, 0x18, 0x14, 0x8f, 0x6c, 0xbe, 0x72,
- 0x2f, 0xd0, 0x47, 0x96, 0x56, 0x2d, 0xfd, 0xb4 }
- },
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
- 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08},
- .cipher_iv_length = AES_GCM_IV_LEN,
- .cipher_iv = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
- 0xde, 0xca, 0xf8, 0x88 },
- .length = 64,
- .plaintext = { 0x45, 0x00, 0x00, 0x3e, 0x69, 0x8f, 0x00, 0x00,
- 0x80, 0x11, 0x4d, 0xcc, 0xc0, 0xa8, 0x01, 0x02,
- 0xc0, 0xa8, 0x01, 0x01, 0x0a, 0x98, 0x00, 0x35,
- 0x00, 0x2a, 0x23, 0x43, 0xb2, 0xd0, 0x01, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x73, 0x69, 0x70, 0x09, 0x63, 0x79, 0x62,
- 0x65, 0x72, 0x63, 0x69, 0x74, 0x79, 0x02, 0x64,
- 0x6b, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01 },
- .ciphertext = { 0xde, 0xb2, 0x2c, 0xd9, 0xb0, 0x7c, 0x72, 0xc1,
- 0x6e, 0x3a, 0x65, 0xbe, 0xeb, 0x8d, 0xf3, 0x04,
- 0xa5, 0xa5, 0x89, 0x7d, 0x33, 0xae, 0x53, 0x0f,
- 0x1b, 0xa7, 0x6d, 0x5d, 0x11, 0x4d, 0x2a, 0x5c,
- 0x3d, 0xe8, 0x18, 0x27, 0xc1, 0x0e, 0x9a, 0x4f,
- 0x51, 0x33, 0x0d, 0x0e, 0xec, 0x41, 0x66, 0x42,
- 0xcf, 0xbb, 0x85, 0xa5, 0xb4, 0x7e, 0x48, 0xa4,
- 0xec, 0x3b, 0x9b, 0xa9, 0x5d, 0x91, 0x8b, 0xd1},
- .aad_length = 8,
- .aad = { 0x00, 0x00, 0xa5, 0xf8, 0x00, 0x00, 0x00, 0x0a },
- .digest_length = AES_GCM_DIGEST_LEN,
- .digest = { 0x83, 0xb7, 0x0d, 0x3a, 0xa8, 0xbc, 0x6e, 0xe4,
- 0xc3, 0x09, 0xe9, 0xd8, 0x5a, 0x41, 0xad, 0x4a }
- },
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
- .cipher_iv_length = AES_GCM_IV_LEN,
- .cipher_iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00 },
- .length = 64,
- .plaintext = { 0x45, 0x00, 0x00, 0x3c, 0x99, 0xc5, 0x00, 0x00,
- 0x80, 0x01, 0xcb, 0x7a, 0x40, 0x67, 0x93, 0x18,
- 0x01, 0x01, 0x01, 0x01, 0x08, 0x00, 0x07, 0x5c,
- 0x02, 0x00, 0x44, 0x00, 0x61, 0x62, 0x63, 0x64,
- 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
- 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
- 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65,
- 0x66, 0x67, 0x68, 0x69, 0x01, 0x02, 0x02, 0x01 },
- .ciphertext = { 0x46, 0x88, 0xda, 0xf2, 0xf9, 0x73, 0xa3, 0x92,
- 0x73, 0x29, 0x09, 0xc3, 0x31, 0xd5, 0x6d, 0x60,
- 0xf6, 0x94, 0xab, 0xaa, 0x41, 0x4b, 0x5e, 0x7f,
- 0xf5, 0xfd, 0xcd, 0xff, 0xf5, 0xe9, 0xa2, 0x84,
- 0x45, 0x64, 0x76, 0x49, 0x27, 0x19, 0xff, 0xb6,
- 0x4d, 0xe7, 0xd9, 0xdc, 0xa1, 0xe1, 0xd8, 0x94,
- 0xbc, 0x3b, 0xd5, 0x78, 0x73, 0xed, 0x4d, 0x18,
- 0x1d, 0x19, 0xd4, 0xd5, 0xc8, 0xc1, 0x8a, 0xf3},
- .aad_length = 8,
- .aad = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
- .digest_length = AES_GCM_DIGEST_LEN,
- .digest = { 0xf8, 0x21, 0xd4, 0x96, 0xee, 0xb0, 0x96, 0xe9,
- 0x8a, 0xd2, 0xb6, 0x9e, 0x47, 0x99, 0xc7, 0x1d }
- },
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0x3d, 0xe0, 0x98, 0x74, 0xb3, 0x88, 0xe6, 0x49,
- 0x19, 0x88, 0xd0, 0xc3, 0x60, 0x7e, 0xae, 0x1f},
- .cipher_iv_length = AES_GCM_IV_LEN,
- .cipher_iv = { 0x57, 0x69, 0x0e, 0x43, 0x4e, 0x28, 0x00, 0x00,
- 0xa2, 0xfc, 0xa1, 0xa3 },
- .length = 28,
- .plaintext = { 0x45, 0x00, 0x00, 0x1c, 0x42, 0xa2, 0x00, 0x00,
- 0x80, 0x01, 0x44, 0x1f, 0x40, 0x67, 0x93, 0xb6,
- 0xe0, 0x00, 0x00, 0x02, 0x0a, 0x00, 0xf5, 0xff,
- 0x01, 0x02, 0x02, 0x01 },
- .ciphertext = { 0xfb, 0xa2, 0xca, 0x84, 0x5e, 0x5d, 0xf9, 0xf0,
- 0xf2, 0x2c, 0x3e, 0x6e, 0x86, 0xdd, 0x83, 0x1e,
- 0x1f, 0xc6, 0x57, 0x92, 0xcd, 0x1a, 0xf9, 0x13,
- 0x0e, 0x13, 0x79, 0xed },
- .aad_length = 12,
- .aad = { 0x42, 0xf6, 0x7e, 0x3f, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10 },
- .digest_length = AES_GCM_DIGEST_LEN,
- .digest = { 0x36, 0x9f, 0x07, 0x1f, 0x35, 0xe0, 0x34, 0xbe,
- 0x95, 0xf1, 0x12, 0xe4, 0xe7, 0xd0, 0x5d, 0x35 }
- },
- {
- .cipher_key_length = AES192_KEY_LEN,
- .cipher_key = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
- 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
- 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c},
- .cipher_iv_length = AES_GCM_IV_LEN,
- .cipher_iv = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
- 0xde, 0xca, 0xf8, 0x88 },
- .length = 40,
- .plaintext = { 0x45, 0x00, 0x00, 0x28, 0xa4, 0xad, 0x40, 0x00,
- 0x40, 0x06, 0x78, 0x80, 0x0a, 0x01, 0x03, 0x8f,
- 0x0a, 0x01, 0x06, 0x12, 0x80, 0x23, 0x06, 0xb8,
- 0xcb, 0x71, 0x26, 0x02, 0xdd, 0x6b, 0xb0, 0x3e,
- 0x50, 0x10, 0x16, 0xd0, 0x75, 0x68, 0x00, 0x01 },
- .ciphertext = { 0xa5, 0xb1, 0xf8, 0x06, 0x60, 0x29, 0xae, 0xa4,
- 0x0e, 0x59, 0x8b, 0x81, 0x22, 0xde, 0x02, 0x42,
- 0x09, 0x38, 0xb3, 0xab, 0x33, 0xf8, 0x28, 0xe6,
- 0x87, 0xb8, 0x85, 0x8b, 0x5b, 0xfb, 0xdb, 0xd0,
- 0x31, 0x5b, 0x27, 0x45, 0x21, 0x44, 0xcc, 0x77},
- .aad_length = 8,
- .aad = { 0x00, 0x00, 0xa5, 0xf8, 0x00, 0x00, 0x00, 0x0a },
- .digest_length = AES_GCM_DIGEST_LEN,
- .digest = { 0x95, 0x45, 0x7b, 0x96, 0x52, 0x03, 0x7f, 0x53,
- 0x18, 0x02, 0x7b, 0x5b, 0x4c, 0xd7, 0xa6, 0x36 }
- },
- {
- .cipher_key_length = AES256_KEY_LEN,
- .cipher_key = { 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23,
- 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab,
- 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23,
- 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab},
- .cipher_iv_length = AES_GCM_IV_LEN,
- .cipher_iv = { 0x11, 0x22, 0x33, 0x44, 0x01, 0x02, 0x03, 0x04,
- 0x05, 0x06, 0x07, 0x08 },
- .length = 52,
- .plaintext = { 0x45, 0x00, 0x00, 0x30, 0x69, 0xa6, 0x40, 0x00,
- 0x80, 0x06, 0x26, 0x90, 0xc0, 0xa8, 0x01, 0x02,
- 0x93, 0x89, 0x15, 0x5e, 0x0a, 0x9e, 0x00, 0x8b,
- 0x2d, 0xc5, 0x7e, 0xe0, 0x00, 0x00, 0x00, 0x00,
- 0x70, 0x02, 0x40, 0x00, 0x20, 0xbf, 0x00, 0x00,
- 0x02, 0x04, 0x05, 0xb4, 0x01, 0x01, 0x04, 0x02,
- 0x01, 0x02, 0x02, 0x01 },
- .ciphertext = { 0xff, 0x42, 0x5c, 0x9b, 0x72, 0x45, 0x99, 0xdf,
- 0x7a, 0x3b, 0xcd, 0x51, 0x01, 0x94, 0xe0, 0x0d,
- 0x6a, 0x78, 0x10, 0x7f, 0x1b, 0x0b, 0x1c, 0xbf,
- 0x06, 0xef, 0xae, 0x9d, 0x65, 0xa5, 0xd7, 0x63,
- 0x74, 0x8a, 0x63, 0x79, 0x85, 0x77, 0x1d, 0x34,
- 0x7f, 0x05, 0x45, 0x65, 0x9f, 0x14, 0xe9, 0x9d,
- 0xef, 0x84, 0x2d, 0x8e },
- .aad_length = 8,
- .aad = { 0x4a, 0x2c, 0xbf, 0xe3, 0x00, 0x00, 0x00, 0x02 },
- .digest_length = AES_GCM_DIGEST_LEN,
- .digest = { 0xb3, 0x35, 0xf4, 0xee, 0xcf, 0xdb, 0xf8, 0x31,
- 0x82, 0x4b, 0x4c, 0x49, 0x15, 0x95, 0x6c, 0x96 }
- }
-};
-
-static crypto_test_reference_t aes_ccm_reference[] = {
- /*
- * AES-CCM reference from RFC 3610
- */
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf},
- .cipher_iv_length = 13,
- .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0,
- 0xa1, 0xa2, 0xa3, 0xa4, 0xa5 },
- .aad_length = 8,
- .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
- .length = 23,
- .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e },
- .ciphertext = { 0x58, 0x8c, 0x97, 0x9a, 0x61, 0xc6, 0x63, 0xd2,
- 0xf0, 0x66, 0xd0, 0xc2, 0xc0, 0xf9, 0x89, 0x80,
- 0x6d, 0x5f, 0x6b, 0x61, 0xda, 0xc3, 0x84 },
- .digest_length = 8,
- .digest = { 0x17, 0xe8, 0xd1, 0x2c, 0xfd, 0xf9, 0x26, 0xe0 }
- },
- /* The rest of test vectors are generated manually, no "interesting"
- * vectors for use cases in RFC 3610 or SP 800-38C. */
- {
- .cipher_key_length = AES192_KEY_LEN,
- .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
- 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7},
- .cipher_iv_length = 13,
- .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0,
- 0xa1, 0xa2, 0xa3, 0xa4, 0xa5 },
- .aad_length = 8,
- .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
- .length = 23,
- .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e },
- .ciphertext = { 0x57, 0x9f, 0xb8, 0x6e, 0xdd, 0xb4, 0xa6, 0x4a,
- 0xae, 0x5f, 0xe9, 0x6d, 0xbd, 0x75, 0x44, 0x05,
- 0x33, 0xa9, 0xfc, 0x3a, 0x84, 0x57, 0x36 },
- .digest_length = 8,
- .digest = { 0x67, 0xae, 0xc8, 0x0a, 0xc5, 0x88, 0xab, 0x16 }
- },
- {
- .cipher_key_length = AES256_KEY_LEN,
- .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
- 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
- 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf},
- .cipher_iv_length = 13,
- .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0,
- 0xa1, 0xa2, 0xa3, 0xa4, 0xa5 },
- .aad_length = 8,
- .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
- .length = 23,
- .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e },
- .ciphertext = { 0x59, 0x61, 0x55, 0x10, 0xa7, 0xc4, 0x3b, 0xfb,
- 0x12, 0x3d, 0x63, 0x6b, 0x46, 0x13, 0xc0, 0x3c,
- 0x6c, 0xe2, 0x69, 0x07, 0x10, 0x2a, 0x3f },
- .digest_length = 8,
- .digest = { 0xb5, 0x57, 0x2a, 0x17, 0x2d, 0x49, 0x16, 0xd5 }
- },
- {
- .cipher_key_length = AES128_KEY_LEN,
- .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf},
- .cipher_iv_length = 11,
- .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0,
- 0xa1, 0xa2, 0xa3 },
- .aad_length = 8,
- .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
- .length = 23,
- .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e },
- .ciphertext = { 0xaa, 0x2d, 0x3e, 0xcb, 0xa6, 0x68, 0x63, 0x75,
- 0x8f, 0x03, 0x01, 0x51, 0x16, 0xde, 0x30, 0xed,
- 0x8a, 0xb5, 0x42, 0xdc, 0xfa, 0x72, 0xd0 },
- .digest_length = 8,
- .digest = { 0x63, 0xe7, 0x01, 0x5c, 0x69, 0xaf, 0xb4, 0x0c }
- },
- {
- .cipher_key_length = AES192_KEY_LEN,
- .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
- 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7},
- .cipher_iv_length = 11,
- .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0,
- 0xa1, 0xa2, 0xa3 },
- .aad_length = 8,
- .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
- .length = 23,
- .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e },
- .ciphertext = { 0xee, 0x99, 0x99, 0x1e, 0xc5, 0x8f, 0xd7, 0x7e,
- 0x56, 0x71, 0x16, 0x39, 0x8e, 0xc4, 0x4f, 0xcc,
- 0x14, 0x45, 0x57, 0x3e, 0x38, 0x76, 0x51 },
- .digest_length = 8,
- .digest = { 0x31, 0x29, 0x47, 0xa4, 0x6d, 0x76, 0x34, 0xb4 }
- },
- {
- .cipher_key_length = AES256_KEY_LEN,
- .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
- 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
- 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf},
- .cipher_iv_length = 11,
- .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0,
- 0xa1, 0xa2, 0xa3 },
- .aad_length = 8,
- .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
- .length = 23,
- .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e },
- .ciphertext = { 0xfa, 0x07, 0x47, 0x5c, 0xe8, 0xc9, 0x37, 0x88,
- 0x54, 0x64, 0xb8, 0xc3, 0x85, 0xbb, 0x76, 0x0b,
- 0xf2, 0xc2, 0x4c, 0x4e, 0x31, 0x16, 0x77 },
- .digest_length = 8,
- .digest = { 0x88, 0x56, 0x7e, 0x19, 0x84, 0x13, 0x29, 0xc4 }
- },
-};
-
-static crypto_test_reference_t aes_gmac_reference[] = {
- {
- .auth_key_length = AES128_KEY_LEN,
- .auth_key = { 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda,
- 0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34},
- .auth_iv_length = AES_GCM_IV_LEN,
- .auth_iv = { 0x22, 0x43, 0x3c, 0x64, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00 },
- .length = 68,
- .plaintext = { 0x00, 0x00, 0x43, 0x21, 0x00, 0x00, 0x00, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x45, 0x00, 0x00, 0x30, 0xda, 0x3a, 0x00, 0x00,
- 0x80, 0x01, 0xdf, 0x3b, 0xc0, 0xa8, 0x00, 0x05,
- 0xc0, 0xa8, 0x00, 0x01, 0x08, 0x00, 0xc6, 0xcd,
- 0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64,
- 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
- 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
- 0x01, 0x02, 0x02, 0x01 },
- .ciphertext = { 0x00, 0x00, 0x43, 0x21, 0x00, 0x00, 0x00, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x45, 0x00, 0x00, 0x30, 0xda, 0x3a, 0x00, 0x00,
- 0x80, 0x01, 0xdf, 0x3b, 0xc0, 0xa8, 0x00, 0x05,
- 0xc0, 0xa8, 0x00, 0x01, 0x08, 0x00, 0xc6, 0xcd,
- 0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64,
- 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
- 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
- 0x01, 0x02, 0x02, 0x01 },
- .digest_length = AES_GCM_DIGEST_LEN,
- .digest = { 0xf2, 0xa9, 0xa8, 0x36, 0xe1, 0x55, 0x10, 0x6a,
- 0xa8, 0xdc, 0xd6, 0x18, 0xe4, 0x09, 0x9a, 0xaa }
- },
- /* AES192-GMAC from DPDK 17.02 */
- {
- .auth_key_length = AES192_KEY_LEN,
- .auth_key = { 0xaa, 0x74, 0x0a, 0xbf, 0xad, 0xcd, 0xa7, 0x79,
- 0x22, 0x0d, 0x3b, 0x40, 0x6c, 0x5d, 0x7e, 0xc0,
- 0x9a, 0x77, 0xfe, 0x9d, 0x94, 0x10, 0x45, 0x39},
- .auth_iv_length = AES_GCM_IV_LEN,
- .auth_iv = { 0xab, 0x22, 0x65, 0xb4, 0xc1, 0x68, 0x95, 0x55,
- 0x61, 0xf0, 0x43, 0x15 },
- .length = 80,
- .plaintext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10},
- .ciphertext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10},
- .digest_length = AES_GCM_DIGEST_LEN,
- .digest = { 0xCF, 0x82, 0x80, 0x64, 0x02, 0x46, 0xF4, 0xFB,
- 0x33, 0xAE, 0x1D, 0x90, 0xEA, 0x48, 0x83, 0xDB },
- },
- /* AES256-GMAC from DPDK 17.02 */
- {
- .auth_key_length = AES256_KEY_LEN,
- .auth_key = { 0xb5, 0x48, 0xe4, 0x93, 0x4f, 0x5c, 0x64, 0xd3,
- 0xc0, 0xf0, 0xb7, 0x8f, 0x7b, 0x4d, 0x88, 0x24,
- 0xaa, 0xc4, 0x6b, 0x3c, 0x8d, 0x2c, 0xc3, 0x5e,
- 0xe4, 0xbf, 0xb2, 0x54, 0xe4, 0xfc, 0xba, 0xf7},
- .auth_iv_length = AES_GCM_IV_LEN,
- .auth_iv = { 0x2e, 0xed, 0xe1, 0xdc, 0x64, 0x47, 0xc7, 0xaf,
- 0xc4, 0x41, 0x53, 0x58 },
- .length = 65,
- .plaintext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02 },
- .ciphertext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x01, 0x02 },
- .digest_length = AES_GCM_DIGEST_LEN,
- .digest = { 0x77, 0x46, 0x0D, 0x6F, 0xB1, 0x87, 0xDB, 0xA9,
- 0x46, 0xAD, 0xCD, 0xFB, 0xB7, 0xF9, 0x13, 0xA1 },
- }
-};
-
-/*
- * Test vectors from SP800-38B / CSRC examples
- * 12-byte vectors are just truncated 16-byte vectors
- */
-static crypto_test_reference_t aes_cmac_reference[] = {
- {
- .auth_key_length = AES128_KEY_LEN,
- .auth_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
- 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c },
- .length = 16,
- .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a},
- .ciphertext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a
- },
- .digest_length = 16,
- .digest = { 0x07, 0x0a, 0x16, 0xb4, 0x6b, 0x4d, 0x41, 0x44,
- 0xf7, 0x9b, 0xdd, 0x9d, 0xd0, 0x4a, 0x28, 0x7c },
- },
- {
- .copy_previous_vector = 1,
- .digest_length = 12,
- },
- {
- .auth_key_length = AES192_KEY_LEN,
- .auth_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52,
- 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
- 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b },
- .length = 16,
- .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a},
- .ciphertext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a
- },
- .digest_length = 16,
- .digest = { 0x9e, 0x99, 0xa7, 0xbf, 0x31, 0xe7, 0x10, 0x90,
- 0x06, 0x62, 0xf6, 0x5e, 0x61, 0x7c, 0x51, 0x84 },
- },
- {
- .copy_previous_vector = 1,
- .digest_length = 12,
- },
- {
- .auth_key_length = AES256_KEY_LEN,
- .auth_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
- 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
- 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
- 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4 },
- .length = 16,
- .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a},
- .ciphertext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a
- },
- .digest_length = 16,
- .digest = { 0x28, 0xa7, 0x02, 0x3f, 0x45, 0x2e, 0x8f, 0x82,
- 0xbd, 0x4b, 0xf2, 0x8d, 0x8c, 0x37, 0xc3, 0x5c },
- },
- {
- .copy_previous_vector = 1,
- .digest_length = 12,
- },
-};
-
-/*
- * Test vector from RFC 7539, sections 2.8.2, A.5
- */
-static crypto_test_reference_t chacha20_poly1305_reference[] = {
- {
- .cipher_key_length = CHACHA20_POLY1305_KEY_LEN,
- .cipher_key = { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
- 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f},
- .cipher_iv_length = CHACHA20_POLY1305_IV_LEN,
- .cipher_iv = { 0x07, 0x00, 0x00, 0x00, 0x40, 0x41, 0x42, 0x43,
- 0x44, 0x45, 0x46, 0x47 },
- .length = 114,
- .plaintext = { 0x4c, 0x61, 0x64, 0x69, 0x65, 0x73, 0x20, 0x61,
- 0x6e, 0x64, 0x20, 0x47, 0x65, 0x6e, 0x74, 0x6c,
- 0x65, 0x6d, 0x65, 0x6e, 0x20, 0x6f, 0x66, 0x20,
- 0x74, 0x68, 0x65, 0x20, 0x63, 0x6c, 0x61, 0x73,
- 0x73, 0x20, 0x6f, 0x66, 0x20, 0x27, 0x39, 0x39,
- 0x3a, 0x20, 0x49, 0x66, 0x20, 0x49, 0x20, 0x63,
- 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x6f, 0x66, 0x66,
- 0x65, 0x72, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x6f,
- 0x6e, 0x6c, 0x79, 0x20, 0x6f, 0x6e, 0x65, 0x20,
- 0x74, 0x69, 0x70, 0x20, 0x66, 0x6f, 0x72, 0x20,
- 0x74, 0x68, 0x65, 0x20, 0x66, 0x75, 0x74, 0x75,
- 0x72, 0x65, 0x2c, 0x20, 0x73, 0x75, 0x6e, 0x73,
- 0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x77, 0x6f,
- 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x69,
- 0x74, 0x2e },
- .ciphertext = { 0xd3, 0x1a, 0x8d, 0x34, 0x64, 0x8e, 0x60, 0xdb,
- 0x7b, 0x86, 0xaf, 0xbc, 0x53, 0xef, 0x7e, 0xc2,
- 0xa4, 0xad, 0xed, 0x51, 0x29, 0x6e, 0x08, 0xfe,
- 0xa9, 0xe2, 0xb5, 0xa7, 0x36, 0xee, 0x62, 0xd6,
- 0x3d, 0xbe, 0xa4, 0x5e, 0x8c, 0xa9, 0x67, 0x12,
- 0x82, 0xfa, 0xfb, 0x69, 0xda, 0x92, 0x72, 0x8b,
- 0x1a, 0x71, 0xde, 0x0a, 0x9e, 0x06, 0x0b, 0x29,
- 0x05, 0xd6, 0xa5, 0xb6, 0x7e, 0xcd, 0x3b, 0x36,
- 0x92, 0xdd, 0xbd, 0x7f, 0x2d, 0x77, 0x8b, 0x8c,
- 0x98, 0x03, 0xae, 0xe3, 0x28, 0x09, 0x1b, 0x58,
- 0xfa, 0xb3, 0x24, 0xe4, 0xfa, 0xd6, 0x75, 0x94,
- 0x55, 0x85, 0x80, 0x8b, 0x48, 0x31, 0xd7, 0xbc,
- 0x3f, 0xf4, 0xde, 0xf0, 0x8e, 0x4b, 0x7a, 0x9d,
- 0xe5, 0x76, 0xd2, 0x65, 0x86, 0xce, 0xc6, 0x4b,
- 0x61, 0x16 },
- .aad_length = 12,
- .aad = { 0x50, 0x51, 0x52, 0x53, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4,
- 0xc5, 0xc6, 0xc7 },
- .digest_length = 16,
- .digest = { 0x1a, 0xe1, 0x0b, 0x59, 0x4f, 0x09, 0xe2, 0x6a,
- 0x7e, 0x90, 0x2e, 0xcb, 0xd0, 0x60, 0x06, 0x91 }
- },
- {
- .cipher_key_length = CHACHA20_POLY1305_KEY_LEN,
- .cipher_key = { 0x1c, 0x92, 0x40, 0xa5, 0xeb, 0x55, 0xd3, 0x8a,
- 0xf3, 0x33, 0x88, 0x86, 0x04, 0xf6, 0xb5, 0xf0,
- 0x47, 0x39, 0x17, 0xc1, 0x40, 0x2b, 0x80, 0x09,
- 0x9d, 0xca, 0x5c, 0xbc, 0x20, 0x70, 0x75, 0xc0},
- .cipher_iv_length = CHACHA20_POLY1305_IV_LEN,
- .cipher_iv = { 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04,
- 0x05, 0x06, 0x07, 0x08 },
- .length = 265,
- .plaintext = { 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74,
- 0x2d, 0x44, 0x72, 0x61, 0x66, 0x74, 0x73, 0x20,
- 0x61, 0x72, 0x65, 0x20, 0x64, 0x72, 0x61, 0x66,
- 0x74, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65,
- 0x6e, 0x74, 0x73, 0x20, 0x76, 0x61, 0x6c, 0x69,
- 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x61, 0x20,
- 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x20,
- 0x6f, 0x66, 0x20, 0x73, 0x69, 0x78, 0x20, 0x6d,
- 0x6f, 0x6e, 0x74, 0x68, 0x73, 0x20, 0x61, 0x6e,
- 0x64, 0x20, 0x6d, 0x61, 0x79, 0x20, 0x62, 0x65,
- 0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64,
- 0x2c, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63,
- 0x65, 0x64, 0x2c, 0x20, 0x6f, 0x72, 0x20, 0x6f,
- 0x62, 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, 0x64,
- 0x20, 0x62, 0x79, 0x20, 0x6f, 0x74, 0x68, 0x65,
- 0x72, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65,
- 0x6e, 0x74, 0x73, 0x20, 0x61, 0x74, 0x20, 0x61,
- 0x6e, 0x79, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x2e,
- 0x20, 0x49, 0x74, 0x20, 0x69, 0x73, 0x20, 0x69,
- 0x6e, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x70, 0x72,
- 0x69, 0x61, 0x74, 0x65, 0x20, 0x74, 0x6f, 0x20,
- 0x75, 0x73, 0x65, 0x20, 0x49, 0x6e, 0x74, 0x65,
- 0x72, 0x6e, 0x65, 0x74, 0x2d, 0x44, 0x72, 0x61,
- 0x66, 0x74, 0x73, 0x20, 0x61, 0x73, 0x20, 0x72,
- 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65,
- 0x20, 0x6d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61,
- 0x6c, 0x20, 0x6f, 0x72, 0x20, 0x74, 0x6f, 0x20,
- 0x63, 0x69, 0x74, 0x65, 0x20, 0x74, 0x68, 0x65,
- 0x6d, 0x20, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x20,
- 0x74, 0x68, 0x61, 0x6e, 0x20, 0x61, 0x73, 0x20,
- 0x2f, 0xe2, 0x80, 0x9c, 0x77, 0x6f, 0x72, 0x6b,
- 0x20, 0x69, 0x6e, 0x20, 0x70, 0x72, 0x6f, 0x67,
- 0x72, 0x65, 0x73, 0x73, 0x2e, 0x2f, 0xe2, 0x80,
- 0x9d },
- .ciphertext = { 0x64, 0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, 0x2b, 0x04, 0xb3, 0x56, 0x4e, 0xea,
- 0x1b, 0x42, 0x22, 0x73, 0xf5, 0x48, 0x27, 0x1a,
- 0x0b, 0xb2, 0x31, 0x60, 0x53, 0xfa, 0x76, 0x99,
- 0x19, 0x55, 0xeb, 0xd6, 0x31, 0x59, 0x43, 0x4e,
- 0xce, 0xbb, 0x4e, 0x46, 0x6d, 0xae, 0x5a, 0x10,
- 0x73, 0xa6, 0x72, 0x76, 0x27, 0x09, 0x7a, 0x10,
- 0x49, 0xe6, 0x17, 0xd9, 0x1d, 0x36, 0x10, 0x94,
- 0xfa, 0x68, 0xf0, 0xff, 0x77, 0x98, 0x71, 0x30,
- 0x30, 0x5b, 0xea, 0xba, 0x2e, 0xda, 0x04, 0xdf,
- 0x99, 0x7b, 0x71, 0x4d, 0x6c, 0x6f, 0x2c, 0x29,
- 0xa6, 0xad, 0x5c, 0xb4, 0x02, 0x2b, 0x02, 0x70,
- 0x9b },
- .aad_length = 12,
- .aad = { 0xf3, 0x33, 0x88, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x4e, 0x91 },
- .digest_length = CHACHA20_POLY1305_CHECK_LEN,
- .digest = { 0xee, 0xad, 0x9d, 0x67, 0x89, 0x0c, 0xbb, 0x22,
- 0x39, 0x23, 0x36, 0xfe, 0xa1, 0x85, 0x1f, 0x38 }
- },
-};
-
-static crypto_test_reference_t hmac_md5_reference[] = {
- {
- .auth_key_length = HMAC_MD5_KEY_LEN,
- .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
- 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b },
- .length = 8,
- /* "Hi There" */
- .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
- .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
- .digest_length = HMAC_MD5_CHECK_LEN,
- .digest = { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c,
- 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d },
-
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_MD5_96_CHECK_LEN,
- },
- {
- .auth_key_length = HMAC_MD5_KEY_LEN,
- /* "Jefe" */
- .auth_key = { 0x4a, 0x65, 0x66, 0x65 },
- .length = 28,
- /* what do ya want for nothing?*/
- .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
- 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
- 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
- 0x69, 0x6e, 0x67, 0x3f },
- .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
- 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
- 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
- 0x69, 0x6e, 0x67, 0x3f },
- .digest_length = HMAC_MD5_CHECK_LEN,
- .digest = { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03,
- 0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38 },
-
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_MD5_96_CHECK_LEN,
- },
- {
- .auth_key_length = HMAC_MD5_KEY_LEN,
- .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa },
- .length = 50,
- .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd },
- .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd },
- .digest_length = HMAC_MD5_CHECK_LEN,
- .digest = { 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88,
- 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_MD5_96_CHECK_LEN,
- },
-};
-
-static crypto_test_reference_t hmac_sha1_reference[] = {
- {
- .auth_key_length = HMAC_SHA1_KEY_LEN,
- .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
- 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
- 0x0b, 0x0b, 0x0b, 0x0b },
- .length = 8,
- /* "Hi There" */
- .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
- .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
- .digest_length = HMAC_SHA1_CHECK_LEN,
- .digest = { 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64,
- 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e,
- 0xf1, 0x46, 0xbe, 0x00 }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_SHA1_96_CHECK_LEN,
- },
- {
- .auth_key_length = HMAC_SHA1_KEY_LEN,
- /* "Jefe" */
- .auth_key = { 0x4a, 0x65, 0x66, 0x65 },
- .length = 28,
- /* what do ya want for nothing?*/
- .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
- 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
- 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
- 0x69, 0x6e, 0x67, 0x3f },
- .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
- 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
- 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
- 0x69, 0x6e, 0x67, 0x3f },
- .digest_length = HMAC_SHA1_CHECK_LEN,
- .digest = { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2,
- 0xd2, 0x74, 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c,
- 0x25, 0x9a, 0x7c, 0x79 }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_SHA1_96_CHECK_LEN,
- },
- {
- .auth_key_length = HMAC_SHA1_KEY_LEN,
- .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xaa, 0xaa, 0xaa, 0xaa },
- .length = 50,
- .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd },
- .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd },
- .digest_length = HMAC_SHA1_CHECK_LEN,
- .digest = { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd,
- 0x91, 0xa3, 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f,
- 0x63, 0xf1, 0x75, 0xd3 }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_SHA1_96_CHECK_LEN,
- },
-};
-
-static crypto_test_reference_t hmac_sha224_reference[] = {
- {
- .auth_key_length = HMAC_SHA224_KEY_LEN,
- .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
- 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
- 0x0b, 0x0b, 0x0b, 0x0b },
- .length = 8,
- /* "Hi There" */
- .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
- .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
- .digest_length = HMAC_SHA224_CHECK_LEN,
- .digest = { 0x89, 0x6f, 0xb1, 0x12, 0x8a, 0xbb, 0xdf, 0x19,
- 0x68, 0x32, 0x10, 0x7c, 0xd4, 0x9d, 0xf3, 0x3f,
- 0x47, 0xb4, 0xb1, 0x16, 0x99, 0x12, 0xba, 0x4f,
- 0x53, 0x68, 0x4b, 0x22 }
- },
- {
- .auth_key_length = HMAC_SHA224_KEY_LEN,
- /* "Jefe" */
- .auth_key = { 0x4a, 0x65, 0x66, 0x65 },
- .length = 28,
- /* what do ya want for nothing?*/
- .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
- 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
- 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
- 0x69, 0x6e, 0x67, 0x3f },
- .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
- 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
- 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
- 0x69, 0x6e, 0x67, 0x3f },
- .digest_length = HMAC_SHA224_CHECK_LEN,
- .digest = { 0xa3, 0x0e, 0x01, 0x09, 0x8b, 0xc6, 0xdb, 0xbf,
- 0x45, 0x69, 0x0f, 0x3a, 0x7e, 0x9e, 0x6d, 0x0f,
- 0x8b, 0xbe, 0xa2, 0xa3, 0x9e, 0x61, 0x48, 0x00,
- 0x8f, 0xd0, 0x5e, 0x44 }
- },
- {
- .auth_key_length = HMAC_SHA224_KEY_LEN,
- .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xaa, 0xaa, 0xaa, 0xaa },
- .length = 50,
- .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd },
- .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd },
- .digest_length = HMAC_SHA224_CHECK_LEN,
- .digest = { 0x7f, 0xb3, 0xcb, 0x35, 0x88, 0xc6, 0xc1, 0xf6,
- 0xff, 0xa9, 0x69, 0x4d, 0x7d, 0x6a, 0xd2, 0x64,
- 0x93, 0x65, 0xb0, 0xc1, 0xf6, 0x5d, 0x69, 0xd1,
- 0xec, 0x83, 0x33, 0xea }
- }
-};
-
-static crypto_test_reference_t hmac_sha256_reference[] = {
- {
- .auth_key_length = HMAC_SHA256_KEY_LEN,
- .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
- 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
- 0x0b, 0x0b, 0x0b, 0x0b },
- .length = 8,
- /* "Hi There" */
- .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
- .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
- .digest_length = HMAC_SHA256_CHECK_LEN,
- .digest = { 0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53,
- 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b,
- 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7,
- 0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7 }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_SHA256_128_CHECK_LEN,
- },
- {
- .auth_key_length = HMAC_SHA256_KEY_LEN,
- /* "Jefe" */
- .auth_key = { 0x4a, 0x65, 0x66, 0x65 },
- .length = 28,
- /* what do ya want for nothing?*/
- .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
- 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
- 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
- 0x69, 0x6e, 0x67, 0x3f },
- .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
- 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
- 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
- 0x69, 0x6e, 0x67, 0x3f },
- .digest_length = HMAC_SHA256_CHECK_LEN,
- .digest = { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
- 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7,
- 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83,
- 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43 }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_SHA256_128_CHECK_LEN,
- },
- {
- .auth_key_length = HMAC_SHA256_KEY_LEN,
- .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xaa, 0xaa, 0xaa, 0xaa },
- .length = 50,
- .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd },
- .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd },
- .digest_length = HMAC_SHA256_CHECK_LEN,
- .digest = { 0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46,
- 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7,
- 0x29, 0x59, 0x09, 0x8b, 0x3e, 0xf8, 0xc1, 0x22,
- 0xd9, 0x63, 0x55, 0x14, 0xce, 0xd5, 0x65, 0xfe }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_SHA256_128_CHECK_LEN,
- },
-};
-
-static crypto_test_reference_t hmac_sha384_reference[] = {
- {
- .auth_key_length = HMAC_SHA384_KEY_LEN,
- .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
- 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
- 0x0b, 0x0b, 0x0b, 0x0b },
- .length = 8,
- /* "Hi There" */
- .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
- .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
- .digest_length = HMAC_SHA384_CHECK_LEN,
- .digest = { 0xaf, 0xd0, 0x39, 0x44, 0xd8, 0x48, 0x95, 0x62,
- 0x6b, 0x08, 0x25, 0xf4, 0xab, 0x46, 0x90, 0x7f,
- 0x15, 0xf9, 0xda, 0xdb, 0xe4, 0x10, 0x1e, 0xc6,
- 0x82, 0xaa, 0x03, 0x4c, 0x7c, 0xeb, 0xc5, 0x9c,
- 0xfa, 0xea, 0x9e, 0xa9, 0x07, 0x6e, 0xde, 0x7f,
- 0x4a, 0xf1, 0x52, 0xe8, 0xb2, 0xfa, 0x9c, 0xb6 }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_SHA384_192_CHECK_LEN,
- },
- {
- .auth_key_length = HMAC_SHA384_KEY_LEN,
- /* "Jefe" */
- .auth_key = { 0x4a, 0x65, 0x66, 0x65 },
- .length = 28,
- /* what do ya want for nothing?*/
- .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
- 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
- 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
- 0x69, 0x6e, 0x67, 0x3f },
- .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
- 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
- 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
- 0x69, 0x6e, 0x67, 0x3f },
- .digest_length = HMAC_SHA384_CHECK_LEN,
- .digest = { 0xaf, 0x45, 0xd2, 0xe3, 0x76, 0x48, 0x40, 0x31,
- 0x61, 0x7f, 0x78, 0xd2, 0xb5, 0x8a, 0x6b, 0x1b,
- 0x9c, 0x7e, 0xf4, 0x64, 0xf5, 0xa0, 0x1b, 0x47,
- 0xe4, 0x2e, 0xc3, 0x73, 0x63, 0x22, 0x44, 0x5e,
- 0x8e, 0x22, 0x40, 0xca, 0x5e, 0x69, 0xe2, 0xc7,
- 0x8b, 0x32, 0x39, 0xec, 0xfa, 0xb2, 0x16, 0x49 }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_SHA384_192_CHECK_LEN,
- },
- {
- .auth_key_length = HMAC_SHA384_KEY_LEN,
- .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xaa, 0xaa, 0xaa, 0xaa },
- .length = 50,
- .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd },
- .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd },
- .digest_length = HMAC_SHA384_CHECK_LEN,
- .digest = {0x88, 0x06, 0x26, 0x08, 0xd3, 0xe6, 0xad, 0x8a,
- 0x0a, 0xa2, 0xac, 0xe0, 0x14, 0xc8, 0xa8, 0x6f,
- 0x0a, 0xa6, 0x35, 0xd9, 0x47, 0xac, 0x9f, 0xeb,
- 0xe8, 0x3e, 0xf4, 0xe5, 0x59, 0x66, 0x14, 0x4b,
- 0x2a, 0x5a, 0xb3, 0x9d, 0xc1, 0x38, 0x14, 0xb9,
- 0x4e, 0x3a, 0xb6, 0xe1, 0x01, 0xa3, 0x4f, 0x27 }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_SHA384_192_CHECK_LEN,
- },
-};
-
-static crypto_test_reference_t hmac_sha512_reference[] = {
- {
- .auth_key_length = HMAC_SHA512_KEY_LEN,
- .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
- 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
- 0x0b, 0x0b, 0x0b, 0x0b },
- .length = 8,
- /* "Hi There" */
- .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
- .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
- .digest_length = HMAC_SHA512_CHECK_LEN,
- .digest = { 0x87, 0xaa, 0x7c, 0xde, 0xa5, 0xef, 0x61, 0x9d,
- 0x4f, 0xf0, 0xb4, 0x24, 0x1a, 0x1d, 0x6c, 0xb0,
- 0x23, 0x79, 0xf4, 0xe2, 0xce, 0x4e, 0xc2, 0x78,
- 0x7a, 0xd0, 0xb3, 0x05, 0x45, 0xe1, 0x7c, 0xde,
- 0xda, 0xa8, 0x33, 0xb7, 0xd6, 0xb8, 0xa7, 0x02,
- 0x03, 0x8b, 0x27, 0x4e, 0xae, 0xa3, 0xf4, 0xe4,
- 0xbe, 0x9d, 0x91, 0x4e, 0xeb, 0x61, 0xf1, 0x70,
- 0x2e, 0x69, 0x6c, 0x20, 0x3a, 0x12, 0x68, 0x54 }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_SHA512_256_CHECK_LEN,
- },
- {
- .auth_key_length = HMAC_SHA512_KEY_LEN,
- /* "Jefe" */
- .auth_key = { 0x4a, 0x65, 0x66, 0x65 },
- .length = 28,
- /* what do ya want for nothing?*/
- .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
- 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
- 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
- 0x69, 0x6e, 0x67, 0x3f },
- .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
- 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
- 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
- 0x69, 0x6e, 0x67, 0x3f },
- .digest_length = HMAC_SHA512_CHECK_LEN,
- .digest = { 0x16, 0x4b, 0x7a, 0x7b, 0xfc, 0xf8, 0x19, 0xe2,
- 0xe3, 0x95, 0xfb, 0xe7, 0x3b, 0x56, 0xe0, 0xa3,
- 0x87, 0xbd, 0x64, 0x22, 0x2e, 0x83, 0x1f, 0xd6,
- 0x10, 0x27, 0x0c, 0xd7, 0xea, 0x25, 0x05, 0x54,
- 0x97, 0x58, 0xbf, 0x75, 0xc0, 0x5a, 0x99, 0x4a,
- 0x6d, 0x03, 0x4f, 0x65, 0xf8, 0xf0, 0xe6, 0xfd,
- 0xca, 0xea, 0xb1, 0xa3, 0x4d, 0x4a, 0x6b, 0x4b,
- 0x63, 0x6e, 0x07, 0x0a, 0x38, 0xbc, 0xe7, 0x37 }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_SHA512_256_CHECK_LEN,
- },
- {
- .auth_key_length = HMAC_SHA512_KEY_LEN,
- .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xaa, 0xaa, 0xaa, 0xaa },
- .length = 50,
- .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd },
- .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
- 0xdd, 0xdd },
- .digest_length = HMAC_SHA512_CHECK_LEN,
- .digest = { 0xfa, 0x73, 0xb0, 0x08, 0x9d, 0x56, 0xa2, 0x84,
- 0xef, 0xb0, 0xf0, 0x75, 0x6c, 0x89, 0x0b, 0xe9,
- 0xb1, 0xb5, 0xdb, 0xdd, 0x8e, 0xe8, 0x1a, 0x36,
- 0x55, 0xf8, 0x3e, 0x33, 0xb2, 0x27, 0x9d, 0x39,
- 0xbf, 0x3e, 0x84, 0x82, 0x79, 0xa7, 0x22, 0xc8,
- 0x06, 0xb4, 0x85, 0xa4, 0x7e, 0x67, 0xc8, 0x07,
- 0xb9, 0x46, 0xa3, 0x37, 0xbe, 0xe8, 0x94, 0x26,
- 0x74, 0x27, 0x88, 0x59, 0xe1, 0x32, 0x92, 0xfb }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = HMAC_SHA512_256_CHECK_LEN,
- },
-};
-
-/*
- * RFC 3566
- */
-static crypto_test_reference_t aes_xcbc_reference[] = {
- /* Test Case #1 */
- {
- .auth_key_length = AES_XCBC_MAC_KEY_LEN,
- .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f},
- .length = 0,
- .digest_length = AES_XCBC_MAC_CHECK_LEN,
- .digest = {0x75, 0xf0, 0x25, 0x1d, 0x52, 0x8a, 0xc0, 0x1c,
- 0x45, 0x73, 0xdf, 0xd5, 0x84, 0xd7, 0x9f, 0x29}
- },
- {
- .copy_previous_vector = 1,
- .digest_length = AES_XCBC_MAC_96_CHECK_LEN,
- },
- /* Test Case #2 */
- {
- .auth_key_length = AES_XCBC_MAC_KEY_LEN,
- .auth_key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
- .length = 3,
- .plaintext = { 0x00, 0x01, 0x02 },
- .ciphertext = { 0x00, 0x01, 0x02 },
- .digest_length = AES_XCBC_MAC_CHECK_LEN,
- .digest = { 0x5b, 0x37, 0x65, 0x80, 0xae, 0x2f, 0x19, 0xaf,
- 0xe7, 0x21, 0x9c, 0xee, 0xf1, 0x72, 0x75, 0x6f }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = AES_XCBC_MAC_96_CHECK_LEN,
- },
- /* Test Case #3 */
- {
- .auth_key_length = AES_XCBC_MAC_KEY_LEN,
- .auth_key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
- .length = 16,
- .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
- .ciphertext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
- .digest_length = AES_XCBC_MAC_CHECK_LEN,
- .digest = { 0xd2, 0xa2, 0x46, 0xfa, 0x34, 0x9b, 0x68, 0xa7,
- 0x99, 0x98, 0xa4, 0x39, 0x4f, 0xf7, 0xa2, 0x63 }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = AES_XCBC_MAC_96_CHECK_LEN,
- },
- /* Test Case #4 */
- {
- .auth_key_length = AES_XCBC_MAC_KEY_LEN,
- .auth_key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
- .length = 20,
- .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13 },
- .ciphertext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13 },
- .digest_length = AES_XCBC_MAC_CHECK_LEN,
- .digest = { 0x47, 0xf5, 0x1b, 0x45, 0x64, 0x96, 0x62, 0x15,
- 0xb8, 0x98, 0x5c, 0x63, 0x05, 0x5e, 0xd3, 0x08 }
- },
- {
- .copy_previous_vector = 1,
- .digest_length = AES_XCBC_MAC_96_CHECK_LEN,
- },
- /* Test Case #5 */
- {
- .auth_key_length = AES_XCBC_MAC_KEY_LEN,
- .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f},
- .length = 32,
- .plaintext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f},
- .ciphertext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f},
- .digest_length = AES_XCBC_MAC_CHECK_LEN,
- .digest = {0xf5, 0x4f, 0x0e, 0xc8, 0xd2, 0xb9, 0xf3, 0xd3,
- 0x68, 0x07, 0x73, 0x4b, 0xd5, 0x28, 0x3f, 0xd4}
- },
- {
- .copy_previous_vector = 1,
- .digest_length = AES_XCBC_MAC_96_CHECK_LEN,
- },
- /* Test Case #6 */
- {
- .auth_key_length = AES_XCBC_MAC_KEY_LEN,
- .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f},
- .length = 34,
- .plaintext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
- 0x20, 0x21},
- .ciphertext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
- 0x20, 0x21},
- .digest_length = AES_XCBC_MAC_CHECK_LEN,
- .digest = {0xbe, 0xcb, 0xb3, 0xbc, 0xcd, 0xb5, 0x18, 0xa3,
- 0x06, 0x77, 0xd5, 0x48, 0x1f, 0xb6, 0xb4, 0xd8}
- },
- {
- .copy_previous_vector = 1,
- .digest_length = AES_XCBC_MAC_96_CHECK_LEN,
- },
- /* Test Case #7 */
- {
- .auth_key_length = AES_XCBC_MAC_KEY_LEN,
- .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f},
- .length = 1000,
- /* Plaintext is 1000 zero bytes. No explicit init needed. */
- .digest_length = AES_XCBC_MAC_CHECK_LEN,
- .digest = {0xf0, 0xda, 0xfe, 0xe8, 0x95, 0xdb, 0x30, 0x25,
- 0x37, 0x61, 0x10, 0x3b, 0x5d, 0x84, 0x52, 0x8f}
- },
- {
- .copy_previous_vector = 1,
- .digest_length = AES_XCBC_MAC_96_CHECK_LEN,
- },
-};
-
-/*
- * Kasumi F8 and F9 test vectors are taken from
- * 3GPP TS 35.203 V9.0.0 (2009-12)
- * 3rd Generation Partnership Project;
- * Technical Specification Group Services and System Aspects;
- * 3G Security;
- * Specification of the 3GPP Confidentiality
- * and Integrity Algorithms;
- * Document 3: Implementors' Test Data
- * (Release 9)
- */
-static crypto_test_reference_t kasumi_f8_reference[] = {
- {
- .cipher_key_length = KASUMI_F8_KEY_LEN,
- .cipher_key = { 0x5a, 0xcb, 0x1d, 0x64, 0x4c, 0x0d, 0x51, 0x20,
- 0x4e, 0xa5, 0xf1, 0x45, 0x10, 0x10, 0xd8, 0x52},
- .cipher_iv_length = KASUMI_F8_IV_LEN,
- .cipher_iv = { 0xfa, 0x55, 0x6b, 0x26, 0x1c, 0x00, 0x00, 0x00},
- .length = 120, /* 15 bytes */
- .is_length_in_bits = true,
- .plaintext = { 0xad, 0x9c, 0x44, 0x1f, 0x89, 0x0b, 0x38, 0xc4,
- 0x57, 0xa4, 0x9d, 0x42, 0x14, 0x07, 0xe8 },
- .ciphertext = { 0x9b, 0xc9, 0x2c, 0xa8, 0x03, 0xc6, 0x7b, 0x28,
- 0xa1, 0x1a, 0x4b, 0xee, 0x5a, 0x0c, 0x25 }
- }
-};
-
-static crypto_test_reference_t kasumi_f9_reference[] = {
- {
- .auth_key_length = KASUMI_F9_KEY_LEN,
- .auth_key = { 0xc7, 0x36, 0xc6, 0xaa, 0xb2, 0x2b, 0xff, 0xf9,
- 0x1e, 0x26, 0x98, 0xd2, 0xe2, 0x2a, 0xd5, 0x7e },
- .auth_iv_length = KASUMI_F9_IV_LEN,
- .auth_iv = { 0x14, 0x79, 0x3e, 0x41, 0x03, 0x97, 0xe8, 0xfd,
- 0x01, },
- .length = 384, /* 48 bytes */
- .is_length_in_bits = true,
- .plaintext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2,
- 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1,
- 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29,
- 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0,
- 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20,
- 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09},
- .ciphertext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2,
- 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1,
- 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29,
- 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0,
- 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20,
- 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09},
- .digest_length = KASUMI_F9_DIGEST_LEN,
- .digest = { 0xdd, 0x7d, 0xfa, 0xdd },
- }
-};
-
-/*
- * Snow3G UEA2 & UIA2 test vectors are taken from
- * Specification of the 3GPP Confidentiality and
- * Integrity Algorithms UEA2 & UIA2
- * Document 3: Implementors’ Test Data
- * Version: 1.1
- * Date: 25 th October 2012
- */
-static crypto_test_reference_t snow3g_uea2_reference[] = {
- {
- .cipher_key_length = SNOW3G_UEA2_KEY_LEN,
- .cipher_key = { 0x5a, 0xcb, 0x1d, 0x64, 0x4c, 0x0d, 0x51, 0x20,
- 0x4e, 0xa5, 0xf1, 0x45, 0x10, 0x10, 0xd8, 0x52},
- .cipher_iv_length = SNOW3G_UEA2_IV_LEN,
- .cipher_iv = { 0xfa, 0x55, 0x6b, 0x26, 0x1c, 0x00, 0x00, 0x00,
- 0xfa, 0x55, 0x6b, 0x26, 0x1c, 0x00, 0x00, 0x00},
- .length = 120, /* 15 bytes */
- .is_length_in_bits = true,
- .plaintext = { 0xad, 0x9c, 0x44, 0x1f, 0x89, 0x0b, 0x38, 0xc4,
- 0x57, 0xa4, 0x9d, 0x42, 0x14, 0x07, 0xe8 },
- .ciphertext = { 0xba, 0x0f, 0x31, 0x30, 0x03, 0x34, 0xc5, 0x6b,
- 0x52, 0xa7, 0x49, 0x7c, 0xba, 0xc0, 0x46 }
- }
-};
-
-static crypto_test_reference_t snow3g_uia2_reference[] = {
- {
- .auth_key_length = SNOW3G_UIA2_KEY_LEN,
- .auth_key = { 0xc7, 0x36, 0xc6, 0xaa, 0xb2, 0x2b, 0xff, 0xf9,
- 0x1e, 0x26, 0x98, 0xd2, 0xe2, 0x2a, 0xd5, 0x7e},
- .auth_iv_length = SNOW3G_UIA2_IV_LEN,
- .auth_iv = { 0x14, 0x79, 0x3e, 0x41, 0x03, 0x97, 0xe8, 0xfd,
- 0x94, 0x79, 0x3e, 0x41, 0x03, 0x97, 0x68, 0xfd },
- .length = 384, /* 48 bytes */
- .is_length_in_bits = true,
- .plaintext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2,
- 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1,
- 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29,
- 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0,
- 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20,
- 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09},
- .ciphertext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2,
- 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1,
- 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29,
- 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0,
- 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20,
- 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09},
- .digest_length = SNOW3G_UIA2_DIGEST_LEN,
- .digest = { 0x38, 0xb5, 0x54, 0xc0 }
- }
-};
-
-/*
- * AES EEA2 and AES EIA2 test vectors from
- * Specification of the 3GPP Confidentiality and Integrity
- * Algorithms 128-EEA2 & 128-EIA2
- */
-static crypto_test_reference_t aes_eea2_reference[] = {
- {
- .cipher_key_length = AES_EEA2_KEY_LEN,
- .cipher_key = { 0xD3, 0xC5, 0xD5, 0x92, 0x32, 0x7F, 0xB1, 0x1C,
- 0x40, 0x35, 0xC6, 0x68, 0x0A, 0xF8, 0xC6, 0xD1},
- .cipher_iv_length = AES_EEA2_IV_LEN,
- .cipher_iv = { 0x39, 0x8a, 0x59, 0xb4, 0xac, },
- .length = 253,
- .is_length_in_bits = true,
- .plaintext = { 0x98, 0x1B, 0xA6, 0x82, 0x4C, 0x1B, 0xFB, 0x1A,
- 0xB4, 0x85, 0x47, 0x20, 0x29, 0xB7, 0x1D, 0x80,
- 0x8C, 0xE3, 0x3E, 0x2C, 0xC3, 0xC0, 0xB5, 0xFC,
- 0x1F, 0x3D, 0xE8, 0xA6, 0xDC, 0x66, 0xB1, 0xF0 },
- .ciphertext = { 0xE9, 0xFE, 0xD8, 0xA6, 0x3D, 0x15, 0x53, 0x04,
- 0xD7, 0x1D, 0xF2, 0x0B, 0xF3, 0xE8, 0x22, 0x14,
- 0xB2, 0x0E, 0xD7, 0xDA, 0xD2, 0xF2, 0x33, 0xDC,
- 0x3C, 0x22, 0xD7, 0xBD, 0xEE, 0xED, 0x8E, 0x78}
- },
- {
- .cipher_key_length = AES_EEA2_KEY_LEN,
- .cipher_key = { 0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC4, 0x40, 0xE0,
- 0x95, 0x2C, 0x49, 0x10, 0x48, 0x05, 0xFF, 0x48},
- .cipher_iv_length = AES_EEA2_IV_LEN,
- .cipher_iv = { 0xc6, 0x75, 0xa6, 0x4b, 0x64, },
- .length = 798,
- .is_length_in_bits = true,
- .plaintext = { 0x7E, 0xC6, 0x12, 0x72, 0x74, 0x3B, 0xF1, 0x61,
- 0x47, 0x26, 0x44, 0x6A, 0x6C, 0x38, 0xCE, 0xD1,
- 0x66, 0xF6, 0xCA, 0x76, 0xEB, 0x54, 0x30, 0x04,
- 0x42, 0x86, 0x34, 0x6C, 0xEF, 0x13, 0x0F, 0x92,
- 0x92, 0x2B, 0x03, 0x45, 0x0D, 0x3A, 0x99, 0x75,
- 0xE5, 0xBD, 0x2E, 0xA0, 0xEB, 0x55, 0xAD, 0x8E,
- 0x1B, 0x19, 0x9E, 0x3E, 0xC4, 0x31, 0x60, 0x20,
- 0xE9, 0xA1, 0xB2, 0x85, 0xE7, 0x62, 0x79, 0x53,
- 0x59, 0xB7, 0xBD, 0xFD, 0x39, 0xBE, 0xF4, 0xB2,
- 0x48, 0x45, 0x83, 0xD5, 0xAF, 0xE0, 0x82, 0xAE,
- 0xE6, 0x38, 0xBF, 0x5F, 0xD5, 0xA6, 0x06, 0x19,
- 0x39, 0x01, 0xA0, 0x8F, 0x4A, 0xB4, 0x1A, 0xAB,
- 0x9B, 0x13, 0x48, 0x80 },
- .ciphertext = { 0x59, 0x61, 0x60, 0x53, 0x53, 0xC6, 0x4B, 0xDC,
- 0xA1, 0x5B, 0x19, 0x5E, 0x28, 0x85, 0x53, 0xA9,
- 0x10, 0x63, 0x25, 0x06, 0xD6, 0x20, 0x0A, 0xA7,
- 0x90, 0xC4, 0xC8, 0x06, 0xC9, 0x99, 0x04, 0xCF,
- 0x24, 0x45, 0xCC, 0x50, 0xBB, 0x1C, 0xF1, 0x68,
- 0xA4, 0x96, 0x73, 0x73, 0x4E, 0x08, 0x1B, 0x57,
- 0xE3, 0x24, 0xCE, 0x52, 0x59, 0xC0, 0xE7, 0x8D,
- 0x4C, 0xD9, 0x7B, 0x87, 0x09, 0x76, 0x50, 0x3C,
- 0x09, 0x43, 0xF2, 0xCB, 0x5A, 0xE8, 0xF0, 0x52,
- 0xC7, 0xB7, 0xD3, 0x92, 0x23, 0x95, 0x87, 0xB8,
- 0x95, 0x60, 0x86, 0xBC, 0xAB, 0x18, 0x83, 0x60,
- 0x42, 0xE2, 0xE6, 0xCE, 0x42, 0x43, 0x2A, 0x17,
- 0x10, 0x5C, 0x53, 0xD0 }
- },
-};
-
-static crypto_test_reference_t aes_eia2_reference[] = {
- /* 3GPP TS 33.401, C.2.1 */
- {
- .auth_key_length = AES_EIA2_KEY_LEN,
- .auth_key = { 0x2b, 0xd6, 0x45, 0x9f, 0x82, 0xc5, 0xb3, 0x00,
- 0x95, 0x2c, 0x49, 0x10, 0x48, 0x81, 0xff, 0x48 },
- .auth_iv_length = AES_EIA2_IV_LEN,
- .auth_iv = { 0x38, 0xa6, 0xf0, 0x56, 0xc0 },
- .length = 58,
- .is_length_in_bits = true,
- .plaintext = { 0x33, 0x32, 0x34, 0x62, 0x63, 0x39, 0x38, 0x40 },
- .ciphertext = { 0x33, 0x32, 0x34, 0x62, 0x63, 0x39, 0x38, 0x40 },
- .digest_length = AES_EIA2_DIGEST_LEN,
- .digest = { 0x11, 0x8c, 0x6e, 0xb8 }
- },
- /* 3GPP TS 33.401, C.2.2. */
- {
- .auth_key_length = AES_EIA2_KEY_LEN,
- .auth_key = { 0xD3, 0xC5, 0xD5, 0x92, 0x32, 0x7F, 0xB1, 0x1C,
- 0x40, 0x35, 0xC6, 0x68, 0x0A, 0xF8, 0xC6, 0xD1 },
- .auth_iv_length = AES_EIA2_IV_LEN,
- .auth_iv = { 0x39, 0x8a, 0x59, 0xb4, 0xd4, },
- .length = 64, /* 8 bytes */
- .is_length_in_bits = true,
- .plaintext = { 0x48, 0x45, 0x83, 0xd5, 0xaf, 0xe0, 0x82, 0xae },
- .ciphertext = { 0x48, 0x45, 0x83, 0xd5, 0xaf, 0xe0, 0x82, 0xae},
- .digest_length = AES_EIA2_DIGEST_LEN,
- .digest = { 0xb9, 0x37, 0x87, 0xe6 }
- },
- /* 3GPP TS 33.401, C.2.5 */
- {
- .auth_key_length = AES_EIA2_KEY_LEN,
- .auth_key = { 0x83, 0xfd, 0x23, 0xa2, 0x44, 0xa7, 0x4c, 0xf3,
- 0x58, 0xda, 0x30, 0x19, 0xf1, 0x72, 0x26, 0x35 },
- .auth_iv_length = AES_EIA2_IV_LEN,
- .auth_iv = { 0x36, 0xaf, 0x61, 0x44, 0x7c },
- .length = 768, /* 96 bytes */
- .is_length_in_bits = true,
- .plaintext = { 0x35, 0xc6, 0x87, 0x16, 0x63, 0x3c, 0x66, 0xfb,
- 0x75, 0x0c, 0x26, 0x68, 0x65, 0xd5, 0x3c, 0x11,
- 0xea, 0x05, 0xb1, 0xe9, 0xfa, 0x49, 0xc8, 0x39,
- 0x8d, 0x48, 0xe1, 0xef, 0xa5, 0x90, 0x9d, 0x39,
- 0x47, 0x90, 0x28, 0x37, 0xf5, 0xae, 0x96, 0xd5,
- 0xa0, 0x5b, 0xc8, 0xd6, 0x1c, 0xa8, 0xdb, 0xef,
- 0x1b, 0x13, 0xa4, 0xb4, 0xab, 0xfe, 0x4f, 0xb1,
- 0x00, 0x60, 0x45, 0xb6, 0x74, 0xbb, 0x54, 0x72,
- 0x93, 0x04, 0xc3, 0x82, 0xbe, 0x53, 0xa5, 0xaf,
- 0x05, 0x55, 0x61, 0x76, 0xf6, 0xea, 0xa2, 0xef,
- 0x1d, 0x05, 0xe4, 0xb0, 0x83, 0x18, 0x1e, 0xe6,
- 0x74, 0xcd, 0xa5, 0xa4, 0x85, 0xf7, 0x4d, 0x7a },
- .ciphertext = { 0x35, 0xc6, 0x87, 0x16, 0x63, 0x3c, 0x66, 0xfb,
- 0x75, 0x0c, 0x26, 0x68, 0x65, 0xd5, 0x3c, 0x11,
- 0xea, 0x05, 0xb1, 0xe9, 0xfa, 0x49, 0xc8, 0x39,
- 0x8d, 0x48, 0xe1, 0xef, 0xa5, 0x90, 0x9d, 0x39,
- 0x47, 0x90, 0x28, 0x37, 0xf5, 0xae, 0x96, 0xd5,
- 0xa0, 0x5b, 0xc8, 0xd6, 0x1c, 0xa8, 0xdb, 0xef,
- 0x1b, 0x13, 0xa4, 0xb4, 0xab, 0xfe, 0x4f, 0xb1,
- 0x00, 0x60, 0x45, 0xb6, 0x74, 0xbb, 0x54, 0x72,
- 0x93, 0x04, 0xc3, 0x82, 0xbe, 0x53, 0xa5, 0xaf,
- 0x05, 0x55, 0x61, 0x76, 0xf6, 0xea, 0xa2, 0xef,
- 0x1d, 0x05, 0xe4, 0xb0, 0x83, 0x18, 0x1e, 0xe6,
- 0x74, 0xcd, 0xa5, 0xa4, 0x85, 0xf7, 0x4d, 0x7a },
- .digest_length = AES_EIA2_DIGEST_LEN,
- .digest = { 0xe6, 0x57, 0xe1, 0x82 }
- },
-};
-
-/*
- * ZUC EEA3 and EIA3 test vectors from
- * Specification of the 3GPP Confidentiality and Integrity
- * Algorithms 128-EEA3 & 128-EIA3
- * Document 3: Implementor’s Test Data
- * Version: 1.1
- * Date: 4 th Jan. 2011
- */
-static crypto_test_reference_t zuc_eea3_reference[] = {
- {
- .cipher_key_length = ZUC_EEA3_KEY_LEN,
- .cipher_key = { 0xe5, 0xbd, 0x3e, 0xa0, 0xeb, 0x55, 0xad, 0xe8,
- 0x66, 0xc6, 0xac, 0x58, 0xbd, 0x54, 0x30, 0x2a},
- .cipher_iv_length = ZUC_EEA3_IV_LEN,
- .cipher_iv = { 0x00, 0x05, 0x68, 0x23, 0xc4, 0x00, 0x00, 0x00,
- 0x00, 0x05, 0x68, 0x23, 0xc4, 0x00, 0x00, 0x00 },
- .length = 800, /* 100 bytes */
- .is_length_in_bits = true,
- .plaintext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13, 0xb2, 0xf2, 0xbc, 0xa6,
- 0xdf, 0x5a, 0x47, 0x3a, 0x57, 0xa4, 0xa0, 0x0d,
- 0x98, 0x5e, 0xba, 0xd8, 0x80, 0xd6, 0xf2, 0x38,
- 0x64, 0xa0, 0x7b, 0x01 }
- },
-
- /* Privately generated test data */
- {
- .cipher_key_length = ZUC_EEA3_256_KEY_LEN,
- .cipher_key = { 0xf7, 0xb4, 0x04, 0x5a, 0x81, 0x5c, 0x1b, 0x01,
- 0x82, 0xf9, 0xf4, 0x26, 0x80, 0xd4, 0x56, 0x26,
- 0xd5, 0xf7, 0x4b, 0x68, 0x48, 0x6b, 0x92, 0x6a,
- 0x34, 0x1f, 0x86, 0x66, 0x60, 0x0a, 0xfc, 0x57},
- .cipher_iv_length = ZUC_EEA3_256_IV_LEN,
- .cipher_iv = { 0x8e, 0x5d, 0xbc, 0x3f, 0xb9, 0xae, 0x66, 0xa3,
- 0xb9, 0x5c, 0x12, 0x14, 0xdb, 0xc5, 0xbc, 0x18,
- 0x48, 0x12, 0x09, 0x06, 0x25, 0x33, 0x2e, 0x12,
- 0x12 },
- .length = 1024,
- .is_length_in_bits = true,
- .plaintext = { 0x36, 0xdb, 0x63, 0x68, 0xb5, 0x1f, 0x4e, 0x92,
- 0x46, 0x1f, 0xde, 0xdb, 0xc2, 0xec, 0xfa, 0x7e,
- 0x49, 0x85, 0x77, 0xaa, 0x46, 0x98, 0x30, 0x2d,
- 0x3b, 0xc4, 0x11, 0x24, 0x98, 0x20, 0xa9, 0xce,
- 0xfb, 0x0d, 0x36, 0xb0, 0x2c, 0x85, 0x42, 0x72,
- 0xa4, 0x21, 0x4e, 0x66, 0x0d, 0x48, 0xe4, 0x57,
- 0xce, 0x5b, 0x01, 0x14, 0xf3, 0x31, 0x42, 0x2e,
- 0xf5, 0x53, 0x52, 0x8d, 0x73, 0xfc, 0x5c, 0x6e,
- 0x09, 0x92, 0x1e, 0x35, 0x17, 0x60, 0xa8, 0xbb,
- 0x81, 0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0x6c,
- 0xae, 0xb5, 0x44, 0x60, 0x43, 0x9d, 0xa7, 0x3f }
- },
- /* Privately generated test data */
- {
- .cipher_key_length = ZUC_EEA3_256_KEY_LEN,
- .cipher_key = { 0x1d, 0x0f, 0x0e, 0x75, 0x86, 0xb3, 0xfc, 0x65,
- 0x94, 0xbf, 0xaa, 0xa8, 0xf5, 0xd0, 0x0f, 0xe8,
- 0x14, 0x7a, 0x96, 0x61, 0x15, 0x49, 0x79, 0x71,
- 0x13, 0x82, 0xb4, 0xae, 0x34, 0x04, 0x75, 0x51 },
- .cipher_iv_length = ZUC_EEA3_256_IV_LEN,
- .cipher_iv = { 0x98, 0xcc, 0x89, 0x9f, 0xaf, 0x6d, 0x64, 0xb6,
- 0xb1, 0xe8, 0x21, 0x72, 0xee, 0xb6, 0xcc, 0xe3,
- 0xcf, 0x32, 0x28, 0x21, 0x21, 0x0d, 0x1e, 0x1c,
- 0x34 },
- .length = 1928,
- .is_length_in_bits = true,
- .plaintext = { 0xa4, 0xcb, 0x6e, 0x76, 0x99, 0xfb, 0x0c, 0xab,
- 0x6d, 0x57, 0xb1, 0x69, 0xc0, 0x47, 0x80, 0x63,
- 0x00, 0xe1, 0xf9, 0x51, 0x10, 0xbe, 0xc0, 0x0f,
- 0x99, 0x62, 0x2d, 0x71, 0xca, 0x75, 0xa0, 0x6e,
- 0x41, 0x0e, 0xe4, 0xda, 0x09, 0xf1, 0x86, 0x76,
- 0x48, 0x37, 0xe0, 0x08, 0x7e, 0x60, 0x6c, 0x7f,
- 0x41, 0x65, 0xd0, 0x51, 0x24, 0x91, 0x61, 0xbd,
- 0xf3, 0x8e, 0x2e, 0xbd, 0x04, 0xce, 0x2b, 0x45,
- 0xdc, 0x0f, 0x1f, 0xe5, 0x00, 0xa5, 0x5c, 0x48,
- 0xdd, 0x3c, 0x51, 0x5b, 0x9c, 0xbd, 0xda, 0xde,
- 0x22, 0xab, 0x2f, 0x46, 0x3c, 0x90, 0x03, 0x2f,
- 0x1f, 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xd7, 0x3d, 0x3a, 0x40, 0x7c, 0x3f, 0xa7, 0x98,
- 0xf3, 0x12, 0x7f, 0x9f, 0x89, 0xcf, 0x48, 0x58,
- 0x01, 0xeb, 0x98, 0x7c, 0x59, 0x11, 0x9f, 0x57,
- 0x74, 0x5f, 0x70, 0x72, 0x74, 0xa4, 0x82, 0x3c,
- 0x36, 0xe6, 0x31, 0x9e, 0xba, 0x7b, 0x53, 0xfc,
- 0x56 }
- },
-};
-
-static crypto_test_reference_t zuc_eia3_reference[] = {
- {
- .auth_key_length = ZUC_EIA3_KEY_LEN,
- .auth_key = { 0xc9, 0xe6, 0xce, 0xc4, 0x60, 0x7c, 0x72, 0xdb,
- 0x00, 0x0a, 0xef, 0xa8, 0x83, 0x85, 0xab, 0x0a },
- .auth_iv_length = ZUC_EIA3_IV_LEN,
- .auth_iv = { 0xa9, 0x40, 0x59, 0xda, 0x50, 0x00, 0x00, 0x00,
- 0x29, 0x40, 0x59, 0xda, 0x50, 0x00, 0x80, 0x00 },
- .length = 584, /* 73 bytes */
- .is_length_in_bits = true,
- .plaintext = { 0x98, 0x3b, 0x41, 0xd4, 0x7d, 0x78, 0x0c, 0x9e,
- 0x1a, 0xd1, 0x1d, 0x7e, 0xb7, 0x03, 0x91, 0xb1,
- 0xde, 0x0b, 0x35, 0xda, 0x2d, 0xc6, 0x2f, 0x83,
- 0xe7, 0xb7, 0x8d, 0x63, 0x06, 0xca, 0x0e, 0xa0,
- 0x7e, 0x94, 0x1b, 0x7b, 0xe9, 0x13, 0x48, 0xf9,
- 0xfc, 0xb1, 0x70, 0xe2, 0x21, 0x7f, 0xec, 0xd9,
- 0x7f, 0x9f, 0x68, 0xad, 0xb1, 0x6e, 0x5d, 0x7d,
- 0x21, 0xe5, 0x69, 0xd2, 0x80, 0xed, 0x77, 0x5c,
- 0xeb, 0xde, 0x3f, 0x40, 0x93, 0xc5, 0x38, 0x81,
- 0x00, 0x00, 0x00, 0x00 },
- .ciphertext = { 0x98, 0x3b, 0x41, 0xd4, 0x7d, 0x78, 0x0c, 0x9e,
- 0x1a, 0xd1, 0x1d, 0x7e, 0xb7, 0x03, 0x91, 0xb1,
- 0xde, 0x0b, 0x35, 0xda, 0x2d, 0xc6, 0x2f, 0x83,
- 0xe7, 0xb7, 0x8d, 0x63, 0x06, 0xca, 0x0e, 0xa0,
- 0x7e, 0x94, 0x1b, 0x7b, 0xe9, 0x13, 0x48, 0xf9,
- 0xfc, 0xb1, 0x70, 0xe2, 0x21, 0x7f, 0xec, 0xd9,
- 0x7f, 0x9f, 0x68, 0xad, 0xb1, 0x6e, 0x5d, 0x7d,
- 0x21, 0xe5, 0x69, 0xd2, 0x80, 0xed, 0x77, 0x5c,
- 0xeb, 0xde, 0x3f, 0x40, 0x93, 0xc5, 0x38, 0x81,
- 0x00, 0x00, 0x00, 0x00 },
- .digest_length = ZUC_EIA3_DIGEST_LEN,
- .digest = { 0x24, 0xa8, 0x42, 0xb3 }
- },
- /* Privately generated test data */
- {
- .auth_key_length = ZUC_EIA3_256_KEY_LEN,
- .auth_key = { 0xe3, 0x8e, 0xaf, 0x08, 0xde, 0x8c, 0x08, 0x41,
- 0x7f, 0x2b, 0x97, 0x20, 0x10, 0x87, 0xc7, 0xf7,
- 0xbe, 0x3c, 0xd2, 0x68, 0x80, 0x10, 0x1e, 0x71,
- 0xfd, 0xb2, 0xbb, 0xad, 0x25, 0x0f, 0x06, 0x08 },
- .auth_iv_length = ZUC_EIA3_256_IV_LEN,
- .auth_iv = { 0xf5, 0x8d, 0x08, 0x26, 0x94, 0x14, 0xc7, 0x4d,
- 0xf5, 0x7c, 0x9c, 0xaa, 0x45, 0x53, 0xfd, 0x85,
- 0x23, 0x0b, 0x00, 0x0e, 0x26, 0x2b, 0x0f, 0x01,
- 0x26 },
- .length = 360,
- .is_length_in_bits = true,
- .plaintext = { 0x08, 0xba, 0x8d, 0xf1, 0xf8, 0x62, 0xa6, 0xaf,
- 0xf9, 0x03, 0x88, 0x9c, 0xa3, 0x68, 0x6b, 0x87,
- 0xb6, 0x92, 0xd1, 0x47, 0x3e, 0x54, 0xaf, 0x46,
- 0x07, 0x8f, 0x89, 0xea, 0x26, 0x9d, 0x0e, 0x2f,
- 0x57, 0x9b, 0x20, 0x4f, 0xfe, 0xc7, 0xfe, 0xf7,
- 0xca, 0x86, 0x93, 0x6d, 0xee },
- .ciphertext = { 0x08, 0xba, 0x8d, 0xf1, 0xf8, 0x62, 0xa6, 0xaf,
- 0xf9, 0x03, 0x88, 0x9c, 0xa3, 0x68, 0x6b, 0x87,
- 0xb6, 0x92, 0xd1, 0x47, 0x3e, 0x54, 0xaf, 0x46,
- 0x07, 0x8f, 0x89, 0xea, 0x26, 0x9d, 0x0e, 0x2f,
- 0x57, 0x9b, 0x20, 0x4f, 0xfe, 0xc7, 0xfe, 0xf7,
- 0xca, 0x86, 0x93, 0x6d, 0xee },
- .digest_length = ZUC_EIA3_DIGEST_LEN,
- .digest = {0x58, 0x19, 0xab, 0xa5}
- },
- /* Privately generated test data */
- {
- .auth_key_length = ZUC_EIA3_256_KEY_LEN,
- .auth_key = { 0x6a, 0x7e, 0x4c, 0x7e, 0x51, 0x25, 0xb3, 0x48,
- 0x84, 0x53, 0x3a, 0x94, 0xfb, 0x31, 0x99, 0x90,
- 0x32, 0x57, 0x44, 0xee, 0x9b, 0xbc, 0xe9, 0xe5,
- 0x25, 0xcf, 0x08, 0xf5, 0xe9, 0xe2, 0x5e, 0x53 },
- .auth_iv_length = ZUC_EIA3_256_IV_LEN,
- .auth_iv = { 0x60, 0xaa, 0xd2, 0xb2, 0xd0, 0x85, 0xfa, 0x54,
- 0xd8, 0x35, 0xe8, 0xd4, 0x66, 0x82, 0x64, 0x98,
- 0xd9, 0x2a, 0x08, 0x1d, 0x35, 0x19, 0x17, 0x01,
- 0x1A },
- .length = 2872,
- .is_length_in_bits = true,
- .plaintext = { 0xc6, 0x69, 0x73, 0x51, 0xff, 0x4a, 0xec, 0x29,
- 0xcd, 0xba, 0xab, 0xf2, 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, 0x23, 0xd0, 0x1a, 0xda, 0x69 },
- .digest_length = ZUC_EIA3_DIGEST_LEN,
- .digest = {0xd1, 0x1e, 0x33, 0xf6}
- },
-};
-
-/*
- * MD5 test vectors from RFC 1321
- */
-static crypto_test_reference_t md5_reference[] = {
- {
- .length = 3,
- .plaintext = { 0x61, 0x62, 0x63 },
- .ciphertext = { 0x61, 0x62, 0x63 },
- .digest_length = MD5_DIGEST_LEN,
- .digest = { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0,
- 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72}
- },
- {
- .length = 62,
- .plaintext = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
- 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
- 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
- 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
- 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
- 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
- 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33,
- 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 },
- .ciphertext = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
- 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
- 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
- 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
- 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
- 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
- 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33,
- 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 },
- .digest_length = MD5_DIGEST_LEN,
- .digest = { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5,
- 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f},
- }
-};
-
-/*
- * SHA test vectors from Crypto++
- */
-static crypto_test_reference_t sha1_reference[] = {
- {
- .length = 3,
- .plaintext = { 0x61, 0x62, 0x63 },
- .ciphertext = { 0x61, 0x62, 0x63 },
- .digest_length = SHA1_DIGEST_LEN,
- .digest = { 0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A,
- 0xBA, 0x3E, 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C,
- 0x9C, 0xD0, 0xD8, 0x9D},
- },
- {
- .length = 56,
- .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65,
- 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67,
- 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69,
- 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b,
- 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d,
- 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f,
- 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71},
- .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65,
- 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67,
- 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69,
- 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b,
- 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d,
- 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f,
- 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71},
- .digest_length = SHA1_DIGEST_LEN,
- .digest = { 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E,
- 0xBA, 0xAE, 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5,
- 0xE5, 0x46, 0x70, 0xF1},
- }
-};
-
-static crypto_test_reference_t sha224_reference[] = {
- {
- .length = 3,
- .plaintext = { 0x61, 0x62, 0x63 },
- .ciphertext = { 0x61, 0x62, 0x63 },
- .digest_length = SHA224_DIGEST_LEN,
- .digest = { 0x23, 0x09, 0x7d, 0x22, 0x34, 0x05, 0xd8, 0x22,
- 0x86, 0x42, 0xa4, 0x77, 0xbd, 0xa2, 0x55, 0xb3,
- 0x2a, 0xad, 0xbc, 0xe4, 0xbd, 0xa0, 0xb3, 0xf7,
- 0xe3, 0x6c, 0x9d, 0xa7 },
- },
- {
- .length = 56,
- .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65,
- 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67,
- 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69,
- 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b,
- 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d,
- 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f,
- 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71},
- .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65,
- 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67,
- 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69,
- 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b,
- 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d,
- 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f,
- 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71},
- .digest_length = SHA224_DIGEST_LEN,
- .digest = { 0x75, 0x38, 0x8b, 0x16, 0x51, 0x27, 0x76, 0xcc,
- 0x5d, 0xba, 0x5d, 0xa1, 0xfd, 0x89, 0x01, 0x50,
- 0xb0, 0xc6, 0x45, 0x5c, 0xb4, 0xf5, 0x8b, 0x19,
- 0x52, 0x52, 0x25, 0x25},
- }
-};
-
-static crypto_test_reference_t sha256_reference[] = {
- {
- .length = 3,
- .plaintext = { 0x61, 0x62, 0x63 },
- .ciphertext = { 0x61, 0x62, 0x63 },
- .digest_length = SHA256_DIGEST_LEN,
- .digest = { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
- 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
- 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
- 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad},
- },
- {
- .length = 56,
- .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65,
- 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67,
- 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69,
- 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b,
- 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d,
- 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f,
- 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71},
- .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65,
- 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67,
- 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69,
- 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b,
- 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d,
- 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f,
- 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71},
- .digest_length = SHA256_DIGEST_LEN,
- .digest = { 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8,
- 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39,
- 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67,
- 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1},
- }
-};
-
-static crypto_test_reference_t sha384_reference[] = {
- {
- .length = 3,
- .plaintext = { 0x61, 0x62, 0x63 },
- .ciphertext = { 0x61, 0x62, 0x63 },
- .digest_length = SHA384_DIGEST_LEN,
- .digest = { 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b,
- 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07,
- 0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63,
- 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed,
- 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23,
- 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7},
- },
- {
- .length = 112,
- .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
- 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
- 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
- 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,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
- 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
- 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75},
- .digest_length = SHA384_DIGEST_LEN,
- .digest = { 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8,
- 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47,
- 0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2,
- 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12,
- 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9,
- 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39},
- }
-};
-
-static crypto_test_reference_t sha512_reference[] = {
- {
- .length = 3,
- .plaintext = { 0x61, 0x62, 0x63 },
- .ciphertext = { 0x61, 0x62, 0x63 },
- .digest_length = SHA512_DIGEST_LEN,
- .digest = { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba,
- 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31,
- 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2,
- 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a,
- 0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8,
- 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd,
- 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e,
- 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f},
- },
- {
- .length = 112,
- .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
- 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
- 0x63, 0x64, 0x65, 0x66, 0x67, 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71, 0x72,
- 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73,
- 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
- 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75},
- .digest_length = SHA512_DIGEST_LEN,
- .digest = { 0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda,
- 0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f,
- 0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1,
- 0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18,
- 0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4,
- 0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a,
- 0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54,
- 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09},
- }
-};
-
-static void init_reference(crypto_test_reference_t *ref, int size)
+static inline void init_reference(crypto_test_reference_t *ref, int size)
{
int n;
crypto_test_reference_t *prev = NULL;
diff --git a/test/validation/api/crypto/util.c b/test/validation/api/crypto/util.c
new file mode 100644
index 000000000..557e5e951
--- /dev/null
+++ b/test/validation/api/crypto/util.c
@@ -0,0 +1,310 @@
+/* Copyright (c) 2014-2018, Linaro Limited
+ * Copyright (c) 2021-2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <odp_api.h>
+#include <odp_cunit_common.h>
+#include <odp/helper/odph_api.h>
+#include "util.h"
+
+struct suite_context_s suite_context;
+
+const char *auth_alg_name(odp_auth_alg_t auth)
+{
+ switch (auth) {
+ case ODP_AUTH_ALG_NULL:
+ return "ODP_AUTH_ALG_NULL";
+ case ODP_AUTH_ALG_MD5_HMAC:
+ return "ODP_AUTH_ALG_MD5_HMAC";
+ case ODP_AUTH_ALG_SHA1_HMAC:
+ return "ODP_AUTH_ALG_SHA1_HMAC";
+ case ODP_AUTH_ALG_SHA224_HMAC:
+ return "ODP_AUTH_ALG_SHA224_HMAC";
+ case ODP_AUTH_ALG_SHA256_HMAC:
+ return "ODP_AUTH_ALG_SHA256_HMAC";
+ case ODP_AUTH_ALG_SHA384_HMAC:
+ return "ODP_AUTH_ALG_SHA384_HMAC";
+ case ODP_AUTH_ALG_SHA512_HMAC:
+ return "ODP_AUTH_ALG_SHA512_HMAC";
+ case ODP_AUTH_ALG_AES_XCBC_MAC:
+ return "ODP_AUTH_ALG_AES_XCBC_MAC";
+ case ODP_AUTH_ALG_AES_GCM:
+ return "ODP_AUTH_ALG_AES_GCM";
+ case ODP_AUTH_ALG_AES_GMAC:
+ return "ODP_AUTH_ALG_AES_GMAC";
+ case ODP_AUTH_ALG_AES_CCM:
+ return "ODP_AUTH_ALG_AES_CCM";
+ case ODP_AUTH_ALG_AES_CMAC:
+ return "ODP_AUTH_ALG_AES_CMAC";
+ case ODP_AUTH_ALG_CHACHA20_POLY1305:
+ return "ODP_AUTH_ALG_CHACHA20_POLY1305";
+ case ODP_AUTH_ALG_KASUMI_F9:
+ return "ODP_AUTH_ALG_KASUMI_F9";
+ case ODP_AUTH_ALG_SNOW3G_UIA2:
+ return "ODP_AUTH_ALG_SNOW3G_UIA2";
+ case ODP_AUTH_ALG_AES_EIA2:
+ return "ODP_AUTH_ALG_AES_EIA2";
+ case ODP_AUTH_ALG_ZUC_EIA3:
+ return "ODP_AUTH_ALG_ZUC_EIA3";
+ case ODP_AUTH_ALG_MD5:
+ return "ODP_AUTH_ALG_MD5";
+ case ODP_AUTH_ALG_SHA1:
+ return "ODP_AUTH_ALG_SHA1";
+ case ODP_AUTH_ALG_SHA224:
+ return "ODP_AUTH_ALG_SHA224";
+ case ODP_AUTH_ALG_SHA256:
+ return "ODP_AUTH_ALG_SHA256";
+ case ODP_AUTH_ALG_SHA384:
+ return "ODP_AUTH_ALG_SHA384";
+ case ODP_AUTH_ALG_SHA512:
+ return "ODP_AUTH_ALG_SHA512";
+ default:
+ return "Unknown";
+ }
+}
+
+const char *cipher_alg_name(odp_cipher_alg_t cipher)
+{
+ switch (cipher) {
+ case ODP_CIPHER_ALG_NULL:
+ return "ODP_CIPHER_ALG_NULL";
+ case ODP_CIPHER_ALG_DES:
+ return "ODP_CIPHER_ALG_DES";
+ case ODP_CIPHER_ALG_3DES_CBC:
+ return "ODP_CIPHER_ALG_3DES_CBC";
+ case ODP_CIPHER_ALG_3DES_ECB:
+ return "ODP_CIPHER_ALG_3DES_ECB";
+ case ODP_CIPHER_ALG_AES_CBC:
+ return "ODP_CIPHER_ALG_AES_CBC";
+ case ODP_CIPHER_ALG_AES_CTR:
+ return "ODP_CIPHER_ALG_AES_CTR";
+ case ODP_CIPHER_ALG_AES_ECB:
+ return "ODP_CIPHER_ALG_AES_ECB";
+ case ODP_CIPHER_ALG_AES_CFB128:
+ return "ODP_CIPHER_ALG_AES_CFB128";
+ case ODP_CIPHER_ALG_AES_XTS:
+ return "ODP_CIPHER_ALG_AES_XTS";
+ case ODP_CIPHER_ALG_AES_GCM:
+ return "ODP_CIPHER_ALG_AES_GCM";
+ case ODP_CIPHER_ALG_AES_CCM:
+ return "ODP_CIPHER_ALG_AES_CCM";
+ case ODP_CIPHER_ALG_CHACHA20_POLY1305:
+ return "ODP_CIPHER_ALG_CHACHA20_POLY1305";
+ case ODP_CIPHER_ALG_KASUMI_F8:
+ return "ODP_CIPHER_ALG_KASUMI_F8";
+ case ODP_CIPHER_ALG_SNOW3G_UEA2:
+ return "ODP_CIPHER_ALG_SNOW3G_UEA2";
+ case ODP_CIPHER_ALG_AES_EEA2:
+ return "ODP_CIPHER_ALG_AES_EEA2";
+ case ODP_CIPHER_ALG_ZUC_EEA3:
+ return "ODP_CIPHER_ALG_ZUC_EEA3";
+ default:
+ return "Unknown";
+ }
+}
+
+int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth)
+{
+ odp_crypto_capability_t capability;
+
+ memset(&capability, 0, sizeof(odp_crypto_capability_t));
+ if (odp_crypto_capability(&capability)) {
+ ODPH_ERR("odp_crypto_capability() failed\n");
+ return ODP_TEST_INACTIVE;
+ }
+
+ if (suite_context.queue != ODP_QUEUE_INVALID) {
+ if (suite_context.q_type == ODP_QUEUE_TYPE_PLAIN &&
+ capability.queue_type_plain == 0)
+ return ODP_TEST_INACTIVE;
+ if (suite_context.q_type == ODP_QUEUE_TYPE_SCHED &&
+ capability.queue_type_sched == 0)
+ return ODP_TEST_INACTIVE;
+ }
+
+ if (suite_context.op_mode == ODP_CRYPTO_SYNC &&
+ capability.sync_mode == ODP_SUPPORT_NO)
+ return ODP_TEST_INACTIVE;
+ if (suite_context.op_mode == ODP_CRYPTO_ASYNC &&
+ capability.async_mode == ODP_SUPPORT_NO)
+ return ODP_TEST_INACTIVE;
+
+ /* Cipher algorithms */
+ switch (cipher) {
+ case ODP_CIPHER_ALG_NULL:
+ if (!capability.ciphers.bit.null)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_DES:
+ if (!capability.ciphers.bit.des)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_3DES_CBC:
+ if (!capability.ciphers.bit.trides_cbc)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_3DES_ECB:
+ if (!capability.ciphers.bit.trides_ecb)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_AES_CBC:
+ if (!capability.ciphers.bit.aes_cbc)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_AES_CTR:
+ if (!capability.ciphers.bit.aes_ctr)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_AES_ECB:
+ if (!capability.ciphers.bit.aes_ecb)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_AES_CFB128:
+ if (!capability.ciphers.bit.aes_cfb128)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_AES_XTS:
+ if (!capability.ciphers.bit.aes_xts)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_AES_GCM:
+ if (!capability.ciphers.bit.aes_gcm)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_AES_CCM:
+ if (!capability.ciphers.bit.aes_ccm)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_CHACHA20_POLY1305:
+ if (!capability.ciphers.bit.chacha20_poly1305)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_KASUMI_F8:
+ if (!capability.ciphers.bit.kasumi_f8)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_SNOW3G_UEA2:
+ if (!capability.ciphers.bit.snow3g_uea2)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_AES_EEA2:
+ if (!capability.ciphers.bit.aes_eea2)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_ZUC_EEA3:
+ if (!capability.ciphers.bit.zuc_eea3)
+ return ODP_TEST_INACTIVE;
+ break;
+ default:
+ ODPH_ERR("Unsupported cipher algorithm\n");
+ return ODP_TEST_INACTIVE;
+ }
+
+ /* Authentication algorithms */
+ switch (auth) {
+ case ODP_AUTH_ALG_NULL:
+ if (!capability.auths.bit.null)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_MD5_HMAC:
+ if (!capability.auths.bit.md5_hmac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA1_HMAC:
+ if (!capability.auths.bit.sha1_hmac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA224_HMAC:
+ if (!capability.auths.bit.sha224_hmac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA256_HMAC:
+ if (!capability.auths.bit.sha256_hmac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA384_HMAC:
+ if (!capability.auths.bit.sha384_hmac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA512_HMAC:
+ if (!capability.auths.bit.sha512_hmac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_AES_XCBC_MAC:
+ if (!capability.auths.bit.aes_xcbc_mac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_AES_GCM:
+ if (!capability.auths.bit.aes_gcm)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_AES_GMAC:
+ if (!capability.auths.bit.aes_gmac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_AES_CCM:
+ if (!capability.auths.bit.aes_ccm)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_AES_CMAC:
+ if (!capability.auths.bit.aes_cmac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_CHACHA20_POLY1305:
+ if (!capability.auths.bit.chacha20_poly1305)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_KASUMI_F9:
+ if (!capability.auths.bit.kasumi_f9)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SNOW3G_UIA2:
+ if (!capability.auths.bit.snow3g_uia2)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_AES_EIA2:
+ if (!capability.auths.bit.aes_eia2)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_ZUC_EIA3:
+ if (!capability.auths.bit.zuc_eia3)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_MD5:
+ if (!capability.auths.bit.md5)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA1:
+ if (!capability.auths.bit.sha1)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA224:
+ if (!capability.auths.bit.sha224)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA256:
+ if (!capability.auths.bit.sha256)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA384:
+ if (!capability.auths.bit.sha384)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA512:
+ if (!capability.auths.bit.sha512)
+ return ODP_TEST_INACTIVE;
+ break;
+ default:
+ ODPH_ERR("Unsupported authentication algorithm\n");
+ return ODP_TEST_INACTIVE;
+ }
+
+ return ODP_TEST_ACTIVE;
+}
+
diff --git a/test/validation/api/crypto/util.h b/test/validation/api/crypto/util.h
new file mode 100644
index 000000000..a81a56820
--- /dev/null
+++ b/test/validation/api/crypto/util.h
@@ -0,0 +1,50 @@
+/* Copyright (c) 2014-2018, Linaro Limited
+ * Copyright (c) 2021-2023, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef UTIL_H
+#define UTIL_H
+
+#include <stdint.h>
+#include <odp_api.h>
+#include <odp_cunit_common.h>
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+struct suite_context_s {
+ odp_crypto_op_mode_t op_mode;
+ odp_pool_t pool;
+ odp_queue_t queue;
+ odp_queue_type_t q_type;
+ odp_event_t (*compl_queue_deq)(void);
+};
+
+extern struct suite_context_s suite_context;
+
+const char *auth_alg_name(odp_auth_alg_t auth);
+
+const char *cipher_alg_name(odp_cipher_alg_t cipher);
+
+/*
+ * Check if given cipher and authentication algorithms are supported
+ *
+ * cipher Cipher algorithm
+ * auth Authentication algorithm
+ *
+ * returns ODP_TEST_ACTIVE when both algorithms are supported or
+ * ODP_TEST_INACTIVE when either algorithm is not supported
+ */
+int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth);
+
+static inline void fill_with_pattern(uint8_t *buf, uint32_t len)
+{
+ static uint8_t value;
+
+ for (uint32_t n = 0; n < len; n++)
+ buf[n] = value++;
+}
+
+#endif
diff --git a/test/validation/api/dma/dma.c b/test/validation/api/dma/dma.c
index ad42c9bb3..6c8eeb00c 100644
--- a/test/validation/api/dma/dma.c
+++ b/test/validation/api/dma/dma.c
@@ -101,7 +101,7 @@ static int dma_suite_init(void)
pkt_len = MIN(pkt_len, global.dma_capa.max_seg_len);
odp_pool_param_init(&pool_param);
pool_param.type = ODP_POOL_PACKET;
- pool_param.pkt.num = 4;
+ pool_param.pkt.num = global.dma_capa.max_src_segs + global.dma_capa.max_dst_segs;
pool_param.pkt.len = pkt_len;
pool_param.pkt.max_len = pkt_len;
@@ -173,7 +173,7 @@ static int dma_suite_term(void)
return -1;
}
- return 0;
+ return odp_cunit_print_inactive();
}
static void test_dma_capability(void)
@@ -234,6 +234,7 @@ static void test_dma_param(uint8_t fill)
memset(&dma_pool_param, fill, sizeof(dma_pool_param));
odp_dma_pool_param_init(&dma_pool_param);
+ CU_ASSERT(dma_pool_param.uarea_size == 0);
CU_ASSERT(dma_pool_param.cache_size <= global.dma_capa.pool.max_cache_size);
CU_ASSERT(dma_pool_param.cache_size >= global.dma_capa.pool.min_cache_size);
}
@@ -269,6 +270,54 @@ static void test_dma_debug(void)
CU_ASSERT(odp_dma_destroy(dma) == 0);
}
+static void test_dma_same_name_null(void)
+{
+ odp_dma_param_t dma_param;
+ odp_dma_t dma_a, dma_b;
+
+ odp_dma_param_init(&dma_param);
+ dma_param.compl_mode_mask = ODP_DMA_COMPL_SYNC;
+ dma_a = odp_dma_create(NULL, &dma_param);
+
+ CU_ASSERT_FATAL(dma_a != ODP_DMA_INVALID);
+
+ dma_b = odp_dma_create(NULL, &dma_param);
+
+ CU_ASSERT_FATAL(dma_b != ODP_DMA_INVALID);
+ CU_ASSERT(odp_dma_to_u64(dma_a) != odp_dma_to_u64(dma_b));
+ CU_ASSERT(odp_dma_destroy(dma_a) == 0);
+ CU_ASSERT(odp_dma_destroy(dma_b) == 0);
+}
+
+static void test_dma_same_name_named(void)
+{
+ odp_dma_param_t dma_param;
+ const char *name = "DMA session";
+ odp_dma_t dma, dma_a, dma_b;
+
+ odp_dma_param_init(&dma_param);
+ dma_param.compl_mode_mask = ODP_DMA_COMPL_SYNC;
+ dma_a = odp_dma_create(name, &dma_param);
+
+ CU_ASSERT_FATAL(dma_a != ODP_DMA_INVALID);
+
+ dma = odp_dma_lookup(name);
+
+ CU_ASSERT(odp_dma_to_u64(dma) == odp_dma_to_u64(dma_a));
+
+ dma_b = odp_dma_create(name, &dma_param);
+
+ CU_ASSERT_FATAL(dma_b != ODP_DMA_INVALID);
+
+ dma = odp_dma_lookup(name);
+
+ CU_ASSERT(odp_dma_to_u64(dma) == odp_dma_to_u64(dma_a) ||
+ odp_dma_to_u64(dma) == odp_dma_to_u64(dma_b));
+ CU_ASSERT(odp_dma_to_u64(dma_a) != odp_dma_to_u64(dma_b));
+ CU_ASSERT(odp_dma_destroy(dma_a) == 0);
+ CU_ASSERT(odp_dma_destroy(dma_b) == 0);
+}
+
static void test_dma_compl_pool(void)
{
odp_pool_t pool;
@@ -291,6 +340,7 @@ static void test_dma_compl_pool(void)
CU_ASSERT(pool_info.pool_ext == 0);
CU_ASSERT(pool_info.type == ODP_POOL_DMA_COMPL);
CU_ASSERT(pool_info.dma_pool_param.num == global.dma_capa.max_transfers);
+ CU_ASSERT(pool_info.dma_pool_param.uarea_size == 0);
CU_ASSERT(pool_info.dma_pool_param.cache_size == global.cache_size);
for (i = 0; i < global.dma_capa.max_transfers; i++) {
@@ -364,6 +414,50 @@ static void test_dma_compl_pool_max_pools(void)
}
}
+static void test_dma_compl_user_area(void)
+{
+ odp_dma_pool_param_t dma_pool_param;
+ uint32_t num = MIN(10, global.dma_capa.pool.max_num),
+ size = global.dma_capa.pool.max_uarea_size, i;
+ odp_pool_t pool;
+ odp_dma_compl_t compl_evs[num];
+ void *addr, *prev = NULL;
+
+ odp_dma_pool_param_init(&dma_pool_param);
+ dma_pool_param.num = num;
+ dma_pool_param.uarea_size = size;
+ pool = odp_dma_pool_create(NULL, &dma_pool_param);
+
+ CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+ for (i = 0; i < num; i++) {
+ odp_event_t ev;
+
+ compl_evs[i] = odp_dma_compl_alloc(pool);
+
+ if (compl_evs[i] == ODP_DMA_COMPL_INVALID)
+ break;
+
+ addr = odp_dma_compl_user_area(compl_evs[i]);
+
+ CU_ASSERT_FATAL(addr != NULL);
+ CU_ASSERT(prev != addr);
+
+ ev = odp_dma_compl_to_event(compl_evs[i]);
+ CU_ASSERT(odp_event_user_area(ev) == addr);
+
+ prev = addr;
+ memset(addr, 0, size);
+ }
+
+ CU_ASSERT(i == num);
+
+ for (uint32_t j = 0; j < i; j++)
+ odp_dma_compl_free(compl_evs[j]);
+
+ CU_ASSERT(odp_pool_destroy(pool) == 0);
+}
+
static void init_source(uint8_t *src, uint32_t len)
{
uint32_t i;
@@ -1043,6 +1137,17 @@ static int check_sync(void)
return ODP_TEST_ACTIVE;
}
+static int check_session_count(void)
+{
+ if (global.disabled)
+ return ODP_TEST_INACTIVE;
+
+ if (global.dma_capa.max_sessions > 1)
+ return ODP_TEST_ACTIVE;
+
+ return ODP_TEST_INACTIVE;
+}
+
static int check_event(void)
{
if (global.disabled)
@@ -1054,6 +1159,18 @@ static int check_event(void)
return ODP_TEST_INACTIVE;
}
+static int check_event_user_area(void)
+{
+ if (global.disabled)
+ return ODP_TEST_INACTIVE;
+
+ if ((global.dma_capa.compl_mode_mask & ODP_DMA_COMPL_EVENT) &&
+ global.dma_capa.pool.max_uarea_size > 0)
+ return ODP_TEST_ACTIVE;
+
+ return ODP_TEST_INACTIVE;
+}
+
static int check_scheduled(void)
{
if (global.disabled)
@@ -1126,6 +1243,72 @@ static void test_dma_addr_to_addr_sync_res(void)
test_dma_addr_to_addr(ODP_DMA_COMPL_SYNC, 1, 0, RESULT);
}
+static void get_seg_lens(uint32_t max_len, uint32_t *src, uint32_t *dst)
+{
+ uint32_t src_segs = *src, dst_segs = *dst;
+
+ *src = max_len / src_segs;
+ *dst = *src * src_segs / dst_segs + *src * src_segs % dst_segs;
+}
+
+static void test_dma_addr_to_addr_sync_max_seg(void)
+{
+ odp_dma_param_t dma_param;
+ odp_dma_transfer_param_t trs_param;
+ odp_dma_t dma;
+ odp_dma_seg_t src_seg[global.dma_capa.max_src_segs];
+ odp_dma_seg_t dst_seg[global.dma_capa.max_dst_segs];
+ uint32_t src_len = global.dma_capa.max_src_segs, dst_len = global.dma_capa.max_dst_segs,
+ len;
+ int ret;
+
+ init_source(global.src_addr, global.data_size);
+ memset(global.dst_addr, 0, global.data_size);
+ odp_dma_param_init(&dma_param);
+ dma_param.compl_mode_mask = ODP_DMA_COMPL_SYNC;
+ dma = odp_dma_create("addr_to_addr_max_seg", &dma_param);
+
+ CU_ASSERT_FATAL(dma != ODP_DMA_INVALID);
+
+ get_seg_lens(global.len, &src_len, &dst_len);
+
+ for (uint32_t i = 0; i < global.dma_capa.max_src_segs; i++) {
+ uint8_t *addr = global.src_addr + i * src_len;
+
+ memset(&src_seg[i], 0, sizeof(odp_dma_seg_t));
+ src_seg[i].addr = addr;
+ src_seg[i].len = src_len;
+ }
+
+ len = src_len * global.dma_capa.max_src_segs;
+
+ for (uint32_t i = 0; i < global.dma_capa.max_dst_segs; i++) {
+ uint8_t *addr = global.dst_addr + i * dst_len;
+
+ memset(&dst_seg[i], 0, sizeof(odp_dma_seg_t));
+ dst_seg[i].addr = addr;
+ dst_seg[i].len = MIN(len, dst_len);
+ len -= dst_len;
+ }
+
+ odp_dma_transfer_param_init(&trs_param);
+ trs_param.src_format = ODP_DMA_FORMAT_ADDR;
+ trs_param.dst_format = ODP_DMA_FORMAT_ADDR;
+ trs_param.num_src = global.dma_capa.max_src_segs;
+ trs_param.num_dst = global.dma_capa.max_dst_segs;
+ trs_param.src_seg = src_seg;
+ trs_param.dst_seg = dst_seg;
+ ret = do_transfer(dma, &trs_param, 0, 0);
+
+ if (ret > 0) {
+ len = src_len * global.dma_capa.max_src_segs;
+
+ CU_ASSERT(check_equal(global.src_addr, global.dst_addr, len) == 0);
+ }
+
+ CU_ASSERT(odp_dma_destroy(dma) == 0);
+}
+
static void test_dma_addr_to_pkt_sync(void)
{
test_dma_addr_to_pkt(ODP_DMA_COMPL_SYNC, 0);
@@ -1141,6 +1324,87 @@ static void test_dma_pkt_to_pkt_sync(void)
test_dma_pkt_to_pkt(ODP_DMA_COMPL_SYNC, 0);
}
+static void test_dma_pkt_to_pkt_sync_max_seg(void)
+{
+ odp_dma_param_t dma_param;
+ odp_dma_transfer_param_t trs_param;
+ odp_dma_t dma;
+ odp_packet_t pkt;
+ odp_dma_seg_t src_seg[global.dma_capa.max_src_segs];
+ odp_dma_seg_t dst_seg[global.dma_capa.max_dst_segs];
+ uint32_t src_len = global.dma_capa.max_src_segs, dst_len = global.dma_capa.max_dst_segs,
+ len;
+ int ret;
+
+ odp_dma_param_init(&dma_param);
+ dma_param.compl_mode_mask = ODP_DMA_COMPL_SYNC;
+ dma = odp_dma_create("pkt_to_pkt_max_seg", &dma_param);
+
+ CU_ASSERT_FATAL(dma != ODP_DMA_INVALID);
+
+ pkt = odp_packet_alloc(global.pkt_pool, global.pkt_len);
+
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+
+ get_seg_lens(odp_packet_seg_len(pkt), &src_len, &dst_len);
+ odp_packet_free(pkt);
+
+ for (uint32_t i = 0; i < global.dma_capa.max_src_segs; i++) {
+ pkt = odp_packet_alloc(global.pkt_pool, src_len);
+
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+
+ init_source(odp_packet_data(pkt), src_len);
+ memset(&src_seg[i], 0, sizeof(odp_dma_seg_t));
+ src_seg[i].packet = pkt;
+ src_seg[i].len = src_len;
+ }
+
+ len = src_len * global.dma_capa.max_src_segs;
+
+ for (uint32_t i = 0; i < global.dma_capa.max_dst_segs; i++) {
+ pkt = odp_packet_alloc(global.pkt_pool, dst_len);
+
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+
+ memset(odp_packet_data(pkt), 0, dst_len);
+ memset(&dst_seg[i], 0, sizeof(odp_dma_seg_t));
+ dst_seg[i].packet = pkt;
+ dst_seg[i].len = MIN(len, dst_len);
+ len -= dst_len;
+ }
+
+ odp_dma_transfer_param_init(&trs_param);
+ trs_param.src_format = ODP_DMA_FORMAT_PACKET;
+ trs_param.dst_format = ODP_DMA_FORMAT_PACKET;
+ trs_param.num_src = global.dma_capa.max_src_segs;
+ trs_param.num_dst = global.dma_capa.max_dst_segs;
+ trs_param.src_seg = src_seg;
+ trs_param.dst_seg = dst_seg;
+ ret = do_transfer(dma, &trs_param, 0, 0);
+
+ if (ret > 0) {
+ len = src_len * global.dma_capa.max_src_segs;
+ uint8_t src[len], dst[len];
+
+ for (uint32_t i = 0; i < global.dma_capa.max_src_segs; i++) {
+ memcpy(src + i * src_len, odp_packet_data(src_seg[i].packet),
+ src_seg[i].len);
+ odp_packet_free(src_seg[i].packet);
+ }
+
+ for (uint32_t i = 0; i < global.dma_capa.max_dst_segs; i++) {
+ memcpy(dst + i * dst_len, odp_packet_data(dst_seg[i].packet),
+ dst_seg[i].len);
+ odp_packet_free(dst_seg[i].packet);
+ }
+
+ CU_ASSERT(check_equal(src, dst, len) == 0);
+ }
+
+ CU_ASSERT(odp_dma_destroy(dma) == 0);
+}
+
static void test_dma_addr_to_addr_poll(void)
{
test_dma_addr_to_addr(ODP_DMA_COMPL_POLL, 1, 0, 0);
@@ -1298,16 +1562,21 @@ odp_testinfo_t dma_suite[] = {
ODP_TEST_INFO(test_dma_capability),
ODP_TEST_INFO_CONDITIONAL(test_dma_param_init, check_sync),
ODP_TEST_INFO_CONDITIONAL(test_dma_debug, check_sync),
+ ODP_TEST_INFO_CONDITIONAL(test_dma_same_name_null, check_session_count),
+ ODP_TEST_INFO_CONDITIONAL(test_dma_same_name_named, check_session_count),
ODP_TEST_INFO_CONDITIONAL(test_dma_compl_pool, check_event),
ODP_TEST_INFO_CONDITIONAL(test_dma_compl_pool_same_name, check_event),
ODP_TEST_INFO_CONDITIONAL(test_dma_compl_pool_max_pools, check_event),
+ ODP_TEST_INFO_CONDITIONAL(test_dma_compl_user_area, check_event_user_area),
ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_sync, check_sync),
ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_sync_mtrs, check_sync),
ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_sync_mseg, check_sync),
ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_sync_res, check_sync),
+ ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_sync_max_seg, check_sync),
ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_pkt_sync, check_sync),
ODP_TEST_INFO_CONDITIONAL(test_dma_pkt_to_addr_sync, check_sync),
ODP_TEST_INFO_CONDITIONAL(test_dma_pkt_to_pkt_sync, check_sync),
+ ODP_TEST_INFO_CONDITIONAL(test_dma_pkt_to_pkt_sync_max_seg, check_sync),
ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_poll, check_poll),
ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_poll_mtrs, check_poll),
ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_poll_mseg, check_poll),
diff --git a/test/validation/api/init/.gitignore b/test/validation/api/init/.gitignore
index e312d2cf6..4e14eb040 100644
--- a/test/validation/api/init/.gitignore
+++ b/test/validation/api/init/.gitignore
@@ -6,3 +6,4 @@ init_num_thr
init_feature_enabled
init_feature_disabled
init_test_param_init
+init_test_term_abnormal
diff --git a/test/validation/api/init/Makefile.am b/test/validation/api/init/Makefile.am
index 1ddf1dd0d..8226b87ce 100644
--- a/test/validation/api/init/Makefile.am
+++ b/test/validation/api/init/Makefile.am
@@ -4,7 +4,7 @@ include ../Makefile.inc
# the same application process to call odp_init_global() multiple times.
test_PROGRAMS = init_defaults init_abort init_log init_num_thr \
init_feature_enabled init_feature_disabled init_log_thread \
- init_test_param_init
+ init_test_param_init init_test_term_abnormal
init_defaults_CPPFLAGS = -DINIT_TEST=0 $(AM_CPPFLAGS)
init_abort_CPPFLAGS = -DINIT_TEST=1 $(AM_CPPFLAGS)
@@ -14,6 +14,7 @@ init_feature_enabled_CPPFLAGS = -DINIT_TEST=4 $(AM_CPPFLAGS)
init_feature_disabled_CPPFLAGS = -DINIT_TEST=5 $(AM_CPPFLAGS)
init_log_thread_CPPFLAGS = -DINIT_TEST=6 $(AM_CPPFLAGS)
init_test_param_init_CPPFLAGS = -DINIT_TEST=7 $(AM_CPPFLAGS)
+init_test_term_abnormal_CPPFLAGS = -DINIT_TEST=8 $(AM_CPPFLAGS)
init_defaults_SOURCES = init_main.c
init_abort_SOURCES = init_main.c
@@ -23,3 +24,4 @@ init_feature_enabled_SOURCES = init_main.c
init_feature_disabled_SOURCES = init_main.c
init_log_thread_SOURCES = init_main.c
init_test_param_init_SOURCES = init_main.c
+init_test_term_abnormal_SOURCES = init_main.c
diff --git a/test/validation/api/init/init_main.c b/test/validation/api/init/init_main.c
index 5cbaf72eb..c3dba105e 100644
--- a/test/validation/api/init/init_main.c
+++ b/test/validation/api/init/init_main.c
@@ -1,11 +1,12 @@
/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
+ * Copyright (c) 2019-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <odp_api.h>
+#include <odp/helper/odph_api.h>
#include <odp_cunit_common.h>
#include <stdarg.h>
@@ -241,6 +242,24 @@ static void init_test_feature_disabled(void)
init_test_feature(1);
}
+static void init_test_term_abnormal(void)
+{
+ int ret;
+ odp_instance_t instance;
+
+ ret = odp_init_global(&instance, NULL, NULL);
+ CU_ASSERT_FATAL(ret == 0);
+
+ ret = odp_init_local(instance, ODP_THREAD_WORKER);
+ CU_ASSERT_FATAL(ret == 0);
+
+ /* odp_term_abnormal() is allowed to fail */
+ ret = odp_term_abnormal(instance, 0, NULL);
+
+ if (ret < 0)
+ ODPH_ERR("Failed to perform all abnormal termination actions: %d\n", ret);
+}
+
odp_testinfo_t testinfo[] = {
ODP_TEST_INFO(init_test_defaults),
ODP_TEST_INFO(init_test_abort),
@@ -250,6 +269,7 @@ odp_testinfo_t testinfo[] = {
ODP_TEST_INFO(init_test_feature_disabled),
ODP_TEST_INFO(init_test_log_thread),
ODP_TEST_INFO(init_test_param_init),
+ ODP_TEST_INFO(init_test_term_abnormal)
};
odp_testinfo_t init_suite[] = {
@@ -265,7 +285,7 @@ odp_suiteinfo_t init_suites[] = {
static int fill_testinfo(odp_testinfo_t *info, unsigned int test_case)
{
if (test_case >= (sizeof(testinfo) / sizeof(odp_testinfo_t))) {
- printf("Bad test case number %u\n", test_case);
+ ODPH_ERR("Bad test case number %u\n", test_case);
return -1;
}
diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c
index 11860bf9b..ea2685666 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -57,12 +57,12 @@ static odp_pktio_t pktio_create(odp_pool_t pool)
if (pktio == ODP_PKTIO_INVALID) {
ret = odp_pool_destroy(pool);
if (ret)
- fprintf(stderr, "unable to destroy pool.\n");
+ ODPH_ERR("Unable to destroy pool\n");
return ODP_PKTIO_INVALID;
}
if (odp_pktio_capability(pktio, &capa)) {
- fprintf(stderr, "pktio capabilities failed.\n");
+ ODPH_ERR("Pktio capabilities failed\n");
return ODP_PKTIO_INVALID;
}
@@ -70,12 +70,12 @@ static odp_pktio_t pktio_create(odp_pool_t pool)
pktin_param.queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC;
if (odp_pktin_queue_config(pktio, &pktin_param)) {
- fprintf(stderr, "pktin queue config failed.\n");
+ ODPH_ERR("Pktin queue config failed\n");
return ODP_PKTIO_INVALID;
}
if (odp_pktout_queue_config(pktio, NULL)) {
- fprintf(stderr, "pktout queue config failed.\n");
+ ODPH_ERR("Pktout queue config failed\n");
return ODP_PKTIO_INVALID;
}
@@ -213,7 +213,7 @@ static void pktio_stop(odp_pktio_t pktio)
odp_pktin_event_queue(pktio, &queue, 1);
if (odp_pktio_stop(pktio))
- fprintf(stderr, "IPsec pktio stop failed.\n");
+ ODPH_ERR("IPsec pktio stop failed\n");
while (1) {
odp_event_t ev = recv_event(queue, 0);
@@ -266,7 +266,7 @@ int ipsec_check(odp_bool_t ah,
if (ah && (ODP_SUPPORT_NO == capa.proto_ah))
return ODP_TEST_INACTIVE;
- if (odph_ipsec_alg_check(capa, cipher, cipher_bits / 8, auth,
+ if (odph_ipsec_alg_check(&capa, cipher, cipher_bits / 8, auth,
auth_bits / 8) < 0)
return ODP_TEST_INACTIVE;
@@ -395,7 +395,10 @@ void ipsec_sa_param_fill(odp_ipsec_sa_param_t *param,
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;
+ if (auth_alg == ODP_AUTH_ALG_NULL)
+ param->inbound.antireplay_ws = 0;
+ else
+ param->inbound.antireplay_ws = capa.max_antireplay_ws;
}
param->proto = proto;
@@ -455,6 +458,9 @@ static void ipsec_status_event_handle(odp_event_t ev_status,
CU_ASSERT_EQUAL(1, odp_event_is_valid(ev_status));
CU_ASSERT_EQUAL_FATAL(ODP_EVENT_IPSEC_STATUS, odp_event_type(ev_status));
+ /* No user area for IPsec status events */
+ CU_ASSERT(odp_event_user_area(ev_status) == NULL);
+
CU_ASSERT_EQUAL(0, odp_ipsec_status(&status, ev_status));
CU_ASSERT_EQUAL(ODP_IPSEC_STATUS_WARN, status.id);
CU_ASSERT_EQUAL(sa, status.sa);
@@ -1276,7 +1282,7 @@ int ipsec_suite_term(void)
if (ODP_QUEUE_INVALID != suite_context.queue) {
if (odp_queue_destroy(suite_context.queue))
- fprintf(stderr, "IPsec destq destroy failed.\n");
+ ODPH_ERR("IPsec destq destroy failed\n");
}
if (odp_cunit_print_inactive())
@@ -1329,7 +1335,7 @@ int ipsec_suite_plain_init(void)
dest_queue = plain_queue_create("ipsec-out");
if (ODP_QUEUE_INVALID == dest_queue) {
- fprintf(stderr, "IPsec destq creation failed.\n");
+ ODPH_ERR("IPsec destq creation failed\n");
return -1;
}
@@ -1345,7 +1351,7 @@ int ipsec_suite_sched_init(void)
dest_queue = sched_queue_create("ipsec-out");
if (ODP_QUEUE_INVALID == dest_queue) {
- fprintf(stderr, "IPsec destq creation failed.\n");
+ ODPH_ERR("IPsec destq creation failed\n");
return -1;
}
@@ -1371,7 +1377,7 @@ int ipsec_init(odp_instance_t *inst, odp_ipsec_op_mode_t mode)
suite_context.default_queue = ODP_QUEUE_INVALID;
if (odph_options(&helper_options)) {
- fprintf(stderr, "error: odph_options() failed.\n");
+ ODPH_ERR("odph_options() failed\n");
return -1;
}
@@ -1379,22 +1385,22 @@ int ipsec_init(odp_instance_t *inst, odp_ipsec_op_mode_t mode)
init_param.mem_model = helper_options.mem_model;
if (0 != odp_init_global(inst, &init_param, NULL)) {
- fprintf(stderr, "error: odp_init_global() failed.\n");
+ ODPH_ERR("odp_init_global() failed\n");
return -1;
}
if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) {
- fprintf(stderr, "error: odp_init_local() failed.\n");
+ ODPH_ERR("odp_init_local() failed\n");
return -1;
}
if (odp_schedule_config(NULL)) {
- fprintf(stderr, "odp_schedule_config() failed.\n");
+ ODPH_ERR("odp_schedule_config() failed\n");
return -1;
}
if (odp_pool_capability(&pool_capa) < 0) {
- fprintf(stderr, "error: odp_pool_capability() failed.\n");
+ ODPH_ERR("odp_pool_capability() failed\n");
return -1;
}
@@ -1406,27 +1412,27 @@ int ipsec_init(odp_instance_t *inst, odp_ipsec_op_mode_t mode)
if (pool_capa.pkt.max_seg_len &&
MAX_PKT_LEN > pool_capa.pkt.max_seg_len) {
- fprintf(stderr, "Warning: small packet segment length\n");
+ ODPH_ERR("Warning: small packet segment length\n");
params.pkt.seg_len = pool_capa.pkt.max_seg_len;
}
if (pool_capa.pkt.max_len &&
MAX_PKT_LEN > pool_capa.pkt.max_len) {
- fprintf(stderr, "Pool max packet length too small\n");
+ ODPH_ERR("Pool max packet length too small\n");
return -1;
}
pool = odp_pool_create("packet_pool", &params);
if (ODP_POOL_INVALID == pool) {
- fprintf(stderr, "Packet pool creation failed.\n");
+ ODPH_ERR("Packet pool creation failed\n");
return -1;
}
if (mode == ODP_IPSEC_OP_MODE_INLINE) {
pktio = pktio_create(pool);
if (ODP_PKTIO_INVALID == pktio) {
- fprintf(stderr, "IPsec pktio creation failed.\n");
+ ODPH_ERR("IPsec pktio creation failed\n");
return -1;
}
}
@@ -1466,7 +1472,7 @@ int ipsec_config(odp_instance_t ODP_UNUSED inst)
suite_context.default_queue = sched_queue_create("ipsec-default");
if (ODP_QUEUE_INVALID == suite_context.default_queue) {
- fprintf(stderr, "IPsec defaultq creation failed.\n");
+ ODPH_ERR("IPsec defaultq creation failed\n");
return -1;
}
}
@@ -1561,26 +1567,26 @@ int ipsec_term(odp_instance_t inst)
if (ODP_PKTIO_INVALID != pktio) {
if (odp_pktio_close(pktio))
- fprintf(stderr, "IPsec pktio close failed.\n");
+ ODPH_ERR("IPsec pktio close failed\n");
}
if (ODP_QUEUE_INVALID != default_queue) {
if (odp_queue_destroy(default_queue))
- fprintf(stderr, "IPsec defaultq destroy failed.\n");
+ ODPH_ERR("IPsec defaultq destroy failed\n");
}
if (ODP_POOL_INVALID != pool) {
if (odp_pool_destroy(pool))
- fprintf(stderr, "Packet pool destroy failed.\n");
+ ODPH_ERR("Packet pool destroy failed\n");
}
if (0 != odp_term_local()) {
- fprintf(stderr, "error: odp_term_local() failed.\n");
+ ODPH_ERR("odp_term_local() failed\n");
return -1;
}
if (0 != odp_term_global(inst)) {
- fprintf(stderr, "error: odp_term_global() failed.\n");
+ ODPH_ERR("odp_term_global() failed\n");
return -1;
}
diff --git a/test/validation/api/lock/lock.c b/test/validation/api/lock/lock.c
index 729994d66..5210f7e5d 100644
--- a/test/validation/api/lock/lock.c
+++ b/test/validation/api/lock/lock.c
@@ -569,12 +569,12 @@ static int spinlock_functional_test(void *arg UNUSED)
if ((global_mem->g_verbose) &&
((sync_failures != 0) || (is_locked_errs != 0)))
- printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32
- " sync_failures and %" PRIu32
- " is_locked_errs in %" PRIu32
- " iterations\n", thread_num,
- per_thread_mem->thread_id, per_thread_mem->thread_core,
- sync_failures, is_locked_errs, iterations);
+ ODPH_ERR("Thread %" PRIu32 " (id=%d core=%d) had %" PRIu32
+ " sync_failures and %" PRIu32
+ " is_locked_errs in %" PRIu32
+ " iterations\n", thread_num,
+ per_thread_mem->thread_id, per_thread_mem->thread_core,
+ sync_failures, is_locked_errs, iterations);
CU_ASSERT(sync_failures == 0);
CU_ASSERT(is_locked_errs == 0);
@@ -675,14 +675,14 @@ static int spinlock_recursive_functional_test(void *arg UNUSED)
if ((global_mem->g_verbose) &&
(sync_failures != 0 || recursive_errs != 0 || is_locked_errs != 0))
- printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32
- " sync_failures and %" PRIu32
- " recursive_errs and %" PRIu32
- " is_locked_errs in %" PRIu32
- " iterations\n", thread_num,
- per_thread_mem->thread_id, per_thread_mem->thread_core,
- sync_failures, recursive_errs, is_locked_errs,
- iterations);
+ ODPH_ERR("Thread %" PRIu32 " (id=%d core=%d) had %" PRIu32
+ " sync_failures and %" PRIu32
+ " recursive_errs and %" PRIu32
+ " is_locked_errs in %" PRIu32
+ " iterations\n", thread_num,
+ per_thread_mem->thread_id, per_thread_mem->thread_core,
+ sync_failures, recursive_errs, is_locked_errs,
+ iterations);
CU_ASSERT(sync_failures == 0);
CU_ASSERT(recursive_errs == 0);
@@ -765,12 +765,12 @@ static int ticketlock_functional_test(void *arg UNUSED)
if ((global_mem->g_verbose) &&
((sync_failures != 0) || (is_locked_errs != 0)))
- printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32
- " sync_failures and %" PRIu32
- " is_locked_errs in %" PRIu32 " iterations\n",
- thread_num,
- per_thread_mem->thread_id, per_thread_mem->thread_core,
- sync_failures, is_locked_errs, iterations);
+ ODPH_ERR("Thread %" PRIu32 " (id=%d core=%d) had %" PRIu32
+ " sync_failures and %" PRIu32
+ " is_locked_errs in %" PRIu32 " iterations\n",
+ thread_num,
+ per_thread_mem->thread_id, per_thread_mem->thread_core,
+ sync_failures, is_locked_errs, iterations);
CU_ASSERT(sync_failures == 0);
CU_ASSERT(is_locked_errs == 0);
@@ -858,11 +858,11 @@ static int rwlock_functional_test(void *arg UNUSED)
}
if ((global_mem->g_verbose) && (sync_failures != 0))
- printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32
- " sync_failures in %" PRIu32 " iterations\n", thread_num,
- per_thread_mem->thread_id,
- per_thread_mem->thread_core,
- sync_failures, iterations);
+ ODPH_ERR("Thread %" PRIu32 " (id=%d core=%d) had %" PRIu32
+ " sync_failures in %" PRIu32 " iterations\n", thread_num,
+ per_thread_mem->thread_id,
+ per_thread_mem->thread_core,
+ sync_failures, iterations);
CU_ASSERT(sync_failures == 0);
@@ -985,13 +985,13 @@ static int rwlock_recursive_functional_test(void *arg UNUSED)
}
if ((global_mem->g_verbose) && (sync_failures != 0))
- printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32
- " sync_failures and %" PRIu32
- " recursive_errs in %" PRIu32
- " iterations\n", thread_num,
- per_thread_mem->thread_id,
- per_thread_mem->thread_core,
- sync_failures, recursive_errs, iterations);
+ ODPH_ERR("Thread %" PRIu32 " (id=%d core=%d) had %" PRIu32
+ " sync_failures and %" PRIu32
+ " recursive_errs in %" PRIu32
+ " iterations\n", thread_num,
+ per_thread_mem->thread_id,
+ per_thread_mem->thread_core,
+ sync_failures, recursive_errs, iterations);
CU_ASSERT(sync_failures == 0);
CU_ASSERT(recursive_errs == 0);
@@ -1153,7 +1153,7 @@ static int lock_init(odp_instance_t *inst)
odph_helper_options_t helper_options;
if (odph_options(&helper_options)) {
- fprintf(stderr, "error: odph_options() failed.\n");
+ ODPH_ERR("odph_options() failed\n");
return -1;
}
@@ -1161,18 +1161,18 @@ static int lock_init(odp_instance_t *inst)
init_param.mem_model = helper_options.mem_model;
if (0 != odp_init_global(inst, &init_param, NULL)) {
- fprintf(stderr, "error: odp_init_global() failed.\n");
+ ODPH_ERR("odp_init_global() failed\n");
return -1;
}
if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) {
- fprintf(stderr, "error: odp_init_local() failed.\n");
+ ODPH_ERR("odp_init_local() failed\n");
return -1;
}
global_shm = odp_shm_reserve(GLOBAL_SHM_NAME,
sizeof(global_shared_mem_t), 64, 0);
if (ODP_SHM_INVALID == global_shm) {
- fprintf(stderr, "Unable reserve memory for global_shm\n");
+ ODPH_ERR("Unable to reserve memory for global_shm\n");
return -1;
}
@@ -1208,17 +1208,17 @@ static int lock_term(odp_instance_t inst)
shm = odp_shm_lookup(GLOBAL_SHM_NAME);
if (0 != odp_shm_free(shm)) {
- fprintf(stderr, "error: odp_shm_free() failed.\n");
+ ODPH_ERR("odp_shm_free() failed\n");
return -1;
}
if (0 != odp_term_local()) {
- fprintf(stderr, "error: odp_term_local() failed.\n");
+ ODPH_ERR("odp_term_local() failed\n");
return -1;
}
if (0 != odp_term_global(inst)) {
- fprintf(stderr, "error: odp_term_global() failed.\n");
+ ODPH_ERR("odp_term_global() failed\n");
return -1;
}
diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c
index c654aa055..a7631d47c 100644
--- a/test/validation/api/packet/packet.c
+++ b/test/validation/api/packet/packet.c
@@ -200,7 +200,7 @@ static int packet_suite_init(void)
memset(&pool_capa, 0, sizeof(odp_pool_capability_t));
if (odp_pool_capability(&pool_capa) < 0) {
- printf("pool_capability failed\n");
+ ODPH_ERR("odp_pool_capability() failed\n");
return -1;
}
@@ -246,14 +246,14 @@ static int packet_suite_init(void)
default_pool = odp_pool_create("default_pool", &params);
if (default_pool == ODP_POOL_INVALID) {
- printf("default pool create failed\n");
+ ODPH_ERR("Default pool create failed\n");
return -1;
}
test_packet = odp_packet_alloc(default_pool, packet_len);
if (test_packet == ODP_PACKET_INVALID) {
- printf("test_packet alloc failed\n");
+ ODPH_ERR("Packet alloc failed\n");
return -1;
}
@@ -277,7 +277,7 @@ static int packet_suite_init(void)
segmented_packet_len > pool_capa.pkt.min_seg_len);
if (ret != PACKET_POOL_NUM_SEG) {
- printf("packet alloc failed\n");
+ ODPH_ERR("Packet alloc failed\n");
return -1;
}
segmented_test_packet = pkt_tbl[0];
@@ -285,7 +285,7 @@ static int packet_suite_init(void)
if (odp_packet_is_valid(test_packet) == 0 ||
odp_packet_is_valid(segmented_test_packet) == 0) {
- printf("packet_is_valid failed\n");
+ ODPH_ERR("odp_packet_is_valid() failed\n");
return -1;
}
@@ -299,7 +299,7 @@ static int packet_suite_init(void)
udat = odp_packet_user_area(test_packet);
if (odp_packet_user_area_size(test_packet) < uarea_size) {
- printf("Bad packet user area size %u\n", odp_packet_user_area_size(test_packet));
+ ODPH_ERR("Bad packet user area size %u\n", odp_packet_user_area_size(test_packet));
return -1;
}
@@ -308,8 +308,8 @@ static int packet_suite_init(void)
udat = odp_packet_user_area(segmented_test_packet);
if (odp_packet_user_area_size(segmented_test_packet) < uarea_size) {
- printf("Bad segmented packet user area size %u\n",
- odp_packet_user_area_size(segmented_test_packet));
+ ODPH_ERR("Bad segmented packet user area size %u\n",
+ odp_packet_user_area_size(segmented_test_packet));
return -1;
}
@@ -873,6 +873,12 @@ static void packet_test_basic_metadata(void)
CU_ASSERT(!odp_time_cmp(ts, odp_packet_ts(pkt)));
odp_packet_has_ts_clr(pkt);
CU_ASSERT(!odp_packet_has_ts(pkt));
+
+ CU_ASSERT(odp_packet_free_ctrl(pkt) == ODP_PACKET_FREE_CTRL_DISABLED);
+ odp_packet_free_ctrl_set(pkt, ODP_PACKET_FREE_CTRL_DONT_FREE);
+ CU_ASSERT(odp_packet_free_ctrl(pkt) == ODP_PACKET_FREE_CTRL_DONT_FREE);
+ odp_packet_free_ctrl_set(pkt, ODP_PACKET_FREE_CTRL_DISABLED);
+ CU_ASSERT(odp_packet_free_ctrl(pkt) == ODP_PACKET_FREE_CTRL_DISABLED);
}
static void packet_test_length(void)
@@ -3255,6 +3261,8 @@ static void packet_vector_test_user_area(void)
CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
for (i = 0; i < num; i++) {
+ odp_event_t ev;
+
pktv[i] = odp_packet_vector_alloc(pool);
if (pktv[i] == ODP_PACKET_VECTOR_INVALID)
@@ -3265,6 +3273,9 @@ static void packet_vector_test_user_area(void)
CU_ASSERT_FATAL(addr != NULL);
CU_ASSERT(prev != addr);
+ ev = odp_packet_vector_to_event(pktv[i]);
+ CU_ASSERT(odp_event_user_area(ev) == addr);
+
prev = addr;
memset(addr, 0, size);
}
@@ -3337,14 +3348,14 @@ static int packet_vector_suite_init(void)
vector_default_pool = odp_pool_create("vector_default_pool", &params);
if (vector_default_pool == ODP_POOL_INVALID) {
- ODPH_ERR("default vector pool create failed\n");
+ ODPH_ERR("Default vector pool create failed\n");
goto err1;
}
/* Allocating a default vector */
pktv_default = odp_packet_vector_alloc(vector_default_pool);
if (pktv_default == ODP_PACKET_VECTOR_INVALID) {
- ODPH_ERR("default vector packet allocation failed\n");
+ ODPH_ERR("Default vector packet allocation failed\n");
goto err2;
}
return 0;
@@ -3400,7 +3411,7 @@ static void packet_test_max_pools(void)
CU_ASSERT(num_pool == max_pools);
if (num_pool != max_pools)
- printf("Error: created only %u pools\n", num_pool);
+ ODPH_ERR("Created only %u pools\n", num_pool);
for (i = 0; i < num_pool; i++) {
packet[i] = odp_packet_alloc(pool[i], len);
@@ -3436,6 +3447,7 @@ static void packet_test_user_area(void)
odp_pool_param_t param;
odp_packet_t pkt;
odp_pool_t pool;
+ odp_event_t ev;
memcpy(&param, &default_param, sizeof(odp_pool_param_t));
@@ -3451,6 +3463,8 @@ static void packet_test_user_area(void)
} else {
CU_ASSERT(odp_packet_user_area(pkt) == NULL);
}
+ ev = odp_packet_to_event(pkt);
+ CU_ASSERT(odp_event_user_area(ev) == odp_packet_user_area(pkt));
odp_packet_free(pkt);
CU_ASSERT(odp_pool_destroy(pool) == 0);
@@ -3464,6 +3478,8 @@ static void packet_test_user_area(void)
pkt = odp_packet_alloc(pool, param.pkt.len);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
CU_ASSERT_FATAL(odp_packet_user_area(pkt) != NULL);
+ ev = odp_packet_to_event(pkt);
+ CU_ASSERT(odp_event_user_area(ev) == odp_packet_user_area(pkt));
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);
@@ -3476,6 +3492,8 @@ static void packet_test_user_area(void)
pkt = odp_packet_alloc(pool, param.pkt.len);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
CU_ASSERT_FATAL(odp_packet_user_area(pkt) != NULL);
+ ev = odp_packet_to_event(pkt);
+ CU_ASSERT(odp_event_user_area(ev) == odp_packet_user_area(pkt));
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);
@@ -3492,7 +3510,7 @@ static int packet_parse_suite_init(void)
memset(&pool_capa, 0, sizeof(odp_pool_capability_t));
if (odp_pool_capability(&pool_capa) < 0) {
- printf("pool_capability failed\n");
+ ODPH_ERR("odp_pool_capability() failed\n");
return -1;
}
diff --git a/test/validation/api/pktio/parser.c b/test/validation/api/pktio/parser.c
index 2b5042724..7d243877c 100644
--- a/test/validation/api/pktio/parser.c
+++ b/test/validation/api/pktio/parser.c
@@ -70,20 +70,19 @@ static int pkt_pool_create(void)
odp_pool_param_t params;
if (odp_pool_capability(&capa) != 0) {
- printf("Error: unable to query pool capability.\n");
+ ODPH_ERR("Unable to query pool capability\n");
return -1;
}
if (capa.pkt.max_num && capa.pkt.max_num < PKT_POOL_NUM) {
- printf("Error: packet pool size not supported.\n");
- printf("MAX: %" PRIu32 "\n", capa.pkt.max_num);
+ ODPH_ERR("Packet pool size not supported: MAX=%" PRIu32 "\n", capa.pkt.max_num);
return -1;
} else if (capa.pkt.max_len && capa.pkt.max_len < PKT_POOL_BUF_LEN) {
- printf("Error: packet length not supported.\n");
+ ODPH_ERR("Packet length not supported\n");
return -1;
} else if (capa.pkt.max_seg_len &&
capa.pkt.max_seg_len < PKT_POOL_BUF_LEN) {
- printf("Error: segment length not supported.\n");
+ ODPH_ERR("Segment length not supported\n");
return -1;
}
@@ -95,7 +94,7 @@ static int pkt_pool_create(void)
parser_pool = odp_pool_create("pkt_pool_default", &params);
if (parser_pool == ODP_POOL_INVALID) {
- printf("Error: packet pool create failed.\n");
+ ODPH_ERR("Packet pool create failed\n");
return -1;
}
@@ -115,24 +114,24 @@ static odp_pktio_t create_pktio(int iface_idx, odp_pool_t pool)
pktio = odp_pktio_open(iface, pool, &pktio_param);
if (pktio == ODP_PKTIO_INVALID) {
- printf("Error: failed to open %s\n", iface);
+ ODPH_ERR("Failed to open %s\n", iface);
return ODP_PKTIO_INVALID;
}
odp_pktio_config_init(&config);
config.parser.layer = ODP_PROTO_LAYER_ALL;
if (odp_pktio_config(pktio, &config)) {
- printf("Error: failed to configure %s\n", iface);
+ ODPH_ERR("Failed to configure %s\n", iface);
return ODP_PKTIO_INVALID;
}
/* By default, single input and output queue is used */
if (odp_pktin_queue_config(pktio, NULL)) {
- printf("Error: failed to config input queue for %s\n", iface);
+ ODPH_ERR("Failed to config input queue for %s\n", iface);
return ODP_PKTIO_INVALID;
}
if (odp_pktout_queue_config(pktio, NULL)) {
- printf("Error: failed to config output queue for %s\n", iface);
+ ODPH_ERR("Failed to config output queue for %s\n", iface);
return ODP_PKTIO_INVALID;
}
@@ -151,7 +150,7 @@ static odp_packet_t create_packet(const uint8_t *data, uint32_t len)
return ODP_PACKET_INVALID;
if (odp_packet_copy_from_mem(pkt, 0, len, data)) {
- printf("Error: failed to copy test packet data\n");
+ ODPH_ERR("Failed to copy test packet data\n");
odp_packet_free(pkt);
return ODP_PACKET_INVALID;
}
@@ -513,7 +512,7 @@ int parser_suite_init(void)
}
if (pkt_pool_create() != 0) {
- printf("Error: failed to create parser pool\n");
+ ODPH_ERR("Failed to create parser pool\n");
return -1;
}
@@ -525,22 +524,22 @@ int parser_suite_init(void)
io->name = iface_name[i];
io->hdl = create_pktio(i, parser_pool);
if (io->hdl == ODP_PKTIO_INVALID) {
- printf("Error: failed to open iface");
+ ODPH_ERR("Failed to open iface");
return -1;
}
if (odp_pktout_queue(io->hdl, &io->pktout, 1) != 1) {
- printf("Error: failed to start iface: %s\n", io->name);
+ ODPH_ERR("Failed to start iface: %s\n", io->name);
return -1;
}
if (odp_pktin_queue(io->hdl, &io->pktin, 1) != 1) {
- printf("Error: failed to start iface: %s\n", io->name);
+ ODPH_ERR("Failed to start iface: %s\n", io->name);
return -1;
}
if (odp_pktio_start(io->hdl)) {
- printf("Error: failed to start iface: %s\n", io->name);
+ ODPH_ERR("Failed to start iface: %s\n", io->name);
return -1;
}
@@ -562,19 +561,17 @@ int parser_suite_term(void)
for (i = 0; i < num_ifaces; ++i) {
if (odp_pktio_stop(pktios[i].hdl)) {
- printf("Error: failed to stop pktio: %s\n",
- pktios[i].name);
+ ODPH_ERR("Failed to stop pktio: %s\n", pktios[i].name);
ret = -1;
}
if (odp_pktio_close(pktios[i].hdl)) {
- printf("Error: failed to close pktio: %s\n",
- pktios[i].name);
+ ODPH_ERR("Failed to close pktio: %s\n", pktios[i].name);
ret = -1;
}
}
if (odp_pool_destroy(parser_pool) != 0) {
- printf("Error: failed to destroy packet pool\n");
+ ODPH_ERR("Failed to destroy packet pool\n");
ret = -1;
}
diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c
index 2f4dda4a4..f412a01c4 100644
--- a/test/validation/api/pktio/pktio.c
+++ b/test/validation/api/pktio/pktio.c
@@ -3495,7 +3495,7 @@ static void pktio_test_pktout_ts(void)
}
}
-static void pktio_test_pktout_compl(bool use_plain_queue)
+static void pktio_test_pktout_compl_event(bool use_plain_queue)
{
odp_pktio_t pktio[MAX_NUM_IFACES] = {ODP_PKTIO_INVALID};
odp_queue_t compl_queue[TX_BATCH_LEN];
@@ -3550,7 +3550,9 @@ static void pktio_test_pktout_compl(bool use_plain_queue)
/* Configure Tx completion offload for PKTIO Tx */
if (i == 0) {
- CU_ASSERT_FATAL(pktio_capa.tx_compl.mode_all == 1);
+ CU_ASSERT_FATAL(pktio_capa.tx_compl.mode_event == 1);
+ CU_ASSERT_FATAL(pktio_capa.tx_compl.mode_all ==
+ pktio_capa.tx_compl.mode_event);
if (use_plain_queue) {
/* CU_ASSERT needs these extra braces */
CU_ASSERT_FATAL(pktio_capa.tx_compl.queue_type_plain != 0);
@@ -3559,7 +3561,7 @@ static void pktio_test_pktout_compl(bool use_plain_queue)
}
odp_pktio_config_init(&config);
- config.pktout.bit.tx_compl_ena = 1;
+ config.tx_compl.mode_event = 1;
CU_ASSERT_FATAL(odp_pktio_config(pktio[i], &config) == 0);
}
@@ -3583,10 +3585,30 @@ static void pktio_test_pktout_compl(bool use_plain_queue)
memset(&opt, 0, sizeof(opt));
+ /* Disabled by default */
+ CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) == 0);
+
+ /* Check that disable works. Also COMPL_ALL should be still supported. */
+ opt.queue = compl_queue[0];
+ opt.mode = ODP_PACKET_TX_COMPL_ALL;
+ odp_packet_tx_compl_request(pkt_tbl[0], &opt);
+ CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) != 0);
+ opt.mode = ODP_PACKET_TX_COMPL_DISABLED;
+ odp_packet_tx_compl_request(pkt_tbl[0], &opt);
+ CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) == 0);
+ opt.queue = compl_queue[0];
+ opt.mode = ODP_PACKET_TX_COMPL_EVENT;
+ odp_packet_tx_compl_request(pkt_tbl[0], &opt);
+ CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) != 0);
+ opt.mode = ODP_PACKET_TX_COMPL_DISABLED;
+ odp_packet_tx_compl_request(pkt_tbl[0], &opt);
+ CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) == 0);
+
/* Prepare batch of pkts with different tx completion queues */
for (i = 0; i < TX_BATCH_LEN; i++) {
+ CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[i]) == 0);
opt.queue = compl_queue[i];
- opt.mode = ODP_PACKET_TX_COMPL_ALL;
+ opt.mode = ODP_PACKET_TX_COMPL_EVENT;
odp_packet_tx_compl_request(pkt_tbl[i], &opt);
CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[i]) != 0);
/* Set pkt sequence number as its user ptr */
@@ -3623,6 +3645,9 @@ static void pktio_test_pktout_compl(bool use_plain_queue)
CU_ASSERT(odp_packet_tx_compl_user_ptr(tx_compl) ==
(const void *)&pkt_seq[i]);
+ /* No user area for TX completion events */
+ CU_ASSERT(odp_event_user_area(ev) == NULL);
+
/* Alternatively call event free / compl free */
if (i % 2)
odp_packet_tx_compl_free(tx_compl);
@@ -3657,6 +3682,10 @@ static void pktio_test_pktout_compl(bool use_plain_queue)
break;
}
}
+
+ /* No user area for TX completion events */
+ CU_ASSERT(odp_event_user_area(ev) == NULL);
+
/* Check that sequence number is found */
CU_ASSERT(j < TX_BATCH_LEN);
@@ -3690,7 +3719,104 @@ static void pktio_test_pktout_compl(bool use_plain_queue)
odp_queue_destroy(compl_queue[i]);
}
-static int pktio_check_pktout_compl(bool plain)
+static void pktio_test_pktout_compl_poll(void)
+{
+ odp_pktio_t pktio[MAX_NUM_IFACES] = {ODP_PKTIO_INVALID};
+ odp_packet_t pkt_tbl[TX_BATCH_LEN];
+ odp_pktio_capability_t pktio_capa;
+ odp_pktout_queue_t pktout_queue;
+ uint32_t pkt_seq[TX_BATCH_LEN];
+ odp_pktio_t pktio_tx, pktio_rx;
+ odp_packet_tx_compl_opt_t opt;
+ pktio_info_t pktio_rx_info;
+ odp_pktio_config_t config;
+ int ret, i, num_rx = 0;
+
+ CU_ASSERT_FATAL(num_ifaces >= 1);
+
+ /* Open and configure interfaces */
+ for (i = 0; i < num_ifaces; ++i) {
+ pktio[i] = create_pktio(i, ODP_PKTIN_MODE_DIRECT,
+ ODP_PKTOUT_MODE_DIRECT);
+ CU_ASSERT_FATAL(pktio[i] != ODP_PKTIO_INVALID);
+
+ CU_ASSERT_FATAL(odp_pktio_capability(pktio[i], &pktio_capa) == 0);
+
+ /* Configure Tx completion offload for PKTIO Tx */
+ if (i == 0) {
+ CU_ASSERT_FATAL(pktio_capa.tx_compl.mode_poll == 1);
+ CU_ASSERT_FATAL(pktio_capa.tx_compl.max_compl_id >= (TX_BATCH_LEN - 1));
+
+ odp_pktio_config_init(&config);
+ config.tx_compl.mode_poll = 1;
+ config.tx_compl.max_compl_id = TX_BATCH_LEN - 1;
+ CU_ASSERT_FATAL(odp_pktio_config(pktio[i], &config) == 0);
+ }
+
+ CU_ASSERT_FATAL(odp_pktio_start(pktio[i]) == 0);
+ }
+
+ for (i = 0; i < num_ifaces; i++)
+ _pktio_wait_linkup(pktio[i]);
+
+ pktio_tx = pktio[0];
+ pktio_rx = (num_ifaces > 1) ? pktio[1] : pktio_tx;
+ pktio_rx_info.id = pktio_rx;
+ pktio_rx_info.inq = ODP_QUEUE_INVALID;
+ pktio_rx_info.in_mode = ODP_PKTIN_MODE_DIRECT;
+
+ ret = create_packets(pkt_tbl, pkt_seq, TX_BATCH_LEN, pktio_tx, pktio_rx);
+ CU_ASSERT_FATAL(ret == TX_BATCH_LEN);
+
+ ret = odp_pktout_queue(pktio_tx, &pktout_queue, 1);
+ CU_ASSERT_FATAL(ret > 0);
+
+ memset(&opt, 0, sizeof(opt));
+
+ /* Disabled by default */
+ CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) == 0);
+
+ /* Check that disable works */
+ opt.compl_id = 0;
+ opt.mode = ODP_PACKET_TX_COMPL_POLL;
+ odp_packet_tx_compl_request(pkt_tbl[0], &opt);
+ CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) != 0);
+ opt.mode = ODP_PACKET_TX_COMPL_DISABLED;
+ odp_packet_tx_compl_request(pkt_tbl[0], &opt);
+ CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) == 0);
+
+ /* Prepare batch of pkts with different tx completion identifiers */
+ for (i = 0; i < TX_BATCH_LEN; i++) {
+ CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[i]) == 0);
+ opt.compl_id = i;
+ opt.mode = ODP_PACKET_TX_COMPL_EVENT;
+ odp_packet_tx_compl_request(pkt_tbl[i], &opt);
+ CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[i]) != 0);
+ /* Set pkt sequence number as its user ptr */
+ odp_packet_user_ptr_set(pkt_tbl[i], (const void *)&pkt_seq[i]);
+ }
+
+ CU_ASSERT_FATAL(odp_pktout_send(pktout_queue, pkt_tbl, TX_BATCH_LEN) == TX_BATCH_LEN);
+
+ num_rx = wait_for_packets(&pktio_rx_info, pkt_tbl, pkt_seq, TX_BATCH_LEN, TXRX_MODE_SINGLE,
+ ODP_TIME_SEC_IN_NS, false);
+ CU_ASSERT(num_rx == TX_BATCH_LEN);
+ for (i = 0; i < num_rx; i++)
+ odp_packet_free(pkt_tbl[i]);
+
+ /* Transmits should be complete since we received the packets already */
+ for (i = 0; i < num_rx; i++) {
+ ret = odp_packet_tx_compl_done(pktio_tx, i);
+ CU_ASSERT(ret > 0);
+ }
+
+ for (i = 0; i < num_ifaces; i++) {
+ CU_ASSERT_FATAL(odp_pktio_stop(pktio[i]) == 0);
+ CU_ASSERT_FATAL(odp_pktio_close(pktio[i]) == 0);
+ }
+}
+
+static int pktio_check_pktout_compl_event(bool plain)
{
odp_pktio_param_t pktio_param;
odp_pktio_capability_t capa;
@@ -3708,7 +3834,7 @@ static int pktio_check_pktout_compl(bool plain)
ret = odp_pktio_capability(pktio, &capa);
(void)odp_pktio_close(pktio);
- if (ret < 0 || !capa.tx_compl.mode_all ||
+ if (ret < 0 || !capa.tx_compl.mode_event ||
(plain && !capa.tx_compl.queue_type_plain) ||
(!plain && !capa.tx_compl.queue_type_sched))
return ODP_TEST_INACTIVE;
@@ -3716,24 +3842,49 @@ static int pktio_check_pktout_compl(bool plain)
return ODP_TEST_ACTIVE;
}
-static int pktio_check_pktout_compl_plain_queue(void)
+static int pktio_check_pktout_compl_poll(void)
+{
+ odp_pktio_param_t pktio_param;
+ odp_pktio_capability_t capa;
+ odp_pktio_t pktio;
+ int ret;
+
+ odp_pktio_param_init(&pktio_param);
+ pktio_param.in_mode = ODP_PKTIN_MODE_DIRECT;
+ pktio_param.out_mode = ODP_PKTOUT_MODE_DIRECT;
+
+ pktio = odp_pktio_open(iface_name[0], pool[0], &pktio_param);
+ if (pktio == ODP_PKTIO_INVALID)
+ return ODP_TEST_INACTIVE;
+
+ ret = odp_pktio_capability(pktio, &capa);
+ (void)odp_pktio_close(pktio);
+
+ if (ret < 0 || capa.tx_compl.mode_poll == 0 ||
+ capa.tx_compl.max_compl_id < (TX_BATCH_LEN - 1))
+ return ODP_TEST_INACTIVE;
+
+ return ODP_TEST_ACTIVE;
+}
+
+static int pktio_check_pktout_compl_event_plain_queue(void)
{
- return pktio_check_pktout_compl(true);
+ return pktio_check_pktout_compl_event(true);
}
-static int pktio_check_pktout_compl_sched_queue(void)
+static int pktio_check_pktout_compl_event_sched_queue(void)
{
- return pktio_check_pktout_compl(false);
+ return pktio_check_pktout_compl_event(false);
}
-static void pktio_test_pktout_compl_plain_queue(void)
+static void pktio_test_pktout_compl_event_plain_queue(void)
{
- pktio_test_pktout_compl(true);
+ pktio_test_pktout_compl_event(true);
}
-static void pktio_test_pktout_compl_sched_queue(void)
+static void pktio_test_pktout_compl_event_sched_queue(void)
{
- pktio_test_pktout_compl(false);
+ pktio_test_pktout_compl_event(false);
}
static void pktio_test_chksum(void (*config_fn)(odp_pktio_t, odp_pktio_t),
@@ -5172,10 +5323,11 @@ odp_testinfo_t pktio_suite_unsegmented[] = {
pktio_check_maxlen_set),
ODP_TEST_INFO_CONDITIONAL(pktio_test_pktout_aging_tmo,
pktio_check_pktout_aging_tmo),
- ODP_TEST_INFO_CONDITIONAL(pktio_test_pktout_compl_plain_queue,
- pktio_check_pktout_compl_plain_queue),
- ODP_TEST_INFO_CONDITIONAL(pktio_test_pktout_compl_sched_queue,
- pktio_check_pktout_compl_sched_queue),
+ ODP_TEST_INFO_CONDITIONAL(pktio_test_pktout_compl_event_plain_queue,
+ pktio_check_pktout_compl_event_plain_queue),
+ ODP_TEST_INFO_CONDITIONAL(pktio_test_pktout_compl_event_sched_queue,
+ pktio_check_pktout_compl_event_sched_queue),
+ ODP_TEST_INFO_CONDITIONAL(pktio_test_pktout_compl_poll, pktio_check_pktout_compl_poll),
ODP_TEST_INFO_CONDITIONAL(pktio_test_enable_pause_rx, pktio_check_pause_rx),
ODP_TEST_INFO_CONDITIONAL(pktio_test_enable_pause_tx, pktio_check_pause_tx),
ODP_TEST_INFO_CONDITIONAL(pktio_test_enable_pause_both, pktio_check_pause_both),
diff --git a/test/validation/api/pool/pool.c b/test/validation/api/pool/pool.c
index cded05650..b335f194c 100644
--- a/test/validation/api/pool/pool.c
+++ b/test/validation/api/pool/pool.c
@@ -1098,6 +1098,7 @@ static int pool_check_timeout_pool_statistics(void)
static void pool_test_pool_statistics(odp_pool_type_t pool_type)
{
odp_pool_stats_t stats;
+ odp_pool_stats_selected_t selected;
odp_pool_param_t param;
odp_pool_stats_opt_t supported;
uint32_t i, j, num_pool, num_obj, cache_size;
@@ -1164,8 +1165,8 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type)
CU_ASSERT_FATAL(max_pools != 0);
/* Extra alloc rounds for testing odp_pool_stats_t.alloc_fails */
- uint32_t num_alloc_rounds = num_obj + 100;
- odp_event_t event[max_pools][num_alloc_rounds];
+ uint32_t num_allocs = num_obj + 100;
+ odp_event_t event[max_pools][num_allocs];
uint32_t num_event[max_pools];
odp_pool_t pool[max_pools];
@@ -1187,22 +1188,40 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type)
stats.thread.first = first;
stats.thread.last = last;
CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0);
+ CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected, &supported) == 0);
CU_ASSERT(stats.available <= num_obj);
+ if (supported.bit.available)
+ CU_ASSERT(selected.available <= num_obj);
CU_ASSERT(stats.alloc_ops == 0);
+ if (supported.bit.alloc_ops)
+ CU_ASSERT(selected.alloc_ops == 0);
CU_ASSERT(stats.alloc_fails == 0);
+ if (supported.bit.alloc_fails)
+ CU_ASSERT(selected.alloc_fails == 0);
CU_ASSERT(stats.free_ops == 0);
+ if (supported.bit.free_ops)
+ CU_ASSERT(selected.free_ops == 0);
CU_ASSERT(stats.total_ops == 0);
+ if (supported.bit.total_ops)
+ CU_ASSERT(selected.total_ops == 0);
CU_ASSERT(stats.cache_available <= num_obj);
+ if (supported.bit.cache_available)
+ CU_ASSERT(selected.cache_available <= num_obj);
CU_ASSERT(stats.cache_alloc_ops == 0);
+ if (supported.bit.cache_alloc_ops)
+ CU_ASSERT(selected.cache_alloc_ops == 0);
CU_ASSERT(stats.cache_free_ops == 0);
+ if (supported.bit.cache_free_ops)
+ CU_ASSERT(selected.cache_free_ops == 0);
+
CU_ASSERT(stats.thread.first == first);
CU_ASSERT(stats.thread.last == last);
for (j = 0; j < ODP_POOL_MAX_THREAD_STATS; j++)
CU_ASSERT(stats.thread.cache_available[j] <= stats.cache_available);
/* Allocate the events */
- for (j = 0; j < num_alloc_rounds; j++) {
+ for (j = 0; j < num_allocs; j++) {
odp_event_t new_event = ODP_EVENT_INVALID;
uint64_t total_cached = 0;
uint16_t first_id = 0;
@@ -1236,8 +1255,14 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type)
num_fails++;
CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0);
+ CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected,
+ &supported) == 0);
CU_ASSERT(stats.available <= num_obj - num_events);
+ if (supported.bit.available)
+ CU_ASSERT(selected.available <= num_obj - num_events);
CU_ASSERT(stats.cache_available <= num_obj - num_events);
+ if (supported.bit.cache_available)
+ CU_ASSERT(selected.cache_available <= num_obj - num_events);
while (first_id < odp_thread_count_max()) {
stats.thread.first = first_id;
@@ -1264,39 +1289,70 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type)
CU_ASSERT(num_events == num_obj);
num_event[i] = num_events;
+ /* Allow implementation some time to update counters */
+ odp_time_wait_ns(ODP_TIME_MSEC_IN_NS);
+
stats.thread.first = first;
stats.thread.last = last;
CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0);
+ CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected, &supported) == 0);
/* All events are allocated, available count in pool and pool
* local caches should be zero. */
CU_ASSERT(stats.available == 0);
+ if (supported.bit.available)
+ CU_ASSERT(selected.available == 0);
CU_ASSERT(stats.cache_available == 0);
+ if (supported.bit.cache_available)
+ CU_ASSERT(selected.cache_available == 0);
for (j = 0; j < ODP_POOL_MAX_THREAD_STATS; j++)
CU_ASSERT(stats.thread.cache_available[j] == 0);
- if (supported.bit.alloc_ops)
- CU_ASSERT(stats.alloc_ops > 0 && stats.alloc_ops <= num_obj + 1);
- if (supported.bit.alloc_fails)
+ if (supported.bit.alloc_ops) {
+ CU_ASSERT(stats.alloc_ops > 0 && stats.alloc_ops <= num_allocs);
+ CU_ASSERT(selected.alloc_ops > 0 && selected.alloc_ops <= num_allocs);
+ }
+ if (supported.bit.alloc_fails) {
CU_ASSERT(stats.alloc_fails == num_fails);
- if (supported.bit.total_ops)
- CU_ASSERT(stats.total_ops > 0 && stats.total_ops <= num_obj + 1);
+ CU_ASSERT(selected.alloc_fails == num_fails);
+ }
+ if (supported.bit.total_ops) {
+ CU_ASSERT(stats.total_ops > 0 && stats.total_ops <= num_allocs);
+ CU_ASSERT(selected.total_ops > 0 && selected.total_ops <= num_allocs);
+ }
CU_ASSERT(stats.free_ops == 0);
+ if (supported.bit.free_ops)
+ CU_ASSERT(selected.free_ops == 0);
+ CU_ASSERT(stats.cache_alloc_ops <= num_allocs);
+ if (supported.bit.cache_alloc_ops)
+ CU_ASSERT(selected.cache_alloc_ops <= num_allocs);
CU_ASSERT(stats.cache_free_ops == 0);
+ if (supported.bit.cache_free_ops)
+ CU_ASSERT(selected.cache_free_ops == 0);
}
for (i = 0; i < num_pool; i++) {
odp_event_free_multi(event[i], num_event[i]);
+ /* Allow implementation some time to update counters */
+ odp_time_wait_ns(ODP_TIME_MSEC_IN_NS);
+
stats.thread.first = odp_thread_id();
stats.thread.last = odp_thread_id();
CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0);
+ CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected, &supported) == 0);
- if (supported.bit.available && supported.bit.cache_available)
+ if (supported.bit.available && supported.bit.cache_available) {
CU_ASSERT(stats.available + stats.cache_available == num_obj);
- if (supported.bit.free_ops)
+ CU_ASSERT(selected.available + selected.cache_available == num_obj);
+ }
+ if (supported.bit.free_ops) {
CU_ASSERT(stats.free_ops > 0);
- if (supported.bit.total_ops)
+ CU_ASSERT(selected.free_ops > 0);
+ }
+ if (supported.bit.total_ops) {
CU_ASSERT(stats.total_ops > 0);
+ CU_ASSERT(selected.total_ops > 0);
+ }
if (i == 0) {
printf("\nPool Statistics\n---------------\n");
@@ -1314,13 +1370,26 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type)
CU_ASSERT_FATAL(odp_pool_stats_reset(pool[i]) == 0);
CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0);
+ CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected, &supported) == 0);
CU_ASSERT(stats.alloc_ops == 0);
+ if (supported.bit.alloc_ops)
+ CU_ASSERT(selected.alloc_ops == 0);
CU_ASSERT(stats.alloc_fails == 0);
+ if (supported.bit.alloc_fails)
+ CU_ASSERT(selected.alloc_fails == 0);
CU_ASSERT(stats.free_ops == 0);
+ if (supported.bit.free_ops)
+ CU_ASSERT(selected.free_ops == 0);
CU_ASSERT(stats.total_ops == 0);
+ if (supported.bit.total_ops)
+ CU_ASSERT(selected.total_ops == 0);
CU_ASSERT(stats.cache_alloc_ops == 0);
+ if (supported.bit.cache_alloc_ops)
+ CU_ASSERT(selected.cache_alloc_ops == 0);
CU_ASSERT(stats.cache_free_ops == 0);
+ if (supported.bit.cache_free_ops)
+ CU_ASSERT(selected.cache_free_ops == 0);
CU_ASSERT(odp_pool_destroy(pool[i]) == 0);
}
@@ -1858,7 +1927,7 @@ static int pool_suite_init(void)
memset(&default_pool_param, 0, sizeof(odp_pool_param_t));
if (odp_pool_capability(&global_pool_capa) < 0) {
- printf("pool_capability failed in suite init\n");
+ ODPH_ERR("odp_pool_capability() failed in suite init\n");
return -1;
}
@@ -1872,12 +1941,12 @@ static int pool_ext_suite_init(void)
memset(&global_pool_ext_capa, 0, sizeof(odp_pool_ext_capability_t));
if (odp_pool_ext_capability(ODP_POOL_PACKET, &global_pool_ext_capa)) {
- printf("Pool ext capa failed in suite init\n");
+ ODPH_ERR("Pool ext capa failed in suite init\n");
return -1;
}
if (global_pool_ext_capa.type != ODP_POOL_PACKET) {
- printf("Bad type from pool ext capa in suite init\n");
+ ODPH_ERR("Bad type from pool ext capa in suite init\n");
return -1;
}
diff --git a/test/validation/api/queue/queue.c b/test/validation/api/queue/queue.c
index f661da075..2cd474455 100644
--- a/test/validation/api/queue/queue.c
+++ b/test/validation/api/queue/queue.c
@@ -6,6 +6,7 @@
*/
#include <odp_api.h>
+#include <odp/helper/odph_api.h>
#include <odp_cunit_common.h>
#define MAX_WORKERS 32
@@ -65,7 +66,7 @@ static int queue_suite_init(void)
ODP_CACHE_LINE_SIZE, 0);
if (shm == ODP_SHM_INVALID) {
- printf("Shared memory reserve failed\n");
+ ODPH_ERR("Shared memory reserve failed\n");
return -1;
}
@@ -91,7 +92,7 @@ static int queue_suite_init(void)
pool = odp_pool_create("msg_pool", &params);
if (ODP_POOL_INVALID == pool) {
- printf("Pool create failed.\n");
+ ODPH_ERR("Pool create failed\n");
return -1;
}
return 0;
@@ -103,17 +104,17 @@ static int queue_suite_term(void)
shm = odp_shm_lookup(GLOBALS_NAME);
if (shm == ODP_SHM_INVALID) {
- printf("SHM lookup failed.\n");
+ ODPH_ERR("SHM lookup failed\n");
return -1;
}
if (odp_shm_free(shm)) {
- printf("SHM free failed.\n");
+ ODPH_ERR("SHM free failed\n");
return -1;
}
if (odp_pool_destroy(pool)) {
- printf("Pool destroy failed.\n");
+ ODPH_ERR("Pool destroy failed\n");
return -1;
}
@@ -455,7 +456,7 @@ static int queue_pair_work_loop(void *arg)
buf = odp_buffer_from_event(ev);
data = odp_buffer_addr(buf);
if (*data != i) {
- printf("Seq error: expected %u, recv %u\n", i, *data);
+ ODPH_ERR("Seq error: expected %u, recv %u\n", i, *data);
CU_FAIL("Sequence number error");
}
diff --git a/test/validation/api/scheduler/scheduler.c b/test/validation/api/scheduler/scheduler.c
index cd9ad1ac1..ec06cf27d 100644
--- a/test/validation/api/scheduler/scheduler.c
+++ b/test/validation/api/scheduler/scheduler.c
@@ -3155,12 +3155,12 @@ static int create_queues(test_globals_t *globals)
int sched_types;
if (odp_queue_capability(&queue_capa) < 0) {
- printf("Queue capability query failed\n");
+ ODPH_ERR("Queue capability query failed\n");
return -1;
}
if (odp_schedule_capability(&sched_capa) < 0) {
- printf("Queue capability query failed\n");
+ ODPH_ERR("Queue capability query failed\n");
return -1;
}
@@ -3196,9 +3196,9 @@ static int create_queues(test_globals_t *globals)
num_plain = (prios * queues_per_prio);
}
if (!queues_per_prio) {
- printf("Not enough queues. At least %d scheduled queues and "
- "%d plain queus required.\n",
- ((prios * sched_types) + CHAOS_NUM_QUEUES), prios);
+ ODPH_ERR("Not enough queues. At least %d scheduled queues and "
+ "%d plain queues required.\n",
+ ((prios * sched_types) + CHAOS_NUM_QUEUES), prios);
return -1;
}
globals->queues_per_prio = queues_per_prio;
@@ -3211,7 +3211,7 @@ static int create_queues(test_globals_t *globals)
queue_ctx_pool = odp_pool_create(QUEUE_CTX_POOL_NAME, &params);
if (queue_ctx_pool == ODP_POOL_INVALID) {
- printf("Pool creation failed (queue ctx).\n");
+ ODPH_ERR("Pool creation failed (queue ctx)\n");
return -1;
}
globals->queue_ctx_pool = queue_ctx_pool;
@@ -3231,7 +3231,7 @@ static int create_queues(test_globals_t *globals)
q = odp_queue_create(name, &p);
if (q == ODP_QUEUE_INVALID) {
- printf("Parallel queue create failed.\n");
+ ODPH_ERR("Parallel queue create failed\n");
return -1;
}
@@ -3241,21 +3241,21 @@ static int create_queues(test_globals_t *globals)
q = odp_queue_create(name, &p);
if (q == ODP_QUEUE_INVALID) {
- printf("Atomic queue create failed.\n");
+ ODPH_ERR("Atomic queue create failed\n");
return -1;
}
snprintf(name, sizeof(name), "plain_%d_%d_o", i, j);
pq = odp_queue_create(name, NULL);
if (pq == ODP_QUEUE_INVALID) {
- printf("Plain queue create failed.\n");
+ ODPH_ERR("Plain queue create failed\n");
return -1;
}
queue_ctx_buf = odp_buffer_alloc(queue_ctx_pool);
if (queue_ctx_buf == ODP_BUFFER_INVALID) {
- printf("Cannot allocate plain queue ctx buf\n");
+ ODPH_ERR("Cannot allocate plain queue ctx buf\n");
return -1;
}
@@ -3266,7 +3266,7 @@ static int create_queues(test_globals_t *globals)
rc = odp_queue_context_set(pq, pqctx, 0);
if (rc != 0) {
- printf("Cannot set plain queue context\n");
+ ODPH_ERR("Cannot set plain queue context\n");
return -1;
}
@@ -3277,7 +3277,7 @@ static int create_queues(test_globals_t *globals)
q = odp_queue_create(name, &p);
if (q == ODP_QUEUE_INVALID) {
- printf("Ordered queue create failed.\n");
+ ODPH_ERR("Ordered queue create failed\n");
return -1;
}
if (odp_queue_lock_count(q) !=
@@ -3293,7 +3293,7 @@ static int create_queues(test_globals_t *globals)
queue_ctx_buf = odp_buffer_alloc(queue_ctx_pool);
if (queue_ctx_buf == ODP_BUFFER_INVALID) {
- printf("Cannot allocate queue ctx buf\n");
+ ODPH_ERR("Cannot allocate queue ctx buf\n");
return -1;
}
@@ -3311,7 +3311,7 @@ static int create_queues(test_globals_t *globals)
rc = odp_queue_context_set(q, qctx, 0);
if (rc != 0) {
- printf("Cannot set queue context\n");
+ ODPH_ERR("Cannot set queue context\n");
return -1;
}
}
@@ -3522,14 +3522,14 @@ static int scheduler_test_global_init(void)
sizeof(test_globals_t), ODP_CACHE_LINE_SIZE, 0);
if (shm == ODP_SHM_INVALID) {
- printf("Shared memory reserve failed (globals).\n");
+ ODPH_ERR("Shared memory reserve failed (globals)\n");
return -1;
}
globals = odp_shm_addr(shm);
if (!globals) {
- printf("Shared memory reserve failed (globals).\n");
+ ODPH_ERR("Shared memory reserve failed (globals)\n");
return -1;
}
@@ -3544,7 +3544,7 @@ static int scheduler_test_global_init(void)
ODP_CACHE_LINE_SIZE, 0);
if (shm == ODP_SHM_INVALID) {
- printf("Shared memory reserve failed (args).\n");
+ ODPH_ERR("Shared memory reserve failed (args)\n");
return -1;
}
@@ -3552,7 +3552,7 @@ static int scheduler_test_global_init(void)
globals->shm_args = shm;
if (!args) {
- printf("Shared memory reserve failed (args).\n");
+ ODPH_ERR("Shared memory reserve failed (args)\n");
return -1;
}
@@ -3572,14 +3572,14 @@ static int scheduler_test_global_init(void)
pool = odp_pool_create(MSG_POOL_NAME, &params);
if (pool == ODP_POOL_INVALID) {
- printf("Pool creation failed (msg).\n");
+ ODPH_ERR("Pool creation failed (msg)\n");
return -1;
}
globals->pool = pool;
if (odp_schedule_capability(&sched_capa)) {
- printf("odp_schedule_capability() failed\n");
+ ODPH_ERR("odp_schedule_capability() failed\n");
return -1;
}
@@ -3599,7 +3599,7 @@ static int scheduler_test_global_init(void)
/* Configure the scheduler. All test cases share the config. */
if (odp_schedule_config(&sched_config)) {
- printf("odp_schedule_config() failed.\n");
+ ODPH_ERR("odp_schedule_config() failed\n");
return -1;
}
diff --git a/test/validation/api/scheduler/scheduler_no_predef_groups.c b/test/validation/api/scheduler/scheduler_no_predef_groups.c
index 3dd79ebcc..1b941ac61 100644
--- a/test/validation/api/scheduler/scheduler_no_predef_groups.c
+++ b/test/validation/api/scheduler/scheduler_no_predef_groups.c
@@ -139,7 +139,7 @@ static int scheduler_suite_init(void)
odp_schedule_config_t sched_config;
if (odp_schedule_capability(&sched_capa)) {
- printf("odp_schedule_capability() failed\n");
+ ODPH_ERR("odp_schedule_capability() failed\n");
return -1;
}
@@ -152,7 +152,7 @@ static int scheduler_suite_init(void)
/* Configure the scheduler. All test cases share the config. */
if (odp_schedule_config(&sched_config)) {
- printf("odp_schedule_config() failed.\n");
+ ODPH_ERR("odp_schedule_config() failed\n");
return -1;
}
diff --git a/test/validation/api/stash/stash.c b/test/validation/api/stash/stash.c
index fd4c04577..67c336a2f 100644
--- a/test/validation/api/stash/stash.c
+++ b/test/validation/api/stash/stash.c
@@ -5,6 +5,8 @@
*/
#include <odp_api.h>
+#include <odp/helper/odph_api.h>
+
#include "odp_cunit_common.h"
#include <string.h>
@@ -63,7 +65,7 @@ static int stash_suite_init(void)
odp_stash_capability_t *capa_fifo = &global.capa_fifo;
if (odp_stash_capability(capa_default, ODP_STASH_TYPE_DEFAULT)) {
- printf("stash capability failed for the default type\n");
+ ODPH_ERR("Stash capability failed for the default type\n");
return -1;
}
diff --git a/test/validation/api/thread/thread.c b/test/validation/api/thread/thread.c
index 2dc799c2a..87c23e74e 100644
--- a/test/validation/api/thread/thread.c
+++ b/test/validation/api/thread/thread.c
@@ -30,7 +30,7 @@ static int thread_global_init(odp_instance_t *inst)
odph_helper_options_t helper_options;
if (odph_options(&helper_options)) {
- fprintf(stderr, "error: odph_options() failed.\n");
+ ODPH_ERR("odph_options() failed\n");
return -1;
}
@@ -38,11 +38,11 @@ static int thread_global_init(odp_instance_t *inst)
init_param.mem_model = helper_options.mem_model;
if (0 != odp_init_global(inst, &init_param, NULL)) {
- fprintf(stderr, "error: odp_init_global() failed.\n");
+ ODPH_ERR("odp_init_global() failed\n");
return -1;
}
if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) {
- fprintf(stderr, "error: odp_init_local() failed.\n");
+ ODPH_ERR("odp_init_local() failed\n");
return -1;
}
@@ -50,7 +50,7 @@ static int thread_global_init(odp_instance_t *inst)
sizeof(global_shared_mem_t),
ODP_CACHE_LINE_SIZE, 0);
if (global_shm == ODP_SHM_INVALID) {
- fprintf(stderr, "Unable reserve memory for global_shm\n");
+ ODPH_ERR("Unable to reserve memory for global_shm\n");
return -1;
}
@@ -66,17 +66,17 @@ static int thread_global_term(odp_instance_t inst)
shm = odp_shm_lookup(GLOBAL_SHM_NAME);
if (0 != odp_shm_free(shm)) {
- fprintf(stderr, "error: odp_shm_free() failed.\n");
+ ODPH_ERR("odp_shm_free() failed\n");
return -1;
}
if (0 != odp_term_local()) {
- fprintf(stderr, "error: odp_term_local() failed.\n");
+ ODPH_ERR("odp_term_local() failed\n");
return -1;
}
if (0 != odp_term_global(inst)) {
- fprintf(stderr, "error: odp_term_global() failed.\n");
+ ODPH_ERR("odp_term_global() failed\n");
return -1;
}
diff --git a/test/validation/api/time/time.c b/test/validation/api/time/time.c
index f285bf8e4..22189ce03 100644
--- a/test/validation/api/time/time.c
+++ b/test/validation/api/time/time.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
+ * Copyright (c) 2019-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -12,6 +12,7 @@
#include <time.h>
#include <odp_api.h>
+#include <odp/helper/odph_api.h>
#include "odp_cunit_common.h"
#define BUSY_LOOP_CNT 30000000 /* used for t > min resolution */
@@ -19,6 +20,11 @@
#define MAX_TIME_RATE 15000000000
#define DELAY_TOLERANCE 40000000 /* deviation for delay */
#define WAIT_SECONDS 3
+#define MAX_WORKERS 32
+#define TIME_SAMPLES 2
+#define TIME_TOLERANCE_NS 1000000
+#define TIME_TOLERANCE_CI_NS 40000000
+#define GLOBAL_SHM_NAME "GlobalTimeTest"
static uint64_t local_res;
static uint64_t global_res;
@@ -28,6 +34,96 @@ typedef uint64_t time_res_cb(void);
typedef odp_time_t time_from_ns_cb(uint64_t ns);
typedef uint64_t time_nsec_cb(void);
+typedef struct {
+ uint32_t num_threads;
+ odp_barrier_t test_barrier;
+ odp_time_t time[MAX_WORKERS + 1][TIME_SAMPLES];
+} global_shared_mem_t;
+
+static global_shared_mem_t *global_mem;
+static odp_instance_t *instance;
+
+static int time_global_init(odp_instance_t *inst)
+{
+ odp_shm_t global_shm;
+ odp_init_t init_param;
+ odph_helper_options_t helper_options;
+ uint32_t workers_count, max_threads;
+
+ if (odph_options(&helper_options)) {
+ ODPH_ERR("odph_options() failed\n");
+ return -1;
+ }
+
+ odp_init_param_init(&init_param);
+ init_param.mem_model = helper_options.mem_model;
+
+ if (0 != odp_init_global(inst, &init_param, NULL)) {
+ ODPH_ERR("odp_init_global() failed\n");
+ return -1;
+ }
+ if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) {
+ ODPH_ERR("odp_init_local() failed\n");
+ return -1;
+ }
+
+ global_shm = odp_shm_reserve(GLOBAL_SHM_NAME,
+ sizeof(global_shared_mem_t),
+ ODP_CACHE_LINE_SIZE, 0);
+ if (global_shm == ODP_SHM_INVALID) {
+ ODPH_ERR("Unable reserve memory for global_shm\n");
+ return -1;
+ }
+
+ global_mem = odp_shm_addr(global_shm);
+ memset(global_mem, 0, sizeof(global_shared_mem_t));
+
+ global_mem->num_threads = MAX_WORKERS;
+
+ workers_count = odp_cpumask_default_worker(NULL, 0);
+
+ max_threads = (workers_count >= MAX_WORKERS) ?
+ MAX_WORKERS : workers_count;
+
+ if (max_threads < global_mem->num_threads) {
+ printf("Requested num of threads is too large\n");
+ printf("reducing from %" PRIu32 " to %" PRIu32 "\n",
+ global_mem->num_threads,
+ max_threads);
+ global_mem->num_threads = max_threads;
+ }
+
+ printf("Num of threads used = %" PRIu32 "\n",
+ global_mem->num_threads);
+
+ instance = inst;
+
+ return 0;
+}
+
+static int time_global_term(odp_instance_t inst)
+{
+ odp_shm_t shm;
+
+ shm = odp_shm_lookup(GLOBAL_SHM_NAME);
+ if (0 != odp_shm_free(shm)) {
+ ODPH_ERR("odp_shm_free() failed\n");
+ return -1;
+ }
+
+ if (0 != odp_term_local()) {
+ ODPH_ERR("odp_term_local() failed\n");
+ return -1;
+ }
+
+ if (0 != odp_term_global(inst)) {
+ ODPH_ERR("odp_term_global() failed\n");
+ return -1;
+ }
+
+ return 0;
+}
+
static void time_test_constants(void)
{
uint64_t ns;
@@ -423,16 +519,14 @@ static void time_test_wait_until(time_cb time_cur, time_from_ns_cb time_from_ns)
DELAY_TOLERANCE);
if (odp_time_cmp(wait, lower_limit) < 0) {
- fprintf(stderr, "Exceed lower limit: "
- "wait is %" PRIu64 ", lower_limit %" PRIu64 "\n",
- odp_time_to_ns(wait), odp_time_to_ns(lower_limit));
+ ODPH_ERR("Exceed lower limit: wait is %" PRIu64 ", lower_limit %" PRIu64 "\n",
+ odp_time_to_ns(wait), odp_time_to_ns(lower_limit));
CU_FAIL("Exceed lower limit\n");
}
if (odp_time_cmp(wait, upper_limit) > 0) {
- fprintf(stderr, "Exceed upper limit: "
- "wait is %" PRIu64 ", upper_limit %" PRIu64 "\n",
- odp_time_to_ns(wait), odp_time_to_ns(lower_limit));
+ ODPH_ERR("Exceed upper limit: wait is %" PRIu64 ", upper_limit %" PRIu64 "\n",
+ odp_time_to_ns(wait), odp_time_to_ns(lower_limit));
CU_FAIL("Exceed upper limit\n");
}
}
@@ -466,16 +560,14 @@ static void time_test_wait_ns(void)
DELAY_TOLERANCE);
if (odp_time_cmp(diff, lower_limit) < 0) {
- fprintf(stderr, "Exceed lower limit: "
- "diff is %" PRIu64 ", lower_limit %" PRIu64 "\n",
- odp_time_to_ns(diff), odp_time_to_ns(lower_limit));
+ ODPH_ERR("Exceed lower limit: diff is %" PRIu64 ", lower_limit %" PRIu64 "\n",
+ odp_time_to_ns(diff), odp_time_to_ns(lower_limit));
CU_FAIL("Exceed lower limit\n");
}
if (odp_time_cmp(diff, upper_limit) > 0) {
- fprintf(stderr, "Exceed upper limit: "
- "diff is %" PRIu64 ", upper_limit %" PRIu64 "\n",
- odp_time_to_ns(diff), odp_time_to_ns(upper_limit));
+ ODPH_ERR("Exceed upper limit: diff is %" PRIu64 ", upper_limit %" PRIu64 "\n",
+ odp_time_to_ns(diff), odp_time_to_ns(upper_limit));
CU_FAIL("Exceed upper limit\n");
}
}
@@ -486,13 +578,13 @@ static void check_time_diff(double t_odp, double t_system,
{
if (t_odp > t_system * 1.05) {
CU_FAIL("ODP time too high");
- fprintf(stderr, "ODP time too high (%s/%d): t_odp: %f, t_system: %f\n",
- test, id, t_odp, t_system);
+ ODPH_ERR("ODP time too high (%s/%d): t_odp: %f, t_system: %f\n",
+ test, id, t_odp, t_system);
}
if (t_odp < t_system * 0.95) {
CU_FAIL("ODP time too low");
- fprintf(stderr, "ODP time too low (%s/%d): t_odp: %f, t_system: %f\n",
- test, id, t_odp, t_system);
+ ODPH_ERR("ODP time too low (%s/%d): t_odp: %f, t_system: %f\n",
+ test, id, t_odp, t_system);
}
}
@@ -589,6 +681,138 @@ static void time_test_accuracy_nsec(void)
}
}
+static int time_test_global_sync_thr(void *arg ODP_UNUSED)
+{
+ int tid = odp_thread_id();
+ odp_shm_t global_shm = odp_shm_lookup(GLOBAL_SHM_NAME);
+ global_shared_mem_t *global_mem = odp_shm_addr(global_shm);
+
+ if (!global_mem)
+ return 1;
+
+ odp_barrier_wait(&global_mem->test_barrier);
+ global_mem->time[tid][0] = odp_time_global();
+ odp_time_wait_ns(ODP_TIME_MSEC_IN_NS * 100);
+ odp_barrier_wait(&global_mem->test_barrier);
+ global_mem->time[tid][1] = odp_time_global();
+
+ return 0;
+}
+
+static void time_test_global_sync(const int ctrl)
+{
+ odp_cpumask_t cpumask;
+ odph_thread_common_param_t thr_common;
+ odph_thread_param_t thr_param;
+ odph_thread_t thread_tbl[MAX_WORKERS];
+ const uint64_t tolerance =
+ odp_cunit_ci() ? TIME_TOLERANCE_CI_NS : TIME_TOLERANCE_NS;
+ const int num = ctrl ? 2 : global_mem->num_threads;
+
+ if (num < 2) {
+ printf(" number of threads is less than two, test skipped. ");
+ return;
+ }
+
+ odp_barrier_init(&global_mem->test_barrier, num);
+
+ odph_thread_param_init(&thr_param);
+ thr_param.start = time_test_global_sync_thr;
+
+ odph_thread_common_param_init(&thr_common);
+ thr_common.instance = *instance;
+
+ int thr = 0;
+
+ if (ctrl) {
+ /* Test sync between one control and one worker thread. */
+ odp_cpumask_default_control(&cpumask, 1);
+ thr_common.cpumask = &cpumask;
+ thr_param.thr_type = ODP_THREAD_CONTROL;
+
+ int r = odph_thread_create(&thread_tbl[thr++],
+ &thr_common, &thr_param, 1);
+ CU_ASSERT_FATAL(r == 1);
+ odp_cpumask_default_worker(&cpumask, 1);
+ } else {
+ /* Test sync between num worker threads. */
+ odp_cpumask_default_worker(&cpumask, num);
+ }
+
+ int cpu = odp_cpumask_first(&cpumask);
+
+ while (cpu >= 0) {
+ odp_cpumask_t cpumask_one;
+
+ /*
+ * Delay for more than the tolerance, so that we notice if the
+ * thread's view of global time is affected.
+ */
+ odp_time_wait_ns(tolerance * 2);
+
+ odp_cpumask_zero(&cpumask_one);
+ odp_cpumask_set(&cpumask_one, cpu);
+ thr_common.cpumask = &cpumask_one;
+ thr_param.thr_type = ODP_THREAD_WORKER;
+
+ int r = odph_thread_create(&thread_tbl[thr++],
+ &thr_common, &thr_param, 1);
+ CU_ASSERT_FATAL(r == 1);
+
+ cpu = odp_cpumask_next(&cpumask, cpu);
+ }
+
+ CU_ASSERT(odph_thread_join(thread_tbl, num) == num);
+
+ for (int s = 0; s < TIME_SAMPLES; s++) {
+ int min_idx = 0, max_idx = 0;
+ uint64_t min = UINT64_MAX, max = 0;
+ double avg = 0;
+
+ for (int i = 1; i < num + 1; i++) {
+ uint64_t t = odp_time_to_ns(global_mem->time[i][s]);
+
+ if (t < min) {
+ min = t;
+ min_idx = i;
+ }
+ }
+
+ printf("\nround %d\nthread time diffs: ", s);
+
+ for (int i = 1; i < num + 1; i++) {
+ uint64_t t = odp_time_to_ns(global_mem->time[i][s]) - min;
+
+ printf("%" PRIu64 " ", t);
+
+ if (t > max) {
+ max = t;
+ max_idx = i;
+ }
+
+ avg += t;
+ }
+
+ /* The min result itself is not included in the average. */
+ avg /= num - 1;
+ printf("\nmin: %" PRIu64 " (tid %d) max diff: %" PRIu64
+ " (tid %d) avg diff: %g", min, min_idx, max, max_idx, avg);
+ CU_ASSERT(max < tolerance);
+ }
+
+ printf("\n");
+}
+
+static void time_test_global_sync_workers(void)
+{
+ time_test_global_sync(0);
+}
+
+static void time_test_global_sync_control(void)
+{
+ time_test_global_sync(1);
+}
+
odp_testinfo_t time_suite_time[] = {
ODP_TEST_INFO(time_test_constants),
ODP_TEST_INFO(time_test_local_res),
@@ -614,6 +838,8 @@ odp_testinfo_t time_suite_time[] = {
ODP_TEST_INFO(time_test_global_strict_diff),
ODP_TEST_INFO(time_test_global_strict_sum),
ODP_TEST_INFO(time_test_global_strict_cmp),
+ ODP_TEST_INFO(time_test_global_sync_workers),
+ ODP_TEST_INFO(time_test_global_sync_control),
ODP_TEST_INFO_NULL
};
@@ -630,6 +856,9 @@ int main(int argc, char *argv[])
if (odp_cunit_parse_options(argc, argv))
return -1;
+ odp_cunit_register_global_init(time_global_init);
+ odp_cunit_register_global_term(time_global_term);
+
ret = odp_cunit_register(time_suites);
if (ret == 0)
diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c
index eb7f0772a..dad99ab41 100644
--- a/test/validation/api/timer/timer.c
+++ b/test/validation/api/timer/timer.c
@@ -15,6 +15,8 @@
#include <odp/helper/odph_api.h>
#include "odp_cunit_common.h"
+#include <stdint.h>
+
#define MAX_WORKERS 32
#define GLOBAL_SHM_NAME "GlobalTimerTest"
@@ -117,7 +119,7 @@ static int timer_global_init(odp_instance_t *inst)
int i;
if (odph_options(&helper_options)) {
- fprintf(stderr, "error: odph_options() failed.\n");
+ ODPH_ERR("odph_options() failed\n");
return -1;
}
@@ -125,11 +127,11 @@ static int timer_global_init(odp_instance_t *inst)
init_param.mem_model = helper_options.mem_model;
if (0 != odp_init_global(inst, &init_param, NULL)) {
- fprintf(stderr, "error: odp_init_global() failed.\n");
+ ODPH_ERR("odp_init_global() failed\n");
return -1;
}
if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) {
- fprintf(stderr, "error: odp_init_local() failed.\n");
+ ODPH_ERR("odp_init_local() failed\n");
return -1;
}
@@ -137,7 +139,7 @@ static int timer_global_init(odp_instance_t *inst)
sizeof(global_shared_mem_t),
ODP_CACHE_LINE_SIZE, 0);
if (global_shm == ODP_SHM_INVALID) {
- fprintf(stderr, "Unable reserve memory for global_shm\n");
+ ODPH_ERR("Unable to reserve memory for global_shm\n");
return -1;
}
@@ -149,7 +151,7 @@ static int timer_global_init(odp_instance_t *inst)
memset(&capa, 0, sizeof(capa));
if (odp_timer_capability(ODP_CLOCK_DEFAULT, &capa)) {
- fprintf(stderr, "Timer capability failed\n");
+ ODPH_ERR("Timer capability failed\n");
return -1;
}
@@ -162,7 +164,7 @@ static int timer_global_init(odp_instance_t *inst)
res_capa.res_ns = res_ns;
if (odp_timer_res_capability(ODP_CLOCK_DEFAULT, &res_capa)) {
- fprintf(stderr, "Timer resolution capability failed\n");
+ ODPH_ERR("Timer resolution capability failed\n");
return -1;
}
@@ -178,7 +180,7 @@ static int timer_global_init(odp_instance_t *inst)
range = (RANGE_MS * 1000) + THREE_POINT_THREE_MSEC;
if ((max_tmo - min_tmo) < range) {
- fprintf(stderr, "Validation test needs %u msec range\n", range);
+ ODPH_ERR("Validation test needs %u msec range\n", range);
return -1;
}
@@ -209,17 +211,17 @@ static int timer_global_term(odp_instance_t inst)
shm = odp_shm_lookup(GLOBAL_SHM_NAME);
if (0 != odp_shm_free(shm)) {
- fprintf(stderr, "error: odp_shm_free() failed.\n");
+ ODPH_ERR("odp_shm_free() failed\n");
return -1;
}
if (0 != odp_term_local()) {
- fprintf(stderr, "error: odp_term_local() failed.\n");
+ ODPH_ERR("odp_term_local() failed\n");
return -1;
}
if (0 != odp_term_global(inst)) {
- fprintf(stderr, "error: odp_term_global() failed.\n");
+ ODPH_ERR("odp_term_global() failed\n");
return -1;
}
@@ -279,7 +281,7 @@ static void timer_test_capa_run(odp_timer_clk_src_t clk_src)
CU_ASSERT_FATAL(ret == 0);
CU_ASSERT(capa.highest_res_ns == capa.max_res.res_ns);
- /* Assuming max resoultion to be 100 msec or better */
+ /* Assuming max resolution to be 100 msec or better */
CU_ASSERT(capa.max_res.res_ns <= 100000000);
CU_ASSERT(capa.max_res.res_hz >= 10);
CU_ASSERT(capa.max_res.res_ns < capa.max_res.max_tmo);
@@ -302,6 +304,13 @@ static void timer_test_capa_run(odp_timer_clk_src_t clk_src)
CU_ASSERT(res_capa.min_tmo == capa.max_res.min_tmo);
CU_ASSERT(res_capa.max_tmo == capa.max_res.max_tmo);
+ if (capa.max_res.res_ns > 1) {
+ memset(&res_capa, 0, sizeof(res_capa));
+ res_capa.res_ns = capa.max_res.res_ns - 1;
+ ret = odp_timer_res_capability(clk_src, &res_capa);
+ CU_ASSERT(ret < 0);
+ }
+
/* Set max resolution in hz */
memset(&res_capa, 0, sizeof(res_capa));
res_capa.res_hz = capa.max_res.res_hz;
@@ -312,6 +321,13 @@ static void timer_test_capa_run(odp_timer_clk_src_t clk_src)
CU_ASSERT(res_capa.min_tmo == capa.max_res.min_tmo);
CU_ASSERT(res_capa.max_tmo == capa.max_res.max_tmo);
+ if (capa.max_res.res_hz < UINT64_MAX) {
+ memset(&res_capa, 0, sizeof(res_capa));
+ res_capa.res_hz = capa.max_res.res_hz + 1;
+ ret = odp_timer_res_capability(clk_src, &res_capa);
+ CU_ASSERT(ret < 0);
+ }
+
/* Set max timeout */
memset(&res_capa, 0, sizeof(res_capa));
res_capa.max_tmo = capa.max_tmo.max_tmo;
@@ -322,6 +338,13 @@ static void timer_test_capa_run(odp_timer_clk_src_t clk_src)
CU_ASSERT(res_capa.min_tmo == capa.max_tmo.min_tmo);
CU_ASSERT(res_capa.res_ns == capa.max_tmo.res_ns);
CU_ASSERT(res_capa.res_hz == capa.max_tmo.res_hz);
+
+ if (capa.max_tmo.max_tmo < UINT64_MAX) {
+ memset(&res_capa, 0, sizeof(res_capa));
+ res_capa.max_tmo = capa.max_tmo.max_tmo + 1;
+ ret = odp_timer_res_capability(clk_src, &res_capa);
+ CU_ASSERT(ret < 0);
+ }
}
static void timer_test_capa(void)
@@ -494,6 +517,8 @@ static void timer_test_timeout_user_area(void)
CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
for (i = 0; i < num; i++) {
+ odp_event_t ev;
+
tmo[i] = odp_timeout_alloc(pool);
if (tmo[i] == ODP_TIMEOUT_INVALID)
@@ -505,6 +530,9 @@ static void timer_test_timeout_user_area(void)
CU_ASSERT_FATAL(addr != NULL);
CU_ASSERT(prev != addr);
+ ev = odp_timeout_to_event(tmo[i]);
+ CU_ASSERT(odp_event_user_area(ev) == addr);
+
prev = addr;
memset(addr, 0, size);
}
@@ -749,9 +777,9 @@ static void timer_pool_max_res(void)
ev = ODP_EVENT_INVALID;
ret = odp_timer_cancel(timer, &ev);
- CU_ASSERT(ret == 0);
+ CU_ASSERT(ret == ODP_TIMER_SUCCESS);
- if (ret == 0) {
+ if (ret == ODP_TIMER_SUCCESS) {
CU_ASSERT(ev != ODP_EVENT_INVALID);
odp_event_free(ev);
}
@@ -922,9 +950,9 @@ static void timer_single_shot(odp_queue_type_t queue_type, odp_timer_tick_type_t
if (cancel) {
ret = odp_timer_cancel(timer, &ev);
- CU_ASSERT(ret == 0);
+ CU_ASSERT(ret == ODP_TIMER_SUCCESS);
- if (ret == 0)
+ if (ret == ODP_TIMER_SUCCESS)
CU_ASSERT(ev != ODP_EVENT_INVALID);
} else {
uint64_t diff_ns;
@@ -1061,6 +1089,148 @@ static void timer_sched_abs_wait_3sec(void)
timer_single_shot(ODP_QUEUE_TYPE_SCHED, ABSOLUTE, START, TIMEOUT, 30, 110 * MSEC);
}
+static void timer_pool_current_tick_run(odp_timer_clk_src_t clk_src)
+{
+ odp_timer_capability_t capa;
+ odp_timer_pool_param_t tp_param;
+ odp_timer_pool_t tp;
+ uint64_t t1, t2, ticks, min, max;
+ uint64_t nsec = 100 * ODP_TIME_MSEC_IN_NS;
+
+ memset(&capa, 0, sizeof(capa));
+ CU_ASSERT_FATAL(odp_timer_capability(clk_src, &capa) == 0);
+
+ /* Highest resolution */
+ odp_timer_pool_param_init(&tp_param);
+ tp_param.res_hz = capa.max_res.res_hz;
+ tp_param.min_tmo = capa.max_res.min_tmo;
+ tp_param.max_tmo = capa.max_res.max_tmo;
+ tp_param.num_timers = 100;
+ tp_param.clk_src = clk_src;
+
+ tp = odp_timer_pool_create("cur_tick", &tp_param);
+ CU_ASSERT_FATAL(tp != ODP_TIMER_POOL_INVALID);
+
+ odp_timer_pool_start();
+
+ /* Allow +-10% error margin */
+ min = odp_timer_ns_to_tick(tp, 0.9 * nsec);
+ max = odp_timer_ns_to_tick(tp, 1.1 * nsec);
+
+ t1 = odp_timer_current_tick(tp);
+
+ odp_time_wait_ns(nsec);
+
+ t2 = odp_timer_current_tick(tp);
+
+ ticks = t2 - t1;
+
+ CU_ASSERT(t2 >= t1);
+ CU_ASSERT(ticks >= min);
+ CU_ASSERT(ticks <= max);
+
+ printf("\nClock source %i\n", clk_src);
+ printf(" Time nsec: %" PRIu64 "\n", nsec);
+ printf(" Measured ticks: %" PRIu64 "\n", ticks);
+ printf(" Expected ticks: %" PRIu64 "\n", odp_timer_ns_to_tick(tp, nsec));
+
+ odp_timer_pool_destroy(tp);
+}
+
+static void timer_pool_current_tick(void)
+{
+ odp_timer_clk_src_t clk_src;
+ int i;
+
+ for (i = 0; i < ODP_CLOCK_NUM_SRC; i++) {
+ clk_src = ODP_CLOCK_SRC_0 + i;
+ if (global_mem->clk_supported[i]) {
+ ODPH_DBG("\nTesting clock source: %i\n", clk_src);
+ timer_pool_current_tick_run(clk_src);
+ }
+ }
+}
+
+static void timer_pool_sample_ticks_run(odp_timer_clk_src_t clk_2)
+{
+ odp_timer_capability_t capa;
+ odp_timer_pool_param_t tp_param;
+ odp_timer_pool_t tp[2];
+ uint64_t t1[2], t2[2], ticks[2], min[2], max[2];
+ uint64_t clk_count[2] = {0};
+ odp_timer_clk_src_t clk_1 = ODP_CLOCK_DEFAULT;
+ uint64_t nsec = 100 * ODP_TIME_MSEC_IN_NS;
+
+ /* Highest resolution */
+ odp_timer_pool_param_init(&tp_param);
+ tp_param.num_timers = 100;
+
+ /* First timer pool: default clock source */
+ memset(&capa, 0, sizeof(capa));
+ CU_ASSERT_FATAL(odp_timer_capability(clk_1, &capa) == 0);
+ tp_param.clk_src = clk_1;
+ tp_param.res_hz = capa.max_res.res_hz;
+ tp_param.min_tmo = capa.max_res.min_tmo;
+ tp_param.max_tmo = capa.max_res.max_tmo;
+
+ tp[0] = odp_timer_pool_create("timer_pool_0", &tp_param);
+ CU_ASSERT_FATAL(tp[0] != ODP_TIMER_POOL_INVALID);
+
+ /* Second timer pool: another clock source */
+ memset(&capa, 0, sizeof(capa));
+ CU_ASSERT_FATAL(odp_timer_capability(clk_2, &capa) == 0);
+ tp_param.clk_src = clk_2;
+ tp_param.res_hz = capa.max_res.res_hz;
+ tp_param.min_tmo = capa.max_res.min_tmo;
+ tp_param.max_tmo = capa.max_res.max_tmo;
+
+ tp[1] = odp_timer_pool_create("timer_pool_1", &tp_param);
+ CU_ASSERT_FATAL(tp[1] != ODP_TIMER_POOL_INVALID);
+
+ odp_timer_pool_start();
+
+ /* Allow +-10% error margin */
+ min[0] = odp_timer_ns_to_tick(tp[0], 0.9 * nsec);
+ max[0] = odp_timer_ns_to_tick(tp[0], 1.1 * nsec);
+ min[1] = odp_timer_ns_to_tick(tp[1], 0.9 * nsec);
+ max[1] = odp_timer_ns_to_tick(tp[1], 1.1 * nsec);
+
+ CU_ASSERT_FATAL(odp_timer_sample_ticks(tp, t1, NULL, 2) == 0);
+
+ odp_time_wait_ns(nsec);
+
+ CU_ASSERT_FATAL(odp_timer_sample_ticks(tp, t2, clk_count, 2) == 0);
+
+ ticks[0] = t2[0] - t1[0];
+ ticks[1] = t2[1] - t1[1];
+
+ CU_ASSERT(t2[0] >= t1[0]);
+ CU_ASSERT(t2[1] >= t1[1]);
+ CU_ASSERT(ticks[0] >= min[0]);
+ CU_ASSERT(ticks[1] >= min[1]);
+ CU_ASSERT(ticks[0] <= max[0]);
+ CU_ASSERT(ticks[1] <= max[1]);
+
+ printf("\nClock source: %i, %i\n", clk_1, clk_2);
+ printf(" Time nsec: %" PRIu64 "\n", nsec);
+ printf(" Measured ticks: %" PRIu64 ", %" PRIu64 "\n", ticks[0], ticks[1]);
+ printf(" Expected ticks: %" PRIu64 ", %" PRIu64 "\n",
+ odp_timer_ns_to_tick(tp[0], nsec), odp_timer_ns_to_tick(tp[1], nsec));
+ printf(" T2 tick: %" PRIu64 ", %" PRIu64 "\n", t2[0], t2[1]);
+ printf(" Clk count: %" PRIu64 ", %" PRIu64 "\n", clk_count[0], clk_count[1]);
+
+ odp_timer_pool_destroy(tp[0]);
+ odp_timer_pool_destroy(tp[1]);
+}
+
+static void timer_pool_sample_ticks(void)
+{
+ for (int i = 0; i < ODP_CLOCK_NUM_SRC; i++) {
+ if (global_mem->clk_supported[i])
+ timer_pool_sample_ticks_run(ODP_CLOCK_SRC_0 + i);
+ }
+}
+
static void timer_pool_tick_info_run(odp_timer_clk_src_t clk_src)
{
odp_timer_capability_t capa;
@@ -1572,7 +1742,7 @@ static void timer_test_cancel(void)
odp_timer_t tim;
odp_event_t ev;
odp_timeout_t tmo;
- odp_timer_set_t rc;
+ odp_timer_retval_t rc;
int ret;
memset(&capa, 0, sizeof(capa));
@@ -1632,7 +1802,7 @@ static void timer_test_cancel(void)
CU_FAIL_FATAL("Failed to set timer (relative time)");
ev = ODP_EVENT_INVALID;
- if (odp_timer_cancel(tim, &ev) != 0)
+ if (odp_timer_cancel(tim, &ev) != ODP_TIMER_SUCCESS)
CU_FAIL_FATAL("Failed to cancel timer (relative time)");
if (ev == ODP_EVENT_INVALID)
@@ -1815,7 +1985,7 @@ static void timer_test_tmo_limit(odp_queue_type_t queue_type,
t2 = odp_time_local();
diff_ns = odp_time_diff_ns(t2, t1);
- CU_ASSERT(ret == 0);
+ CU_ASSERT(ret == ODP_TIMER_SUCCESS);
CU_ASSERT(ev != ODP_EVENT_INVALID);
if (ev != ODP_EVENT_INVALID)
@@ -1962,7 +2132,6 @@ static int worker_entrypoint(void *arg ODP_UNUSED)
int thr = odp_thread_id();
uint32_t i, allocated;
unsigned seed = thr;
- int rc;
odp_queue_t queue;
struct test_timer *tt;
uint32_t nset;
@@ -1976,7 +2145,7 @@ static int worker_entrypoint(void *arg ODP_UNUSED)
odp_event_t ev;
struct timespec ts;
uint32_t nstale;
- odp_timer_set_t timer_rc;
+ odp_timer_retval_t rc;
odp_timer_start_t start_param;
odp_timer_pool_t tp = global_mem->tp;
odp_pool_t tbp = global_mem->tbp;
@@ -2049,11 +2218,11 @@ static int worker_entrypoint(void *arg ODP_UNUSED)
start_param.tmo_ev = tt[i].ev;
tt[i].ev = ODP_EVENT_INVALID;
- timer_rc = odp_timer_start(tt[i].tim, &start_param);
- if (timer_rc == ODP_TIMER_TOO_NEAR) {
+ rc = odp_timer_start(tt[i].tim, &start_param);
+ if (rc == ODP_TIMER_TOO_NEAR) {
ODPH_ERR("Missed tick, setting timer\n");
- } else if (timer_rc != ODP_TIMER_SUCCESS) {
- ODPH_ERR("Failed to set timer: %d\n", timer_rc);
+ } else if (rc != ODP_TIMER_SUCCESS) {
+ ODPH_ERR("Failed to set timer: %d\n", rc);
CU_FAIL("Failed to set timer");
} else {
tt[i].tick = tck;
@@ -2087,16 +2256,18 @@ static int worker_entrypoint(void *arg ODP_UNUSED)
goto sleep;
/* Timer active, cancel it */
rc = odp_timer_cancel(tt[i].tim, &tt[i].ev);
- if (rc != 0) {
+
+ if (rc == ODP_TIMER_SUCCESS) {
+ tt[i].tick = TICK_INVALID;
+ ncancel++;
+ } else if (rc == ODP_TIMER_TOO_NEAR) {
/* Cancel failed, timer already expired */
ntoolate++;
- ODPH_DBG("Failed to cancel timer, probably already expired\n");
+ ODPH_DBG("Failed to cancel timer, already expired\n");
} else {
- tt[i].tick = TICK_INVALID;
- ncancel++;
+ CU_FAIL_FATAL("Cancel failed");
}
} else {
- odp_timer_set_t rc;
uint64_t cur_tick;
uint64_t tck;
int reset_timer = 0;
@@ -2151,15 +2322,21 @@ sleep:
CU_FAIL_FATAL("nanosleep failed");
}
- /* Cancel and free all timers */
+ /* Try to cancel all active timers */
nstale = 0;
for (i = 0; i < allocated; i++) {
- (void)odp_timer_cancel(tt[i].tim, &tt[i].ev);
+ if (tt[i].ev != ODP_EVENT_INVALID)
+ continue;
+
+ rc = odp_timer_cancel(tt[i].tim, &tt[i].ev);
tt[i].tick = TICK_INVALID;
- if (tt[i].ev == ODP_EVENT_INVALID)
- /* Cancel too late, timer already expired and
- * timeout enqueued */
+
+ if (rc == ODP_TIMER_TOO_NEAR) {
+ /* Cancel too late, timer already expired and timeout enqueued */
nstale++;
+ } else if (rc != ODP_TIMER_SUCCESS) {
+ CU_FAIL("Timer cancel failed");
+ }
}
ODPH_DBG("Thread %u: %" PRIu32 " timers set\n", thr, nset);
@@ -2207,8 +2384,7 @@ sleep:
if (ev != ODP_EVENT_INVALID)
CU_FAIL("Unexpected event received");
- rc = odp_queue_destroy(queue);
- CU_ASSERT(rc == 0);
+ CU_ASSERT(odp_queue_destroy(queue) == 0);
for (i = 0; i < allocated; i++) {
if (tt[i].ev != ODP_EVENT_INVALID)
odp_event_free(tt[i].ev);
@@ -2407,11 +2583,15 @@ static void timer_test_periodic_capa(void)
CU_ASSERT_FATAL(min_fract.integer || min_fract.numer);
CU_ASSERT_FATAL(max_fract.integer || max_fract.numer);
- if (min_fract.numer)
+ if (min_fract.numer) {
CU_ASSERT_FATAL(min_fract.denom);
+ CU_ASSERT_FATAL(min_fract.numer < min_fract.denom);
+ }
- if (max_fract.numer)
+ if (max_fract.numer) {
CU_ASSERT_FATAL(max_fract.denom);
+ CU_ASSERT_FATAL(max_fract.numer < max_fract.denom);
+ }
min_freq = odp_fract_u64_to_dbl(&min_fract);
max_freq = odp_fract_u64_to_dbl(&max_fract);
@@ -2497,8 +2677,11 @@ static void timer_test_periodic_capa(void)
capa.base_freq_hz.numer != base_freq.numer ||
capa.base_freq_hz.denom != base_freq.denom)
- if (capa.base_freq_hz.numer)
+ if (capa.base_freq_hz.numer) {
CU_ASSERT_FATAL(capa.base_freq_hz.denom);
+ CU_ASSERT_FATAL(capa.base_freq_hz.numer <
+ capa.base_freq_hz.denom);
+ }
CU_ASSERT(odp_fract_u64_to_dbl(&capa.base_freq_hz) >= min_freq);
CU_ASSERT(odp_fract_u64_to_dbl(&capa.base_freq_hz) <= max_freq);
@@ -2583,6 +2766,11 @@ static void timer_test_periodic(odp_queue_type_t queue_type, int use_first)
if (ret == 0) {
/* Allow 10% difference in outputted base frequency */
CU_ASSERT((freq_out > (0.9 * freq)) && (freq_out < (1.1 * freq)));
+
+ if (periodic_capa.base_freq_hz.numer) {
+ CU_ASSERT_FATAL(periodic_capa.base_freq_hz.numer <
+ periodic_capa.base_freq_hz.denom);
+ }
} else {
CU_ASSERT(base_freq.integer == periodic_capa.base_freq_hz.integer);
CU_ASSERT(base_freq.numer == periodic_capa.base_freq_hz.numer);
@@ -2798,6 +2986,8 @@ odp_testinfo_t timer_suite[] = {
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_current_tick),
+ ODP_TEST_INFO(timer_pool_sample_ticks),
ODP_TEST_INFO(timer_pool_tick_info),
ODP_TEST_INFO_CONDITIONAL(timer_plain_rel_wait, check_plain_queue_support),
ODP_TEST_INFO_CONDITIONAL(timer_plain_abs_wait, check_plain_queue_support),