This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, api-next has been updated via 2e93b540f69eae505b4505ada1912ac0d2bdea31 (commit) via a2c78489c30722a5d0b14e994f713e4a393a0801 (commit) via be13cd9dfdc276d039cbd5658ec1b0166397ac0c (commit) via 84cf048f83fb15fbfae66bca824220635ddc0339 (commit) from 89159170e2e4fc90f6f2c8b0d7f017a3a650623d (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 2e93b540f69eae505b4505ada1912ac0d2bdea31 Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Tue Nov 7 17:34:29 2017 +0300
linux-gen: ipsec: use new odp checksum API
Use odp_chksum_ones_comp16 which may be platform-optimized.
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index aaa566ca..b17e4cd7 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -7,6 +7,7 @@ #include "config.h"
#include <odp/api/ipsec.h> +#include <odp/api/chksum.h>
#include <odp/api/plat/packet_inlines.h>
@@ -98,34 +99,6 @@ static odp_ipsec_packet_result_t *ipsec_pkt_result(odp_packet_t packet) return &odp_packet_hdr(packet)->ipsec_ctx; }
-/** - * Checksum - * - * @param buffer calculate chksum for buffer - * @param len buffer length - * - * @return checksum value in network order - */ -static inline -odp_u16sum_t _odp_chksum(void *buffer, int len) -{ - uint16_t *buf = (uint16_t *)buffer; - uint32_t sum = 0; - uint16_t result; - - for (sum = 0; len > 1; len -= 2) - sum += *buf++; - - if (len == 1) - sum += *(unsigned char *)buf; - - sum = (sum >> 16) + (sum & 0xFFFF); - sum += (sum >> 16); - result = ~sum; - - return (__odp_force odp_u16sum_t) result; -} - static inline int _odp_ipv4_csum(odp_packet_t pkt, uint32_t offset, _odp_ipv4hdr_t *ip, @@ -145,7 +118,7 @@ static inline int _odp_ipv4_csum(odp_packet_t pkt, if (odp_unlikely(res < 0)) return res;
- *chksum = _odp_chksum(buf, nleft); + *chksum = ~odp_chksum_ones_comp16(buf, nleft);
return 0; }
commit a2c78489c30722a5d0b14e994f713e4a393a0801 Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Tue Nov 7 17:33:30 2017 +0300
helper: use new odp checksum API
Use odp_chksum_ones_comp16 which may be platform-optimized. This removes now unnecessary odph_cksum() function.
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/helper/include/odp/helper/chksum.h b/helper/include/odp/helper/chksum.h index 1bf950c8..ed2de91f 100644 --- a/helper/include/odp/helper/chksum.h +++ b/helper/include/odp/helper/chksum.h @@ -34,33 +34,6 @@ typedef enum { ODPH_CHKSUM_RETURN /**< Don't generate or verify chksum */ } odph_chksum_op_t;
-/** - * Checksum - * - * @param buffer calculate chksum for buffer - * @param len buffer length - * - * @return checksum value in network order - */ -static inline odp_u16sum_t odph_chksum(void *buffer, int len) -{ - uint16_t *buf = (uint16_t *)buffer; - uint32_t sum = 0; - uint16_t result; - - for (sum = 0; len > 1; len -= 2) - sum += *buf++; - - if (len == 1) - sum += *(unsigned char *)buf; - - sum = (sum >> 16) + (sum & 0xFFFF); - sum += (sum >> 16); - result = ~sum; - - return (__odp_force odp_u16sum_t) result; -} - /** * General Purpose TCP/UDP checksum function * diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h index c6eb9d76..b96aab28 100644 --- a/helper/include/odp/helper/ip.h +++ b/helper/include/odp/helper/ip.h @@ -125,7 +125,7 @@ static inline int odph_ipv4_csum(odp_packet_t pkt, if (odp_unlikely(res < 0)) return res;
- *chksum = odph_chksum(buf, nleft); + *chksum = ~odp_chksum_ones_comp16(buf, nleft);
return 0; }
commit be13cd9dfdc276d039cbd5658ec1b0166397ac0c Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Mon Nov 20 17:41:02 2017 +0300
example: switch to using ODP chksum API
ODP now provides odp_chksum_ones_comp16, switch examples to use it instead of odph_chksum helper function.
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 912fe7e9..e1d98539 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -355,7 +355,7 @@ static int setup_udp_pkt(odp_packet_t pkt, odp_pktout_config_opt_t *pktout_cfg) ip->id = odp_cpu_to_be_16(seq); if (!pktout_cfg->bit.ipv4_chksum) { ip->chksum = 0; - ip->chksum = odph_chksum(ip, ODPH_IPV4HDR_LEN); + ip->chksum = ~odp_chksum_ones_comp16(ip, ODPH_IPV4HDR_LEN); }
if (pktout_cfg->bit.ipv4_chksum || pktout_cfg->bit.udp_chksum) { @@ -453,7 +453,7 @@ static int setup_icmp_pkt(odp_packet_t pkt, ip->id = odp_cpu_to_be_16(seq); if (!pktout_cfg->bit.ipv4_chksum) { ip->chksum = 0; - ip->chksum = odph_chksum(ip, ODPH_IPV4HDR_LEN); + ip->chksum = ~odp_chksum_ones_comp16(ip, ODPH_IPV4HDR_LEN); }
/* icmp */ @@ -466,7 +466,8 @@ static int setup_icmp_pkt(odp_packet_t pkt, memcpy(tval_d, &tval, sizeof(uint64_t));
icmp->chksum = 0; - icmp->chksum = odph_chksum(icmp, args->appl.payload + ODPH_ICMPHDR_LEN); + icmp->chksum = ~odp_chksum_ones_comp16(icmp, args->appl.payload + + ODPH_ICMPHDR_LEN);
if (pktout_cfg->bit.ipv4_chksum) { odp_packet_l2_offset_set(pkt, 0); diff --git a/example/ipsec/odp_ipsec_stream.c b/example/ipsec/odp_ipsec_stream.c index e37fbee2..bc5d572f 100644 --- a/example/ipsec/odp_ipsec_stream.c +++ b/example/ipsec/odp_ipsec_stream.c @@ -269,7 +269,8 @@ odp_packet_t create_ipv4_packet(stream_db_entry_t *stream, inner_ip->frag_offset = 0; inner_ip->src_addr = odp_cpu_to_be_32(stream->src_ip); inner_ip->dst_addr = odp_cpu_to_be_32(stream->dst_ip); - inner_ip->chksum = odph_chksum(inner_ip, sizeof(*inner_ip)); + inner_ip->chksum = ~odp_chksum_ones_comp16(inner_ip, + sizeof(*inner_ip)); data += sizeof(*inner_ip); }
@@ -290,7 +291,7 @@ odp_packet_t create_ipv4_packet(stream_db_entry_t *stream,
/* Close ICMP */ icmp->chksum = 0; - icmp->chksum = odph_chksum(icmp, data - (uint8_t *)icmp); + icmp->chksum = ~odp_chksum_ones_comp16(icmp, data - (uint8_t *)icmp);
/* Close ESP if specified */ if (esp) {
commit 84cf048f83fb15fbfae66bca824220635ddc0339 Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Nov 7 10:33:22 2017 +0200
api: crypto: move AAD length to session param
Moved AAD length from crypto operation parameters to session parameters. AAD length is commonly constant per session. Also some implementations (such as DPDK) expect AAD length at session creation time.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h index 6a4304d8..2109509f 100644 --- a/include/odp/api/spec/crypto.h +++ b/include/odp/api/spec/crypto.h @@ -333,6 +333,14 @@ typedef struct odp_crypto_session_param_t { */ uint32_t auth_digest_len;
+ /** Additional Authenticated Data (AAD) length in bytes + * + * AAD length is constant for all operations (packets) of the session. + * Set to zero when AAD is not used. Use odp_crypto_auth_capability() + * for supported AAD lengths. The default value is zero. + */ + uint32_t auth_aad_len; + /** Async mode completion event queue * * The completion queue is used to return completions from @@ -401,12 +409,11 @@ typedef struct odp_crypto_op_param_t {
/** Additional Authenticated Data (AAD) */ struct { - /** Pointer to ADD */ + /** Pointer to AAD. AAD length is defined by 'auth_aad_len' + * session parameter. + */ uint8_t *ptr;
- /** AAD length in bytes. Use odp_crypto_auth_capability() for - * supported AAD lengths. */ - uint32_t length; } aad;
/** Data range to apply cipher */ @@ -442,12 +449,11 @@ typedef struct odp_crypto_packet_op_param_t {
/** Additional Authenticated Data (AAD) */ struct { - /** Pointer to ADD */ + /** Pointer to AAD. AAD length is defined by 'auth_aad_len' + * session parameter. + */ uint8_t *ptr;
- /** AAD length in bytes. Use odp_crypto_auth_capability() for - * supported AAD lengths. */ - uint32_t length; } aad;
/** Data range to apply cipher */ diff --git a/platform/linux-generic/include/odp_ipsec_internal.h b/platform/linux-generic/include/odp_ipsec_internal.h index b50b65be..06447870 100644 --- a/platform/linux-generic/include/odp_ipsec_internal.h +++ b/platform/linux-generic/include/odp_ipsec_internal.h @@ -177,6 +177,12 @@ typedef struct odp_ipsec_sa_lookup_s { void *dst_addr; } ipsec_sa_lookup_t;
+/** IPSEC AAD */ +typedef struct ODP_PACKED { + odp_u32be_t spi; /**< Security Parameter Index */ + odp_u32be_t seq_no; /**< Sequence Number */ +} ipsec_aad_t; + /** * Obtain SA reference */ diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 67dd3249..b5f538dd 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -479,7 +479,7 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_packet_t pkt, { EVP_CIPHER_CTX *ctx; const uint8_t *aad_head = param->aad.ptr; - uint32_t aad_len = param->aad.length; + uint32_t aad_len = session->p.auth_aad_len; void *iv_ptr; int dummy_len = 0; uint8_t block[EVP_MAX_MD_SIZE]; @@ -526,7 +526,7 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_packet_t pkt, { EVP_CIPHER_CTX *ctx; const uint8_t *aad_head = param->aad.ptr; - uint32_t aad_len = param->aad.length; + uint32_t aad_len = session->p.auth_aad_len; int dummy_len = 0; void *iv_ptr; uint8_t block[EVP_MAX_MD_SIZE]; @@ -1058,7 +1058,6 @@ odp_crypto_operation(odp_crypto_op_param_t *param, packet_param.override_iv_ptr = param->override_iv_ptr; packet_param.hash_result_offset = param->hash_result_offset; packet_param.aad.ptr = param->aad.ptr; - packet_param.aad.length = param->aad.length; packet_param.cipher_range = param->cipher_range; packet_param.auth_range = param->auth_range;
diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index 0ebc6534..aaa566ca 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -20,11 +20,6 @@
#include <string.h>
-typedef struct ODP_PACKED { - odp_u32be_t spi; /**< Security Parameter Index */ - odp_u32be_t seq_no; /**< Sequence Number */ -} ipsec_aad_t; - int odp_ipsec_capability(odp_ipsec_capability_t *capa) { int rc; @@ -358,7 +353,6 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, aad.seq_no = esp.seq_no;
param.aad.ptr = (uint8_t *)&aad; - param.aad.length = sizeof(aad);
param.auth_range.offset = ipsec_offset; param.auth_range.length = odp_be_to_cpu_16(ip->tot_len) - @@ -431,7 +425,6 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, aad.seq_no = ah.seq_no;
param.aad.ptr = (uint8_t *)&aad; - param.aad.length = sizeof(aad);
param.auth_range.offset = ip_offset; param.auth_range.length = odp_be_to_cpu_16(ip->tot_len); @@ -798,7 +791,6 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, aad.seq_no = esp.seq_no;
param.aad.ptr = (uint8_t *)&aad; - param.aad.length = sizeof(aad);
memset(&esptrl, 0, sizeof(esptrl)); esptrl.pad_len = encrypt_len - ip_data_len - _ODP_ESPTRL_LEN; @@ -874,7 +866,6 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, aad.seq_no = ah.seq_no;
param.aad.ptr = (uint8_t *)&aad; - param.aad.length = sizeof(aad);
/* For GMAC */ if (ipsec_sa->use_counter_iv) { diff --git a/platform/linux-generic/odp_ipsec_sad.c b/platform/linux-generic/odp_ipsec_sad.c index f1fde5e6..0287d6f7 100644 --- a/platform/linux-generic/odp_ipsec_sad.c +++ b/platform/linux-generic/odp_ipsec_sad.c @@ -195,6 +195,7 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param) ipsec_sa_t *ipsec_sa; odp_crypto_session_param_t crypto_param; odp_crypto_ses_create_err_t ses_create_rc; + uint32_t aad_len = 0;
ipsec_sa = ipsec_sa_reserve(); if (NULL == ipsec_sa) { @@ -334,6 +335,7 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param) #endif case ODP_AUTH_ALG_AES_GCM: ipsec_sa->icv_len = 16; + aad_len = sizeof(ipsec_aad_t); break; case ODP_AUTH_ALG_AES_GMAC: if (ODP_CIPHER_ALG_NULL != crypto_param.cipher_alg) @@ -353,6 +355,7 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param) odp_atomic_init_u64(&ipsec_sa->out.counter, 1);
crypto_param.auth_digest_len = ipsec_sa->icv_len; + crypto_param.auth_aad_len = aad_len;
if (param->crypto.cipher_key_extra.length) { if (param->crypto.cipher_key_extra.length > diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index 87f0ed93..cba472de 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -82,7 +82,6 @@ static int alg_op(odp_packet_t pkt, odp_packet_data_range_t *cipher_range, odp_packet_data_range_t *auth_range, uint8_t *aad, - uint32_t aad_len, unsigned int plaintext_len) { int rc; @@ -104,7 +103,6 @@ static int alg_op(odp_packet_t pkt, op_params.override_iv_ptr = op_iv_ptr;
op_params.aad.ptr = aad; - op_params.aad.length = aad_len;
op_params.hash_result_offset = plaintext_len;
@@ -159,7 +157,6 @@ static int alg_packet_op(odp_packet_t pkt, odp_packet_data_range_t *cipher_range, odp_packet_data_range_t *auth_range, uint8_t *aad, - uint32_t aad_len, unsigned int plaintext_len) { int rc; @@ -178,7 +175,6 @@ static int alg_packet_op(odp_packet_t pkt, op_params.override_iv_ptr = op_iv_ptr;
op_params.aad.ptr = aad; - op_params.aad.length = aad_len;
op_params.hash_result_offset = plaintext_len;
@@ -218,7 +214,6 @@ static int alg_packet_op_enq(odp_packet_t pkt, odp_packet_data_range_t *cipher_range, odp_packet_data_range_t *auth_range, uint8_t *aad, - uint32_t aad_len, unsigned int plaintext_len) { int rc; @@ -238,7 +233,6 @@ static int alg_packet_op_enq(odp_packet_t pkt, op_params.override_iv_ptr = op_iv_ptr;
op_params.aad.ptr = aad; - op_params.aad.length = aad_len;
op_params.hash_result_offset = plaintext_len;
@@ -440,6 +434,7 @@ static void alg_test(odp_crypto_op_t op, ses_params.iv = iv; ses_params.auth_key = auth_key; ses_params.auth_digest_len = ref->digest_length; + ses_params.auth_aad_len = ref->aad_length;
rc = odp_crypto_session_create(&ses_params, &session, &status); CU_ASSERT_FATAL(!rc); @@ -476,20 +471,17 @@ restart: rc = alg_op(pkt, &ok, session, ovr_iv ? ref->iv : NULL, &cipher_range, &auth_range, - ref->aad, ref->aad_length, - ref->length); + ref->aad, ref->length); else if (ODP_CRYPTO_ASYNC == suite_context.op_mode) rc = alg_packet_op_enq(pkt, &ok, session, ovr_iv ? ref->iv : NULL, &cipher_range, &auth_range, - ref->aad, ref->aad_length, - ref->length); + ref->aad, ref->length); else rc = alg_packet_op(pkt, &ok, session, ovr_iv ? ref->iv : NULL, &cipher_range, &auth_range, - ref->aad, ref->aad_length, - ref->length); + ref->aad, ref->length); if (rc < 0) { goto cleanup; }
-----------------------------------------------------------------------
Summary of changes: example/generator/odp_generator.c | 7 ++-- example/ipsec/odp_ipsec_stream.c | 5 +-- helper/include/odp/helper/chksum.h | 27 --------------- helper/include/odp/helper/ip.h | 2 +- include/odp/api/spec/crypto.h | 22 +++++++----- .../linux-generic/include/odp_ipsec_internal.h | 6 ++++ platform/linux-generic/odp_crypto.c | 5 ++- platform/linux-generic/odp_ipsec.c | 40 ++-------------------- platform/linux-generic/odp_ipsec_sad.c | 3 ++ test/validation/api/crypto/odp_crypto_test_inp.c | 16 +++------ 10 files changed, 39 insertions(+), 94 deletions(-)
hooks/post-receive