diff options
author | Tadeusz Struk <tadeusz.struk@intel.com> | 2014-09-10 17:07:36 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-09-24 02:01:26 -0400 |
commit | 26c3af6c1580a0a6d63cf507ad249953cfaff703 (patch) | |
tree | 2cde71f20da0e2d572cf4c033f518f0d963298ad /drivers/crypto/qat | |
parent | 7752759d957a84c889556e3096db21ec43312eb3 (diff) |
crypto: qat - Removed unneeded partial state
Removed additional bufer for HW state for partial requests, which are not going
to be supported.
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/qat')
-rw-r--r-- | drivers/crypto/qat/qat_common/qat_algs.c | 66 |
1 files changed, 7 insertions, 59 deletions
diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c index 59df48872955..3e26fa2b293f 100644 --- a/drivers/crypto/qat/qat_common/qat_algs.c +++ b/drivers/crypto/qat/qat_common/qat_algs.c | |||
@@ -105,7 +105,7 @@ struct qat_alg_cd { | |||
105 | #define MAX_AUTH_STATE_SIZE sizeof(struct icp_qat_hw_auth_algo_blk) | 105 | #define MAX_AUTH_STATE_SIZE sizeof(struct icp_qat_hw_auth_algo_blk) |
106 | 106 | ||
107 | struct qat_auth_state { | 107 | struct qat_auth_state { |
108 | uint8_t data[MAX_AUTH_STATE_SIZE]; | 108 | uint8_t data[MAX_AUTH_STATE_SIZE + 64]; |
109 | } __aligned(64); | 109 | } __aligned(64); |
110 | 110 | ||
111 | struct qat_alg_session_ctx { | 111 | struct qat_alg_session_ctx { |
@@ -113,10 +113,6 @@ struct qat_alg_session_ctx { | |||
113 | dma_addr_t enc_cd_paddr; | 113 | dma_addr_t enc_cd_paddr; |
114 | struct qat_alg_cd *dec_cd; | 114 | struct qat_alg_cd *dec_cd; |
115 | dma_addr_t dec_cd_paddr; | 115 | dma_addr_t dec_cd_paddr; |
116 | struct qat_auth_state *auth_hw_state_enc; | ||
117 | dma_addr_t auth_state_enc_paddr; | ||
118 | struct qat_auth_state *auth_hw_state_dec; | ||
119 | dma_addr_t auth_state_dec_paddr; | ||
120 | struct icp_qat_fw_la_bulk_req enc_fw_req_tmpl; | 116 | struct icp_qat_fw_la_bulk_req enc_fw_req_tmpl; |
121 | struct icp_qat_fw_la_bulk_req dec_fw_req_tmpl; | 117 | struct icp_qat_fw_la_bulk_req dec_fw_req_tmpl; |
122 | struct qat_crypto_instance *inst; | 118 | struct qat_crypto_instance *inst; |
@@ -150,8 +146,9 @@ static int qat_get_inter_state_size(enum icp_qat_hw_auth_algo qat_hash_alg) | |||
150 | static int qat_alg_do_precomputes(struct icp_qat_hw_auth_algo_blk *hash, | 146 | static int qat_alg_do_precomputes(struct icp_qat_hw_auth_algo_blk *hash, |
151 | struct qat_alg_session_ctx *ctx, | 147 | struct qat_alg_session_ctx *ctx, |
152 | const uint8_t *auth_key, | 148 | const uint8_t *auth_key, |
153 | unsigned int auth_keylen, uint8_t *auth_state) | 149 | unsigned int auth_keylen) |
154 | { | 150 | { |
151 | struct qat_auth_state auth_state; | ||
155 | struct { | 152 | struct { |
156 | struct shash_desc shash; | 153 | struct shash_desc shash; |
157 | char ctx[crypto_shash_descsize(ctx->hash_tfm)]; | 154 | char ctx[crypto_shash_descsize(ctx->hash_tfm)]; |
@@ -161,12 +158,13 @@ static int qat_alg_do_precomputes(struct icp_qat_hw_auth_algo_blk *hash, | |||
161 | struct sha512_state sha512; | 158 | struct sha512_state sha512; |
162 | int block_size = crypto_shash_blocksize(ctx->hash_tfm); | 159 | int block_size = crypto_shash_blocksize(ctx->hash_tfm); |
163 | int digest_size = crypto_shash_digestsize(ctx->hash_tfm); | 160 | int digest_size = crypto_shash_digestsize(ctx->hash_tfm); |
164 | uint8_t *ipad = auth_state; | 161 | uint8_t *ipad = auth_state.data; |
165 | uint8_t *opad = ipad + block_size; | 162 | uint8_t *opad = ipad + block_size; |
166 | __be32 *hash_state_out; | 163 | __be32 *hash_state_out; |
167 | __be64 *hash512_state_out; | 164 | __be64 *hash512_state_out; |
168 | int i, offset; | 165 | int i, offset; |
169 | 166 | ||
167 | memset(auth_state.data, '\0', MAX_AUTH_STATE_SIZE + 64); | ||
170 | desc.shash.tfm = ctx->hash_tfm; | 168 | desc.shash.tfm = ctx->hash_tfm; |
171 | desc.shash.flags = 0x0; | 169 | desc.shash.flags = 0x0; |
172 | 170 | ||
@@ -298,10 +296,6 @@ static int qat_alg_init_enc_session(struct qat_alg_session_ctx *ctx, | |||
298 | void *ptr = &req_tmpl->cd_ctrl; | 296 | void *ptr = &req_tmpl->cd_ctrl; |
299 | struct icp_qat_fw_cipher_cd_ctrl_hdr *cipher_cd_ctrl = ptr; | 297 | struct icp_qat_fw_cipher_cd_ctrl_hdr *cipher_cd_ctrl = ptr; |
300 | struct icp_qat_fw_auth_cd_ctrl_hdr *hash_cd_ctrl = ptr; | 298 | struct icp_qat_fw_auth_cd_ctrl_hdr *hash_cd_ctrl = ptr; |
301 | struct icp_qat_fw_la_auth_req_params *auth_param = | ||
302 | (struct icp_qat_fw_la_auth_req_params *) | ||
303 | ((char *)&req_tmpl->serv_specif_rqpars + | ||
304 | sizeof(struct icp_qat_fw_la_cipher_req_params)); | ||
305 | 299 | ||
306 | /* CD setup */ | 300 | /* CD setup */ |
307 | cipher->aes.cipher_config.val = QAT_AES_HW_CONFIG_ENC(alg); | 301 | cipher->aes.cipher_config.val = QAT_AES_HW_CONFIG_ENC(alg); |
@@ -312,8 +306,7 @@ static int qat_alg_init_enc_session(struct qat_alg_session_ctx *ctx, | |||
312 | hash->sha.inner_setup.auth_counter.counter = | 306 | hash->sha.inner_setup.auth_counter.counter = |
313 | cpu_to_be32(crypto_shash_blocksize(ctx->hash_tfm)); | 307 | cpu_to_be32(crypto_shash_blocksize(ctx->hash_tfm)); |
314 | 308 | ||
315 | if (qat_alg_do_precomputes(hash, ctx, keys->authkey, keys->authkeylen, | 309 | if (qat_alg_do_precomputes(hash, ctx, keys->authkey, keys->authkeylen)) |
316 | (uint8_t *)ctx->auth_hw_state_enc)) | ||
317 | return -EFAULT; | 310 | return -EFAULT; |
318 | 311 | ||
319 | /* Request setup */ | 312 | /* Request setup */ |
@@ -359,9 +352,6 @@ static int qat_alg_init_enc_session(struct qat_alg_session_ctx *ctx, | |||
359 | hash_cd_ctrl->inner_state2_offset = hash_cd_ctrl->hash_cfg_offset + | 352 | hash_cd_ctrl->inner_state2_offset = hash_cd_ctrl->hash_cfg_offset + |
360 | ((sizeof(struct icp_qat_hw_auth_setup) + | 353 | ((sizeof(struct icp_qat_hw_auth_setup) + |
361 | round_up(hash_cd_ctrl->inner_state1_sz, 8)) >> 3); | 354 | round_up(hash_cd_ctrl->inner_state1_sz, 8)) >> 3); |
362 | auth_param->u1.auth_partial_st_prefix = ctx->auth_state_enc_paddr + | ||
363 | sizeof(struct icp_qat_hw_auth_counter) + | ||
364 | round_up(hash_cd_ctrl->inner_state1_sz, 8); | ||
365 | ICP_QAT_FW_COMN_CURR_ID_SET(hash_cd_ctrl, ICP_QAT_FW_SLICE_AUTH); | 355 | ICP_QAT_FW_COMN_CURR_ID_SET(hash_cd_ctrl, ICP_QAT_FW_SLICE_AUTH); |
366 | ICP_QAT_FW_COMN_NEXT_ID_SET(hash_cd_ctrl, ICP_QAT_FW_SLICE_DRAM_WR); | 356 | ICP_QAT_FW_COMN_NEXT_ID_SET(hash_cd_ctrl, ICP_QAT_FW_SLICE_DRAM_WR); |
367 | return 0; | 357 | return 0; |
@@ -399,8 +389,7 @@ static int qat_alg_init_dec_session(struct qat_alg_session_ctx *ctx, | |||
399 | hash->sha.inner_setup.auth_counter.counter = | 389 | hash->sha.inner_setup.auth_counter.counter = |
400 | cpu_to_be32(crypto_shash_blocksize(ctx->hash_tfm)); | 390 | cpu_to_be32(crypto_shash_blocksize(ctx->hash_tfm)); |
401 | 391 | ||
402 | if (qat_alg_do_precomputes(hash, ctx, keys->authkey, keys->authkeylen, | 392 | if (qat_alg_do_precomputes(hash, ctx, keys->authkey, keys->authkeylen)) |
403 | (uint8_t *)ctx->auth_hw_state_dec)) | ||
404 | return -EFAULT; | 393 | return -EFAULT; |
405 | 394 | ||
406 | /* Request setup */ | 395 | /* Request setup */ |
@@ -450,9 +439,6 @@ static int qat_alg_init_dec_session(struct qat_alg_session_ctx *ctx, | |||
450 | hash_cd_ctrl->inner_state2_offset = hash_cd_ctrl->hash_cfg_offset + | 439 | hash_cd_ctrl->inner_state2_offset = hash_cd_ctrl->hash_cfg_offset + |
451 | ((sizeof(struct icp_qat_hw_auth_setup) + | 440 | ((sizeof(struct icp_qat_hw_auth_setup) + |
452 | round_up(hash_cd_ctrl->inner_state1_sz, 8)) >> 3); | 441 | round_up(hash_cd_ctrl->inner_state1_sz, 8)) >> 3); |
453 | auth_param->u1.auth_partial_st_prefix = ctx->auth_state_enc_paddr + | ||
454 | sizeof(struct icp_qat_hw_auth_counter) + | ||
455 | round_up(hash_cd_ctrl->inner_state1_sz, 8); | ||
456 | auth_param->auth_res_sz = digestsize; | 442 | auth_param->auth_res_sz = digestsize; |
457 | ICP_QAT_FW_COMN_CURR_ID_SET(hash_cd_ctrl, ICP_QAT_FW_SLICE_AUTH); | 443 | ICP_QAT_FW_COMN_CURR_ID_SET(hash_cd_ctrl, ICP_QAT_FW_SLICE_AUTH); |
458 | ICP_QAT_FW_COMN_NEXT_ID_SET(hash_cd_ctrl, ICP_QAT_FW_SLICE_CIPHER); | 444 | ICP_QAT_FW_COMN_NEXT_ID_SET(hash_cd_ctrl, ICP_QAT_FW_SLICE_CIPHER); |
@@ -512,10 +498,6 @@ static int qat_alg_setkey(struct crypto_aead *tfm, const uint8_t *key, | |||
512 | dev = &GET_DEV(ctx->inst->accel_dev); | 498 | dev = &GET_DEV(ctx->inst->accel_dev); |
513 | memset(ctx->enc_cd, 0, sizeof(struct qat_alg_cd)); | 499 | memset(ctx->enc_cd, 0, sizeof(struct qat_alg_cd)); |
514 | memset(ctx->dec_cd, 0, sizeof(struct qat_alg_cd)); | 500 | memset(ctx->dec_cd, 0, sizeof(struct qat_alg_cd)); |
515 | memset(ctx->auth_hw_state_enc, 0, | ||
516 | sizeof(struct qat_auth_state)); | ||
517 | memset(ctx->auth_hw_state_dec, 0, | ||
518 | sizeof(struct qat_auth_state)); | ||
519 | memset(&ctx->enc_fw_req_tmpl, 0, | 501 | memset(&ctx->enc_fw_req_tmpl, 0, |
520 | sizeof(struct icp_qat_fw_la_bulk_req)); | 502 | sizeof(struct icp_qat_fw_la_bulk_req)); |
521 | memset(&ctx->dec_fw_req_tmpl, 0, | 503 | memset(&ctx->dec_fw_req_tmpl, 0, |
@@ -548,22 +530,6 @@ static int qat_alg_setkey(struct crypto_aead *tfm, const uint8_t *key, | |||
548 | spin_unlock(&ctx->lock); | 530 | spin_unlock(&ctx->lock); |
549 | goto out_free_enc; | 531 | goto out_free_enc; |
550 | } | 532 | } |
551 | ctx->auth_hw_state_enc = | ||
552 | dma_zalloc_coherent(dev, sizeof(struct qat_auth_state), | ||
553 | &ctx->auth_state_enc_paddr, | ||
554 | GFP_ATOMIC); | ||
555 | if (!ctx->auth_hw_state_enc) { | ||
556 | spin_unlock(&ctx->lock); | ||
557 | goto out_free_dec; | ||
558 | } | ||
559 | ctx->auth_hw_state_dec = | ||
560 | dma_zalloc_coherent(dev, sizeof(struct qat_auth_state), | ||
561 | &ctx->auth_state_dec_paddr, | ||
562 | GFP_ATOMIC); | ||
563 | if (!ctx->auth_hw_state_dec) { | ||
564 | spin_unlock(&ctx->lock); | ||
565 | goto out_free_auth_enc; | ||
566 | } | ||
567 | } | 533 | } |
568 | spin_unlock(&ctx->lock); | 534 | spin_unlock(&ctx->lock); |
569 | if (qat_alg_init_sessions(ctx, key, keylen)) | 535 | if (qat_alg_init_sessions(ctx, key, keylen)) |
@@ -572,14 +538,6 @@ static int qat_alg_setkey(struct crypto_aead *tfm, const uint8_t *key, | |||
572 | return 0; | 538 | return 0; |
573 | 539 | ||
574 | out_free_all: | 540 | out_free_all: |
575 | dma_free_coherent(dev, sizeof(struct qat_auth_state), | ||
576 | ctx->auth_hw_state_dec, ctx->auth_state_dec_paddr); | ||
577 | ctx->auth_hw_state_dec = NULL; | ||
578 | out_free_auth_enc: | ||
579 | dma_free_coherent(dev, sizeof(struct qat_auth_state), | ||
580 | ctx->auth_hw_state_enc, ctx->auth_state_enc_paddr); | ||
581 | ctx->auth_hw_state_enc = NULL; | ||
582 | out_free_dec: | ||
583 | dma_free_coherent(dev, sizeof(struct qat_alg_cd), | 541 | dma_free_coherent(dev, sizeof(struct qat_alg_cd), |
584 | ctx->dec_cd, ctx->dec_cd_paddr); | 542 | ctx->dec_cd, ctx->dec_cd_paddr); |
585 | ctx->dec_cd = NULL; | 543 | ctx->dec_cd = NULL; |
@@ -924,16 +882,6 @@ static void qat_alg_exit(struct crypto_tfm *tfm) | |||
924 | if (ctx->dec_cd) | 882 | if (ctx->dec_cd) |
925 | dma_free_coherent(dev, sizeof(struct qat_alg_cd), | 883 | dma_free_coherent(dev, sizeof(struct qat_alg_cd), |
926 | ctx->dec_cd, ctx->dec_cd_paddr); | 884 | ctx->dec_cd, ctx->dec_cd_paddr); |
927 | if (ctx->auth_hw_state_enc) | ||
928 | dma_free_coherent(dev, sizeof(struct qat_auth_state), | ||
929 | ctx->auth_hw_state_enc, | ||
930 | ctx->auth_state_enc_paddr); | ||
931 | |||
932 | if (ctx->auth_hw_state_dec) | ||
933 | dma_free_coherent(dev, sizeof(struct qat_auth_state), | ||
934 | ctx->auth_hw_state_dec, | ||
935 | ctx->auth_state_dec_paddr); | ||
936 | |||
937 | qat_crypto_put_instance(inst); | 885 | qat_crypto_put_instance(inst); |
938 | } | 886 | } |
939 | 887 | ||