From d158bbd99e4cd9e64393a18737021bbbed2f862d Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Mon, 12 Jun 2023 17:05:51 +0300 Subject: linux-gen: dma: inline completion event conversion functions Add necessary header files and inline implementations of odp_dma_compl_from_event() and odp_dma_compl_to_event(). Signed-off-by: Matias Elo Reviewed-by: Tuomas Taipale --- include/odp/api/abi-default/dma.h | 20 ++++++++++++++++++++ include/odp/api/dma.h | 2 ++ include/odp/arch/arm32-linux/odp/api/abi/dma.h | 7 +++++++ include/odp/arch/arm64-linux/odp/api/abi/dma.h | 7 +++++++ include/odp/arch/default-linux/odp/api/abi/dma.h | 7 +++++++ include/odp/arch/power64-linux/odp/api/abi/dma.h | 7 +++++++ include/odp/arch/x86_32-linux/odp/api/abi/dma.h | 7 +++++++ include/odp/arch/x86_64-linux/odp/api/abi/dma.h | 7 +++++++ 8 files changed, 64 insertions(+) create mode 100644 include/odp/api/abi-default/dma.h create mode 100644 include/odp/arch/arm32-linux/odp/api/abi/dma.h create mode 100644 include/odp/arch/arm64-linux/odp/api/abi/dma.h create mode 100644 include/odp/arch/default-linux/odp/api/abi/dma.h create mode 100644 include/odp/arch/power64-linux/odp/api/abi/dma.h create mode 100644 include/odp/arch/x86_32-linux/odp/api/abi/dma.h create mode 100644 include/odp/arch/x86_64-linux/odp/api/abi/dma.h (limited to 'include/odp') diff --git a/include/odp/api/abi-default/dma.h b/include/odp/api/abi-default/dma.h new file mode 100644 index 000000000..e7e0ad970 --- /dev/null +++ b/include/odp/api/abi-default/dma.h @@ -0,0 +1,20 @@ +/* Copyright (c) 2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_ABI_DMA_H_ +#define ODP_ABI_DMA_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Empty header required due to the inline functions */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/odp/api/dma.h b/include/odp/api/dma.h index 4720f57c9..10e00a506 100644 --- a/include/odp/api/dma.h +++ b/include/odp/api/dma.h @@ -17,6 +17,8 @@ extern "C" { #endif +#include + #include #ifdef __cplusplus diff --git a/include/odp/arch/arm32-linux/odp/api/abi/dma.h b/include/odp/arch/arm32-linux/odp/api/abi/dma.h new file mode 100644 index 000000000..f4656c4cf --- /dev/null +++ b/include/odp/arch/arm32-linux/odp/api/abi/dma.h @@ -0,0 +1,7 @@ +/* Copyright (c) 2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include diff --git a/include/odp/arch/arm64-linux/odp/api/abi/dma.h b/include/odp/arch/arm64-linux/odp/api/abi/dma.h new file mode 100644 index 000000000..f4656c4cf --- /dev/null +++ b/include/odp/arch/arm64-linux/odp/api/abi/dma.h @@ -0,0 +1,7 @@ +/* Copyright (c) 2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include diff --git a/include/odp/arch/default-linux/odp/api/abi/dma.h b/include/odp/arch/default-linux/odp/api/abi/dma.h new file mode 100644 index 000000000..f4656c4cf --- /dev/null +++ b/include/odp/arch/default-linux/odp/api/abi/dma.h @@ -0,0 +1,7 @@ +/* Copyright (c) 2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include diff --git a/include/odp/arch/power64-linux/odp/api/abi/dma.h b/include/odp/arch/power64-linux/odp/api/abi/dma.h new file mode 100644 index 000000000..f4656c4cf --- /dev/null +++ b/include/odp/arch/power64-linux/odp/api/abi/dma.h @@ -0,0 +1,7 @@ +/* Copyright (c) 2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include diff --git a/include/odp/arch/x86_32-linux/odp/api/abi/dma.h b/include/odp/arch/x86_32-linux/odp/api/abi/dma.h new file mode 100644 index 000000000..f4656c4cf --- /dev/null +++ b/include/odp/arch/x86_32-linux/odp/api/abi/dma.h @@ -0,0 +1,7 @@ +/* Copyright (c) 2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include diff --git a/include/odp/arch/x86_64-linux/odp/api/abi/dma.h b/include/odp/arch/x86_64-linux/odp/api/abi/dma.h new file mode 100644 index 000000000..f4656c4cf --- /dev/null +++ b/include/odp/arch/x86_64-linux/odp/api/abi/dma.h @@ -0,0 +1,7 @@ +/* Copyright (c) 2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include -- cgit v1.2.3 From 45f9da2e051612a64f4d36df5974b2dd5f5f4600 Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Wed, 21 Jun 2023 15:52:29 +0300 Subject: api: event: add odp_event_user_area_and_flag() function Add new odp_event_user_area_and_flag() function, which returns both event user area and user flag value with a single function call. This can improve throughput compared to calling individual functions separately. Signed-off-by: Matias Elo Reviewed-by: Petri Savolainen Reviewed-by: Ashwin Sekhar T K --- include/odp/api/spec/event.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'include/odp') diff --git a/include/odp/api/spec/event.h b/include/odp/api/spec/event.h index 9dc614329..23e77bcb6 100644 --- a/include/odp/api/spec/event.h +++ b/include/odp/api/spec/event.h @@ -93,6 +93,28 @@ int odp_event_type_multi(const odp_event_t event[], int num, */ void *odp_event_user_area(odp_event_t event); +/** + * Event user area and flag + * + * Returns pointer to the user area and outputs value of user flag associated + * with the event. The user area maps to the user area of underlying event type + * (e.g. odp_packet_user_area() for packets). If the event does not have user + * area, NULL is returned. + * + * 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, a + * negative value is outputted. + * + * @param event Event handle + * @param[out] flag User flag value pointer for output. >0 if user flag is + * set, 0 if flags is not set, or <0 if event does not have + * user flag. + * + * @return Pointer to the user area of the event + * @retval NULL The event does not have user area + */ +void *odp_event_user_area_and_flag(odp_event_t event, int *flag); + /** * Filter and convert packet events * -- cgit v1.2.3 From dce33e87f7555e4f81bd52746ead8640640a63b2 Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Wed, 21 Jun 2023 17:03:21 +0300 Subject: api: packet: change user flag function return value Specify that the return values of odp_packet_user_flag() and odp_packet_vector_user_flag() are positive if user flag is set. This way the specifications match better with the new odp_event_user_area_and_flag() API. Signed-off-by: Matias Elo Reviewed-by: Petri Savolainen Reviewed-by: Ashwin Sekhar T K --- include/odp/api/spec/packet.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/odp') diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index 9f41edf1a..267bf819c 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -1502,7 +1502,7 @@ uint32_t odp_packet_user_area_size(odp_packet_t pkt); * @param pkt Packet handle * * @retval 0 User flag is clear - * @retval !0 User flag is set + * @retval >0 User flag is set */ int odp_packet_user_flag(odp_packet_t pkt); @@ -2306,7 +2306,7 @@ void *odp_packet_vector_user_area(odp_packet_vector_t pktv); * @param pktv Packet vector handle * * @retval 0 User flag is clear - * @retval !0 User flag is set + * @retval >0 User flag is set */ int odp_packet_vector_user_flag(odp_packet_vector_t pktv); -- cgit v1.2.3 From 544a3f17d8cd12c59af7e40663737cf88e3f51fb Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Fri, 16 Jun 2023 14:18:04 +0300 Subject: api: timer: add odp_timeout_from_event_multi() function Add new odp_timeout_from_event_multi() function for converting multiple events of type ODP_EVENT_TIMEOUT to timeout handles. This can improve throughput compared to calling odp_timeout_from_event() multiple times. Signed-off-by: Matias Elo Reviewed-by: Tuomas Taipale Reviewed-by: Petri Savolainen Acked-by: Ashwin Sekhar T K --- include/odp/api/spec/timer.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'include/odp') diff --git a/include/odp/api/spec/timer.h b/include/odp/api/spec/timer.h index bbb439692..a50817c27 100644 --- a/include/odp/api/spec/timer.h +++ b/include/odp/api/spec/timer.h @@ -1,5 +1,5 @@ /* Copyright (c) 2013-2018, Linaro Limited - * Copyright (c) 2019-2022, Nokia + * Copyright (c) 2019-2023, Nokia * * All rights reserved. * @@ -477,6 +477,17 @@ int odp_timer_cancel(odp_timer_t timer, odp_event_t *tmo_ev); */ odp_timeout_t odp_timeout_from_event(odp_event_t ev); +/** + * Convert multiple timeout events to timeout handles + * + * All events must be of type ODP_EVENT_TIMEOUT. + * + * @param[out] tmo Timeout handle array for output + * @param ev Array of event handles to convert + * @param num Number of timeouts and events + */ +void odp_timeout_from_event_multi(odp_timeout_t tmo[], const odp_event_t ev[], int num); + /** * Convert timeout handle to event handle * -- cgit v1.2.3 From d0b2fb533d8e87c7b9ec026515a7cc6b66904f59 Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Fri, 16 Jun 2023 15:56:01 +0300 Subject: api: event: add odp_event_types_multi() function Add new odp_event_types_multi() function for reading event types and subtypes (optional) from all given events. Signed-off-by: Matias Elo Reviewed-by: Tuomas Taipale Reviewed-by: Petri Savolainen Acked-by: Ashwin Sekhar T K --- include/odp/api/spec/event.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include/odp') diff --git a/include/odp/api/spec/event.h b/include/odp/api/spec/event.h index 23e77bcb6..65b5dd7ff 100644 --- a/include/odp/api/spec/event.h +++ b/include/odp/api/spec/event.h @@ -63,6 +63,22 @@ odp_event_subtype_t odp_event_subtype(odp_event_t event); odp_event_type_t odp_event_types(odp_event_t event, odp_event_subtype_t *subtype); +/** + * Event types and subtypes of multiple events + * + * Outputs the event types and subtypes (optional) of all given events into the + * output arrays. Application can pass NULL as 'subtype' parameter if subtype + * values are not required. The types are written in the same order as input + * events. + * + * @param event Array of event handles + * @param[out] type Event type array for output + * @param[out] subtype Event subtype array for output, or NULL + * @param num Number of events, event types, and optionally subtypes + */ +void odp_event_types_multi(const odp_event_t event[], odp_event_type_t type[], + odp_event_subtype_t subtype[], int num); + /** * Event type of multiple events * -- cgit v1.2.3 From 42a7166da5685a814f01aaf0ac4b7c0e6feccfcc Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Fri, 16 Jun 2023 12:54:51 +0300 Subject: api: init: add new ODP_LOG_WARN log level Add new ODP_LOG_WARN log level to odp_log_level_t. Signed-off-by: Matias Elo Reviewed-by: Tuomas Taipale Reviewed-by: Petri Savolainen Acked-by: Ashwin Sekhar T K --- include/odp/api/spec/init.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/odp') diff --git a/include/odp/api/spec/init.h b/include/odp/api/spec/init.h index c4f64d4fd..371222267 100644 --- a/include/odp/api/spec/init.h +++ b/include/odp/api/spec/init.h @@ -51,6 +51,9 @@ typedef enum { /** Debug */ ODP_LOG_DBG, + /** Warning */ + ODP_LOG_WARN, + /** Error */ ODP_LOG_ERR, -- cgit v1.2.3 From 48948c24a43681fa6b0e32bc5569277f0a977078 Mon Sep 17 00:00:00 2001 From: Janne Peltonen Date: Mon, 19 Jun 2023 13:39:16 +0300 Subject: api: crypto: add bit mode session parameters for cipher and auth MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add cipher_range_in_bits and auth_range_in_bits session parameters that control whether cipher/auth range is given in bits or bytes. By default the range is in bytes. Change bit_mode cipher/auth capability flag to indicate whether bit mode is supported in addition to byte mode that is always supported. Previously bit_mode capability told whether the cipher/auth had to be used in bit or byte mode. This simplifies crypto API usage as ODP applications that do not require bit mode can simply request byte mode sessions and do not have to check in which mode a particular algorithm in a particular ODP implementation has to be used and then convert range units accordingly. After this change it is possible for an ODP implementation to start supporting bit mode for an algorithm without affecting applications that use byte mode and do not fully do the capability checking and unit conversion dance. This also removes the ambiguity regarding the range units of the null algorithms. Currently some ODP implementations advertise null algorithm capabilities both with and without bit_mode, which is inconsistent and will break as soon as the ranges of the null algorithms are not ignored (as then the ODP implementation could not tell if the range given to it was in bits or bytes). Signed-off-by: Janne Peltonen Reviewed-by: Petri Savolainen Reviewed-by: Jere Leppänen Reviewed-by: Anoob Joseph --- include/odp/api/spec/crypto_types.h | 84 +++++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 26 deletions(-) (limited to 'include/odp') diff --git a/include/odp/api/spec/crypto_types.h b/include/odp/api/spec/crypto_types.h index 46d9ae3f7..5bcb1e2e0 100644 --- a/include/odp/api/spec/crypto_types.h +++ b/include/odp/api/spec/crypto_types.h @@ -560,6 +560,30 @@ typedef struct odp_crypto_session_param_t { */ odp_crypto_op_type_t op_type; + /** Cipher range unit + * + * When this flag is true, cipher range offset and length are in bits. + * Otherwise the offset and length are in bytes. + * + * If cipher capabilities do not include bit_mode, setting this to + * true causes a session creation failure. + * + * The default value is false. + */ + odp_bool_t cipher_range_in_bits; + + /** Auth range unit + * + * When this flag is true, auth range offset and length are in bits. + * Otherwise the offset and length are in bytes. + * + * If auth capabilities do not include bit_mode, setting this to + * true causes a session creation failure. + * + * The default value is false. + */ + odp_bool_t auth_range_in_bits; + /** Authenticate cipher vs. plain text * * Controls ordering of authentication and cipher operations, @@ -724,6 +748,9 @@ typedef struct odp_crypto_packet_op_param_t { const uint8_t *aad_ptr; /** Data range to be ciphered. + * + * The range is given in bits or bytes as configured at session + * creation. * * Ignored by the null cipher with operation types other than * ODP_CRYPTO_OP_TYPE_OOP. Must be set to zero range (zero offset @@ -733,6 +760,9 @@ typedef struct odp_crypto_packet_op_param_t { odp_packet_data_range_t cipher_range; /** Data range to be authenticated + * + * The range is given in bits or bytes as configured at session + * creation. * * The value is ignored with authenticated encryption algorithms, * such as AES-GCM, which authenticate data in the cipher range @@ -937,22 +967,23 @@ typedef struct odp_crypto_cipher_capability_t { /** IV length in bytes */ uint32_t iv_len; - /** Cipher is operating in bitwise mode + /** Cipher supports bit mode * - * This cipher works on series of bits, rather than sequences of bytes: - * cipher_range in odp_crypto_op_param_t and - * odp_crypto_packet_op_param_t will use bits, rather than bytes. + * This cipher can work on a range of bits in addition to a range of + * bytes. When this capability is not present, only byte ranges are + * supported. The unit of cipher range is selected at session creation + * through the cipher_range_in_bits session parameter. * - * Note: data buffer MUST start on the byte boundary, using offset - * which is not divisible by 8 is unsupported and will result in - * unspecified behaviour. + * Note: In bit mode the cipher range must start on a byte boundary. + * Using an offset which is not divisible by 8 will result in + * undefined behaviour. * - * Note2: If the data length is not a multiple of 8, the remaining - * bits of the data in the last byte of the input/output will be the - * most significant bits, i.e. the most significant bit is considered - * to be the first bit of a byte for the purpose of input and output - * data range. The output bits that fall out of the output range are - * undefined. + * Note2: If the range length in bit mode is not a multiple of 8, + * the remaining bits of the data in the last byte of the input/output + * will be the most significant bits, i.e. the most significant bit is + * considered to be the first bit of a byte for the purpose of input + * and output data range. The output bits that fall out of the output + * range are undefined. */ odp_bool_t bit_mode; @@ -984,22 +1015,23 @@ typedef struct odp_crypto_auth_capability_t { uint32_t inc; } aad_len; - /** Auth is operating in bitstring mode + /** Auth algorithm supports bit mode * - * This auth works on series of bits, rather than sequences of bytes: - * auth_range in odp_crypto_op_param_t and - * odp_crypto_packet_op_param_t will use bits, rather than bytes. + * This auth algorithm can work on a range of bits in addition to + * a range of bytes. When this capability is not present, only byte + * ranges are supported. The unit of auth range is selected at session + * creation through the auth_range_in_bits session parameter. * - * Note: data buffer MUST start on the byte boundary, using offset - * which is not divisible by 8 is unsupported and will result in - * unpredictable behaviour. + * Note: In bit mode the auth range must start on a byte boundary. + * Using an offset which is not divisible by 8 will result in + * undefined behaviour. * - * Note2: If the data length is not a multiple of 8, the remaining - * bits of the data in the last byte of the input/output will be the - * most significant bits, i.e. the most significant bit is considered - * to be the first bit of a byte for the purpose of input and output - * data range. The output bits that fall out of the output range are - * undefined. + * Note2: If the range length in bit mode is not a multiple of 8, + * the remaining bits of the data in the last byte of the input/output + * will be the most significant bits, i.e. the most significant bit is + * considered to be the first bit of a byte for the purpose of input + * and output data range. The output bits that fall out of the output + * range are undefined. */ odp_bool_t bit_mode; -- cgit v1.2.3 From 8d125896ef6647fe2a3e4c245a5120dabcd9f3fa Mon Sep 17 00:00:00 2001 From: Janne Peltonen Date: Tue, 6 Jun 2023 08:40:53 +0300 Subject: api: crypto: copy the ranges of null algorithms in OOP op type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow non-zero-length cipher and auth ranges for the null cipher and auth algorithms in the OOP operation type. Copy the ranges to the output packet as with non-null algorithms. Allow implementations to not fully support non-zero-length ranges by explicitly mentioning that a crypto operation with such a range may fail if not supported. This change makes null algorithms behave as non-null algorithms with respect to packet data copying in the OOP operation type. When both the cipher and the auth algorithms are null, a crypto operation reduces to a packet data copying operation (if supported by the underlying ODP implementation). Such copying may be useful for applications that wish to process crypto and non-crypto packets in the same way using the OOP crypto operation type. Signed-off-by: Janne Peltonen Reviewed-by: Petri Savolainen Reviewed-by: Jere Leppänen Reviewed-by: Anoob Joseph --- include/odp/api/spec/crypto.h | 4 +--- include/odp/api/spec/crypto_types.h | 30 +++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 12 deletions(-) (limited to 'include/odp') diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h index 1c477336e..453eb9eeb 100644 --- a/include/odp/api/spec/crypto.h +++ b/include/odp/api/spec/crypto.h @@ -255,9 +255,7 @@ int odp_crypto_result(odp_crypto_packet_result_t *result, * input packet to the output packet and then the crypto operation * was applied to the output packet. * - * Crypto range and auth range of null cipher and auth algorithms are - * ignored, i.e. not copied in the output packet. Auth range of (AEAD) - * algorithms that ignore auth range is not copied. + * Auth range of (AEAD) algorithms that ignore auth range is not copied. * * The offset of the crypto range and auth range in the output packet is * the same as in the input packet, adjusted by dst_offset_shift operation diff --git a/include/odp/api/spec/crypto_types.h b/include/odp/api/spec/crypto_types.h index 5bcb1e2e0..6aa3f38a6 100644 --- a/include/odp/api/spec/crypto_types.h +++ b/include/odp/api/spec/crypto_types.h @@ -1,5 +1,5 @@ /* Copyright (c) 2014-2018, Linaro Limited - * Copyright (c) 2021-2022, Nokia + * Copyright (c) 2021-2023, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -509,7 +509,7 @@ typedef struct odp_crypto_key { */ typedef enum odp_crypto_op_type_t { /** - * Input packet data and metadata are copied in the output packet + * Input packet data and metadata are copied to the output packet * and then processed. Output packet is allocated by the caller * or by ODP. * @@ -518,7 +518,7 @@ typedef enum odp_crypto_op_type_t { ODP_CRYPTO_OP_TYPE_LEGACY, /** - * Input packet data and metadata are copied in the output packet + * Input packet data and metadata are copied to the output packet * and then processed. Output packet is allocated by ODP. */ ODP_CRYPTO_OP_TYPE_BASIC, @@ -753,9 +753,15 @@ typedef struct odp_crypto_packet_op_param_t { * creation. * * Ignored by the null cipher with operation types other than - * ODP_CRYPTO_OP_TYPE_OOP. Must be set to zero range (zero offset - * and zero length) with the null cipher used with the out-of-place - * operation type. + * ODP_CRYPTO_OP_TYPE_OOP. + * + * With the OOP operation type the cipher range is copied to the + * output packet even with the null cipher. Non-zero-length ranges + * are not necessarily supported with the null cipher and the OOP + * operation type. If the requested range is not supported, the + * crypto operation will fail. The failure is indicated through + * odp_crypto_result() or through a negative return value of + * odp_crypto_op()/odp_crypto_op_enq(). **/ odp_packet_data_range_t cipher_range; @@ -769,9 +775,15 @@ typedef struct odp_crypto_packet_op_param_t { * and the AAD. * * Ignored by the null auth algorithm with operation types other than - * ODP_CRYPTO_OP_TYPE_OOP. Must be set to zero range (zero offset - * and zero length) with the null cipher used with the out-of-place - * operation type. + * ODP_CRYPTO_OP_TYPE_OOP. + * + * With the OOP operation type the auth range is copied to the + * output packet even with the null auth algorithm. Non-zero-length + * ranges are not necessarily supported with the null algorithm and + * the OOP operation type. If the requested range is not supported, + * the crypto operation will fail. The failure is indicated through + * 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 * for the data bytes to be authenticated. -- cgit v1.2.3 From 02ecd50dd05e44e68808bb3d77a0d90c863e1061 Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Wed, 21 Jun 2023 12:25:22 +0300 Subject: api: timer: improve documentation Improved timer alloc and restart documentation. Functionality is not changed. Signed-off-by: Petri Savolainen Reviewed-by: Matias Elo Reviewed-by: Jerin Jacob --- include/odp/api/spec/timer.h | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'include/odp') diff --git a/include/odp/api/spec/timer.h b/include/odp/api/spec/timer.h index a50817c27..a6ad6f2b3 100644 --- a/include/odp/api/spec/timer.h +++ b/include/odp/api/spec/timer.h @@ -227,13 +227,20 @@ int odp_timer_pool_info(odp_timer_pool_t timer_pool, /** * Allocate a timer * - * Create a timer (allocating all necessary resources e.g. timeout event) from - * the timer pool. The user_ptr is copied to timeouts and can be retrieved - * using the odp_timeout_user_ptr() call. + * Allocates a timer from the timer pool. Depending on timer type, the allocated timer is started + * with either odp_timer_start() or odp_timer_periodic_start() call. A timer may be reused multiple + * times before freeing it back into the timer pool. + * + * When timer expires, the timeout event defined in timer start parameters (see + * odp_timer_start_t::tmo_ev or odp_timer_periodic_start_t::tmo_ev) is sent into the provided + * destination queue. + * + * The provided user pointer value is copied into timeout events when the event type is + * ODP_EVENT_TIMEOUT. The value can be retrieved from an event with odp_timeout_user_ptr() call. * * @param timer_pool Timer pool - * @param queue Destination queue for timeout notifications - * @param user_ptr User defined pointer or NULL to be copied to timeouts + * @param queue Destination queue for timeout events + * @param user_ptr User defined pointer value or NULL * * @return Timer handle on success * @retval ODP_TIMER_INVALID on failure @@ -286,9 +293,12 @@ int odp_timer_start(odp_timer_t timer, const odp_timer_start_t *start_param); * Restart a timer * * A successful restart call updates the expiration time of an active timer. The timeout event - * is not changed. The timer is not modified when a failure is returned. The call returns - * ODP_TIMER_FAIL if the timer has expired already, or is so close to expire that it cannot be - * restarted anymore. + * is not changed. + * + * The timer is not modified when a failure is returned. The call returns #ODP_TIMER_FAIL if + * the timer has expired already, or is so close to expire that it cannot be restarted anymore. + * A failure is returned also when the new expiration time is too near to the current time + * (#ODP_TIMER_TOO_NEAR) or too far from the current time (#ODP_TIMER_TOO_FAR). * * The new expiration time is passed the same way as with odp_timer_start() call. * -- cgit v1.2.3 From ced5a54a7fb4b96ec03a60b2a6eb3a3a9ccadd7e Mon Sep 17 00:00:00 2001 From: Tuomas Taipale Date: Mon, 26 Jun 2023 06:00:41 +0000 Subject: api: pool: add user area content persistence capability New `uarea_persistence` pool capability signals if implementation is able to maintain the content of pool user areas across frees and allocations. In case the content can be maintained, applications could initialize all user areas only once after pool creation and trust that the content remains valid after freeing an event. Otherwise, user areas need re-initialization after every allocation. Signed-off-by: Tuomas Taipale Acked-by: Ashwin Sekhar T K Reviewed-by: Petri Savolainen --- include/odp/api/spec/dma_types.h | 8 +++++++- include/odp/api/spec/pool_types.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) (limited to 'include/odp') diff --git a/include/odp/api/spec/dma_types.h b/include/odp/api/spec/dma_types.h index 26350e998..2f9e618b7 100644 --- a/include/odp/api/spec/dma_types.h +++ b/include/odp/api/spec/dma_types.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2022, Nokia +/* Copyright (c) 2021-2023, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -80,6 +80,12 @@ typedef struct odp_dma_pool_capability_t { /** Maximum user area size in bytes */ uint32_t max_uarea_size; + /** Pool user area persistence + * + * See buf.uarea_persistence of odp_pool_capability_t for details + * (odp_pool_capability_t::uarea_persistence). */ + odp_bool_t uarea_persistence; + /** Minimum size of thread local cache */ uint32_t min_cache_size; diff --git a/include/odp/api/spec/pool_types.h b/include/odp/api/spec/pool_types.h index cf1051a07..7f56fb937 100644 --- a/include/odp/api/spec/pool_types.h +++ b/include/odp/api/spec/pool_types.h @@ -209,6 +209,19 @@ typedef struct odp_pool_capability_t { /** Maximum user area size in bytes */ uint32_t max_uarea_size; + /** Pool user area persistence + * + * When supported, implementation does not overwrite buffer user area + * content at any point of buffer lifetime nor after freeing a buffer + * back into pool. + * + * 0: User area content is maintained throughout regular buffer usage + * after allocation, but may be modified after free (default) + * 1: User area content is maintained throughout regular buffer usage + * and additionally also after buffer is freed into the pool (between + * buffer free and allocation) */ + odp_bool_t uarea_persistence; + /** Minimum size of thread local cache */ uint32_t min_cache_size; @@ -288,6 +301,11 @@ typedef struct odp_pool_capability_t { /** Maximum user area size in bytes */ uint32_t max_uarea_size; + /** Pool user area persistence + * + * See buf.uarea_persistence for details. */ + odp_bool_t uarea_persistence; + /** Maximum number of subparameters * * Maximum number of packet pool subparameters. Valid range is @@ -318,6 +336,11 @@ typedef struct odp_pool_capability_t { /** Maximum user area size in bytes */ uint32_t max_uarea_size; + /** Pool user area persistence + * + * See buf.uarea_persistence for details. */ + odp_bool_t uarea_persistence; + /** Minimum size of thread local cache */ uint32_t min_cache_size; @@ -345,6 +368,11 @@ typedef struct odp_pool_capability_t { /** Maximum user area size in bytes */ uint32_t max_uarea_size; + /** Pool user area persistence + * + * See buf.uarea_persistence for details. */ + odp_bool_t uarea_persistence; + /** Minimum size of thread local cache */ uint32_t min_cache_size; @@ -713,6 +741,12 @@ typedef struct odp_pool_ext_capability_t { /** Maximum user area size in bytes */ uint32_t max_uarea_size; + /** Pool user area persistence + * + * See buf.uarea_persistence of odp_pool_capability_t for details + * (odp_pool_capability_t::uarea_persistence). */ + odp_bool_t uarea_persistence; + } pkt; } odp_pool_ext_capability_t; -- cgit v1.2.3 From f2fca4ddfa0ad5a293b4f222c1d2cb0af4274e1c Mon Sep 17 00:00:00 2001 From: Tuomas Taipale Date: Mon, 26 Jun 2023 07:50:07 +0000 Subject: api: pool: add user area initialization parameters New `uarea_init` pool parameters `init_fn` and `args` can be used to initialize event user areas of a pool at pool creation time. This enables straightforward user area initialization in case implementation supports the new `uarea_persistence` pool capability. Signed-off-by: Tuomas Taipale Acked-by: Ashwin Sekhar T K Reviewed-by: Petri Savolainen --- include/odp/api/spec/dma_types.h | 13 +++++++++++++ include/odp/api/spec/pool_types.h | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) (limited to 'include/odp') diff --git a/include/odp/api/spec/dma_types.h b/include/odp/api/spec/dma_types.h index 2f9e618b7..739b705fd 100644 --- a/include/odp/api/spec/dma_types.h +++ b/include/odp/api/spec/dma_types.h @@ -110,6 +110,19 @@ typedef struct odp_dma_pool_param_t { */ uint32_t uarea_size; + /** Parameters for user area initialization */ + struct { + /** See uarea_init.init_fn of odp_pool_param_t for details + * (odp_pool_param_t::init_fn). Function is called during + * odp_dma_pool_create(). */ + void (*init_fn)(void *uarea, uint32_t size, void *args, uint32_t index); + + /** See uarea_init.args of odp_pool_param_t for details + * (odp_pool_param_t::args). */ + void *args; + + } uarea_init; + /** Maximum number of events cached locally per thread * * See odp_pool_param_t::cache_size documentation for details. Valid values range from diff --git a/include/odp/api/spec/pool_types.h b/include/odp/api/spec/pool_types.h index 7f56fb937..81974abc6 100644 --- a/include/odp/api/spec/pool_types.h +++ b/include/odp/api/spec/pool_types.h @@ -609,6 +609,30 @@ typedef struct odp_pool_param_t { uint32_t cache_size; } vector; + /** Parameters for user area initialization */ + struct { + /** User area initialization function + * + * Application defined user area initialization function to be + * called for each event of the pool during odp_pool_create(). Ignored + * if user area persistence is not supported + * (odp_pool_capability_t::uarea_persistence) or pool will not have any + * user area. The default value is NULL. + * + * @param uarea Pointer to the user area of an event + * @param size User area size + * @param args Pointer to application defined arguments + * @param index Index of the event (0..num events in pool - 1), not + * necessarily in order + */ + void (*init_fn)(void *uarea, uint32_t size, void *args, uint32_t index); + + /** Pointer to application defined arguments to be passed to every call + * of init_fn. The default value is NULL. + */ + void *args; + } uarea_init; + /** * Configure statistics counters * @@ -758,6 +782,23 @@ typedef struct odp_pool_ext_param_t { /** Pool type */ odp_pool_type_t type; + /** Parameters for user area initialization */ + struct { + /** See uarea_init.init_fn of odp_pool_param_t for details + * (odp_pool_param_t::init_fn). However, note that with external memory + * pools, this function is called during memory population and not during + * pool creation (odp_pool_ext_populate()). Depending on the implementation, + * the function may be called each time pool is being populated with + * odp_pool_ext_populate() or during the last population call + * (odp_pool_ext_populate() with #ODP_POOL_POPULATE_DONE). */ + void (*init_fn)(void *uarea, uint32_t size, void *args, uint32_t index); + + /** See uarea_init.args of odp_pool_param_t for details + * (odp_pool_param_t::args). */ + void *args; + + } uarea_init; + /** Maximum thread local cache size for the pool * * Valid value range is from min_cache_size to max_cache_size capability. -- cgit v1.2.3 From 0eb63396734283e0ea8949562e9edf8dd925fb4c Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Wed, 28 Jun 2023 16:35:42 +0300 Subject: api: dma: pack DMA segment data structure Move odp_dma_seg_t structure fields so that addr/packet field is directly followed by length and offset fields. After this change all commonly used fields are located in the first 16 bytes of the structure, which may improve performance. Signed-off-by: Petri Savolainen Reviewed-by: Matias Elo Reviewed-by: Pavan Nikhilesh --- include/odp/api/spec/dma_types.h | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'include/odp') diff --git a/include/odp/api/spec/dma_types.h b/include/odp/api/spec/dma_types.h index 739b705fd..5e18faab2 100644 --- a/include/odp/api/spec/dma_types.h +++ b/include/odp/api/spec/dma_types.h @@ -384,41 +384,39 @@ typedef struct odp_dma_param_t { * DMA segment */ typedef struct odp_dma_seg_t { - /** Segment start */ + /** Segment start address or packet handle */ union { /** Segment start address in memory * - * Defines segment start when data format is ODP_DMA_FORMAT_ADDR. Ignored with + * Defines segment start when data format is #ODP_DMA_FORMAT_ADDR. Ignored with * other data formats. */ void *addr; - /** Segment start as an offset into a packet */ - struct { - /** Packet handle - * - * Defines the packet when data format is ODP_DMA_FORMAT_PACKET. Ignored - * with other data formats. */ - odp_packet_t packet; + /** Packet handle + * + * Defines the packet when data format is #ODP_DMA_FORMAT_PACKET. Ignored + * with other data formats. */ + odp_packet_t packet; - /** Segment start offset into the packet - * - * Defines segment start when data format is ODP_DMA_FORMAT_PACKET. - * The offset is calculated from odp_packet_data() position, and the value - * must not exceed odp_packet_len(). - */ - uint32_t offset; - }; }; /** Segment length in bytes * * Defines segment length with all data formats. The maximum value is defined by - * max_seg_len capability. When data format is ODP_DMA_FORMAT_PACKET, the value must not + * max_seg_len capability. When data format is #ODP_DMA_FORMAT_PACKET, the value must not * exceed odp_packet_len() - 'offset'. */ uint32_t len; + /** Segment start offset into the packet + * + * Defines segment start within the packet data. The offset is calculated from + * odp_packet_data() position, and the value must not exceed odp_packet_len(). + * Ignored when data format is other than #ODP_DMA_FORMAT_PACKET. + */ + uint32_t offset; + /** Segment hints * * Depending on the implementation, setting these hints may improve performance. -- cgit v1.2.3 From 6cf41639a8400b32999626b029e522a0ddcde16f Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Wed, 28 Jun 2023 10:02:43 +0300 Subject: api: sync: add load and store synchronization barriers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added memory barriers which ensure that load/store instructions started before the barrier are complete, before load/store instructions after the barrier are started. These are stronger barriers than the current acquire, release and full barriers. Those ensure visibility order of memory accesses, but do not wait access completion. The new barriers are useful e.g. when serializing access to memory mapped registers of a device. Signed-off-by: Petri Savolainen Reviewed-by: Matias Elo Reviewed-by: Jere Leppänen Acked-by: Jerin Jacob --- include/odp/api/spec/sync.h | 67 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 13 deletions(-) (limited to 'include/odp') diff --git a/include/odp/api/spec/sync.h b/include/odp/api/spec/sync.h index 0b75ffaee..18272af88 100644 --- a/include/odp/api/spec/sync.h +++ b/include/odp/api/spec/sync.h @@ -1,7 +1,6 @@ -/* 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 + * Copyright (c) 2023 Nokia */ /** @@ -23,15 +22,24 @@ extern "C" { * @details * Memory barriers * - * Memory barriers enforce ordering of memory load and store operations - * specified before and after the barrier. These barriers may affect both - * compiler optimizations and CPU out-of-order execution. All ODP - * synchronization mechanisms (e.g. execution barriers, locks, queues, etc ) - * include all necessary memory barriers, so these calls are not needed when - * using those. Also ODP atomic operations have memory ordered versions. These - * explicit barriers may be needed when thread synchronization is based on - * a non-ODP defined mechanism. Depending on the HW platform, heavy usage of - * memory barriers may cause significant performance degradation. + * A memory barrier enforces the order between memory accesses (loads and/or stores) + * specified (in program order) before the barrier with those specified after the barrier. + * A barrier may affect both compiler optimizations and CPU out-of-order execution. Depending + * on the used HW platform and barrier types, heavy usage of barriers may cause significant + * performance degradation. + * + * An application may use these memory barrier functions e.g. to build a synchronization + * mechanism between its threads in shared memory, or when it accesses memory mapped registers + * of a device. + * + * An application does not need to use these memory barriers when using other ODP APIs for thread + * synchronization (execution barriers, spinlocks, etc.), or when exchanging data through ODP API + * mechanisms (queues, stashes, etc.). Those ODP calls include necessary (acquire and release) + * memory barriers to maintain coherency between data producers and consumers. + * + * Some ODP atomic operations include a memory barrier - see for example odp_atomic_load_acq_u32() + * or odp_atomic_store_rel_u32(). Application may use also those (non-relaxed) atomic operations + * to enforce memory ordering while using atomic variables. * * @{ */ @@ -79,6 +87,39 @@ void odp_mb_acquire(void); */ void odp_mb_full(void); +/** + * Memory barrier for load and store synchronization + * + * This memory barrier ensures that all memory accesses (loads and stores) specified before the + * barrier (in program order) are complete prior to any memory access specified after the barrier + * begins execution. + * + * This is a stronger barrier than odp_mb_full(), as in addition to visibility order also memory + * access completion is ensured. The barrier may be useful e.g. when synchronizing loads and stores + * into memory mapped registers of a device. + */ +void odp_mb_sync(void); + +/** + * Memory barrier for load synchronization + * + * This memory barrier ensures that all memory loads specified before the barrier (in program + * order) are complete prior to any memory load specified after the barrier begins execution. + * + * The barrier may be useful e.g. when synchronizing loads from memory mapped registers of a device. + */ +void odp_mb_sync_load(void); + +/** + * Memory synchronization barrier for stores + * + * This memory barrier ensures that all memory stores specified before the barrier (in program + * order) are complete prior to any memory store specified after the barrier begins execution. + * + * The barrier may be useful e.g. when synchronizing stores to memory mapped registers of a device. + */ +void odp_mb_sync_store(void); + /** * @} */ -- cgit v1.2.3