summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPablo de Lara <pablo.de.lara.guarch@intel.com>2017-07-02 06:41:13 +0100
committerPablo de Lara <pablo.de.lara.guarch@intel.com>2017-07-06 22:26:48 +0200
commit5082f991f6def0ef06e9ff1cf9f39ef3b78657c5 (patch)
treef98a8f2b6371a24200280afafba04a2004684cb9 /test
parentdad71e9958e62b61cf4edf16d716d38738ead20e (diff)
downloaddpdk-5082f991f6def0ef06e9ff1cf9f39ef3b78657c5.zip
dpdk-5082f991f6def0ef06e9ff1cf9f39ef3b78657c5.tar.gz
dpdk-5082f991f6def0ef06e9ff1cf9f39ef3b78657c5.tar.xz
cryptodev: pass IV as offset
Since IV now is copied after the crypto operation, in its private size, IV can be passed only with offset and length. Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com> Acked-by: Declan Doherty <declan.doherty@intel.com> Acked-by: Akhil Goyal <akhil.goyal@nxp.com> Acked-by: Fiona Trahe <fiona.trahe@intel.com>
Diffstat (limited to 'test')
-rw-r--r--test/test/test_cryptodev.c107
-rw-r--r--test/test/test_cryptodev_blockcipher.c8
-rw-r--r--test/test/test_cryptodev_perf.c60
3 files changed, 68 insertions, 107 deletions
diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index 4603679..a509bea 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -1312,13 +1312,11 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
sym_op->auth.data.length = QUOTE_512_BYTES;
/* Set crypto operation cipher parameters */
- sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
- uint8_t *, IV_OFFSET);
- sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
- IV_OFFSET);
+ sym_op->cipher.iv.offset = IV_OFFSET;
sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
- rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
+ rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
+ aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
sym_op->cipher.data.offset = 0;
sym_op->cipher.data.length = QUOTE_512_BYTES;
@@ -1465,13 +1463,11 @@ test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
sym_op->auth.data.offset = 0;
sym_op->auth.data.length = QUOTE_512_BYTES;
- sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
- uint8_t *, IV_OFFSET);
- sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
- IV_OFFSET);
+ sym_op->cipher.iv.offset = IV_OFFSET;
sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
- rte_memcpy(sym_op->cipher.iv.data, iv, CIPHER_IV_LENGTH_AES_CBC);
+ rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
+ iv, CIPHER_IV_LENGTH_AES_CBC);
sym_op->cipher.data.offset = 0;
sym_op->cipher.data.length = QUOTE_512_BYTES;
@@ -1861,13 +1857,11 @@ create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
sym_op->m_src = ut_params->ibuf;
/* iv */
- sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
- uint8_t *, IV_OFFSET);
- sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
- IV_OFFSET);
+ sym_op->cipher.iv.offset = IV_OFFSET;
sym_op->cipher.iv.length = iv_len;
- rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
+ rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
+ iv, iv_len);
sym_op->cipher.data.length = cipher_len;
sym_op->cipher.data.offset = cipher_offset;
return 0;
@@ -1897,13 +1891,11 @@ create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
sym_op->m_dst = ut_params->obuf;
/* iv */
- sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
- uint8_t *, IV_OFFSET);
- sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
- IV_OFFSET);
+ sym_op->cipher.iv.offset = IV_OFFSET;
sym_op->cipher.iv.length = iv_len;
- rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
+ rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
+ iv, iv_len);
sym_op->cipher.data.length = cipher_len;
sym_op->cipher.data.offset = cipher_offset;
return 0;
@@ -2220,13 +2212,11 @@ create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
/* iv */
- sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
- uint8_t *, IV_OFFSET);
- sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
- IV_OFFSET);
+ sym_op->cipher.iv.offset = IV_OFFSET;
sym_op->cipher.iv.length = iv_len;
- rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
+ rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
+ iv, iv_len);
sym_op->cipher.data.length = cipher_len;
sym_op->cipher.data.offset = cipher_offset + auth_offset;
sym_op->auth.data.length = auth_len;
@@ -2317,13 +2307,11 @@ create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
/* iv */
- sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
- uint8_t *, IV_OFFSET);
- sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
- IV_OFFSET);
+ sym_op->cipher.iv.offset = IV_OFFSET;
sym_op->cipher.iv.length = iv_len;
- rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
+ rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
+ iv, iv_len);
sym_op->cipher.data.length = cipher_len;
sym_op->cipher.data.offset = cipher_offset + auth_offset;
sym_op->auth.data.length = auth_len;
@@ -2402,14 +2390,11 @@ create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
sym_op->auth.aad.data, aad_len);
/* iv */
- sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
- uint8_t *, IV_OFFSET);
- sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
- IV_OFFSET);
+ sym_op->cipher.iv.offset = IV_OFFSET;
sym_op->cipher.iv.length = iv_len;
- rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
-
+ rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
+ iv, iv_len);
sym_op->cipher.data.length = cipher_len;
sym_op->cipher.data.offset = auth_offset + cipher_offset;
@@ -4855,14 +4840,13 @@ create_gcm_operation(enum rte_crypto_cipher_operation op,
sym_op->auth.aad.length);
/* Append IV at the end of the crypto operation*/
- sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
- uint8_t *, IV_OFFSET);
- sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
- IV_OFFSET);
+ uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
+ uint8_t *, IV_OFFSET);
+ sym_op->cipher.iv.offset = IV_OFFSET;
sym_op->cipher.iv.length = tdata->iv.len;
- rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
- TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data,
+ rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
+ TEST_HEXDUMP(stdout, "iv:", iv_ptr,
sym_op->cipher.iv.length);
/* Append plaintext/ciphertext */
@@ -6430,15 +6414,15 @@ create_gmac_operation(enum rte_crypto_auth_operation op,
sym_op->auth.digest.length);
}
- sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
- uint8_t *, IV_OFFSET);
- sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
- IV_OFFSET);
+ uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
+ uint8_t *, IV_OFFSET);
+
+ sym_op->cipher.iv.offset = IV_OFFSET;
sym_op->cipher.iv.length = tdata->iv.len;
- rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
+ rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
- TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, tdata->iv.len);
+ TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
sym_op->cipher.data.length = 0;
sym_op->cipher.data.offset = 0;
@@ -6976,13 +6960,11 @@ create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
sym_op->auth.digest.data,
sym_op->auth.digest.length);
- sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
- uint8_t *, IV_OFFSET);
- sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
- IV_OFFSET);
+ sym_op->cipher.iv.offset = IV_OFFSET;
sym_op->cipher.iv.length = reference->iv.len;
- rte_memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
+ rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
+ reference->iv.data, reference->iv.len);
sym_op->cipher.data.length = 0;
sym_op->cipher.data.offset = 0;
@@ -7035,13 +7017,11 @@ create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
sym_op->auth.digest.data,
sym_op->auth.digest.length);
- sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
- uint8_t *, IV_OFFSET);
- sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
- IV_OFFSET);
+ sym_op->cipher.iv.offset = IV_OFFSET;
sym_op->cipher.iv.length = reference->iv.len;
- rte_memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
+ rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
+ reference->iv.data, reference->iv.len);
sym_op->cipher.data.length = reference->ciphertext.len;
sym_op->cipher.data.offset = 0;
@@ -7285,13 +7265,12 @@ create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
sym_op->auth.digest.length);
}
- sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
- uint8_t *, IV_OFFSET);
- sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
- IV_OFFSET);
+ uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
+ uint8_t *, IV_OFFSET);
+ sym_op->cipher.iv.offset = IV_OFFSET;
sym_op->cipher.iv.length = iv_len;
- rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, iv_len);
+ rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
ut_params->ibuf, aad_len);
@@ -7304,7 +7283,7 @@ create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
memset(sym_op->auth.aad.data, 0, aad_len);
rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
- TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_len);
+ TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
TEST_HEXDUMP(stdout, "aad:",
sym_op->auth.aad.data, aad_len);
diff --git a/test/test/test_cryptodev_blockcipher.c b/test/test/test_cryptodev_blockcipher.c
index aa3ecc8..aed6c84 100644
--- a/test/test/test_cryptodev_blockcipher.c
+++ b/test/test/test_cryptodev_blockcipher.c
@@ -291,12 +291,10 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
sym_op->cipher.data.offset = 0;
sym_op->cipher.data.length = tdata->ciphertext.len;
- sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(op,
- uint8_t *, IV_OFFSET);
- sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
- IV_OFFSET);
+ sym_op->cipher.iv.offset = IV_OFFSET;
sym_op->cipher.iv.length = tdata->iv.len;
- rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data,
+ rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
+ tdata->iv.data,
tdata->iv.len);
}
diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c
index a959a6c..cbf21c7 100644
--- a/test/test/test_cryptodev_perf.c
+++ b/test/test/test_cryptodev_perf.c
@@ -1981,15 +1981,11 @@ test_perf_crypto_qp_vary_burst_size(uint16_t dev_num)
op->sym->auth.data.offset = 0;
op->sym->auth.data.length = data_params[0].length;
-
- op->sym->cipher.iv.data = rte_crypto_op_ctod_offset(op,
- uint8_t *, IV_OFFSET);
- op->sym->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
- IV_OFFSET);
+ op->sym->cipher.iv.offset = IV_OFFSET;
op->sym->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
- rte_memcpy(op->sym->cipher.iv.data, aes_cbc_128_iv,
- CIPHER_IV_LENGTH_AES_CBC);
+ rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
+ aes_cbc_128_iv, CIPHER_IV_LENGTH_AES_CBC);
op->sym->cipher.data.offset = 0;
op->sym->cipher.data.length = data_params[0].length;
@@ -2898,13 +2894,10 @@ test_perf_set_crypto_op_aes(struct rte_crypto_op *op, struct rte_mbuf *m,
/* Cipher Parameters */
- op->sym->cipher.iv.data = rte_crypto_op_ctod_offset(op,
- uint8_t *, IV_OFFSET);
- op->sym->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
- IV_OFFSET);
+ op->sym->cipher.iv.offset = IV_OFFSET;
op->sym->cipher.iv.length = AES_CIPHER_IV_LENGTH;
-
- rte_memcpy(op->sym->cipher.iv.data, aes_iv, AES_CIPHER_IV_LENGTH);
+ rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
+ aes_iv, AES_CIPHER_IV_LENGTH);
op->sym->cipher.data.offset = 0;
op->sym->cipher.data.length = data_len;
@@ -2934,12 +2927,10 @@ test_perf_set_crypto_op_aes_gcm(struct rte_crypto_op *op, struct rte_mbuf *m,
op->sym->auth.aad.length = AES_GCM_AAD_LENGTH;
/* Cipher Parameters */
- op->sym->cipher.iv.data = rte_crypto_op_ctod_offset(op,
- uint8_t *, IV_OFFSET);
- op->sym->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
- IV_OFFSET);
+ op->sym->cipher.iv.offset = IV_OFFSET;
op->sym->cipher.iv.length = AES_CIPHER_IV_LENGTH;
- rte_memcpy(op->sym->cipher.iv.data, aes_iv, AES_CIPHER_IV_LENGTH);
+ rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
+ aes_iv, AES_CIPHER_IV_LENGTH);
/* Data lengths/offsets Parameters */
op->sym->auth.data.offset = 0;
@@ -2980,9 +2971,7 @@ test_perf_set_crypto_op_snow3g(struct rte_crypto_op *op, struct rte_mbuf *m,
op->sym->auth.aad.length = SNOW3G_CIPHER_IV_LENGTH;
/* Cipher Parameters */
- op->sym->cipher.iv.data = iv_ptr;
- op->sym->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
- IV_OFFSET);
+ op->sym->cipher.iv.offset = IV_OFFSET;
op->sym->cipher.iv.length = SNOW3G_CIPHER_IV_LENGTH;
/* Data lengths/offsets Parameters */
@@ -3009,12 +2998,10 @@ test_perf_set_crypto_op_snow3g_cipher(struct rte_crypto_op *op,
}
/* Cipher Parameters */
- op->sym->cipher.iv.data = rte_crypto_op_ctod_offset(op,
- uint8_t *, IV_OFFSET);
- op->sym->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
- IV_OFFSET);
+ op->sym->cipher.iv.offset = IV_OFFSET;
op->sym->cipher.iv.length = SNOW3G_CIPHER_IV_LENGTH;
- rte_memcpy(op->sym->cipher.iv.data, snow3g_iv, SNOW3G_CIPHER_IV_LENGTH);
+ rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
+ snow3g_iv, SNOW3G_CIPHER_IV_LENGTH);
op->sym->cipher.data.offset = 0;
op->sym->cipher.data.length = data_len << 3;
@@ -3082,13 +3069,10 @@ test_perf_set_crypto_op_3des(struct rte_crypto_op *op, struct rte_mbuf *m,
op->sym->auth.digest.length = digest_len;
/* Cipher Parameters */
- op->sym->cipher.iv.data = rte_crypto_op_ctod_offset(op,
- uint8_t *, IV_OFFSET);
- op->sym->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
- IV_OFFSET);
+ op->sym->cipher.iv.offset = IV_OFFSET;
op->sym->cipher.iv.length = TRIPLE_DES_CIPHER_IV_LENGTH;
- rte_memcpy(op->sym->cipher.iv.data, triple_des_iv,
- TRIPLE_DES_CIPHER_IV_LENGTH);
+ rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
+ triple_des_iv, TRIPLE_DES_CIPHER_IV_LENGTH);
/* Data lengths/offsets Parameters */
op->sym->auth.data.offset = 0;
@@ -4183,6 +4167,9 @@ perf_gcm_set_crypto_op(struct rte_crypto_op *op, struct rte_mbuf *m,
struct crypto_params *m_hlp,
struct perf_test_params *params)
{
+ uint8_t *iv_ptr = rte_crypto_op_ctod_offset(op,
+ uint8_t *, IV_OFFSET);
+
if (rte_crypto_op_attach_sym_session(op, sess) != 0) {
rte_crypto_op_free(op);
return NULL;
@@ -4203,14 +4190,11 @@ perf_gcm_set_crypto_op(struct rte_crypto_op *op, struct rte_mbuf *m,
rte_memcpy(op->sym->auth.aad.data, params->symmetric_op->aad_data,
params->symmetric_op->aad_len);
- op->sym->cipher.iv.data = rte_crypto_op_ctod_offset(op,
- uint8_t *, IV_OFFSET);
- op->sym->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
- IV_OFFSET);
- rte_memcpy(op->sym->cipher.iv.data, params->symmetric_op->iv_data,
+ op->sym->cipher.iv.offset = IV_OFFSET;
+ rte_memcpy(iv_ptr, params->symmetric_op->iv_data,
params->symmetric_op->iv_len);
if (params->symmetric_op->iv_len == 12)
- op->sym->cipher.iv.data[15] = 1;
+ iv_ptr[15] = 1;
op->sym->cipher.iv.length = params->symmetric_op->iv_len;