aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2024-06-05 13:51:39 +0300
committerGitHub <noreply@github.com>2024-06-05 13:51:39 +0300
commit616034b9c9c789923f7ebe7f1c6d014c4ce8a5d2 (patch)
treedd1b579c93404d2d98b78944bbdf8313ec499bee
parent8063101c4fac56e16c5a2bb9843f2fd9c5acbfd7 (diff)
parent87913e636da621d47a8d3bc91fbe131abc09c294 (diff)
Merge ODP linux-generic v1.45.0.0 into linux-dpdk.
-rw-r--r--.github/workflows/ci-pipeline.yml19
-rw-r--r--CHANGELOG124
-rw-r--r--configure.ac4
-rw-r--r--doc/application-api-guide/api_guide_lines.dox7
-rw-r--r--doc/application-api-guide/odp.dox6
-rw-r--r--doc/application-api-guide/release.dox6
-rw-r--r--doc/helper-guide/odp.dox6
-rw-r--r--doc/users-guide/users-guide-packet.adoc8
-rw-r--r--doc/users-guide/users-guide-utilities-examples.adoc5
-rw-r--r--example/Makefile.am2
-rw-r--r--example/classifier/odp_classifier.c48
-rw-r--r--example/cli/odp_cli.c15
-rw-r--r--example/generator/.gitignore2
-rw-r--r--example/generator/Makefile.am34
-rwxr-xr-xexample/generator/generator_run.sh29
-rw-r--r--example/generator/odp_generator.c1760
-rw-r--r--example/ipfragreass/odp_ipfragreass_reassemble.c2
-rw-r--r--example/ipsec_api/odp_ipsec.c7
-rw-r--r--example/ipsec_crypto/odp_ipsec.c7
-rw-r--r--example/ipsec_crypto/odp_ipsec_fwd_db.c3
-rw-r--r--example/ipsec_crypto/odp_ipsec_misc.h8
-rw-r--r--example/ipsec_crypto/odp_ipsec_stream.c25
-rw-r--r--example/ipsec_crypto/odp_ipsec_stream.h7
-rw-r--r--example/l2fwd/README14
l---------example/l2fwd/odp_l2fwd.c1
-rw-r--r--example/l2fwd_simple/odp_l2fwd_simple.c16
-rw-r--r--example/l3fwd/odp_l3fwd_db.c3
-rw-r--r--example/m4/configure.m42
-rw-r--r--example/simple_pipeline/odp_simple_pipeline.c3
-rw-r--r--example/sysinfo/odp_sysinfo.c94
-rw-r--r--example/time/.gitignore1
-rw-r--r--example/time/Makefile.am9
-rw-r--r--example/time/odp_time_global_test.c397
-rw-r--r--example/timer/.gitignore2
-rw-r--r--example/timer/Makefile.am13
-rwxr-xr-xexample/timer/odp_timer_accuracy_run.sh7
-rw-r--r--example/timer/odp_timer_test.c569
-rw-r--r--example/traffic_mgmt/odp_traffic_mgmt.c6
-rw-r--r--helper/Makefile.am18
-rw-r--r--helper/cli.c4
-rw-r--r--helper/cuckootable.c776
-rw-r--r--helper/hashtable.c356
-rw-r--r--helper/include/odp/helper/debug.h (renamed from helper/include/odp/helper/odph_debug.h)0
-rw-r--r--helper/include/odp/helper/odph_api.h9
-rw-r--r--helper/include/odp/helper/odph_cuckootable.h146
-rw-r--r--helper/include/odp/helper/odph_hashtable.h111
-rw-r--r--helper/include/odp/helper/odph_iplookuptable.h125
-rw-r--r--helper/include/odp/helper/odph_lineartable.h101
-rw-r--r--helper/include/odp/helper/stress.h238
-rw-r--r--helper/include/odp/helper/string.h62
-rw-r--r--helper/include/odp/helper/table.h244
-rw-r--r--helper/include/odp/helper/threads.h45
-rw-r--r--helper/include/odph_list_internal.h88
-rw-r--r--helper/iplookuptable.c990
-rw-r--r--helper/ipsec.c2
-rw-r--r--helper/lineartable.c216
-rw-r--r--helper/linux/thread.c2
-rw-r--r--helper/m4/configure.m44
-rw-r--r--helper/m4/libcli.m44
-rw-r--r--helper/test/.gitignore4
-rw-r--r--helper/test/Makefile.am10
-rw-r--r--helper/test/cli.c15
-rw-r--r--helper/test/cuckootable.c577
-rw-r--r--helper/test/iplookuptable.c170
-rw-r--r--helper/test/odpthreads.c39
-rw-r--r--helper/test/stress.c118
-rw-r--r--helper/test/table.c130
-rw-r--r--helper/threads.c85
-rw-r--r--include/odp/api/abi-default/proto_stats_types.h2
-rw-r--r--include/odp/api/abi-default/traffic_mngr.h2
-rw-r--r--include/odp/api/spec/classification.h4
-rw-r--r--include/odp/api/spec/cpu.h94
-rw-r--r--include/odp/api/spec/crypto_types.h211
-rw-r--r--include/odp/api/spec/dma.h6
-rw-r--r--include/odp/api/spec/dma_types.h2
-rw-r--r--include/odp/api/spec/event.h16
-rw-r--r--include/odp/api/spec/hints.h19
-rw-r--r--include/odp/api/spec/ml.h9
-rw-r--r--include/odp/api/spec/ml_types.h8
-rw-r--r--include/odp/api/spec/packet.h57
-rw-r--r--include/odp/api/spec/packet_io_stats.h4
-rw-r--r--include/odp/api/spec/pool.h5
-rw-r--r--include/odp/api/spec/pool_types.h10
-rw-r--r--include/odp/api/spec/proto_stats.h3
-rw-r--r--include/odp/api/spec/proto_stats_types.h5
-rw-r--r--include/odp/api/spec/queue.h2
-rw-r--r--include/odp/api/spec/queue_types.h2
-rw-r--r--include/odp/api/spec/schedule.h2
-rw-r--r--include/odp/api/spec/schedule_types.h2
-rw-r--r--include/odp/api/spec/shared_memory.h8
-rw-r--r--include/odp/api/spec/stash.h2
-rw-r--r--include/odp/api/spec/stash_types.h2
-rw-r--r--include/odp/api/spec/timer.h2
-rw-r--r--include/odp/api/spec/timer_types.h2
-rw-r--r--include/odp/api/spec/traffic_mngr.h22
-rw-r--r--m4/odp_atomic.m44
-rw-r--r--m4/odp_check_flag.m46
-rw-r--r--m4/odp_dpdk.m44
-rw-r--r--m4/odp_libconfig.m44
-rw-r--r--m4/odp_openssl.m44
-rw-r--r--m4/odp_pthread.m47
-rw-r--r--m4/odp_timer.m44
-rw-r--r--m4/odp_visibility.m44
-rw-r--r--platform/linux-dpdk/Makefile.am22
-rw-r--r--platform/linux-dpdk/README9
-rw-r--r--platform/linux-dpdk/arch/aarch64/odp/api/abi/cpu.h8
-rw-r--r--platform/linux-dpdk/arch/arm/odp/api/abi/cpu.h8
-rw-r--r--platform/linux-dpdk/arch/default/odp/api/abi/cpu.h8
-rw-r--r--platform/linux-dpdk/arch/powerpc/odp/api/abi/cpu.h8
-rw-r--r--platform/linux-dpdk/arch/x86/odp/api/abi/cpu.h8
-rw-r--r--platform/linux-dpdk/doc/platform_specific.dox6
-rw-r--r--platform/linux-dpdk/include-abi/odp/api/abi/packet.h6
-rw-r--r--platform/linux-dpdk/include-abi/odp/api/abi/packet_types.h8
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/buffer_inlines.h6
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/byteorder_inlines.h6
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/event_inline_types.h8
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/packet_flag_inlines.h6
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/packet_inline_types.h8
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/packet_inlines.h14
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/std_inlines.h6
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/time_inlines.h8
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/timer_inline_types.h6
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/timer_inlines.h6
-rw-r--r--platform/linux-dpdk/include/odp_buffer_internal.h8
-rw-r--r--platform/linux-dpdk/include/odp_config_internal.h8
-rw-r--r--platform/linux-dpdk/include/odp_errno_define.h6
-rw-r--r--platform/linux-dpdk/include/odp_event_internal.h6
-rw-r--r--platform/linux-dpdk/include/odp_event_vector_internal.h6
-rw-r--r--platform/linux-dpdk/include/odp_eventdev_internal.h6
-rw-r--r--platform/linux-dpdk/include/odp_packet_internal.h8
-rw-r--r--platform/linux-dpdk/include/odp_packet_io_internal.h8
-rw-r--r--platform/linux-dpdk/include/odp_pool_internal.h8
l---------platform/linux-dpdk/include/odp_posix_extensions.h1
-rw-r--r--platform/linux-dpdk/include/odp_ptr_ring_mpmc_internal.h6
-rw-r--r--platform/linux-dpdk/include/odp_ptr_ring_spsc_internal.h6
-rw-r--r--platform/linux-dpdk/include/odp_ptr_ring_st_internal.h6
-rw-r--r--platform/linux-dpdk/include/odp_queue_basic_internal.h6
-rw-r--r--platform/linux-dpdk/include/odp_shm_internal.h6
-rw-r--r--platform/linux-dpdk/include/odp_thread_internal.h6
-rw-r--r--platform/linux-dpdk/include/odp_timer_internal.h8
l---------platform/linux-dpdk/include/protocols1
-rw-r--r--platform/linux-dpdk/m4/configure.m45
-rw-r--r--platform/linux-dpdk/m4/odp_libconfig.m44
-rw-r--r--platform/linux-dpdk/odp_buffer.c10
-rw-r--r--platform/linux-dpdk/odp_crypto.c34
-rw-r--r--platform/linux-dpdk/odp_dma.c7
-rw-r--r--platform/linux-dpdk/odp_errno.c6
-rw-r--r--platform/linux-dpdk/odp_event.c8
-rw-r--r--platform/linux-dpdk/odp_init.c22
-rw-r--r--platform/linux-dpdk/odp_packet.c38
-rw-r--r--platform/linux-dpdk/odp_packet_dpdk.c33
-rw-r--r--platform/linux-dpdk/odp_packet_flags.c6
-rw-r--r--platform/linux-dpdk/odp_pool.c36
-rw-r--r--platform/linux-dpdk/odp_queue_basic.c18
-rw-r--r--platform/linux-dpdk/odp_queue_eventdev.c16
-rw-r--r--platform/linux-dpdk/odp_queue_if.c8
-rw-r--r--platform/linux-dpdk/odp_queue_spsc.c9
-rw-r--r--platform/linux-dpdk/odp_schedule_eventdev.c16
-rw-r--r--platform/linux-dpdk/odp_schedule_if.c8
-rw-r--r--platform/linux-dpdk/odp_shared_memory.c33
-rw-r--r--platform/linux-dpdk/odp_std_api.c6
-rw-r--r--platform/linux-dpdk/odp_system_info.c16
-rw-r--r--platform/linux-dpdk/odp_thread.c58
-rw-r--r--platform/linux-dpdk/odp_time.c8
-rw-r--r--platform/linux-dpdk/odp_timer.c19
-rw-r--r--platform/linux-dpdk/test/example/Makefile.am1
-rw-r--r--platform/linux-dpdk/test/example/classifier/pktio_env6
-rw-r--r--platform/linux-dpdk/test/example/generator/Makefile.am1
-rw-r--r--platform/linux-dpdk/test/example/generator/pktio_env34
-rw-r--r--platform/linux-dpdk/test/example/ipsec_api/pktio_env6
-rw-r--r--platform/linux-dpdk/test/example/ipsec_crypto/pktio_env6
-rw-r--r--platform/linux-dpdk/test/example/l2fwd_simple/pktio_env8
-rw-r--r--platform/linux-dpdk/test/example/l3fwd/pktio_env8
-rw-r--r--platform/linux-dpdk/test/example/packet/pktio_env8
-rw-r--r--platform/linux-dpdk/test/example/ping/pktio_env8
-rw-r--r--platform/linux-dpdk/test/example/simple_pipeline/pktio_env8
-rw-r--r--platform/linux-dpdk/test/example/switch/pktio_env8
-rwxr-xr-xplatform/linux-dpdk/test/validation/api/pktio/pktio_run.sh6
-rw-r--r--platform/linux-generic/Makefile.am6
-rw-r--r--platform/linux-generic/README8
-rw-r--r--platform/linux-generic/arch/aarch64/cpu_flags.c8
-rw-r--r--platform/linux-generic/arch/aarch64/cpu_flags.h6
-rw-r--r--platform/linux-generic/arch/aarch64/odp/api/abi/atomic.h6
-rw-r--r--platform/linux-generic/arch/aarch64/odp/api/abi/atomic_inlines.h8
-rw-r--r--platform/linux-generic/arch/aarch64/odp/api/abi/cpu.h6
-rw-r--r--platform/linux-generic/arch/aarch64/odp/api/abi/cpu_inlines.h8
-rw-r--r--platform/linux-generic/arch/aarch64/odp/api/abi/hash_crc32.h6
-rw-r--r--platform/linux-generic/arch/aarch64/odp/api/abi/time_cpu.h6
-rw-r--r--platform/linux-generic/arch/aarch64/odp/api/abi/time_inlines.h6
-rw-r--r--platform/linux-generic/arch/aarch64/odp_atomic.c8
-rw-r--r--platform/linux-generic/arch/aarch64/odp_atomic.h8
-rw-r--r--platform/linux-generic/arch/aarch64/odp_cpu.h9
-rw-r--r--platform/linux-generic/arch/aarch64/odp_crypto_armv8.c10
-rw-r--r--platform/linux-generic/arch/aarch64/odp_random.h6
-rw-r--r--platform/linux-generic/arch/aarch64/odp_sysinfo_parse.c8
-rw-r--r--platform/linux-generic/arch/arm/odp/api/abi/cpu.h6
-rw-r--r--platform/linux-generic/arch/arm/odp/api/abi/cpu_inlines.h8
-rw-r--r--platform/linux-generic/arch/arm/odp_cpu.h9
-rw-r--r--platform/linux-generic/arch/arm/odp_sysinfo_parse.c6
-rw-r--r--platform/linux-generic/arch/common/odp/api/abi/time_cpu_inlines.h8
-rw-r--r--platform/linux-generic/arch/common/odp_time_cpu.c8
-rw-r--r--platform/linux-generic/arch/default/odp/api/abi/atomic_generic.h8
-rw-r--r--platform/linux-generic/arch/default/odp/api/abi/atomic_inlines.h6
-rw-r--r--platform/linux-generic/arch/default/odp/api/abi/cpu.h6
-rw-r--r--platform/linux-generic/arch/default/odp/api/abi/cpu_generic.h8
-rw-r--r--platform/linux-generic/arch/default/odp/api/abi/cpu_inlines.h6
-rw-r--r--platform/linux-generic/arch/default/odp/api/abi/hash_crc32.h6
-rw-r--r--platform/linux-generic/arch/default/odp/api/abi/time_inlines.h8
-rw-r--r--platform/linux-generic/arch/default/odp_atomic.c8
-rw-r--r--platform/linux-generic/arch/default/odp_atomic.h6
-rw-r--r--platform/linux-generic/arch/default/odp_cpu.h9
-rw-r--r--platform/linux-generic/arch/default/odp_cpu_cycles.c8
-rw-r--r--platform/linux-generic/arch/default/odp_hash_crc32.c40
-rw-r--r--platform/linux-generic/arch/default/odp_random.c6
-rw-r--r--platform/linux-generic/arch/default/odp_random.h6
-rw-r--r--platform/linux-generic/arch/default/odp_sysinfo_parse.c6
-rw-r--r--platform/linux-generic/arch/default/odp_time.c8
-rw-r--r--platform/linux-generic/arch/powerpc/odp/api/abi/cpu.h8
-rw-r--r--platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c15
-rw-r--r--platform/linux-generic/arch/x86/cpu_flags.c13
-rw-r--r--platform/linux-generic/arch/x86/cpu_flags.h6
-rw-r--r--platform/linux-generic/arch/x86/odp/api/abi/cpu.h6
-rw-r--r--platform/linux-generic/arch/x86/odp/api/abi/cpu_inlines.h8
-rw-r--r--platform/linux-generic/arch/x86/odp/api/abi/cpu_rdtsc.h6
-rw-r--r--platform/linux-generic/arch/x86/odp/api/abi/hash_crc32.h15
-rw-r--r--platform/linux-generic/arch/x86/odp/api/abi/time_cpu.h6
-rw-r--r--platform/linux-generic/arch/x86/odp/api/abi/time_inlines.h6
-rw-r--r--platform/linux-generic/arch/x86/odp_cpu.h6
-rw-r--r--platform/linux-generic/arch/x86/odp_cpu_cycles.c6
-rw-r--r--platform/linux-generic/arch/x86/odp_random.h6
-rw-r--r--platform/linux-generic/arch/x86/odp_sysinfo_parse.c13
-rw-r--r--platform/linux-generic/doc/platform_specific.dox6
-rw-r--r--platform/linux-generic/dumpconfig/dumpconfig.c6
-rw-r--r--platform/linux-generic/example/ml/mnist.c4
-rw-r--r--platform/linux-generic/example/ml/model_explorer.c5
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/align.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/atomic.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/barrier.h39
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/buffer.h8
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/buffer_types.h8
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/byteorder.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/classification.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/comp.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/cpumask.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/crypto.h9
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/crypto_types.h8
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/debug.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/dma.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/dma_types.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/errno.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/event.h9
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/event_types.h8
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/hash.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/init.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/ipsec.h8
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/ipsec_types.h8
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/packet.h8
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/packet_flags.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/packet_io.h9
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/packet_io_types.h8
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/packet_types.h8
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/pool.h8
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/pool_types.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/proto_stats.h8
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/proto_stats_types.h8
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/queue.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/queue_types.h8
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/random.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/rwlock.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/rwlock_recursive.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/schedule.h8
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/schedule_types.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/shared_memory.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/spinlock.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/spinlock_recursive.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/stash.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/stash_types.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/std.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/std_types.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/sync.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/thread.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/thrmask.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/ticketlock.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/time.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/time_types.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/timer.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/timer_types.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/traffic_mngr.h6
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/version.h6
-rw-r--r--platform/linux-generic/include/ishmphy_internal.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/atomic_inlines.h8
-rw-r--r--platform/linux-generic/include/odp/api/plat/buffer_inline_types.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/buffer_inlines.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/byteorder_inlines.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/cpu_inlines.h84
-rw-r--r--platform/linux-generic/include/odp/api/plat/crypto_inlines.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/debug_inlines.h8
-rw-r--r--platform/linux-generic/include/odp/api/plat/dma_inlines.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/event_inline_types.h8
-rw-r--r--platform/linux-generic/include/odp/api/plat/event_inlines.h37
-rw-r--r--platform/linux-generic/include/odp/api/plat/event_validation_external.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/event_vector_inline_types.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/hash_inlines.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/ipsec_inlines.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h8
-rw-r--r--platform/linux-generic/include/odp/api/plat/packet_inline_types.h8
-rw-r--r--platform/linux-generic/include/odp/api/plat/packet_inlines.h9
-rw-r--r--platform/linux-generic/include/odp/api/plat/packet_io_inlines.h8
-rw-r--r--platform/linux-generic/include/odp/api/plat/packet_vector_inlines.h7
-rw-r--r--platform/linux-generic/include/odp/api/plat/pool_inline_types.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/pool_inlines.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/queue_inline_types.h8
-rw-r--r--platform/linux-generic/include/odp/api/plat/queue_inlines.h8
-rw-r--r--platform/linux-generic/include/odp/api/plat/rwlock_inlines.h8
-rw-r--r--platform/linux-generic/include/odp/api/plat/rwlock_recursive_inlines.h8
-rw-r--r--platform/linux-generic/include/odp/api/plat/schedule_inline_types.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/schedule_inlines.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/spinlock_inlines.h8
-rw-r--r--platform/linux-generic/include/odp/api/plat/spinlock_recursive_inlines.h8
-rw-r--r--platform/linux-generic/include/odp/api/plat/std_inlines.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/strong_types.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/thread_inline_types.h8
-rw-r--r--platform/linux-generic/include/odp/api/plat/thread_inlines.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/time_inlines.h8
-rw-r--r--platform/linux-generic/include/odp/api/plat/timer_inline_types.h6
-rw-r--r--platform/linux-generic/include/odp/api/plat/timer_inlines.h6
-rw-r--r--platform/linux-generic/include/odp_atomic_internal.h6
-rw-r--r--platform/linux-generic/include/odp_bitset.h9
-rw-r--r--platform/linux-generic/include/odp_buffer_internal.h8
-rw-r--r--platform/linux-generic/include/odp_chksum_internal.h6
-rw-r--r--platform/linux-generic/include/odp_classification_datamodel.h6
-rw-r--r--platform/linux-generic/include/odp_classification_internal.h8
-rw-r--r--platform/linux-generic/include/odp_config_internal.h8
-rw-r--r--platform/linux-generic/include/odp_debug_internal.h9
-rw-r--r--platform/linux-generic/include/odp_errno_define.h6
-rw-r--r--platform/linux-generic/include/odp_ethtool_rss.h6
-rw-r--r--platform/linux-generic/include/odp_ethtool_stats.h8
-rw-r--r--platform/linux-generic/include/odp_event_internal.h6
-rw-r--r--platform/linux-generic/include/odp_event_validation_internal.h6
-rw-r--r--platform/linux-generic/include/odp_event_vector_internal.h6
-rw-r--r--platform/linux-generic/include/odp_fdserver_internal.h6
-rw-r--r--platform/linux-generic/include/odp_forward_typedefs_internal.h6
-rw-r--r--platform/linux-generic/include/odp_global_data.h8
-rw-r--r--platform/linux-generic/include/odp_init_internal.h6
-rw-r--r--platform/linux-generic/include/odp_ipsec_internal.h8
-rw-r--r--platform/linux-generic/include/odp_ishmphy_internal.h6
-rw-r--r--platform/linux-generic/include/odp_ishmpool_internal.h6
-rw-r--r--platform/linux-generic/include/odp_libconfig_internal.h6
-rw-r--r--platform/linux-generic/include/odp_llqueue.h9
-rw-r--r--platform/linux-generic/include/odp_macros_internal.h8
-rw-r--r--platform/linux-generic/include/odp_name_table_internal.h12
-rw-r--r--platform/linux-generic/include/odp_packet_dpdk.h8
-rw-r--r--platform/linux-generic/include/odp_packet_internal.h40
-rw-r--r--platform/linux-generic/include/odp_packet_io_internal.h8
-rw-r--r--platform/linux-generic/include/odp_packet_io_stats.h8
-rw-r--r--platform/linux-generic/include/odp_packet_io_stats_common.h6
-rw-r--r--platform/linux-generic/include/odp_parse_internal.h8
-rw-r--r--platform/linux-generic/include/odp_pcapng.h8
-rw-r--r--platform/linux-generic/include/odp_pkt_queue_internal.h9
-rw-r--r--platform/linux-generic/include/odp_pool_internal.h8
-rw-r--r--platform/linux-generic/include/odp_posix_extensions.h6
-rw-r--r--platform/linux-generic/include/odp_print_internal.h22
-rw-r--r--platform/linux-generic/include/odp_queue_basic_internal.h8
-rw-r--r--platform/linux-generic/include/odp_queue_if.h8
-rw-r--r--platform/linux-generic/include/odp_queue_lf.h6
-rw-r--r--platform/linux-generic/include/odp_queue_scalable_internal.h9
-rw-r--r--platform/linux-generic/include/odp_random_openssl_internal.h6
-rw-r--r--platform/linux-generic/include/odp_random_std_internal.h6
-rw-r--r--platform/linux-generic/include/odp_ring_common.h6
-rw-r--r--platform/linux-generic/include/odp_ring_internal.h8
-rw-r--r--platform/linux-generic/include/odp_ring_mpmc_internal.h8
-rw-r--r--platform/linux-generic/include/odp_ring_mpmc_u32_internal.h6
-rw-r--r--platform/linux-generic/include/odp_ring_mpmc_u64_internal.h6
-rw-r--r--platform/linux-generic/include/odp_ring_ptr_internal.h6
-rw-r--r--platform/linux-generic/include/odp_ring_spsc_internal.h6
-rw-r--r--platform/linux-generic/include/odp_ring_st_internal.h6
-rw-r--r--platform/linux-generic/include/odp_ring_u32_internal.h6
-rw-r--r--platform/linux-generic/include/odp_ring_u64_internal.h6
-rw-r--r--platform/linux-generic/include/odp_schedule_if.h8
-rw-r--r--platform/linux-generic/include/odp_schedule_scalable.h9
-rw-r--r--platform/linux-generic/include/odp_schedule_scalable_config.h9
-rw-r--r--platform/linux-generic/include/odp_schedule_scalable_ordered.h9
-rw-r--r--platform/linux-generic/include/odp_shm_internal.h8
-rw-r--r--platform/linux-generic/include/odp_socket_common.h8
-rw-r--r--platform/linux-generic/include/odp_sorted_list_internal.h9
-rw-r--r--platform/linux-generic/include/odp_string_internal.h34
-rw-r--r--platform/linux-generic/include/odp_sysfs_stats.h8
-rw-r--r--platform/linux-generic/include/odp_sysinfo_internal.h6
-rw-r--r--platform/linux-generic/include/odp_timer_internal.h8
-rw-r--r--platform/linux-generic/include/odp_timer_wheel_internal.h9
-rw-r--r--platform/linux-generic/include/odp_traffic_mngr_internal.h11
-rw-r--r--platform/linux-generic/include/odp_types_internal.h6
-rw-r--r--platform/linux-generic/include/protocols/eth.h6
-rw-r--r--platform/linux-generic/include/protocols/ip.h6
-rw-r--r--platform/linux-generic/include/protocols/ipsec.h6
-rw-r--r--platform/linux-generic/include/protocols/sctp.h6
-rw-r--r--platform/linux-generic/include/protocols/tcp.h6
-rw-r--r--platform/linux-generic/include/protocols/thash.h6
-rw-r--r--platform/linux-generic/include/protocols/udp.h6
-rw-r--r--platform/linux-generic/m4/configure.m45
-rw-r--r--platform/linux-generic/m4/odp_cpu.m44
-rw-r--r--platform/linux-generic/m4/odp_crypto.m45
-rw-r--r--platform/linux-generic/m4/odp_dpdk.m44
-rw-r--r--platform/linux-generic/m4/odp_event_validation.m44
-rw-r--r--platform/linux-generic/m4/odp_ipsec_mb.m44
-rw-r--r--platform/linux-generic/m4/odp_libconfig.m44
-rw-r--r--platform/linux-generic/m4/odp_ml.m44
-rw-r--r--platform/linux-generic/m4/odp_openssl.m44
-rw-r--r--platform/linux-generic/m4/odp_pcap.m44
-rw-r--r--platform/linux-generic/m4/odp_pcapng.m44
-rw-r--r--platform/linux-generic/m4/odp_scheduler.m44
-rw-r--r--platform/linux-generic/m4/odp_wfe.m44
-rw-r--r--platform/linux-generic/m4/odp_xdp.m44
-rw-r--r--platform/linux-generic/odp_atomic_api.c6
-rw-r--r--platform/linux-generic/odp_barrier.c6
-rw-r--r--platform/linux-generic/odp_buffer.c10
-rw-r--r--platform/linux-generic/odp_buffer_api.c6
-rw-r--r--platform/linux-generic/odp_byteorder_api.c6
-rw-r--r--platform/linux-generic/odp_chksum.c6
-rw-r--r--platform/linux-generic/odp_classification.c18
-rw-r--r--platform/linux-generic/odp_comp.c6
-rw-r--r--platform/linux-generic/odp_cpu_api.c6
-rw-r--r--platform/linux-generic/odp_cpumask.c6
-rw-r--r--platform/linux-generic/odp_cpumask_task.c8
-rw-r--r--platform/linux-generic/odp_crypto_api.c6
-rw-r--r--platform/linux-generic/odp_crypto_ipsecmb.c10
-rw-r--r--platform/linux-generic/odp_crypto_null.c8
-rw-r--r--platform/linux-generic/odp_crypto_openssl.c14
-rw-r--r--platform/linux-generic/odp_dma.c13
-rw-r--r--platform/linux-generic/odp_dma_api.c6
-rw-r--r--platform/linux-generic/odp_errno.c6
-rw-r--r--platform/linux-generic/odp_event.c8
-rw-r--r--platform/linux-generic/odp_event_api.c6
-rw-r--r--platform/linux-generic/odp_event_validation.c8
-rw-r--r--platform/linux-generic/odp_fdserver.c6
-rw-r--r--platform/linux-generic/odp_hash_api.c6
-rw-r--r--platform/linux-generic/odp_hash_crc_gen.c36
-rw-r--r--platform/linux-generic/odp_impl.c6
-rw-r--r--platform/linux-generic/odp_init.c8
-rw-r--r--platform/linux-generic/odp_ipsec.c8
-rw-r--r--platform/linux-generic/odp_ipsec_api.c6
-rw-r--r--platform/linux-generic/odp_ipsec_events.c6
-rw-r--r--platform/linux-generic/odp_ipsec_sad.c8
-rw-r--r--platform/linux-generic/odp_ishm.c26
-rw-r--r--platform/linux-generic/odp_ishmphy.c6
-rw-r--r--platform/linux-generic/odp_ishmpool.c6
-rw-r--r--platform/linux-generic/odp_libconfig.c10
-rw-r--r--platform/linux-generic/odp_ml.c49
-rw-r--r--platform/linux-generic/odp_name_table.c9
-rw-r--r--platform/linux-generic/odp_packet.c28
-rw-r--r--platform/linux-generic/odp_packet_api.c6
-rw-r--r--platform/linux-generic/odp_packet_flags.c6
-rw-r--r--platform/linux-generic/odp_packet_flags_api.c6
-rw-r--r--platform/linux-generic/odp_packet_io.c14
-rw-r--r--platform/linux-generic/odp_packet_io_api.c6
-rw-r--r--platform/linux-generic/odp_packet_vector.c8
-rw-r--r--platform/linux-generic/odp_parse.c21
-rw-r--r--platform/linux-generic/odp_pcapng.c8
-rw-r--r--platform/linux-generic/odp_pkt_queue.c12
-rw-r--r--platform/linux-generic/odp_pool.c31
-rw-r--r--platform/linux-generic/odp_pool_api.c6
-rw-r--r--platform/linux-generic/odp_pool_mem_src_ops.c6
-rw-r--r--platform/linux-generic/odp_queue_api.c6
-rw-r--r--platform/linux-generic/odp_queue_basic.c17
-rw-r--r--platform/linux-generic/odp_queue_if.c8
-rw-r--r--platform/linux-generic/odp_queue_lf.c8
-rw-r--r--platform/linux-generic/odp_queue_scalable.c12
-rw-r--r--platform/linux-generic/odp_queue_spsc.c8
-rw-r--r--platform/linux-generic/odp_random.c6
-rw-r--r--platform/linux-generic/odp_random_openssl.c8
-rw-r--r--platform/linux-generic/odp_random_std.c29
-rw-r--r--platform/linux-generic/odp_rwlock_api.c6
-rw-r--r--platform/linux-generic/odp_rwlock_recursive_api.c6
-rw-r--r--platform/linux-generic/odp_schedule_api.c6
-rw-r--r--platform/linux-generic/odp_schedule_basic.c35
-rw-r--r--platform/linux-generic/odp_schedule_if.c8
-rw-r--r--platform/linux-generic/odp_schedule_scalable.c12
-rw-r--r--platform/linux-generic/odp_schedule_scalable_ordered.c9
-rw-r--r--platform/linux-generic/odp_schedule_sp.c33
-rw-r--r--platform/linux-generic/odp_shared_memory.c8
-rw-r--r--platform/linux-generic/odp_sorted_list.c9
-rw-r--r--platform/linux-generic/odp_spinlock_api.c6
-rw-r--r--platform/linux-generic/odp_spinlock_recursive_api.c6
-rw-r--r--platform/linux-generic/odp_stash.c6
-rw-r--r--platform/linux-generic/odp_std.c6
-rw-r--r--platform/linux-generic/odp_std_api.c6
-rw-r--r--platform/linux-generic/odp_string.c (renamed from platform/linux-generic/odp_print.c)24
-rw-r--r--platform/linux-generic/odp_sync_api.c6
-rw-r--r--platform/linux-generic/odp_system_info.c17
-rw-r--r--platform/linux-generic/odp_thread.c58
-rw-r--r--platform/linux-generic/odp_thread_api.c6
-rw-r--r--platform/linux-generic/odp_thrmask.c6
-rw-r--r--platform/linux-generic/odp_ticketlock_api.c6
-rw-r--r--platform/linux-generic/odp_time_api.c6
-rw-r--r--platform/linux-generic/odp_timer.c49
-rw-r--r--platform/linux-generic/odp_timer_api.c6
-rw-r--r--platform/linux-generic/odp_timer_wheel.c9
-rw-r--r--platform/linux-generic/odp_traffic_mngr.c48
-rw-r--r--platform/linux-generic/odp_version.c6
-rw-r--r--platform/linux-generic/odp_weak.c6
-rw-r--r--platform/linux-generic/pktio/dpdk.c35
-rw-r--r--platform/linux-generic/pktio/ethtool_rss.c6
-rw-r--r--platform/linux-generic/pktio/io_ops.c6
-rw-r--r--platform/linux-generic/pktio/ipc.c10
-rw-r--r--platform/linux-generic/pktio/loop.c8
-rw-r--r--platform/linux-generic/pktio/null.c8
-rw-r--r--platform/linux-generic/pktio/pcap.c10
-rw-r--r--platform/linux-generic/pktio/pktio_common.c8
-rw-r--r--platform/linux-generic/pktio/socket.c8
-rw-r--r--platform/linux-generic/pktio/socket_common.c8
-rw-r--r--platform/linux-generic/pktio/socket_mmap.c8
-rw-r--r--platform/linux-generic/pktio/socket_xdp.c6
-rw-r--r--platform/linux-generic/pktio/stats/ethtool_stats.c11
-rw-r--r--platform/linux-generic/pktio/stats/packet_io_stats.c8
-rw-r--r--platform/linux-generic/pktio/stats/sysfs_stats.c8
-rw-r--r--platform/linux-generic/pktio/tap.c8
-rw-r--r--platform/linux-generic/test/example/Makefile.am1
-rw-r--r--platform/linux-generic/test/example/classifier/pktio_env6
-rw-r--r--platform/linux-generic/test/example/generator/Makefile.am1
-rw-r--r--platform/linux-generic/test/example/generator/pktio_env34
-rw-r--r--platform/linux-generic/test/example/ipsec_api/pktio_env6
-rw-r--r--platform/linux-generic/test/example/ipsec_crypto/pktio_env6
-rw-r--r--platform/linux-generic/test/example/l2fwd_simple/pktio_env6
-rw-r--r--platform/linux-generic/test/example/l3fwd/pktio_env6
-rw-r--r--platform/linux-generic/test/example/packet/pktio_env6
-rw-r--r--platform/linux-generic/test/example/ping/pktio_env6
-rw-r--r--platform/linux-generic/test/example/simple_pipeline/pktio_env6
-rw-r--r--platform/linux-generic/test/example/switch/pktio_env6
-rw-r--r--platform/linux-generic/test/validation/api/ml/ml_linux.c16
-rw-r--r--platform/linux-generic/test/validation/api/pktio/pktio_env6
-rwxr-xr-xplatform/linux-generic/test/validation/api/pktio/pktio_run.sh6
-rwxr-xr-xplatform/linux-generic/test/validation/api/pktio/pktio_run_dpdk.sh6
-rwxr-xr-xplatform/linux-generic/test/validation/api/pktio/pktio_run_pcap.sh6
-rwxr-xr-xplatform/linux-generic/test/validation/api/pktio/pktio_run_tap.sh6
-rw-r--r--platform/linux-generic/test/validation/api/shmem/shmem_common.h6
-rw-r--r--platform/linux-generic/test/validation/api/shmem/shmem_linux.c17
-rw-r--r--platform/linux-generic/test/validation/api/shmem/shmem_linux.h6
-rw-r--r--platform/linux-generic/test/validation/api/shmem/shmem_odp1.c6
-rw-r--r--platform/linux-generic/test/validation/api/shmem/shmem_odp1.h6
-rw-r--r--platform/linux-generic/test/validation/api/shmem/shmem_odp2.c6
-rw-r--r--platform/linux-generic/test/validation/api/shmem/shmem_odp2.h6
-rwxr-xr-xscripts/git-transplant.py6
-rw-r--r--test/README6
-rw-r--r--test/common/mask_common.c25
-rw-r--r--test/common/mask_common.h6
-rw-r--r--test/common/odp_cunit_common.c31
-rw-r--r--test/common/odp_cunit_common.h63
-rw-r--r--test/common/packet_common.c6
-rw-r--r--test/common/packet_common.h6
-rw-r--r--test/common/test_common_macros.h6
-rw-r--r--test/common/test_packet_custom.h6
-rw-r--r--test/common/test_packet_ipsec.h8
-rw-r--r--test/common/test_packet_ipv4.h8
-rw-r--r--test/common/test_packet_ipv4_with_crc.h6
-rw-r--r--test/common/test_packet_ipv6.h8
-rw-r--r--test/m4/configure.m41
-rw-r--r--test/miscellaneous/.gitignore1
-rw-r--r--test/miscellaneous/Makefile.am37
-rw-r--r--test/miscellaneous/odp_api_headers.c7
-rw-r--r--test/miscellaneous/odp_dyn_workers.c1357
-rwxr-xr-xtest/miscellaneous/odp_dyn_workers_run.sh23
-rw-r--r--test/performance/.gitignore2
-rw-r--r--test/performance/Makefile.am11
-rw-r--r--test/performance/dummy_crc.h40
-rw-r--r--test/performance/odp_atomic_perf.c7
-rw-r--r--test/performance/odp_bench_buffer.c8
-rw-r--r--test/performance/odp_bench_misc.c6
-rw-r--r--test/performance/odp_bench_packet.c8
-rw-r--r--test/performance/odp_bench_pktio_sp.c4
-rw-r--r--test/performance/odp_bench_timer.c6
-rw-r--r--test/performance/odp_cpu_bench.c10
-rwxr-xr-xtest/performance/odp_cpu_bench_run.sh5
-rw-r--r--test/performance/odp_crc.c7
-rw-r--r--test/performance/odp_crypto.c8
-rwxr-xr-xtest/performance/odp_crypto_run.sh5
-rwxr-xr-xtest/performance/odp_dma_perf_run.sh5
-rwxr-xr-xtest/performance/odp_dmafwd_run.sh1
-rw-r--r--test/performance/odp_ipsec.c10
-rwxr-xr-xtest/performance/odp_ipsec_run.sh5
-rw-r--r--test/performance/odp_l2fwd.c763
-rwxr-xr-xtest/performance/odp_l2fwd_run.sh35
-rw-r--r--test/performance/odp_lock_perf.c7
-rw-r--r--test/performance/odp_mem_perf.c7
-rw-r--r--test/performance/odp_packet_gen.c325
-rwxr-xr-xtest/performance/odp_packet_gen_run.sh6
-rw-r--r--test/performance/odp_pktio_ordered.c22
-rwxr-xr-xtest/performance/odp_pktio_ordered_run.sh17
-rw-r--r--test/performance/odp_pktio_perf.c6
-rw-r--r--test/performance/odp_pool_latency.c81
-rw-r--r--test/performance/odp_pool_perf.c9
-rw-r--r--test/performance/odp_queue_perf.c8
-rw-r--r--test/performance/odp_random.c18
-rw-r--r--test/performance/odp_sched_latency.c8
-rwxr-xr-xtest/performance/odp_sched_latency_run.sh6
-rw-r--r--test/performance/odp_sched_perf.c124
-rwxr-xr-xtest/performance/odp_sched_perf_run.sh62
-rw-r--r--test/performance/odp_sched_pktio.c6
-rwxr-xr-xtest/performance/odp_sched_pktio_run.sh24
-rw-r--r--test/performance/odp_scheduling.c1042
-rwxr-xr-xtest/performance/odp_scheduling_run.sh37
-rw-r--r--test/performance/odp_stress.c131
-rw-r--r--test/performance/odp_timer_accuracy.c (renamed from example/timer/odp_timer_accuracy.c)9
-rwxr-xr-xtest/performance/odp_timer_accuracy_run.sh17
-rw-r--r--test/performance/odp_timer_perf.c6
-rwxr-xr-xtest/performance/odp_timer_perf_run.sh6
-rw-r--r--test/validation/api/Makefile.am2
-rw-r--r--test/validation/api/README7
-rw-r--r--test/validation/api/atomic/atomic.c8
-rw-r--r--test/validation/api/barrier/barrier.c10
-rw-r--r--test/validation/api/buffer/buffer.c44
-rw-r--r--test/validation/api/chksum/chksum.c6
-rw-r--r--test/validation/api/classification/classification.c6
-rw-r--r--test/validation/api/classification/classification.h6
-rw-r--r--test/validation/api/classification/odp_classification_basic.c18
-rw-r--r--test/validation/api/classification/odp_classification_common.c8
-rw-r--r--test/validation/api/classification/odp_classification_test_pmr.c8
-rw-r--r--test/validation/api/classification/odp_classification_tests.c10
-rw-r--r--test/validation/api/classification/odp_classification_testsuites.h6
-rw-r--r--test/validation/api/comp/comp.c6
-rw-r--r--test/validation/api/comp/test_vectors.h6
-rw-r--r--test/validation/api/cpu/.gitignore1
-rw-r--r--test/validation/api/cpu/Makefile.am4
-rw-r--r--test/validation/api/cpu/cpu.c461
-rw-r--r--test/validation/api/cpumask/cpumask.c8
-rw-r--r--test/validation/api/crypto/crypto_op_test.c12
-rw-r--r--test/validation/api/crypto/crypto_op_test.h7
-rw-r--r--test/validation/api/crypto/odp_crypto_test_inp.c52
-rw-r--r--test/validation/api/crypto/test_vector_defs.h8
-rw-r--r--test/validation/api/crypto/test_vectors.h8
-rw-r--r--test/validation/api/crypto/test_vectors_len.h7
-rw-r--r--test/validation/api/crypto/util.c140
-rw-r--r--test/validation/api/crypto/util.h8
-rw-r--r--test/validation/api/dma/dma.c45
-rw-r--r--test/validation/api/errno/errno.c10
-rw-r--r--test/validation/api/event/event.c8
-rw-r--r--test/validation/api/hash/hash.c8
-rw-r--r--test/validation/api/ipsec/ipsec.c197
-rw-r--r--test/validation/api/ipsec/ipsec.h10
-rw-r--r--test/validation/api/ipsec/ipsec_test_in.c130
-rw-r--r--test/validation/api/ipsec/ipsec_test_out.c211
-rw-r--r--test/validation/api/ipsec/reass_test_vectors.c6
-rw-r--r--test/validation/api/ipsec/reass_test_vectors.h6
-rw-r--r--test/validation/api/ipsec/test_vectors.h8
-rw-r--r--test/validation/api/lock/lock.c8
-rw-r--r--test/validation/api/ml/ml.c1
-rw-r--r--test/validation/api/packet/packet.c213
-rw-r--r--test/validation/api/pktio/lso.c12
-rw-r--r--test/validation/api/pktio/lso.h6
-rw-r--r--test/validation/api/pktio/parser.c6
-rw-r--r--test/validation/api/pktio/parser.h6
-rw-r--r--test/validation/api/pktio/pktio.c91
-rw-r--r--test/validation/api/pool/pool.c68
-rw-r--r--test/validation/api/queue/queue.c41
-rw-r--r--test/validation/api/random/random.c8
-rw-r--r--test/validation/api/scheduler/scheduler.c45
-rw-r--r--test/validation/api/scheduler/scheduler_no_predef_groups.c8
-rw-r--r--test/validation/api/shmem/shmem.c59
-rw-r--r--test/validation/api/stash/stash.c31
-rw-r--r--test/validation/api/std/std.c6
-rw-r--r--test/validation/api/system/system.c366
-rw-r--r--test/validation/api/thread/thread.c14
-rw-r--r--test/validation/api/time/time.c199
-rw-r--r--test/validation/api/timer/timer.c36
-rw-r--r--test/validation/api/traffic_mngr/traffic_mngr.c153
665 files changed, 7636 insertions, 12362 deletions
diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml
index 832d91ee1..498ec5b2d 100644
--- a/.github/workflows/ci-pipeline.yml
+++ b/.github/workflows/ci-pipeline.yml
@@ -379,3 +379,22 @@ jobs:
$CONTAINER_NAMESPACE/odp-ci-${OS}-${ARCH} /odp/scripts/ci/check_validation.sh
- if: ${{ failure() }}
uses: ./.github/actions/run-failure-log
+
+ Run_sanitizer:
+ runs-on: ubuntu-20.04
+ env:
+ OS: ubuntu_22.04
+ strategy:
+ fail-fast: false
+ matrix:
+ flags: ['-fsanitize=address,undefined -fno-sanitize-recover=all']
+ steps:
+ - uses: actions/checkout@v4
+ - run: sudo docker run -i -v `pwd`:/odp --privileged --shm-size 8g -e CC="${CC}" -e ARCH="${ARCH}"
+ -e CFLAGS="-O0 -g -Wno-error ${{matrix.flags}}"
+ -e CXXFLAGS="-O0 -g -Wno-error ${{matrix.flags}}"
+ -e LDFLAGS="-g ${{matrix.flags}}"
+ $CONTAINER_NAMESPACE/odp-ci-${OS}-${ARCH} /odp/scripts/ci/check.sh
+ - if: ${{ failure() }}
+ uses: ./.github/actions/run-failure-log
+
diff --git a/CHANGELOG b/CHANGELOG
index e9d953a92..04998834c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,127 @@
+== OpenDataPlane (1.45.0.0)
+
+=== Backward incompatible API changes
+==== Crypto
+* Increase size of `all_bits` fields of `odp_crypto_cipher_algos_t` and
+`odp_crypto_auth_algos_t` algorithm capability unions.
+
+==== Packet
+* Change `odp_packet_reset()` specification to use new
+`odp_packet_reset_max_len()` function for maximum packet data length value.
+
+==== Protocol Stats
+* Limit length of `odp_proto_stats_create()` object name parameter to a new
+`ODP_PROTO_STATS_NAME_LEN` define.
+
+==== Traffic Manager
+* Limit lengths of traffic manager object names to a new `ODP_TM_NAME_LEN`
+define.
+
+=== Backward compatible API changes
+==== Common
+* Make mentions of maximum string lengths clear and consistent and always state
+that the null character is included.
+
+==== CPU
+* Add more specific data prefetch variants: `odp_prefetch_l1()`,
+`odp_prefetch_l2()`, and `odp_prefetch_l3()`.
+* Add more specific data prefetch variants for store: `odp_prefetch_store_l1()`,
+`odp_prefetch_store_l2()`, and `odp_prefetch_store_l3()`.
+* Add streaming prefetch functions `odp_prefetch_strm_l1()` and
+`odp_prefetch_store_strm_l1()`.
+
+==== Crypto
+* Add SHA-3 based cryptographic hash functions and HMACs based on them.
+* Add SNOW-V cipher algorithm and SNOW-V-GCM AEAD algorithm.
+* Add SM3 cryptographic hash function and a HMAC based on it.
+* Add SM4 cipher in ECB, CBC, CTR, GCM, CCM and GMAC modes.
+
+==== Event
+* Add `odp_event_user_flag_set()` function for setting/clearing event's user
+flag value.
+
+==== Packet
+* Clarify `odp_packet_buf_len()` specification to state that total packet buffer
+length includes also headroom and tailroom lengths.
+* Clarify `odp_packet_reset()` specification to state that packet data start is
+adjusted according to pool parameters, user area content is maintained, and
+packet data persistence is not guaranteed.
+* Add `odp_packet_reset_meta()` function for resetting only packet metadata
+without modifying packet data.
+
+==== Pool
+* Clarify in `odp_pool_param_t.buf.size` specification that the actual buffer
+size may be rounded up by the implementation. Also, remove the limitation that
+an application will never store more than 'size' bytes in each buffer, which
+conflicted with `odp_buffer_size()` API.
+
+=== Helper (1.6.0)
+==== Backward incompatible changes
+* Remove unused cuckoo table API.
+* Remove unused hash table API.
+* Remove unused linear table API.
+* Remove unused IP lookup table API.
+* Remove unused table interface API.
+
+==== Backward compatible changes
+===== Stress
+* Add CPU stress functions (`odph_stress_pow2_u32()`, `odph_stress_log2_u32()`,
+`odph_stress_sqrt_u32()`, `odph_stress_sqrt_f32()`) which may be used in test
+applications to create dummy CPU load. Functions are not highly optimized but
+try to stress various parts of CPU instruction set.
+
+===== String
+* Add `odph_strcpy()` function, which guarantees termination of the destination
+string.
+
+===== Thread
+* Add `odph_thread_join_result()` function which is similar to the existing
+`odph_thread_join()` but outputs results of joined threads.
+* Clarify in `odph_thread_create()` specification that the output thread table
+elements must not be modified during the lifetime of the threads if
+`odph_thread_join()` is used to wait for thread exit.
+
+=== Example Applications
+* Remove `odp_generator` application which has been made redundant by
+`odp_packet_gen`.
+* Remove `odp_timer_test` application which has been made redundant by
+`odp_timer_accuracy`.
+
+=== Miscellaneous Tests
+==== dyn_workers
+* Add a simple dynamic worker tester that can be used to verify the ability of
+an ODP implementation to dynamically add and remove workers from one ODP
+application to another.
+
+=== Performance Tests
+==== l2fwd
+* Add `-O, --output_map` option for changing the default output port mappings
+for interfaces.
+* Add `-C, --tx_compl` option for configuring packet transmit completion.
+* Add `-X, --flow_control` option for enabling reception and/or transmission of
+Ethernet pause frames.
+
+==== packet_gen
+* Enable running the application with only RX or TX threads.
+* Add support for transmitting TCP packets (`-N, --proto`). The application
+doesn't implement actual TCP protocol, but simply transmits packets with valid
+TCP headers at a selected rate.
+
+==== pool_latency
+* Enable running the application indefinitely with special round count (`-r`)
+value `0`.
+
+==== sched_perf
+* Add `-S, --stress` option for selecting stress function(s) to be used on event
+data. Functions add various amount of CPU load to each event to simulate
+application data processing.
+* Rename `-a` option (`--fairness`) to `-F` for better match of short and long
+option names.
+
+==== stress
+* Add simple memory copy loop and square root calculation test modes
+(`-m, --mode`) to generate CPU load.
+
== OpenDataPlane (1.44.0.0)
=== Backward compatible API changes
diff --git a/configure.ac b/configure.ac
index d71c5a4ae..cbedcf88e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@ AC_PREREQ([2.5])
# ODP API version
##########################################################################
m4_define([odp_version_generation], [1])
-m4_define([odp_version_major], [44])
+m4_define([odp_version_major], [45])
m4_define([odp_version_minor], [0])
m4_define([odp_version_patch], [0])
@@ -27,7 +27,7 @@ AC_SUBST(ODP_VERSION_API)
# Helper library version
##########################################################################
m4_define([odph_version_generation], [1])
-m4_define([odph_version_major], [5])
+m4_define([odph_version_major], [6])
m4_define([odph_version_minor], [0])
m4_define([odph_version],
diff --git a/doc/application-api-guide/api_guide_lines.dox b/doc/application-api-guide/api_guide_lines.dox
index 22b9159d4..e1dfe1b3c 100644
--- a/doc/application-api-guide/api_guide_lines.dox
+++ b/doc/application-api-guide/api_guide_lines.dox
@@ -1,8 +1,5 @@
-/* Copyright (c) 2014-2018, Linaro Limited
-
- * All rights reserved
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
*/
/**
diff --git a/doc/application-api-guide/odp.dox b/doc/application-api-guide/odp.dox
index 88a85093a..a03c5bab5 100644
--- a/doc/application-api-guide/odp.dox
+++ b/doc/application-api-guide/odp.dox
@@ -1,7 +1,5 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * All rights reserved
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
*/
/**
diff --git a/doc/application-api-guide/release.dox b/doc/application-api-guide/release.dox
index 3577878c1..b646cf894 100644
--- a/doc/application-api-guide/release.dox
+++ b/doc/application-api-guide/release.dox
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
diff --git a/doc/helper-guide/odp.dox b/doc/helper-guide/odp.dox
index 11333e910..ae341918e 100644
--- a/doc/helper-guide/odp.dox
+++ b/doc/helper-guide/odp.dox
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
/**
diff --git a/doc/users-guide/users-guide-packet.adoc b/doc/users-guide/users-guide-packet.adoc
index c38c5c866..246cf7702 100644
--- a/doc/users-guide/users-guide-packet.adoc
+++ b/doc/users-guide/users-guide-packet.adoc
@@ -42,11 +42,11 @@ to manipulate its structure.
To support packet manipulation, predefined _headroom_ and _tailroom_
areas are logically associated with a packet. Packets can be adjusted by
_pulling_ and _pushing_ these areas. Typical packet processing might consist
-of stripping headers from a packet via `odp_pull_head()` calls as part of
+of stripping headers from a packet via `odp_packet_pull_head()` calls as part of
receive processing and then replacing them with new headers via
-`odp_push_head()` calls as the packet is being prepared for transmit. Note that
-while headroom and tailroom represent reserved areas of memory, these areas
-not not addressable or directly usable by ODP applications until they are
+`odp_packet_push_head()` calls as the packet is being prepared for transmit.
+Note that while headroom and tailroom represent reserved areas of memory, these
+areas are not addressable or directly usable by ODP applications until they are
made part of the packet via associated push operations. Similarly, bytes
removed via pull operations become part of a packet's headroom or tailroom
and are again no longer accessible to the application.
diff --git a/doc/users-guide/users-guide-utilities-examples.adoc b/doc/users-guide/users-guide-utilities-examples.adoc
index e51bbef85..2d5ad0113 100644
--- a/doc/users-guide/users-guide-utilities-examples.adoc
+++ b/doc/users-guide/users-guide-utilities-examples.adoc
@@ -11,9 +11,8 @@ will stop the capturing process.
. `./configure --enable-pcapng-support`
. `sudo mkdir /var/run/odp`
-. `sudo ./example/generator/odp_generator -I enp2s0 -mu --dstmac
-A0:F6:FD:AE:62:6C --dstip 192.168.49.20 --srcmac 2c:56:dc:9a:8f:06 --srcip
-192.168.49.4 -i0 -w1`
+. `sudo ./test/performance/odp_packet_gen -i enp2s0 --eth_dst A0:F6:FD:AE:62:6C
+--ipv4_dst 192.168.49.20 --ipv4_src 192.168.49.4 -g 0`
. `sudo dd if=/var/run/odp/26737-enp2s0-flow-0 of=~/test.pcap`
. `ctrl^c`
. `wireshark ~/test.pcap`
diff --git a/example/Makefile.am b/example/Makefile.am
index d6d242cf9..2ef6abd9d 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -1,6 +1,5 @@
SUBDIRS = classifier \
debug \
- generator \
hello \
ipsec_api \
ipsec_crypto \
@@ -11,7 +10,6 @@ SUBDIRS = classifier \
simple_pipeline \
switch \
sysinfo \
- time \
timer \
traffic_mgmt
diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c
index f4218fd9c..d24224e6f 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -783,6 +783,8 @@ int main(int argc, char *argv[])
if (odp_pool_destroy(pool))
ODPH_ERR("err: odp_pool_destroy error\n");
+ free(args->if_name);
+
args_error:
odp_shm_free(shm);
@@ -977,16 +979,16 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
case ODP_PMR_TCP_SPORT:
/* :<port>:<mask> */
token = strtok(NULL, ":");
- strncpy(stats[policy_count].value, token,
- DISPLAY_STRING_LEN - 1);
+ odph_strcpy(stats[policy_count].value, token,
+ DISPLAY_STRING_LEN);
value = strtoul(token, NULL, 0);
u16 = value;
u16 = odp_cpu_to_be_16(u16);
memcpy(stats[policy_count].rule.value_be, &u16, sizeof(u16));
token = strtok(NULL, ":");
- strncpy(stats[policy_count].mask, token,
- DISPLAY_STRING_LEN - 1);
+ odph_strcpy(stats[policy_count].mask, token,
+ DISPLAY_STRING_LEN);
mask = strtoul(token, NULL, 0);
u16 = mask;
u16 = odp_cpu_to_be_16(u16);
@@ -999,8 +1001,8 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
case ODP_PMR_SIP_ADDR:
/* :<IP addr>:<mask> */
token = strtok(NULL, ":");
- strncpy(stats[policy_count].value, token,
- DISPLAY_STRING_LEN - 1);
+ odph_strcpy(stats[policy_count].value, token,
+ DISPLAY_STRING_LEN);
if (odph_ipv4_addr_parse(&ip_addr, token)) {
ODPH_ERR("Bad IP address\n");
@@ -1011,8 +1013,8 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
memcpy(stats[policy_count].rule.value_be, &u32, sizeof(u32));
token = strtok(NULL, ":");
- strncpy(stats[policy_count].mask, token,
- DISPLAY_STRING_LEN - 1);
+ odph_strcpy(stats[policy_count].mask, token,
+ DISPLAY_STRING_LEN);
mask = strtoul(token, NULL, 0);
u32 = mask;
u32 = odp_cpu_to_be_32(u32);
@@ -1023,8 +1025,8 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
case ODP_PMR_DMAC:
/* :<MAC addr>:<mask> */
token = strtok(NULL, ":");
- strncpy(stats[policy_count].value, token,
- DISPLAY_STRING_LEN - 1);
+ odph_strcpy(stats[policy_count].value, token,
+ DISPLAY_STRING_LEN);
/* Replace hyphens in the MAC string with colons to be compatible with
* odph_eth_addr_parse(). */
@@ -1041,7 +1043,7 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
stats[policy_count].rule.val_sz = 6;
token = strtok(NULL, ":");
- strncpy(stats[policy_count].mask, token, DISPLAY_STRING_LEN - 1);
+ odph_strcpy(stats[policy_count].mask, token, DISPLAY_STRING_LEN);
mask_sz = parse_custom(token, stats[policy_count].rule.mask_be, ODPH_ETHADDR_LEN);
if (mask_sz != ODPH_ETHADDR_LEN) {
ODPH_ERR("Invalid mask. Provide mask without 0x prefix.\n");
@@ -1060,8 +1062,8 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
goto error;
token = strtok(NULL, ":");
- strncpy(stats[policy_count].value, token,
- DISPLAY_STRING_LEN - 1);
+ odph_strcpy(stats[policy_count].value, token,
+ DISPLAY_STRING_LEN);
val_sz = parse_custom(token,
stats[policy_count].rule.value_be,
MAX_VAL_SIZE);
@@ -1070,8 +1072,8 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
goto error;
token = strtok(NULL, ":");
- strncpy(stats[policy_count].mask, token,
- DISPLAY_STRING_LEN - 1);
+ odph_strcpy(stats[policy_count].mask, token,
+ DISPLAY_STRING_LEN);
mask_sz = parse_custom(token,
stats[policy_count].rule.mask_be,
MAX_VAL_SIZE);
@@ -1091,13 +1093,13 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
if (cos1) {
stats[policy_count].has_src_cos = 1;
- strncpy(stats[policy_count].src_cos_name, cos0,
- ODP_COS_NAME_LEN - 1);
- strncpy(stats[policy_count].cos_name, cos1,
- ODP_COS_NAME_LEN - 1);
+ odph_strcpy(stats[policy_count].src_cos_name, cos0,
+ ODP_COS_NAME_LEN);
+ odph_strcpy(stats[policy_count].cos_name, cos1,
+ ODP_COS_NAME_LEN);
} else {
- strncpy(stats[policy_count].cos_name, cos0,
- ODP_COS_NAME_LEN - 1);
+ odph_strcpy(stats[policy_count].cos_name, cos0,
+ ODP_COS_NAME_LEN);
}
appl_args->policy_count++;
@@ -1281,9 +1283,7 @@ static int parse_args(int argc, char *argv[], appl_args_t *appl_args)
if (ret) {
usage();
-
- if (appl_args->if_name)
- free(appl_args->if_name);
+ free(appl_args->if_name);
}
/* reset optind from the getopt lib */
diff --git a/example/cli/odp_cli.c b/example/cli/odp_cli.c
index 381fc8a59..bc5dad960 100644
--- a/example/cli/odp_cli.c
+++ b/example/cli/odp_cli.c
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2021 Nokia
+ * Copyright (c) 2021-2024 Nokia
*/
/**
@@ -101,7 +101,7 @@ static int cli_server(void *arg ODP_UNUSED)
/* Run CLI server. */
if (odph_cli_run()) {
ODPH_ERR("odph_cli_run() failed.\n");
- exit(EXIT_FAILURE);
+ return -1;
}
return 0;
@@ -178,6 +178,7 @@ int main(int argc, char *argv[])
odph_thread_common_param_t thr_common;
odph_thread_param_t thr_param;
odph_thread_t thr_server;
+ odph_thread_join_result_t res;
if (odp_cpumask_default_control(&cpumask, 1) != 1) {
ODPH_ERR("Failed to get default CPU mask.\n");
@@ -199,7 +200,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- printf("CLI server started on %s:%d\n", cli_param.address,
+ printf("CLI server started on %s:%d.\n", cli_param.address,
cli_param.port);
/* Wait for the given number of seconds. */
@@ -215,11 +216,17 @@ int main(int argc, char *argv[])
}
/* Wait for server thread to exit. */
- if (odph_thread_join(&thr_server, 1) != 1) {
+ if (odph_thread_join_result(&thr_server, &res, 1) != 1) {
ODPH_ERR("Failed to join server thread.\n");
exit(EXIT_FAILURE);
}
+ if (res.is_sig || res.ret != 0) {
+ ODPH_ERR("Worker thread failure%s: %d.\n", res.is_sig ? " (signaled)" : "",
+ res.ret);
+ exit(EXIT_FAILURE);
+ }
+
/* Terminate CLI helper. */
if (odph_cli_term()) {
ODPH_ERR("CLI helper termination failed.\n");
diff --git a/example/generator/.gitignore b/example/generator/.gitignore
deleted file mode 100644
index 37364a254..000000000
--- a/example/generator/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-odp_generator
-pktio_env
diff --git a/example/generator/Makefile.am b/example/generator/Makefile.am
deleted file mode 100644
index c3c08a663..000000000
--- a/example/generator/Makefile.am
+++ /dev/null
@@ -1,34 +0,0 @@
-include $(top_srcdir)/example/Makefile.inc
-
-bin_PROGRAMS = odp_generator
-
-odp_generator_SOURCES = odp_generator.c
-
-TEST_EXTENSIONS = .sh
-
-if test_example
-TESTS = generator_run.sh
-endif
-EXTRA_DIST = generator_run.sh
-
-# If building out-of-tree, make check will not copy the scripts and data to the
-# $(builddir) assuming that all commands are run locally. However this prevents
-# running tests on a remote target using LOG_COMPILER.
-# So copy all script and data files explicitly here.
-all-local:
- if [ "x$(srcdir)" != "x$(builddir)" ]; then \
- for f in $(EXTRA_DIST); do \
- if [ -e $(srcdir)/$$f ]; then \
- mkdir -p $(builddir)/$$(dirname $$f); \
- cp -f $(srcdir)/$$f $(builddir)/$$f; \
- fi \
- done \
- fi
- ln -f -s $(top_srcdir)/platform/$(with_platform)/test/example/generator/pktio_env \
- pktio_env
-clean-local:
- if [ "x$(srcdir)" != "x$(builddir)" ]; then \
- for f in $(EXTRA_DIST); do \
- rm -f $(builddir)/$$f; \
- done \
- fi
diff --git a/example/generator/generator_run.sh b/example/generator/generator_run.sh
deleted file mode 100755
index ca69b53bd..000000000
--- a/example/generator/generator_run.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-#
-# SPDX-License-Identifier: BSD-3-Clause
-# Copyright (c) 2020 Marvell
-#
-
-if [ -f ./pktio_env ]; then
- . ./pktio_env
-else
- echo "BUG: unable to find pktio_env!"
- echo "pktio_env has to be in current directory"
- exit 1
-fi
-
-setup_interfaces
-
-./odp_generator${EXEEXT} -w 1 -n 1 -I $IF0 -m u
-STATUS=$?
-
-if [ "$STATUS" -ne 0 ]; then
- echo "Error: status was: $STATUS, expected 0"
- exit 1
-fi
-
-validate_result
-
-cleanup_interfaces
-
-exit 0
diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
deleted file mode 100644
index 6ec19d0ea..000000000
--- a/example/generator/odp_generator.c
+++ /dev/null
@@ -1,1760 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2014-2018 Linaro Limited
- */
-
-/**
- * @example odp_generator.c
- *
- * Traffic generator and loopback demo application
- *
- * @cond _ODP_HIDE_FROM_DOXYGEN_
- */
-
-/** enable strtok */
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#include <time.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <sys/time.h>
-#include <signal.h>
-
-#include <odp_api.h>
-
-#include <odp/helper/odph_api.h>
-
-/* Max number of workers */
-#define MAX_WORKERS (ODP_THREAD_COUNT_MAX - 1)
-#define POOL_NUM_PKT 2048 /* Number of packets in packet pool */
-#define POOL_PKT_LEN 1856 /* Max packet length */
-#define DEFAULT_PKT_INTERVAL 1000 /* Interval between each packet */
-#define DEFAULT_UDP_TX_BURST 16
-#define MAX_UDP_TX_BURST 512
-#define DEFAULT_RX_BURST 32
-#define MAX_RX_BURST 512
-#define STATS_INTERVAL 10 /* Interval between stats prints (sec) */
-
-#define APPL_MODE_UDP 0 /**< UDP mode */
-#define APPL_MODE_PING 1 /**< ping mode */
-#define APPL_MODE_RCV 2 /**< receive mode */
-
-#define PING_THR_TX 0
-#define PING_THR_RX 1
-
-/** print appl mode */
-#define PRINT_APPL_MODE(x) printf("%s(%i)\n", #x, (x))
-
-/** Get rid of path in filename - only for unix-type paths using '/' */
-#define NO_PATH(file_name) (strrchr((file_name), '/') ? \
- strrchr((file_name), '/') + 1 : (file_name))
-
-/**
- * Interfaces
- */
-
-typedef struct {
- odp_pktio_t pktio;
- odp_pktio_config_t config;
- odp_pktout_queue_t pktout[MAX_WORKERS];
- uint32_t pktout_count;
- odp_pktin_queue_t pktin[MAX_WORKERS];
- uint32_t pktin_count;
-} interface_t;
-
-/**
- * Parsed command line application arguments
- */
-typedef struct {
- int num_workers; /**< Number of worker thread */
- const char *mask; /**< CPU mask */
- int if_count; /**< Number of interfaces to be used */
- char **if_names; /**< Array of pointers to interface names */
- char *if_str; /**< Storage for interface names */
- odp_pool_t pool; /**< Pool for packet IO */
- odph_ethaddr_t srcmac; /**< src mac addr */
- odph_ethaddr_t dstmac; /**< dest mac addr */
- unsigned int srcip; /**< src ip addr */
- unsigned int dstip; /**< dest ip addr */
- uint16_t srcport; /**< src udp port */
- uint16_t srcport_end; /**< src udp end port */
- uint16_t dstport; /**< dest udp port */
- uint16_t dstport_end; /**< dest udp end port */
- int mode; /**< work mode */
- int number; /**< packets number to be sent */
- int payload; /**< data len */
- int timeout; /**< wait time */
- int interval; /**< wait interval ms between sending
- each packet */
- int udp_tx_burst; /**< number of udp packets to send with one
- API call */
- int rx_burst; /**< number of packets to receive with one
- API call */
- odp_bool_t csum; /**< use platform csum support if available */
- odp_bool_t sched; /**< use scheduler API to receive packets */
-} appl_args_t;
-
-/**
- * counters
-*/
-typedef struct {
- uint64_t ctr_pkt_snd; /**< sent packets*/
- uint64_t ctr_pkt_snd_drop; /**< packets dropped in transmit */
-
- uint64_t ctr_pkt_rcv; /**< recv packets */
- uint64_t ctr_seq; /**< ip seq to be send */
- uint64_t ctr_udp_rcv; /**< udp packets */
- uint64_t ctr_icmp_reply_rcv; /**< icmp reply packets */
-} counters_t;
-
-/** UDP Packet processing function argument */
-typedef struct {
- odp_bool_t multi_flow;
- uint16_t srcport_crt;
- uint16_t srcport_start;
- uint16_t srcport_end;
- uint16_t dstport_crt;
- uint16_t dstport_start;
- uint16_t dstport_end;
-} udp_args_t;
-
-/** * Thread specific arguments
- */
-typedef struct {
- counters_t counters; /**< Packet counters */
- odp_bool_t stop; /**< Stop packet processing */
- union {
- struct {
- odp_pktout_queue_t pktout; /**< Packet output queue */
- odp_pktout_config_opt_t *pktout_cfg; /**< Packet output config*/
- udp_args_t udp_param; /**< UDP configuration */
- } tx;
- struct {
- odp_pktin_queue_t pktin; /**< Packet input queue */
- } rx;
- };
- odp_pool_t pool; /**< Pool for packet IO */
- int mode; /**< Thread mode */
-} thread_args_t;
-
-/**
- * Grouping of both parsed CL args and thread specific args - alloc together
- */
-typedef struct {
- /** Application (parsed) arguments */
- appl_args_t appl;
- /** Thread specific arguments */
- thread_args_t thread[MAX_WORKERS];
- /** Global arguments */
- int thread_cnt;
- int tx_burst_size;
- int rx_burst_size;
- /** Barrier to sync threads execution */
- odp_barrier_t barrier;
-} args_t;
-
-/** Global pointer to args */
-static args_t *args;
-
-/** Packet processing function types */
-typedef odp_packet_t (*setup_pkt_ref_fn_t)(odp_pool_t,
- odp_pktout_config_opt_t *);
-typedef int (*setup_pkt_fn_t)(odp_packet_t, odp_pktout_config_opt_t *,
- counters_t *, void *);
-
-/* helper funcs */
-static void parse_args(int argc, char *argv[], appl_args_t *appl_args);
-static void print_info(char *progname, appl_args_t *appl_args);
-static void usage(char *progname);
-static int scan_ip(char *buf, unsigned int *paddr);
-static void print_global_stats(int num_workers);
-
-static void sig_handler(int signo ODP_UNUSED)
-{
- int i;
- if (args == NULL)
- return;
- for (i = 0; i < args->thread_cnt; i++)
- args->thread[i].stop = 1;
-}
-
-/**
- * Scan ip
- * Parse ip address.
- *
- * @param buf ip address string xxx.xxx.xxx.xx
- * @param paddr ip address for odp_packet
- * @return 1 success, 0 failed
-*/
-static int scan_ip(char *buf, unsigned int *paddr)
-{
- unsigned int part1, part2, part3, part4;
- char tail = 0;
- int field;
-
- if (buf == NULL)
- return 0;
-
- field = sscanf(buf, "%u . %u . %u . %u %c",
- &part1, &part2, &part3, &part4, &tail);
-
- if (field < 4 || field > 5) {
- printf("expect 4 field,get %d/n", field);
- return 0;
- }
-
- if (tail != 0) {
- printf("ip address mixed with non number/n");
- return 0;
- }
-
- if (part1 <= 255 && part2 <= 255 && part3 <= 255 && part4 <= 255) {
- if (paddr)
- *paddr = part1 << 24 | part2 << 16 | part3 << 8 | part4;
- return 1;
- }
-
- printf("not good ip %u:%u:%u:%u/n", part1, part2, part3, part4);
-
- return 0;
-}
-
-/**
- * Setup array of reference packets
- *
- * @param pool Packet pool
- * @param pktout_cfg Interface output configuration
- * @param pkt_ref_array Packet array
- * @param pkt_ref_array_size Packet array size
- * @param setup_ref Packet setup function
- * @return 0 success, -1 failed
-*/
-static int setup_pkt_ref_array(odp_pool_t pool,
- odp_pktout_config_opt_t *pktout_cfg,
- odp_packet_t *pkt_ref_array,
- int pkt_ref_array_size,
- setup_pkt_ref_fn_t setup_ref)
-{
- int i;
-
- for (i = 0; i < pkt_ref_array_size; i++) {
- pkt_ref_array[i] = (*setup_ref)(pool, pktout_cfg);
- if (pkt_ref_array[i] == ODP_PACKET_INVALID)
- break;
- }
-
- if (i < pkt_ref_array_size) {
- odp_packet_free_multi(pkt_ref_array, i);
- return -1;
- }
- return 0;
-}
-
-/**
- * Setup array of packets
- *
- * @param pktout_cfg Interface output configuration
- * @param pkt_ref_array Reference packet array
- * @param pkt_array Packet array
- * @param pkt_array_size Packet array size
- * @param setup_pkt Packet setup function
- * @return 0 success, -1 failed
-*/
-static int setup_pkt_array(odp_pktout_config_opt_t *pktout_cfg,
- counters_t *counters,
- odp_packet_t *pkt_ref_array,
- odp_packet_t *pkt_array,
- int pkt_array_size,
- setup_pkt_fn_t setup_pkt,
- void *setup_pkt_arg)
-{
- int i;
-
- for (i = 0; i < pkt_array_size; i++) {
- if ((*setup_pkt)(pkt_ref_array[i], pktout_cfg, counters,
- setup_pkt_arg))
- break;
-
- pkt_array[i] = odp_packet_ref_static(pkt_ref_array[i]);
- if (pkt_array[i] == ODP_PACKET_INVALID)
- break;
- }
- if (i < pkt_array_size) {
- if (i)
- odp_packet_free_multi(pkt_array, i - 1);
-
- return -1;
- }
- return 0;
-}
-
-/**
- * set up an udp packet reference
- *
- * @param pool Buffer pool to create packet in
- * @param pktout_cfg Interface output configuration
- *
- *
- * @retval Handle of created packet
- * @retval ODP_PACKET_INVALID Packet could not be created
- *
- */
-static odp_packet_t setup_udp_pkt_ref(odp_pool_t pool,
- odp_pktout_config_opt_t *pktout_cfg)
-{
- odp_packet_t pkt;
- char *buf;
- odph_ethhdr_t *eth;
- odph_ipv4hdr_t *ip;
- odph_udphdr_t *udp;
-
- pkt = odp_packet_alloc(pool, args->appl.payload + ODPH_UDPHDR_LEN +
- ODPH_IPV4HDR_LEN + ODPH_ETHHDR_LEN);
-
- if (pkt == ODP_PACKET_INVALID)
- return pkt;
-
- buf = odp_packet_data(pkt);
-
- /* ether */
- odp_packet_l2_offset_set(pkt, 0);
- eth = (odph_ethhdr_t *)buf;
- memcpy((char *)eth->src.addr, args->appl.srcmac.addr, ODPH_ETHADDR_LEN);
- memcpy((char *)eth->dst.addr, args->appl.dstmac.addr, ODPH_ETHADDR_LEN);
- eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);
-
- /* ip */
- odp_packet_l3_offset_set(pkt, ODPH_ETHHDR_LEN);
- odp_packet_has_ipv4_set(pkt, 1);
- ip = (odph_ipv4hdr_t *)(buf + ODPH_ETHHDR_LEN);
- ip->dst_addr = odp_cpu_to_be_32(args->appl.dstip);
- ip->src_addr = odp_cpu_to_be_32(args->appl.srcip);
- ip->ver_ihl = ODPH_IPV4 << 4 | ODPH_IPV4HDR_IHL_MIN;
- ip->tot_len = odp_cpu_to_be_16(args->appl.payload + ODPH_UDPHDR_LEN +
- ODPH_IPV4HDR_LEN);
- ip->proto = ODPH_IPPROTO_UDP;
- ip->id = 0;
- ip->ttl = 64;
- ip->chksum = 0;
-
- /* udp */
- odp_packet_l4_offset_set(pkt, ODPH_ETHHDR_LEN + ODPH_IPV4HDR_LEN);
- odp_packet_has_udp_set(pkt, 1);
- udp = (odph_udphdr_t *)(buf + ODPH_ETHHDR_LEN + ODPH_IPV4HDR_LEN);
- udp->src_port = odp_cpu_to_be_16(args->appl.srcport);
- udp->dst_port = odp_cpu_to_be_16(args->appl.dstport);
- udp->length = odp_cpu_to_be_16(args->appl.payload + ODPH_UDPHDR_LEN);
- if (!pktout_cfg->bit.udp_chksum) {
- udp->chksum = 0;
- udp->chksum = odph_ipv4_udp_chksum(pkt);
- }
-
- return pkt;
-}
-
-/**
- * set up an udp packet
- *
- * @param pkt Reference UDP packet
- * @param pktout_cfg Interface output configuration
- *
- * @return Success/Failed
- * @retval 0 on success, -1 on fail
- */
-static int setup_udp_pkt(odp_packet_t pkt, odp_pktout_config_opt_t *pktout_cfg,
- counters_t *counters, void *arg)
-{
- char *buf;
- odph_ipv4hdr_t *ip;
- unsigned short seq;
- udp_args_t *udp_arg = (udp_args_t *)arg;
-
- buf = (char *)odp_packet_data(pkt);
-
- /*Update IP ID and checksum*/
- ip = (odph_ipv4hdr_t *)(buf + ODPH_ETHHDR_LEN);
- seq = counters->ctr_seq % 0xFFFF;
- counters->ctr_seq++;
- ip->id = odp_cpu_to_be_16(seq);
- if (!pktout_cfg->bit.ipv4_chksum) {
- ip->chksum = 0;
- ip->chksum = ~odp_chksum_ones_comp16(ip, ODPH_IPV4HDR_LEN);
- }
-
- if (udp_arg->multi_flow) {
- odph_udphdr_t *udp = (odph_udphdr_t *)(buf + ODPH_ETHHDR_LEN +
- ODPH_IPV4HDR_LEN);
-
- if (udp_arg->srcport_start != udp_arg->srcport_end) {
- udp->src_port = odp_cpu_to_be_16(udp_arg->srcport_crt);
- if (udp_arg->srcport_crt >= udp_arg->srcport_end)
- udp_arg->srcport_crt = udp_arg->srcport_start;
- else
- udp_arg->srcport_crt++;
- }
- if (udp_arg->dstport_start != udp_arg->dstport_end) {
- udp->dst_port = odp_cpu_to_be_16(udp_arg->dstport_crt);
- if (udp_arg->dstport_crt >= udp_arg->dstport_end)
- udp_arg->dstport_crt = udp_arg->dstport_start;
- else
- udp_arg->dstport_crt++;
- }
-
- udp->chksum = 0;
- }
-
- if (pktout_cfg->bit.ipv4_chksum || pktout_cfg->bit.udp_chksum) {
- odp_packet_l2_offset_set(pkt, 0);
- odp_packet_l3_offset_set(pkt, ODPH_ETHHDR_LEN);
- odp_packet_has_ipv4_set(pkt, 1);
- odp_packet_l4_offset_set(pkt, ODPH_ETHHDR_LEN +
- ODPH_IPV4HDR_LEN);
- odp_packet_has_udp_set(pkt, 1);
- }
- return 0;
-}
-
-/**
- * Set up an icmp packet reference
- *
- * @param pool Buffer pool to create packet in
- * @param pktout_cfg Interface output configuration
- *
- * @return Handle of created packet
- * @retval ODP_PACKET_INVALID Packet could not be created
- */
-static odp_packet_t setup_icmp_pkt_ref(odp_pool_t pool,
- odp_pktout_config_opt_t *pktout_cfg)
-{
- odp_packet_t pkt;
- char *buf;
- odph_ethhdr_t *eth;
- odph_ipv4hdr_t *ip;
- odph_icmphdr_t *icmp;
-
- (void)pktout_cfg;
-
- args->appl.payload = 56;
- pkt = odp_packet_alloc(pool, args->appl.payload + ODPH_ICMPHDR_LEN +
- ODPH_IPV4HDR_LEN + ODPH_ETHHDR_LEN);
-
- if (pkt == ODP_PACKET_INVALID)
- return pkt;
-
- buf = odp_packet_data(pkt);
-
- /* ether */
- odp_packet_l2_offset_set(pkt, 0);
- eth = (odph_ethhdr_t *)buf;
- memcpy((char *)eth->src.addr, args->appl.srcmac.addr, ODPH_ETHADDR_LEN);
- memcpy((char *)eth->dst.addr, args->appl.dstmac.addr, ODPH_ETHADDR_LEN);
- eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);
- /* ip */
- odp_packet_l3_offset_set(pkt, ODPH_ETHHDR_LEN);
- ip = (odph_ipv4hdr_t *)(buf + ODPH_ETHHDR_LEN);
- ip->dst_addr = odp_cpu_to_be_32(args->appl.dstip);
- ip->src_addr = odp_cpu_to_be_32(args->appl.srcip);
- ip->ver_ihl = ODPH_IPV4 << 4 | ODPH_IPV4HDR_IHL_MIN;
- ip->ttl = 64;
- ip->tot_len = odp_cpu_to_be_16(args->appl.payload + ODPH_ICMPHDR_LEN +
- ODPH_IPV4HDR_LEN);
- ip->proto = ODPH_IPPROTO_ICMPV4;
- ip->id = 0;
- ip->chksum = 0;
-
- /* icmp */
- icmp = (odph_icmphdr_t *)(buf + ODPH_ETHHDR_LEN + ODPH_IPV4HDR_LEN);
- icmp->type = ODPH_ICMP_ECHO;
- icmp->code = 0;
- icmp->un.echo.id = 0;
- icmp->un.echo.sequence = 0;
- icmp->chksum = 0;
-
- return pkt;
-}
-
-/**
- * Set up an icmp packet
- *
- * @param pkt Reference ICMP packet
- * @param pktout_cfg Interface output configuration
- *
- * @return Success/Failed
- * @retval 0 on success, -1 on fail
- */
-static int setup_icmp_pkt(odp_packet_t pkt,
- odp_pktout_config_opt_t *pktout_cfg,
- counters_t *counters, void *arg ODP_UNUSED)
-{
- char *buf;
- odph_ipv4hdr_t *ip;
- odph_icmphdr_t *icmp;
- uint64_t tval;
- uint8_t *tval_d;
- unsigned short seq;
-
- buf = (char *)odp_packet_data(pkt);
-
- /* ip */
- ip = (odph_ipv4hdr_t *)(buf + ODPH_ETHHDR_LEN);
- seq = counters->ctr_seq % 0xffff;
- counters->ctr_seq++;
- ip->id = odp_cpu_to_be_16(seq);
- if (!pktout_cfg->bit.ipv4_chksum) {
- ip->chksum = 0;
- ip->chksum = ~odp_chksum_ones_comp16(ip, ODPH_IPV4HDR_LEN);
- }
-
- /* icmp */
- icmp = (odph_icmphdr_t *)(buf + ODPH_ETHHDR_LEN + ODPH_IPV4HDR_LEN);
- icmp->un.echo.sequence = ip->id;
-
- tval_d = (uint8_t *)(buf + ODPH_ETHHDR_LEN + ODPH_IPV4HDR_LEN +
- ODPH_ICMPHDR_LEN);
- tval = odp_time_to_ns(odp_time_local());
- memcpy(tval_d, &tval, sizeof(uint64_t));
-
- icmp->chksum = 0;
- icmp->chksum = ~odp_chksum_ones_comp16(icmp, args->appl.payload +
- ODPH_ICMPHDR_LEN);
-
- if (pktout_cfg->bit.ipv4_chksum) {
- odp_packet_l2_offset_set(pkt, 0);
- odp_packet_l3_offset_set(pkt, ODPH_ETHHDR_LEN);
- odp_packet_has_ipv4_set(pkt, 1);
- odp_packet_l4_offset_set(pkt, ODPH_ETHHDR_LEN +
- ODPH_IPV4HDR_LEN);
- }
-
- return 0;
-}
-
-/**
- * Create a pktio object
- *
- * @param dev Name of device to open
- * @param pool Pool to associate with device for packet RX/TX
- *
- * @return The handle of the created pktio object.
- * @warning This routine aborts if the create is unsuccessful.
- */
-static int create_pktio(const char *dev, odp_pool_t pool,
- uint32_t num_rx_queues,
- uint32_t num_tx_queues,
- interface_t *itf)
-{
- odp_pktio_capability_t capa;
- int ret;
- odp_pktio_param_t pktio_param;
- odp_pktin_queue_param_t pktin_param;
- odp_pktout_queue_param_t pktout_param;
- odp_pktio_op_mode_t pktout_mode, pktin_mode;
- odp_bool_t sched = args->appl.sched;
-
- odp_pktio_param_init(&pktio_param);
- pktio_param.in_mode = num_rx_queues ?
- (sched ? ODP_PKTIN_MODE_SCHED : ODP_PKTIN_MODE_DIRECT) :
- ODP_PKTIN_MODE_DISABLED;
- pktio_param.out_mode = num_tx_queues ? ODP_PKTOUT_MODE_DIRECT :
- ODP_PKTOUT_MODE_DISABLED;
-
- /* Open a packet IO instance */
- itf->pktio = odp_pktio_open(dev, pool, &pktio_param);
-
- if (itf->pktio == ODP_PKTIO_INVALID) {
- ODPH_ERR("Error: pktio create failed for %s\n", dev);
- return -1;
- }
-
- if (odp_pktio_capability(itf->pktio, &capa)) {
- ODPH_ERR("Error: Failed to get interface capabilities %s\n",
- dev);
- return -1;
- }
- odp_pktio_config_init(&itf->config);
- if (args->appl.csum) {
- itf->config.pktin.bit.ipv4_chksum =
- capa.config.pktin.bit.ipv4_chksum;
- itf->config.pktin.bit.udp_chksum =
- capa.config.pktin.bit.udp_chksum;
- itf->config.pktin.bit.drop_ipv4_err =
- capa.config.pktin.bit.drop_ipv4_err;
- itf->config.pktin.bit.drop_udp_err =
- capa.config.pktin.bit.drop_udp_err;
-
- itf->config.pktout.bit.ipv4_chksum_ena =
- capa.config.pktout.bit.ipv4_chksum_ena;
- itf->config.pktout.bit.udp_chksum_ena =
- capa.config.pktout.bit.udp_chksum_ena;
- itf->config.pktout.bit.ipv4_chksum =
- capa.config.pktout.bit.ipv4_chksum;
- itf->config.pktout.bit.udp_chksum =
- capa.config.pktout.bit.udp_chksum;
- } else { /* explicit disable */
- itf->config.pktin.bit.ipv4_chksum = 0;
- itf->config.pktin.bit.udp_chksum = 0;
- itf->config.pktout.bit.ipv4_chksum_ena = 0;
- itf->config.pktout.bit.udp_chksum_ena = 0;
- itf->config.pktout.bit.ipv4_chksum = 0;
- itf->config.pktout.bit.udp_chksum = 0;
- }
-
- itf->config.parser.layer = ODP_PROTO_LAYER_L2;
- if (itf->config.pktin.bit.udp_chksum)
- itf->config.parser.layer = ODP_PROTO_LAYER_L4;
- else if (itf->config.pktin.bit.ipv4_chksum)
- itf->config.parser.layer = ODP_PROTO_LAYER_L3;
-
- if (odp_pktio_config(itf->pktio, &itf->config)) {
- ODPH_ERR("Error: Failed to set interface configuration %s\n",
- dev);
- return -1;
- }
-
- if (num_rx_queues) {
- pktin_mode = ODP_PKTIO_OP_MT_UNSAFE;
- if (num_rx_queues > capa.max_input_queues) {
- num_rx_queues = capa.max_input_queues;
- pktin_mode = ODP_PKTIO_OP_MT;
- ODPH_DBG("Warning: Force RX multithread safe mode "
- "(slower)on %s\n", dev);
- }
-
- odp_pktin_queue_param_init(&pktin_param);
- pktin_param.num_queues = num_rx_queues;
- pktin_param.op_mode = pktin_mode;
- if (sched)
- pktin_param.queue_param.sched.sync =
- ODP_SCHED_SYNC_ATOMIC;
-
- if (odp_pktin_queue_config(itf->pktio, &pktin_param)) {
- ODPH_ERR("Error: pktin queue config failed for %s\n",
- dev);
- return -1;
- }
- }
-
- if (num_tx_queues) {
- pktout_mode = ODP_PKTIO_OP_MT_UNSAFE;
- if (num_tx_queues > capa.max_output_queues) {
- num_tx_queues = capa.max_output_queues;
- pktout_mode = ODP_PKTIO_OP_MT;
- ODPH_DBG("Warning: Force TX multithread safe mode "
- "(slower) on %s\n", dev);
- }
-
- odp_pktout_queue_param_init(&pktout_param);
- pktout_param.num_queues = num_tx_queues;
- pktout_param.op_mode = pktout_mode;
-
- if (odp_pktout_queue_config(itf->pktio, &pktout_param)) {
- ODPH_ERR("Error: pktout queue config failed for %s\n",
- dev);
- return -1;
- }
- }
-
- ret = odp_pktio_start(itf->pktio);
- if (ret)
- ODPH_ABORT("Error: unable to start %s\n", dev);
-
- itf->pktout_count = num_tx_queues;
- if (itf->pktout_count &&
- odp_pktout_queue(itf->pktio, itf->pktout, itf->pktout_count) !=
- (int)itf->pktout_count) {
- ODPH_ERR("Error: failed to get output queues for %s\n", dev);
- return -1;
- }
-
- itf->pktin_count = num_rx_queues;
- if (!sched && itf->pktin_count &&
- odp_pktin_queue(itf->pktio, itf->pktin, itf->pktin_count) !=
- (int)itf->pktin_count) {
- ODPH_ERR("Error: failed to get input queues for %s\n", dev);
- return -1;
- }
-
- printf(" created pktio:%02" PRIu64
- ", dev:%s, queue mode (ATOMIC queues)\n"
- " default pktio%02" PRIu64 "\n",
- odp_pktio_to_u64(itf->pktio), dev,
- odp_pktio_to_u64(itf->pktio));
- fflush(NULL);
-
- return 0;
-}
-
-/**
- * Packet IO loopback worker thread using ODP queues
- *
- * @param arg thread arguments of type 'thread_args_t *'
- */
-
-static int gen_send_thread(void *arg)
-{
- int thr;
- int ret = 0;
- thread_args_t *thr_args;
- odp_pktout_queue_t pktout;
- odp_pktout_config_opt_t *pktout_cfg;
- odp_packet_t pkt_ref_array[MAX_UDP_TX_BURST];
- odp_packet_t pkt_array[MAX_UDP_TX_BURST];
- int pkt_array_size, seq_step;
- int burst_start, burst_size;
- setup_pkt_ref_fn_t setup_pkt_ref = NULL;
- setup_pkt_fn_t setup_pkt = NULL;
- void *setup_pkt_arg = NULL;
- counters_t *counters;
- uint64_t pkt_count_max = 0;
-
- thr = odp_thread_id();
- thr_args = arg;
- pktout = thr_args->tx.pktout;
- pktout_cfg = thr_args->tx.pktout_cfg;
- counters = &thr_args->counters;
-
- /* Create reference packets*/
- if (args->appl.mode == APPL_MODE_UDP) {
- setup_pkt_ref = setup_udp_pkt_ref;
- setup_pkt = setup_udp_pkt;
- seq_step = args->tx_burst_size * (args->thread_cnt - 1);
- if (args->appl.number != -1)
- pkt_count_max = args->appl.number / args->thread_cnt +
- (args->appl.number % args->thread_cnt ? 1 : 0);
- setup_pkt_arg = &thr_args->tx.udp_param;
- } else if (args->appl.mode == APPL_MODE_PING) {
- setup_pkt_ref = setup_icmp_pkt_ref;
- setup_pkt = setup_icmp_pkt;
- seq_step = 0;
- if (args->appl.number != -1)
- pkt_count_max = args->appl.number;
- } else {
- ODPH_ERR(" [%02i] Error: invalid processing mode %d\n", thr,
- args->appl.mode);
- return -1;
- }
- pkt_array_size = args->tx_burst_size;
-
- if (setup_pkt_ref_array(thr_args->pool, pktout_cfg,
- pkt_ref_array, pkt_array_size,
- setup_pkt_ref)) {
- ODPH_ERR("[%02i] Error: failed to create reference packets\n",
- thr);
- return -1;
- }
-
- printf(" [%02i] created mode: SEND\n", thr);
-
- odp_barrier_wait(&args->barrier);
-
- for (;;) {
- if (thr_args->stop)
- break;
-
- if (pkt_count_max && counters->ctr_pkt_snd > pkt_count_max) {
- sleep(1); /* wait for stop command */
- continue;
- }
-
- /* Setup TX burst*/
- if (setup_pkt_array(pktout_cfg, counters,
- pkt_ref_array, pkt_array,
- pkt_array_size, setup_pkt, setup_pkt_arg)) {
- ODPH_ERR("[%02i] Error: failed to setup packets\n",
- thr);
- break;
- }
-
- /* Send TX burst*/
- for (burst_start = 0, burst_size = pkt_array_size;;) {
- ret = odp_pktout_send(pktout, &pkt_array[burst_start],
- burst_size);
- if (ret == burst_size) {
- burst_size = 0;
- break;
- } else if (ret >= 0 && ret < burst_size) {
- thr_args->counters.ctr_pkt_snd_drop +=
- burst_size - ret;
-
- burst_start += ret;
- burst_size -= ret;
- continue;
- }
- ODPH_ERR(" [%02i] packet send failed\n", thr);
- odp_packet_free_multi(&pkt_array[burst_start],
- burst_size);
- break;
- }
-
- counters->ctr_pkt_snd += pkt_array_size - burst_size;
-
- if (args->appl.interval != 0)
- odp_time_wait_ns((uint64_t)args->appl.interval *
- ODP_TIME_MSEC_IN_NS);
- counters->ctr_seq += seq_step;
- }
-
- odp_packet_free_multi(pkt_ref_array, pkt_array_size);
-
- return 0;
-}
-
-/**
- * Process icmp packets
- *
- * @param thr worker id
- * @param thr_args worker argument
- * @param icmp icmp header address
- */
-
-static void process_icmp_pkt(int thr, thread_args_t *thr_args,
- uint8_t *_icmp)
-{
- uint64_t trecv;
- uint64_t tsend;
- uint64_t rtt_ms, rtt_us;
- odph_icmphdr_t *icmp = (odph_icmphdr_t *)_icmp;
-
- if (icmp->type == ODPH_ICMP_ECHOREPLY) {
- thr_args->counters.ctr_icmp_reply_rcv++;
-
- memcpy(&tsend, (uint8_t *)icmp + ODPH_ICMPHDR_LEN,
- sizeof(uint64_t));
- trecv = odp_time_to_ns(odp_time_local());
- rtt_ms = (trecv - tsend) / ODP_TIME_MSEC_IN_NS;
- rtt_us = (trecv - tsend) / ODP_TIME_USEC_IN_NS -
- 1000 * rtt_ms;
- printf(" [%02i] ICMP Echo Reply seq %d time %"
- PRIu64 ".%.03" PRIu64" ms\n", thr,
- odp_be_to_cpu_16(icmp->un.echo.sequence),
- rtt_ms, rtt_us);
- } else if (icmp->type == ODPH_ICMP_ECHO) {
- printf(" [%02i] ICMP Echo Request\n", thr);
- }
-}
-
-/**
- * Process odp packets
- *
- * @param thr worker id
- * @param thr_args worker argument
- * @param pkt_tbl packets to be print
- * @param len packet number
- */
-static void process_pkts(int thr, thread_args_t *thr_args,
- odp_packet_t pkt_tbl[], unsigned len)
-{
- odp_packet_t pkt;
- uint32_t left, offset, i;
- odph_ipv4hdr_t *ip;
-
- for (i = 0; i < len; ++i) {
- pkt = pkt_tbl[i];
-
- /* Drop packets with errors */
- if (odp_unlikely(odp_packet_has_error(pkt)))
- continue;
-
- offset = odp_packet_l3_offset(pkt);
- left = odp_packet_len(pkt) - offset;
-
- if (left < sizeof(odph_ipv4hdr_t))
- continue;
-
- ip = (odph_ipv4hdr_t *)((uint8_t *)odp_packet_data(pkt) +
- offset);
-
- /* only ip pkts */
- if (ODPH_IPV4HDR_VER(ip->ver_ihl) != ODPH_IPV4)
- continue;
-
- thr_args->counters.ctr_pkt_rcv++;
-
- /* udp */
- if (ip->proto == ODPH_IPPROTO_UDP) {
- thr_args->counters.ctr_udp_rcv++;
- } else if (ip->proto == ODPH_IPPROTO_ICMPV4) {
- uint32_t l3_size = ODPH_IPV4HDR_IHL(ip->ver_ihl) * 4;
-
- offset += l3_size;
- left -= l3_size;
-
- if (left < sizeof(odph_icmphdr_t))
- continue;
-
- process_icmp_pkt(thr, thr_args,
- (uint8_t *)odp_packet_data(pkt) +
- offset);
- }
- }
-}
-
-/**
- * Scheduler receive function
- *
- * @param arg thread arguments of type 'thread_args_t *'
- */
-static int gen_recv_thread(void *arg)
-{
- int thr;
- thread_args_t *thr_args;
- odp_packet_t pkts[MAX_RX_BURST];
- odp_event_t events[MAX_RX_BURST], ev;
- int pkt_cnt, ev_cnt, i;
- int burst_size;
-
- thr = odp_thread_id();
- thr_args = (thread_args_t *)arg;
- burst_size = args->rx_burst_size;
-
- printf(" [%02i] created mode: RECEIVE SCHEDULER\n", thr);
- odp_barrier_wait(&args->barrier);
-
- for (;;) {
- if (thr_args->stop)
- break;
-
- /* Use schedule to get buf from any input queue */
- ev_cnt = odp_schedule_multi(NULL, ODP_SCHED_NO_WAIT,
- events, burst_size);
- if (ev_cnt == 0)
- continue;
-
- for (i = 0, pkt_cnt = 0; i < ev_cnt; i++) {
- ev = events[i];
-
- if (odp_event_type(ev) == ODP_EVENT_PACKET)
- pkts[pkt_cnt++] = odp_packet_from_event(ev);
- else
- odp_event_free(ev);
- }
-
- if (pkt_cnt) {
- process_pkts(thr, thr_args, pkts, pkt_cnt);
-
- odp_packet_free_multi(pkts, pkt_cnt);
- }
- }
-
- return 0;
-}
-
-/**
- * Direct receive function
- *
- * @param arg thread arguments of type 'thread_args_t *'
- */
-static int gen_recv_direct_thread(void *arg)
-{
- int thr;
- thread_args_t *thr_args;
- odp_packet_t pkts[MAX_RX_BURST];
- int pkt_cnt, burst_size;
- odp_pktin_queue_t pktin;
- uint64_t wait = odp_pktin_wait_time(ODP_TIME_SEC_IN_NS);
-
- thr = odp_thread_id();
- thr_args = (thread_args_t *)arg;
- pktin = thr_args->rx.pktin;
- burst_size = args->rx_burst_size;
-
- printf(" [%02i] created mode: RECEIVE\n", thr);
- odp_barrier_wait(&args->barrier);
-
- for (;;) {
- if (thr_args->stop)
- break;
-
- pkt_cnt = odp_pktin_recv_tmo(pktin, pkts, burst_size, wait);
-
- if (pkt_cnt > 0) {
- process_pkts(thr, thr_args, pkts, pkt_cnt);
-
- odp_packet_free_multi(pkts, pkt_cnt);
- } else if (pkt_cnt == 0) {
- continue;
- } else {
- break;
- }
- }
-
- return 0;
-}
-
-#define COUNTER_SUM(_c, _nw) \
-__extension__ ({ \
- int _itr; \
- uint64_t _result = 0; \
- \
- for (_itr = 0; _itr < _nw; _itr++) \
- _result += args->thread[_itr].counters.ctr_ ## _c; \
- \
- _result; \
-})
-
-static void garceful_stop_ping(void)
-{
- uint64_t snd, rcv;
-
- if (args->appl.mode != APPL_MODE_PING)
- return;
-
- while (args->appl.timeout >= 0) {
- snd = COUNTER_SUM(pkt_snd, 2);
- rcv = COUNTER_SUM(icmp_reply_rcv, 2);
- if (rcv >= snd)
- break;
-
- sleep(1);
- args->appl.timeout--;
- }
-}
-
-/**
- * printing verbose statistics
- *
- */
-static void print_global_stats(int num_workers)
-{
- odp_time_t cur, wait, next, left;
- uint64_t pkts_snd = 0, pkts_snd_prev = 0;
- uint64_t pps_snd = 0, maximum_pps_snd = 0;
- uint64_t pkts_rcv = 0, pkts_rcv_prev = 0;
- uint64_t pps_rcv = 0, maximum_pps_rcv = 0;
- uint64_t stall, pkts_snd_drop;
- int verbose_interval = STATS_INTERVAL, i;
- odp_thrmask_t thrd_mask;
-
- odp_barrier_wait(&args->barrier);
-
- wait = odp_time_local_from_ns(verbose_interval * ODP_TIME_SEC_IN_NS);
- next = odp_time_sum(odp_time_local(), wait);
-
- while (odp_thrmask_worker(&thrd_mask) == num_workers) {
- if (args->appl.mode != APPL_MODE_RCV &&
- args->appl.number != -1) {
- uint64_t cnt = COUNTER_SUM(pkt_snd, num_workers);
-
- if (cnt >= (unsigned int)args->appl.number) {
- garceful_stop_ping();
- break;
- }
- }
- cur = odp_time_local();
- if (odp_time_cmp(next, cur) > 0) {
- left = odp_time_diff(next, cur);
- stall = odp_time_to_ns(left);
- if (stall / ODP_TIME_SEC_IN_NS)
- sleep(1);
- else
- usleep(stall / ODP_TIME_USEC_IN_NS);
- continue;
- }
- next = odp_time_sum(cur, wait);
-
- switch (args->appl.mode) {
- case APPL_MODE_RCV:
- pkts_rcv = COUNTER_SUM(pkt_rcv, num_workers);
- pkts_snd = 0;
- pkts_snd_drop = 0;
- break;
- case APPL_MODE_PING:
- pkts_snd = COUNTER_SUM(pkt_snd, num_workers);
- pkts_snd_drop = COUNTER_SUM(pkt_snd_drop, num_workers);
- pkts_rcv = COUNTER_SUM(icmp_reply_rcv, num_workers);
- break;
- case APPL_MODE_UDP:
- pkts_snd = COUNTER_SUM(pkt_snd, num_workers);
- pkts_snd_drop = COUNTER_SUM(pkt_snd_drop, num_workers);
- break;
- default:
- continue;
- }
-
- pps_snd = (pkts_snd - pkts_snd_prev) / verbose_interval;
- pkts_snd_prev = pkts_snd;
- if (pps_snd > maximum_pps_snd)
- maximum_pps_snd = pps_snd;
-
- pps_rcv = (pkts_rcv - pkts_rcv_prev) / verbose_interval;
- pkts_rcv_prev = pkts_rcv;
- if (pps_rcv > maximum_pps_rcv)
- maximum_pps_rcv = pps_rcv;
-
- printf("sent: %" PRIu64 ", drops: %" PRIu64 ", "
- "send rate: %" PRIu64 " pps, "
- "max send rate: %" PRIu64 " pps, "
- "rcv: %" PRIu64 ", "
- "recv rate: %" PRIu64 " pps, "
- "max recv rate: %" PRIu64 " pps\n",
- pkts_snd, pkts_snd_drop,
- pps_snd, maximum_pps_snd,
- pkts_rcv, pps_rcv, maximum_pps_rcv);
- fflush(NULL);
- }
-
- for (i = 0; i < num_workers; i++)
- args->thread[i].stop = 1;
-}
-
-/**
- * ODP packet example main function
- */
-int main(int argc, char *argv[])
-{
- odph_helper_options_t helper_options;
- odph_thread_t thread_tbl[MAX_WORKERS];
- odp_pool_t pool;
- int num_workers;
- uint32_t num_rx_queues, num_tx_queues;
- int i;
- odp_shm_t shm;
- odp_cpumask_t cpumask;
- char cpumaskstr[ODP_CPUMASK_STR_SIZE];
- odp_pool_param_t params;
- interface_t *ifs;
- odp_instance_t instance;
- odp_init_t init_param;
- odph_thread_common_param_t thr_common;
- odph_thread_param_t thr_param;
-
- /* Signal handler has to be registered before global init in case ODP
- * implementation creates internal threads/processes. */
- signal(SIGINT, sig_handler);
-
- /* Let helper collect its own arguments (e.g. --odph_proc) */
- argc = odph_parse_options(argc, argv);
- if (odph_options(&helper_options)) {
- ODPH_ERR("Error: 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("Error: ODP global init failed.\n");
- exit(EXIT_FAILURE);
- }
-
- if (odp_init_local(instance, ODP_THREAD_CONTROL)) {
- ODPH_ERR("Error: ODP local init failed.\n");
- exit(EXIT_FAILURE);
- }
-
- /* Reserve memory for args from shared mem */
- shm = odp_shm_reserve("shm_args", sizeof(args_t),
- ODP_CACHE_LINE_SIZE, 0);
-
- if (shm == ODP_SHM_INVALID) {
- ODPH_ERR("Error: shared mem reserve failed.\n");
- exit(EXIT_FAILURE);
- }
-
- args = odp_shm_addr(shm);
-
- if (args == NULL) {
- ODPH_ERR("Error: shared mem alloc failed.\n");
- exit(EXIT_FAILURE);
- }
- memset(args, 0, sizeof(*args));
-
- /* Parse and store the application arguments */
- parse_args(argc, argv, &args->appl);
-
- /* Print both system and application information */
- print_info(NO_PATH(argv[0]), &args->appl);
-
- num_workers = 1;
- num_workers = odp_cpumask_default_worker(&cpumask, num_workers);
-
- if (args->appl.num_workers) {
- /* -w option: number of workers */
- num_workers = args->appl.num_workers;
- num_workers = odp_cpumask_default_worker(&cpumask, num_workers);
- } else if (args->appl.mask) {
- /* -c option: cpumask */
- odp_cpumask_from_str(&cpumask, args->appl.mask);
- num_workers = odp_cpumask_count(&cpumask);
- }
-
- (void)odp_cpumask_to_str(&cpumask, cpumaskstr, sizeof(cpumaskstr));
-
- printf("num worker threads: %i\n", num_workers);
- printf("first CPU: %i\n", odp_cpumask_first(&cpumask));
- printf("cpu mask: %s\n", cpumaskstr);
- fflush(NULL);
-
- /* ping mode need two workers */
- if (args->appl.mode == APPL_MODE_PING) {
- if (num_workers < 2) {
- ODPH_ERR("Need at least two worker threads\n");
- exit(EXIT_FAILURE);
- } else {
- num_workers = 2;
- }
- }
- args->thread_cnt = num_workers;
-
- /* Burst size */
- if (args->appl.mode == APPL_MODE_PING) {
- args->tx_burst_size = 1;
- args->rx_burst_size = 1;
- } else if (args->appl.mode == APPL_MODE_UDP) {
- args->tx_burst_size = args->appl.udp_tx_burst;
- args->rx_burst_size = 0;
- } else {
- args->tx_burst_size = 0;
- args->rx_burst_size = args->appl.rx_burst;
- }
-
- /* Configure scheduler */
- odp_schedule_config(NULL);
-
- /* Create packet pool */
- odp_pool_param_init(&params);
- params.pkt.seg_len = POOL_PKT_LEN;
- params.pkt.len = POOL_PKT_LEN;
- params.pkt.num = POOL_NUM_PKT;
- params.type = ODP_POOL_PACKET;
-
- pool = odp_pool_create("packet_pool", &params);
-
- if (pool == ODP_POOL_INVALID) {
- ODPH_ERR("Error: packet pool create failed.\n");
- exit(EXIT_FAILURE);
- }
- odp_pool_print(pool);
-
- ifs = malloc(sizeof(interface_t) * args->appl.if_count);
-
- for (i = 0; i < args->appl.if_count; ++i) {
- if (args->appl.mode == APPL_MODE_PING) {
- num_rx_queues = 1;
- num_tx_queues = 1;
- } else if (args->appl.mode == APPL_MODE_UDP) {
- num_rx_queues = 0;
- num_tx_queues = num_workers / args->appl.if_count;
- if (i < num_workers % args->appl.if_count)
- num_tx_queues++;
- } else { /* APPL_MODE_RCV*/
- num_rx_queues = num_workers / args->appl.if_count;
- if (i < num_workers % args->appl.if_count)
- num_rx_queues++;
- num_tx_queues = 0;
- }
-
- if (create_pktio(args->appl.if_names[i], pool, num_rx_queues,
- num_tx_queues, &ifs[i])) {
- ODPH_ERR("Error: create interface %s failed.\n",
- args->appl.if_names[i]);
- exit(EXIT_FAILURE);
- }
- }
-
- /* Create and init worker threads */
- memset(thread_tbl, 0, sizeof(thread_tbl));
-
- /* Init threads params */
- odph_thread_param_init(&thr_param);
- thr_param.thr_type = ODP_THREAD_WORKER;
-
- odph_thread_common_param_init(&thr_common);
- thr_common.instance = instance;
-
- /* num workers + print thread */
- odp_barrier_init(&args->barrier, num_workers + 1);
-
- if (args->appl.mode == APPL_MODE_PING) {
- odp_cpumask_t cpu_mask;
- int cpu_first, cpu_next;
- thread_args_t *thr_args;
-
- odp_cpumask_zero(&cpu_mask);
- cpu_first = odp_cpumask_first(&cpumask);
- odp_cpumask_set(&cpu_mask, cpu_first);
-
- thr_args = &args->thread[PING_THR_RX];
- if (!args->appl.sched)
- thr_args->rx.pktin = ifs[0].pktin[0];
- thr_args->pool = pool;
- thr_args->mode = args->appl.mode;
-
- if (args->appl.sched)
- thr_param.start = gen_recv_thread;
- else
- thr_param.start = gen_recv_direct_thread;
-
- thr_param.arg = thr_args;
-
- thr_common.cpumask = &cpu_mask;
-
- odph_thread_create(&thread_tbl[PING_THR_RX], &thr_common,
- &thr_param, 1);
-
- thr_args = &args->thread[PING_THR_TX];
- thr_args->tx.pktout = ifs[0].pktout[0];
- thr_args->tx.pktout_cfg = &ifs[0].config.pktout;
- thr_args->pool = pool;
- thr_args->mode = args->appl.mode;
- cpu_next = odp_cpumask_next(&cpumask, cpu_first);
- odp_cpumask_zero(&cpu_mask);
- odp_cpumask_set(&cpu_mask, cpu_next);
-
- thr_param.start = gen_send_thread;
- thr_param.arg = thr_args;
-
- odph_thread_create(&thread_tbl[PING_THR_TX], &thr_common,
- &thr_param, 1);
-
- } else {
- int cpu = odp_cpumask_first(&cpumask);
- udp_args_t *udp_param = NULL;
- uint16_t sport_range = args->appl.srcport_end -
- args->appl.srcport + 1;
- uint16_t dport_range = args->appl.dstport_end -
- args->appl.dstport + 1;
- float sport_step = (float)(sport_range) / num_workers;
- float dport_step = (float)(dport_range) / num_workers;
- odp_bool_t multi_flow = false;
-
- if (sport_range > 1 || dport_range > 1)
- multi_flow = true;
-
- for (i = 0; i < num_workers; ++i) {
- odp_cpumask_t thd_mask;
- int (*thr_run_func)(void *);
- int if_idx, pktq_idx;
- uint64_t start_seq;
-
- if_idx = i % args->appl.if_count;
-
- if (args->appl.mode == APPL_MODE_RCV) {
- pktq_idx = (i / args->appl.if_count) %
- ifs[if_idx].pktin_count;
- if (!args->appl.sched)
- args->thread[i].rx.pktin =
- ifs[if_idx].pktin[pktq_idx];
- } else {
- udp_param = &args->thread[i].tx.udp_param;
-
- pktq_idx = (i / args->appl.if_count) %
- ifs[if_idx].pktout_count;
- start_seq = i * args->tx_burst_size;
-
- args->thread[i].tx.pktout =
- ifs[if_idx].pktout[pktq_idx];
- args->thread[i].tx.pktout_cfg =
- &ifs[if_idx].config.pktout;
-
- udp_param->multi_flow = multi_flow;
- udp_param->srcport_start = args->appl.srcport;
- udp_param->srcport_end = args->appl.srcport_end;
- udp_param->srcport_crt = args->appl.srcport;
- if (sport_range > 1)
- udp_param->srcport_crt +=
- (uint16_t)(i * sport_step);
-
- udp_param->dstport_start = args->appl.dstport;
- udp_param->dstport_end = args->appl.dstport_end;
- udp_param->dstport_crt = args->appl.dstport;
- if (dport_range > 1)
- udp_param->dstport_crt +=
- (uint16_t)(i * dport_step);
-
- args->thread[i].counters.ctr_seq = start_seq;
- }
- args->thread[i].pool = pool;
- args->thread[i].mode = args->appl.mode;
-
- if (args->appl.mode == APPL_MODE_UDP) {
- thr_run_func = gen_send_thread;
- } else if (args->appl.mode == APPL_MODE_RCV) {
- if (args->appl.sched)
- thr_run_func = gen_recv_thread;
- else
- thr_run_func = gen_recv_direct_thread;
- } else {
- ODPH_ERR("ERR MODE\n");
- exit(EXIT_FAILURE);
- }
- /*
- * Create threads one-by-one instead of all-at-once,
- * because each thread might get different arguments.
- * Calls odp_thread_create(cpu) for each thread
- */
- odp_cpumask_zero(&thd_mask);
- odp_cpumask_set(&thd_mask, cpu);
-
- thr_param.start = thr_run_func;
- thr_param.arg = &args->thread[i];
-
- thr_common.cpumask = &thd_mask;
-
- odph_thread_create(&thread_tbl[i], &thr_common,
- &thr_param, 1);
- cpu = odp_cpumask_next(&cpumask, cpu);
- }
- }
-
- print_global_stats(num_workers);
-
- /* Master thread waits for other threads to exit */
- odph_thread_join(thread_tbl, num_workers);
-
- for (i = 0; i < args->appl.if_count; ++i)
- odp_pktio_stop(ifs[i].pktio);
-
- for (i = 0; i < args->appl.if_count; ++i)
- odp_pktio_close(ifs[i].pktio);
- free(ifs);
- free(args->appl.if_names);
- free(args->appl.if_str);
- args = NULL;
- odp_mb_full();
- if (0 != odp_pool_destroy(pool))
- fprintf(stderr, "unable to destroy pool \"pool\"\n");
- if (0 != odp_shm_free(shm))
- fprintf(stderr, "unable to free \"shm\"\n");
- odp_term_local();
- odp_term_global(instance);
- printf("Exit\n\n");
-
- return 0;
-}
-
-/**
- * Parse and store the command line arguments
- *
- * @param argc argument count
- * @param argv[] argument vector
- * @param appl_args Store application arguments here
- */
-static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
-{
- int opt;
- int long_index;
- char *token;
- size_t len;
- odp_cpumask_t cpumask, cpumask_args, cpumask_and;
- int i, num_workers;
- static const struct option longopts[] = {
- {"interface", required_argument, NULL, 'I'},
- {"workers", required_argument, NULL, 'w'},
- {"cpumask", required_argument, NULL, 'c'},
- {"srcmac", required_argument, NULL, 'a'},
- {"dstmac", required_argument, NULL, 'b'},
- {"srcip", required_argument, NULL, 's'},
- {"dstip", required_argument, NULL, 'd'},
- {"srcport", required_argument, NULL, 'e'},
- {"srcport_end", required_argument, NULL, 'j'},
- {"dstport", required_argument, NULL, 'f'},
- {"dstport_end", required_argument, NULL, 'k'},
- {"packetsize", required_argument, NULL, 'p'},
- {"mode", required_argument, NULL, 'm'},
- {"count", required_argument, NULL, 'n'},
- {"timeout", required_argument, NULL, 't'},
- {"interval", required_argument, NULL, 'i'},
- {"help", no_argument, NULL, 'h'},
- {"udp_tx_burst", required_argument, NULL, 'x'},
- {"rx_burst", required_argument, NULL, 'r'},
- {"csum", no_argument, NULL, 'y'},
- {"sched", no_argument, NULL, 'z'},
- {NULL, 0, NULL, 0}
- };
-
- static const char *shortopts = "+I:a:b:s:d:p:i:m:n:t:w:c:x:he:j:f:k"
- ":yr:z";
-
- appl_args->mode = -1; /* Invalid, must be changed by parsing */
- appl_args->number = -1;
- appl_args->payload = 56;
- appl_args->timeout = -1;
- appl_args->interval = DEFAULT_PKT_INTERVAL;
- appl_args->udp_tx_burst = DEFAULT_UDP_TX_BURST;
- appl_args->rx_burst = DEFAULT_RX_BURST;
- appl_args->srcport = 0;
- appl_args->srcport_end = 0;
- appl_args->dstport = 0;
- appl_args->dstport_end = 0;
- appl_args->csum = 0;
- appl_args->sched = 0;
- appl_args->num_workers = -1;
-
- while (1) {
- opt = getopt_long(argc, argv, shortopts, longopts, &long_index);
- if (opt == -1)
- break; /* No more options */
-
- switch (opt) {
- case 'w':
- appl_args->num_workers = atoi(optarg);
- break;
- case 'c':
- appl_args->mask = optarg;
- odp_cpumask_from_str(&cpumask_args, args->appl.mask);
- num_workers = odp_cpumask_default_worker(&cpumask, 0);
- odp_cpumask_and(&cpumask_and, &cpumask_args, &cpumask);
- if (odp_cpumask_count(&cpumask_and) <
- odp_cpumask_count(&cpumask_args) ||
- odp_cpumask_count(&cpumask_args) > MAX_WORKERS) {
- ODPH_ERR("Wrong cpu mask, max cpu's:%d\n",
- num_workers < MAX_WORKERS ?
- num_workers : MAX_WORKERS);
- exit(EXIT_FAILURE);
- }
- break;
- /* parse packet-io interface names */
- case 'I':
- len = strlen(optarg);
- if (len == 0) {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
- len += 1; /* add room for '\0' */
-
- appl_args->if_str = malloc(len);
- if (appl_args->if_str == NULL) {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
-
- /* count the number of tokens separated by ',' */
- strcpy(appl_args->if_str, optarg);
- for (token = strtok(appl_args->if_str, ","), i = 0;
- token != NULL;
- token = strtok(NULL, ","), i++)
- ;
-
- appl_args->if_count = i;
-
- if (appl_args->if_count == 0) {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
-
- /* allocate storage for the if names */
- appl_args->if_names =
- calloc(appl_args->if_count, sizeof(char *));
-
- /* store the if names (reset names string) */
- strcpy(appl_args->if_str, optarg);
- for (token = strtok(appl_args->if_str, ","), i = 0;
- token != NULL; token = strtok(NULL, ","), i++) {
- appl_args->if_names[i] = token;
- }
- break;
-
- case 'm':
- if (optarg[0] == 'u') {
- appl_args->mode = APPL_MODE_UDP;
- } else if (optarg[0] == 'p') {
- appl_args->mode = APPL_MODE_PING;
- } else if (optarg[0] == 'r') {
- appl_args->mode = APPL_MODE_RCV;
- } else {
- ODPH_ERR("wrong mode!\n");
- exit(EXIT_FAILURE);
- }
- break;
-
- case 'a':
- if (odph_eth_addr_parse(&appl_args->srcmac, optarg)) {
- ODPH_ERR("wrong src mac:%s\n", optarg);
- exit(EXIT_FAILURE);
- }
- break;
-
- case 'b':
- if (odph_eth_addr_parse(&appl_args->dstmac, optarg)) {
- ODPH_ERR("wrong dst mac:%s\n", optarg);
- exit(EXIT_FAILURE);
- }
- break;
-
- case 's':
- if (scan_ip(optarg, &appl_args->srcip) != 1) {
- ODPH_ERR("wrong src ip:%s\n", optarg);
- exit(EXIT_FAILURE);
- }
- break;
-
- case 'd':
- if (scan_ip(optarg, &appl_args->dstip) != 1) {
- ODPH_ERR("wrong dst ip:%s\n", optarg);
- exit(EXIT_FAILURE);
- }
- break;
-
- case 'e':
- appl_args->srcport = (unsigned short)atoi(optarg);
- break;
- case 'j':
- appl_args->srcport_end = (unsigned short)atoi(optarg);
- break;
- case 'f':
- appl_args->dstport = (unsigned short)atoi(optarg);
- break;
- case 'k':
- appl_args->dstport_end = (unsigned short)atoi(optarg);
- break;
- case 'p':
- appl_args->payload = atoi(optarg);
- break;
-
- case 'n':
- appl_args->number = atoi(optarg);
- break;
-
- case 't':
- appl_args->timeout = atoi(optarg);
- break;
-
- case 'i':
- appl_args->interval = atoi(optarg);
- if (appl_args->interval <= 200 && geteuid() != 0) {
- ODPH_ERR("should be root user\n");
- exit(EXIT_FAILURE);
- }
- break;
- case 'x':
- appl_args->udp_tx_burst = atoi(optarg);
- if (appl_args->udp_tx_burst > MAX_UDP_TX_BURST) {
- ODPH_ERR("wrong UDP Tx burst size (max %d)\n",
- MAX_UDP_TX_BURST);
- exit(EXIT_FAILURE);
- }
- break;
- case 'r':
- appl_args->rx_burst = atoi(optarg);
- if (appl_args->rx_burst > MAX_RX_BURST) {
- ODPH_ERR("wrong Rx burst size (max %d)\n",
- MAX_RX_BURST);
- exit(EXIT_FAILURE);
- }
- break;
-
- case 'y':
- appl_args->csum = 1;
- break;
- case 'z':
- appl_args->sched = 1;
- break;
- case 'h':
- usage(argv[0]);
- exit(EXIT_SUCCESS);
- break;
-
- default:
- break;
- }
- }
-
- if (appl_args->num_workers < 0)
- appl_args->num_workers = 0;
- else if (appl_args->num_workers == 0 ||
- appl_args->num_workers > MAX_WORKERS)
- appl_args->num_workers = MAX_WORKERS;
-
- if (appl_args->if_count == 0 || appl_args->mode == -1) {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
-
- if ((appl_args->srcport != 0 && appl_args->srcport_end == 0) ||
- (appl_args->srcport_end < appl_args->srcport))
- appl_args->srcport_end = appl_args->srcport;
-
- if ((appl_args->dstport != 0 && appl_args->dstport_end == 0) ||
- (appl_args->dstport_end < appl_args->dstport))
- appl_args->dstport_end = appl_args->dstport;
-
- optind = 1; /* reset 'extern optind' from the getopt lib */
-}
-
-/**
- * Print system and application info
- */
-static void print_info(char *progname, appl_args_t *appl_args)
-{
- int i;
-
- odp_sys_info_print();
-
- printf("Running ODP appl: \"%s\"\n"
- "-----------------\n"
- "IF-count: %i\n"
- "Using IFs: ",
- progname, appl_args->if_count);
- for (i = 0; i < appl_args->if_count; ++i)
- printf(" %s", appl_args->if_names[i]);
- printf("\n"
- "Mode: ");
- if (appl_args->mode == 0)
- PRINT_APPL_MODE(APPL_MODE_UDP);
- else if (appl_args->mode == 1)
- PRINT_APPL_MODE(APPL_MODE_PING);
- else
- PRINT_APPL_MODE(APPL_MODE_RCV);
- printf("\n\n");
- fflush(NULL);
-}
-
-/**
- * Print usage information
- */
-static void usage(char *progname)
-{
- printf("\n"
- "Usage: %s OPTIONS\n"
- " E.g. %s -I eth1 -r\n"
- "\n"
- "OpenDataPlane example application.\n"
- "\n"
- " Work mode:\n"
- " 1.send ipv4 udp packets\n"
- " odp_generator -I eth0 --srcmac fe:0f:97:c9:e0:44 --dstmac 32:cb:9b:27:2f:1a --srcip 192.168.0.1 --dstip 192.168.0.2 -m u\n"
- " 2.receive ipv4 packets\n"
- " odp_generator -I eth0 -m r\n"
- " 3.work likes ping\n"
- " odp_generator -I eth0 --srcmac fe:0f:97:c9:e0:44 --dstmac 32:cb:9b:27:2f:1a --srcip 192.168.0.1 --dstip 192.168.0.2 --cpumask 0xc -m p\n"
- "\n"
- "Mandatory OPTIONS:\n"
- " -I, --interface Eth interfaces (comma-separated, no spaces)\n"
- " -a, --srcmac src mac address\n"
- " -b, --dstmac dst mac address\n"
- " -s, --srcip src ip address\n"
- " -d, --dstip dst ip address\n"
- " -m, --mode work mode: send udp(u), receive(r), send icmp(p)\n"
- "\n"
- "Optional OPTIONS\n"
- " -h, --help Display help and exit.\n"
- " -e, --srcport udp source port start value\n"
- " default is 0\n"
- " -j, --srcport_end udp source port end value\n"
- " default is udp source port start value\n"
- " -f, --dstport udp destination port start value\n"
- " default is 0\n"
- " -k, --dstport_end udp destination port end value\n"
- " default is udp destination port start value\n"
- " -p, --packetsize payload length of the packets\n"
- " -t, --timeout only for ping mode, wait ICMP reply timeout seconds\n"
- " -i, --interval wait interval ms between sending each packet\n"
- " default is 1000ms. 0 for flood mode\n"
- " -w, --workers specify number of workers need to be assigned to application\n"
- " default is 1, 0 for all available\n"
- " -n, --count the number of packets to be send\n"
- " -c, --cpumask to set on cores\n"
- " -x, --udp_tx_burst size of UDP TX burst\n"
- " -r, --rx_burst size of RX burst\n"
- " -y, --csum use platform checksum support if available\n"
- " default is disabled\n"
- " -z, --sched use scheduler API to receive packets\n"
- " default is direct mode API\n"
- "\n", NO_PATH(progname), NO_PATH(progname)
- );
-}
diff --git a/example/ipfragreass/odp_ipfragreass_reassemble.c b/example/ipfragreass/odp_ipfragreass_reassemble.c
index 55ee42504..89055e6e4 100644
--- a/example/ipfragreass/odp_ipfragreass_reassemble.c
+++ b/example/ipfragreass/odp_ipfragreass_reassemble.c
@@ -89,7 +89,7 @@ static inline uint32_t hash(odph_ipv4hdr_t *hdr)
{
uint32_t a = hdr->src_addr;
uint32_t b = hdr->dst_addr;
- uint32_t c = hdr->id << 16 | hdr->proto;
+ uint32_t c = (uint32_t)hdr->id << 16 | hdr->proto;
/* A degenerate 3x32-bit Jenkins hash */
c ^= b;
diff --git a/example/ipsec_api/odp_ipsec.c b/example/ipsec_api/odp_ipsec.c
index a67a3a1e8..b6cc9ee22 100644
--- a/example/ipsec_api/odp_ipsec.c
+++ b/example/ipsec_api/odp_ipsec.c
@@ -45,6 +45,7 @@
#include <odp_ipsec_stream.h>
#else
static void init_stream_db(void) {}
+static void deinit_stream_db(void) {}
static void resolve_stream_db(void) {}
static int create_stream_db_inputs(void)
{
@@ -1154,9 +1155,9 @@ main(int argc, char *argv[])
shm = odp_shm_lookup("shm_sp_db");
if (odp_shm_free(shm) != 0)
ODPH_ERR("Error: shm free shm_sp_db failed\n");
- shm = odp_shm_lookup("stream_db");
- if (odp_shm_free(shm) != 0)
- ODPH_ERR("Error: shm free stream_db failed\n");
+
+ deinit_stream_db();
+
if (odp_shm_free(global->shm)) {
ODPH_ERR("Error: shm free global data failed\n");
exit(EXIT_FAILURE);
diff --git a/example/ipsec_crypto/odp_ipsec.c b/example/ipsec_crypto/odp_ipsec.c
index 92e32d301..490d2ad0a 100644
--- a/example/ipsec_crypto/odp_ipsec.c
+++ b/example/ipsec_crypto/odp_ipsec.c
@@ -46,6 +46,7 @@
#include <odp_ipsec_stream.h>
#else
static void init_stream_db(void) {}
+static void deinit_stream_db(void) {}
static void resolve_stream_db(void) {}
static int create_stream_db_inputs(void)
{
@@ -1437,9 +1438,9 @@ main(int argc, char *argv[])
shm = odp_shm_lookup("shm_sp_db");
if (odp_shm_free(shm) != 0)
ODPH_ERR("Error: shm free shm_sp_db failed\n");
- shm = odp_shm_lookup("stream_db");
- if (odp_shm_free(shm) != 0)
- ODPH_ERR("Error: shm free stream_db failed\n");
+
+ deinit_stream_db();
+
if (odp_shm_free(global->shm)) {
ODPH_ERR("Error: shm free global data failed\n");
exit(EXIT_FAILURE);
diff --git a/example/ipsec_crypto/odp_ipsec_fwd_db.c b/example/ipsec_crypto/odp_ipsec_fwd_db.c
index 292d9c7c6..482813d41 100644
--- a/example/ipsec_crypto/odp_ipsec_fwd_db.c
+++ b/example/ipsec_crypto/odp_ipsec_fwd_db.c
@@ -78,8 +78,7 @@ int create_fwd_db_entry(char *input, char **if_names, int if_count)
&entry->subnet.mask);
break;
case 1:
- strncpy(entry->oif, token, OIF_LEN - 1);
- entry->oif[OIF_LEN - 1] = 0;
+ odph_strcpy(entry->oif, token, OIF_LEN);
for (i = 0; i < if_count; i++) {
if (!strcmp(if_names[i], entry->oif)) {
match = 1;
diff --git a/example/ipsec_crypto/odp_ipsec_misc.h b/example/ipsec_crypto/odp_ipsec_misc.h
index 921c4e3c0..5fba274d0 100644
--- a/example/ipsec_crypto/odp_ipsec_misc.h
+++ b/example/ipsec_crypto/odp_ipsec_misc.h
@@ -167,18 +167,18 @@ char *ipv4_addr_str(char *b, uint32_t addr)
static inline
int parse_ipv4_string(char *ipaddress, uint32_t *addr, uint32_t *mask)
{
- int b[4];
+ unsigned int b[4];
int qualifier = 32;
int converted;
if (strchr(ipaddress, '/')) {
- converted = sscanf(ipaddress, "%d.%d.%d.%d/%d",
+ converted = sscanf(ipaddress, "%u.%u.%u.%u/%d",
&b[3], &b[2], &b[1], &b[0],
&qualifier);
if (5 != converted)
return -1;
} else {
- converted = sscanf(ipaddress, "%d.%d.%d.%d",
+ converted = sscanf(ipaddress, "%u.%u.%u.%u",
&b[3], &b[2], &b[1], &b[0]);
if (4 != converted)
return -1;
@@ -189,7 +189,7 @@ int parse_ipv4_string(char *ipaddress, uint32_t *addr, uint32_t *mask)
if (!qualifier || (qualifier > 32))
return -1;
- *addr = b[0] | b[1] << 8 | b[2] << 16 | b[3] << 24;
+ *addr = (uint32_t)b[0] | (uint32_t)b[1] << 8 | (uint32_t)b[2] << 16 | (uint32_t)b[3] << 24;
if (mask)
*mask = ~(0xFFFFFFFF & ((1ULL << (32 - qualifier)) - 1));
diff --git a/example/ipsec_crypto/odp_ipsec_stream.c b/example/ipsec_crypto/odp_ipsec_stream.c
index 330b4cc54..505ee900b 100644
--- a/example/ipsec_crypto/odp_ipsec_stream.c
+++ b/example/ipsec_crypto/odp_ipsec_stream.c
@@ -40,13 +40,14 @@ typedef struct ODP_PACKED stream_pkt_hdr_s {
uint8_t data[]; /**< Incrementing data stream */
} stream_pkt_hdr_t;
+static const char *shm_name = "stream_db";
stream_db_t *stream_db;
void init_stream_db(void)
{
odp_shm_t shm;
- shm = odp_shm_reserve("stream_db",
+ shm = odp_shm_reserve(shm_name,
sizeof(stream_db_t),
ODP_CACHE_LINE_SIZE,
0);
@@ -65,6 +66,28 @@ void init_stream_db(void)
memset(stream_db, 0, sizeof(*stream_db));
}
+void deinit_stream_db(void)
+{
+ stream_db_entry_t *stream = NULL;
+
+ for (stream = stream_db->list; NULL != stream; stream = stream->next) {
+ free(stream->input.intf);
+ free(stream->output.intf);
+ }
+
+ odp_shm_t shm = odp_shm_lookup(shm_name);
+
+ if (shm == ODP_SHM_INVALID) {
+ ODPH_ERR("Error: shared mem not found.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (odp_shm_free(shm)) {
+ ODPH_ERR("Error: shared mem free failed.\n");
+ exit(EXIT_FAILURE);
+ }
+}
+
int create_stream_db_entry(char *input)
{
int pos = 0;
diff --git a/example/ipsec_crypto/odp_ipsec_stream.h b/example/ipsec_crypto/odp_ipsec_stream.h
index 8e1e936dd..c6bbb618b 100644
--- a/example/ipsec_crypto/odp_ipsec_stream.h
+++ b/example/ipsec_crypto/odp_ipsec_stream.h
@@ -31,14 +31,14 @@ typedef struct stream_db_entry_s {
uint32_t verified; /**< Number successfully verified */
const EVP_MD *evp_md; /**< Digest method */
struct {
- const char *intf; /**< Input interface name */
+ char *intf; /**< Input interface name */
odp_pktio_t pktio; /**< Input PktI/O interface */
uint32_t ah_seq; /**< AH sequence number if present */
uint32_t esp_seq; /**< ESP sequence number if present */
ipsec_cache_entry_t *entry; /**< IPsec to apply on input */
} input;
struct {
- const char *intf; /**< Output interface name */
+ char *intf; /**< Output interface name */
odp_pktio_t pktio; /**< Output PktI/O interface */
ipsec_cache_entry_t *entry; /**t IPsec to verify on output */
} output;
@@ -58,6 +58,9 @@ extern stream_db_t *stream_db;
/** Initialize stream database global control structure */
void init_stream_db(void);
+/** Deinitialize stream database global control structure */
+void deinit_stream_db(void);
+
/**
* Create an stream DB entry
*
diff --git a/example/l2fwd/README b/example/l2fwd/README
deleted file mode 100644
index 091d046ea..000000000
--- a/example/l2fwd/README
+++ /dev/null
@@ -1,14 +0,0 @@
- ODP L2FWD application
-
-Source code and Makefiles placed under test/performance/ directory.
-
-This L2 forwarding application can be used as example reference as well
-as performance test for different odp modes (direct, queue or scheduler
-with parallel, atomic or ordered queues).
-
-Note that this example is tuned for performance. As a result, when using
-scheduled mode with direct packet I/O output or queued output with multiple
-output queues, packet order is not guaranteed. To achieve guaranteed order,
-use a single worker thread or output interfaces with single output
-queues. Other examples of scalable processing using ordered queues that
-preserve order can be seen in the odp_pktio_ordered performance test.
diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c
deleted file mode 120000
index fb585f437..000000000
--- a/example/l2fwd/odp_l2fwd.c
+++ /dev/null
@@ -1 +0,0 @@
-../../test/performance/odp_l2fwd.c \ No newline at end of file
diff --git a/example/l2fwd_simple/odp_l2fwd_simple.c b/example/l2fwd_simple/odp_l2fwd_simple.c
index 5d9aaec87..1ea08cce1 100644
--- a/example/l2fwd_simple/odp_l2fwd_simple.c
+++ b/example/l2fwd_simple/odp_l2fwd_simple.c
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2024 Nokia
*/
/**
@@ -101,12 +102,12 @@ static int run_worker(void *arg ODP_UNUSED)
if (odp_pktio_start(global->if0)) {
printf("unable to start input interface\n");
- exit(1);
+ return -1;
}
printf("started input interface\n");
if (odp_pktio_start(global->if1)) {
printf("unable to start output interface\n");
- exit(1);
+ return -1;
}
printf("started output interface\n");
printf("started all\n");
@@ -159,6 +160,7 @@ int main(int argc, char **argv)
odph_ethaddr_t correct_src;
uint32_t mtu1, mtu2;
odp_shm_t shm;
+ odph_thread_join_result_t res[MAX_WORKERS];
/* Let helper collect its own arguments (e.g. --odph_proc) */
argc = odph_parse_options(argc, argv);
@@ -271,11 +273,19 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
- if (odph_thread_join(thd, MAX_WORKERS) != MAX_WORKERS) {
+ if (odph_thread_join_result(thd, res, MAX_WORKERS) != MAX_WORKERS) {
printf("Error: failed to join threads\n");
exit(EXIT_FAILURE);
}
+ for (int i = 0; i < MAX_WORKERS; i++) {
+ if (res[i].is_sig || res[i].ret != 0) {
+ printf("Error: thread failure%s: %d\n", res[i].is_sig ?
+ " (signaled)" : "", res[i].ret);
+ exit(EXIT_FAILURE);
+ }
+ }
+
if (odp_pktio_stop(global->if0) || odp_pktio_close(global->if0)) {
printf("Error: failed to close interface %s\n", argv[1]);
exit(EXIT_FAILURE);
diff --git a/example/l3fwd/odp_l3fwd_db.c b/example/l3fwd/odp_l3fwd_db.c
index 7d82695be..622c0a118 100644
--- a/example/l3fwd/odp_l3fwd_db.c
+++ b/example/l3fwd/odp_l3fwd_db.c
@@ -401,8 +401,7 @@ int create_fwd_db_entry(char *input, char **oif, uint8_t **dst_mac)
&entry->subnet.depth);
break;
case 1:
- strncpy(entry->oif, token, OIF_LEN - 1);
- entry->oif[OIF_LEN - 1] = 0;
+ odph_strcpy(entry->oif, token, OIF_LEN);
*oif = entry->oif;
break;
case 2:
diff --git a/example/m4/configure.m4 b/example/m4/configure.m4
index b02fd72a5..b51d8bd42 100644
--- a/example/m4/configure.m4
+++ b/example/m4/configure.m4
@@ -22,7 +22,6 @@ AM_CONDITIONAL([test_example], [test x$test_example = xyes ])
AC_CONFIG_FILES([example/classifier/Makefile
example/cli/Makefile
example/debug/Makefile
- example/generator/Makefile
example/hello/Makefile
example/ipsec_api/Makefile
example/ipsec_crypto/Makefile
@@ -34,7 +33,6 @@ AC_CONFIG_FILES([example/classifier/Makefile
example/simple_pipeline/Makefile
example/switch/Makefile
example/sysinfo/Makefile
- example/time/Makefile
example/timer/Makefile
example/traffic_mgmt/Makefile
example/Makefile])
diff --git a/example/simple_pipeline/odp_simple_pipeline.c b/example/simple_pipeline/odp_simple_pipeline.c
index ad80bc394..3a05bf1c5 100644
--- a/example/simple_pipeline/odp_simple_pipeline.c
+++ b/example/simple_pipeline/odp_simple_pipeline.c
@@ -922,6 +922,9 @@ int main(int argc, char **argv)
odph_thread_join(thr_tbl, num_threads);
+ free(global->appl.if_names);
+ free(global->appl.if_str);
+
if (odp_pktio_close(global->if0)) {
printf("Error: failed to close interface %s\n", argv[1]);
exit(EXIT_FAILURE);
diff --git a/example/sysinfo/odp_sysinfo.c b/example/sysinfo/odp_sysinfo.c
index df33f45cf..6ddbf0ad9 100644
--- a/example/sysinfo/odp_sysinfo.c
+++ b/example/sysinfo/odp_sysinfo.c
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2018 Linaro Limited
- * Copyright (c) 2022-2023 Nokia
+ * Copyright (c) 2022-2024 Nokia
*/
/**
@@ -169,6 +169,8 @@ static const char *cipher_alg_name(odp_cipher_alg_t cipher)
return "des";
case ODP_CIPHER_ALG_3DES_CBC:
return "3des_cbc";
+ case ODP_CIPHER_ALG_3DES_ECB:
+ return "3des_ecb";
case ODP_CIPHER_ALG_AES_CBC:
return "aes_cbc";
case ODP_CIPHER_ALG_AES_CTR:
@@ -193,6 +195,20 @@ static const char *cipher_alg_name(odp_cipher_alg_t cipher)
return "aes_eea2";
case ODP_CIPHER_ALG_ZUC_EEA3:
return "zuc_eea3";
+ case ODP_CIPHER_ALG_SNOW_V:
+ return "snow_v";
+ case ODP_CIPHER_ALG_SNOW_V_GCM:
+ return "snow_v_gcm";
+ case ODP_CIPHER_ALG_SM4_ECB:
+ return "sm4_ecb";
+ case ODP_CIPHER_ALG_SM4_CBC:
+ return "sm4_cbc";
+ case ODP_CIPHER_ALG_SM4_CTR:
+ return "sm4_ctr";
+ case ODP_CIPHER_ALG_SM4_GCM:
+ return "sm4_gcm";
+ case ODP_CIPHER_ALG_SM4_CCM:
+ return "sm4_ccm";
default:
return "Unknown";
}
@@ -215,6 +231,14 @@ static const char *auth_alg_name(odp_auth_alg_t auth)
return "sha384_hmac";
case ODP_AUTH_ALG_SHA512_HMAC:
return "sha512_hmac";
+ case ODP_AUTH_ALG_SHA3_224_HMAC:
+ return "sha3_224_hmac";
+ case ODP_AUTH_ALG_SHA3_256_HMAC:
+ return "sha3_256_hmac";
+ case ODP_AUTH_ALG_SHA3_384_HMAC:
+ return "sha3_384_hmac";
+ case ODP_AUTH_ALG_SHA3_512_HMAC:
+ return "sha3_512_hmac";
case ODP_AUTH_ALG_AES_GCM:
return "aes_gcm";
case ODP_AUTH_ALG_AES_GMAC:
@@ -235,6 +259,18 @@ static const char *auth_alg_name(odp_auth_alg_t auth)
return "aes_eia2";
case ODP_AUTH_ALG_ZUC_EIA3:
return "zuc_eia3";
+ case ODP_AUTH_ALG_SNOW_V_GCM:
+ return "snow_v_gcm";
+ case ODP_AUTH_ALG_SNOW_V_GMAC:
+ return "snow_v_gmac";
+ case ODP_AUTH_ALG_SM3_HMAC:
+ return "sm3_hmac";
+ case ODP_AUTH_ALG_SM4_GCM:
+ return "sm4_gcm";
+ case ODP_AUTH_ALG_SM4_GMAC:
+ return "sm4_gmac";
+ case ODP_AUTH_ALG_SM4_CCM:
+ return "sm4_ccm";
case ODP_AUTH_ALG_MD5:
return "md5";
case ODP_AUTH_ALG_SHA1:
@@ -247,6 +283,16 @@ static const char *auth_alg_name(odp_auth_alg_t auth)
return "sha384";
case ODP_AUTH_ALG_SHA512:
return "sha512";
+ case ODP_AUTH_ALG_SHA3_224:
+ return "sha3_224";
+ case ODP_AUTH_ALG_SHA3_256:
+ return "sha3_256";
+ case ODP_AUTH_ALG_SHA3_384:
+ return "sha3_384";
+ case ODP_AUTH_ALG_SHA3_512:
+ return "sha3_512";
+ case ODP_AUTH_ALG_SM3:
+ return "sm3";
default:
return "Unknown";
}
@@ -289,6 +335,20 @@ static void foreach_cipher(odp_crypto_cipher_algos_t ciphers, cipher_op_t op)
op(ODP_CIPHER_ALG_AES_EEA2);
if (ciphers.bit.zuc_eea3)
op(ODP_CIPHER_ALG_ZUC_EEA3);
+ if (ciphers.bit.snow_v)
+ op(ODP_CIPHER_ALG_SNOW_V);
+ if (ciphers.bit.snow_v_gcm)
+ op(ODP_CIPHER_ALG_SNOW_V_GCM);
+ if (ciphers.bit.sm4_ecb)
+ op(ODP_CIPHER_ALG_SM4_ECB);
+ if (ciphers.bit.sm4_cbc)
+ op(ODP_CIPHER_ALG_SM4_CBC);
+ if (ciphers.bit.sm4_ctr)
+ op(ODP_CIPHER_ALG_SM4_CTR);
+ if (ciphers.bit.sm4_gcm)
+ op(ODP_CIPHER_ALG_SM4_GCM);
+ if (ciphers.bit.sm4_ccm)
+ op(ODP_CIPHER_ALG_SM4_CCM);
}
static void foreach_auth(odp_crypto_auth_algos_t auths, auth_op_t op)
@@ -307,6 +367,14 @@ static void foreach_auth(odp_crypto_auth_algos_t auths, auth_op_t op)
op(ODP_AUTH_ALG_SHA384_HMAC);
if (auths.bit.sha512_hmac)
op(ODP_AUTH_ALG_SHA512_HMAC);
+ if (auths.bit.sha3_224_hmac)
+ op(ODP_AUTH_ALG_SHA3_224_HMAC);
+ if (auths.bit.sha3_256_hmac)
+ op(ODP_AUTH_ALG_SHA3_256_HMAC);
+ if (auths.bit.sha3_384_hmac)
+ op(ODP_AUTH_ALG_SHA3_384_HMAC);
+ if (auths.bit.sha3_512_hmac)
+ op(ODP_AUTH_ALG_SHA3_512_HMAC);
if (auths.bit.aes_gcm)
op(ODP_AUTH_ALG_AES_GCM);
if (auths.bit.aes_gmac)
@@ -327,6 +395,18 @@ static void foreach_auth(odp_crypto_auth_algos_t auths, auth_op_t op)
op(ODP_AUTH_ALG_AES_EIA2);
if (auths.bit.zuc_eia3)
op(ODP_AUTH_ALG_ZUC_EIA3);
+ if (auths.bit.snow_v_gcm)
+ op(ODP_AUTH_ALG_SNOW_V_GCM);
+ if (auths.bit.snow_v_gmac)
+ op(ODP_AUTH_ALG_SNOW_V_GMAC);
+ if (auths.bit.sm3_hmac)
+ op(ODP_AUTH_ALG_SM3_HMAC);
+ if (auths.bit.sm4_gcm)
+ op(ODP_AUTH_ALG_SM4_GCM);
+ if (auths.bit.sm4_gmac)
+ op(ODP_AUTH_ALG_SM4_GMAC);
+ if (auths.bit.sm4_ccm)
+ op(ODP_AUTH_ALG_SM4_CCM);
if (auths.bit.md5)
op(ODP_AUTH_ALG_MD5);
if (auths.bit.sha1)
@@ -339,6 +419,16 @@ static void foreach_auth(odp_crypto_auth_algos_t auths, auth_op_t op)
op(ODP_AUTH_ALG_SHA384);
if (auths.bit.sha512)
op(ODP_AUTH_ALG_SHA512);
+ if (auths.bit.sha3_224)
+ op(ODP_AUTH_ALG_SHA3_224);
+ if (auths.bit.sha3_256)
+ op(ODP_AUTH_ALG_SHA3_256);
+ if (auths.bit.sha3_384)
+ op(ODP_AUTH_ALG_SHA3_384);
+ if (auths.bit.sha3_512)
+ op(ODP_AUTH_ALG_SHA3_512);
+ if (auths.bit.sm3)
+ op(ODP_AUTH_ALG_SM3);
}
static void print_cipher_capa(odp_cipher_alg_t cipher)
@@ -686,7 +776,7 @@ static void parse_interfaces(appl_args_t *config, const char *optarg)
MAX_NAME_LEN);
exit(EXIT_FAILURE);
}
- strncpy(config->pktio[config->num_pktio].name, tmp, MAX_NAME_LEN);
+ odph_strcpy(config->pktio[config->num_pktio].name, tmp, MAX_NAME_LEN);
config->num_pktio++;
diff --git a/example/time/.gitignore b/example/time/.gitignore
deleted file mode 100644
index 938c1aaed..000000000
--- a/example/time/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-odp_time_global
diff --git a/example/time/Makefile.am b/example/time/Makefile.am
deleted file mode 100644
index b5a1ad35d..000000000
--- a/example/time/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-include $(top_srcdir)/example/Makefile.inc
-
-bin_PROGRAMS = odp_time_global
-
-if test_example
-TESTS = odp_time_global
-endif
-
-odp_time_global_SOURCES = odp_time_global_test.c
diff --git a/example/time/odp_time_global_test.c b/example/time/odp_time_global_test.c
deleted file mode 100644
index 7c1409abf..000000000
--- a/example/time/odp_time_global_test.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2015-2018 Linaro Limited
- */
-
-/**
- * @example odp_time_global_test.c
- *
- * Time API test application
- *
- * @cond _ODP_HIDE_FROM_DOXYGEN_
- */
-
-#include <inttypes.h>
-
-#include <odp_api.h>
-#include <odp/helper/odph_api.h>
-
-#define MAX_WORKERS 32
-#define MAX_NUM_BUF 8192
-#define ITERATION_NUM 2048
-#define LOG_BASE 8
-#define LOG_ENTRY_SIZE 19
-#define LOG_LINE_SIZE (LOG_BASE * LOG_ENTRY_SIZE + 1)
-
-#define QUEUE_NAME_PREFIX "thread_queue_"
-
-typedef struct {
- odp_time_t timestamp;
- int id;
-} timestamp_event_t;
-
-typedef struct {
- uint8_t thr;
- uint8_t id;
- odp_time_t time;
-} log_entry_t;
-
-typedef struct {
- uint32_t iteration_num;
- odp_atomic_u32_t iteration_counter;
- odp_atomic_u32_t id_counter;
- odp_atomic_u32_t log_counter;
- odp_atomic_u32_t err_counter;
- odp_barrier_t start_barrier;
- odp_barrier_t end_barrier;
- int thread_num;
- log_entry_t *log;
- int log_enries_num;
-} test_globals_t;
-
-static void print_log(test_globals_t *gbls)
-{
- uint32_t err_num;
- int i, j, k, pad;
- char line[LOG_LINE_SIZE];
-
- memset(line, '-', LOG_LINE_SIZE - 1);
- line[LOG_LINE_SIZE - 1] = 0;
- for (i = 1; i <= gbls->thread_num; i++) {
- printf("\n==== history of %d buffer, time,ns (thread) ====\n%s\n",
- i, line);
-
- /* print log for buffer */
- k = 0;
- for (j = 0; j < gbls->log_enries_num; j++)
- if (gbls->log[j].id == i) {
- printf("%10" PRIu64 " (%-3d)",
- odp_time_to_ns(gbls->log[j].time),
- gbls->log[j].thr);
-
- if (!(++k % LOG_BASE))
- printf(" |\n");
- else
- printf(" =>");
- }
-
- if ((k % LOG_BASE)) {
- pad = (LOG_BASE - k % LOG_BASE) * LOG_ENTRY_SIZE - 4;
- printf(" end%*c\n%s\n", pad, '|', line);
- } else {
- printf("%s\n", line);
- }
- }
-
- printf("\n\n");
-
- err_num = odp_atomic_load_u32(&gbls->err_counter);
- if (err_num)
- printf("Number of errors: %u\n", err_num);
-}
-
-static void generate_next_queue(test_globals_t *gbls, odp_queue_t *queue,
- unsigned int id)
-{
- int thr;
- uint8_t rand_u8;
- char queue_name[sizeof(QUEUE_NAME_PREFIX) + 2];
- unsigned int rand_id = 1;
-
- thr = odp_thread_id();
-
- /* generate next random id */
- if (gbls->thread_num > 1) {
- do {
- odp_random_data(&rand_u8, 1, ODP_RANDOM_BASIC);
- rand_id = rand_u8 % gbls->thread_num + 1;
- } while (rand_id == id);
- }
-
- sprintf(queue_name, QUEUE_NAME_PREFIX "%d", rand_id);
- *queue = odp_queue_lookup(queue_name);
-
- if (ODP_QUEUE_INVALID == *queue)
- ODPH_ABORT("Cannot lookup thread queue \"%s\", thread %d\n",
- queue_name, thr);
-}
-
-static void test_global_timestamps(test_globals_t *gbls,
- odp_queue_t queue, unsigned int id)
-{
- int thr;
- int log_entry;
- odp_event_t ev;
- odp_time_t time;
- odp_buffer_t buf;
- odp_queue_t queue_next;
- timestamp_event_t *timestamp_ev;
-
- thr = odp_thread_id();
- while (odp_atomic_load_u32(&gbls->iteration_counter) <
- gbls->iteration_num) {
- ev = odp_queue_deq(queue);
-
- if (ev == ODP_EVENT_INVALID)
- continue;
-
- buf = odp_buffer_from_event(ev);
- timestamp_ev = (timestamp_event_t *)odp_buffer_addr(buf);
-
- time = odp_time_global();
- if (odp_time_cmp(time, timestamp_ev->timestamp) < 0) {
- ODPH_ERR("timestamp is less than previous time_prev=%"
- PRIu64 "ns, time_next=%"
- PRIu64 "ns, thread %d\n",
- odp_time_to_ns(timestamp_ev->timestamp),
- odp_time_to_ns(time), thr);
- odp_atomic_inc_u32(&gbls->err_counter);
- }
-
- /* update the log */
- log_entry = odp_atomic_fetch_inc_u32(&gbls->log_counter);
- gbls->log[log_entry].time = timestamp_ev->timestamp;
- gbls->log[log_entry].id = timestamp_ev->id;
- gbls->log[log_entry].thr = thr;
-
- /* assign new current time and send */
- generate_next_queue(gbls, &queue_next, id);
- timestamp_ev->timestamp = time;
- if (odp_queue_enq(queue_next, ev))
- ODPH_ABORT("Cannot enqueue event %" PRIu64 " on queue "
- "%" PRIu64 ", thread %d\n",
- odp_event_to_u64(ev),
- odp_queue_to_u64(queue_next), thr);
-
- odp_atomic_inc_u32(&gbls->iteration_counter);
- }
-}
-
-/**
- * @internal Worker thread
- *
- * @param ptr Pointer to test arguments
- *
- * @return Pointer to exit status
- */
-static int run_thread(void *ptr)
-{
- int thr;
- uint32_t id;
- odp_event_t ev;
- odp_buffer_t buf;
- test_globals_t *gbls;
- odp_pool_t buffer_pool;
- odp_queue_t queue, queue_next;
- timestamp_event_t *timestamp_ev;
- char queue_name[sizeof(QUEUE_NAME_PREFIX) + 2];
-
- gbls = ptr;
- thr = odp_thread_id();
- printf("Thread %i starts on cpu %i\n", thr, odp_cpu_id());
-
- /*
- * Allocate own queue for receiving timestamps.
- * Own queue is needed to guarantee that next thread for receiving
- * buffer is not the same thread.
- */
- id = odp_atomic_fetch_inc_u32(&gbls->id_counter);
- sprintf(queue_name, QUEUE_NAME_PREFIX "%d", id);
- queue = odp_queue_create(queue_name, NULL);
- if (queue == ODP_QUEUE_INVALID)
- ODPH_ABORT("Cannot create thread queue, thread %d", thr);
-
- /* allocate buffer for timestamp */
- buffer_pool = odp_pool_lookup("time buffers pool");
- if (buffer_pool == ODP_POOL_INVALID)
- ODPH_ABORT("Buffer pool was not found, thread %d\n", thr);
-
- buf = odp_buffer_alloc(buffer_pool);
- if (buf == ODP_BUFFER_INVALID)
- ODPH_ABORT("Buffer was not allocated, thread %d\n", thr);
-
- /* wait all threads allocated their queues */
- odp_barrier_wait(&gbls->start_barrier);
-
- /* enqueue global timestamp to some queue of some other thread */
- generate_next_queue(gbls, &queue_next, id);
-
- /* save global timestamp and id for tracing */
- ev = odp_buffer_to_event(buf);
- timestamp_ev = (timestamp_event_t *)odp_buffer_addr(buf);
- timestamp_ev->id = id;
- timestamp_ev->timestamp = odp_time_global();
- if (odp_queue_enq(queue_next, ev))
- ODPH_ABORT("Cannot enqueue timestamp event %" PRIu64 " on "
- "queue %" PRIu64 ", thread %d", odp_event_to_u64(ev),
- odp_queue_to_u64(queue_next), thr);
-
- test_global_timestamps(gbls, queue, id);
-
- /* wait all threads are finished their jobs */
- odp_barrier_wait(&gbls->end_barrier);
-
- /* free all events on the allocated queue */
- while (1) {
- ev = odp_queue_deq(queue);
- if (ev == ODP_EVENT_INVALID)
- break;
-
- buf = odp_buffer_from_event(ev);
- odp_buffer_free(buf);
- }
-
- /* free allocated queue */
- if (odp_queue_destroy(queue))
- ODPH_ABORT("Cannot destroy queue %" PRIu64 "",
- odp_queue_to_u64(queue));
-
- printf("Thread %i exits\n", thr);
- fflush(NULL);
- return 0;
-}
-
-int main(int argc, char *argv[])
-{
- int err = 0;
- odp_pool_t pool = ODP_POOL_INVALID;
- int num_workers;
- test_globals_t *gbls;
- odp_cpumask_t cpumask;
- odp_pool_capability_t pool_capa;
- odp_pool_param_t pool_param;
- odp_shm_t shm_glbls = ODP_SHM_INVALID;
- odp_shm_t shm_log = ODP_SHM_INVALID;
- int log_size, log_enries_num;
- odph_helper_options_t helper_options;
- odph_thread_t thread_tbl[MAX_WORKERS];
- odp_instance_t instance;
- odp_init_t init_param;
- odph_thread_common_param_t thr_common;
- odph_thread_param_t thr_param;
-
- printf("\nODP global time test starts\n");
-
- /* Let helper collect its own arguments (e.g. --odph_proc) */
- argc = odph_parse_options(argc, argv);
- if (odph_options(&helper_options)) {
- ODPH_ERR("Error: reading ODP helper options failed.\n");
- exit(EXIT_FAILURE);
- }
-
- odp_init_param_init(&init_param);
- init_param.mem_model = helper_options.mem_model;
-
- if (odp_init_global(&instance, &init_param, NULL)) {
- err = 1;
- ODPH_ERR("ODP global init failed.\n");
- goto end;
- }
-
- /* Init this thread. */
- if (odp_init_local(instance, ODP_THREAD_CONTROL)) {
- err = 1;
- ODPH_ERR("ODP local init failed.\n");
- goto err_global;
- }
-
- num_workers = MAX_WORKERS;
- num_workers = odp_cpumask_default_worker(&cpumask, num_workers);
-
- shm_glbls = odp_shm_reserve("test_globals", sizeof(test_globals_t),
- ODP_CACHE_LINE_SIZE, 0);
- if (ODP_SHM_INVALID == shm_glbls) {
- err = 1;
- ODPH_ERR("Error: shared mem reserve failed.\n");
- goto err;
- }
-
- log_enries_num = num_workers * (ITERATION_NUM + num_workers);
- log_size = sizeof(log_entry_t) * log_enries_num;
- shm_log = odp_shm_reserve("test_log", log_size, ODP_CACHE_LINE_SIZE, 0);
- if (ODP_SHM_INVALID == shm_log) {
- err = 1;
- ODPH_ERR("Error: shared mem reserve failed.\n");
- goto err;
- }
-
- gbls = odp_shm_addr(shm_glbls);
- gbls->thread_num = num_workers;
- gbls->iteration_num = ITERATION_NUM;
- odp_atomic_store_u32(&gbls->iteration_counter, 0);
- odp_atomic_store_u32(&gbls->id_counter, 1);
- odp_atomic_store_u32(&gbls->log_counter, 0);
- odp_atomic_store_u32(&gbls->err_counter, 0);
- gbls->log_enries_num = log_enries_num;
- gbls->log = odp_shm_addr(shm_log);
- odp_barrier_init(&gbls->start_barrier, num_workers);
- odp_barrier_init(&gbls->end_barrier, num_workers);
- memset(gbls->log, 0, log_size);
-
- if (odp_pool_capability(&pool_capa)) {
- err = 1;
- ODPH_ERR("Error: pool capability failed.\n");
- goto err;
- }
-
- odp_pool_param_init(&pool_param);
-
- pool_param.buf.size = sizeof(timestamp_event_t);
- pool_param.buf.num = MAX_NUM_BUF;
- pool_param.type = ODP_POOL_BUFFER;
-
- if (pool_capa.buf.max_num && MAX_NUM_BUF > pool_capa.buf.max_num)
- pool_param.buf.num = pool_capa.buf.max_num;
-
- pool = odp_pool_create("time buffers pool", &pool_param);
- if (pool == ODP_POOL_INVALID) {
- err = 1;
- ODPH_ERR("Pool create failed.\n");
- goto err;
- }
-
- odph_thread_common_param_init(&thr_common);
- odph_thread_param_init(&thr_param);
-
- thr_param.start = run_thread;
- thr_param.arg = gbls;
- thr_param.thr_type = ODP_THREAD_WORKER;
-
- thr_common.instance = instance;
- thr_common.cpumask = &cpumask;
- thr_common.share_param = 1;
-
- /* Create and launch worker threads */
- odph_thread_create(thread_tbl, &thr_common, &thr_param, num_workers);
-
- /* Wait for worker threads to exit */
- odph_thread_join(thread_tbl, num_workers);
-
- print_log(gbls);
-
-err:
- if (pool != ODP_POOL_INVALID)
- if (odp_pool_destroy(pool))
- err = 1;
-
- if (shm_log != ODP_SHM_INVALID)
- if (odp_shm_free(shm_log))
- err = 1;
-
- if (shm_glbls != ODP_SHM_INVALID)
- if (odp_shm_free(shm_glbls))
- err = 1;
-
- if (odp_term_local())
- err = 1;
-err_global:
- if (odp_term_global(instance))
- err = 1;
-end:
- if (err) {
- ODPH_ERR("Err: ODP global time test failed\n\n");
- return -1;
- }
-
- printf("ODP global time test complete\n\n");
- return 0;
-}
diff --git a/example/timer/.gitignore b/example/timer/.gitignore
index 2b077829d..9502b573b 100644
--- a/example/timer/.gitignore
+++ b/example/timer/.gitignore
@@ -1,5 +1,3 @@
*.log
*.trs
-odp_timer_accuracy
-odp_timer_test
odp_timer_simple
diff --git a/example/timer/Makefile.am b/example/timer/Makefile.am
index 66cf0edfb..007a2842b 100644
--- a/example/timer/Makefile.am
+++ b/example/timer/Makefile.am
@@ -1,18 +1,9 @@
include $(top_srcdir)/example/Makefile.inc
-bin_PROGRAMS = odp_timer_accuracy \
- odp_timer_simple \
- odp_timer_test
-
-odp_timer_accuracy_SOURCES = odp_timer_accuracy.c
+bin_PROGRAMS = odp_timer_simple
odp_timer_simple_SOURCES = odp_timer_simple.c
-odp_timer_test_SOURCES = odp_timer_test.c
-
if test_example
-TESTS = odp_timer_accuracy_run.sh \
- odp_timer_simple
+TESTS = odp_timer_simple
endif
-
-EXTRA_DIST = odp_timer_accuracy_run.sh
diff --git a/example/timer/odp_timer_accuracy_run.sh b/example/timer/odp_timer_accuracy_run.sh
deleted file mode 100755
index 1c879f4e6..000000000
--- a/example/timer/odp_timer_accuracy_run.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-#
-# SPDX-License-Identifier: BSD-3-Clause
-# Copyright (c) 2022 Nokia
-#
-
-./odp_timer_accuracy${EXEEXT} -p 100000000 -n 10
diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
deleted file mode 100644
index 674d4f4ce..000000000
--- a/example/timer/odp_timer_test.c
+++ /dev/null
@@ -1,569 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2013-2018 Linaro Limited
- */
-
-/**
- * @example odp_timer_test.c
- *
- * Timer test application
- *
- * @cond _ODP_HIDE_FROM_DOXYGEN_
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <inttypes.h>
-
-/* ODP main header */
-#include <odp_api.h>
-
-/* ODP helper for Linux apps */
-#include <odp/helper/odph_api.h>
-
-/* GNU lib C */
-#include <getopt.h>
-
-/* Max worker threads */
-#define MAX_WORKERS (ODP_THREAD_COUNT_MAX - 1)
-#define NUM_TMOS 10000 /**< Number of timers */
-#define WAIT_NUM 10 /**< Max tries to rx last tmo per worker */
-
-/** Test arguments */
-typedef struct {
- unsigned int cpu_count; /**< CPU count*/
- int resolution_us; /**< Timeout resolution in usec*/
- int min_us; /**< Minimum timeout in usec*/
- int max_us; /**< Maximum timeout in usec*/
- int period_us; /**< Timeout period in usec*/
- int tmo_count; /**< Timeout count*/
-} test_args_t;
-
-/** @private Helper struct for timers */
-struct test_timer {
- odp_timer_t tim;
- odp_event_t ev;
-};
-
-/** Test global variables */
-typedef struct {
- test_args_t args; /**< Test argunments*/
- odp_barrier_t test_barrier; /**< Barrier for test synchronisation*/
- odp_pool_t pool; /**< pool handle*/
- odp_timer_pool_t tp; /**< Timer pool handle*/
- odp_atomic_u32_t remain; /**< Number of timeouts to receive*/
- struct test_timer tt[256]; /**< Array of all timer helper structs*/
- uint32_t num_workers; /**< Number of threads */
-} test_globals_t;
-
-/** @private Timer set status ASCII strings */
-static const char *timerset2str(odp_timer_retval_t val)
-{
- switch (val) {
- case ODP_TIMER_SUCCESS:
- return "success";
- case ODP_TIMER_TOO_NEAR:
- return "too near";
- case ODP_TIMER_TOO_FAR:
- return "too far";
- case ODP_TIMER_FAIL:
- return "failure";
- default:
- return "?";
- }
-}
-
-/** @private test timeout */
-static void remove_prescheduled_events(void)
-{
- odp_event_t ev;
- odp_queue_t queue;
- odp_schedule_pause();
- while ((ev = odp_schedule(&queue, ODP_SCHED_NO_WAIT)) !=
- ODP_EVENT_INVALID) {
- odp_event_free(ev);
- }
-}
-
-/** @private test timeout */
-static void test_abs_timeouts(int thr, test_globals_t *gbls)
-{
- uint64_t period;
- uint64_t period_ns;
- odp_queue_t queue;
- uint64_t tick;
- struct test_timer *ttp;
- odp_timeout_t tmo;
- uint32_t num_workers = gbls->num_workers;
-
- ODPH_DBG(" [%i] test_timeouts\n", thr);
-
- queue = odp_queue_lookup("timer_queue");
-
- period_ns = gbls->args.period_us * ODP_TIME_USEC_IN_NS;
- period = odp_timer_ns_to_tick(gbls->tp, period_ns);
-
- ODPH_DBG(" [%i] period %" PRIu64 " ticks, %" PRIu64 " ns\n", thr,
- period, period_ns);
-
- ODPH_DBG(" [%i] current tick %" PRIu64 "\n", thr,
- odp_timer_current_tick(gbls->tp));
-
- ttp = &gbls->tt[thr];
- ttp->tim = odp_timer_alloc(gbls->tp, queue, ttp);
- if (ttp->tim == ODP_TIMER_INVALID) {
- ODPH_ERR("Failed to allocate timer\n");
- return;
- }
- tmo = odp_timeout_alloc(gbls->pool);
- if (tmo == ODP_TIMEOUT_INVALID) {
- ODPH_ERR("Failed to allocate timeout\n");
- return;
- }
- ttp->ev = odp_timeout_to_event(tmo);
- tick = odp_timer_current_tick(gbls->tp);
-
- while (1) {
- int wait = 0;
- odp_event_t ev;
- odp_timer_retval_t rc;
- odp_timer_start_t start_param;
-
- if (ttp) {
- tick += period;
-
- start_param.tick_type = ODP_TIMER_TICK_ABS;
- start_param.tick = tick;
- start_param.tmo_ev = ttp->ev;
-
- rc = odp_timer_start(ttp->tim, &start_param);
- if (odp_unlikely(rc != ODP_TIMER_SUCCESS)) {
- /* Too early or too late timeout requested */
- ODPH_ABORT("odp_timer_start() failed: %s\n", timerset2str(rc));
- }
- }
-
- /* Get the next expired timeout.
- * We invoke the scheduler in a loop with a timeout because
- * we are not guaranteed to receive any more timeouts. The
- * scheduler isn't guaranteeing fairness when scheduling
- * buffers to threads.
- * Use 1.5 second timeout for scheduler */
- uint64_t sched_tmo =
- odp_schedule_wait_time(1500000000ULL);
- do {
- ev = odp_schedule(&queue, sched_tmo);
- /* Check if odp_schedule() timed out, possibly there
- * are no remaining timeouts to receive */
- if (++wait > WAIT_NUM &&
- odp_atomic_load_u32(&gbls->remain) < num_workers)
- ODPH_ABORT("At least one TMO was lost\n");
- } while (ev == ODP_EVENT_INVALID &&
- (int)odp_atomic_load_u32(&gbls->remain) > 0);
-
- if (ev == ODP_EVENT_INVALID)
- break; /* No more timeouts */
- if (odp_event_type(ev) != ODP_EVENT_TIMEOUT) {
- /* Not a default timeout event */
- ODPH_ABORT("Unexpected event type (%u) received\n",
- odp_event_type(ev));
- }
- tmo = odp_timeout_from_event(ev);
- tick = odp_timeout_tick(tmo);
- ttp = odp_timeout_user_ptr(tmo);
- ttp->ev = ev;
-
- ODPH_DBG(" [%i] timeout, tick %" PRIu64 "\n", thr, tick);
-
- uint32_t rx_num = odp_atomic_fetch_dec_u32(&gbls->remain);
-
- if (!rx_num)
- ODPH_ABORT("Unexpected timeout received (timer "
- "%" PRIu64 ", tick %" PRIu64 ")\n",
- odp_timer_to_u64(ttp->tim), tick);
- else if (rx_num > num_workers)
- continue;
-
- odp_event_free(ttp->ev);
-
- if (odp_timer_free(ttp->tim))
- ODPH_ABORT("Timer free failed (%" PRIu64 ")\n", odp_timer_to_u64(ttp->tim));
-
- ttp = NULL;
- }
-
- /* Remove any prescheduled events */
- remove_prescheduled_events();
-}
-
-
-/**
- * @internal Worker thread
- *
- * @param ptr Pointer to test arguments
- *
- * @return Pointer to exit status
- */
-static int run_thread(void *ptr)
-{
- int thr;
- odp_pool_t msg_pool;
- test_globals_t *gbls;
-
- gbls = ptr;
- thr = odp_thread_id();
-
- printf("Thread %i starts on cpu %i\n", thr, odp_cpu_id());
-
- /*
- * Find the pool
- */
- msg_pool = odp_pool_lookup("msg_pool");
-
- if (msg_pool == ODP_POOL_INVALID) {
- ODPH_ERR(" [%i] msg_pool not found\n", thr);
- return -1;
- }
-
- odp_barrier_wait(&gbls->test_barrier);
-
- test_abs_timeouts(thr, gbls);
-
-
- printf("Thread %i exits\n", thr);
- fflush(NULL);
- return 0;
-}
-
-
-/**
- * @internal Print help
- */
-static void print_usage(void)
-{
- printf("\n\nUsage: ./odp_example [options]\n");
- printf("Options:\n");
- printf(" -c, --count <number> CPU count, 0=all available, default=1\n");
- printf(" -r, --resolution <us> timeout resolution in usec\n");
- printf(" -m, --min <us> minimum timeout in usec\n");
- printf(" -x, --max <us> maximum timeout in usec\n");
- printf(" -p, --period <us> timeout period in usec\n");
- printf(" -t, --timeouts <count> timeout repeat count\n");
- printf(" -h, --help this help\n");
- printf("\n\n");
-}
-
-
-/**
- * @internal Parse arguments
- *
- * @param argc Argument count
- * @param argv Argument vector
- * @param args Test arguments
- */
-static int parse_args(int argc, char *argv[], test_args_t *args)
-{
- int opt;
- int long_index;
- odp_timer_capability_t timer_capa;
-
- static const struct option longopts[] = {
- {"count", required_argument, NULL, 'c'},
- {"resolution", required_argument, NULL, 'r'},
- {"min", required_argument, NULL, 'm'},
- {"max", required_argument, NULL, 'x'},
- {"period", required_argument, NULL, 'p'},
- {"timeouts", required_argument, NULL, 't'},
- {"help", no_argument, NULL, 'h'},
- {NULL, 0, NULL, 0}
- };
-
- static const char *shortopts = "+c:r:m:x:p:t:h";
-
- /* defaults */
- if (odp_timer_capability(ODP_CLOCK_DEFAULT, &timer_capa))
- return -1;
-
- args->cpu_count = 1;
- args->resolution_us = ODPH_MAX(10000u, timer_capa.highest_res_ns / ODP_TIME_USEC_IN_NS);
- args->min_us = 0;
- args->max_us = 10000000;
- args->period_us = 1000000;
- args->tmo_count = 30;
-
- while (1) {
- opt = getopt_long(argc, argv, shortopts, longopts, &long_index);
-
- if (opt == -1)
- break; /* No more options */
-
- switch (opt) {
- case 'c':
- args->cpu_count = atoi(optarg);
- break;
- case 'r':
- args->resolution_us = atoi(optarg);
- break;
- case 'm':
- args->min_us = atoi(optarg);
- break;
- case 'x':
- args->max_us = atoi(optarg);
- break;
- case 'p':
- args->period_us = atoi(optarg);
- break;
- case 't':
- args->tmo_count = atoi(optarg);
- break;
- case 'h':
- print_usage();
- exit(EXIT_SUCCESS);
- break;
-
- default:
- break;
- }
- }
-
- if (args->period_us < args->resolution_us)
- printf("\n\tWarn: timeout is set less then resolution\n");
-
- return 0;
-}
-
-/**
- * Test main function
- */
-int main(int argc, char *argv[])
-{
- odph_helper_options_t helper_options;
- odph_thread_t thread_tbl[MAX_WORKERS];
- odph_thread_common_param_t thr_common;
- odph_thread_param_t thr_param;
- int num_workers;
- odp_queue_t queue;
- uint64_t tick, ns;
- odp_queue_param_t param;
- odp_pool_param_t params;
- odp_timer_pool_param_t tparams;
- odp_timer_pool_info_t tpinfo;
- odp_cpumask_t cpumask;
- char cpumaskstr[ODP_CPUMASK_STR_SIZE];
- odp_instance_t instance;
- odp_init_t init_param;
- odp_shm_t shm = ODP_SHM_INVALID;
- test_globals_t *gbls = NULL;
- int err = 0;
-
- printf("\nODP timer example starts\n");
-
- /* Let helper collect its own arguments (e.g. --odph_proc) */
- argc = odph_parse_options(argc, argv);
- if (odph_options(&helper_options)) {
- ODPH_ERR("Error: reading ODP helper options failed.\n");
- exit(EXIT_FAILURE);
- }
-
- odp_init_param_init(&init_param);
- init_param.mem_model = helper_options.mem_model;
-
- if (odp_init_global(&instance, &init_param, NULL)) {
- err = 1;
- printf("ODP global init failed.\n");
- goto err_global;
- }
-
- /* Init this thread. */
- if (odp_init_local(instance, ODP_THREAD_CONTROL)) {
- err = 1;
- printf("ODP local init failed.\n");
- goto err_local;
- }
-
- printf("\n");
- odp_sys_info_print();
-
- /* Reserve memory for test_globals_t from shared mem */
- shm = odp_shm_reserve("shm_test_globals", sizeof(test_globals_t),
- ODP_CACHE_LINE_SIZE, 0);
- if (ODP_SHM_INVALID == shm) {
- err = 1;
- ODPH_ERR("Error: shared mem reserve failed.\n");
- goto err;
- }
-
- gbls = odp_shm_addr(shm);
- if (NULL == gbls) {
- err = 1;
- ODPH_ERR("Error: shared mem alloc failed.\n");
- goto err;
- }
- memset(gbls, 0, sizeof(test_globals_t));
- gbls->pool = ODP_POOL_INVALID;
- gbls->tp = ODP_TIMER_POOL_INVALID;
-
- if (parse_args(argc, argv, &gbls->args)) {
- ODPH_ERR("Parse args failed.\n");
- goto err;
- }
-
- memset(thread_tbl, 0, sizeof(thread_tbl));
-
- num_workers = MAX_WORKERS;
- if (gbls->args.cpu_count && gbls->args.cpu_count < MAX_WORKERS)
- num_workers = gbls->args.cpu_count;
-
- /* Get default worker cpumask */
- num_workers = odp_cpumask_default_worker(&cpumask, num_workers);
- (void)odp_cpumask_to_str(&cpumask, cpumaskstr, sizeof(cpumaskstr));
-
- printf("num worker threads: %i\n", num_workers);
- printf("first CPU: %i\n", odp_cpumask_first(&cpumask));
- printf("cpu mask: %s\n", cpumaskstr);
-
- printf("resolution: %i usec\n", gbls->args.resolution_us);
- printf("min timeout: %i usec\n", gbls->args.min_us);
- printf("max timeout: %i usec\n", gbls->args.max_us);
- printf("period: %i usec\n", gbls->args.period_us);
- printf("timeouts: %i\n", gbls->args.tmo_count);
-
- /* Configure scheduler */
- odp_schedule_config(NULL);
-
- /*
- * Create pool for timeouts
- */
- odp_pool_param_init(&params);
- params.tmo.num = NUM_TMOS;
- params.type = ODP_POOL_TIMEOUT;
-
- gbls->pool = odp_pool_create("msg_pool", &params);
-
- if (gbls->pool == ODP_POOL_INVALID) {
- err = 1;
- ODPH_ERR("Pool create failed.\n");
- goto err;
- }
-
- odp_timer_pool_param_init(&tparams);
- tparams.res_ns = gbls->args.resolution_us * ODP_TIME_USEC_IN_NS;
- tparams.min_tmo = gbls->args.min_us * ODP_TIME_USEC_IN_NS;
- tparams.max_tmo = gbls->args.max_us * ODP_TIME_USEC_IN_NS;
- tparams.num_timers = num_workers; /* One timer per worker */
- tparams.priv = 0; /* Shared */
- tparams.clk_src = ODP_CLOCK_DEFAULT;
-
- gbls->tp = odp_timer_pool_create("timer_pool", &tparams);
- if (gbls->tp == ODP_TIMER_POOL_INVALID) {
- err = 1;
- ODPH_ERR("Timer pool create failed.\n");
- goto err;
- }
-
- if (odp_timer_pool_start_multi(&gbls->tp, 1) != 1) {
- ODPH_ERR("Timer pool start failed\n");
- return -1;
- }
-
- odp_shm_print_all();
- (void)odp_timer_pool_info(gbls->tp, &tpinfo);
- printf("Timer pool\n");
- printf("----------\n");
- printf(" name: %s\n", tpinfo.name);
- printf(" resolution: %"PRIu64" ns\n", tpinfo.param.res_ns);
- printf(" min tmo: %"PRIu64" ticks\n", tpinfo.param.min_tmo);
- printf(" max tmo: %"PRIu64" ticks\n", tpinfo.param.max_tmo);
- printf("\n");
-
- /*
- * Create a queue for timer test
- */
- odp_queue_param_init(&param);
- param.type = ODP_QUEUE_TYPE_SCHED;
- param.sched.prio = odp_schedule_default_prio();
- param.sched.sync = ODP_SCHED_SYNC_PARALLEL;
- param.sched.group = ODP_SCHED_GROUP_ALL;
-
- queue = odp_queue_create("timer_queue", &param);
-
- if (queue == ODP_QUEUE_INVALID) {
- err = 1;
- ODPH_ERR("Timer queue create failed.\n");
- goto err;
- }
-
- printf("CPU freq %"PRIu64" Hz\n", odp_cpu_hz_max());
- printf("Timer ticks vs nanoseconds:\n");
- ns = 0;
- tick = odp_timer_ns_to_tick(gbls->tp, ns);
-
- printf(" %12" PRIu64 " ns -> %12" PRIu64 " ticks\n", ns, tick);
- printf(" %12" PRIu64 " ticks -> %12" PRIu64 " ns\n", tick,
- odp_timer_tick_to_ns(gbls->tp, tick));
-
- for (ns = 1; ns <= 100 * ODP_TIME_SEC_IN_NS; ns *= 10) {
- tick = odp_timer_ns_to_tick(gbls->tp, ns);
-
- printf(" %12" PRIu64 " ns -> %12" PRIu64 " ticks\n", ns,
- tick);
- printf(" %12" PRIu64 " ticks -> %12" PRIu64 " ns\n", tick,
- odp_timer_tick_to_ns(gbls->tp, tick));
- }
-
- printf("\n");
-
- gbls->num_workers = num_workers;
-
- /* Initialize number of timeouts to receive */
- odp_atomic_init_u32(&gbls->remain, gbls->args.tmo_count * num_workers);
-
- /* Barrier to sync test case execution */
- odp_barrier_init(&gbls->test_barrier, num_workers);
-
- /* Create and launch worker threads */
- 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_thread;
- thr_param.arg = gbls;
- thr_param.thr_type = ODP_THREAD_WORKER;
-
- odph_thread_create(thread_tbl, &thr_common, &thr_param, num_workers);
-
- /* Wait for worker threads to exit */
- odph_thread_join(thread_tbl, num_workers);
-
- /* free resources */
- if (odp_queue_destroy(queue))
- err = 1;
-
-err:
-
- if (gbls != NULL && gbls->tp != ODP_TIMER_POOL_INVALID)
- odp_timer_pool_destroy(gbls->tp);
-
- if (gbls != NULL && gbls->pool != ODP_POOL_INVALID)
- if (odp_pool_destroy(gbls->pool))
- err = 1;
-
- if (shm != ODP_SHM_INVALID)
- if (odp_shm_free(shm))
- err = 1;
-
- if (odp_term_local())
- err = 1;
-err_local:
- if (odp_term_global(instance))
- err = 1;
-err_global:
- if (err) {
- printf("Err: ODP timer test failed\n\n");
- return -1;
- }
-
- printf("ODP timer test complete\n\n");
- return 0;
-}
diff --git a/example/traffic_mgmt/odp_traffic_mgmt.c b/example/traffic_mgmt/odp_traffic_mgmt.c
index 4ed4f2044..17dcbaa13 100644
--- a/example/traffic_mgmt/odp_traffic_mgmt.c
+++ b/example/traffic_mgmt/odp_traffic_mgmt.c
@@ -343,7 +343,7 @@ static uint32_t create_profile_set(profile_params_set_t *profile_params_set,
odp_tm_shaper_params_t shaper_params, *shaper;
odp_tm_wred_params_t wred_params, *wred;
uint32_t err_cnt, color;
- char name[64], wred_name[64];
+ char name[ODP_TM_NAME_LEN], wred_name[ODP_TM_NAME_LEN];
err_cnt = 0;
if (name_idx == 0)
@@ -477,7 +477,7 @@ static int config_example_user(odp_tm_node_t cos_tm_node,
odp_tm_node_t user_tm_node;
profile_set_t *profile_set;
uint32_t app_idx, queue_idx, svc_class_queue_num;
- char user_name[64];
+ char user_name[ODP_TM_NAME_LEN];
int rc;
profile_set = &USER_PROFILE_SETS[svc_class];
@@ -538,7 +538,7 @@ static int config_company_node(const char *company_name)
profile_set_t *profile_set;
odp_tm_node_t company_tm_node, cos_tm_node;
uint32_t cos_idx, user_idx;
- char cos_node_name[64];
+ char cos_node_name[ODP_TM_NAME_LEN];
profile_set = &COMPANY_PROFILE_SET;
odp_tm_node_params_init(&tm_node_params);
diff --git a/helper/Makefile.am b/helper/Makefile.am
index 54d4fbf66..5dd078596 100644
--- a/helper/Makefile.am
+++ b/helper/Makefile.am
@@ -20,7 +20,7 @@ helperinclude_HEADERS = \
include/odp/helper/autoheader_external.h\
include/odp/helper/deprecated.h\
include/odp/helper/chksum.h\
- include/odp/helper/odph_debug.h \
+ include/odp/helper/debug.h \
include/odp/helper/eth.h\
include/odp/helper/gtp.h\
include/odp/helper/icmp.h\
@@ -29,14 +29,11 @@ helperinclude_HEADERS = \
include/odp/helper/ipsec.h\
include/odp/helper/macros.h\
include/odp/helper/odph_api.h\
- include/odp/helper/odph_cuckootable.h\
- include/odp/helper/odph_hashtable.h\
- include/odp/helper/odph_iplookuptable.h\
- include/odp/helper/odph_lineartable.h\
include/odp/helper/sctp.h \
+ include/odp/helper/stress.h\
+ include/odp/helper/string.h\
include/odp/helper/strong_types.h\
include/odp/helper/tcp.h\
- include/odp/helper/table.h\
include/odp/helper/threads.h \
include/odp/helper/udp.h \
include/odp/helper/version.h
@@ -56,17 +53,10 @@ helperinclude_HEADERS += \
include/odp/helper/cli.h
endif
-noinst_HEADERS = \
- include/odph_list_internal.h
-
__LIB__libodphelper_la_SOURCES = \
eth.c \
ip.c \
chksum.c \
- hashtable.c \
- lineartable.c \
- cuckootable.c \
- iplookuptable.c \
ipsec.c \
threads.c \
version.c
@@ -86,7 +76,7 @@ __LIB__libodphelper_la_LIBADD += $(LIBCLI_LIBS)
lib_LTLIBRARIES = $(LIB)/libodphelper.la
-CHECK_GLOBALS_REGEX = " (odph_|_deprecated_odph_)"
+CHECK_GLOBALS_REGEX = " (odph_|_deprecated_odph_|__odr_asan)"
TESTS_ENVIRONMENT = \
LIBTOOL="$(LIBTOOL)" \
diff --git a/helper/cli.c b/helper/cli.c
index 4ce4bf62e..dc6491f6b 100644
--- a/helper/cli.c
+++ b/helper/cli.c
@@ -153,13 +153,13 @@ int odph_cli_register_command(const char *name, odph_cli_user_cmd_func_t func,
cmd->fn = func;
- if (strlen(name) >= MAX_NAME_LEN - 1) {
+ if (strlen(name) >= MAX_NAME_LEN) {
ODPH_ERR("Error: command name too long\n");
goto error;
}
strcpy(cmd->name, name);
- if (strlen(help) >= MAX_HELP_LEN - 1) {
+ if (strlen(help) >= MAX_HELP_LEN) {
ODPH_ERR("Error: command help too long\n");
goto error;
}
diff --git a/helper/cuckootable.c b/helper/cuckootable.c
deleted file mode 100644
index 85f715b3c..000000000
--- a/helper/cuckootable.c
+++ /dev/null
@@ -1,776 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2016-2018 Linaro Limited
- */
-
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <string.h>
-#include <stdint.h>
-#include <errno.h>
-#include <stdio.h>
-
-#include <odp/helper/odph_cuckootable.h>
-#include <odp/helper/odph_debug.h>
-#include <odp_api.h>
-
-/* More efficient access to a map of single ullong */
-#define ULLONG_FOR_EACH_1(IDX, MAP) \
- for (; MAP && (((IDX) = __builtin_ctzll(MAP)), true); \
- MAP = (MAP & (MAP - 1)))
-
-/** @magic word, write to the first byte of the memory block
- * to indicate this block is used by a cuckoo hash table
- */
-#define ODPH_CUCKOO_TABLE_MAGIC_WORD 0xDFDFFDFD
-
-/** Number of items per bucket. */
-#define HASH_BUCKET_ENTRIES 4
-
-#define NULL_SIGNATURE 0
-#define KEY_ALIGNMENT 16
-
-/** Maximum size of hash table that can be created. */
-#define HASH_ENTRIES_MAX 1048576
-
-/** @internal signature struct
- * Structure storing both primary and secondary hashes
- */
-struct cuckoo_table_signatures {
- union {
- struct {
- uint32_t current;
- uint32_t alt;
- };
- uint64_t sig;
- };
-};
-
-/** @internal kay-value struct
- * Structure that stores key-value pair
- */
-struct cuckoo_table_key_value {
- uint8_t *key;
- uint8_t *value;
-};
-
-/** @internal bucket structure
- * Put the elements with different keys but a same signature
- * into a bucket, and each bucket has at most HASH_BUCKET_ENTRIES
- * elements.
- */
-struct ODP_ALIGNED_CACHE cuckoo_table_bucket {
- struct cuckoo_table_signatures signatures[HASH_BUCKET_ENTRIES];
- /* Includes dummy key index that always contains index 0 */
- odp_buffer_t key_buf[HASH_BUCKET_ENTRIES + 1];
- uint8_t flag[HASH_BUCKET_ENTRIES];
-};
-
-/* More efficient access to a map of single ullong */
-#define ULLONG_FOR_EACH_1(IDX, MAP) \
- for (; MAP && (((IDX) = __builtin_ctzll(MAP)), true); \
- MAP = (MAP & (MAP - 1)))
-
-/** A hash table structure. */
-typedef struct ODP_ALIGNED_CACHE {
- /**< for check */
- uint32_t magicword;
- /**< Name of the hash. */
- char name[ODPH_TABLE_NAME_LEN];
- /**< Total table entries. */
- uint32_t entries;
- /**< Number of buckets in table. */
- uint32_t num_buckets;
- /**< Length of hash key. */
- uint32_t key_len;
- /**< Length of value. */
- uint32_t value_len;
- /**< Bitmask for getting bucket index from hash signature. */
- uint32_t bucket_bitmask;
- /**< Queue that stores all free key-value slots*/
- odp_queue_t free_slots;
- /** Table with buckets storing all the hash values and key indexes
- to the key table*/
- struct cuckoo_table_bucket *buckets;
-} odph_cuckoo_table_impl;
-
-/**
- * Aligns input parameter to the next power of 2
- *
- * @param x
- * The integer value to algin
- *
- * @return
- * Input parameter aligned to the next power of 2
- */
-static inline uint32_t
-align32pow2(uint32_t x)
-{
- x--;
- x |= x >> 1;
- x |= x >> 2;
- x |= x >> 4;
- x |= x >> 8;
- x |= x >> 16;
-
- return x + 1;
-}
-
-odph_table_t
-odph_cuckoo_table_lookup(const char *name)
-{
- odph_cuckoo_table_impl *tbl = NULL;
- odp_shm_t shm;
-
- if (name == NULL || strlen(name) >= ODPH_TABLE_NAME_LEN)
- return NULL;
-
- shm = odp_shm_lookup(name);
- if (shm != ODP_SHM_INVALID)
- tbl = (odph_cuckoo_table_impl *)odp_shm_addr(shm);
- if (!tbl || tbl->magicword != ODPH_CUCKOO_TABLE_MAGIC_WORD)
- return NULL;
-
- if (strcmp(tbl->name, name))
- return NULL;
-
- return (odph_table_t)tbl;
-}
-
-odph_table_t
-odph_cuckoo_table_create(
- const char *name, uint32_t capacity, uint32_t key_size,
- uint32_t value_size)
-{
- odph_cuckoo_table_impl *tbl;
- odp_shm_t shm_tbl;
-
- odp_pool_t pool;
- odp_pool_param_t param;
-
- odp_queue_t queue;
- odp_queue_param_t qparam;
- odp_queue_capability_t qcapa;
- odp_pool_capability_t pcapa;
-
- char pool_name[ODPH_TABLE_NAME_LEN + 3],
- queue_name[ODPH_TABLE_NAME_LEN + 3];
- unsigned i;
- uint32_t impl_size, kv_entry_size,
- bucket_num, bucket_size;
-
- if (odp_queue_capability(&qcapa)) {
- ODPH_DBG("queue capa failed\n");
- return NULL;
- }
-
- if (qcapa.plain.max_size && qcapa.plain.max_size < capacity) {
- ODPH_DBG("queue max_size too small\n");
- return NULL;
- }
-
- if (odp_pool_capability(&pcapa)) {
- ODPH_DBG("pool capa failed\n");
- return NULL;
- }
-
- if (pcapa.buf.max_num && pcapa.buf.max_num < capacity) {
- ODPH_DBG("pool max_num too small\n");
- return NULL;
- }
-
- /* Check for valid parameters */
- if (
- (capacity > HASH_ENTRIES_MAX) ||
- (capacity < HASH_BUCKET_ENTRIES) ||
- (key_size == 0) ||
- (strlen(name) == 0)) {
- ODPH_DBG("invalid parameters\n");
- return NULL;
- }
-
- /* Guarantee there's no existing */
- tbl = (odph_cuckoo_table_impl *)(void *)odph_cuckoo_table_lookup(name);
- if (tbl != NULL) {
- ODPH_DBG("cuckoo hash table %s already exists\n", name);
- return NULL;
- }
-
- /* Calculate the sizes of different parts of cuckoo hash table */
- impl_size = sizeof(odph_cuckoo_table_impl);
- kv_entry_size = sizeof(struct cuckoo_table_key_value)
- + key_size + value_size;
-
- bucket_num = align32pow2(capacity) / HASH_BUCKET_ENTRIES;
- bucket_size = bucket_num * sizeof(struct cuckoo_table_bucket);
-
- shm_tbl = odp_shm_reserve(name, impl_size + bucket_size,
- ODP_CACHE_LINE_SIZE, 0);
-
- if (shm_tbl == ODP_SHM_INVALID) {
- ODPH_DBG(
- "shm allocation failed for odph_cuckoo_table_impl %s\n",
- name);
- return NULL;
- }
-
- tbl = (odph_cuckoo_table_impl *)odp_shm_addr(shm_tbl);
- memset(tbl, 0, impl_size + bucket_size);
-
- /* header of this mem block is the table impl struct,
- * then the bucket pool.
- */
- tbl->buckets = (void *)((char *)tbl + impl_size);
-
- /* initialize key-value buffer pool */
- snprintf(pool_name, sizeof(pool_name), "kv_%s", name);
- pool = odp_pool_lookup(pool_name);
-
- if (pool != ODP_POOL_INVALID)
- if (odp_pool_destroy(pool)) {
- odp_shm_free(shm_tbl);
- ODPH_DBG("failed to destroy pre-existing pool\n");
- return NULL;
- }
-
- odp_pool_param_init(&param);
- param.type = ODP_POOL_BUFFER;
- param.buf.size = kv_entry_size;
- if (pcapa.buf.max_align >= ODP_CACHE_LINE_SIZE)
- param.buf.align = ODP_CACHE_LINE_SIZE;
- param.buf.num = capacity;
-
- pool = odp_pool_create(pool_name, &param);
-
- if (pool == ODP_POOL_INVALID) {
- ODPH_DBG("failed to create key-value pool\n");
- odp_shm_free(shm_tbl);
- return NULL;
- }
-
- /* initialize free_slots queue */
- odp_queue_param_init(&qparam);
- qparam.type = ODP_QUEUE_TYPE_PLAIN;
- qparam.size = capacity;
-
- snprintf(queue_name, sizeof(queue_name), "fs_%s", name);
- queue = odp_queue_create(queue_name, &qparam);
- if (queue == ODP_QUEUE_INVALID) {
- ODPH_DBG("failed to create free_slots queue\n");
- (void)odp_pool_destroy(pool);
- odp_shm_free(shm_tbl);
- return NULL;
- }
-
- /* Setup hash context */
- snprintf(tbl->name, sizeof(tbl->name), "%s", name);
- tbl->magicword = ODPH_CUCKOO_TABLE_MAGIC_WORD;
- tbl->entries = capacity;
- tbl->key_len = key_size;
- tbl->value_len = value_size;
- tbl->num_buckets = bucket_num;
- tbl->bucket_bitmask = bucket_num - 1;
- tbl->free_slots = queue;
-
- /* generate all free buffers, and put into queue */
- for (i = 0; i < capacity; i++) {
- odp_event_t ev = odp_buffer_to_event(
- odp_buffer_alloc(pool));
- if (ev == ODP_EVENT_INVALID) {
- ODPH_DBG("failed to generate free slots\n");
- odph_cuckoo_table_destroy((odph_table_t)tbl);
- return NULL;
- }
-
- if (odp_queue_enq(queue, ev) < 0) {
- ODPH_DBG("failed to enqueue free slots\n");
- odph_cuckoo_table_destroy((odph_table_t)tbl);
- return NULL;
- }
- }
-
- return (odph_table_t)tbl;
-}
-
-int
-odph_cuckoo_table_destroy(odph_table_t tbl)
-{
- int ret;
- odph_cuckoo_table_impl *impl = NULL;
- char pool_name[ODPH_TABLE_NAME_LEN + 3];
- odp_event_t ev;
- odp_shm_t shm;
- odp_pool_t pool;
- uint32_t i, j;
-
- if (tbl == NULL)
- return -1;
-
- impl = (odph_cuckoo_table_impl *)(void *)tbl;
-
- /* check magic word */
- if (impl->magicword != ODPH_CUCKOO_TABLE_MAGIC_WORD) {
- ODPH_DBG("wrong magicword for cuckoo table\n");
- return -1;
- }
-
- /* free all used buffers*/
- for (i = 0; i < impl->num_buckets; i++) {
- for (j = 0; j < HASH_BUCKET_ENTRIES; j++) {
- if (impl->buckets[i].signatures[j].current
- != NULL_SIGNATURE)
- odp_buffer_free(impl->buckets[i].key_buf[j]);
- }
- }
-
- /* free all free buffers */
- while ((ev = odp_queue_deq(impl->free_slots))
- != ODP_EVENT_INVALID) {
- odp_buffer_free(odp_buffer_from_event(ev));
- }
-
- /* destroy free_slots queue */
- ret = odp_queue_destroy(impl->free_slots);
- if (ret < 0)
- ODPH_DBG("failed to destroy free_slots queue\n");
-
- /* destroy key-value pool */
- snprintf(pool_name, sizeof(pool_name), "kv_%s", impl->name);
- pool = odp_pool_lookup(pool_name);
- if (pool == ODP_POOL_INVALID) {
- ODPH_DBG("invalid pool\n");
- return -1;
- }
-
- ret = odp_pool_destroy(pool);
- if (ret != 0) {
- ODPH_DBG("failed to destroy key-value buffer pool\n");
- return -1;
- }
-
- /* free impl */
- shm = odp_shm_lookup(impl->name);
- if (shm == ODP_SHM_INVALID) {
- ODPH_DBG("unable look up shm\n");
- return -1;
- }
-
- return odp_shm_free(shm);
-}
-
-static uint32_t hash(const odph_cuckoo_table_impl *h, const void *key)
-{
- /* calc hash result by key */
- return odp_hash_crc32c(key, h->key_len, 0);
-}
-
-/* Calc the secondary hash value from the primary hash value of a given key */
-static inline uint32_t
-hash_secondary(const uint32_t primary_hash)
-{
- static const unsigned all_bits_shift = 12;
- static const unsigned alt_bits_xor = 0x5bd1e995;
-
- uint32_t tag = primary_hash >> all_bits_shift;
-
- return (primary_hash ^ ((tag + 1) * alt_bits_xor));
-}
-
-/* Search for an entry that can be pushed to its alternative location */
-static inline int
-make_space_bucket(
- const odph_cuckoo_table_impl *impl,
- struct cuckoo_table_bucket *bkt)
-{
- unsigned i, j;
- int ret;
- uint32_t next_bucket_idx;
- struct cuckoo_table_bucket *next_bkt[HASH_BUCKET_ENTRIES];
-
- /*
- * Push existing item (search for bucket with space in
- * alternative locations) to its alternative location
- */
- for (i = 0; i < HASH_BUCKET_ENTRIES; i++) {
- /* Search for space in alternative locations */
- next_bucket_idx = bkt->signatures[i].alt & impl->bucket_bitmask;
- next_bkt[i] = &impl->buckets[next_bucket_idx];
- for (j = 0; j < HASH_BUCKET_ENTRIES; j++) {
- if (next_bkt[i]->signatures[j].sig == NULL_SIGNATURE)
- break;
- }
-
- if (j != HASH_BUCKET_ENTRIES)
- break;
- }
-
- /* Alternative location has spare room (end of recursive function) */
- if (i != HASH_BUCKET_ENTRIES) {
- next_bkt[i]->signatures[j].alt = bkt->signatures[i].current;
- next_bkt[i]->signatures[j].current = bkt->signatures[i].alt;
- next_bkt[i]->key_buf[j] = bkt->key_buf[i];
- return i;
- }
-
- /* Pick entry that has not been pushed yet */
- for (i = 0; i < HASH_BUCKET_ENTRIES; i++)
- if (bkt->flag[i] == 0)
- break;
-
- /* All entries have been pushed, so entry cannot be added */
- if (i == HASH_BUCKET_ENTRIES)
- return -ENOSPC;
-
- /* Set flag to indicate that this entry is going to be pushed */
- bkt->flag[i] = 1;
- /* Need room in alternative bucket to insert the pushed entry */
- ret = make_space_bucket(impl, next_bkt[i]);
- /*
- * After recursive function.
- * Clear flags and insert the pushed entry
- * in its alternative location if successful,
- * or return error
- */
- bkt->flag[i] = 0;
- if (ret >= 0) {
- next_bkt[i]->signatures[ret].alt = bkt->signatures[i].current;
- next_bkt[i]->signatures[ret].current = bkt->signatures[i].alt;
- next_bkt[i]->key_buf[ret] = bkt->key_buf[i];
- return i;
- }
-
- return ret;
-}
-
-static inline int32_t
-cuckoo_table_add_key_with_hash(
- const odph_cuckoo_table_impl *h, const void *key,
- uint32_t sig, void *data)
-{
- uint32_t alt_hash;
- uint32_t prim_bucket_idx, sec_bucket_idx;
- unsigned i;
- struct cuckoo_table_bucket *prim_bkt, *sec_bkt;
- struct cuckoo_table_key_value *new_kv, *kv;
-
- odp_buffer_t new_buf;
- int ret;
-
- prim_bucket_idx = sig & h->bucket_bitmask;
- prim_bkt = &h->buckets[prim_bucket_idx];
- __builtin_prefetch((const void *)(uintptr_t)prim_bkt, 0, 3);
-
- alt_hash = hash_secondary(sig);
- sec_bucket_idx = alt_hash & h->bucket_bitmask;
- sec_bkt = &h->buckets[sec_bucket_idx];
- __builtin_prefetch((const void *)(uintptr_t)sec_bkt, 0, 3);
-
- /* Get a new slot for storing the new key */
- new_buf = odp_buffer_from_event(odp_queue_deq(h->free_slots));
- if (new_buf == ODP_BUFFER_INVALID)
- return -ENOSPC;
-
- /* Check if key is already inserted in primary location */
- for (i = 0; i < HASH_BUCKET_ENTRIES; i++) {
- if (
- prim_bkt->signatures[i].current == sig &&
- prim_bkt->signatures[i].alt == alt_hash) {
- kv = (struct cuckoo_table_key_value *)odp_buffer_addr(
- prim_bkt->key_buf[i]);
- if (memcmp(key, kv->key, h->key_len) == 0) {
- odp_queue_enq(
- h->free_slots,
- odp_buffer_to_event(new_buf));
- /* Update data */
- if (kv->value != NULL)
- memcpy(kv->value, data, h->value_len);
-
- /* Return bucket index */
- return prim_bucket_idx;
- }
- }
- }
-
- /* Check if key is already inserted in secondary location */
- for (i = 0; i < HASH_BUCKET_ENTRIES; i++) {
- if (
- sec_bkt->signatures[i].alt == sig &&
- sec_bkt->signatures[i].current == alt_hash) {
- kv = (struct cuckoo_table_key_value *)odp_buffer_addr(
- sec_bkt->key_buf[i]);
- if (memcmp(key, kv->key, h->key_len) == 0) {
- odp_queue_enq(
- h->free_slots,
- odp_buffer_to_event(new_buf));
- /* Update data */
- if (kv->value != NULL)
- memcpy(kv->value, data, h->value_len);
-
- /* Return bucket index */
- return sec_bucket_idx;
- }
- }
- }
-
- new_kv = (struct cuckoo_table_key_value *)odp_buffer_addr(new_buf);
- __builtin_prefetch((const void *)(uintptr_t)new_kv, 0, 3);
-
- /* Copy key and value.
- * key-value mem block : struct cuckoo_table_key_value
- * + key (key_len) + value (value_len)
- */
- new_kv->key = (uint8_t *)new_kv
- + sizeof(struct cuckoo_table_key_value);
- memcpy(new_kv->key, key, h->key_len);
-
- if (h->value_len > 0) {
- new_kv->value = new_kv->key + h->key_len;
- memcpy(new_kv->value, data, h->value_len);
- } else {
- new_kv->value = NULL;
- }
-
- /* Insert new entry is there is room in the primary bucket */
- for (i = 0; i < HASH_BUCKET_ENTRIES; i++) {
- /* Check if slot is available */
- if (odp_likely(prim_bkt->signatures[i].sig == NULL_SIGNATURE)) {
- prim_bkt->signatures[i].current = sig;
- prim_bkt->signatures[i].alt = alt_hash;
- prim_bkt->key_buf[i] = new_buf;
- return prim_bucket_idx;
- }
- }
-
- /* Primary bucket is full, so we need to make space for new entry */
- ret = make_space_bucket(h, prim_bkt);
-
- /*
- * After recursive function.
- * Insert the new entry in the position of the pushed entry
- * if successful or return error and
- * store the new slot back in the pool
- */
- if (ret >= 0) {
- prim_bkt->signatures[ret].current = sig;
- prim_bkt->signatures[ret].alt = alt_hash;
- prim_bkt->key_buf[ret] = new_buf;
- return prim_bucket_idx;
- }
-
- /* Error in addition, store new slot back in the free_slots */
- odp_queue_enq(h->free_slots, odp_buffer_to_event(new_buf));
- return ret;
-}
-
-int
-odph_cuckoo_table_put_value(odph_table_t tbl, void *key, void *value)
-{
- odph_cuckoo_table_impl *impl;
- int ret;
-
- if ((tbl == NULL) || (key == NULL))
- return -EINVAL;
-
- impl = (odph_cuckoo_table_impl *)(void *)tbl;
- ret = cuckoo_table_add_key_with_hash(
- impl, key, hash(impl, key), value);
-
- if (ret < 0)
- return -1;
-
- return 0;
-}
-
-static inline int32_t
-cuckoo_table_lookup_with_hash(
- const odph_cuckoo_table_impl *h, const void *key,
- uint32_t sig, void **data_ptr)
-{
- uint32_t bucket_idx;
- uint32_t alt_hash;
- unsigned i;
- struct cuckoo_table_bucket *bkt;
- struct cuckoo_table_key_value *kv;
-
- bucket_idx = sig & h->bucket_bitmask;
- bkt = &h->buckets[bucket_idx];
-
- /* Check if key is in primary location */
- for (i = 0; i < HASH_BUCKET_ENTRIES; i++) {
- if (
- bkt->signatures[i].current == sig &&
- bkt->signatures[i].sig != NULL_SIGNATURE) {
- kv = (struct cuckoo_table_key_value *)odp_buffer_addr(
- bkt->key_buf[i]);
- if (memcmp(key, kv->key, h->key_len) == 0) {
- if (data_ptr != NULL)
- *data_ptr = kv->value;
- /*
- * Return index where key is stored,
- * subtracting the first dummy index
- */
- return bucket_idx;
- }
- }
- }
-
- /* Calculate secondary hash */
- alt_hash = hash_secondary(sig);
- bucket_idx = alt_hash & h->bucket_bitmask;
- bkt = &h->buckets[bucket_idx];
-
- /* Check if key is in secondary location */
- for (i = 0; i < HASH_BUCKET_ENTRIES; i++) {
- if (
- bkt->signatures[i].current == alt_hash &&
- bkt->signatures[i].alt == sig) {
- kv = (struct cuckoo_table_key_value *)odp_buffer_addr(
- bkt->key_buf[i]);
- if (memcmp(key, kv->key, h->key_len) == 0) {
- if (data_ptr != NULL)
- *data_ptr = kv->value;
- /*
- * Return index where key is stored,
- * subtracting the first dummy index
- */
- return bucket_idx;
- }
- }
- }
-
- return -ENOENT;
-}
-
-int odph_cuckoo_table_get_value(odph_table_t tbl, void *key,
- void *buffer, uint32_t buffer_size ODP_UNUSED)
-{
- odph_cuckoo_table_impl *impl = (odph_cuckoo_table_impl *)(void *)tbl;
- void *tmp = NULL;
- int ret;
-
- if ((tbl == NULL) || (key == NULL))
- return -EINVAL;
-
- ret = cuckoo_table_lookup_with_hash(impl, key, hash(impl, key), &tmp);
-
- if (ret < 0)
- return -1;
-
- if (impl->value_len > 0)
- memcpy(buffer, tmp, impl->value_len);
-
- return 0;
-}
-
-static inline int32_t
-cuckoo_table_del_key_with_hash(
- const odph_cuckoo_table_impl *h,
- const void *key, uint32_t sig)
-{
- uint32_t bucket_idx;
- uint32_t alt_hash;
- unsigned i;
- struct cuckoo_table_bucket *bkt;
- struct cuckoo_table_key_value *kv;
-
- bucket_idx = sig & h->bucket_bitmask;
- bkt = &h->buckets[bucket_idx];
-
- /* Check if key is in primary location */
- for (i = 0; i < HASH_BUCKET_ENTRIES; i++) {
- if (
- bkt->signatures[i].current == sig &&
- bkt->signatures[i].sig != NULL_SIGNATURE) {
- kv = (struct cuckoo_table_key_value *)odp_buffer_addr(
- bkt->key_buf[i]);
- if (memcmp(key, kv->key, h->key_len) == 0) {
- bkt->signatures[i].sig = NULL_SIGNATURE;
- odp_queue_enq(
- h->free_slots,
- odp_buffer_to_event(
- bkt->key_buf[i]));
- return bucket_idx;
- }
- }
- }
-
- /* Calculate secondary hash */
- alt_hash = hash_secondary(sig);
- bucket_idx = alt_hash & h->bucket_bitmask;
- bkt = &h->buckets[bucket_idx];
-
- /* Check if key is in secondary location */
- for (i = 0; i < HASH_BUCKET_ENTRIES; i++) {
- if (
- bkt->signatures[i].current == alt_hash &&
- bkt->signatures[i].sig != NULL_SIGNATURE) {
- kv = (struct cuckoo_table_key_value *)odp_buffer_addr(
- bkt->key_buf[i]);
- if (memcmp(key, kv->key, h->key_len) == 0) {
- bkt->signatures[i].sig = NULL_SIGNATURE;
- odp_queue_enq(
- h->free_slots,
- odp_buffer_to_event(
- bkt->key_buf[i]));
- return bucket_idx;
- }
- }
- }
-
- return -ENOENT;
-}
-
-int
-odph_cuckoo_table_remove_value(odph_table_t tbl, void *key)
-{
- odph_cuckoo_table_impl *impl = (void *)tbl;
- int ret;
-
- if ((tbl == NULL) || (key == NULL))
- return -EINVAL;
-
- ret = cuckoo_table_del_key_with_hash(impl, key, hash(impl, key));
- if (ret < 0)
- return -1;
-
- return 0;
-}
-
-odph_table_ops_t odph_cuckoo_table_ops = {
- odph_cuckoo_table_create,
- odph_cuckoo_table_lookup,
- odph_cuckoo_table_destroy,
- odph_cuckoo_table_put_value,
- odph_cuckoo_table_get_value,
- odph_cuckoo_table_remove_value
-};
diff --git a/helper/hashtable.c b/helper/hashtable.c
deleted file mode 100644
index 28c23a58c..000000000
--- a/helper/hashtable.c
+++ /dev/null
@@ -1,356 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2015-2018 Linaro Limited
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <malloc.h>
-
-#include <odp/helper/odph_hashtable.h>
-#include <odp/helper/odph_debug.h>
-#include "odph_list_internal.h"
-#include <odp_api.h>
-
-#define ODPH_SUCCESS 0
-#define ODPH_FAIL -1
-
-/** @magic word, write to the first byte of the memory block
- * to indicate this block is used by a hash table structure
- */
-#define ODPH_HASH_TABLE_MAGIC_WORD 0xABABBABA
-
-/** @support 64k buckets. Bucket is a list that composed of
- * elements with the same HASH-value but different keys
- */
-#define ODPH_MAX_BUCKET_NUM 0x10000
-
-/** @inner element structure of hash table
- * To resolve the hash conflict:
- * we put the elements with different keys but a same HASH-value
- * into a list
- */
-typedef struct odph_hash_node {
- /** list structure,for list opt */
- odph_list_object list_node;
- /** Flexible Array,memory will be alloced when table has been created
- * Its length is key_size + value_size,
- * suppose key_size = m; value_size = n;
- * its structure is like:
- * k_byte1 k_byte2...k_byten v_byte1...v_bytem
- */
- char content[];
-} odph_hash_node;
-
-typedef struct {
- uint32_t magicword; /**< for check */
- uint32_t key_size; /**< input param when create,in Bytes */
- uint32_t value_size; /**< input param when create,in Bytes */
- uint32_t init_cap; /**< input param when create,in Bytes */
- /** multi-process support,every list has one rw lock */
- odp_rwlock_t *lock_pool;
- /** table bucket pool,every hash value has one list head */
- odph_list_head *list_head_pool;
- /** number of the list head in list_head_pool */
- uint32_t head_num;
- /** table element pool */
- odph_hash_node *hash_node_pool;
- /** number of element in the hash_node_pool */
- uint32_t hash_node_num;
- char rsv[7]; /**< Reserved,for alignment */
- char name[ODPH_TABLE_NAME_LEN]; /**< table name */
-} odph_hash_table_imp;
-
-odph_table_t odph_hash_table_create(const char *name, uint32_t capacity,
- uint32_t key_size,
- uint32_t value_size)
-{
- int i;
- uint32_t node_num;
- odph_hash_table_imp *tbl;
- odp_shm_t shmem;
- uint32_t node_mem;
-
- if (strlen(name) >= ODPH_TABLE_NAME_LEN || capacity < 1 ||
- capacity >= 0x1000 || key_size == 0 || value_size == 0) {
- ODPH_DBG("create para input error!\n");
- return NULL;
- }
- if (odp_shm_lookup(name) != ODP_SHM_INVALID) {
- ODPH_DBG("name already exist\n");
- return NULL;
- }
- shmem = odp_shm_reserve(name, capacity << 20, 64, 0);
- if (shmem == ODP_SHM_INVALID) {
- ODPH_DBG("shm reserve fail\n");
- return NULL;
- }
- tbl = (odph_hash_table_imp *)odp_shm_addr(shmem);
-
- /* clean this block of memory */
- memset(tbl, 0, capacity << 20);
-
- tbl->init_cap = capacity << 20;
- strncpy(tbl->name, name, ODPH_TABLE_NAME_LEN - 1);
- tbl->key_size = key_size;
- tbl->value_size = value_size;
-
- /* header of this mem block is the table control struct,
- * then the lock pool, then the list header pool
- * the last part is the element node pool
- */
-
- tbl->lock_pool = (odp_rwlock_t *)(void *)((char *)tbl
- + sizeof(odph_hash_table_imp));
- tbl->list_head_pool = (odph_list_head *)(void *)((char *)tbl->lock_pool
- + ODPH_MAX_BUCKET_NUM * sizeof(odp_rwlock_t));
-
- node_mem = tbl->init_cap - sizeof(odph_hash_table_imp)
- - ODPH_MAX_BUCKET_NUM * sizeof(odph_list_head)
- - ODPH_MAX_BUCKET_NUM * sizeof(odp_rwlock_t);
-
- node_num = node_mem / (sizeof(odph_hash_node) + key_size + value_size);
- tbl->hash_node_num = node_num;
- tbl->hash_node_pool =
- (odph_hash_node *)(void *)((char *)tbl->list_head_pool
- + ODPH_MAX_BUCKET_NUM * sizeof(odph_list_head));
-
- /* init every list head and rw lock */
- for (i = 0; i < ODPH_MAX_BUCKET_NUM; i++) {
- ODPH_INIT_LIST_HEAD(&tbl->list_head_pool[i]);
- odp_rwlock_init((odp_rwlock_t *)&tbl->lock_pool[i]);
- }
-
- tbl->magicword = ODPH_HASH_TABLE_MAGIC_WORD;
- return (odph_table_t)tbl;
-}
-
-int odph_hash_table_destroy(odph_table_t table)
-{
- int ret;
-
- if (table != NULL) {
- odph_hash_table_imp *hash_tbl;
-
- hash_tbl = (odph_hash_table_imp *)(void *)table;
- if (hash_tbl->magicword != ODPH_HASH_TABLE_MAGIC_WORD)
- return ODPH_FAIL;
-
- ret = odp_shm_free(odp_shm_lookup(hash_tbl->name));
- if (ret != 0) {
- ODPH_DBG("free fail\n");
- return ret;
- }
- /* clean head */
- return ODPH_SUCCESS;
- }
- return ODPH_FAIL;
-}
-
-odph_table_t odph_hash_table_lookup(const char *name)
-{
- odph_hash_table_imp *hash_tbl = NULL;
- odp_shm_t shm;
-
- if (name == NULL || strlen(name) >= ODPH_TABLE_NAME_LEN)
- return NULL;
-
- shm = odp_shm_lookup(name);
- if (shm != ODP_SHM_INVALID)
- hash_tbl = (odph_hash_table_imp *)odp_shm_addr(shm);
- if (hash_tbl != NULL && strcmp(hash_tbl->name, name) == 0)
- return (odph_table_t)hash_tbl;
- return NULL;
-}
-
-/**
- * Calculate has value by the input key and key_size
- * This hash algorithm is the most simple one, so we choose it as an DEMO
- * User can use any other algorithm, like CRC...
- */
-static uint16_t odp_key_hash(void *key, uint32_t key_size)
-{
- register uint32_t hash = 0;
- uint32_t idx = (key_size == 0 ? 1 : key_size);
- uint32_t ch;
-
- while (idx != 0) {
- ch = (uint32_t)(*(char *)key);
- hash = hash * 131 + ch;
- idx--;
- }
- return (uint16_t)(hash & 0x0000FFFF);
-}
-
-/**
- * Get an available node from pool
- */
-static odph_hash_node *hashnode_take(odph_table_t table)
-{
- odph_hash_table_imp *tbl;
- uint32_t idx;
- odph_hash_node *node;
-
- tbl = (odph_hash_table_imp *)(void *)table;
- for (idx = 0; idx < tbl->hash_node_num; idx++) {
- /** notice: memory of one hash_node is
- * not only sizeof(odph_hash_node)
- * should add the size of Flexible Array
- */
- node = (odph_hash_node *)(void *)((char *)tbl->hash_node_pool
- + idx * (sizeof(odph_hash_node)
- + tbl->key_size
- + tbl->value_size));
- if (node->list_node.next == NULL &&
- node->list_node.prev == NULL) {
- ODPH_INIT_LIST_HEAD(&node->list_node);
- return node;
- }
- }
- return NULL;
-}
-
-/**
- * Release an node to the pool
- */
-static void hashnode_give(odph_table_t table, odph_hash_node *node)
-{
- odph_hash_table_imp *tbl;
-
- if (node == NULL)
- return;
-
- tbl = (odph_hash_table_imp *)(void *)table;
-
- odph_list_del(&node->list_node);
- memset(node, 0,
- (sizeof(odph_hash_node) + tbl->key_size + tbl->value_size));
-}
-
-/* should make sure the input table exists and is available */
-int odph_hash_put_value(odph_table_t table, void *key, void *value)
-{
- odph_hash_table_imp *tbl;
- uint16_t hash = 0;
- odph_hash_node *node = NULL;
- char *tmp = NULL;
-
- if (table == NULL || key == NULL || value == NULL)
- return ODPH_FAIL;
-
- tbl = (odph_hash_table_imp *)(void *)table;
- /* hash value is just the index of the list head in pool */
- hash = odp_key_hash(key, tbl->key_size);
-
- odp_rwlock_write_lock(&tbl->lock_pool[hash]);
- /* First, check if the key already exist */
- ODPH_LIST_FOR_EACH(node, &tbl->list_head_pool[hash], odph_hash_node,
- list_node)
- {
- if (memcmp(node->content, key, tbl->key_size) == 0) {
- /* copy value content to hash node*/
- tmp = (void *)((char *)node->content + tbl->key_size);
- memcpy(tmp, value, tbl->value_size);
- odp_rwlock_write_unlock(&tbl->lock_pool[hash]);
- return ODPH_SUCCESS;
- }
- }
-
- /*if the key is a new one, get a new hash node form the pool */
- node = hashnode_take(table);
- if (node == NULL) {
- odp_rwlock_write_unlock(&tbl->lock_pool[hash]);
- return ODPH_FAIL;
- }
-
- /* copy both key and value content to the hash node */
- memcpy(node->content, key, tbl->key_size);
- tmp = (void *)((char *)node->content + tbl->key_size);
- memcpy(tmp, value, tbl->value_size);
-
- /* add the node to list */
- odph_list_add(&node->list_node, &tbl->list_head_pool[hash]);
-
- odp_rwlock_write_unlock(&tbl->lock_pool[hash]);
- return ODPH_SUCCESS;
-}
-
-/* should make sure the input table exists and is available */
-int odph_hash_get_value(odph_table_t table, void *key, void *buffer,
- uint32_t buffer_size)
-{
- odph_hash_table_imp *tbl;
- uint16_t hash = 0;
- odph_hash_node *node;
- char *tmp = NULL;
-
- tbl = (odph_hash_table_imp *)(void *)table;
-
- if (table == NULL || key == NULL || buffer == NULL ||
- buffer_size < tbl->value_size)
- return ODPH_FAIL;
-
- /* hash value is just the index of the list head in pool */
- hash = odp_key_hash(key, tbl->key_size);
-
- odp_rwlock_read_lock(&tbl->lock_pool[hash]);
-
- ODPH_LIST_FOR_EACH(node, &tbl->list_head_pool[hash],
- odph_hash_node, list_node)
- {
- /* in case of hash conflict, compare the whole key */
- if (memcmp(node->content, key, tbl->key_size) == 0) {
- /* find the target */
- tmp = (void *)((char *)node->content + tbl->key_size);
- memcpy(buffer, tmp, tbl->value_size);
-
- odp_rwlock_read_unlock(&tbl->lock_pool[hash]);
-
- return ODPH_SUCCESS;
- }
- }
-
- odp_rwlock_read_unlock(&tbl->lock_pool[hash]);
-
- return ODPH_FAIL;
-}
-
-/* should make sure the input table exists and is available */
-int odph_hash_remove_value(odph_table_t table, void *key)
-{
- odph_hash_table_imp *tbl;
- uint16_t hash = 0;
- odph_hash_node *node;
-
- if (table == NULL || key == NULL)
- return ODPH_FAIL;
-
- tbl = (odph_hash_table_imp *)(void *)table;
-
- /* hash value is just the index of the list head in pool */
- hash = odp_key_hash(key, tbl->key_size);
-
- odp_rwlock_write_lock(&tbl->lock_pool[hash]);
-
- ODPH_LIST_FOR_EACH(node, &tbl->list_head_pool[hash], odph_hash_node,
- list_node)
- {
- if (memcmp(node->content, key, tbl->key_size) == 0) {
- hashnode_give(table, node);
- odp_rwlock_write_unlock(&tbl->lock_pool[hash]);
- return ODPH_SUCCESS;
- }
- }
-
- odp_rwlock_write_unlock(&tbl->lock_pool[hash]);
-
- return ODPH_SUCCESS;
-}
-
-odph_table_ops_t odph_hash_table_ops = {
- odph_hash_table_create,
- odph_hash_table_lookup,
- odph_hash_table_destroy,
- odph_hash_put_value,
- odph_hash_get_value,
- odph_hash_remove_value};
-
diff --git a/helper/include/odp/helper/odph_debug.h b/helper/include/odp/helper/debug.h
index 41b425ab2..41b425ab2 100644
--- a/helper/include/odp/helper/odph_debug.h
+++ b/helper/include/odp/helper/debug.h
diff --git a/helper/include/odp/helper/odph_api.h b/helper/include/odp/helper/odph_api.h
index 94d43a61b..2541efa89 100644
--- a/helper/include/odp/helper/odph_api.h
+++ b/helper/include/odp/helper/odph_api.h
@@ -18,23 +18,20 @@ extern "C" {
#include <odp/helper/autoheader_external.h>
-#include <odp/helper/odph_debug.h>
#include <odp/helper/chksum.h>
-#include <odp/helper/odph_cuckootable.h>
+#include <odp/helper/debug.h>
#include <odp/helper/eth.h>
#include <odp/helper/gtp.h>
-#include <odp/helper/odph_hashtable.h>
#include <odp/helper/icmp.h>
#include <odp/helper/igmp.h>
#include <odp/helper/ip.h>
#include <odp/helper/ipsec.h>
#include <odp/helper/macros.h>
-#include <odp/helper/odph_lineartable.h>
-#include <odp/helper/odph_iplookuptable.h>
+#include <odp/helper/stress.h>
#include <odp/helper/sctp.h>
+#include <odp/helper/string.h>
#include <odp/helper/strong_types.h>
#include <odp/helper/tcp.h>
-#include <odp/helper/table.h>
#include <odp/helper/threads.h>
#include <odp/helper/udp.h>
#include <odp/helper/version.h>
diff --git a/helper/include/odp/helper/odph_cuckootable.h b/helper/include/odp/helper/odph_cuckootable.h
deleted file mode 100644
index 1c87a3d42..000000000
--- a/helper/include/odp/helper/odph_cuckootable.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2016-2018 Linaro Limited
- */
-
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ODPH_CUCKOO_TABLE_H_
-#define ODPH_CUCKOO_TABLE_H_
-
-#include <odp/helper/table.h>
-
-/**
- * @file
- *
- * ODP Cuckoo Hash Table
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @defgroup odph_cuckootable ODPH CUCKOO TABLE
- * Cuckoo table
- *
- * @{
- */
-
-/**
- * Create a cuckoo table
- *
- * @param name Name of the cuckoo table to be created
- * @param capacity Number of elements table may store
- * @param key_size Size of the key for each element
- * @param value_size Size of the value stored for each element
- *
- * @return Handle of created cuckoo table
- * @retval NULL Create failed
- */
-odph_table_t odph_cuckoo_table_create(
- const char *name,
- uint32_t capacity,
- uint32_t key_size,
- uint32_t value_size);
-
-/**
- * Lookup a cuckoo table by name
- *
- * @param name Name of the table to be located
- *
- * @return Handle of the located cuckoo table
- * @retval NULL No table matching supplied name found
- */
-odph_table_t odph_cuckoo_table_lookup(const char *name);
-
-/**
- * Destroy a cuckoo table
- *
- * @param table Handle of the cuckoo table to be destroyed
- *
- * @retval 0 Success
- * @retval < 0 Failure
- */
-int odph_cuckoo_table_destroy(odph_table_t table);
-
-/**
- * Insert a key/value pair into a cuckoo table
- *
- * @param table Table into which value is to be stored
- * @param key Address of an odph_table_t to be used as key
- * @param value Value to be associated with specified key
- *
- * @retval >= 0 Success
- * @retval < 0 Failure
- */
-int odph_cuckoo_table_put_value(odph_table_t table, void *key, void *value);
-
-/**
- * Retrieve a value from a cuckoo table
- *
- * @param table Table from which value is to be retrieved
- * @param key Address of an odph_table_t to be used as key
- * @param[out] buffer Address of buffer to receive resulting value
- * @param buffer_size Size of supplied buffer
- *
- * @retval 0 Success
- * @retval 1 Success
- * @retval < 0 Failure
- */
-int odph_cuckoo_table_get_value(odph_table_t table,
- void *key, void *buffer,
- uint32_t buffer_size);
-
-/**
- * Remove a value from a cuckoo table
- *
- * @param table Table from which value is to be removed
- * @param key Address of odph_table_t to be used as key
- *
- * @retval >= 0 Success
- * @retval < 0 Failure
- */
-int odph_cuckoo_table_remove_value(odph_table_t table, void *key);
-
-extern odph_table_ops_t odph_cuckoo_table_ops; /**< @internal */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ODPH_CUCKOO_TABLE_H_ */
diff --git a/helper/include/odp/helper/odph_hashtable.h b/helper/include/odp/helper/odph_hashtable.h
deleted file mode 100644
index b2dd21920..000000000
--- a/helper/include/odp/helper/odph_hashtable.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2015-2018 Linaro Limited
- */
-
-/**
- * @file
- *
- * ODP Hash Table
- */
-
-#ifndef ODPH_HASH_TABLE_H_
-#define ODPH_HASH_TABLE_H_
-
-#include <odp/helper/table.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @defgroup odph_hash_table ODPH HASH TABLE
- * Hash table
- *
- * @{
- */
-
-/**
- * Create a hash table
- *
- * @param name Name of the hash table to be created.
- * @param capacity Number of elements table may store
- * @param key_size Size of the key for each element
- * @param value_size Size of the value stored for each element
- *
- * @return Handle of created hash table
- * @retval NULL Create failed
- */
-odph_table_t odph_hash_table_create(const char *name,
- uint32_t capacity,
- uint32_t key_size,
- uint32_t value_size);
-
-/**
- * Lookup a hash table by name
- *
- * @param name Name of the table to be located
- *
- * @return Handle of the located hash table
- * @return NULL No table matching supplied name found
- */
-odph_table_t odph_hash_table_lookup(const char *name);
-
-/**
- * Destroy a hash table
- *
- * @param table Handle of the hash table to be destroyed
- *
- * @retval 0 Success
- * @retval < 0 Failure
- */
-int odph_hash_table_destroy(odph_table_t table);
-
-/**
- * Insert a key/value pair into a hash table
- *
- * @param table Table into which value is to be stored
- * @param key Address of an odph_table_t to be used as key
- * @param value Value to be associated with specified key
- *
- * @retval >= 0 Success
- * @retval < 0 Failure
- */
-int odph_hash_put_value(odph_table_t table, void *key, void *value);
-
-/**
- * Retrieve a value from a hash table
- *
- * @param table Table from which value is to be retrieved
- * @param key Address of an odph_table_t to be used as key
- * @param[out] buffer Address of buffer to receive resulting value
- * @param buffer_size Size of supplied buffer
- *
- * @retval 0 Success
- * @retval 1 Success
- * @retval < 0 Failure
- */
-int odph_hash_get_value(odph_table_t table, void *key, void *buffer,
- uint32_t buffer_size);
-
-/**
- * Remove a value from a hash table
- *
- * @param table Table from which value is to be removed
- * @param key Address of odph_table_t to be used as key
- *
- * @retval >= 0 Success
- * @retval < 0 Failure
- */
-int odph_hash_remove_value(odph_table_t table, void *key);
-
-extern odph_table_ops_t odph_hash_table_ops; /**< @internal */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/helper/include/odp/helper/odph_iplookuptable.h b/helper/include/odp/helper/odph_iplookuptable.h
deleted file mode 100644
index 41235ecc6..000000000
--- a/helper/include/odp/helper/odph_iplookuptable.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2016-2018 Linaro Limited
- */
-
-/**
- * @file
- *
- * ODP IP Lookup Table
- */
-
-#ifndef ODPH_IPLOOKUP_TABLE_H_
-#define ODPH_IPLOOKUP_TABLE_H_
-
-#include <odp/helper/table.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @defgroup odph_iplookuptable ODPH IP LOOKUP TABLE
- * IP lookup table
- *
- * @details
- * This is an implementation of the IP lookup table. The key of this table is
- * IPv4 address (32 bits), and the value can be defined by user. This table uses
- * the 16,8,8 ip lookup (longest prefix matching) algorithm.
- *
- * @{
- */
-
-/**
- * IP Lookup Prefix
- */
-typedef struct {
- uint32_t ip; /**< IPv4 address */
- uint8_t cidr; /**< CIDR value for prefix matching */
-} odph_iplookup_prefix_t;
-
-/**
- * Create an IP lookup table
- *
- * @param name Name of the table to be created
- * @param ODP_IGNORED_1 Unused
- * @param ODP_IGNORED_2 Unused
- * @param value_size Byte size of each entry in the table
- *
- * @return Handle of the created ip lookup table
- * @retval NULL If table create failed
- */
-odph_table_t odph_iplookup_table_create(const char *name,
- uint32_t ODP_IGNORED_1,
- uint32_t ODP_IGNORED_2,
- uint32_t value_size);
-
-/**
- * Lookup an IP lookup table by name
- *
- * @param name Name of the table to be located
- *
- * @return Handle of the located ip lookup table
- * @retval NULL No table matching supplied name found
- */
-odph_table_t odph_iplookup_table_lookup(const char *name);
-
-/**
- * Destroy an IP lookup table
- *
- * @param table Handle of the ip lookup table to be destroyed
- *
- * @retval 0 Success
- * @retval < 0 Failure
- */
-int odph_iplookup_table_destroy(odph_table_t table);
-
-/**
- * Insert a key/value pair into an ip lookup table
- *
- * @param table Table into which value is to be stored
- * @param key Address of an odph_iplookup_prefix_t to be used as key
- * @param value Value to be associated with specified key
- *
- * @retval >= 0 Success
- * @retval < 0 Failure
- */
-int odph_iplookup_table_put_value(odph_table_t table, void *key, void *value);
-
-/**
- * Retrieve a value from an iplookup table
- *
- * @param table Table from which value is to be retrieved
- * @param key Address of an odph_iplookup_prefix_t to be used as key
- * @param[out] buffer Address of buffer to receive resulting value
- * @param buffer_size Size of supplied buffer
- *
- * @retval 0 Success
- * @retval 1 Success
- * @retval < 0 Failure
- */
-int odph_iplookup_table_get_value(odph_table_t table, void *key,
- void *buffer, uint32_t buffer_size);
-
-/**
- * Remove a value from an iplookup table
- *
- * @param table Table from which value is to be removed
- * @param key Address of odph_iplookup_prefix_t to be used as key
- *
- * @retval >= 0 Success
- * @retval < 0 Failure
- *
- */
-int odph_iplookup_table_remove_value(odph_table_t table, void *key);
-
-extern odph_table_ops_t odph_iplookup_table_ops; /**< @internal */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ODPH_IPLOOKUP_TABLE_H_ */
diff --git a/helper/include/odp/helper/odph_lineartable.h b/helper/include/odp/helper/odph_lineartable.h
deleted file mode 100644
index dc61113a5..000000000
--- a/helper/include/odp/helper/odph_lineartable.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2015-2018 Linaro Limited
- */
-
-/**
- * @file
- *
- * ODP Linear Table
- */
-
-#ifndef ODPH_LINEAR_TABLE_H_
-#define ODPH_LINEAR_TABLE_H_
-
-#include <stdint.h>
-#include <odp/helper/table.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @defgroup odph_lineartable ODPH LINEAR TABLE
- * Linear table
- *
- * @{
- */
-
-/**
- * Create a linear table
- *
- * @param name Name of the linear table to be created
- * @param capacity Number of elements table may store
- * @param ODP_IGNORED Ignored parameter
- * @param value_size Size of the value stored for each element
- *
- * @return Handle of created linear table
- * @return NULL Create failed
- */
-odph_table_t odph_linear_table_create(const char *name,
- uint32_t capacity,
- uint32_t ODP_IGNORED,
- uint32_t value_size);
-
-/**
- * Lookup a linear table
- *
- * @param name Name of the table to be located
- *
- * @return Handle of the located linear table
- * @retval NULL No table matching supplied name found
- */
-odph_table_t odph_linear_table_lookup(const char *name);
-
-/**
- * Destroy a linear table
- *
- * @param table Handle of linear table to be destroyed
- *
- * @retval 0 Success
- * @retval < 0 Failure
- */
-int odph_linear_table_destroy(odph_table_t table);
-
-/**
- * Insert a value into a linear table
- *
- * @param table Table into which value is to be stored
- * @param key Index value used as key
- * @param value Value to be assoceiated with specified key index
- *
- * @retval >= 0 Success
- * @retval < 0 Failure
- */
-int odph_linear_put_value(odph_table_t table, void *key, void *value);
-
-/**
- * Retrieve a value from a linear table
- *
- * @param table Table from which value is to be retrieved
- * @param key Index value used as key
- * @param[out] buffer Address of buffer to receive resulting value
- * @param buffer_size Size of supplied buffer
- *
- * @retval 0 Success
- * @retval 1 Success
- * @retval < 0 Failure
- */
-int odph_linear_get_value(odph_table_t table, void *key, void *buffer,
- uint32_t buffer_size);
-
-extern odph_table_ops_t odph_linear_table_ops; /**< @internal */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/helper/include/odp/helper/stress.h b/helper/include/odp/helper/stress.h
new file mode 100644
index 000000000..cfdc41033
--- /dev/null
+++ b/helper/include/odp/helper/stress.h
@@ -0,0 +1,238 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2024 Nokia
+ */
+
+/**
+ * @file
+ *
+ * ODP helper stress
+ */
+
+#ifndef ODPH_STRESS_H_
+#define ODPH_STRESS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup odph_stress ODPH STRESS
+ * Dummy CPU stress functions
+ *
+ * These functions may be used in test applications to create dummy CPU load. Functions are not
+ * highly optimized, as they try to utilize various parts of CPU instruction set (load/store,
+ * branch, integer/float arithmetics, vector, etc. instructions).
+ *
+ * @{
+ */
+
+/**
+ * Returns 'value' raised to the power of 2
+ *
+ * @param value Base value
+ *
+ * @return The value raised to the power of 2
+ */
+static inline uint32_t odph_stress_pow2_u32(uint32_t value)
+{
+ uint64_t v = (uint64_t)value;
+ uint64_t res = v * v;
+
+ if (odp_unlikely(res > UINT32_MAX))
+ return UINT32_MAX;
+
+ return (uint32_t)res;
+}
+
+/**
+ * Returns base 2 logarithm of 'value'
+ *
+ * @param value The value for which the logarithm is being calculated
+ *
+ * @return Base 2 logarithm of 'value'
+ */
+static inline uint32_t odph_stress_log2_u32(uint32_t value)
+{
+ uint32_t ret = 0;
+
+ while ((value >>= 1) != 0)
+ ret++;
+
+ return ret;
+}
+
+/**
+ * Calculates square root of a 32-bit unsigned integer value
+ *
+ * @param value The value for which the square root is being calculated
+ *
+ * @return Square root of the value
+ */
+static inline uint32_t odph_stress_sqrt_u32(uint32_t value)
+{
+ uint64_t x;
+ uint64_t pow = 1;
+
+ if (odp_unlikely(value == 0 || value == 1))
+ return value;
+
+ if (value & 0xffff0000) {
+ if (value & 0xff000000) {
+ if (value & 0xf0000000) {
+ x = 16384;
+ if (value & 0xe0000000)
+ x = 23170;
+ if (value & 0xc0000000)
+ x = 32768;
+ if (value & 0x80000000)
+ x = 46340;
+ } else {
+ /* value & 0x0f000000 */
+ x = 4096;
+ if (value & 0x0e000000)
+ x = 5792;
+ if (value & 0x0c000000)
+ x = 8192;
+ if (value & 0x08000000)
+ x = 11585;
+ }
+ } else {
+ if (value & 0x00f00000) {
+ x = 1024;
+ if (value & 0x00e00000)
+ x = 1448;
+ if (value & 0x00c00000)
+ x = 2048;
+ if (value & 0x00800000)
+ x = 2896;
+ } else {
+ /* value & 0x000f0000 */
+ x = 256;
+ if (value & 0x000e0000)
+ x = 362;
+ if (value & 0x000c0000)
+ x = 512;
+ if (value & 0x00080000)
+ x = 724;
+ }
+ }
+ } else {
+ /* value & 0xffff */
+ x = 1;
+
+ if (value >= 16384) {
+ x = 128;
+ if (value >= 25600)
+ x = 160;
+ if (value >= 36864)
+ x = 192;
+ if (value >= 50176)
+ x = 224;
+ } else {
+ if (value >= 1024)
+ x = 32;
+ if (value >= 4096)
+ x = 64;
+ if (value >= 9216)
+ x = 96;
+ }
+ }
+
+ while (pow <= value) {
+ x++;
+ pow = x * x;
+ }
+
+ return (uint32_t)(x - 1);
+}
+
+/**
+ * Calculates square root of a floating point value
+ *
+ * @param value The value for which the square root is being calculated
+ *
+ * @return Square root of the value
+ */
+static inline float odph_stress_sqrt_f32(float value)
+{
+ double x;
+ double pow = 1;
+
+ if (odp_unlikely(value == 0 || value == 1))
+ return value;
+
+ if (value >= 65536) {
+ if (value >= 16777215) {
+ if (value >= 268435456) {
+ x = 16384;
+ if (value >= 536870912)
+ x = 23170;
+ if (value >= 1073741824)
+ x = 32768;
+ if (value >= 2147483648)
+ x = 46340;
+ } else {
+ x = 4096;
+ if (value >= 33554432)
+ x = 5792;
+ if (value >= 67108864)
+ x = 8192;
+ if (value >= 134217728)
+ x = 11585;
+ }
+ } else {
+ if (value >= 1048576) {
+ x = 1024;
+ if (value >= 2097152)
+ x = 1448;
+ if (value >= 4194304)
+ x = 2048;
+ if (value >= 8388608)
+ x = 2896;
+ } else {
+ x = 256;
+ if (value >= 131072)
+ x = 362;
+ if (value >= 262144)
+ x = 512;
+ if (value >= 524288)
+ x = 724;
+ }
+ }
+ } else {
+ x = 1;
+
+ if (value >= 16384) {
+ x = 128;
+ if (value >= 25600)
+ x = 160;
+ if (value >= 36864)
+ x = 192;
+ if (value >= 50176)
+ x = 224;
+ } else {
+ if (value >= 1024)
+ x = 32;
+ if (value >= 4096)
+ x = 64;
+ if (value >= 9216)
+ x = 96;
+ }
+ }
+
+ while (pow <= value) {
+ x = x + 1;
+ pow = x * x;
+ }
+
+ return (float)(x - 1);
+}
+
+/**
+ * @}
+ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/helper/include/odp/helper/string.h b/helper/include/odp/helper/string.h
new file mode 100644
index 000000000..da2d61a6b
--- /dev/null
+++ b/helper/include/odp/helper/string.h
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2024 Nokia
+ */
+
+/**
+ * @file
+ *
+ * ODP string helper
+ */
+
+#ifndef ODPH_STRING_H_
+#define ODPH_STRING_H_
+
+#include <odp/api/hints.h>
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup odph_string ODPH STRING
+ * String helper
+ *
+ * @{
+ */
+
+/**
+ * Copy a string
+ *
+ * Like strncpy(), but additionally ensures that the destination string is null
+ * terminated, unless sz is zero in which case returns dst without doing
+ * anything else.
+ *
+ * @param[out] dst Pointer to destination string.
+ * @param src Pointer to source string.
+ * @param sz Destination size.
+ * @return Pointer to destination string.
+ */
+#ifdef __cplusplus
+ODP_UNUSED static char *odph_strcpy(char *dst, const char *src, size_t sz)
+#else
+ODP_UNUSED static char *odph_strcpy(char *restrict dst, const char *restrict src, size_t sz)
+#endif
+{
+ if (!sz)
+ return dst;
+
+ strncpy(dst, src, sz - 1);
+ dst[sz - 1] = 0;
+ return dst;
+}
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/helper/include/odp/helper/table.h b/helper/include/odp/helper/table.h
deleted file mode 100644
index 6a24e742b..000000000
--- a/helper/include/odp/helper/table.h
+++ /dev/null
@@ -1,244 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2015-2018 Linaro Limited
- */
-
-/**
- * @file
- *
- * ODP table
- */
-
-#ifndef ODPH_TABLE_H_
-#define ODPH_TABLE_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @defgroup odph_tables ODPH TABLES
- * Table interface
- *
- * @details
- * TCAM(Ternary Content Addressable Memory) is used widely in packet
- * forwarding to speedup the table lookup.
- *
- * This file contains a simple interface for creating and using the table.
- * Table here means a collection of related data held in a structured
- * format.
- * Some examples for table are ARP Table, Routing Table, etc.The table
- * contains many entries, each consist of key and associated data
- * (called key/value pair or rule/action pair in some paper.).
- * Enclosed are some classical table examples, used publicly
- * in data plane packet processing:
- *
- * <H3>Use Case: ARP table</H3>
- * Once a route has been identified for an IP packet (so the output
- * interface and the IP address of the next hop station are known),
- * the MAC address of the next hop station is needed in order to
- * send this packet onto the next leg of the journey
- * towards its destination (as identified by its destination IP address).
- * The MAC address of the next hop station becomes the destination
- * MAC address of the outgoing Ethernet frame.
- * <ol>
- * <li>Key: The pair of (Output interface, Next Hop IP address)
- * <li>Associated Data: MAC address of the next hop station
- * <li>Algorithm: Hash
- * </ol>
- *
- * <H3>Use Case: Routing Table</H3>
- * When each router receives a packet, it searches its routing table
- * to find the best match between the destination IP address of
- * the packet and one of the network addresses in the routing table.
- * <ol>
- * <li>Key: destination IP address
- * <li>Associated Data: The pair of (Output interface, Next Hop IP address)
- * <li>Algorithm: LPM(Longest Prefix Match)
- * </ol>
- *
- * <H3>Use Case: Flow Classification</H3>
- * The flow classification is executed at least once for each
- * input packet.This operation maps each incoming packet against
- * one of the known traffic
- * flows in the flow database that typically contains millions of flows.
- * <ol>
- * <li>Key:n-tuple of packet fields that uniquely identify a traffic flow.
- * <li>Associated data:
- * actions and action meta-data describing what processing to be
- * applied for the packets of the current flow, such as whether
- * encryption/decryption is required on this packet, what kind of cipher
- * algorithm should be chosen.
- * <li>Algorithm: Hash
- * </ol>
- *
- * All these different types of lookup tables have the common operations:
- * create a table, destroy a table, add (key,associated data),
- * delete key and look up the associated data via the key.
- * Usually these operations are software based, but also can be
- * hardware accelerated such as using TCAM to implement ARP table
- * or Routing Table.
- * And specific alogithm can be used for specific lookup table.
- *
- * notes: key/value and key/associated data mean the same thing
- * in this file unless otherwise mentioned.
- *
- * @{
- */
-
-#include <stdint.h>
-
-/**
- * @def ODPH_TABLE_NAME_LEN
- * Max length of table name
- */
-#define ODPH_TABLE_NAME_LEN 32
-
-#include <odp/helper/strong_types.h>
-/** @internal ODPH table handle @return */
-typedef ODPH_HANDLE_T(odph_table_t);
-
-/**
-* create a table
-* Generally, tables only support key-value pair both with fixed size
-*
-* @param name
-* name of this table, max ODPH_TABLE_NAME_LEN - 1
-* May be specified as NULL for anonymous table
-* @param capacity
-* Max memory usage this table use, in MBytes
-* @param key_size
-* fixed size of the 'key' in bytes.
-* @param value_size
-* fixed size of the 'value' in bytes.
-* @return
-* Handle to table instance or NULL if failed
-* @note
-*/
-typedef odph_table_t (*odph_table_create)(const char *name,
- uint32_t capacity,
- uint32_t key_size,
- uint32_t value_size);
-
-/**
- * Find a table by name
- *
- * @param name Name of the table
- *
- * @return Handle of found table
- * @retval NULL table could not be found
- *
- * @note This routine cannot be used to look up an anonymous
- * table (one created with no name).
- * This API supports Multiprocess
- */
-typedef odph_table_t (*odph_table_lookup)(const char *name);
-
-/**
- * Destroy a table previously created by odph_table_create()
- *
- * @param table Handle of the table to be destroyed
- *
- * @retval 0 Success
- * @retval -1 Failure
- *
- * @note This routine destroys a previously created pool
- * also should free any memory allocated at creation
- *
- */
-typedef int (*odph_table_destroy)(odph_table_t table);
-
-/**
- * Add (key,associated data) pair into the specific table.
- * When no associated data is currently associated with key,
- * then the (key,assocatied data) association is created.
- * When key is already associated with data0, then association (key, data0)
- * will be removed and association (key, associated data) is created.
- *
- * @param table Handle of the table that the element be added
- *
- * @param key address of 'key' in key-value pair.
- * User should make sure the address and 'key_size'
- * bytes after are accessible
- * @param value address of 'value' in key-value pair
- * User should make sure the address and 'value_size'
- * bytes after are accessible
- * @retval 0 Success
- * @retval -1 Failure
- * @note Add a same key again with a new value, the older one will
- * be covered.
- */
-typedef int (*odph_table_put_value)(odph_table_t table, void *key,
- void *value);
-
-/**
- * Lookup the associated data via specific key.
- * When no value is currently associated with key, then this operation
- * restuns <0 to indicate the lookup miss.
- * When key is associated with value,
- * then this operation returns value.
- * The (key,value) association won't change.
- *
- * @param table Handle of the table that the element be added
- *
- * @param key address of 'key' in key-value pair
- * User should make sure the address and key_size bytes after
- * are accessible
- *
- * @param buffer output The buffer address to the 'value'
- * After successfully found, the content of 'value' will be
- * copied to this address
- * User should make sure the address and value_size bytes
- * after are accessible
- * @param buffer_size size of the buffer
- * should be equal or bigger than value_size
- * @retval 0 Success
- * @retval -1 Failure
- *
- * @note
- */
-typedef int (*odph_table_get_value)(odph_table_t table, void *key,
- void *buffer,
- uint32_t buffer_size);
-/**
- * Delete the association specified by key
- * When no data is currently associated with key, this operation
- * has no effect. When key is already associated data ad0,
- * then (key,ad0) pair is deleted.
- *
- * @param table Handle of the table that the element will be removed from
- *
- * @param key address of 'key' in key-value pair
- * User should make sure the address and key_size bytes after
- * are accessible
- *
- * @retval 0 Success
- * @retval -1 Failure
- *
- * @note
- */
-typedef int (*odph_table_remove_value)(odph_table_t table, void *key);
-
-/**
- * Table interface set. Defining the table operations.
- */
-typedef struct odph_table_ops_t {
- odph_table_create f_create; /**< Table Create */
- odph_table_lookup f_lookup; /**< Table Lookup */
- odph_table_destroy f_des; /**< Table Destroy */
- /** add (key,associated data) pair into the specific table */
- odph_table_put_value f_put;
- /** lookup the associated data via specific key */
- odph_table_get_value f_get;
- /** delete the association specified by key */
- odph_table_remove_value f_remove;
-} odph_table_ops_t;
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/helper/include/odp/helper/threads.h b/helper/include/odp/helper/threads.h
index c18a46e8a..ca420e80a 100644
--- a/helper/include/odp/helper/threads.h
+++ b/helper/include/odp/helper/threads.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2013-2018 Linaro Limited
- * Copyright (c) 2019-2021 Nokia
+ * Copyright (c) 2019-2024 Nokia
*/
@@ -191,6 +191,20 @@ typedef struct {
} odph_thread_common_param_t;
+/** Thread join result */
+typedef struct {
+ /** Exit caused by signal */
+ odp_bool_t is_sig;
+
+ /**
+ * Exit status of the joined thread/process
+ *
+ * If 'is_sig' is true, then this is the signal number that caused
+ * process exit. Otherwise status of the exited thread/process.
+ */
+ int ret;
+} odph_thread_join_result_t;
+
/**
* Initialize thread params
*
@@ -236,7 +250,8 @@ void odph_thread_common_param_init(odph_thread_common_param_t *param);
* thread goes to the smallest CPU number of the mask, etc.
*
* Launched threads may be waited for exit with odph_thread_join(), or with
- * direct Linux system calls.
+ * direct Linux system calls. If odph_thread_join() is used, the output thread
+ * table elements must not be modified during the life time of the threads.
*
* @param[out] thread Thread table for output
* @param param Common parameters for all threads to be created
@@ -261,10 +276,14 @@ int odph_thread_create(odph_thread_t thread[],
* A function call may be used to wait any number of launched threads to exit.
* A particular thread may be waited only once.
*
+ * Threads are joined in the order they are in 'thread' table. Returns on the
+ * first non-zero exit status or other failure.
+ *
* @param thread Table of threads to exit
* @param num Number of threads to exit
*
- * @return Number of threads exited
+ * @return Number of threads successfully joined with zero exit status
+ * (0 ... num)
* @retval -1 On failure
*
* @see odph_thread_create()
@@ -272,6 +291,26 @@ int odph_thread_create(odph_thread_t thread[],
int odph_thread_join(odph_thread_t thread[], int num);
/**
+ * Wait previously launched threads to exit
+ *
+ * Similar to odph_thread_join() but outputs results of joined threads and
+ * stops only if the actual join operation fails for some thread. Threads are
+ * joined in the order they are in 'thread' table. Returns number of threads
+ * successfully joined and writes respective exit statuses into the 'res'
+ * table.
+ *
+ * @param thread Table of threads to exit
+ * @param[out] res Table for result output
+ * @param num Number of threads to exit and results to output
+ *
+ * @return Number of threads successfully joined (0 ... num)
+ * @retval -1 On failure
+ *
+ * @see odph_thread_create()
+ */
+int odph_thread_join_result(odph_thread_t thread[], odph_thread_join_result_t res[], int num);
+
+/**
* Set CPU affinity of the current odp thread
*
* CPU affinity determines the CPU core on which the thread is
diff --git a/helper/include/odph_list_internal.h b/helper/include/odph_list_internal.h
deleted file mode 100644
index d90b07ebc..000000000
--- a/helper/include/odph_list_internal.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2015-2018 Linaro Limited
- */
-
-/**
- * @file
- *
- * ODP list
- * a simple implementation of Doubly linked list
- */
-
-#ifndef ODPH_LIST_INTER_H_
-#define ODPH_LIST_INTER_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** @cond _ODP_HIDE_FROM_DOXYGEN_ */
-
-typedef struct odph_list_object {
- struct odph_list_object *next;
-
- struct odph_list_object *prev;
-} odph_list_object;
-
-typedef odph_list_object odph_list_head;
-
-static inline void ODPH_INIT_LIST_HEAD(odph_list_object *list)
-{
- list->next = list;
- list->prev = list;
-}
-
-static inline void __odph_list_add(odph_list_object *new,
- odph_list_object *prev,
- odph_list_object *next)
-{
- next->prev = new;
- new->next = next;
- new->prev = prev;
- prev->next = new;
-}
-
-static inline void odph_list_add(odph_list_object *new, odph_list_object *head)
-{
- __odph_list_add(new, head, head->next);
-}
-
-static inline void odph_list_add_tail(struct odph_list_object *new,
- odph_list_object *head)
-{
- __odph_list_add(new, head->prev, head);
-}
-
-static inline void __odph_list_del(struct odph_list_object *prev,
- odph_list_object *next)
-{
- next->prev = prev;
- prev->next = next;
-}
-
-static inline void odph_list_del(struct odph_list_object *entry)
-{
- __odph_list_del(entry->prev, entry->next);
- ODPH_INIT_LIST_HEAD(entry);
-}
-
-static inline int odph_list_empty(const struct odph_list_object *head)
-{
- return head->next == head;
-}
-
-#define container_of(ptr, type, list_node) \
- ((type *)(void *)((char *)ptr - offsetof(type, list_node)))
-
-#define ODPH_LIST_FOR_EACH(pos, list_head, type, list_node) \
- for (pos = container_of((list_head)->next, type, list_node); \
- &pos->list_node != (list_head); \
- pos = container_of(pos->list_node.next, type, list_node))
-
-/** @endcond */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/helper/iplookuptable.c b/helper/iplookuptable.c
deleted file mode 100644
index 31273a0a5..000000000
--- a/helper/iplookuptable.c
+++ /dev/null
@@ -1,990 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2016-2018 Linaro Limited
- */
-
-#include <string.h>
-#include <stdint.h>
-#include <errno.h>
-#include <stdio.h>
-
-#include <odp/helper/odph_iplookuptable.h>
-#include <odp/helper/odph_debug.h>
-#include "odph_list_internal.h"
-#include <odp_api.h>
-
-/** @magic word, write to the first byte of the memory block
- * to indicate this block is used by a ip lookup table
- */
-#define ODPH_IP_LOOKUP_TABLE_MAGIC_WORD 0xCFCFFCFC
-
-/* The length(bit) of the IPv4 address */
-#define IP_LENGTH 32
-
-/* The number of L1 entries */
-#define ENTRY_NUM_L1 (1 << 16)
-/* The size of one L2\L3 subtree */
-#define ENTRY_NUM_SUBTREE (1 << 8)
-
-#define WHICH_CHILD(ip, cidr) ((ip >> (IP_LENGTH - cidr)) & 0x00000001)
-
-/** @internal entry struct
- * Structure store an entry of the ip prefix table.
- * Because of the leaf pushing, each entry of the table must have
- * either a child entry, or a nexthop info.
- * If child == 0 and index != ODP_BUFFER_INVALID, this entry has
- * a nexthop info, index indicates the buffer that stores the
- * nexthop value, and ptr points to the address of the buffer.
- * If child == 1, this entry has a subtree, index indicates
- * the buffer that stores the subtree, and ptr points to the
- * address of the buffer.
- */
-typedef struct {
- union {
- odp_buffer_t nexthop;
- void *ptr;
- };
- union {
- uint8_t u8;
- struct {
-#if ODP_BYTE_ORDER == ODP_BIG_ENDIAN
- uint8_t child : 1;
- uint8_t cidr : 7;
-#else
- uint8_t cidr : 7;
- uint8_t child : 1;
-#endif
- };
- };
-} prefix_entry_t;
-
-#define ENTRY_SIZE (sizeof(prefix_entry_t) + sizeof(odp_buffer_t))
-#define ENTRY_BUFF_ARR(x) ((odp_buffer_t *)(void *)((char *)x \
- + sizeof(prefix_entry_t) * ENTRY_NUM_SUBTREE))
-
-/** @internal trie node struct
- * In this IP lookup algorithm, we use a
- * binary tire to detect the overlap prefix.
- */
-typedef struct trie_node {
- /* tree structure */
- struct trie_node *parent;
- struct trie_node *left;
- struct trie_node *right;
- /* IP prefix length */
- uint8_t cidr;
- /* Nexthop buffer index */
- odp_buffer_t nexthop;
- /* Buffer that stores this node */
- odp_buffer_t buffer;
-} trie_node_t;
-
-/** Number of L2\L3 entries(subtrees) per cache cube. */
-#define CACHE_NUM_SUBTREE (4 * 1024)
-/** Number of trie nodes per cache cube. */
-#define CACHE_NUM_TRIE (4 * 1024)
-
-/** @typedef cache_type_t
- * Cache node type
- */
-typedef enum {
- CACHE_TYPE_SUBTREE = 0,
- CACHE_TYPE_TRIE
-} cache_type_t;
-
-/** A IP lookup table structure. */
-typedef struct ODP_ALIGNED_CACHE {
- /**< for check */
- uint32_t magicword;
- /** Name of the hash. */
- char name[ODPH_TABLE_NAME_LEN];
- /** Total L1 entries. */
- prefix_entry_t *l1e;
- /** Root node of the binary trie */
- trie_node_t *trie;
- /** Length of value. */
- uint32_t nexthop_len;
- /** Queues of free slots (caches)
- * There are two queues:
- * - free_slots[CACHE_TYPE_SUBTREE] is used for L2 and
- * L3 entries (subtrees). Each entry stores an 8-bit
- * subtree.
- * - free_slots[CACHE_TYPE_TRIE] is used for the binary
- * trie. Each entry contains a trie node.
- */
- odp_queue_t free_slots[2];
- /** The number of pool used by each queue. */
- uint32_t cache_count[2];
-} odph_iplookup_table_impl;
-
-/***********************************************************
- ***************** Cache management ********************
- ***********************************************************/
-
-/** Destroy all caches */
-static void
-cache_destroy(odph_iplookup_table_impl *impl)
-{
- odp_queue_t queue;
- odp_event_t ev;
- uint32_t i = 0, count = 0;
- char pool_name[ODPH_TABLE_NAME_LEN + 8];
-
- /* free all buffers in the queue */
- for (; i < 2; i++) {
- queue = impl->free_slots[i];
- if (queue == ODP_QUEUE_INVALID)
- continue;
-
- while ((ev = odp_queue_deq(queue))
- != ODP_EVENT_INVALID) {
- odp_buffer_free(odp_buffer_from_event(ev));
- }
- odp_queue_destroy(queue);
- }
-
- /* destroy all cache pools */
- for (i = 0; i < 2; i++) {
- for (count = 0; count < impl->cache_count[i]; count++) {
- sprintf(
- pool_name, "%s_%d_%d",
- impl->name, i, count);
- (void)odp_pool_destroy(odp_pool_lookup(pool_name));
- }
- }
-}
-
-/** According to the type of cache, set the value of
- * a buffer to the initial value.
- */
-static void
-cache_init_buffer(odp_buffer_t buffer, cache_type_t type, uint32_t size)
-{
- int i = 0;
- void *addr = odp_buffer_addr(buffer);
-
- memset(addr, 0, size);
- if (type == CACHE_TYPE_SUBTREE) {
- prefix_entry_t *entry = (prefix_entry_t *)addr;
-
- for (i = 0; i < ENTRY_NUM_SUBTREE; i++, entry++)
- entry->nexthop = ODP_BUFFER_INVALID;
- } else if (type == CACHE_TYPE_TRIE) {
- trie_node_t *node = (trie_node_t *)addr;
-
- node->buffer = buffer;
- node->nexthop = ODP_BUFFER_INVALID;
- }
-}
-
-/** Create a new buffer pool, and insert its buffer into the queue. */
-static int
-cache_alloc_new_pool(
- odph_iplookup_table_impl *tbl, cache_type_t type)
-{
- odp_pool_t pool;
- odp_pool_param_t param;
- odp_pool_capability_t pool_capa;
- odp_queue_t queue = tbl->free_slots[type];
-
- odp_buffer_t buffer;
- char pool_name[ODPH_TABLE_NAME_LEN + 8];
- uint32_t size = 0, num = 0;
-
- if (odp_pool_capability(&pool_capa)) {
- ODPH_ERR("pool capa failed\n");
- return -1;
- }
-
- if (pool_capa.buf.max_num) {
- if (pool_capa.buf.max_num < CACHE_NUM_TRIE ||
- pool_capa.buf.max_num < CACHE_NUM_SUBTREE) {
- ODPH_ERR("pool size too small\n");
- return -1;
- }
- }
-
- if (pool_capa.buf.max_size) {
- if (pool_capa.buf.max_size < ENTRY_SIZE * ENTRY_NUM_SUBTREE ||
- pool_capa.buf.max_size < sizeof(trie_node_t)) {
- ODPH_ERR("buffer size too small\n");
- return -1;
- }
- }
-
- /* Create new pool (new free buffers). */
- odp_pool_param_init(&param);
- param.type = ODP_POOL_BUFFER;
- if (pool_capa.buf.max_align >= ODP_CACHE_LINE_SIZE)
- param.buf.align = ODP_CACHE_LINE_SIZE;
- if (type == CACHE_TYPE_SUBTREE) {
- num = CACHE_NUM_SUBTREE;
- size = ENTRY_SIZE * ENTRY_NUM_SUBTREE;
- } else if (type == CACHE_TYPE_TRIE) {
- num = CACHE_NUM_TRIE;
- size = sizeof(trie_node_t);
- } else {
- ODPH_DBG("wrong cache_type_t.\n");
- return -1;
- }
- param.buf.size = size;
- param.buf.num = num;
-
- sprintf(
- pool_name, "%s_%d_%d",
- tbl->name, type, tbl->cache_count[type]);
- pool = odp_pool_create(pool_name, &param);
- if (pool == ODP_POOL_INVALID) {
- ODPH_DBG("failed to create a new pool.\n");
- return -1;
- }
-
- /* insert new free buffers into queue */
- while ((buffer = odp_buffer_alloc(pool))
- != ODP_BUFFER_INVALID) {
- cache_init_buffer(buffer, type, size);
- if (odp_queue_enq(queue, odp_buffer_to_event(buffer))) {
- ODPH_DBG("queue enqueue failed\n");
- odp_buffer_free(buffer);
- break;
- }
- }
-
- tbl->cache_count[type]++;
- return 0;
-}
-
-/** Get a new buffer from a cache list. If there is no
- * available buffer, allocate a new pool.
- */
-static odp_buffer_t
-cache_get_buffer(odph_iplookup_table_impl *tbl, cache_type_t type)
-{
- odp_buffer_t buffer = ODP_BUFFER_INVALID;
- odp_queue_t queue = tbl->free_slots[type];
-
- /* get free buffer from queue */
- buffer = odp_buffer_from_event(
- odp_queue_deq(queue));
-
- /* If there is no free buffer available, allocate new pool */
- if (buffer == ODP_BUFFER_INVALID) {
- cache_alloc_new_pool(tbl, type);
- buffer = odp_buffer_from_event(odp_queue_deq(queue));
- }
-
- return buffer;
-}
-
-/***********************************************************
- ****************** Binary trie ********************
- ***********************************************************/
-
-/* Initialize the root node of the trie */
-static int
-trie_init(odph_iplookup_table_impl *tbl)
-{
- trie_node_t *root = NULL;
- odp_buffer_t buffer = cache_get_buffer(tbl, CACHE_TYPE_TRIE);
-
- if (buffer != ODP_BUFFER_INVALID) {
- root = (trie_node_t *)odp_buffer_addr(buffer);
- root->cidr = 0;
- tbl->trie = root;
- return 0;
- }
-
- return -1;
-}
-
-/* Destroy the whole trie (recursively) */
-static void
-trie_destroy(odph_iplookup_table_impl *tbl, trie_node_t *trie)
-{
- if (trie->left != NULL)
- trie_destroy(tbl, trie->left);
- if (trie->right != NULL)
- trie_destroy(tbl, trie->right);
-
- /* destroy this node */
- odp_queue_enq(
- tbl->free_slots[CACHE_TYPE_TRIE],
- odp_buffer_to_event(trie->buffer));
-}
-
-/* Insert a new prefix node into the trie
- * If the node is already existed, update its nexthop info,
- * Return 0 and set nexthop pointer to INVALID.
- * If the node is not exitsed, create this target node and
- * all nodes along the path from root to the target node.
- * Then return 0 and set nexthop pointer points to the
- * new buffer.
- * Return -1 for error.
- */
-static int
-trie_insert_node(
- odph_iplookup_table_impl *tbl, trie_node_t *root,
- uint32_t ip, uint8_t cidr, odp_buffer_t nexthop)
-{
- uint8_t level = 0, child;
- odp_buffer_t buf;
- trie_node_t *node = root, *prev = root;
-
- /* create/update all nodes along the path
- * from root to the new node. */
- for (level = 1; level <= cidr; level++) {
- child = WHICH_CHILD(ip, level);
-
- node = child == 0 ? prev->left : prev->right;
- /* If the child node doesn't exit, create it. */
- if (node == NULL) {
- buf = cache_get_buffer(tbl, CACHE_TYPE_TRIE);
- if (buf == ODP_BUFFER_INVALID)
- return -1;
-
- node = (trie_node_t *)odp_buffer_addr(buf);
- node->cidr = level;
- node->parent = prev;
-
- if (child == 0)
- prev->left = node;
- else
- prev->right = node;
- }
- prev = node;
- }
-
- /* The final one is the target. */
- node->nexthop = nexthop;
- return 0;
-}
-
-/* Delete a node */
-static int
-trie_delete_node(
- odph_iplookup_table_impl *tbl,
- trie_node_t *root, uint32_t ip, uint8_t cidr)
-{
- if (root == NULL)
- return -1;
-
- /* The default prefix (root node) cannot be deleted. */
- if (cidr == 0)
- return -1;
-
- trie_node_t *node = root, *prev = NULL;
- uint8_t level = 1, child = 0;
- odp_buffer_t tmp;
-
- /* Find the target node. */
- for (level = 1; level <= cidr; level++) {
- child = WHICH_CHILD(ip, level);
- node = (child == 0) ? node->left : node->right;
- if (node == NULL) {
- ODPH_DBG("Trie node is not existed\n");
- return -1;
- }
- }
-
- node->nexthop = ODP_BUFFER_INVALID;
-
- /* Delete all redundant nodes along the path. */
- for (level = cidr; level > 0; level--) {
- if (
- node->left != NULL || node->right != NULL ||
- node->nexthop != ODP_BUFFER_INVALID)
- break;
-
- child = WHICH_CHILD(ip, level);
- prev = node->parent;
-
- /* free trie node */
- tmp = node->buffer;
- cache_init_buffer(
- tmp, CACHE_TYPE_TRIE, sizeof(trie_node_t));
- odp_queue_enq(
- tbl->free_slots[CACHE_TYPE_TRIE],
- odp_buffer_to_event(tmp));
-
- if (child == 0)
- prev->left = NULL;
- else
- prev->right = NULL;
- node = prev;
- }
- return 0;
-}
-
-/* Detect the longest overlapping prefix. */
-static int
-trie_detect_overlap(
- trie_node_t *trie, uint32_t ip, uint8_t cidr,
- uint8_t leaf_push, uint8_t *over_cidr,
- odp_buffer_t *over_nexthop)
-{
- uint8_t child = 0;
- uint32_t level, limit = cidr > leaf_push ? leaf_push + 1 : cidr;
- trie_node_t *node = trie, *longest = trie;
-
- for (level = 1; level < limit; level++) {
- child = WHICH_CHILD(ip, level);
- node = (child == 0) ? node->left : node->right;
- if (node->nexthop != ODP_BUFFER_INVALID)
- longest = node;
- }
-
- *over_cidr = longest->cidr;
- *over_nexthop = longest->nexthop;
- return 0;
-}
-
-/***********************************************************
- *************** IP prefix lookup table ****************
- ***********************************************************/
-
-odph_table_t
-odph_iplookup_table_lookup(const char *name)
-{
- odph_iplookup_table_impl *tbl = NULL;
- odp_shm_t shm;
-
- if (name == NULL || strlen(name) >= ODPH_TABLE_NAME_LEN)
- return NULL;
-
- shm = odp_shm_lookup(name);
- if (shm != ODP_SHM_INVALID)
- tbl = (odph_iplookup_table_impl *)odp_shm_addr(shm);
-
- if (
- tbl != NULL &&
- tbl->magicword == ODPH_IP_LOOKUP_TABLE_MAGIC_WORD &&
- strcmp(tbl->name, name) == 0)
- return (odph_table_t)tbl;
-
- return NULL;
-}
-
-odph_table_t odph_iplookup_table_create(const char *name,
- uint32_t p1 ODP_UNUSED,
- uint32_t p2 ODP_UNUSED,
- uint32_t value_size)
-{
- odph_iplookup_table_impl *tbl;
- odp_shm_t shm_tbl;
- odp_queue_t queue;
- odp_queue_param_t qparam;
- odp_queue_capability_t queue_capa;
- unsigned i;
- uint32_t impl_size, l1_size, queue_size;
- char queue_name[ODPH_TABLE_NAME_LEN + 2];
-
- if (odp_queue_capability(&queue_capa)) {
- ODPH_ERR("queue capa failed\n");
- return NULL;
- }
-
- if (queue_capa.plain.max_size) {
- if (queue_capa.plain.max_size < CACHE_NUM_TRIE ||
- queue_capa.plain.max_size < CACHE_NUM_SUBTREE) {
- ODPH_ERR("queue size too small\n");
- return NULL;
- }
- }
-
- queue_size = CACHE_NUM_TRIE;
- if (CACHE_NUM_SUBTREE > CACHE_NUM_TRIE)
- queue_size = CACHE_NUM_SUBTREE;
-
- /* Check for valid parameters */
- if (strlen(name) == 0) {
- ODPH_DBG("invalid parameters\n");
- return NULL;
- }
-
- /* Guarantee there's no existing */
- tbl = (void *)odph_iplookup_table_lookup(name);
- if (tbl != NULL) {
- ODPH_DBG("IP prefix table %s already exists\n", name);
- return NULL;
- }
-
- /* Calculate the sizes of different parts of IP prefix table */
- impl_size = sizeof(odph_iplookup_table_impl);
- l1_size = ENTRY_SIZE * ENTRY_NUM_L1;
-
- shm_tbl = odp_shm_reserve(name, impl_size + l1_size, ODP_CACHE_LINE_SIZE, 0);
-
- if (shm_tbl == ODP_SHM_INVALID) {
- ODPH_DBG(
- "shm allocation failed for odph_iplookup_table_impl %s\n",
- name);
- return NULL;
- }
-
- tbl = (odph_iplookup_table_impl *)odp_shm_addr(shm_tbl);
- memset(tbl, 0, impl_size + l1_size);
-
- /* header of this mem block is the table impl struct,
- * then the l1 entries array.
- */
- tbl->l1e = (prefix_entry_t *)(void *)((char *)tbl + impl_size);
- for (i = 0; i < ENTRY_NUM_L1; i++)
- tbl->l1e[i].nexthop = ODP_BUFFER_INVALID;
-
- /* Setup table context. */
- snprintf(tbl->name, sizeof(tbl->name), "%s", name);
- tbl->magicword = ODPH_IP_LOOKUP_TABLE_MAGIC_WORD;
- tbl->nexthop_len = value_size;
-
- /* Initialize cache */
- for (i = 0; i < 2; i++) {
- tbl->cache_count[i] = 0;
-
- odp_queue_param_init(&qparam);
- qparam.type = ODP_QUEUE_TYPE_PLAIN;
- qparam.size = queue_size;
- sprintf(queue_name, "%s_%d", name, i);
- queue = odp_queue_create(queue_name, &qparam);
- if (queue == ODP_QUEUE_INVALID) {
- ODPH_DBG("failed to create queue");
- cache_destroy(tbl);
- return NULL;
- }
- tbl->free_slots[i] = queue;
- cache_alloc_new_pool(tbl, i);
- }
-
- /* Initialize tire */
- if (trie_init(tbl) < 0) {
- odp_shm_free(shm_tbl);
- return NULL;
- }
-
- return (odph_table_t)tbl;
-}
-
-int
-odph_iplookup_table_destroy(odph_table_t tbl)
-{
- int i, j;
- odph_iplookup_table_impl *impl = NULL;
- prefix_entry_t *subtree = NULL;
- odp_buffer_t *buff1 = NULL, *buff2 = NULL;
-
- if (tbl == NULL)
- return -1;
-
- impl = (odph_iplookup_table_impl *)(void *)tbl;
-
- /* check magic word */
- if (impl->magicword != ODPH_IP_LOOKUP_TABLE_MAGIC_WORD) {
- ODPH_DBG("wrong magicword for IP prefix table\n");
- return -1;
- }
-
- /* destroy trie */
- trie_destroy(impl, impl->trie);
-
- /* free all L2 and L3 entries */
- buff1 = ENTRY_BUFF_ARR(impl->l1e);
- for (i = 0; i < ENTRY_NUM_L1; i++) {
- if ((impl->l1e[i]).child == 0)
- continue;
-
- subtree = (prefix_entry_t *)impl->l1e[i].ptr;
- buff2 = ENTRY_BUFF_ARR(subtree);
- /* destroy all l3 subtrees of this l2 subtree */
- for (j = 0; j < ENTRY_NUM_SUBTREE; j++) {
- if (subtree[j].child == 0)
- continue;
- odp_queue_enq(
- impl->free_slots[CACHE_TYPE_TRIE],
- odp_buffer_to_event(buff2[j]));
- }
- /* destroy this l2 subtree */
- odp_queue_enq(
- impl->free_slots[CACHE_TYPE_TRIE],
- odp_buffer_to_event(buff1[i]));
- }
-
- /* destroy all cache */
- cache_destroy(impl);
-
- /* free impl */
- odp_shm_free(odp_shm_lookup(impl->name));
- return 0;
-}
-
-/* Insert the prefix into level x
- * Return:
- * -1 error
- * 0 the table is unmodified
- * 1 the table is modified
- */
-static int
-prefix_insert_into_lx(
- odph_iplookup_table_impl *tbl, prefix_entry_t *entry,
- uint8_t cidr, odp_buffer_t nexthop, uint8_t level)
-{
- int ret = 0;
- uint32_t i = 0, limit = (1 << (level - cidr));
- prefix_entry_t *e = entry, *ne = NULL;
-
- for (i = 0; i < limit; i++, e++) {
- if (e->cidr > cidr)
- continue;
-
- if (e->child == 1) {
- e->cidr = cidr;
- /* push to next level */
- ne = (prefix_entry_t *)e->ptr;
- ret = prefix_insert_into_lx(
- tbl, ne, cidr, nexthop, cidr + 8);
- if (ret == -1)
- return -1;
- if (ret == 0)
- return ret;
- } else {
- e->child = 0;
- e->cidr = cidr;
- e->nexthop = nexthop;
- ret = 1;
- }
- }
- return ret;
-}
-
-static int
-prefix_insert_iter(
- odph_iplookup_table_impl *tbl, prefix_entry_t *entry,
- odp_buffer_t *buff, uint32_t ip, uint8_t cidr,
- odp_buffer_t nexthop, uint8_t level, uint8_t depth)
-{
- uint8_t state = 0;
- prefix_entry_t *ne = NULL;
- odp_buffer_t *nbuff = NULL;
-
- /* If child subtree is existed, get it. */
- if (entry->child) {
- ne = (prefix_entry_t *)entry->ptr;
- nbuff = ENTRY_BUFF_ARR(ne);
- } else {
- /* If the child is not existed, create a new subtree. */
- odp_buffer_t buf, push = entry->nexthop;
-
- buf = cache_get_buffer(tbl, CACHE_TYPE_SUBTREE);
- if (buf == ODP_BUFFER_INVALID) {
- ODPH_DBG("failed to get subtree buffer from cache.\n");
- return -1;
- }
- ne = (prefix_entry_t *)odp_buffer_addr(buf);
- nbuff = ENTRY_BUFF_ARR(ne);
-
- entry->child = 1;
- entry->ptr = ne;
- *buff = buf;
-
- /* If this entry contains a nexthop and a small cidr,
- * push it to the next level.
- */
- if (entry->cidr > 0)
- (void)prefix_insert_into_lx(tbl, ne, entry->cidr,
- push, entry->cidr + 8);
- }
-
- ne += (ip >> 24);
- nbuff += (ip >> 24);
- if (cidr <= 8) {
- state = prefix_insert_into_lx(
- tbl, ne, cidr + depth * 8, nexthop, level);
- } else {
- state = prefix_insert_iter(
- tbl, ne, nbuff, ip << 8, cidr - 8,
- nexthop, level + 8, depth + 1);
- }
-
- return state;
-}
-
-int
-odph_iplookup_table_put_value(odph_table_t tbl, void *key, void *value)
-{
- odph_iplookup_table_impl *impl = (void *)tbl;
- odph_iplookup_prefix_t *prefix = (odph_iplookup_prefix_t *)key;
- prefix_entry_t *l1e = NULL;
- odp_buffer_t nexthop;
- int ret = 0;
-
- if ((tbl == NULL) || (key == NULL) || (value == NULL))
- return -1;
-
- nexthop = *((odp_buffer_t *)value);
-
- if (prefix->cidr == 0 || prefix->cidr > 32)
- return -1;
-
- prefix->ip = prefix->ip & (0xffffffff << (IP_LENGTH - prefix->cidr));
-
- /* insert into trie */
- ret = trie_insert_node(
- impl, impl->trie,
- prefix->ip, prefix->cidr, nexthop);
-
- if (ret < 0) {
- ODPH_DBG("failed to insert into trie\n");
- return -1;
- }
-
- /* get L1 entry */
- l1e = &impl->l1e[prefix->ip >> 16];
- odp_buffer_t *buff = ENTRY_BUFF_ARR(impl->l1e) + (prefix->ip >> 16);
-
- if (prefix->cidr <= 16) {
- ret = prefix_insert_into_lx(
- impl, l1e, prefix->cidr, nexthop, 16);
- } else {
- ret = prefix_insert_iter(
- impl, l1e, buff,
- ((prefix->ip) << 16), prefix->cidr - 16,
- nexthop, 24, 2);
- }
-
- return ret;
-}
-
-int odph_iplookup_table_get_value(odph_table_t tbl, void *key,
- void *buffer ODP_UNUSED,
- uint32_t buffer_size ODP_UNUSED)
-{
- odph_iplookup_table_impl *impl = (void *)tbl;
- uint32_t ip;
- prefix_entry_t *entry;
- odp_buffer_t *buff = (odp_buffer_t *)buffer;
-
- if ((tbl == NULL) || (key == NULL) || (buffer == NULL))
- return -EINVAL;
-
- ip = *((uint32_t *)key);
- entry = &impl->l1e[ip >> 16];
-
- if (entry == NULL) {
- ODPH_DBG("failed to get L1 entry.\n");
- return -1;
- }
-
- ip <<= 16;
- while (entry->child) {
- entry = (prefix_entry_t *)entry->ptr;
- entry += ip >> 24;
- ip <<= 8;
- }
-
- /* copy data */
- if (entry->nexthop == ODP_BUFFER_INVALID) {
- /* ONLY match the default prefix */
- printf("only match the default prefix\n");
- *buff = ODP_BUFFER_INVALID;
- } else {
- *buff = entry->nexthop;
- }
-
- return 0;
-}
-
-static int
-prefix_delete_lx(
- odph_iplookup_table_impl *tbl, prefix_entry_t *l1e,
- odp_buffer_t *buff, uint8_t cidr, uint8_t over_cidr,
- odp_buffer_t over_nexthop, uint8_t level)
-{
- uint8_t ret, flag = 1;
- prefix_entry_t *e = l1e;
- odp_buffer_t *b = buff;
- uint32_t i = 0, limit = 1 << (level - cidr);
-
- for (i = 0; i < limit; i++, e++, b++) {
- if (e->child == 1) {
- if (e->cidr > cidr) {
- flag = 0;
- continue;
- }
-
- prefix_entry_t *ne = (prefix_entry_t *)e->ptr;
- odp_buffer_t *nbuff = ENTRY_BUFF_ARR(ne);
-
- e->cidr = over_cidr;
- ret = prefix_delete_lx(
- tbl, ne, nbuff, cidr, over_cidr,
- over_nexthop, cidr + 8);
-
- /* If ret == 1, the next 2^8 entries equal to
- * (over_cidr, over_nexthop). In this case, we
- * should not push the (over_cidr, over_nexthop)
- * to the next level. In fact, we should recycle
- * the next 2^8 entries.
- */
- if (ret) {
- /* destroy subtree */
- cache_init_buffer(
- *b, CACHE_TYPE_SUBTREE,
- ENTRY_SIZE * ENTRY_NUM_SUBTREE);
- odp_queue_enq(
- tbl->free_slots[CACHE_TYPE_SUBTREE],
- odp_buffer_to_event(*b));
- e->child = 0;
- e->nexthop = over_nexthop;
- } else {
- flag = 0;
- }
- } else {
- if (e->cidr > cidr) {
- flag = 0;
- continue;
- } else {
- e->cidr = over_cidr;
- e->nexthop = over_nexthop;
- }
- }
- }
- return flag;
-}
-
-/* Check if the entry can be recycled.
- * An entry can be recycled duo to two reasons:
- * - all children of the entry are the same,
- * - all children of the entry have a cidr smaller than the level
- * bottom bound.
- */
-static uint8_t
-can_recycle(prefix_entry_t *e, uint32_t level)
-{
- uint8_t recycle = 1;
- int i = 1;
- prefix_entry_t *ne = (prefix_entry_t *)e->ptr;
-
- if (ne->child)
- return 0;
-
- uint8_t cidr = ne->cidr;
- odp_buffer_t index = ne->nexthop;
-
- if (cidr > level)
- return 0;
-
- ne++;
- for (; i < 256; i++, ne++) {
- if (
- ne->child != 0 || ne->cidr != cidr ||
- ne->nexthop != index) {
- recycle = 0;
- break;
- }
- }
- return recycle;
-}
-
-static uint8_t
-prefix_delete_iter(
- odph_iplookup_table_impl *tbl, prefix_entry_t *e,
- odp_buffer_t *buff, uint32_t ip, uint8_t cidr,
- uint8_t level, uint8_t depth)
-{
- uint8_t ret = 0, over_cidr;
- odp_buffer_t over_nexthop;
-
- trie_detect_overlap(
- tbl->trie, ip, cidr + 8 * depth, level,
- &over_cidr, &over_nexthop);
- if (cidr > 8) {
- prefix_entry_t *ne =
- (prefix_entry_t *)e->ptr;
- odp_buffer_t *nbuff = ENTRY_BUFF_ARR(ne);
-
- ne += ((uint32_t)(ip << level) >> 24);
- nbuff += ((uint32_t)(ip << level) >> 24);
- ret = prefix_delete_iter(
- tbl, ne, nbuff, ip, cidr - 8,
- level + 8, depth + 1);
-
- if (ret && can_recycle(e, level)) {
- /* destroy subtree */
- cache_init_buffer(
- *buff, CACHE_TYPE_SUBTREE,
- ENTRY_SIZE * ENTRY_NUM_SUBTREE);
- odp_queue_enq(
- tbl->free_slots[CACHE_TYPE_SUBTREE],
- odp_buffer_to_event(*buff));
- e->child = 0;
- e->nexthop = over_nexthop;
- e->cidr = over_cidr;
- return 1;
- }
- return 0;
- }
-
- ret = prefix_delete_lx(
- tbl, e, buff, cidr + 8 * depth,
- over_cidr, over_nexthop, level);
- return ret;
-}
-
-int
-odph_iplookup_table_remove_value(odph_table_t tbl, void *key)
-{
- odph_iplookup_table_impl *impl = (void *)tbl;
- odph_iplookup_prefix_t *prefix = (odph_iplookup_prefix_t *)key;
- uint32_t ip;
- uint8_t cidr;
-
- if ((tbl == NULL) || (key == NULL))
- return -EINVAL;
-
- ip = prefix->ip;
- cidr = prefix->cidr;
-
- if (cidr == 0 || cidr > 32)
- return -EINVAL;
-
- prefix_entry_t *entry = &impl->l1e[ip >> 16];
- odp_buffer_t *buff = ENTRY_BUFF_ARR(impl->l1e) + (ip >> 16);
- uint8_t over_cidr, ret;
- odp_buffer_t over_nexthop;
-
- trie_detect_overlap(
- impl->trie, ip, cidr, 16, &over_cidr, &over_nexthop);
-
- if (cidr <= 16) {
- prefix_delete_lx(
- impl, entry, buff, cidr, over_cidr, over_nexthop, 16);
- } else {
- prefix_entry_t *ne = (prefix_entry_t *)entry->ptr;
- odp_buffer_t *nbuff = ENTRY_BUFF_ARR(ne);
-
- ne += ((uint32_t)(ip << 16) >> 24);
- nbuff += ((uint32_t)(ip << 16) >> 24);
- ret = prefix_delete_iter(impl, ne, nbuff, ip, cidr - 16, 24, 2);
-
- if (ret && can_recycle(entry, 16)) {
- /* destroy subtree */
- cache_init_buffer(
- *buff, CACHE_TYPE_SUBTREE,
- sizeof(prefix_entry_t) * ENTRY_NUM_SUBTREE);
- odp_queue_enq(
- impl->free_slots[CACHE_TYPE_SUBTREE],
- odp_buffer_to_event(*buff));
- entry->child = 0;
- entry->cidr = over_cidr;
- entry->nexthop = over_nexthop;
- }
- }
-
- return trie_delete_node(impl, impl->trie, ip, cidr);
-}
-
-odph_table_ops_t odph_iplookup_table_ops = {
- odph_iplookup_table_create,
- odph_iplookup_table_lookup,
- odph_iplookup_table_destroy,
- odph_iplookup_table_put_value,
- odph_iplookup_table_get_value,
- odph_iplookup_table_remove_value
-};
diff --git a/helper/ipsec.c b/helper/ipsec.c
index bb7d5d0eb..1589d33bd 100644
--- a/helper/ipsec.c
+++ b/helper/ipsec.c
@@ -4,8 +4,8 @@
* Copyright (c) 2021 Nokia
*/
+#include <odp/helper/debug.h>
#include <odp/helper/ipsec.h>
-#include <odp/helper/odph_debug.h>
uint32_t odph_ipsec_auth_icv_len_default(odp_auth_alg_t auth_alg)
{
diff --git a/helper/lineartable.c b/helper/lineartable.c
deleted file mode 100644
index 290a90c02..000000000
--- a/helper/lineartable.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2015-2018 Linaro Limited
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <malloc.h>
-
-#include <odp/helper/odph_lineartable.h>
-#include <odp/helper/odph_debug.h>
-#include <odp_api.h>
-
-#define ODPH_SUCCESS 0
-#define ODPH_FAIL -1
-
-/** @magic word, write to the first byte of the memory block
- * to indicate this block is used by a linear table structure
- */
-#define ODPH_LINEAR_TABLE_MAGIC_WORD 0xEFEFFEFE
-
-/** @internal table struct
- * For linear table, value is orgnized as a big array,
- * and key is the index of this array, so we just need to record the
- * content of value, and make sure the key won't overflow
- */
-typedef struct {
- uint32_t magicword; /**< for check */
- uint32_t init_cap; /**< input param of capacity */
- /** given the capacity, calculate out the max supported nodes number */
- uint32_t node_sum;
- /** size of a lineartable element,including the rwlock in the head */
- uint32_t value_size;
- void *value_array; /**< value pool in array format */
- char name[ODPH_TABLE_NAME_LEN]; /**< name of the table */
-} odph_linear_table_imp;
-
-/** Note: for linear table, key must be an number, its size is fixed 4.
- * So, we ignore the input key_size here
- */
-
-odph_table_t odph_linear_table_create(const char *name, uint32_t capacity,
- uint32_t un ODP_UNUSED,
- uint32_t value_size)
-{
- uint32_t idx;
- uint32_t node_num;
- odp_shm_t shmem;
- odph_linear_table_imp *tbl;
-
- if (strlen(name) >= ODPH_TABLE_NAME_LEN || capacity < 1 ||
- capacity >= 0x1000 || value_size == 0) {
- printf("create para input error or less than !");
- return NULL;
- }
- /* check name conflict in shm*/
- if (odp_shm_lookup(name) != ODP_SHM_INVALID) {
- ODPH_DBG("name already exist\n");
- return NULL;
- }
-
- /* alloc memory from shm */
- shmem = odp_shm_reserve(name, capacity << 20, 64, 0);
- if (shmem == ODP_SHM_INVALID) {
- ODPH_DBG("shm reserve fail\n");
- return NULL;
- }
- tbl = (odph_linear_table_imp *)odp_shm_addr(shmem);
-
- /* clean this block of memory */
- memset(tbl, 0, capacity << 20);
-
- tbl->init_cap = capacity < 20;
-
- strncpy(tbl->name, name, ODPH_TABLE_NAME_LEN - 1);
-
- /* for linear table, the key is just the index, without conflict
- * so we just need to record the value content
- * there is a rwlock in the head of every node
- */
-
- tbl->value_size = value_size + sizeof(odp_rwlock_t);
-
- node_num = tbl->init_cap / tbl->value_size;
- tbl->node_sum = node_num;
-
- tbl->value_array = (void *)((char *)tbl
- + sizeof(odph_linear_table_imp));
-
- /* initialize rwlock*/
- for (idx = 0; idx < tbl->node_sum; idx++) {
- odp_rwlock_t *lock;
-
- lock = (odp_rwlock_t *)(void *)((char *)tbl->value_array
- + idx * tbl->value_size);
- odp_rwlock_init(lock);
- }
-
- tbl->magicword = ODPH_LINEAR_TABLE_MAGIC_WORD;
-
- return (odph_table_t)(tbl);
-}
-
-int odph_linear_table_destroy(odph_table_t table)
-{
- int ret;
- odph_linear_table_imp *linear_tbl = NULL;
-
- if (table != NULL) {
- linear_tbl = (odph_linear_table_imp *)(void *)table;
-
- /* check magicword, make sure the memory is used by a table */
- if (linear_tbl->magicword != ODPH_LINEAR_TABLE_MAGIC_WORD)
- return ODPH_FAIL;
-
- ret = odp_shm_free(odp_shm_lookup(linear_tbl->name));
- if (ret != 0) {
- ODPH_DBG("free fail\n");
- return ret;
- }
-
- return ODPH_SUCCESS;
- }
- return ODPH_FAIL;
-}
-
-odph_table_t odph_linear_table_lookup(const char *name)
-{
- odph_linear_table_imp *tbl = NULL;
- odp_shm_t shm;
-
- if (name == NULL || strlen(name) >= ODPH_TABLE_NAME_LEN)
- return NULL;
-
- shm = odp_shm_lookup(name);
- if (shm != ODP_SHM_INVALID)
- tbl = (odph_linear_table_imp *)odp_shm_addr(shm);
-
- /* check magicword to make sure the memory block is used by a table */
- if (tbl != NULL &&
- tbl->magicword == ODPH_LINEAR_TABLE_MAGIC_WORD &&
- strcmp(tbl->name, name) == 0)
- return (odph_table_t)tbl;
-
- return NULL;
-}
-
-/* should make sure the input table exists and is available */
-static int odph_lineartable_put_value(odph_table_t table,
- void *key, void *value)
-{
- odph_linear_table_imp *tbl;
- uint32_t ikey = 0;
- void *entry = NULL;
- odp_rwlock_t *lock = NULL;
-
- if (table == NULL || key == NULL || value == NULL)
- return ODPH_FAIL;
-
- tbl = (odph_linear_table_imp *)(void *)table;
- ikey = *(uint32_t *)key;
- if (ikey >= tbl->node_sum)
- return ODPH_FAIL;
-
- entry = (void *)((char *)tbl->value_array + ikey * tbl->value_size);
- lock = (odp_rwlock_t *)entry;
- entry = (char *)entry + sizeof(odp_rwlock_t);
-
- odp_rwlock_write_lock(lock);
-
- memcpy(entry, value, tbl->value_size - sizeof(odp_rwlock_t));
-
- odp_rwlock_write_unlock(lock);
-
- return ODPH_SUCCESS;
-}
-
-/* should make sure the input table exists and is available */
-static int odph_lineartable_get_value(odph_table_t table,
- void *key, void *buffer,
- uint32_t buffer_size ODP_UNUSED)
-{
- odph_linear_table_imp *tbl;
- uint32_t ikey = 0;
- void *entry = NULL;
- odp_rwlock_t *lock = NULL;
-
- if (table == NULL || key == NULL || buffer == NULL)
- return ODPH_FAIL;
-
- tbl = (odph_linear_table_imp *)(void *)table;
- ikey = *(uint32_t *)key;
- if (ikey >= tbl->node_sum)
- return ODPH_FAIL;
-
- entry = (void *)((char *)tbl->value_array + ikey * tbl->value_size);
- lock = (odp_rwlock_t *)entry;
- entry = (char *)entry + sizeof(odp_rwlock_t);
-
- odp_rwlock_read_lock(lock);
-
- memcpy(buffer, entry, tbl->value_size - sizeof(odp_rwlock_t));
-
- odp_rwlock_read_unlock(lock);
-
- return ODPH_SUCCESS;
-}
-
-odph_table_ops_t odph_linear_table_ops = {
- odph_linear_table_create,
- odph_linear_table_lookup,
- odph_linear_table_destroy,
- odph_lineartable_put_value,
- odph_lineartable_get_value,
- NULL,
- };
-
diff --git a/helper/linux/thread.c b/helper/linux/thread.c
index d5b016833..ec2847a88 100644
--- a/helper/linux/thread.c
+++ b/helper/linux/thread.c
@@ -18,9 +18,9 @@
#include <stdbool.h>
#include <odp_api.h>
+#include <odp/helper/debug.h>
#include <odp/helper/linux/pthread.h>
#include <odp/helper/linux/process.h>
-#include <odp/helper/odph_debug.h>
static void *_odph_run_start_routine(void *arg)
{
diff --git a/helper/m4/configure.m4 b/helper/m4/configure.m4
index 2e1076172..04768f25e 100644
--- a/helper/m4/configure.m4
+++ b/helper/m4/configure.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2016 Linaro Limited
+#
+
##########################################################################
# Include m4 files
##########################################################################
diff --git a/helper/m4/libcli.m4 b/helper/m4/libcli.m4
index 6748cbb41..7edaf3a5d 100644
--- a/helper/m4/libcli.m4
+++ b/helper/m4/libcli.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021 Nokia
+#
+
##########################################################################
# Set optional libcli path
##########################################################################
diff --git a/helper/test/.gitignore b/helper/test/.gitignore
index 3db451f68..6fb54ea3b 100644
--- a/helper/test/.gitignore
+++ b/helper/test/.gitignore
@@ -2,13 +2,11 @@
*.log
chksum
cli
-cuckootable
-iplookuptable
macros
odpthreads
parse
process
-table
+stress
thread
pthread
version
diff --git a/helper/test/Makefile.am b/helper/test/Makefile.am
index 9cf48d7d9..07986761c 100644
--- a/helper/test/Makefile.am
+++ b/helper/test/Makefile.am
@@ -3,11 +3,9 @@ include $(top_srcdir)/test/Makefile.inc
EXECUTABLES = version \
debug \
chksum \
- cuckootable \
macros \
- parse\
- table \
- iplookuptable
+ parse \
+ stress
#These are platform specific extensions that are not portable
#They are a convenience to app writers who have chosen to
@@ -39,12 +37,10 @@ test_PROGRAMS = $(EXECUTABLES) $(COMPILE_ONLY)
dist_check_SCRIPTS = odpthreads_as_processes odpthreads_as_pthreads
chksum_SOURCES = chksum.c
-cuckootable_SOURCES = cuckootable.c
macros_SOURCES = macros.c
odpthreads_SOURCES = odpthreads.c
parse_SOURCES = parse.c
-table_SOURCES = table.c
-iplookuptable_SOURCES = iplookuptable.c
+stress_SOURCES = stress.c
version_SOURCES = version.c
debug_SOURCES = debug.c
diff --git a/helper/test/cli.c b/helper/test/cli.c
index 08e750153..f7f072fef 100644
--- a/helper/test/cli.c
+++ b/helper/test/cli.c
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2021 Nokia
+ * Copyright (c) 2021-2024 Nokia
*/
#include <odp_api.h>
@@ -9,7 +9,7 @@ static int cli_server(void *arg ODP_UNUSED)
{
if (odph_cli_run()) {
ODPH_ERR("odph_cli_run() failed.\n");
- exit(EXIT_FAILURE);
+ return -1;
}
return 0;
@@ -55,6 +55,7 @@ int main(int argc, char *argv[])
odph_thread_common_param_t thr_common;
odph_thread_param_t thr_param;
odph_thread_t thr_server;
+ odph_thread_join_result_t res;
if (odp_cpumask_default_control(&cpumask, 1) != 1) {
ODPH_ERR("Failed to get default CPU mask.\n");
@@ -86,8 +87,14 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- if (odph_thread_join(&thr_server, 1) != 1) {
- ODPH_ERR("Failed to join server thread.\n");
+ if (odph_thread_join_result(&thr_server, &res, 1) != 1) {
+ ODPH_ERR("Error: failed to join server thread.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (res.is_sig || res.ret != 0) {
+ ODPH_ERR("Error: worker thread failure%s: %d.\n", res.is_sig ? " (signaled)" : "",
+ res.ret);
exit(EXIT_FAILURE);
}
diff --git a/helper/test/cuckootable.c b/helper/test/cuckootable.c
deleted file mode 100644
index d17f79562..000000000
--- a/helper/test/cuckootable.c
+++ /dev/null
@@ -1,577 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2016-2018 Linaro Limited
- */
-
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-#include <time.h>
-
-#include <odp_api.h>
-#include <odp/helper/odph_api.h>
-
-/*******************************************************************************
- * Hash function performance test configuration section.
- *
- * The five arrays below control what tests are performed. Every combination
- * from the array entries is tested.
- */
-/******************************************************************************/
-
-/* 5-tuple key type */
-struct flow_key {
- uint32_t ip_src;
- uint32_t ip_dst;
- uint16_t port_src;
- uint16_t port_dst;
- uint8_t proto;
-} __packed;
-
-/*
- * Print out result of unit test hash operation.
- */
-static void print_key_info(
- const char *msg, const struct flow_key *key)
-{
- const uint8_t *p = (const uint8_t *)key;
- unsigned i;
-
- printf("%s key:0x", msg);
- for (i = 0; i < sizeof(struct flow_key); i++)
- printf("%02X", p[i]);
- printf("\n");
-}
-
-static double get_time_diff(struct timeval *start, struct timeval *end)
-{
- int sec = end->tv_sec - start->tv_sec;
- int usec = end->tv_usec - start->tv_usec;
-
- if (usec < 0) {
- sec--;
- usec += 1000000;
- }
- double diff = sec + (double)usec / 1000000;
-
- return diff;
-}
-
-/** Create IPv4 address */
-#define IPv4(a, b, c, d) ((uint32_t)(((a) & 0xff) << 24) | \
- (((b) & 0xff) << 16) | \
- (((c) & 0xff) << 8) | \
- ((d) & 0xff))
-
-/* Keys used by unit test functions */
-static struct flow_key keys[5] = { {
- .ip_src = IPv4(0x03, 0x02, 0x01, 0x00),
- .ip_dst = IPv4(0x07, 0x06, 0x05, 0x04),
- .port_src = 0x0908,
- .port_dst = 0x0b0a,
- .proto = 0x0c,
-}, {
- .ip_src = IPv4(0x13, 0x12, 0x11, 0x10),
- .ip_dst = IPv4(0x17, 0x16, 0x15, 0x14),
- .port_src = 0x1918,
- .port_dst = 0x1b1a,
- .proto = 0x1c,
-}, {
- .ip_src = IPv4(0x23, 0x22, 0x21, 0x20),
- .ip_dst = IPv4(0x27, 0x26, 0x25, 0x24),
- .port_src = 0x2928,
- .port_dst = 0x2b2a,
- .proto = 0x2c,
-}, {
- .ip_src = IPv4(0x33, 0x32, 0x31, 0x30),
- .ip_dst = IPv4(0x37, 0x36, 0x35, 0x34),
- .port_src = 0x3938,
- .port_dst = 0x3b3a,
- .proto = 0x3c,
-}, {
- .ip_src = IPv4(0x43, 0x42, 0x41, 0x40),
- .ip_dst = IPv4(0x47, 0x46, 0x45, 0x44),
- .port_src = 0x4948,
- .port_dst = 0x4b4a,
- .proto = 0x4c,
-} };
-
-/*
- * Basic sequence of operations for a single key:
- * - put
- * - get (hit)
- * - remove
- * - get (miss)
- */
-static int test_put_remove(void)
-{
- odph_table_t table;
- odph_table_ops_t *ops;
-
- ops = &odph_cuckoo_table_ops;
-
- /* test with standard put/get/remove functions */
- int ret;
-
- table = ops->f_create("put_remove", 10, sizeof(struct flow_key), 0);
- if (table == NULL) {
- printf("cuckoo hash table creation failed\n");
- return -1;
- }
-
- ret = odph_cuckoo_table_put_value(table, &keys[0], NULL);
- print_key_info("Add", &keys[0]);
- if (ret < 0) {
- printf("failed to add key\n");
- odph_cuckoo_table_destroy(table);
- return -1;
- }
-
- ret = odph_cuckoo_table_get_value(table, &keys[0], NULL, 0);
- print_key_info("Lkp", &keys[0]);
- if (ret < 0) {
- printf("failed to find key\n");
- odph_cuckoo_table_destroy(table);
- return -1;
- }
-
- ret = odph_cuckoo_table_remove_value(table, &keys[0]);
- print_key_info("Del", &keys[0]);
- if (ret < 0) {
- printf("failed to delete key\n");
- odph_cuckoo_table_destroy(table);
- return -1;
- }
-
- ret = odph_cuckoo_table_get_value(table, &keys[0], NULL, 0);
- print_key_info("Lkp", &keys[0]);
- if (ret >= 0) {
- printf("error: found key after deleting!\n");
- odph_cuckoo_table_destroy(table);
- return -1;
- }
-
- odph_cuckoo_table_destroy(table);
- return 0;
-}
-
-/*
- * Sequence of operations for a single key:
- * key type : struct flow_key
- * value type: uint8_t
- * - remove: miss
- * - put
- * - get: hit
- * - put: update
- * - get: hit (updated data)
- * - remove: hit
- * - remove: miss
- */
-static int test_put_update_remove(void)
-{
- odph_table_t table;
- int ret;
- uint8_t val1 = 1, val2 = 2, val = 0;
-
- table = odph_cuckoo_table_create(
- "put_update_remove",
- 10, sizeof(struct flow_key), sizeof(uint8_t));
- if (table == NULL) {
- printf("failed to create table\n");
- return -1;
- }
-
- ret = odph_cuckoo_table_remove_value(table, &keys[0]);
- print_key_info("Del", &keys[0]);
- if (ret >= 0) {
- printf("error: found non-existent key\n");
- odph_cuckoo_table_destroy(table);
- return -1;
- }
-
- ret = odph_cuckoo_table_put_value(table, &keys[0], &val1);
- print_key_info("Add", &keys[0]);
- if (ret < 0) {
- printf("failed to add key\n");
- odph_cuckoo_table_destroy(table);
- return -1;
- }
-
- ret = odph_cuckoo_table_get_value(
- table, &keys[0], &val, sizeof(uint8_t));
- print_key_info("Lkp", &keys[0]);
- if (ret < 0) {
- printf("failed to find key\n");
- odph_cuckoo_table_destroy(table);
- return -1;
- }
-
- ret = odph_cuckoo_table_put_value(table, &keys[0], &val2);
- if (ret < 0) {
- printf("failed to re-add key\n");
- odph_cuckoo_table_destroy(table);
- return -1;
- }
-
- ret = odph_cuckoo_table_get_value(
- table, &keys[0], &val, sizeof(uint8_t));
- print_key_info("Lkp", &keys[0]);
- if (ret < 0) {
- printf("failed to find key\n");
- odph_cuckoo_table_destroy(table);
- return -1;
- }
-
- ret = odph_cuckoo_table_remove_value(table, &keys[0]);
- print_key_info("Del", &keys[0]);
- if (ret < 0) {
- printf("failed to delete key\n");
- odph_cuckoo_table_destroy(table);
- return -1;
- }
-
- ret = odph_cuckoo_table_remove_value(table, &keys[0]);
- print_key_info("Del", &keys[0]);
- if (ret >= 0) {
- printf("error: deleted already deleted key\n");
- odph_cuckoo_table_destroy(table);
- return -1;
- }
-
- odph_cuckoo_table_destroy(table);
- return 0;
-}
-
-/*
- * Sequence of operations for find existing hash table
- *
- * - create table
- * - find existing table: hit
- * - find non-existing table: miss
- *
- */
-static int test_table_lookup(void)
-{
- odph_table_t table, result;
-
- /* Create cuckoo hash table. */
- table = odph_cuckoo_table_create("table_lookup", 10, 4, 0);
- if (table == NULL) {
- printf("failed to create table\n");
- return -1;
- }
-
- /* Try to find existing hash table */
- result = odph_cuckoo_table_lookup("table_lookup");
- if (result != table) {
- printf("error: could not find existing table\n");
- odph_cuckoo_table_destroy(table);
- return -1;
- }
-
- /* Try to find non-existing hash table */
- result = odph_cuckoo_table_lookup("non_existing");
- if (result != NULL) {
- printf("error: found table that shouldn't exist.\n");
- odph_cuckoo_table_destroy(table);
- return -1;
- }
-
- /* Cleanup. */
- odph_cuckoo_table_destroy(table);
- return 0;
-}
-
-/*
- * Sequence of operations for 5 keys
- * - put keys
- * - get keys: hit
- * - remove keys : hit
- * - get keys: miss
- */
-static int test_five_keys(void)
-{
- odph_table_t table;
- unsigned i;
- int ret;
-
- table = odph_cuckoo_table_create(
- "five_keys", 10, sizeof(struct flow_key), 0);
- if (table == NULL) {
- printf("failed to create table\n");
- return -1;
- }
-
- /* put */
- for (i = 0; i < 5; i++) {
- ret = odph_cuckoo_table_put_value(table, &keys[i], NULL);
- print_key_info("Add", &keys[i]);
- if (ret < 0) {
- printf("failed to add key %d\n", i);
- odph_cuckoo_table_destroy(table);
- return -1;
- }
- }
-
- /* get */
- for (i = 0; i < 5; i++) {
- ret = odph_cuckoo_table_get_value(table, &keys[i], NULL, 0);
- print_key_info("Lkp", &keys[i]);
- if (ret < 0) {
- printf("failed to find key %d\n", i);
- odph_cuckoo_table_destroy(table);
- return -1;
- }
- }
-
- /* remove */
- for (i = 0; i < 5; i++) {
- ret = odph_cuckoo_table_remove_value(table, &keys[i]);
- print_key_info("Del", &keys[i]);
- if (ret < 0) {
- printf("failed to delete key %d\n", i);
- odph_cuckoo_table_destroy(table);
- return -1;
- }
- }
-
- /* get */
- for (i = 0; i < 5; i++) {
- ret = odph_cuckoo_table_get_value(table, &keys[i], NULL, 0);
- print_key_info("Lkp", &keys[i]);
- if (ret >= 0) {
- printf("found non-existing key %d\n", i);
- odph_cuckoo_table_destroy(table);
- return -1;
- }
- }
-
- odph_cuckoo_table_destroy(table);
- return 0;
-}
-
-#define BUCKET_ENTRIES 4
-#define HASH_ENTRIES_MAX 1048576
-/*
- * Do tests for cuchoo table creation with bad parameters.
- */
-static int test_creation_with_bad_parameters(void)
-{
- odph_table_t table;
-
- table = odph_cuckoo_table_create(
- "bad_param_0", HASH_ENTRIES_MAX + 1, 4, 0);
- if (table != NULL) {
- odph_cuckoo_table_destroy(table);
- printf("Impossible creating table successfully with entries in parameter exceeded\n");
- return -1;
- }
-
- table = odph_cuckoo_table_create(
- "bad_param_1", BUCKET_ENTRIES - 1, 4, 0);
- if (table != NULL) {
- odph_cuckoo_table_destroy(table);
- printf("Impossible creating hash successfully if entries less than bucket_entries in parameter\n");
- return -1;
- }
-
- table = odph_cuckoo_table_create("bad_param_2", 10, 0, 0);
- if (table != NULL) {
- odph_cuckoo_table_destroy(table);
- printf("Impossible creating hash successfully if key_len in parameter is zero\n");
- return -1;
- }
-
- printf("# Test successful. No more errors expected\n");
-
- return 0;
-}
-
-#define PERFORMANCE_CAPACITY 4000
-
-/*
- * Test the performance of cuckoo hash table.
- * table capacity : 1,000,000
- * key size : 4 bytes
- * value size : 0
- * Insert at most number random keys into the table. If one
- * insertion is failed, the rest insertions will be cancelled.
- * The table utilization of the report will show actual number
- * of items inserted.
- * Then search all inserted items.
- */
-static int test_performance(int number)
-{
- odph_table_t table;
-
- /* generate random keys */
- uint8_t *key_space = NULL;
- const void **key_ptr = NULL;
- unsigned key_len = 4, j;
- unsigned elem_num = (number > PERFORMANCE_CAPACITY) ?
- PERFORMANCE_CAPACITY : number;
- unsigned key_num = key_len * elem_num;
-
- key_space = (uint8_t *)malloc(key_num);
- if (key_space == NULL)
- return -ENOENT;
-
- key_ptr = (const void **)malloc(sizeof(void *) * elem_num);
- if (key_ptr == NULL) {
- free(key_space);
- return -ENOENT;
- }
-
- for (j = 0; j < key_num; j++) {
- key_space[j] = rand() % 255;
- if (j % key_len == 0)
- key_ptr[j / key_len] = &key_space[j];
- }
-
- unsigned num;
- int ret = 0;
- struct timeval start, end;
- double add_time = 0;
-
- fflush(stdout);
- table = odph_cuckoo_table_create(
- "performance_test", PERFORMANCE_CAPACITY, key_len, 0);
- if (table == NULL) {
- printf("cuckoo table creation failed\n");
- free(key_ptr);
- free(key_space);
- return -ENOENT;
- }
-
- /* insert (put) */
- gettimeofday(&start, 0);
- for (j = 0; j < elem_num; j++) {
- ret = odph_cuckoo_table_put_value(
- table, &key_space[j * key_len], NULL);
- if (ret < 0)
- break;
- }
- gettimeofday(&end, 0);
- num = j;
- add_time = get_time_diff(&start, &end);
- printf(
- "add %u/%u (%.2f) items, time = %.9lfs\n",
- num, PERFORMANCE_CAPACITY,
- (double)num / PERFORMANCE_CAPACITY, add_time);
-
- /* search (get) */
- gettimeofday(&start, 0);
- for (j = 0; j < num; j++) {
- ret = odph_cuckoo_table_get_value(
- table, &key_space[j * key_len], NULL, 0);
-
- if (ret < 0)
- printf("lookup error\n");
- }
- gettimeofday(&end, 0);
- printf(
- "lookup %u items, time = %.9lfs\n",
- num, get_time_diff(&start, &end));
-
- odph_cuckoo_table_destroy(table);
- free(key_ptr);
- free(key_space);
- return ret;
-}
-
-/*
- * Do all unit and performance tests.
- */
-static int
-test_cuckoo_hash_table(void)
-{
- if (test_put_remove() < 0)
- return -1;
- if (test_table_lookup() < 0)
- return -1;
- if (test_put_update_remove() < 0)
- return -1;
- if (test_five_keys() < 0)
- return -1;
- if (test_creation_with_bad_parameters() < 0)
- return -1;
- if (test_performance(950000) < 0)
- return -1;
-
- return 0;
-}
-
-int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED)
-{
- odp_instance_t instance;
- int ret = 0;
-
- ret = odp_init_global(&instance, NULL, NULL);
- if (ret != 0) {
- fprintf(stderr, "Error: ODP global init failed.\n");
- exit(EXIT_FAILURE);
- }
-
- ret = odp_init_local(instance, ODP_THREAD_WORKER);
- if (ret != 0) {
- fprintf(stderr, "Error: ODP local init failed.\n");
- exit(EXIT_FAILURE);
- }
-
- srand(time(0));
- ret = test_cuckoo_hash_table();
-
- if (ret < 0)
- printf("cuckoo hash table test fail!!\n");
- else
- printf("All Tests pass!!\n");
-
- if (odp_term_local()) {
- fprintf(stderr, "Error: ODP local term failed.\n");
- exit(EXIT_FAILURE);
- }
-
- if (odp_term_global(instance)) {
- fprintf(stderr, "Error: ODP global term failed.\n");
- exit(EXIT_FAILURE);
- }
-
- return ret;
-}
diff --git a/helper/test/iplookuptable.c b/helper/test/iplookuptable.c
deleted file mode 100644
index 669d334dd..000000000
--- a/helper/test/iplookuptable.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2016-2018 Linaro Limited
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include <odp_api.h>
-#include <odp/helper/odph_api.h>
-
-static void print_prefix_info(
- const char *msg, uint32_t ip, uint8_t cidr)
-{
- int i = 0;
- uint8_t *ptr = (uint8_t *)(&ip);
-
- printf("%s IP prefix: ", msg);
- for (i = 3; i >= 0; i--) {
- if (i != 3)
- printf(".");
- printf("%d", ptr[i]);
- }
- printf("/%d\n", cidr);
-}
-
-/*
- * Basic sequence of operations for a single key:
- * - put short prefix
- * - put long prefix
- * - get (hit long prefix)
- * - remove long prefix
- * - get (hit short prefix)
- */
-static int test_ip_lookup_table(void)
-{
- odph_iplookup_prefix_t prefix1, prefix2;
- odph_table_t table;
- int ret;
- uint64_t value1 = 1, value2 = 2, result = 0;
- uint32_t lkp_ip = 0;
-
- table = odph_iplookup_table_create(
- "prefix_test", 0, 0, sizeof(uint32_t));
- if (table == NULL) {
- printf("IP prefix lookup table creation failed\n");
- return -1;
- }
-
- ret = odph_ipv4_addr_parse(&prefix1.ip, "192.168.0.0");
- if (ret < 0) {
- printf("Failed to get IP addr from str\n");
- odph_iplookup_table_destroy(table);
- return -1;
- }
- prefix1.cidr = 11;
-
- ret = odph_ipv4_addr_parse(&prefix2.ip, "192.168.0.0");
- if (ret < 0) {
- printf("Failed to get IP addr from str\n");
- odph_iplookup_table_destroy(table);
- return -1;
- }
- prefix2.cidr = 24;
-
- ret = odph_ipv4_addr_parse(&lkp_ip, "192.168.0.1");
- if (ret < 0) {
- printf("Failed to get IP addr from str\n");
- odph_iplookup_table_destroy(table);
- return -1;
- }
-
- /* test with standard put/get/remove functions */
- ret = odph_iplookup_table_put_value(table, &prefix1, &value1);
- print_prefix_info("Add", prefix1.ip, prefix1.cidr);
- if (ret < 0) {
- printf("Failed to add ip prefix\n");
- odph_iplookup_table_destroy(table);
- return -1;
- }
-
- ret = odph_iplookup_table_get_value(table, &lkp_ip, &result, 0);
- print_prefix_info("Lkp", lkp_ip, 32);
- if (ret < 0 || result != 1) {
- printf("Failed to find longest prefix\n");
- odph_iplookup_table_destroy(table);
- return -1;
- }
-
- /* add a longer prefix */
- ret = odph_iplookup_table_put_value(table, &prefix2, &value2);
- print_prefix_info("Add", prefix2.ip, prefix2.cidr);
- if (ret < 0) {
- printf("Failed to add ip prefix\n");
- odph_iplookup_table_destroy(table);
- return -1;
- }
-
- ret = odph_iplookup_table_get_value(table, &lkp_ip, &result, 0);
- print_prefix_info("Lkp", lkp_ip, 32);
- if (ret < 0 || result != 2) {
- printf("Failed to find longest prefix\n");
- odph_iplookup_table_destroy(table);
- return -1;
- }
-
- ret = odph_iplookup_table_remove_value(table, &prefix2);
- print_prefix_info("Del", prefix2.ip, prefix2.cidr);
- if (ret < 0) {
- printf("Failed to delete ip prefix\n");
- odph_iplookup_table_destroy(table);
- return -1;
- }
-
- ret = odph_iplookup_table_get_value(table, &lkp_ip, &result, 0);
- print_prefix_info("Lkp", lkp_ip, 32);
- if (ret < 0 || result != 1) {
- printf("Error: found result ater deleting\n");
- odph_iplookup_table_destroy(table);
- return -1;
- }
-
- ret = odph_iplookup_table_remove_value(table, &prefix1);
- print_prefix_info("Del", prefix1.ip, prefix1.cidr);
- if (ret < 0) {
- printf("Failed to delete prefix\n");
- odph_iplookup_table_destroy(table);
- return -1;
- }
-
- odph_iplookup_table_destroy(table);
- return 0;
-}
-
-int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED)
-{
- odp_instance_t instance;
- int ret = 0;
-
- ret = odp_init_global(&instance, NULL, NULL);
- if (ret != 0) {
- fprintf(stderr, "Error: ODP global init failed.\n");
- exit(EXIT_FAILURE);
- }
-
- ret = odp_init_local(instance, ODP_THREAD_WORKER);
- if (ret != 0) {
- fprintf(stderr, "Error: ODP local init failed.\n");
- exit(EXIT_FAILURE);
- }
-
- if (test_ip_lookup_table() < 0)
- printf("Test failed\n");
- else
- printf("All tests passed\n");
-
- if (odp_term_local()) {
- fprintf(stderr, "Error: ODP local term failed.\n");
- exit(EXIT_FAILURE);
- }
-
- if (odp_term_global(instance)) {
- fprintf(stderr, "Error: ODP global term failed.\n");
- exit(EXIT_FAILURE);
- }
-
- return ret;
-}
diff --git a/helper/test/odpthreads.c b/helper/test/odpthreads.c
index bf623569b..158b1d3c3 100644
--- a/helper/test/odpthreads.c
+++ b/helper/test/odpthreads.c
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2016-2018 Linaro Limited
- * Copyright (c) 2021 Nokia
+ * Copyright (c) 2021-2024 Nokia
*/
/*
@@ -73,7 +73,6 @@ int main(int argc, char *argv[])
odp_init_t init_param;
int num_workers;
int cpu, affinity;
- int ret;
char cpumaskstr[ODP_CPUMASK_STR_SIZE];
struct rlimit rlimit;
pthread_attr_t attr;
@@ -161,11 +160,25 @@ int main(int argc, char *argv[])
thr_param.arg = NULL;
thr_param.thr_type = ODP_THREAD_WORKER;
- odph_thread_create(thread_tbl, &thr_common, &thr_param, num_workers);
+ if (odph_thread_create(thread_tbl, &thr_common, &thr_param, num_workers) != num_workers) {
+ ODPH_ERR("Error: failed to create worker threads.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ odph_thread_join_result_t res[num_workers];
- ret = odph_thread_join(thread_tbl, num_workers);
- if (ret < 0)
+ if (odph_thread_join_result(thread_tbl, res, num_workers) != num_workers) {
+ ODPH_ERR("Error: failed to join worker threads.\n");
exit(EXIT_FAILURE);
+ }
+
+ for (int i = 0; i < num_workers; i++) {
+ if (res[i].is_sig || res[i].ret != 0) {
+ ODPH_ERR("Error: worker thread failure%s: %d.\n", res[i].is_sig ?
+ " (signaled)" : "", res[i].ret);
+ exit(EXIT_FAILURE);
+ }
+ }
/* Test threads with non-default stack size and sync timeout. */
@@ -195,11 +208,23 @@ int main(int argc, char *argv[])
printf("use sync timeout: %" PRIu64 "\n", thr_common.sync_timeout);
printf("\n");
- if (odph_thread_create(thread_tbl, &thr_common, &thr_param, num_workers) != num_workers)
+ if (odph_thread_create(thread_tbl, &thr_common, &thr_param, num_workers) != num_workers) {
+ ODPH_ERR("Error: failed to create worker threads.\n");
exit(EXIT_FAILURE);
+ }
- if (odph_thread_join(thread_tbl, num_workers) != num_workers)
+ if (odph_thread_join_result(thread_tbl, res, num_workers) != num_workers) {
+ ODPH_ERR("Error: failed to join worker threads.\n");
exit(EXIT_FAILURE);
+ }
+
+ for (int i = 0; i < num_workers; i++) {
+ if (res[i].is_sig || res[i].ret != 0) {
+ ODPH_ERR("Error: worker thread failure%s: %d.\n", res[i].is_sig ?
+ " (signaled)" : "", res[i].ret);
+ exit(EXIT_FAILURE);
+ }
+ }
return 0;
}
diff --git a/helper/test/stress.c b/helper/test/stress.c
new file mode 100644
index 000000000..e66a0447d
--- /dev/null
+++ b/helper/test/stress.c
@@ -0,0 +1,118 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Nokia
+ */
+
+#include <odp_api.h>
+#include <odp/helper/odph_api.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+static int test_pow2(void)
+{
+ uint32_t in[] = {0, 1, 2, 3, 4, 0xff, 0x100, 0xfffe, 0xffff, 0x10000};
+ uint32_t out[] = {0, 1, 4, 9, 16, 0xfe01, 0x10000, 0xfffc0004, 0xfffe0001, 0xffffffff};
+ uint32_t num = ODPH_ARRAY_SIZE(out);
+ int ret = 0;
+
+ printf(" odph_stress_pow2_u32() ... ");
+
+ for (uint32_t i = 0; i < num; i++)
+ if (odph_stress_pow2_u32(in[i]) != out[i])
+ ret++;
+
+ if (ret)
+ printf("%i tests failed\n", ret);
+ else
+ printf("passed\n");
+
+ return ret;
+}
+
+static int test_log2(void)
+{
+ uint32_t in[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 15, 16, 255, 256, 257, 512, 513, 1023, 1024};
+ uint32_t out[] = {0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 4, 7, 8, 8, 9, 9, 9, 10};
+ uint32_t num = ODPH_ARRAY_SIZE(out);
+ int ret = 0;
+
+ printf(" odph_stress_log2_u32() ... ");
+
+ for (uint32_t i = 0; i < num; i++)
+ if (odph_stress_log2_u32(in[i]) != out[i])
+ ret++;
+
+ if (ret)
+ printf("%i tests failed\n", ret);
+ else
+ printf("passed\n");
+
+ return ret;
+}
+
+static int test_sqrt_u32(void)
+{
+ uint32_t in[] = {0, 1, 2, 3, 4, 7, 8, 9, 100, 1500, 2900, 4096, 6213, 8191, 16384, 100000,
+ 1000000, 4036587, 0x42c1d80, 0x8000000, 0x1fffffff, 0x2faf0800,
+ 0xffffffff};
+ uint32_t out[] = {0, 1, 1, 1, 2, 2, 2, 3, 10, 38, 53, 64, 78, 90, 128, 316, 1000, 2009,
+ 8366, 11585, 23170, 28284, 65535};
+ uint32_t num = ODPH_ARRAY_SIZE(out);
+ int ret = 0;
+
+ printf(" odph_stress_sqrt_u32() ... ");
+
+ for (uint32_t i = 0; i < num; i++)
+ if (odph_stress_sqrt_u32(in[i]) != out[i])
+ ret++;
+
+ if (ret)
+ printf("%i tests failed\n", ret);
+ else
+ printf("passed\n");
+
+ return ret;
+}
+
+/*
+ * 32-bit floating point can represent integers between 0 and 16777216 exactly, and integers
+ * between 16777216 and 33554432 in multiples of 2, etc.
+ */
+static int test_sqrt_f32(void)
+{
+ float in[] = {0, 1, 2, 3, 4, 7, 8, 9, 100, 1500, 2900, 4096, 6213, 8191, 16384, 100000,
+ 1000000, 4036587, 16777216, 33554432, 134217728, 3000000000, 4294967296};
+ float out[] = {0, 1, 1, 1, 2, 2, 2, 3, 10, 38, 53, 64, 78, 90, 128, 316, 1000, 2009, 4096,
+ 5792, 11585, 54772, 65536};
+ uint32_t num = ODPH_ARRAY_SIZE(out);
+ int ret = 0;
+
+ printf(" odph_stress_sqrt_f32() ... ");
+
+ for (uint32_t i = 0; i < num; i++)
+ if (odph_stress_sqrt_f32(in[i]) != out[i])
+ ret++;
+
+ if (ret)
+ printf("%i tests failed\n", ret);
+ else
+ printf("passed\n");
+
+ return ret;
+}
+
+int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED)
+{
+ int ret = 0;
+
+ printf("Running helper algorithm tests:\n");
+
+ ret += test_pow2();
+ ret += test_log2();
+ ret += test_sqrt_u32();
+ ret += test_sqrt_f32();
+
+ printf("\n");
+
+ return ret ? EXIT_FAILURE : EXIT_SUCCESS;
+}
diff --git a/helper/test/table.c b/helper/test/table.c
deleted file mode 100644
index fb17e8a37..000000000
--- a/helper/test/table.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2015-2018 Linaro Limited
- */
-
-#include <odp_api.h>
-#include <odp/helper/odph_api.h>
-
-/**
- * Address Resolution Protocol (ARP)
- * Description: Once a route has been identified for an IP packet (so the
- * output interface and the IP address of the next hop station are known),
- * the MAC address of the next hop station is needed in order to send this
- * packet onto the next leg of the journey towards its destination
- * (as identified by its destination IP address). The MAC address of the next
- * hop station becomes the destination MAC address of the outgoing
- * Ethernet frame.
- * Hash table name: ARP table
- * Number of keys: Thousands
- * Key format: The pair of (Output interface, Next Hop IP address),
- * which is typically 5 bytes for IPv4 and 17 bytes for IPv6.
- * value (data): MAC address of the next hop station (6 bytes).
- */
-
-int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED)
-{
- odp_instance_t instance;
- int ret = 0;
- odph_table_t table;
- odph_table_t tmp_tbl;
- odph_table_ops_t *test_ops;
- char tmp[32];
- char ip_addr1[] = "12345678";
- char ip_addr2[] = "11223344";
- char ip_addr3[] = "55667788";
- char mac_addr1[] = "0A1122334401";
- char mac_addr2[] = "0A1122334402";
- char mac_addr3[] = "0B4433221101";
- char mac_addr4[] = "0B4433221102";
-
- ret = odp_init_global(&instance, NULL, NULL);
- if (ret != 0) {
- ODPH_ERR("odp_shm_init_global fail\n");
- exit(EXIT_FAILURE);
- }
- ret = odp_init_local(instance, ODP_THREAD_WORKER);
- if (ret != 0) {
- ODPH_ERR("odp_shm_init_local fail\n");
- exit(EXIT_FAILURE);
- }
-
- printf("test hash table:\n");
- test_ops = &odph_hash_table_ops;
-
- table = test_ops->f_create("test", 2, 4, 16);
- if (table == NULL) {
- printf("table create fail\n");
- return -1;
- }
- ret += test_ops->f_put(table, &ip_addr1, mac_addr1);
-
- ret += test_ops->f_put(table, &ip_addr2, mac_addr2);
-
- ret += test_ops->f_put(table, &ip_addr3, mac_addr3);
-
- if (ret != 0) {
- printf("put value fail\n");
- return -1;
- }
-
- ret = test_ops->f_get(table, &ip_addr1, &tmp, 32);
- if (ret != 0) {
- printf("get value fail\n");
- return -1;
- }
- printf("\t1 get '123' tmp = %s,\n", tmp);
-
- ret = test_ops->f_put(table, &ip_addr1, mac_addr4);
- if (ret != 0) {
- printf("repeat put value fail\n");
- return -1;
- }
-
- ret = test_ops->f_get(table, &ip_addr1, &tmp, 32);
- if (ret != 0 || strcmp(tmp, mac_addr4) != 0) {
- printf("get value fail\n");
- return -1;
- }
-
- printf("\t2 repeat get '123' value = %s\n", tmp);
-
- ret = test_ops->f_remove(table, &ip_addr1);
- if (ret != 0) {
- printf("remove value fail\n");
- return -1;
- }
- ret = test_ops->f_get(table, &ip_addr1, tmp, 32);
- if (ret == 0) {
- printf("remove value fail actually\n");
- return -1;
- }
- printf("\t3 remove success!\n");
-
- tmp_tbl = test_ops->f_lookup("test");
- if (tmp_tbl != table) {
- printf("lookup table fail!!!\n");
- return -1;
- }
- printf("\t4 lookup table success!\n");
-
- ret = test_ops->f_des(table);
- if (ret != 0) {
- printf("destroy table fail!!!\n");
- exit(EXIT_FAILURE);
- }
- printf("\t5 destroy table success!\n");
-
- printf("all test finished success!!\n");
-
- if (odp_term_local()) {
- ODPH_ERR("Error: ODP local term failed.\n");
- exit(EXIT_FAILURE);
- }
-
- if (odp_term_global(instance)) {
- ODPH_ERR("Error: ODP global term failed.\n");
- exit(EXIT_FAILURE);
- }
-
- return 0;
-}
diff --git a/helper/threads.c b/helper/threads.c
index 72003d0f4..5063725b2 100644
--- a/helper/threads.c
+++ b/helper/threads.c
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2013-2018 Linaro Limited
- * Copyright (c) 2019-2022 Nokia
+ * Copyright (c) 2019-2024 Nokia
*/
#ifndef _GNU_SOURCE
@@ -21,8 +21,8 @@
#include <inttypes.h>
#include <odp_api.h>
+#include <odp/helper/debug.h>
#include <odp/helper/threads.h>
-#include <odp/helper/odph_debug.h>
#define FAILED_CPU -1
@@ -144,10 +144,10 @@ static int create_process(odph_thread_t *thread, int cpu, uint64_t stack_size)
/*
* Wait single process to exit
*/
-static int wait_process(odph_thread_t *thread)
+static int wait_process(odph_thread_t *thread, odph_thread_join_result_t *res)
{
pid_t pid;
- int status = 0;
+ int status = 0, estatus;
pid = waitpid(thread->proc.pid, &status, 0);
@@ -157,19 +157,27 @@ static int wait_process(odph_thread_t *thread)
}
/* Examine the child process' termination status */
- if (WIFEXITED(status) &&
- WEXITSTATUS(status) != EXIT_SUCCESS) {
- ODPH_ERR("Child exit status:%d (pid:%d)\n",
- WEXITSTATUS(status), (int)pid);
- return -1;
- }
-
- if (WIFSIGNALED(status)) {
+ if (WIFEXITED(status)) {
+ estatus = WEXITSTATUS(status);
+
+ if (res != NULL) {
+ res->is_sig = false;
+ res->ret = estatus;
+ } else if (estatus != EXIT_SUCCESS) {
+ ODPH_ERR("Child exit status:%d (pid:%d)\n", estatus, (int)pid);
+ return -1;
+ }
+ } else {
int signo = WTERMSIG(status);
- ODPH_ERR("Child term signo:%d - %s (pid:%d)\n",
- signo, strsignal(signo), (int)pid);
- return -1;
+ if (res != NULL) {
+ res->is_sig = true;
+ res->ret = signo;
+ } else {
+ ODPH_ERR("Child term signo:%d - %s (pid:%d)\n", signo, strsignal(signo),
+ (int)pid);
+ return -1;
+ }
}
return 0;
@@ -229,7 +237,7 @@ static int create_pthread(odph_thread_t *thread, int cpu, uint64_t stack_size)
/*
* Wait single pthread to exit
*/
-static int wait_pthread(odph_thread_t *thread)
+static int wait_pthread(odph_thread_t *thread, odph_thread_join_result_t *res)
{
int ret;
void *thread_ret = NULL;
@@ -243,9 +251,11 @@ static int wait_pthread(odph_thread_t *thread)
return -1;
}
- if (thread_ret) {
- ODPH_ERR("Bad exit status cpu #%i %p\n",
- thread->cpu, thread_ret);
+ if (res != NULL) {
+ res->is_sig = false;
+ res->ret = (int)(intptr_t)thread_ret;
+ } else if (thread_ret) {
+ ODPH_ERR("Bad exit status cpu #%i %p\n", thread->cpu, thread_ret);
return -1;
}
@@ -254,7 +264,9 @@ static int wait_pthread(odph_thread_t *thread)
if (ret) {
ODPH_ERR("pthread_attr_destroy failed (%i) from cpu #%i\n",
ret, thread->cpu);
- return -1;
+
+ if (res == NULL)
+ return -1;
}
return 0;
@@ -380,7 +392,7 @@ int odph_thread_create(odph_thread_t thread[],
return i;
}
-int odph_thread_join(odph_thread_t thread[], int num)
+static int join_threads(odph_thread_t thread[], odph_thread_join_result_t res[], int num)
{
odph_thread_start_args_t *start_args;
int i;
@@ -389,15 +401,15 @@ int odph_thread_join(odph_thread_t thread[], int num)
start_args = &thread[i].start_args;
if (start_args->status != STARTED) {
- ODPH_DBG("Thread (i:%i) not started.\n", i);
+ ODPH_ERR("Thread (i:%i) not started.\n", i);
break;
}
if (thread[i].start_args.mem_model == ODP_MEM_MODEL_THREAD) {
- if (wait_pthread(&thread[i]))
+ if (wait_pthread(&thread[i], res != NULL ? &res[i] : NULL))
break;
} else {
- if (wait_process(&thread[i]))
+ if (wait_process(&thread[i], res != NULL ? &res[i] : NULL))
break;
}
@@ -407,6 +419,31 @@ int odph_thread_join(odph_thread_t thread[], int num)
return i;
}
+int odph_thread_join(odph_thread_t thread[], int num)
+{
+ if (thread == NULL) {
+ ODPH_ERR("Bad thread table pointer\n");
+ return -1;
+ }
+
+ return join_threads(thread, NULL, num);
+}
+
+int odph_thread_join_result(odph_thread_t thread[], odph_thread_join_result_t res[], int num)
+{
+ if (thread == NULL) {
+ ODPH_ERR("Bad thread table pointer\n");
+ return -1;
+ }
+
+ if (res == NULL) {
+ ODPH_ERR("Bad result table pointer\n");
+ return -1;
+ }
+
+ return join_threads(thread, res, num);
+}
+
/* man gettid() notes:
* Glibc does not provide a wrapper for this system call;
*/
diff --git a/include/odp/api/abi-default/proto_stats_types.h b/include/odp/api/abi-default/proto_stats_types.h
index e17adf886..554a24eb1 100644
--- a/include/odp/api/abi-default/proto_stats_types.h
+++ b/include/odp/api/abi-default/proto_stats_types.h
@@ -23,6 +23,8 @@ typedef _odp_abi_proto_stats_t *odp_proto_stats_t;
#define ODP_PROTO_STATS_INVALID ((odp_proto_stats_t)0)
+#define ODP_PROTO_STATS_NAME_LEN 64
+
/**
* @}
*/
diff --git a/include/odp/api/abi-default/traffic_mngr.h b/include/odp/api/abi-default/traffic_mngr.h
index 32a0ab473..9e9d017f6 100644
--- a/include/odp/api/abi-default/traffic_mngr.h
+++ b/include/odp/api/abi-default/traffic_mngr.h
@@ -79,6 +79,8 @@ extern "C" {
*/
#define ODP_TM_INVALID_PRIORITY 255
+#define ODP_TM_NAME_LEN 32
+
/** The odp_tm_percent_t type is used when specifying fields that are
* percentages. It is a fixed point integer whose units are 1/100 of a
* percent. Hence 100% is represented as the integer value 10000. Note
diff --git a/include/odp/api/spec/classification.h b/include/odp/api/spec/classification.h
index 518b2bd3c..2186c0bff 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -49,7 +49,7 @@ extern "C" {
/**
* @def ODP_COS_NAME_LEN
- * Maximum class of service name length in chars including null char
+ * Maximum class of service name length, including the null character
*/
/**
@@ -719,7 +719,7 @@ int odp_cls_capability(odp_cls_capability_t *capability);
* values.
*
* @param name Name of the class-of-service or NULL. Maximum string
- * length is ODP_COS_NAME_LEN.
+ * length is ODP_COS_NAME_LEN, including the null character.
* @param param Class-of-service parameters
*
* @retval Class-of-service handle
diff --git a/include/odp/api/spec/cpu.h b/include/odp/api/spec/cpu.h
index 9550354fa..63f313ef3 100644
--- a/include/odp/api/spec/cpu.h
+++ b/include/odp/api/spec/cpu.h
@@ -176,6 +176,100 @@ uint64_t odp_cpu_cycles_resolution(void);
void odp_cpu_pause(void);
/**
+ * Prefetch into data cache
+ *
+ * Hints CPU to prefetch data into all data cache levels. Depending on implementation, this
+ * function may be equal to odp_prefetch_l1().
+ *
+ * @param addr Data address to be prefetched (may be invalid)
+ */
+void odp_prefetch(const void *addr);
+
+/**
+ * Prefetch into L1 data cache
+ *
+ * Hints CPU to prefetch data into L1 data cache.
+ *
+ * @param addr Data address to be prefetched (may be invalid)
+ */
+void odp_prefetch_l1(const void *addr);
+
+/**
+ * Prefetch into L2 data cache
+ *
+ * Hints CPU to prefetch data into L2 data cache.
+ *
+ * @param addr Data address to be prefetched (may be invalid)
+ */
+void odp_prefetch_l2(const void *addr);
+
+/**
+ * Prefetch into L3 data cache
+ *
+ * Hints CPU to prefetch data into L3 data cache.
+ *
+ * @param addr Data address to be prefetched (may be invalid)
+ */
+void odp_prefetch_l3(const void *addr);
+
+/**
+ * Prefetch into data cache for storing
+ *
+ * Hints CPU to prefetch data into all data cache levels for storing. Depending on implementation,
+ * this function may be equal to odp_prefetch_store_l1().
+ *
+ * @param addr Data address to be prefetched (may be invalid)
+ */
+void odp_prefetch_store(const void *addr);
+
+/**
+ * Prefetch into L1 data cache for storing
+ *
+ * Hints CPU to prefetch data into L1 data cache for storing.
+ *
+ * @param addr Data address to be prefetched (may be invalid)
+ */
+void odp_prefetch_store_l1(const void *addr);
+
+/**
+ * Prefetch into L2 data cache for storing
+ *
+ * Hints CPU to prefetch data into L2 data cache for storing.
+ *
+ * @param addr Data address to be prefetched (may be invalid)
+ */
+void odp_prefetch_store_l2(const void *addr);
+
+/**
+ * Prefetch into L3 data cache for storing
+ *
+ * Hints CPU to prefetch data into L3 data cache for storing.
+ *
+ * @param addr Data address to be prefetched (may be invalid)
+ */
+void odp_prefetch_store_l3(const void *addr);
+
+/**
+ * Streaming prefetch into L1 data cache
+ *
+ * Hints CPU to prefetch data of low temporal locality into L1 data cache. Streaming prefetch is
+ * optimal for data that will be used only once.
+ *
+ * @param addr Data address to be prefetched (may be invalid)
+ */
+void odp_prefetch_strm_l1(const void *addr);
+
+/**
+ * Streaming prefetch into L1 data cache for storing
+ *
+ * Hints CPU to prefetch data of low temporal locality into L1 data cache for storing. Streaming
+ * prefetch is optimal for data that will be used only once.
+ *
+ * @param addr Data address to be prefetched (may be invalid)
+ */
+void odp_prefetch_store_strm_l1(const void *addr);
+
+/**
* @}
*/
diff --git a/include/odp/api/spec/crypto_types.h b/include/odp/api/spec/crypto_types.h
index 579022762..987c9e1a1 100644
--- a/include/odp/api/spec/crypto_types.h
+++ b/include/odp/api/spec/crypto_types.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2014-2018 Linaro Limited
- * Copyright (c) 2021-2023 Nokia
+ * Copyright (c) 2021-2024 Nokia
*/
/**
@@ -163,6 +163,42 @@ typedef enum {
*/
ODP_CIPHER_ALG_ZUC_EEA3,
+ /** SNOW-V stream cipher */
+ ODP_CIPHER_ALG_SNOW_V,
+
+ /** SNOW-V-GCM AEAD algorithm
+ *
+ * SNOW-V-GCM provides both authentication and encryption. This cipher
+ * algorithm must always be paired with ODP_AUTH_ALG_SNOW_V_GCM auth
+ * algorithm in crypto session creation.
+ */
+ ODP_CIPHER_ALG_SNOW_V_GCM,
+
+ /** SM4 block cipher in ECB mode */
+ ODP_CIPHER_ALG_SM4_ECB,
+
+ /** SM4 block cipher in CBC mode */
+ ODP_CIPHER_ALG_SM4_CBC,
+
+ /** SM4 block cipher in CTR mode */
+ ODP_CIPHER_ALG_SM4_CTR,
+
+ /** SM4-GCM AEAD algorithm
+ *
+ * SM4-GCM provides both authentication and encryption. This cipher
+ * algorithm must always be paired with ODP_AUTH_ALG_SM4_GCM auth
+ * algorithm in crypto session creation.
+ */
+ ODP_CIPHER_ALG_SM4_GCM,
+
+ /** SM4-CCM AEAD algorithm
+ *
+ * SM4-CCM provides both authentication and encryption. This cipher
+ * algorithm must always be paired with ODP_AUTH_ALG_SM4_CCM auth
+ * algorithm in crypto session creation.
+ */
+ ODP_CIPHER_ALG_SM4_CCM,
+
} odp_cipher_alg_t;
/**
@@ -208,6 +244,18 @@ typedef enum {
*/
ODP_AUTH_ALG_SHA512_HMAC,
+ /** HMAC using SHA3-224 */
+ ODP_AUTH_ALG_SHA3_224_HMAC,
+
+ /** HMAC using SHA3-256 */
+ ODP_AUTH_ALG_SHA3_256_HMAC,
+
+ /** HMAC using SHA3-384 */
+ ODP_AUTH_ALG_SHA3_384_HMAC,
+
+ /** HMAC using SHA3-512 */
+ ODP_AUTH_ALG_SHA3_512_HMAC,
+
/** AES-GCM
*
* AES in Galois/Counter Mode (GCM) algorithm. GCM provides both
@@ -322,6 +370,63 @@ typedef enum {
*/
ODP_AUTH_ALG_ZUC_EIA3,
+ /** SNOW-V-GCM AEAD algorithm
+ *
+ * SNOW-V-GCM provides both authentication and encryption. This auth
+ * algorithm must always be paired with ODP_CIPHER_ALG_SNOW_V_GCM
+ * cipher algorithm in crypto session creation.
+ */
+ ODP_AUTH_ALG_SNOW_V_GCM,
+
+ /** SNOW-V-GMAC
+ *
+ * SNOW-V-GMAC is similar to SNOW-V-GCM without any ciphered data.
+ * This algorithm can be paired only with ODP_CIPHER_ALG_NULL.
+ *
+ * Unlike with SNOW-V-GCM, authenticated data is not provided as
+ * AAD in ODP but as packet data indicated by the auth_range.
+ * The auth_aad_len session parameter and the aad_ptr operation
+ * parameter are ignored.
+ *
+ * GMAC needs an initialization vector, which must be passed via
+ * operation parameters (auth_iv_ptr).
+ */
+ ODP_AUTH_ALG_SNOW_V_GMAC,
+
+ /** HMAC using SM3 */
+ ODP_AUTH_ALG_SM3_HMAC,
+
+ /** SM4-GCM AEAD algorithm
+ *
+ * SM4-GCM provides both authentication and encryption. This auth
+ * algorithm must always be paired with ODP_CIPHER_ALG_SM4_GCM cipher
+ * algorithm in crypto session creation.
+ */
+ ODP_AUTH_ALG_SM4_GCM,
+
+ /** SM4-GMAC
+ *
+ * SM4-GMAC is similar to SM4-GCM without any ciphered data.
+ * This algorithm can be paired only with ODP_CIPHER_ALG_NULL.
+ *
+ * Unlike with SM4-GCM, authenticated data is not provided as
+ * AAD in ODP but as packet data indicated by the auth_range.
+ * The auth_aad_len session parameter and the aad_ptr operation
+ * parameter are ignored.
+ *
+ * GMAC needs an initialization vector, which must be passed via
+ * operation parameters (auth_iv_ptr).
+ */
+ ODP_AUTH_ALG_SM4_GMAC,
+
+ /** SM4-CCM AEAD algorithm
+ *
+ * SM4-CCM provides both authentication and encryption. This auth
+ * algorithm must always be paired with ODP_CIPHER_ALG_SM4_CCM cipher
+ * algorithm in crypto session creation.
+ */
+ ODP_AUTH_ALG_SM4_CCM,
+
/** MD5 algorithm */
ODP_AUTH_ALG_MD5,
@@ -340,6 +445,21 @@ typedef enum {
/** 512 bit SHA2 algorithm */
ODP_AUTH_ALG_SHA512,
+ /** SHA-3 hash function producing 224-bit digests */
+ ODP_AUTH_ALG_SHA3_224,
+
+ /** SHA-3 hash function producing 256-bit digests */
+ ODP_AUTH_ALG_SHA3_256,
+
+ /** SHA-3 hash function producing 384-bit digests */
+ ODP_AUTH_ALG_SHA3_384,
+
+ /** SHA-3 hash function producing 512-bit digests */
+ ODP_AUTH_ALG_SHA3_512,
+
+ /** SM3 hash function */
+ ODP_AUTH_ALG_SM3,
+
} odp_auth_alg_t;
/**
@@ -396,13 +516,34 @@ typedef union odp_crypto_cipher_algos_t {
/** ODP_CIPHER_ALG_ZUC_EEA3 */
uint32_t zuc_eea3 : 1;
+ /** ODP_CIPHER_ALG_SNOW_V */
+ uint32_t snow_v : 1;
+
+ /** ODP_CIPHER_ALG_SNOW_V_GCM */
+ uint32_t snow_v_gcm : 1;
+
+ /** ODP_CIPHER_ALG_SM4_ECB */
+ uint32_t sm4_ecb : 1;
+
+ /** ODP_CIPHER_ALG_SM4_CBC */
+ uint32_t sm4_cbc : 1;
+
+ /** ODP_CIPHER_ALG_SM4_CTR */
+ uint32_t sm4_ctr : 1;
+
+ /** ODP_CIPHER_ALG_SM4_GCM */
+ uint32_t sm4_gcm : 1;
+
+ /** ODP_CIPHER_ALG_SM4_CCM */
+ uint32_t sm4_ccm : 1;
+
} bit;
/** All bits of the bit field structure
*
* This field can be used to set/clear all flags, or bitwise
* operations over the entire structure. */
- uint32_t all_bits;
+ uint64_t all_bits;
} odp_crypto_cipher_algos_t;
/**
@@ -432,6 +573,18 @@ typedef union odp_crypto_auth_algos_t {
/** ODP_AUTH_ALG_SHA512_HMAC */
uint32_t sha512_hmac : 1;
+ /** ODP_AUTH_ALG_SHA3_224_HMAC */
+ uint32_t sha3_224_hmac : 1;
+
+ /** ODP_AUTH_ALG_SHA3_256_HMAC */
+ uint32_t sha3_256_hmac : 1;
+
+ /** ODP_AUTH_ALG_SHA3_384_HMAC */
+ uint32_t sha3_384_hmac : 1;
+
+ /** ODP_AUTH_ALG_SHA3_512_HMAC */
+ uint32_t sha3_512_hmac : 1;
+
/** ODP_AUTH_ALG_AES_GCM */
uint32_t aes_gcm : 1;
@@ -462,6 +615,24 @@ typedef union odp_crypto_auth_algos_t {
/** ODP_AUTH_ALG_ZUC_EIA3 */
uint32_t zuc_eia3 : 1;
+ /** ODP_AUTH_ALG_SNOW_V_GCM */
+ uint32_t snow_v_gcm : 1;
+
+ /** ODP_AUTH_ALG_SNOW_V_GMAC */
+ uint32_t snow_v_gmac : 1;
+
+ /** ODP_AUTH_ALG_SM3_HMAC */
+ uint32_t sm3_hmac : 1;
+
+ /** ODP_AUTH_ALG_SM4_GCM */
+ uint32_t sm4_gcm : 1;
+
+ /** ODP_AUTH_ALG_SM4_GMAC */
+ uint32_t sm4_gmac : 1;
+
+ /** ODP_AUTH_ALG_SM4_CCM */
+ uint32_t sm4_ccm : 1;
+
/** ODP_AUTH_ALG_MD5 */
uint32_t md5 : 1;
@@ -480,13 +651,28 @@ typedef union odp_crypto_auth_algos_t {
/** ODP_AUTH_ALG_SHA512 */
uint32_t sha512 : 1;
+ /** ODP_AUTH_ALG_SHA3_224 */
+ uint32_t sha3_224 : 1;
+
+ /** ODP_AUTH_ALG_SHA3_256 */
+ uint32_t sha3_256 : 1;
+
+ /** ODP_AUTH_ALG_SHA3_384 */
+ uint32_t sha3_384 : 1;
+
+ /** ODP_AUTH_ALG_SHA3_512 */
+ uint32_t sha3_512 : 1;
+
+ /** ODP_AUTH_ALG_SM3 */
+ uint32_t sm3 : 1;
+
} bit;
/** All bits of the bit field structure
*
* This field can be used to set/clear all flags, or bitwise
* operations over the entire structure. */
- uint32_t all_bits;
+ uint64_t all_bits;
} odp_crypto_auth_algos_t;
/**
@@ -673,19 +859,18 @@ typedef struct odp_crypto_session_param_t {
* Select authentication algorithm to be used. ODP_AUTH_ALG_NULL
* indicates that authentication is disabled. Use
* odp_crypto_capability() for supported algorithms. Note that some
- * algorithms restrict choice of the pairing cipher algorithm. When
- * single algorithm provides both ciphering and authentication
- * (i.e. Authenticated Encryption), authentication side key
- * (auth_key) and IV (auth_iv) are ignored, and cipher side values are
- * used instead. These algorithms ignore authentication side key
- * and IV: ODP_AUTH_ALG_AES_GCM, ODP_AUTH_ALG_AES_CCM and
- * ODP_AUTH_ALG_CHACHA20_POLY1305. Otherwise, all authentication side
- * parameters must be set when authentication is enabled. The default
- * value is ODP_AUTH_ALG_NULL.
+ * algorithms restrict choice of the pairing cipher algorithm.
+ *
+ * When single algorithm provides both ciphering and authentication
+ * (i.e. authenticated encryption), authentication side key (auth_key)
+ * and IV (auth_iv) are ignored, and cipher side parameters are used
+ * instead.
*
* When authentication is disabled, i.e. auth_alg is
* ODP_AUTH_ALG_NULL, auth_key, auth_iv_len, auth_digest_len,
* auth_aad_len and hash_result_in_auth_range parameters are ignored.
+ *
+ * The default value is ODP_AUTH_ALG_NULL.
*/
odp_auth_alg_t auth_alg;
@@ -811,7 +996,7 @@ typedef struct odp_crypto_packet_op_param_t {
* odp_crypto_result() or through a negative return value of
* odp_crypto_op()/odp_crypto_op_enq().
*
- * As a special case AES-GMAC uses this field instead of aad_ptr
+ * Algorithms in GMAC mode use this field instead of aad_ptr
* for the data bytes to be authenticated.
*/
odp_packet_data_range_t auth_range;
diff --git a/include/odp/api/spec/dma.h b/include/odp/api/spec/dma.h
index 5303dc03f..0d07544dd 100644
--- a/include/odp/api/spec/dma.h
+++ b/include/odp/api/spec/dma.h
@@ -51,7 +51,8 @@ void odp_dma_param_init(odp_dma_param_t *param);
* 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 name DMA session name or NULL. Maximum string length is ODP_DMA_NAME_LEN,
+ * including the null character.
* @param param DMA session parameters
*
* @return DMA session handle on success
@@ -349,7 +350,8 @@ void odp_dma_pool_param_init(odp_dma_pool_param_t *pool_param);
* into their default values. Parameters values must not exceed pool capabilities
* (odp_dma_pool_capability_t).
*
- * @param name Name of the pool or NULL. Maximum string length is ODP_POOL_NAME_LEN.
+ * @param name Name of the pool or NULL. Maximum string length is ODP_POOL_NAME_LEN,
+ * including the null character.
* @param pool_param Pool parameters
*
* @return Handle of the created pool
diff --git a/include/odp/api/spec/dma_types.h b/include/odp/api/spec/dma_types.h
index 0a0e267df..36a04eb5c 100644
--- a/include/odp/api/spec/dma_types.h
+++ b/include/odp/api/spec/dma_types.h
@@ -58,7 +58,7 @@ extern "C" {
/**
* @def ODP_DMA_NAME_LEN
- * Maximum DMA name length in chars including null char
+ * Maximum DMA name length, including the null character
*/
/**
diff --git a/include/odp/api/spec/event.h b/include/odp/api/spec/event.h
index 69464125b..e5684c634 100644
--- a/include/odp/api/spec/event.h
+++ b/include/odp/api/spec/event.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2015-2018 Linaro Limited
- * Copyright (c) 2022-2023 Nokia
+ * Copyright (c) 2022-2024 Nokia
*/
/**
@@ -144,6 +144,20 @@ void *odp_event_user_area(odp_event_t event);
void *odp_event_user_area_and_flag(odp_event_t event, int *flag);
/**
+ * Set event user flag
+ *
+ * Set (or clear) the user flag.
+ *
+ * The user flag maps to the user flag value of underlying event type (e.g.
+ * odp_packet_user_flag() for packets). If the event does not have user flag,
+ * nothing is done.
+ *
+ * @param event Event handle
+ * @param val New value for the flag. Zero clears the flag, other values set the flag.
+ */
+void odp_event_user_flag_set(odp_event_t event, int val);
+
+/**
* 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/hints.h b/include/odp/api/spec/hints.h
index fa5b1b9bb..58272c16a 100644
--- a/include/odp/api/spec/hints.h
+++ b/include/odp/api/spec/hints.h
@@ -63,23 +63,6 @@ extern "C" {
*/
#define odp_unlikely(x) __builtin_expect(!!(x), 0)
-/*
- * __builtin_prefetch (const void *addr, rw, locality)
- *
- * rw 0..1 (0: read, 1: write)
- * locality 0..3 (0: don't leave to cache, 3: leave on all cache levels)
- */
-
-/**
- * Cache prefetch address
- */
-#define odp_prefetch(x) __builtin_prefetch((x), 0, 3)
-
-/**
- * Cache prefetch address for storing
- */
-#define odp_prefetch_store(x) __builtin_prefetch((x), 1, 3)
-
#else
#define ODP_WEAK_SYMBOL
@@ -88,8 +71,6 @@ extern "C" {
#define ODP_UNUSED
#define odp_likely(x)
#define odp_unlikely(x)
-#define odp_prefetch(x)
-#define odp_prefetch_store(x)
#endif
diff --git a/include/odp/api/spec/ml.h b/include/odp/api/spec/ml.h
index 1a7710ab3..443c6136d 100644
--- a/include/odp/api/spec/ml.h
+++ b/include/odp/api/spec/ml.h
@@ -111,8 +111,7 @@ void odp_ml_model_param_init(odp_ml_model_param_t *param);
*
* Creates an ML model according to the parameters. Use odp_ml_model_param_init() to initialize
* parameters into their default values. The use of model name is optional. Unique names are not
- * required. However, odp_ml_model_lookup() returns only a single matching model. Maximum name
- * string length is #ODP_ML_MODEL_NAME_LEN.
+ * required. However, odp_ml_model_lookup() returns only a single matching model.
*
* The call copies the model binary and prepares it for loading. Application may free memory
* buffers pointed by the parameters when the call returns. Use odp_ml_model_load()
@@ -124,7 +123,8 @@ void odp_ml_model_param_init(odp_ml_model_param_t *param);
* implementation specific extra parameters (e.g. hints about HW resource usage), user can pass
* those with odp_ml_model_param_t.extra_param when applicable.
*
- * @param name Name of the model, or NULL
+ * @param name Name of the model, or NULL. Maximum string length is ODP_ML_MODEL_NAME_LEN,
+ * including the null character.
* @param param ML model parameters
*
* @return ML model handle on success
@@ -454,7 +454,8 @@ void odp_ml_compl_pool_param_init(odp_ml_compl_pool_param_t *param);
* parameters into their default values. Parameters values must not exceed pool capabilities
* (see odp_ml_compl_pool_capability_t).
*
- * @param name Name of the pool or NULL. Maximum string length is #ODP_POOL_NAME_LEN.
+ * @param name Name of the pool or NULL. Maximum string length is ODP_POOL_NAME_LEN,
+ * including the null character.
* @param param Pool parameters
*
* @return Pool handle on success
diff --git a/include/odp/api/spec/ml_types.h b/include/odp/api/spec/ml_types.h
index 2b8f9d6c8..c91b49036 100644
--- a/include/odp/api/spec/ml_types.h
+++ b/include/odp/api/spec/ml_types.h
@@ -47,22 +47,22 @@ extern "C" {
/**
* @def ODP_ML_MODEL_NAME_LEN
- * Maximum length of model name in chars (including null char)
+ * Maximum length of model name, including the null character
*/
/**
* @def ODP_ML_MODEL_IO_NAME_LEN
- * Maximum length of model input/output name in chars (including null char)
+ * Maximum length of model input/output name, including the null character
*/
/**
* @def ODP_ML_SHAPE_NAME_LEN
- * Maximum length of data dimension name in chars (including null char)
+ * Maximum length of data dimension name, including the null character
*/
/**
* @def ODP_ML_EXTRA_STAT_NAME_LEN
- * Maximum length of extra statistics counter name in chars (including null char)
+ * Maximum length of extra statistics counter name, including the null character
*/
/**
diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index 7f6c732ee..624c3c7c3 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -123,21 +123,59 @@ void odp_packet_free_sp(const odp_packet_t pkt[], int num);
/**
* Reset packet
*
- * Resets all packet metadata to their default values. Packet length is used
- * to initialize pointers and lengths. It must be less than the total buffer
- * length of the packet. Packet is not modified on failure.
+ * Resets all packet metadata and adjusts packet data to start according to pool
+ * parameters (align, seg_len, headroom). Packet data length is set to 'len'.
+ * Maximum value for 'len' can be queried with odp_packet_reset_max_len()
+ * function. Passing larger 'len' than the maximum value is allowed, but will
+ * cause failure to be returned.
+ *
+ * Packet reset maintains the original user area content. The operation may
+ * change data layout in packet segments and free possible extra segments. Data
+ * content may not be preserved. Packet is not modified on failure.
+ *
+ * This function must not be called for packets with references or incomplete
+ * reassembly status (ODP_PACKET_REASS_INCOMPLETE).
*
* @param pkt Packet handle
- * @param len Packet data length (1 ... odp_packet_buf_len())
+ * @param len Packet data length (1 ... odp_packet_reset_max_len())
*
* @retval 0 on success
* @retval <0 on failure
- *
- * @see odp_packet_buf_len()
*/
int odp_packet_reset(odp_packet_t pkt, uint32_t len);
/**
+ * Maximum packet data reset length
+ *
+ * Returns the maximum packet data reset length for odp_packet_reset() based
+ * on current packet buffer space and pool parameters (align, seg_len,
+ * headroom).
+ *
+ * @param pkt Packet handle
+ *
+ * @return Maximum packet data length for odp_packet_reset()
+ */
+uint32_t odp_packet_reset_max_len(odp_packet_t pkt);
+
+/**
+ * Reset packet metadata
+ *
+ * Resets all packet metadata to their default values, except the ones listed
+ * below which are not modified:
+ * - Data pointer and length
+ * - Headroom and tailroom pointers and lengths
+ * - Packet segmentation
+ * - User area content
+ * - Dynamic reference count
+ *
+ * This function must not be called for packets with static references or
+ * incomplete reassembly status (ODP_PACKET_REASS_INCOMPLETE).
+ *
+ * @param pkt Packet handle
+ */
+void odp_packet_reset_meta(odp_packet_t pkt);
+
+/**
* Get packet handle from event
*
* Converts an ODP_EVENT_PACKET type event to a packet.
@@ -243,13 +281,12 @@ void *odp_packet_head(odp_packet_t pkt);
/**
* Total packet buffer length
*
- * Returns sum of buffer lengths over all packet segments.
+ * Returns sum of buffer lengths over all packet segments. Buffer length
+ * includes headroom, data, and tailroom lengths.
*
* @param pkt Packet handle
*
* @return Total packet buffer length in bytes
- *
- * @see odp_packet_reset()
*/
uint32_t odp_packet_buf_len(odp_packet_t pkt);
@@ -2414,7 +2451,7 @@ odp_event_t odp_packet_tx_compl_to_event(odp_packet_tx_compl_t tx_compl);
*
* @param tx_compl Packet Tx completion handle
*
- * @see odp_packet_tx_completion_request()
+ * @see odp_packet_tx_compl_request()
*/
void odp_packet_tx_compl_free(odp_packet_tx_compl_t tx_compl);
diff --git a/include/odp/api/spec/packet_io_stats.h b/include/odp/api/spec/packet_io_stats.h
index d711d75f7..39ce86920 100644
--- a/include/odp/api/spec/packet_io_stats.h
+++ b/include/odp/api/spec/packet_io_stats.h
@@ -25,8 +25,8 @@ extern "C" {
/**
* @def ODP_PKTIO_STATS_EXTRA_NAME_LEN
- * Maximum packet IO extra statistics counter name length in chars including
- * null char
+ * Maximum packet IO extra statistics counter name length, including the null
+ * character
*/
/**
diff --git a/include/odp/api/spec/pool.h b/include/odp/api/spec/pool.h
index 1b71a5a09..32f01fb59 100644
--- a/include/odp/api/spec/pool.h
+++ b/include/odp/api/spec/pool.h
@@ -46,7 +46,7 @@ int odp_pool_capability(odp_pool_capability_t *capa);
* into their default values.
*
* @param name Name of the pool or NULL. Maximum string length is
- * ODP_POOL_NAME_LEN.
+ * ODP_POOL_NAME_LEN, including the null character.
* @param param Pool parameters.
*
* @return Handle of the created pool
@@ -246,7 +246,8 @@ void odp_pool_ext_param_init(odp_pool_type_t type, odp_pool_ext_param_t *param);
* single matching pool. Use odp_pool_ext_param_init() to initialize parameters
* into their default values.
*
- * @param name Name of the pool or NULL. Maximum string length is ODP_POOL_NAME_LEN.
+ * @param name Name of the pool or NULL. Maximum string length is
+ * ODP_POOL_NAME_LEN, including the null character.
* @param param Pool parameters
*
* @return Pool handle on success
diff --git a/include/odp/api/spec/pool_types.h b/include/odp/api/spec/pool_types.h
index cb3db4737..c9e629374 100644
--- a/include/odp/api/spec/pool_types.h
+++ b/include/odp/api/spec/pool_types.h
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2021-2023 Nokia
+ * Copyright (c) 2021-2024 Nokia
*/
/**
@@ -36,7 +36,7 @@ extern "C" {
/**
* @def ODP_POOL_NAME_LEN
- * Maximum pool name length in chars including null char
+ * Maximum pool name length, including the null character
*/
/**
@@ -437,8 +437,10 @@ typedef struct odp_pool_param_t {
/** Number of buffers in the pool */
uint32_t num;
- /** Buffer size in bytes. The maximum number of bytes
- * application will store in each buffer.
+ /** Minimum buffer size in bytes.
+ *
+ * An implementation may round up the given value. The maximum
+ * value is defined by buf.max_size pool capability.
*/
uint32_t size;
diff --git a/include/odp/api/spec/proto_stats.h b/include/odp/api/spec/proto_stats.h
index 7dd57ac0f..5fa0f4cea 100644
--- a/include/odp/api/spec/proto_stats.h
+++ b/include/odp/api/spec/proto_stats.h
@@ -55,7 +55,8 @@ int odp_proto_stats_capability(odp_pktio_t pktio, odp_proto_stats_capability_t *
* for that PKTIO associated packets. Same proto stats object can be used with
* any PKTIO.
*
- * @param name Object name
+ * @param name Object name. Maximum string length is ODP_PROTO_STATS_NAME_LEN,
+ * including the null character.
* @param param Proto stats parameters
*
* @return Proto stats object handle
diff --git a/include/odp/api/spec/proto_stats_types.h b/include/odp/api/spec/proto_stats_types.h
index 4c08e60ab..4ba51f48e 100644
--- a/include/odp/api/spec/proto_stats_types.h
+++ b/include/odp/api/spec/proto_stats_types.h
@@ -33,6 +33,11 @@ extern "C" {
* Invalid proto stats handle
*/
+/**
+ * @def ODP_PROTO_STATS_NAME_LEN
+ * Maximum proto stats name length, including the null character
+ */
+
/** ODP proto stats counters
*
* Statistics that can be enabled in proto stats object. For Tx stats counters,
diff --git a/include/odp/api/spec/queue.h b/include/odp/api/spec/queue.h
index 9ce2ac73f..f12c3a185 100644
--- a/include/odp/api/spec/queue.h
+++ b/include/odp/api/spec/queue.h
@@ -36,7 +36,7 @@ extern "C" {
* 'param' pointer is NULL.
*
* @param name Name of the queue or NULL. Maximum string length is
- * ODP_QUEUE_NAME_LEN.
+ * ODP_QUEUE_NAME_LEN, including the null character.
* @param param Queue parameters. Uses defaults if NULL.
*
* @return Queue handle
diff --git a/include/odp/api/spec/queue_types.h b/include/odp/api/spec/queue_types.h
index 9edf7271d..057df405a 100644
--- a/include/odp/api/spec/queue_types.h
+++ b/include/odp/api/spec/queue_types.h
@@ -34,7 +34,7 @@ extern "C" {
/**
* @def ODP_QUEUE_NAME_LEN
- * Maximum queue name length in chars including null char
+ * Maximum queue name length, including the null character
*/
/**
diff --git a/include/odp/api/spec/schedule.h b/include/odp/api/spec/schedule.h
index 7226c198b..62422b43d 100644
--- a/include/odp/api/spec/schedule.h
+++ b/include/odp/api/spec/schedule.h
@@ -329,7 +329,7 @@ int odp_schedule_capability(odp_schedule_capability_t *capa);
* returns only a single matching group.
*
* @param name Name of the schedule group or NULL. Maximum string length is
- * ODP_SCHED_GROUP_NAME_LEN.
+ * ODP_SCHED_GROUP_NAME_LEN, including the null character.
* @param mask Thread mask
*
* @return Schedule group handle
diff --git a/include/odp/api/spec/schedule_types.h b/include/odp/api/spec/schedule_types.h
index 30cb939dc..9525ee423 100644
--- a/include/odp/api/spec/schedule_types.h
+++ b/include/odp/api/spec/schedule_types.h
@@ -36,7 +36,7 @@ extern "C" {
/**
* @def ODP_SCHED_GROUP_NAME_LEN
- * Maximum schedule group name length in chars including null char
+ * Maximum schedule group name length, including the null character
*/
/**
diff --git a/include/odp/api/spec/shared_memory.h b/include/odp/api/spec/shared_memory.h
index 3845f6e4d..7b2b28d11 100644
--- a/include/odp/api/spec/shared_memory.h
+++ b/include/odp/api/spec/shared_memory.h
@@ -35,7 +35,7 @@ extern "C" {
/**
* @def ODP_SHM_NAME_LEN
- * Maximum shared memory block name length in chars including null char
+ * Maximum shared memory block name length, including the null character
*/
/**
@@ -208,7 +208,8 @@ int odp_shm_capability(odp_shm_capability_t *capa);
* searched with odp_shm_lookup() or odp_shm_import(), a unique name is needed
* for correct match.
*
- * @param name Name of the block or NULL. Maximum string length is ODP_SHM_NAME_LEN.
+ * @param name Name of the block or NULL. Maximum string length is ODP_SHM_NAME_LEN, including the
+ * null character.
* @param size Block size in bytes
* @param align Block alignment in bytes
* @param flags Shared memory parameter flags (ODP_SHM_*). Default value is 0.
@@ -257,7 +258,8 @@ odp_shm_t odp_shm_lookup(const char *name);
* @param odp_inst Remote ODP instance, as returned by odp_init_global()
* @param local_name Name given to the block, in the local ODP instance
* May be NULL, if the application doesn't need a name
- * (for a lookup).
+ * (for a lookup). Maximum string length is
+ * ODP_SHM_NAME_LEN, including the null character.
*
* @return A handle to access a block exported by another ODP instance.
* @retval ODP_SHM_INVALID on failure
diff --git a/include/odp/api/spec/stash.h b/include/odp/api/spec/stash.h
index 61ae58eba..d1b2f66c9 100644
--- a/include/odp/api/spec/stash.h
+++ b/include/odp/api/spec/stash.h
@@ -61,7 +61,7 @@ void odp_stash_param_init(odp_stash_param_t *param);
* odp_stash_lookup() returns only a single matching stash.
*
* @param name Name of the stash or NULL. Maximum string length is
- * ODP_STASH_NAME_LEN.
+ * ODP_STASH_NAME_LEN, including the null character.
* @param param Stash creation parameters
*
* @return Handle of the created stash
diff --git a/include/odp/api/spec/stash_types.h b/include/odp/api/spec/stash_types.h
index 48c4b9be8..0f56a98d4 100644
--- a/include/odp/api/spec/stash_types.h
+++ b/include/odp/api/spec/stash_types.h
@@ -34,7 +34,7 @@ extern "C" {
/**
* @def ODP_STASH_NAME_LEN
- * Maximum stash name length in chars including null char
+ * Maximum stash name length, including the null character
*/
/**
diff --git a/include/odp/api/spec/timer.h b/include/odp/api/spec/timer.h
index 1e7a06ad4..9766eafa3 100644
--- a/include/odp/api/spec/timer.h
+++ b/include/odp/api/spec/timer.h
@@ -125,7 +125,7 @@ void odp_timer_pool_param_init(odp_timer_pool_param_t *param);
* 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.
+ * ODP_TIMER_POOL_NAME_LEN, including the null character.
* @param params Timer pool parameters. The content will be copied.
*
* @return Timer pool handle on success
diff --git a/include/odp/api/spec/timer_types.h b/include/odp/api/spec/timer_types.h
index 7db57c340..e2e8b917e 100644
--- a/include/odp/api/spec/timer_types.h
+++ b/include/odp/api/spec/timer_types.h
@@ -58,7 +58,7 @@ extern "C" {
/**
* @def ODP_TIMER_POOL_NAME_LEN
- * Maximum timer pool name length in chars including null char
+ * Maximum timer pool name length, including the null character
*/
/**
diff --git a/include/odp/api/spec/traffic_mngr.h b/include/odp/api/spec/traffic_mngr.h
index 117ed22cd..d75277f2b 100644
--- a/include/odp/api/spec/traffic_mngr.h
+++ b/include/odp/api/spec/traffic_mngr.h
@@ -101,6 +101,11 @@ extern "C" {
*/
/**
+ * @def ODP_TM_NAME_LEN
+ * Maximum traffic manager name length, including the null character
+ */
+
+/**
* @typedef odp_tm_percent_t
* Is used when specifying fields that are percentages. It is a fixed point
* integer whose units are 1/100 of a percent. Hence 100% is represented as
@@ -771,7 +776,8 @@ int odp_tm_egress_capabilities(odp_tm_capabilities_t *capabilities,
*
* @param name The name to be assigned to this TM system. Cannot
* be NULL, and also must be unique amongst all other
- * TM system names.
+ * TM system names. Maximum string length is
+ * ODP_TM_NAME_LEN, including the null character.
* @param requirements The minimum required feature set and limits needed
* by the ODP application.
* @param egress Describes the single egress "spigot" of this
@@ -1129,7 +1135,8 @@ void odp_tm_shaper_params_init(odp_tm_shaper_params_t *params);
*
* @param name Optional name associated with this shaper profile. Can
* be NULL. If non-NULL must be unique amongst the set of
- * all other shaper profiles.
+ * all other shaper profiles. Maximum string length is
+ * ODP_TM_NAME_LEN, including the null character.
* @param params The profile parameters. See comments associated with
* the odp_tm_shaper_params_t for more details.
* @return Returns ODP_TM_INVALID upon failure, or the newly
@@ -1242,7 +1249,8 @@ void odp_tm_sched_params_init(odp_tm_sched_params_t *params);
*
* @param name Optional name associated with this scheduler profile.
* Can be NULL. If non-NULL must be unique amongst the
- * set of all other scheduler profiles.
+ * set of all other scheduler profiles. Maximum string length is
+ * ODP_TM_NAME_LEN, including the null character.
* @param params The profile parameters. See comments associated with
* the odp_tm_sched_params_t for more details.
* @return Returns ODP_TM_INVALID upon failure, or the newly
@@ -1339,6 +1347,8 @@ void odp_tm_threshold_params_init(odp_tm_threshold_params_t *params);
* @param name Optional name associated with this queue threshold
* profile. Can be NULL. If non-NULL must be unique
* amongst the set of all other queue threshold profiles.
+ * Maximum string length is ODP_TM_NAME_LEN, including the null
+ * character.
* @param params The profile parameters. See comments associated with
* the odp_tm_threshold_params_t for more details.
* @return Returns ODP_TM_INVALID upon failure, or the newly
@@ -1477,7 +1487,8 @@ void odp_tm_wred_params_init(odp_tm_wred_params_t *params);
*
* @param name Optional name associated with this WRED profile. Can
* be NULL. If non-NULL must be unique amongst the set of
- * all other WRED profiles.
+ * all other WRED profiles. Maximum string length is
+ * ODP_TM_NAME_LEN, including the null character.
* @param params The profile parameters. See comments associated with the
* odp_tm_wred_params_t for more details.
* @return Returns ODP_TM_INVALID upon failure, or the newly
@@ -1616,7 +1627,8 @@ void odp_tm_node_params_init(odp_tm_node_params_t *params);
* created.
* @param name Optional name that can be used later later to find this
* same odp_tm_node_t. Can be NULL, otherwise must be
- * unique across all odp_tm_node objects.
+ * unique across all odp_tm_node objects. Maximum string length
+ * is ODP_TM_NAME_LEN, including the null character.
* @param params TM node parameters.
*
* @return Returns ODP_TM_INVALID upon failure, otherwise returns
diff --git a/m4/odp_atomic.m4 b/m4/odp_atomic.m4
index 2554502fd..c87319d38 100644
--- a/m4/odp_atomic.m4
+++ b/m4/odp_atomic.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2017 Linaro Limited
+#
+
# ODP_ATOMIC
# ----------
# Run different atomic-related checks
diff --git a/m4/odp_check_flag.m4 b/m4/odp_check_flag.m4
index 37667d4ea..012997ff2 100644
--- a/m4/odp_check_flag.m4
+++ b/m4/odp_check_flag.m4
@@ -1,7 +1,5 @@
-# Copyright (c) 2018, Linaro Limited
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2018 Linaro Limited
#
dnl Use -Werror in the checks below since Clang emits a warning instead of
diff --git a/m4/odp_dpdk.m4 b/m4/odp_dpdk.m4
index 1852d316c..b67d8629e 100644
--- a/m4/odp_dpdk.m4
+++ b/m4/odp_dpdk.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2017 Linaro Limited
+#
+
# ODP_DPDK_PMDS(DPDK_DRIVER_PATH)
# -------------------------------
# Update DPDK_LIBS to include dependencies.
diff --git a/m4/odp_libconfig.m4 b/m4/odp_libconfig.m4
index 31619934c..f6e4c672b 100644
--- a/m4/odp_libconfig.m4
+++ b/m4/odp_libconfig.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2018 Linaro Limited
+#
+
# ODP_LIBCONFIG(PLATFORM, CONFIG-FILE-PATH)
# -----------------------------------------
AC_DEFUN([ODP_LIBCONFIG],
diff --git a/m4/odp_openssl.m4 b/m4/odp_openssl.m4
index dfab10a5e..4f62dba8e 100644
--- a/m4/odp_openssl.m4
+++ b/m4/odp_openssl.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2017 Linaro Limited
+#
+
# ODP_OPENSSL([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# -----------------------------------------------------
AC_DEFUN([ODP_OPENSSL],
diff --git a/m4/odp_pthread.m4 b/m4/odp_pthread.m4
index ad1ecdff4..2076a4691 100644
--- a/m4/odp_pthread.m4
+++ b/m4/odp_pthread.m4
@@ -1,8 +1,7 @@
-# Copyright (c) 2018, Linaro Limited
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2018 Linaro Limited
#
+
# ODP_PTHREAD
# -----------
# Check for pthreads availability
diff --git a/m4/odp_timer.m4 b/m4/odp_timer.m4
index 9a552f9ff..be0ac0013 100644
--- a/m4/odp_timer.m4
+++ b/m4/odp_timer.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2017 Linaro Limited
+#
+
# ODP_TIMER([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
##########################################################################
# Check for POSIX timer functions
diff --git a/m4/odp_visibility.m4 b/m4/odp_visibility.m4
index 955971f3c..9edba1f43 100644
--- a/m4/odp_visibility.m4
+++ b/m4/odp_visibility.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2017 Linaro Limited
+#
+
# ODP_VISIBILITY
# --------------
# Enable -fvisibility=hidden if using a gcc that supports it
diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am
index 0bfe35092..86dc1d495 100644
--- a/platform/linux-dpdk/Makefile.am
+++ b/platform/linux-dpdk/Makefile.am
@@ -149,7 +149,6 @@ noinst_HEADERS = \
${top_srcdir}/platform/linux-generic/include/odp_name_table_internal.h \
include/odp_packet_io_internal.h \
${top_srcdir}/platform/linux-generic/include/odp_parse_internal.h \
- ${top_srcdir}/platform/linux-generic/include/odp_print_internal.h \
include/odp_errno_define.h \
include/odp_event_internal.h \
${top_srcdir}/platform/linux-generic/include/odp_event_validation_internal.h \
@@ -157,7 +156,7 @@ noinst_HEADERS = \
${top_srcdir}/platform/linux-generic/include/odp_pcapng.h \
${top_srcdir}/platform/linux-generic/include/odp_pkt_queue_internal.h \
include/odp_pool_internal.h \
- include/odp_posix_extensions.h \
+ ${top_srcdir}/platform/linux-generic/include/odp_posix_extensions.h \
include/odp_queue_basic_internal.h \
${top_srcdir}/platform/linux-generic/include/odp_queue_if.h \
${top_srcdir}/platform/linux-generic/include/odp_queue_lf.h \
@@ -176,6 +175,7 @@ noinst_HEADERS = \
${top_srcdir}/platform/linux-generic/include/odp_ring_u64_internal.h \
${top_srcdir}/platform/linux-generic/include/odp_schedule_if.h \
${top_srcdir}/platform/linux-generic/include/odp_sorted_list_internal.h \
+ ${top_srcdir}/platform/linux-generic/include/odp_string_internal.h \
${top_srcdir}/platform/linux-generic/include/odp_sysinfo_internal.h \
include/odp_shm_internal.h \
include/odp_thread_internal.h \
@@ -184,13 +184,13 @@ noinst_HEADERS = \
${top_srcdir}/platform/linux-generic/include/odp_traffic_mngr_internal.h \
${top_srcdir}/platform/linux-generic/include/odp_types_internal.h \
include/odp_event_vector_internal.h \
- include/protocols/eth.h \
- include/protocols/ip.h \
- include/protocols/ipsec.h \
- include/protocols/sctp.h \
- include/protocols/tcp.h \
- include/protocols/thash.h \
- include/protocols/udp.h \
+ ${top_srcdir}/platform/linux-generic/include/protocols/eth.h \
+ ${top_srcdir}/platform/linux-generic/include/protocols/ip.h \
+ ${top_srcdir}/platform/linux-generic/include/protocols/ipsec.h \
+ ${top_srcdir}/platform/linux-generic/include/protocols/sctp.h \
+ ${top_srcdir}/platform/linux-generic/include/protocols/tcp.h \
+ ${top_srcdir}/platform/linux-generic/include/protocols/thash.h \
+ ${top_srcdir}/platform/linux-generic/include/protocols/udp.h \
Makefile.inc
BUILT_SOURCES = \
@@ -231,7 +231,6 @@ __LIB__libodp_dpdk_la_SOURCES = \
../linux-generic/pktio/loop.c \
../linux-generic/pktio/null.c \
../linux-generic/odp_pkt_queue.c \
- ../linux-generic/odp_print.c \
odp_pool.c \
odp_queue_basic.c \
odp_queue_eventdev.c \
@@ -249,6 +248,7 @@ __LIB__libodp_dpdk_la_SOURCES = \
../linux-generic/odp_sorted_list.c \
../linux-generic/odp_stash.c \
../linux-generic/odp_std.c \
+ ../linux-generic/odp_string.c \
odp_system_info.c \
../linux-generic/odp_pcapng.c \
odp_thread.c \
@@ -425,7 +425,7 @@ __LIB__libodp_dpdk_la_LIBADD += $(PTHREAD_LIBS)
__LIB__libodp_dpdk_la_LIBADD += $(TIMER_LIBS)
__LIB__libodp_dpdk_la_LIBADD += $(ORT_LIBS)
-CHECK_GLOBALS_REGEX = " (odp_|_odp_|_deprecated_odp_|miniz_|mz_|tdefl_|tinfl_|mp_hdlr_init_odp_pool_ops)"
+CHECK_GLOBALS_REGEX = " (odp_|_odp_|_deprecated_odp_|miniz_|mz_|tdefl_|tinfl_|mp_hdlr_init_odp_pool_ops|__odr_asan)"
TESTS_ENVIRONMENT = \
LIBTOOL="$(LIBTOOL)" \
diff --git a/platform/linux-dpdk/README b/platform/linux-dpdk/README
index c0298ab34..8326d6baf 100644
--- a/platform/linux-dpdk/README
+++ b/platform/linux-dpdk/README
@@ -1,9 +1,6 @@
-Copyright (c) 2018-2019, Linaro Limited
-Copyright (c) 2019-2024, Nokia
-All rights reserved.
-
-SPDX-License-Identifier: BSD-3-Clause
-
+SPDX-License-Identifier: BSD-3-Clause
+Copyright (c) 2018-2019 Linaro Limited
+Copyright (c) 2019-2024 Nokia
1. Rationale
=================================================
diff --git a/platform/linux-dpdk/arch/aarch64/odp/api/abi/cpu.h b/platform/linux-dpdk/arch/aarch64/odp/api/abi/cpu.h
index 35d59f108..96ada8d97 100644
--- a/platform/linux-dpdk/arch/aarch64/odp/api/abi/cpu.h
+++ b/platform/linux-dpdk/arch/aarch64/odp/api/abi/cpu.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2021, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_API_ABI_CPU_H_
diff --git a/platform/linux-dpdk/arch/arm/odp/api/abi/cpu.h b/platform/linux-dpdk/arch/arm/odp/api/abi/cpu.h
index 6644a1ed3..ace4e2640 100644
--- a/platform/linux-dpdk/arch/arm/odp/api/abi/cpu.h
+++ b/platform/linux-dpdk/arch/arm/odp/api/abi/cpu.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_API_ABI_CPU_H_
diff --git a/platform/linux-dpdk/arch/default/odp/api/abi/cpu.h b/platform/linux-dpdk/arch/default/odp/api/abi/cpu.h
index e4fe6f631..0e6fdfa38 100644
--- a/platform/linux-dpdk/arch/default/odp/api/abi/cpu.h
+++ b/platform/linux-dpdk/arch/default/odp/api/abi/cpu.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_API_ABI_CPU_H_
diff --git a/platform/linux-dpdk/arch/powerpc/odp/api/abi/cpu.h b/platform/linux-dpdk/arch/powerpc/odp/api/abi/cpu.h
index 7b7720a42..bfdd7dce0 100644
--- a/platform/linux-dpdk/arch/powerpc/odp/api/abi/cpu.h
+++ b/platform/linux-dpdk/arch/powerpc/odp/api/abi/cpu.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_API_ABI_CPU_H_
diff --git a/platform/linux-dpdk/arch/x86/odp/api/abi/cpu.h b/platform/linux-dpdk/arch/x86/odp/api/abi/cpu.h
index 6644a1ed3..ace4e2640 100644
--- a/platform/linux-dpdk/arch/x86/odp/api/abi/cpu.h
+++ b/platform/linux-dpdk/arch/x86/odp/api/abi/cpu.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_API_ABI_CPU_H_
diff --git a/platform/linux-dpdk/doc/platform_specific.dox b/platform/linux-dpdk/doc/platform_specific.dox
index ad3126e20..2c964f33d 100644
--- a/platform/linux-dpdk/doc/platform_specific.dox
+++ b/platform/linux-dpdk/doc/platform_specific.dox
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-dpdk/include-abi/odp/api/abi/packet.h b/platform/linux-dpdk/include-abi/odp/api/abi/packet.h
index 913181b7a..bfd2176c9 100644
--- a/platform/linux-dpdk/include-abi/odp/api/abi/packet.h
+++ b/platform/linux-dpdk/include-abi/odp/api/abi/packet.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-dpdk/include-abi/odp/api/abi/packet_types.h b/platform/linux-dpdk/include-abi/odp/api/abi/packet_types.h
index 9ca66db54..e66ad11f2 100644
--- a/platform/linux-dpdk/include-abi/odp/api/abi/packet_types.h
+++ b/platform/linux-dpdk/include-abi/odp/api/abi/packet_types.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
/**
diff --git a/platform/linux-dpdk/include/odp/api/plat/buffer_inlines.h b/platform/linux-dpdk/include/odp/api/plat/buffer_inlines.h
index 1740c36b3..aec041500 100644
--- a/platform/linux-dpdk/include/odp/api/plat/buffer_inlines.h
+++ b/platform/linux-dpdk/include/odp/api/plat/buffer_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2019-2023 Nokia
*/
#ifndef ODP_PLAT_BUFFER_INLINES_H_
diff --git a/platform/linux-dpdk/include/odp/api/plat/byteorder_inlines.h b/platform/linux-dpdk/include/odp/api/plat/byteorder_inlines.h
index 3fdb5179c..54e4dde70 100644
--- a/platform/linux-dpdk/include/odp/api/plat/byteorder_inlines.h
+++ b/platform/linux-dpdk/include/odp/api/plat/byteorder_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
/**
diff --git a/platform/linux-dpdk/include/odp/api/plat/event_inline_types.h b/platform/linux-dpdk/include/odp/api/plat/event_inline_types.h
index 94a95a889..689743cbc 100644
--- a/platform/linux-dpdk/include/odp/api/plat/event_inline_types.h
+++ b/platform/linux-dpdk/include/odp/api/plat/event_inline_types.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_EVENT_INLINE_TYPES_H_
diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_flag_inlines.h b/platform/linux-dpdk/include/odp/api/plat/packet_flag_inlines.h
index b6876e6d7..799a8c42c 100644
--- a/platform/linux-dpdk/include/odp/api/plat/packet_flag_inlines.h
+++ b/platform/linux-dpdk/include/odp/api/plat/packet_flag_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
/**
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 255db9d78..38e8d9d88 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
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2022-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2022-2023 Nokia
*/
/**
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 b41a272ef..627ed1d44 100644
--- a/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
+++ b/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2019-2024 Nokia
*/
/**
@@ -61,6 +59,7 @@ extern "C" {
#define odp_packet_data_seg_len __odp_packet_data_seg_len
#define odp_packet_len __odp_packet_len
#define odp_packet_buf_len __odp_packet_buf_len
+ #define odp_packet_reset_max_len __odp_packet_reset_max_len
#define odp_packet_headroom __odp_packet_headroom
#define odp_packet_tailroom __odp_packet_tailroom
#define odp_packet_pool __odp_packet_pool
@@ -187,6 +186,11 @@ _ODP_INLINE uint32_t odp_packet_buf_len(odp_packet_t pkt)
return (uint32_t)(mb->nb_segs * mb->buf_len);
}
+_ODP_INLINE uint32_t odp_packet_reset_max_len(odp_packet_t pkt)
+{
+ return odp_packet_buf_len(pkt) - RTE_PKTMBUF_HEADROOM;
+}
+
_ODP_INLINE void *odp_packet_data_seg_len(odp_packet_t pkt,
uint32_t *seg_len)
{
diff --git a/platform/linux-dpdk/include/odp/api/plat/std_inlines.h b/platform/linux-dpdk/include/odp/api/plat/std_inlines.h
index b52b0512a..9c719bed0 100644
--- a/platform/linux-dpdk/include/odp/api/plat/std_inlines.h
+++ b/platform/linux-dpdk/include/odp/api/plat/std_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#ifndef ODP_PLAT_STD_INLINE_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 f3d2a6947..3b4d9cc10 100644
--- a/platform/linux-dpdk/include/odp/api/plat/time_inlines.h
+++ b/platform/linux-dpdk/include/odp/api/plat/time_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2020-2024, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2020-2024 Nokia
*/
#ifndef ODP_PLAT_TIME_INLINES_H_
diff --git a/platform/linux-dpdk/include/odp/api/plat/timer_inline_types.h b/platform/linux-dpdk/include/odp/api/plat/timer_inline_types.h
index 6c997e80d..ddfc380f3 100644
--- a/platform/linux-dpdk/include/odp/api/plat/timer_inline_types.h
+++ b/platform/linux-dpdk/include/odp/api/plat/timer_inline_types.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_TIMER_INLINE_TYPES_H_
diff --git a/platform/linux-dpdk/include/odp/api/plat/timer_inlines.h b/platform/linux-dpdk/include/odp/api/plat/timer_inlines.h
index a85c7582d..b59d65a8e 100644
--- a/platform/linux-dpdk/include/odp/api/plat/timer_inlines.h
+++ b/platform/linux-dpdk/include/odp/api/plat/timer_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022-2024, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022-2024 Nokia
*/
#ifndef ODP_PLAT_TIMER_INLINES_H_
diff --git a/platform/linux-dpdk/include/odp_buffer_internal.h b/platform/linux-dpdk/include/odp_buffer_internal.h
index cb7f50073..760c5ca2f 100644
--- a/platform/linux-dpdk/include/odp_buffer_internal.h
+++ b/platform/linux-dpdk/include/odp_buffer_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
/**
diff --git a/platform/linux-dpdk/include/odp_config_internal.h b/platform/linux-dpdk/include/odp_config_internal.h
index c423ec14b..70b2e14df 100644
--- a/platform/linux-dpdk/include/odp_config_internal.h
+++ b/platform/linux-dpdk/include/odp_config_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2020-2023 Nokia
*/
#ifndef ODP_CONFIG_INTERNAL_H_
diff --git a/platform/linux-dpdk/include/odp_errno_define.h b/platform/linux-dpdk/include/odp_errno_define.h
index 9f9486267..44f15a11c 100644
--- a/platform/linux-dpdk/include/odp_errno_define.h
+++ b/platform/linux-dpdk/include/odp_errno_define.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
/**
diff --git a/platform/linux-dpdk/include/odp_event_internal.h b/platform/linux-dpdk/include/odp_event_internal.h
index cbe6d960b..5a1b9c02e 100644
--- a/platform/linux-dpdk/include/odp_event_internal.h
+++ b/platform/linux-dpdk/include/odp_event_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021-2023 Nokia
*/
/**
diff --git a/platform/linux-dpdk/include/odp_event_vector_internal.h b/platform/linux-dpdk/include/odp_event_vector_internal.h
index 0d4cd9048..572e687b1 100644
--- a/platform/linux-dpdk/include/odp_event_vector_internal.h
+++ b/platform/linux-dpdk/include/odp_event_vector_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020-2023 Nokia
*/
/**
diff --git a/platform/linux-dpdk/include/odp_eventdev_internal.h b/platform/linux-dpdk/include/odp_eventdev_internal.h
index a36b85ff5..68a3b6a91 100644
--- a/platform/linux-dpdk/include/odp_eventdev_internal.h
+++ b/platform/linux-dpdk/include/odp_eventdev_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2019, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2019 Nokia
*/
/**
diff --git a/platform/linux-dpdk/include/odp_packet_internal.h b/platform/linux-dpdk/include/odp_packet_internal.h
index cae77245a..a00212541 100644
--- a/platform/linux-dpdk/include/odp_packet_internal.h
+++ b/platform/linux-dpdk/include/odp_packet_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
/**
diff --git a/platform/linux-dpdk/include/odp_packet_io_internal.h b/platform/linux-dpdk/include/odp_packet_io_internal.h
index bab750a22..781e07c96 100644
--- a/platform/linux-dpdk/include/odp_packet_io_internal.h
+++ b/platform/linux-dpdk/include/odp_packet_io_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2023 Nokia
*/
/**
diff --git a/platform/linux-dpdk/include/odp_pool_internal.h b/platform/linux-dpdk/include/odp_pool_internal.h
index b8fd17314..f8be1f026 100644
--- a/platform/linux-dpdk/include/odp_pool_internal.h
+++ b/platform/linux-dpdk/include/odp_pool_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
/**
diff --git a/platform/linux-dpdk/include/odp_posix_extensions.h b/platform/linux-dpdk/include/odp_posix_extensions.h
deleted file mode 120000
index 420e11dd9..000000000
--- a/platform/linux-dpdk/include/odp_posix_extensions.h
+++ /dev/null
@@ -1 +0,0 @@
-../../linux-generic/include/odp_posix_extensions.h \ No newline at end of file
diff --git a/platform/linux-dpdk/include/odp_ptr_ring_mpmc_internal.h b/platform/linux-dpdk/include/odp_ptr_ring_mpmc_internal.h
index 3e56c7f0e..4f7ecc2c3 100644
--- a/platform/linux-dpdk/include/odp_ptr_ring_mpmc_internal.h
+++ b/platform/linux-dpdk/include/odp_ptr_ring_mpmc_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_RING_MPMC_INTERNAL_H_
diff --git a/platform/linux-dpdk/include/odp_ptr_ring_spsc_internal.h b/platform/linux-dpdk/include/odp_ptr_ring_spsc_internal.h
index 3680f087a..0c158f83b 100644
--- a/platform/linux-dpdk/include/odp_ptr_ring_spsc_internal.h
+++ b/platform/linux-dpdk/include/odp_ptr_ring_spsc_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_RING_SPSC_INTERNAL_H_
diff --git a/platform/linux-dpdk/include/odp_ptr_ring_st_internal.h b/platform/linux-dpdk/include/odp_ptr_ring_st_internal.h
index cc258aeb4..e11d9f205 100644
--- a/platform/linux-dpdk/include/odp_ptr_ring_st_internal.h
+++ b/platform/linux-dpdk/include/odp_ptr_ring_st_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_RING_ST_INTERNAL_H_
diff --git a/platform/linux-dpdk/include/odp_queue_basic_internal.h b/platform/linux-dpdk/include/odp_queue_basic_internal.h
index 4e693d9b0..e3da311d3 100644
--- a/platform/linux-dpdk/include/odp_queue_basic_internal.h
+++ b/platform/linux-dpdk/include/odp_queue_basic_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_QUEUE_BASIC_INTERNAL_H_
diff --git a/platform/linux-dpdk/include/odp_shm_internal.h b/platform/linux-dpdk/include/odp_shm_internal.h
index b83b63a91..a19fb92f4 100644
--- a/platform/linux-dpdk/include/odp_shm_internal.h
+++ b/platform/linux-dpdk/include/odp_shm_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-dpdk/include/odp_thread_internal.h b/platform/linux-dpdk/include/odp_thread_internal.h
index 6342cc420..089db05f9 100644
--- a/platform/linux-dpdk/include/odp_thread_internal.h
+++ b/platform/linux-dpdk/include/odp_thread_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_THREAD_INTERNAL_H_
diff --git a/platform/linux-dpdk/include/odp_timer_internal.h b/platform/linux-dpdk/include/odp_timer_internal.h
index 35a4911af..2a1aed312 100644
--- a/platform/linux-dpdk/include/odp_timer_internal.h
+++ b/platform/linux-dpdk/include/odp_timer_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
/**
diff --git a/platform/linux-dpdk/include/protocols b/platform/linux-dpdk/include/protocols
deleted file mode 120000
index 39a0a7ad1..000000000
--- a/platform/linux-dpdk/include/protocols
+++ /dev/null
@@ -1 +0,0 @@
-../../linux-generic/include/protocols \ No newline at end of file
diff --git a/platform/linux-dpdk/m4/configure.m4 b/platform/linux-dpdk/m4/configure.m4
index 535cfc5fa..3faea267b 100644
--- a/platform/linux-dpdk/m4/configure.m4
+++ b/platform/linux-dpdk/m4/configure.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2015 Linaro Limited
+#
+
ODP_IMPLEMENTATION_NAME="odp-dpdk"
ODP_LIB_NAME="odp-dpdk"
@@ -101,7 +105,6 @@ AC_CONFIG_FILES([platform/linux-dpdk/Makefile
platform/linux-dpdk/test/Makefile
platform/linux-dpdk/test/example/Makefile
platform/linux-dpdk/test/example/classifier/Makefile
- platform/linux-dpdk/test/example/generator/Makefile
platform/linux-dpdk/test/example/ipsec_api/Makefile
platform/linux-dpdk/test/example/ipsec_crypto/Makefile
platform/linux-dpdk/test/example/l2fwd_simple/Makefile
diff --git a/platform/linux-dpdk/m4/odp_libconfig.m4 b/platform/linux-dpdk/m4/odp_libconfig.m4
index 2bf89ac2e..d2e4401de 100644
--- a/platform/linux-dpdk/m4/odp_libconfig.m4
+++ b/platform/linux-dpdk/m4/odp_libconfig.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Nokia
+#
+
##########################################################################
# Configuration file version
##########################################################################
diff --git a/platform/linux-dpdk/odp_buffer.c b/platform/linux-dpdk/odp_buffer.c
index 6cabe41e2..e8bf2f100 100644
--- a/platform/linux-dpdk/odp_buffer.c
+++ b/platform/linux-dpdk/odp_buffer.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2021-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2021-2022 Nokia
*/
#include <odp/api/align.h>
@@ -13,7 +11,7 @@
#include <odp_buffer_internal.h>
#include <odp_debug_internal.h>
#include <odp_pool_internal.h>
-#include <odp_print_internal.h>
+#include <odp_string_internal.h>
#include <string.h>
#include <stdio.h>
diff --git a/platform/linux-dpdk/odp_crypto.c b/platform/linux-dpdk/odp_crypto.c
index 6170dd8df..5ce9699f3 100644
--- a/platform/linux-dpdk/odp_crypto.c
+++ b/platform/linux-dpdk/odp_crypto.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2018-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2018-2023 Nokia
*/
#include <odp_posix_extensions.h>
@@ -756,7 +754,7 @@ static int cipher_aead_capability(odp_cipher_alg_t cipher,
odp_crypto_cipher_capability_t dst[],
int num_copy)
{
- odp_crypto_cipher_capability_t src[num_copy];
+ odp_crypto_cipher_capability_t src[_ODP_MAX(num_copy, 1)];
int idx = 0, rc = 0;
int size = sizeof(odp_crypto_cipher_capability_t);
@@ -794,7 +792,8 @@ static int cipher_aead_capability(odp_cipher_alg_t cipher,
if (idx < num_copy)
num_copy = idx;
- memcpy(dst, src, num_copy * size);
+ if (dst)
+ memcpy(dst, src, num_copy * size);
return idx;
}
@@ -803,7 +802,7 @@ static int cipher_capability(odp_cipher_alg_t cipher,
odp_crypto_cipher_capability_t dst[],
int num_copy)
{
- odp_crypto_cipher_capability_t src[num_copy];
+ odp_crypto_cipher_capability_t src[_ODP_MAX(num_copy, 1)];
int idx = 0, rc = 0;
int size = sizeof(odp_crypto_cipher_capability_t);
uint8_t cdev_id, cdev_count;
@@ -840,7 +839,8 @@ static int cipher_capability(odp_cipher_alg_t cipher,
if (idx < num_copy)
num_copy = idx;
- memcpy(dst, src, num_copy * size);
+ if (dst)
+ memcpy(dst, src, num_copy * size);
return idx;
}
@@ -956,7 +956,7 @@ static int auth_aead_capability(odp_auth_alg_t auth,
odp_crypto_auth_capability_t dst[],
int num_copy)
{
- odp_crypto_auth_capability_t src[num_copy];
+ odp_crypto_auth_capability_t src[_ODP_MAX(num_copy, 1)];
int idx = 0, rc = 0;
int size = sizeof(odp_crypto_auth_capability_t);
@@ -996,7 +996,8 @@ static int auth_aead_capability(odp_auth_alg_t auth,
if (idx < num_copy)
num_copy = idx;
- memcpy(dst, src, num_copy * size);
+ if (dst)
+ memcpy(dst, src, num_copy * size);
return idx;
}
@@ -1005,7 +1006,7 @@ static int auth_capability(odp_auth_alg_t auth,
odp_crypto_auth_capability_t dst[],
int num_copy)
{
- odp_crypto_auth_capability_t src[num_copy];
+ odp_crypto_auth_capability_t src[_ODP_MAX(num_copy, 1)];
int idx = 0, rc = 0;
int size = sizeof(odp_crypto_auth_capability_t);
uint8_t cdev_id, cdev_count;
@@ -1084,7 +1085,8 @@ static int auth_capability(odp_auth_alg_t auth,
if (idx < num_copy)
num_copy = idx;
- memcpy(dst, src, num_copy * size);
+ if (dst)
+ memcpy(dst, src, num_copy * size);
return idx;
}
@@ -1736,9 +1738,11 @@ static void crypto_fill_sym_param(const crypto_session_entry_t *session,
_ODP_ASSERT(cipher_iv_len == 0 || param->cipher_iv_ptr != NULL);
_ODP_ASSERT(auth_iv_len == 0 || param->auth_iv_ptr != NULL);
- iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET);
- memcpy(iv_ptr, param->cipher_iv_ptr, cipher_iv_len);
+ if (cipher_iv_len > 0) {
+ iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET);
+ memcpy(iv_ptr, param->cipher_iv_ptr, cipher_iv_len);
+ }
if (odp_unlikely(auth_iv_len > 0)) {
iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET + MAX_IV_LENGTH);
memcpy(iv_ptr, param->auth_iv_ptr, auth_iv_len);
diff --git a/platform/linux-dpdk/odp_dma.c b/platform/linux-dpdk/odp_dma.c
index 0a470ea23..40f294304 100644
--- a/platform/linux-dpdk/odp_dma.c
+++ b/platform/linux-dpdk/odp_dma.c
@@ -28,6 +28,7 @@
#include <odp_pool_internal.h>
#include <odp_queue_if.h>
#include <odp_schedule_if.h>
+#include <odp_string_internal.h>
#include <rte_dmadev.h>
#include <rte_mbuf_core.h>
@@ -541,10 +542,8 @@ odp_dma_t odp_dma_create(const char *name, const odp_dma_param_t *param)
session->is_mt = param->mt_mode == ODP_DMA_MT_SAFE;
session->name[0] = 0;
- if (name) {
- strncpy(session->name, name, ODP_DMA_NAME_LEN - 1);
- session->name[ODP_DMA_NAME_LEN - 1] = 0;
- }
+ if (name)
+ _odp_strcpy(session->name, name, ODP_DMA_NAME_LEN);
return (odp_dma_t)session;
}
diff --git a/platform/linux-dpdk/odp_errno.c b/platform/linux-dpdk/odp_errno.c
index 2f03ee898..433129efb 100644
--- a/platform/linux-dpdk/odp_errno.c
+++ b/platform/linux-dpdk/odp_errno.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <odp/api/errno.h>
diff --git a/platform/linux-dpdk/odp_event.c b/platform/linux-dpdk/odp_event.c
index 0c2f3d22e..761c78cfd 100644
--- a/platform/linux-dpdk/odp_event.c
+++ b/platform/linux-dpdk/odp_event.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2020-2023 Nokia
*/
#include <odp/api/event.h>
diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c
index 79c449f1d..0e855524e 100644
--- a/platform/linux-dpdk/odp_init.c
+++ b/platform/linux-dpdk/odp_init.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2023 Nokia
*/
#include <odp_posix_extensions.h>
@@ -28,6 +26,7 @@
#include <rte_config.h>
#include <rte_debug.h>
#include <rte_eal.h>
+#include <rte_errno.h>
#include <rte_string_fns.h>
enum init_stage {
@@ -221,6 +220,8 @@ static int _odp_init_dpdk(const char *cmdline)
_ODP_ERR("Error reading PCI config\n");
return -1;
}
+ if (pci_cmd != NULL)
+ pci_str = pci_cmd;
/* Read any additional EAL command string from config */
ealcmdlen = read_eal_cmdstr(&eal_cmd);
@@ -230,15 +231,12 @@ static int _odp_init_dpdk(const char *cmdline)
free(pci_cmd);
return -1;
}
- cmdlen = snprintf(NULL, 0, "odpdpdk --legacy-mem -m %" PRIu32 " %s ", mem_prealloc,
- cmdline) + pcicmdlen + ealcmdlen;
-
- if (pci_cmd != NULL)
- pci_str = pci_cmd;
-
if (eal_cmd != NULL)
eal_str = eal_cmd;
+ cmdlen = snprintf(NULL, 0, "odpdpdk --legacy-mem -m %" PRIu32 " %s %s %s",
+ mem_prealloc, cmdline, pci_str, eal_str);
+
char full_cmdline[cmdlen];
/* First argument is facility log, simply bind it to odpdpdk for now. In
@@ -271,7 +269,7 @@ static int _odp_init_dpdk(const char *cmdline)
i = rte_eal_init(dpdk_argc, dpdk_argv);
if (i < 0) {
- _ODP_ERR("Cannot init the Intel DPDK EAL!\n");
+ _ODP_ERR("DPDK EAL init failed: %s\n", rte_strerror(rte_errno));
return -1;
} else if (i + 1 != dpdk_argc) {
_ODP_DBG("Some DPDK args were not processed!\n");
diff --git a/platform/linux-dpdk/odp_packet.c b/platform/linux-dpdk/odp_packet.c
index bcd2c2fb3..e08654d93 100644
--- a/platform/linux-dpdk/odp_packet.c
+++ b/platform/linux-dpdk/odp_packet.c
@@ -1,13 +1,12 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2024 Nokia
*/
#include <odp/api/align.h>
#include <odp/api/buffer.h>
#include <odp/api/byteorder.h>
+#include <odp/api/cpu.h>
#include <odp/api/hash.h>
#include <odp/api/hints.h>
#include <odp/api/packet.h>
@@ -30,7 +29,7 @@
#include <odp_packet_io_internal.h>
#include <odp_parse_internal.h>
#include <odp_pool_internal.h>
-#include <odp_print_internal.h>
+#include <odp_string_internal.h>
#include <rte_version.h>
@@ -128,6 +127,14 @@ static inline int num_segments(uint32_t len, uint32_t seg_len)
return num;
}
+static inline void packet_reset_md(odp_packet_hdr_t *pkt_hdr, struct rte_mbuf *mb)
+{
+ mb->port = 0xff;
+ mb->vlan_tci = 0;
+
+ packet_init(pkt_hdr, ODP_PKTIO_INVALID);
+}
+
static inline int packet_reset(odp_packet_t pkt, uint32_t len)
{
odp_packet_hdr_t *const pkt_hdr = packet_hdr(pkt);
@@ -135,12 +142,10 @@ static inline int packet_reset(odp_packet_t pkt, uint32_t len)
uint8_t nb_segs = 0;
int32_t lenleft = len;
- packet_init(pkt_hdr, ODP_PKTIO_INVALID);
+ packet_reset_md(pkt_hdr, mb);
- mb->port = 0xff;
mb->pkt_len = len;
mb->data_off = RTE_PKTMBUF_HEADROOM;
- mb->vlan_tci = 0;
nb_segs = 1;
if (RTE_PKTMBUF_HEADROOM + lenleft <= mb->buf_len) {
@@ -318,18 +323,19 @@ int odp_packet_alloc_multi(odp_pool_t pool_hdl, uint32_t len,
int odp_packet_reset(odp_packet_t pkt, uint32_t len)
{
- if (odp_unlikely(len == 0))
+ if (odp_unlikely(len == 0 || len > odp_packet_reset_max_len(pkt)))
return -1;
- if (RTE_PKTMBUF_HEADROOM + len > odp_packet_buf_len(pkt)) {
- _ODP_DBG("Not enough head room for that packet %d/%d\n",
- RTE_PKTMBUF_HEADROOM + len, odp_packet_buf_len(pkt));
- return -1;
- }
-
return packet_reset(pkt, len);
}
+void odp_packet_reset_meta(odp_packet_t pkt)
+{
+ odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
+
+ packet_reset_md(pkt_hdr, &pkt_hdr->mb);
+}
+
int odp_event_filter_packet(const odp_event_t event[],
odp_packet_t packet[],
odp_event_t remain[], int num)
diff --git a/platform/linux-dpdk/odp_packet_dpdk.c b/platform/linux-dpdk/odp_packet_dpdk.c
index da76db06d..776cc24ac 100644
--- a/platform/linux-dpdk/odp_packet_dpdk.c
+++ b/platform/linux-dpdk/odp_packet_dpdk.c
@@ -1,12 +1,11 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2023 Nokia
*/
#include <odp_posix_extensions.h>
+#include <odp/api/cpu.h>
#include <odp/api/hints.h>
#include <odp/api/packet.h>
#include <odp/api/packet_io.h>
@@ -26,6 +25,7 @@
#include <odp_packet_internal.h>
#include <odp_packet_io_internal.h>
#include <odp_pool_internal.h>
+#include <odp_string_internal.h>
#include <protocols/eth.h>
#include <rte_config.h>
@@ -104,6 +104,8 @@
#define IXGBE_DRV_NAME "net_ixgbe"
#define I40E_DRV_NAME "net_i40e"
+#define PCAP_DRV_NAME "net_pcap"
+
/* Minimum RX burst size */
#define DPDK_MIN_RX_BURST 4
@@ -890,14 +892,20 @@ static int dpdk_start(pktio_entry_t *pktio_entry)
pktio_entry->state == PKTIO_STATE_STOP_PENDING)
rte_eth_dev_stop(pkt_dpdk->port_id);
- /* DPDK doesn't support nb_rx_q/nb_tx_q being 0 */
- if (!pktio_entry->num_in_queue)
- pktio_entry->num_in_queue = 1;
- if (!pktio_entry->num_out_queue)
- pktio_entry->num_out_queue = 1;
-
rte_eth_dev_info_get(port_id, &dev_info);
+ /* Pcap driver reconfiguration may fail if number of rx/tx queues is set to zero */
+ if (!strncmp(dev_info.driver_name, PCAP_DRV_NAME, strlen(PCAP_DRV_NAME))) {
+ if (!pktio_entry->num_in_queue) {
+ pktio_entry->num_in_queue = 1;
+ pkt_dpdk->num_rx_desc[0] = dev_info.rx_desc_lim.nb_min;
+ }
+ if (!pktio_entry->num_out_queue) {
+ pktio_entry->num_out_queue = 1;
+ pkt_dpdk->num_tx_desc[0] = dev_info.tx_desc_lim.nb_min;
+ }
+ }
+
/* Setup device */
if (dpdk_setup_eth_dev(pktio_entry, &dev_info)) {
_ODP_ERR("Failed to configure device\n");
@@ -1551,8 +1559,7 @@ static int dpdk_extra_stat_info(pktio_entry_t *pktio_entry,
num_stats = ret;
for (i = 0; i < num && i < num_stats; i++)
- strncpy(info[i].name, xstats_names[i].name,
- ODP_PKTIO_STATS_EXTRA_NAME_LEN - 1);
+ _odp_strcpy(info[i].name, xstats_names[i].name, ODP_PKTIO_STATS_EXTRA_NAME_LEN);
return num_stats;
}
diff --git a/platform/linux-dpdk/odp_packet_flags.c b/platform/linux-dpdk/odp_packet_flags.c
index 345ac8488..3856aba4f 100644
--- a/platform/linux-dpdk/odp_packet_flags.c
+++ b/platform/linux-dpdk/odp_packet_flags.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
*/
#include <odp/api/plat/packet_flag_inlines.h>
diff --git a/platform/linux-dpdk/odp_pool.c b/platform/linux-dpdk/odp_pool.c
index dfd14a978..8b15518c9 100644
--- a/platform/linux-dpdk/odp_pool.c
+++ b/platform/linux-dpdk/odp_pool.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2023 Nokia
*/
#include <odp/api/align.h>
@@ -24,6 +22,7 @@
#include <odp_macros_internal.h>
#include <odp_packet_internal.h>
#include <odp_pool_internal.h>
+#include <odp_string_internal.h>
#include <odp_timer_internal.h>
#include <rte_config.h>
@@ -57,8 +56,9 @@
/* Pool name format */
#define POOL_NAME_FORMAT "%" PRIu64 "-%d-%s"
-/* Define a practical limit for contiguous memory allocations */
-#define MAX_SIZE (CONFIG_PACKET_SEG_SIZE - CONFIG_BUFFER_ALIGN_MIN)
+/* Default alignment for buffers */
+#define BUFFER_ALIGN_DEFAULT ODP_CACHE_LINE_SIZE
+ODP_STATIC_ASSERT(_ODP_CHECK_IS_POWER2(BUFFER_ALIGN_DEFAULT), "Buffer align must be power of two");
/* Maximum packet user area size */
#define MAX_UAREA_SIZE 2048
@@ -263,7 +263,8 @@ int odp_pool_capability(odp_pool_capability_t *capa)
/* Buffer pools */
capa->buf.max_pools = max_pools;
capa->buf.max_align = CONFIG_BUFFER_ALIGN_MAX;
- capa->buf.max_size = MAX_SIZE;
+ capa->buf.max_size = _ODP_ROUNDDOWN_POWER2(CONFIG_PACKET_SEG_SIZE, BUFFER_ALIGN_DEFAULT) -
+ _ODP_EV_ENDMARK_SIZE;
capa->buf.max_num = CONFIG_POOL_MAX_NUM;
capa->buf.max_uarea_size = MAX_UAREA_SIZE;
capa->buf.uarea_persistence = true;
@@ -274,8 +275,8 @@ int odp_pool_capability(odp_pool_capability_t *capa)
/* Packet pools */
capa->pkt.max_align = CONFIG_BUFFER_ALIGN_MIN;
capa->pkt.max_pools = max_pools;
- capa->pkt.max_len = CONFIG_PACKET_MAX_SEG_LEN;
- capa->pkt.max_num = _odp_pool_glb->config.pkt_max_num;
+ capa->pkt.max_len = CONFIG_PACKET_MAX_SEG_LEN - _ODP_EV_ENDMARK_SIZE;
+ capa->pkt.max_num = _odp_pool_glb->config.pkt_max_num;
capa->pkt.min_headroom = RTE_PKTMBUF_HEADROOM;
capa->pkt.max_headroom = RTE_PKTMBUF_HEADROOM;
capa->pkt.min_tailroom = CONFIG_PACKET_TAILROOM;
@@ -657,7 +658,6 @@ static void init_obj_priv_data(struct rte_mempool *mp ODP_UNUSED, void *arg, voi
}
}
-
odp_pool_t _odp_pool_create(const char *name, const odp_pool_param_t *params,
odp_pool_type_t type_2)
{
@@ -677,14 +677,14 @@ odp_pool_t _odp_pool_create(const char *name, const odp_pool_param_t *params,
priv_data.type = params->type;
if (name)
- strncpy(pool->name, name, ODP_POOL_NAME_LEN - 1);
+ _odp_strcpy(pool->name, name, ODP_POOL_NAME_LEN);
switch (params->type) {
case ODP_POOL_BUFFER:
num = params->buf.num;
cache_size = params->buf.cache_size;
priv_size = get_mbuf_priv_size(sizeof(odp_buffer_hdr_t));
- align = params->buf.align > 0 ? params->buf.align : ODP_CACHE_LINE_SIZE;
+ align = params->buf.align > 0 ? params->buf.align : BUFFER_ALIGN_DEFAULT;
align = _ODP_MAX(align, (uint32_t)CONFIG_BUFFER_ALIGN_MIN);
data_size = _ODP_ROUNDUP_ALIGN(params->buf.size + trailer, align);
uarea_size = params->buf.uarea_size;
@@ -1118,7 +1118,7 @@ int odp_pool_ext_capability(odp_pool_type_t type,
capa->stats.all = supported_stats.all;
capa->pkt.max_num_buf = _odp_pool_glb->config.pkt_max_num;
- capa->pkt.max_buf_size = MAX_SIZE;
+ capa->pkt.max_buf_size = CONFIG_PACKET_SEG_SIZE - CONFIG_BUFFER_ALIGN_MIN;
capa->pkt.odp_header_size = SIZEOF_OBJHDR + sizeof(odp_packet_hdr_t);
capa->pkt.odp_trailer_size = _ODP_EV_ENDMARK_SIZE;
capa->pkt.min_mem_align = ODP_CACHE_LINE_SIZE;
@@ -1216,12 +1216,10 @@ odp_pool_t odp_pool_ext_create(const char *name,
if (check_pool_ext_param(params))
return ODP_POOL_INVALID;
- if (name == NULL) {
+ if (name == NULL)
pool_name[0] = 0;
- } else {
- strncpy(pool_name, name, ODP_POOL_NAME_LEN - 1);
- pool_name[ODP_POOL_NAME_LEN - 1] = 0;
- }
+ else
+ _odp_strcpy(pool_name, name, ODP_POOL_NAME_LEN);
/* Find an unused buffer pool slot and initialize it as requested */
for (i = 0; i < CONFIG_POOLS; i++) {
diff --git a/platform/linux-dpdk/odp_queue_basic.c b/platform/linux-dpdk/odp_queue_basic.c
index 4b9dee891..4ee51ee6b 100644
--- a/platform/linux-dpdk/odp_queue_basic.c
+++ b/platform/linux-dpdk/odp_queue_basic.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
#include <odp/api/align.h>
@@ -32,6 +30,7 @@
#include <odp_queue_basic_internal.h>
#include <odp_queue_if.h>
#include <odp_schedule_if.h>
+#include <odp_string_internal.h>
#include <odp_timer_internal.h>
#include <inttypes.h>
@@ -1000,12 +999,11 @@ static int queue_init(queue_entry_t *queue, const char *name,
queue_type = param->type;
- if (name == NULL) {
+ if (name == NULL)
queue->name[0] = 0;
- } else {
- strncpy(queue->name, name, ODP_QUEUE_NAME_LEN - 1);
- queue->name[ODP_QUEUE_NAME_LEN - 1] = 0;
- }
+ else
+ _odp_strcpy(queue->name, name, ODP_QUEUE_NAME_LEN);
+
memcpy(&queue->param, param, sizeof(odp_queue_param_t));
if (queue->param.sched.lock_count > _odp_sched_fn->max_ordered_locks())
return -1;
diff --git a/platform/linux-dpdk/odp_queue_eventdev.c b/platform/linux-dpdk/odp_queue_eventdev.c
index c0928bfd2..8071c1785 100644
--- a/platform/linux-dpdk/odp_queue_eventdev.c
+++ b/platform/linux-dpdk/odp_queue_eventdev.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2019-2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2019-2021 Nokia
*/
#include <odp_eventdev_internal.h>
@@ -20,6 +18,7 @@
#include <odp_libconfig_internal.h>
#include <odp_queue_if.h>
#include <odp_schedule_if.h>
+#include <odp_string_internal.h>
#include <odp_timer_internal.h>
#include <rte_config.h>
@@ -1123,12 +1122,11 @@ static int queue_init(queue_entry_t *queue, const char *name,
queue_type = param->type;
- if (name == NULL) {
+ if (name == NULL)
queue->name[0] = 0;
- } else {
- strncpy(queue->name, name, ODP_QUEUE_NAME_LEN - 1);
- queue->name[ODP_QUEUE_NAME_LEN - 1] = 0;
- }
+ else
+ _odp_strcpy(queue->name, name, ODP_QUEUE_NAME_LEN);
+
memcpy(&queue->param, param, sizeof(odp_queue_param_t));
if (queue->param.sched.lock_count > _odp_sched_fn->max_ordered_locks())
return -1;
diff --git a/platform/linux-dpdk/odp_queue_if.c b/platform/linux-dpdk/odp_queue_if.c
index efe3eb155..856d2f66e 100644
--- a/platform/linux-dpdk/odp_queue_if.c
+++ b/platform/linux-dpdk/odp_queue_if.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2023 Nokia
*/
#include <odp/autoheader_internal.h>
diff --git a/platform/linux-dpdk/odp_queue_spsc.c b/platform/linux-dpdk/odp_queue_spsc.c
index 61dde0ed0..a47d2a4be 100644
--- a/platform/linux-dpdk/odp_queue_spsc.c
+++ b/platform/linux-dpdk/odp_queue_spsc.c
@@ -1,9 +1,8 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
+
#include <odp/api/hints.h>
#include <odp_debug_internal.h>
diff --git a/platform/linux-dpdk/odp_schedule_eventdev.c b/platform/linux-dpdk/odp_schedule_eventdev.c
index 4ef8a51b7..5e13b5ad2 100644
--- a/platform/linux-dpdk/odp_schedule_eventdev.c
+++ b/platform/linux-dpdk/odp_schedule_eventdev.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2019, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2019 Nokia
*/
#include <odp_posix_extensions.h>
@@ -20,6 +18,7 @@
#include <odp_eventdev_internal.h>
#include <odp_packet_io_internal.h>
#include <odp_schedule_if.h>
+#include <odp_string_internal.h>
#include <odp_timer_internal.h>
#include <rte_config.h>
@@ -821,13 +820,10 @@ static odp_schedule_group_t schedule_group_create(const char *name,
if (!_odp_eventdev_gbl->grp[i].allocated) {
char *grp_name = _odp_eventdev_gbl->grp[i].name;
- if (name == NULL) {
+ if (name == NULL)
grp_name[0] = 0;
- } else {
- strncpy(grp_name, name,
- ODP_SCHED_GROUP_NAME_LEN - 1);
- grp_name[ODP_SCHED_GROUP_NAME_LEN - 1] = 0;
- }
+ else
+ _odp_strcpy(grp_name, name, ODP_SCHED_GROUP_NAME_LEN);
grp_update_mask(i, mask);
group = (odp_schedule_group_t)i;
diff --git a/platform/linux-dpdk/odp_schedule_if.c b/platform/linux-dpdk/odp_schedule_if.c
index dbb098e8b..b83de135f 100644
--- a/platform/linux-dpdk/odp_schedule_if.c
+++ b/platform/linux-dpdk/odp_schedule_if.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2021-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2021-2022 Nokia
*/
#include <odp/autoheader_internal.h>
diff --git a/platform/linux-dpdk/odp_shared_memory.c b/platform/linux-dpdk/odp_shared_memory.c
index 398771708..dff52fc55 100644
--- a/platform/linux-dpdk/odp_shared_memory.c
+++ b/platform/linux-dpdk/odp_shared_memory.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
#include <odp_posix_extensions.h>
@@ -18,6 +16,7 @@
#include <odp_global_data.h>
#include <odp_macros_internal.h>
#include <odp_shm_internal.h>
+#include <odp_string_internal.h>
#include <stdio.h>
#include <string.h>
@@ -287,8 +286,12 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align,
}
block->mz = mz;
- snprintf(block->name, ODP_SHM_NAME_LEN, "%s", name);
- block->name[ODP_SHM_NAME_LEN - 1] = 0;
+
+ if (name == NULL)
+ block->name[0] = 0;
+ else
+ _odp_strcpy(block->name, name, ODP_SHM_NAME_LEN);
+
block->type = SHM_TYPE_LOCAL;
block->size = size;
@@ -334,8 +337,12 @@ odp_shm_t odp_shm_import(const char *remote_name, odp_instance_t odp_inst,
block = &shm_tbl->block[idx];
block->mz = mz;
- snprintf(block->name, ODP_SHM_NAME_LEN, "%s", local_name);
- block->name[ODP_SHM_NAME_LEN - 1] = 0;
+
+ if (local_name == NULL)
+ block->name[0] = 0;
+ else
+ _odp_strcpy(block->name, local_name, ODP_SHM_NAME_LEN);
+
block->type = SHM_TYPE_REMOTE;
odp_spinlock_unlock(&shm_tbl->lock);
@@ -481,7 +488,6 @@ static void walk_memzone(const struct rte_memzone *mz, void *arg)
odp_system_memblock_t *memblock;
int32_t cur = data->blocks;
const char *name;
- int name_len;
data->info->total_mapped += mz->len;
data->blocks++;
@@ -499,12 +505,7 @@ static void walk_memzone(const struct rte_memzone *mz, void *arg)
return;
memblock = &data->memblock[cur];
- name_len = strlen(name);
- if (name_len >= ODP_SYSTEM_MEMBLOCK_NAME_LEN)
- name_len = ODP_SYSTEM_MEMBLOCK_NAME_LEN - 1;
-
- memcpy(memblock->name, name, name_len);
- memblock->name[name_len] = 0;
+ _odp_strcpy(memblock->name, name, ODP_SYSTEM_MEMBLOCK_NAME_LEN);
memblock->addr = (uintptr_t)mz->addr;
memblock->used = mz->len;
diff --git a/platform/linux-dpdk/odp_std_api.c b/platform/linux-dpdk/odp_std_api.c
index 251e6f874..ea6379061 100644
--- a/platform/linux-dpdk/odp_std_api.c
+++ b/platform/linux-dpdk/odp_std_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <odp/api/std.h>
diff --git a/platform/linux-dpdk/odp_system_info.c b/platform/linux-dpdk/odp_system_info.c
index d9cddcb40..dd257b811 100644
--- a/platform/linux-dpdk/odp_system_info.c
+++ b/platform/linux-dpdk/odp_system_info.c
@@ -1,15 +1,9 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2020-2024, Nokia
- * All rights reserved.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2020-2024 Nokia
*
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-/*
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
+ * Copyright(c) 2010-2014 Intel Corporation
+ * - lib/eal/linux/eal_hugepage_info.c
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-dpdk/odp_thread.c b/platform/linux-dpdk/odp_thread.c
index 10b5de5e0..3afad4e89 100644
--- a/platform/linux-dpdk/odp_thread.c
+++ b/platform/linux-dpdk/odp_thread.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#include <odp_posix_extensions.h>
@@ -40,9 +38,9 @@ typedef struct {
odp_thrmask_t control;
};
odp_atomic_u64_t thrmask_all_epoch;
- uint32_t num;
- uint32_t num_worker;
- uint32_t num_control;
+ odp_atomic_u32_t num;
+ odp_atomic_u32_t num_worker;
+ odp_atomic_u32_t num_control;
uint32_t num_max;
odp_spinlock_t lock;
odp_shm_t shm;
@@ -86,6 +84,9 @@ int _odp_thread_init_global(void)
return -1;
memset(thread_globals, 0, sizeof(thread_globals_t));
+ odp_atomic_init_u32(&thread_globals->num, 0);
+ odp_atomic_init_u32(&thread_globals->num_worker, 0);
+ odp_atomic_init_u32(&thread_globals->num_control, 0);
thread_globals->shm = shm;
@@ -102,10 +103,7 @@ int _odp_thread_term_global(void)
{
int ret, num;
- odp_spinlock_lock(&thread_globals->lock);
- num = thread_globals->num;
- odp_spinlock_unlock(&thread_globals->lock);
-
+ num = odp_atomic_load_u32(&thread_globals->num);
if (num)
_ODP_ERR("%u threads have not called odp_term_local().\n", num);
@@ -140,7 +138,7 @@ static int alloc_id(odp_thread_type_t type)
int thr;
odp_thrmask_t *all = &thread_globals->all;
- if (thread_globals->num >= thread_globals->num_max)
+ if (odp_atomic_load_u32(&thread_globals->num) >= thread_globals->num_max)
return -1;
for (thr = 0; thr < (int)thread_globals->num_max; thr++) {
@@ -150,13 +148,13 @@ static int alloc_id(odp_thread_type_t type)
if (type == ODP_THREAD_WORKER) {
odp_thrmask_set(&thread_globals->worker, thr);
- thread_globals->num_worker++;
+ odp_atomic_inc_u32(&thread_globals->num_worker);
} else {
odp_thrmask_set(&thread_globals->control, thr);
- thread_globals->num_control++;
+ odp_atomic_inc_u32(&thread_globals->num_control);
}
- thread_globals->num++;
+ odp_atomic_inc_u32(&thread_globals->num);
return thr;
}
}
@@ -179,14 +177,13 @@ static int free_id(int thr)
if (thread_globals->thr[thr].type == ODP_THREAD_WORKER) {
odp_thrmask_clr(&thread_globals->worker, thr);
- thread_globals->num_worker--;
+ odp_atomic_dec_u32(&thread_globals->num_worker);
} else {
odp_thrmask_clr(&thread_globals->control, thr);
- thread_globals->num_control--;
+ odp_atomic_dec_u32(&thread_globals->num_control);
}
- thread_globals->num--;
- return thread_globals->num;
+ return odp_atomic_fetch_dec_u32(&thread_globals->num) - 1;
}
int _odp_thread_init_local(odp_thread_type_t type)
@@ -288,17 +285,17 @@ int _odp_thread_term_local(void)
int odp_thread_count(void)
{
- return thread_globals->num;
+ return odp_atomic_load_u32(&thread_globals->num);
}
int odp_thread_control_count(void)
{
- return thread_globals->num_control;
+ return odp_atomic_load_u32(&thread_globals->num_control);
}
int odp_thread_worker_count(void)
{
- return thread_globals->num_worker;
+ return odp_atomic_load_u32(&thread_globals->num_worker);
}
int odp_thread_count_max(void)
@@ -318,12 +315,23 @@ int odp_thread_worker_count_max(void)
int odp_thrmask_worker(odp_thrmask_t *mask)
{
+ uint32_t num_worker;
+
+ odp_spinlock_lock(&thread_globals->lock);
odp_thrmask_copy(mask, &thread_globals->worker);
- return thread_globals->num_worker;
+ num_worker = odp_atomic_load_u32(&thread_globals->num_worker);
+ odp_spinlock_unlock(&thread_globals->lock);
+ return num_worker;
+
}
int odp_thrmask_control(odp_thrmask_t *mask)
{
+ uint32_t num_control;
+
+ odp_spinlock_lock(&thread_globals->lock);
odp_thrmask_copy(mask, &thread_globals->control);
- return thread_globals->num_control;
+ num_control = odp_atomic_load_u32(&thread_globals->num_control);
+ odp_spinlock_unlock(&thread_globals->lock);
+ return num_control;
}
diff --git a/platform/linux-dpdk/odp_time.c b/platform/linux-dpdk/odp_time.c
index fbee02df1..35c4cbabb 100644
--- a/platform/linux-dpdk/odp_time.c
+++ b/platform/linux-dpdk/odp_time.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2021-2024, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2021-2024 Nokia
*/
#include <odp/api/plat/time_inlines.h>
diff --git a/platform/linux-dpdk/odp_timer.c b/platform/linux-dpdk/odp_timer.c
index f4c190aad..08689322a 100644
--- a/platform/linux-dpdk/odp_timer.c
+++ b/platform/linux-dpdk/odp_timer.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2019-2024, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2019-2024 Nokia
*/
#include <odp_posix_extensions.h>
@@ -26,9 +24,9 @@
#include <odp_libconfig_internal.h>
#include <odp_macros_internal.h>
#include <odp_pool_internal.h>
-#include <odp_print_internal.h>
#include <odp_queue_if.h>
#include <odp_ring_u32_internal.h>
+#include <odp_string_internal.h>
#include <odp_thread_internal.h>
#include <odp_timer_internal.h>
@@ -129,7 +127,7 @@ typedef struct timer_pool_s {
} free_timer;
odp_timer_pool_param_t param;
- char name[ODP_TIMER_POOL_NAME_LEN + 1];
+ char name[ODP_TIMER_POOL_NAME_LEN];
int used;
odp_ticketlock_t lock;
uint32_t cur_timers;
@@ -715,11 +713,8 @@ odp_timer_pool_t odp_timer_pool_create(const char *name,
}
odp_ticketlock_unlock(&timer_global->lock);
- if (name) {
- strncpy(timer_pool->name, name,
- ODP_TIMER_POOL_NAME_LEN);
- timer_pool->name[ODP_TIMER_POOL_NAME_LEN] = 0;
- }
+ if (name)
+ _odp_strcpy(timer_pool->name, name, ODP_TIMER_POOL_NAME_LEN);
timer_pool->param = *param;
timer_pool->param.res_ns = res_ns;
diff --git a/platform/linux-dpdk/test/example/Makefile.am b/platform/linux-dpdk/test/example/Makefile.am
index 947647cd4..a9d0948de 100644
--- a/platform/linux-dpdk/test/example/Makefile.am
+++ b/platform/linux-dpdk/test/example/Makefile.am
@@ -1,6 +1,5 @@
SUBDIRS = \
classifier \
- generator \
ipsec_api \
ipsec_crypto \
l2fwd_simple \
diff --git a/platform/linux-dpdk/test/example/classifier/pktio_env b/platform/linux-dpdk/test/example/classifier/pktio_env
index 8b390092c..e6778cb39 100644
--- a/platform/linux-dpdk/test/example/classifier/pktio_env
+++ b/platform/linux-dpdk/test/example/classifier/pktio_env
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2020, Marvell
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Marvell
#
# Script to setup interfaces used for running application on linux-generic.
#
diff --git a/platform/linux-dpdk/test/example/generator/Makefile.am b/platform/linux-dpdk/test/example/generator/Makefile.am
deleted file mode 100644
index 2ffced539..000000000
--- a/platform/linux-dpdk/test/example/generator/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-EXTRA_DIST = pktio_env
diff --git a/platform/linux-dpdk/test/example/generator/pktio_env b/platform/linux-dpdk/test/example/generator/pktio_env
deleted file mode 100644
index cea715a5b..000000000
--- a/platform/linux-dpdk/test/example/generator/pktio_env
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2020, Marvell
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-# Script to setup interfaces used for running application on odp-dpdk.
-#
-# Generator uses a loop interface to validate udp mode.
-#
-# Network set-up
-# IF0 ---> null:0
-
-IF0=null:0
-
-if [ "$0" = "$BASH_SOURCE" ]; then
- echo "Error: Platform specific env file has to be sourced."
-fi
-
-validate_result()
-{
- return 0
-}
-
-setup_interfaces()
-{
- return 0
-}
-
-cleanup_interfaces()
-{
- return 0
-}
diff --git a/platform/linux-dpdk/test/example/ipsec_api/pktio_env b/platform/linux-dpdk/test/example/ipsec_api/pktio_env
index 3267bd4cd..ec501b319 100644
--- a/platform/linux-dpdk/test/example/ipsec_api/pktio_env
+++ b/platform/linux-dpdk/test/example/ipsec_api/pktio_env
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (C) 2021, Marvell
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (C) 2021 Marvell
#
# Script to setup interfaces used for running application on linux-dpdk.
#
diff --git a/platform/linux-dpdk/test/example/ipsec_crypto/pktio_env b/platform/linux-dpdk/test/example/ipsec_crypto/pktio_env
index 1c6e7d172..006293eaa 100644
--- a/platform/linux-dpdk/test/example/ipsec_crypto/pktio_env
+++ b/platform/linux-dpdk/test/example/ipsec_crypto/pktio_env
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (C) 2021, Marvell
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (C) 2021 Marvell
#
# Script to setup interfaces used for running application on linux-dpdk.
#
diff --git a/platform/linux-dpdk/test/example/l2fwd_simple/pktio_env b/platform/linux-dpdk/test/example/l2fwd_simple/pktio_env
index d1cb6d84a..cea4e1c23 100644
--- a/platform/linux-dpdk/test/example/l2fwd_simple/pktio_env
+++ b/platform/linux-dpdk/test/example/l2fwd_simple/pktio_env
@@ -1,10 +1,8 @@
#!/bin/sh
#
-# Copyright (c) 2020, Marvell
-# Copyright (c) 2020, Nokia
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Marvell
+# Copyright (c) 2020 Nokia
#
# Script to setup interfaces used for running application on linux-dpdk.
#
diff --git a/platform/linux-dpdk/test/example/l3fwd/pktio_env b/platform/linux-dpdk/test/example/l3fwd/pktio_env
index c9e35f09a..475272ecc 100644
--- a/platform/linux-dpdk/test/example/l3fwd/pktio_env
+++ b/platform/linux-dpdk/test/example/l3fwd/pktio_env
@@ -1,10 +1,8 @@
#!/bin/sh
#
-# Copyright (c) 2020, Marvell
-# Copyright (c) 2020, Nokia
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Marvell
+# Copyright (c) 2020 Nokia
#
# Script to setup interfaces used for running application on linux-dpdk.
#
diff --git a/platform/linux-dpdk/test/example/packet/pktio_env b/platform/linux-dpdk/test/example/packet/pktio_env
index 0f6a1c233..ef10c3436 100644
--- a/platform/linux-dpdk/test/example/packet/pktio_env
+++ b/platform/linux-dpdk/test/example/packet/pktio_env
@@ -1,10 +1,8 @@
#!/bin/sh
#
-# Copyright (c) 2020, Marvell
-# Copyright (c) 2020, Nokia
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Marvell
+# Copyright (c) 2020 Nokia
#
# Script to setup interfaces used for running application on linux-dpdk.
#
diff --git a/platform/linux-dpdk/test/example/ping/pktio_env b/platform/linux-dpdk/test/example/ping/pktio_env
index a8dba6e9a..45a58935a 100644
--- a/platform/linux-dpdk/test/example/ping/pktio_env
+++ b/platform/linux-dpdk/test/example/ping/pktio_env
@@ -1,10 +1,8 @@
#!/bin/sh
#
-# Copyright (c) 2020, Marvell
-# Copyright (c) 2020, Nokia
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Marvell
+# Copyright (c) 2020 Nokia
#
# Script to setup interfaces used for running application on linux-dpdk.
#
diff --git a/platform/linux-dpdk/test/example/simple_pipeline/pktio_env b/platform/linux-dpdk/test/example/simple_pipeline/pktio_env
index c2cccffbc..5ebc4b8d7 100644
--- a/platform/linux-dpdk/test/example/simple_pipeline/pktio_env
+++ b/platform/linux-dpdk/test/example/simple_pipeline/pktio_env
@@ -1,10 +1,8 @@
#!/bin/sh
#
-# Copyright (c) 2020, Marvell
-# Copyright (c) 2020, Nokia
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Marvell
+# Copyright (c) 2020 Nokia
#
# Script to setup interfaces used for running application on linux-dpdk.
#
diff --git a/platform/linux-dpdk/test/example/switch/pktio_env b/platform/linux-dpdk/test/example/switch/pktio_env
index 8daca3c3e..ee2e97d40 100644
--- a/platform/linux-dpdk/test/example/switch/pktio_env
+++ b/platform/linux-dpdk/test/example/switch/pktio_env
@@ -1,10 +1,8 @@
#!/bin/sh
#
-# Copyright (c) 2020, Marvell
-# Copyright (c) 2020, Nokia
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Marvell
+# Copyright (c) 2020 Nokia
#
# Script to setup interfaces used for running application on linux-dpdk.
#
diff --git a/platform/linux-dpdk/test/validation/api/pktio/pktio_run.sh b/platform/linux-dpdk/test/validation/api/pktio/pktio_run.sh
index 641b39493..7d73036dc 100755
--- a/platform/linux-dpdk/test/validation/api/pktio/pktio_run.sh
+++ b/platform/linux-dpdk/test/validation/api/pktio/pktio_run.sh
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2015-2018, Linaro Limited
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2015-2018 Linaro Limited
#
# Proceed the pktio tests. This script expects at least one argument:
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 11cdb4c64..d1d482849 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -156,8 +156,8 @@ noinst_HEADERS = \
include/odp_packet_internal.h \
include/odp_packet_io_internal.h \
include/odp_parse_internal.h \
- include/odp_print_internal.h \
include/odp_socket_common.h \
+ include/odp_string_internal.h \
include/odp_packet_io_stats_common.h \
include/odp_packet_io_stats.h \
include/odp_sysfs_stats.h \
@@ -240,7 +240,6 @@ __LIB__libodp_linux_la_SOURCES = \
odp_packet_io.c \
odp_parse.c \
odp_pkt_queue.c \
- odp_print.c \
odp_pool.c \
odp_pool_mem_src_ops.c \
odp_queue_basic.c \
@@ -260,6 +259,7 @@ __LIB__libodp_linux_la_SOURCES = \
odp_sorted_list.c \
odp_stash.c \
odp_std.c \
+ odp_string.c \
odp_system_info.c \
odp_pcapng.c \
odp_thread.c \
@@ -492,7 +492,7 @@ if ODP_PKTIO_PCAP
__LIB__libodp_linux_la_LIBADD += $(PCAP_LIBS)
endif
-CHECK_GLOBALS_REGEX = " (odp_|_odp_|_deprecated_odp_|miniz_|mz_|tdefl_|tinfl_|mp_hdlr_init_odp_pool_ops)"
+CHECK_GLOBALS_REGEX = " (odp_|_odp_|_deprecated_odp_|miniz_|mz_|tdefl_|tinfl_|mp_hdlr_init_odp_pool_ops|__odr_asan)"
TESTS_ENVIRONMENT = \
LIBTOOL="$(LIBTOOL)" \
diff --git a/platform/linux-generic/README b/platform/linux-generic/README
index 8fa50c127..905b06a4a 100644
--- a/platform/linux-generic/README
+++ b/platform/linux-generic/README
@@ -1,8 +1,6 @@
-Copyright (c) 2014-2018, Linaro Limited
-Copyright (c) 2019-2023, Nokia
-All rights reserved.
-
-SPDX-License-Identifier: BSD-3-Clause
+SPDX-License-Identifier: BSD-3-Clause
+Copyright (c) 2014-2018 Linaro Limited
+Copyright (c) 2019-2023 Nokia
1. Intro
OpenDataPlane API generic Linux implementation. Directory linux-generic
diff --git a/platform/linux-generic/arch/aarch64/cpu_flags.c b/platform/linux-generic/arch/aarch64/cpu_flags.c
index 9923e9306..35ef7c1f0 100644
--- a/platform/linux-generic/arch/aarch64/cpu_flags.c
+++ b/platform/linux-generic/arch/aarch64/cpu_flags.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2020-2023 Nokia
*/
#include <odp/api/hints.h>
diff --git a/platform/linux-generic/arch/aarch64/cpu_flags.h b/platform/linux-generic/arch/aarch64/cpu_flags.h
index 177b1c44f..f520306ac 100644
--- a/platform/linux-generic/arch/aarch64/cpu_flags.h
+++ b/platform/linux-generic/arch/aarch64/cpu_flags.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, ARM Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 ARM Limited
*/
#ifndef ODP_PLAT_CPU_FLAGS_H_
diff --git a/platform/linux-generic/arch/aarch64/odp/api/abi/atomic.h b/platform/linux-generic/arch/aarch64/odp/api/abi/atomic.h
index 14cca3ca0..32a763ee6 100644
--- a/platform/linux-generic/arch/aarch64/odp/api/abi/atomic.h
+++ b/platform/linux-generic/arch/aarch64/odp/api/abi/atomic.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, ARM Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 ARM Limited
*/
#ifdef __ARM_FEATURE_ATOMICS
diff --git a/platform/linux-generic/arch/aarch64/odp/api/abi/atomic_inlines.h b/platform/linux-generic/arch/aarch64/odp/api/abi/atomic_inlines.h
index 3b0f94efe..19180ffee 100644
--- a/platform/linux-generic/arch/aarch64/odp/api/abi/atomic_inlines.h
+++ b/platform/linux-generic/arch/aarch64/odp/api/abi/atomic_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2021, ARM Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 ARM Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_API_ABI_ATOMIC_INLINES_H_
diff --git a/platform/linux-generic/arch/aarch64/odp/api/abi/cpu.h b/platform/linux-generic/arch/aarch64/odp/api/abi/cpu.h
index 825ff19d4..0e7cbf86b 100644
--- a/platform/linux-generic/arch/aarch64/odp/api/abi/cpu.h
+++ b/platform/linux-generic/arch/aarch64/odp/api/abi/cpu.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#ifndef ODP_API_ABI_CPU_H_
diff --git a/platform/linux-generic/arch/aarch64/odp/api/abi/cpu_inlines.h b/platform/linux-generic/arch/aarch64/odp/api/abi/cpu_inlines.h
index a26908e66..5890fc7a4 100644
--- a/platform/linux-generic/arch/aarch64/odp/api/abi/cpu_inlines.h
+++ b/platform/linux-generic/arch/aarch64/odp/api/abi/cpu_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
#ifndef ODP_ARCH_CPU_INLINES_H_
diff --git a/platform/linux-generic/arch/aarch64/odp/api/abi/hash_crc32.h b/platform/linux-generic/arch/aarch64/odp/api/abi/hash_crc32.h
index fd7bf91c6..56bdd2812 100644
--- a/platform/linux-generic/arch/aarch64/odp/api/abi/hash_crc32.h
+++ b/platform/linux-generic/arch/aarch64/odp/api/abi/hash_crc32.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021 ARM Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 ARM Limited
*/
#ifndef ODP_API_ABI_HASH_CRC32_H_
diff --git a/platform/linux-generic/arch/aarch64/odp/api/abi/time_cpu.h b/platform/linux-generic/arch/aarch64/odp/api/abi/time_cpu.h
index aba2799c7..29e92da2a 100644
--- a/platform/linux-generic/arch/aarch64/odp/api/abi/time_cpu.h
+++ b/platform/linux-generic/arch/aarch64/odp/api/abi/time_cpu.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_API_ABI_TIME_CPU_H_
diff --git a/platform/linux-generic/arch/aarch64/odp/api/abi/time_inlines.h b/platform/linux-generic/arch/aarch64/odp/api/abi/time_inlines.h
index 331d1996f..eed571027 100644
--- a/platform/linux-generic/arch/aarch64/odp/api/abi/time_inlines.h
+++ b/platform/linux-generic/arch/aarch64/odp/api/abi/time_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
*/
#include <odp/api/abi/time_cpu_inlines.h>
diff --git a/platform/linux-generic/arch/aarch64/odp_atomic.c b/platform/linux-generic/arch/aarch64/odp_atomic.c
index c6b809768..56604f7f0 100644
--- a/platform/linux-generic/arch/aarch64/odp_atomic.c
+++ b/platform/linux-generic/arch/aarch64/odp_atomic.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021, ARM Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2021 ARM Limited
*/
#include <odp/api/atomic.h>
diff --git a/platform/linux-generic/arch/aarch64/odp_atomic.h b/platform/linux-generic/arch/aarch64/odp_atomic.h
index d3b8ea4dc..5bbaa9ca8 100644
--- a/platform/linux-generic/arch/aarch64/odp_atomic.h
+++ b/platform/linux-generic/arch/aarch64/odp_atomic.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2021, ARM Limited
- * Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2021 ARM Limited
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#ifndef PLATFORM_LINUXGENERIC_ARCH_ARM_ODP_ATOMIC_H
diff --git a/platform/linux-generic/arch/aarch64/odp_cpu.h b/platform/linux-generic/arch/aarch64/odp_cpu.h
index ad8b36d87..cd15cda2d 100644
--- a/platform/linux-generic/arch/aarch64/odp_cpu.h
+++ b/platform/linux-generic/arch/aarch64/odp_cpu.h
@@ -1,9 +1,6 @@
-/* Copyright (c) 2017, ARM Limited. All rights reserved.
- *
- * Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#ifndef PLATFORM_LINUXGENERIC_ARCH_ARM_ODP_CPU_H
diff --git a/platform/linux-generic/arch/aarch64/odp_crypto_armv8.c b/platform/linux-generic/arch/aarch64/odp_crypto_armv8.c
index 52936dacf..3d1d7bf40 100644
--- a/platform/linux-generic/arch/aarch64/odp_crypto_armv8.c
+++ b/platform/linux-generic/arch/aarch64/odp_crypto_armv8.c
@@ -1,9 +1,7 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021, ARM Limited
- * Copyright (c) 2022-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021 ARM Limited
+ * Copyright (c) 2022-2023 Nokia
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/arch/aarch64/odp_random.h b/platform/linux-generic/arch/aarch64/odp_random.h
index 023e6c455..1f6187c31 100644
--- a/platform/linux-generic/arch/aarch64/odp_random.h
+++ b/platform/linux-generic/arch/aarch64/odp_random.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, ARM Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 ARM Limited
*/
#ifndef ODP_AARCH64_RANDOM_H_
diff --git a/platform/linux-generic/arch/aarch64/odp_sysinfo_parse.c b/platform/linux-generic/arch/aarch64/odp_sysinfo_parse.c
index f242c845e..b1bbb0305 100644
--- a/platform/linux-generic/arch/aarch64/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/aarch64/odp_sysinfo_parse.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2020-2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2020-2021 Nokia
*/
#include <stdio.h>
diff --git a/platform/linux-generic/arch/arm/odp/api/abi/cpu.h b/platform/linux-generic/arch/arm/odp/api/abi/cpu.h
index 9224af9a0..ad93cc816 100644
--- a/platform/linux-generic/arch/arm/odp/api/abi/cpu.h
+++ b/platform/linux-generic/arch/arm/odp/api/abi/cpu.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#ifndef ODP_API_ABI_CPU_H_
diff --git a/platform/linux-generic/arch/arm/odp/api/abi/cpu_inlines.h b/platform/linux-generic/arch/arm/odp/api/abi/cpu_inlines.h
index bf44806a0..298953d95 100644
--- a/platform/linux-generic/arch/arm/odp/api/abi/cpu_inlines.h
+++ b/platform/linux-generic/arch/arm/odp/api/abi/cpu_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_ARCH_CPU_INLINES_H_
diff --git a/platform/linux-generic/arch/arm/odp_cpu.h b/platform/linux-generic/arch/arm/odp_cpu.h
index 6b2674736..f8af54800 100644
--- a/platform/linux-generic/arch/arm/odp_cpu.h
+++ b/platform/linux-generic/arch/arm/odp_cpu.h
@@ -1,9 +1,6 @@
-/* Copyright (c) 2017, ARM Limited. All rights reserved.
- *
- * Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#ifndef PLATFORM_LINUXGENERIC_ARCH_ARM_ODP_CPU_H
diff --git a/platform/linux-generic/arch/arm/odp_sysinfo_parse.c b/platform/linux-generic/arch/arm/odp_sysinfo_parse.c
index 4cbe46d7c..57c17d8ee 100644
--- a/platform/linux-generic/arch/arm/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/arm/odp_sysinfo_parse.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020 Nokia
*/
#include <odp_global_data.h>
diff --git a/platform/linux-generic/arch/common/odp/api/abi/time_cpu_inlines.h b/platform/linux-generic/arch/common/odp/api/abi/time_cpu_inlines.h
index 553114666..3b0808072 100644
--- a/platform/linux-generic/arch/common/odp/api/abi/time_cpu_inlines.h
+++ b/platform/linux-generic/arch/common/odp/api/abi/time_cpu_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2020-2023 Nokia
*/
#ifndef ODP_ARCH_TIME_CPU_INLINES_H_
diff --git a/platform/linux-generic/arch/common/odp_time_cpu.c b/platform/linux-generic/arch/common/odp_time_cpu.c
index 3c392de0c..6416f5575 100644
--- a/platform/linux-generic/arch/common/odp_time_cpu.c
+++ b/platform/linux-generic/arch/common/odp_time_cpu.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2020-2023 Nokia
*/
#include <odp/api/time_types.h>
diff --git a/platform/linux-generic/arch/default/odp/api/abi/atomic_generic.h b/platform/linux-generic/arch/default/odp/api/abi/atomic_generic.h
index c6ed86363..b2029777c 100644
--- a/platform/linux-generic/arch/default/odp/api/abi/atomic_generic.h
+++ b/platform/linux-generic/arch/default/odp/api/abi/atomic_generic.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2021, ARM Limited
- * Copyright (c) 2021-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 ARM Limited
+ * Copyright (c) 2021-2022 Nokia
*/
#ifndef ODP_API_ABI_ATOMIC_GENERIC_H_
diff --git a/platform/linux-generic/arch/default/odp/api/abi/atomic_inlines.h b/platform/linux-generic/arch/default/odp/api/abi/atomic_inlines.h
index f1072d11f..8da9b73d1 100644
--- a/platform/linux-generic/arch/default/odp/api/abi/atomic_inlines.h
+++ b/platform/linux-generic/arch/default/odp/api/abi/atomic_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#include <odp/api/abi/atomic_generic.h>
diff --git a/platform/linux-generic/arch/default/odp/api/abi/cpu.h b/platform/linux-generic/arch/default/odp/api/abi/cpu.h
index e09efdfcf..402655dfc 100644
--- a/platform/linux-generic/arch/default/odp/api/abi/cpu.h
+++ b/platform/linux-generic/arch/default/odp/api/abi/cpu.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_API_ABI_CPU_H_
diff --git a/platform/linux-generic/arch/default/odp/api/abi/cpu_generic.h b/platform/linux-generic/arch/default/odp/api/abi/cpu_generic.h
index b75e65717..b2ba3972a 100644
--- a/platform/linux-generic/arch/default/odp/api/abi/cpu_generic.h
+++ b/platform/linux-generic/arch/default/odp/api/abi/cpu_generic.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_API_ABI_CPU_GENERIC_H_
diff --git a/platform/linux-generic/arch/default/odp/api/abi/cpu_inlines.h b/platform/linux-generic/arch/default/odp/api/abi/cpu_inlines.h
index 54aeae946..6a35e93eb 100644
--- a/platform/linux-generic/arch/default/odp/api/abi/cpu_inlines.h
+++ b/platform/linux-generic/arch/default/odp/api/abi/cpu_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_ARCH_CPU_INLINES_H_
diff --git a/platform/linux-generic/arch/default/odp/api/abi/hash_crc32.h b/platform/linux-generic/arch/default/odp/api/abi/hash_crc32.h
index 8759ed948..07da45621 100644
--- a/platform/linux-generic/arch/default/odp/api/abi/hash_crc32.h
+++ b/platform/linux-generic/arch/default/odp/api/abi/hash_crc32.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_API_ABI_HASH_CRC32_H_
diff --git a/platform/linux-generic/arch/default/odp/api/abi/time_inlines.h b/platform/linux-generic/arch/default/odp/api/abi/time_inlines.h
index ed0ffdb3f..6e592d7a8 100644
--- a/platform/linux-generic/arch/default/odp/api/abi/time_inlines.h
+++ b/platform/linux-generic/arch/default/odp/api/abi/time_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2020-2023 Nokia
*/
#ifndef ODP_ARCH_TIME_INLINES_H_
diff --git a/platform/linux-generic/arch/default/odp_atomic.c b/platform/linux-generic/arch/default/odp_atomic.c
index 36fc5e8ea..a2a3bd2f2 100644
--- a/platform/linux-generic/arch/default/odp_atomic.c
+++ b/platform/linux-generic/arch/default/odp_atomic.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021, ARM Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2021 ARM Limited
*/
#include <odp/api/atomic.h>
diff --git a/platform/linux-generic/arch/default/odp_atomic.h b/platform/linux-generic/arch/default/odp_atomic.h
index 4cfc6b4bd..eef88c7b3 100644
--- a/platform/linux-generic/arch/default/odp_atomic.h
+++ b/platform/linux-generic/arch/default/odp_atomic.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, ARM Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 ARM Limited
*/
#ifndef ODP_DEFAULT_ATOMIC_H_
diff --git a/platform/linux-generic/arch/default/odp_cpu.h b/platform/linux-generic/arch/default/odp_cpu.h
index 6b10966c6..e9d88c791 100644
--- a/platform/linux-generic/arch/default/odp_cpu.h
+++ b/platform/linux-generic/arch/default/odp_cpu.h
@@ -1,9 +1,6 @@
-/* Copyright (c) 2017, ARM Limited. All rights reserved.
- *
- * Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#ifndef ODP_DEFAULT_CPU_H_
diff --git a/platform/linux-generic/arch/default/odp_cpu_cycles.c b/platform/linux-generic/arch/default/odp_cpu_cycles.c
index 41436a672..97c1da93c 100644
--- a/platform/linux-generic/arch/default/odp_cpu_cycles.c
+++ b/platform/linux-generic/arch/default/odp_cpu_cycles.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/arch/default/odp_hash_crc32.c b/platform/linux-generic/arch/default/odp_hash_crc32.c
index f71c11909..c6956787f 100644
--- a/platform/linux-generic/arch/default/odp_hash_crc32.c
+++ b/platform/linux-generic/arch/default/odp_hash_crc32.c
@@ -1,40 +1,8 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright(c) 2010-2014 Intel Corporation
+ * - lib/hash/rte_crc_sw.h
*/
#include <odp/api/align.h>
diff --git a/platform/linux-generic/arch/default/odp_random.c b/platform/linux-generic/arch/default/odp_random.c
index 18d2a45d2..7c8b33c42 100644
--- a/platform/linux-generic/arch/default/odp_random.c
+++ b/platform/linux-generic/arch/default/odp_random.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#include <odp_random.h>
diff --git a/platform/linux-generic/arch/default/odp_random.h b/platform/linux-generic/arch/default/odp_random.h
index 215eb6d93..7b6c5a2f3 100644
--- a/platform/linux-generic/arch/default/odp_random.h
+++ b/platform/linux-generic/arch/default/odp_random.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_DEFAULT_RANDOM_H_
diff --git a/platform/linux-generic/arch/default/odp_sysinfo_parse.c b/platform/linux-generic/arch/default/odp_sysinfo_parse.c
index 11d33d576..024bc8217 100644
--- a/platform/linux-generic/arch/default/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/default/odp_sysinfo_parse.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#include <odp_global_data.h>
diff --git a/platform/linux-generic/arch/default/odp_time.c b/platform/linux-generic/arch/default/odp_time.c
index 664a5deae..ec9da0896 100644
--- a/platform/linux-generic/arch/default/odp_time.c
+++ b/platform/linux-generic/arch/default/odp_time.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2020-2023 Nokia
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/arch/powerpc/odp/api/abi/cpu.h b/platform/linux-generic/arch/powerpc/odp/api/abi/cpu.h
index ecf56e82e..dc128e1a8 100644
--- a/platform/linux-generic/arch/powerpc/odp/api/abi/cpu.h
+++ b/platform/linux-generic/arch/powerpc/odp/api/abi/cpu.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_API_ABI_CPU_H_
diff --git a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
index 2049cc42f..519ca62ed 100644
--- a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
@@ -1,11 +1,10 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#include <odp_global_data.h>
#include <odp_sysinfo_internal.h>
+#include <odp_string_internal.h>
#include <string.h>
int _odp_cpuinfo_parser(FILE *file, system_info_t *sysinfo)
@@ -39,13 +38,9 @@ int _odp_cpuinfo_parser(FILE *file, system_info_t *sysinfo)
pos = strstr(str, "cpu");
if (pos) {
- int len;
-
pos = strchr(str, ':');
- strncpy(sysinfo->model_str[id], pos + 2,
- MODEL_STR_SIZE - 1);
- len = strlen(sysinfo->model_str[id]);
- sysinfo->model_str[id][len - 1] = 0;
+ _odp_strcpy(sysinfo->model_str[id], pos + 2,
+ MODEL_STR_SIZE);
model = 1;
count--;
}
diff --git a/platform/linux-generic/arch/x86/cpu_flags.c b/platform/linux-generic/arch/x86/cpu_flags.c
index 9211df002..124f1d184 100644
--- a/platform/linux-generic/arch/x86/cpu_flags.c
+++ b/platform/linux-generic/arch/x86/cpu_flags.c
@@ -1,12 +1,11 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2023 Nokia
+ *
* Copyright(c) 2010-2015 Intel Corporation
+ * - lib/eal/x86/include/rte_cpuflags.h
+ * - lib/eal/x86/rte_cpuflags.c
+ * - lib/eal/x86/rte_cpuid.h
*/
#include "cpu_flags.h"
diff --git a/platform/linux-generic/arch/x86/cpu_flags.h b/platform/linux-generic/arch/x86/cpu_flags.h
index 8d485dbfa..8f6be6813 100644
--- a/platform/linux-generic/arch/x86/cpu_flags.h
+++ b/platform/linux-generic/arch/x86/cpu_flags.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#ifndef ODP_PLAT_CPU_FLAGS_H_
diff --git a/platform/linux-generic/arch/x86/odp/api/abi/cpu.h b/platform/linux-generic/arch/x86/odp/api/abi/cpu.h
index 9224af9a0..ad93cc816 100644
--- a/platform/linux-generic/arch/x86/odp/api/abi/cpu.h
+++ b/platform/linux-generic/arch/x86/odp/api/abi/cpu.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#ifndef ODP_API_ABI_CPU_H_
diff --git a/platform/linux-generic/arch/x86/odp/api/abi/cpu_inlines.h b/platform/linux-generic/arch/x86/odp/api/abi/cpu_inlines.h
index 4b542a577..066945e7b 100644
--- a/platform/linux-generic/arch/x86/odp/api/abi/cpu_inlines.h
+++ b/platform/linux-generic/arch/x86/odp/api/abi/cpu_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_ARCH_CPU_INLINES_H_
diff --git a/platform/linux-generic/arch/x86/odp/api/abi/cpu_rdtsc.h b/platform/linux-generic/arch/x86/odp/api/abi/cpu_rdtsc.h
index ccc5f0f36..9e6d9f278 100644
--- a/platform/linux-generic/arch/x86/odp/api/abi/cpu_rdtsc.h
+++ b/platform/linux-generic/arch/x86/odp/api/abi/cpu_rdtsc.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_ARCH_CPU_RDTSC_H_
diff --git a/platform/linux-generic/arch/x86/odp/api/abi/hash_crc32.h b/platform/linux-generic/arch/x86/odp/api/abi/hash_crc32.h
index c2c71bcb7..576b68f20 100644
--- a/platform/linux-generic/arch/x86/odp/api/abi/hash_crc32.h
+++ b/platform/linux-generic/arch/x86/odp/api/abi/hash_crc32.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_API_ABI_HASH_CRC32_H_
@@ -11,6 +9,7 @@
extern "C" {
#endif
+#include <odp/api/std_types.h>
#include <stdint.h>
uint32_t _odp_hash_crc32_generic(const void *data, uint32_t data_len,
@@ -34,23 +33,23 @@ static inline uint32_t _odp_hash_crc32c(const void *data, uint32_t data_len,
#ifdef __x86_64__
for (i = 0; i < data_len / 8; i++) {
- init_val = (uint32_t)__builtin_ia32_crc32di(init_val, *(const uint64_t *)pd);
+ init_val = (uint32_t)__builtin_ia32_crc32di(init_val, *(const odp_una_u64_t *)pd);
pd += 8;
}
if (data_len & 0x4) {
- init_val = __builtin_ia32_crc32si(init_val, *(const uint32_t *)pd);
+ init_val = __builtin_ia32_crc32si(init_val, *(const odp_una_u32_t *)pd);
pd += 4;
}
#else
for (i = 0; i < data_len / 4; i++) {
- init_val = __builtin_ia32_crc32si(init_val, *(const uint32_t *)pd);
+ init_val = __builtin_ia32_crc32si(init_val, *(const odp_una_u32_t *)pd);
pd += 4;
}
#endif
if (data_len & 0x2) {
- init_val = __builtin_ia32_crc32hi(init_val, *(const uint16_t *)pd);
+ init_val = __builtin_ia32_crc32hi(init_val, *(const odp_una_u16_t *)pd);
pd += 2;
}
diff --git a/platform/linux-generic/arch/x86/odp/api/abi/time_cpu.h b/platform/linux-generic/arch/x86/odp/api/abi/time_cpu.h
index baf79ad3f..74b6eb740 100644
--- a/platform/linux-generic/arch/x86/odp/api/abi/time_cpu.h
+++ b/platform/linux-generic/arch/x86/odp/api/abi/time_cpu.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_ARCH_TIME_CPU_H_
diff --git a/platform/linux-generic/arch/x86/odp/api/abi/time_inlines.h b/platform/linux-generic/arch/x86/odp/api/abi/time_inlines.h
index 331d1996f..eed571027 100644
--- a/platform/linux-generic/arch/x86/odp/api/abi/time_inlines.h
+++ b/platform/linux-generic/arch/x86/odp/api/abi/time_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
*/
#include <odp/api/abi/time_cpu_inlines.h>
diff --git a/platform/linux-generic/arch/x86/odp_cpu.h b/platform/linux-generic/arch/x86/odp_cpu.h
index 8f8f22daf..2282285fc 100644
--- a/platform/linux-generic/arch/x86/odp_cpu.h
+++ b/platform/linux-generic/arch/x86/odp_cpu.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_X86_CPU_H_
diff --git a/platform/linux-generic/arch/x86/odp_cpu_cycles.c b/platform/linux-generic/arch/x86/odp_cpu_cycles.c
index 2624af0f6..4950f0bad 100644
--- a/platform/linux-generic/arch/x86/odp_cpu_cycles.c
+++ b/platform/linux-generic/arch/x86/odp_cpu_cycles.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <odp/api/cpu.h>
diff --git a/platform/linux-generic/arch/x86/odp_random.h b/platform/linux-generic/arch/x86/odp_random.h
index 54628038e..14551f47e 100644
--- a/platform/linux-generic/arch/x86/odp_random.h
+++ b/platform/linux-generic/arch/x86/odp_random.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
/*
diff --git a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
index 3cbdb2037..0a5aedfcc 100644
--- a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
@@ -1,11 +1,10 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2023 Nokia
*/
#include <odp_sysinfo_internal.h>
+#include <odp_string_internal.h>
#include "cpu_flags.h"
#include <string.h>
@@ -49,8 +48,8 @@ int _odp_cpuinfo_parser(FILE *file, system_info_t *sysinfo)
if (pos_end != NULL)
*(pos_end - 1) = '\0';
- strncpy(sysinfo->model_str[id], pos + 2,
- MODEL_STR_SIZE - 1);
+ _odp_strcpy(sysinfo->model_str[id], pos + 2,
+ MODEL_STR_SIZE);
if (sysinfo->cpu_hz_max[id]) {
freq_set = true;
diff --git a/platform/linux-generic/doc/platform_specific.dox b/platform/linux-generic/doc/platform_specific.dox
index be0486666..197e6de10 100644
--- a/platform/linux-generic/doc/platform_specific.dox
+++ b/platform/linux-generic/doc/platform_specific.dox
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/dumpconfig/dumpconfig.c b/platform/linux-generic/dumpconfig/dumpconfig.c
index a04f5c2dd..47ad48b70 100644
--- a/platform/linux-generic/dumpconfig/dumpconfig.c
+++ b/platform/linux-generic/dumpconfig/dumpconfig.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#include <stdio.h>
diff --git a/platform/linux-generic/example/ml/mnist.c b/platform/linux-generic/example/ml/mnist.c
index 4c1066302..28720a3fd 100644
--- a/platform/linux-generic/example/ml/mnist.c
+++ b/platform/linux-generic/example/ml/mnist.c
@@ -56,8 +56,8 @@ static int read_digit_csv(const char *file_name, uint8_t *expected_digit, float
size = ftell(digit_file);
rewind(digit_file);
- tmp = malloc(size);
- memset(tmp, 0, size);
+ tmp = malloc(size + 1);
+ memset(tmp, 0, size + 1);
num_elem = fread(tmp, size, 1, digit_file);
fclose(digit_file);
diff --git a/platform/linux-generic/example/ml/model_explorer.c b/platform/linux-generic/example/ml/model_explorer.c
index bd449b032..408b96c03 100644
--- a/platform/linux-generic/example/ml/model_explorer.c
+++ b/platform/linux-generic/example/ml/model_explorer.c
@@ -73,6 +73,11 @@ int main(int argc, char *argv[])
odp_ml_model_print(ml_model);
+ if (odp_ml_model_destroy(ml_model)) {
+ printf("odp_ml_model_destroy failed.\n");
+ ret = -1;
+ }
+
odp_term:
if (odp_term_local()) {
printf("Local term failed.\n");
diff --git a/platform/linux-generic/include-abi/odp/api/abi/align.h b/platform/linux-generic/include-abi/odp/api/abi/align.h
index 7fa343078..aa8f2eab7 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/align.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/align.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/abi-default/align.h>
diff --git a/platform/linux-generic/include-abi/odp/api/abi/atomic.h b/platform/linux-generic/include-abi/odp/api/abi/atomic.h
index 4f481f913..cb5d6fcc9 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/atomic.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/atomic.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/barrier.h b/platform/linux-generic/include-abi/odp/api/abi/barrier.h
index cff12c577..6e804ce31 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/barrier.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/barrier.h
@@ -1,38 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
-/**
- * @file
- *
- * ODP barrier
- */
-
-#ifndef ODP_ABI_BARRIER_H_
-#define ODP_ABI_BARRIER_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <odp/api/std_types.h>
-#include <odp/api/atomic.h>
-
-/**
- * @internal
- * ODP thread synchronization barrier
- */
-struct odp_barrier_s {
- uint32_t count; /**< Thread count */
- odp_atomic_u32_t bar; /**< Barrier counter */
-};
-
-typedef struct odp_barrier_s odp_barrier_t;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+#include <odp/api/abi-default/barrier.h>
diff --git a/platform/linux-generic/include-abi/odp/api/abi/buffer.h b/platform/linux-generic/include-abi/odp/api/abi/buffer.h
index a6309fe39..51759e974 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/buffer.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/buffer.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2023 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/buffer_types.h b/platform/linux-generic/include-abi/odp/api/abi/buffer_types.h
index 63067268c..da7a6532d 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/buffer_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/buffer_types.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2023 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/byteorder.h b/platform/linux-generic/include-abi/odp/api/abi/byteorder.h
index c0b5ebe0c..e9cebff02 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/byteorder.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/byteorder.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/classification.h b/platform/linux-generic/include-abi/odp/api/abi/classification.h
index d63763dbd..e67f585ac 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/classification.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/classification.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/comp.h b/platform/linux-generic/include-abi/odp/api/abi/comp.h
index 45681e961..590950aef 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/comp.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/comp.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_ABI_COMP_H_
diff --git a/platform/linux-generic/include-abi/odp/api/abi/cpumask.h b/platform/linux-generic/include-abi/odp/api/abi/cpumask.h
index c64bf2a69..696f8664f 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/cpumask.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/cpumask.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/abi-default/cpumask.h>
diff --git a/platform/linux-generic/include-abi/odp/api/abi/crypto.h b/platform/linux-generic/include-abi/odp/api/abi/crypto.h
index bef725c28..3be9b138c 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/crypto.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/crypto.h
@@ -1,11 +1,8 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
-
/**
* @file
*
diff --git a/platform/linux-generic/include-abi/odp/api/abi/crypto_types.h b/platform/linux-generic/include-abi/odp/api/abi/crypto_types.h
index b1e4aa5ae..b37a78f86 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/crypto_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/crypto_types.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/debug.h b/platform/linux-generic/include-abi/odp/api/abi/debug.h
index a3a86e64a..b82e2d171 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/debug.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/debug.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/dma.h b/platform/linux-generic/include-abi/odp/api/abi/dma.h
index 60798143c..fb40d38c3 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/dma.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/dma.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/dma_types.h b/platform/linux-generic/include-abi/odp/api/abi/dma_types.h
index d5bee0374..4ad113ddd 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/dma_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/dma_types.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_API_ABI_DMA_TYPES_H_
diff --git a/platform/linux-generic/include-abi/odp/api/abi/errno.h b/platform/linux-generic/include-abi/odp/api/abi/errno.h
index 6215a0676..fdfd03e3a 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/errno.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/errno.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020, Marvell
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020 Marvell
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/event.h b/platform/linux-generic/include-abi/odp/api/abi/event.h
index e059f318c..ca2901c87 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/event.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/event.h
@@ -1,11 +1,8 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
-
/**
* @file
*
diff --git a/platform/linux-generic/include-abi/odp/api/abi/event_types.h b/platform/linux-generic/include-abi/odp/api/abi/event_types.h
index 01ee66cd3..4beafa6b7 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/event_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/event_types.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2022-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2022-2023 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/hash.h b/platform/linux-generic/include-abi/odp/api/abi/hash.h
index b132d7eb4..fe61a2111 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/hash.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/hash.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020, Marvell
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020 Marvell
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/init.h b/platform/linux-generic/include-abi/odp/api/abi/init.h
index 7ad523fde..936644f46 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/init.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/init.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/abi-default/init.h>
diff --git a/platform/linux-generic/include-abi/odp/api/abi/ipsec.h b/platform/linux-generic/include-abi/odp/api/abi/ipsec.h
index 1817e5564..40ae34b17 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/ipsec.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/ipsec.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/ipsec_types.h b/platform/linux-generic/include-abi/odp/api/abi/ipsec_types.h
index 1c5501997..50a859d3c 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/ipsec_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/ipsec_types.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/packet.h b/platform/linux-generic/include-abi/odp/api/abi/packet.h
index 5703141d4..e3ada64a0 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/packet.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/packet.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2019, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2019 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/packet_flags.h b/platform/linux-generic/include-abi/odp/api/abi/packet_flags.h
index 8e7b88ca2..22cae8e1b 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/packet_flags.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/packet_flags.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/packet_io.h b/platform/linux-generic/include-abi/odp/api/abi/packet_io.h
index c7c7b2faa..d60d29d3c 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/packet_io.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/packet_io.h
@@ -1,11 +1,8 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2020-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2020-2022 Nokia
*/
-
/**
* @file
*
diff --git a/platform/linux-generic/include-abi/odp/api/abi/packet_io_types.h b/platform/linux-generic/include-abi/odp/api/abi/packet_io_types.h
index 76b162020..7d66e9da5 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/packet_io_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/packet_io_types.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2020-2023 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/packet_types.h b/platform/linux-generic/include-abi/odp/api/abi/packet_types.h
index 90b2af107..7ffdec678 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/packet_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/packet_types.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2019-2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2019-2021 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/pool.h b/platform/linux-generic/include-abi/odp/api/abi/pool.h
index d8a80197c..fd5cd04ec 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/pool.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/pool.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/pool_types.h b/platform/linux-generic/include-abi/odp/api/abi/pool_types.h
index 77b0ff638..143a1c4ee 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/pool_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/pool_types.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/proto_stats.h b/platform/linux-generic/include-abi/odp/api/abi/proto_stats.h
index d81035df2..f9399407d 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/proto_stats.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/proto_stats.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2021, Marvell
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Marvell
+ * Copyright (c) 2021 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/proto_stats_types.h b/platform/linux-generic/include-abi/odp/api/abi/proto_stats_types.h
index d9db29188..0404ace05 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/proto_stats_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/proto_stats_types.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2021, Marvell
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Marvell
+ * Copyright (c) 2021 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/queue.h b/platform/linux-generic/include-abi/odp/api/abi/queue.h
index 6c34123df..59cbe9bb6 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/queue.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/queue.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/queue_types.h b/platform/linux-generic/include-abi/odp/api/abi/queue_types.h
index 4eff762bd..18ab36286 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/queue_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/queue_types.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/random.h b/platform/linux-generic/include-abi/odp/api/abi/random.h
index 07714a47e..89745378b 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/random.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/random.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/rwlock.h b/platform/linux-generic/include-abi/odp/api/abi/rwlock.h
index 78d7c1a4a..8194aa649 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/rwlock.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/rwlock.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/abi-default/rwlock.h>
diff --git a/platform/linux-generic/include-abi/odp/api/abi/rwlock_recursive.h b/platform/linux-generic/include-abi/odp/api/abi/rwlock_recursive.h
index ab7150605..fb9142332 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/rwlock_recursive.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/rwlock_recursive.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/abi-default/rwlock_recursive.h>
diff --git a/platform/linux-generic/include-abi/odp/api/abi/schedule.h b/platform/linux-generic/include-abi/odp/api/abi/schedule.h
index bb28886b0..c65aa6a22 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/schedule.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/schedule.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/schedule_types.h b/platform/linux-generic/include-abi/odp/api/abi/schedule_types.h
index d5164ff79..1b2990c2b 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/schedule_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/schedule_types.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/abi-default/schedule_types.h>
diff --git a/platform/linux-generic/include-abi/odp/api/abi/shared_memory.h b/platform/linux-generic/include-abi/odp/api/abi/shared_memory.h
index bfcb9ebe5..a7ef9c5a9 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/shared_memory.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/shared_memory.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
diff --git a/platform/linux-generic/include-abi/odp/api/abi/spinlock.h b/platform/linux-generic/include-abi/odp/api/abi/spinlock.h
index d1e5fa1e9..22f093ab5 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/spinlock.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/spinlock.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/abi-default/spinlock.h>
diff --git a/platform/linux-generic/include-abi/odp/api/abi/spinlock_recursive.h b/platform/linux-generic/include-abi/odp/api/abi/spinlock_recursive.h
index cdcbae1b4..f7d2e5212 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/spinlock_recursive.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/spinlock_recursive.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/abi-default/spinlock_recursive.h>
diff --git a/platform/linux-generic/include-abi/odp/api/abi/stash.h b/platform/linux-generic/include-abi/odp/api/abi/stash.h
index 69bf989d6..f28f8ee96 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/stash.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/stash.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/stash_types.h b/platform/linux-generic/include-abi/odp/api/abi/stash_types.h
index 2a4115886..140f5a2ef 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/stash_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/stash_types.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/std.h b/platform/linux-generic/include-abi/odp/api/abi/std.h
index 201fca18e..639e730b4 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/std.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/std.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/std_types.h b/platform/linux-generic/include-abi/odp/api/abi/std_types.h
index 594e6f9dd..c0d930e1f 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/std_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/std_types.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/abi-default/std_types.h>
diff --git a/platform/linux-generic/include-abi/odp/api/abi/sync.h b/platform/linux-generic/include-abi/odp/api/abi/sync.h
index 276514b58..b1053f478 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/sync.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/sync.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include-abi/odp/api/abi/thread.h b/platform/linux-generic/include-abi/odp/api/abi/thread.h
index 14c074b95..31145dade 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/thread.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/thread.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
/* Inlined API functions */
diff --git a/platform/linux-generic/include-abi/odp/api/abi/thrmask.h b/platform/linux-generic/include-abi/odp/api/abi/thrmask.h
index ab05cd83f..2bb61d233 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/thrmask.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/thrmask.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/abi-default/thrmask.h>
diff --git a/platform/linux-generic/include-abi/odp/api/abi/ticketlock.h b/platform/linux-generic/include-abi/odp/api/abi/ticketlock.h
index b621bea7e..1a9322264 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/ticketlock.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/ticketlock.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
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 62c7e2b67..d641ddda5 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/time.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/time.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
/* Inlined API functions */
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
index cba80f508..a415200a0 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/time_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/time_types.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
*/
#include <odp/api/abi-default/time_types.h>
diff --git a/platform/linux-generic/include-abi/odp/api/abi/timer.h b/platform/linux-generic/include-abi/odp/api/abi/timer.h
index 0a3b3a9cc..f9209591f 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/timer.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/timer.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
/* Inlined functions for non-ABI compat mode */
diff --git a/platform/linux-generic/include-abi/odp/api/abi/timer_types.h b/platform/linux-generic/include-abi/odp/api/abi/timer_types.h
index 6cfa37a36..efcf25fcc 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/timer_types.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/timer_types.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
*/
diff --git a/platform/linux-generic/include-abi/odp/api/abi/traffic_mngr.h b/platform/linux-generic/include-abi/odp/api/abi/traffic_mngr.h
index 0e6bc7982..9a457c370 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/traffic_mngr.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/traffic_mngr.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/abi-default/traffic_mngr.h>
diff --git a/platform/linux-generic/include-abi/odp/api/abi/version.h b/platform/linux-generic/include-abi/odp/api/abi/version.h
index 429d4f3fa..cf4b9a128 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/version.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/version.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/abi-default/version.h>
diff --git a/platform/linux-generic/include/ishmphy_internal.h b/platform/linux-generic/include/ishmphy_internal.h
index 3ed29f40a..f979825c5 100644
--- a/platform/linux-generic/include/ishmphy_internal.h
+++ b/platform/linux-generic/include/ishmphy_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#ifndef _ISHMPHY_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp/api/plat/atomic_inlines.h b/platform/linux-generic/include/odp/api/plat/atomic_inlines.h
index e47559102..fabf2eb04 100644
--- a/platform/linux-generic/include/odp/api/plat/atomic_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/atomic_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
/**
diff --git a/platform/linux-generic/include/odp/api/plat/buffer_inline_types.h b/platform/linux-generic/include/odp/api/plat/buffer_inline_types.h
index f64a176f5..3b0307cea 100644
--- a/platform/linux-generic/include/odp/api/plat/buffer_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/buffer_inline_types.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_BUFFER_INLINE_TYPES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/buffer_inlines.h b/platform/linux-generic/include/odp/api/plat/buffer_inlines.h
index 75ef36cf3..4ef9687e7 100644
--- a/platform/linux-generic/include/odp/api/plat/buffer_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/buffer_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2019-2023 Nokia
*/
#ifndef ODP_PLAT_BUFFER_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h b/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h
index 31d2f1db9..692c66c74 100644
--- a/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include/odp/api/plat/cpu_inlines.h b/platform/linux-generic/include/odp/api/plat/cpu_inlines.h
index bb1b89154..556597441 100644
--- a/platform/linux-generic/include/odp/api/plat/cpu_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/cpu_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
#ifndef ODP_PLAT_CPU_INLINES_H_
@@ -19,11 +17,21 @@
#ifndef _ODP_NO_INLINE
/* Inline functions by default */
#define _ODP_INLINE static inline
- #define odp_cpu_pause __odp_cpu_pause
- #define odp_cpu_cycles __odp_cpu_cycles
- #define odp_cpu_cycles_max __odp_cpu_cycles_max
- #define odp_cpu_cycles_resolution __odp_cpu_cycles_resolution
- #define odp_cpu_cycles_diff __odp_cpu_cycles_diff
+ #define odp_cpu_pause __odp_cpu_pause
+ #define odp_cpu_cycles __odp_cpu_cycles
+ #define odp_cpu_cycles_max __odp_cpu_cycles_max
+ #define odp_cpu_cycles_resolution __odp_cpu_cycles_resolution
+ #define odp_cpu_cycles_diff __odp_cpu_cycles_diff
+ #define odp_prefetch __odp_prefetch
+ #define odp_prefetch_l1 __odp_prefetch_l1
+ #define odp_prefetch_l2 __odp_prefetch_l2
+ #define odp_prefetch_l3 __odp_prefetch_l3
+ #define odp_prefetch_store __odp_prefetch_store
+ #define odp_prefetch_store_l1 __odp_prefetch_store_l1
+ #define odp_prefetch_store_l2 __odp_prefetch_store_l2
+ #define odp_prefetch_store_l3 __odp_prefetch_store_l3
+ #define odp_prefetch_strm_l1 __odp_prefetch_strm_l1
+ #define odp_prefetch_store_strm_l1 __odp_prefetch_store_strm_l1
#else
#define _ODP_INLINE
#endif
@@ -56,6 +64,62 @@ _ODP_INLINE uint64_t odp_cpu_cycles_diff(uint64_t c2, uint64_t c1)
return c2 + (odp_cpu_cycles_max() - c1) + _odp_cpu_cycles_resolution();
}
+_ODP_INLINE void odp_prefetch(const void *ptr)
+{
+ /*
+ * __builtin_prefetch (const void *addr, rw, locality)
+ *
+ * rw 0..1 (0: read, 1: write)
+ * locality 0..3 (0: don't leave to cache, 3: leave on all cache levels)
+ */
+ __builtin_prefetch(ptr, 0, 3);
+}
+
+_ODP_INLINE void odp_prefetch_l1(const void *ptr)
+{
+ __builtin_prefetch(ptr, 0, 3);
+}
+
+_ODP_INLINE void odp_prefetch_l2(const void *ptr)
+{
+ __builtin_prefetch(ptr, 0, 2);
+}
+
+_ODP_INLINE void odp_prefetch_l3(const void *ptr)
+{
+ __builtin_prefetch(ptr, 0, 1);
+}
+
+_ODP_INLINE void odp_prefetch_store(const void *ptr)
+{
+ __builtin_prefetch(ptr, 1, 3);
+}
+
+_ODP_INLINE void odp_prefetch_store_l1(const void *ptr)
+{
+ __builtin_prefetch(ptr, 1, 3);
+}
+
+_ODP_INLINE void odp_prefetch_store_l2(const void *ptr)
+{
+ __builtin_prefetch(ptr, 1, 2);
+}
+
+_ODP_INLINE void odp_prefetch_store_l3(const void *ptr)
+{
+ __builtin_prefetch(ptr, 1, 1);
+}
+
+_ODP_INLINE void odp_prefetch_strm_l1(const void *ptr)
+{
+ __builtin_prefetch(ptr, 0, 0);
+}
+
+_ODP_INLINE void odp_prefetch_store_strm_l1(const void *ptr)
+{
+ __builtin_prefetch(ptr, 1, 0);
+}
+
/** @endcond */
#endif
diff --git a/platform/linux-generic/include/odp/api/plat/crypto_inlines.h b/platform/linux-generic/include/odp/api/plat/crypto_inlines.h
index f350edfea..c8b6ae5ba 100644
--- a/platform/linux-generic/include/odp/api/plat/crypto_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/crypto_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_CRYPTO_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/debug_inlines.h b/platform/linux-generic/include/odp/api/plat/debug_inlines.h
index 0755b1fda..8502cb05e 100644
--- a/platform/linux-generic/include/odp/api/plat/debug_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/debug_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2020-2023 Nokia
*/
/**
diff --git a/platform/linux-generic/include/odp/api/plat/dma_inlines.h b/platform/linux-generic/include/odp/api/plat/dma_inlines.h
index 84b5fef5b..da3b25c0d 100644
--- a/platform/linux-generic/include/odp/api/plat/dma_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/dma_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
*/
#ifndef ODP_PLAT_DMA_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/event_inline_types.h b/platform/linux-generic/include/odp/api/plat/event_inline_types.h
index cbf01588f..641b2a290 100644
--- a/platform/linux-generic/include/odp/api/plat/event_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/event_inline_types.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_EVENT_INLINE_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 990575166..0bff84aef 100644
--- a/platform/linux-generic/include/odp/api/plat/event_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/event_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2022-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2022-2024 Nokia
*/
#ifndef ODP_PLAT_EVENT_INLINES_H_
@@ -31,6 +29,7 @@
#define odp_event_pool __odp_event_pool
#define odp_event_user_area __odp_event_user_area
#define odp_event_user_area_and_flag __odp_event_user_area_and_flag
+ #define odp_event_user_flag_set __odp_event_user_flag_set
#define odp_event_subtype __odp_event_subtype
#define odp_event_types __odp_event_types
#define odp_event_types_multi __odp_event_types_multi
@@ -154,6 +153,34 @@ _ODP_INLINE void *odp_event_user_area_and_flag(odp_event_t event, int *flag)
}
}
+_ODP_INLINE void odp_event_user_flag_set(odp_event_t event, int val)
+{
+ const odp_event_type_t type = __odp_event_type_get(event);
+
+ switch (type) {
+ case ODP_EVENT_PACKET:
+ {
+ odp_packet_t pkt = (odp_packet_t)event;
+ _odp_packet_flags_t *flags = _odp_pkt_get_ptr(pkt, _odp_packet_flags_t, flags);
+
+ flags->user_flag = !!val;
+ return;
+ }
+ case ODP_EVENT_PACKET_VECTOR:
+ {
+ odp_packet_vector_t pktv = (odp_packet_vector_t)event;
+ _odp_event_vector_flags_t *flags =
+ _odp_event_vect_get_ptr(pktv, _odp_event_vector_flags_t, flags);
+
+ flags->user_flag = !!val;
+ return;
+ }
+ default:
+ /* Nothing to do */
+ return;
+ }
+}
+
_ODP_INLINE odp_event_subtype_t odp_event_subtype(odp_event_t event)
{
return __odp_event_subtype_get(event);
diff --git a/platform/linux-generic/include/odp/api/plat/event_validation_external.h b/platform/linux-generic/include/odp/api/plat/event_validation_external.h
index 7f5c0364f..05d98bcf2 100644
--- a/platform/linux-generic/include/odp/api/plat/event_validation_external.h
+++ b/platform/linux-generic/include/odp/api/plat/event_validation_external.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
*/
/**
diff --git a/platform/linux-generic/include/odp/api/plat/event_vector_inline_types.h b/platform/linux-generic/include/odp/api/plat/event_vector_inline_types.h
index 773f5171c..7b956be5d 100644
--- a/platform/linux-generic/include/odp/api/plat/event_vector_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/event_vector_inline_types.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020 Nokia
*/
#ifndef ODP_PLAT_EVENT_VECTOR_INLINE_TYPES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/hash_inlines.h b/platform/linux-generic/include/odp/api/plat/hash_inlines.h
index b38a34d53..db781597f 100644
--- a/platform/linux-generic/include/odp/api/plat/hash_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/hash_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_PLAT_HASH_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/ipsec_inlines.h b/platform/linux-generic/include/odp/api/plat/ipsec_inlines.h
index 1d1f6ec61..924708371 100644
--- a/platform/linux-generic/include/odp/api/plat/ipsec_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/ipsec_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_IPSEC_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h
index 9330d89f8..00ca1e694 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
/**
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 691965624..e819c48a3 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
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2019-2022 Nokia
*/
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 2dd74fa29..ff79013e6 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2019-2022 Nokia
*/
/**
@@ -14,6 +12,7 @@
#ifndef _ODP_PLAT_PACKET_INLINES_H_
#define _ODP_PLAT_PACKET_INLINES_H_
+#include <odp/api/cpu.h>
#include <odp/api/event.h>
#include <odp/api/hints.h>
#include <odp/api/packet_types.h>
diff --git a/platform/linux-generic/include/odp/api/plat/packet_io_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_io_inlines.h
index a3d1d0d61..5c7a815b5 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_io_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_io_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_PACKET_IO_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/packet_vector_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_vector_inlines.h
index 2f8e0a709..9aa15ae60 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_vector_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_vector_inlines.h
@@ -1,8 +1,5 @@
-/* Copyright (c) 2020-2022, Nokia
- *
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020-2022 Nokia
*/
/**
diff --git a/platform/linux-generic/include/odp/api/plat/pool_inline_types.h b/platform/linux-generic/include/odp/api/plat/pool_inline_types.h
index fbff7eda7..b1c078c6a 100644
--- a/platform/linux-generic/include/odp/api/plat/pool_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/pool_inline_types.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include/odp/api/plat/pool_inlines.h b/platform/linux-generic/include/odp/api/plat/pool_inlines.h
index 58d66fad2..9b206b9f7 100644
--- a/platform/linux-generic/include/odp/api/plat/pool_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/pool_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_POOL_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/queue_inline_types.h b/platform/linux-generic/include/odp/api/plat/queue_inline_types.h
index 593942072..c224ae092 100644
--- a/platform/linux-generic/include/odp/api/plat/queue_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/queue_inline_types.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2023 Nokia
*/
#ifndef ODP_PLAT_QUEUE_INLINE_TYPES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/queue_inlines.h b/platform/linux-generic/include/odp/api/plat/queue_inlines.h
index 609c0c9e4..1c8d369c3 100644
--- a/platform/linux-generic/include/odp/api/plat/queue_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/queue_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2023 Nokia
*/
#ifndef ODP_PLAT_QUEUE_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/rwlock_inlines.h b/platform/linux-generic/include/odp/api/plat/rwlock_inlines.h
index 0bb9d8c6e..7df3727dd 100644
--- a/platform/linux-generic/include/odp/api/plat/rwlock_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/rwlock_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_RWLOCK_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/rwlock_recursive_inlines.h b/platform/linux-generic/include/odp/api/plat/rwlock_recursive_inlines.h
index 21ad4be4a..ab9a03e21 100644
--- a/platform/linux-generic/include/odp/api/plat/rwlock_recursive_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/rwlock_recursive_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_RWLOCK_RECURSIVE_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/schedule_inline_types.h b/platform/linux-generic/include/odp/api/plat/schedule_inline_types.h
index 92089c9a0..17bad6488 100644
--- a/platform/linux-generic/include/odp/api/plat/schedule_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/schedule_inline_types.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_SCHEDULE_INLINE_TYPES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/schedule_inlines.h b/platform/linux-generic/include/odp/api/plat/schedule_inlines.h
index 733b068d9..2162bd8e6 100644
--- a/platform/linux-generic/include/odp/api/plat/schedule_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/schedule_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_SCHEDULE_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/spinlock_inlines.h b/platform/linux-generic/include/odp/api/plat/spinlock_inlines.h
index a04c43f88..6a07350de 100644
--- a/platform/linux-generic/include/odp/api/plat/spinlock_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/spinlock_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_SPINLOCK_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/spinlock_recursive_inlines.h b/platform/linux-generic/include/odp/api/plat/spinlock_recursive_inlines.h
index e795353f4..04d3ee11d 100644
--- a/platform/linux-generic/include/odp/api/plat/spinlock_recursive_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/spinlock_recursive_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_SPINLOCK_RECURSIVE_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/std_inlines.h b/platform/linux-generic/include/odp/api/plat/std_inlines.h
index 3f6a7e9d4..0e875258b 100644
--- a/platform/linux-generic/include/odp/api/plat/std_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/std_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#ifndef ODP_PLAT_STD_INLINE_H_
diff --git a/platform/linux-generic/include/odp/api/plat/strong_types.h b/platform/linux-generic/include/odp/api/plat/strong_types.h
index 6b61c7c27..3866c8080 100644
--- a/platform/linux-generic/include/odp/api/plat/strong_types.h
+++ b/platform/linux-generic/include/odp/api/plat/strong_types.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
diff --git a/platform/linux-generic/include/odp/api/plat/thread_inline_types.h b/platform/linux-generic/include/odp/api/plat/thread_inline_types.h
index d24263fa7..e594a37ff 100644
--- a/platform/linux-generic/include/odp/api/plat/thread_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/thread_inline_types.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_THREAD_INLINE_TYPES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/thread_inlines.h b/platform/linux-generic/include/odp/api/plat/thread_inlines.h
index 2b6957064..be8ee9725 100644
--- a/platform/linux-generic/include/odp/api/plat/thread_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/thread_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_PLAT_THREAD_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h b/platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h
index b596d1609..24eddf195 100644
--- a/platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#ifndef _ODP_PLAT_TICKETLOCK_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 8ead06f7b..d7295c9d0 100644
--- a/platform/linux-generic/include/odp/api/plat/time_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/time_inlines.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2020-2023 Nokia
*/
#ifndef ODP_PLAT_TIME_INLINES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/timer_inline_types.h b/platform/linux-generic/include/odp/api/plat/timer_inline_types.h
index 330cbe4ce..a89660bc2 100644
--- a/platform/linux-generic/include/odp/api/plat/timer_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/timer_inline_types.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_PLAT_TIMER_INLINE_TYPES_H_
diff --git a/platform/linux-generic/include/odp/api/plat/timer_inlines.h b/platform/linux-generic/include/odp/api/plat/timer_inlines.h
index d2982079f..c5ba380e5 100644
--- a/platform/linux-generic/include/odp/api/plat/timer_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/timer_inlines.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022-2023 Nokia
*/
#ifndef ODP_PLAT_TIMER_INLINES_H_
diff --git a/platform/linux-generic/include/odp_atomic_internal.h b/platform/linux-generic/include/odp_atomic_internal.h
index 6de8cd485..3e6c45a27 100644
--- a/platform/linux-generic/include/odp_atomic_internal.h
+++ b/platform/linux-generic/include/odp_atomic_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include/odp_bitset.h b/platform/linux-generic/include/odp_bitset.h
index e55b9ef1a..92212330b 100644
--- a/platform/linux-generic/include/odp_bitset.h
+++ b/platform/linux-generic/include/odp_bitset.h
@@ -1,9 +1,6 @@
-/* Copyright (c) 2017, ARM Limited. All rights reserved.
- *
- * Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#ifndef _ODP_BITSET_H_
diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h
index 676b9f116..66b2a454c 100644
--- a/platform/linux-generic/include/odp_buffer_internal.h
+++ b/platform/linux-generic/include/odp_buffer_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2021 Nokia
*/
/**
diff --git a/platform/linux-generic/include/odp_chksum_internal.h b/platform/linux-generic/include/odp_chksum_internal.h
index e589ecb94..04f79771c 100644
--- a/platform/linux-generic/include/odp_chksum_internal.h
+++ b/platform/linux-generic/include/odp_chksum_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020, 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020-2023 Nokia
*/
#ifndef ODP_CHKSUM_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_classification_datamodel.h b/platform/linux-generic/include/odp_classification_datamodel.h
index c042a5308..1da4ed1f7 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include/odp_classification_internal.h b/platform/linux-generic/include/odp_classification_internal.h
index 7841e64fb..4223af1b4 100644
--- a/platform/linux-generic/include/odp_classification_internal.h
+++ b/platform/linux-generic/include/odp_classification_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
/**
diff --git a/platform/linux-generic/include/odp_config_internal.h b/platform/linux-generic/include/odp_config_internal.h
index 89d89936c..c7147acaf 100644
--- a/platform/linux-generic/include/odp_config_internal.h
+++ b/platform/linux-generic/include/odp_config_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2019-2023 Nokia
*/
#ifndef ODP_CONFIG_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_debug_internal.h b/platform/linux-generic/include/odp_debug_internal.h
index d1fc0d0ba..456612aab 100644
--- a/platform/linux-generic/include/odp_debug_internal.h
+++ b/platform/linux-generic/include/odp_debug_internal.h
@@ -1,9 +1,8 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2020-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2020-2022 Nokia
*/
+
/**
* @file
*
diff --git a/platform/linux-generic/include/odp_errno_define.h b/platform/linux-generic/include/odp_errno_define.h
index 3f97618b0..7303c70c7 100644
--- a/platform/linux-generic/include/odp_errno_define.h
+++ b/platform/linux-generic/include/odp_errno_define.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include/odp_ethtool_rss.h b/platform/linux-generic/include/odp_ethtool_rss.h
index 66221aa51..2dfb30a3b 100644
--- a/platform/linux-generic/include/odp_ethtool_rss.h
+++ b/platform/linux-generic/include/odp_ethtool_rss.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_ETHTOOL_RSS_H_
diff --git a/platform/linux-generic/include/odp_ethtool_stats.h b/platform/linux-generic/include/odp_ethtool_stats.h
index 2888d1c81..d3de8ce88 100644
--- a/platform/linux-generic/include/odp_ethtool_stats.h
+++ b/platform/linux-generic/include/odp_ethtool_stats.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_ETHTOOL_H_
diff --git a/platform/linux-generic/include/odp_event_internal.h b/platform/linux-generic/include/odp_event_internal.h
index 1b85d64fc..33e6fa927 100644
--- a/platform/linux-generic/include/odp_event_internal.h
+++ b/platform/linux-generic/include/odp_event_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021-2022 Nokia
*/
/**
diff --git a/platform/linux-generic/include/odp_event_validation_internal.h b/platform/linux-generic/include/odp_event_validation_internal.h
index f4ac16f31..06be79e7a 100644
--- a/platform/linux-generic/include/odp_event_validation_internal.h
+++ b/platform/linux-generic/include/odp_event_validation_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
*/
#ifndef ODP_EVENT_VALIDATION_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_event_vector_internal.h b/platform/linux-generic/include/odp_event_vector_internal.h
index 39f9daf04..eab64dc9d 100644
--- a/platform/linux-generic/include/odp_event_vector_internal.h
+++ b/platform/linux-generic/include/odp_event_vector_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020-2023 Nokia
*/
/**
diff --git a/platform/linux-generic/include/odp_fdserver_internal.h b/platform/linux-generic/include/odp_fdserver_internal.h
index 0b0a9bb0e..8637b53be 100644
--- a/platform/linux-generic/include/odp_fdserver_internal.h
+++ b/platform/linux-generic/include/odp_fdserver_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#ifndef _FD_SERVER_INTERNAL_H
diff --git a/platform/linux-generic/include/odp_forward_typedefs_internal.h b/platform/linux-generic/include/odp_forward_typedefs_internal.h
index 350ad6a36..9212281fe 100644
--- a/platform/linux-generic/include/odp_forward_typedefs_internal.h
+++ b/platform/linux-generic/include/odp_forward_typedefs_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include/odp_global_data.h b/platform/linux-generic/include/odp_global_data.h
index 2a87192df..e532cf0e7 100644
--- a/platform/linux-generic/include/odp_global_data.h
+++ b/platform/linux-generic/include/odp_global_data.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2023 Nokia
*/
#ifndef ODP_GLOBAL_DATA_H_
diff --git a/platform/linux-generic/include/odp_init_internal.h b/platform/linux-generic/include/odp_init_internal.h
index ca5d68c87..4ee80114a 100644
--- a/platform/linux-generic/include/odp_init_internal.h
+++ b/platform/linux-generic/include/odp_init_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
*/
#ifndef ODP_INIT_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_ipsec_internal.h b/platform/linux-generic/include/odp_ipsec_internal.h
index b97aa7031..030cb6bf3 100644
--- a/platform/linux-generic/include/odp_ipsec_internal.h
+++ b/platform/linux-generic/include/odp_ipsec_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2018, 2020-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2018-2022 Nokia
*/
/**
diff --git a/platform/linux-generic/include/odp_ishmphy_internal.h b/platform/linux-generic/include/odp_ishmphy_internal.h
index 2bc9911ce..89178bd4e 100644
--- a/platform/linux-generic/include/odp_ishmphy_internal.h
+++ b/platform/linux-generic/include/odp_ishmphy_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#ifndef _ISHMPHY_INTERNAL_H
diff --git a/platform/linux-generic/include/odp_ishmpool_internal.h b/platform/linux-generic/include/odp_ishmpool_internal.h
index d5a0ccd47..4c1e071f5 100644
--- a/platform/linux-generic/include/odp_ishmpool_internal.h
+++ b/platform/linux-generic/include/odp_ishmpool_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#ifndef ODP_ISHMBUDDY_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_libconfig_internal.h b/platform/linux-generic/include/odp_libconfig_internal.h
index 3f051547b..98320d823 100644
--- a/platform/linux-generic/include/odp_libconfig_internal.h
+++ b/platform/linux-generic/include/odp_libconfig_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include/odp_llqueue.h b/platform/linux-generic/include/odp_llqueue.h
index 29810ebf3..40e2b2dda 100644
--- a/platform/linux-generic/include/odp_llqueue.h
+++ b/platform/linux-generic/include/odp_llqueue.h
@@ -1,9 +1,6 @@
-/* Copyright (c) 2017, ARM Limited. All rights reserved.
- *
- * Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#ifndef ODP_LLQUEUE_H_
diff --git a/platform/linux-generic/include/odp_macros_internal.h b/platform/linux-generic/include/odp_macros_internal.h
index 047e550f9..88251d627 100644
--- a/platform/linux-generic/include/odp_macros_internal.h
+++ b/platform/linux-generic/include/odp_macros_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2022-2024, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2022-2024 Nokia
*/
/**
diff --git a/platform/linux-generic/include/odp_name_table_internal.h b/platform/linux-generic/include/odp_name_table_internal.h
index 9101acfa8..4d329c907 100644
--- a/platform/linux-generic/include/odp_name_table_internal.h
+++ b/platform/linux-generic/include/odp_name_table_internal.h
@@ -1,9 +1,6 @@
-/* Copyright 2015 EZchip Semiconductor Ltd. All Rights Reserved.
- *
- * Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015 EZchip Semiconductor Ltd.
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#ifndef ODP_INT_NAME_TABLE_H_
@@ -13,6 +10,7 @@
extern "C" {
#endif
+#include <odp/api/traffic_mngr.h>
#include <stdint.h>
typedef enum {
@@ -34,7 +32,7 @@ typedef enum {
typedef uint32_t _odp_int_name_t;
#define ODP_INVALID_NAME 0
-#define _ODP_INT_NAME_LEN 32
+#define _ODP_INT_NAME_LEN (ODP_TM_NAME_LEN - 1)
_odp_int_name_t _odp_int_name_tbl_add(const char *name,
uint8_t name_kind,
diff --git a/platform/linux-generic/include/odp_packet_dpdk.h b/platform/linux-generic/include/odp_packet_dpdk.h
index 23b1677a5..d40cf7d95 100644
--- a/platform/linux-generic/include/odp_packet_dpdk.h
+++ b/platform/linux-generic/include/odp_packet_dpdk.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2019-2022 Nokia
*/
#ifndef ODP_PACKET_DPDK_H
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index 0b03aa211..60b49a89b 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2022 Nokia
*/
/**
@@ -219,6 +217,25 @@ static inline void packet_subtype_set(odp_packet_t pkt, int subtype)
}
/**
+ * Reset packet metadata
+ */
+static inline void _odp_packet_reset_md(odp_packet_hdr_t *pkt_hdr)
+{
+ /* Clear all flags. Resets also return value of cls_mark, user_ptr, etc. */
+ pkt_hdr->p.input_flags.all = 0;
+ pkt_hdr->p.flags.all_flags = 0;
+
+ pkt_hdr->p.l2_offset = 0;
+ pkt_hdr->p.l3_offset = ODP_PACKET_OFFSET_INVALID;
+ pkt_hdr->p.l4_offset = ODP_PACKET_OFFSET_INVALID;
+
+ if (odp_unlikely(pkt_hdr->event_hdr.subtype != ODP_EVENT_PACKET_BASIC))
+ pkt_hdr->event_hdr.subtype = ODP_EVENT_PACKET_BASIC;
+
+ pkt_hdr->input = ODP_PKTIO_INVALID;
+}
+
+/**
* Initialize packet
*/
static inline void packet_init(odp_packet_hdr_t *pkt_hdr, uint32_t len)
@@ -240,14 +257,6 @@ static inline void packet_init(odp_packet_hdr_t *pkt_hdr, uint32_t len)
last->seg_len = seg_len;
}
- /* Clear all flags. Resets also return value of cls_mark, user_ptr, etc. */
- pkt_hdr->p.input_flags.all = 0;
- pkt_hdr->p.flags.all_flags = 0;
-
- pkt_hdr->p.l2_offset = 0;
- pkt_hdr->p.l3_offset = ODP_PACKET_OFFSET_INVALID;
- pkt_hdr->p.l4_offset = ODP_PACKET_OFFSET_INVALID;
-
/*
* Packet headroom is set from the pool's headroom
* Packet tailroom is rounded up to fill the last
@@ -257,10 +266,7 @@ static inline void packet_init(odp_packet_hdr_t *pkt_hdr, uint32_t len)
pkt_hdr->headroom = pool->headroom;
pkt_hdr->tailroom = pool->seg_len - seg_len + pool->tailroom;
- if (odp_unlikely(pkt_hdr->event_hdr.subtype != ODP_EVENT_PACKET_BASIC))
- pkt_hdr->event_hdr.subtype = ODP_EVENT_PACKET_BASIC;
-
- pkt_hdr->input = ODP_PKTIO_INVALID;
+ _odp_packet_reset_md(pkt_hdr);
}
/**
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h
index 6c8a2305b..d8fb77c74 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2023 Nokia
*/
/**
diff --git a/platform/linux-generic/include/odp_packet_io_stats.h b/platform/linux-generic/include/odp_packet_io_stats.h
index c1b37fb29..b86e7b845 100644
--- a/platform/linux-generic/include/odp_packet_io_stats.h
+++ b/platform/linux-generic/include/odp_packet_io_stats.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_PACKET_IO_STATS_H_
diff --git a/platform/linux-generic/include/odp_packet_io_stats_common.h b/platform/linux-generic/include/odp_packet_io_stats_common.h
index 19bd7c448..7e7ef9723 100644
--- a/platform/linux-generic/include/odp_packet_io_stats_common.h
+++ b/platform/linux-generic/include/odp_packet_io_stats_common.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_PACKET_IO_STATS_COMMON_H_
diff --git a/platform/linux-generic/include/odp_parse_internal.h b/platform/linux-generic/include/odp_parse_internal.h
index 8b3fb480b..28a401c25 100644
--- a/platform/linux-generic/include/odp_parse_internal.h
+++ b/platform/linux-generic/include/odp_parse_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2022 Nokia
*/
#ifndef ODP_PARSE_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_pcapng.h b/platform/linux-generic/include/odp_pcapng.h
index 6f2a3dda5..1afe96867 100644
--- a/platform/linux-generic/include/odp_pcapng.h
+++ b/platform/linux-generic/include/odp_pcapng.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2019, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2019 Nokia
*/
#ifndef ODP_PCAPNG_H_
diff --git a/platform/linux-generic/include/odp_pkt_queue_internal.h b/platform/linux-generic/include/odp_pkt_queue_internal.h
index 03e5b575e..3c6ac7230 100644
--- a/platform/linux-generic/include/odp_pkt_queue_internal.h
+++ b/platform/linux-generic/include/odp_pkt_queue_internal.h
@@ -1,9 +1,6 @@
-/* Copyright 2015 EZchip Semiconductor Ltd. All Rights Reserved.
- *
- * Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015 EZchip Semiconductor Ltd.
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#ifndef _ODP_INT_PKT_QUEUE_H_
diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h
index 2c33bb4a2..b98e7e334 100644
--- a/platform/linux-generic/include/odp_pool_internal.h
+++ b/platform/linux-generic/include/odp_pool_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2022 Nokia
*/
/**
diff --git a/platform/linux-generic/include/odp_posix_extensions.h b/platform/linux-generic/include/odp_posix_extensions.h
index 93c8fdb6c..cda257d1d 100644
--- a/platform/linux-generic/include/odp_posix_extensions.h
+++ b/platform/linux-generic/include/odp_posix_extensions.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#ifndef ODP_POSIX_EXTENSIONS_H
diff --git a/platform/linux-generic/include/odp_print_internal.h b/platform/linux-generic/include/odp_print_internal.h
deleted file mode 100644
index 949a1cc70..000000000
--- a/platform/linux-generic/include/odp_print_internal.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef ODP_PRINT_INTERNAL_H_
-#define ODP_PRINT_INTERNAL_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stddef.h>
-
-int _odp_snprint(char *str, size_t size, const char *format, ...);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/platform/linux-generic/include/odp_queue_basic_internal.h b/platform/linux-generic/include/odp_queue_basic_internal.h
index 3cdcf8600..e6edec1cd 100644
--- a/platform/linux-generic/include/odp_queue_basic_internal.h
+++ b/platform/linux-generic/include/odp_queue_basic_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2023 Nokia
*/
#ifndef ODP_QUEUE_BASIC_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_queue_if.h b/platform/linux-generic/include/odp_queue_if.h
index ed4ec4e61..48be24b0a 100644
--- a/platform/linux-generic/include/odp_queue_if.h
+++ b/platform/linux-generic/include/odp_queue_if.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017, ARM Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_QUEUE_IF_H_
diff --git a/platform/linux-generic/include/odp_queue_lf.h b/platform/linux-generic/include/odp_queue_lf.h
index 9419812cf..f58327520 100644
--- a/platform/linux-generic/include/odp_queue_lf.h
+++ b/platform/linux-generic/include/odp_queue_lf.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_QUEUE_LF_H_
diff --git a/platform/linux-generic/include/odp_queue_scalable_internal.h b/platform/linux-generic/include/odp_queue_scalable_internal.h
index dccc2aef9..7ba668f5f 100644
--- a/platform/linux-generic/include/odp_queue_scalable_internal.h
+++ b/platform/linux-generic/include/odp_queue_scalable_internal.h
@@ -1,9 +1,6 @@
-/* Copyright (c) 2017, ARM Limited. All rights reserved.
- *
- * Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#ifndef ODP_QUEUE_SCALABLE_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_random_openssl_internal.h b/platform/linux-generic/include/odp_random_openssl_internal.h
index 5cb9006d1..fb4b78e81 100644
--- a/platform/linux-generic/include/odp_random_openssl_internal.h
+++ b/platform/linux-generic/include/odp_random_openssl_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020 Nokia
*/
#ifndef ODP_RANDOM_OPENSSL_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_random_std_internal.h b/platform/linux-generic/include/odp_random_std_internal.h
index fb350fd22..22583089c 100644
--- a/platform/linux-generic/include/odp_random_std_internal.h
+++ b/platform/linux-generic/include/odp_random_std_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020 Nokia
*/
#ifndef ODP_RANDOM_STD_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_ring_common.h b/platform/linux-generic/include/odp_ring_common.h
index a2d9e4be5..7c28abde8 100644
--- a/platform/linux-generic/include/odp_ring_common.h
+++ b/platform/linux-generic/include/odp_ring_common.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2019-2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2019-2021 Nokia
*/
#ifndef ODP_RING_COMMON_H_
diff --git a/platform/linux-generic/include/odp_ring_internal.h b/platform/linux-generic/include/odp_ring_internal.h
index 296a87116..53c5e944c 100644
--- a/platform/linux-generic/include/odp_ring_internal.h
+++ b/platform/linux-generic/include/odp_ring_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2019-2022 Nokia
*/
/* This header should NOT be included directly. There are no include guards for
diff --git a/platform/linux-generic/include/odp_ring_mpmc_internal.h b/platform/linux-generic/include/odp_ring_mpmc_internal.h
index 3526b3866..63e86baca 100644
--- a/platform/linux-generic/include/odp_ring_mpmc_internal.h
+++ b/platform/linux-generic/include/odp_ring_mpmc_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2023 Nokia
*/
#ifndef ODP_RING_MPMC_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_ring_mpmc_u32_internal.h b/platform/linux-generic/include/odp_ring_mpmc_u32_internal.h
index 4699b5b47..b5896f9d4 100644
--- a/platform/linux-generic/include/odp_ring_mpmc_u32_internal.h
+++ b/platform/linux-generic/include/odp_ring_mpmc_u32_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
*/
#ifndef ODP_RING_MPMC_U32_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_ring_mpmc_u64_internal.h b/platform/linux-generic/include/odp_ring_mpmc_u64_internal.h
index e7bf31a94..a77b38c3f 100644
--- a/platform/linux-generic/include/odp_ring_mpmc_u64_internal.h
+++ b/platform/linux-generic/include/odp_ring_mpmc_u64_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
*/
#ifndef ODP_RING_MPMC_U64_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_ring_ptr_internal.h b/platform/linux-generic/include/odp_ring_ptr_internal.h
index 13b2b2fbf..ee3c29ff0 100644
--- a/platform/linux-generic/include/odp_ring_ptr_internal.h
+++ b/platform/linux-generic/include/odp_ring_ptr_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2019, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2019 Nokia
*/
#ifndef ODP_RING_PTR_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_ring_spsc_internal.h b/platform/linux-generic/include/odp_ring_spsc_internal.h
index 23e7d8868..0b774f197 100644
--- a/platform/linux-generic/include/odp_ring_spsc_internal.h
+++ b/platform/linux-generic/include/odp_ring_spsc_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_RING_SPSC_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_ring_st_internal.h b/platform/linux-generic/include/odp_ring_st_internal.h
index 406d043b5..543ca9cb2 100644
--- a/platform/linux-generic/include/odp_ring_st_internal.h
+++ b/platform/linux-generic/include/odp_ring_st_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef ODP_RING_ST_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_ring_u32_internal.h b/platform/linux-generic/include/odp_ring_u32_internal.h
index baa02e4ca..2e91e1d88 100644
--- a/platform/linux-generic/include/odp_ring_u32_internal.h
+++ b/platform/linux-generic/include/odp_ring_u32_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2019, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2019 Nokia
*/
#ifndef ODP_RING_U32_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_ring_u64_internal.h b/platform/linux-generic/include/odp_ring_u64_internal.h
index 4b4c7b1b5..1de098d45 100644
--- a/platform/linux-generic/include/odp_ring_u64_internal.h
+++ b/platform/linux-generic/include/odp_ring_u64_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_RING_U64_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_schedule_if.h b/platform/linux-generic/include/odp_schedule_if.h
index 07f935bc9..7a61b1dc0 100644
--- a/platform/linux-generic/include/odp_schedule_if.h
+++ b/platform/linux-generic/include/odp_schedule_if.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_SCHEDULE_IF_H_
diff --git a/platform/linux-generic/include/odp_schedule_scalable.h b/platform/linux-generic/include/odp_schedule_scalable.h
index 28c0a9894..a2db327df 100644
--- a/platform/linux-generic/include/odp_schedule_scalable.h
+++ b/platform/linux-generic/include/odp_schedule_scalable.h
@@ -1,9 +1,6 @@
-/* Copyright (c) 2017, ARM Limited. All rights reserved.
- *
- * Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#ifndef ODP_SCHEDULE_SCALABLE_H
diff --git a/platform/linux-generic/include/odp_schedule_scalable_config.h b/platform/linux-generic/include/odp_schedule_scalable_config.h
index 3462d047b..1133d49aa 100644
--- a/platform/linux-generic/include/odp_schedule_scalable_config.h
+++ b/platform/linux-generic/include/odp_schedule_scalable_config.h
@@ -1,9 +1,6 @@
-/* Copyright (c) 2017, ARM Limited. All rights reserved.
- *
- * Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#ifndef ODP_SCHEDULE_SCALABLE_CONFIG_H_
diff --git a/platform/linux-generic/include/odp_schedule_scalable_ordered.h b/platform/linux-generic/include/odp_schedule_scalable_ordered.h
index be4894f73..ad2dfc8ee 100644
--- a/platform/linux-generic/include/odp_schedule_scalable_ordered.h
+++ b/platform/linux-generic/include/odp_schedule_scalable_ordered.h
@@ -1,9 +1,6 @@
-/* Copyright (c) 2017, ARM Limited. All rights reserved.
- *
- * Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#ifndef ODP_SCHEDULE_SCALABLE_ORDERED_H
diff --git a/platform/linux-generic/include/odp_shm_internal.h b/platform/linux-generic/include/odp_shm_internal.h
index 9e51ffad1..bd9566e74 100644
--- a/platform/linux-generic/include/odp_shm_internal.h
+++ b/platform/linux-generic/include/odp_shm_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2019, Nokia
- * Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2019 Nokia
*/
#ifndef ODP_SHM_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_socket_common.h b/platform/linux-generic/include/odp_socket_common.h
index f48dabc3b..bb89133a7 100644
--- a/platform/linux-generic/include/odp_socket_common.h
+++ b/platform/linux-generic/include/odp_socket_common.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2019, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2019 Nokia
*/
#ifndef ODP_SOCKET_COMMON_H_
diff --git a/platform/linux-generic/include/odp_sorted_list_internal.h b/platform/linux-generic/include/odp_sorted_list_internal.h
index 9e5a457dc..feb1fc7d6 100644
--- a/platform/linux-generic/include/odp_sorted_list_internal.h
+++ b/platform/linux-generic/include/odp_sorted_list_internal.h
@@ -1,9 +1,6 @@
-/* Copyright 2015 EZchip Semiconductor Ltd. All Rights Reserved.
- *
- * Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015 EZchip Semiconductor Ltd.
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#ifndef _ODP_INT_SORTED_LIST_H_
diff --git a/platform/linux-generic/include/odp_string_internal.h b/platform/linux-generic/include/odp_string_internal.h
new file mode 100644
index 000000000..37e9361af
--- /dev/null
+++ b/platform/linux-generic/include/odp_string_internal.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
+ */
+
+#ifndef ODP_STRING_INTERNAL_H_
+#define ODP_STRING_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stddef.h>
+
+/* Helps with snprintf() return value checking
+ *
+ * Otherwise like snprintf(), but returns always the number of characters
+ * printed (without the end mark) or zero on error. Terminates the string
+ * always with the end mark. */
+int _odp_snprint(char *str, size_t size, const char *format, ...);
+
+/*
+ * Copy a string
+ *
+ * Like strncpy(), but additionally ensures that the destination string is null
+ * terminated, unless sz is zero in which case returns dst without doing
+ * anything else.
+ */
+char *_odp_strcpy(char *restrict dst, const char *restrict src, size_t sz);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-generic/include/odp_sysfs_stats.h b/platform/linux-generic/include/odp_sysfs_stats.h
index 0adb67c84..8d7ac2327 100644
--- a/platform/linux-generic/include/odp_sysfs_stats.h
+++ b/platform/linux-generic/include/odp_sysfs_stats.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef ODP_SYSFS_STATS_H_
diff --git a/platform/linux-generic/include/odp_sysinfo_internal.h b/platform/linux-generic/include/odp_sysinfo_internal.h
index c14cf78d9..793d7986e 100644
--- a/platform/linux-generic/include/odp_sysinfo_internal.h
+++ b/platform/linux-generic/include/odp_sysinfo_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
*/
#ifndef ODP_SYSINFO_INTERNAL_H_
diff --git a/platform/linux-generic/include/odp_timer_internal.h b/platform/linux-generic/include/odp_timer_internal.h
index 38192d917..2351def95 100644
--- a/platform/linux-generic/include/odp_timer_internal.h
+++ b/platform/linux-generic/include/odp_timer_internal.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021-2022 Nokia
*/
/**
diff --git a/platform/linux-generic/include/odp_timer_wheel_internal.h b/platform/linux-generic/include/odp_timer_wheel_internal.h
index c0c411b91..f54c058d7 100644
--- a/platform/linux-generic/include/odp_timer_wheel_internal.h
+++ b/platform/linux-generic/include/odp_timer_wheel_internal.h
@@ -1,9 +1,6 @@
-/* Copyright 2015 EZchip Semiconductor Ltd. All Rights Reserved.
- *
- * Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015 EZchip Semiconductor Ltd.
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#ifndef _ODP_INT_TIMER_WHEEL_H_
diff --git a/platform/linux-generic/include/odp_traffic_mngr_internal.h b/platform/linux-generic/include/odp_traffic_mngr_internal.h
index 28744d8b1..960756340 100644
--- a/platform/linux-generic/include/odp_traffic_mngr_internal.h
+++ b/platform/linux-generic/include/odp_traffic_mngr_internal.h
@@ -1,9 +1,6 @@
-/* Copyright 2015 EZchip Semiconductor Ltd. All Rights Reserved.
- *
- * Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015 EZchip Semiconductor Ltd.
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
@@ -407,7 +404,7 @@ struct tm_system_s {
uint64_t current_time;
uint8_t tm_idx;
uint8_t first_enq;
- odp_bool_t is_idle;
+ odp_atomic_u32_t is_idle;
tm_status_t status;
uint64_t shaper_green_cnt;
diff --git a/platform/linux-generic/include/odp_types_internal.h b/platform/linux-generic/include/odp_types_internal.h
index a97ac9cd4..d69db19f6 100644
--- a/platform/linux-generic/include/odp_types_internal.h
+++ b/platform/linux-generic/include/odp_types_internal.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#ifndef ODP_TYPES_INTERNAL_H_
diff --git a/platform/linux-generic/include/protocols/eth.h b/platform/linux-generic/include/protocols/eth.h
index e66dd52c7..d9ea4f704 100644
--- a/platform/linux-generic/include/protocols/eth.h
+++ b/platform/linux-generic/include/protocols/eth.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include/protocols/ip.h b/platform/linux-generic/include/protocols/ip.h
index e145cbe25..97652d02c 100644
--- a/platform/linux-generic/include/protocols/ip.h
+++ b/platform/linux-generic/include/protocols/ip.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include/protocols/ipsec.h b/platform/linux-generic/include/protocols/ipsec.h
index 0eb320330..5bb0d2169 100644
--- a/platform/linux-generic/include/protocols/ipsec.h
+++ b/platform/linux-generic/include/protocols/ipsec.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
diff --git a/platform/linux-generic/include/protocols/sctp.h b/platform/linux-generic/include/protocols/sctp.h
index 0e7abb475..e8c4b0c03 100644
--- a/platform/linux-generic/include/protocols/sctp.h
+++ b/platform/linux-generic/include/protocols/sctp.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include/protocols/tcp.h b/platform/linux-generic/include/protocols/tcp.h
index 5b302be53..04620d571 100644
--- a/platform/linux-generic/include/protocols/tcp.h
+++ b/platform/linux-generic/include/protocols/tcp.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
diff --git a/platform/linux-generic/include/protocols/thash.h b/platform/linux-generic/include/protocols/thash.h
index 7e1bec549..f8539f524 100644
--- a/platform/linux-generic/include/protocols/thash.h
+++ b/platform/linux-generic/include/protocols/thash.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/include/protocols/udp.h b/platform/linux-generic/include/protocols/udp.h
index 2614d31ab..0eccbd44d 100644
--- a/platform/linux-generic/include/protocols/udp.h
+++ b/platform/linux-generic/include/protocols/udp.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
/**
diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4
index 3306849d2..d662ecfcd 100644
--- a/platform/linux-generic/m4/configure.m4
+++ b/platform/linux-generic/m4/configure.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2014 Linaro Limited
+#
+
ODP_IMPLEMENTATION_NAME="odp-linux"
ODP_LIB_NAME="odp-linux"
@@ -66,7 +70,6 @@ AC_CONFIG_FILES([platform/linux-generic/Makefile
platform/linux-generic/test/Makefile
platform/linux-generic/test/example/Makefile
platform/linux-generic/test/example/classifier/Makefile
- platform/linux-generic/test/example/generator/Makefile
platform/linux-generic/test/example/ipsec_api/Makefile
platform/linux-generic/test/example/ipsec_crypto/Makefile
platform/linux-generic/test/example/l2fwd_simple/Makefile
diff --git a/platform/linux-generic/m4/odp_cpu.m4 b/platform/linux-generic/m4/odp_cpu.m4
index 35a83faf6..f363813f1 100644
--- a/platform/linux-generic/m4/odp_cpu.m4
+++ b/platform/linux-generic/m4/odp_cpu.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021 Nokia
+#
+
##########################################################################
# Set ODP_CACHE_LINE_SIZE define
##########################################################################
diff --git a/platform/linux-generic/m4/odp_crypto.m4 b/platform/linux-generic/m4/odp_crypto.m4
index 1cec6edb4..e7cfa8865 100644
--- a/platform/linux-generic/m4/odp_crypto.m4
+++ b/platform/linux-generic/m4/odp_crypto.m4
@@ -1,3 +1,8 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2022 ARM Limited
+# Copyright (c) 2022 Nokia
+#
+
# ODP_CRYPTO
# ----------
# Select default crypto implementation
diff --git a/platform/linux-generic/m4/odp_dpdk.m4 b/platform/linux-generic/m4/odp_dpdk.m4
index dc3c9610e..2e101df30 100644
--- a/platform/linux-generic/m4/odp_dpdk.m4
+++ b/platform/linux-generic/m4/odp_dpdk.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2016 Linaro Limited
+#
+
##########################################################################
# Enable DPDK support
##########################################################################
diff --git a/platform/linux-generic/m4/odp_event_validation.m4 b/platform/linux-generic/m4/odp_event_validation.m4
index 08bb8902e..df466d4ee 100644
--- a/platform/linux-generic/m4/odp_event_validation.m4
+++ b/platform/linux-generic/m4/odp_event_validation.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2022 Nokia
+#
+
# ODP_EVENT_VALIDATION
# --------------------
# Select event validation level
diff --git a/platform/linux-generic/m4/odp_ipsec_mb.m4 b/platform/linux-generic/m4/odp_ipsec_mb.m4
index 3268d94c0..d85d179a3 100644
--- a/platform/linux-generic/m4/odp_ipsec_mb.m4
+++ b/platform/linux-generic/m4/odp_ipsec_mb.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2022 ARM Limited
+#
+
#########################################################################
# Check for libIPSec_MB availability
#########################################################################
diff --git a/platform/linux-generic/m4/odp_libconfig.m4 b/platform/linux-generic/m4/odp_libconfig.m4
index 77095e0fe..25ffd87a4 100644
--- a/platform/linux-generic/m4/odp_libconfig.m4
+++ b/platform/linux-generic/m4/odp_libconfig.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Nokia
+#
+
##########################################################################
# Configuration file version
##########################################################################
diff --git a/platform/linux-generic/m4/odp_ml.m4 b/platform/linux-generic/m4/odp_ml.m4
index a7b9a4fd6..ab424ab39 100644
--- a/platform/linux-generic/m4/odp_ml.m4
+++ b/platform/linux-generic/m4/odp_ml.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2023 Nokia
+#
+
##########################################################################
# Onnxruntime library path and name
##########################################################################
diff --git a/platform/linux-generic/m4/odp_openssl.m4 b/platform/linux-generic/m4/odp_openssl.m4
index 3d3f13a81..4f51b6b01 100644
--- a/platform/linux-generic/m4/odp_openssl.m4
+++ b/platform/linux-generic/m4/odp_openssl.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2015 Linaro Limited
+#
+
##########################################################################
# Enable/disable usage of OpenSSL library
##########################################################################
diff --git a/platform/linux-generic/m4/odp_pcap.m4 b/platform/linux-generic/m4/odp_pcap.m4
index dd1c16e69..cc74d0ca3 100644
--- a/platform/linux-generic/m4/odp_pcap.m4
+++ b/platform/linux-generic/m4/odp_pcap.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2015 Linaro Limited
+#
+
# ODP_PCAP([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# --------------------------------------------------
AC_DEFUN([ODP_PCAP],
diff --git a/platform/linux-generic/m4/odp_pcapng.m4 b/platform/linux-generic/m4/odp_pcapng.m4
index 6ad92db88..58e537478 100644
--- a/platform/linux-generic/m4/odp_pcapng.m4
+++ b/platform/linux-generic/m4/odp_pcapng.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2018 Linaro Limited
+#
+
##########################################################################
# Enable PCAPNG support
##########################################################################
diff --git a/platform/linux-generic/m4/odp_scheduler.m4 b/platform/linux-generic/m4/odp_scheduler.m4
index c199ceed5..d6f1c6e5c 100644
--- a/platform/linux-generic/m4/odp_scheduler.m4
+++ b/platform/linux-generic/m4/odp_scheduler.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2016 Linaro Limited
+#
+
# ODP_SCHEDULER
# -------------
# Select default scheduler
diff --git a/platform/linux-generic/m4/odp_wfe.m4 b/platform/linux-generic/m4/odp_wfe.m4
index f0f0542f7..678e6229b 100644
--- a/platform/linux-generic/m4/odp_wfe.m4
+++ b/platform/linux-generic/m4/odp_wfe.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2023 Nokia
+#
+
##########################################################################
# Enable/disable WFE based lock implementations
##########################################################################
diff --git a/platform/linux-generic/m4/odp_xdp.m4 b/platform/linux-generic/m4/odp_xdp.m4
index dcfd39ed7..6820088af 100644
--- a/platform/linux-generic/m4/odp_xdp.m4
+++ b/platform/linux-generic/m4/odp_xdp.m4
@@ -1,3 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2022 Nokia
+#
+
##########################################################################
# Check for libxdp availability
##########################################################################
diff --git a/platform/linux-generic/odp_atomic_api.c b/platform/linux-generic/odp_atomic_api.c
index c56f2c53f..f887f5c1c 100644
--- a/platform/linux-generic/odp_atomic_api.c
+++ b/platform/linux-generic/odp_atomic_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <odp/api/atomic.h>
diff --git a/platform/linux-generic/odp_barrier.c b/platform/linux-generic/odp_barrier.c
index 3747713f6..634f1fe4e 100644
--- a/platform/linux-generic/odp_barrier.c
+++ b/platform/linux-generic/odp_barrier.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
*/
#include <odp/api/barrier.h>
diff --git a/platform/linux-generic/odp_buffer.c b/platform/linux-generic/odp_buffer.c
index 82bf61add..af9b85edc 100644
--- a/platform/linux-generic/odp_buffer.c
+++ b/platform/linux-generic/odp_buffer.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2022 Nokia
*/
#include <odp/api/align.h>
@@ -13,7 +11,7 @@
#include <odp_pool_internal.h>
#include <odp_buffer_internal.h>
#include <odp_debug_internal.h>
-#include <odp_print_internal.h>
+#include <odp_string_internal.h>
#include <string.h>
#include <stdio.h>
diff --git a/platform/linux-generic/odp_buffer_api.c b/platform/linux-generic/odp_buffer_api.c
index 01f99b158..71f0e6d4e 100644
--- a/platform/linux-generic/odp_buffer_api.c
+++ b/platform/linux-generic/odp_buffer_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2019, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2019 Nokia
*/
#include <odp/api/buffer.h>
diff --git a/platform/linux-generic/odp_byteorder_api.c b/platform/linux-generic/odp_byteorder_api.c
index 4b9f0da7a..ebd945ef5 100644
--- a/platform/linux-generic/odp_byteorder_api.c
+++ b/platform/linux-generic/odp_byteorder_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#include <odp/api/byteorder.h>
diff --git a/platform/linux-generic/odp_chksum.c b/platform/linux-generic/odp_chksum.c
index a0336893e..33997fcb7 100644
--- a/platform/linux-generic/odp_chksum.c
+++ b/platform/linux-generic/odp_chksum.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/chksum.h>
diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c
index 016a8f0c5..83a676ce5 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2019-2023 Nokia
*/
#include <odp/api/classification.h>
@@ -21,6 +19,7 @@
#include <odp_packet_io_internal.h>
#include <odp_classification_datamodel.h>
#include <odp_classification_internal.h>
+#include <odp_string_internal.h>
#include <protocols/eth.h>
#include <protocols/ip.h>
#include <protocols/ipsec.h>
@@ -278,12 +277,11 @@ odp_cos_t odp_cls_cos_create(const char *name, const odp_cls_cos_param_t *param_
if (0 == cos->valid) {
char *cos_name = cos->name;
- if (name == NULL) {
+ if (name == NULL)
cos_name[0] = 0;
- } else {
- strncpy(cos_name, name, ODP_COS_NAME_LEN - 1);
- cos_name[ODP_COS_NAME_LEN - 1] = 0;
- }
+ else
+ _odp_strcpy(cos_name, name, ODP_COS_NAME_LEN);
+
for (j = 0; j < CLS_PMR_PER_COS_MAX; j++) {
cos->pmr[j] = NULL;
cos->linked_cos[j] = NULL;
diff --git a/platform/linux-generic/odp_comp.c b/platform/linux-generic/odp_comp.c
index 13999457f..21403bda3 100644
--- a/platform/linux-generic/odp_comp.c
+++ b/platform/linux-generic/odp_comp.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#include <string.h>
diff --git a/platform/linux-generic/odp_cpu_api.c b/platform/linux-generic/odp_cpu_api.c
index 503fbd4c7..16107e701 100644
--- a/platform/linux-generic/odp_cpu_api.c
+++ b/platform/linux-generic/odp_cpu_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#include <odp/api/cpu.h>
diff --git a/platform/linux-generic/odp_cpumask.c b/platform/linux-generic/odp_cpumask.c
index 7d7575f51..778a851a3 100644
--- a/platform/linux-generic/odp_cpumask.c
+++ b/platform/linux-generic/odp_cpumask.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/odp_cpumask_task.c b/platform/linux-generic/odp_cpumask_task.c
index a579b2e7e..b0819bbf0 100644
--- a/platform/linux-generic/odp_cpumask_task.c
+++ b/platform/linux-generic/odp_cpumask_task.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2021-2022 Nokia
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/odp_crypto_api.c b/platform/linux-generic/odp_crypto_api.c
index 646472e2e..aaa167044 100644
--- a/platform/linux-generic/odp_crypto_api.c
+++ b/platform/linux-generic/odp_crypto_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#include <odp/api/crypto.h>
diff --git a/platform/linux-generic/odp_crypto_ipsecmb.c b/platform/linux-generic/odp_crypto_ipsecmb.c
index e58844098..917b5ff14 100644
--- a/platform/linux-generic/odp_crypto_ipsecmb.c
+++ b/platform/linux-generic/odp_crypto_ipsecmb.c
@@ -1,9 +1,7 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021, ARM Limited
- * Copyright (c) 2022-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021 ARM Limited
+ * Copyright (c) 2022-2023 Nokia
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/odp_crypto_null.c b/platform/linux-generic/odp_crypto_null.c
index 6eda0f455..91e65a5a8 100644
--- a/platform/linux-generic/odp_crypto_null.c
+++ b/platform/linux-generic/odp_crypto_null.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/odp_crypto_openssl.c b/platform/linux-generic/odp_crypto_openssl.c
index 879ce0b97..b67038280 100644
--- a/platform/linux-generic/odp_crypto_openssl.c
+++ b/platform/linux-generic/odp_crypto_openssl.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
#include <odp_posix_extensions.h>
@@ -1910,7 +1908,8 @@ int odp_crypto_cipher_capability(odp_cipher_alg_t cipher,
if (num < num_copy)
num_copy = num;
- memcpy(dst, src, num_copy * size);
+ if (dst)
+ memcpy(dst, src, num_copy * size);
return num;
}
@@ -2012,7 +2011,8 @@ int odp_crypto_auth_capability(odp_auth_alg_t auth,
if (num < num_copy)
num_copy = num;
- memcpy(dst, src, num_copy * size);
+ if (dst)
+ memcpy(dst, src, num_copy * size);
return num;
}
diff --git a/platform/linux-generic/odp_dma.c b/platform/linux-generic/odp_dma.c
index b3439498c..879a2a59b 100644
--- a/platform/linux-generic/odp_dma.c
+++ b/platform/linux-generic/odp_dma.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021-2023 Nokia
*/
#include <odp/api/dma.h>
@@ -23,6 +21,7 @@
#include <odp_init_internal.h>
#include <odp_event_internal.h>
#include <odp_pool_internal.h>
+#include <odp_string_internal.h>
#include <string.h>
#include <inttypes.h>
@@ -263,10 +262,8 @@ odp_dma_t odp_dma_create(const char *name, const odp_dma_param_t *param)
session->name[0] = 0;
- if (name) {
- strncpy(session->name, name, ODP_DMA_NAME_LEN - 1);
- session->name[ODP_DMA_NAME_LEN - 1] = 0;
- }
+ if (name)
+ _odp_strcpy(session->name, name, ODP_DMA_NAME_LEN);
session->dma_param = *param;
diff --git a/platform/linux-generic/odp_dma_api.c b/platform/linux-generic/odp_dma_api.c
index 1e1d5d91f..96b3f7ec3 100644
--- a/platform/linux-generic/odp_dma_api.c
+++ b/platform/linux-generic/odp_dma_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
*/
#include <odp/api/dma.h>
diff --git a/platform/linux-generic/odp_errno.c b/platform/linux-generic/odp_errno.c
index bce398834..6e9119a5f 100644
--- a/platform/linux-generic/odp_errno.c
+++ b/platform/linux-generic/odp_errno.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <odp/api/errno.h>
diff --git a/platform/linux-generic/odp_event.c b/platform/linux-generic/odp_event.c
index f3644f02b..ce2745497 100644
--- a/platform/linux-generic/odp_event.c
+++ b/platform/linux-generic/odp_event.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2020-2023 Nokia
*/
#include <odp/api/event.h>
diff --git a/platform/linux-generic/odp_event_api.c b/platform/linux-generic/odp_event_api.c
index 4fbc98ddf..bd4b1a2d5 100644
--- a/platform/linux-generic/odp_event_api.c
+++ b/platform/linux-generic/odp_event_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#include <odp/api/event.h>
diff --git a/platform/linux-generic/odp_event_validation.c b/platform/linux-generic/odp_event_validation.c
index c2d430f1a..f3cb98f7f 100644
--- a/platform/linux-generic/odp_event_validation.c
+++ b/platform/linux-generic/odp_event_validation.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
*/
#include <odp/api/atomic.h>
@@ -20,7 +18,7 @@
#include <odp_init_internal.h>
#include <odp_libconfig_internal.h>
#include <odp_macros_internal.h>
-#include <odp_print_internal.h>
+#include <odp_string_internal.h>
#include <inttypes.h>
#include <string.h>
diff --git a/platform/linux-generic/odp_fdserver.c b/platform/linux-generic/odp_fdserver.c
index e72df0669..9d866f6a1 100644
--- a/platform/linux-generic/odp_fdserver.c
+++ b/platform/linux-generic/odp_fdserver.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
/*
diff --git a/platform/linux-generic/odp_hash_api.c b/platform/linux-generic/odp_hash_api.c
index 893c9dc11..620ea0dfc 100644
--- a/platform/linux-generic/odp_hash_api.c
+++ b/platform/linux-generic/odp_hash_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#include <odp/api/hash.h>
diff --git a/platform/linux-generic/odp_hash_crc_gen.c b/platform/linux-generic/odp_hash_crc_gen.c
index f831c63b8..4090d3863 100644
--- a/platform/linux-generic/odp_hash_crc_gen.c
+++ b/platform/linux-generic/odp_hash_crc_gen.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#include <stdio.h>
@@ -82,37 +80,37 @@ static inline uint8_t reflect_u8(uint8_t byte)
/* Reflect 32 bits */
static inline uint32_t reflect_u32(uint32_t u32)
{
- uint8_t u8[4];
+ uint32_t r[4];
- u8[0] = reflect_u8((u32 & 0xff000000u) >> 24);
- u8[1] = reflect_u8((u32 & 0x00ff0000u) >> 16);
- u8[2] = reflect_u8((u32 & 0x0000ff00u) >> 8);
- u8[3] = reflect_u8(u32 & 0xffu);
+ r[0] = reflect_u8((u32 & 0xff000000u) >> 24);
+ r[1] = reflect_u8((u32 & 0x00ff0000u) >> 16);
+ r[2] = reflect_u8((u32 & 0x0000ff00u) >> 8);
+ r[3] = reflect_u8(u32 & 0xffu);
- return (u8[3] << 24) | (u8[2] << 16) | (u8[1] << 8) | u8[0];
+ return (r[3] << 24) | (r[2] << 16) | (r[1] << 8) | r[0];
}
/* Reflect 24 bits */
static inline uint32_t reflect_u24(uint32_t u32)
{
- uint8_t u8[4];
+ uint32_t r[4];
- u8[0] = reflect_u8((u32 & 0xff0000u) >> 16);
- u8[1] = reflect_u8((u32 & 0x00ff00u) >> 8);
- u8[2] = reflect_u8(u32 & 0xffu);
+ r[0] = reflect_u8((u32 & 0xff0000u) >> 16);
+ r[1] = reflect_u8((u32 & 0x00ff00u) >> 8);
+ r[2] = reflect_u8(u32 & 0xffu);
- return (u8[2] << 16) | (u8[1] << 8) | u8[0];
+ return (r[2] << 16) | (r[1] << 8) | r[0];
}
/* Reflect 16 bits */
static inline uint32_t reflect_u16(uint32_t u32)
{
- uint8_t u8[4];
+ uint32_t r[4];
- u8[0] = reflect_u8((u32 & 0xff00u) >> 8);
- u8[1] = reflect_u8(u32 & 0xffu);
+ r[0] = reflect_u8((u32 & 0xff00u) >> 8);
+ r[1] = reflect_u8(u32 & 0xffu);
- return (u8[1] << 8) | u8[0];
+ return (r[1] << 8) | r[0];
}
/* Generate table for a 32/24/16 bit CRCs.
diff --git a/platform/linux-generic/odp_impl.c b/platform/linux-generic/odp_impl.c
index f8af2c51f..0b192a82f 100644
--- a/platform/linux-generic/odp_impl.c
+++ b/platform/linux-generic/odp_impl.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
*/
#include <odp/autoheader_internal.h>
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index 795252df1..6c9c12860 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c
index ee402b935..033d7706d 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2018-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2018-2022 Nokia
*/
#include <odp/api/byteorder.h>
diff --git a/platform/linux-generic/odp_ipsec_api.c b/platform/linux-generic/odp_ipsec_api.c
index 1d1abe84a..b92cc9225 100644
--- a/platform/linux-generic/odp_ipsec_api.c
+++ b/platform/linux-generic/odp_ipsec_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#include <odp/api/ipsec.h>
diff --git a/platform/linux-generic/odp_ipsec_events.c b/platform/linux-generic/odp_ipsec_events.c
index 769cab78b..c88089d98 100644
--- a/platform/linux-generic/odp_ipsec_events.c
+++ b/platform/linux-generic/odp_ipsec_events.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/ipsec.h>
diff --git a/platform/linux-generic/odp_ipsec_sad.c b/platform/linux-generic/odp_ipsec_sad.c
index 89cc8aef7..34320522b 100644
--- a/platform/linux-generic/odp_ipsec_sad.c
+++ b/platform/linux-generic/odp_ipsec_sad.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2018-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2018-2023 Nokia
*/
#include <odp/api/atomic.h>
diff --git a/platform/linux-generic/odp_ishm.c b/platform/linux-generic/odp_ishm.c
index 3ef1894bc..84663078c 100644
--- a/platform/linux-generic/odp_ishm.c
+++ b/platform/linux-generic/odp_ishm.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2019, Nokia
- * Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2019 Nokia
*/
/* This file handles the internal shared memory: internal shared memory
@@ -49,6 +47,7 @@
#include <odp_ishmphy_internal.h>
#include <odp_ishmpool_internal.h>
#include <odp_libconfig_internal.h>
+#include <odp_string_internal.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@@ -652,6 +651,7 @@ static int create_file(int block_index, huge_flag_t huge, uint64_t len,
int oflag = O_RDWR | O_CREAT | O_TRUNC; /* flags for open */
char dir[ISHM_FILENAME_MAXLEN];
int ret;
+ const odp_bool_t use_huge = huge == HUGE;
/* No ishm_block_t for the master single VA memory file */
if (single_va) {
@@ -665,11 +665,10 @@ static int create_file(int block_index, huge_flag_t huge, uint64_t len,
}
/* huge dir must be known to create files there!: */
- if ((huge == HUGE) &&
- (!odp_global_ro.hugepage_info.default_huge_page_dir))
+ if (use_huge && !odp_global_ro.hugepage_info.default_huge_page_dir)
return -1;
- if (huge == HUGE)
+ if (use_huge)
snprintf(dir, ISHM_FILENAME_MAXLEN, "%s/%s",
odp_global_ro.hugepage_info.default_huge_page_dir,
odp_global_ro.uid);
@@ -685,7 +684,7 @@ static int create_file(int block_index, huge_flag_t huge, uint64_t len,
fd = open(filename, oflag, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd < 0) {
- if (huge != HUGE)
+ if (!use_huge)
_ODP_ERR("Normal page open failed: file=%s, "
"err=\"%s\"\n", filename, strerror(errno));
return -1;
@@ -699,9 +698,10 @@ static int create_file(int block_index, huge_flag_t huge, uint64_t len,
}
if (ret == -1) {
- _ODP_ERR("%s memory allocation failed: fd=%d, file=%s, "
- "err=\"%s\"\n", (huge == HUGE) ? "Huge page" :
- "Normal page", fd, filename, strerror(errno));
+ _ODP_LOG(use_huge ? ODP_LOG_WARN : ODP_LOG_ERR,
+ use_huge ? "WARN" : "ERR",
+ "%s page memory allocation failed: fd=%d, file=%s, err=\"%s\"\n",
+ use_huge ? "Huge" : "Normal", fd, filename, strerror(errno));
close(fd);
unlink(filename);
return -1;
@@ -1090,7 +1090,7 @@ int _odp_ishm_reserve(const char *name, uint64_t size, int fd,
/* save block name (if any given): */
if (name)
- strncpy(new_block->name, name, ISHM_NAME_MAXLEN - 1);
+ _odp_strcpy(new_block->name, name, ISHM_NAME_MAXLEN);
else
new_block->name[0] = 0;
diff --git a/platform/linux-generic/odp_ishmphy.c b/platform/linux-generic/odp_ishmphy.c
index 796482b98..046b254c3 100644
--- a/platform/linux-generic/odp_ishmphy.c
+++ b/platform/linux-generic/odp_ishmphy.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
/*
diff --git a/platform/linux-generic/odp_ishmpool.c b/platform/linux-generic/odp_ishmpool.c
index 89ec10695..fb2cf43c4 100644
--- a/platform/linux-generic/odp_ishmpool.c
+++ b/platform/linux-generic/odp_ishmpool.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
/* This file gathers the buddy and slab allocation functionality provided
diff --git a/platform/linux-generic/odp_libconfig.c b/platform/linux-generic/odp_libconfig.c
index d5e159e21..7c362a755 100644
--- a/platform/linux-generic/odp_libconfig.c
+++ b/platform/linux-generic/odp_libconfig.c
@@ -1,9 +1,7 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2020, Nokia
- * Copyright (c) 2021, Marvell
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2020 Nokia
+ * Copyright (c) 2021 Marvell
*/
#include <stdlib.h>
diff --git a/platform/linux-generic/odp_ml.c b/platform/linux-generic/odp_ml.c
index 6ab9e7177..a5d055f4f 100644
--- a/platform/linux-generic/odp_ml.c
+++ b/platform/linux-generic/odp_ml.c
@@ -26,6 +26,7 @@
#include <odp_libconfig_internal.h>
#include <odp_macros_internal.h>
#include <odp_pool_internal.h>
+#include <odp_string_internal.h>
#include <onnxruntime_c_api.h>
@@ -505,8 +506,7 @@ static int get_model_io_info(OrtSession *session, ml_model_t *mdl,
return -1;
}
- strncpy(input_info[i].name, name, ODP_ML_MODEL_IO_NAME_LEN - 1);
- input_info[i].name[ODP_ML_MODEL_IO_NAME_LEN - 1] = 0;
+ _odp_strcpy(input_info[i].name, name, ODP_ML_MODEL_IO_NAME_LEN);
/* Free memory allocated by SessionGetInputName */
status = ort_api->AllocatorFree(allocator, name);
@@ -556,8 +556,7 @@ static int get_model_io_info(OrtSession *session, ml_model_t *mdl,
return -1;
}
- strncpy(output_info[i].name, name, ODP_ML_MODEL_IO_NAME_LEN - 1);
- output_info[i].name[ODP_ML_MODEL_IO_NAME_LEN - 1] = 0;
+ _odp_strcpy(output_info[i].name, name, ODP_ML_MODEL_IO_NAME_LEN);
/* Free memory allocated by SessionGetOutputName */
status = ort_api->AllocatorFree(allocator, name);
@@ -784,23 +783,31 @@ static int check_io_shape(ml_model_t *mdl)
odp_ml_shape_info_t *shape;
for (uint32_t i = 0; i < mdl->info.num_inputs; i++) {
+ int num_dyn = 0;
+
shape = &mdl->input_info[i].shape;
- if (shape->type == ODP_ML_SHAPE_NONE) {
- _ODP_ERR("Undefined shape type for model input[%u]\n", i);
- return -1;
- }
+ switch (shape->type) {
+ case ODP_ML_SHAPE_STATIC:
+ break;
- if (shape->type == ODP_ML_SHAPE_STATIC)
- continue;
+ case ODP_ML_SHAPE_BATCH:
+ for (uint32_t j = 0; j < shape->num_dim; j++)
+ if (shape->dim[j] == ODP_ML_DIM_DYNAMIC)
+ num_dyn++;
- /* shape->type == ODP_ML_SHAPE_BATCH */
- for (uint32_t j = 0; j < shape->num_dim; j++) {
- if (shape->dim[j] == ODP_ML_DIM_DYNAMIC && !shape->dim_max[j]) {
- _ODP_ERR("Missing dim_max[%u] for dynamic sized input[%u], please"
- " provide via the extra_info of model param\n", j, i);
+ if (num_dyn != 1) {
+ _ODP_ERR("Incorrect number (%d) of dynamic dimensions "
+ "for model input[%u]\n",
+ num_dyn, i);
return -1;
}
+
+ break;
+
+ default:
+ _ODP_ERR("Undefined shape type for model input[%u]\n", i);
+ return -1;
}
}
@@ -917,10 +924,8 @@ odp_ml_model_t odp_ml_model_create(const char *name, const odp_ml_model_param_t
mdl->session_opts = session_opts;
info->index = i;
- if (name) {
- strncpy(info->name, name, ODP_ML_MODEL_NAME_LEN - 1);
- info->name[ODP_ML_MODEL_NAME_LEN - 1] = 0;
- }
+ if (name)
+ _odp_strcpy(info->name, name, ODP_ML_MODEL_NAME_LEN);
mdl->max_compl_id = param->max_compl_id;
for (uint32_t j = 0; j < ML_MAX_COMPL_ID; j++)
@@ -2523,7 +2528,7 @@ static int read_config_file(ort_run_opts_t *opts)
_ODP_PRINT(" %s: %i\n", conf_str, opts->enable_profiling);
conf_str = "ml.execution_mode";
- if (_odp_libconfig_lookup_str(conf_str, mode_str, ML_MAX_CONFIG_STR_LEN) < 0) {
+ if (_odp_libconfig_lookup_str(conf_str, mode_str, ML_MAX_CONFIG_STR_LEN - 1) < 0) {
_ODP_ERR("Config option '%s' not found.\n", conf_str);
return -1;
}
@@ -2550,7 +2555,7 @@ static int read_config_file(ort_run_opts_t *opts)
conf_str = "ml.graph_optimization_level";
if (_odp_libconfig_lookup_str(conf_str, opt_level_str,
- ML_MAX_CONFIG_STR_LEN) < 0) {
+ ML_MAX_CONFIG_STR_LEN - 1) < 0) {
_ODP_ERR("Config option '%s' not found.\n", conf_str);
return -1;
}
@@ -2563,7 +2568,7 @@ static int read_config_file(ort_run_opts_t *opts)
conf_str = "ml.optimized_model_filepath";
if (_odp_libconfig_lookup_str(conf_str, opts->opt_model_filepath,
- ML_MAX_CONFIG_STR_LEN) < 0) {
+ ML_MAX_CONFIG_STR_LEN - 1) < 0) {
_ODP_ERR("Config option '%s' not found.\n", conf_str);
return -1;
}
diff --git a/platform/linux-generic/odp_name_table.c b/platform/linux-generic/odp_name_table.c
index 7c93d594b..46a038ac7 100644
--- a/platform/linux-generic/odp_name_table.c
+++ b/platform/linux-generic/odp_name_table.c
@@ -1,9 +1,6 @@
- /* Copyright 2015 EZchip Semiconductor Ltd. All Rights Reserved.
-
- * Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+ /* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015 EZchip Semiconductor Ltd.
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <odp/api/hash.h>
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 17a4a9298..6559ba606 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2023 Nokia
*/
#include <odp/autoheader_external.h>
@@ -25,7 +23,7 @@
#include <odp_packet_internal.h>
#include <odp_packet_io_internal.h>
#include <odp_pool_internal.h>
-#include <odp_print_internal.h>
+#include <odp_string_internal.h>
/* Inlined API functions */
#include <odp/api/plat/byteorder_inlines.h>
@@ -701,6 +699,9 @@ void odp_packet_free(odp_packet_t pkt)
static inline void packet_free_multi_ev(const odp_packet_t pkt[], int num, _odp_ev_id_t id)
{
+ if (odp_unlikely(!num))
+ return;
+
odp_packet_hdr_t *pkt_hdrs[num];
int i;
int num_freed = 0;
@@ -736,6 +737,14 @@ void odp_packet_free_sp(const odp_packet_t pkt[], int num)
packet_free_multi_ev(pkt, num, _ODP_EV_PACKET_FREE_SP);
}
+uint32_t odp_packet_reset_max_len(odp_packet_t pkt)
+{
+ odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
+ pool_t *pool = _odp_pool_entry(pkt_hdr->event_hdr.pool);
+
+ return pool->seg_len * pkt_hdr->seg_count;
+}
+
int odp_packet_reset(odp_packet_t pkt, uint32_t len)
{
odp_packet_hdr_t *const pkt_hdr = packet_hdr(pkt);
@@ -757,6 +766,13 @@ int odp_packet_reset(odp_packet_t pkt, uint32_t len)
return 0;
}
+void odp_packet_reset_meta(odp_packet_t pkt)
+{
+ _ODP_ASSERT(pkt != ODP_PACKET_INVALID);
+
+ _odp_packet_reset_md(packet_hdr(pkt));
+}
+
int odp_event_filter_packet(const odp_event_t event[],
odp_packet_t packet[],
odp_event_t remain[], int num)
diff --git a/platform/linux-generic/odp_packet_api.c b/platform/linux-generic/odp_packet_api.c
index 61d03d0c8..0309c4e5a 100644
--- a/platform/linux-generic/odp_packet_api.c
+++ b/platform/linux-generic/odp_packet_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
*/
#include <odp/api/packet.h>
diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux-generic/odp_packet_flags.c
index 777da12ae..e119d136f 100644
--- a/platform/linux-generic/odp_packet_flags.c
+++ b/platform/linux-generic/odp_packet_flags.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
*/
#include <odp/api/plat/packet_flag_inlines.h>
diff --git a/platform/linux-generic/odp_packet_flags_api.c b/platform/linux-generic/odp_packet_flags_api.c
index e77f22c3e..91457504c 100644
--- a/platform/linux-generic/odp_packet_flags_api.c
+++ b/platform/linux-generic/odp_packet_flags_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
*/
#include <odp/api/packet_flags.h>
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 8283c41e6..f523d6de5 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2023 Nokia
*/
#include <odp_posix_extensions.h>
@@ -31,6 +29,7 @@
#include <odp_libconfig_internal.h>
#include <odp_packet_internal.h>
#include <odp_packet_io_internal.h>
+#include <odp_string_internal.h>
#include <odp_pcapng.h>
#include <odp_queue_if.h>
#include <odp_schedule_if.h>
@@ -229,8 +228,7 @@ static const char *strip_pktio_type(const char *name, char *type_out)
int type_len = if_name - name;
char pktio_type[type_len + 1];
- strncpy(pktio_type, name, type_len);
- pktio_type[type_len] = '\0';
+ _odp_strcpy(pktio_type, name, type_len + 1);
/* Remove colon */
if_name++;
@@ -301,7 +299,7 @@ static odp_pktio_t setup_pktio_entry(const char *name, odp_pool_t pool,
uint16_t pktin_frame_offset = pktio_global->config.pktin_frame_offset;
int ret = -1;
- if (strlen(name) >= PKTIO_NAME_LEN - 1) {
+ if (strlen(name) >= PKTIO_NAME_LEN) {
/* ioctl names limitation */
_ODP_ERR("pktio name %s is too long (max: %d chars)\n", name, PKTIO_NAME_LEN - 1);
return ODP_PKTIO_INVALID;
diff --git a/platform/linux-generic/odp_packet_io_api.c b/platform/linux-generic/odp_packet_io_api.c
index d0b66a67f..196d8ce01 100644
--- a/platform/linux-generic/odp_packet_io_api.c
+++ b/platform/linux-generic/odp_packet_io_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#include <odp/api/packet_io.h>
diff --git a/platform/linux-generic/odp_packet_vector.c b/platform/linux-generic/odp_packet_vector.c
index 698445181..80533da25 100644
--- a/platform/linux-generic/odp_packet_vector.c
+++ b/platform/linux-generic/odp_packet_vector.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020-2022 Nokia
*/
#include <odp/api/align.h>
@@ -14,7 +12,7 @@
#include <odp_debug_internal.h>
#include <odp_event_vector_internal.h>
#include <odp_pool_internal.h>
-#include <odp_print_internal.h>
+#include <odp_string_internal.h>
#include <inttypes.h>
#include <stdint.h>
diff --git a/platform/linux-generic/odp_parse.c b/platform/linux-generic/odp_parse.c
index d7fdb1439..60e8e5922 100644
--- a/platform/linux-generic/odp_parse.c
+++ b/platform/linux-generic/odp_parse.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2022 Nokia
*/
#include <odp_parse_internal.h>
@@ -42,17 +40,13 @@ uint16_t _odp_parse_eth(packet_parser_t *prs, const uint8_t **parseptr,
input_flags.jumbo = 1;
/* Handle Ethernet broadcast/multicast addresses */
- macaddr0 = odp_be_to_cpu_16(*((const uint16_t *)(const void *)eth));
+ macaddr0 = odp_be_to_cpu_16(*((const odp_una_u16_t *)eth));
if (odp_unlikely((macaddr0 & 0x0100) == 0x0100))
input_flags.eth_mcast = 1;
if (odp_unlikely(macaddr0 == 0xffff)) {
- macaddr2 =
- odp_be_to_cpu_16(*((const uint16_t *)
- (const void *)eth + 1));
- macaddr4 =
- odp_be_to_cpu_16(*((const uint16_t *)
- (const void *)eth + 2));
+ macaddr2 = odp_be_to_cpu_16(*((const odp_una_u16_t *)eth + 1));
+ macaddr4 = odp_be_to_cpu_16(*((const odp_una_u16_t *)eth + 2));
if ((macaddr2 == 0xffff) && (macaddr4 == 0xffff))
input_flags.eth_bcast = 1;
@@ -71,8 +65,7 @@ uint16_t _odp_parse_eth(packet_parser_t *prs, const uint8_t **parseptr,
ethtype = 0;
goto error;
}
- ethtype = odp_be_to_cpu_16(*((const uint16_t *)(uintptr_t)
- (*parseptr + 6)));
+ ethtype = odp_be_to_cpu_16(*((const odp_una_u16_t *)(*parseptr + 6)));
*offset += 8;
*parseptr += 8;
}
diff --git a/platform/linux-generic/odp_pcapng.c b/platform/linux-generic/odp_pcapng.c
index 7f11f4340..db9bf1af7 100644
--- a/platform/linux-generic/odp_pcapng.c
+++ b/platform/linux-generic/odp_pcapng.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2019-2022 Nokia
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/odp_pkt_queue.c b/platform/linux-generic/odp_pkt_queue.c
index d3dd6639f..1a5c9bd3c 100644
--- a/platform/linux-generic/odp_pkt_queue.c
+++ b/platform/linux-generic/odp_pkt_queue.c
@@ -1,9 +1,6 @@
-/* Copyright 2015 EZchip Semiconductor Ltd. All Rights Reserved.
-
- * Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015 EZchip Semiconductor Ltd.
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <odp/api/packet.h>
@@ -18,6 +15,7 @@
#include <malloc.h>
#include <stdio.h>
#include <inttypes.h>
+#include <stdalign.h>
#define NUM_PKTS 7
@@ -109,7 +107,7 @@ static int pkt_queue_free_list_add(queue_pool_t *pool,
queue_blks = region_desc->queue_blks;
if (!queue_blks) {
malloc_len = num_blks * sizeof(queue_blk_t);
- queue_blks = malloc(malloc_len);
+ queue_blks = aligned_alloc(alignof(queue_blk_t), malloc_len);
if (!queue_blks) {
free_alloced_queue_blks(alloc_cnt,
alloced_queue_blks);
diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index d3fde70f6..92f3fb7da 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2023 Nokia
*/
#include <odp/api/align.h>
@@ -32,6 +30,7 @@
#include <odp_timer_internal.h>
#include <odp_event_vector_internal.h>
#include <odp_buffer_internal.h>
+#include <odp_string_internal.h>
#include <string.h>
#include <stdio.h>
@@ -136,6 +135,9 @@ static void cache_flush(pool_cache_t *cache, pool_t *pool)
ring_ptr_t *ring;
uint32_t mask;
+ if (!pool->ring)
+ return;
+
ring = &pool->ring->hdr;
mask = pool->ring_mask;
@@ -429,7 +431,7 @@ static pool_t *reserve_pool(uint32_t shmflags, uint8_t pool_ext, uint32_t num)
odp_shm_t shm;
uint32_t mem_size;
pool_t *pool;
- char ring_name[ODP_POOL_NAME_LEN];
+ char ring_name[ODP_SHM_NAME_LEN];
for (i = 0; i < CONFIG_POOLS; i++) {
pool = _odp_pool_entry_from_idx(i);
@@ -647,12 +649,10 @@ static bool shm_is_from_huge_pages(odp_shm_t shm)
static void set_pool_name(pool_t *pool, const char *name)
{
- if (name == NULL) {
+ if (name == NULL)
pool->name[0] = 0;
- } else {
- strncpy(pool->name, name, ODP_POOL_NAME_LEN - 1);
- pool->name[ODP_POOL_NAME_LEN - 1] = 0;
- }
+ else
+ _odp_strcpy(pool->name, name, ODP_POOL_NAME_LEN);
}
static void set_pool_cache_size(pool_t *pool, uint32_t cache_size)
@@ -890,7 +890,7 @@ odp_pool_t _odp_pool_create(const char *name, const odp_pool_param_t *params,
if (!adj_size) {
_ODP_ERR("Calculating adjusted block size failed\n");
- return ODP_POOL_INVALID;
+ goto error;
}
}
@@ -995,6 +995,11 @@ error:
if (pool->uarea_shm != ODP_SHM_INVALID)
odp_shm_free(pool->uarea_shm);
+ if (pool->ring_shm != ODP_SHM_INVALID)
+ odp_shm_free(pool->ring_shm);
+
+ pool->ring = NULL;
+
LOCK(&pool->lock);
pool->reserved = 0;
UNLOCK(&pool->lock);
@@ -2047,6 +2052,8 @@ error:
if (pool->ring_shm != ODP_SHM_INVALID)
odp_shm_free(pool->ring_shm);
+ pool->ring = NULL;
+
LOCK(&pool->lock);
pool->reserved = 0;
UNLOCK(&pool->lock);
diff --git a/platform/linux-generic/odp_pool_api.c b/platform/linux-generic/odp_pool_api.c
index d9e0aabad..f81e864aa 100644
--- a/platform/linux-generic/odp_pool_api.c
+++ b/platform/linux-generic/odp_pool_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#include <odp/api/pool.h>
diff --git a/platform/linux-generic/odp_pool_mem_src_ops.c b/platform/linux-generic/odp_pool_mem_src_ops.c
index 2f8dc2078..c07abc78e 100644
--- a/platform/linux-generic/odp_pool_mem_src_ops.c
+++ b/platform/linux-generic/odp_pool_mem_src_ops.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#include <odp/autoheader_internal.h>
diff --git a/platform/linux-generic/odp_queue_api.c b/platform/linux-generic/odp_queue_api.c
index 495cf8746..e1beeeb58 100644
--- a/platform/linux-generic/odp_queue_api.c
+++ b/platform/linux-generic/odp_queue_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#include <odp/api/queue.h>
diff --git a/platform/linux-generic/odp_queue_basic.c b/platform/linux-generic/odp_queue_basic.c
index f9700742c..ec51b65f2 100644
--- a/platform/linux-generic/odp_queue_basic.c
+++ b/platform/linux-generic/odp_queue_basic.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
#include <odp/api/align.h>
@@ -33,6 +31,7 @@
#include <odp_queue_if.h>
#include <odp_schedule_if.h>
#include <odp_timer_internal.h>
+#include <odp_string_internal.h>
#include <inttypes.h>
#include <string.h>
@@ -1049,12 +1048,10 @@ static int queue_init(queue_entry_t *queue, const char *name,
queue_type = param->type;
- if (name == NULL) {
+ if (name == NULL)
queue->name[0] = 0;
- } else {
- strncpy(queue->name, name, ODP_QUEUE_NAME_LEN - 1);
- queue->name[ODP_QUEUE_NAME_LEN - 1] = 0;
- }
+ else
+ _odp_strcpy(queue->name, name, ODP_QUEUE_NAME_LEN);
memcpy(&queue->param, param, sizeof(odp_queue_param_t));
if (queue->param.sched.lock_count > _odp_sched_fn->max_ordered_locks())
return -1;
diff --git a/platform/linux-generic/odp_queue_if.c b/platform/linux-generic/odp_queue_if.c
index cc6594afd..248e7743a 100644
--- a/platform/linux-generic/odp_queue_if.c
+++ b/platform/linux-generic/odp_queue_if.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017, ARM Limited
- * Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2023 Nokia
*/
#include <odp/autoheader_internal.h>
diff --git a/platform/linux-generic/odp_queue_lf.c b/platform/linux-generic/odp_queue_lf.c
index 7c9ba4013..e7f8fa435 100644
--- a/platform/linux-generic/odp_queue_lf.c
+++ b/platform/linux-generic/odp_queue_lf.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#include <odp/api/queue.h>
diff --git a/platform/linux-generic/odp_queue_scalable.c b/platform/linux-generic/odp_queue_scalable.c
index bddaa532d..f2eb82d23 100644
--- a/platform/linux-generic/odp_queue_scalable.c
+++ b/platform/linux-generic/odp_queue_scalable.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017, ARM Limited
- * Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/hints.h>
@@ -29,6 +27,7 @@
#include <odp/api/plat/queue_inline_types.h>
#include <odp_global_data.h>
#include <odp_macros_internal.h>
+#include <odp_string_internal.h>
#include <string.h>
#include <inttypes.h>
@@ -104,8 +103,7 @@ static int queue_init(queue_entry_t *queue, const char *name,
sched_elem = &queue->sched_elem;
ring_size = param->size > 0 ?
_ODP_ROUNDUP_POWER2_U32(param->size) : CONFIG_SCAL_QUEUE_SIZE;
- strncpy(queue->name, name ? name : "", ODP_QUEUE_NAME_LEN - 1);
- queue->name[ODP_QUEUE_NAME_LEN - 1] = 0;
+ _odp_strcpy(queue->name, name ? name : "", ODP_QUEUE_NAME_LEN);
memcpy(&queue->param, param, sizeof(odp_queue_param_t));
size = ring_size * sizeof(_odp_event_hdr_t *);
diff --git a/platform/linux-generic/odp_queue_spsc.c b/platform/linux-generic/odp_queue_spsc.c
index 74cc740e0..bb2a7ce9f 100644
--- a/platform/linux-generic/odp_queue_spsc.c
+++ b/platform/linux-generic/odp_queue_spsc.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#include <odp_debug_internal.h>
diff --git a/platform/linux-generic/odp_random.c b/platform/linux-generic/odp_random.c
index 3060e8ed9..d96f03f39 100644
--- a/platform/linux-generic/odp_random.c
+++ b/platform/linux-generic/odp_random.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020 Nokia
*/
#include <stdint.h>
diff --git a/platform/linux-generic/odp_random_openssl.c b/platform/linux-generic/odp_random_openssl.c
index fdc40871b..c45cb470b 100644
--- a/platform/linux-generic/odp_random_openssl.c
+++ b/platform/linux-generic/odp_random_openssl.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2020, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2020 Nokia
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/odp_random_std.c b/platform/linux-generic/odp_random_std.c
index 50cd773f2..5ae47d596 100644
--- a/platform/linux-generic/odp_random_std.c
+++ b/platform/linux-generic/odp_random_std.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
*/
#include <odp/api/byteorder.h>
@@ -42,11 +40,11 @@ static int32_t _random_data(uint8_t *buf, uint32_t len, uint64_t *seed)
{
const uint32_t ret = len;
- if (!_ODP_UNALIGNED && ((uintptr_t)buf & 3) && len) {
+ if (!_ODP_UNALIGNED) {
uint32_t r = xorshift64s32(seed);
- if ((uintptr_t)buf & 1) {
- *(uint8_t *)(uintptr_t)buf = r & 0xff;
+ if (((uintptr_t)buf & 1) && len) {
+ *(uint8_t *)buf = r & 0xff;
r >>= 8;
buf += 1;
len -= 1;
@@ -57,24 +55,29 @@ static int32_t _random_data(uint8_t *buf, uint32_t len, uint64_t *seed)
buf += 2;
len -= 2;
}
- }
- for (uint32_t i = 0; i < len / 4; i++) {
- *(uint32_t *)(uintptr_t)buf = xorshift64s32(seed);
- buf += 4;
+ for (uint32_t i = 0; i < len / 4; i++) {
+ *(uint32_t *)(uintptr_t)buf = xorshift64s32(seed);
+ buf += 4;
+ }
+ } else {
+ for (uint32_t i = 0; i < len / 4; i++) {
+ *(odp_una_u32_t *)buf = xorshift64s32(seed);
+ buf += 4;
+ }
}
if (len & 3) {
uint32_t r = xorshift64s32(seed);
if (len & 2) {
- *(uint16_t *)(uintptr_t)buf = r & 0xffff;
+ *(odp_una_u16_t *)buf = r & 0xffff;
r >>= 16;
buf += 2;
}
if (len & 1)
- *(uint8_t *)(uintptr_t)buf = r & 0xff;
+ *(uint8_t *)buf = r & 0xff;
}
return ret;
diff --git a/platform/linux-generic/odp_rwlock_api.c b/platform/linux-generic/odp_rwlock_api.c
index 217479598..9969473d1 100644
--- a/platform/linux-generic/odp_rwlock_api.c
+++ b/platform/linux-generic/odp_rwlock_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#include <odp/api/rwlock.h>
diff --git a/platform/linux-generic/odp_rwlock_recursive_api.c b/platform/linux-generic/odp_rwlock_recursive_api.c
index b2580ae42..b13dd5522 100644
--- a/platform/linux-generic/odp_rwlock_recursive_api.c
+++ b/platform/linux-generic/odp_rwlock_recursive_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#include <odp/api/rwlock_recursive.h>
diff --git a/platform/linux-generic/odp_schedule_api.c b/platform/linux-generic/odp_schedule_api.c
index 4be1ba6f7..1a758405a 100644
--- a/platform/linux-generic/odp_schedule_api.c
+++ b/platform/linux-generic/odp_schedule_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#include <odp/api/schedule.h>
diff --git a/platform/linux-generic/odp_schedule_basic.c b/platform/linux-generic/odp_schedule_basic.c
index 379f1f828..69fbf7d6f 100644
--- a/platform/linux-generic/odp_schedule_basic.c
+++ b/platform/linux-generic/odp_schedule_basic.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2022 Nokia
*/
/*
@@ -40,7 +38,7 @@
#include <odp_global_data.h>
#include <odp_event_internal.h>
#include <odp_macros_internal.h>
-#include <odp_print_internal.h>
+#include <odp_string_internal.h>
#include <string.h>
#include <time.h>
@@ -674,13 +672,12 @@ static int schedule_init_global(void)
sched->sched_grp[ODP_SCHED_GROUP_ALL].allocated = 1;
sched->sched_grp[ODP_SCHED_GROUP_WORKER].allocated = 1;
sched->sched_grp[ODP_SCHED_GROUP_CONTROL].allocated = 1;
- strncpy(sched->sched_grp[ODP_SCHED_GROUP_ALL].name, "__SCHED_GROUP_ALL",
- ODP_SCHED_GROUP_NAME_LEN - 1);
- strncpy(sched->sched_grp[ODP_SCHED_GROUP_WORKER].name, "__SCHED_GROUP_WORKER",
- ODP_SCHED_GROUP_NAME_LEN - 1);
- strncpy(sched->sched_grp[ODP_SCHED_GROUP_CONTROL].name, "__SCHED_GROUP_CONTROL",
- ODP_SCHED_GROUP_NAME_LEN - 1);
-
+ _odp_strcpy(sched->sched_grp[ODP_SCHED_GROUP_ALL].name, "__SCHED_GROUP_ALL",
+ ODP_SCHED_GROUP_NAME_LEN);
+ _odp_strcpy(sched->sched_grp[ODP_SCHED_GROUP_WORKER].name, "__SCHED_GROUP_WORKER",
+ ODP_SCHED_GROUP_NAME_LEN);
+ _odp_strcpy(sched->sched_grp[ODP_SCHED_GROUP_CONTROL].name, "__SCHED_GROUP_CONTROL",
+ ODP_SCHED_GROUP_NAME_LEN);
odp_thrmask_setall(&sched->mask_all);
@@ -1922,7 +1919,7 @@ static odp_schedule_group_t schedule_group_create(const char *name,
return ODP_SCHED_GROUP_INVALID;
}
- int thr_tbl[count];
+ int thr_tbl[ODP_THREAD_COUNT_MAX];
if (count && threads_from_mask(thr_tbl, count, mask))
return ODP_SCHED_GROUP_INVALID;
@@ -1933,13 +1930,11 @@ static odp_schedule_group_t schedule_group_create(const char *name,
if (!sched->sched_grp[i].allocated) {
char *grp_name = sched->sched_grp[i].name;
- if (name == NULL) {
+ if (name == NULL)
grp_name[0] = 0;
- } else {
- strncpy(grp_name, name,
- ODP_SCHED_GROUP_NAME_LEN - 1);
- grp_name[ODP_SCHED_GROUP_NAME_LEN - 1] = 0;
- }
+ else
+ _odp_strcpy(grp_name, name,
+ ODP_SCHED_GROUP_NAME_LEN);
grp_update_mask(i, mask);
group = (odp_schedule_group_t)i;
diff --git a/platform/linux-generic/odp_schedule_if.c b/platform/linux-generic/odp_schedule_if.c
index f4d50f84e..c0f015623 100644
--- a/platform/linux-generic/odp_schedule_if.c
+++ b/platform/linux-generic/odp_schedule_if.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2021-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2021-2022 Nokia
*/
#include <odp/autoheader_internal.h>
diff --git a/platform/linux-generic/odp_schedule_scalable.c b/platform/linux-generic/odp_schedule_scalable.c
index 5166fb6d0..4947353d6 100644
--- a/platform/linux-generic/odp_schedule_scalable.c
+++ b/platform/linux-generic/odp_schedule_scalable.c
@@ -1,9 +1,6 @@
-/* Copyright (c) 2017, ARM Limited. All rights reserved.
- *
- * Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/align.h>
@@ -35,6 +32,7 @@
#include <odp_macros_internal.h>
#include <odp_packet_io_internal.h>
#include <odp_timer_internal.h>
+#include <odp_string_internal.h>
#include <limits.h>
#include <stdbool.h>
@@ -1468,7 +1466,7 @@ static odp_schedule_group_t schedule_group_create(const char *name,
if (sg == NULL)
goto shm_pool_alloc_failed;
- strncpy(sg->name, name ? name : "", ODP_SCHED_GROUP_NAME_LEN - 1);
+ _odp_strcpy(sg->name, name ? name : "", ODP_SCHED_GROUP_NAME_LEN);
global->sg_vec[sgi] = sg;
memset(sg->thr_actual, 0, sizeof(sg->thr_actual));
sg->thr_wanted = bitset_null();
diff --git a/platform/linux-generic/odp_schedule_scalable_ordered.c b/platform/linux-generic/odp_schedule_scalable_ordered.c
index f8568ce53..d8e0bcaaa 100644
--- a/platform/linux-generic/odp_schedule_scalable_ordered.c
+++ b/platform/linux-generic/odp_schedule_scalable_ordered.c
@@ -1,9 +1,6 @@
-/* Copyright (c) 2017, ARM Limited. All rights reserved.
- *
- * Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017 ARM Limited
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp/api/shared_memory.h>
diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c
index 030e95171..1ada5581b 100644
--- a/platform/linux-generic/odp_schedule_sp.c
+++ b/platform/linux-generic/odp_schedule_sp.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2019-2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2019-2021 Nokia
*/
/*
@@ -32,6 +30,7 @@
#include <odp_ring_u32_internal.h>
#include <odp_timer_internal.h>
#include <odp_queue_basic_internal.h>
+#include <odp_string_internal.h>
#include <odp_global_data.h>
#include <string.h>
@@ -107,7 +106,7 @@ typedef struct ODP_ALIGNED_CACHE sched_group_t {
/* All groups */
struct {
- char name[ODP_SCHED_GROUP_NAME_LEN + 1];
+ char name[ODP_SCHED_GROUP_NAME_LEN];
odp_thrmask_t mask;
int allocated;
} group[NUM_GROUP];
@@ -213,18 +212,18 @@ static int init_global(void)
for (i = 0; i < NUM_THREAD; i++)
odp_atomic_init_u32(&sched_group->s.thr[i].gen_cnt, 0);
- strncpy(sched_group->s.group[GROUP_ALL].name, "__group_all",
- ODP_SCHED_GROUP_NAME_LEN);
+ _odp_strcpy(sched_group->s.group[GROUP_ALL].name, "__group_all",
+ ODP_SCHED_GROUP_NAME_LEN);
odp_thrmask_zero(&sched_group->s.group[GROUP_ALL].mask);
sched_group->s.group[GROUP_ALL].allocated = 1;
- strncpy(sched_group->s.group[GROUP_WORKER].name, "__group_worker",
- ODP_SCHED_GROUP_NAME_LEN);
+ _odp_strcpy(sched_group->s.group[GROUP_WORKER].name, "__group_worker",
+ ODP_SCHED_GROUP_NAME_LEN);
odp_thrmask_zero(&sched_group->s.group[GROUP_WORKER].mask);
sched_group->s.group[GROUP_WORKER].allocated = 1;
- strncpy(sched_group->s.group[GROUP_CONTROL].name, "__group_control",
- ODP_SCHED_GROUP_NAME_LEN);
+ _odp_strcpy(sched_group->s.group[GROUP_CONTROL].name, "__group_control",
+ ODP_SCHED_GROUP_NAME_LEN);
odp_thrmask_zero(&sched_group->s.group[GROUP_CONTROL].mask);
sched_group->s.group[GROUP_CONTROL].allocated = 1;
@@ -804,13 +803,11 @@ static odp_schedule_group_t schedule_group_create(const char *name,
#if __GNUC__ >= 13
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
- if (name == NULL) {
+ if (name == NULL)
grp_name[0] = 0;
- } else {
- strncpy(grp_name, name,
- ODP_SCHED_GROUP_NAME_LEN - 1);
- grp_name[ODP_SCHED_GROUP_NAME_LEN - 1] = 0;
- }
+ else
+ _odp_strcpy(grp_name, name,
+ ODP_SCHED_GROUP_NAME_LEN);
#pragma GCC diagnostic pop
odp_thrmask_copy(&sched_group->s.group[i].mask, thrmask);
diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c
index ef4df3a33..a6ea427f3 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2021 Nokia
*/
#include <odp_config_internal.h>
diff --git a/platform/linux-generic/odp_sorted_list.c b/platform/linux-generic/odp_sorted_list.c
index c93b11886..3cca8be0c 100644
--- a/platform/linux-generic/odp_sorted_list.c
+++ b/platform/linux-generic/odp_sorted_list.c
@@ -1,9 +1,6 @@
-/* Copyright 2015 EZchip Semiconductor Ltd. All Rights Reserved.
- *
- * Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015 EZchip Semiconductor Ltd.
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <stdint.h>
diff --git a/platform/linux-generic/odp_spinlock_api.c b/platform/linux-generic/odp_spinlock_api.c
index 06925e9a5..27155d867 100644
--- a/platform/linux-generic/odp_spinlock_api.c
+++ b/platform/linux-generic/odp_spinlock_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#include <odp/api/spinlock.h>
diff --git a/platform/linux-generic/odp_spinlock_recursive_api.c b/platform/linux-generic/odp_spinlock_recursive_api.c
index 2b1e8b200..ae87cb2f3 100644
--- a/platform/linux-generic/odp_spinlock_recursive_api.c
+++ b/platform/linux-generic/odp_spinlock_recursive_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#include <odp/api/spinlock_recursive.h>
diff --git a/platform/linux-generic/odp_stash.c b/platform/linux-generic/odp_stash.c
index cb87a5fa5..154815dd4 100644
--- a/platform/linux-generic/odp_stash.c
+++ b/platform/linux-generic/odp_stash.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020-2023 Nokia
*/
#include <odp/api/align.h>
diff --git a/platform/linux-generic/odp_std.c b/platform/linux-generic/odp_std.c
index 9db5a35b3..dd2cd486c 100644
--- a/platform/linux-generic/odp_std.c
+++ b/platform/linux-generic/odp_std.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#include <odp/api/std.h>
diff --git a/platform/linux-generic/odp_std_api.c b/platform/linux-generic/odp_std_api.c
index 0bcd68de2..1843fb1ce 100644
--- a/platform/linux-generic/odp_std_api.c
+++ b/platform/linux-generic/odp_std_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#include <odp/api/std.h>
diff --git a/platform/linux-generic/odp_print.c b/platform/linux-generic/odp_string.c
index 30a06c2f4..9ba56dee8 100644
--- a/platform/linux-generic/odp_print.c
+++ b/platform/linux-generic/odp_string.c
@@ -1,19 +1,13 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#include <odp/api/hints.h>
-#include <odp_print_internal.h>
+#include <odp_string_internal.h>
#include <stdarg.h>
#include <stdio.h>
+#include <string.h>
-/* Helps with snprintf() return value checking
- *
- * Otherwise like snprintf(), but returns always the number of characters
- * printed (without the end mark) or zero on error. Terminates the string
- * always with the end mark. */
ODP_PRINTF_FORMAT(3, 4)
int _odp_snprint(char *str, size_t size, const char *format, ...)
{
@@ -45,3 +39,13 @@ int _odp_snprint(char *str, size_t size, const char *format, ...)
return len;
}
+
+char *_odp_strcpy(char *restrict dst, const char *restrict src, size_t sz)
+{
+ if (!sz)
+ return dst;
+
+ strncpy(dst, src, sz - 1);
+ dst[sz - 1] = 0;
+ return dst;
+}
diff --git a/platform/linux-generic/odp_sync_api.c b/platform/linux-generic/odp_sync_api.c
index 56c86db14..cbcf16802 100644
--- a/platform/linux-generic/odp_sync_api.c
+++ b/platform/linux-generic/odp_sync_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#include <odp/api/sync.h>
diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c
index a2593b531..c31068492 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -1,15 +1,10 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2020-2022, Nokia
- * All rights reserved.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2020-2022 Nokia
*
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-/*
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
+ * Copyright(c) 2010-2014 Intel Corporation
+ * - lib/eal/common/eal_common_string_fns.c
+ * - lib/eal/linux/eal_hugepage_info.c
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/odp_thread.c b/platform/linux-generic/odp_thread.c
index 88aec8f06..34dbb2990 100644
--- a/platform/linux-generic/odp_thread.c
+++ b/platform/linux-generic/odp_thread.c
@@ -1,13 +1,12 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#include <odp_posix_extensions.h>
#include <sched.h>
+#include <odp/api/atomic.h>
#include <odp/api/thread.h>
#include <odp/api/thrmask.h>
#include <odp/api/spinlock.h>
@@ -34,9 +33,9 @@ typedef struct {
odp_thrmask_t control;
};
- uint32_t num;
- uint32_t num_worker;
- uint32_t num_control;
+ odp_atomic_u32_t num;
+ odp_atomic_u32_t num_worker;
+ odp_atomic_u32_t num_control;
uint32_t num_max;
odp_spinlock_t lock;
} thread_globals_t;
@@ -78,6 +77,9 @@ int _odp_thread_init_global(void)
return -1;
memset(thread_globals, 0, sizeof(thread_globals_t));
+ odp_atomic_init_u32(&thread_globals->num, 0);
+ odp_atomic_init_u32(&thread_globals->num_worker, 0);
+ odp_atomic_init_u32(&thread_globals->num_control, 0);
odp_spinlock_init(&thread_globals->lock);
thread_globals->num_max = num_max;
_ODP_PRINT("System config:\n");
@@ -90,10 +92,7 @@ int _odp_thread_term_global(void)
{
int ret, num;
- odp_spinlock_lock(&thread_globals->lock);
- num = thread_globals->num;
- odp_spinlock_unlock(&thread_globals->lock);
-
+ num = odp_atomic_load_u32(&thread_globals->num);
if (num)
_ODP_ERR("%u threads have not called odp_term_local().\n", num);
@@ -109,7 +108,7 @@ static int alloc_id(odp_thread_type_t type)
int thr;
odp_thrmask_t *all = &thread_globals->all;
- if (thread_globals->num >= thread_globals->num_max)
+ if (odp_atomic_load_u32(&thread_globals->num) >= thread_globals->num_max)
return -1;
for (thr = 0; thr < (int)thread_globals->num_max; thr++) {
@@ -118,13 +117,13 @@ static int alloc_id(odp_thread_type_t type)
if (type == ODP_THREAD_WORKER) {
odp_thrmask_set(&thread_globals->worker, thr);
- thread_globals->num_worker++;
+ odp_atomic_inc_u32(&thread_globals->num_worker);
} else {
odp_thrmask_set(&thread_globals->control, thr);
- thread_globals->num_control++;
+ odp_atomic_inc_u32(&thread_globals->num_control);
}
- thread_globals->num++;
+ odp_atomic_inc_u32(&thread_globals->num);
return thr;
}
}
@@ -146,14 +145,13 @@ static int free_id(int thr)
if (thread_globals->thr[thr].type == ODP_THREAD_WORKER) {
odp_thrmask_clr(&thread_globals->worker, thr);
- thread_globals->num_worker--;
+ odp_atomic_dec_u32(&thread_globals->num_worker);
} else {
odp_thrmask_clr(&thread_globals->control, thr);
- thread_globals->num_control--;
+ odp_atomic_dec_u32(&thread_globals->num_control);
}
- thread_globals->num--;
- return thread_globals->num;
+ return odp_atomic_fetch_dec_u32(&thread_globals->num) - 1;
}
int _odp_thread_init_local(odp_thread_type_t type)
@@ -254,17 +252,17 @@ int _odp_thread_term_local(void)
int odp_thread_count(void)
{
- return thread_globals->num;
+ return odp_atomic_load_u32(&thread_globals->num);
}
int odp_thread_control_count(void)
{
- return thread_globals->num_control;
+ return odp_atomic_load_u32(&thread_globals->num_control);
}
int odp_thread_worker_count(void)
{
- return thread_globals->num_worker;
+ return odp_atomic_load_u32(&thread_globals->num_worker);
}
int odp_thread_count_max(void)
@@ -284,12 +282,22 @@ int odp_thread_worker_count_max(void)
int odp_thrmask_worker(odp_thrmask_t *mask)
{
+ uint32_t num_worker;
+
+ odp_spinlock_lock(&thread_globals->lock);
odp_thrmask_copy(mask, &thread_globals->worker);
- return thread_globals->num_worker;
+ num_worker = odp_atomic_load_u32(&thread_globals->num_worker);
+ odp_spinlock_unlock(&thread_globals->lock);
+ return num_worker;
}
int odp_thrmask_control(odp_thrmask_t *mask)
{
+ uint32_t num_control;
+
+ odp_spinlock_lock(&thread_globals->lock);
odp_thrmask_copy(mask, &thread_globals->control);
- return thread_globals->num_control;
+ num_control = odp_atomic_load_u32(&thread_globals->num_control);
+ odp_spinlock_unlock(&thread_globals->lock);
+ return num_control;
}
diff --git a/platform/linux-generic/odp_thread_api.c b/platform/linux-generic/odp_thread_api.c
index 470a82de7..65f7820f6 100644
--- a/platform/linux-generic/odp_thread_api.c
+++ b/platform/linux-generic/odp_thread_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#include <odp/api/thread.h>
diff --git a/platform/linux-generic/odp_thrmask.c b/platform/linux-generic/odp_thrmask.c
index f8704a0dd..1dfde9e1b 100644
--- a/platform/linux-generic/odp_thrmask.c
+++ b/platform/linux-generic/odp_thrmask.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <odp/api/thrmask.h>
diff --git a/platform/linux-generic/odp_ticketlock_api.c b/platform/linux-generic/odp_ticketlock_api.c
index 8995dd555..aac5945a6 100644
--- a/platform/linux-generic/odp_ticketlock_api.c
+++ b/platform/linux-generic/odp_ticketlock_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
*/
#include <odp/api/ticketlock.h>
diff --git a/platform/linux-generic/odp_time_api.c b/platform/linux-generic/odp_time_api.c
index d906e14b8..1aca5eb8c 100644
--- a/platform/linux-generic/odp_time_api.c
+++ b/platform/linux-generic/odp_time_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#include <odp/api/time.h>
diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c
index c8ea31078..7741cfd4c 100644
--- a/platform/linux-generic/odp_timer.c
+++ b/platform/linux-generic/odp_timer.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2023 Nokia
*/
/**
@@ -46,7 +44,7 @@
#include <odp_libconfig_internal.h>
#include <odp_macros_internal.h>
#include <odp_pool_internal.h>
-#include <odp_print_internal.h>
+#include <odp_string_internal.h>
#include <odp_queue_if.h>
#include <odp_timer_internal.h>
#include <odp_types_internal.h>
@@ -190,10 +188,10 @@ typedef struct timer_pool_s {
odp_atomic_u32_t notify_overrun;
int owner;
pthread_t thr_pthread; /* pthread_t of timer thread */
- pid_t thr_pid; /* gettid() for timer thread */
+ odp_atomic_u64_t thr_pid; /* gettid() for timer thread */
int thr_warm_up; /* number of warm up rounds */
odp_atomic_u32_t thr_ready; /* thread ready from warm up */
- int thr_exit; /* request to exit for timer thread */
+ odp_atomic_u32_t thr_exit; /* request to exit for timer thread */
double base_freq;
uint64_t max_multiplier;
uint8_t periodic;
@@ -342,7 +340,7 @@ static void posix_timer_stop(timer_pool_t *tp)
/* Stop the thread */
_ODP_DBG("stop\n");
- tp->thr_exit = 1;
+ odp_atomic_store_u32(&tp->thr_exit, 1);
ret = pthread_join(tp->thr_pthread, NULL);
if (ret != 0)
_ODP_ABORT("Unable to join thread, err %d\n", ret);
@@ -934,6 +932,7 @@ static void *timer_thread(void *arg)
siginfo_t si;
int warm_up = tp->thr_warm_up;
int num = 0;
+ pid_t thr_pid;
tmo.tv_sec = 0;
tmo.tv_nsec = ODP_TIME_MSEC_IN_NS * 100;
@@ -944,15 +943,18 @@ static void *timer_thread(void *arg)
sigaddset(&sigset, SIGALRM);
/* Signal that this thread has started */
- odp_mb_full();
- tp->thr_pid = (pid_t)syscall(SYS_gettid);
- odp_mb_full();
+ thr_pid = (pid_t)syscall(SYS_gettid);
+ if (thr_pid <= 0) {
+ _ODP_ERR("Invalid tid: %d\n", thr_pid);
+ return NULL;
+ }
+ odp_atomic_store_u64(&tp->thr_pid, thr_pid);
while (1) {
ret = sigtimedwait(&sigset, &si, &tmo);
- if (tp->thr_exit) {
- tp->thr_pid = 0;
+ if (odp_atomic_load_u32(&tp->thr_exit)) {
+ odp_atomic_store_u64(&tp->thr_pid, 0);
return NULL;
}
@@ -1061,7 +1063,7 @@ static void posix_timer_start(timer_pool_t *tp)
sec = res / ODP_TIME_SEC_IN_NS;
nsec = res - sec * ODP_TIME_SEC_IN_NS;
- tp->thr_pid = 0;
+ odp_atomic_init_u64(&tp->thr_pid, 0);
tp->thr_warm_up = 1;
/* 20ms warm up */
@@ -1074,13 +1076,13 @@ static void posix_timer_start(timer_pool_t *tp)
_ODP_ABORT("Unable to create timer thread: %d\n", ret);
/* wait thread set tp->thr_pid */
- while (tp->thr_pid == 0)
- sched_yield();
+ while (!odp_atomic_load_u64(&tp->thr_pid))
+ odp_cpu_pause();
memset(&sigev, 0, sizeof(sigev));
sigev.sigev_notify = SIGEV_THREAD_ID;
sigev.sigev_value.sival_ptr = tp;
- sigev._sigev_un._tid = tp->thr_pid;
+ sigev._sigev_un._tid = odp_atomic_load_u64(&tp->thr_pid);
sigev.sigev_signo = SIGALRM;
if (timer_create(CLOCK_MONOTONIC, &sigev, &tp->timerid))
@@ -1098,7 +1100,7 @@ static void posix_timer_start(timer_pool_t *tp)
/* Wait response from timer thread that warm up signals have been
* processed. Warm up helps avoiding overrun on the first timeout. */
while (odp_atomic_load_acq_u32(&tp->thr_ready) == 0)
- sched_yield();
+ odp_cpu_pause();
if (ODP_DEBUG_PRINT) {
uint32_t old_val = 0;
@@ -1232,12 +1234,10 @@ static odp_timer_pool_t timer_pool_new(const char *name, const odp_timer_pool_pa
odp_atomic_init_u64(&tp->cur_tick, 0);
- if (name == NULL) {
+ if (name == NULL)
tp->name[0] = 0;
- } else {
- strncpy(tp->name, name, ODP_TIMER_POOL_NAME_LEN - 1);
- tp->name[ODP_TIMER_POOL_NAME_LEN - 1] = 0;
- }
+ else
+ _odp_strcpy(tp->name, name, ODP_TIMER_POOL_NAME_LEN);
tp->param = *param;
tp->param.res_ns = res_ns;
@@ -1251,6 +1251,7 @@ static odp_timer_pool_t timer_pool_new(const char *name, const odp_timer_pool_pa
tp->num_alloc = 0;
odp_atomic_init_u32(&tp->high_wm, 0);
odp_atomic_init_u32(&tp->notify_overrun, 0);
+ odp_atomic_init_u32(&tp->thr_exit, 0);
tp->first_free = 0;
tp->owner = -1;
diff --git a/platform/linux-generic/odp_timer_api.c b/platform/linux-generic/odp_timer_api.c
index cd657956b..7a3f6efce 100644
--- a/platform/linux-generic/odp_timer_api.c
+++ b/platform/linux-generic/odp_timer_api.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#include <odp/api/timer.h>
diff --git a/platform/linux-generic/odp_timer_wheel.c b/platform/linux-generic/odp_timer_wheel.c
index 876e06730..aee65e82d 100644
--- a/platform/linux-generic/odp_timer_wheel.c
+++ b/platform/linux-generic/odp_timer_wheel.c
@@ -1,9 +1,6 @@
-/* Copyright 2015 EZchip Semiconductor Ltd. All Rights Reserved.
- *
- * Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015 EZchip Semiconductor Ltd.
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <stdint.h>
diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c
index f0327fad0..6311c941d 100644
--- a/platform/linux-generic/odp_traffic_mngr.c
+++ b/platform/linux-generic/odp_traffic_mngr.c
@@ -1,15 +1,13 @@
-/* Copyright 2015 EZchip Semiconductor Ltd. All Rights Reserved.
- *
- * Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2022, Marvell
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015 EZchip Semiconductor Ltd.
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2022 Marvell
+ * Copyright (c) 2022 Nokia
*/
#include <odp_posix_extensions.h>
+#include <odp/api/cpu.h>
#include <odp/api/packet.h>
#include <odp/api/packet_flags.h>
#include <odp/api/std_types.h>
@@ -160,7 +158,6 @@ typedef struct {
int cpu_num;
/* Service threads */
- uint64_t busy_wait_counter;
odp_bool_t main_loop_running;
odp_atomic_u64_t atomic_request_cnt;
odp_atomic_u64_t currently_serving_cnt;
@@ -492,6 +489,7 @@ static tm_system_t *tm_system_alloc(void)
memset(tm_system, 0, sizeof(tm_system_t));
tm_system->tm_idx = tm_idx;
tm_system->status = TM_STATUS_RESERVED;
+ odp_atomic_init_u32(&tm_system->is_idle, 0);
return tm_system;
}
}
@@ -2415,14 +2413,6 @@ static int tm_process_expired_timers(tm_system_t *tm_system,
return work_done;
}
-static void busy_wait(uint32_t iterations)
-{
- uint32_t cnt;
-
- for (cnt = 1; cnt <= iterations; cnt++)
- tm_glb->busy_wait_counter++;
-}
-
static void signal_request(void)
{
uint64_t request_num, serving;
@@ -2431,7 +2421,7 @@ static void signal_request(void)
serving = odp_atomic_load_u64(&tm_glb->currently_serving_cnt);
while (serving != request_num) {
- busy_wait(100);
+ odp_cpu_pause();
serving = odp_atomic_load_u64(&tm_glb->currently_serving_cnt);
}
}
@@ -2448,11 +2438,11 @@ static void check_for_request(void)
/* Signal the other requesting thread to proceed and then
* wait for their done indication */
odp_atomic_inc_u64(&tm_glb->currently_serving_cnt);
- busy_wait(100);
+ odp_cpu_pause();
done_cnt = odp_atomic_load_u64(&tm_glb->atomic_done_cnt);
while (done_cnt != request_num) {
- busy_wait(100);
+ odp_cpu_pause();
done_cnt = odp_atomic_load_u64(&tm_glb->atomic_done_cnt);
}
}
@@ -2506,7 +2496,7 @@ static void *tm_system_thread(void *arg)
odp_barrier_wait(&tm_group->tm_group_barrier);
tm_glb->main_loop_running = true;
- destroying = odp_atomic_load_u64(&tm_system->destroying);
+ destroying = odp_atomic_load_acq_u64(&tm_system->destroying);
current_ns = odp_time_to_ns(odp_time_local());
_odp_timer_wheel_start(_odp_int_timer_wheel, current_ns);
@@ -2547,9 +2537,9 @@ static void *tm_system_thread(void *arg)
current_ns = odp_time_to_ns(odp_time_local());
tm_system->current_time = current_ns;
- tm_system->is_idle = (timer_cnt == 0) &&
- (work_queue_cnt == 0);
- destroying = odp_atomic_load_u64(&tm_system->destroying);
+ odp_atomic_store_rel_u32(&tm_system->is_idle,
+ (timer_cnt == 0) && (work_queue_cnt == 0));
+ destroying = odp_atomic_load_acq_u64(&tm_system->destroying);
/* Advance to the next tm_system in the tm_system_group. */
tm_system = tm_system->next;
@@ -2569,7 +2559,7 @@ odp_bool_t odp_tm_is_idle(odp_tm_t odp_tm)
tm_system_t *tm_system;
tm_system = GET_TM_SYSTEM(odp_tm);
- return tm_system->is_idle;
+ return odp_atomic_load_acq_u32(&tm_system->is_idle);
}
void odp_tm_requirements_init(odp_tm_requirements_t *requirements)
@@ -3214,7 +3204,7 @@ int odp_tm_destroy(odp_tm_t odp_tm)
* all new pkts are prevented from coming in.
*/
odp_barrier_init(&tm_system->tm_system_destroy_barrier, 2);
- odp_atomic_inc_u64(&tm_system->destroying);
+ odp_atomic_store_rel_u64(&tm_system->destroying, 1);
odp_barrier_wait(&tm_system->tm_system_destroy_barrier);
/* Remove ourselves from the group. If we are the last tm_system in
@@ -4525,7 +4515,7 @@ int odp_tm_enq(odp_tm_queue_t tm_queue, odp_packet_t pkt)
if (!tm_system)
return -1;
- if (odp_atomic_load_u64(&tm_system->destroying))
+ if (odp_atomic_load_acq_u64(&tm_system->destroying))
return -1;
rc = tm_enqueue(tm_system, tm_queue_obj, pkt);
@@ -4549,7 +4539,7 @@ int odp_tm_enq_with_cnt(odp_tm_queue_t tm_queue, odp_packet_t pkt)
if (!tm_system)
return -1;
- if (odp_atomic_load_u64(&tm_system->destroying))
+ if (odp_atomic_load_acq_u64(&tm_system->destroying))
return -1;
rc = tm_enqueue(tm_system, tm_queue_obj, pkt);
@@ -4575,7 +4565,7 @@ int odp_tm_enq_multi(odp_tm_queue_t tm_queue, const odp_packet_t packets[],
if (!tm_system)
return -1;
- if (odp_atomic_load_u64(&tm_system->destroying))
+ if (odp_atomic_load_acq_u64(&tm_system->destroying))
return -1;
for (i = 0; i < num; i++) {
diff --git a/platform/linux-generic/odp_version.c b/platform/linux-generic/odp_version.c
index baa336839..8c8b9be09 100644
--- a/platform/linux-generic/odp_version.c
+++ b/platform/linux-generic/odp_version.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <odp/api/version.h>
diff --git a/platform/linux-generic/odp_weak.c b/platform/linux-generic/odp_weak.c
index 747886d4e..aab23b1ec 100644
--- a/platform/linux-generic/odp_weak.c
+++ b/platform/linux-generic/odp_weak.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
*/
#include <odp/api/debug.h>
diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c
index 3fa796007..b28e63890 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2019-2023 Nokia
*/
#include <odp/autoheader_internal.h>
@@ -34,6 +32,7 @@
#include <protocols/udp.h>
#include <odp_pool_internal.h>
#include <odp_socket_common.h>
+#include <odp_string_internal.h>
#include <rte_config.h>
#include <rte_common.h>
@@ -119,6 +118,8 @@ ODP_STATIC_ASSERT(CONFIG_PACKET_HEADROOM == RTE_PKTMBUF_HEADROOM,
#define IXGBE_DRV_NAME "net_ixgbe"
#define I40E_DRV_NAME "net_i40e"
+#define PCAP_DRV_NAME "net_pcap"
+
#define DPDK_MEMORY_MB 512
#define DPDK_NB_MBUF 16384
#define DPDK_MBUF_BUF_SIZE RTE_MBUF_DEFAULT_BUF_SIZE
@@ -1434,7 +1435,7 @@ static int dpdk_pktio_init(void)
if (numa_nodes <= 0)
numa_nodes = 1;
- char mem_str[mem_str_len * numa_nodes];
+ char mem_str[mem_str_len * numa_nodes + 1];
for (i = 0; i < numa_nodes; i++)
sprintf(&mem_str[i * mem_str_len], "%d,", DPDK_MEMORY_MB);
@@ -2084,14 +2085,20 @@ static int dpdk_start(pktio_entry_t *pktio_entry)
uint16_t port_id = pkt_dpdk->port_id;
int ret;
- /* DPDK doesn't support nb_rx_q/nb_tx_q being 0 */
- if (!pktio_entry->num_in_queue)
- pktio_entry->num_in_queue = 1;
- if (!pktio_entry->num_out_queue)
- pktio_entry->num_out_queue = 1;
-
rte_eth_dev_info_get(port_id, &dev_info);
+ /* Pcap driver reconfiguration may fail if number of rx/tx queues is set to zero */
+ if (!strncmp(dev_info.driver_name, PCAP_DRV_NAME, strlen(PCAP_DRV_NAME))) {
+ if (!pktio_entry->num_in_queue) {
+ pktio_entry->num_in_queue = 1;
+ pkt_dpdk->num_rx_desc[0] = dev_info.rx_desc_lim.nb_min;
+ }
+ if (!pktio_entry->num_out_queue) {
+ pktio_entry->num_out_queue = 1;
+ pkt_dpdk->num_tx_desc[0] = dev_info.tx_desc_lim.nb_min;
+ }
+ }
+
/* Setup device */
if (dpdk_setup_eth_dev(pktio_entry)) {
_ODP_ERR("Failed to configure device\n");
@@ -2468,8 +2475,8 @@ static int dpdk_extra_stat_info(pktio_entry_t *pktio_entry,
num_stats = ret;
for (i = 0; i < num && i < num_stats; i++)
- strncpy(info[i].name, xstats_names[i].name,
- ODP_PKTIO_STATS_EXTRA_NAME_LEN - 1);
+ _odp_strcpy(info[i].name, xstats_names[i].name,
+ ODP_PKTIO_STATS_EXTRA_NAME_LEN);
return num_stats;
}
diff --git a/platform/linux-generic/pktio/ethtool_rss.c b/platform/linux-generic/pktio/ethtool_rss.c
index df97e2417..7cfce7812 100644
--- a/platform/linux-generic/pktio/ethtool_rss.c
+++ b/platform/linux-generic/pktio/ethtool_rss.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/pktio/io_ops.c b/platform/linux-generic/pktio/io_ops.c
index 141b881e3..ff97a25be 100644
--- a/platform/linux-generic/pktio/io_ops.c
+++ b/platform/linux-generic/pktio/io_ops.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
*/
#include <odp/autoheader_internal.h>
diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c
index dd286328a..2e6110dc2 100644
--- a/platform/linux-generic/pktio/ipc.c
+++ b/platform/linux-generic/pktio/ipc.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2019-2022 Nokia
*/
#include <odp/api/hints.h>
@@ -313,7 +311,7 @@ static int _ipc_init_master(pktio_entry_t *pktio_entry,
/* Set up pool name for remote info */
pinfo = pktio_ipc->pinfo;
pool_name = _ipc_odp_buffer_pool_shm_name(pool_hdl);
- if (strlen(pool_name) > ODP_POOL_NAME_LEN) {
+ if (strlen(pool_name) >= ODP_POOL_NAME_LEN) {
_ODP_ERR("pid %d ipc pool name %s is too big %zu\n",
getpid(), pool_name, strlen(pool_name));
goto free_s_prod;
diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c
index ff48525a3..05a1a3dce 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2013-2023, Nokia Solutions and Networks
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2013-2023 Nokia Solutions and Networks
*/
#include <odp/api/debug.h>
diff --git a/platform/linux-generic/pktio/null.c b/platform/linux-generic/pktio/null.c
index 00c45f84a..862969415 100644
--- a/platform/linux-generic/pktio/null.c
+++ b/platform/linux-generic/pktio/null.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
#include <odp/api/debug.h>
diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c
index 78b9876d7..02b4d467a 100644
--- a/platform/linux-generic/pktio/pcap.c
+++ b/platform/linux-generic/pktio/pcap.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
/**
@@ -195,10 +193,12 @@ static int pcapif_promisc_mode_set(pktio_entry_t *pktio_entry,
}
if (pcap_setfilter(pcap->rx, &bpf) != 0) {
+ pcap_freecode(&bpf);
_ODP_ERR("failed to set promisc mode filter: %s\n", pcap_geterr(pcap->rx));
return -1;
}
+ pcap_freecode(&bpf);
pcap->promisc = enable;
return 0;
diff --git a/platform/linux-generic/pktio/pktio_common.c b/platform/linux-generic/pktio/pktio_common.c
index 097b8cf29..7dbd77c49 100644
--- a/platform/linux-generic/pktio/pktio_common.c
+++ b/platform/linux-generic/pktio/pktio_common.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2013, Nokia Solutions and Networks
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2013 Nokia Solutions and Networks
*/
#include <odp_packet_io_internal.h>
diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c
index 2a037e51f..bd4ffc94f 100644
--- a/platform/linux-generic/pktio/socket.c
+++ b/platform/linux-generic/pktio/socket.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2013-2023, Nokia Solutions and Networks
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2013-2023 Nokia Solutions and Networks
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/pktio/socket_common.c b/platform/linux-generic/pktio/socket_common.c
index dabe86aa2..503df1685 100644
--- a/platform/linux-generic/pktio/socket_common.c
+++ b/platform/linux-generic/pktio/socket_common.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2019-2020, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2019-2020 Nokia
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c
index 92bf8a4bf..e8457cac2 100644
--- a/platform/linux-generic/pktio/socket_mmap.c
+++ b/platform/linux-generic/pktio/socket_mmap.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2013-2023, Nokia Solutions and Networks
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2013-2023 Nokia Solutions and Networks
*/
#include <odp_posix_extensions.h>
diff --git a/platform/linux-generic/pktio/socket_xdp.c b/platform/linux-generic/pktio/socket_xdp.c
index 599942657..2cd7b080b 100644
--- a/platform/linux-generic/pktio/socket_xdp.c
+++ b/platform/linux-generic/pktio/socket_xdp.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022-2023 Nokia
*/
#include <odp/autoheader_internal.h>
diff --git a/platform/linux-generic/pktio/stats/ethtool_stats.c b/platform/linux-generic/pktio/stats/ethtool_stats.c
index bbf0729f1..1cee0c4d5 100644
--- a/platform/linux-generic/pktio/stats/ethtool_stats.c
+++ b/platform/linux-generic/pktio/stats/ethtool_stats.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2021-2022 Nokia
*/
#include <odp_posix_extensions.h>
@@ -10,6 +8,7 @@
#include <odp/api/packet_io_stats.h>
#include <odp_debug_internal.h>
+#include <odp_string_internal.h>
#include <odp_ethtool_stats.h>
#include <sys/ioctl.h>
@@ -234,7 +233,7 @@ int _odp_ethtool_extra_stat_info(int fd, const char *name,
for (i = 0; i < n_stats && i < (unsigned int)num; i++) {
char *cnt = (char *)&strings->data[i * ETH_GSTRING_LEN];
- strncpy(info[i].name, cnt, ODP_PKTIO_STATS_EXTRA_NAME_LEN - 1);
+ _odp_strcpy(info[i].name, cnt, ODP_PKTIO_STATS_EXTRA_NAME_LEN);
}
free(strings);
diff --git a/platform/linux-generic/pktio/stats/packet_io_stats.c b/platform/linux-generic/pktio/stats/packet_io_stats.c
index 280aca250..b839faaa6 100644
--- a/platform/linux-generic/pktio/stats/packet_io_stats.c
+++ b/platform/linux-generic/pktio/stats/packet_io_stats.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#include <odp_packet_io_stats.h>
diff --git a/platform/linux-generic/pktio/stats/sysfs_stats.c b/platform/linux-generic/pktio/stats/sysfs_stats.c
index 2b47d4b83..9d2b3ec75 100644
--- a/platform/linux-generic/pktio/stats/sysfs_stats.c
+++ b/platform/linux-generic/pktio/stats/sysfs_stats.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2021-2022 Nokia
*/
#include <odp/api/packet_io_stats.h>
diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c
index baac09646..7806f825a 100644
--- a/platform/linux-generic/pktio/tap.c
+++ b/platform/linux-generic/pktio/tap.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015, Ilya Maximets <i.maximets@samsung.com>
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015 Ilya Maximets <i.maximets@samsung.com>
+ * Copyright (c) 2021-2023 Nokia
*/
/**
diff --git a/platform/linux-generic/test/example/Makefile.am b/platform/linux-generic/test/example/Makefile.am
index 947647cd4..a9d0948de 100644
--- a/platform/linux-generic/test/example/Makefile.am
+++ b/platform/linux-generic/test/example/Makefile.am
@@ -1,6 +1,5 @@
SUBDIRS = \
classifier \
- generator \
ipsec_api \
ipsec_crypto \
l2fwd_simple \
diff --git a/platform/linux-generic/test/example/classifier/pktio_env b/platform/linux-generic/test/example/classifier/pktio_env
index eb8f2a80a..1a3cc51a2 100644
--- a/platform/linux-generic/test/example/classifier/pktio_env
+++ b/platform/linux-generic/test/example/classifier/pktio_env
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2020, Marvell
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Marvell
#
# Script to setup interfaces used for running application on linux-generic.
#
diff --git a/platform/linux-generic/test/example/generator/Makefile.am b/platform/linux-generic/test/example/generator/Makefile.am
deleted file mode 100644
index 2ffced539..000000000
--- a/platform/linux-generic/test/example/generator/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-EXTRA_DIST = pktio_env
diff --git a/platform/linux-generic/test/example/generator/pktio_env b/platform/linux-generic/test/example/generator/pktio_env
deleted file mode 100644
index 06af667e8..000000000
--- a/platform/linux-generic/test/example/generator/pktio_env
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2020, Marvell
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-# Script to setup interfaces used for running application on linux-generic.
-#
-# Generator uses null interfaces to validate udp mode.
-#
-# Network set-up
-# IF0 ---> null:0
-
-IF0=null:0
-
-if [ "$0" = "$BASH_SOURCE" ]; then
- echo "Error: Platform specific env file has to be sourced."
-fi
-
-validate_result()
-{
- return 0
-}
-
-setup_interfaces()
-{
- return 0
-}
-
-cleanup_interfaces()
-{
- return 0
-}
diff --git a/platform/linux-generic/test/example/ipsec_api/pktio_env b/platform/linux-generic/test/example/ipsec_api/pktio_env
index b3a073631..67a59919a 100644
--- a/platform/linux-generic/test/example/ipsec_api/pktio_env
+++ b/platform/linux-generic/test/example/ipsec_api/pktio_env
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (C) 2021, Marvell
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021 Marvell
#
# Script to setup interfaces used for running application on linux-generic.
#
diff --git a/platform/linux-generic/test/example/ipsec_crypto/pktio_env b/platform/linux-generic/test/example/ipsec_crypto/pktio_env
index fd770ac41..82d68f860 100644
--- a/platform/linux-generic/test/example/ipsec_crypto/pktio_env
+++ b/platform/linux-generic/test/example/ipsec_crypto/pktio_env
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (C) 2021, Marvell
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021 Marvell
#
# Script to setup interfaces used for running application on linux-generic.
#
diff --git a/platform/linux-generic/test/example/l2fwd_simple/pktio_env b/platform/linux-generic/test/example/l2fwd_simple/pktio_env
index e1fbe87cc..016ebf660 100644
--- a/platform/linux-generic/test/example/l2fwd_simple/pktio_env
+++ b/platform/linux-generic/test/example/l2fwd_simple/pktio_env
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (C) 2020, Marvell
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Marvell
#
# Script to setup interfaces used for running application on linux-generic.
#
diff --git a/platform/linux-generic/test/example/l3fwd/pktio_env b/platform/linux-generic/test/example/l3fwd/pktio_env
index a692d79bc..b176d5a3b 100644
--- a/platform/linux-generic/test/example/l3fwd/pktio_env
+++ b/platform/linux-generic/test/example/l3fwd/pktio_env
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (C) 2020, Marvell
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Marvell
#
# Script to setup interfaces used for running application on linux-generic.
#
diff --git a/platform/linux-generic/test/example/packet/pktio_env b/platform/linux-generic/test/example/packet/pktio_env
index 4e1914e2e..47d643ef0 100644
--- a/platform/linux-generic/test/example/packet/pktio_env
+++ b/platform/linux-generic/test/example/packet/pktio_env
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (C) 2020, Marvell
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Marvell
#
# Script to setup interfaces used for running application on linux-generic.
#
diff --git a/platform/linux-generic/test/example/ping/pktio_env b/platform/linux-generic/test/example/ping/pktio_env
index 90106da9d..8b3464ee4 100644
--- a/platform/linux-generic/test/example/ping/pktio_env
+++ b/platform/linux-generic/test/example/ping/pktio_env
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (C) 2020, Marvell
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Marvell
#
# Script to setup interfaces used for running application on linux-generic.
#
diff --git a/platform/linux-generic/test/example/simple_pipeline/pktio_env b/platform/linux-generic/test/example/simple_pipeline/pktio_env
index e1fbe87cc..016ebf660 100644
--- a/platform/linux-generic/test/example/simple_pipeline/pktio_env
+++ b/platform/linux-generic/test/example/simple_pipeline/pktio_env
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (C) 2020, Marvell
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Marvell
#
# Script to setup interfaces used for running application on linux-generic.
#
diff --git a/platform/linux-generic/test/example/switch/pktio_env b/platform/linux-generic/test/example/switch/pktio_env
index 78201cec7..8df735b3b 100644
--- a/platform/linux-generic/test/example/switch/pktio_env
+++ b/platform/linux-generic/test/example/switch/pktio_env
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (C) 2020, Marvell
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Marvell
#
# Script to setup interfaces used for running application on linux-generic.
#
diff --git a/platform/linux-generic/test/validation/api/ml/ml_linux.c b/platform/linux-generic/test/validation/api/ml/ml_linux.c
index 28e18fbb5..30d4ec6ba 100644
--- a/platform/linux-generic/test/validation/api/ml/ml_linux.c
+++ b/platform/linux-generic/test/validation/api/ml/ml_linux.c
@@ -414,6 +414,21 @@ static void test_ml_model_lookup(void)
CU_ASSERT(odp_ml_model_destroy(model2) == 0);
}
+static void test_ml_model_long_name(void)
+{
+ odp_ml_model_t model;
+ char name[ODP_ML_MODEL_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ model = odp_ml_model_create(name, &global.model_param);
+ CU_ASSERT_FATAL(model != ODP_ML_MODEL_INVALID);
+
+ CU_ASSERT(odp_ml_model_to_u64(model) == odp_ml_model_to_u64(odp_ml_model_lookup(name)));
+ CU_ASSERT(odp_ml_model_destroy(model) == 0);
+}
+
static void test_ml_model_info(void)
{
int ret;
@@ -1130,6 +1145,7 @@ odp_testinfo_t ml_suite[] = {
ODP_TEST_INFO_CONDITIONAL(test_ml_debug, check_ml_support),
ODP_TEST_INFO_CONDITIONAL(test_ml_model_create, check_ml_support),
ODP_TEST_INFO_CONDITIONAL(test_ml_model_lookup, check_ml_support),
+ ODP_TEST_INFO_CONDITIONAL(test_ml_model_long_name, check_ml_support),
ODP_TEST_INFO_CONDITIONAL(test_ml_model_info, check_ml_support),
ODP_TEST_INFO_CONDITIONAL(test_ml_model_load, check_load_sync),
ODP_TEST_INFO_CONDITIONAL(test_ml_model_load_async_poll, check_load_poll),
diff --git a/platform/linux-generic/test/validation/api/pktio/pktio_env b/platform/linux-generic/test/validation/api/pktio/pktio_env
index ba9998e6a..754e73b75 100644
--- a/platform/linux-generic/test/validation/api/pktio/pktio_env
+++ b/platform/linux-generic/test/validation/api/pktio/pktio_env
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2015-2018, Linaro Limited
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2015-2018 Linaro Limited
#
# Test script wrapper for running ODP pktio apps on linux-generic.
#
diff --git a/platform/linux-generic/test/validation/api/pktio/pktio_run.sh b/platform/linux-generic/test/validation/api/pktio/pktio_run.sh
index cac297768..89671df54 100755
--- a/platform/linux-generic/test/validation/api/pktio/pktio_run.sh
+++ b/platform/linux-generic/test/validation/api/pktio/pktio_run.sh
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2015-2018, Linaro Limited
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2015-2018 Linaro Limited
#
# Proceed the pktio tests. This script expects at least one argument:
diff --git a/platform/linux-generic/test/validation/api/pktio/pktio_run_dpdk.sh b/platform/linux-generic/test/validation/api/pktio/pktio_run_dpdk.sh
index 39b540228..68510c2a3 100755
--- a/platform/linux-generic/test/validation/api/pktio/pktio_run_dpdk.sh
+++ b/platform/linux-generic/test/validation/api/pktio/pktio_run_dpdk.sh
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2016-2018, Linaro Limited
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2016-2018 Linaro Limited
#
# Proceed the pktio tests. This script expects at least one argument:
diff --git a/platform/linux-generic/test/validation/api/pktio/pktio_run_pcap.sh b/platform/linux-generic/test/validation/api/pktio/pktio_run_pcap.sh
index 290bc81d5..700abbf35 100755
--- a/platform/linux-generic/test/validation/api/pktio/pktio_run_pcap.sh
+++ b/platform/linux-generic/test/validation/api/pktio/pktio_run_pcap.sh
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2015-2018, Linaro Limited
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2015-2018 Linaro Limited
#
# any parameter passed as arguments to this script is passed unchanged to
diff --git a/platform/linux-generic/test/validation/api/pktio/pktio_run_tap.sh b/platform/linux-generic/test/validation/api/pktio/pktio_run_tap.sh
index ecfe5a126..0fd08134e 100755
--- a/platform/linux-generic/test/validation/api/pktio/pktio_run_tap.sh
+++ b/platform/linux-generic/test/validation/api/pktio/pktio_run_tap.sh
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2015, Ilya Maximets <i.maximets@samsung.com>
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2015 Ilya Maximets <i.maximets@samsung.com>
#
diff --git a/platform/linux-generic/test/validation/api/shmem/shmem_common.h b/platform/linux-generic/test/validation/api/shmem/shmem_common.h
index 33df4476c..145aea350 100644
--- a/platform/linux-generic/test/validation/api/shmem/shmem_common.h
+++ b/platform/linux-generic/test/validation/api/shmem/shmem_common.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#ifndef _COMMON_TEST_SHMEM_H_
diff --git a/platform/linux-generic/test/validation/api/shmem/shmem_linux.c b/platform/linux-generic/test/validation/api/shmem/shmem_linux.c
index 03a9255f7..061d86d6e 100644
--- a/platform/linux-generic/test/validation/api/shmem/shmem_linux.c
+++ b/platform/linux-generic/test/validation/api/shmem/shmem_linux.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
/* this test makes sure that odp shared memory created with the ODP_SHM_PROC
@@ -222,13 +220,17 @@ int main(int argc __attribute__((unused)), char *argv[])
uid_t uid = getuid();
char *shm_dir = getenv("ODP_SHM_DIR");
const char *exeext = getenv("EXEEXT");
+ char *dir_name;
if (exeext == NULL)
exeext = "";
- /* odp_app1 is in the same directory as this file: */
strncpy(prg_name, argv[0], PATH_MAX - 1);
- sprintf(odp_name1, "%s/%s%s", dirname(prg_name), ODP_APP1_NAME, exeext);
+ prg_name[PATH_MAX - 1] = 0;
+ dir_name = dirname(prg_name);
+
+ /* odp_app1 is in the same directory as this file: */
+ snprintf(odp_name1, sizeof(odp_name1), "%s/%s%s", dir_name, ODP_APP1_NAME, exeext);
/* start the ODP application: */
odp_app1 = fork();
@@ -300,8 +302,7 @@ int main(int argc __attribute__((unused)), char *argv[])
}
/* odp_app2 is in the same directory as this file: */
- strncpy(prg_name, argv[0], PATH_MAX - 1);
- sprintf(odp_name2, "%s/%s%s", dirname(prg_name), ODP_APP2_NAME, exeext);
+ snprintf(odp_name2, sizeof(odp_name2), "%s/%s%s", dir_name, ODP_APP2_NAME, exeext);
/* start the second ODP application with pid of ODP_APP1 as parameter:*/
sprintf(pid1, "%d", odp_app1);
diff --git a/platform/linux-generic/test/validation/api/shmem/shmem_linux.h b/platform/linux-generic/test/validation/api/shmem/shmem_linux.h
index 24646ae7c..d3f83636b 100644
--- a/platform/linux-generic/test/validation/api/shmem/shmem_linux.h
+++ b/platform/linux-generic/test/validation/api/shmem/shmem_linux.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
void test_success(char *fifo_name, int fd, pid_t odp_app);
diff --git a/platform/linux-generic/test/validation/api/shmem/shmem_odp1.c b/platform/linux-generic/test/validation/api/shmem/shmem_odp1.c
index 98148d6c7..09dd04cd1 100644
--- a/platform/linux-generic/test/validation/api/shmem/shmem_odp1.c
+++ b/platform/linux-generic/test/validation/api/shmem/shmem_odp1.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#include <odp_api.h>
diff --git a/platform/linux-generic/test/validation/api/shmem/shmem_odp1.h b/platform/linux-generic/test/validation/api/shmem/shmem_odp1.h
index 241637e58..64bffd684 100644
--- a/platform/linux-generic/test/validation/api/shmem/shmem_odp1.h
+++ b/platform/linux-generic/test/validation/api/shmem/shmem_odp1.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
void shmem_test_odp_shm_proc(void);
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 14ad2d82e..1f4c04fa0 100644
--- a/platform/linux-generic/test/validation/api/shmem/shmem_odp2.c
+++ b/platform/linux-generic/test/validation/api/shmem/shmem_odp2.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
#include <odp_api.h>
diff --git a/platform/linux-generic/test/validation/api/shmem/shmem_odp2.h b/platform/linux-generic/test/validation/api/shmem/shmem_odp2.h
index 0493d6caa..cf841e6fd 100644
--- a/platform/linux-generic/test/validation/api/shmem/shmem_odp2.h
+++ b/platform/linux-generic/test/validation/api/shmem/shmem_odp2.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
int main(int argc, char *argv[]);
diff --git a/scripts/git-transplant.py b/scripts/git-transplant.py
index 69bcf72b5..b6abf0ebb 100755
--- a/scripts/git-transplant.py
+++ b/scripts/git-transplant.py
@@ -1,9 +1,7 @@
#!/usr/bin/python
-# Copyright (c) 2015-2018, Linaro Limited
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2015-2018 Linaro Limited
# Usage: git-transplant.py [orig dir] [overlay dir] [interval]
#
diff --git a/test/README b/test/README
index 4ef634d53..eebde9a47 100644
--- a/test/README
+++ b/test/README
@@ -1,7 +1,5 @@
-Copyright (c) 2014-2018, Linaro Limited
-All rights reserved.
-
-SPDX-License-Identifier: BSD-3-Clause
+SPDX-License-Identifier: BSD-3-Clause
+Copyright (c) 2014-2018 Linaro Limited
Files in test/validation directory are intended to be terse
checks that help ensure that the ODP implementations all perform identically
diff --git a/test/common/mask_common.c b/test/common/mask_common.c
index 65c9c6629..130429c61 100644
--- a/test/common/mask_common.c
+++ b/test/common/mask_common.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <odp_api.h>
@@ -123,8 +121,8 @@ MASK_TESTFUNC(to_from_str)
/* check that returned size matches original (with NULL): */
CU_ASSERT(str_sz == (int32_t)stringlen(buf_in) + 1);
- /* check that returned string matches original (with NULL): */
- CU_ASSERT_NSTRING_EQUAL(buf_out, buf_in, stringlen(buf_in) + 1);
+ /* check that returned string matches original: */
+ CU_ASSERT(!strcmp(buf_out, buf_in));
/* check that no extra buffer writes occurred: */
CU_ASSERT(buf_out[stringlen(buf_in) + 2] == FILLING_PATTERN);
@@ -150,8 +148,7 @@ MASK_TESTFUNC(to_from_str)
stringlen(TEST_MASK_0) + 1);
CU_ASSERT(str_sz == (int32_t)stringlen(TEST_MASK_0) + 1);
- CU_ASSERT_NSTRING_EQUAL(buf_out, TEST_MASK_0,
- stringlen(TEST_MASK_0) + 1);
+ CU_ASSERT(!strcmp(buf_out, TEST_MASK_0));
free(buf_out);
free(buf_in);
@@ -167,7 +164,7 @@ MASK_TESTFUNC(equal)
_odp_mask_from_str(&mask2, TEST_MASK_0);
_odp_mask_from_str(&mask3, TEST_MASK_NONE);
CU_ASSERT(_odp_mask_equal(&mask1, &mask2));
- CU_ASSERT_FALSE(_odp_mask_equal(&mask1, &mask3));
+ CU_ASSERT(!_odp_mask_equal(&mask1, &mask3));
if (mask_capacity() < 4)
return;
@@ -176,7 +173,7 @@ MASK_TESTFUNC(equal)
_odp_mask_from_str(&mask2, TEST_MASK_0_2);
_odp_mask_from_str(&mask3, TEST_MASK_1_2);
CU_ASSERT(_odp_mask_equal(&mask1, &mask2));
- CU_ASSERT_FALSE(_odp_mask_equal(&mask1, &mask3));
+ CU_ASSERT(!_odp_mask_equal(&mask1, &mask3));
if (mask_capacity() < 8)
return;
@@ -185,7 +182,7 @@ MASK_TESTFUNC(equal)
_odp_mask_from_str(&mask2, TEST_MASK_0_2_4_6);
_odp_mask_from_str(&mask3, TEST_MASK_1_2_4_6);
CU_ASSERT(_odp_mask_equal(&mask1, &mask2));
- CU_ASSERT_FALSE(_odp_mask_equal(&mask1, &mask3));
+ CU_ASSERT(!_odp_mask_equal(&mask1, &mask3));
}
MASK_TESTFUNC(zero)
@@ -256,16 +253,16 @@ MASK_TESTFUNC(isset)
CU_ASSERT(_odp_mask_isset(&mask1, 0));
_odp_mask_from_str(&mask1, TEST_MASK_NONE);
- CU_ASSERT_FALSE(_odp_mask_isset(&mask1, 0));
+ CU_ASSERT(!_odp_mask_isset(&mask1, 0));
if (mask_capacity() < 4)
return;
_odp_mask_from_str(&mask1, TEST_MASK_0_2);
CU_ASSERT(_odp_mask_isset(&mask1, 0));
- CU_ASSERT_FALSE(_odp_mask_isset(&mask1, 1));
+ CU_ASSERT(!_odp_mask_isset(&mask1, 1));
CU_ASSERT(_odp_mask_isset(&mask1, 2));
- CU_ASSERT_FALSE(_odp_mask_isset(&mask1, 3));
+ CU_ASSERT(!_odp_mask_isset(&mask1, 3));
}
MASK_TESTFUNC(count)
diff --git a/test/common/mask_common.h b/test/common/mask_common.h
index 60c2390b8..a40dd7c04 100644
--- a/test/common/mask_common.h
+++ b/test/common/mask_common.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#ifndef ODP_MASK_COMMON_H_
diff --git a/test/common/odp_cunit_common.c b/test/common/odp_cunit_common.c
index 651ae791e..e4e678a54 100644
--- a/test/common/odp_cunit_common.c
+++ b/test/common/odp_cunit_common.c
@@ -1,9 +1,7 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- * Copyright (c) 2021, Marvell
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2019-2024 Nokia
+ * Copyright (c) 2021 Marvell
*/
#ifndef _GNU_SOURCE
@@ -107,10 +105,8 @@ void odp_cu_assert(CU_BOOL value, unsigned int line,
if (idx < MAX_FAILURES) {
assertion_failure_t *a = &thr_global->failure[idx];
- strncpy(a->cond, condition, sizeof(a->cond));
- strncpy(a->file, file, sizeof(a->file));
- a->cond[sizeof(a->cond) - 1] = 0;
- a->file[sizeof(a->file) - 1] = 0;
+ odph_strcpy(a->cond, condition, sizeof(a->cond));
+ odph_strcpy(a->file, file, sizeof(a->file));
a->line = line;
a->fatal = fatal;
}
@@ -244,14 +240,25 @@ int odp_cunit_thread_create(int num, int func_ptr(void *), void *const arg[], in
int odp_cunit_thread_join(int num)
{
+ odph_thread_join_result_t res[num];
+
/* Wait for threads to exit */
- if (odph_thread_join(thread_tbl, num) != num) {
- fprintf(stderr, "error: odph_thread_join() failed.\n");
+ if (odph_thread_join_result(thread_tbl, res, num) != num) {
+ fprintf(stderr, "error: odph_thread_join_result() failed.\n");
return -1;
}
+
threads_running = 0;
thread_func = 0;
+ for (int i = 0; i < num; i++) {
+ if (res[i].is_sig || res[i].ret != 0) {
+ fprintf(stderr, "error: worker thread failure%s: %d.\n", res[i].is_sig ?
+ " (signaled)" : "", res[i].ret);
+ return -1;
+ }
+ }
+
handle_postponed_asserts();
return 0;
diff --git a/test/common/odp_cunit_common.h b/test/common/odp_cunit_common.h
index 63e95d5fb..8a5053589 100644
--- a/test/common/odp_cunit_common.h
+++ b/test/common/odp_cunit_common.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2020-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2020-2022 Nokia
*/
/**
@@ -154,48 +152,33 @@ static inline void odp_cu_assert_fatal(CU_BOOL value, unsigned int line,
#define CU_FAIL_FATAL(msg) \
{ odp_cu_assert_fatal(CU_FALSE, __LINE__, ("CU_FAIL_FATAL(" #msg ")"), __FILE__); }
+#undef CU_ASSERT_TRUE
+#undef CU_ASSERT_TRUE_FATAL
+#undef CU_ASSERT_FALSE
+#undef CU_ASSERT_FALSE_FATAL
#undef CU_ASSERT_EQUAL
-#define CU_ASSERT_EQUAL(actual, expected) \
- { odp_cu_assert(((actual) == (expected)), __LINE__, \
- ("CU_ASSERT_EQUAL(" #actual "," #expected ")"), \
- __FILE__, CU_FALSE); }
-
#undef CU_ASSERT_EQUAL_FATAL
-#define CU_ASSERT_EQUAL_FATAL(actual, expected) \
- { odp_cu_assert_fatal(((actual) == (expected)), __LINE__, \
- ("CU_ASSERT_EQUAL_FATAL(" #actual "," #expected ")"), \
- __FILE__); }
-
#undef CU_ASSERT_NOT_EQUAL
-#define CU_ASSERT_NOT_EQUAL(actual, expected) \
- { odp_cu_assert(((actual) != (expected)), __LINE__, \
- ("CU_ASSERT_NOT_EQUAL(" #actual "," #expected ")"), \
- __FILE__, CU_FALSE); }
-
#undef CU_ASSERT_NOT_EQUAL_FATAL
-#define CU_ASSERT_NOT_EQUAL_FATAL(actual, expected) \
- { odp_cu_assert_fatal(((actual) != (expected)), __LINE__, \
- ("CU_ASSERT_NOT_EQUAL_FATAL(" #actual "," #expected ")"), \
- __FILE__); }
-
+#undef CU_ASSERT_PTR_EQUAL
+#undef CU_ASSERT_PTR_EQUAL_FATAL
+#undef CU_ASSERT_PTR_NOT_EQUAL
+#undef CU_ASSERT_PTR_NOT_EQUAL_FATAL
#undef CU_ASSERT_PTR_NULL
-#define CU_ASSERT_PTR_NULL(value) \
- { odp_cu_assert((NULL == (const void *)(value)), __LINE__, \
- ("CU_ASSERT_PTR_NULL(" #value ")"), __FILE__, CU_FALSE); }
-
#undef CU_ASSERT_PTR_NULL_FATAL
-#define CU_ASSERT_PTR_NULL_FATAL(value) \
- { odp_cu_assert_fatal((NULL == (const void *)(value)), __LINE__, \
- ("CU_ASSERT_PTR_NULL_FATAL(" #value ")"), __FILE__); }
-
#undef CU_ASSERT_PTR_NOT_NULL
-#define CU_ASSERT_PTR_NOT_NULL(value) \
- { odp_cu_assert((NULL != (const void *)(value)), __LINE__, \
- ("CU_ASSERT_PTR_NOT_NULL_FATAL(" #value ")"), __FILE__, CU_FALSE); }
-
#undef CU_ASSERT_PTR_NOT_NULL_FATAL
-#define CU_ASSERT_PTR_NOT_NULL_FATAL(value) \
- { odp_cu_assert_fatal((NULL != (const void *)(value)), __LINE__, \
- ("CU_ASSERT_PTR_NOT_NULL_FATAL(" #value ")"), __FILE__); }
+#undef CU_ASSERT_STRING_EQUAL
+#undef CU_ASSERT_STRING_EQUAL_FATAL
+#undef CU_ASSERT_STRING_NOT_EQUAL
+#undef CU_ASSERT_STRING_NOT_EQUAL_FATAL
+#undef CU_ASSERT_NSTRING_EQUAL
+#undef CU_ASSERT_NSTRING_EQUAL_FATAL
+#undef CU_ASSERT_NSTRING_NOT_EQUAL
+#undef CU_ASSERT_NSTRING_NOT_EQUAL_FATAL
+#undef CU_ASSERT_DOUBLE_EQUAL
+#undef CU_ASSERT_DOUBLE_EQUAL_FATAL
+#undef CU_ASSERT_DOUBLE_NOT_EQUAL
+#undef CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL
#endif /* ODP_CUNICT_COMMON_H */
diff --git a/test/common/packet_common.c b/test/common/packet_common.c
index e0bca3147..a2b960af6 100644
--- a/test/common/packet_common.c
+++ b/test/common/packet_common.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
*/
#include <packet_common.h>
diff --git a/test/common/packet_common.h b/test/common/packet_common.h
index c7cd5e27f..2ffc5eab0 100644
--- a/test/common/packet_common.h
+++ b/test/common/packet_common.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
*/
#include <odp_api.h>
diff --git a/test/common/test_common_macros.h b/test/common/test_common_macros.h
index 344ac8159..405f626e9 100644
--- a/test/common/test_common_macros.h
+++ b/test/common/test_common_macros.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#ifndef TEST_COMMON_MACROS_H_
diff --git a/test/common/test_packet_custom.h b/test/common/test_packet_custom.h
index 7ff652bd8..5045a14aa 100644
--- a/test/common/test_packet_custom.h
+++ b/test/common/test_packet_custom.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020-2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020-2021 Nokia
*/
#ifndef TEST_PACKET_CUSTOM_H_
diff --git a/test/common/test_packet_ipsec.h b/test/common/test_packet_ipsec.h
index 918870c99..9fb6ae2c2 100644
--- a/test/common/test_packet_ipsec.h
+++ b/test/common/test_packet_ipsec.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef TEST_PACKET_IPSEC_H_
diff --git a/test/common/test_packet_ipv4.h b/test/common/test_packet_ipv4.h
index 8dd98d60d..c9c0ef09f 100644
--- a/test/common/test_packet_ipv4.h
+++ b/test/common/test_packet_ipv4.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2021-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2021-2022 Nokia
*/
#ifndef TEST_PACKET_IPV4_H_
diff --git a/test/common/test_packet_ipv4_with_crc.h b/test/common/test_packet_ipv4_with_crc.h
index f10c405e1..f0763823b 100644
--- a/test/common/test_packet_ipv4_with_crc.h
+++ b/test/common/test_packet_ipv4_with_crc.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
#ifndef TEST_PACKET_IPV4_WITH_CRC_H_
diff --git a/test/common/test_packet_ipv6.h b/test/common/test_packet_ipv6.h
index 8703aab34..427f7fbdd 100644
--- a/test/common/test_packet_ipv6.h
+++ b/test/common/test_packet_ipv6.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#ifndef TEST_PACKET_IPV6_H_
diff --git a/test/m4/configure.m4 b/test/m4/configure.m4
index ea05e954f..97d824c86 100644
--- a/test/m4/configure.m4
+++ b/test/m4/configure.m4
@@ -25,6 +25,7 @@ AC_CONFIG_FILES([test/common/Makefile
test/validation/api/chksum/Makefile
test/validation/api/classification/Makefile
test/validation/api/comp/Makefile
+ test/validation/api/cpu/Makefile
test/validation/api/cpumask/Makefile
test/validation/api/crypto/Makefile
test/validation/api/dma/Makefile
diff --git a/test/miscellaneous/.gitignore b/test/miscellaneous/.gitignore
index 6069e336d..74fb9b3ca 100644
--- a/test/miscellaneous/.gitignore
+++ b/test/miscellaneous/.gitignore
@@ -1,3 +1,4 @@
+odp_dyn_workers
odp_api_from_cpp
odp_api_headers
*.trs
diff --git a/test/miscellaneous/Makefile.am b/test/miscellaneous/Makefile.am
index 95514edcb..449ee7b24 100644
--- a/test/miscellaneous/Makefile.am
+++ b/test/miscellaneous/Makefile.am
@@ -1,12 +1,23 @@
include $(top_srcdir)/test/Makefile.inc
+bin_PROGRAMS = odp_dyn_workers
+
if test_cpp
-bin_PROGRAMS = odp_api_from_cpp
-TESTS = odp_api_from_cpp
+bin_PROGRAMS += odp_api_from_cpp
endif
+odp_dyn_workers_CFLAGS = $(AM_CFLAGS) -Wno-format-nonliteral
+odp_dyn_workers_SOURCES = odp_dyn_workers.c
odp_api_from_cpp_SOURCES = odp_api_from_cpp.cpp
+TESTSCRIPTS = odp_dyn_workers_run.sh
+
+TESTS = $(TESTSCRIPTS)
+
+if test_cpp
+TESTS += odp_api_from_cpp
+endif
+
noinst_PROGRAMS = odp_api_headers
odp_api_headers_CFLAGS = $(AM_CFLAGS) -Wconversion
odp_api_headers_SOURCES = odp_api_headers.c
@@ -43,3 +54,25 @@ endif
endif
DISTCLEANFILES = $(PROGRAM_shared) $(PROGRAM_static)
+
+dist_check_SCRIPTS = $(TESTSCRIPTS)
+
+# If building out-of-tree, make check will not copy the scripts and data to the
+# $(builddir) assuming that all commands are run locally. However this prevents
+# running tests on a remote target using LOG_COMPILER.
+# So copy all script and data files explicitly here.
+all-local:
+ if [ "x$(srcdir)" != "x$(builddir)" ]; then \
+ for f in $(dist_check_SCRIPTS) $(dist_check_DATA); do \
+ if [ -e $(srcdir)/$$f ]; then \
+ mkdir -p $(builddir)/$$(dirname $$f); \
+ cp -f $(srcdir)/$$f $(builddir)/$$f; \
+ fi \
+ done \
+ fi
+clean-local:
+ if [ "x$(srcdir)" != "x$(builddir)" ]; then \
+ for f in $(dist_check_SCRIPTS) $(dist_check_DATA); do \
+ rm -f $(builddir)/$$f; \
+ done \
+ fi
diff --git a/test/miscellaneous/odp_api_headers.c b/test/miscellaneous/odp_api_headers.c
index 0dd6b0a2e..3884ab307 100644
--- a/test/miscellaneous/odp_api_headers.c
+++ b/test/miscellaneous/odp_api_headers.c
@@ -1,8 +1,5 @@
-/* Copyright (c) 2022, Nokia
- *
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Nokia
*/
#include <odp_api.h>
diff --git a/test/miscellaneous/odp_dyn_workers.c b/test/miscellaneous/odp_dyn_workers.c
new file mode 100644
index 000000000..14cbdaa0d
--- /dev/null
+++ b/test/miscellaneous/odp_dyn_workers.c
@@ -0,0 +1,1357 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2024 Nokia
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <signal.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <syslog.h>
+#include <sys/prctl.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+
+#include <odp_api.h>
+#include <odp/helper/odph_api.h>
+
+#define S_(x) #x
+#define S(x) S_(x)
+#define MAX_PROGS 8
+#define CMD_DELIMITER ","
+#define PROG_NAME "odp_dyn_workers"
+
+#define FOREACH_CMD(CMD) \
+ CMD(ADD_WORKER) \
+ CMD(REM_WORKER)
+
+#define GENERATE_ENUM(ENUM) ENUM,
+#define GENERATE_STRING(STRING) #STRING,
+#define ADDITION 'a'
+#define REMOVAL 'r'
+#define DELAY 'd'
+#define IDX_DELIMITER ":"
+#define MAX_NIBBLE 15
+#define MAX_WORKERS MAX_NIBBLE
+#define MAX_PATTERN_LEN 32U
+#define ENV_PREFIX "ODP"
+#define ENV_DELIMITER "="
+#define UNKNOWN_CMD MAX_NIBBLE
+#define EXIT_PROG (UNKNOWN_CMD - 1U)
+#define DELAY_PROG (EXIT_PROG - 1U)
+
+ODP_STATIC_ASSERT(MAX_WORKERS <= MAX_NIBBLE, "Too many workers");
+
+enum {
+ FOREACH_CMD(GENERATE_ENUM)
+};
+
+typedef enum {
+ PRS_OK,
+ PRS_NOK,
+ PRS_TERM
+} parse_result_t;
+
+enum {
+ PARENT,
+ CHILD
+};
+
+typedef enum {
+ DOWN,
+ UP
+} state_t;
+
+enum {
+ CONN_ERR = -1,
+ PEER_ERR,
+ CMD_NOK,
+ CMD_SUMMARY,
+ CMD_OK
+};
+
+static const char *const cmdstrs[] = {
+ FOREACH_CMD(GENERATE_STRING)
+};
+
+ODP_STATIC_ASSERT(ODPH_ARRAY_SIZE(cmdstrs) < DELAY_PROG, "Too many commands");
+
+typedef struct {
+ uint64_t thread_id;
+ uint64_t num_handled;
+ uint64_t enq_errs;
+ uint64_t runtime;
+} summary_t;
+
+typedef struct prog_t {
+ summary_t summary;
+ char *env;
+ char *cpumask;
+ pid_t pid;
+ int socket;
+ state_t state;
+} prog_t;
+
+typedef struct {
+ uint64_t val1;
+ uint8_t val2;
+ uint8_t op;
+} pattern_t;
+
+typedef struct {
+ pattern_t pattern[MAX_PATTERN_LEN];
+ prog_t progs[MAX_PROGS];
+ uint32_t num_p_elems;
+ uint32_t num_progs;
+ uint32_t max_cmd_len;
+ odp_bool_t is_running;
+} global_config_t;
+
+typedef struct worker_config_s worker_config_t;
+
+typedef struct worker_config_s {
+ odph_thread_t thread;
+ odp_barrier_t barrier;
+ summary_t summary;
+ odp_ticketlock_t lock;
+ odp_schedule_group_t grp;
+ odp_queue_t queue;
+ worker_config_t *configs;
+ odp_atomic_u32_t is_running;
+ uint8_t idx;
+} worker_config_t;
+
+typedef struct {
+ worker_config_t worker_config[MAX_WORKERS];
+ odp_instance_t instance;
+ odp_cpumask_t cpumask;
+ odp_pool_t pool;
+ summary_t *pending_summary;
+ uint32_t num_workers;
+ int socket;
+} prog_config_t;
+
+typedef struct {
+ struct {
+ uint16_t is_active;
+ uint16_t cpu;
+ uint32_t thread_id;
+ } workers[MAX_WORKERS];
+} result_t;
+
+typedef odp_bool_t (*input_fn_t)(global_config_t *config, uint8_t *cmd, uint32_t *prog_idx,
+ uint32_t *worker_idx);
+typedef odp_bool_t (*cmd_fn_t)(prog_config_t *config, uint8_t aux);
+
+static global_config_t conf;
+static prog_config_t *prog_conf;
+
+static void terminate(int signal ODP_UNUSED)
+{
+ conf.is_running = false;
+}
+
+static odp_bool_t setup_signals(void)
+{
+ 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)
+ return false;
+
+ return true;
+}
+
+static void init_options(global_config_t *config)
+{
+ uint32_t max_len = 0U, str_len;
+
+ memset(config, 0, sizeof(*config));
+
+ for (uint32_t i = 0U; i < ODPH_ARRAY_SIZE(cmdstrs); ++i) {
+ str_len = strlen(cmdstrs[i]);
+
+ if (str_len > max_len)
+ max_len = str_len;
+ }
+
+ config->max_cmd_len = max_len;
+}
+
+static void parse_masks(global_config_t *config, const char *optarg)
+{
+ char *tmp_str = strdup(optarg), *tmp;
+ prog_t *prog;
+
+ if (tmp_str == NULL)
+ return;
+
+ tmp = strtok(tmp_str, CMD_DELIMITER);
+
+ while (tmp && config->num_progs < MAX_PROGS) {
+ prog = &config->progs[config->num_progs];
+ prog->cpumask = strdup(tmp);
+
+ if (prog->cpumask != NULL)
+ ++config->num_progs;
+
+ tmp = strtok(NULL, CMD_DELIMITER);
+ }
+
+ free(tmp_str);
+}
+
+static void parse_pattern(global_config_t *config, const char *optarg)
+{
+ char *tmp_str = strdup(optarg), *tmp, op;
+ uint8_t num_elems = 0U;
+ pattern_t *pattern;
+ uint64_t val1;
+ uint32_t val2;
+ int ret;
+
+ if (tmp_str == NULL)
+ return;
+
+ tmp = strtok(tmp_str, CMD_DELIMITER);
+
+ while (tmp && num_elems < MAX_PATTERN_LEN) {
+ pattern = &config->pattern[num_elems];
+ /* Use invalid values to prevent correct values by chance. */
+ val1 = -1;
+ val2 = -1;
+ ret = sscanf(tmp, "%c%" PRIu64 IDX_DELIMITER "%u", &op, &val1, &val2);
+
+ if ((ret == 2 || ret == 3) && (op == ADDITION || op == REMOVAL || op == DELAY)) {
+ pattern->val1 = val1;
+ pattern->val2 = val2;
+ pattern->op = op;
+ ++num_elems;
+ }
+
+ tmp = strtok(NULL, CMD_DELIMITER);
+ }
+
+ free(tmp_str);
+ config->num_p_elems = num_elems;
+}
+
+static void print_usage(void)
+{
+ printf("\n"
+ "Simple interactive ODP dynamic worker tester. Can be used to verify ability of\n"
+ "an implementation to dynamically add and remove workers from one ODP application\n"
+ "to another. Acts as a frontend and forks ODP applications based on\n"
+ "configuration.\n"
+ "\n"
+ "Usage: " PROG_NAME " OPTIONS\n"
+ "\n"
+ " E.g. ODP0=MY_ENV=MY_VAL ODP1=MY_ENV=MY_VAL " PROG_NAME " -c 0x80,0x80\n"
+ " ...\n"
+ " > %s 0 0\n"
+ " > %s 0 0\n"
+ " > %s 1 0\n"
+ " > %s 1 0\n"
+ " ...\n"
+ " " PROG_NAME " -c 0x80,0x80 -p %c0%s0%s%c1000000000%s%c0%s0\n"
+ "\n"
+ "Mandatory OPTIONS:\n"
+ "\n"
+ " -c, --cpumasks CPU masks for to-be-created ODP processes, comma-separated, no\n"
+ " spaces. CPU mask format should be as expected by\n"
+ " 'odp_cpumask_from_str()'. Parsed amount of CPU masks will be\n"
+ " the number of ODP processes to be created. Theoretical maximum\n"
+ " number of CPU mask entries (and to-be-created ODP processes) is\n"
+ " %u. Theoretical maximum number of workers per ODP process is\n"
+ " %u. These might be further limited by the implementation.\n\n"
+ " A single environment variable can be passed to the processes.\n"
+ " The format should be: 'ODP<x>=<name>=<value>', where <x> is\n"
+ " process index, starting from 0.\n"
+ "\n"
+ "Optional OPTIONS:\n"
+ "\n"
+ " -p, --pattern Non-interactive mode with a pattern of worker additions,\n"
+ " removals and delays, delimited by '%s', no spaces. Additions\n"
+ " are indicated with '%c' prefix, removals with '%c' prefix, both\n"
+ " followed by process index, starting from 0 and worker thread\n"
+ " index within given cpumask delimited by '%s', and delays with\n"
+ " '%c' prefix, followed by a delay in nanoseconds. Process\n"
+ " indexes are based on the parsed process count of '--cpumasks'\n"
+ " option. Additions and removals should be equal in the aggregate\n"
+ " and removals should never outnumber additions at any instant.\n"
+ " Maximum pattern length is %u.\n"
+ " -h, --help This help.\n"
+ "\n", cmdstrs[ADD_WORKER], cmdstrs[REM_WORKER], cmdstrs[ADD_WORKER],
+ cmdstrs[REM_WORKER], ADDITION, IDX_DELIMITER, CMD_DELIMITER, DELAY, CMD_DELIMITER,
+ REMOVAL, IDX_DELIMITER, MAX_PROGS, MAX_WORKERS, CMD_DELIMITER, ADDITION, REMOVAL,
+ IDX_DELIMITER, DELAY, MAX_PATTERN_LEN);
+}
+
+static parse_result_t check_options(const global_config_t *config)
+{
+ const pattern_t *pattern;
+ int64_t num_tot = 0U;
+
+ if (config->num_progs == 0U || config->num_progs > MAX_PROGS) {
+ printf("Invalid number of CPU masks: %u\n", config->num_progs);
+ return PRS_NOK;
+ }
+
+ for (uint32_t i = 0U; i < config->num_p_elems; ++i) {
+ pattern = &config->pattern[i];
+
+ if (pattern->op != DELAY) {
+ if (pattern->val1 >= config->num_progs) {
+ ODPH_ERR("Invalid pattern, invalid process index: %" PRIu64 "\n",
+ pattern->val1);
+ return PRS_NOK;
+ }
+
+ if (pattern->val2 > MAX_WORKERS - 1) {
+ ODPH_ERR("Invalid pattern, invalid worker index: %u\n",
+ pattern->val2);
+ return PRS_NOK;
+ }
+ }
+
+ if (pattern->op == ADDITION)
+ ++num_tot;
+ else if (pattern->op == REMOVAL)
+ --num_tot;
+
+ if (num_tot < 0) {
+ ODPH_ERR("Invalid pattern, removals exceed additions instantaneously\n");
+ return PRS_NOK;
+ }
+ }
+
+ if (num_tot > 0) {
+ ODPH_ERR("Invalid pattern, more additions than removals\n");
+ return PRS_NOK;
+ }
+
+ return PRS_OK;
+}
+
+static parse_result_t parse_options(int argc, char **argv, global_config_t *config)
+{
+ int opt, long_index;
+
+ static const struct option longopts[] = {
+ { "cpumasks", required_argument, NULL, 'c' },
+ { "pattern", required_argument, NULL, 'p' },
+ { "help", no_argument, NULL, 'h' },
+ { NULL, 0, NULL, 0 }
+ };
+
+ static const char *shortopts = "c:p:h";
+
+ init_options(config);
+
+ while (1) {
+ opt = getopt_long(argc, argv, shortopts, longopts, &long_index);
+
+ if (opt == -1)
+ break;
+
+ switch (opt) {
+ case 'c':
+ parse_masks(config, optarg);
+ break;
+ case 'p':
+ parse_pattern(config, optarg);
+ break;
+ case 'h':
+ print_usage();
+ return PRS_TERM;
+ case '?':
+ default:
+ print_usage();
+ return PRS_NOK;
+ }
+ }
+
+ return check_options(config);
+}
+
+static odp_bool_t setup_pkill(pid_t ppid)
+{
+ return prctl(PR_SET_PDEATHSIG, SIGKILL) != -1 && getppid() == ppid;
+}
+
+ODP_PRINTF_FORMAT(2, 3)
+int log_fn(odp_log_level_t level, const char *fmt, ...);
+
+int log_fn(odp_log_level_t level, const char *fmt, ...)
+{
+ int pri;
+ va_list args;
+
+ switch (level) {
+ case ODP_LOG_DBG:
+ case ODP_LOG_PRINT:
+ pri = LOG_INFO;
+ break;
+ case ODP_LOG_WARN:
+ pri = LOG_WARNING;
+ break;
+ case ODP_LOG_ERR:
+ case ODP_LOG_UNIMPLEMENTED:
+ case ODP_LOG_ABORT:
+ pri = LOG_ERR;
+ break;
+ default:
+ pri = LOG_INFO;
+ break;
+ }
+
+ va_start(args, fmt);
+ vsyslog(pri, fmt, args);
+ va_end(args);
+
+ /* Just return something that's not considered an error. */
+ return 0;
+}
+
+static odp_bool_t disable_stream(int fd, odp_bool_t read)
+{
+ const int null = open("/dev/null", read ? O_RDONLY : O_WRONLY);
+ odp_bool_t ret = false;
+
+ if (null == -1)
+ return ret;
+
+ ret = dup2(null, fd) != -1;
+ close(null);
+
+ return ret;
+}
+
+static odp_bool_t set_odp_env(char *env)
+{
+ char *tmp_str = strdup(env), *tmp;
+ int ret;
+ odp_bool_t func_ret = false;
+
+ if (tmp_str == NULL)
+ return func_ret;
+
+ tmp = strtok(tmp_str, ENV_DELIMITER);
+
+ if (tmp != NULL) {
+ ret = setenv(tmp, strstr(env, ENV_DELIMITER) + 1U, 1);
+
+ if (ret == -1)
+ perror("setenv");
+
+ func_ret = ret != -1;
+ }
+
+ free(tmp_str);
+
+ return func_ret;
+}
+
+static odp_bool_t setup_prog_config(prog_config_t *config, odp_instance_t odp_instance,
+ char *cpumask, int socket)
+{
+ worker_config_t *worker_config;
+ odp_pool_param_t param;
+ odp_pool_t pool;
+
+ memset(config, 0, sizeof(*config));
+
+ for (uint32_t i = 0U; i < MAX_WORKERS; ++i) {
+ worker_config = &config->worker_config[i];
+ worker_config->thread.cpu = -1;
+ odp_ticketlock_init(&worker_config->lock);
+ worker_config->queue = ODP_QUEUE_INVALID;
+ odp_atomic_init_u32(&worker_config->is_running, 0U);
+ }
+
+ config->instance = odp_instance;
+ odp_cpumask_from_str(&config->cpumask, cpumask);
+ odp_pool_param_init(&param);
+ param.type = ODP_POOL_BUFFER;
+ param.buf.num = 1U;
+ param.buf.size = ODP_CACHE_LINE_SIZE;
+ pool = odp_pool_create(NULL, &param);
+
+ if (pool == ODP_POOL_INVALID) {
+ log_fn(ODP_LOG_ERR, "Error creating process buffer pool\n");
+ return false;
+ }
+
+ config->pool = pool;
+ config->socket = socket;
+
+ return true;
+}
+
+static inline void decode_cmd(uint8_t data, uint8_t *cmd, uint8_t *aux)
+{
+ /* Actual command will be in the high nibble and worker index in the low nibble. */
+ *cmd = data >> 4U;
+ *aux = data & 0xF;
+}
+
+static void build_result(const prog_config_t *config, result_t *result)
+{
+ uint32_t num = 0U;
+ const worker_config_t *worker_config;
+
+ for (uint32_t i = 0U; i < MAX_WORKERS; ++i) {
+ worker_config = &config->worker_config[i];
+
+ if (worker_config->thread.cpu != -1) {
+ result->workers[num].is_active = 1;
+ result->workers[num].thread_id = worker_config->summary.thread_id;
+ result->workers[num].cpu = worker_config->thread.cpu;
+ ++num;
+ }
+ }
+}
+
+static void run_command(cmd_fn_t cmd_fn, uint8_t aux, prog_config_t *config, int socket)
+{
+ const odp_bool_t is_ok = cmd_fn(config, aux);
+ const summary_t *summary = config->pending_summary;
+ uint8_t rep = !is_ok ? CMD_NOK : summary != NULL ? CMD_SUMMARY : CMD_OK;
+ result_t result;
+
+ (void)TEMP_FAILURE_RETRY(send(socket, &rep, sizeof(rep), MSG_NOSIGNAL));
+
+ /* Same machine, no internet in-between, just send the structs as is. */
+ if (rep == CMD_OK) {
+ memset(&result, 0, sizeof(result));
+ build_result(config, &result);
+ (void)TEMP_FAILURE_RETRY(send(socket, (const void *)&result, sizeof(result),
+ MSG_NOSIGNAL));
+ } else if (rep == CMD_SUMMARY) {
+ (void)TEMP_FAILURE_RETRY(send(socket, (const void *)summary, sizeof(*summary),
+ MSG_NOSIGNAL));
+ config->pending_summary = NULL;
+ }
+}
+
+static odp_bool_t setup_worker_config(worker_config_t *config)
+{
+ odp_thrmask_t tmask;
+ odp_schedule_group_t grp;
+ odp_queue_param_t queue_param;
+ odp_queue_t queue;
+
+ odp_thrmask_zero(&tmask);
+ grp = odp_schedule_group_create(NULL, &tmask);
+
+ if (grp == ODP_SCHED_GROUP_INVALID) {
+ log_fn(ODP_LOG_ERR, "Error creating scheduler group\n");
+ return false;
+ }
+
+ config->grp = grp;
+ odp_queue_param_init(&queue_param);
+ queue_param.type = ODP_QUEUE_TYPE_SCHED;
+ queue_param.sched.group = config->grp;
+ queue = odp_queue_create(NULL, &queue_param);
+
+ if (queue == ODP_QUEUE_INVALID) {
+ log_fn(ODP_LOG_ERR, "Error creating queue\n");
+ (void)odp_schedule_group_destroy(config->grp);
+ return false;
+ }
+
+ odp_ticketlock_lock(&config->lock);
+ config->queue = queue;
+ odp_ticketlock_unlock(&config->lock);
+
+ return true;
+}
+
+static inline int get_cpu(odp_cpumask_t *mask, int idx)
+{
+ int cpu = odp_cpumask_first(mask);
+
+ while (idx--) {
+ cpu = odp_cpumask_next(mask, cpu);
+
+ if (cpu < 0)
+ break;
+ }
+
+ return cpu;
+}
+
+static odp_bool_t signal_ready(int socket)
+{
+ uint8_t cmd = CMD_OK;
+ ssize_t ret;
+
+ ret = TEMP_FAILURE_RETRY(send(socket, &cmd, sizeof(cmd), MSG_NOSIGNAL));
+
+ if (ret != 1) {
+ log_fn(ODP_LOG_ERR, "Error signaling process readiness: %s\n", strerror(errno));
+ return false;
+ }
+
+ return true;
+}
+
+static void enq_to_next_queue(worker_config_t *config, int idx, odp_event_t ev, summary_t *summary)
+{
+ worker_config_t *worker_config;
+ int ret;
+
+ for (uint32_t i = 1U; i <= MAX_WORKERS; ++i) {
+ worker_config = &config[(idx + i) % MAX_WORKERS];
+ odp_ticketlock_lock(&worker_config->lock);
+
+ if (worker_config->queue == ODP_QUEUE_INVALID) {
+ odp_ticketlock_unlock(&worker_config->lock);
+ continue;
+ }
+
+ ret = odp_queue_enq(worker_config->queue, ev);
+ ++summary->num_handled;
+
+ if (ret < 0)
+ ++summary->enq_errs;
+
+ odp_ticketlock_unlock(&worker_config->lock);
+ return;
+ }
+
+ odp_event_free(ev);
+}
+
+static int run_worker(void *args)
+{
+ odp_time_t tm;
+ odp_thrmask_t tmask;
+ const int thread_id = odp_thread_id();
+ worker_config_t *config = args;
+ odp_event_t ev;
+ worker_config_t *configs = config->configs;
+ summary_t *summary = &config->summary;
+ const uint8_t idx = config->idx;
+
+ summary->thread_id = thread_id;
+ tm = odp_time_local_strict();
+ odp_thrmask_zero(&tmask);
+ odp_thrmask_set(&tmask, thread_id);
+
+ if (odp_schedule_group_join(config->grp, &tmask) < 0)
+ /* Log but still continue. */
+ log_fn(ODP_LOG_ERR, "Error joining scheduler group\n");
+
+ odp_barrier_wait(&config->barrier);
+
+ while (odp_atomic_load_u32(&config->is_running)) {
+ ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT);
+
+ if (ev == ODP_EVENT_INVALID)
+ continue;
+
+ enq_to_next_queue(configs, idx, ev, summary);
+ }
+
+ while (true) {
+ ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT);
+
+ if (ev == ODP_EVENT_INVALID)
+ break;
+
+ enq_to_next_queue(configs, idx, ev, summary);
+ }
+
+ summary->runtime = odp_time_diff_ns(odp_time_local_strict(), tm);
+
+ return 0;
+}
+
+static void shutdown_worker(worker_config_t *config)
+{
+ odp_queue_t queue;
+
+ odp_ticketlock_lock(&config->lock);
+ queue = config->queue;
+ config->queue = ODP_QUEUE_INVALID;
+ odp_ticketlock_unlock(&config->lock);
+
+ odp_atomic_store_u32(&config->is_running, 0U);
+ (void)odph_thread_join(&config->thread, 1);
+ (void)odp_queue_destroy(queue);
+ (void)odp_schedule_group_destroy(config->grp);
+}
+
+static odp_bool_t bootstrap_scheduling(worker_config_t *config, odp_pool_t pool)
+{
+ odp_buffer_t buf = odp_buffer_alloc(pool);
+
+ if (buf == ODP_BUFFER_INVALID)
+ /* Event still in circulation. */
+ return true;
+
+ if (odp_queue_enq(config->queue, odp_buffer_to_event(buf)) < 0) {
+ log_fn(ODP_LOG_ERR, "Error enqueueing bootstrap event\n");
+ odp_buffer_free(buf);
+ shutdown_worker(config);
+ return false;
+ }
+
+ return true;
+}
+
+static odp_bool_t add_worker(prog_config_t *config, uint8_t idx)
+{
+ worker_config_t *worker_config;
+ odph_thread_common_param_t thr_common;
+ int set_cpu;
+ odp_cpumask_t cpumask;
+ odph_thread_param_t thr_param;
+
+ if (config->num_workers == MAX_WORKERS) {
+ log_fn(ODP_LOG_WARN, "Maximum number of workers already created\n");
+ return false;
+ }
+
+ if (idx >= MAX_WORKERS) {
+ log_fn(ODP_LOG_ERR, "Worker index out of bounds: %u\n", idx);
+ return false;
+ }
+
+ worker_config = &config->worker_config[idx];
+
+ if (worker_config->thread.cpu != -1) {
+ log_fn(ODP_LOG_WARN, "Worker already created: %u\n", idx);
+ return false;
+ }
+
+ set_cpu = get_cpu(&config->cpumask, idx);
+
+ if (set_cpu < 0) {
+ log_fn(ODP_LOG_ERR, "No CPU found for index: %u\n", idx);
+ return false;
+ }
+
+ memset(&worker_config->summary, 0, sizeof(worker_config->summary));
+
+ if (!setup_worker_config(worker_config))
+ return false;
+
+ worker_config->configs = config->worker_config;
+ worker_config->idx = idx;
+ odph_thread_common_param_init(&thr_common);
+ thr_common.instance = config->instance;
+
+ odp_cpumask_zero(&cpumask);
+ odp_cpumask_set(&cpumask, set_cpu);
+ thr_common.cpumask = &cpumask;
+ odph_thread_param_init(&thr_param);
+ thr_param.start = run_worker;
+ thr_param.thr_type = ODP_THREAD_WORKER;
+ thr_param.arg = worker_config;
+ odp_atomic_store_u32(&worker_config->is_running, 1U);
+ /* Control thread + worker thread = barrier count */
+ odp_barrier_init(&worker_config->barrier, 2);
+
+ if (odph_thread_create(&worker_config->thread, &thr_common, &thr_param, 1) != 1) {
+ log_fn(ODP_LOG_ERR, "Error creating worker\n");
+ (void)odp_queue_destroy(worker_config->queue);
+ (void)odp_schedule_group_destroy(worker_config->grp);
+ return false;
+ }
+
+ odp_barrier_wait(&worker_config->barrier);
+ ++config->num_workers;
+
+ if (config->num_workers == 1U && !bootstrap_scheduling(worker_config, config->pool))
+ return false;
+
+ return true;
+}
+
+static odp_bool_t remove_worker(prog_config_t *config, uint8_t idx)
+{
+ worker_config_t *worker_config;
+
+ if (config->num_workers == 0U) {
+ log_fn(ODP_LOG_WARN, "No more workers to remove\n");
+ return false;
+ }
+
+ if (idx >= MAX_WORKERS) {
+ log_fn(ODP_LOG_ERR, "Worker index out of bounds: %u\n", idx);
+ return false;
+ }
+
+ worker_config = &config->worker_config[idx];
+
+ if (worker_config->thread.cpu == -1) {
+ log_fn(ODP_LOG_WARN, "Worker already removed: %u\n", idx);
+ return false;
+ }
+
+ shutdown_worker(worker_config);
+ --config->num_workers;
+ worker_config->thread.cpu = -1;
+ config->pending_summary = &worker_config->summary;
+
+ return true;
+}
+
+static odp_bool_t do_exit(prog_config_t *config, uint8_t aux ODP_UNUSED)
+{
+ for (uint32_t i = 0U; i < MAX_WORKERS; ++i)
+ remove_worker(config, i);
+
+ return true;
+}
+
+static void run_prog(prog_config_t *config)
+{
+ odp_bool_t is_running = true;
+ int socket = config->socket;
+ ssize_t ret;
+ uint8_t data, cmd, aux;
+
+ while (is_running) {
+ ret = TEMP_FAILURE_RETRY(recv(socket, &data, sizeof(data), 0));
+
+ if (ret != 1)
+ continue;
+
+ decode_cmd(data, &cmd, &aux);
+
+ switch (cmd) {
+ case ADD_WORKER:
+ run_command(add_worker, aux, config, socket);
+ break;
+ case REM_WORKER:
+ run_command(remove_worker, aux, config, socket);
+ break;
+ case EXIT_PROG:
+ run_command(do_exit, aux, config, socket);
+ is_running = false;
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+static void teardown_prog(prog_config_t *config)
+{
+ (void)odp_pool_destroy(config->pool);
+}
+
+static void run_odp(char *cpumask, int socket)
+{
+ odp_instance_t odp_instance;
+ odp_init_t param;
+ odp_shm_t shm_cfg = ODP_SHM_INVALID;
+
+ odp_init_param_init(&param);
+ param.log_fn = log_fn;
+
+ if (odp_init_global(&odp_instance, &param, NULL)) {
+ log_fn(ODP_LOG_ERR, "ODP global init failed\n");
+ return;
+ }
+
+ if (odp_init_local(odp_instance, ODP_THREAD_CONTROL)) {
+ log_fn(ODP_LOG_ERR, "ODP local init failed\n");
+ return;
+ }
+
+ shm_cfg = odp_shm_reserve(NULL, sizeof(prog_config_t), ODP_CACHE_LINE_SIZE, 0U);
+
+ if (shm_cfg == ODP_SHM_INVALID) {
+ log_fn(ODP_LOG_ERR, "Error reserving shared memory\n");
+ return;
+ }
+
+ prog_conf = odp_shm_addr(shm_cfg);
+
+ if (prog_conf == NULL) {
+ log_fn(ODP_LOG_ERR, "Error resolving shared memory address\n");
+ return;
+ }
+
+ if (odp_schedule_config(NULL) < 0) {
+ log_fn(ODP_LOG_ERR, "Error configuring scheduler\n");
+ return;
+ }
+
+ if (!setup_prog_config(prog_conf, odp_instance, cpumask, socket))
+ return;
+
+ if (!signal_ready(prog_conf->socket))
+ return;
+
+ run_prog(prog_conf);
+ teardown_prog(prog_conf);
+ (void)odp_shm_free(shm_cfg);
+
+ if (odp_term_local()) {
+ log_fn(ODP_LOG_ERR, "ODP local terminate failed\n");
+ return;
+ }
+
+ if (odp_term_global(odp_instance)) {
+ log_fn(ODP_LOG_ERR, "ODP global terminate failed\n");
+ return;
+ }
+}
+
+static odp_bool_t wait_process_ready(int socket)
+{
+ uint8_t data;
+ ssize_t ret;
+
+ ret = TEMP_FAILURE_RETRY(recv(socket, &data, sizeof(data), 0));
+
+ if (ret <= 0) {
+ if (ret < 0)
+ perror("recv");
+
+ return false;
+ }
+
+ return true;
+}
+
+static inline odp_bool_t is_interactive(const global_config_t *config)
+{
+ return config->num_p_elems == 0U;
+}
+
+static void print_cli_usage(void)
+{
+ printf("\nValid commands are:\n\n");
+
+ for (uint32_t i = 0U; i < ODPH_ARRAY_SIZE(cmdstrs); ++i)
+ printf(" %s <process index> <worker index>\n", cmdstrs[i]);
+
+ printf("\n");
+}
+
+static char *get_format_str(uint32_t max_cmd_len)
+{
+ const int cmd_len = snprintf(NULL, 0U, "%u", max_cmd_len);
+ uint32_t str_len;
+
+ if (cmd_len <= 0)
+ return NULL;
+
+ str_len = strlen("%s %u %u") + cmd_len + 1U;
+
+ char fmt[str_len];
+
+ snprintf(fmt, str_len, "%%%ds %%u %%u", max_cmd_len);
+
+ return strdup(fmt);
+}
+
+static uint8_t map_str_to_command(const char *cmdstr, uint32_t len)
+{
+ for (uint32_t i = 0U; i < ODPH_ARRAY_SIZE(cmdstrs); ++i)
+ if (strncmp(cmdstr, cmdstrs[i], len) == 0)
+ return i;
+
+ return UNKNOWN_CMD;
+}
+
+static odp_bool_t get_stdin_command(global_config_t *config, uint8_t *cmd, uint32_t *prog_idx,
+ uint32_t *worker_idx)
+{
+ char *input, cmdstr[config->max_cmd_len + 1U], *fmt;
+ size_t size;
+ ssize_t ret;
+
+ input = NULL;
+ memset(cmdstr, 0, sizeof(cmdstr));
+ printf("> ");
+ ret = getline(&input, &size, stdin);
+
+ if (ret == -1)
+ return false;
+
+ fmt = get_format_str(config->max_cmd_len);
+
+ if (fmt == NULL) {
+ printf("Unable to parse command\n");
+ return false;
+ }
+
+ ret = sscanf(input, fmt, cmdstr, prog_idx, worker_idx);
+ free(input);
+ free(fmt);
+
+ if (ret == EOF)
+ return false;
+
+ if (ret != 3) {
+ printf("Unable to parse command\n");
+ return false;
+ }
+
+ *cmd = map_str_to_command(cmdstr, config->max_cmd_len);
+ return true;
+}
+
+static uint8_t map_char_to_command(char cmdchar)
+{
+ switch (cmdchar) {
+ case ADDITION:
+ return ADD_WORKER;
+ case REMOVAL:
+ return REM_WORKER;
+ case DELAY:
+ return DELAY_PROG;
+ default:
+ return UNKNOWN_CMD;
+ }
+}
+
+static odp_bool_t get_pattern_command(global_config_t *config, uint8_t *cmd, uint32_t *prog_idx,
+ uint32_t *worker_idx)
+{
+ static uint32_t i;
+ const pattern_t *pattern;
+ struct timespec ts;
+
+ if (i == config->num_p_elems) {
+ config->is_running = false;
+ return false;
+ }
+
+ pattern = &config->pattern[i++];
+ *cmd = map_char_to_command(pattern->op);
+
+ if (*cmd == DELAY_PROG) {
+ ts.tv_sec = pattern->val1 / ODP_TIME_SEC_IN_NS;
+ ts.tv_nsec = pattern->val1 % ODP_TIME_SEC_IN_NS;
+ nanosleep(&ts, NULL);
+ return false;
+ }
+
+ *prog_idx = pattern->val1;
+ *worker_idx = pattern->val2;
+
+ return true;
+}
+
+static inline uint8_t encode_cmd(uint8_t cmd, uint8_t worker_idx)
+{
+ /* Actual command will be in the high nibble and worker index in the low nibble. */
+ cmd <<= 4U;
+ cmd |= worker_idx;
+
+ return cmd;
+}
+
+static odp_bool_t is_peer_down(int error)
+{
+ return error == ECONNRESET || error == EPIPE || error == ETIMEDOUT;
+}
+
+static int send_command(int socket, uint8_t cmd)
+{
+ uint8_t data;
+ ssize_t ret;
+ odp_bool_t is_down;
+
+ ret = TEMP_FAILURE_RETRY(send(socket, &cmd, sizeof(cmd), MSG_NOSIGNAL));
+
+ if (ret != 1) {
+ is_down = is_peer_down(errno);
+ perror("send");
+ return is_down ? PEER_ERR : CONN_ERR;
+ }
+
+ ret = TEMP_FAILURE_RETRY(recv(socket, &data, sizeof(data), 0));
+
+ if (ret <= 0) {
+ is_down = ret == 0 || is_peer_down(errno);
+
+ if (ret < 0)
+ perror("recv");
+
+ return is_down ? PEER_ERR : CONN_ERR;
+ }
+
+ return data;
+}
+
+static odp_bool_t recv_summary(int socket, summary_t *summary)
+{
+ const ssize_t size = sizeof(*summary),
+ ret = TEMP_FAILURE_RETRY(recv(socket, summary, size, 0));
+
+ return ret == size;
+}
+
+static void dump_summary(pid_t pid, const summary_t *summary)
+{
+ printf("\nremoved worker summary:\n"
+ " ODP process ID: %d\n"
+ " thread ID: %" PRIu64 "\n"
+ " events handled: %" PRIu64 "\n"
+ " enqueue errors: %" PRIu64 "\n"
+ " runtime: %" PRIu64 " (ns)\n\n", pid, summary->thread_id,
+ summary->num_handled, summary->enq_errs, summary->runtime);
+}
+
+static odp_bool_t check_summary(const summary_t *summary)
+{
+ if (summary->num_handled == 0U) {
+ printf("Summary check failure: no events handled\n");
+ return false;
+ }
+
+ if (summary->enq_errs > 0U) {
+ printf("Summary check failure: enqueue errors\n");
+ return false;
+ }
+
+ if (summary->runtime == 0U) {
+ printf("Summary check failure: no run time recorded\n");
+ return false;
+ }
+
+ return true;
+}
+
+static void dump_result(int socket, pid_t pid)
+{
+ result_t result;
+ const ssize_t size = sizeof(result),
+ ret = TEMP_FAILURE_RETRY(recv(socket, &result, size, 0));
+
+ if (ret != size)
+ return;
+
+ printf("\nODP process %d:\n"
+ "|\n", pid);
+
+ for (uint32_t i = 0U; i < MAX_WORKERS; i++)
+ if (result.workers[i].is_active)
+ printf("|--- Worker thread ID %u on CPU %u\n",
+ result.workers[i].thread_id, result.workers[i].cpu);
+
+ printf("\n");
+}
+
+static odp_bool_t run_global(global_config_t *config)
+{
+ input_fn_t input_fn;
+ uint32_t prog_idx, worker_idx;
+ uint8_t cmd;
+ prog_t *prog;
+ ssize_t ret;
+ odp_bool_t is_recv, func_ret = true;
+
+ print_cli_usage();
+ input_fn = is_interactive(config) ? get_stdin_command : get_pattern_command;
+ config->is_running = true;
+
+ while (config->is_running) {
+ if (!input_fn(config, &cmd, &prog_idx, &worker_idx))
+ continue;
+
+ if (cmd == UNKNOWN_CMD) {
+ printf("Unrecognized command\n");
+ continue;
+ }
+
+ if (prog_idx >= config->num_progs) {
+ printf("Invalid process index: %u\n", prog_idx);
+ continue;
+ }
+
+ prog = &config->progs[prog_idx];
+
+ if (prog->state == DOWN) {
+ printf("ODP process index %u has already exited\n", prog_idx);
+ continue;
+ }
+
+ ret = send_command(prog->socket, encode_cmd(cmd, worker_idx));
+
+ if (ret == CONN_ERR) {
+ printf("Fatal connection error, aborting\n");
+ abort();
+ }
+
+ if (ret == PEER_ERR) {
+ printf("ODP process index %u has exited\n", prog_idx);
+ prog->state = DOWN;
+ continue;
+ }
+
+ if (ret == CMD_NOK) {
+ printf("ODP process index %u was unable to execute the command\n",
+ prog_idx);
+ continue;
+ }
+
+ if (ret == CMD_SUMMARY) {
+ is_recv = recv_summary(prog->socket, &prog->summary);
+
+ if (is_recv)
+ dump_summary(prog->pid, &prog->summary);
+
+ if (!is_interactive(config) &&
+ !(is_recv && check_summary(&prog->summary))) {
+ config->is_running = false;
+ func_ret = false;
+ }
+
+ continue;
+ }
+
+ if (ret == CMD_OK)
+ dump_result(prog->socket, prog->pid);
+ }
+
+ for (uint32_t i = 0U; i < config->num_progs; ++i) {
+ prog = &config->progs[i];
+
+ if (prog->state == UP) {
+ for (uint32_t j = 0U; j < MAX_WORKERS; ++j) {
+ ret = send_command(prog->socket, encode_cmd(REM_WORKER, j));
+
+ if (ret == CONN_ERR || ret == PEER_ERR)
+ break;
+
+ if (ret != CMD_SUMMARY)
+ continue;
+
+ if (recv_summary(prog->socket, &prog->summary))
+ dump_summary(prog->pid, &prog->summary);
+ }
+
+ (void)send_command(prog->socket, encode_cmd(EXIT_PROG, 0));
+ (void)TEMP_FAILURE_RETRY(waitpid(prog->pid, NULL, 0));
+ }
+ }
+
+ return func_ret;
+}
+
+static void teardown_global(const global_config_t *config)
+{
+ const prog_t *prog;
+
+ for (uint32_t i = 0U; i < config->num_progs; ++i) {
+ prog = &config->progs[i];
+ close(prog->socket);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ parse_result_t res;
+ int ret, func_ret = EXIT_SUCCESS;
+ prog_t *prog;
+ pid_t pid, ppid;
+ const size_t envsize = strlen(ENV_PREFIX S(MAX_PROGS)) + 1U;
+ char *env, prog_env[envsize];
+
+ if (!setup_signals()) {
+ printf("Error setting up signals, exiting\n");
+ return EXIT_FAILURE;
+ }
+
+ res = parse_options(argc, argv, &conf);
+
+ if (res == PRS_NOK)
+ return EXIT_FAILURE;
+
+ if (res == PRS_TERM)
+ return EXIT_SUCCESS;
+
+ printf("*** ODP dynamic worker tester ***\n\n");
+
+ for (uint32_t i = 0U; i < conf.num_progs; ++i) {
+ int sockets[2U];
+
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
+
+ if (ret == -1) {
+ perror("socketpair");
+ return EXIT_FAILURE;
+ }
+
+ prog = &conf.progs[i];
+ snprintf(prog_env, envsize, "%s%u", ENV_PREFIX, i);
+ env = getenv(prog_env);
+
+ if (env != NULL)
+ prog->env = strdup(env);
+
+ prog->socket = sockets[PARENT];
+ ppid = getpid();
+ pid = fork();
+
+ if (pid == -1) {
+ perror("fork");
+ return EXIT_FAILURE;
+ }
+
+ if (pid == 0) {
+ close(sockets[PARENT]);
+
+ if (!setup_pkill(ppid)) {
+ log_fn(ODP_LOG_ERR, "Error setting up pdeath signal, exiting\n");
+ return EXIT_FAILURE;
+ }
+
+ if (!disable_stream(STDIN_FILENO, true) ||
+ !disable_stream(STDERR_FILENO, false) ||
+ !disable_stream(STDOUT_FILENO, false)) {
+ log_fn(ODP_LOG_ERR, "Error disabling streams, exiting\n");
+ return EXIT_FAILURE;
+ }
+
+ if (prog->env != NULL && !set_odp_env(prog->env)) {
+ log_fn(ODP_LOG_ERR, "Error setting up environment, exiting\n");
+ return EXIT_FAILURE;
+ }
+
+ run_odp(prog->cpumask, sockets[CHILD]);
+ goto exit;
+ } else {
+ close(sockets[CHILD]);
+ prog->pid = pid;
+
+ if (!wait_process_ready(prog->socket)) {
+ printf("Error launching process: %d, exiting\n", prog->pid);
+ return EXIT_FAILURE;
+ }
+
+ prog->state = UP;
+ printf("Created ODP process, pid: %d, CPU mask: %s, process index: %u\n",
+ prog->pid, prog->cpumask, i);
+ }
+ }
+
+ func_ret = run_global(&conf) ? EXIT_SUCCESS : EXIT_FAILURE;
+ teardown_global(&conf);
+
+exit:
+ return func_ret;
+}
diff --git a/test/miscellaneous/odp_dyn_workers_run.sh b/test/miscellaneous/odp_dyn_workers_run.sh
new file mode 100755
index 000000000..188713d77
--- /dev/null
+++ b/test/miscellaneous/odp_dyn_workers_run.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2024 Nokia
+#
+
+MAX_CPUS=$(nproc)
+# Frontend and control threads on one core and to-be-swapped worker thread on another core,
+# otherwise weird issues might occur
+REQ_CPUS=2
+TEST_DIR="${TEST_DIR:-$(dirname $0)}"
+BIN=odp_dyn_workers
+DEL=100000000
+
+export ODP0="ODP_PLATFORM_PARAMS=-m 256 --file-prefix odp0 --proc-type auto --no-pci"
+export ODP1="ODP_PLATFORM_PARAMS=-m 256 --file-prefix odp1 --proc-type auto --no-pci"
+
+if [ ${MAX_CPUS} -lt ${REQ_CPUS} ]; then
+ echo "Not enough CPUs (requested ${REQ_CPUS}, available ${MAX_CPUS}). Skipping test."
+ exit 77
+fi
+
+taskset -c 0 ${TEST_DIR}/${BIN}${EXEEXT} -c 0x2,0x2 -p a0:0,d${DEL},r0:0,d${DEL},a1:0,d${DEL},r1:0
diff --git a/test/performance/.gitignore b/test/performance/.gitignore
index 46d9e9c2c..d5ab7df24 100644
--- a/test/performance/.gitignore
+++ b/test/performance/.gitignore
@@ -27,7 +27,7 @@ odp_random
odp_sched_latency
odp_sched_perf
odp_sched_pktio
-odp_scheduling
odp_stash_perf
odp_stress
+odp_timer_accuracy
odp_timer_perf
diff --git a/test/performance/Makefile.am b/test/performance/Makefile.am
index 356e98a2d..8142d5db9 100644
--- a/test/performance/Makefile.am
+++ b/test/performance/Makefile.am
@@ -30,7 +30,7 @@ COMPILE_ONLY = odp_cpu_bench \
odp_sched_latency \
odp_sched_perf \
odp_sched_pktio \
- odp_scheduling \
+ odp_timer_accuracy \
odp_timer_perf
if LIBCONFIG
@@ -46,7 +46,7 @@ TESTSCRIPTS = odp_cpu_bench_run.sh \
odp_sched_latency_run.sh \
odp_sched_perf_run.sh \
odp_sched_pktio_run.sh \
- odp_scheduling_run.sh \
+ odp_timer_accuracy_run.sh \
odp_timer_perf_run.sh
if ODP_PKTIO_PCAP
@@ -80,7 +80,6 @@ odp_packet_gen_SOURCES = odp_packet_gen.c
odp_pktio_ordered_SOURCES = odp_pktio_ordered.c dummy_crc.h
odp_sched_latency_SOURCES = odp_sched_latency.c
odp_sched_pktio_SOURCES = odp_sched_pktio.c
-odp_scheduling_SOURCES = odp_scheduling.c
odp_pktio_perf_SOURCES = odp_pktio_perf.c
odp_pool_latency_SOURCES = odp_pool_latency.c
odp_pool_perf_SOURCES = odp_pool_perf.c
@@ -88,6 +87,7 @@ odp_queue_perf_SOURCES = odp_queue_perf.c
odp_random_SOURCES = odp_random.c
odp_sched_perf_SOURCES = odp_sched_perf.c
odp_stress_SOURCES = odp_stress.c
+odp_timer_accuracy_SOURCES = odp_timer_accuracy.c
odp_timer_perf_SOURCES = odp_timer_perf.c
if LIBCONFIG
@@ -95,11 +95,6 @@ odp_ipsecfwd_SOURCES = odp_ipsecfwd.c
AM_CFLAGS += $(LIBCONFIG_CFLAGS)
endif
-# l2fwd test depends on generator example
-EXTRA_odp_l2fwd_DEPENDENCIES = $(top_builddir)/example/generator/odp_generator$(EXEEXT)
-$(top_builddir)/example/generator/odp_generator$(EXEEXT):
- $(MAKE) -C $(top_builddir)/example/generator odp_generator$(EXEEXT)
-
dist_check_SCRIPTS = $(TESTSCRIPTS)
dist_check_DATA = udp64.pcap
diff --git a/test/performance/dummy_crc.h b/test/performance/dummy_crc.h
index 01e6c2433..8491b8fdc 100644
--- a/test/performance/dummy_crc.h
+++ b/test/performance/dummy_crc.h
@@ -1,40 +1,8 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright(c) 2010-2014 Intel Corporation
+ * - lib/hash/rte_crc_sw.h
*/
/** @cond _ODP_HIDE_FROM_DOXYGEN_ */
diff --git a/test/performance/odp_atomic_perf.c b/test/performance/odp_atomic_perf.c
index e665081a2..af0a37921 100644
--- a/test/performance/odp_atomic_perf.c
+++ b/test/performance/odp_atomic_perf.c
@@ -1,8 +1,5 @@
-/* Copyright (c) 2021, Nokia
- *
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
/**
diff --git a/test/performance/odp_bench_buffer.c b/test/performance/odp_bench_buffer.c
index ce14ec8b3..838617f78 100644
--- a/test/performance/odp_bench_buffer.c
+++ b/test/performance/odp_bench_buffer.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2022-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2022-2023 Nokia
*/
/**
diff --git a/test/performance/odp_bench_misc.c b/test/performance/odp_bench_misc.c
index 61afdc398..a0e9476e6 100644
--- a/test/performance/odp_bench_misc.c
+++ b/test/performance/odp_bench_misc.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022-2023 Nokia
*/
/**
diff --git a/test/performance/odp_bench_packet.c b/test/performance/odp_bench_packet.c
index cb9e3ca03..a8494bd28 100644
--- a/test/performance/odp_bench_packet.c
+++ b/test/performance/odp_bench_packet.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2022-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2022-2023 Nokia
*/
/**
diff --git a/test/performance/odp_bench_pktio_sp.c b/test/performance/odp_bench_pktio_sp.c
index 017e7565f..179db129d 100644
--- a/test/performance/odp_bench_pktio_sp.c
+++ b/test/performance/odp_bench_pktio_sp.c
@@ -824,7 +824,7 @@ static int parse_interface(appl_args_t *appl_args, const char *optarg)
ODPH_ERR("Unable to store interface name (MAX_NAME_LEN=%d)\n", MAX_NAME_LEN);
return -1;
}
- strncpy(appl_args->opt.name, optarg, MAX_NAME_LEN);
+ odph_strcpy(appl_args->opt.name, optarg, MAX_NAME_LEN);
return 0;
}
@@ -849,7 +849,7 @@ static int parse_args(int argc, char *argv[])
static const char *shortopts = "i:m:o:p:q:r:s:t:h";
- strncpy(gbl_args->opt.name, "loop", MAX_NAME_LEN);
+ odph_strcpy(gbl_args->opt.name, "loop", MAX_NAME_LEN);
gbl_args->opt.rounds = ROUNDS;
gbl_args->opt.in_mode = ODP_PKTIN_MODE_DIRECT;
gbl_args->opt.out_mode = ODP_PKTOUT_MODE_DIRECT;
diff --git a/test/performance/odp_bench_timer.c b/test/performance/odp_bench_timer.c
index 65c7a9168..ad80367d1 100644
--- a/test/performance/odp_bench_timer.c
+++ b/test/performance/odp_bench_timer.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
*/
/**
diff --git a/test/performance/odp_cpu_bench.c b/test/performance/odp_cpu_bench.c
index 39eff620d..674015d8a 100644
--- a/test/performance/odp_cpu_bench.c
+++ b/test/performance/odp_cpu_bench.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
/**
@@ -192,7 +190,7 @@ static void sig_handler(int signo ODP_UNUSED)
static inline void init_packet(odp_packet_t pkt, uint32_t seq, uint16_t group)
{
- uint32_t *payload;
+ odp_una_u32_t *payload;
test_hdr_t *hdr;
odp_packet_parse_param_t param;
@@ -224,7 +222,7 @@ static inline odp_queue_t work_on_event(odp_event_t event)
odph_udphdr_t *udp_hdr;
test_hdr_t *hdr;
lookup_entry_t *lookup_entry;
- uint32_t *payload;
+ odp_una_u32_t *payload;
uint32_t crc;
uint32_t pkt_len;
uint8_t *data;
diff --git a/test/performance/odp_cpu_bench_run.sh b/test/performance/odp_cpu_bench_run.sh
index c33e0b38e..15be2e729 100755
--- a/test/performance/odp_cpu_bench_run.sh
+++ b/test/performance/odp_cpu_bench_run.sh
@@ -1,9 +1,8 @@
#!/bin/sh
#
-# Copyright (c) 2022, Nokia
-# All rights reserved.
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2022 Nokia
#
-# SPDX-License-Identifier: BSD-3-Clause
TEST_DIR="${TEST_DIR:-$(dirname $0)}"
diff --git a/test/performance/odp_crc.c b/test/performance/odp_crc.c
index 89e2e971f..1b631c691 100644
--- a/test/performance/odp_crc.c
+++ b/test/performance/odp_crc.c
@@ -1,8 +1,5 @@
-/* Copyright (c) 2021, Nokia
- *
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
/**
diff --git a/test/performance/odp_crypto.c b/test/performance/odp_crypto.c
index a644da5e1..380e798c9 100644
--- a/test/performance/odp_crypto.c
+++ b/test/performance/odp_crypto.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2023 Nokia
*/
/**
diff --git a/test/performance/odp_crypto_run.sh b/test/performance/odp_crypto_run.sh
index f50311ae0..fcb7435fd 100755
--- a/test/performance/odp_crypto_run.sh
+++ b/test/performance/odp_crypto_run.sh
@@ -1,9 +1,8 @@
#!/bin/sh
#
-# Copyright (c) 2022, Nokia
-# All rights reserved.
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2022 Nokia
#
-# SPDX-License-Identifier: BSD-3-Clause
TEST_DIR="${TEST_DIR:-$(dirname $0)}"
diff --git a/test/performance/odp_dma_perf_run.sh b/test/performance/odp_dma_perf_run.sh
index 31948e40a..fb7b2bb34 100755
--- a/test/performance/odp_dma_perf_run.sh
+++ b/test/performance/odp_dma_perf_run.sh
@@ -1,9 +1,8 @@
#!/bin/sh
#
-# Copyright (c) 2022-2023, Nokia
-# All rights reserved.
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2022-2023 Nokia
#
-# SPDX-License-Identifier: BSD-3-Clause
TEST_DIR="${TEST_DIR:-$(dirname $0)}"
BIN_NAME=odp_dma_perf
diff --git a/test/performance/odp_dmafwd_run.sh b/test/performance/odp_dmafwd_run.sh
index ebb9b153a..38fcc8dc2 100755
--- a/test/performance/odp_dmafwd_run.sh
+++ b/test/performance/odp_dmafwd_run.sh
@@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Nokia
+#
TEST_DIR="${TEST_DIR:-$PWD}"
TEST_SRC_DIR=$(dirname $0)
diff --git a/test/performance/odp_ipsec.c b/test/performance/odp_ipsec.c
index 3ea93ec96..58be03dad 100644
--- a/test/performance/odp_ipsec.c
+++ b/test/performance/odp_ipsec.c
@@ -1,9 +1,7 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2022, Marvell
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2022 Marvell
+ * Copyright (c) 2022 Nokia
*/
/**
diff --git a/test/performance/odp_ipsec_run.sh b/test/performance/odp_ipsec_run.sh
index 2ddb48d07..f050cb8e0 100755
--- a/test/performance/odp_ipsec_run.sh
+++ b/test/performance/odp_ipsec_run.sh
@@ -1,9 +1,8 @@
#!/bin/sh
#
-# Copyright (c) 2022, Nokia
-# All rights reserved.
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2022 Nokia
#
-# SPDX-License-Identifier: BSD-3-Clause
TEST_DIR="${TEST_DIR:-$(dirname $0)}"
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index b993de4cb..5f3efd464 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -1,15 +1,19 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2019-2024, Nokia
- * Copyright (c) 2020-2021, Marvell
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2019-2024 Nokia
+ * Copyright (c) 2020-2021 Marvell
*/
/**
* @example odp_l2fwd.c
*
- * L2 forwarding example application
+ * This L2 forwarding application can be used as example as well as performance
+ * test for different ODP packet I/O modes (direct, queue or scheduled).
+ *
+ * Note that this example is tuned for performance. As a result, when using
+ * scheduled packet input mode with direct or queued output mode and multiple
+ * output queues, packet order is not guaranteed. To maintain packet order,
+ * use a single worker thread or output interfaces with one output queue.
*
* @cond _ODP_HIDE_FROM_DOXYGEN_
*/
@@ -91,6 +95,9 @@ typedef struct {
/* Some extra features (e.g. error checks) have been enabled */
uint8_t extra_feat;
+ /* Has some state that needs to be maintained across tx and/or rx */
+ uint8_t has_state;
+
/* Prefetch packet data */
uint8_t prefetch;
@@ -133,6 +140,9 @@ typedef struct {
int rx_queues; /* RX queues per interface */
int pool_per_if; /* Create pool per interface */
uint32_t num_pkt; /* Number of packets per pool */
+ int flow_control; /* Flow control mode */
+ bool pause_rx; /* Reception of pause frames enabled */
+ bool pause_tx; /* Transmission of pause frames enabled */
bool vector_mode; /* Vector mode enabled */
uint32_t num_vec; /* Number of vectors per pool */
uint64_t vec_tmo_ns; /* Vector formation timeout in ns */
@@ -144,7 +154,17 @@ typedef struct {
int flow_aware; /* Flow aware scheduling enabled */
uint8_t input_ts; /* Packet input timestamping enabled */
int mtu; /* Interface MTU */
+ int num_om;
int num_prio;
+
+ struct {
+ odp_packet_tx_compl_mode_t mode;
+ uint32_t nth;
+ uint32_t thr_compl_id;
+ uint32_t tot_compl_id;
+ } tx_compl;
+
+ char *output_map[MAX_PKTIOS]; /* Destination port mappings for interfaces */
odp_schedule_prio_t prio[MAX_PKTIOS]; /* Priority of input queues of an interface */
} appl_args_t;
@@ -158,6 +178,10 @@ typedef union ODP_ALIGNED_CACHE {
uint64_t rx_drops;
/* Packets dropped due to transmit error */
uint64_t tx_drops;
+ /* Number of transmit completion start misses (previous incomplete) */
+ uint64_t tx_c_misses;
+ /* Number of transmit completion start failures */
+ uint64_t tx_c_fails;
/* Number of failed packet copies */
uint64_t copy_fails;
/* Dummy sum of packet data */
@@ -167,9 +191,37 @@ typedef union ODP_ALIGNED_CACHE {
uint8_t padding[ODP_CACHE_LINE_SIZE];
} stats_t;
+/* Transmit completion specific state data */
+typedef struct {
+ /* Options that are passed to transmit completion requests */
+ odp_packet_tx_compl_opt_t opt;
+ /* Thread specific initial value for transmit completion IDs */
+ uint32_t init;
+ /* Thread specific maximum value for transmit completion IDs */
+ uint32_t max;
+ /* Next free completion ID to be used for a transmit completion request */
+ uint32_t free_head;
+ /* Next completion ID to be polled for transmit completion readiness */
+ uint32_t poll_head;
+ /* Number of active requests */
+ uint32_t num_act;
+ /* Maximum number of active requests */
+ uint32_t max_act;
+ /* Transmit completion request interval for packets */
+ int interval;
+ /* Next packet in a send burst for which to request transmit completion */
+ int next_req;
+} tx_compl_t;
+
+/* Thread specific state data */
+typedef struct {
+ tx_compl_t tx_compl;
+} state_t;
+
/* Thread specific data */
typedef struct thread_args_t {
stats_t stats;
+ state_t state;
struct {
odp_pktin_queue_t pktin;
@@ -217,6 +269,7 @@ typedef struct {
odp_pktout_queue_t pktout[MAX_QUEUES];
odp_queue_t rx_q[MAX_QUEUES];
odp_queue_t tx_q[MAX_QUEUES];
+ odp_queue_t compl_q;
int num_rx_thr;
int num_tx_thr;
int num_rx_queue;
@@ -251,6 +304,16 @@ static void sig_handler(int signo ODP_UNUSED)
odp_atomic_store_u32(&gbl_args->exit_threads, 1);
}
+static int setup_sig_handler(void)
+{
+ struct sigaction action = { .sa_handler = sig_handler };
+
+ if (sigemptyset(&action.sa_mask) || sigaction(SIGINT, &action, NULL))
+ return -1;
+
+ return 0;
+}
+
/*
* Drop packets which input parsing marked as containing errors.
*
@@ -471,16 +534,122 @@ static inline int process_extra_features(const appl_args_t *appl_args, odp_packe
return pkts;
}
+static inline void handle_tx_event_compl(tx_compl_t *tx_c, odp_packet_t pkts[], int num,
+ int tx_idx, stats_t *stats)
+{
+ odp_packet_t pkt;
+ int next_req = tx_c->next_req;
+ const int interval = tx_c->interval;
+
+ tx_c->opt.queue = gbl_args->pktios[tx_idx].compl_q;
+
+ while (next_req <= num) {
+ pkt = pkts[next_req - 1];
+
+ if (odp_packet_tx_compl_request(pkt, &tx_c->opt) < 0) {
+ stats->s.tx_c_fails++;
+ /* Missed one, try requesting for the first packet of next burst. */
+ next_req = num + 1;
+ break;
+ }
+
+ next_req += interval;
+ }
+
+ tx_c->next_req = next_req - num;
+}
+
+static inline void handle_tx_poll_compl(tx_compl_t *tx_c, odp_packet_t pkts[], int num, int tx_idx,
+ stats_t *stats)
+{
+ uint32_t num_act = tx_c->num_act, poll_head = tx_c->poll_head, free_head = tx_c->free_head;
+ const uint32_t max = tx_c->max, init = tx_c->init, max_act = tx_c->max_act;
+ odp_pktio_t pktio = gbl_args->pktios[tx_idx].pktio;
+ int next_req = tx_c->next_req;
+ odp_packet_t pkt;
+ const int interval = tx_c->interval;
+
+ while (num_act > 0) {
+ if (odp_packet_tx_compl_done(pktio, poll_head) < 1)
+ break;
+
+ --num_act;
+
+ if (++poll_head > max)
+ poll_head = init;
+ }
+
+ while (next_req <= num) {
+ pkt = pkts[next_req - 1];
+
+ if (num_act == max_act) {
+ stats->s.tx_c_misses++;
+ /* Missed one, try requesting for the first packet of next burst. */
+ next_req = num + 1;
+ break;
+ }
+
+ tx_c->opt.compl_id = free_head;
+
+ if (odp_packet_tx_compl_request(pkt, &tx_c->opt) < 0) {
+ stats->s.tx_c_fails++;
+ /* Missed one, try requesting for the first packet of next burst. */
+ next_req = num + 1;
+ break;
+ }
+
+ if (++free_head > max)
+ free_head = init;
+
+ ++num_act;
+ next_req += interval;
+ }
+
+ tx_c->free_head = free_head;
+ tx_c->poll_head = poll_head;
+ tx_c->num_act = num_act;
+ tx_c->next_req = next_req - num;
+}
+
+static inline void handle_tx_state(state_t *state, odp_packet_t pkts[], int num, int tx_idx,
+ stats_t *stats)
+{
+ tx_compl_t *tx_c = &state->tx_compl;
+
+ if (tx_c->opt.mode == ODP_PACKET_TX_COMPL_EVENT)
+ handle_tx_event_compl(tx_c, pkts, num, tx_idx, stats);
+ else if (tx_c->opt.mode == ODP_PACKET_TX_COMPL_POLL)
+ handle_tx_poll_compl(tx_c, pkts, num, tx_idx, stats);
+}
+
+static inline void handle_state_failure(state_t *state, odp_packet_t packet)
+{
+ if (odp_packet_has_tx_compl_request(packet) != 0) {
+ --state->tx_compl.num_act;
+ --state->tx_compl.free_head;
+
+ if (state->tx_compl.free_head == UINT32_MAX ||
+ state->tx_compl.free_head < state->tx_compl.init)
+ state->tx_compl.free_head = state->tx_compl.max;
+ }
+}
+
static inline void send_packets(odp_packet_t *pkt_tbl,
int pkts,
int use_event_queue,
+ int tx_idx,
odp_queue_t tx_queue,
odp_pktout_queue_t pktout_queue,
+ state_t *state,
stats_t *stats)
{
int sent;
unsigned int tx_drops;
int i;
+ odp_packet_t pkt;
+
+ if (odp_unlikely(state != NULL))
+ handle_tx_state(state, pkt_tbl, pkts, tx_idx, stats);
if (odp_unlikely(use_event_queue))
sent = event_queue_send(tx_queue, pkt_tbl, pkts);
@@ -494,13 +663,27 @@ static inline void send_packets(odp_packet_t *pkt_tbl,
stats->s.tx_drops += tx_drops;
/* Drop rejected packets */
- for (i = sent; i < pkts; i++)
- odp_packet_free(pkt_tbl[i]);
+ for (i = sent; i < pkts; i++) {
+ pkt = pkt_tbl[i];
+ handle_state_failure(state, pkt);
+ odp_packet_free(pkt);
+ }
}
stats->s.packets += pkts;
}
+static int handle_rx_state(state_t *state, odp_event_t evs[], int num)
+{
+ if (state->tx_compl.opt.mode != ODP_PACKET_TX_COMPL_EVENT ||
+ odp_event_type(evs[0]) != ODP_EVENT_PACKET_TX_COMPL)
+ return num;
+
+ odp_event_free_multi(evs, num);
+
+ return 0;
+}
+
/*
* Packet IO worker thread using scheduled queues and vector mode.
*
@@ -518,6 +701,7 @@ static int run_worker_sched_mode_vector(void *arg)
thread_args_t *thr_args = arg;
stats_t *stats = &thr_args->stats;
const appl_args_t *appl_args = &gbl_args->appl;
+ state_t *state = appl_args->has_state ? &thr_args->state : NULL;
int use_event_queue = gbl_args->appl.out_mode;
pktin_mode_t in_mode = gbl_args->appl.in_mode;
@@ -566,19 +750,23 @@ static int run_worker_sched_mode_vector(void *arg)
for (i = 0; i < events; i++) {
odp_packet_vector_t pkt_vec = ODP_PACKET_VECTOR_INVALID;
- odp_packet_t *pkt_tbl;
+ odp_packet_t *pkt_tbl = NULL;
odp_packet_t pkt;
int src_idx, dst_idx;
- int pkts;
+ int pkts = 0;
if (odp_event_type(ev_tbl[i]) == ODP_EVENT_PACKET) {
pkt = odp_packet_from_event(ev_tbl[i]);
pkt_tbl = &pkt;
pkts = 1;
- } else {
- ODPH_ASSERT(odp_event_type(ev_tbl[i]) == ODP_EVENT_PACKET_VECTOR);
+ } else if (odp_event_type(ev_tbl[i]) == ODP_EVENT_PACKET_VECTOR) {
pkt_vec = odp_packet_vector_from_event(ev_tbl[i]);
pkts = odp_packet_vector_tbl(pkt_vec, &pkt_tbl);
+ } else if (state != NULL) {
+ pkts = handle_rx_state(state, ev_tbl, events);
+
+ if (pkts <= 0)
+ continue;
}
prefetch_data(appl_args->prefetch, pkt_tbl, pkts);
@@ -597,11 +785,8 @@ static int run_worker_sched_mode_vector(void *arg)
dst_idx = gbl_args->dst_port_from_idx[src_idx];
fill_eth_addrs(pkt_tbl, pkts, dst_idx);
- send_packets(pkt_tbl, pkts,
- use_event_queue,
- tx_queue[dst_idx],
- pktout[dst_idx],
- stats);
+ send_packets(pkt_tbl, pkts, use_event_queue, dst_idx, tx_queue[dst_idx],
+ pktout[dst_idx], state, stats);
if (pkt_vec != ODP_PACKET_VECTOR_INVALID)
odp_packet_vector_free(pkt_vec);
@@ -668,6 +853,7 @@ static int run_worker_sched_mode(void *arg)
thread_args_t *thr_args = arg;
stats_t *stats = &thr_args->stats;
const appl_args_t *appl_args = &gbl_args->appl;
+ state_t *state = appl_args->has_state ? &thr_args->state : NULL;
int use_event_queue = gbl_args->appl.out_mode;
pktin_mode_t in_mode = gbl_args->appl.in_mode;
@@ -729,6 +915,13 @@ static int run_worker_sched_mode(void *arg)
if (pkts <= 0)
continue;
+ if (odp_unlikely(state != NULL)) {
+ pkts = handle_rx_state(state, ev_tbl, pkts);
+
+ if (pkts <= 0)
+ continue;
+ }
+
odp_packet_from_event_multi(pkt_tbl, ev_tbl, pkts);
prefetch_data(appl_args->prefetch, pkt_tbl, pkts);
@@ -744,11 +937,8 @@ static int run_worker_sched_mode(void *arg)
dst_idx = gbl_args->dst_port_from_idx[src_idx];
fill_eth_addrs(pkt_tbl, pkts, dst_idx);
- send_packets(pkt_tbl, pkts,
- use_event_queue,
- tx_queue[dst_idx],
- pktout[dst_idx],
- stats);
+ send_packets(pkt_tbl, pkts, use_event_queue, dst_idx, tx_queue[dst_idx],
+ pktout[dst_idx], state, stats);
}
/*
@@ -809,6 +999,7 @@ static int run_worker_plain_queue_mode(void *arg)
thread_args_t *thr_args = arg;
stats_t *stats = &thr_args->stats;
const appl_args_t *appl_args = &gbl_args->appl;
+ state_t *state = appl_args->has_state ? &thr_args->state : NULL;
int use_event_queue = gbl_args->appl.out_mode;
int i;
@@ -857,10 +1048,7 @@ static int run_worker_plain_queue_mode(void *arg)
fill_eth_addrs(pkt_tbl, pkts, dst_idx);
- send_packets(pkt_tbl, pkts,
- use_event_queue,
- tx_queue,
- pktout,
+ send_packets(pkt_tbl, pkts, use_event_queue, dst_idx, tx_queue, pktout, state,
stats);
}
@@ -910,6 +1098,7 @@ static int run_worker_direct_mode(void *arg)
thread_args_t *thr_args = arg;
stats_t *stats = &thr_args->stats;
const appl_args_t *appl_args = &gbl_args->appl;
+ state_t *state = appl_args->has_state ? &thr_args->state : NULL;
int use_event_queue = gbl_args->appl.out_mode;
thr = odp_thread_id();
@@ -953,10 +1142,7 @@ static int run_worker_direct_mode(void *arg)
fill_eth_addrs(pkt_tbl, pkts, dst_idx);
- send_packets(pkt_tbl, pkts,
- use_event_queue,
- tx_queue,
- pktout,
+ send_packets(pkt_tbl, pkts, use_event_queue, dst_idx, tx_queue, pktout, state,
stats);
}
@@ -1036,6 +1222,7 @@ static int create_pktio(const char *dev, int idx, int num_rx, int num_tx, odp_po
odp_pktio_config_t config;
odp_pktin_queue_param_t pktin_param;
odp_pktout_queue_param_t pktout_param;
+ odp_queue_param_t compl_queue;
odp_pktio_op_mode_t mode_rx;
odp_pktio_op_mode_t mode_tx;
pktin_mode_t in_mode = gbl_args->appl.in_mode;
@@ -1052,6 +1239,12 @@ static int create_pktio(const char *dev, int idx, int num_rx, int num_tx, odp_po
if (gbl_args->appl.out_mode != PKTOUT_DIRECT)
pktio_param.out_mode = ODP_PKTOUT_MODE_QUEUE;
+ if (num_rx == 0)
+ pktio_param.in_mode = ODP_PKTIN_MODE_DISABLED;
+
+ if (num_tx == 0)
+ pktio_param.out_mode = ODP_PKTOUT_MODE_DISABLED;
+
pktio = odp_pktio_open(dev, pool, &pktio_param);
if (pktio == ODP_PKTIO_INVALID) {
ODPH_ERR("Pktio open failed: %s\n", dev);
@@ -1063,9 +1256,6 @@ static int create_pktio(const char *dev, int idx, int num_rx, int num_tx, odp_po
return -1;
}
- if (gbl_args->appl.verbose)
- odp_pktio_print(pktio);
-
if (odp_pktio_capability(pktio, &pktio_capa)) {
ODPH_ERR("Pktio capability query failed: %s\n", dev);
return -1;
@@ -1091,9 +1281,48 @@ static int create_pktio(const char *dev, int idx, int num_rx, int num_tx, odp_po
config.pktout.bit.tcp_chksum_ena = 1;
}
+ if (gbl_args->appl.tx_compl.mode != ODP_PACKET_TX_COMPL_DISABLED) {
+ if (gbl_args->appl.tx_compl.mode == ODP_PACKET_TX_COMPL_EVENT &&
+ !(pktio_capa.tx_compl.mode_event && pktio_capa.tx_compl.queue_type_sched)) {
+ ODPH_ERR("Transmit event completion not supported: %s\n", dev);
+ return -1;
+ }
+
+ if (gbl_args->appl.tx_compl.mode == ODP_PACKET_TX_COMPL_POLL &&
+ !(pktio_capa.tx_compl.mode_poll &&
+ pktio_capa.tx_compl.max_compl_id >= gbl_args->appl.tx_compl.tot_compl_id)) {
+ ODPH_ERR("Transmit poll completion not supported: %s\n", dev);
+ return -1;
+ }
+
+ if (gbl_args->appl.tx_compl.mode == ODP_PACKET_TX_COMPL_EVENT)
+ config.tx_compl.mode_event = 1;
+
+ if (gbl_args->appl.tx_compl.mode == ODP_PACKET_TX_COMPL_POLL) {
+ config.tx_compl.mode_poll = 1;
+ config.tx_compl.max_compl_id = gbl_args->appl.tx_compl.tot_compl_id;
+ }
+ }
+
/* Provide hint to pktio that packet references are not used */
config.pktout.bit.no_packet_refs = 1;
+ if (gbl_args->appl.pause_rx) {
+ if (!pktio_capa.flow_control.pause_rx) {
+ ODPH_ERR("Reception of pause frames not supported: %s\n", dev);
+ return -1;
+ }
+ config.flow_control.pause_rx = ODP_PKTIO_LINK_PAUSE_ON;
+ }
+
+ if (gbl_args->appl.pause_tx) {
+ if (!pktio_capa.flow_control.pause_tx) {
+ ODPH_ERR("Transmission of pause frames not supported: %s\n", dev);
+ return -1;
+ }
+ config.flow_control.pause_tx = ODP_PKTIO_LINK_PAUSE_ON;
+ }
+
odp_pktio_config(pktio, &config);
if (gbl_args->appl.promisc_mode && odp_pktio_promisc_mode(pktio) != 1) {
@@ -1169,6 +1398,20 @@ static int create_pktio(const char *dev, int idx, int num_rx, int num_tx, odp_po
pktin_param.queue_param.sched.prio = prio;
pktin_param.queue_param.sched.sync = sync_mode;
pktin_param.queue_param.sched.group = group;
+
+ if (gbl_args->appl.tx_compl.mode == ODP_PACKET_TX_COMPL_EVENT) {
+ odp_queue_param_init(&compl_queue);
+ compl_queue.type = ODP_QUEUE_TYPE_SCHED;
+ compl_queue.sched.prio = prio;
+ compl_queue.sched.sync = ODP_SCHED_SYNC_PARALLEL;
+ compl_queue.sched.group = group;
+ gbl_args->pktios[idx].compl_q = odp_queue_create(NULL, &compl_queue);
+
+ if (gbl_args->pktios[idx].compl_q == ODP_QUEUE_INVALID) {
+ ODPH_ERR("Creating completion queue failed: %s\n", dev);
+ return -1;
+ }
+ }
}
if (num_rx > (int)pktio_capa.max_input_queues) {
@@ -1205,37 +1448,45 @@ static int create_pktio(const char *dev, int idx, int num_rx, int num_tx, odp_po
return -1;
}
- if (odp_pktin_queue_config(pktio, &pktin_param)) {
+ if (num_rx > 0 && odp_pktin_queue_config(pktio, &pktin_param)) {
ODPH_ERR("Input queue config failed: %s\n", dev);
return -1;
}
- if (odp_pktout_queue_config(pktio, &pktout_param)) {
+ if (num_tx > 0 && odp_pktout_queue_config(pktio, &pktout_param)) {
ODPH_ERR("Output queue config failed: %s\n", dev);
return -1;
}
- if (gbl_args->appl.in_mode == DIRECT_RECV) {
- if (odp_pktin_queue(pktio, gbl_args->pktios[idx].pktin, num_rx) != num_rx) {
- ODPH_ERR("Pktin queue query failed: %s\n", dev);
- return -1;
- }
- } else {
- if (odp_pktin_event_queue(pktio, gbl_args->pktios[idx].rx_q, num_rx) != num_rx) {
- ODPH_ERR("Pktin event queue query failed: %s\n", dev);
- return -1;
+ if (num_rx > 0) {
+ if (gbl_args->appl.in_mode == DIRECT_RECV) {
+ if (odp_pktin_queue(pktio, gbl_args->pktios[idx].pktin, num_rx)
+ != num_rx) {
+ ODPH_ERR("Pktin queue query failed: %s\n", dev);
+ return -1;
+ }
+ } else {
+ if (odp_pktin_event_queue(pktio, gbl_args->pktios[idx].rx_q, num_rx)
+ != num_rx) {
+ ODPH_ERR("Pktin event queue query failed: %s\n", dev);
+ return -1;
+ }
}
}
- if (gbl_args->appl.out_mode == PKTOUT_DIRECT) {
- if (odp_pktout_queue(pktio, gbl_args->pktios[idx].pktout, num_tx) != num_tx) {
- ODPH_ERR("Pktout queue query failed: %s\n", dev);
- return -1;
- }
- } else {
- if (odp_pktout_event_queue(pktio, gbl_args->pktios[idx].tx_q, num_tx) != num_tx) {
- ODPH_ERR("Event queue query failed: %s\n", dev);
- return -1;
+ if (num_tx > 0) {
+ if (gbl_args->appl.out_mode == PKTOUT_DIRECT) {
+ if (odp_pktout_queue(pktio, gbl_args->pktios[idx].pktout, num_tx)
+ != num_tx) {
+ ODPH_ERR("Pktout queue query failed: %s\n", dev);
+ return -1;
+ }
+ } else {
+ if (odp_pktout_event_queue(pktio, gbl_args->pktios[idx].tx_q, num_tx)
+ != num_tx) {
+ ODPH_ERR("Event queue query failed: %s\n", dev);
+ return -1;
+ }
}
}
@@ -1250,6 +1501,9 @@ static int create_pktio(const char *dev, int idx, int num_rx, int num_tx, odp_po
"%02x:%02x:%02x:%02x:%02x:%02x\n", dev, info.drv_name, num_rx, num_tx,
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
+ if (gbl_args->appl.verbose)
+ odp_pktio_print(pktio);
+
gbl_args->pktios[idx].num_rx_queue = num_rx;
gbl_args->pktios[idx].num_tx_queue = num_tx;
gbl_args->pktios[idx].pktio = pktio;
@@ -1271,7 +1525,7 @@ static int print_speed_stats(int num_workers, stats_t **thr_stats,
uint64_t pkts = 0;
uint64_t pkts_prev = 0;
uint64_t pps;
- uint64_t rx_drops, tx_drops, copy_fails;
+ uint64_t rx_drops, tx_drops, tx_c_misses, tx_c_fails, copy_fails;
uint64_t maximum_pps = 0;
int i;
int elapsed = 0;
@@ -1289,6 +1543,8 @@ static int print_speed_stats(int num_workers, stats_t **thr_stats,
pkts = 0;
rx_drops = 0;
tx_drops = 0;
+ tx_c_misses = 0;
+ tx_c_fails = 0;
copy_fails = 0;
sleep(timeout);
@@ -1297,6 +1553,8 @@ static int print_speed_stats(int num_workers, stats_t **thr_stats,
pkts += thr_stats[i]->s.packets;
rx_drops += thr_stats[i]->s.rx_drops;
tx_drops += thr_stats[i]->s.tx_drops;
+ tx_c_misses += thr_stats[i]->s.tx_c_misses;
+ tx_c_fails += thr_stats[i]->s.tx_c_fails;
copy_fails += thr_stats[i]->s.copy_fails;
}
if (stats_enabled) {
@@ -1309,6 +1567,10 @@ static int print_speed_stats(int num_workers, stats_t **thr_stats,
if (gbl_args->appl.packet_copy)
printf("%" PRIu64 " copy fails, ", copy_fails);
+ if (gbl_args->appl.tx_compl.mode != ODP_PACKET_TX_COMPL_DISABLED)
+ printf("%" PRIu64 " tx compl misses, %" PRIu64 " tx compl fails, ",
+ tx_c_misses, tx_c_fails);
+
printf("%" PRIu64 " rx drops, %" PRIu64 " tx drops\n",
rx_drops, tx_drops);
@@ -1358,6 +1620,14 @@ static void print_port_mapping(void)
*/
static int find_dest_port(int port)
{
+ const char *output = gbl_args->appl.output_map[port];
+
+ /* Check output mappings first */
+ if (output != NULL)
+ for (int i = 0; i < gbl_args->appl.if_count; i++)
+ if (strcmp(output, gbl_args->appl.if_names[i]) == 0)
+ return i;
+
/* Even number of ports */
if (gbl_args->appl.if_count % 2 == 0)
return (port % 2 == 0) ? port + 1 : port - 1;
@@ -1522,6 +1792,21 @@ static void bind_queues(void)
printf("\n");
}
+static void init_state(const appl_args_t *args, state_t *state, int thr_idx)
+{
+ const uint32_t cnt = args->tx_compl.thr_compl_id + 1;
+
+ state->tx_compl.opt.mode = args->tx_compl.mode;
+ state->tx_compl.init = thr_idx * cnt;
+ state->tx_compl.max = state->tx_compl.init + cnt - 1;
+ state->tx_compl.free_head = state->tx_compl.init;
+ state->tx_compl.poll_head = state->tx_compl.init;
+ state->tx_compl.num_act = 0;
+ state->tx_compl.max_act = state->tx_compl.max - state->tx_compl.init + 1;
+ state->tx_compl.interval = args->tx_compl.nth;
+ state->tx_compl.next_req = state->tx_compl.interval;
+}
+
static void init_port_lookup_tbl(void)
{
int rx_idx, if_count;
@@ -1560,88 +1845,119 @@ static void usage(char *progname)
" eth2 will send pkts to eth3 and vice versa\n"
"\n"
"Mandatory OPTIONS:\n"
- " -i, --interface <name> Eth interfaces (comma-separated, no spaces)\n"
- " Interface count min 1, max %i\n"
+ " -i, --interface <name> Eth interfaces (comma-separated, no spaces)\n"
+ " Interface count min 1, max %i\n"
"\n"
"Optional OPTIONS:\n"
- " -m, --mode <arg> Packet input mode\n"
- " 0: Direct mode: PKTIN_MODE_DIRECT (default)\n"
- " 1: Scheduler mode with parallel queues:\n"
- " PKTIN_MODE_SCHED + SCHED_SYNC_PARALLEL\n"
- " 2: Scheduler mode with atomic queues:\n"
- " PKTIN_MODE_SCHED + SCHED_SYNC_ATOMIC\n"
- " 3: Scheduler mode with ordered queues:\n"
- " PKTIN_MODE_SCHED + SCHED_SYNC_ORDERED\n"
- " 4: Plain queue mode: PKTIN_MODE_QUEUE\n"
- " -o, --out_mode <arg> Packet output mode\n"
- " 0: Direct mode: PKTOUT_MODE_DIRECT (default)\n"
- " 1: Queue mode: PKTOUT_MODE_QUEUE\n"
- " -c, --count <num> CPU count, 0=all available, default=1\n"
- " -t, --time <sec> Time in seconds to run.\n"
- " -a, --accuracy <sec> Time in seconds get print statistics\n"
- " (default is 1 second).\n"
- " -d, --dst_change <arg> 0: Don't change packets' dst eth addresses\n"
- " 1: Change packets' dst eth addresses (default)\n"
- " -s, --src_change <arg> 0: Don't change packets' src eth addresses\n"
- " 1: Change packets' src eth addresses (default)\n"
- " -r, --dst_addr <addr> Destination addresses (comma-separated, no spaces)\n"
- " Requires also the -d flag to be set\n"
- " -e, --error_check <arg> 0: Don't check packet errors (default)\n"
- " 1: Check packet errors\n"
- " -k, --chksum <arg> 0: Don't use checksum offload (default)\n"
- " 1: Use checksum offload\n",
+ " -m, --mode <arg> Packet input mode\n"
+ " 0: Direct mode: PKTIN_MODE_DIRECT (default)\n"
+ " 1: Scheduler mode with parallel queues:\n"
+ " PKTIN_MODE_SCHED + SCHED_SYNC_PARALLEL\n"
+ " 2: Scheduler mode with atomic queues:\n"
+ " PKTIN_MODE_SCHED + SCHED_SYNC_ATOMIC\n"
+ " 3: Scheduler mode with ordered queues:\n"
+ " PKTIN_MODE_SCHED + SCHED_SYNC_ORDERED\n"
+ " 4: Plain queue mode: PKTIN_MODE_QUEUE\n"
+ " -o, --out_mode <arg> Packet output mode\n"
+ " 0: Direct mode: PKTOUT_MODE_DIRECT (default)\n"
+ " 1: Queue mode: PKTOUT_MODE_QUEUE\n"
+ " -O, --output_map <list> List of destination ports for passed interfaces\n"
+ " (comma-separated, no spaces). Ordering follows\n"
+ " the '--interface' option, e.g. passing\n"
+ " '-i eth0,eth1' and '-O eth0,eth1' would result\n"
+ " in eth0 and eth1 looping packets back.\n"
+ " -c, --count <num> CPU count, 0=all available, default=1\n"
+ " -t, --time <sec> Time in seconds to run.\n"
+ " -a, --accuracy <sec> Time in seconds get print statistics\n"
+ " (default is 1 second).\n"
+ " -d, --dst_change <arg> 0: Don't change packets' dst eth addresses\n"
+ " 1: Change packets' dst eth addresses (default)\n"
+ " -s, --src_change <arg> 0: Don't change packets' src eth addresses\n"
+ " 1: Change packets' src eth addresses (default)\n"
+ " -r, --dst_addr <addr> Destination addresses (comma-separated, no\n"
+ " spaces) Requires also the -d flag to be set\n"
+ " -e, --error_check <arg> 0: Don't check packet errors (default)\n"
+ " 1: Check packet errors\n"
+ " -k, --chksum <arg> 0: Don't use checksum offload (default)\n"
+ " 1: Use checksum offload\n",
NO_PATH(progname), NO_PATH(progname), MAX_PKTIOS);
- printf(" -g, --groups <num> Number of new groups to create (1 ... num). Interfaces\n"
- " are placed into the groups in round robin.\n"
- " 0: Use SCHED_GROUP_ALL (default)\n"
- " -1: Use SCHED_GROUP_WORKER\n"
- " -G, --group_mode <arg> Select how threads join new groups (when -g > 0)\n"
- " 0: All threads join all created groups (default)\n"
- " 1: All threads join first N created groups.\n"
- " N is number of interfaces (== active groups).\n"
- " 2: Each thread joins a part of the first N groups\n"
- " (in round robin).\n"
- " -I, --prio <prio list> Schedule priority of packet input queues.\n"
- " Comma separated list of priorities (no spaces). A value\n"
- " per interface. All queues of an interface have the same\n"
- " priority. Values must be between odp_schedule_min_prio\n"
- " and odp_schedule_max_prio. odp_schedule_default_prio is\n"
- " used by default.\n"
- " -b, --burst_rx <num> 0: Use max burst size (default)\n"
- " num: Max number of packets per receive call\n"
- " -q, --rx_queues <num> Number of RX queues per interface in scheduler mode\n"
- " 0: RX queue per worker CPU (default)\n"
- " -p, --packet_copy 0: Don't copy packet (default)\n"
- " 1: Create and send copy of the received packet.\n"
- " Free the original packet.\n"
- " -R, --data_rd <num> Number of packet data words (uint64_t) to read from\n"
- " every received packet. Number of words is rounded down\n"
- " to fit into the first segment of a packet. Default\n"
- " is 0.\n"
- " -y, --pool_per_if Create a packet (and packet vector) pool per interface.\n"
- " 0: Share a single pool between all interfaces (default)\n"
- " 1: Create a pool per interface\n"
- " -n, --num_pkt <num> Number of packets per pool. Default is 16k or\n"
- " the maximum capability. Use 0 for the default.\n"
- " -u, --vector_mode Enable vector mode.\n"
- " Supported only with scheduler packet input modes (1-3).\n"
- " -w, --num_vec <num> Number of vectors per pool.\n"
- " Default is num_pkts divided by vec_size.\n"
- " -x, --vec_size <num> Vector size (default %i).\n"
- " -z, --vec_tmo_ns <ns> Vector timeout in ns (default %llu ns).\n"
- " -M, --mtu <len> Interface MTU in bytes.\n"
- " -P, --promisc_mode Enable promiscuous mode.\n"
- " -l, --packet_len <len> Maximum length of packets supported (default %d).\n"
- " -L, --seg_len <len> Packet pool segment length\n"
- " (default equal to packet length).\n"
- " -F, --prefetch <num> Prefetch packet data in 64 byte multiples (default 1).\n"
- " -f, --flow_aware Enable flow aware scheduling.\n"
- " -T, --input_ts Enable packet input timestamping.\n"
- " -v, --verbose Verbose output.\n"
- " -V, --verbose_pkt Print debug information on every received packet.\n"
- " -h, --help Display help and exit.\n\n"
- "\n", DEFAULT_VEC_SIZE, DEFAULT_VEC_TMO, POOL_PKT_LEN);
+ printf(" -g, --groups <num> Number of new groups to create (1 ... num).\n"
+ " Interfaces are placed into the groups in round\n"
+ " robin.\n"
+ " 0: Use SCHED_GROUP_ALL (default)\n"
+ " -1: Use SCHED_GROUP_WORKER\n"
+ " -G, --group_mode <arg> Select how threads join new groups\n"
+ " (when -g > 0)\n"
+ " 0: All threads join all created groups\n"
+ " (default)\n"
+ " 1: All threads join first N created groups.\n"
+ " N is number of interfaces (== active\n"
+ " groups).\n"
+ " 2: Each thread joins a part of the first N\n"
+ " groups (in round robin).\n"
+ " -I, --prio <prio list> Schedule priority of packet input queues.\n"
+ " Comma separated list of priorities (no spaces).\n"
+ " A value per interface. All queues of an\n"
+ " interface have the same priority. Values must\n"
+ " be between odp_schedule_min_prio and\n"
+ " odp_schedule_max_prio.\n"
+ " odp_schedule_default_prio is used by default.\n"
+ " -b, --burst_rx <num> 0: Use max burst size (default)\n"
+ " num: Max number of packets per receive call\n"
+ " -q, --rx_queues <num> Number of RX queues per interface in scheduler\n"
+ " mode\n"
+ " 0: RX queue per worker CPU (default)\n"
+ " -p, --packet_copy 0: Don't copy packet (default)\n"
+ " 1: Create and send copy of the received packet.\n"
+ " Free the original packet.\n"
+ " -R, --data_rd <num> Number of packet data words (uint64_t) to read\n"
+ " from every received packet. Number of words is\n"
+ " rounded down to fit into the first segment of a\n"
+ " packet. Default is 0.\n"
+ " -y, --pool_per_if Create a packet (and packet vector) pool per\n"
+ " interface.\n"
+ " 0: Share a single pool between all interfaces\n"
+ " (default)\n"
+ " 1: Create a pool per interface\n"
+ " -n, --num_pkt <num> Number of packets per pool. Default is 16k or\n"
+ " the maximum capability. Use 0 for the default.\n"
+ " -u, --vector_mode Enable vector mode.\n"
+ " Supported only with scheduler packet input\n"
+ " modes (1-3).\n"
+ " -w, --num_vec <num> Number of vectors per pool.\n"
+ " Default is num_pkts divided by vec_size.\n"
+ " -x, --vec_size <num> Vector size (default %i).\n"
+ " -z, --vec_tmo_ns <ns> Vector timeout in ns (default %llu ns).\n"
+ " -M, --mtu <len> Interface MTU in bytes.\n"
+ " -P, --promisc_mode Enable promiscuous mode.\n"
+ " -l, --packet_len <len> Maximum length of packets supported\n"
+ " (default %d).\n"
+ " -L, --seg_len <len> Packet pool segment length\n"
+ " (default equal to packet length).\n"
+ " -F, --prefetch <num> Prefetch packet data in 64 byte multiples\n"
+ " (default 1).\n"
+ " -f, --flow_aware Enable flow aware scheduling.\n"
+ " -T, --input_ts Enable packet input timestamping.\n",
+ DEFAULT_VEC_SIZE, DEFAULT_VEC_TMO, POOL_PKT_LEN);
+
+ printf(" -C, --tx_compl <mode,n,max_id> Enable transmit completion with a specified\n"
+ " completion mode for nth packet, with maximum\n"
+ " completion ID per worker thread in case of poll\n"
+ " completion (comma-separated, no spaces).\n"
+ " 0: Event completion mode\n"
+ " 1: Poll completion mode\n"
+ " -X, --flow_control <mode> Ethernet flow control mode.\n"
+ " 0: Flow control disabled (default)\n"
+ " 1: Enable reception of pause frames\n"
+ " 2: Enable transmission of pause frames\n"
+ " 3: Enable reception and transmission of pause\n"
+ " frames\n"
+ " -v, --verbose Verbose output.\n"
+ " -V, --verbose_pkt Print debug information on every received\n"
+ " packet.\n"
+ " -h, --help Display help and exit.\n\n"
+ "\n");
}
/*
@@ -1656,7 +1972,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
int opt;
int long_index;
char *token;
- char *tmp_str;
+ char *tmp_str, *tmp;
size_t str_len, len;
int i;
static const struct option longopts[] = {
@@ -1666,6 +1982,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
{"interface", required_argument, NULL, 'i'},
{"mode", required_argument, NULL, 'm'},
{"out_mode", required_argument, NULL, 'o'},
+ {"output_map", required_argument, NULL, 'O'},
{"dst_addr", required_argument, NULL, 'r'},
{"dst_change", required_argument, NULL, 'd'},
{"src_change", required_argument, NULL, 's'},
@@ -1691,14 +2008,16 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
{"prefetch", required_argument, NULL, 'F'},
{"flow_aware", no_argument, NULL, 'f'},
{"input_ts", no_argument, NULL, 'T'},
+ {"tx_compl", required_argument, NULL, 'C'},
+ {"flow_control", required_argument, NULL, 'X'},
{"verbose", no_argument, NULL, 'v'},
{"verbose_pkt", no_argument, NULL, 'V'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};
- static const char *shortopts = "+c:t:a:i:m:o:r:d:s:e:k:g:G:I:"
- "b:q:p:R:y:n:l:L:w:x:z:M:F:uPfTvVh";
+ static const char *shortopts = "+c:t:a:i:m:o:O:r:d:s:e:k:g:G:I:"
+ "b:q:p:R:y:n:l:L:w:x:X:z:M:F:uPfTC:vVh";
appl_args->time = 0; /* loop forever if time to run is 0 */
appl_args->accuracy = 1; /* get and print pps stats second */
@@ -1729,6 +2048,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
appl_args->num_prio = 0;
appl_args->prefetch = 1;
appl_args->data_rd = 0;
+ appl_args->flow_control = 0;
while (1) {
opt = getopt_long(argc, argv, shortopts, longopts, &long_index);
@@ -1838,6 +2158,40 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
if (i != 0)
appl_args->out_mode = PKTOUT_QUEUE;
break;
+ case 'O':
+ if (strlen(optarg) == 0) {
+ ODPH_ERR("Bad output map string\n");
+ exit(EXIT_FAILURE);
+ }
+
+ tmp_str = strdup(optarg);
+
+ if (tmp_str == NULL) {
+ ODPH_ERR("Output map string duplication failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ token = strtok(tmp_str, ",");
+
+ while (token) {
+ if (appl_args->num_om >= MAX_PKTIOS) {
+ ODPH_ERR("Bad output map element count\n");
+ exit(EXIT_FAILURE);
+ }
+
+ appl_args->output_map[appl_args->num_om] = strdup(token);
+
+ if (appl_args->output_map[appl_args->num_om] == NULL) {
+ ODPH_ERR("Output map element duplication failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ appl_args->num_om++;
+ token = strtok(NULL, ",");
+ }
+
+ free(tmp_str);
+ break;
case 'd':
appl_args->dst_change = atoi(optarg);
break;
@@ -1930,6 +2284,13 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
case 'x':
appl_args->vec_size = atoi(optarg);
break;
+ case 'X':
+ appl_args->flow_control = atoi(optarg);
+ if (appl_args->flow_control == 1 || appl_args->flow_control == 3)
+ appl_args->pause_rx = true;
+ if (appl_args->flow_control == 2 || appl_args->flow_control == 3)
+ appl_args->pause_tx = true;
+ break;
case 'z':
appl_args->vec_tmo_ns = atoi(optarg);
break;
@@ -1942,6 +2303,56 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
case 'T':
appl_args->input_ts = 1;
break;
+ case 'C':
+ if (strlen(optarg) == 0) {
+ ODPH_ERR("Bad transmit completion parameter string\n");
+ exit(EXIT_FAILURE);
+ }
+
+ tmp_str = strdup(optarg);
+
+ if (tmp_str == NULL) {
+ ODPH_ERR("Transmit completion parameter string duplication"
+ " failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ tmp = strtok(tmp_str, ",");
+
+ if (tmp == NULL) {
+ ODPH_ERR("Invalid transmit completion parameter format\n");
+ exit(EXIT_FAILURE);
+ }
+
+ i = atoi(tmp);
+
+ if (i == 0)
+ appl_args->tx_compl.mode = ODP_PACKET_TX_COMPL_EVENT;
+ else if (i == 1)
+ appl_args->tx_compl.mode = ODP_PACKET_TX_COMPL_POLL;
+
+ tmp = strtok(NULL, ",");
+
+ if (tmp == NULL) {
+ ODPH_ERR("Invalid transmit completion parameter format\n");
+ exit(EXIT_FAILURE);
+ }
+
+ appl_args->tx_compl.nth = atoi(tmp);
+
+ if (appl_args->tx_compl.mode == ODP_PACKET_TX_COMPL_POLL) {
+ tmp = strtok(NULL, ",");
+
+ if (tmp == NULL) {
+ ODPH_ERR("Invalid transmit completion parameter format\n");
+ exit(EXIT_FAILURE);
+ }
+
+ appl_args->tx_compl.thr_compl_id = atoi(tmp);
+ }
+
+ free(tmp_str);
+ break;
case 'v':
appl_args->verbose = 1;
break;
@@ -1962,6 +2373,11 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
exit(EXIT_FAILURE);
}
+ if (appl_args->num_om && appl_args->num_om != appl_args->if_count) {
+ ODPH_ERR("Different number of output mappings and pktio interfaces\n");
+ exit(EXIT_FAILURE);
+ }
+
if (appl_args->num_prio && appl_args->num_prio != appl_args->if_count) {
ODPH_ERR("Different number of priorities and pktio interfaces\n");
exit(EXIT_FAILURE);
@@ -1978,6 +2394,23 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
exit(EXIT_FAILURE);
}
+ if (appl_args->tx_compl.mode != ODP_PACKET_TX_COMPL_DISABLED &&
+ appl_args->tx_compl.nth == 0) {
+ ODPH_ERR("Invalid packet interval for transmit completion: %u\n",
+ appl_args->tx_compl.nth);
+ exit(EXIT_FAILURE);
+ }
+
+ if (appl_args->tx_compl.mode == ODP_PACKET_TX_COMPL_EVENT &&
+ (appl_args->in_mode == PLAIN_QUEUE || appl_args->in_mode == DIRECT_RECV)) {
+ ODPH_ERR("Transmit event completion mode not supported with plain queue or direct "
+ "input modes\n");
+ exit(EXIT_FAILURE);
+ }
+
+ appl_args->tx_compl.tot_compl_id = (appl_args->tx_compl.thr_compl_id + 1) *
+ appl_args->cpu_count - 1;
+
if (appl_args->burst_rx == 0)
appl_args->burst_rx = MAX_PKT_BURST;
@@ -1986,6 +2419,10 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
appl_args->packet_copy || appl_args->data_rd || appl_args->verbose_pkt)
appl_args->extra_feat = 1;
+ appl_args->has_state = 0;
+ if (appl_args->tx_compl.mode != ODP_PACKET_TX_COMPL_DISABLED)
+ appl_args->has_state = 1;
+
optind = 1; /* reset 'extern optind' from the getopt lib */
}
@@ -2020,6 +2457,15 @@ static void print_options(void)
else
printf("PKTOUT_DIRECT\n");
+ if (appl_args->num_om > 0) {
+ printf("Output mappings: ");
+
+ for (i = 0; i < appl_args->num_om; ++i)
+ printf(" %s", appl_args->output_map[i]);
+
+ printf("\n");
+ }
+
printf("MTU: ");
if (appl_args->mtu)
printf("%i bytes\n", appl_args->mtu);
@@ -2027,6 +2473,10 @@ static void print_options(void)
printf("interface default\n");
printf("Promisc mode: %s\n", appl_args->promisc_mode ?
"enabled" : "disabled");
+ if (appl_args->flow_control)
+ printf("Flow control: %s%s\n",
+ appl_args->pause_rx ? "rx " : "",
+ appl_args->pause_tx ? "tx" : "");
printf("Flow aware: %s\n", appl_args->flow_aware ?
"yes" : "no");
printf("Input TS: %s\n", appl_args->input_ts ? "yes" : "no");
@@ -2035,12 +2485,13 @@ static void print_options(void)
printf("Number of pools: %i\n", appl_args->pool_per_if ?
appl_args->if_count : 1);
- if (appl_args->extra_feat) {
- printf("Extra features: %s%s%s%s%s\n",
+ if (appl_args->extra_feat || appl_args->has_state) {
+ printf("Extra features: %s%s%s%s%s%s\n",
appl_args->error_check ? "error_check " : "",
appl_args->chksum ? "chksum " : "",
appl_args->packet_copy ? "packet_copy " : "",
appl_args->data_rd ? "data_rd" : "",
+ appl_args->tx_compl.mode != ODP_PACKET_TX_COMPL_DISABLED ? "tx_compl" : "",
appl_args->verbose_pkt ? "verbose_pkt" : "");
}
@@ -2082,7 +2533,11 @@ static void gbl_args_init(args_t *args)
for (queue = 0; queue < MAX_QUEUES; queue++)
args->pktios[pktio].rx_q[queue] = ODP_QUEUE_INVALID;
+
+ args->pktios[pktio].compl_q = ODP_QUEUE_INVALID;
}
+
+ args->appl.tx_compl.mode = ODP_PACKET_TX_COMPL_DISABLED;
}
static void create_groups(int num, odp_schedule_group_t *group)
@@ -2199,9 +2654,10 @@ int main(int argc, char *argv[])
init.mem_model = helper_options.mem_model;
- /* Signal handler has to be registered before global init in case ODP
- * implementation creates internal threads/processes. */
- signal(SIGINT, sig_handler);
+ if (setup_sig_handler()) {
+ ODPH_ERR("Signal handler setup failed\n");
+ exit(EXIT_FAILURE);
+ }
/* Init ODP before calling anything else */
if (odp_init_global(&instance, &init, NULL)) {
@@ -2518,6 +2974,7 @@ int main(int argc, char *argv[])
int num_join;
int mode = gbl_args->appl.group_mode;
+ init_state(&gbl_args->appl, &gbl_args->thread_args[i].state, i);
odph_thread_param_init(&thr_param[i]);
thr_param[i].start = thr_run_func;
thr_param[i].arg = &gbl_args->thread_args[i];
@@ -2584,11 +3041,20 @@ int main(int argc, char *argv[])
if (gbl_args->appl.in_mode != DIRECT_RECV)
odp_barrier_wait(&gbl_args->term_barrier);
+ odph_thread_join_result_t res[num_workers];
+
/* Master thread waits for other threads to exit */
- num_thr = odph_thread_join(gbl_args->thread_tbl, num_workers);
- if (num_thr != num_workers) {
- ODPH_ERR("Worker join failed: %i\n", num_thr);
- exit(EXIT_FAILURE);
+ if (odph_thread_join_result(gbl_args->thread_tbl, res, num_workers) != num_workers) {
+ ODPH_ERR("Worker join failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ for (i = 0; i < num_workers; i++) {
+ if (res[i].is_sig || res[i].ret != 0) {
+ ODPH_ERR("Worker thread failure%s: %d\n", res[i].is_sig ?
+ " (signaled)" : "", res[i].ret);
+ exit(EXIT_FAILURE);
+ }
}
for (i = 0; i < if_count; ++i) {
@@ -2599,6 +3065,9 @@ int main(int argc, char *argv[])
odp_pktio_extra_stats_print(pktio);
}
+ if (gbl_args->pktios[i].compl_q != ODP_QUEUE_INVALID)
+ (void)odp_queue_destroy(gbl_args->pktios[i].compl_q);
+
if (odp_pktio_close(pktio)) {
ODPH_ERR("Pktio close failed: %s\n", gbl_args->appl.if_names[i]);
exit(EXIT_FAILURE);
@@ -2607,6 +3076,10 @@ int main(int argc, char *argv[])
free(gbl_args->appl.if_names);
free(gbl_args->appl.if_str);
+
+ for (i = 0; i < gbl_args->appl.num_om; i++)
+ free(gbl_args->appl.output_map[i]);
+
gbl_args = NULL;
odp_mb_full();
diff --git a/test/performance/odp_l2fwd_run.sh b/test/performance/odp_l2fwd_run.sh
index cd750ca35..626b6da72 100755
--- a/test/performance/odp_l2fwd_run.sh
+++ b/test/performance/odp_l2fwd_run.sh
@@ -1,9 +1,7 @@
#!/bin/bash
#
-# Copyright (c) 2015-2018, Linaro Limited
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2015-2018 Linaro Limited
#
# TEST_DIR is set by Makefile, when we add a rule to Makefile for odp_l2fwd_run
@@ -25,7 +23,7 @@ TEST_DIR="${TEST_DIR:-$PWD}"
# directory where test sources are, including scripts
TEST_SRC_DIR=$(dirname $0)
-PATH=$TEST_DIR:$TEST_DIR/../../example/generator:$PATH
+PATH=$TEST_DIR:$PATH
# exit codes expected by automake for skipped tests
TEST_SKIPPED=77
@@ -33,8 +31,6 @@ TEST_SKIPPED=77
VALIDATION_TESTDIR=platform/$ODP_PLATFORM/test/validation
PLATFORM_VALIDATION=${TEST_SRC_DIR}/../../$VALIDATION_TESTDIR
-FLOOD_MODE=0
-
# Use installed pktio env or for make check take it from platform directory
if [ -f "./pktio_env" ]; then
. ./pktio_env
@@ -60,40 +56,33 @@ run_l2fwd()
exit $TEST_SKIPPED
fi
- type odp_generator > /dev/null
+ type odp_packet_gen > /dev/null
if [ $? -ne 0 ]; then
- echo "odp_generator not installed. Aborting."
+ echo "odp_packet_gen not installed. Aborting."
cleanup_pktio_env
exit 1
fi
- export ODP_PLATFORM_PARAMS="-m 256 --file-prefix="gen" \
+ export ODP_PLATFORM_PARAMS="-m 512 --file-prefix="gen" \
--proc-type auto --no-pci \
--vdev net_pcap0,iface=$IF0"
- # Run generator with one worker
- (odp_generator${EXEEXT} --interval $FLOOD_MODE -I 0 \
- --srcip 192.168.0.1 --dstip 192.168.0.2 \
- -m u -w 1 2>&1 > /dev/null) \
+ # Run odp_packet_gen with one tx thread
+ (odp_packet_gen${EXEEXT} --gap 0 -i 0 \
+ --ipv4_src 192.168.0.1 --ipv4_dst 192.168.0.2 \
+ -r 0 -t 1 2>&1 > /dev/null) \
2>&1 > /dev/null &
GEN_PID=$!
- # this just turns off output buffering so that you still get periodic
- # output while piping to tee, as long as stdbuf is available.
- if [ "$(which stdbuf)" != "" ]; then
- STDBUF="stdbuf -o 0"
- else
- STDBUF=
- fi
LOG=odp_l2fwd_tmp.log
- export ODP_PLATFORM_PARAMS="-m 256 --file-prefix="l2fwd" \
+ export ODP_PLATFORM_PARAMS="-m 512 --file-prefix="l2fwd" \
--proc-type auto --no-pci --vdev net_pcap1,iface=$IF1 \
--vdev net_pcap2,iface=$IF2"
# Max 2 workers
- $STDBUF odp_l2fwd${EXEEXT} -i 0,1 -m 0 -t 5 -c 2 | tee $LOG
+ odp_l2fwd${EXEEXT} -i 0,1 -m 0 -t 5 -c 2 | tee $LOG
ret=${PIPESTATUS[0]}
kill -2 ${GEN_PID}
diff --git a/test/performance/odp_lock_perf.c b/test/performance/odp_lock_perf.c
index 0f78db3b8..43dea0728 100644
--- a/test/performance/odp_lock_perf.c
+++ b/test/performance/odp_lock_perf.c
@@ -1,8 +1,5 @@
-/* Copyright (c) 2021, Nokia
- *
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
/**
diff --git a/test/performance/odp_mem_perf.c b/test/performance/odp_mem_perf.c
index 241128b1f..5a7642a10 100644
--- a/test/performance/odp_mem_perf.c
+++ b/test/performance/odp_mem_perf.c
@@ -1,8 +1,5 @@
-/* Copyright (c) 2021, Nokia
- *
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Nokia
*/
/**
diff --git a/test/performance/odp_packet_gen.c b/test/performance/odp_packet_gen.c
index c88535791..7954a08bb 100644
--- a/test/performance/odp_packet_gen.c
+++ b/test/performance/odp_packet_gen.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020-2024 Nokia
*/
/**
@@ -38,8 +36,8 @@
#define MAX_WORKERS (MAX_THREADS - 1)
-/* At least one control and two worker threads */
-ODP_STATIC_ASSERT(MAX_WORKERS >= 2, "Too few threads");
+/* At least one control and one worker thread */
+ODP_STATIC_ASSERT(MAX_WORKERS >= 1, "Too few threads");
/* Maximum number of packet IO interfaces */
#define MAX_PKTIOS 16
@@ -57,10 +55,12 @@ ODP_STATIC_ASSERT(MAX_WORKERS >= 2, "Too few threads");
/* Max retries to generate random data */
#define MAX_RAND_RETRIES 1000
-/* Used don't free */
+/* Use don't free */
#define TX_MODE_DF 0
/* Use static references */
#define TX_MODE_REF 1
+/* Use packet copy */
+#define TX_MODE_COPY 2
/* Minimum number of packets to receive in CI test */
#define MIN_RX_PACKETS_CI 800
@@ -68,6 +68,11 @@ ODP_STATIC_ASSERT(MAX_WORKERS >= 2, "Too few threads");
/* Identifier for payload-timestamped packets */
#define TS_MAGIC 0xff88ee99ddaaccbb
+enum {
+ L4_PROTO_UDP = 0,
+ L4_PROTO_TCP
+};
+
ODP_STATIC_ASSERT(MAX_PKTIOS <= UINT8_MAX, "Interface index must fit into uint8_t\n");
typedef struct test_options_t {
@@ -91,11 +96,12 @@ typedef struct test_options_t {
uint32_t num_vlan;
uint32_t ipv4_src;
uint32_t ipv4_dst;
- uint16_t udp_src;
- uint16_t udp_dst;
+ uint16_t src_port;
+ uint16_t dst_port;
uint32_t wait_sec;
uint32_t wait_start_sec;
uint32_t mtu;
+ uint8_t l4_proto;
int tx_mode;
odp_bool_t promisc_mode;
odp_bool_t calc_latency;
@@ -108,8 +114,8 @@ typedef struct test_options_t {
} vlan[MAX_VLANS];
struct {
- uint32_t udp_src;
- uint32_t udp_dst;
+ uint32_t src_port;
+ uint32_t dst_port;
} c_mode;
char pktio_name[MAX_PKTIOS][MAX_PKTIO_NAME + 1];
@@ -252,15 +258,18 @@ static void print_usage(void)
" num_tx * burst_size * bursts * (10^9 / gap)\n"
" -s, --ipv4_src IPv4 source address. Default: 192.168.0.1\n"
" -d, --ipv4_dst IPv4 destination address. Default: 192.168.0.2\n"
- " -o, --udp_src UDP source port. Default: 10000\n"
- " -p, --udp_dst UDP destination port. Default: 20000\n"
+ " -o, --src_port UDP/TCP source port. Default: 10000\n"
+ " -p, --dst_port UDP/TCP destination port. Default: 20000\n"
+ " -N, --proto L4 protocol. Default: 0\n"
+ " 0: UDP\n"
+ " 1: TCP\n"
" -P, --promisc_mode Enable promiscuous mode.\n"
" -a, --latency Calculate latency. Cannot be used with packet\n"
" references (see \"--tx_mode\").\n"
- " -c, --c_mode <counts> Counter mode for incrementing UDP port numbers.\n"
+ " -c, --c_mode <counts> Counter mode for incrementing UDP/TCP port numbers.\n"
" Specify the number of port numbers used starting from\n"
- " udp_src/udp_dst. Comma-separated (no spaces) list of\n"
- " count values: <udp_src count>,<udp_dst count>\n"
+ " src_port/dst_port. Comma-separated (no spaces) list of\n"
+ " count values: <src_port count>,<dst_port count>\n"
" Default value: 0,0\n"
" -C, --no_udp_checksum Do not calculate UDP checksum. Instead, set it to\n"
" zero in every packet.\n"
@@ -354,7 +363,7 @@ static int init_bins(test_global_t *global)
static int parse_options(int argc, char *argv[], test_global_t *global)
{
- int opt, i, len, str_len, long_index, udp_port;
+ int opt, i, len, str_len, long_index, port;
unsigned long int count;
uint32_t min_packets, num_tx_pkt, num_tx_alloc, pkt_len, val, bins;
char *name, *str, *end;
@@ -368,6 +377,7 @@ static int parse_options(int argc, char *argv[], test_global_t *global)
{"num_rx", required_argument, NULL, 'r'},
{"num_tx", required_argument, NULL, 't'},
{"num_pkt", required_argument, NULL, 'n'},
+ {"proto", required_argument, NULL, 'N'},
{"len", required_argument, NULL, 'l'},
{"len_range", required_argument, NULL, 'L'},
{"direct_rx", required_argument, NULL, 'D'},
@@ -378,8 +388,8 @@ static int parse_options(int argc, char *argv[], test_global_t *global)
{"vlan", required_argument, NULL, 'v'},
{"ipv4_src", required_argument, NULL, 's'},
{"ipv4_dst", required_argument, NULL, 'd'},
- {"udp_src", required_argument, NULL, 'o'},
- {"udp_dst", required_argument, NULL, 'p'},
+ {"src_port", required_argument, NULL, 'o'},
+ {"dst_port", required_argument, NULL, 'p'},
{"promisc_mode", no_argument, NULL, 'P'},
{"latency", no_argument, NULL, 'a'},
{"c_mode", required_argument, NULL, 'c'},
@@ -394,7 +404,7 @@ static int parse_options(int argc, char *argv[], test_global_t *global)
{NULL, 0, NULL, 0}
};
- static const char *shortopts = "+i:e:r:t:n:l:L:D:m:M:b:x:g:v:s:d:o:p:c:CAq:u:w:W:Pah";
+ static const char *shortopts = "+i:e:r:t:n:N:l:L:D:m:M:b:x:g:v:s:d:o:p:c:CAq:u:w:W:Pah";
test_options->num_pktio = 0;
test_options->num_rx = 1;
@@ -412,10 +422,10 @@ static int parse_options(int argc, char *argv[], test_global_t *global)
test_options->calc_latency = 0;
test_options->calc_cs = 1;
test_options->fill_pl = 1;
- strncpy(test_options->ipv4_src_s, "192.168.0.1",
- sizeof(test_options->ipv4_src_s) - 1);
- strncpy(test_options->ipv4_dst_s, "192.168.0.2",
- sizeof(test_options->ipv4_dst_s) - 1);
+ odph_strcpy(test_options->ipv4_src_s, "192.168.0.1",
+ sizeof(test_options->ipv4_src_s));
+ odph_strcpy(test_options->ipv4_dst_s, "192.168.0.2",
+ sizeof(test_options->ipv4_dst_s));
if (odph_ipv4_addr_parse(&test_options->ipv4_src, test_options->ipv4_src_s)) {
ODPH_ERR("Address parse failed\n");
return -1;
@@ -424,15 +434,16 @@ static int parse_options(int argc, char *argv[], test_global_t *global)
ODPH_ERR("Address parse failed\n");
return -1;
}
- test_options->udp_src = 10000;
- test_options->udp_dst = 20000;
- test_options->c_mode.udp_src = 0;
- test_options->c_mode.udp_dst = 0;
+ test_options->src_port = 10000;
+ test_options->dst_port = 20000;
+ test_options->c_mode.src_port = 0;
+ test_options->c_mode.dst_port = 0;
test_options->quit = 0;
test_options->update_msec = 0;
test_options->wait_sec = 0;
test_options->wait_start_sec = 0;
test_options->mtu = 0;
+ test_options->l4_proto = L4_PROTO_UDP;
for (i = 0; i < MAX_PKTIOS; i++) {
memcpy(global->pktio[i].eth_dst.addr, default_eth_dst, 6);
@@ -504,22 +515,22 @@ static int parse_options(int argc, char *argv[], test_global_t *global)
}
break;
case 'o':
- udp_port = atoi(optarg);
- if (udp_port < 0 || udp_port > UINT16_MAX) {
- ODPH_ERR("Error: Bad UDP source port: %d\n", udp_port);
+ port = atoi(optarg);
+ if (port < 0 || port > UINT16_MAX) {
+ ODPH_ERR("Error: Bad source port: %d\n", port);
ret = -1;
break;
}
- test_options->udp_src = udp_port;
+ test_options->src_port = port;
break;
case 'p':
- udp_port = atoi(optarg);
- if (udp_port < 0 || udp_port > UINT16_MAX) {
- ODPH_ERR("Error: Bad UDP destination port: %d\n", udp_port);
+ port = atoi(optarg);
+ if (port < 0 || port > UINT16_MAX) {
+ ODPH_ERR("Error: Bad destination port: %d\n", port);
ret = -1;
break;
}
- test_options->udp_dst = udp_port;
+ test_options->dst_port = port;
break;
case 'P':
test_options->promisc_mode = 1;
@@ -536,6 +547,9 @@ static int parse_options(int argc, char *argv[], test_global_t *global)
case 'n':
test_options->num_pkt = atoi(optarg);
break;
+ case 'N':
+ test_options->l4_proto = atoi(optarg);
+ break;
case 'l':
test_options->pkt_len = atoi(optarg);
break;
@@ -581,8 +595,8 @@ static int parse_options(int argc, char *argv[], test_global_t *global)
ODPH_ERR("Error: Bad IPv4 source address: %s\n", optarg);
ret = -1;
}
- strncpy(test_options->ipv4_src_s, optarg,
- sizeof(test_options->ipv4_src_s) - 1);
+ odph_strcpy(test_options->ipv4_src_s, optarg,
+ sizeof(test_options->ipv4_src_s));
break;
case 'd':
if (odph_ipv4_addr_parse(&test_options->ipv4_dst,
@@ -590,16 +604,16 @@ static int parse_options(int argc, char *argv[], test_global_t *global)
ODPH_ERR("Error: Bad IPv4 destination address: %s\n", optarg);
ret = -1;
}
- strncpy(test_options->ipv4_dst_s, optarg,
- sizeof(test_options->ipv4_dst_s) - 1);
+ odph_strcpy(test_options->ipv4_dst_s, optarg,
+ sizeof(test_options->ipv4_dst_s));
break;
case 'c':
count = strtoul(optarg, &end, 0);
- test_options->c_mode.udp_src = count;
+ test_options->c_mode.src_port = count;
end++;
count = strtoul(end, NULL, 0);
- test_options->c_mode.udp_dst = count;
+ test_options->c_mode.dst_port = count;
break;
case 'C':
test_options->calc_cs = 0;
@@ -637,8 +651,8 @@ static int parse_options(int argc, char *argv[], test_global_t *global)
return -1;
}
- if (test_options->num_rx < 1 || test_options->num_tx < 1) {
- ODPH_ERR("Error: At least one rx and tx thread needed.\n");
+ if (test_options->num_rx < 1 && test_options->num_tx < 1) {
+ ODPH_ERR("Error: At least one rx or tx thread needed.\n");
return -1;
}
@@ -684,6 +698,10 @@ static int parse_options(int argc, char *argv[], test_global_t *global)
ODPH_ERR("Error: Latency test is not supported with packet references (--tx_mode 1)\n");
return -1;
}
+ if (test_options->calc_latency && (test_options->num_rx < 1 || test_options->num_tx < 1)) {
+ ODPH_ERR("Error: Latency test requires both rx and tx threads\n");
+ return -1;
+ }
if (test_options->gap_nsec) {
double gap_hz = 1000000000.0 / test_options->gap_nsec;
@@ -702,17 +720,25 @@ static int parse_options(int argc, char *argv[], test_global_t *global)
ODPH_ERR("\nWARNING: Not enough packets for every packet length bin.\n\n");
}
- if (test_options->c_mode.udp_dst &&
- num_tx_pkt % test_options->c_mode.udp_dst)
- ODPH_ERR("\nWARNING: Transmit packet count is not evenly divisible by UDP destination port count.\n\n");
+ if (test_options->c_mode.dst_port && num_tx_pkt % test_options->c_mode.dst_port)
+ ODPH_ERR("\nWARNING: Transmit packet count is not evenly divisible by destination port count.\n\n");
+
+ if (test_options->c_mode.src_port && num_tx_pkt % test_options->c_mode.src_port)
+ ODPH_ERR("\nWARNING: Transmit packet count is not evenly divisible by source port count.\n\n");
- if (test_options->c_mode.udp_src &&
- num_tx_pkt % test_options->c_mode.udp_src)
- ODPH_ERR("\nWARNING: Transmit packet count is not evenly divisible by UDP source port count.\n\n");
+ if (test_options->l4_proto != L4_PROTO_TCP && test_options->l4_proto != L4_PROTO_UDP) {
+ ODPH_ERR("Error: Invalid L4 protocol: %" PRIu8 "\n", test_options->l4_proto);
+ return -1;
+ }
+ if (test_options->l4_proto == L4_PROTO_TCP && test_options->tx_mode != TX_MODE_COPY) {
+ ODPH_ERR("Error: TCP protocol supported only with copy transmit mode\n");
+ return -1;
+ }
- test_options->hdr_len = ODPH_ETHHDR_LEN +
- (test_options->num_vlan * ODPH_VLANHDR_LEN) +
- ODPH_IPV4HDR_LEN + ODPH_UDPHDR_LEN;
+ test_options->hdr_len = ODPH_ETHHDR_LEN + (test_options->num_vlan * ODPH_VLANHDR_LEN) +
+ ODPH_IPV4HDR_LEN;
+ test_options->hdr_len += test_options->l4_proto == L4_PROTO_UDP ?
+ ODPH_UDPHDR_LEN : ODPH_TCPHDR_LEN;
pkt_len = test_options->use_rand_pkt_len ?
test_options->rand_pkt_len_min : test_options->pkt_len;
@@ -784,8 +810,6 @@ static int open_pktios(test_global_t *global)
uint32_t num_pkt = test_options->num_pkt;
uint32_t pkt_len = test_options->use_rand_pkt_len ?
test_options->rand_pkt_len_max : test_options->pkt_len;
- odp_pktout_queue_t pktout[num_tx];
- odp_pktin_queue_t pktin[num_rx];
printf("\nODP packet generator\n");
printf(" quit test after %" PRIu64 " rounds\n",
@@ -822,10 +846,12 @@ static int open_pktios(test_global_t *global)
}
printf(" IPv4 source %s\n", test_options->ipv4_src_s);
printf(" IPv4 destination %s\n", test_options->ipv4_dst_s);
- printf(" UDP source %u\n", test_options->udp_src);
- printf(" UDP destination %u\n", test_options->udp_dst);
- printf(" UDP src count %u\n", test_options->c_mode.udp_src);
- printf(" UDP dst count %u\n", test_options->c_mode.udp_dst);
+ printf(" L4 protocol: %s\n",
+ test_options->l4_proto == L4_PROTO_UDP ? "UDP" : "TCP");
+ printf(" source port %u\n", test_options->src_port);
+ printf(" destination port %u\n", test_options->dst_port);
+ printf(" src port count %u\n", test_options->c_mode.src_port);
+ printf(" dst port count %u\n", test_options->c_mode.dst_port);
printf(" num pktio %u\n", num_pktio);
printf(" interfaces names: ");
@@ -891,12 +917,11 @@ static int open_pktios(test_global_t *global)
odp_pktio_param_init(&pktio_param);
- if (test_options->direct_rx)
- pktio_param.in_mode = ODP_PKTIN_MODE_DIRECT;
- else
- pktio_param.in_mode = ODP_PKTIN_MODE_SCHED;
+ pktio_param.in_mode = num_rx ? (test_options->direct_rx ?
+ ODP_PKTIN_MODE_DIRECT : ODP_PKTIN_MODE_SCHED) :
+ ODP_PKTIN_MODE_DISABLED;
- pktio_param.out_mode = ODP_PKTOUT_MODE_DIRECT;
+ pktio_param.out_mode = num_tx ? ODP_PKTOUT_MODE_DIRECT : ODP_PKTOUT_MODE_DISABLED;
for (i = 0; i < num_pktio; i++)
global->pktio[i].pktio = ODP_PKTIO_INVALID;
@@ -1034,15 +1059,21 @@ static int open_pktios(test_global_t *global)
return -1;
}
- if (odp_pktout_queue(pktio, pktout, num_tx) != num_tx) {
- ODPH_ERR("Error (%s): Pktout queue request failed.\n", name);
- return -1;
+ if (num_tx > 0) {
+ odp_pktout_queue_t pktout[MAX_THREADS];
+
+ if (odp_pktout_queue(pktio, pktout, num_tx) != num_tx) {
+ ODPH_ERR("Error (%s): Pktout queue request failed.\n", name);
+ return -1;
+ }
+
+ for (j = 0; j < num_tx; j++)
+ global->pktio[i].pktout[j] = pktout[j];
}
- for (j = 0; j < num_tx; j++)
- global->pktio[i].pktout[j] = pktout[j];
+ if (num_rx > 0 && test_options->direct_rx) {
+ odp_pktin_queue_t pktin[MAX_THREADS];
- if (test_options->direct_rx) {
if (odp_pktin_queue(pktio, pktin, num_rx) != num_rx) {
ODPH_ERR("Error (%s): Pktin queue request failed.\n", name);
return -1;
@@ -1082,6 +1113,7 @@ static int print_link_info(odp_pktio_t pktio)
return 0;
}
+
static int start_pktios(test_global_t *global)
{
uint32_t i;
@@ -1386,15 +1418,16 @@ static int init_packets(test_global_t *global, int pktio,
uint8_t *u8;
odph_ethhdr_t *eth;
odph_ipv4hdr_t *ip;
- odph_udphdr_t *udp;
uint16_t tpid;
test_options_t *test_options = &global->test_options;
+ const odp_bool_t use_tcp = test_options->l4_proto == L4_PROTO_TCP;
uint32_t num_vlan = test_options->num_vlan;
uint32_t hdr_len = test_options->hdr_len;
- uint16_t udp_src = test_options->udp_src;
- uint16_t udp_dst = test_options->udp_dst;
- uint32_t udp_src_cnt = 0;
- uint32_t udp_dst_cnt = 0;
+ uint16_t src_port = test_options->src_port;
+ uint16_t dst_port = test_options->dst_port;
+ uint32_t src_cnt = 0;
+ uint32_t dst_cnt = 0;
+ uint32_t tcp_seqnum = 0x1234;
odph_vlanhdr_t *vlan = NULL; /* Fixes bogus compiler warning */
if (num_vlan > MAX_VLANS)
@@ -1446,56 +1479,75 @@ static int init_packets(test_global_t *global, int pktio,
ip->tot_len = odp_cpu_to_be_16(pkt_len - l2_len);
ip->id = odp_cpu_to_be_16(seq + i);
ip->ttl = 64;
- ip->proto = ODPH_IPPROTO_UDP;
+ ip->proto = use_tcp ? ODPH_IPPROTO_TCP : ODPH_IPPROTO_UDP;
ip->src_addr = odp_cpu_to_be_32(test_options->ipv4_src);
ip->dst_addr = odp_cpu_to_be_32(test_options->ipv4_dst);
ip->chksum = ~odp_chksum_ones_comp16(ip, ODPH_IPV4HDR_LEN);
- /* UDP */
- udp = (odph_udphdr_t *)((uint8_t *)data + l2_len +
- ODPH_IPV4HDR_LEN);
- memset(udp, 0, ODPH_UDPHDR_LEN);
- udp->src_port = odp_cpu_to_be_16(udp_src);
- udp->dst_port = odp_cpu_to_be_16(udp_dst);
- udp->length = odp_cpu_to_be_16(payload_len + ODPH_UDPHDR_LEN);
- udp->chksum = 0;
+ u8 = ((uint8_t *)data + l2_len + ODPH_IPV4HDR_LEN);
+
+ if (use_tcp) {
+ odph_tcphdr_t *tcp = (odph_tcphdr_t *)u8;
+
+ memset(tcp, 0, ODPH_TCPHDR_LEN);
+ tcp->src_port = odp_cpu_to_be_16(src_port);
+ tcp->dst_port = odp_cpu_to_be_16(dst_port);
+ tcp->seq_no = odp_cpu_to_be_32(tcp_seqnum);
+ tcp->ack_no = odp_cpu_to_be_32(0x12345678);
+ tcp->window = odp_cpu_to_be_16(0x4000);
+ tcp->hl = 5;
+ tcp->ack = 1;
+ tcp_seqnum += payload_len;
+ } else {
+ odph_udphdr_t *udp = (odph_udphdr_t *)u8;
+
+ memset(udp, 0, ODPH_UDPHDR_LEN);
+ udp->src_port = odp_cpu_to_be_16(src_port);
+ udp->dst_port = odp_cpu_to_be_16(dst_port);
+ udp->length = odp_cpu_to_be_16(payload_len + ODPH_UDPHDR_LEN);
+ udp->chksum = 0;
+ }
u8 = data;
u8 += hdr_len;
if (test_options->fill_pl) {
- /* Init UDP payload until the end of the first segment */
+ /* Init payload until the end of the first segment */
for (j = 0; j < seg_len - hdr_len; j++)
u8[j] = j;
}
- /* Insert UDP checksum */
+ /* Insert checksum */
odp_packet_l3_offset_set(pkt, l2_len);
odp_packet_l4_offset_set(pkt, l2_len + ODPH_IPV4HDR_LEN);
odp_packet_has_eth_set(pkt, 1);
odp_packet_has_ipv4_set(pkt, 1);
- odp_packet_has_udp_set(pkt, 1);
-
- udp->chksum = !test_options->calc_latency && test_options->calc_cs ?
- odph_ipv4_udp_chksum(pkt) : 0;
+ if (use_tcp) {
+ odp_packet_has_tcp_set(pkt, 1);
+ /* TCP checksum is always updated before TX */
+ } else {
+ odp_packet_has_udp_set(pkt, 1);
+ if (!test_options->calc_latency && test_options->calc_cs)
+ odph_udp_chksum_set(pkt);
+ }
/* Increment port numbers */
- if (test_options->c_mode.udp_src) {
- udp_src_cnt++;
- if (udp_src_cnt < test_options->c_mode.udp_src) {
- udp_src++;
+ if (test_options->c_mode.src_port) {
+ src_cnt++;
+ if (src_cnt < test_options->c_mode.src_port) {
+ src_port++;
} else {
- udp_src = test_options->udp_src;
- udp_src_cnt = 0;
+ src_port = test_options->src_port;
+ src_cnt = 0;
}
}
- if (test_options->c_mode.udp_dst) {
- udp_dst_cnt++;
- if (udp_dst_cnt < test_options->c_mode.udp_dst) {
- udp_dst++;
+ if (test_options->c_mode.dst_port) {
+ dst_cnt++;
+ if (dst_cnt < test_options->c_mode.dst_port) {
+ dst_port++;
} else {
- udp_dst = test_options->udp_dst;
- udp_dst_cnt = 0;
+ dst_port = test_options->dst_port;
+ dst_cnt = 0;
}
}
}
@@ -1503,6 +1555,20 @@ static int init_packets(test_global_t *global, int pktio,
return 0;
}
+static inline void update_tcp_hdr(odp_packet_t pkt, odp_packet_t base_pkt, uint32_t hdr_len)
+{
+ odph_tcphdr_t *tcp = odp_packet_l4_ptr(pkt, NULL);
+ odph_tcphdr_t *tcp_base = odp_packet_l4_ptr(base_pkt, NULL);
+ uint32_t prev_seqnum = odp_be_to_cpu_32(tcp_base->seq_no);
+
+ tcp->seq_no = odp_cpu_to_be_32(prev_seqnum + (odp_packet_len(pkt) - hdr_len));
+
+ /* Last used sequence number is stored in the base packet */
+ tcp_base->seq_no = tcp->seq_no;
+
+ odph_tcp_chksum_set(pkt);
+}
+
static inline int update_rand_data(uint8_t *data, uint32_t data_len)
{
uint32_t generated = 0;
@@ -1528,13 +1594,11 @@ static inline int update_rand_data(uint8_t *data, uint32_t data_len)
return 0;
}
-static inline void set_timestamp(odp_packet_t pkt, uint32_t ts_off, odp_bool_t calc_cs)
+static inline void set_timestamp(odp_packet_t pkt, uint32_t ts_off)
{
const ts_data_t ts_data = { .magic = TS_MAGIC, .tx_ts = odp_time_global_ns() };
- odph_udphdr_t *udp = odp_packet_l4_ptr(pkt, NULL);
(void)odp_packet_copy_from_mem(pkt, ts_off, sizeof(ts_data), &ts_data);
- udp->chksum = calc_cs ? odph_ipv4_udp_chksum(pkt) : 0;
}
static int alloc_packets(odp_pool_t pool, odp_packet_t *pkt_tbl, uint32_t num,
@@ -1570,8 +1634,8 @@ static int alloc_packets(odp_pool_t pool, odp_packet_t *pkt_tbl, uint32_t num,
static inline uint32_t form_burst(odp_packet_t out_pkt[], uint32_t burst_size, uint32_t num_bins,
uint32_t burst, odp_packet_t *pkt_tbl, odp_pool_t pool,
- int tx_mode, uint32_t ts_off, odp_bool_t calc_cs,
- uint64_t *total_bytes)
+ int tx_mode, odp_bool_t calc_latency, uint32_t hdr_len,
+ odp_bool_t calc_udp_cs, uint64_t *total_bytes, uint8_t l4_proto)
{
uint32_t i, idx;
odp_packet_t pkt;
@@ -1615,8 +1679,13 @@ static inline uint32_t form_burst(odp_packet_t out_pkt[], uint32_t burst_size, u
if (odp_unlikely(out_pkt[i] == ODP_PACKET_INVALID))
break;
- if (ts_off)
- set_timestamp(out_pkt[i], ts_off, calc_cs);
+ if (calc_latency)
+ set_timestamp(out_pkt[i], hdr_len);
+
+ if (l4_proto == L4_PROTO_TCP)
+ update_tcp_hdr(out_pkt[i], pkt, hdr_len);
+ else if (calc_latency && calc_udp_cs)
+ odph_udp_chksum_set(out_pkt[i]);
}
bytes += odp_packet_len(out_pkt[i]);
@@ -1675,16 +1744,19 @@ static int tx_thread(void *arg)
uint64_t tx_packets = 0;
uint64_t tx_drops = 0;
int ret = 0;
+ const uint32_t hdr_len = test_options->hdr_len;
const uint32_t burst_size = test_options->burst_size;
const uint32_t bursts = test_options->bursts;
const uint32_t num_tx = test_options->num_tx;
+ const uint8_t l4_proto = test_options->l4_proto;
const int tx_mode = test_options->tx_mode;
- odp_bool_t calc_cs = test_options->calc_cs;
+ const odp_bool_t calc_cs = test_options->calc_cs;
+ const odp_bool_t calc_latency = test_options->calc_latency;
int num_pktio = test_options->num_pktio;
odp_pktout_queue_t pktout[num_pktio];
- uint32_t ts_off = test_options->calc_latency ? test_options->hdr_len : 0;
uint32_t tot_packets = 0;
uint32_t num_bins = global->num_bins;
+
thr = odp_thread_id();
tx_thr = thread_arg->tx_thr;
global->stat[thr].thread_type = TX_THREAD;
@@ -1754,7 +1826,8 @@ static int tx_thread(void *arg)
for (j = 0; j < bursts; j++) {
num = form_burst(pkt, burst_size, num_bins, j, pkt_tbl, pool,
- tx_mode, ts_off, calc_cs, &total_bytes);
+ tx_mode, calc_latency, hdr_len, calc_cs,
+ &total_bytes, l4_proto);
if (odp_unlikely(num == 0)) {
ret = -1;
@@ -1777,7 +1850,6 @@ static int tx_thread(void *arg)
if (odp_unlikely(periodic_stat))
global->stat[thr].pktio[i].tx_packets += sent;
-
}
}
}
@@ -1884,16 +1956,19 @@ static void print_periodic_stat(test_global_t *global, uint64_t nsec)
num_tx[i] += global->stat[j].pktio[i].tx_packets;
}
}
+ if (global->test_options.num_tx) {
+ printf(" TX: %12.6fs", sec);
+ for (i = 0; i < num_pktio; i++)
+ printf(" %10" PRIu64 "", num_tx[i]);
+ printf("\n");
+ }
- printf(" TX: %12.6fs", sec);
- for (i = 0; i < num_pktio; i++)
- printf(" %10" PRIu64 "", num_tx[i]);
-
- printf("\n RX: %12.6fs", sec);
- for (i = 0; i < num_pktio; i++)
- printf(" %10" PRIu64 "", num_rx[i]);
-
- printf("\n");
+ if (global->test_options.num_rx) {
+ printf(" RX: %12.6fs", sec);
+ for (i = 0; i < num_pktio; i++)
+ printf(" %10" PRIu64 "", num_rx[i]);
+ printf("\n");
+ }
}
static void periodic_print_loop(test_global_t *global)
@@ -1948,7 +2023,7 @@ static void print_humanised_latency(double lat_nsec, double lat_min_nsec, double
static int print_final_stat(test_global_t *global)
{
int i, num_thr;
- double rx_pkt_ave, rx_mbit_per_sec, tx_mbit_per_sec;
+ double rx_mbit_per_sec, tx_mbit_per_sec;
test_options_t *test_options = &global->test_options;
int num_rx = test_options->num_rx;
int num_tx = test_options->num_tx;
@@ -1965,6 +2040,7 @@ static int print_final_stat(test_global_t *global)
uint64_t tx_byte_sum = 0;
uint64_t tx_drop_sum = 0;
uint64_t tx_tmo_sum = 0;
+ double rx_pkt_ave = 0.0;
double rx_pkt_per_sec = 0.0;
double rx_byte_per_sec = 0.0;
double rx_pkt_len = 0.0;
@@ -2036,7 +2112,8 @@ static int print_final_stat(test_global_t *global)
}
}
- rx_pkt_ave = (double)rx_pkt_sum / num_rx;
+ if (num_rx)
+ rx_pkt_ave = (double)rx_pkt_sum / num_rx;
rx_sec = rx_nsec_sum / 1000000000.0;
tx_sec = tx_nsec_sum / 1000000000.0;
diff --git a/test/performance/odp_packet_gen_run.sh b/test/performance/odp_packet_gen_run.sh
index af272f619..437513d47 100755
--- a/test/performance/odp_packet_gen_run.sh
+++ b/test/performance/odp_packet_gen_run.sh
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2020, Nokia
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Nokia
#
# directory where test binaries have been built
diff --git a/test/performance/odp_pktio_ordered.c b/test/performance/odp_pktio_ordered.c
index 6177a8160..18845a5df 100644
--- a/test/performance/odp_pktio_ordered.c
+++ b/test/performance/odp_pktio_ordered.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
*/
/**
@@ -190,13 +188,13 @@ typedef union ODP_ALIGNED_CACHE {
* IPv4 5-tuple
*/
typedef struct {
- int32_t src_ip;
- int32_t dst_ip;
- int16_t src_port;
- int16_t dst_port;
- int8_t proto;
- int8_t pad0;
- int16_t pad1;
+ uint32_t src_ip;
+ uint32_t dst_ip;
+ uint16_t src_port;
+ uint16_t dst_port;
+ uint8_t proto;
+ uint8_t pad0;
+ uint16_t pad1;
} ipv4_tuple5_t;
/**
@@ -335,7 +333,7 @@ static inline uint64_t calc_ipv4_5tuple_hash(ipv4_tuple5_t *tuple)
mix(a, b, c);
- a += (tuple->src_port << 16) + tuple->dst_port + JHASH_GOLDEN_RATIO;
+ a += ((uint32_t)tuple->src_port << 16) + tuple->dst_port + JHASH_GOLDEN_RATIO;
final(a, b, c);
return c;
diff --git a/test/performance/odp_pktio_ordered_run.sh b/test/performance/odp_pktio_ordered_run.sh
index b4584753f..4c573731b 100755
--- a/test/performance/odp_pktio_ordered_run.sh
+++ b/test/performance/odp_pktio_ordered_run.sh
@@ -1,10 +1,9 @@
#!/bin/bash
#
-# Copyright (c) 2016-2018, Linaro Limited
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2016-2018 Linaro Limited
#
+
TEST_SRC_DIR=$(dirname $0)
TEST_DIR="${TEST_DIR:-$(dirname $0)}"
@@ -20,19 +19,11 @@ if [ ! -f ${PCAP_IN} ]; then
exit 1
fi
-# This just turns off output buffering so that you still get periodic
-# output while piping to tee, as long as stdbuf is available.
-if [ "$(which stdbuf)" != "" ]; then
- STDBUF="stdbuf -o 0"
-else
- STDBUF=
-fi
-
export ODP_PLATFORM_PARAMS="--no-pci \
--vdev net_pcap0,rx_pcap=${PCAP_IN},tx_pcap=${PCAP_OUT} \
--vdev net_pcap1,rx_pcap=${PCAP_IN},tx_pcap=${PCAP_OUT}"
-$STDBUF ${TEST_DIR}/odp_pktio_ordered${EXEEXT} \
+${TEST_DIR}/odp_pktio_ordered${EXEEXT} \
-i 0,1 \
-t $DURATION | tee $LOG
ret=${PIPESTATUS[0]}
diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
index 4cfeb50cf..8ca9d076e 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
/**
diff --git a/test/performance/odp_pool_latency.c b/test/performance/odp_pool_latency.c
index 6b964e773..0afe2f317 100644
--- a/test/performance/odp_pool_latency.c
+++ b/test/performance/odp_pool_latency.c
@@ -16,6 +16,7 @@
#endif
#include <inttypes.h>
+#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -107,6 +108,7 @@ typedef struct {
uint64_t reallocs;
uint64_t alloc_errs;
uint64_t pattern_errs;
+ uint64_t act_num_rounds;
uint8_t max_alloc_pt;
uint8_t min_alloc_pt;
uint8_t max_uarea_pt;
@@ -150,13 +152,14 @@ typedef struct prog_config_s {
alloc_fn_t alloc_fn;
free_fn_t free_fn;
int64_t cache_size;
+ uint64_t num_rounds;
+ uint64_t num_ignore;
+ odp_atomic_u32_t is_running;
uint32_t num_data_elems;
uint32_t seg_len;
uint32_t handle_size;
uint32_t num_evs;
uint32_t data_size;
- uint32_t num_rounds;
- uint32_t num_ignore;
uint32_t num_workers;
uint32_t uarea_size;
uint8_t num_elems;
@@ -166,6 +169,11 @@ typedef struct prog_config_s {
static prog_config_t *prog_conf;
+static void terminate(int signal ODP_UNUSED)
+{
+ odp_atomic_store_u32(&prog_conf->is_running, 0U);
+}
+
static void init_config(prog_config_t *config)
{
alloc_elem_t *alloc_elem;
@@ -298,7 +306,8 @@ static void print_usage(const dynamic_defs_t *dyn_defs)
" Policies:\n"
" 0: One pool shared by workers\n"
" 1: One pool per worker\n"
- " -r, --round_count Number of rounds to run. %u by default.\n"
+ " -r, --round_count Number of rounds to run. Use 0 to run indefinitely. %u by\n"
+ " default.\n"
" -i, --ignore_rounds Ignore an amount of initial rounds. %u by default.\n"
" -c, --worker_count Number of workers. %u by default.\n"
" -C, --cache_size Maximum cache size for pools. Defaults:\n"
@@ -547,14 +556,9 @@ static parse_result_t check_options(prog_config_t *config)
return PRS_NOK;
}
- if (config->num_rounds == 0U) {
- ODPH_ERR("Invalid round count: %u (min: 1)\n", config->num_rounds);
- return PRS_NOK;
- }
-
- if (config->num_ignore >= config->num_rounds) {
- ODPH_ERR("Invalid round ignorance count: %u (max: %u)\n", config->num_ignore,
- config->num_rounds - 1U);
+ if (config->num_rounds > 0U && config->num_ignore >= config->num_rounds) {
+ ODPH_ERR("Invalid round ignore count: %" PRIu64 " (max: %" PRIu64 ")\n",
+ config->num_ignore, config->num_rounds - 1U);
return PRS_NOK;
}
@@ -607,10 +611,10 @@ static parse_result_t parse_options(int argc, char **argv, prog_config_t *config
config->policy = atoi(optarg);
break;
case 'r':
- config->num_rounds = atoi(optarg);
+ config->num_rounds = atoll(optarg);
break;
case 'i':
- config->num_ignore = atoi(optarg);
+ config->num_ignore = atoll(optarg);
break;
case 'c':
config->num_workers = atoi(optarg);
@@ -634,6 +638,21 @@ static parse_result_t parse_options(int argc, char **argv, prog_config_t *config
return check_options(config);
}
+static parse_result_t setup_program(int argc, char **argv, prog_config_t *config)
+{
+ 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;
+ }
+
+ return parse_options(argc, argv, config);
+}
+
static inline void save_alloc_stats(odp_time_t t1, odp_time_t t2, uint32_t num_alloc,
uint64_t round, uint8_t pattern, stats_t *stats)
{
@@ -1040,8 +1059,10 @@ static int run_test(void *args)
{
worker_config_t *config = args;
odp_time_t t1, t2;
- uint32_t head_idx, cur_idx, num_ignore = config->prog_config->num_ignore, val, num_alloc,
- idx;
+ uint64_t i, num_ignore = config->prog_config->num_ignore;
+ const uint64_t num_rnds = config->prog_config->num_rounds;
+ odp_atomic_u32_t *is_running = &config->prog_config->is_running;
+ uint32_t head_idx, cur_idx, val, num_alloc, idx;
odp_bool_t is_saved;
const uint8_t num_elems = config->prog_config->num_elems;
const alloc_elem_t *elems = config->prog_config->alloc_elems, *elem;
@@ -1054,7 +1075,7 @@ static int run_test(void *args)
odp_barrier_wait(&config->prog_config->init_barrier);
t1 = odp_time_local_strict();
- for (uint32_t i = 0U; i < config->prog_config->num_rounds; ++i) {
+ for (i = 0U; (i < num_rnds || num_rnds == 0U) && odp_atomic_load_u32(is_running); ++i) {
head_idx = 0U;
cur_idx = head_idx;
is_saved = (num_ignore > 0U ? num_ignore-- : num_ignore) == 0U;
@@ -1093,6 +1114,7 @@ static int run_test(void *args)
t2 = odp_time_local_strict();
stats->tot_tm = odp_time_diff_ns(t2, t1);
+ stats->act_num_rounds = i;
odp_barrier_wait(&config->prog_config->term_barrier);
return 0;
@@ -1151,20 +1173,21 @@ static void print_stats(const prog_config_t *config)
printf("\n==================\n\n"
"Pool latency test done\n\n"
- " type: %s\n"
- " event count: %u\n", config->type == BUFFER ? "buffer" :
+ " type: %s\n"
+ " event count: %u\n", config->type == BUFFER ? "buffer" :
config->type == PACKET ? "packet" : config->type == TMO ? "timeout" : "vector",
config->num_evs);
if (config->type != TMO)
- printf(" %s %u\n", config->type != VECTOR ? "data size: " : "vector size:",
+ printf(" %s %u\n",
+ config->type != VECTOR ? "data size: " : "vector size: ",
config->data_size);
- printf(" pool policy: %s\n"
- " round count: %u\n"
- " ignore count: %u\n"
- " cache size: %" PRIi64 "\n"
- " user area: %u (B)\n"
+ printf(" pool policy: %s\n"
+ " target round count: %" PRIu64 "\n"
+ " ignore count: %" PRIu64 "\n"
+ " cache size: %" PRIi64 "\n"
+ " user area: %u (B)\n"
" burst pattern:\n", config->policy == SINGLE ? "shared" : "per-worker",
config->num_rounds, config->num_ignore, config->cache_size, config->uarea_size);
@@ -1194,6 +1217,7 @@ static void print_stats(const prog_config_t *config)
ave_free_tm = stats->alloc_cnt > 0U ? stats->free_tm / stats->alloc_cnt : 0U;
printf(" worker %d:\n"
+ " actual round count: %" PRIu64 "\n"
" significant events allocated/freed: %" PRIu64 "\n"
" allocation retries: %" PRIu64 "\n"
" allocation errors: %" PRIu64 "\n"
@@ -1208,9 +1232,9 @@ static void print_stats(const prog_config_t *config)
" per free burst: %" PRIu64 " (min: %" PRIu64 " (round: %"
PRIu64 ", pattern: %u), max: %" PRIu64 " (round: %" PRIu64 ", pattern: %u))"
"\n"
- " per free: %" PRIu64 "\n", i, stats->alloc_cnt,
- stats->reallocs, stats->alloc_errs, stats->pattern_errs, stats->tot_tm,
- ev_rate, ave_b_alloc_tm, b_alloc_min, stats->min_alloc_rnd,
+ " per free: %" PRIu64 "\n", i, stats->act_num_rounds,
+ stats->alloc_cnt, stats->reallocs, stats->alloc_errs, stats->pattern_errs,
+ stats->tot_tm, ev_rate, ave_b_alloc_tm, b_alloc_min, stats->min_alloc_rnd,
stats->min_alloc_pt, b_alloc_max, stats->max_alloc_rnd, stats->max_alloc_pt,
ave_alloc_tm, ave_b_free_tm, b_free_min, stats->min_free_rnd,
stats->min_free_pt, b_free_max, stats->max_free_rnd, stats->max_free_pt,
@@ -1339,7 +1363,7 @@ int main(int argc, char **argv)
goto out;
}
- parse_res = parse_options(argc, argv, prog_conf);
+ parse_res = setup_program(argc, argv, prog_conf);
if (parse_res == PRS_NOK) {
ret = EXIT_FAILURE;
@@ -1352,6 +1376,7 @@ int main(int argc, char **argv)
}
prog_conf->odp_instance = odp_instance;
+ odp_atomic_init_u32(&prog_conf->is_running, 1U);
if (!setup_test(prog_conf)) {
ret = EXIT_FAILURE;
diff --git a/test/performance/odp_pool_perf.c b/test/performance/odp_pool_perf.c
index 43a39a21e..c79465e53 100644
--- a/test/performance/odp_pool_perf.c
+++ b/test/performance/odp_pool_perf.c
@@ -1,9 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- *
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2019-2022 Nokia
*/
/**
diff --git a/test/performance/odp_queue_perf.c b/test/performance/odp_queue_perf.c
index 7d4612cb8..153f87d10 100644
--- a/test/performance/odp_queue_perf.c
+++ b/test/performance/odp_queue_perf.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
/**
diff --git a/test/performance/odp_random.c b/test/performance/odp_random.c
index 99714d7b3..4a689e440 100644
--- a/test/performance/odp_random.c
+++ b/test/performance/odp_random.c
@@ -1,8 +1,5 @@
-/* Copyright (c) 2021-2022, Nokia
- *
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021-2024 Nokia
*/
/**
@@ -379,11 +376,20 @@ static void test_type(odp_instance_t instance, test_global_t *global, odp_random
exit(EXIT_FAILURE);
}
- if (odph_thread_join(thr_worker, num_threads) != num_threads) {
+ odph_thread_join_result_t res[num_threads];
+
+ if (odph_thread_join_result(thr_worker, res, num_threads) != num_threads) {
ODPH_ERR("Failed to join worker threads.\n");
exit(EXIT_FAILURE);
}
+ for (i = 0; i < num_threads; i++) {
+ if (res[i].ret != 0) {
+ ODPH_ERR("Worker thread failure: %d.\n", res[i].ret);
+ exit(EXIT_FAILURE);
+ }
+ }
+
double mb, seconds, nsec = 0;
for (i = 0; i < num_threads; i++)
diff --git a/test/performance/odp_sched_latency.c b/test/performance/odp_sched_latency.c
index 0fec49fb9..f3230cc17 100644
--- a/test/performance/odp_sched_latency.c
+++ b/test/performance/odp_sched_latency.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2016-2018, Linaro Limited
- * Copyright (c) 2020-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2016-2018 Linaro Limited
+ * Copyright (c) 2020-2022 Nokia
*/
/**
diff --git a/test/performance/odp_sched_latency_run.sh b/test/performance/odp_sched_latency_run.sh
index b051c1a4e..8cd6dd480 100755
--- a/test/performance/odp_sched_latency_run.sh
+++ b/test/performance/odp_sched_latency_run.sh
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2016-2018, Linaro Limited
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2016-2018 Linaro Limited
#
# Script that passes command line arguments to odp_sched_latency test when
# launched by 'make check'
diff --git a/test/performance/odp_sched_perf.c b/test/performance/odp_sched_perf.c
index 47f703338..85a158c9e 100644
--- a/test/performance/odp_sched_perf.c
+++ b/test/performance/odp_sched_perf.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2018, Linaro Limited
- * Copyright (c) 2020-2024, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2020-2024 Nokia
*/
/**
@@ -31,6 +29,9 @@
#define MAX_QUEUES (256 * 1024)
#define MAX_GROUPS 256
+/* Limit data values to 16 bits. Large data values are costly on square root calculation. */
+#define DATA_MASK 0xffff
+
/* Max time to wait for new events in nanoseconds */
#define MAX_SCHED_WAIT_NS (10 * ODP_TIME_SEC_IN_NS)
@@ -60,6 +61,7 @@ typedef struct test_options_t {
uint32_t tot_queue;
uint32_t tot_event;
int touch_data;
+ uint32_t stress;
uint32_t rd_words;
uint32_t rw_words;
uint32_t ctx_size;
@@ -156,8 +158,15 @@ static void print_usage(void)
" -b, --burst Maximum number of events per operation. Default: 100.\n"
" -t, --type Queue type. 0: parallel, 1: atomic, 2: ordered. Default: 0.\n"
" -f, --forward 0: Keep event in the original queue, 1: Forward event to the next queue. Default: 0.\n"
- " -a, --fairness 0: Don't count events per queue, 1: Count and report events relative to average. Default: 0.\n"
+ " -F, --fairness 0: Don't count events per queue, 1: Count and report events relative to average. Default: 0.\n"
" -w, --wait_ns Number of nsec to wait before enqueueing events. Default: 0.\n"
+ " -S, --stress CPU stress function(s) to be called for each event data word (requires -n or -m).\n"
+ " Data is processed as uint32_t words. Multiple flags may be selected.\n"
+ " 0: No extra data processing (default)\n"
+ " 0x1: Calculate square of each uint32_t\n"
+ " 0x2: Calculate log2 of each uint32_t\n"
+ " 0x4: Calculate square root of each uint32_t\n"
+ " 0x8: Calculate square root of each uint32_t in floating point\n"
" -k, --ctx_rd_words Number of queue context words (uint64_t) to read on every event. Default: 0.\n"
" -l, --ctx_rw_words Number of queue context words (uint64_t) to modify on every event. Default: 0.\n"
" -n, --rd_words Number of event data words (uint64_t) to read before enqueueing it. Default: 0.\n"
@@ -190,8 +199,9 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options)
{"burst", required_argument, NULL, 'b'},
{"type", required_argument, NULL, 't'},
{"forward", required_argument, NULL, 'f'},
- {"fairness", required_argument, NULL, 'a'},
+ {"fairness", required_argument, NULL, 'F'},
{"wait_ns", required_argument, NULL, 'w'},
+ {"stress", required_argument, NULL, 'S'},
{"ctx_rd_words", required_argument, NULL, 'k'},
{"ctx_rw_words", required_argument, NULL, 'l'},
{"rd_words", required_argument, NULL, 'n'},
@@ -204,7 +214,7 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options)
{NULL, 0, NULL, 0}
};
- static const char *shortopts = "+c:q:L:H:d:e:s:g:j:b:t:f:a:w:k:l:n:m:p:u:U:vh";
+ static const char *shortopts = "+c:q:L:H:d:e:s:g:j:b:t:f:F:w:S:k:l:n:m:p:u:U:vh";
test_options->num_cpu = 1;
test_options->num_queue = 1;
@@ -219,6 +229,7 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options)
test_options->queue_type = 0;
test_options->forward = 0;
test_options->fairness = 0;
+ test_options->stress = 0;
test_options->ctx_rd_words = 0;
test_options->ctx_rw_words = 0;
test_options->rd_words = 0;
@@ -271,9 +282,12 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options)
case 'f':
test_options->forward = atoi(optarg);
break;
- case 'a':
+ case 'F':
test_options->fairness = atoi(optarg);
break;
+ case 'S':
+ test_options->stress = strtoul(optarg, NULL, 0);
+ break;
case 'k':
test_options->ctx_rd_words = atoi(optarg);
break;
@@ -321,6 +335,11 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options)
test_options->touch_data = test_options->rd_words ||
test_options->rw_words;
+ if (test_options->stress && test_options->touch_data == 0) {
+ ODPH_ERR("Use -n or/and -m to select event data size with a stress function\n");
+ ret = -1;
+ }
+
if ((test_options->num_queue + test_options->num_dummy) > MAX_QUEUES) {
ODPH_ERR("Too many queues. Max supported %i.\n", MAX_QUEUES);
ret = -1;
@@ -420,6 +439,19 @@ static int set_num_cpu(test_global_t *global)
return 0;
}
+static uint64_t init_data(uint64_t init, uint64_t *data, uint32_t words)
+{
+ uint32_t i;
+ uint64_t val = init;
+
+ for (i = 0; i < words; i++) {
+ data[i] = val;
+ val = (val + 1) & DATA_MASK;
+ }
+
+ return val;
+}
+
static int create_pool(test_global_t *global)
{
odp_pool_capability_t pool_capa;
@@ -474,6 +506,7 @@ static int create_pool(test_global_t *global)
printf(" queue size %u\n", queue_size);
printf(" max burst size %u\n", max_burst);
printf(" total events %u\n", tot_event);
+ printf(" stress 0x%x\n", test_options->stress);
printf(" event size %u bytes", event_size);
if (touch_data)
printf(" (rd: %u, rw: %u)", 8 * test_options->rd_words, 8 * test_options->rw_words);
@@ -612,6 +645,7 @@ static int create_queues(test_global_t *global)
odp_pool_t pool = global->pool;
uint8_t *ctx = NULL;
uint32_t ctx_size = test_options->ctx_size;
+ uint64_t init_val = 0;
if (type == 0) {
type_str = "parallel";
@@ -755,6 +789,8 @@ static int create_queues(test_global_t *global)
for (j = 0; j < num_event; j++) {
odp_event_t ev;
+ uint64_t *data;
+ uint32_t words;
if (test_options->pool_type == ODP_POOL_BUFFER) {
odp_buffer_t buf = odp_buffer_alloc(pool);
@@ -764,6 +800,9 @@ static int create_queues(test_global_t *global)
return -1;
}
ev = odp_buffer_to_event(buf);
+
+ data = odp_buffer_addr(buf);
+ words = odp_buffer_size(buf) / 8;
} else {
odp_packet_t pkt = odp_packet_alloc(pool, event_size);
@@ -772,7 +811,13 @@ static int create_queues(test_global_t *global)
return -1;
}
ev = odp_packet_to_event(pkt);
+
+ data = odp_packet_data(pkt);
+ words = odp_packet_seg_len(pkt) / 8;
}
+
+ init_val = init_data(init_val, data, words);
+
if (odp_queue_enq(queue, ev)) {
ODPH_ERR("Error: enqueue failed %u/%u\n", i, j);
return -1;
@@ -952,15 +997,14 @@ static inline uint64_t rw_ctx_data(void *ctx, uint32_t offset,
return sum;
}
-static uint64_t rw_data(odp_event_t ev[], int num,
- uint32_t rd_words, uint32_t rw_words, odp_pool_type_t pool_type)
+static uint64_t rw_data(odp_event_t ev[], int num, uint32_t rd_words, uint32_t rw_words,
+ odp_pool_type_t pool_type)
{
uint64_t *data;
- int i;
uint32_t j;
uint64_t sum = 0;
- for (i = 0; i < num; i++) {
+ for (int i = 0; i < num; i++) {
if (pool_type == ODP_POOL_BUFFER)
data = odp_buffer_addr(odp_buffer_from_event(ev[i]));
else
@@ -978,6 +1022,40 @@ static uint64_t rw_data(odp_event_t ev[], int num,
return sum;
}
+static uint64_t rw_data_stress(odp_event_t ev[], int num, uint32_t rd_words, uint32_t rw_words,
+ uint32_t stress, odp_pool_type_t pool_type)
+{
+ uint64_t *data;
+ uint64_t word;
+ uint32_t j;
+ uint64_t sum = 0;
+
+ for (int i = 0; i < num; i++) {
+ if (pool_type == ODP_POOL_BUFFER)
+ data = odp_buffer_addr(odp_buffer_from_event(ev[i]));
+ else
+ data = odp_packet_data(odp_packet_from_event(ev[i]));
+
+ for (j = 0; j < rd_words + rw_words; j++) {
+ word = data[j];
+
+ if (stress & 0x1)
+ sum += odph_stress_pow2_u32(word);
+ if (stress & 0x2)
+ sum += odph_stress_log2_u32(word);
+ if (stress & 0x4)
+ sum += odph_stress_sqrt_u32(word);
+ if (stress & 0x8)
+ sum += odph_stress_sqrt_f32(word);
+
+ if (j >= rd_words)
+ data[j] = (word + 1) & DATA_MASK;
+ }
+ }
+
+ return sum;
+}
+
static int test_sched(void *arg)
{
int num, num_enq, ret, thr;
@@ -994,16 +1072,17 @@ static int test_sched(void *arg)
int num_group = test_options->num_group;
int forward = test_options->forward;
int fairness = test_options->fairness;
- int touch_data = test_options->touch_data;
- uint32_t rd_words = test_options->rd_words;
- uint32_t rw_words = test_options->rw_words;
+ const int touch_data = test_options->touch_data;
+ const uint32_t stress = test_options->stress;
+ const uint32_t rd_words = test_options->rd_words;
+ const uint32_t rw_words = test_options->rw_words;
uint32_t ctx_size = test_options->ctx_size;
uint32_t ctx_rd_words = test_options->ctx_rd_words;
uint32_t ctx_rw_words = test_options->ctx_rw_words;
const uint32_t uarea_size = test_options->uarea_size;
const uint32_t uarea_rd = test_options->uarea_rd;
const uint32_t uarea_rw = test_options->uarea_rw;
- odp_pool_type_t pool_type = test_options->pool_type;
+ const odp_pool_type_t pool_type = test_options->pool_type;
int touch_ctx = ctx_rd_words || ctx_rw_words;
odp_atomic_u32_t *exit_threads = &global->exit_threads;
uint32_t ctx_offset = 0;
@@ -1095,9 +1174,14 @@ static int test_sched(void *arg)
ctx_rw_words);
}
- if (odp_unlikely(touch_data))
- data_sum += rw_data(ev, num, rd_words,
- rw_words, pool_type);
+ if (odp_unlikely(touch_data)) {
+ if (stress) {
+ data_sum += rw_data_stress(ev, num, rd_words, rw_words,
+ stress, pool_type);
+ } else {
+ data_sum += rw_data(ev, num, rd_words, rw_words, pool_type);
+ }
+ }
if (odp_unlikely(wait_ns)) {
waits++;
diff --git a/test/performance/odp_sched_perf_run.sh b/test/performance/odp_sched_perf_run.sh
index 8e7911290..d4c8ebf6e 100755
--- a/test/performance/odp_sched_perf_run.sh
+++ b/test/performance/odp_sched_perf_run.sh
@@ -1,33 +1,45 @@
#!/bin/sh
#
-# Copyright (c) 2021, Nokia
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021-2024 Nokia
#
TEST_DIR="${TEST_DIR:-$(dirname $0)}"
-echo odp_sched_perf: buffer pool
-echo ===============================================
-
-$TEST_DIR/odp_sched_perf${EXEEXT} -p 0
-
-RET_VAL=$?
-if [ $RET_VAL -ne 0 ]; then
- echo odp_sched_perf -p 0: FAILED
- exit $RET_VAL
-fi
-
-echo odp_sched_perf: packet pool
-echo ===============================================
-
-$TEST_DIR/odp_sched_perf${EXEEXT} -p 1
-
-RET_VAL=$?
-if [ $RET_VAL -ne 0 ]; then
- echo odp_sched_perf -p 1: FAILED
- exit $RET_VAL
-fi
+run()
+{
+ # Maximum number of workers may be less than the number of available processors. One worker
+ # should be always available.
+ MAX_WORKERS=$(($(nproc) - 2))
+ if [ $MAX_WORKERS -lt 1 ]; then
+ MAX_WORKERS=1
+ fi
+
+ if [ $MAX_WORKERS -lt $1 ]; then
+ echo "Not enough CPU cores (requested $1, available $MAX_WORKERS). Skipping test."
+ else
+ echo odp_sched_perf -p 0 -c $1
+ echo ===============================================
+ $TEST_DIR/odp_sched_perf${EXEEXT} -p 0 -c $1
+ RET_VAL=$?
+ if [ $RET_VAL -ne 0 ]; then
+ echo odp_sched_perf FAILED
+ exit $RET_VAL
+ fi
+
+ echo odp_sched_perf -p 1 -c $1
+ echo ===============================================
+ $TEST_DIR/odp_sched_perf${EXEEXT} -p 1 -c $1
+ RET_VAL=$?
+ if [ $RET_VAL -ne 0 ]; then
+ echo odp_sched_perf FAILED
+ exit $RET_VAL
+ fi
+ fi
+}
+
+run 1
+run 2
+run 6
exit 0
diff --git a/test/performance/odp_sched_pktio.c b/test/performance/odp_sched_pktio.c
index d8ab1b279..eb79b6b69 100644
--- a/test/performance/odp_sched_pktio.c
+++ b/test/performance/odp_sched_pktio.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
/**
diff --git a/test/performance/odp_sched_pktio_run.sh b/test/performance/odp_sched_pktio_run.sh
index dd332c191..828a83029 100755
--- a/test/performance/odp_sched_pktio_run.sh
+++ b/test/performance/odp_sched_pktio_run.sh
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2018, Linaro Limited
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2018 Linaro Limited
#
# directory where test binaries have been built
@@ -11,7 +9,7 @@ TEST_DIR="${TEST_DIR:-$PWD}"
# directory where test sources are, including scripts
TEST_SRC_DIR=$(dirname $0)
-PATH=$TEST_DIR:$TEST_DIR/../../example/generator:$PATH
+PATH=$TEST_DIR:$PATH
# exit codes expected by automake for skipped tests
TEST_SKIPPED=77
@@ -19,8 +17,6 @@ TEST_SKIPPED=77
VALIDATION_TESTDIR=platform/$ODP_PLATFORM/test/validation
PLATFORM_VALIDATION=${TEST_SRC_DIR}/../../$VALIDATION_TESTDIR
-FLOOD_MODE=0
-
# Use installed pktio env or for make check take it from platform directory
if [ -f "./pktio_env" ]; then
. ./pktio_env
@@ -47,9 +43,9 @@ run_sched_pktio()
exit $TEST_SKIPPED
fi
- type odp_generator > /dev/null
+ type odp_packet_gen > /dev/null
if [ $? -ne 0 ]; then
- echo "odp_generator not installed. Aborting."
+ echo "odp_packet_gen not installed. Aborting."
cleanup_pktio_env
exit 1
fi
@@ -65,14 +61,14 @@ run_sched_pktio()
sleep 1
- # Run generator with one worker
- export ODP_PLATFORM_PARAMS="-m 256 --file-prefix="gen" \
+ # Run odp_packet_gen with one tx thread
+ export ODP_PLATFORM_PARAMS="-m 512 --file-prefix="gen" \
--proc-type auto --no-pci \
--vdev net_pcap0,iface=$IF0"
- (odp_generator${EXEEXT} --interval $FLOOD_MODE -I 0 \
- --srcip 192.168.0.1 --dstip 192.168.0.2 \
- -m u -w 1 2>&1 > /dev/null) \
+ (odp_packet_gen${EXEEXT} --gap 0 -i 0 \
+ --ipv4_src 192.168.0.1 --ipv4_dst 192.168.0.2 \
+ -r 0 -t 1 2>&1 > /dev/null) \
2>&1 > /dev/null &
GEN_PID=$!
diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c
deleted file mode 100644
index c9f3eb89f..000000000
--- a/test/performance/odp_scheduling.c
+++ /dev/null
@@ -1,1042 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2013-2018 Linaro Limited
- * Copyright (c) 2019-2023 Nokia
- */
-
-/**
- * @example odp_scheduling.c
- *
- * Performance test application for miscellaneous scheduling operations
- *
- * @cond _ODP_HIDE_FROM_DOXYGEN_
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <inttypes.h>
-
-/* ODP main header */
-#include <odp_api.h>
-
-/* ODP helper for Linux apps */
-#include <odp/helper/odph_api.h>
-
-/* Needs librt*/
-#include <time.h>
-
-/* GNU lib C */
-#include <getopt.h>
-
-#define MAX_BUF (512 * 1024) /**< Maximum pool size */
-#define MAX_ALLOCS 32 /**< Alloc burst size */
-#define QUEUES_PER_PRIO 64 /**< Queue per priority */
-#define NUM_PRIOS 2 /**< Number of tested priorities */
-#define QUEUE_ROUNDS (512 * 1024) /**< Queue test rounds */
-#define ALLOC_ROUNDS (1024 * 1024) /**< Alloc test rounds */
-#define MULTI_BUFS_MAX 4 /**< Buffer burst size */
-#define TEST_SEC 2 /**< Time test duration in sec */
-#define STATS_PER_LINE 8 /**< Stats per printed line */
-
-/** Dummy message */
-typedef struct {
- int msg_id; /**< Message ID */
- int seq; /**< Sequence number */
-} test_message_t;
-
-#define MSG_HELLO 1 /**< Hello */
-#define MSG_ACK 2 /**< Ack */
-
-/** Test arguments */
-typedef struct {
- double test_sec; /**< CPU frequency test duration in seconds */
- unsigned int cpu_count; /**< CPU count */
- int fairness; /**< Check fairness */
-} test_args_t;
-
-typedef struct ODP_ALIGNED_CACHE {
- uint64_t num_ev;
-} queue_context_t;
-
-/** Test global variables */
-typedef struct {
- odp_barrier_t barrier;
- odp_spinlock_t lock;
- odp_pool_t pool;
- int first_thr;
- int queues_per_prio;
- test_args_t args;
- odp_queue_t queue[NUM_PRIOS][QUEUES_PER_PRIO];
- queue_context_t queue_ctx[NUM_PRIOS][QUEUES_PER_PRIO];
-} test_globals_t;
-
-/* Prints and initializes queue statistics */
-static void print_stats(int prio, test_globals_t *globals)
-{
- int i, j, k;
-
- if (prio == odp_schedule_max_prio())
- i = 0;
- else
- i = 1;
-
- printf("\nQueue fairness\n-----+--------\n");
-
- for (j = 0; j < globals->queues_per_prio;) {
- printf(" %2i | ", j);
-
- for (k = 0; k < STATS_PER_LINE - 1; k++) {
- printf(" %8" PRIu64,
- globals->queue_ctx[i][j].num_ev);
- globals->queue_ctx[i][j++].num_ev = 0;
- }
-
- printf(" %8" PRIu64 "\n", globals->queue_ctx[i][j].num_ev);
- globals->queue_ctx[i][j++].num_ev = 0;
- }
-
- printf("\n");
-}
-
-/**
- * @internal Clear all scheduled queues. Retry to be sure that all
- * buffers have been scheduled.
- */
-static void clear_sched_queues(void)
-{
- odp_event_t ev;
-
- while (1) {
- ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT);
-
- if (ev == ODP_EVENT_INVALID)
- break;
-
- odp_event_free(ev);
- }
-}
-
-/**
- * @internal Enqueue events into queues
- *
- * @param thr Thread
- * @param prio Queue priority
- * @param num_queues Number of queues
- * @param num_events Number of events
- * @param globals Test shared data
- *
- * @return 0 if successful
- */
-static int enqueue_events(int thr, int prio, int num_queues, int num_events,
- test_globals_t *globals)
-{
- odp_buffer_t buf[num_events];
- odp_event_t ev[num_events];
- odp_queue_t queue;
- int i, j, k, ret;
-
- if (prio == odp_schedule_max_prio())
- i = 0;
- else
- i = 1;
-
- /* Alloc and enqueue a buffer per queue */
- for (j = 0; j < num_queues; j++) {
- queue = globals->queue[i][j];
-
- ret = odp_buffer_alloc_multi(globals->pool, buf, num_events);
- if (ret != num_events) {
- ODPH_ERR(" [%i] buffer alloc failed\n", thr);
- ret = ret < 0 ? 0 : ret;
- ret = ret > num_events ? num_events : ret; /* GCC-9 -O3 workaround */
- odp_buffer_free_multi(buf, ret);
- return -1;
- }
- for (k = 0; k < num_events; k++) {
- if (!odp_buffer_is_valid(buf[k])) {
- ODPH_ERR(" [%i] buffer alloc failed\n", thr);
- odp_buffer_free_multi(buf, num_events);
- return -1;
- }
- ev[k] = odp_buffer_to_event(buf[k]);
- }
-
- ret = odp_queue_enq_multi(queue, ev, num_events);
- if (ret != num_events) {
- ODPH_ERR(" [%i] Queue enqueue failed.\n", thr);
- ret = ret < 0 ? 0 : ret;
- odp_buffer_free_multi(&buf[ret], num_events - ret);
- return -1;
- }
- }
-
- return 0;
-}
-
-/**
- * @internal Test single buffer alloc and free
- *
- * @param thr Thread
- * @param globals Test shared data
- *
- * @return 0 if successful
- */
-static int test_alloc_single(int thr, test_globals_t *globals)
-{
- int i;
- odp_buffer_t temp_buf;
- uint64_t c1, c2, cycles;
-
- c1 = odp_cpu_cycles();
-
- for (i = 0; i < ALLOC_ROUNDS; i++) {
- temp_buf = odp_buffer_alloc(globals->pool);
-
- if (!odp_buffer_is_valid(temp_buf)) {
- ODPH_ERR(" [%i] alloc_single failed\n", thr);
- return -1;
- }
-
- odp_buffer_free(temp_buf);
- }
-
- c2 = odp_cpu_cycles();
- cycles = odp_cpu_cycles_diff(c2, c1);
- cycles = cycles / ALLOC_ROUNDS;
-
- printf(" [%i] alloc_sng alloc+free %6" PRIu64 " CPU cycles\n",
- thr, cycles);
-
- return 0;
-}
-
-/**
- * @internal Test multiple buffers alloc and free
- *
- * @param thr Thread
- * @param globals Test shared data
- *
- * @return 0 if successful
- */
-static int test_alloc_multi(int thr, test_globals_t *globals)
-{
- int i, j, ret;
- const int num_alloc = MAX_ALLOCS;
- odp_buffer_t temp_buf[num_alloc];
- uint64_t c1, c2, cycles;
-
- c1 = odp_cpu_cycles();
-
- for (i = 0; i < ALLOC_ROUNDS; i++) {
- ret = odp_buffer_alloc_multi(globals->pool, temp_buf, num_alloc);
- if (ret != num_alloc) {
- ODPH_ERR(" [%i] buffer alloc failed\n", thr);
- ret = ret < 0 ? 0 : ret;
- odp_buffer_free_multi(temp_buf, ret);
- return -1;
- }
-
- for (j = 0; j < num_alloc; j++) {
- if (!odp_buffer_is_valid(temp_buf[j])) {
- ODPH_ERR(" [%i] alloc_multi failed\n", thr);
- odp_buffer_free_multi(temp_buf, num_alloc);
- return -1;
- }
- }
- odp_buffer_free_multi(temp_buf, num_alloc);
- }
-
- c2 = odp_cpu_cycles();
- cycles = odp_cpu_cycles_diff(c2, c1);
- cycles = cycles / (ALLOC_ROUNDS * num_alloc);
-
- printf(" [%i] alloc_multi alloc+free %6" PRIu64 " CPU cycles\n",
- thr, cycles);
-
- return 0;
-}
-
-/**
- * @internal Test plain queues
- *
- * Enqueue to and dequeue to/from a single shared queue.
- *
- * @param thr Thread
- * @param globals Test shared data
- *
- * @return 0 if successful
- */
-static int test_plain_queue(int thr, test_globals_t *globals)
-{
- odp_event_t ev;
- odp_buffer_t buf;
- test_message_t *t_msg;
- odp_queue_t queue;
- uint64_t c1, c2, cycles;
- int i, j;
-
- /* Alloc test message */
- buf = odp_buffer_alloc(globals->pool);
-
- if (!odp_buffer_is_valid(buf)) {
- ODPH_ERR(" [%i] buffer alloc failed\n", thr);
- return -1;
- }
-
- /* odp_buffer_print(buf); */
-
- t_msg = odp_buffer_addr(buf);
- t_msg->msg_id = MSG_HELLO;
- t_msg->seq = 0;
-
- queue = odp_queue_lookup("plain_queue");
-
- if (queue == ODP_QUEUE_INVALID) {
- printf(" [%i] Queue lookup failed.\n", thr);
- return -1;
- }
-
- c1 = odp_cpu_cycles();
-
- for (i = 0; i < QUEUE_ROUNDS; i++) {
- ev = odp_buffer_to_event(buf);
-
- if (odp_queue_enq(queue, ev)) {
- ODPH_ERR(" [%i] Queue enqueue failed.\n", thr);
- odp_buffer_free(buf);
- return -1;
- }
-
- /* When enqueue and dequeue are decoupled (e.g. not using a
- * common lock), an enqueued event may not be immediately
- * visible to dequeue. So we just try again for a while. */
- for (j = 0; j < 100; j++) {
- ev = odp_queue_deq(queue);
- if (ev != ODP_EVENT_INVALID)
- break;
- odp_cpu_pause();
- }
-
- buf = odp_buffer_from_event(ev);
-
- if (!odp_buffer_is_valid(buf)) {
- ODPH_ERR(" [%i] Queue empty.\n", thr);
- return -1;
- }
- }
-
- c2 = odp_cpu_cycles();
- cycles = odp_cpu_cycles_diff(c2, c1);
- cycles = cycles / QUEUE_ROUNDS;
-
- printf(" [%i] plain_queue enq+deq %6" PRIu64 " CPU cycles\n",
- thr, cycles);
-
- odp_buffer_free(buf);
- return 0;
-}
-
-/**
- * @internal Test scheduling of a single queue - with odp_schedule()
- *
- * Enqueue a buffer to the shared queue. Schedule and enqueue the received
- * buffer back into the queue.
- *
- * @param str Test case name string
- * @param thr Thread
- * @param prio Priority
- * @param globals Test shared data
- *
- * @return 0 if successful
- */
-static int test_schedule_single(const char *str, int thr,
- int prio, test_globals_t *globals)
-{
- odp_event_t ev;
- odp_queue_t queue;
- uint64_t c1, c2, cycles;
- uint32_t i;
- uint32_t tot;
-
- if (enqueue_events(thr, prio, 1, 1, globals))
- return -1;
-
- c1 = odp_cpu_cycles();
-
- for (i = 0; i < QUEUE_ROUNDS; i++) {
- ev = odp_schedule(&queue, ODP_SCHED_WAIT);
-
- if (odp_queue_enq(queue, ev)) {
- ODPH_ERR(" [%i] Queue enqueue failed.\n", thr);
- odp_event_free(ev);
- return -1;
- }
- }
-
- /* Clear possible locally stored buffers */
- odp_schedule_pause();
-
- tot = i;
-
- while (1) {
- ev = odp_schedule(&queue, ODP_SCHED_NO_WAIT);
-
- if (ev == ODP_EVENT_INVALID)
- break;
-
- tot++;
-
- if (odp_queue_enq(queue, ev)) {
- ODPH_ERR(" [%i] Queue enqueue failed.\n", thr);
- odp_event_free(ev);
- return -1;
- }
- }
-
- c2 = odp_cpu_cycles();
- cycles = odp_cpu_cycles_diff(c2, c1);
-
- odp_barrier_wait(&globals->barrier);
-
- odp_schedule_resume();
-
- clear_sched_queues();
-
- cycles = cycles / tot;
-
- printf(" [%i] %s enq+deq %6" PRIu64 " CPU cycles\n", thr, str, cycles);
-
- return 0;
-}
-
-/**
- * @internal Test scheduling of multiple queues - with odp_schedule()
- *
- * Enqueue a buffer to each queue. Schedule and enqueue the received
- * buffer back into the queue it came from.
- *
- * @param str Test case name string
- * @param thr Thread
- * @param prio Priority
- * @param globals Test shared data
- *
- * @return 0 if successful
- */
-static int test_schedule_many(const char *str, int thr,
- int prio, test_globals_t *globals)
-{
- odp_event_t ev;
- odp_queue_t queue;
- uint64_t c1, c2, cycles;
- uint32_t i;
- uint32_t tot;
-
- if (enqueue_events(thr, prio, globals->queues_per_prio, 1, globals))
- return -1;
-
- /* Start sched-enq loop */
- c1 = odp_cpu_cycles();
-
- for (i = 0; i < QUEUE_ROUNDS; i++) {
- ev = odp_schedule(&queue, ODP_SCHED_WAIT);
-
- if (odp_queue_enq(queue, ev)) {
- ODPH_ERR(" [%i] Queue enqueue failed.\n", thr);
- odp_event_free(ev);
- return -1;
- }
- }
-
- /* Clear possible locally stored buffers */
- odp_schedule_pause();
-
- tot = i;
-
- while (1) {
- ev = odp_schedule(&queue, ODP_SCHED_NO_WAIT);
-
- if (ev == ODP_EVENT_INVALID)
- break;
-
- tot++;
-
- if (odp_queue_enq(queue, ev)) {
- ODPH_ERR(" [%i] Queue enqueue failed.\n", thr);
- odp_event_free(ev);
- return -1;
- }
- }
-
- c2 = odp_cpu_cycles();
- cycles = odp_cpu_cycles_diff(c2, c1);
-
- odp_barrier_wait(&globals->barrier);
-
- odp_schedule_resume();
-
- clear_sched_queues();
-
- cycles = cycles / tot;
-
- printf(" [%i] %s enq+deq %6" PRIu64 " CPU cycles\n", thr, str, cycles);
-
- return 0;
-}
-
-/**
- * @internal Test scheduling of multiple queues with multi_sched and multi_enq
- *
- * @param str Test case name string
- * @param thr Thread
- * @param prio Priority
- * @param globals Test shared data
- *
- * @return 0 if successful
- */
-static int test_schedule_multi(const char *str, int thr,
- int prio, test_globals_t *globals)
-{
- odp_event_t ev[MULTI_BUFS_MAX];
- odp_queue_t queue;
- uint64_t c1, c2, cycles;
- int i;
- int num;
- uint32_t tot = 0;
-
- if (enqueue_events(thr, prio, globals->queues_per_prio, MULTI_BUFS_MAX,
- globals))
- return -1;
-
- /* Start sched-enq loop */
- c1 = odp_cpu_cycles();
-
- for (i = 0; i < QUEUE_ROUNDS; i++) {
- num = odp_schedule_multi(&queue, ODP_SCHED_WAIT, ev,
- MULTI_BUFS_MAX);
-
- tot += num;
-
- if (globals->args.fairness) {
- queue_context_t *queue_ctx;
-
- queue_ctx = odp_queue_context(queue);
- queue_ctx->num_ev += num;
- }
-
- /* Assume we can enqueue all events */
- if (odp_queue_enq_multi(queue, ev, num) != num) {
- ODPH_ERR(" [%i] Queue enqueue failed.\n", thr);
- return -1;
- }
- }
-
- /* Clear possible locally stored events */
- odp_schedule_pause();
-
- while (1) {
- num = odp_schedule_multi(&queue, ODP_SCHED_NO_WAIT, ev,
- MULTI_BUFS_MAX);
-
- if (num == 0)
- break;
-
- tot += num;
-
- if (globals->args.fairness) {
- queue_context_t *queue_ctx;
-
- queue_ctx = odp_queue_context(queue);
- queue_ctx->num_ev += num;
- }
-
- /* Assume we can enqueue all events */
- if (odp_queue_enq_multi(queue, ev, num) != num) {
- ODPH_ERR(" [%i] Queue enqueue failed.\n", thr);
- return -1;
- }
- }
-
- c2 = odp_cpu_cycles();
- cycles = odp_cpu_cycles_diff(c2, c1);
-
- odp_barrier_wait(&globals->barrier);
-
- odp_schedule_resume();
-
- clear_sched_queues();
-
- if (tot)
- cycles = cycles / tot;
- else
- cycles = 0;
-
- printf(" [%i] %s enq+deq %6" PRIu64 " CPU cycles\n", thr, str, cycles);
-
- odp_barrier_wait(&globals->barrier);
-
- if (globals->args.fairness && globals->first_thr == thr)
- print_stats(prio, globals);
-
- return 0;
-}
-
-/**
- * @internal Worker thread
- *
- * @param arg Arguments
- *
- * @return non zero on failure
- */
-static int run_thread(void *arg ODP_UNUSED)
-{
- int thr;
- odp_shm_t shm;
- test_globals_t *globals;
- odp_barrier_t *barrier;
-
- thr = odp_thread_id();
-
- printf("Thread %i starts on CPU %i\n", thr, odp_cpu_id());
-
- shm = odp_shm_lookup("test_globals");
- globals = odp_shm_addr(shm);
-
- if (globals == NULL) {
- ODPH_ERR("Shared mem lookup failed\n");
- return -1;
- }
-
- barrier = &globals->barrier;
-
- /*
- * Test barriers back-to-back
- */
- odp_barrier_wait(barrier);
- odp_barrier_wait(barrier);
- odp_barrier_wait(barrier);
- odp_barrier_wait(barrier);
- odp_barrier_wait(barrier);
-
- /* Select which thread is the first_thr */
- while (globals->first_thr < 0) {
- if (odp_spinlock_trylock(&globals->lock)) {
- globals->first_thr = thr;
- odp_spinlock_unlock(&globals->lock);
- }
- }
-
- odp_barrier_wait(barrier);
-
- if (test_alloc_single(thr, globals))
- return -1;
-
- odp_barrier_wait(barrier);
-
- if (test_alloc_multi(thr, globals))
- return -1;
-
- odp_barrier_wait(barrier);
-
- if (test_plain_queue(thr, globals))
- return -1;
-
- /* Low prio */
-
- odp_barrier_wait(barrier);
-
- if (test_schedule_single("sched_____s_lo", thr,
- odp_schedule_min_prio(), globals))
- return -1;
-
- odp_barrier_wait(barrier);
-
- if (test_schedule_many("sched_____m_lo", thr,
- odp_schedule_min_prio(), globals))
- return -1;
-
- odp_barrier_wait(barrier);
-
- if (test_schedule_multi("sched_multi_lo", thr,
- odp_schedule_min_prio(), globals))
- return -1;
-
- /* High prio */
-
- odp_barrier_wait(barrier);
-
- if (test_schedule_single("sched_____s_hi", thr,
- odp_schedule_max_prio(), globals))
- return -1;
-
- odp_barrier_wait(barrier);
-
- if (test_schedule_many("sched_____m_hi", thr,
- odp_schedule_max_prio(), globals))
- return -1;
-
- odp_barrier_wait(barrier);
-
- if (test_schedule_multi("sched_multi_hi", thr,
- odp_schedule_max_prio(), globals))
- return -1;
-
- printf("Thread %i exits\n", thr);
- fflush(NULL);
- return 0;
-}
-
-/**
- * @internal Test cycle counter frequency
- */
-static void test_cpu_freq(double test_sec)
-{
- odp_time_t cur_time, test_time, start_time, end_time;
- uint64_t c1, c2, cycles;
- uint64_t nsec;
- double diff_max_hz, max_cycles;
-
- printf("\nCPU cycle count frequency test (runs about %f sec)\n",
- test_sec);
-
- test_time = odp_time_local_from_ns(test_sec * ODP_TIME_SEC_IN_NS);
- start_time = odp_time_local();
- end_time = odp_time_sum(start_time, test_time);
-
- /* Start the measurement */
- c1 = odp_cpu_cycles();
-
- do {
- cur_time = odp_time_local();
- } while (odp_time_cmp(end_time, cur_time) > 0);
-
- c2 = odp_cpu_cycles();
-
- test_time = odp_time_diff(cur_time, start_time);
- nsec = odp_time_to_ns(test_time);
-
- cycles = odp_cpu_cycles_diff(c2, c1);
- max_cycles = (nsec * odp_cpu_hz_max()) / 1000000000.0;
-
- /* Compare measured CPU cycles to maximum theoretical CPU cycle count */
- diff_max_hz = ((double)(cycles) - max_cycles) / max_cycles;
-
- printf("odp_time %" PRIu64 " ns\n", nsec);
- printf("odp_cpu_cycles %" PRIu64 " CPU cycles\n", cycles);
- printf("odp_sys_cpu_hz %" PRIu64 " hz\n", odp_cpu_hz_max());
- printf("Diff from max CPU freq %f%%\n", diff_max_hz * 100.0);
-
- printf("\n");
-}
-
-/**
- * @internal Print help
- */
-static void print_usage(void)
-{
- printf("\n\nUsage: ./odp_example [options]\n");
- printf("Options:\n");
- printf(" -t, --time <number> test duration, default=%.1f\n", (double)TEST_SEC);
- printf(" -c, --count <number> CPU count, 0=all available, default=1\n");
- printf(" -h, --help this help\n");
- printf(" -f, --fair collect fairness statistics\n");
- printf("\n\n");
-}
-
-/**
- * @internal Parse arguments
- *
- * @param argc Argument count
- * @param argv Argument vector
- * @param args Test arguments
- */
-static void parse_args(int argc, char *argv[], test_args_t *args)
-{
- int opt;
- int long_index;
-
- static const struct option longopts[] = {
- {"time", required_argument, NULL, 't'},
- {"count", required_argument, NULL, 'c'},
- {"fair", no_argument, NULL, 'f'},
- {"help", no_argument, NULL, 'h'},
- {NULL, 0, NULL, 0}
- };
-
- static const char *shortopts = "+t:c:fh";
-
- args->cpu_count = 1; /* use one worker by default */
- args->test_sec = TEST_SEC;
-
- while (1) {
- opt = getopt_long(argc, argv, shortopts, longopts, &long_index);
-
- if (opt == -1)
- break; /* No more options */
-
- switch (opt) {
- case 'f':
- args->fairness = 1;
- break;
-
- case 't':
- args->test_sec = atof(optarg);
- break;
-
- case 'c':
- args->cpu_count = atoi(optarg);
- break;
-
- case 'h':
- print_usage();
- exit(EXIT_SUCCESS);
- break;
-
- default:
- break;
- }
- }
-}
-
-/**
- * Test main function
- */
-int main(int argc, char *argv[])
-{
- odph_helper_options_t helper_options;
- odph_thread_t *thread_tbl;
- test_args_t args;
- int num_workers;
- odp_cpumask_t cpumask;
- odp_pool_t pool;
- odp_queue_t plain_queue;
- int i, j;
- odp_shm_t shm;
- test_globals_t *globals;
- char cpumaskstr[ODP_CPUMASK_STR_SIZE];
- odp_pool_param_t params;
- int ret = 0;
- odp_instance_t instance;
- odp_init_t init_param;
- odph_thread_common_param_t thr_common;
- odph_thread_param_t thr_param;
- odp_queue_capability_t capa;
- odp_pool_capability_t pool_capa;
- odp_schedule_config_t schedule_config;
- uint32_t num_queues, num_buf;
-
- printf("\nODP example starts\n\n");
-
- /* Let helper collect its own arguments (e.g. --odph_proc) */
- argc = odph_parse_options(argc, argv);
- if (odph_options(&helper_options)) {
- ODPH_ERR("Error: reading ODP helper options failed.\n");
- exit(EXIT_FAILURE);
- }
-
- odp_init_param_init(&init_param);
- init_param.mem_model = helper_options.mem_model;
-
- memset(&args, 0, sizeof(args));
- parse_args(argc, argv, &args);
-
- /* ODP global init */
- if (odp_init_global(&instance, &init_param, NULL)) {
- ODPH_ERR("ODP global init failed.\n");
- return -1;
- }
-
- /*
- * Init this thread. It makes also ODP calls when
- * setting up resources for worker threads.
- */
- if (odp_init_local(instance, ODP_THREAD_CONTROL)) {
- ODPH_ERR("ODP global init failed.\n");
- return -1;
- }
-
- printf("\n");
- odp_sys_info_print();
-
- /* Get default worker cpumask */
- num_workers = odp_cpumask_default_worker(&cpumask, args.cpu_count);
- (void)odp_cpumask_to_str(&cpumask, cpumaskstr, sizeof(cpumaskstr));
-
- printf("num worker threads: %i\n", num_workers);
- printf("first CPU: %i\n", odp_cpumask_first(&cpumask));
- printf("cpu mask: %s\n", cpumaskstr);
-
- thread_tbl = calloc(num_workers, sizeof(odph_thread_t));
- if (!thread_tbl) {
- ODPH_ERR("no memory for thread_tbl\n");
- return -1;
- }
-
- /* Test cycle count frequency */
- test_cpu_freq(args.test_sec);
-
- shm = odp_shm_reserve("test_globals",
- sizeof(test_globals_t), ODP_CACHE_LINE_SIZE, 0);
- if (shm == ODP_SHM_INVALID) {
- ODPH_ERR("Shared memory reserve failed.\n");
- return -1;
- }
-
- globals = odp_shm_addr(shm);
- memset(globals, 0, sizeof(test_globals_t));
- memcpy(&globals->args, &args, sizeof(test_args_t));
-
- /*
- * Create message pool
- */
- if (odp_pool_capability(&pool_capa)) {
- ODPH_ERR("Pool capabilities failed.\n");
- return -1;
- }
-
- num_buf = MAX_BUF;
- if (pool_capa.buf.max_num && pool_capa.buf.max_num < MAX_BUF)
- num_buf = pool_capa.buf.max_num;
-
- odp_pool_param_init(&params);
- params.buf.size = sizeof(test_message_t);
- params.buf.align = 0;
- params.buf.num = num_buf;
- params.type = ODP_POOL_BUFFER;
-
- pool = odp_pool_create("msg_pool", &params);
-
- if (pool == ODP_POOL_INVALID) {
- ODPH_ERR("Pool create failed.\n");
- return -1;
- }
-
- globals->pool = pool;
-
- if (odp_queue_capability(&capa)) {
- ODPH_ERR("Fetching queue capabilities failed.\n");
- return -1;
- }
-
- odp_schedule_config_init(&schedule_config);
- odp_schedule_config(&schedule_config);
-
- globals->queues_per_prio = QUEUES_PER_PRIO;
- num_queues = globals->queues_per_prio * NUM_PRIOS;
- if (schedule_config.num_queues &&
- num_queues > schedule_config.num_queues)
- globals->queues_per_prio = schedule_config.num_queues /
- NUM_PRIOS;
-
- /* One plain queue is also used */
- num_queues = (globals->queues_per_prio * NUM_PRIOS) + 1;
- if (num_queues > capa.max_queues)
- globals->queues_per_prio--;
-
- if (globals->queues_per_prio <= 0) {
- ODPH_ERR("Not enough queues. At least 1 plain and %d scheduled "
- "queues required.\n", NUM_PRIOS);
- return -1;
- }
-
- /*
- * Create a queue for plain queue test
- */
- plain_queue = odp_queue_create("plain_queue", NULL);
-
- if (plain_queue == ODP_QUEUE_INVALID) {
- ODPH_ERR("Plain queue create failed.\n");
- return -1;
- }
-
- /*
- * Create queues for schedule test.
- */
- for (i = 0; i < NUM_PRIOS; i++) {
- char name[] = "sched_XX_YY";
- odp_queue_t queue;
- odp_queue_param_t param;
- int prio;
-
- if (i == 0)
- prio = odp_schedule_max_prio();
- else
- prio = odp_schedule_min_prio();
-
- name[6] = '0' + (prio / 10);
- name[7] = '0' + prio - (10 * (prio / 10));
-
- odp_queue_param_init(&param);
- param.type = ODP_QUEUE_TYPE_SCHED;
- param.sched.prio = prio;
- param.sched.sync = ODP_SCHED_SYNC_ATOMIC;
- param.sched.group = ODP_SCHED_GROUP_ALL;
-
- for (j = 0; j < globals->queues_per_prio; j++) {
- name[9] = '0' + j / 10;
- name[10] = '0' + j - 10 * (j / 10);
-
- queue = odp_queue_create(name, &param);
-
- if (queue == ODP_QUEUE_INVALID) {
- ODPH_ERR("Schedule queue create failed.\n");
- return -1;
- }
-
- globals->queue[i][j] = queue;
-
- if (odp_queue_context_set(queue,
- &globals->queue_ctx[i][j],
- sizeof(queue_context_t))
- < 0) {
- ODPH_ERR("Queue context set failed.\n");
- return -1;
- }
- }
- }
-
- odp_shm_print_all();
-
- odp_pool_print(pool);
-
- /* Barrier to sync test case execution */
- odp_barrier_init(&globals->barrier, num_workers);
-
- odp_spinlock_init(&globals->lock);
- globals->first_thr = -1;
-
- /* Create and launch worker threads */
-
- 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.thr_type = ODP_THREAD_WORKER;
- thr_param.start = run_thread;
- thr_param.arg = NULL;
-
- odph_thread_create(thread_tbl, &thr_common, &thr_param, num_workers);
-
- /* Wait for worker threads to terminate */
- odph_thread_join(thread_tbl, num_workers);
- free(thread_tbl);
-
- printf("ODP example complete\n\n");
-
- for (i = 0; i < NUM_PRIOS; i++) {
- odp_queue_t queue;
-
- for (j = 0; j < globals->queues_per_prio; j++) {
- queue = globals->queue[i][j];
- ret += odp_queue_destroy(queue);
- }
- }
-
- ret += odp_shm_free(shm);
- ret += odp_queue_destroy(plain_queue);
- ret += odp_pool_destroy(pool);
- ret += odp_term_local();
- ret += odp_term_global(instance);
-
- return ret;
-}
diff --git a/test/performance/odp_scheduling_run.sh b/test/performance/odp_scheduling_run.sh
deleted file mode 100755
index 4e004264e..000000000
--- a/test/performance/odp_scheduling_run.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2015-2018, Linaro Limited
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-# Script that passes command line arguments to odp_scheduling test when
-# launched by 'make check'
-
-TEST_DIR="${TEST_DIR:-$(dirname $0)}"
-ALL=0
-
-run()
-{
- echo odp_scheduling_run starts requesting $1 worker threads
- echo ======================================================
-
- if [ $(nproc) -lt $1 ]; then
- echo "Not enough CPU cores. Skipping test."
- else
- $TEST_DIR/odp_scheduling${EXEEXT} -c $1 -t 0.1
- RET_VAL=$?
- if [ $RET_VAL -ne 0 ]; then
- echo odp_scheduling FAILED
- exit $RET_VAL
- fi
- fi
-}
-
-run 1
-run 5
-run 8
-run 11
-run $ALL
-
-exit 0
diff --git a/test/performance/odp_stress.c b/test/performance/odp_stress.c
index 3ec01df33..1f768b353 100644
--- a/test/performance/odp_stress.c
+++ b/test/performance/odp_stress.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022-2024 Nokia
*/
/**
@@ -23,6 +21,11 @@
#include <odp_api.h>
#include <odp/helper/odph_api.h>
+#define MODE_MEMCPY 0x1
+#define MODE_COPY_U32 0x2
+#define MODE_SQRT_U32 0x4
+#define MODE_SQRT_F32 0x8
+
typedef struct test_options_t {
uint32_t num_cpu;
uint64_t period_ns;
@@ -37,6 +40,7 @@ typedef struct test_stat_t {
uint64_t rounds;
uint64_t tot_nsec;
uint64_t work_nsec;
+ uint64_t dummy_sum;
} test_stat_t;
@@ -61,7 +65,7 @@ typedef struct test_global_t {
odp_timer_pool_t timer_pool;
odp_pool_t tmo_pool;
uint64_t period_ticks;
- uint8_t *worker_mem;
+ void *worker_mem;
odp_timer_t timer[ODP_THREAD_COUNT_MAX];
odp_queue_t tmo_queue[ODP_THREAD_COUNT_MAX];
odp_schedule_group_t group[ODP_THREAD_COUNT_MAX];
@@ -75,6 +79,35 @@ typedef struct test_global_t {
test_global_t *test_global;
+/* 250 random numbers: values between 100 and 20000 */
+static const uint32_t pseudo_rand[] = {
+ 14917, 9914, 5313, 4092, 16041, 7757, 17247, 14804, 3255, 7675,
+ 13149, 7288, 5665, 7095, 9594, 1296, 2058, 6013, 17779, 11788,
+ 14855, 760, 16891, 2483, 10937, 16385, 13593, 10674, 4080, 2392,
+ 12218, 11475, 6009, 5798, 7582, 8358, 4520, 14655, 10555, 6598,
+ 10598, 16097, 16634, 17102, 16296, 17142, 5748, 11079, 14569, 10961,
+ 16693, 17775, 19155, 14102, 16132, 19561, 8746, 4521, 8280, 355,
+ 10655, 14539, 5641, 2343, 19213, 9187, 570, 15096, 780, 1711,
+ 8007, 8128, 17416, 14123, 4713, 13774, 11450, 9031, 1194, 16531,
+ 9349, 3496, 19130, 19458, 12412, 9168, 9508, 10607, 5952, 19375,
+ 14934, 18276, 12116, 510, 14272, 10362, 4095, 6789, 1600, 18509,
+ 9274, 2815, 3175, 1122, 6495, 7991, 18831, 17550, 7056, 16185,
+ 18594, 19178, 10028, 1182, 13410, 16173, 3548, 8013, 6099, 2619,
+ 7359, 6889, 15227, 4910, 12341, 18904, 671, 5851, 9836, 18105,
+ 13624, 8138, 5751, 15590, 17415, 15330, 697, 11439, 7008, 10676,
+ 9863, 17163, 10885, 5581, 8078, 4689, 9870, 18370, 19323, 8831,
+ 11444, 3602, 10125, 6244, 13171, 19335, 15635, 19684, 17581, 9513,
+ 8444, 13724, 5243, 9987, 19886, 5087, 17292, 16294, 19627, 14985,
+ 1999, 9889, 1311, 5589, 10084, 911, 301, 2260, 15305, 8265,
+ 409, 1732, 1463, 17680, 15038, 2440, 4239, 9554, 14045, 924,
+ 13997, 3472, 18304, 4848, 10601, 18604, 6459, 19394, 2962, 11218,
+ 5405, 9869, 133, 2512, 13440, 4350, 625, 6580, 5082, 12908,
+ 11517, 8919, 354, 14216, 3190, 15515, 1277, 1028, 507, 9525,
+ 10115, 811, 1268, 17587, 5192, 7240, 17371, 4902, 19908, 1027,
+ 3475, 8658, 11782, 13701, 13034, 154, 4940, 12679, 14067, 2707,
+ 10180, 4669, 17756, 6602, 6727, 818, 8644, 580, 16988, 19127
+};
+
static void print_usage(void)
{
printf("\n"
@@ -83,9 +116,12 @@ static void print_usage(void)
" -c, --num_cpu Number of CPUs (worker threads). 0: all available CPUs. Default: 1\n"
" -p, --period_ns Timeout period in nsec. Default: 100 ms\n"
" -r, --rounds Number of timeout rounds. Default: 2\n"
- " -m, --mode Select test mode. Default: 1\n"
- " 0: No stress, just wait for timeouts\n"
- " 1: Memcpy\n"
+ " -m, --mode Test mode flags, multiple may be selected. Default: 0x1\n"
+ " 0: No stress, just wait for timeouts\n"
+ " 0x1: memcpy()\n"
+ " 0x2: Memory copy loop\n"
+ " 0x4: Integer square root\n"
+ " 0x8: Floating point square root\n"
" -s, --mem_size Memory size per worker in bytes. Default: 2048\n"
" -g, --group_mode Select schedule group mode: Default: 1\n"
" 0: Use GROUP_ALL group. Scheduler load balances timeout events.\n"
@@ -116,7 +152,7 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options)
test_options->num_cpu = 1;
test_options->period_ns = 100 * ODP_TIME_MSEC_IN_NS;
test_options->rounds = 2;
- test_options->mode = 1;
+ test_options->mode = MODE_MEMCPY;
test_options->mem_size = 2048;
test_options->group_mode = 1;
@@ -137,7 +173,7 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options)
test_options->rounds = atoll(optarg);
break;
case 'm':
- test_options->mode = atoi(optarg);
+ test_options->mode = strtoul(optarg, NULL, 0);
break;
case 's':
test_options->mem_size = atoll(optarg);
@@ -155,8 +191,9 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options)
}
if (test_options->mode) {
- if (test_options->mem_size < 2) {
- ODPH_ERR("Too small memory size\n");
+ if (test_options->mem_size < sizeof(uint32_t)) {
+ ODPH_ERR("Too small memory size. Minimum is %zu bytes.\n",
+ sizeof(uint32_t));
return -1;
}
}
@@ -218,20 +255,25 @@ static int worker_thread(void *arg)
odp_event_t ev;
odp_timeout_t tmo;
odp_timer_t timer;
- uint64_t tot_nsec, work_sum, max_nsec;
+ uint64_t tot_nsec, work_sum, max_nsec, i;
odp_timer_start_t start_param;
odp_time_t t1, t2, max_time;
odp_time_t work_t1, work_t2;
uint8_t *src = NULL, *dst = NULL;
+ uint32_t *src_u32 = NULL, *dst_u32 = NULL;
thread_arg_t *thread_arg = arg;
int worker_idx = thread_arg->worker_idx;
test_global_t *global = thread_arg->global;
test_options_t *test_options = &global->test_options;
- int mode = test_options->mode;
- int group_mode = test_options->group_mode;
- uint64_t mem_size = test_options->mem_size;
- uint64_t copy_size = mem_size / 2;
+ const int group_mode = test_options->group_mode;
+ const int mode = test_options->mode;
+ const int data_mode = mode & (MODE_SQRT_U32 | MODE_SQRT_F32);
+ const uint64_t mem_size = test_options->mem_size;
+ const uint64_t copy_size = mem_size / 2;
+ const uint64_t num_words = mem_size / sizeof(uint32_t);
+ const uint64_t copy_words = num_words / 2;
uint64_t rounds = 0;
+ uint64_t dummy_sum = 0;
int ret = 0;
uint32_t done = 0;
uint64_t wait = ODP_SCHED_WAIT;
@@ -255,8 +297,10 @@ static int worker_thread(void *arg)
}
if (mode) {
- src = global->worker_mem + worker_idx * mem_size;
+ src = (uint8_t *)global->worker_mem + worker_idx * mem_size;
dst = src + copy_size;
+ src_u32 = (uint32_t *)(uintptr_t)src;
+ dst_u32 = (uint32_t *)(uintptr_t)dst;
}
start_param.tick_type = ODP_TIMER_TICK_REL;
@@ -316,7 +360,22 @@ static int worker_thread(void *arg)
if (mode) {
work_t1 = odp_time_local();
- memcpy(dst, src, copy_size);
+ if (mode & MODE_MEMCPY)
+ memcpy(dst, src, copy_size);
+
+ if (mode & MODE_COPY_U32)
+ for (i = 0; i < copy_words; i++)
+ dst_u32[i] = src_u32[i];
+
+ if (data_mode) {
+ for (i = 0; i < num_words; i++) {
+ if (mode & MODE_SQRT_U32)
+ dummy_sum += odph_stress_sqrt_u32(src_u32[i]);
+
+ if (mode & MODE_SQRT_F32)
+ dummy_sum += odph_stress_sqrt_f32(src_u32[i]);
+ }
+ }
work_t2 = odp_time_local();
work_sum += odp_time_diff_ns(work_t2, work_t1);
@@ -336,6 +395,7 @@ static int worker_thread(void *arg)
global->stat[thr].rounds = rounds;
global->stat[thr].tot_nsec = tot_nsec;
global->stat[thr].work_nsec = work_sum;
+ global->stat[thr].dummy_sum = dummy_sum;
return ret;
}
@@ -656,8 +716,8 @@ static void print_stat(test_global_t *global)
test_stat_sum_t *sum = &global->stat_sum;
double sec_ave, work_ave, perc;
double round_ave = 0.0;
- double copy_ave = 0.0;
- double copy_tot = 0.0;
+ double rate_ave = 0.0;
+ double rate_tot = 0.0;
double cpu_load = 0.0;
const double mega = 1000000.0;
const double giga = 1000000000.0;
@@ -692,10 +752,16 @@ static void print_stat(test_global_t *global)
cpu_load = 100.0 * (work_ave / sec_ave);
if (mode) {
- uint64_t copy_bytes = sum->rounds * test_options->mem_size / 2;
+ uint64_t data_bytes;
+
+ if (mode == MODE_MEMCPY || mode == MODE_COPY_U32 ||
+ mode == (MODE_COPY_U32 | MODE_MEMCPY))
+ data_bytes = sum->rounds * test_options->mem_size / 2;
+ else
+ data_bytes = sum->rounds * test_options->mem_size;
- copy_ave = copy_bytes / (sum->work_nsec / giga);
- copy_tot = copy_ave * num_cpu;
+ rate_ave = data_bytes / (sum->work_nsec / giga);
+ rate_tot = rate_ave * num_cpu;
}
}
@@ -705,8 +771,8 @@ static void print_stat(test_global_t *global)
printf(" ave work: %.2f sec\n", work_ave);
printf(" ave CPU load: %.2f\n", cpu_load);
printf(" ave rounds per sec: %.2f\n", round_ave / sec_ave);
- printf(" ave copy speed: %.2f MB/sec\n", copy_ave / mega);
- printf(" total copy speed: %.2f MB/sec\n", copy_tot / mega);
+ printf(" ave data rate: %.2f MB/sec\n", rate_ave / mega);
+ printf(" total data rate: %.2f MB/sec\n", rate_tot / mega);
printf("\n");
}
@@ -798,6 +864,10 @@ int main(int argc, char **argv)
/* Memory for workers */
if (mode) {
+ uint64_t num_words;
+ uint32_t *word;
+ uint32_t num_rand = ODPH_ARRAY_SIZE(pseudo_rand);
+
mem_size = test_options->mem_size * num_cpu;
shm = odp_shm_reserve("Test memory", mem_size, ODP_CACHE_LINE_SIZE, 0);
@@ -813,13 +883,18 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
- memset(global->worker_mem, 0, mem_size);
+ num_words = mem_size / sizeof(uint32_t);
+ word = (uint32_t *)global->worker_mem;
+
+ for (uint64_t j = 0; j < num_words; j++)
+ word[j] = pseudo_rand[j % num_rand];
+
}
printf("\n");
printf("Test parameters\n");
printf(" num workers %u\n", num_cpu);
- printf(" mode %i\n", mode);
+ printf(" mode 0x%x\n", mode);
printf(" group mode %i\n", test_options->group_mode);
printf(" mem size per worker %" PRIu64 " bytes\n", test_options->mem_size);
diff --git a/example/timer/odp_timer_accuracy.c b/test/performance/odp_timer_accuracy.c
index e5df1c24e..a663c894a 100644
--- a/example/timer/odp_timer_accuracy.c
+++ b/test/performance/odp_timer_accuracy.c
@@ -59,7 +59,7 @@ typedef struct test_opt_t {
uint64_t warmup_timers;
uint64_t tot_timers;
uint64_t alloc_timers;
- char filename[MAX_FILENAME + 1];
+ char filename[MAX_FILENAME];
} test_opt_t;
typedef struct timer_ctx_t {
@@ -277,8 +277,11 @@ static int parse_options(int argc, char *argv[], test_opt_t *test_opt)
break;
case 'o':
test_opt->output = 1;
- /* filename is NULL terminated in anycase */
- strncpy(test_opt->filename, optarg, MAX_FILENAME);
+ if (strlen(optarg) >= MAX_FILENAME) {
+ printf("Filename too long\n");
+ return -1;
+ }
+ odph_strcpy(test_opt->filename, optarg, MAX_FILENAME);
break;
case 'e':
test_opt->early_retry = atoi(optarg);
diff --git a/test/performance/odp_timer_accuracy_run.sh b/test/performance/odp_timer_accuracy_run.sh
new file mode 100755
index 000000000..84ad2a573
--- /dev/null
+++ b/test/performance/odp_timer_accuracy_run.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2022-2024 Nokia
+#
+
+TEST_DIR="${TEST_DIR:-$(dirname $0)}"
+
+$TEST_DIR/odp_timer_accuracy${EXEEXT} -p 100000000 -n 10
+
+RET_VAL=$?
+if [ $RET_VAL -ne 0 ] ; then
+ echo odp_timer_accuracy FAILED
+ exit $RET_VAL
+fi
+
+exit 0
diff --git a/test/performance/odp_timer_perf.c b/test/performance/odp_timer_perf.c
index 918267a1b..6da5f2296 100644
--- a/test/performance/odp_timer_perf.c
+++ b/test/performance/odp_timer_perf.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2019-2023 Nokia
*/
/**
diff --git a/test/performance/odp_timer_perf_run.sh b/test/performance/odp_timer_perf_run.sh
index 7738ca91b..aa8890e8e 100755
--- a/test/performance/odp_timer_perf_run.sh
+++ b/test/performance/odp_timer_perf_run.sh
@@ -1,9 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2020, Nokia
-# All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Nokia
#
TEST_DIR="${TEST_DIR:-$(dirname $0)}"
diff --git a/test/validation/api/Makefile.am b/test/validation/api/Makefile.am
index 5a3c0216b..5a846b0c6 100644
--- a/test/validation/api/Makefile.am
+++ b/test/validation/api/Makefile.am
@@ -6,6 +6,7 @@ ODP_MODULES = align \
chksum \
classification \
comp \
+ cpu \
cpumask \
crypto \
dma \
@@ -46,6 +47,7 @@ TESTS = \
chksum/chksum_main$(EXEEXT) \
classification/classification_main$(EXEEXT) \
comp/comp_main$(EXEEXT) \
+ cpu/cpu_main$(EXEEXT) \
cpumask/cpumask_main$(EXEEXT) \
crypto/crypto_main$(EXEEXT) \
dma/dma_main$(EXEEXT) \
diff --git a/test/validation/api/README b/test/validation/api/README
index 7ee903478..665bb7896 100644
--- a/test/validation/api/README
+++ b/test/validation/api/README
@@ -1,8 +1,5 @@
-Copyright (c) 2015-2018, Linaro Limited
-All rights reserved.
-
-SPDX-License-Identifier: BSD-3-Clause
-
+SPDX-License-Identifier: BSD-3-Clause
+Copyright (c) 2015-2018 Linaro Limited
To add tests in here, please observe the rules listed below. This list
is a brief overview, for a more detailed explanation of the test
diff --git a/test/validation/api/atomic/atomic.c b/test/validation/api/atomic/atomic.c
index fab982462..8ae541fe4 100644
--- a/test/validation/api/atomic/atomic.c
+++ b/test/validation/api/atomic/atomic.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
* Copyright (c) 2021-2022 Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
*/
#include <malloc.h>
@@ -55,7 +53,7 @@ static void thread_init(void)
global_shm = odp_shm_lookup(GLOBAL_SHM_NAME);
global_mem = odp_shm_addr(global_shm);
- CU_ASSERT_PTR_NOT_NULL(global_mem);
+ CU_ASSERT(global_mem != NULL);
}
static void test_atomic_inc_32(void)
diff --git a/test/validation/api/barrier/barrier.c b/test/validation/api/barrier/barrier.c
index 7dc9a44c6..aaf646e8a 100644
--- a/test/validation/api/barrier/barrier.c
+++ b/test/validation/api/barrier/barrier.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
#include <malloc.h>
@@ -106,7 +104,7 @@ static per_thread_mem_t *thread_init(void)
global_shm = odp_shm_lookup(GLOBAL_SHM_NAME);
global_mem = odp_shm_addr(global_shm);
- CU_ASSERT_PTR_NOT_NULL(global_mem);
+ CU_ASSERT(global_mem != NULL);
per_thread_mem->global_mem = global_mem;
diff --git a/test/validation/api/buffer/buffer.c b/test/validation/api/buffer/buffer.c
index 2a79ed27e..89f16d283 100644
--- a/test/validation/api/buffer/buffer.c
+++ b/test/validation/api/buffer/buffer.c
@@ -1,16 +1,15 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
- * Copyright (c) 2022, Marvell
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2019-2024 Nokia
+ * Copyright (c) 2022 Marvell
*/
#include <odp_api.h>
-#include <odp/helper/odph_debug.h>
+#include <odp/helper/odph_api.h>
#include "odp_cunit_common.h"
#define BUF_ALIGN ODP_CACHE_LINE_SIZE
+#define BUF_MAX_SIZE 65536
#define BUF_SIZE 1500
#define BUF_NUM 100
#define BURST 8
@@ -61,6 +60,7 @@ static void test_pool_alloc_free(const odp_pool_param_t *param)
uint32_t num_buf = 0;
void *addr;
odp_event_subtype_t subtype;
+ const uint32_t max_size = pool_capa.buf.max_size;
uint32_t num = param->buf.num;
uint32_t size = param->buf.size;
uint32_t align = param->buf.align;
@@ -104,7 +104,8 @@ static void test_pool_alloc_free(const odp_pool_param_t *param)
wrong_type = true;
if (subtype != ODP_EVENT_NO_SUBTYPE)
wrong_subtype = true;
- if (odp_buffer_size(buffer[i]) < size)
+ if (odp_buffer_size(buffer[i]) < size ||
+ (max_size && odp_buffer_size(buffer[i]) > max_size))
wrong_size = true;
addr = odp_buffer_addr(buffer[i]);
@@ -142,6 +143,7 @@ static void test_pool_alloc_free_multi(const odp_pool_param_t *param)
odp_event_t ev;
void *addr;
odp_event_subtype_t subtype;
+ const uint32_t max_size = pool_capa.buf.max_size;
uint32_t num = param->buf.num;
uint32_t size = param->buf.size;
uint32_t align = param->buf.align;
@@ -193,7 +195,8 @@ static void test_pool_alloc_free_multi(const odp_pool_param_t *param)
wrong_type = true;
if (subtype != ODP_EVENT_NO_SUBTYPE)
wrong_subtype = true;
- if (odp_buffer_size(buffer[i]) < size)
+ if (odp_buffer_size(buffer[i]) < size ||
+ (max_size && odp_buffer_size(buffer[i]) > max_size))
wrong_size = true;
addr = odp_buffer_addr(buffer[i]);
@@ -389,6 +392,16 @@ static void buffer_test_pool_alloc_free(void)
test_pool_alloc_free(&default_param);
}
+static void buffer_test_pool_alloc_free_max_size(void)
+{
+ odp_pool_param_t param;
+
+ memcpy(&param, &default_param, sizeof(odp_pool_param_t));
+ param.buf.size = pool_capa.buf.max_size ? pool_capa.buf.max_size : BUF_MAX_SIZE;
+
+ test_pool_alloc_free(&param);
+}
+
static void buffer_test_pool_alloc_free_min_cache(void)
{
odp_pool_param_t param;
@@ -412,6 +425,16 @@ static void buffer_test_pool_alloc_free_multi(void)
test_pool_alloc_free_multi(&default_param);
}
+static void buffer_test_pool_alloc_free_multi_max_size(void)
+{
+ odp_pool_param_t param;
+
+ memcpy(&param, &default_param, sizeof(odp_pool_param_t));
+ param.buf.size = pool_capa.buf.max_size ? pool_capa.buf.max_size : BUF_MAX_SIZE;
+
+ test_pool_alloc_free_multi(&param);
+}
+
static void buffer_test_pool_alloc_free_multi_min_cache(void)
{
odp_pool_param_t param;
@@ -552,6 +575,7 @@ static void buffer_test_user_area(void)
CU_ASSERT(prev != addr);
ev = odp_buffer_to_event(buffer[i]);
+ odp_event_user_flag_set(ev, 1);
CU_ASSERT(odp_event_user_area(ev) == addr);
CU_ASSERT(odp_event_user_area_and_flag(ev, &flag) == addr);
CU_ASSERT(flag < 0);
@@ -570,9 +594,11 @@ static void buffer_test_user_area(void)
odp_testinfo_t buffer_suite[] = {
ODP_TEST_INFO(buffer_test_pool_alloc_free),
+ ODP_TEST_INFO(buffer_test_pool_alloc_free_max_size),
ODP_TEST_INFO(buffer_test_pool_alloc_free_min_cache),
ODP_TEST_INFO(buffer_test_pool_alloc_free_max_cache),
ODP_TEST_INFO(buffer_test_pool_alloc_free_multi),
+ ODP_TEST_INFO(buffer_test_pool_alloc_free_multi_max_size),
ODP_TEST_INFO(buffer_test_pool_alloc_free_multi_min_cache),
ODP_TEST_INFO(buffer_test_pool_alloc_free_multi_max_cache),
ODP_TEST_INFO(buffer_test_pool_single_pool),
diff --git a/test/validation/api/chksum/chksum.c b/test/validation/api/chksum/chksum.c
index 0be418f3a..17f8fed12 100644
--- a/test/validation/api/chksum/chksum.c
+++ b/test/validation/api/chksum/chksum.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp_api.h>
diff --git a/test/validation/api/classification/classification.c b/test/validation/api/classification/classification.c
index ef9a647cb..ef975c237 100644
--- a/test/validation/api/classification/classification.c
+++ b/test/validation/api/classification/classification.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <odp_api.h>
diff --git a/test/validation/api/classification/classification.h b/test/validation/api/classification/classification.h
index 70dcc6230..1f66b832a 100644
--- a/test/validation/api/classification/classification.h
+++ b/test/validation/api/classification/classification.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#ifndef _ODP_TEST_CLASSIFICATION_H_
diff --git a/test/validation/api/classification/odp_classification_basic.c b/test/validation/api/classification/odp_classification_basic.c
index ca0b58ad5..b5ccdcfea 100644
--- a/test/validation/api/classification/odp_classification_basic.c
+++ b/test/validation/api/classification/odp_classification_basic.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
#include <odp_cunit_common.h>
@@ -22,14 +20,14 @@ static void test_defaults(uint8_t fill)
CU_ASSERT(cos_param.action == ODP_COS_ACTION_ENQUEUE);
CU_ASSERT(cos_param.num_queue == 1);
- CU_ASSERT_EQUAL(cos_param.stats_enable, false);
- CU_ASSERT_EQUAL(cos_param.red.enable, false);
- CU_ASSERT_EQUAL(cos_param.bp.enable, false);
- CU_ASSERT_EQUAL(cos_param.vector.enable, false);
+ CU_ASSERT(cos_param.stats_enable == false);
+ CU_ASSERT(cos_param.red.enable == false);
+ CU_ASSERT(cos_param.bp.enable == false);
+ CU_ASSERT(cos_param.vector.enable == false);
memset(&pmr_param, fill, sizeof(pmr_param));
odp_cls_pmr_param_init(&pmr_param);
- CU_ASSERT_EQUAL(pmr_param.range_term, false);
+ CU_ASSERT(pmr_param.range_term == false);
}
static void cls_default_values(void)
diff --git a/test/validation/api/classification/odp_classification_common.c b/test/validation/api/classification/odp_classification_common.c
index 1fb4c51b5..b767a7582 100644
--- a/test/validation/api/classification/odp_classification_common.c
+++ b/test/validation/api/classification/odp_classification_common.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2020, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2020 Nokia
*/
#include "odp_classification_testsuites.h"
diff --git a/test/validation/api/classification/odp_classification_test_pmr.c b/test/validation/api/classification/odp_classification_test_pmr.c
index 7db0e1b5e..04cf098e3 100644
--- a/test/validation/api/classification/odp_classification_test_pmr.c
+++ b/test/validation/api/classification/odp_classification_test_pmr.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2019-2023 Nokia
*/
#include "odp_classification_testsuites.h"
diff --git a/test/validation/api/classification/odp_classification_tests.c b/test/validation/api/classification/odp_classification_tests.c
index d81884006..086b712ad 100644
--- a/test/validation/api/classification/odp_classification_tests.c
+++ b/test/validation/api/classification/odp_classification_tests.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2020-2023 Nokia
*/
#include "odp_classification_testsuites.h"
@@ -226,7 +224,7 @@ void configure_cls_pmr_chain(odp_bool_t enable_pktv)
uint16_t val;
uint16_t maskport;
- char cosname[ODP_QUEUE_NAME_LEN];
+ char cosname[ODP_COS_NAME_LEN];
odp_queue_param_t qparam;
odp_cls_cos_param_t cls_param;
char queuename[ODP_QUEUE_NAME_LEN];
diff --git a/test/validation/api/classification/odp_classification_testsuites.h b/test/validation/api/classification/odp_classification_testsuites.h
index 888613b1f..34f93ee8d 100644
--- a/test/validation/api/classification/odp_classification_testsuites.h
+++ b/test/validation/api/classification/odp_classification_testsuites.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#ifndef ODP_CLASSIFICATION_TESTSUITES_H_
diff --git a/test/validation/api/comp/comp.c b/test/validation/api/comp/comp.c
index b7dfcd359..7078453df 100644
--- a/test/validation/api/comp/comp.c
+++ b/test/validation/api/comp/comp.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#include <odp_api.h>
diff --git a/test/validation/api/comp/test_vectors.h b/test/validation/api/comp/test_vectors.h
index 36d98b30d..c99041c9a 100644
--- a/test/validation/api/comp/test_vectors.h
+++ b/test/validation/api/comp/test_vectors.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2018 Linaro Limited
*/
#ifndef _ODP_TEST_COMP_VECTORS_H_
diff --git a/test/validation/api/cpu/.gitignore b/test/validation/api/cpu/.gitignore
new file mode 100644
index 000000000..1b07639e6
--- /dev/null
+++ b/test/validation/api/cpu/.gitignore
@@ -0,0 +1 @@
+cpu_main
diff --git a/test/validation/api/cpu/Makefile.am b/test/validation/api/cpu/Makefile.am
new file mode 100644
index 000000000..c53fbc850
--- /dev/null
+++ b/test/validation/api/cpu/Makefile.am
@@ -0,0 +1,4 @@
+include ../Makefile.inc
+
+test_PROGRAMS = cpu_main
+cpu_main_SOURCES = cpu.c
diff --git a/test/validation/api/cpu/cpu.c b/test/validation/api/cpu/cpu.c
new file mode 100644
index 000000000..5b05a0f83
--- /dev/null
+++ b/test/validation/api/cpu/cpu.c
@@ -0,0 +1,461 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2024 Nokia
+ * Copyright (c) 2015-2018 Linaro Limited
+ */
+
+#include <odp_api.h>
+#include <odp/helper/odph_api.h>
+
+#include "odp_cunit_common.h"
+#include "test_common_macros.h"
+
+#define PERIODS_100_MSEC 160
+#define RES_TRY_NUM 10
+#define GIGA_HZ 1000000000ULL
+#define KILO_HZ 1000ULL
+
+/* 10 usec wait time assumes >100kHz resolution on CPU cycles counter */
+#define WAIT_TIME (10 * ODP_TIME_USEC_IN_NS)
+
+/* Data for cache prefetch test cases */
+static uint8_t global_data[8 * ODP_CACHE_LINE_SIZE] ODP_ALIGNED_CACHE;
+
+static int check_cycle_counter(void)
+{
+ if (odp_cpu_cycles_max() == 0) {
+ printf("Cycle counter is not supported, skipping test\n");
+ return ODP_TEST_INACTIVE;
+ }
+
+ return ODP_TEST_ACTIVE;
+}
+
+static int check_cpu_hz(void)
+{
+ if (odp_cpu_hz() == 0) {
+ printf("odp_cpu_hz() is not supported, skipping test\n");
+ return ODP_TEST_INACTIVE;
+ }
+
+ return ODP_TEST_ACTIVE;
+}
+
+static int check_cpu_hz_max(void)
+{
+ if (odp_cpu_hz_max() == 0) {
+ printf("odp_cpu_hz_max() is not supported, skipping test\n");
+ return ODP_TEST_INACTIVE;
+ }
+ return ODP_TEST_ACTIVE;
+}
+
+static int check_cpu_hz_id(void)
+{
+ uint64_t hz;
+ odp_cpumask_t mask;
+ int i, num, cpu;
+
+ num = odp_cpumask_all_available(&mask);
+ cpu = odp_cpumask_first(&mask);
+
+ for (i = 0; i < num; i++) {
+ hz = odp_cpu_hz_id(cpu);
+ if (hz == 0) {
+ printf("odp_cpu_hz_id() is not supported by CPU %d, skipping test\n", cpu);
+ return ODP_TEST_INACTIVE;
+ }
+ cpu = odp_cpumask_next(&mask, cpu);
+ }
+
+ return ODP_TEST_ACTIVE;
+}
+
+static int check_cpu_hz_max_id(void)
+{
+ uint64_t hz;
+ odp_cpumask_t mask;
+ int i, num, cpu;
+
+ num = odp_cpumask_all_available(&mask);
+ cpu = odp_cpumask_first(&mask);
+
+ for (i = 0; i < num; i++) {
+ hz = odp_cpu_hz_max_id(cpu);
+ if (hz == 0) {
+ printf("odp_cpu_hz_max_id() is not supported by CPU %d, skipping test\n",
+ cpu);
+ return ODP_TEST_INACTIVE;
+ }
+ cpu = odp_cpumask_next(&mask, cpu);
+ }
+
+ return ODP_TEST_ACTIVE;
+}
+
+static void cpu_id(void)
+{
+ CU_ASSERT(odp_cpu_id() >= 0);
+}
+
+static void cpu_count(void)
+{
+ int cpus;
+
+ cpus = odp_cpu_count();
+ CU_ASSERT(0 < cpus);
+}
+
+static void cpu_model_str(void)
+{
+ char model[128];
+
+ snprintf(model, 128, "%s", odp_cpu_model_str());
+ CU_ASSERT(strlen(model) > 0);
+ CU_ASSERT(strlen(model) < 127);
+}
+
+static void cpu_model_str_id(void)
+{
+ char model[128];
+ odp_cpumask_t mask;
+ int i, num, cpu;
+
+ num = odp_cpumask_all_available(&mask);
+ cpu = odp_cpumask_first(&mask);
+
+ for (i = 0; i < num; i++) {
+ snprintf(model, 128, "%s", odp_cpu_model_str_id(cpu));
+ CU_ASSERT(strlen(model) > 0);
+ CU_ASSERT(strlen(model) < 127);
+ cpu = odp_cpumask_next(&mask, cpu);
+ }
+}
+
+static void cpu_hz(void)
+{
+ uint64_t hz = odp_cpu_hz();
+
+ /* Test value sanity: less than 10GHz */
+ CU_ASSERT(hz < 10 * GIGA_HZ);
+
+ /* larger than 1kHz */
+ CU_ASSERT(hz > 1 * KILO_HZ);
+}
+
+static void cpu_hz_id(void)
+{
+ uint64_t hz;
+ odp_cpumask_t mask;
+ int i, num, cpu;
+
+ num = odp_cpumask_all_available(&mask);
+ cpu = odp_cpumask_first(&mask);
+
+ for (i = 0; i < num; i++) {
+ hz = odp_cpu_hz_id(cpu);
+ /* Test value sanity: less than 10GHz */
+ CU_ASSERT(hz < 10 * GIGA_HZ);
+ /* larger than 1kHz */
+ CU_ASSERT(hz > 1 * KILO_HZ);
+ cpu = odp_cpumask_next(&mask, cpu);
+ }
+}
+
+static void cpu_hz_max(void)
+{
+ uint64_t hz = odp_cpu_hz_max();
+
+ /* Sanity check value */
+ CU_ASSERT(hz > 1 * KILO_HZ);
+ CU_ASSERT(hz < 20 * GIGA_HZ);
+}
+
+static void cpu_hz_max_id(void)
+{
+ uint64_t hz;
+ odp_cpumask_t mask;
+ int i, num, cpu;
+
+ num = odp_cpumask_all_available(&mask);
+ cpu = odp_cpumask_first(&mask);
+
+ for (i = 0; i < num; i++) {
+ hz = odp_cpu_hz_max_id(cpu);
+ /* Sanity check value */
+ CU_ASSERT(hz > 1 * KILO_HZ);
+ CU_ASSERT(hz < 20 * GIGA_HZ);
+ cpu = odp_cpumask_next(&mask, cpu);
+ }
+}
+
+static void cpu_cycles(void)
+{
+ uint64_t c2, c1, diff, max;
+
+ c1 = odp_cpu_cycles();
+ odp_time_wait_ns(WAIT_TIME);
+ c2 = odp_cpu_cycles();
+
+ CU_ASSERT(c2 != c1);
+
+ max = odp_cpu_cycles_max();
+
+ /* With 10 usec delay, diff should be small compared to the maximum.
+ * Otherwise, counter is going backwards. */
+ if (c2 > c1) {
+ diff = c2 - c1;
+ CU_ASSERT(diff < (max - diff));
+ }
+
+ /* Same applies also when there was a wrap. */
+ if (c2 < c1) {
+ diff = max - c1 + c2;
+ CU_ASSERT(diff < (max - diff));
+ }
+}
+
+static void cpu_cycles_diff(void)
+{
+ uint64_t c2, c1, max;
+ uint64_t tmp, diff, res;
+
+ res = odp_cpu_cycles_resolution();
+ max = odp_cpu_cycles_max();
+
+ c1 = res;
+ c2 = 2 * res;
+ diff = odp_cpu_cycles_diff(c2, c1);
+ CU_ASSERT(diff == res);
+
+ c1 = odp_cpu_cycles();
+ odp_time_wait_ns(WAIT_TIME);
+ c2 = odp_cpu_cycles();
+ diff = odp_cpu_cycles_diff(c2, c1);
+ CU_ASSERT(diff > 0);
+ CU_ASSERT(diff < (max - diff));
+
+ /* check resolution for wrap */
+ c1 = max - 2 * res;
+ do
+ c2 = odp_cpu_cycles();
+ while (c1 < c2);
+
+ diff = odp_cpu_cycles_diff(c1, c1);
+ CU_ASSERT(diff == 0);
+
+ /* wrap */
+ tmp = c2 + (max - c1) + res;
+ diff = odp_cpu_cycles_diff(c2, c1);
+ CU_ASSERT(diff == tmp);
+
+ /* no wrap, revert args */
+ tmp = c1 - c2;
+ diff = odp_cpu_cycles_diff(c1, c2);
+ CU_ASSERT(diff == tmp);
+}
+
+static void cpu_cycles_max(void)
+{
+ uint64_t c2, c1;
+ uint64_t max1, max2;
+
+ max1 = odp_cpu_cycles_max();
+ odp_time_wait_ns(WAIT_TIME);
+ max2 = odp_cpu_cycles_max();
+
+ CU_ASSERT(max1 >= UINT32_MAX / 2);
+ CU_ASSERT(max1 == max2);
+
+ c1 = odp_cpu_cycles();
+ odp_time_wait_ns(WAIT_TIME);
+ c2 = odp_cpu_cycles();
+
+ CU_ASSERT(c1 <= max1 && c2 <= max1);
+}
+
+static void cpu_cycles_resolution(void)
+{
+ int i;
+ uint64_t res;
+ uint64_t c2, c1, max;
+ uint64_t test_cycles = odp_cpu_hz() / 100; /* CPU cycles in 10 msec */
+
+ max = odp_cpu_cycles_max();
+
+ res = odp_cpu_cycles_resolution();
+ CU_ASSERT(res != 0);
+ CU_ASSERT(res < max / 1024);
+
+ for (i = 0; i < RES_TRY_NUM; i++) {
+ c1 = odp_cpu_cycles();
+ odp_time_wait_ns(10 * ODP_TIME_MSEC_IN_NS + i);
+ c2 = odp_cpu_cycles();
+
+ /* Diff may be zero with low resolution */
+ if (test_cycles && test_cycles > res) {
+ uint64_t diff = odp_cpu_cycles_diff(c2, c1);
+
+ CU_ASSERT(diff >= res);
+ }
+ }
+}
+
+static void cpu_cycles_long_period(void)
+{
+ int i;
+ int periods = PERIODS_100_MSEC;
+ uint64_t max_period_duration = 100 * ODP_TIME_MSEC_IN_NS + periods - 1;
+ uint64_t c2, c1, c3, max;
+ uint64_t tmp, diff, res;
+
+ res = odp_cpu_cycles_resolution();
+ max = odp_cpu_cycles_max();
+
+ c3 = odp_cpu_cycles();
+
+ CU_ASSERT(c3 <= max);
+ /*
+ * If the cycle counter is not close to wrapping around during
+ * the test, then speed up the test by not trying to see the wrap
+ * around too hard. Assume cycle counter frequency of less than 10 GHz.
+ */
+ CU_ASSERT(odp_cpu_hz_max() < 10ULL * ODP_TIME_SEC_IN_NS);
+ if (max - c3 > 10 * periods * max_period_duration)
+ periods = 10;
+
+ printf("\n Testing CPU cycles for %i seconds... ", periods / 10);
+
+ for (i = 0; i < periods; i++) {
+ c1 = odp_cpu_cycles();
+ odp_time_wait_ns(100 * ODP_TIME_MSEC_IN_NS + i);
+ c2 = odp_cpu_cycles();
+
+ CU_ASSERT(c2 != c1);
+ CU_ASSERT(c1 <= max && c2 <= max);
+
+ if (c2 > c1)
+ tmp = c2 - c1;
+ else
+ tmp = c2 + (max - c1) + res;
+
+ diff = odp_cpu_cycles_diff(c2, c1);
+ CU_ASSERT(diff == tmp);
+
+ /* wrap is detected and verified */
+ if (c2 < c1)
+ break;
+ }
+
+ /* wrap was detected, no need to continue */
+ if (i < periods) {
+ printf("wrap was detected.\n");
+ return;
+ }
+
+ /* wrap has to be detected if possible */
+ CU_ASSERT(max > UINT32_MAX);
+ CU_ASSERT((max - c3) > UINT32_MAX);
+
+ printf("wrap was not detected.\n");
+}
+
+static void cpu_pause(void)
+{
+ odp_cpu_pause();
+}
+
+static void cpu_prefetch(void)
+{
+ /* Cacheline aligned address */
+ odp_prefetch(&global_data[0]);
+
+ /* Not cacheline aligned address */
+ odp_prefetch(&global_data[ODP_CACHE_LINE_SIZE + 11]);
+
+ /* An invalid address */
+ odp_prefetch(NULL);
+
+ odp_prefetch_l1(&global_data[0]);
+ odp_prefetch_l1(&global_data[ODP_CACHE_LINE_SIZE + 11]);
+ odp_prefetch_l1(NULL);
+
+ odp_prefetch_l2(&global_data[0]);
+ odp_prefetch_l2(&global_data[ODP_CACHE_LINE_SIZE + 11]);
+ odp_prefetch_l2(NULL);
+
+ odp_prefetch_l3(&global_data[0]);
+ odp_prefetch_l3(&global_data[ODP_CACHE_LINE_SIZE + 11]);
+ odp_prefetch_l3(NULL);
+}
+
+static void cpu_prefetch_store(void)
+{
+ odp_prefetch_store(&global_data[0]);
+ odp_prefetch_store(&global_data[ODP_CACHE_LINE_SIZE + 11]);
+ odp_prefetch_store(NULL);
+
+ odp_prefetch_store_l1(&global_data[0]);
+ odp_prefetch_store_l1(&global_data[ODP_CACHE_LINE_SIZE + 11]);
+ odp_prefetch_store_l1(NULL);
+
+ odp_prefetch_store_l2(&global_data[0]);
+ odp_prefetch_store_l2(&global_data[ODP_CACHE_LINE_SIZE + 11]);
+ odp_prefetch_store_l2(NULL);
+
+ odp_prefetch_store_l3(&global_data[0]);
+ odp_prefetch_store_l3(&global_data[ODP_CACHE_LINE_SIZE + 11]);
+ odp_prefetch_store_l3(NULL);
+}
+
+static void cpu_prefetch_strm(void)
+{
+ odp_prefetch_strm_l1(&global_data[0]);
+ odp_prefetch_strm_l1(&global_data[ODP_CACHE_LINE_SIZE + 11]);
+ odp_prefetch_strm_l1(NULL);
+
+ odp_prefetch_store_strm_l1(&global_data[0]);
+ odp_prefetch_store_strm_l1(&global_data[ODP_CACHE_LINE_SIZE + 11]);
+ odp_prefetch_store_strm_l1(NULL);
+}
+
+odp_testinfo_t cpu_suite[] = {
+ ODP_TEST_INFO(cpu_id),
+ ODP_TEST_INFO(cpu_count),
+ ODP_TEST_INFO(cpu_model_str),
+ ODP_TEST_INFO(cpu_model_str_id),
+ ODP_TEST_INFO_CONDITIONAL(cpu_hz, check_cpu_hz),
+ ODP_TEST_INFO_CONDITIONAL(cpu_hz_id, check_cpu_hz_id),
+ ODP_TEST_INFO_CONDITIONAL(cpu_hz_max, check_cpu_hz_max),
+ ODP_TEST_INFO_CONDITIONAL(cpu_hz_max_id, check_cpu_hz_max_id),
+ ODP_TEST_INFO_CONDITIONAL(cpu_cycles, check_cycle_counter),
+ ODP_TEST_INFO_CONDITIONAL(cpu_cycles_diff, check_cycle_counter),
+ ODP_TEST_INFO_CONDITIONAL(cpu_cycles_max, check_cycle_counter),
+ ODP_TEST_INFO_CONDITIONAL(cpu_cycles_resolution, check_cycle_counter),
+ ODP_TEST_INFO_CONDITIONAL(cpu_cycles_long_period, check_cycle_counter),
+ ODP_TEST_INFO(cpu_pause),
+ ODP_TEST_INFO(cpu_prefetch),
+ ODP_TEST_INFO(cpu_prefetch_store),
+ ODP_TEST_INFO(cpu_prefetch_strm),
+ ODP_TEST_INFO_NULL,
+};
+
+odp_suiteinfo_t cpu_suites[] = {
+ {"CPU", NULL, NULL, cpu_suite},
+ ODP_SUITE_INFO_NULL,
+};
+
+int main(int argc, char *argv[])
+{
+ int ret;
+
+ /* parse common options: */
+ if (odp_cunit_parse_options(&argc, argv))
+ return -1;
+
+ ret = odp_cunit_register(cpu_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
+}
diff --git a/test/validation/api/cpumask/cpumask.c b/test/validation/api/cpumask/cpumask.c
index db500df3a..9ca182fc9 100644
--- a/test/validation/api/cpumask/cpumask.c
+++ b/test/validation/api/cpumask/cpumask.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2021-2022 Nokia
*/
#include <odp_api.h>
diff --git a/test/validation/api/crypto/crypto_op_test.c b/test/validation/api/crypto/crypto_op_test.c
index ae1465581..f2703c5cc 100644
--- a/test/validation/api/crypto/crypto_op_test.c
+++ b/test/validation/api/crypto/crypto_op_test.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2024, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021-2024 Nokia
*/
#include <string.h>
@@ -164,6 +162,10 @@ static void write_header_and_trailer(odp_packet_t pkt,
{
uint32_t trailer_offset = odp_packet_len(pkt) - trailer_len;
uint32_t max_len = header_len > trailer_len ? header_len : trailer_len;
+
+ if (!max_len)
+ return;
+
uint8_t buffer[max_len];
int rc;
diff --git a/test/validation/api/crypto/crypto_op_test.h b/test/validation/api/crypto/crypto_op_test.h
index 9805457ad..966e0a643 100644
--- a/test/validation/api/crypto/crypto_op_test.h
+++ b/test/validation/api/crypto/crypto_op_test.h
@@ -1,8 +1,5 @@
-/*
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021-2023 Nokia
*/
#ifndef CRYPTO_OP_TEST_H
diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c
index 532aaf525..7ce37a3cd 100644
--- a/test/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/validation/api/crypto/odp_crypto_test_inp.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021-2024 Nokia
*/
#include <string.h>
@@ -34,18 +32,18 @@ static void test_defaults(uint8_t fill)
memset(&param, fill, sizeof(param));
odp_crypto_session_param_init(&param);
- CU_ASSERT_EQUAL(param.op, ODP_CRYPTO_OP_ENCODE);
- CU_ASSERT_EQUAL(param.op_type, ODP_CRYPTO_OP_TYPE_LEGACY);
- CU_ASSERT_EQUAL(param.cipher_range_in_bits, false);
- CU_ASSERT_EQUAL(param.auth_range_in_bits, false);
- CU_ASSERT_EQUAL(param.auth_cipher_text, false);
- CU_ASSERT_EQUAL(param.null_crypto_enable, false);
- CU_ASSERT_EQUAL(param.op_mode, ODP_CRYPTO_SYNC);
- CU_ASSERT_EQUAL(param.cipher_alg, ODP_CIPHER_ALG_NULL);
- CU_ASSERT_EQUAL(param.cipher_iv_len, 0);
- CU_ASSERT_EQUAL(param.auth_alg, ODP_AUTH_ALG_NULL);
- CU_ASSERT_EQUAL(param.auth_iv_len, 0);
- CU_ASSERT_EQUAL(param.auth_aad_len, 0);
+ CU_ASSERT(param.op == ODP_CRYPTO_OP_ENCODE);
+ CU_ASSERT(param.op_type == ODP_CRYPTO_OP_TYPE_LEGACY);
+ CU_ASSERT(param.cipher_range_in_bits == false);
+ CU_ASSERT(param.auth_range_in_bits == false);
+ CU_ASSERT(param.auth_cipher_text == false);
+ CU_ASSERT(param.null_crypto_enable == false);
+ CU_ASSERT(param.op_mode == ODP_CRYPTO_SYNC);
+ CU_ASSERT(param.cipher_alg == ODP_CIPHER_ALG_NULL);
+ CU_ASSERT(param.cipher_iv_len == 0);
+ CU_ASSERT(param.auth_alg == ODP_AUTH_ALG_NULL);
+ CU_ASSERT(param.auth_iv_len == 0);
+ CU_ASSERT(param.auth_aad_len == 0);
}
static void test_default_values(void)
@@ -190,8 +188,8 @@ static int session_create(crypto_session_t *session,
int rc;
odp_crypto_ses_create_err_t status;
odp_crypto_session_param_t ses_params;
- uint8_t cipher_key_data[ref->cipher_key_length];
- uint8_t auth_key_data[ref->auth_key_length];
+ uint8_t cipher_key_data[MAX_KEY_LEN];
+ uint8_t auth_key_data[MAX_KEY_LEN];
odp_crypto_key_t cipher_key = {
.data = cipher_key_data,
.length = ref->cipher_key_length
@@ -776,6 +774,10 @@ static odp_cipher_alg_t cipher_algs[] = {
ODP_CIPHER_ALG_SNOW3G_UEA2,
ODP_CIPHER_ALG_AES_EEA2,
ODP_CIPHER_ALG_ZUC_EEA3,
+ ODP_CIPHER_ALG_SNOW_V,
+ ODP_CIPHER_ALG_SM4_ECB,
+ ODP_CIPHER_ALG_SM4_CBC,
+ ODP_CIPHER_ALG_SM4_CTR,
};
/*
@@ -790,6 +792,10 @@ static odp_auth_alg_t auth_algs[] = {
ODP_AUTH_ALG_SHA256_HMAC,
ODP_AUTH_ALG_SHA384_HMAC,
ODP_AUTH_ALG_SHA512_HMAC,
+ ODP_AUTH_ALG_SHA3_224_HMAC,
+ ODP_AUTH_ALG_SHA3_256_HMAC,
+ ODP_AUTH_ALG_SHA3_384_HMAC,
+ ODP_AUTH_ALG_SHA3_512_HMAC,
ODP_AUTH_ALG_AES_GMAC,
ODP_AUTH_ALG_AES_CMAC,
ODP_AUTH_ALG_AES_XCBC_MAC,
@@ -797,12 +803,20 @@ static odp_auth_alg_t auth_algs[] = {
ODP_AUTH_ALG_SNOW3G_UIA2,
ODP_AUTH_ALG_AES_EIA2,
ODP_AUTH_ALG_ZUC_EIA3,
+ ODP_AUTH_ALG_SNOW_V_GMAC,
+ ODP_AUTH_ALG_SM3_HMAC,
+ ODP_AUTH_ALG_SM4_GMAC,
ODP_AUTH_ALG_MD5,
ODP_AUTH_ALG_SHA1,
ODP_AUTH_ALG_SHA224,
ODP_AUTH_ALG_SHA256,
ODP_AUTH_ALG_SHA384,
ODP_AUTH_ALG_SHA512,
+ ODP_AUTH_ALG_SHA3_224,
+ ODP_AUTH_ALG_SHA3_256,
+ ODP_AUTH_ALG_SHA3_384,
+ ODP_AUTH_ALG_SHA3_512,
+ ODP_AUTH_ALG_SM3,
};
static void test_auth_hashes_in_auth_range(void)
diff --git a/test/validation/api/crypto/test_vector_defs.h b/test/validation/api/crypto/test_vector_defs.h
index 46ae4e4e1..6c2eb2085 100644
--- a/test/validation/api/crypto/test_vector_defs.h
+++ b/test/validation/api/crypto/test_vector_defs.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
#ifndef TEST_VECTOR_DEFS_H
diff --git a/test/validation/api/crypto/test_vectors.h b/test/validation/api/crypto/test_vectors.h
index a38644246..33ba52d34 100644
--- a/test/validation/api/crypto/test_vectors.h
+++ b/test/validation/api/crypto/test_vectors.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
#ifndef TEST_VECTORS_H
diff --git a/test/validation/api/crypto/test_vectors_len.h b/test/validation/api/crypto/test_vectors_len.h
index 3818b57a0..92b5c8453 100644
--- a/test/validation/api/crypto/test_vectors_len.h
+++ b/test/validation/api/crypto/test_vectors_len.h
@@ -1,8 +1,7 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
*/
+
#ifndef TEST_VECTORS_LEN_
#define TEST_VECTORS_LEN_
diff --git a/test/validation/api/crypto/util.c b/test/validation/api/crypto/util.c
index 557e5e951..c40d61313 100644
--- a/test/validation/api/crypto/util.c
+++ b/test/validation/api/crypto/util.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021-2024 Nokia
*/
#include <string.h>
@@ -32,8 +30,14 @@ const char *auth_alg_name(odp_auth_alg_t auth)
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_SHA3_224_HMAC:
+ return "ODP_AUTH_ALG_SHA3_224_HMAC";
+ case ODP_AUTH_ALG_SHA3_256_HMAC:
+ return "ODP_AUTH_ALG_SHA3_256_HMAC";
+ case ODP_AUTH_ALG_SHA3_384_HMAC:
+ return "ODP_AUTH_ALG_SHA3_384_HMAC";
+ case ODP_AUTH_ALG_SHA3_512_HMAC:
+ return "ODP_AUTH_ALG_SHA3_512_HMAC";
case ODP_AUTH_ALG_AES_GCM:
return "ODP_AUTH_ALG_AES_GCM";
case ODP_AUTH_ALG_AES_GMAC:
@@ -42,6 +46,8 @@ const char *auth_alg_name(odp_auth_alg_t auth)
return "ODP_AUTH_ALG_AES_CCM";
case ODP_AUTH_ALG_AES_CMAC:
return "ODP_AUTH_ALG_AES_CMAC";
+ case ODP_AUTH_ALG_AES_XCBC_MAC:
+ return "ODP_AUTH_ALG_AES_XCBC_MAC";
case ODP_AUTH_ALG_CHACHA20_POLY1305:
return "ODP_AUTH_ALG_CHACHA20_POLY1305";
case ODP_AUTH_ALG_KASUMI_F9:
@@ -52,6 +58,18 @@ const char *auth_alg_name(odp_auth_alg_t auth)
return "ODP_AUTH_ALG_AES_EIA2";
case ODP_AUTH_ALG_ZUC_EIA3:
return "ODP_AUTH_ALG_ZUC_EIA3";
+ case ODP_AUTH_ALG_SNOW_V_GCM:
+ return "ODP_AUTH_ALG_SNOW_V_GCM";
+ case ODP_AUTH_ALG_SNOW_V_GMAC:
+ return "ODP_AUTH_ALG_SNOW_V_GMAC";
+ case ODP_AUTH_ALG_SM3_HMAC:
+ return "ODP_AUTH_ALG_SM3_HMAC";
+ case ODP_AUTH_ALG_SM4_GCM:
+ return "ODP_AUTH_ALG_SM4_GCM";
+ case ODP_AUTH_ALG_SM4_GMAC:
+ return "ODP_AUTH_ALG_SM4_GMAC";
+ case ODP_AUTH_ALG_SM4_CCM:
+ return "ODP_AUTH_ALG_SM4_CCM";
case ODP_AUTH_ALG_MD5:
return "ODP_AUTH_ALG_MD5";
case ODP_AUTH_ALG_SHA1:
@@ -64,6 +82,8 @@ const char *auth_alg_name(odp_auth_alg_t auth)
return "ODP_AUTH_ALG_SHA384";
case ODP_AUTH_ALG_SHA512:
return "ODP_AUTH_ALG_SHA512";
+ case ODP_AUTH_ALG_SM3:
+ return "ODP_AUTH_ALG_SM3";
default:
return "Unknown";
}
@@ -104,6 +124,20 @@ const char *cipher_alg_name(odp_cipher_alg_t cipher)
return "ODP_CIPHER_ALG_AES_EEA2";
case ODP_CIPHER_ALG_ZUC_EEA3:
return "ODP_CIPHER_ALG_ZUC_EEA3";
+ case ODP_CIPHER_ALG_SNOW_V:
+ return "ODP_CIPHER_ALG_SNOW_V";
+ case ODP_CIPHER_ALG_SNOW_V_GCM:
+ return "ODP_CIPHER_ALG_SNOW_V_GCM";
+ case ODP_CIPHER_ALG_SM4_ECB:
+ return "ODP_CIPHER_ALG_SM4_ECB";
+ case ODP_CIPHER_ALG_SM4_CBC:
+ return "ODP_CIPHER_ALG_SM4_CBC";
+ case ODP_CIPHER_ALG_SM4_CTR:
+ return "ODP_CIPHER_ALG_SM4_CTR";
+ case ODP_CIPHER_ALG_SM4_GCM:
+ return "ODP_CIPHER_ALG_SM4_GCM";
+ case ODP_CIPHER_ALG_SM4_CCM:
+ return "ODP_CIPHER_ALG_SM4_CCM";
default:
return "Unknown";
}
@@ -201,6 +235,34 @@ int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth)
if (!capability.ciphers.bit.zuc_eea3)
return ODP_TEST_INACTIVE;
break;
+ case ODP_CIPHER_ALG_SNOW_V:
+ if (!capability.ciphers.bit.snow_v)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_SNOW_V_GCM:
+ if (!capability.ciphers.bit.snow_v_gcm)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_SM4_ECB:
+ if (!capability.ciphers.bit.sm4_ecb)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_SM4_CBC:
+ if (!capability.ciphers.bit.sm4_cbc)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_SM4_CTR:
+ if (!capability.ciphers.bit.sm4_ctr)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_SM4_GCM:
+ if (!capability.ciphers.bit.sm4_gcm)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_CIPHER_ALG_SM4_CCM:
+ if (!capability.ciphers.bit.sm4_ccm)
+ return ODP_TEST_INACTIVE;
+ break;
default:
ODPH_ERR("Unsupported cipher algorithm\n");
return ODP_TEST_INACTIVE;
@@ -236,8 +298,20 @@ int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth)
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)
+ case ODP_AUTH_ALG_SHA3_224_HMAC:
+ if (!capability.auths.bit.sha3_224_hmac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA3_256_HMAC:
+ if (!capability.auths.bit.sha3_256_hmac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA3_384_HMAC:
+ if (!capability.auths.bit.sha3_384_hmac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA3_512_HMAC:
+ if (!capability.auths.bit.sha3_512_hmac)
return ODP_TEST_INACTIVE;
break;
case ODP_AUTH_ALG_AES_GCM:
@@ -256,6 +330,10 @@ int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth)
if (!capability.auths.bit.aes_cmac)
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_CHACHA20_POLY1305:
if (!capability.auths.bit.chacha20_poly1305)
return ODP_TEST_INACTIVE;
@@ -276,6 +354,30 @@ int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth)
if (!capability.auths.bit.zuc_eia3)
return ODP_TEST_INACTIVE;
break;
+ case ODP_AUTH_ALG_SNOW_V_GCM:
+ if (!capability.auths.bit.snow_v_gcm)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SNOW_V_GMAC:
+ if (!capability.auths.bit.snow_v_gmac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SM3_HMAC:
+ if (!capability.auths.bit.sm3_hmac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SM4_GCM:
+ if (!capability.auths.bit.sm4_gcm)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SM4_GMAC:
+ if (!capability.auths.bit.sm4_gmac)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SM4_CCM:
+ if (!capability.auths.bit.sm4_ccm)
+ return ODP_TEST_INACTIVE;
+ break;
case ODP_AUTH_ALG_MD5:
if (!capability.auths.bit.md5)
return ODP_TEST_INACTIVE;
@@ -300,6 +402,26 @@ int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth)
if (!capability.auths.bit.sha512)
return ODP_TEST_INACTIVE;
break;
+ case ODP_AUTH_ALG_SHA3_224:
+ if (!capability.auths.bit.sha3_224)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA3_256:
+ if (!capability.auths.bit.sha3_256)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA3_384:
+ if (!capability.auths.bit.sha3_384)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SHA3_512:
+ if (!capability.auths.bit.sha3_512)
+ return ODP_TEST_INACTIVE;
+ break;
+ case ODP_AUTH_ALG_SM3:
+ if (!capability.auths.bit.sm3)
+ return ODP_TEST_INACTIVE;
+ break;
default:
ODPH_ERR("Unsupported authentication algorithm\n");
return ODP_TEST_INACTIVE;
diff --git a/test/validation/api/crypto/util.h b/test/validation/api/crypto/util.h
index 5cba21890..b6a013255 100644
--- a/test/validation/api/crypto/util.h
+++ b/test/validation/api/crypto/util.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
#ifndef UTIL_H
diff --git a/test/validation/api/dma/dma.c b/test/validation/api/dma/dma.c
index efc7fa039..739a6c5c6 100644
--- a/test/validation/api/dma/dma.c
+++ b/test/validation/api/dma/dma.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021-2023 Nokia
*/
#include <odp_api.h>
@@ -325,6 +323,24 @@ static void test_dma_same_name_named(void)
CU_ASSERT(odp_dma_destroy(dma_b) == 0);
}
+static void test_dma_long_name(void)
+{
+ odp_dma_param_t dma_param;
+ odp_dma_t dma;
+ char name[ODP_DMA_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ odp_dma_param_init(&dma_param);
+ dma_param.compl_mode_mask = ODP_DMA_COMPL_SYNC;
+ dma = odp_dma_create(name, &dma_param);
+
+ CU_ASSERT_FATAL(dma != ODP_DMA_INVALID);
+ CU_ASSERT(odp_dma_to_u64(dma) == odp_dma_to_u64(odp_dma_lookup(name)));
+ CU_ASSERT(odp_dma_destroy(dma) == 0);
+}
+
static void test_dma_compl_pool(void)
{
odp_pool_t pool;
@@ -397,6 +413,24 @@ static void test_dma_compl_pool_same_name(void)
CU_ASSERT_FATAL(odp_pool_destroy(pool_b) == 0);
}
+static void test_dma_compl_pool_long_name(void)
+{
+ odp_dma_pool_param_t dma_pool_param;
+ odp_pool_t pool;
+ char name[ODP_POOL_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ odp_dma_pool_param_init(&dma_pool_param);
+ dma_pool_param.num = 1;
+ pool = odp_dma_pool_create(name, &dma_pool_param);
+
+ CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+ CU_ASSERT(pool == odp_pool_lookup(name));
+ CU_ASSERT_FATAL(odp_pool_destroy(pool) == 0);
+}
+
static void test_dma_compl_pool_max_pools(void)
{
odp_dma_pool_param_t dma_pool_param;
@@ -458,6 +492,7 @@ static void test_dma_compl_user_area(void)
CU_ASSERT(prev != addr);
ev = odp_dma_compl_to_event(compl_evs[i]);
+ odp_event_user_flag_set(ev, 1);
CU_ASSERT(odp_event_user_area(ev) == addr);
CU_ASSERT(odp_event_user_area_and_flag(ev, &flag) == addr);
CU_ASSERT(flag < 0);
@@ -1636,8 +1671,10 @@ odp_testinfo_t dma_suite[] = {
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_long_name, 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_long_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_compl_user_area_init, check_event_user_area_init),
diff --git a/test/validation/api/errno/errno.c b/test/validation/api/errno/errno.c
index 70708ce01..1cbd27b1b 100644
--- a/test/validation/api/errno/errno.c
+++ b/test/validation/api/errno/errno.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <odp_api.h>
@@ -13,9 +11,9 @@ static void errno_test_odp_errno_sunny_day(void)
odp_errno_zero();
my_errno = odp_errno();
- CU_ASSERT_TRUE(my_errno == 0);
+ CU_ASSERT(my_errno == 0);
odp_errno_print("odp_errno");
- CU_ASSERT_PTR_NOT_NULL(odp_errno_str(my_errno));
+ CU_ASSERT(odp_errno_str(my_errno) != NULL);
}
odp_testinfo_t errno_suite[] = {
diff --git a/test/validation/api/event/event.c b/test/validation/api/event/event.c
index fbcc08d6f..a4f967791 100644
--- a/test/validation/api/event/event.c
+++ b/test/validation/api/event/event.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2023 Nokia
*/
#include <odp_api.h>
diff --git a/test/validation/api/hash/hash.c b/test/validation/api/hash/hash.c
index a935ef7ac..60c6755b2 100644
--- a/test/validation/api/hash/hash.c
+++ b/test/validation/api/hash/hash.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2021 Nokia
*/
#include <odp_api.h>
diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c
index 5ad7bd48d..0389175f0 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -1,9 +1,7 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2018-2022, Nokia
- * Copyright (c) 2020-2021, Marvell
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2018-2022 Nokia
+ * Copyright (c) 2020-2021 Marvell
*/
#include <odp_api.h>
@@ -457,27 +455,28 @@ static void ipsec_status_event_handle(odp_event_t ev_status,
};
CU_ASSERT_FATAL(ODP_EVENT_INVALID != 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));
+ CU_ASSERT(1 == odp_event_is_valid(ev_status));
+ CU_ASSERT_FATAL(ODP_EVENT_IPSEC_STATUS == odp_event_type(ev_status));
- /* No user area or source pool for IPsec status events */
+ /* No user area/flag or source pool for IPsec status events */
+ odp_event_user_flag_set(ev_status, 1);
CU_ASSERT(odp_event_user_area(ev_status) == NULL);
CU_ASSERT(odp_event_user_area_and_flag(ev_status, &flag) == NULL);
CU_ASSERT(flag < 0);
CU_ASSERT(odp_event_pool(ev_status) == ODP_POOL_INVALID);
- 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);
- CU_ASSERT_EQUAL(0, status.result);
+ CU_ASSERT(0 == odp_ipsec_status(&status, ev_status));
+ CU_ASSERT(ODP_IPSEC_STATUS_WARN == status.id);
+ CU_ASSERT(sa == status.sa);
+ CU_ASSERT(0 == status.result);
if (IPSEC_TEST_EXPIRY_IGNORED != sa_expiry) {
if (IPSEC_TEST_EXPIRY_SOFT_PKT == sa_expiry) {
- CU_ASSERT_EQUAL(1, status.warn.soft_exp_packets);
+ CU_ASSERT(1 == status.warn.soft_exp_packets);
sa_expiry_notified = true;
} else if (IPSEC_TEST_EXPIRY_SOFT_BYTE == sa_expiry) {
- CU_ASSERT_EQUAL(1, status.warn.soft_exp_bytes);
+ CU_ASSERT(1 == status.warn.soft_exp_bytes);
sa_expiry_notified = true;
}
}
@@ -502,51 +501,47 @@ void ipsec_sa_destroy(odp_ipsec_sa_t sa)
odp_ipsec_status_t status;
int ret;
- CU_ASSERT_EQUAL(IPSEC_SA_CTX, odp_ipsec_sa_context(sa));
+ CU_ASSERT(IPSEC_SA_CTX == odp_ipsec_sa_context(sa));
- CU_ASSERT_EQUAL(ODP_IPSEC_OK, odp_ipsec_sa_disable(sa));
+ CU_ASSERT(ODP_IPSEC_OK == odp_ipsec_sa_disable(sa));
if (ODP_QUEUE_INVALID != suite_context.queue) {
event = recv_event(suite_context.queue, EVENT_WAIT_TIME);
CU_ASSERT(odp_event_is_valid(event) == 1);
- CU_ASSERT_EQUAL(ODP_EVENT_IPSEC_STATUS, odp_event_type(event));
+ CU_ASSERT(ODP_EVENT_IPSEC_STATUS == odp_event_type(event));
ret = odp_ipsec_status(&status, event);
CU_ASSERT(ret == 0);
if (ret == 0) {
- CU_ASSERT_EQUAL(ODP_IPSEC_STATUS_SA_DISABLE, status.id);
- CU_ASSERT_EQUAL(sa, status.sa);
- CU_ASSERT_EQUAL(0, status.result);
- CU_ASSERT_EQUAL(0, status.warn.all);
+ CU_ASSERT(ODP_IPSEC_STATUS_SA_DISABLE == status.id);
+ CU_ASSERT(sa == status.sa);
+ CU_ASSERT(0 == status.result);
+ CU_ASSERT(0 == status.warn.all);
}
odp_event_free(event);
}
- CU_ASSERT_EQUAL(ODP_IPSEC_OK, odp_ipsec_sa_destroy(sa));
+ CU_ASSERT(ODP_IPSEC_OK == odp_ipsec_sa_destroy(sa));
}
odp_packet_t ipsec_packet(const ipsec_test_packet *itp)
{
odp_packet_t pkt = odp_packet_alloc(suite_context.pool, itp->len);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_PACKET_INVALID, pkt);
+ CU_ASSERT_FATAL(ODP_PACKET_INVALID != pkt);
if (ODP_PACKET_INVALID == pkt)
return pkt;
- CU_ASSERT_EQUAL(0, odp_packet_copy_from_mem(pkt, 0, itp->len,
- itp->data));
+ CU_ASSERT(0 == odp_packet_copy_from_mem(pkt, 0, itp->len, itp->data));
if (itp->l2_offset != ODP_PACKET_OFFSET_INVALID)
- CU_ASSERT_EQUAL(0, odp_packet_l2_offset_set(pkt,
- itp->l2_offset));
+ CU_ASSERT(0 == odp_packet_l2_offset_set(pkt, itp->l2_offset));
if (itp->l3_offset != ODP_PACKET_OFFSET_INVALID)
- CU_ASSERT_EQUAL(0, odp_packet_l3_offset_set(pkt,
- itp->l3_offset));
+ CU_ASSERT(0 == odp_packet_l3_offset_set(pkt, itp->l3_offset));
if (itp->l4_offset != ODP_PACKET_OFFSET_INVALID)
- CU_ASSERT_EQUAL(0, odp_packet_l4_offset_set(pkt,
- itp->l4_offset));
+ CU_ASSERT(0 == odp_packet_l4_offset_set(pkt, itp->l4_offset));
odp_packet_user_ptr_set(pkt, PACKET_USER_PTR);
@@ -568,11 +563,9 @@ static void check_l2_header(const ipsec_test_packet *itp, odp_packet_t pkt)
CU_ASSERT_FATAL(l2 != ODP_PACKET_OFFSET_INVALID);
CU_ASSERT_FATAL(l3 != ODP_PACKET_OFFSET_INVALID);
- CU_ASSERT_EQUAL(l3 - l2, hdr_len);
+ CU_ASSERT(l3 - l2 == hdr_len);
odp_packet_copy_to_mem(pkt, 0, len, data);
- CU_ASSERT_EQUAL(0, memcmp(data + l2,
- itp->data + itp->l2_offset,
- hdr_len));
+ CU_ASSERT(0 == memcmp(data + l2, itp->data + itp->l2_offset, hdr_len));
}
/*
@@ -595,17 +588,17 @@ static void ipsec_check_packet(const ipsec_test_packet *itp, odp_packet_t pkt,
odp_packet_copy_to_mem(pkt, 0, len, data);
if (l3 == ODP_PACKET_OFFSET_INVALID) {
- CU_ASSERT_EQUAL(itp->l3_offset, ODP_PACKET_OFFSET_INVALID);
- CU_ASSERT_EQUAL(l4, ODP_PACKET_OFFSET_INVALID);
+ CU_ASSERT(itp->l3_offset == ODP_PACKET_OFFSET_INVALID);
+ CU_ASSERT(l4 == ODP_PACKET_OFFSET_INVALID);
return;
}
- CU_ASSERT_EQUAL(len - l3, itp->len - itp->l3_offset);
+ CU_ASSERT(len - l3 == itp->len - itp->l3_offset);
if (len - l3 != itp->len - itp->l3_offset)
return;
- CU_ASSERT_EQUAL(l4 - l3, itp->l4_offset - itp->l3_offset);
+ CU_ASSERT(l4 - l3 == itp->l4_offset - itp->l3_offset);
if (l4 - l3 != itp->l4_offset - itp->l3_offset)
return;
@@ -634,16 +627,13 @@ static void ipsec_check_packet(const ipsec_test_packet *itp, odp_packet_t pkt,
* Check packet data before the first possible
* location of the AH ICV field.
*/
- CU_ASSERT_EQUAL(0, memcmp(data + l3,
- itp->data + itp->l3_offset,
- ODPH_IPV4HDR_LEN + 12));
+ CU_ASSERT(0 == memcmp(data + l3, itp->data + itp->l3_offset,
+ ODPH_IPV4HDR_LEN + 12));
return;
}
}
- CU_ASSERT_EQUAL(0, memcmp(data + l3,
- itp->data + itp->l3_offset,
- len - l3));
+ CU_ASSERT(0 == memcmp(data + l3, itp->data + itp->l3_offset, len - l3));
}
static int send_pkts(const ipsec_test_part part[], int num_part)
@@ -660,7 +650,7 @@ static int send_pkts(const ipsec_test_part part[], int num_part)
for (i = 0; i < num_part; i++)
pkt[i] = ipsec_packet(part[i].pkt_in);
- CU_ASSERT_EQUAL(num_part, odp_pktout_send(pktout, pkt, num_part));
+ CU_ASSERT(num_part == odp_pktout_send(pktout, pkt, num_part));
return num_part;
}
@@ -689,8 +679,7 @@ static int recv_pkts_inline(const ipsec_test_part *part,
odp_queue_t queue = ODP_QUEUE_INVALID;
int i;
- CU_ASSERT_EQUAL_FATAL(1, odp_pktin_event_queue(suite_context.pktio,
- &queue, 1));
+ CU_ASSERT_FATAL(1 == odp_pktin_event_queue(suite_context.pktio, &queue, 1));
for (i = 0; i < part->num_pkt;) {
odp_event_t ev;
@@ -699,10 +688,8 @@ static int recv_pkts_inline(const ipsec_test_part *part,
ev = recv_event(queue, 0);
if (ODP_EVENT_INVALID != ev) {
CU_ASSERT(odp_event_is_valid(ev) == 1);
- CU_ASSERT_EQUAL(ODP_EVENT_PACKET,
- odp_event_types(ev, &subtype));
- CU_ASSERT_EQUAL(ODP_EVENT_PACKET_BASIC,
- subtype);
+ CU_ASSERT(ODP_EVENT_PACKET == odp_event_types(ev, &subtype));
+ CU_ASSERT(ODP_EVENT_PACKET_BASIC == subtype);
CU_ASSERT(part->out[i].status.error.sa_lookup);
pkto[i] = odp_packet_from_event(ev);
@@ -722,7 +709,7 @@ static int recv_pkts_inline(const ipsec_test_part *part,
int j;
CU_ASSERT(odp_event_is_valid(ev) == 1);
- CU_ASSERT_EQUAL(ODP_EVENT_PACKET, odp_event_type(ev));
+ CU_ASSERT(ODP_EVENT_PACKET == odp_event_type(ev));
pkt = odp_packet_from_event(ev);
CU_ASSERT(!part->out[i].status.error.sa_lookup);
@@ -785,10 +772,8 @@ static int ipsec_process_in(const ipsec_test_part *part,
if (ODP_IPSEC_OP_MODE_SYNC == suite_context.inbound_op_mode) {
pkt = ipsec_packet(part->pkt_in);
- CU_ASSERT_EQUAL(part->num_pkt, odp_ipsec_in(&pkt, 1,
- pkto, &num_out,
- &param));
- CU_ASSERT_EQUAL(num_out, part->num_pkt);
+ CU_ASSERT(part->num_pkt == odp_ipsec_in(&pkt, 1, pkto, &num_out, &param));
+ CU_ASSERT(num_out == part->num_pkt);
CU_ASSERT_FATAL(*pkto != ODP_PACKET_INVALID);
CU_ASSERT(odp_packet_subtype(*pkto) == ODP_EVENT_PACKET_IPSEC);
} else if (ODP_IPSEC_OP_MODE_ASYNC == suite_context.inbound_op_mode) {
@@ -796,7 +781,7 @@ static int ipsec_process_in(const ipsec_test_part *part,
pkt = ipsec_packet(part->pkt_in);
consumed = odp_ipsec_in_enq(&pkt, 1, &param);
- CU_ASSERT_EQUAL(1, consumed);
+ CU_ASSERT(1 == consumed);
if (consumed <= 0)
num_out = 0;
@@ -807,18 +792,17 @@ static int ipsec_process_in(const ipsec_test_part *part,
event = recv_pkt_async_inbound(part->out[i].status);
CU_ASSERT(odp_event_is_valid(event) == 1);
- CU_ASSERT_EQUAL(ODP_EVENT_PACKET,
- odp_event_types(event, &subtype));
- CU_ASSERT_EQUAL(ODP_EVENT_PACKET_IPSEC, subtype);
+ CU_ASSERT(ODP_EVENT_PACKET == odp_event_types(event, &subtype));
+ CU_ASSERT(ODP_EVENT_PACKET_IPSEC == subtype);
pkto[i] = odp_ipsec_packet_from_event(event);
CU_ASSERT_FATAL(pkto[i] != ODP_PACKET_INVALID);
CU_ASSERT(odp_packet_subtype(pkto[i]) ==
ODP_EVENT_PACKET_IPSEC);
}
} else {
- CU_ASSERT_EQUAL(1, send_pkts(part, 1));
+ CU_ASSERT(1 == send_pkts(part, 1));
if (part->num_pkt)
- CU_ASSERT_EQUAL(part->num_pkt, recv_pkts_inline(part, pkto));
+ CU_ASSERT(part->num_pkt == recv_pkts_inline(part, pkto));
}
return num_out;
@@ -881,14 +865,13 @@ static int ipsec_send_out_one(const ipsec_test_part *part,
param.opt = &part->opt;
if (ODP_IPSEC_OP_MODE_SYNC == suite_context.outbound_op_mode) {
- CU_ASSERT_EQUAL(1, odp_ipsec_out(&pkt, 1, pkto, &num_out,
- &param));
+ CU_ASSERT(1 == odp_ipsec_out(&pkt, 1, pkto, &num_out, &param));
CU_ASSERT_FATAL(num_out == 1);
CU_ASSERT_FATAL(*pkto != ODP_PACKET_INVALID);
CU_ASSERT(odp_packet_subtype(*pkto) == ODP_EVENT_PACKET_IPSEC);
} else if (ODP_IPSEC_OP_MODE_ASYNC == suite_context.outbound_op_mode) {
num_out = odp_ipsec_out_enq(&pkt, 1, &param);
- CU_ASSERT_EQUAL(1, num_out);
+ CU_ASSERT(1 == num_out);
num_out = (num_out == 1) ? 1 : 0;
@@ -899,9 +882,8 @@ static int ipsec_send_out_one(const ipsec_test_part *part,
event = recv_event(suite_context.queue, EVENT_WAIT_TIME);
CU_ASSERT(odp_event_is_valid(event) == 1);
- CU_ASSERT_EQUAL(ODP_EVENT_PACKET,
- odp_event_types(event, &subtype));
- CU_ASSERT_EQUAL(ODP_EVENT_PACKET_IPSEC, subtype);
+ CU_ASSERT(ODP_EVENT_PACKET == odp_event_types(event, &subtype));
+ CU_ASSERT(ODP_EVENT_PACKET_IPSEC == subtype);
pkto[i] = odp_ipsec_packet_from_event(event);
CU_ASSERT_FATAL(pkto[i] != ODP_PACKET_INVALID);
CU_ASSERT(odp_packet_subtype(pkto[i]) ==
@@ -967,12 +949,8 @@ static int ipsec_send_out_one(const ipsec_test_part *part,
inline_param.tm_queue = ODP_TM_INVALID;
inline_param.outer_hdr.len = hdr_len;
- CU_ASSERT_EQUAL(1, odp_ipsec_out_inline(&pkt, 1, &param,
- &inline_param));
- CU_ASSERT_EQUAL_FATAL(1,
- odp_pktin_event_queue(suite_context.
- pktio,
- &queue, 1));
+ CU_ASSERT(1 == odp_ipsec_out_inline(&pkt, 1, &param, &inline_param));
+ CU_ASSERT_FATAL(1 == odp_pktin_event_queue(suite_context.pktio, &queue, 1));
for (i = 0; i < num_out;) {
odp_event_t ev;
@@ -981,10 +959,8 @@ static int ipsec_send_out_one(const ipsec_test_part *part,
ev = recv_event(queue, 0);
if (ODP_EVENT_INVALID != ev) {
CU_ASSERT(odp_event_is_valid(ev) == 1);
- CU_ASSERT_EQUAL(ODP_EVENT_PACKET,
- odp_event_types(ev, &subtype));
- CU_ASSERT_EQUAL(ODP_EVENT_PACKET_BASIC,
- subtype);
+ CU_ASSERT(ODP_EVENT_PACKET == odp_event_types(ev, &subtype));
+ CU_ASSERT(ODP_EVENT_PACKET_BASIC == subtype);
CU_ASSERT(!part->out[i].status.error.all);
pkto[i] = odp_packet_from_event(ev);
@@ -1010,10 +986,8 @@ static int ipsec_send_out_one(const ipsec_test_part *part,
continue;
}
- CU_ASSERT_EQUAL(ODP_EVENT_PACKET,
- ev_type);
- CU_ASSERT_EQUAL(ODP_EVENT_PACKET_IPSEC,
- subtype);
+ CU_ASSERT(ODP_EVENT_PACKET == ev_type);
+ CU_ASSERT(ODP_EVENT_PACKET_IPSEC == subtype);
/* In the case of SA hard expiry tests, hard expiry error bits are
* expected to be set. The exact error bits expected to be set based
@@ -1053,9 +1027,8 @@ static void ipsec_pkt_seq_num_check(odp_packet_t pkt, uint32_t seq_num)
uint32_t l4_off;
odph_ipv4hdr_t ip;
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_PACKET_OFFSET_INVALID, l3_off);
- CU_ASSERT_EQUAL_FATAL(0, odp_packet_copy_to_mem(pkt, l3_off, sizeof(ip),
- &ip));
+ CU_ASSERT_FATAL(ODP_PACKET_OFFSET_INVALID != l3_off);
+ CU_ASSERT_FATAL(0 == odp_packet_copy_to_mem(pkt, l3_off, sizeof(ip), &ip));
if (ODPH_IPV4HDR_VER(ip.ver_ihl) == ODPH_IPV4) {
l4_off = l3_off + (ODPH_IPV4HDR_IHL(ip.ver_ihl) * 4);
@@ -1064,12 +1037,12 @@ static void ipsec_pkt_seq_num_check(odp_packet_t pkt, uint32_t seq_num)
odph_esphdr_t esp;
odp_packet_copy_to_mem(pkt, l4_off, sizeof(esp), &esp);
- CU_ASSERT_EQUAL(odp_be_to_cpu_32(esp.seq_no), seq_num);
+ CU_ASSERT(odp_be_to_cpu_32(esp.seq_no) == seq_num);
} else if (ip.proto == ODPH_IPPROTO_AH) {
odph_ahhdr_t ah;
odp_packet_copy_to_mem(pkt, l4_off, sizeof(ah), &ah);
- CU_ASSERT_EQUAL(odp_be_to_cpu_32(ah.seq_no), seq_num);
+ CU_ASSERT(odp_be_to_cpu_32(ah.seq_no) == seq_num);
} else {
CU_FAIL("Unexpected IP Proto");
}
@@ -1092,11 +1065,10 @@ static void verify_in(const ipsec_test_part *part,
if (ODP_EVENT_PACKET_IPSEC !=
odp_event_subtype(odp_packet_to_event(pkto[i]))) {
/* Inline packet failed SA lookup */
- CU_ASSERT_EQUAL(1, part->out[i].status.error.sa_lookup);
+ CU_ASSERT(1 == part->out[i].status.error.sa_lookup);
} else {
- CU_ASSERT_EQUAL(0, odp_ipsec_result(&result, pkto[i]));
- CU_ASSERT_EQUAL(part->out[i].status.error.all,
- result.status.error.all);
+ CU_ASSERT(0 == odp_ipsec_result(&result, pkto[i]));
+ CU_ASSERT(part->out[i].status.error.all == result.status.error.all);
if (part->out[i].status.error.all != 0) {
odp_packet_free(pkto[i]);
@@ -1104,17 +1076,13 @@ static void verify_in(const ipsec_test_part *part,
}
if (0 == result.status.error.all)
- CU_ASSERT_EQUAL(0,
- odp_packet_has_error(pkto[i]));
- CU_ASSERT_EQUAL(suite_context.inbound_op_mode ==
- ODP_IPSEC_OP_MODE_INLINE,
- result.flag.inline_mode);
- CU_ASSERT_EQUAL(sa, result.sa);
- CU_ASSERT_EQUAL(part->out[i].status.warn.all,
- result.status.warn.all);
+ CU_ASSERT(0 == odp_packet_has_error(pkto[i]));
+ CU_ASSERT((suite_context.inbound_op_mode == ODP_IPSEC_OP_MODE_INLINE) ==
+ result.flag.inline_mode);
+ CU_ASSERT(sa == result.sa);
+ CU_ASSERT(part->out[i].status.warn.all == result.status.warn.all);
if (ODP_IPSEC_SA_INVALID != sa)
- CU_ASSERT_EQUAL(IPSEC_SA_CTX,
- odp_ipsec_sa_context(sa));
+ CU_ASSERT(IPSEC_SA_CTX == odp_ipsec_sa_context(sa));
if (suite_context.inbound_op_mode != ODP_IPSEC_OP_MODE_SYNC) {
uint32_t len;
@@ -1135,12 +1103,10 @@ static void verify_in(const ipsec_test_part *part,
if (part->out[i].pkt_res != NULL &&
part->out[i].l3_type != _ODP_PROTO_L3_TYPE_UNDEF)
- CU_ASSERT_EQUAL(part->out[i].l3_type,
- odp_packet_l3_type(pkto[i]));
+ CU_ASSERT(part->out[i].l3_type == odp_packet_l3_type(pkto[i]));
if (part->out[i].pkt_res != NULL &&
part->out[i].l4_type != _ODP_PROTO_L4_TYPE_UNDEF)
- CU_ASSERT_EQUAL(part->out[i].l4_type,
- odp_packet_l4_type(pkto[i]));
+ CU_ASSERT(part->out[i].l4_type == odp_packet_l4_type(pkto[i]));
odp_packet_free(pkto[i]);
}
}
@@ -1180,26 +1146,23 @@ int ipsec_check_out(const ipsec_test_part *part, odp_ipsec_sa_t sa,
if (ODP_EVENT_PACKET_IPSEC !=
odp_event_subtype(odp_packet_to_event(pkto[i]))) {
/* Inline packet went through loop */
- CU_ASSERT_EQUAL(0, part->out[i].status.error.all);
+ CU_ASSERT(0 == part->out[i].status.error.all);
CU_ASSERT(odp_packet_user_ptr(pkto[i]) == NULL);
/* L2 header must match the requested one */
check_l2_header(part->out[i].pkt_res, pkto[i]);
} else {
/* IPsec packet */
- CU_ASSERT_EQUAL(0, odp_ipsec_result(&result, pkto[i]));
+ CU_ASSERT(0 == odp_ipsec_result(&result, pkto[i]));
if (part->out[i].sa_expiry != IPSEC_TEST_EXPIRY_NONE)
if (ipsec_check_sa_expiry(part->out[i].sa_expiry, &result) != 0)
return num_out;
- CU_ASSERT_EQUAL(part->out[i].status.error.all,
- result.status.error.all);
+ CU_ASSERT(part->out[i].status.error.all == result.status.error.all);
if (0 == result.status.error.all)
- CU_ASSERT_EQUAL(0,
- odp_packet_has_error(pkto[i]));
- CU_ASSERT_EQUAL(sa, result.sa);
- CU_ASSERT_EQUAL(IPSEC_SA_CTX,
- odp_ipsec_sa_context(sa));
+ CU_ASSERT(0 == odp_packet_has_error(pkto[i]));
+ CU_ASSERT(sa == result.sa);
+ CU_ASSERT(IPSEC_SA_CTX == odp_ipsec_sa_context(sa));
CU_ASSERT(odp_packet_user_ptr(pkto[i]) == PACKET_USER_PTR);
/* Parse the packet to set L4 offset and type */
@@ -1236,7 +1199,7 @@ void ipsec_check_in_one(const ipsec_test_part *part, odp_ipsec_sa_t sa)
int num_out;
num_out = ipsec_process_in(part, sa, pkto);
- CU_ASSERT_EQUAL(num_out, part->num_pkt);
+ CU_ASSERT(num_out == part->num_pkt);
verify_in(part, sa, pkto);
}
diff --git a/test/validation/api/ipsec/ipsec.h b/test/validation/api/ipsec/ipsec.h
index 47612e3b3..3daa364cc 100644
--- a/test/validation/api/ipsec/ipsec.h
+++ b/test/validation/api/ipsec/ipsec.h
@@ -1,9 +1,7 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2020, Marvell
- * Copyright (c) 2020, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2020 Marvell
+ * Copyright (c) 2020 Nokia
*/
#ifndef _ODP_TEST_IPSEC_H_
diff --git a/test/validation/api/ipsec/ipsec_test_in.c b/test/validation/api/ipsec/ipsec_test_in.c
index b5251544e..a93bf9f2a 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -1,9 +1,7 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2020-2021, Marvell
- * Copyright (c) 2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2020-2021 Marvell
+ * Copyright (c) 2021 Nokia
*/
#include <odp/helper/odph_api.h>
@@ -62,7 +60,7 @@ static void test_in_ipv4_ah_sha256(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_ah_sha256_1,
@@ -97,7 +95,7 @@ static void test_in_ipv4_ah_sha256_tun_ipv4(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_ah_tun_ipv4_sha256_1,
@@ -132,7 +130,7 @@ static void test_in_ipv4_ah_sha256_tun_ipv6(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_ah_tun_ipv6_sha256_1,
@@ -164,7 +162,7 @@ static void test_in_ipv4_ah_sha256_tun_ipv4_notun(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_ah_tun_ipv4_sha256_1,
@@ -197,7 +195,7 @@ static void test_in_ipv4_esp_null_sha256(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_null_sha256_1,
@@ -229,7 +227,7 @@ static void test_in_ipv4_esp_aes_cbc_null(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_aes_cbc_null_1,
@@ -261,7 +259,7 @@ static void test_in_ipv4_esp_aes_cbc_sha1(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_aes_cbc_sha1_1,
@@ -293,7 +291,7 @@ static void test_in_ipv4_esp_aes_cbc_sha256(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_aes_cbc_sha256_1,
@@ -325,7 +323,7 @@ static void test_in_ipv4_esp_aes_cbc_sha384(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_aes_cbc_sha384_1,
@@ -357,7 +355,7 @@ static void test_in_ipv4_esp_aes_cbc_sha512(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_aes_cbc_sha512_1,
@@ -389,7 +387,7 @@ static void test_in_ipv4_esp_aes_ctr_null(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_aes_ctr_null_1,
@@ -421,7 +419,7 @@ static void test_in_ipv4_ah_sha256_lookup(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_ah_sha256_1,
@@ -456,7 +454,7 @@ static void test_in_ipv4_esp_null_sha256_lookup(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_null_sha256_1,
@@ -494,7 +492,7 @@ static void test_in_ipv4_esp_null_sha256_tun_ipv4(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_tun_ipv4_null_sha256_1,
@@ -529,7 +527,7 @@ static void test_in_ipv4_esp_null_sha256_tun_ipv6(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_tun_ipv6_null_sha256_1,
@@ -562,7 +560,7 @@ static void test_in_ipv4_esp_udp_null_sha256(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_udp_null_sha256_1,
@@ -595,7 +593,7 @@ static void test_in_ipv4_esp_udp_null_sha256_lookup(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_udp_null_sha256_1,
@@ -631,7 +629,7 @@ static void test_in_ipv4_ah_sha256_noreplay(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_ah_sha256_1,
@@ -682,7 +680,7 @@ static void test_in_ipv4_ah_sha256_replay(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_ah_sha256_1,
@@ -734,7 +732,7 @@ static void test_in_ipv4_esp_null_sha256_noreplay(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_null_sha256_1,
@@ -785,7 +783,7 @@ static void test_in_ipv4_esp_null_sha256_replay(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_null_sha256_1,
@@ -844,7 +842,7 @@ static void test_in_ipv4_ah_esp_pkt(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
test.pkt_in = &pkt_ipv4_icmp_0_esp_null_sha256_1;
test.num_pkt = 1;
@@ -876,7 +874,7 @@ static void test_in_ipv4_esp_ah_pkt(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
test.pkt_in = &pkt_ipv4_icmp_0_ah_sha256_1;
test.num_pkt = 1;
@@ -903,7 +901,7 @@ static void test_in_ipv4_ah_esp_pkt_lookup(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
test.pkt_in = &pkt_ipv4_icmp_0_esp_null_sha256_1;
test.flags.lookup = 1;
@@ -931,7 +929,7 @@ static void test_in_ipv4_esp_ah_pkt_lookup(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
test.pkt_in = &pkt_ipv4_icmp_0_ah_sha256_1;
test.flags.lookup = 1;
@@ -959,7 +957,7 @@ static void test_in_ipv4_ah_sha256_bad1(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
test.pkt_in = &pkt_ipv4_icmp_0_ah_sha256_1_bad1;
test.num_pkt = 1;
@@ -986,7 +984,7 @@ static void test_in_ipv4_ah_sha256_bad2(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
test.pkt_in = &pkt_ipv4_icmp_0_ah_sha256_1_bad2;
test.num_pkt = 1;
@@ -1013,7 +1011,7 @@ static void test_in_ipv4_esp_null_sha256_bad1(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
test.pkt_in = &pkt_ipv4_icmp_0_esp_null_sha256_1_bad1;
test.num_pkt = 1;
@@ -1037,7 +1035,7 @@ static void test_in_ipv4_rfc3602_5_esp(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_rfc3602_5_esp,
@@ -1069,7 +1067,7 @@ static void test_in_ipv4_rfc3602_6_esp(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_rfc3602_6_esp,
@@ -1105,7 +1103,7 @@ static void test_in_ipv4_rfc3602_7_esp(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_rfc3602_7_esp,
@@ -1141,7 +1139,7 @@ static void test_in_ipv4_rfc3602_8_esp(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_rfc3602_8_esp,
@@ -1177,7 +1175,7 @@ static void test_in_ipv4_mcgrew_gcm_2_esp(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_mcgrew_gcm_test_2_esp,
@@ -1213,7 +1211,7 @@ static void test_in_ipv4_mcgrew_gcm_3_esp(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_mcgrew_gcm_test_3_esp,
@@ -1249,7 +1247,7 @@ static void test_in_ipv4_mcgrew_gcm_4_esp(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_mcgrew_gcm_test_4_esp,
@@ -1290,7 +1288,7 @@ static void test_in_ipv4_mcgrew_gcm_12_esp(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_mcgrew_gcm_test_12_esp,
@@ -1323,7 +1321,7 @@ static void test_in_ipv4_mcgrew_gcm_12_esp_notun(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_mcgrew_gcm_test_12_esp,
@@ -1359,7 +1357,7 @@ static void test_in_ipv4_mcgrew_gcm_15_esp(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_mcgrew_gcm_test_15_esp,
@@ -1395,7 +1393,7 @@ static void test_in_ipv4_rfc7634_chacha(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_rfc7634_esp,
@@ -1427,7 +1425,7 @@ static void test_in_ipv4_ah_aes_gmac_128(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_ah_aes_gmac_128_1,
@@ -1459,7 +1457,7 @@ static void test_in_ipv4_esp_null_aes_gmac_128(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0_esp_null_aes_gmac_128_1,
@@ -1491,7 +1489,7 @@ static void test_in_ipv6_ah_sha256(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0_ah_sha256_1,
@@ -1526,7 +1524,7 @@ static void test_in_ipv6_ah_sha256_tun_ipv4(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0_ah_tun_ipv4_sha256_1,
@@ -1561,7 +1559,7 @@ static void test_in_ipv6_ah_sha256_tun_ipv6(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0_ah_tun_ipv6_sha256_1,
@@ -1593,7 +1591,7 @@ static void test_in_ipv6_esp_null_sha256(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0_esp_null_sha256_1,
@@ -1628,7 +1626,7 @@ static void test_in_ipv6_esp_null_sha256_tun_ipv4(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0_esp_tun_ipv4_null_sha256_1,
@@ -1663,7 +1661,7 @@ static void test_in_ipv6_esp_null_sha256_tun_ipv6(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0_esp_tun_ipv6_null_sha256_1,
@@ -1696,7 +1694,7 @@ static void test_in_ipv6_esp_udp_null_sha256(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0_esp_udp_null_sha256_1,
@@ -1729,7 +1727,7 @@ static void test_in_ipv6_esp_udp_null_sha256_lookup(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0_esp_udp_null_sha256_1,
@@ -1769,7 +1767,7 @@ static void test_ipsec_sa_print(void)
in_sa = odp_ipsec_sa_create(&param_in);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, in_sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != in_sa);
odp_ipsec_sa_print(in_sa);
@@ -1802,7 +1800,7 @@ static void test_multi_out_in(odp_ipsec_sa_t out_sa,
*/
part_prep_esp(&test_out, 1, tunnel_ip_ver == ODPH_IPV6);
test_out.pkt_in = input_packets[i];
- CU_ASSERT_EQUAL(ipsec_check_out(&test_out, out_sa, &pkt), 1);
+ CU_ASSERT(ipsec_check_out(&test_out, out_sa, &pkt) == 1);
/*
* Perform inbound IPsec processing for the IPsec packet.
@@ -1952,10 +1950,10 @@ static void test_in_ipv4_esp_reass_success(void)
param_in.inbound.reassembly_en = 1;
out_sa = odp_ipsec_sa_create(&param_out);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, out_sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != out_sa);
in_sa = odp_ipsec_sa_create(&param_in);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, in_sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != in_sa);
printf("\n IPv4 two frags");
test_in_ipv4_esp_reass_success_two_frags(out_sa, in_sa);
@@ -2007,10 +2005,10 @@ static void test_in_ipv4_esp_reass_incomp(void)
param_in.inbound.reassembly_en = 1;
out_sa = odp_ipsec_sa_create(&param_out);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, out_sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != out_sa);
in_sa = odp_ipsec_sa_create(&param_in);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, in_sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != in_sa);
printf("\n IPv4 missing frag");
test_in_ipv4_esp_reass_incomp_missing(out_sa, in_sa);
@@ -2141,10 +2139,10 @@ static void test_in_ipv6_esp_reass_success(void)
param_in.inbound.reassembly_en = 1;
out_sa = odp_ipsec_sa_create(&param_out);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, out_sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != out_sa);
in_sa = odp_ipsec_sa_create(&param_in);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, in_sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != in_sa);
printf("\n IPv6 two frags");
test_in_ipv6_esp_reass_success_two_frags(out_sa, in_sa);
@@ -2200,10 +2198,10 @@ static void test_in_ipv6_esp_reass_incomp(void)
param_in.inbound.reassembly_en = 1;
out_sa = odp_ipsec_sa_create(&param_out);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, out_sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != out_sa);
in_sa = odp_ipsec_sa_create(&param_in);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, in_sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != in_sa);
printf("\n IPv6 missing frag");
test_in_ipv6_esp_reass_incomp_missing(out_sa, in_sa);
@@ -2231,7 +2229,7 @@ static void test_in_ipv4_null_aes_xcbc_esp(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_null_aes_xcbc_esp,
diff --git a/test/validation/api/ipsec/ipsec_test_out.c b/test/validation/api/ipsec/ipsec_test_out.c
index ca8bf97a5..fea66b630 100644
--- a/test/validation/api/ipsec/ipsec_test_out.c
+++ b/test/validation/api/ipsec/ipsec_test_out.c
@@ -1,9 +1,7 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2020, Marvell
- * Copyright (c) 2020-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2020 Marvell
+ * Copyright (c) 2020-2022 Nokia
*/
#include <odp/helper/odph_api.h>
@@ -145,7 +143,7 @@ static void test_out_ipv4_ah_sha256(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0,
@@ -184,7 +182,7 @@ static void test_out_ipv4_ah_sha256_tun_ipv4(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0,
@@ -229,7 +227,7 @@ static void test_out_ipv4_ah_sha256_tun_ipv6(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0,
@@ -259,7 +257,7 @@ static void test_out_ipv4_esp_null_sha256(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0,
@@ -298,7 +296,7 @@ static void test_out_ipv4_esp_null_sha256_tun_ipv4(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0,
@@ -344,7 +342,7 @@ static void test_out_ipv4_esp_null_sha256_tun_ipv6(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0,
@@ -364,15 +362,15 @@ static void test_out_ipv4_esp_null_sha256_tun_ipv6(void)
static void test_ipsec_stats_zero_assert(odp_ipsec_stats_t *stats)
{
- CU_ASSERT_EQUAL(stats->success, 0);
- CU_ASSERT_EQUAL(stats->proto_err, 0);
- CU_ASSERT_EQUAL(stats->auth_err, 0);
- CU_ASSERT_EQUAL(stats->antireplay_err, 0);
- CU_ASSERT_EQUAL(stats->alg_err, 0);
- CU_ASSERT_EQUAL(stats->mtu_err, 0);
- CU_ASSERT_EQUAL(stats->hard_exp_bytes_err, 0);
- CU_ASSERT_EQUAL(stats->hard_exp_pkts_err, 0);
- CU_ASSERT_EQUAL(stats->success_bytes, 0);
+ CU_ASSERT(stats->success == 0);
+ CU_ASSERT(stats->proto_err == 0);
+ CU_ASSERT(stats->auth_err == 0);
+ CU_ASSERT(stats->antireplay_err == 0);
+ CU_ASSERT(stats->alg_err == 0);
+ CU_ASSERT(stats->mtu_err == 0);
+ CU_ASSERT(stats->hard_exp_bytes_err == 0);
+ CU_ASSERT(stats->hard_exp_pkts_err == 0);
+ CU_ASSERT(stats->success_bytes == 0);
}
static void test_ipsec_stats_test_assert(odp_ipsec_stats_t *stats,
@@ -380,34 +378,34 @@ static void test_ipsec_stats_test_assert(odp_ipsec_stats_t *stats,
uint64_t succ_bytes)
{
if (test == IPSEC_TEST_STATS_SUCCESS) {
- CU_ASSERT_EQUAL(stats->success, 1);
+ CU_ASSERT(stats->success == 1);
CU_ASSERT(stats->success_bytes >= succ_bytes);
} else {
- CU_ASSERT_EQUAL(stats->success, 0);
- CU_ASSERT_EQUAL(stats->success_bytes, 0);
+ CU_ASSERT(stats->success == 0);
+ CU_ASSERT(stats->success_bytes == 0);
}
if (test == IPSEC_TEST_STATS_PROTO_ERR) {
/* Braces needed by CU macro */
- CU_ASSERT_EQUAL(stats->proto_err, 1);
+ CU_ASSERT(stats->proto_err == 1);
} else {
/* Braces needed by CU macro */
- CU_ASSERT_EQUAL(stats->proto_err, 0);
+ CU_ASSERT(stats->proto_err == 0);
}
if (test == IPSEC_TEST_STATS_AUTH_ERR) {
/* Braces needed by CU macro */
- CU_ASSERT_EQUAL(stats->auth_err, 1);
+ CU_ASSERT(stats->auth_err == 1);
} else {
/* Braces needed by CU macro */
- CU_ASSERT_EQUAL(stats->auth_err, 0);
+ CU_ASSERT(stats->auth_err == 0);
}
- CU_ASSERT_EQUAL(stats->antireplay_err, 0);
- CU_ASSERT_EQUAL(stats->alg_err, 0);
- CU_ASSERT_EQUAL(stats->mtu_err, 0);
- CU_ASSERT_EQUAL(stats->hard_exp_bytes_err, 0);
- CU_ASSERT_EQUAL(stats->hard_exp_pkts_err, 0);
+ CU_ASSERT(stats->antireplay_err == 0);
+ CU_ASSERT(stats->alg_err == 0);
+ CU_ASSERT(stats->mtu_err == 0);
+ CU_ASSERT(stats->hard_exp_bytes_err == 0);
+ CU_ASSERT(stats->hard_exp_pkts_err == 0);
}
static void ipsec_pkt_proto_err_set(odp_packet_t pkt)
@@ -527,7 +525,7 @@ static void test_out_in_common(const ipsec_test_flags *flags,
odp_proto_l3_type_t out_l3_type = ODP_PROTO_L3_TYPE_IPV4;
odp_proto_l4_type_t out_l4_type = ODP_PROTO_L4_TYPE_ESP;
- CU_ASSERT_NOT_EQUAL_FATAL(flags, NULL);
+ CU_ASSERT_FATAL(flags != NULL);
/* ICV won't be generated for NULL AUTH */
if ((flags->stats == IPSEC_TEST_STATS_AUTH_ERR) &&
@@ -566,7 +564,7 @@ static void test_out_in_common(const ipsec_test_flags *flags,
if (sa_out == ODP_IPSEC_SA_INVALID && sa_creation_failure_ok(&param))
return;
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa_out);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa_out);
ipsec_sa_param_fill(&param,
ODP_IPSEC_DIR_INBOUND, proto, 123, tun_ptr,
@@ -579,7 +577,7 @@ static void test_out_in_common(const ipsec_test_flags *flags,
sa_in = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa_in);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa_in);
if ((flags->tunnel && flags->tunnel_is_v6) ||
(!flags->tunnel && flags->v6))
@@ -627,9 +625,9 @@ static void test_out_in_common(const ipsec_test_flags *flags,
test_in.out[0].status.error.auth = 1;
if (flags->stats != IPSEC_TEST_STATS_NONE) {
- CU_ASSERT_EQUAL(odp_ipsec_stats(sa_out, &stats), 0);
+ CU_ASSERT(odp_ipsec_stats(sa_out, &stats) == 0);
test_ipsec_stats_zero_assert(&stats);
- CU_ASSERT_EQUAL(odp_ipsec_stats(sa_in, &stats), 0);
+ CU_ASSERT(odp_ipsec_stats(sa_in, &stats) == 0);
test_ipsec_stats_zero_assert(&stats);
}
@@ -675,11 +673,11 @@ static void test_out_in_common(const ipsec_test_flags *flags,
/* All stats tests have outbound operation success and inbound
* varying.
*/
- CU_ASSERT_EQUAL(odp_ipsec_stats(sa_out, &stats), 0);
+ CU_ASSERT(odp_ipsec_stats(sa_out, &stats) == 0);
test_ipsec_stats_test_assert(&stats, IPSEC_TEST_STATS_SUCCESS,
succ_bytes);
- CU_ASSERT_EQUAL(odp_ipsec_stats(sa_in, &stats), 0);
+ CU_ASSERT(odp_ipsec_stats(sa_in, &stats) == 0);
test_ipsec_stats_test_assert(&stats, flags->stats, succ_bytes);
}
@@ -815,7 +813,7 @@ static void test_out_ipv4_esp_udp_null_sha256(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_icmp_0,
@@ -852,7 +850,7 @@ static void test_out_ipv4_ah_sha256_frag_check(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
test.pkt_in = &pkt_ipv4_icmp_0;
test.num_pkt = 1;
@@ -892,7 +890,7 @@ static void test_out_ipv4_ah_sha256_frag_check_2(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
test.pkt_in = &pkt_ipv4_icmp_0;
test.num_pkt = 1;
@@ -940,7 +938,7 @@ static void test_out_ipv4_esp_null_sha256_frag_check(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
test.pkt_in = &pkt_ipv4_icmp_0;
test.num_pkt = 1;
@@ -981,7 +979,7 @@ static void test_out_ipv4_esp_null_sha256_frag_check_2(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
test.pkt_in = &pkt_ipv4_icmp_0;
test.num_pkt = 1;
@@ -1021,7 +1019,7 @@ static void test_out_ipv6_ah_sha256(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0,
@@ -1060,7 +1058,7 @@ static void test_out_ipv6_ah_sha256_tun_ipv4(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0,
@@ -1105,7 +1103,7 @@ static void test_out_ipv6_ah_sha256_tun_ipv6(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0,
@@ -1135,7 +1133,7 @@ static void test_out_ipv6_esp_null_sha256(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0,
@@ -1174,7 +1172,7 @@ static void test_out_ipv6_esp_null_sha256_tun_ipv4(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0,
@@ -1220,7 +1218,7 @@ static void test_out_ipv6_esp_null_sha256_tun_ipv6(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0,
@@ -1252,7 +1250,7 @@ static void test_out_ipv6_esp_udp_null_sha256(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv6_icmp_0,
@@ -1299,7 +1297,7 @@ static void test_out_dummy_esp_null_sha256_tun(odp_ipsec_tunnel_param_t tunnel)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_sa_param_fill(&param,
ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP, 123, &tunnel,
@@ -1309,7 +1307,7 @@ static void test_out_dummy_esp_null_sha256_tun(odp_ipsec_tunnel_param_t tunnel)
sa2 = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa2);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa2);
test.pkt_in = &pkt_test_nodata;
test.num_opt = 1;
@@ -1387,7 +1385,7 @@ static void test_out_ipv4_udp_esp_null_sha256(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_udp,
@@ -1429,7 +1427,7 @@ static void test_out_ipv4_null_aes_xcbc(void)
sa = odp_ipsec_sa_create(&param);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa);
ipsec_test_part test = {
.pkt_in = &pkt_ipv4_null_aes_xcbc_plain,
@@ -1478,7 +1476,7 @@ static void test_sa_info(void)
sa_out = odp_ipsec_sa_create(&param_out);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa_out);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != sa_out);
ipsec_sa_param_fill(&param_in,
ODP_IPSEC_DIR_INBOUND, ODP_IPSEC_ESP,
@@ -1492,57 +1490,48 @@ static void test_sa_info(void)
CU_ASSERT_FATAL(sa_in != ODP_IPSEC_SA_INVALID);
memset(&info_out, 0, sizeof(info_out));
- CU_ASSERT_EQUAL_FATAL(0, odp_ipsec_sa_info(sa_out, &info_out));
-
- CU_ASSERT_EQUAL(info_out.param.dir, param_out.dir);
- CU_ASSERT_EQUAL(info_out.param.proto, param_out.proto);
- CU_ASSERT_EQUAL(info_out.param.mode, param_out.mode);
-
- CU_ASSERT_EQUAL(info_out.param.crypto.cipher_alg,
- param_out.crypto.cipher_alg);
- CU_ASSERT_EQUAL(info_out.param.crypto.auth_alg,
- param_out.crypto.auth_alg);
- CU_ASSERT_EQUAL(info_out.param.opt.udp_encap, param_out.opt.udp_encap);
- CU_ASSERT_EQUAL(info_out.param.spi, param_out.spi);
- CU_ASSERT_EQUAL(info_out.param.opt.esn, param_out.opt.esn);
- CU_ASSERT_EQUAL(info_out.param.opt.udp_encap, param_out.opt.udp_encap);
- CU_ASSERT_EQUAL(info_out.param.opt.copy_dscp, param_out.opt.copy_dscp);
- CU_ASSERT_EQUAL(info_out.param.opt.copy_flabel, param_out.opt.copy_flabel);
- CU_ASSERT_EQUAL(info_out.param.opt.copy_df, param_out.opt.copy_df);
-
- CU_ASSERT_EQUAL(ODP_IPSEC_MODE_TUNNEL, info_out.param.mode);
-
- CU_ASSERT_EQUAL(info_out.param.outbound.tunnel.type,
- param_out.outbound.tunnel.type);
- CU_ASSERT_EQUAL(info_out.param.outbound.tunnel.ipv4.dscp,
- param_out.outbound.tunnel.ipv4.dscp);
- CU_ASSERT_EQUAL(info_out.param.outbound.tunnel.ipv4.df,
- param_out.outbound.tunnel.ipv4.df);
- CU_ASSERT_NOT_EQUAL_FATAL(NULL,
- info_out.param.outbound.tunnel.ipv4.src_addr);
- CU_ASSERT_EQUAL(0, memcmp(info_out.param.outbound.tunnel.ipv4.src_addr,
- param_out.outbound.tunnel.ipv4.src_addr,
- ODP_IPV4_ADDR_SIZE));
- CU_ASSERT_NOT_EQUAL_FATAL(NULL,
- info_out.param.outbound.tunnel.ipv4.dst_addr);
- CU_ASSERT_EQUAL(0, memcmp(info_out.param.outbound.tunnel.ipv4.dst_addr,
- param_out.outbound.tunnel.ipv4.dst_addr,
- ODP_IPV4_ADDR_SIZE));
-
- CU_ASSERT_EQUAL(info_out.param.lifetime.soft_limit.bytes,
- param_out.lifetime.soft_limit.bytes);
- CU_ASSERT_EQUAL(info_out.param.lifetime.hard_limit.bytes,
- param_out.lifetime.hard_limit.bytes);
- CU_ASSERT_EQUAL(info_out.param.lifetime.soft_limit.packets,
- param_out.lifetime.soft_limit.packets);
- CU_ASSERT_EQUAL(info_out.param.lifetime.hard_limit.packets,
- param_out.lifetime.hard_limit.packets);
-
- CU_ASSERT_EQUAL(0, info_out.outbound.seq_num);
+ CU_ASSERT_FATAL(0 == odp_ipsec_sa_info(sa_out, &info_out));
+
+ CU_ASSERT(info_out.param.dir == param_out.dir);
+ CU_ASSERT(info_out.param.proto == param_out.proto);
+ CU_ASSERT(info_out.param.mode == param_out.mode);
+
+ CU_ASSERT(info_out.param.crypto.cipher_alg == param_out.crypto.cipher_alg);
+ CU_ASSERT(info_out.param.crypto.auth_alg == param_out.crypto.auth_alg);
+ CU_ASSERT(info_out.param.opt.udp_encap == param_out.opt.udp_encap);
+ CU_ASSERT(info_out.param.spi == param_out.spi);
+ CU_ASSERT(info_out.param.opt.esn == param_out.opt.esn);
+ CU_ASSERT(info_out.param.opt.udp_encap == param_out.opt.udp_encap);
+ CU_ASSERT(info_out.param.opt.copy_dscp == param_out.opt.copy_dscp);
+ CU_ASSERT(info_out.param.opt.copy_flabel == param_out.opt.copy_flabel);
+ CU_ASSERT(info_out.param.opt.copy_df == param_out.opt.copy_df);
+
+ CU_ASSERT(ODP_IPSEC_MODE_TUNNEL == info_out.param.mode);
+
+ CU_ASSERT(info_out.param.outbound.tunnel.type == param_out.outbound.tunnel.type);
+ CU_ASSERT(info_out.param.outbound.tunnel.ipv4.dscp == param_out.outbound.tunnel.ipv4.dscp);
+ CU_ASSERT(info_out.param.outbound.tunnel.ipv4.df == param_out.outbound.tunnel.ipv4.df);
+ CU_ASSERT_FATAL(NULL != info_out.param.outbound.tunnel.ipv4.src_addr);
+ CU_ASSERT(0 == memcmp(info_out.param.outbound.tunnel.ipv4.src_addr,
+ param_out.outbound.tunnel.ipv4.src_addr,
+ ODP_IPV4_ADDR_SIZE));
+ CU_ASSERT_FATAL(NULL != info_out.param.outbound.tunnel.ipv4.dst_addr);
+ CU_ASSERT(0 == memcmp(info_out.param.outbound.tunnel.ipv4.dst_addr,
+ param_out.outbound.tunnel.ipv4.dst_addr,
+ ODP_IPV4_ADDR_SIZE));
+
+ CU_ASSERT(info_out.param.lifetime.soft_limit.bytes == param_out.lifetime.soft_limit.bytes);
+ CU_ASSERT(info_out.param.lifetime.hard_limit.bytes == param_out.lifetime.hard_limit.bytes);
+ CU_ASSERT(info_out.param.lifetime.soft_limit.packets ==
+ param_out.lifetime.soft_limit.packets);
+ CU_ASSERT(info_out.param.lifetime.hard_limit.packets ==
+ param_out.lifetime.hard_limit.packets);
+
+ CU_ASSERT(0 == info_out.outbound.seq_num);
memset(&info_in, 0, sizeof(info_in));
- CU_ASSERT_EQUAL_FATAL(0, odp_ipsec_sa_info(sa_in, &info_in));
- CU_ASSERT_EQUAL(0, info_in.inbound.antireplay_window_top);
+ CU_ASSERT_FATAL(0 == odp_ipsec_sa_info(sa_in, &info_in));
+ CU_ASSERT(0 == info_in.inbound.antireplay_window_top);
ipsec_test_part test_out = {
.pkt_in = &pkt_ipv4_icmp_0,
@@ -1569,12 +1558,12 @@ static void test_sa_info(void)
ipsec_check_out_in_one(&test_out, &test_in, sa_out, sa_in, NULL);
memset(&info_out, 0, sizeof(info_out));
- CU_ASSERT_EQUAL_FATAL(0, odp_ipsec_sa_info(sa_out, &info_out));
- CU_ASSERT_EQUAL(1, info_out.outbound.seq_num);
+ CU_ASSERT_FATAL(0 == odp_ipsec_sa_info(sa_out, &info_out));
+ CU_ASSERT(1 == info_out.outbound.seq_num);
memset(&info_in, 0, sizeof(info_in));
- CU_ASSERT_EQUAL_FATAL(0, odp_ipsec_sa_info(sa_in, &info_in));
- CU_ASSERT_EQUAL(1, info_in.inbound.antireplay_window_top);
+ CU_ASSERT_FATAL(0 == odp_ipsec_sa_info(sa_in, &info_in));
+ CU_ASSERT(1 == info_in.inbound.antireplay_window_top);
ipsec_sa_destroy(sa_out);
ipsec_sa_destroy(sa_in);
@@ -1697,7 +1686,7 @@ static void test_out_ipv4_esp_sa_expiry(enum ipsec_test_sa_expiry expiry)
param_out.lifetime.hard_limit.packets = hard_limit_pkt;
out_sa = odp_ipsec_sa_create(&param_out);
- CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, out_sa);
+ CU_ASSERT_FATAL(ODP_IPSEC_SA_INVALID != out_sa);
ipsec_test_part test_out = {
.pkt_in = &pkt_ipv4_icmp_0,
diff --git a/test/validation/api/ipsec/reass_test_vectors.c b/test/validation/api/ipsec/reass_test_vectors.c
index c3bb2bfd4..45dd7af1b 100644
--- a/test/validation/api/ipsec/reass_test_vectors.c
+++ b/test/validation/api/ipsec/reass_test_vectors.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2021, Marvell
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Marvell
*/
#include "ipsec.h"
diff --git a/test/validation/api/ipsec/reass_test_vectors.h b/test/validation/api/ipsec/reass_test_vectors.h
index 02b41c573..4c8d8e1f4 100644
--- a/test/validation/api/ipsec/reass_test_vectors.h
+++ b/test/validation/api/ipsec/reass_test_vectors.h
@@ -1,7 +1,5 @@
- /* Copyright (c) 2021, Marvell
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021 Marvell
*/
#ifndef _ODP_REASS_TEST_VECTORS_H_
diff --git a/test/validation/api/ipsec/test_vectors.h b/test/validation/api/ipsec/test_vectors.h
index b032ef973..b02912f68 100644
--- a/test/validation/api/ipsec/test_vectors.h
+++ b/test/validation/api/ipsec/test_vectors.h
@@ -1,8 +1,6 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * Copyright (c) 2020, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2020 Nokia
*/
#ifndef _ODP_TEST_IPSEC_VECTORS_H_
diff --git a/test/validation/api/lock/lock.c b/test/validation/api/lock/lock.c
index a4e6932c4..e8eb4360b 100644
--- a/test/validation/api/lock/lock.c
+++ b/test/validation/api/lock/lock.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
*/
#include <malloc.h>
@@ -117,7 +115,7 @@ static per_thread_mem_t *thread_init(void)
global_shm = odp_shm_lookup(GLOBAL_SHM_NAME);
global_mem = odp_shm_addr(global_shm);
- CU_ASSERT_PTR_NOT_NULL(global_mem);
+ CU_ASSERT(global_mem != NULL);
per_thread_mem->global_mem = global_mem;
diff --git a/test/validation/api/ml/ml.c b/test/validation/api/ml/ml.c
index 5f8be1b64..1f3383428 100644
--- a/test/validation/api/ml/ml.c
+++ b/test/validation/api/ml/ml.c
@@ -317,6 +317,7 @@ static void test_ml_compl_user_area(void)
memset(addr, 0, size);
ev = odp_ml_compl_to_event(compl_evs[i]);
+ odp_event_user_flag_set(ev, 1);
CU_ASSERT(odp_event_user_area(ev) == addr);
CU_ASSERT(odp_event_user_area_and_flag(ev, &flag) == addr);
CU_ASSERT(flag < 0);
diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c
index ca9c73f17..7e7208755 100644
--- a/test/validation/api/packet/packet.c
+++ b/test/validation/api/packet/packet.c
@@ -1,13 +1,9 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * Copyright (c) 2020, Marvell
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2019-2024 Nokia
+ * Copyright (c) 2020 Marvell
*/
-#include <stdlib.h>
-
#include <odp_api.h>
#include <odp_cunit_common.h>
#include <test_packet_ipv4.h>
@@ -16,6 +12,9 @@
#include <odp/helper/odph_api.h>
+#include <stdint.h>
+#include <stdlib.h>
+
/* Reserve some tailroom for tests */
#define TAILROOM_RESERVE 4
/* Number of packets in the test packet pool */
@@ -118,8 +117,8 @@ static void _packet_compare_data(odp_packet_t pkt1, odp_packet_t pkt2,
pkt1map = odp_packet_offset(pkt1, offset, &seglen1, NULL);
pkt2map = odp_packet_offset(pkt2, offset, &seglen2, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(pkt1map);
- CU_ASSERT_PTR_NOT_NULL_FATAL(pkt2map);
+ CU_ASSERT_FATAL(pkt1map != NULL);
+ CU_ASSERT_FATAL(pkt2map != NULL);
cmplen = seglen1 < seglen2 ? seglen1 : seglen2;
ret = memcmp(pkt1map, pkt2map, cmplen);
@@ -849,8 +848,8 @@ static void packet_test_basic_metadata(void)
odp_time_t ts;
odp_packet_data_range_t range;
- CU_ASSERT_PTR_NOT_NULL(odp_packet_head(pkt));
- CU_ASSERT_PTR_NOT_NULL(odp_packet_data(pkt));
+ CU_ASSERT(odp_packet_head(pkt) != NULL);
+ CU_ASSERT(odp_packet_data(pkt) != NULL);
CU_ASSERT(odp_packet_pool(pkt) != ODP_POOL_INVALID);
/* Packet was allocated by application so shouldn't have valid pktio. */
@@ -908,14 +907,24 @@ static void packet_test_length(void)
static void packet_test_reset(void)
{
- uint32_t len, headroom;
+ uint32_t len, max_len, headroom;
+ uint32_t uarea_size = default_param.pkt.uarea_size;
uintptr_t ptr_len;
void *data, *new_data, *tail, *new_tail;
+ struct udata_struct *udat;
odp_packet_t pkt;
pkt = odp_packet_alloc(default_pool, packet_len);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+ if (uarea_size) {
+ udat = odp_packet_user_area(pkt);
+
+ CU_ASSERT_FATAL(udat != NULL);
+ CU_ASSERT_FATAL(odp_packet_user_area_size(pkt) >= uarea_size);
+ memcpy(udat, &test_packet_udata, uarea_size);
+ }
+
len = odp_packet_len(pkt);
CU_ASSERT(len == packet_len);
@@ -946,8 +955,10 @@ static void packet_test_reset(void)
ptr_len = (uintptr_t)odp_packet_data(pkt) -
(uintptr_t)odp_packet_head(pkt);
CU_ASSERT(ptr_len == (headroom + 1));
- CU_ASSERT(odp_packet_reset(pkt, len) == 0);
- CU_ASSERT(odp_packet_len(pkt) == len);
+ max_len = odp_packet_reset_max_len(pkt);
+ CU_ASSERT(max_len >= len);
+ CU_ASSERT(odp_packet_reset(pkt, max_len) == 0);
+ CU_ASSERT(odp_packet_len(pkt) == max_len);
CU_ASSERT(odp_packet_headroom(pkt) == headroom);
ptr_len = (uintptr_t)odp_packet_data(pkt) -
(uintptr_t)odp_packet_head(pkt);
@@ -956,7 +967,7 @@ static void packet_test_reset(void)
tail = odp_packet_tail(pkt);
new_tail = odp_packet_pull_tail(pkt, 1);
- CU_ASSERT(odp_packet_len(pkt) == len - 1);
+ CU_ASSERT(odp_packet_len(pkt) == max_len - 1);
CU_ASSERT((uintptr_t)new_tail == ((uintptr_t)tail - 1));
CU_ASSERT(odp_packet_reset(pkt, len) == 0);
CU_ASSERT(odp_packet_len(pkt) == len);
@@ -973,6 +984,86 @@ static void packet_test_reset(void)
CU_ASSERT(odp_packet_reset(pkt, len) == 0);
CU_ASSERT(odp_packet_len(pkt) == len);
+ if (odp_packet_reset_max_len(pkt) < UINT32_MAX) {
+ CU_ASSERT(odp_packet_reset(pkt, odp_packet_reset_max_len(pkt) + 1) < 0);
+ CU_ASSERT(odp_packet_len(pkt) == len);
+ }
+
+ if (uarea_size) {
+ udat = odp_packet_user_area(pkt);
+
+ CU_ASSERT_FATAL(udat != NULL);
+ CU_ASSERT_FATAL(odp_packet_user_area_size(pkt) >= uarea_size);
+ CU_ASSERT(memcmp(udat, &test_packet_udata, uarea_size) == 0);
+ }
+
+ odp_packet_free(pkt);
+}
+
+static void packet_test_reset_meta(void)
+{
+ uint32_t data_len, seg_len, headroom, tailroom;
+ uint32_t uarea_size = default_param.pkt.uarea_size;
+ void *data, *head, *tail;
+ struct udata_struct *udat;
+ odp_packet_t pkt;
+ int num_segs;
+
+ pkt = odp_packet_alloc(default_pool, segmented_packet_len);
+ CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
+
+ if (uarea_size) {
+ udat = odp_packet_user_area(pkt);
+
+ CU_ASSERT_FATAL(udat != NULL);
+ CU_ASSERT_FATAL(odp_packet_user_area_size(pkt) >= uarea_size);
+ memcpy(udat, &test_packet_udata, uarea_size);
+ }
+
+ data_len = odp_packet_len(pkt);
+ CU_ASSERT(data_len == segmented_packet_len);
+
+ odp_packet_pull_head(pkt, 1);
+ head = odp_packet_head(pkt);
+ CU_ASSERT(head != NULL);
+
+ odp_packet_pull_tail(pkt, 1);
+ tail = odp_packet_tail(pkt);
+ CU_ASSERT(tail != NULL);
+
+ headroom = odp_packet_headroom(pkt);
+ tailroom = odp_packet_tailroom(pkt);
+
+ data = odp_packet_data(pkt);
+ data_len = odp_packet_len(pkt);
+
+ seg_len = odp_packet_seg_len(pkt);
+ num_segs = odp_packet_num_segs(pkt);
+
+ odp_packet_reset_meta(pkt);
+
+ CU_ASSERT(odp_packet_data(pkt) == data);
+ CU_ASSERT(odp_packet_len(pkt) == data_len);
+ CU_ASSERT(odp_packet_seg_len(pkt) == seg_len);
+ CU_ASSERT(odp_packet_num_segs(pkt) == num_segs);
+ CU_ASSERT(odp_packet_headroom(pkt) == headroom);
+ CU_ASSERT(odp_packet_tailroom(pkt) == tailroom);
+ CU_ASSERT(odp_packet_head(pkt) == head);
+ CU_ASSERT(odp_packet_tail(pkt) == tail);
+
+ packet_set_inflags_common(pkt, 1);
+ packet_check_inflags_common(pkt, 1);
+ odp_packet_reset_meta(pkt);
+ packet_check_inflags_all(pkt, 0);
+
+ if (uarea_size) {
+ udat = odp_packet_user_area(pkt);
+
+ CU_ASSERT_FATAL(udat != NULL);
+ CU_ASSERT_FATAL(odp_packet_user_area_size(pkt) >= uarea_size);
+ CU_ASSERT(memcmp(udat, &test_packet_udata, uarea_size) == 0);
+ }
+
odp_packet_free(pkt);
}
@@ -1066,7 +1157,7 @@ static void packet_test_layer_offsets(void)
CU_ASSERT(seg_len != 0);
l4_addr = odp_packet_l4_ptr(pkt, &seg_len);
CU_ASSERT(seg_len != 0);
- CU_ASSERT_PTR_NOT_NULL(l2_addr);
+ CU_ASSERT(l2_addr != NULL);
CU_ASSERT(l2_addr == l3_addr);
CU_ASSERT(l2_addr == l4_addr);
@@ -1080,11 +1171,11 @@ static void packet_test_layer_offsets(void)
/* Addresses should not be the same */
l2_addr = odp_packet_l2_ptr(pkt, NULL);
- CU_ASSERT_PTR_NOT_NULL(l2_addr);
+ CU_ASSERT(l2_addr != NULL);
l3_addr = odp_packet_l3_ptr(pkt, NULL);
- CU_ASSERT_PTR_NOT_NULL(l3_addr);
+ CU_ASSERT(l3_addr != NULL);
l4_addr = odp_packet_l4_ptr(pkt, NULL);
- CU_ASSERT_PTR_NOT_NULL(l4_addr);
+ CU_ASSERT(l4_addr != NULL);
CU_ASSERT(l2_addr != l3_addr);
CU_ASSERT(l2_addr != l4_addr);
@@ -1124,7 +1215,7 @@ static void _verify_headroom_shift(odp_packet_t *pkt,
}
packet_sanity_check(*pkt);
- CU_ASSERT_PTR_NOT_NULL(data);
+ CU_ASSERT(data != NULL);
if (extended) {
CU_ASSERT(rc >= 0);
CU_ASSERT(odp_packet_seg_len(*pkt) == seg_len);
@@ -1222,7 +1313,7 @@ static void _verify_tailroom_shift(odp_packet_t *pkt,
}
packet_sanity_check(*pkt);
- CU_ASSERT_PTR_NOT_NULL(tail);
+ CU_ASSERT(tail != NULL);
if (extended) {
CU_ASSERT(rc >= 0);
@@ -1323,7 +1414,7 @@ static void packet_test_segments(void)
seg_data = odp_packet_seg_data(pkt, seg);
CU_ASSERT(seg_data_len > 0);
- CU_ASSERT_PTR_NOT_NULL(seg_data);
+ CU_ASSERT(seg_data != NULL);
CU_ASSERT(odp_packet_seg_to_u64(seg) !=
odp_packet_seg_to_u64(ODP_PACKET_SEG_INVALID));
CU_ASSERT(odp_memcmp(seg_data, seg_data, seg_data_len) == 0);
@@ -1635,8 +1726,8 @@ static void _packet_compare_offset(odp_packet_t pkt1, uint32_t off1,
pkt1map = odp_packet_offset(pkt1, off1, &seglen1, NULL);
pkt2map = odp_packet_offset(pkt2, off2, &seglen2, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(pkt1map);
- CU_ASSERT_PTR_NOT_NULL_FATAL(pkt2map);
+ CU_ASSERT_FATAL(pkt1map != NULL);
+ CU_ASSERT_FATAL(pkt2map != NULL);
cmplen = seglen1 < seglen2 ? seglen1 : seglen2;
if (len < cmplen)
cmplen = len;
@@ -1855,7 +1946,7 @@ static void packet_test_copydata(void)
CU_ASSERT_FATAL(pkt_len > 0);
data_buf = malloc(pkt_len);
- CU_ASSERT_PTR_NOT_NULL_FATAL(data_buf);
+ CU_ASSERT_FATAL(data_buf != NULL);
for (i = 0; i < pkt_len; i++)
data_buf[i] = (uint8_t)i;
@@ -2614,7 +2705,7 @@ static void packet_test_offset(void)
CU_ASSERT(seg_len > 1);
CU_ASSERT(seg_len == odp_packet_seg_len(pkt));
CU_ASSERT(seg_len == odp_packet_seg_data_len(pkt, seg));
- CU_ASSERT_PTR_NOT_NULL(ptr);
+ CU_ASSERT(ptr != NULL);
CU_ASSERT(ptr == odp_packet_data(pkt));
CU_ASSERT(ptr == odp_packet_seg_data(pkt, seg));
@@ -2624,7 +2715,7 @@ static void packet_test_offset(void)
offset = 1;
ptr = odp_packet_offset(pkt, offset, &seg_len, NULL);
- CU_ASSERT_PTR_NOT_NULL(ptr);
+ CU_ASSERT(ptr != NULL);
CU_ASSERT(ptr == start_ptr + offset);
CU_ASSERT(seg_len == full_seg_len - offset);
@@ -2632,19 +2723,19 @@ static void packet_test_offset(void)
offset = full_seg_len - 1;
ptr = odp_packet_offset(pkt, offset, &seg_len, NULL);
- CU_ASSERT_PTR_NOT_NULL(ptr);
+ CU_ASSERT(ptr != NULL);
CU_ASSERT(ptr == start_ptr + offset);
CU_ASSERT(seg_len == full_seg_len - offset);
/* Query the last byte in a packet */
offset = odp_packet_len(pkt) - 1;
ptr = odp_packet_offset(pkt, offset, &seg_len, NULL);
- CU_ASSERT_PTR_NOT_NULL(ptr);
+ CU_ASSERT(ptr != NULL);
CU_ASSERT(seg_len == 1);
/* Pass NULL to [out] arguments */
ptr = odp_packet_offset(pkt, 0, NULL, NULL);
- CU_ASSERT_PTR_NOT_NULL(ptr);
+ CU_ASSERT(ptr != NULL);
}
static void packet_test_ref(void)
@@ -3285,6 +3376,10 @@ static void packet_vector_test_user_area(void)
CU_ASSERT(odp_event_user_area(ev) == addr);
CU_ASSERT(odp_event_user_area_and_flag(ev, &flag) == addr);
CU_ASSERT(flag == 0);
+ odp_event_user_flag_set(ev, 1);
+ CU_ASSERT(odp_event_user_area_and_flag(ev, &flag) == addr);
+ CU_ASSERT(flag > 0);
+ CU_ASSERT(odp_packet_vector_user_flag(pktv[i]) > 0);
prev = addr;
memset(addr, 0, size);
@@ -3478,6 +3573,10 @@ static void packet_test_user_area(void)
CU_ASSERT(odp_event_user_area(ev) == odp_packet_user_area(pkt));
CU_ASSERT(odp_event_user_area_and_flag(ev, &flag) == odp_packet_user_area(pkt));
CU_ASSERT(flag == 0);
+ odp_event_user_flag_set(ev, 1);
+ CU_ASSERT(odp_event_user_area_and_flag(ev, &flag) == odp_packet_user_area(pkt));
+ CU_ASSERT(flag > 0);
+ CU_ASSERT(odp_packet_user_flag(pkt) > 0);
odp_packet_free(pkt);
CU_ASSERT(odp_pool_destroy(pool) == 0);
@@ -3629,12 +3728,9 @@ static void parse_eth_ipv4_udp(void)
CU_ASSERT(odp_packet_has_udp(pkt[i]));
CU_ASSERT(!odp_packet_has_ipv6(pkt[i]));
CU_ASSERT(!odp_packet_has_tcp(pkt[i]));
- CU_ASSERT_EQUAL(odp_packet_l2_type(pkt[i]),
- ODP_PROTO_L2_TYPE_ETH);
- CU_ASSERT_EQUAL(odp_packet_l3_type(pkt[i]),
- ODP_PROTO_L3_TYPE_IPV4);
- CU_ASSERT_EQUAL(odp_packet_l4_type(pkt[i]),
- ODP_PROTO_L4_TYPE_UDP);
+ CU_ASSERT(odp_packet_l2_type(pkt[i]) == ODP_PROTO_L2_TYPE_ETH);
+ CU_ASSERT(odp_packet_l3_type(pkt[i]) == ODP_PROTO_L3_TYPE_IPV4);
+ CU_ASSERT(odp_packet_l4_type(pkt[i]) == ODP_PROTO_L4_TYPE_UDP);
}
odp_packet_free_multi(pkt, num_pkt);
@@ -3673,12 +3769,9 @@ static void parse_eth_snap_ipv4_udp(void)
CU_ASSERT(odp_packet_has_udp(pkt[i]));
CU_ASSERT(!odp_packet_has_ipv6(pkt[i]));
CU_ASSERT(!odp_packet_has_tcp(pkt[i]));
- CU_ASSERT_EQUAL(odp_packet_l2_type(pkt[i]),
- ODP_PROTO_L2_TYPE_ETH);
- CU_ASSERT_EQUAL(odp_packet_l3_type(pkt[i]),
- ODP_PROTO_L3_TYPE_IPV4);
- CU_ASSERT_EQUAL(odp_packet_l4_type(pkt[i]),
- ODP_PROTO_L4_TYPE_UDP);
+ CU_ASSERT(odp_packet_l2_type(pkt[i]) == ODP_PROTO_L2_TYPE_ETH);
+ CU_ASSERT(odp_packet_l3_type(pkt[i]) == ODP_PROTO_L3_TYPE_IPV4);
+ CU_ASSERT(odp_packet_l4_type(pkt[i]) == ODP_PROTO_L4_TYPE_UDP);
}
odp_packet_free_multi(pkt, num_pkt);
@@ -3712,10 +3805,8 @@ static void parse_ipv4_udp(void)
CU_ASSERT(odp_packet_has_udp(pkt[i]));
CU_ASSERT(!odp_packet_has_ipv6(pkt[i]));
CU_ASSERT(!odp_packet_has_tcp(pkt[i]));
- CU_ASSERT_EQUAL(odp_packet_l3_type(pkt[i]),
- ODP_PROTO_L3_TYPE_IPV4);
- CU_ASSERT_EQUAL(odp_packet_l4_type(pkt[i]),
- ODP_PROTO_L4_TYPE_UDP);
+ CU_ASSERT(odp_packet_l3_type(pkt[i]) == ODP_PROTO_L3_TYPE_IPV4);
+ CU_ASSERT(odp_packet_l4_type(pkt[i]) == ODP_PROTO_L4_TYPE_UDP);
}
odp_packet_free_multi(pkt, num_pkt);
@@ -3746,12 +3837,9 @@ static void parse_eth_ipv4_tcp(void)
CU_ASSERT(odp_packet_has_tcp(pkt[i]));
CU_ASSERT(!odp_packet_has_ipv6(pkt[i]));
CU_ASSERT(!odp_packet_has_udp(pkt[i]));
- CU_ASSERT_EQUAL(odp_packet_l2_type(pkt[i]),
- ODP_PROTO_L2_TYPE_ETH);
- CU_ASSERT_EQUAL(odp_packet_l3_type(pkt[i]),
- ODP_PROTO_L3_TYPE_IPV4);
- CU_ASSERT_EQUAL(odp_packet_l4_type(pkt[i]),
- ODP_PROTO_L4_TYPE_TCP);
+ CU_ASSERT(odp_packet_l2_type(pkt[i]) == ODP_PROTO_L2_TYPE_ETH);
+ CU_ASSERT(odp_packet_l3_type(pkt[i]) == ODP_PROTO_L3_TYPE_IPV4);
+ CU_ASSERT(odp_packet_l4_type(pkt[i]) == ODP_PROTO_L4_TYPE_TCP);
}
odp_packet_free_multi(pkt, num_pkt);
@@ -3874,12 +3962,9 @@ static void parse_eth_vlan_ipv6_udp(void)
CU_ASSERT(odp_packet_has_udp(pkt[i]));
CU_ASSERT(!odp_packet_has_ipv4(pkt[i]));
CU_ASSERT(!odp_packet_has_tcp(pkt[i]));
- CU_ASSERT_EQUAL(odp_packet_l2_type(pkt[i]),
- ODP_PROTO_L2_TYPE_ETH);
- CU_ASSERT_EQUAL(odp_packet_l3_type(pkt[i]),
- ODP_PROTO_L3_TYPE_IPV6);
- CU_ASSERT_EQUAL(odp_packet_l4_type(pkt[i]),
- ODP_PROTO_L4_TYPE_UDP);
+ CU_ASSERT(odp_packet_l2_type(pkt[i]) == ODP_PROTO_L2_TYPE_ETH);
+ CU_ASSERT(odp_packet_l3_type(pkt[i]) == ODP_PROTO_L3_TYPE_IPV6);
+ CU_ASSERT(odp_packet_l4_type(pkt[i]) == ODP_PROTO_L4_TYPE_UDP);
}
odp_packet_free_multi(pkt, num_pkt);
@@ -4130,12 +4215,9 @@ static void parse_eth_ipv6_ipsec_ah(void)
CU_ASSERT(!odp_packet_has_ipv4(pkt[i]));
CU_ASSERT(!odp_packet_has_tcp(pkt[i]));
CU_ASSERT(!odp_packet_has_udp(pkt[i]));
- CU_ASSERT_EQUAL(odp_packet_l2_type(pkt[i]),
- ODP_PROTO_L2_TYPE_ETH);
- CU_ASSERT_EQUAL(odp_packet_l3_type(pkt[i]),
- ODP_PROTO_L3_TYPE_IPV6);
- CU_ASSERT_EQUAL(odp_packet_l4_type(pkt[i]),
- ODP_PROTO_L4_TYPE_AH);
+ CU_ASSERT(odp_packet_l2_type(pkt[i]) == ODP_PROTO_L2_TYPE_ETH);
+ CU_ASSERT(odp_packet_l3_type(pkt[i]) == ODP_PROTO_L3_TYPE_IPV6);
+ CU_ASSERT(odp_packet_l4_type(pkt[i]) == ODP_PROTO_L4_TYPE_AH);
}
odp_packet_free_multi(pkt, num_pkt);
@@ -4493,6 +4575,7 @@ odp_testinfo_t packet_suite[] = {
ODP_TEST_INFO(packet_test_segments),
ODP_TEST_INFO(packet_test_length),
ODP_TEST_INFO(packet_test_reset),
+ ODP_TEST_INFO(packet_test_reset_meta),
ODP_TEST_INFO(packet_test_prefetch),
ODP_TEST_INFO(packet_test_headroom),
ODP_TEST_INFO(packet_test_tailroom),
diff --git a/test/validation/api/pktio/lso.c b/test/validation/api/pktio/lso.c
index 832c08859..40d0917b4 100644
--- a/test/validation/api/pktio/lso.c
+++ b/test/validation/api/pktio/lso.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020-2022 Nokia
*/
#include <odp_api.h>
@@ -657,7 +655,7 @@ static void test_lso_request_clear(odp_lso_profile_t lso_profile, const uint8_t
static void lso_send_custom_eth(const uint8_t *test_packet, uint32_t pkt_len, uint32_t max_payload,
int use_opt)
{
- int i, ret, num;
+ int i, ret, num, num_rcv;
odp_lso_profile_param_t param;
odp_lso_profile_t profile;
uint32_t offset, len, payload_len, payload_sum;
@@ -698,6 +696,7 @@ static void lso_send_custom_eth(const uint8_t *test_packet, uint32_t pkt_len, ui
offset = hdr_len;
payload_sum = 0;
segnum = 0xffff;
+ num_rcv = 0;
for (i = 0; i < num; i++) {
odph_ethhdr_t *eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt_out[i], NULL);
@@ -712,7 +711,7 @@ static void lso_send_custom_eth(const uint8_t *test_packet, uint32_t pkt_len, ui
if (ret == 0) {
segnum = odp_be_to_cpu_16(segnum);
- CU_ASSERT(segnum == i);
+ CU_ASSERT(segnum == num_rcv);
} else {
CU_FAIL("Seg num field read failed\n");
}
@@ -729,6 +728,7 @@ static void lso_send_custom_eth(const uint8_t *test_packet, uint32_t pkt_len, ui
offset += payload_len;
payload_sum += payload_len;
+ num_rcv++;
}
ODPH_DBG(" Received payload length: %u bytes\n", payload_sum);
diff --git a/test/validation/api/pktio/lso.h b/test/validation/api/pktio/lso.h
index ce3dc7b64..d5688369f 100644
--- a/test/validation/api/pktio/lso.h
+++ b/test/validation/api/pktio/lso.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020 Nokia
*/
#ifndef _ODP_TEST_PKTIO_LSO_H_
diff --git a/test/validation/api/pktio/parser.c b/test/validation/api/pktio/parser.c
index 7d243877c..a21a9c0f8 100644
--- a/test/validation/api/pktio/parser.c
+++ b/test/validation/api/pktio/parser.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#include <odp_api.h>
diff --git a/test/validation/api/pktio/parser.h b/test/validation/api/pktio/parser.h
index 4424737fd..8341d9a2c 100644
--- a/test/validation/api/pktio/parser.h
+++ b/test/validation/api/pktio/parser.h
@@ -1,7 +1,5 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
*/
#ifndef _ODP_TEST_PARSER_H_
diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c
index deef4895a..12e0a2cd9 100644
--- a/test/validation/api/pktio/pktio.c
+++ b/test/validation/api/pktio/pktio.c
@@ -1,9 +1,7 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2020-2024, Nokia
- * Copyright (c) 2020, Marvell
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2020-2024 Nokia
+ * Copyright (c) 2020 Marvell
*/
#include <odp_api.h>
@@ -1598,48 +1596,48 @@ static void test_defaults(uint8_t fill)
memset(&pktio_p, fill, sizeof(pktio_p));
odp_pktio_param_init(&pktio_p);
- CU_ASSERT_EQUAL(pktio_p.in_mode, ODP_PKTIN_MODE_DIRECT);
- CU_ASSERT_EQUAL(pktio_p.out_mode, ODP_PKTOUT_MODE_DIRECT);
+ CU_ASSERT(pktio_p.in_mode == ODP_PKTIN_MODE_DIRECT);
+ CU_ASSERT(pktio_p.out_mode == ODP_PKTOUT_MODE_DIRECT);
memset(&qp_in, fill, sizeof(qp_in));
odp_pktin_queue_param_init(&qp_in);
- CU_ASSERT_EQUAL(qp_in.op_mode, ODP_PKTIO_OP_MT);
- CU_ASSERT_EQUAL(qp_in.classifier_enable, 0);
- CU_ASSERT_EQUAL(qp_in.hash_enable, 0);
- CU_ASSERT_EQUAL(qp_in.hash_proto.all_bits, 0);
- CU_ASSERT_EQUAL(qp_in.num_queues, 1);
- CU_ASSERT_EQUAL(qp_in.queue_size[0], 0);
- CU_ASSERT_EQUAL(qp_in.queue_param.enq_mode, ODP_QUEUE_OP_MT);
- CU_ASSERT_EQUAL(qp_in.queue_param.sched.prio, odp_schedule_default_prio());
- CU_ASSERT_EQUAL(qp_in.queue_param.sched.sync, ODP_SCHED_SYNC_PARALLEL);
- CU_ASSERT_EQUAL(qp_in.queue_param.sched.group, ODP_SCHED_GROUP_ALL);
- CU_ASSERT_EQUAL(qp_in.queue_param.sched.lock_count, 0);
- CU_ASSERT_EQUAL(qp_in.queue_param.order, ODP_QUEUE_ORDER_KEEP);
- CU_ASSERT_EQUAL(qp_in.queue_param.nonblocking, ODP_BLOCKING);
- CU_ASSERT_EQUAL(qp_in.queue_param.context, NULL);
- CU_ASSERT_EQUAL(qp_in.queue_param.context_len, 0);
- CU_ASSERT_EQUAL(qp_in.queue_param_ovr, NULL);
- CU_ASSERT_EQUAL(qp_in.vector.enable, false);
+ CU_ASSERT(qp_in.op_mode == ODP_PKTIO_OP_MT);
+ CU_ASSERT(qp_in.classifier_enable == 0);
+ CU_ASSERT(qp_in.hash_enable == 0);
+ CU_ASSERT(qp_in.hash_proto.all_bits == 0);
+ CU_ASSERT(qp_in.num_queues == 1);
+ CU_ASSERT(qp_in.queue_size[0] == 0);
+ CU_ASSERT(qp_in.queue_param.enq_mode == ODP_QUEUE_OP_MT);
+ CU_ASSERT(qp_in.queue_param.sched.prio == odp_schedule_default_prio());
+ CU_ASSERT(qp_in.queue_param.sched.sync == ODP_SCHED_SYNC_PARALLEL);
+ CU_ASSERT(qp_in.queue_param.sched.group == ODP_SCHED_GROUP_ALL);
+ CU_ASSERT(qp_in.queue_param.sched.lock_count == 0);
+ CU_ASSERT(qp_in.queue_param.order == ODP_QUEUE_ORDER_KEEP);
+ CU_ASSERT(qp_in.queue_param.nonblocking == ODP_BLOCKING);
+ CU_ASSERT(qp_in.queue_param.context == NULL);
+ CU_ASSERT(qp_in.queue_param.context_len == 0);
+ CU_ASSERT(qp_in.queue_param_ovr == NULL);
+ CU_ASSERT(qp_in.vector.enable == false);
memset(&qp_out, fill, sizeof(qp_out));
odp_pktout_queue_param_init(&qp_out);
- CU_ASSERT_EQUAL(qp_out.op_mode, ODP_PKTIO_OP_MT);
- CU_ASSERT_EQUAL(qp_out.num_queues, 1);
- CU_ASSERT_EQUAL(qp_out.queue_size[0], 0);
+ CU_ASSERT(qp_out.op_mode == ODP_PKTIO_OP_MT);
+ CU_ASSERT(qp_out.num_queues == 1);
+ CU_ASSERT(qp_out.queue_size[0] == 0);
memset(&pktio_conf, fill, sizeof(pktio_conf));
odp_pktio_config_init(&pktio_conf);
- CU_ASSERT_EQUAL(pktio_conf.pktin.all_bits, 0);
- CU_ASSERT_EQUAL(pktio_conf.pktout.all_bits, 0);
- CU_ASSERT_EQUAL(pktio_conf.parser.layer, ODP_PROTO_LAYER_ALL);
- CU_ASSERT_EQUAL(pktio_conf.enable_loop, false);
- CU_ASSERT_EQUAL(pktio_conf.inbound_ipsec, false);
- CU_ASSERT_EQUAL(pktio_conf.outbound_ipsec, false);
- CU_ASSERT_EQUAL(pktio_conf.enable_lso, false);
- CU_ASSERT_EQUAL(pktio_conf.reassembly.en_ipv4, false);
- CU_ASSERT_EQUAL(pktio_conf.reassembly.en_ipv6, false);
- CU_ASSERT_EQUAL(pktio_conf.reassembly.max_wait_time, 0);
- CU_ASSERT_EQUAL(pktio_conf.reassembly.max_num_frags, 2);
+ CU_ASSERT(pktio_conf.pktin.all_bits == 0);
+ CU_ASSERT(pktio_conf.pktout.all_bits == 0);
+ CU_ASSERT(pktio_conf.parser.layer == ODP_PROTO_LAYER_ALL);
+ CU_ASSERT(pktio_conf.enable_loop == false);
+ CU_ASSERT(pktio_conf.inbound_ipsec == false);
+ CU_ASSERT(pktio_conf.outbound_ipsec == false);
+ CU_ASSERT(pktio_conf.enable_lso == false);
+ CU_ASSERT(pktio_conf.reassembly.en_ipv4 == false);
+ CU_ASSERT(pktio_conf.reassembly.en_ipv6 == false);
+ CU_ASSERT(pktio_conf.reassembly.max_wait_time == 0);
+ CU_ASSERT(pktio_conf.reassembly.max_num_frags == 2);
}
static void pktio_test_default_values(void)
@@ -3661,7 +3659,8 @@ static void pktio_test_pktout_compl_event(bool use_plain_queue)
CU_ASSERT(odp_packet_tx_compl_user_ptr(tx_compl) ==
(const void *)&pkt_seq[i]);
- /* No user area or source pool for TX completion events */
+ /* No user area/flag or source pool for TX completion events */
+ odp_event_user_flag_set(ev, 1);
CU_ASSERT(odp_event_user_area(ev) == NULL);
CU_ASSERT(odp_event_user_area_and_flag(ev, &flag) == NULL);
CU_ASSERT(flag < 0);
@@ -3703,7 +3702,8 @@ static void pktio_test_pktout_compl_event(bool use_plain_queue)
}
}
- /* No user area or source pool for TX completion events */
+ /* No user area/flag or source pool for TX completion events */
+ odp_event_user_flag_set(ev, 1);
CU_ASSERT(odp_event_user_area(ev) == NULL);
CU_ASSERT(odp_event_user_area_and_flag(ev, &flag) == NULL);
CU_ASSERT(flag < 0);
@@ -5095,7 +5095,7 @@ static void pktio_test_pktin_event_queue(odp_pktin_mode_t pktin_mode)
odp_pktin_queue_param_t in_queue_param;
odp_pktout_queue_param_t out_queue_param;
odp_pktout_queue_t pktout_queue;
- odp_queue_t queue, from;
+ odp_queue_t queue, from = ODP_QUEUE_INVALID;
odp_pool_t buf_pool;
odp_pool_param_t pool_param;
odp_packet_t pkt_tbl[TX_BATCH_LEN];
@@ -5189,8 +5189,6 @@ static void pktio_test_pktin_event_queue(odp_pktin_mode_t pktin_mode)
if (ev == ODP_EVENT_INVALID)
break;
-
- CU_ASSERT(from == queue);
} else {
ev = odp_queue_deq(queue);
@@ -5214,9 +5212,12 @@ static void pktio_test_pktin_event_queue(odp_pktin_mode_t pktin_mode)
if (odp_event_type(ev) == ODP_EVENT_PACKET) {
pkt = odp_packet_from_event(ev);
- if (pktio_pkt_seq(pkt) != TEST_SEQ_INVALID)
+ if (pktio_pkt_seq(pkt) != TEST_SEQ_INVALID) {
num_pkt++;
+ if (pktin_mode == ODP_PKTIN_MODE_SCHED)
+ CU_ASSERT(from == queue);
+ }
} else if (odp_event_type(ev) == ODP_EVENT_BUFFER) {
num_buf++;
} else {
diff --git a/test/validation/api/pool/pool.c b/test/validation/api/pool/pool.c
index 86a47230a..95d9ef14e 100644
--- a/test/validation/api/pool/pool.c
+++ b/test/validation/api/pool/pool.c
@@ -1,9 +1,7 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2020, Marvell
- * Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2020 Marvell
+ * Copyright (c) 2020-2023 Nokia
*/
#include <odp_api.h>
@@ -402,6 +400,35 @@ static void pool_test_lookup_info_print(void)
CU_ASSERT(odp_pool_destroy(pool) == 0);
}
+static void pool_test_long_name(void)
+{
+ odp_pool_t pool;
+ odp_pool_info_t info;
+ odp_pool_param_t param;
+ char name[ODP_POOL_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ memset(&info, 0, sizeof(info));
+ odp_pool_param_init(&param);
+
+ param.type = ODP_POOL_BUFFER;
+ param.buf.size = BUF_SIZE;
+ param.buf.num = BUF_NUM;
+ param.buf.uarea_size = 64;
+
+ pool = odp_pool_create(name, &param);
+ CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+ pool = odp_pool_lookup(name);
+ CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+ CU_ASSERT_FATAL(odp_pool_info(pool, &info) == 0);
+ CU_ASSERT(strncmp(name, info.name, sizeof(name)) == 0);
+ CU_ASSERT(odp_pool_destroy(pool) == 0);
+}
+
static void pool_test_same_name(const odp_pool_param_t *param)
{
odp_pool_t pool, pool_a, pool_b;
@@ -1136,7 +1163,7 @@ static void pool_test_create_after_fork(void)
shm = odp_shm_reserve(NULL, sizeof(global_shared_mem_t), 0, 0);
CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
global_mem = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL_FATAL(global_mem);
+ CU_ASSERT_FATAL(global_mem != NULL);
num = odp_cpumask_default_worker(NULL, 0);
if (num > MAX_WORKERS)
@@ -1832,6 +1859,31 @@ static void test_packet_pool_ext_info(void)
CU_ASSERT(odp_pool_destroy(pool) == 0);
}
+static void test_packet_pool_ext_long_name(void)
+{
+ odp_pool_t pool;
+ odp_pool_ext_param_t param;
+ odp_pool_info_t info;
+ char name[ODP_POOL_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ pool_ext_init_packet_pool_param(&param);
+ pool = odp_pool_ext_create(name, &param);
+
+ CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+ CU_ASSERT_FATAL(pool == odp_pool_lookup(name));
+
+ memset(&info, 0, sizeof(odp_pool_info_t));
+ CU_ASSERT_FATAL(odp_pool_info(pool, &info) == 0);
+
+ CU_ASSERT(info.pool_ext);
+ CU_ASSERT(strncmp(name, info.name, strlen(name)) == 0);
+
+ CU_ASSERT(odp_pool_destroy(pool) == 0);
+}
+
static odp_shm_t populate_pool(odp_pool_t pool, odp_pool_ext_capability_t *capa,
void *buf[], uint32_t num, uint32_t buf_size)
{
@@ -2303,6 +2355,7 @@ odp_testinfo_t pool_suite[] = {
ODP_TEST_INFO_CONDITIONAL(pool_test_vector_uarea_init, pool_check_vector_uarea_init),
ODP_TEST_INFO_CONDITIONAL(pool_test_timeout_uarea_init, pool_check_timeout_uarea_init),
ODP_TEST_INFO(pool_test_lookup_info_print),
+ ODP_TEST_INFO(pool_test_long_name),
ODP_TEST_INFO(pool_test_same_name_buf),
ODP_TEST_INFO(pool_test_same_name_pkt),
ODP_TEST_INFO(pool_test_same_name_tmo),
@@ -2347,6 +2400,7 @@ odp_testinfo_t pool_ext_suite[] = {
ODP_TEST_INFO_CONDITIONAL(test_packet_pool_ext_create, check_pool_ext_support),
ODP_TEST_INFO_CONDITIONAL(test_packet_pool_ext_lookup, check_pool_ext_support),
ODP_TEST_INFO_CONDITIONAL(test_packet_pool_ext_info, check_pool_ext_support),
+ ODP_TEST_INFO_CONDITIONAL(test_packet_pool_ext_long_name, check_pool_ext_support),
ODP_TEST_INFO_CONDITIONAL(test_packet_pool_ext_populate, check_pool_ext_support),
ODP_TEST_INFO_CONDITIONAL(test_packet_pool_ext_alloc, check_pool_ext_support),
ODP_TEST_INFO_CONDITIONAL(test_packet_pool_ext_uarea_init,
diff --git a/test/validation/api/queue/queue.c b/test/validation/api/queue/queue.c
index 4b5ccde65..992f4e4d3 100644
--- a/test/validation/api/queue/queue.c
+++ b/test/validation/api/queue/queue.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2021-2023 Nokia
*/
#include <odp_api.h>
@@ -843,6 +841,37 @@ static void queue_test_same_name_sched(void)
queue_test_same_name(1);
}
+static void queue_test_long_name(int sched)
+{
+ odp_queue_t queue;
+ odp_queue_param_t param;
+ char name[ODP_QUEUE_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ odp_queue_param_init(&param);
+
+ if (sched)
+ param.type = ODP_QUEUE_TYPE_SCHED;
+
+ queue = odp_queue_create(name, &param);
+ CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);
+ CU_ASSERT(queue == odp_queue_lookup(name));
+
+ CU_ASSERT_FATAL(odp_queue_destroy(queue) == 0);
+}
+
+static void queue_test_long_name_plain(void)
+{
+ queue_test_long_name(0);
+}
+
+static void queue_test_long_name_sched(void)
+{
+ queue_test_long_name(1);
+}
+
static void queue_test_info(void)
{
odp_queue_t q_plain, q_order;
@@ -1148,6 +1177,8 @@ odp_testinfo_t queue_suite[] = {
ODP_TEST_INFO(queue_test_param),
ODP_TEST_INFO(queue_test_same_name_plain),
ODP_TEST_INFO(queue_test_same_name_sched),
+ ODP_TEST_INFO(queue_test_long_name_plain),
+ ODP_TEST_INFO(queue_test_long_name_sched),
ODP_TEST_INFO(queue_test_info),
ODP_TEST_INFO(queue_test_mt_plain_block),
ODP_TEST_INFO(queue_test_mt_plain_nonblock_lf),
diff --git a/test/validation/api/random/random.c b/test/validation/api/random/random.c
index 551fe775d..6c32cb0f7 100644
--- a/test/validation/api/random/random.c
+++ b/test/validation/api/random/random.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2021-2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2021-2022 Nokia
*/
#include <odp_api.h>
diff --git a/test/validation/api/scheduler/scheduler.c b/test/validation/api/scheduler/scheduler.c
index 8dddd8d8f..9ecb88a5d 100644
--- a/test/validation/api/scheduler/scheduler.c
+++ b/test/validation/api/scheduler/scheduler.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2019-2024, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2019-2024 Nokia
*/
#include <odp_api.h>
@@ -987,6 +985,26 @@ static void scheduler_test_create_group(void)
CU_ASSERT_FATAL(odp_schedule(NULL, wait_time) == ODP_EVENT_INVALID);
}
+static void scheduler_test_group_long_name(void)
+{
+ odp_thrmask_t mask;
+ odp_schedule_group_t group;
+ int thr_id;
+ char name[ODP_SCHED_GROUP_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ thr_id = odp_thread_id();
+ odp_thrmask_zero(&mask);
+ odp_thrmask_set(&mask, thr_id);
+
+ group = odp_schedule_group_create(name, &mask);
+ CU_ASSERT_FATAL(group != ODP_SCHED_GROUP_INVALID);
+ CU_ASSERT(group == odp_schedule_group_lookup(name));
+ CU_ASSERT_FATAL(odp_schedule_group_destroy(group) == 0);
+}
+
static void scheduler_test_create_max_groups(void)
{
odp_thrmask_t mask;
@@ -1367,12 +1385,12 @@ static void chaos_run(unsigned int qtype)
shm = odp_shm_lookup(GLOBALS_SHM_NAME);
CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
globals = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL_FATAL(globals);
+ CU_ASSERT_FATAL(globals != NULL);
shm = odp_shm_lookup(SHM_THR_ARGS_NAME);
CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
args = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL_FATAL(args);
+ CU_ASSERT_FATAL(args != NULL);
args->globals = globals;
@@ -1798,7 +1816,7 @@ static void schedule_common(odp_schedule_sync_t sync, int num_queues,
shm = odp_shm_lookup(GLOBALS_SHM_NAME);
CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
globals = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL_FATAL(globals);
+ CU_ASSERT_FATAL(globals != NULL);
memset(&args, 0, sizeof(thread_args_t));
args.globals = globals;
@@ -1829,12 +1847,12 @@ static void parallel_execute(odp_schedule_sync_t sync, int num_queues,
shm = odp_shm_lookup(GLOBALS_SHM_NAME);
CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
globals = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL_FATAL(globals);
+ CU_ASSERT_FATAL(globals != NULL);
shm = odp_shm_lookup(SHM_THR_ARGS_NAME);
CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
args = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL_FATAL(args);
+ CU_ASSERT_FATAL(args != NULL);
args->globals = globals;
args->sync = sync;
@@ -2583,12 +2601,12 @@ static void scheduler_test_sched_and_plain(odp_schedule_sync_t sync)
shm = odp_shm_lookup(GLOBALS_SHM_NAME);
CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
globals = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL_FATAL(globals);
+ CU_ASSERT_FATAL(globals != NULL);
shm = odp_shm_lookup(SHM_THR_ARGS_NAME);
CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
args = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL_FATAL(args);
+ CU_ASSERT_FATAL(args != NULL);
args->globals = globals;
/* Make sure all events fit to queues */
@@ -3183,7 +3201,7 @@ static int create_queues(test_globals_t *globals)
for (j = 0; j < queues_per_prio; j++) {
/* Per sched sync type */
- char name[32];
+ char name[ODP_QUEUE_NAME_LEN];
odp_queue_t q, pq;
snprintf(name, sizeof(name), "sched_%d_%d_n", i, j);
@@ -3674,6 +3692,7 @@ odp_testinfo_t scheduler_basic_suite[] = {
ODP_TEST_INFO(scheduler_test_order_ignore),
ODP_TEST_INFO(scheduler_test_group_info_predef),
ODP_TEST_INFO(scheduler_test_create_group),
+ ODP_TEST_INFO(scheduler_test_group_long_name),
ODP_TEST_INFO(scheduler_test_create_max_groups),
ODP_TEST_INFO(scheduler_test_groups),
ODP_TEST_INFO(scheduler_test_pause_resume),
diff --git a/test/validation/api/scheduler/scheduler_no_predef_groups.c b/test/validation/api/scheduler/scheduler_no_predef_groups.c
index ad6f6d3a2..d2ea48eb6 100644
--- a/test/validation/api/scheduler/scheduler_no_predef_groups.c
+++ b/test/validation/api/scheduler/scheduler_no_predef_groups.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2013-2018, Linaro Limited
- * Copyright (c) 2019-2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2021 Nokia
*/
#include <odp_api.h>
diff --git a/test/validation/api/shmem/shmem.c b/test/validation/api/shmem/shmem.c
index 9e91dab35..51a6b316e 100644
--- a/test/validation/api/shmem/shmem.c
+++ b/test/validation/api/shmem/shmem.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2019-2021, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014-2018 Linaro Limited
+ * Copyright (c) 2019-2021 Nokia
*/
#include <odp_api.h>
@@ -261,6 +259,20 @@ static void shmem_test_reserve(void)
CU_ASSERT(odp_shm_free(shm) == 0);
}
+static void shmem_test_reserve_long_name(void)
+{
+ odp_shm_t shm;
+ char name[ODP_SHM_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ shm = odp_shm_reserve(name, MEDIUM_MEM, ALIGN_SIZE, 0);
+ CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
+ CU_ASSERT_FATAL(shm == odp_shm_lookup(name));
+ CU_ASSERT(odp_shm_free(shm) == 0);
+}
+
static void shmem_test_info(void)
{
odp_shm_t shm;
@@ -610,7 +622,7 @@ static int run_test_reserve_after_fork(void *arg ODP_UNUSED)
CU_ASSERT(ODP_SHM_INVALID != shm);
glob_data->shm[thr_index] = shm;
pattern_small = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL(pattern_small);
+ CU_ASSERT(pattern_small != NULL);
for (i = 0; i < SMALL_MEM; i++)
pattern_small->data[i] = i;
break;
@@ -620,7 +632,7 @@ static int run_test_reserve_after_fork(void *arg ODP_UNUSED)
CU_ASSERT(ODP_SHM_INVALID != shm);
glob_data->shm[thr_index] = shm;
pattern_medium = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL(pattern_medium);
+ CU_ASSERT(pattern_medium != NULL);
for (i = 0; i < MEDIUM_MEM; i++)
pattern_medium->data[i] = (i << 2);
break;
@@ -630,7 +642,7 @@ static int run_test_reserve_after_fork(void *arg ODP_UNUSED)
CU_ASSERT(ODP_SHM_INVALID != shm);
glob_data->shm[thr_index] = shm;
pattern_big = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL(pattern_big);
+ CU_ASSERT(pattern_big != NULL);
for (i = 0; i < BIG_MEM; i++)
pattern_big->data[i] = (i >> 2);
break;
@@ -663,7 +675,7 @@ static void shmem_test_reserve_after_fork(void)
shm = odp_shm_reserve(MEM_NAME, sizeof(shared_test_data_t), 0, 0);
CU_ASSERT(ODP_SHM_INVALID != shm);
glob_data = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL(glob_data);
+ CU_ASSERT(glob_data != NULL);
num = odp_cpumask_default_worker(NULL, 0);
if (num > MAX_WORKERS)
@@ -690,21 +702,21 @@ static void shmem_test_reserve_after_fork(void)
case 0:
pattern_small =
odp_shm_addr(glob_data->shm[thr_index]);
- CU_ASSERT_PTR_NOT_NULL(pattern_small);
+ CU_ASSERT(pattern_small != NULL);
for (i = 0; i < SMALL_MEM; i++)
CU_ASSERT(pattern_small->data[i] == i);
break;
case 1:
pattern_medium =
odp_shm_addr(glob_data->shm[thr_index]);
- CU_ASSERT_PTR_NOT_NULL(pattern_medium);
+ CU_ASSERT(pattern_medium != NULL);
for (i = 0; i < MEDIUM_MEM; i++)
CU_ASSERT(pattern_medium->data[i] == (i << 2));
break;
case 2:
pattern_big =
odp_shm_addr(glob_data->shm[thr_index]);
- CU_ASSERT_PTR_NOT_NULL(pattern_big);
+ CU_ASSERT(pattern_big != NULL);
for (i = 0; i < BIG_MEM; i++)
CU_ASSERT(pattern_big->data[i] == (i >> 2));
break;
@@ -774,7 +786,7 @@ static int run_test_singleva_after_fork(void *arg ODP_UNUSED)
CU_ASSERT_FATAL(ODP_SHM_INVALID != shm);
glob_data->shm[thr_index] = shm;
pattern_small = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL(pattern_small);
+ CU_ASSERT(pattern_small != NULL);
glob_data->address[thr_index] = (void *)pattern_small;
for (i = 0; i < SMALL_MEM; i++)
pattern_small->data[i] = i;
@@ -786,7 +798,7 @@ static int run_test_singleva_after_fork(void *arg ODP_UNUSED)
CU_ASSERT_FATAL(ODP_SHM_INVALID != shm);
glob_data->shm[thr_index] = shm;
pattern_medium = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL(pattern_medium);
+ CU_ASSERT(pattern_medium != NULL);
glob_data->address[thr_index] = (void *)pattern_medium;
for (i = 0; i < MEDIUM_MEM; i++)
pattern_medium->data[i] = (i << 2);
@@ -798,7 +810,7 @@ static int run_test_singleva_after_fork(void *arg ODP_UNUSED)
CU_ASSERT_FATAL(ODP_SHM_INVALID != shm);
glob_data->shm[thr_index] = shm;
pattern_big = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL(pattern_big);
+ CU_ASSERT(pattern_big != NULL);
glob_data->address[thr_index] = (void *)pattern_big;
for (i = 0; i < BIG_MEM; i++)
pattern_big->data[i] = (i >> 2);
@@ -855,7 +867,7 @@ static void shmem_test_singleva_after_fork(void)
0, 0);
CU_ASSERT(ODP_SHM_INVALID != shm);
glob_data = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL(glob_data);
+ CU_ASSERT(glob_data != NULL);
num = odp_cpumask_default_worker(NULL, 3);
if (num > MAX_WORKERS)
@@ -885,21 +897,21 @@ static void shmem_test_singleva_after_fork(void)
case 0:
pattern_small =
odp_shm_addr(glob_data->shm[thr_index]);
- CU_ASSERT_PTR_NOT_NULL_FATAL(pattern_small);
+ CU_ASSERT_FATAL(pattern_small != NULL);
for (i = 0; i < SMALL_MEM; i++)
CU_ASSERT(pattern_small->data[i] == i);
break;
case 1:
pattern_medium =
odp_shm_addr(glob_data->shm[thr_index]);
- CU_ASSERT_PTR_NOT_NULL_FATAL(pattern_medium);
+ CU_ASSERT_FATAL(pattern_medium != NULL);
for (i = 0; i < MEDIUM_MEM; i++)
CU_ASSERT(pattern_medium->data[i] == (i << 2));
break;
case 2:
pattern_big =
odp_shm_addr(glob_data->shm[thr_index]);
- CU_ASSERT_PTR_NOT_NULL_FATAL(pattern_big);
+ CU_ASSERT_FATAL(pattern_big != NULL);
for (i = 0; i < BIG_MEM; i++)
CU_ASSERT(pattern_big->data[i] == (i >> 2));
break;
@@ -950,7 +962,7 @@ static int run_test_stress(void *arg ODP_UNUSED)
shm = odp_shm_lookup(MEM_NAME);
glob_data = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL(glob_data);
+ CU_ASSERT(glob_data != NULL);
/* wait for general GO! */
odp_barrier_wait(&glob_data->test_barrier1);
@@ -1000,7 +1012,7 @@ static int run_test_stress(void *arg ODP_UNUSED)
}
address = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL(address);
+ CU_ASSERT(address != NULL);
glob_data->stress[index].address = address;
glob_data->stress[index].flags = flags;
glob_data->stress[index].size = size;
@@ -1035,7 +1047,7 @@ static int run_test_stress(void *arg ODP_UNUSED)
!= 0);
address = odp_shm_addr(shm);
- CU_ASSERT_PTR_NOT_NULL(address);
+ CU_ASSERT(address != NULL);
align = glob_data->stress[index].align;
if (align) {
@@ -1091,7 +1103,7 @@ static void shmem_test_stress(void)
0, 0);
CU_ASSERT(ODP_SHM_INVALID != globshm);
glob_data = odp_shm_addr(globshm);
- CU_ASSERT_PTR_NOT_NULL(glob_data);
+ CU_ASSERT(glob_data != NULL);
num = odp_cpumask_default_worker(NULL, 0);
if (num > MAX_WORKERS)
@@ -1139,6 +1151,7 @@ static int shm_suite_init(void)
odp_testinfo_t shmem_suite[] = {
ODP_TEST_INFO(shmem_test_capability),
ODP_TEST_INFO(shmem_test_reserve),
+ ODP_TEST_INFO(shmem_test_reserve_long_name),
ODP_TEST_INFO(shmem_test_info),
ODP_TEST_INFO_CONDITIONAL(shmem_test_flag_hp, shmem_check_flag_hp),
ODP_TEST_INFO_CONDITIONAL(shmem_test_flag_no_hp, shmem_check_flag_no_hp),
diff --git a/test/validation/api/stash/stash.c b/test/validation/api/stash/stash.c
index 162697ba9..80b09fd93 100644
--- a/test/validation/api/stash/stash.c
+++ b/test/validation/api/stash/stash.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2020-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020-2023 Nokia
*/
#include <odp_api.h>
@@ -237,6 +235,30 @@ static void stash_create_u32(void)
CU_ASSERT_FATAL(odp_stash_destroy(stash) == 0);
}
+static void stash_create_u32_long_name(void)
+{
+ odp_stash_t stash;
+ odp_stash_param_t param;
+ uint32_t num = global.num_default.u32;
+ char name[ODP_STASH_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ odp_stash_param_init(&param);
+ param.num_obj = num;
+ param.obj_size = sizeof(uint32_t);
+
+ stash = odp_stash_create(name, &param);
+
+ CU_ASSERT_FATAL(stash != ODP_STASH_INVALID);
+
+ printf("\n Stash handle: 0x%" PRIx64 "\n", odp_stash_to_u64(stash));
+
+ CU_ASSERT(stash == odp_stash_lookup(name));
+ CU_ASSERT_FATAL(odp_stash_destroy(stash) == 0);
+}
+
static void stash_create_u64_all(void)
{
odp_stash_param_t param;
@@ -1309,6 +1331,7 @@ odp_testinfo_t stash_suite[] = {
ODP_TEST_INFO(stash_param_defaults),
ODP_TEST_INFO_CONDITIONAL(stash_create_u64, check_support_64),
ODP_TEST_INFO(stash_create_u32),
+ ODP_TEST_INFO(stash_create_u32_long_name),
ODP_TEST_INFO_CONDITIONAL(stash_default_put_u64_1, check_support_64),
ODP_TEST_INFO_CONDITIONAL(stash_default_put_u64_n, check_support_64),
ODP_TEST_INFO_CONDITIONAL(stash_default_u64_put_u64_1, check_support_64),
diff --git a/test/validation/api/std/std.c b/test/validation/api/std/std.c
index 161ee87cf..85a8ec0a5 100644
--- a/test/validation/api/std/std.c
+++ b/test/validation/api/std/std.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <odp_api.h>
diff --git a/test/validation/api/system/system.c b/test/validation/api/system/system.c
index 3f7e0497d..63a0a7e2a 100644
--- a/test/validation/api/system/system.c
+++ b/test/validation/api/system/system.c
@@ -1,7 +1,5 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
*/
#include <ctype.h>
@@ -27,8 +25,8 @@ static void test_version_api_str(void)
char version_string[128];
char *s = version_string;
- strncpy(version_string, odp_version_api_str(),
- sizeof(version_string) - 1);
+ odph_strcpy(version_string, odp_version_api_str(),
+ sizeof(version_string));
while (*s) {
if (isdigit((int)*s) || (strncmp(s, ".", 1) == 0)) {
@@ -77,186 +75,6 @@ static void test_version_macro(void)
ODP_VERSION_API);
}
-static void system_test_odp_cpu_count(void)
-{
- int cpus;
-
- cpus = odp_cpu_count();
- CU_ASSERT(0 < cpus);
-}
-
-static void system_test_cpu_cycles(void)
-{
- uint64_t c2, c1, diff, max;
-
- c1 = odp_cpu_cycles();
- odp_time_wait_ns(WAIT_TIME);
- c2 = odp_cpu_cycles();
-
- CU_ASSERT(c2 != c1);
-
- max = odp_cpu_cycles_max();
-
- /* With 10 usec delay, diff should be small compared to the maximum.
- * Otherwise, counter is going backwards. */
- if (c2 > c1) {
- diff = c2 - c1;
- CU_ASSERT(diff < (max - diff));
- }
-
- /* Same applies also when there was a wrap. */
- if (c2 < c1) {
- diff = max - c1 + c2;
- CU_ASSERT(diff < (max - diff));
- }
-}
-
-static void system_test_cpu_cycles_max(void)
-{
- uint64_t c2, c1;
- uint64_t max1, max2;
-
- max1 = odp_cpu_cycles_max();
- odp_time_wait_ns(WAIT_TIME);
- max2 = odp_cpu_cycles_max();
-
- CU_ASSERT(max1 >= UINT32_MAX / 2);
- CU_ASSERT(max1 == max2);
-
- c1 = odp_cpu_cycles();
- odp_time_wait_ns(WAIT_TIME);
- c2 = odp_cpu_cycles();
-
- CU_ASSERT(c1 <= max1 && c2 <= max1);
-}
-
-static void system_test_cpu_cycles_resolution(void)
-{
- int i;
- uint64_t res;
- uint64_t c2, c1, max;
- uint64_t test_cycles = odp_cpu_hz() / 100; /* CPU cycles in 10 msec */
-
- max = odp_cpu_cycles_max();
-
- res = odp_cpu_cycles_resolution();
- CU_ASSERT(res != 0);
- CU_ASSERT(res < max / 1024);
-
- for (i = 0; i < RES_TRY_NUM; i++) {
- c1 = odp_cpu_cycles();
- odp_time_wait_ns(10 * ODP_TIME_MSEC_IN_NS + i);
- c2 = odp_cpu_cycles();
-
- /* Diff may be zero with low resolution */
- if (test_cycles && test_cycles > res) {
- uint64_t diff = odp_cpu_cycles_diff(c2, c1);
-
- CU_ASSERT(diff >= res);
- }
-
- }
-}
-
-static void system_test_cpu_cycles_diff(void)
-{
- uint64_t c2, c1, max;
- uint64_t tmp, diff, res;
-
- res = odp_cpu_cycles_resolution();
- max = odp_cpu_cycles_max();
-
- c1 = res;
- c2 = 2 * res;
- diff = odp_cpu_cycles_diff(c2, c1);
- CU_ASSERT(diff == res);
-
- c1 = odp_cpu_cycles();
- odp_time_wait_ns(WAIT_TIME);
- c2 = odp_cpu_cycles();
- diff = odp_cpu_cycles_diff(c2, c1);
- CU_ASSERT(diff > 0);
- CU_ASSERT(diff < (max - diff));
-
- /* check resolution for wrap */
- c1 = max - 2 * res;
- do
- c2 = odp_cpu_cycles();
- while (c1 < c2);
-
- diff = odp_cpu_cycles_diff(c1, c1);
- CU_ASSERT(diff == 0);
-
- /* wrap */
- tmp = c2 + (max - c1) + res;
- diff = odp_cpu_cycles_diff(c2, c1);
- CU_ASSERT(diff == tmp);
-
- /* no wrap, revert args */
- tmp = c1 - c2;
- diff = odp_cpu_cycles_diff(c1, c2);
- CU_ASSERT(diff == tmp);
-}
-
-static void system_test_cpu_cycles_long_period(void)
-{
- int i;
- int periods = PERIODS_100_MSEC;
- uint64_t max_period_duration = 100 * ODP_TIME_MSEC_IN_NS + periods - 1;
- uint64_t c2, c1, c3, max;
- uint64_t tmp, diff, res;
-
- res = odp_cpu_cycles_resolution();
- max = odp_cpu_cycles_max();
-
- c3 = odp_cpu_cycles();
-
- CU_ASSERT(c3 <= max);
- /*
- * If the cycle counter is not close to wrapping around during
- * the test, then speed up the test by not trying to see the wrap
- * around too hard. Assume cycle counter frequency of less than 10 GHz.
- */
- CU_ASSERT(odp_cpu_hz_max() < 10ULL * ODP_TIME_SEC_IN_NS);
- if (max - c3 > 10 * periods * max_period_duration)
- periods = 10;
-
- printf("\n Testing CPU cycles for %i seconds... ", periods / 10);
-
- for (i = 0; i < periods; i++) {
- c1 = odp_cpu_cycles();
- odp_time_wait_ns(100 * ODP_TIME_MSEC_IN_NS + i);
- c2 = odp_cpu_cycles();
-
- CU_ASSERT(c2 != c1);
- CU_ASSERT(c1 <= max && c2 <= max);
-
- if (c2 > c1)
- tmp = c2 - c1;
- else
- tmp = c2 + (max - c1) + res;
-
- diff = odp_cpu_cycles_diff(c2, c1);
- CU_ASSERT(diff == tmp);
-
- /* wrap is detected and verified */
- if (c2 < c1)
- break;
- }
-
- /* wrap was detected, no need to continue */
- if (i < periods) {
- printf("wrap was detected.\n");
- return;
- }
-
- /* wrap has to be detected if possible */
- CU_ASSERT(max > UINT32_MAX);
- CU_ASSERT((max - c3) > UINT32_MAX);
-
- printf("wrap was not detected.\n");
-}
-
static void system_test_odp_sys_cache_line_size(void)
{
uint64_t cache_size;
@@ -277,32 +95,6 @@ static void system_test_odp_sys_cache_line_size(void)
2 * ODP_CACHE_LINE_SIZE);
}
-static void system_test_odp_cpu_model_str(void)
-{
- char model[128];
-
- snprintf(model, 128, "%s", odp_cpu_model_str());
- CU_ASSERT(strlen(model) > 0);
- CU_ASSERT(strlen(model) < 127);
-}
-
-static void system_test_odp_cpu_model_str_id(void)
-{
- char model[128];
- odp_cpumask_t mask;
- int i, num, cpu;
-
- num = odp_cpumask_all_available(&mask);
- cpu = odp_cpumask_first(&mask);
-
- for (i = 0; i < num; i++) {
- snprintf(model, 128, "%s", odp_cpu_model_str_id(cpu));
- CU_ASSERT(strlen(model) > 0);
- CU_ASSERT(strlen(model) < 127);
- cpu = odp_cpumask_next(&mask, cpu);
- }
-}
-
static void system_test_odp_sys_page_size(void)
{
uint64_t page;
@@ -343,135 +135,6 @@ static void system_test_odp_sys_huge_page_size_all(void)
}
}
-static int system_check_cycle_counter(void)
-{
- if (odp_cpu_cycles_max() == 0) {
- printf("Cycle counter is not supported, skipping test\n");
- return ODP_TEST_INACTIVE;
- }
-
- return ODP_TEST_ACTIVE;
-}
-
-static int system_check_odp_cpu_hz(void)
-{
- if (odp_cpu_hz() == 0) {
- printf("odp_cpu_hz() is not supported, skipping test\n");
- return ODP_TEST_INACTIVE;
- }
-
- return ODP_TEST_ACTIVE;
-}
-
-static void system_test_odp_cpu_hz(void)
-{
- uint64_t hz = odp_cpu_hz();
-
- /* Test value sanity: less than 10GHz */
- CU_ASSERT(hz < 10 * GIGA_HZ);
-
- /* larger than 1kHz */
- CU_ASSERT(hz > 1 * KILO_HZ);
-}
-
-static int system_check_odp_cpu_hz_id(void)
-{
- uint64_t hz;
- odp_cpumask_t mask;
- int i, num, cpu;
-
- num = odp_cpumask_all_available(&mask);
- cpu = odp_cpumask_first(&mask);
-
- for (i = 0; i < num; i++) {
- hz = odp_cpu_hz_id(cpu);
- if (hz == 0) {
- printf("odp_cpu_hz_id() is not supported by CPU %d, skipping test\n", cpu);
- return ODP_TEST_INACTIVE;
- }
- cpu = odp_cpumask_next(&mask, cpu);
- }
-
- return ODP_TEST_ACTIVE;
-}
-
-static void system_test_odp_cpu_hz_id(void)
-{
- uint64_t hz;
- odp_cpumask_t mask;
- int i, num, cpu;
-
- num = odp_cpumask_all_available(&mask);
- cpu = odp_cpumask_first(&mask);
-
- for (i = 0; i < num; i++) {
- hz = odp_cpu_hz_id(cpu);
- /* Test value sanity: less than 10GHz */
- CU_ASSERT(hz < 10 * GIGA_HZ);
- /* larger than 1kHz */
- CU_ASSERT(hz > 1 * KILO_HZ);
- cpu = odp_cpumask_next(&mask, cpu);
- }
-}
-
-static int system_check_odp_cpu_hz_max(void)
-{
- if (odp_cpu_hz_max() == 0) {
- printf("odp_cpu_hz_max() is not supported, skipping test\n");
- return ODP_TEST_INACTIVE;
- }
- return ODP_TEST_ACTIVE;
-}
-
-static void system_test_odp_cpu_hz_max(void)
-{
- uint64_t hz = odp_cpu_hz_max();
-
- /* Sanity check value */
- CU_ASSERT(hz > 1 * KILO_HZ);
- CU_ASSERT(hz < 20 * GIGA_HZ);
-}
-
-static int system_check_odp_cpu_hz_max_id(void)
-{
- uint64_t hz;
- odp_cpumask_t mask;
- int i, num, cpu;
-
- num = odp_cpumask_all_available(&mask);
- cpu = odp_cpumask_first(&mask);
-
- for (i = 0; i < num; i++) {
- hz = odp_cpu_hz_max_id(cpu);
- if (hz == 0) {
- printf("odp_cpu_hz_max_id() is not supported by CPU %d, skipping test\n",
- cpu);
- return ODP_TEST_INACTIVE;
- }
- cpu = odp_cpumask_next(&mask, cpu);
- }
-
- return ODP_TEST_ACTIVE;
-}
-
-static void system_test_odp_cpu_hz_max_id(void)
-{
- uint64_t hz;
- odp_cpumask_t mask;
- int i, num, cpu;
-
- num = odp_cpumask_all_available(&mask);
- cpu = odp_cpumask_first(&mask);
-
- for (i = 0; i < num; i++) {
- hz = odp_cpu_hz_max_id(cpu);
- /* Sanity check value */
- CU_ASSERT(hz > 1 * KILO_HZ);
- CU_ASSERT(hz < 20 * GIGA_HZ);
- cpu = odp_cpumask_next(&mask, cpu);
- }
-}
-
static void system_test_info_print(void)
{
printf("\n\nCalling system info print...\n");
@@ -645,31 +308,10 @@ odp_testinfo_t system_suite[] = {
ODP_TEST_INFO(test_version_api_str),
ODP_TEST_INFO(test_version_str),
ODP_TEST_INFO(test_version_macro),
- ODP_TEST_INFO(system_test_odp_cpu_count),
ODP_TEST_INFO(system_test_odp_sys_cache_line_size),
- ODP_TEST_INFO(system_test_odp_cpu_model_str),
- ODP_TEST_INFO(system_test_odp_cpu_model_str_id),
ODP_TEST_INFO(system_test_odp_sys_page_size),
ODP_TEST_INFO(system_test_odp_sys_huge_page_size),
ODP_TEST_INFO(system_test_odp_sys_huge_page_size_all),
- ODP_TEST_INFO_CONDITIONAL(system_test_odp_cpu_hz,
- system_check_odp_cpu_hz),
- ODP_TEST_INFO_CONDITIONAL(system_test_odp_cpu_hz_id,
- system_check_odp_cpu_hz_id),
- ODP_TEST_INFO_CONDITIONAL(system_test_odp_cpu_hz_max,
- system_check_odp_cpu_hz_max),
- ODP_TEST_INFO_CONDITIONAL(system_test_odp_cpu_hz_max_id,
- system_check_odp_cpu_hz_max_id),
- ODP_TEST_INFO_CONDITIONAL(system_test_cpu_cycles,
- system_check_cycle_counter),
- ODP_TEST_INFO_CONDITIONAL(system_test_cpu_cycles_max,
- system_check_cycle_counter),
- ODP_TEST_INFO_CONDITIONAL(system_test_cpu_cycles_resolution,
- system_check_cycle_counter),
- ODP_TEST_INFO_CONDITIONAL(system_test_cpu_cycles_diff,
- system_check_cycle_counter),
- ODP_TEST_INFO_CONDITIONAL(system_test_cpu_cycles_long_period,
- system_check_cycle_counter),
ODP_TEST_INFO(system_test_info),
ODP_TEST_INFO(system_test_meminfo),
ODP_TEST_INFO(system_test_info_print),
diff --git a/test/validation/api/thread/thread.c b/test/validation/api/thread/thread.c
index ad9ffa745..778e51b07 100644
--- a/test/validation/api/thread/thread.c
+++ b/test/validation/api/thread/thread.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2022 Nokia
*/
#include <odp_api.h>
@@ -83,11 +81,6 @@ static int thread_global_term(odp_instance_t inst)
return 0;
}
-static void thread_test_odp_cpu_id(void)
-{
- CU_ASSERT(odp_cpu_id() >= 0);
-}
-
static void thread_test_odp_thread_id(void)
{
int id = odp_thread_id();
@@ -222,7 +215,6 @@ static void thread_test_odp_thrmask_control(void)
}
odp_testinfo_t thread_suite[] = {
- ODP_TEST_INFO(thread_test_odp_cpu_id),
ODP_TEST_INFO(thread_test_odp_thread_id),
ODP_TEST_INFO(thread_test_odp_thread_count),
ODP_TEST_INFO(thread_test_odp_thread_count_max),
diff --git a/test/validation/api/time/time.c b/test/validation/api/time/time.c
index cfef7f619..67eae7190 100644
--- a/test/validation/api/time/time.c
+++ b/test/validation/api/time/time.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2019-2024, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2019-2024 Nokia
*/
#ifndef _GNU_SOURCE
@@ -19,14 +17,15 @@
#define MIN_TIME_RATE 32000
#define MAX_TIME_RATE 15000000000
#define DELAY_TOLERANCE 40000000 /* deviation for delay */
-#define WAIT_SECONDS 3
+#define WAIT_SECONDS 3
#define MAX_WORKERS 32
+#define TEST_ROUNDS 1024
#define TIME_SAMPLES 2
#define TIME_TOLERANCE_NS 1000000
#define TIME_TOLERANCE_CI_NS 40000000
#define TIME_TOLERANCE_1CPU_NS 40000000
#define GLOBAL_SHM_NAME "GlobalTimeTest"
-#define YEAR_IN_NS (365 * 24 * ODP_TIME_HOUR_IN_NS)
+#define YEAR_IN_NS (365 * 24 * ODP_TIME_HOUR_IN_NS)
static uint64_t local_res;
static uint64_t global_res;
@@ -40,6 +39,9 @@ typedef struct {
uint32_t num_threads;
odp_barrier_t test_barrier;
odp_time_t time[MAX_WORKERS + 1][TIME_SAMPLES];
+ odp_queue_t queue[MAX_WORKERS];
+ uint32_t num_queues;
+ odp_atomic_u32_t event_count;
} global_shared_mem_t;
static global_shared_mem_t *global_mem;
@@ -924,7 +926,14 @@ static void time_test_global_sync(const int ctrl)
cpu = odp_cpumask_next(&cpumask, cpu);
}
- CU_ASSERT(odph_thread_join(thread_tbl, num) == num);
+ odph_thread_join_result_t res[num];
+
+ int ret = odph_thread_join_result(thread_tbl, res, num);
+
+ CU_ASSERT(ret == num);
+
+ for (int i = 0; i < num; i++)
+ CU_ASSERT(!res[i].is_sig && res[i].ret == 0);
for (int s = 0; s < TIME_SAMPLES; s++) {
int min_idx = 0, max_idx = 0;
@@ -975,6 +984,179 @@ static void time_test_global_sync_control(void)
time_test_global_sync(1);
}
+static odp_queue_t select_dst_queue(int thread_id, const odp_queue_t queue[], uint32_t num)
+{
+ uint8_t rand_u8;
+ int rand_id = 0;
+
+ if (num == 1)
+ return queue[0];
+
+ do {
+ odp_random_data(&rand_u8, 1, ODP_RANDOM_BASIC);
+ rand_id = rand_u8 % num;
+ } while (rand_id == thread_id);
+
+ return queue[rand_id];
+}
+
+static int run_time_global_thread(void *arg)
+{
+ global_shared_mem_t *gbl = arg;
+ const int thread_id = odp_thread_id();
+ const odp_queue_t src_queue = gbl->queue[thread_id % gbl->num_queues];
+ const odp_queue_t *queues = gbl->queue;
+ const uint32_t num_queues = gbl->num_queues;
+ odp_atomic_u32_t *event_count = &gbl->event_count;
+
+ odp_barrier_wait(&gbl->test_barrier);
+
+ while (odp_atomic_load_u32(event_count) < TEST_ROUNDS) {
+ odp_time_t *ts;
+ odp_time_t cur_time;
+ odp_buffer_t buf;
+ odp_queue_t dst_queue;
+ odp_event_t ev = odp_queue_deq(src_queue);
+
+ if (ev == ODP_EVENT_INVALID) {
+ odp_cpu_pause();
+ continue;
+ }
+
+ cur_time = odp_time_global();
+
+ buf = odp_buffer_from_event(ev);
+ ts = odp_buffer_addr(buf);
+
+ CU_ASSERT(odp_time_cmp(cur_time, *ts) >= 0);
+
+ *ts = cur_time;
+
+ dst_queue = select_dst_queue(thread_id, queues, num_queues);
+
+ CU_ASSERT_FATAL(odp_queue_enq(dst_queue, ev) == 0);
+
+ odp_atomic_inc_u32(event_count);
+ }
+ return 0;
+}
+
+static void time_test_global_mt(void)
+{
+ odp_cpumask_t cpumask;
+ odp_pool_t pool;
+ odp_pool_param_t pool_param;
+ odp_pool_capability_t pool_capa;
+ odp_queue_param_t queue_param;
+ odp_queue_capability_t queue_capa;
+ odph_thread_t thread_tbl[MAX_WORKERS];
+ odph_thread_common_param_t thr_common;
+ odph_thread_param_t thr_param;
+ odp_time_t cur_time;
+ uint32_t i;
+ int num_workers = odp_cpumask_default_worker(&cpumask, global_mem->num_threads);
+ uint32_t num_events = num_workers;
+ uint32_t num_queues = num_workers;
+
+ CU_ASSERT_FATAL(odp_pool_capability(&pool_capa) == 0);
+ CU_ASSERT_FATAL(odp_queue_capability(&queue_capa) == 0);
+
+ if (pool_capa.buf.max_num && num_events > pool_capa.buf.max_num)
+ num_events = pool_capa.buf.max_num;
+
+ if (queue_capa.plain.max_size && num_events > queue_capa.plain.max_size)
+ num_events = queue_capa.plain.max_size;
+
+ if (queue_capa.plain.max_num < num_queues)
+ num_queues = queue_capa.plain.max_num;
+ CU_ASSERT_FATAL(num_queues > 0);
+
+ odp_pool_param_init(&pool_param);
+ pool_param.buf.size = sizeof(odp_time_t);
+ pool_param.buf.num = num_events;
+ pool_param.type = ODP_POOL_BUFFER;
+
+ pool = odp_pool_create("test event pool", &pool_param);
+ CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+ odp_queue_param_init(&queue_param);
+ queue_param.size = num_events;
+ queue_param.type = ODP_QUEUE_TYPE_PLAIN;
+
+ for (i = 0; i < num_queues; i++) {
+ global_mem->queue[i] = odp_queue_create(NULL, &queue_param);
+ CU_ASSERT_FATAL(global_mem->queue[i] != ODP_QUEUE_INVALID);
+ }
+ global_mem->num_queues = num_queues;
+
+ odp_atomic_init_u32(&global_mem->event_count, 0);
+
+ for (i = 0; i < num_events; i++) {
+ odp_time_t *ts;
+ odp_buffer_t buf = odp_buffer_alloc(pool);
+
+ if (buf == ODP_BUFFER_INVALID)
+ break;
+
+ ts = odp_buffer_addr(buf);
+ *ts = odp_time_global();
+
+ CU_ASSERT_FATAL(odp_queue_enq(global_mem->queue[i % num_queues],
+ odp_buffer_to_event(buf)) == 0);
+ }
+ CU_ASSERT_FATAL(i > 0);
+ CU_ASSERT(i == num_events);
+
+ odp_barrier_init(&global_mem->test_barrier, num_workers);
+
+ odph_thread_param_init(&thr_param);
+ thr_param.start = run_time_global_thread;
+ thr_param.arg = global_mem;
+ thr_param.thr_type = ODP_THREAD_WORKER;
+
+ odph_thread_common_param_init(&thr_common);
+ thr_common.instance = *instance;
+ thr_common.cpumask = &cpumask;
+ thr_common.share_param = 1;
+
+ CU_ASSERT_FATAL(odph_thread_create(thread_tbl, &thr_common, &thr_param, num_workers) ==
+ num_workers);
+
+ odph_thread_join_result_t res[num_workers];
+
+ int ret = odph_thread_join_result(thread_tbl, res, num_workers);
+
+ CU_ASSERT(ret == num_workers);
+
+ for (i = 0; i < (uint32_t)num_workers; i++)
+ CU_ASSERT(!res[i].is_sig && res[i].ret == 0);
+
+ cur_time = odp_time_global_strict();
+
+ for (i = 0; i < num_queues; i++) {
+ odp_queue_t queue = global_mem->queue[i];
+
+ while (1) {
+ odp_buffer_t buf;
+ odp_time_t *ts;
+ odp_event_t ev = odp_queue_deq(queue);
+
+ if (ev == ODP_EVENT_INVALID)
+ break;
+
+ buf = odp_buffer_from_event(ev);
+ ts = odp_buffer_addr(buf);
+
+ CU_ASSERT(odp_time_cmp(cur_time, *ts) >= 0);
+ odp_buffer_free(buf);
+ };
+
+ CU_ASSERT(odp_queue_destroy(queue) == 0);
+ }
+
+ CU_ASSERT(odp_pool_destroy(pool) == 0);
+}
+
odp_testinfo_t time_suite_time[] = {
ODP_TEST_INFO(time_test_constants),
ODP_TEST_INFO(time_test_startup_time),
@@ -983,6 +1165,7 @@ odp_testinfo_t time_suite_time[] = {
ODP_TEST_INFO(time_test_local_cmp),
ODP_TEST_INFO(time_test_local_diff),
ODP_TEST_INFO(time_test_local_sum),
+ ODP_TEST_INFO(time_test_global_mt),
ODP_TEST_INFO(time_test_global_res),
ODP_TEST_INFO(time_test_global_conversion),
ODP_TEST_INFO(time_test_global_cmp),
diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c
index 3678d0cb2..98637b2e1 100644
--- a/test/validation/api/timer/timer.c
+++ b/test/validation/api/timer/timer.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2019-2023 Nokia
*/
/* For rand_r and nanosleep */
@@ -650,6 +648,7 @@ static void timer_test_timeout_user_area(void)
CU_ASSERT(prev != addr);
ev = odp_timeout_to_event(tmo[i]);
+ odp_event_user_flag_set(ev, 1);
CU_ASSERT(odp_event_user_area(ev) == addr);
CU_ASSERT(odp_event_user_area_and_flag(ev, &flag) == addr);
CU_ASSERT(flag < 0);
@@ -748,6 +747,32 @@ static void timer_pool_create_destroy(void)
CU_ASSERT(odp_queue_destroy(queue) == 0);
}
+static void timer_pool_long_name(void)
+{
+ odp_timer_pool_param_t tparam;
+ odp_timer_pool_info_t info;
+ odp_timer_pool_t pool;
+ odp_timer_clk_src_t clk_src = test_global->clk_src;
+ char name[ODP_TIMER_POOL_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ odp_timer_pool_param_init(&tparam);
+ tparam.res_ns = global_mem->param.res_ns;
+ tparam.min_tmo = global_mem->param.min_tmo;
+ tparam.max_tmo = global_mem->param.max_tmo;
+ tparam.num_timers = 100;
+ tparam.priv = 0;
+ tparam.clk_src = clk_src;
+
+ pool = odp_timer_pool_create(name, &tparam);
+ CU_ASSERT(pool != ODP_TIMER_POOL_INVALID);
+ CU_ASSERT(odp_timer_pool_info(pool, &info) == 0);
+ CU_ASSERT(!strcmp(name, info.name));
+ odp_timer_pool_destroy(pool);
+}
+
static void timer_pool_create_max(void)
{
odp_timer_capability_t capa;
@@ -3160,6 +3185,7 @@ odp_suiteinfo_t timer_general_suites[] = {
odp_testinfo_t timer_suite[] = {
ODP_TEST_INFO(timer_test_capa),
ODP_TEST_INFO(timer_pool_create_destroy),
+ ODP_TEST_INFO(timer_pool_long_name),
ODP_TEST_INFO(timer_pool_create_max),
ODP_TEST_INFO(timer_pool_max_res),
ODP_TEST_INFO(timer_pool_current_tick),
diff --git a/test/validation/api/traffic_mngr/traffic_mngr.c b/test/validation/api/traffic_mngr/traffic_mngr.c
index b7f546dcd..dcf21b820 100644
--- a/test/validation/api/traffic_mngr/traffic_mngr.c
+++ b/test/validation/api/traffic_mngr/traffic_mngr.c
@@ -1,9 +1,7 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2022, Marvell
- * Copyright (c) 2022, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2022 Marvell
+ * Copyright (c) 2022 Nokia
*/
#ifndef _GNU_SOURCE
@@ -67,7 +65,8 @@
#define MAX_PKTS 1000u
#define PKT_BUF_SIZE 1460
-#define MAX_PAYLOAD 1400
+#define MIN_HDR_LEN (ODPH_ETHHDR_LEN + ODPH_UDPHDR_LEN + ODPH_IPV4HDR_LEN)
+#define MAX_PAYLOAD (PKT_BUF_SIZE - MIN_HDR_LEN)
#define USE_IPV4 false
#define USE_IPV6 true
#define USE_UDP false
@@ -103,7 +102,6 @@
#define ETHERNET_OVHD_LEN (ETHERNET_IFG + ETHERNET_PREAMBLE)
#define CRC_LEN 4
#define SHAPER_LEN_ADJ ETHERNET_OVHD_LEN
-#define TM_NAME_LEN 32
#define BILLION 1000000000ULL
#define MS 1000000 /* Millisecond in units of NS */
#define MBPS 1000000
@@ -801,6 +799,12 @@ static odp_packet_t make_pkt(odp_pool_t pkt_pool,
uint8_t *buf, *pkt_class_ptr, next_hdr;
int rc;
+ if (payload_len > MAX_PAYLOAD) {
+ ODPH_ERR("packet payload length of %u exceeds MAX_PAYLOAD of %u\n",
+ payload_len, MAX_PAYLOAD);
+ return ODP_PACKET_INVALID;
+ }
+
l4_hdr_len = pkt_info->use_tcp ? ODPH_TCPHDR_LEN : ODPH_UDPHDR_LEN;
l3_hdr_len = pkt_info->use_ipv6 ? ODPH_IPV6HDR_LEN : ODPH_IPV4HDR_LEN;
vlan_hdr_len = pkt_info->use_vlan ? ODPH_VLANHDR_LEN : 0;
@@ -1570,7 +1574,7 @@ static tm_node_desc_t *create_tm_node(odp_tm_t odp_tm,
odp_tm_wred_t green_profile, yellow_profile, red_profile;
odp_tm_node_t tm_node, parent_node;
uint32_t node_desc_size, queue_desc_size, priority;
- char node_name[TM_NAME_LEN];
+ char node_name[ODP_TM_NAME_LEN];
int rc;
odp_tm_node_params_init(&node_params);
@@ -1731,7 +1735,7 @@ static tm_node_desc_t *find_node_desc(uint8_t tm_system_idx,
name_ptr++;
while (node_desc != NULL) {
- if (strncmp(node_desc->node_name, node_name, TM_NAME_LEN) == 0)
+ if (strncmp(node_desc->node_name, node_name, ODP_TM_NAME_LEN) == 0)
return node_desc;
if (name_ptr == NULL)
@@ -1866,7 +1870,7 @@ static int create_tm_system(void)
tm_node_desc_t *root_node_desc;
uint32_t level, max_nodes[ODP_TM_MAX_LEVELS];
odp_tm_t odp_tm, found_odp_tm;
- char tm_name[TM_NAME_LEN];
+ char tm_name[ODP_TM_NAME_LEN];
int rc;
odp_tm_requirements_init(&requirements);
@@ -2546,7 +2550,7 @@ static void traffic_mngr_test_shaper_profile(void)
odp_tm_shaper_params_t shaper_params;
odp_tm_shaper_t profile;
uint32_t idx, shaper_idx, i;
- char shaper_name[TM_NAME_LEN];
+ char shaper_name[ODP_TM_NAME_LEN];
odp_tm_shaper_params_init(&shaper_params);
shaper_params.shaper_len_adjust = SHAPER_LEN_ADJ;
@@ -2610,7 +2614,7 @@ static void traffic_mngr_test_sched_profile(void)
odp_tm_sched_params_t sched_params;
odp_tm_sched_t profile;
uint32_t idx, priority, sched_idx, i;
- char sched_name[TM_NAME_LEN];
+ char sched_name[ODP_TM_NAME_LEN];
odp_tm_sched_params_init(&sched_params);
@@ -2683,7 +2687,7 @@ static void traffic_mngr_test_threshold_profile(threshold_type_t threshold)
odp_tm_threshold_params_t threshold_params;
odp_tm_threshold_t profile;
uint32_t idx, threshold_idx, i;
- char threshold_name[TM_NAME_LEN];
+ char threshold_name[ODP_TM_NAME_LEN];
odp_tm_threshold_params_init(&threshold_params);
@@ -2778,7 +2782,7 @@ static void traffic_mngr_test_wred_profile(void)
odp_tm_wred_params_t wred_params;
odp_tm_wred_t profile;
uint32_t idx, color, wred_idx, i, c;
- char wred_name[TM_NAME_LEN];
+ char wred_name[ODP_TM_NAME_LEN];
odp_tm_wred_params_init(&wred_params);
wred_params.enable_wred = 1;
@@ -3068,7 +3072,7 @@ static int set_sched_fanin(const char *node_name,
odp_tm_node_t tm_node, fanin_node;
uint32_t fanin_cnt, fanin, priority;
uint8_t sched_weight;
- char sched_name[TM_NAME_LEN];
+ char sched_name[ODP_TM_NAME_LEN];
int rc;
node_desc = find_node_desc(0, node_name);
@@ -4456,7 +4460,7 @@ static void test_defaults(uint8_t fill)
memset(&req, fill, sizeof(req));
odp_tm_requirements_init(&req);
- CU_ASSERT_EQUAL(req.num_levels, 0);
+ CU_ASSERT(req.num_levels == 0);
CU_ASSERT(!req.tm_queue_shaper_needed);
CU_ASSERT(!req.tm_queue_wred_needed);
CU_ASSERT(!req.tm_queue_dual_slope_needed);
@@ -4466,7 +4470,7 @@ static void test_defaults(uint8_t fill)
CU_ASSERT(!req.drop_prec_marking_needed);
for (n = 0; n < ODP_NUM_PACKET_COLORS; n++)
CU_ASSERT(!req.marking_colors_needed[n]);
- CU_ASSERT_EQUAL(req.pkt_prio_mode, ODP_TM_PKT_PRIO_MODE_PRESERVE);
+ CU_ASSERT(req.pkt_prio_mode == ODP_TM_PKT_PRIO_MODE_PRESERVE);
for (n = 0; n < ODP_TM_MAX_LEVELS; n++) {
odp_tm_level_requirements_t *l_req = &req.per_level[n];
@@ -4481,14 +4485,14 @@ static void test_defaults(uint8_t fill)
memset(&shaper, fill, sizeof(shaper));
odp_tm_shaper_params_init(&shaper);
CU_ASSERT(shaper.packet_mode == ODP_TM_SHAPER_RATE_SHAPE);
- CU_ASSERT_EQUAL(shaper.shaper_len_adjust, 0);
+ CU_ASSERT(shaper.shaper_len_adjust == 0);
CU_ASSERT(!shaper.dual_rate);
CU_ASSERT(!shaper.packet_mode);
memset(&sched, 0xff, sizeof(sched));
odp_tm_sched_params_init(&sched);
for (n = 0; n < ODP_TM_MAX_PRIORITIES; n++)
- CU_ASSERT_EQUAL(sched.sched_modes[n], ODP_TM_BYTE_BASED_WEIGHTS);
+ CU_ASSERT(sched.sched_modes[n] == ODP_TM_BYTE_BASED_WEIGHTS);
memset(&threshold, fill, sizeof(threshold));
odp_tm_threshold_params_init(&threshold);
@@ -4502,18 +4506,18 @@ static void test_defaults(uint8_t fill)
memset(&node, fill, sizeof(node));
odp_tm_node_params_init(&node);
- CU_ASSERT_EQUAL(node.shaper_profile, ODP_TM_INVALID);
- CU_ASSERT_EQUAL(node.threshold_profile, ODP_TM_INVALID);
+ CU_ASSERT(node.shaper_profile == ODP_TM_INVALID);
+ CU_ASSERT(node.threshold_profile == ODP_TM_INVALID);
for (n = 0; n < ODP_NUM_PACKET_COLORS; n++)
- CU_ASSERT_EQUAL(node.wred_profile[n], ODP_TM_INVALID);
+ CU_ASSERT(node.wred_profile[n] == ODP_TM_INVALID);
memset(&queue, fill, sizeof(queue));
odp_tm_queue_params_init(&queue);
- CU_ASSERT_EQUAL(queue.shaper_profile, ODP_TM_INVALID);
- CU_ASSERT_EQUAL(queue.threshold_profile, ODP_TM_INVALID);
+ CU_ASSERT(queue.shaper_profile == ODP_TM_INVALID);
+ CU_ASSERT(queue.threshold_profile == ODP_TM_INVALID);
for (n = 0; n < ODP_NUM_PACKET_COLORS; n++)
- CU_ASSERT_EQUAL(queue.wred_profile[n], ODP_TM_INVALID);
- CU_ASSERT_EQUAL(queue.priority, 0);
+ CU_ASSERT(queue.wred_profile[n] == ODP_TM_INVALID);
+ CU_ASSERT(queue.priority == 0);
CU_ASSERT(queue.ordered_enqueue);
}
@@ -4961,6 +4965,92 @@ static void traffic_mngr_test_lso_ipv4(void)
CU_ASSERT(odp_tm_is_idle(odp_tm_systems[0]));
}
+static void traffic_mngr_test_node_long_name(void)
+{
+ odp_tm_node_params_t node_params;
+ odp_tm_node_t tm_node;
+ char name[ODP_TM_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ odp_tm_node_params_init(&node_params);
+
+ tm_node = odp_tm_node_create(odp_tm_systems[0], name, &node_params);
+ CU_ASSERT(tm_node != ODP_TM_INVALID);
+ CU_ASSERT(tm_node == odp_tm_node_lookup(odp_tm_systems[0], name));
+ CU_ASSERT(!odp_tm_node_destroy(tm_node));
+}
+
+static void traffic_mngr_test_shaper_long_name(void)
+{
+ odp_tm_shaper_params_t shaper_params;
+ odp_tm_shaper_t profile;
+ char name[ODP_TM_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ odp_tm_shaper_params_init(&shaper_params);
+ profile = odp_tm_shaper_create(name, &shaper_params);
+
+ CU_ASSERT(profile != ODP_TM_INVALID);
+ CU_ASSERT(profile == odp_tm_shaper_lookup(name));
+ CU_ASSERT(!odp_tm_shaper_destroy(profile));
+}
+
+static void traffic_mngr_test_sched_long_name(void)
+{
+ odp_tm_sched_params_t sched_params;
+ odp_tm_sched_t profile;
+ char name[ODP_TM_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ odp_tm_sched_params_init(&sched_params);
+ profile = odp_tm_sched_create(name, &sched_params);
+
+ CU_ASSERT(profile != ODP_TM_INVALID);
+ CU_ASSERT(profile == odp_tm_sched_lookup(name));
+ CU_ASSERT(!odp_tm_sched_destroy(profile));
+}
+
+static void traffic_mngr_test_threshold_long_name(void)
+{
+ odp_tm_threshold_params_t threshold_params;
+ odp_tm_threshold_t profile;
+ char name[ODP_TM_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ odp_tm_threshold_params_init(&threshold_params);
+ threshold_params.enable_max_bytes = true;
+ profile = odp_tm_threshold_create(name, &threshold_params);
+
+ CU_ASSERT(profile != ODP_TM_INVALID);
+ CU_ASSERT(profile == odp_tm_thresholds_lookup(name));
+ CU_ASSERT(!odp_tm_threshold_destroy(profile));
+}
+
+static void traffic_mngr_test_wred_long_name(void)
+{
+ odp_tm_wred_params_t wred_params;
+ odp_tm_wred_t profile;
+ char name[ODP_TM_NAME_LEN];
+
+ memset(name, 'a', sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
+ odp_tm_wred_params_init(&wred_params);
+ profile = odp_tm_wred_create(name, &wred_params);
+
+ CU_ASSERT(profile != ODP_TM_INVALID);
+ CU_ASSERT(profile == odp_tm_wred_lookup(name));
+ CU_ASSERT(!odp_tm_wred_destroy(profile));
+}
+
static void traffic_mngr_test_destroy(void)
{
CU_ASSERT(destroy_tm_systems() == 0);
@@ -5012,6 +5102,15 @@ odp_testinfo_t traffic_mngr_suite[] = {
traffic_mngr_check_tx_aging),
ODP_TEST_INFO(traffic_mngr_test_fanin_info),
ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_lso_ipv4, traffic_mngr_check_lso_ipv4),
+ ODP_TEST_INFO(traffic_mngr_test_node_long_name),
+ ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_shaper_long_name,
+ traffic_mngr_check_shaper),
+ ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_sched_long_name,
+ traffic_mngr_check_scheduler),
+ ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_threshold_long_name,
+ traffic_mngr_check_thresholds_byte),
+ ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_wred_long_name,
+ traffic_mngr_check_wred),
ODP_TEST_INFO(traffic_mngr_test_destroy),
ODP_TEST_INFO_NULL,
};