aboutsummaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2022-10-28 18:15:36 +0300
committerPetri Savolainen <petri.savolainen@nokia.com>2022-12-29 14:55:25 +0200
commit76e9963229adb40410d7e4439bac35ec92e42c46 (patch)
tree6fc859f5dbfeb739a7045c9c9e64e1f0da42f5a4 /platform
parente2eb952cc47843f453edd01bc3b153feeff5ef68 (diff)
linux-gen: crypto: inline odp_crypto_result() implementation
Inline odp_crypto_result() function implementation. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
Diffstat (limited to 'platform')
-rw-r--r--platform/linux-generic/arch/aarch64/odp_crypto_armv8.c25
-rw-r--r--platform/linux-generic/include/odp/api/plat/crypto_inlines.h16
-rw-r--r--platform/linux-generic/include/odp/api/plat/packet_inline_types.h1
-rw-r--r--platform/linux-generic/odp_crypto_ipsecmb.c25
-rw-r--r--platform/linux-generic/odp_crypto_null.c25
-rw-r--r--platform/linux-generic/odp_crypto_openssl.c25
-rw-r--r--platform/linux-generic/odp_packet.c1
7 files changed, 22 insertions, 96 deletions
diff --git a/platform/linux-generic/arch/aarch64/odp_crypto_armv8.c b/platform/linux-generic/arch/aarch64/odp_crypto_armv8.c
index 58e566c22..a1c2c96d2 100644
--- a/platform/linux-generic/arch/aarch64/odp_crypto_armv8.c
+++ b/platform/linux-generic/arch/aarch64/odp_crypto_armv8.c
@@ -180,21 +180,13 @@ void free_session(odp_crypto_generic_session_t *session)
odp_spinlock_unlock(&global->lock);
}
-static
-odp_crypto_packet_result_t *get_op_result_from_packet(odp_packet_t pkt)
-{
- odp_packet_hdr_t *hdr = packet_hdr(pkt);
-
- return &hdr->crypto_op_result;
-}
-
static inline void set_crypto_op_result(odp_packet_t pkt,
odp_crypto_alg_err_t cipher_err,
odp_crypto_alg_err_t auth_err)
{
odp_crypto_packet_result_t *op_result;
- op_result = get_op_result_from_packet(pkt);
+ op_result = &packet_hdr(pkt)->crypto_op_result;
op_result->cipher_status.alg_err = cipher_err;
op_result->cipher_status.hw_err = ODP_CRYPTO_HW_ERR_NONE;
op_result->auth_status.alg_err = auth_err;
@@ -889,21 +881,6 @@ uint64_t odp_crypto_session_to_u64(odp_crypto_session_t hdl)
return (uint64_t)hdl;
}
-int odp_crypto_result(odp_crypto_packet_result_t *result,
- odp_packet_t packet)
-{
- odp_crypto_packet_result_t *op_result;
-
- _ODP_ASSERT(odp_event_subtype(odp_packet_to_event(packet)) ==
- ODP_EVENT_PACKET_CRYPTO);
-
- op_result = get_op_result_from_packet(packet);
-
- memcpy(result, op_result, sizeof(*result));
-
- return 0;
-}
-
static int copy_data_and_metadata(odp_packet_t dst, odp_packet_t src)
{
int md_copy;
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 cfea67283..8e98d8580 100644
--- a/platform/linux-generic/include/odp/api/plat/crypto_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/crypto_inlines.h
@@ -11,10 +11,12 @@
extern "C" {
#endif
+#include <odp/api/crypto_types.h>
#include <odp/api/event.h>
#include <odp/api/packet.h>
#include <odp/api/plat/debug_inlines.h>
+#include <odp/api/plat/packet_inline_types.h>
/** @cond _ODP_HIDE_FROM_DOXYGEN_ */
@@ -23,6 +25,7 @@ extern "C" {
#define _ODP_INLINE static inline
#define odp_crypto_packet_from_event __odp_crypto_packet_from_event
#define odp_crypto_packet_to_event __odp_crypto_packet_to_event
+ #define odp_crypto_result __odp_crypto_result
#else
#define _ODP_INLINE
#endif
@@ -40,6 +43,19 @@ _ODP_INLINE odp_event_t odp_crypto_packet_to_event(odp_packet_t pkt)
return odp_packet_to_event(pkt);
}
+_ODP_INLINE int odp_crypto_result(odp_crypto_packet_result_t *result, odp_packet_t pkt)
+{
+ odp_crypto_packet_result_t *op_result;
+
+ _ODP_ASSERT(odp_packet_subtype(pkt) == ODP_EVENT_PACKET_CRYPTO);
+
+ op_result = _odp_pkt_get_ptr(pkt, odp_crypto_packet_result_t, crypto_op);
+
+ *result = *op_result;
+
+ return 0;
+}
+
/** @endcond */
#ifdef __cplusplus
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 ae03457f9..6773b73ad 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
@@ -53,6 +53,7 @@ typedef struct _odp_packet_inline_offset_t {
uint16_t subtype;
uint16_t cls_mark;
uint16_t ipsec_ctx;
+ uint16_t crypto_op;
} _odp_packet_inline_offset_t;
diff --git a/platform/linux-generic/odp_crypto_ipsecmb.c b/platform/linux-generic/odp_crypto_ipsecmb.c
index 34b62fdee..89e964a83 100644
--- a/platform/linux-generic/odp_crypto_ipsecmb.c
+++ b/platform/linux-generic/odp_crypto_ipsecmb.c
@@ -151,14 +151,6 @@ void free_session(odp_crypto_generic_session_t *session)
odp_spinlock_unlock(&global->lock);
}
-static
-odp_crypto_packet_result_t *get_op_result_from_packet(odp_packet_t pkt)
-{
- odp_packet_hdr_t *hdr = packet_hdr(pkt);
-
- return &hdr->crypto_op_result;
-}
-
static odp_crypto_alg_err_t
null_crypto_routine(odp_packet_t pkt ODP_UNUSED,
const odp_crypto_packet_op_param_t *param ODP_UNUSED,
@@ -790,21 +782,6 @@ uint64_t odp_crypto_session_to_u64(odp_crypto_session_t hdl)
return (uint64_t)hdl;
}
-int odp_crypto_result(odp_crypto_packet_result_t *result,
- odp_packet_t packet)
-{
- odp_crypto_packet_result_t *op_result;
-
- _ODP_ASSERT(odp_event_subtype(odp_packet_to_event(packet)) ==
- ODP_EVENT_PACKET_CRYPTO);
-
- op_result = get_op_result_from_packet(packet);
-
- memcpy(result, op_result, sizeof(*result));
-
- return 0;
-}
-
static int copy_data_and_metadata(odp_packet_t dst, odp_packet_t src)
{
int md_copy;
@@ -884,7 +861,7 @@ int crypto_int(odp_packet_t pkt_in,
}
packet_subtype_set(out_pkt, ODP_EVENT_PACKET_CRYPTO);
- op_result = get_op_result_from_packet(out_pkt);
+ op_result = &packet_hdr(out_pkt)->crypto_op_result;
op_result->cipher_status.alg_err = rc_cipher;
op_result->cipher_status.hw_err = ODP_CRYPTO_HW_ERR_NONE;
op_result->auth_status.alg_err = rc_auth;
diff --git a/platform/linux-generic/odp_crypto_null.c b/platform/linux-generic/odp_crypto_null.c
index aeb27ab5b..50d4b5c6b 100644
--- a/platform/linux-generic/odp_crypto_null.c
+++ b/platform/linux-generic/odp_crypto_null.c
@@ -449,29 +449,6 @@ uint64_t odp_crypto_session_to_u64(odp_crypto_session_t hdl)
return (uint64_t)hdl;
}
-static
-odp_crypto_packet_result_t *get_op_result_from_packet(odp_packet_t pkt)
-{
- odp_packet_hdr_t *hdr = packet_hdr(pkt);
-
- return &hdr->crypto_op_result;
-}
-
-int odp_crypto_result(odp_crypto_packet_result_t *result,
- odp_packet_t packet)
-{
- odp_crypto_packet_result_t *op_result;
-
- _ODP_ASSERT(odp_event_subtype(odp_packet_to_event(packet)) ==
- ODP_EVENT_PACKET_CRYPTO);
-
- op_result = get_op_result_from_packet(packet);
-
- memcpy(result, op_result, sizeof(*result));
-
- return 0;
-}
-
static int copy_data_and_metadata(odp_packet_t dst, odp_packet_t src)
{
int md_copy;
@@ -541,7 +518,7 @@ int crypto_int(odp_packet_t pkt_in,
/* Fill in result */
packet_subtype_set(out_pkt, ODP_EVENT_PACKET_CRYPTO);
- op_result = get_op_result_from_packet(out_pkt);
+ op_result = &packet_hdr(out_pkt)->crypto_op_result;
op_result->cipher_status.alg_err = ODP_CRYPTO_ALG_ERR_NONE;
op_result->cipher_status.hw_err = ODP_CRYPTO_HW_ERR_NONE;
op_result->auth_status.alg_err = ODP_CRYPTO_ALG_ERR_NONE;
diff --git a/platform/linux-generic/odp_crypto_openssl.c b/platform/linux-generic/odp_crypto_openssl.c
index 210cad38d..88b9e5800 100644
--- a/platform/linux-generic/odp_crypto_openssl.c
+++ b/platform/linux-generic/odp_crypto_openssl.c
@@ -2778,29 +2778,6 @@ uint64_t odp_crypto_session_to_u64(odp_crypto_session_t hdl)
return (uint64_t)hdl;
}
-static
-odp_crypto_packet_result_t *get_op_result_from_packet(odp_packet_t pkt)
-{
- odp_packet_hdr_t *hdr = packet_hdr(pkt);
-
- return &hdr->crypto_op_result;
-}
-
-int odp_crypto_result(odp_crypto_packet_result_t *result,
- odp_packet_t packet)
-{
- odp_crypto_packet_result_t *op_result;
-
- _ODP_ASSERT(odp_event_subtype(odp_packet_to_event(packet)) ==
- ODP_EVENT_PACKET_CRYPTO);
-
- op_result = get_op_result_from_packet(packet);
-
- memcpy(result, op_result, sizeof(*result));
-
- return 0;
-}
-
static int copy_data_and_metadata(odp_packet_t dst, odp_packet_t src)
{
int md_copy;
@@ -2895,7 +2872,7 @@ int crypto_int(odp_packet_t pkt_in,
out:
/* Fill in result */
packet_subtype_set(out_pkt, ODP_EVENT_PACKET_CRYPTO);
- op_result = get_op_result_from_packet(out_pkt);
+ op_result = &packet_hdr(out_pkt)->crypto_op_result;
op_result->cipher_status.alg_err = rc_cipher;
op_result->cipher_status.hw_err = ODP_CRYPTO_HW_ERR_NONE;
op_result->auth_status.alg_err = rc_auth;
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 212e48de0..1ce475625 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -69,6 +69,7 @@ const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = {
.subtype = offsetof(odp_packet_hdr_t, subtype),
.cls_mark = offsetof(odp_packet_hdr_t, cls_mark),
.ipsec_ctx = offsetof(odp_packet_hdr_t, ipsec_ctx),
+ .crypto_op = offsetof(odp_packet_hdr_t, crypto_op_result),
};
#include <odp/visibility_end.h>