diff options
author | Janne Peltonen <janne.peltonen@nokia.com> | 2023-03-06 15:20:44 +0200 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2023-03-07 09:53:24 +0200 |
commit | 0a094fc1002edb607045bd485c9b6da14ed506ae (patch) | |
tree | 61ca1af0b9fd7d23d8720432499045ade54bdc19 /example | |
parent | 83593b79033e574ab2744b965652249e74e0784f (diff) |
example: ipsec_crypto: switch to basic crypto operation type
Simplify the example by switching to ODP_CRYPTO_OP_TYPE_BASIC from
ODP_CRYPTO_OP_TYPE_LEGACY. Remove the selection between in-place
and new-buffer API modes as the basic operation type always
consumes the input packets and produces a new output packet.
Signed-off-by: Janne Peltonen <janne.peltonen@nokia.com>
Reviewed-by: Matias Elo <matias.elo@nokia.com>
Diffstat (limited to 'example')
-rw-r--r-- | example/ipsec_crypto/odp_ipsec.c | 14 | ||||
-rw-r--r-- | example/ipsec_crypto/odp_ipsec_cache.c | 6 | ||||
-rw-r--r-- | example/ipsec_crypto/odp_ipsec_cache.h | 4 |
3 files changed, 6 insertions, 18 deletions
diff --git a/example/ipsec_crypto/odp_ipsec.c b/example/ipsec_crypto/odp_ipsec.c index 565d85a3f..c5dd7398e 100644 --- a/example/ipsec_crypto/odp_ipsec.c +++ b/example/ipsec_crypto/odp_ipsec.c @@ -634,7 +634,6 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t *pkt, /* Initialize parameters block */ memset(¶ms, 0, sizeof(params)); params.session = entry->state.session; - out_pkt = entry->in_place ? *pkt : ODP_PACKET_INVALID; /*Save everything to context */ ctx->ipsec.ip_tos = ip->tos; @@ -679,7 +678,7 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t *pkt, *skip = FALSE; ctx->state = PKT_STATE_IPSEC_IN_FINISH; if (entry->async) { - if (odp_crypto_op_enq(pkt, &out_pkt, ¶ms, 1) != 1) { + if (odp_crypto_op_enq(pkt, NULL, ¶ms, 1) != 1) { ODPH_ERR("Error: odp_crypto_op_enq() failed\n"); exit(EXIT_FAILURE); } @@ -989,11 +988,9 @@ pkt_disposition_e do_ipsec_out_seq(odp_packet_t *pkt, ip->id = odp_cpu_to_be_16((*ctx->ipsec.tun_hdr_id)++); } - out_pkt = entry->in_place ? *pkt : ODP_PACKET_INVALID; - /* Issue crypto request */ if (entry->async) { - if (odp_crypto_op_enq(pkt, &out_pkt, + if (odp_crypto_op_enq(pkt, NULL, &ctx->ipsec.params, 1) != 1) { ODPH_ERR("Error: odp_crypto_op_enq() failed\n"); exit(EXIT_FAILURE); @@ -1362,9 +1359,7 @@ main(int argc, char *argv[]) /* Populate our IPsec cache */ printf("Using %s mode for crypto API\n\n", - (CRYPTO_API_SYNC == global->appl.mode) ? "SYNC" : - (CRYPTO_API_ASYNC_IN_PLACE == global->appl.mode) ? - "ASYNC_IN_PLACE" : "ASYNC_NEW_BUFFER"); + (CRYPTO_API_SYNC == global->appl.mode) ? "SYNC" : "ASYNC"); ipsec_init_post(global->appl.mode); /* Initialize interfaces (which resolves FWD DB entries */ @@ -1661,8 +1656,7 @@ static void usage(char *progname) "Mandatory OPTIONS:\n" " -i, --interface Eth interfaces (comma-separated, no spaces)\n" " -m, --mode 0: SYNC\n" - " 1: ASYNC_IN_PLACE\n" - " 2: ASYNC_NEW_BUFFER\n" + " 1: ASYNC\n" " Default: 0: SYNC api mode\n" "\n" "Routing / IPSec OPTIONS:\n" diff --git a/example/ipsec_crypto/odp_ipsec_cache.c b/example/ipsec_crypto/odp_ipsec_cache.c index d6ea8ecd4..65a51bd1d 100644 --- a/example/ipsec_crypto/odp_ipsec_cache.c +++ b/example/ipsec_crypto/odp_ipsec_cache.c @@ -71,6 +71,7 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa, /* Setup parameters and call crypto library to create session */ params.op = (in) ? ODP_CRYPTO_OP_DECODE : ODP_CRYPTO_OP_ENCODE; + params.op_type = ODP_CRYPTO_OP_TYPE_BASIC; params.auth_cipher_text = TRUE; if (CRYPTO_API_SYNC == api_mode) { params.op_mode = ODP_CRYPTO_SYNC; @@ -84,11 +85,6 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa, entry->async = TRUE; } - if (CRYPTO_API_ASYNC_NEW_BUFFER == api_mode) - entry->in_place = FALSE; - else - entry->in_place = TRUE; - entry->sa_flags = 0; /* Cipher */ diff --git a/example/ipsec_crypto/odp_ipsec_cache.h b/example/ipsec_crypto/odp_ipsec_cache.h index 0634f8a3c..b1e3e7ac1 100644 --- a/example/ipsec_crypto/odp_ipsec_cache.h +++ b/example/ipsec_crypto/odp_ipsec_cache.h @@ -22,8 +22,7 @@ extern "C" { */ typedef enum { CRYPTO_API_SYNC, /**< Synchronous mode */ - CRYPTO_API_ASYNC_IN_PLACE, /**< Asynchronous in place */ - CRYPTO_API_ASYNC_NEW_BUFFER /**< Asynchronous new buffer */ + CRYPTO_API_ASYNC, /**< Asynchronous mode */ } crypto_api_mode_e; /** @@ -31,7 +30,6 @@ typedef enum { */ typedef struct ipsec_cache_entry_s { struct ipsec_cache_entry_s *next; /**< Next entry on list */ - odp_bool_t in_place; /**< Crypto API mode */ odp_bool_t async; /**< ASYNC or SYNC mode */ int sa_flags; uint32_t src_ip; /**< Source v4 address */ |