diff options
author | Neale Ranns <neale@graphiant.com> | 2021-02-24 09:18:53 +0000 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2021-02-24 14:21:33 +0000 |
commit | 63ab85130cc3a5f52a5ee6b8f9c9bc6e9a2fcd72 (patch) | |
tree | 726657092d1765723578706f6de765d09ee04364 /src/vnet/crypto/crypto.h | |
parent | 48307fb4be6507e5fda450975cd4546f813cd0ce (diff) |
crypto: A more memory efficient layout of the frame element struct
Type: improvement
Also:
- state as enum so my GDB life is easier
- typo; s/indice/indices/;
Signed-off-by: Neale Ranns <neale@graphiant.com>
Change-Id: I3320f5ef1ccd7d042071ef336488a41adfad7463
Diffstat (limited to 'src/vnet/crypto/crypto.h')
-rw-r--r-- | src/vnet/crypto/crypto.h | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/vnet/crypto/crypto.h b/src/vnet/crypto/crypto.h index 529c70ac088..eeb120400a8 100644 --- a/src/vnet/crypto/crypto.h +++ b/src/vnet/crypto/crypto.h @@ -300,13 +300,6 @@ typedef struct typedef struct { - vnet_crypto_op_status_t status:8; - u32 key_index; - i16 crypto_start_offset; /* first buffer offset */ - i16 integ_start_offset; - u32 crypto_total_length; - /* adj total_length for integ, e.g.4 bytes for IPSec ESN */ - u16 integ_length_adj; u8 *iv; union { @@ -314,18 +307,33 @@ typedef struct u8 *tag; }; u8 *aad; + u32 key_index; + u32 crypto_total_length; + i16 crypto_start_offset; /* first buffer offset */ + i16 integ_start_offset; + /* adj total_length for integ, e.g.4 bytes for IPSec ESN */ + u16 integ_length_adj; + vnet_crypto_op_status_t status : 8; u8 flags; /**< share same VNET_CRYPTO_OP_FLAG_* values */ } vnet_crypto_async_frame_elt_t; +/* Assert the size so the compiler will warn us when it changes */ +STATIC_ASSERT_SIZEOF (vnet_crypto_async_frame_elt_t, 5 * sizeof (u64)); + +typedef enum vnet_crypto_async_frame_state_t_ +{ + VNET_CRYPTO_FRAME_STATE_NOT_PROCESSED, + /* frame waiting to be processed */ + VNET_CRYPTO_FRAME_STATE_PENDING, + VNET_CRYPTO_FRAME_STATE_WORK_IN_PROGRESS, + VNET_CRYPTO_FRAME_STATE_SUCCESS, + VNET_CRYPTO_FRAME_STATE_ELT_ERROR +} __clib_packed vnet_crypto_async_frame_state_t; + typedef struct { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); -#define VNET_CRYPTO_FRAME_STATE_NOT_PROCESSED 0 -#define VNET_CRYPTO_FRAME_STATE_PENDING 1 /* frame waiting to be processed */ -#define VNET_CRYPTO_FRAME_STATE_WORK_IN_PROGRESS 2 -#define VNET_CRYPTO_FRAME_STATE_SUCCESS 3 -#define VNET_CRYPTO_FRAME_STATE_ELT_ERROR 4 - u8 state; + vnet_crypto_async_frame_state_t state; vnet_crypto_async_op_id_t op:8; u16 n_elts; vnet_crypto_async_frame_elt_t elts[VNET_CRYPTO_FRAME_SIZE]; @@ -339,7 +347,7 @@ typedef struct CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); vnet_crypto_async_frame_t *frames[VNET_CRYPTO_ASYNC_OP_N_IDS]; vnet_crypto_async_frame_t *frame_pool; - u32 *buffer_indice; + u32 *buffer_indices; u16 *nexts; } vnet_crypto_thread_t; |