From 91931fd1e6bff5b5bfe7a7082dba431fd7da3b1e Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Thu, 7 Jul 2022 16:28:23 +0300 Subject: api: stash: add batch variants of put/get functions Add batch variants of all put/get functions and capabilities for maximum supported batch sizes. The batch operations output always either zero or all requested objects. Signed-off-by: Matias Elo Reviewed-by: Tuomas Taipale Reviewed-by: Petri Savolainen Reviewed-by: Jerin Jacob --- include/odp/api/spec/stash.h | 140 +++++++++++++++++++++++++++++++++++++ include/odp/api/spec/stash_types.h | 12 ++++ 2 files changed, 152 insertions(+) (limited to 'include/odp') diff --git a/include/odp/api/spec/stash.h b/include/odp/api/spec/stash.h index 38e388dd7..f5929c45a 100644 --- a/include/odp/api/spec/stash.h +++ b/include/odp/api/spec/stash.h @@ -131,6 +131,25 @@ uint64_t odp_stash_to_u64(odp_stash_t stash); */ int32_t odp_stash_put(odp_stash_t stash, const void *obj, int32_t num); +/** + * Put batch of object handles into a stash + * + * Otherwise like odp_stash_put(), except that this function stores either all + * 'num' object handles or none. odp_stash_capability_t.max_put_batch defines + * the maximum supported batch size. + * + * @param stash Stash handle + * @param obj Points to an array of object handles to be stored. + * Object handle size is specified by 'obj_size' in stash + * creation parameters. The array must be 'obj_size' aligned + * in memory. + * @param num Number of object handles to store + * + * @return Number of object handles actually stored (0 or num) + * @retval <0 on failure + */ +int32_t odp_stash_put_batch(odp_stash_t stash, const void *obj, int32_t num); + /** * Put 32-bit integers into a stash * @@ -147,6 +166,23 @@ int32_t odp_stash_put(odp_stash_t stash, const void *obj, int32_t num); */ int32_t odp_stash_put_u32(odp_stash_t stash, const uint32_t val[], int32_t num); +/** + * Put batch of 32-bit integers into a stash + * + * Otherwise like odp_stash_put_u32(), except that this function stores either + * all 'num' object handles or none. odp_stash_capability_t.max_put_batch + * defines the maximum supported batch size. + * + * @param stash Stash handle + * @param val Points to an array of 32-bit integers to be stored. The array + * must be 32-bit aligned in memory. + * @param num Number of integers to store + * + * @return Number of integers actually stored (0 or num) + * @retval <0 on failure + */ +int32_t odp_stash_put_u32_batch(odp_stash_t stash, const uint32_t val[], int32_t num); + /** * Put 64-bit integers into a stash * @@ -163,6 +199,23 @@ int32_t odp_stash_put_u32(odp_stash_t stash, const uint32_t val[], int32_t num); */ int32_t odp_stash_put_u64(odp_stash_t stash, const uint64_t val[], int32_t num); +/** + * Put batch of 64-bit integers into a stash + * + * Otherwise like odp_stash_put_u64(), except that this function stores either + * all 'num' object handles or none. odp_stash_capability_t.max_put_batch + * defines the maximum supported batch size. + * + * @param stash Stash handle + * @param val Points to an array of 64-bit integers to be stored. The array + * must be 64-bit aligned in memory. + * @param num Number of integers to store + * + * @return Number of integers actually stored (0 or num) + * @retval <0 on failure + */ +int32_t odp_stash_put_u64_batch(odp_stash_t stash, const uint64_t val[], int32_t num); + /** * Put pointers into a stash * @@ -180,6 +233,23 @@ int32_t odp_stash_put_u64(odp_stash_t stash, const uint64_t val[], int32_t num); */ int32_t odp_stash_put_ptr(odp_stash_t stash, const uintptr_t ptr[], int32_t num); +/** + * Put batch of pointers into a stash + * + * Otherwise like odp_stash_put_ptr(), except that this function stores either + * all 'num' object handles or none. odp_stash_capability_t.max_put_batch + * defines the maximum supported batch size. + * + * @param stash Stash handle + * @param ptr Points to an array of pointers to be stored. The array must be + * pointer size aligned in memory. + * @param num Number of pointers to store + * + * @return Number of pointers actually stored (0 or num) + * @retval <0 on failure + */ +int32_t odp_stash_put_ptr_batch(odp_stash_t stash, const uintptr_t ptr[], int32_t num); + /** * Get object handles from a stash * @@ -198,6 +268,25 @@ int32_t odp_stash_put_ptr(odp_stash_t stash, const uintptr_t ptr[], int32_t num) */ int32_t odp_stash_get(odp_stash_t stash, void *obj, int32_t num); +/** + * Get batch of object handles from a stash + * + * Otherwise like odp_stash_get(), except that this function outputs either + * all 'num' object handles or none. odp_stash_capability_t.max_get_batch + * defines the maximum supported batch size. + * + * @param stash Stash handle + * @param[out] obj Points to an array of object handles for output. + * Object handle size is specified by 'obj_size' in stash + * creation parameters. The array must be 'obj_size' aligned + * in memory. + * @param num Number of object handles to get from the stash + * + * @return Number of object handles actually output (0 or num) to 'obj' array + * @retval <0 on failure + */ +int32_t odp_stash_get_batch(odp_stash_t stash, void *obj, int32_t num); + /** * Get 32-bit integers from a stash * @@ -214,6 +303,23 @@ int32_t odp_stash_get(odp_stash_t stash, void *obj, int32_t num); */ int32_t odp_stash_get_u32(odp_stash_t stash, uint32_t val[], int32_t num); +/** + * Get batch of 32-bit integers from a stash + * + * Otherwise like odp_stash_get_u32(), except that this function outputs either + * all 'num' object handles or none. odp_stash_capability_t.max_get_batch + * defines the maximum supported batch size. + * + * @param stash Stash handle + * @param[out] val Points to an array of 32-bit integers for output. The + * array must be 32-bit aligned in memory. + * @param num Number of integers to get from the stash + * + * @return Number of integers actually output (0 or num) to 'val' array + * @retval <0 on failure + */ +int32_t odp_stash_get_u32_batch(odp_stash_t stash, uint32_t val[], int32_t num); + /** * Get 64-bit integers from a stash * @@ -230,6 +336,23 @@ int32_t odp_stash_get_u32(odp_stash_t stash, uint32_t val[], int32_t num); */ int32_t odp_stash_get_u64(odp_stash_t stash, uint64_t val[], int32_t num); +/** + * Get batch of 64-bit integers from a stash + * + * Otherwise like odp_stash_get_u64(), except that this function outputs either + * all 'num' object handles or none. odp_stash_capability_t.max_get_batch + * defines the maximum supported batch size. + * + * @param stash Stash handle + * @param[out] val Points to an array of 64-bit integers for output. The + * array must be 64-bit aligned in memory. + * @param num Number of integers to get from the stash + * + * @return Number of integers actually output (0 or num) to 'val' array + * @retval <0 on failure + */ +int32_t odp_stash_get_u64_batch(odp_stash_t stash, uint64_t val[], int32_t num); + /** * Get pointers from a stash * @@ -247,6 +370,23 @@ int32_t odp_stash_get_u64(odp_stash_t stash, uint64_t val[], int32_t num); */ int32_t odp_stash_get_ptr(odp_stash_t stash, uintptr_t ptr[], int32_t num); +/** + * Get batch of pointers from a stash + * + * Otherwise like odp_stash_get_ptr(), except that this function outputs either + * all 'num' object handles or none. odp_stash_capability_t.max_get_batch + * defines the maximum supported batch size. + * + * @param stash Stash handle + * @param[out] ptr Points to an array of pointers for output. The array must + * be pointer size aligned in memory. + * @param num Number of pointers to get from the stash + * + * @return Number of pointers actually output (0 or num) to 'ptr' array + * @retval <0 on failure + */ +int32_t odp_stash_get_ptr_batch(odp_stash_t stash, uintptr_t ptr[], int32_t num); + /** * Flush object handles from the thread local cache * diff --git a/include/odp/api/spec/stash_types.h b/include/odp/api/spec/stash_types.h index dc966cb71..5f3e608bb 100644 --- a/include/odp/api/spec/stash_types.h +++ b/include/odp/api/spec/stash_types.h @@ -172,6 +172,18 @@ typedef struct odp_stash_capability_t { /** Maximum size of thread local cache */ uint32_t max_cache_size; + /** Maximum number of object handles in batch get operations + * + * At least 1 object batch size is always supported. + */ + uint32_t max_get_batch; + + /** Maximum number of object handles in batch put operations + * + * At least 1 object batch size is always supported. + */ + uint32_t max_put_batch; + /** Supported statistics counters */ odp_stash_stats_opt_t stats; -- cgit v1.2.3 From a4978927570df86941392111f7cbab2f0fb8b5b4 Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Wed, 20 Jul 2022 14:20:55 +0300 Subject: api: thread: clarify odp_thread_id() specification Clarify odp_thread_id() specification to state that thread IDs are assigned sequentially starting from 0 in the order threads call odp_init_local(). Signed-off-by: Matias Elo Reviewed-by: Tuomas Taipale Reviewed-by: Petri Savolainen Reviewed-by: Jerin Jacob --- include/odp/api/spec/thread.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'include/odp') diff --git a/include/odp/api/spec/thread.h b/include/odp/api/spec/thread.h index 52bd82a09..0d85b3432 100644 --- a/include/odp/api/spec/thread.h +++ b/include/odp/api/spec/thread.h @@ -1,4 +1,5 @@ /* Copyright (c) 2013-2018, Linaro Limited + * Copyright (c) 2022, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -33,10 +34,13 @@ extern "C" { /** * Get thread identifier * - * Returns the thread identifier of the current thread. Thread ids range from 0 - * to odp_thread_count_max() - 1. The ODP thread id is assigned by - * odp_init_local() and freed by odp_term_local(). Thread id is unique within - * the ODP instance. + * Returns the ODP thread identifier of current thread. Thread IDs range from 0 + * to odp_thread_count_max() - 1 and are unique within an ODP instance. + * + * Thread IDs are assigned by odp_init_local() and freed by odp_term_local(). + * IDs are assigned sequentially starting from 0 in the same order threads call + * odp_init_local(). Thread IDs freed by odp_term_local() may be reused by + * following odp_init_local() calls. * * @return Thread identifier of the current thread */ -- cgit v1.2.3 From 6d93593fa41705902ded11147fd753853e2f0420 Mon Sep 17 00:00:00 2001 From: Janne Peltonen Date: Tue, 13 Sep 2022 10:57:36 +0300 Subject: api: crypto: add experimental ZUC-256 support Mention that ODP_CIPHER_ALG_ZUC_EEA3 and ODP_AUTH_ALG_ZUC_EIA3 may support 256 bit key length but that the support is experimental and subject to change. The standardization status of the algorithms is open and it is not clear what the defining specifications are. There are are already two different initialization schemes with different IV lengths defined. Mention NEA3 and NIA3 in addition to EEA3 and EIA3 in the API as they are identical, respectively. Signed-off-by: Janne Peltonen Reviewed-by: Anoob Joseph --- include/odp/api/spec/crypto.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'include/odp') diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h index b45731e1b..4f2961f3c 100644 --- a/include/odp/api/spec/crypto.h +++ b/include/odp/api/spec/crypto.h @@ -154,14 +154,23 @@ typedef enum { */ ODP_CIPHER_ALG_AES_EEA2, - /** Confidentiality 128-EEA3 algorithm + /** ZUC based confidentiality algorithm * - * ZUC-based 128-EEA3 algorithm. + * 128-EEA3/128-NEA3 algorithm when key length is 128 bits. * * IV (128 bit) should be formatted according to the ETSI/SAGE * 128-EEA3 & 128-EIA3 specification: * COUNT || BEARER || DIRECTION || 0...0 || * COUNT || BEARER || DIRECTION || 0...0 || + * + * 256-bit key length support is experimental and subject to + * change. The following variants may be supported: + * + * - ZUC-256 with 25 byte IV (of which 184 bits are variable) + * as specified in "The ZUC-256 Stream Cipher". + * - ZUC-256 with 16 byte IV as specified in + * "An Addendum to the ZUC-256 Stream Cipher", + * https://eprint.iacr.org/2021/1439 */ ODP_CIPHER_ALG_ZUC_EEA3, @@ -304,15 +313,24 @@ typedef enum { */ ODP_AUTH_ALG_AES_EIA2, - /** Integrity 128-EIA3 algorithm + /** ZUC-based integrity algorithm. * - * ZUC-based 128-EIA3 algorithm. + * 128-EIA3/128-NIA3 algorithm when key length is 128 bits. * * IV (128 bit) should be formatted according to the ETSI/SAGE * 128-EA3 & 128-EIA2 specification: * COUNT || BEARER || * DIRECTION XOR COUNT0 || COUNT1 .. COUNT31 || * BEARER || 0...0 || DIRECTION || 0...0 + * + * 256-bit key length support is experimental and subject to + * change. The following variants may be supported: + * + * - ZUC-256 with 25 byte IV (of which 184 bits are variable) and + * 32/64/128 bit MAC as specified in "The ZUC-256 Stream Cipher". + * - ZUC-256 with 16 byte IV and 32/64/128 bit MAC as specified in + * "An Addendum to the ZUC-256 Stream Cipher", + * https://eprint.iacr.org/2021/1439 */ ODP_AUTH_ALG_ZUC_EIA3, -- cgit v1.2.3 From 5733e23e494db9bc6f51dad2fb46d844707b3bbf Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Tue, 30 Aug 2022 11:11:22 +0300 Subject: api: pool: reword vector definition Replace term "general type" with handle in specification text. Signed-off-by: Petri Savolainen Reviewed-by: Ashwin Sekhar T K Reviewed-by: Matias Elo --- include/odp/api/spec/pool_types.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include/odp') diff --git a/include/odp/api/spec/pool_types.h b/include/odp/api/spec/pool_types.h index e8026c642..88c762ebb 100644 --- a/include/odp/api/spec/pool_types.h +++ b/include/odp/api/spec/pool_types.h @@ -304,7 +304,7 @@ typedef struct odp_pool_capability_t { * memory size for the pool. */ uint32_t max_num; - /** Maximum number of general types, such as odp_packet_t, in a vector. */ + /** Maximum number of handles (such as odp_packet_t) in a vector. */ uint32_t max_size; /** Minimum size of thread local cache */ @@ -344,10 +344,10 @@ typedef enum odp_pool_type_t { /** Timeout pool */ ODP_POOL_TIMEOUT = ODP_EVENT_TIMEOUT, - /** Vector pool + /** Vector event pool * - * The pool to hold a vector of general type such as odp_packet_t. - * Each vector holds an array of generic types of the same type. + * Each vector event holds an array of handles. All handles of a vector + * are the same type (such as odp_packet_t). * @see ODP_EVENT_PACKET_VECTOR */ ODP_POOL_VECTOR, @@ -515,7 +515,7 @@ typedef struct odp_pool_param_t { /** Number of vectors in the pool */ uint32_t num; - /** Maximum number of general types, such as odp_packet_t, in a vector. */ + /** Maximum number of handles (such as odp_packet_t) in a vector. */ uint32_t max_size; /** Maximum number of vectors cached locally per thread -- cgit v1.2.3 From 53b046807e53b5699bb7bb1126012cc72ec38a1e Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Tue, 30 Aug 2022 17:17:06 +0300 Subject: api: pool: packet user area capability may be zero Applications do not benefit from implementation offering unlimited user area size in capability, as usually only a small number of bytes is enough per packet. Comparisons in application code are simpler when capability value of zero means zero bytes (area not supported). Define that implementation may round up the user area size and the default value of the parameter is zero. Signed-off-by: Petri Savolainen Reviewed-by: Ashwin Sekhar T K Reviewed-by: Matias Elo --- include/odp/api/spec/pool_types.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'include/odp') diff --git a/include/odp/api/spec/pool_types.h b/include/odp/api/spec/pool_types.h index 88c762ebb..c1fe8f8fa 100644 --- a/include/odp/api/spec/pool_types.h +++ b/include/odp/api/spec/pool_types.h @@ -250,10 +250,7 @@ typedef struct odp_pool_capability_t { * memory size for the pool. */ uint32_t max_seg_len; - /** Maximum user area size in bytes - * - * The value of zero means that limited only by the available - * memory size for the pool. */ + /** Maximum user area size in bytes */ uint32_t max_uarea_size; /** Maximum number of subparameters @@ -454,9 +451,9 @@ typedef struct odp_pool_param_t { */ uint32_t seg_len; - /** User area size in bytes. The maximum value is defined by + /** Minimum user area size in bytes. The maximum value is defined by * pool capability pkt.max_uarea_size. Specify as 0 if no user - * area is needed. + * area is needed. The default value is 0. */ uint32_t uarea_size; -- cgit v1.2.3 From c84c179f49f5bc085d8db936e6ca179cc9921142 Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Wed, 31 Aug 2022 10:04:00 +0300 Subject: api: pool: add user area into buf, tmo and vector Added user area size capability and parameter into buffer, timeout and vector event pools. User area size is zero by default. Signed-off-by: Petri Savolainen Reviewed-by: Ashwin Sekhar T K Reviewed-by: Matias Elo --- include/odp/api/spec/pool_types.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'include/odp') diff --git a/include/odp/api/spec/pool_types.h b/include/odp/api/spec/pool_types.h index c1fe8f8fa..9f433fba5 100644 --- a/include/odp/api/spec/pool_types.h +++ b/include/odp/api/spec/pool_types.h @@ -174,6 +174,9 @@ typedef struct odp_pool_capability_t { * memory size for the pool. */ uint32_t max_num; + /** Maximum user area size in bytes */ + uint32_t max_uarea_size; + /** Minimum size of thread local cache */ uint32_t min_cache_size; @@ -280,6 +283,9 @@ typedef struct odp_pool_capability_t { * memory size for the pool. */ uint32_t max_num; + /** Maximum user area size in bytes */ + uint32_t max_uarea_size; + /** Minimum size of thread local cache */ uint32_t min_cache_size; @@ -304,6 +310,9 @@ typedef struct odp_pool_capability_t { /** Maximum number of handles (such as odp_packet_t) in a vector. */ uint32_t max_size; + /** Maximum user area size in bytes */ + uint32_t max_uarea_size; + /** Minimum size of thread local cache */ uint32_t min_cache_size; @@ -377,6 +386,12 @@ typedef struct odp_pool_param_t { */ uint32_t align; + /** Minimum user area size in bytes. The maximum value is defined by + * pool capability buf.max_uarea_size. Specify as 0 if no user + * area is needed. The default value is 0. + */ + uint32_t uarea_size; + /** Maximum number of buffers cached locally per thread * * A non-zero value allows implementation to cache buffers @@ -500,6 +515,12 @@ typedef struct odp_pool_param_t { /** Number of timeouts in the pool */ uint32_t num; + /** Minimum user area size in bytes. The maximum value is defined by + * pool capability tmo.max_uarea_size. Specify as 0 if no user + * area is needed. The default value is 0. + */ + uint32_t uarea_size; + /** Maximum number of timeouts cached locally per thread * * See buf.cache_size documentation for details. @@ -515,6 +536,12 @@ typedef struct odp_pool_param_t { /** Maximum number of handles (such as odp_packet_t) in a vector. */ uint32_t max_size; + /** Minimum user area size in bytes. The maximum value is defined by + * pool capability vector.max_uarea_size. Specify as 0 if no user + * area is needed. The default value is 0. + */ + uint32_t uarea_size; + /** Maximum number of vectors cached locally per thread * * See buf.cache_size documentation for details. -- cgit v1.2.3 From 91bfa674f6e833711741a991cff21178b483fa1f Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Wed, 31 Aug 2022 10:57:18 +0300 Subject: api: buffer: add pointer to user area Added odp_buffer_user_area() which returns pointer to the user area. Area size is configured with pool create parameters. Signed-off-by: Petri Savolainen Reviewed-by: Ashwin Sekhar T K Reviewed-by: Matias Elo --- include/odp/api/spec/buffer.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include/odp') diff --git a/include/odp/api/spec/buffer.h b/include/odp/api/spec/buffer.h index c11a3c7b4..b739e549f 100644 --- a/include/odp/api/spec/buffer.h +++ b/include/odp/api/spec/buffer.h @@ -1,4 +1,5 @@ /* Copyright (c) 2013-2018, Linaro Limited + * Copyright (c) 2022, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -77,6 +78,19 @@ void *odp_buffer_addr(odp_buffer_t buf); */ uint32_t odp_buffer_size(odp_buffer_t buf); +/** + * Buffer user area + * + * Returns pointer to the user area associated with the buffer. Size of the area is fixed + * and defined in buffer pool parameters. + * + * @param buf Buffer handle + * + * @return Pointer to the user area of the buffer + * @retval NULL The buffer does not have user area + */ +void *odp_buffer_user_area(odp_buffer_t buf); + /** * Check that buffer is valid * -- cgit v1.2.3 From 4d219446a5867a1ee82852b538de8458d3d06787 Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Wed, 31 Aug 2022 11:03:32 +0300 Subject: api: timer: add pointer to timeout user area Added odp_timeout_user_area() which returns pointer to the user area. Area size is configured with pool create parameters. Signed-off-by: Petri Savolainen Reviewed-by: Ashwin Sekhar T K Reviewed-by: Matias Elo --- include/odp/api/spec/timer.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/odp') diff --git a/include/odp/api/spec/timer.h b/include/odp/api/spec/timer.h index b51db7dbc..edfa423e7 100644 --- a/include/odp/api/spec/timer.h +++ b/include/odp/api/spec/timer.h @@ -504,6 +504,19 @@ uint64_t odp_timeout_tick(odp_timeout_t tmo); */ void *odp_timeout_user_ptr(odp_timeout_t tmo); +/** + * Timeout user area + * + * Returns pointer to the user area associated with the timeout. Size of the area is fixed + * and defined in timeout pool parameters. + * + * @param tmo Timeout handle + * + * @return Pointer to the user area of the timeout + * @retval NULL The timeout does not have user area + */ +void *odp_timeout_user_area(odp_timeout_t tmo); + /** * Timeout alloc * -- cgit v1.2.3 From d10f1e7811bca37cf18e2b5a23403733ed3cf4ae Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Wed, 31 Aug 2022 13:05:06 +0300 Subject: api: packet: add pointer to packet vector user area Added odp_packet_vector_user_area() which returns pointer to the user area. Area size is configured with pool create parameters. Signed-off-by: Petri Savolainen Reviewed-by: Ashwin Sekhar T K Reviewed-by: Matias Elo --- include/odp/api/spec/packet.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/odp') diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index c745d29ad..54a7e0eaf 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -2212,6 +2212,19 @@ uint32_t odp_packet_vector_size(odp_packet_vector_t pktv); */ void odp_packet_vector_size_set(odp_packet_vector_t pktv, uint32_t size); +/** + * Packet vector user area + * + * Returns pointer to the user area associated with the packet vector. Size of the area is fixed + * and defined in vector pool parameters. + * + * @param pktv Packet vector handle + * + * @return Pointer to the user area of the packet vector + * @retval NULL The packet vector does not have user area + */ +void *odp_packet_vector_user_area(odp_packet_vector_t pktv); + /** * Check that packet vector is valid * -- cgit v1.2.3 From b024c18782a1909694d4008489783d295a73c08d Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Wed, 31 Aug 2022 18:06:05 +0300 Subject: api: packet: add user flags Added new "user flag" to packet and packet vector metadata. It helps user to differentiate between new packets (/vectors) and packets (/vectors) that user has seen before. Implementation initializes the flag to zero (in alloc/reset/packet input), but does not modify its value otherwise. Signed-off-by: Petri Savolainen Reviewed-by: Ashwin Sekhar T K Reviewed-by: Matias Elo --- include/odp/api/spec/packet.h | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'include/odp') diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index 54a7e0eaf..a8d4caa8c 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -1491,6 +1491,31 @@ void *odp_packet_user_area(odp_packet_t pkt); */ uint32_t odp_packet_user_area_size(odp_packet_t pkt); +/** + * Check user flag + * + * Implementation clears user flag during new packet creation (e.g. alloc and packet input) + * and reset. User may set the flag with odp_packet_user_flag_set(). Implementation never + * sets the flag, only clears it. The flag may be useful e.g. to mark when the user area + * content is valid. + * + * @param pkt Packet handle + * + * @retval 0 User flag is clear + * @retval !0 User flag is set + */ +int odp_packet_user_flag(odp_packet_t pkt); + +/** + * Set user flag + * + * Set (or clear) the user flag. + * + * @param pkt Packet handle + * @param val New value for the flag. Zero clears the flag, other values set the flag. + */ +void odp_packet_user_flag_set(odp_packet_t pkt, int val); + /** * Layer 2 start pointer * @@ -2225,6 +2250,31 @@ void odp_packet_vector_size_set(odp_packet_vector_t pktv, uint32_t size); */ void *odp_packet_vector_user_area(odp_packet_vector_t pktv); +/** + * Check user flag + * + * Implementation clears user flag during new packet vector creation (e.g. alloc and packet input) + * and reset. User may set the flag with odp_packet_vector_user_flag_set(). Implementation never + * sets the flag, only clears it. The flag may be useful e.g. to mark when the user area + * content is valid. + * + * @param pktv Packet vector handle + * + * @retval 0 User flag is clear + * @retval !0 User flag is set + */ +int odp_packet_vector_user_flag(odp_packet_vector_t pktv); + +/** + * Set user flag + * + * Set (or clear) the user flag. + * + * @param pktv Packet vector handle + * @param val New value for the flag. Zero clears the flag, other values set the flag. + */ +void odp_packet_vector_user_flag_set(odp_packet_vector_t pktv, int val); + /** * Check that packet vector is valid * -- cgit v1.2.3