diff options
author | Harsh Jain <harsh@chelsio.com> | 2016-11-29 08:30:42 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-11-30 07:01:50 -0500 |
commit | 5c86a8ff2e0deba95324cc59e6b90c28da8af535 (patch) | |
tree | 2c4193a6a6781948d929aa01cc22e3f4d90605e0 | |
parent | e7922729bef4474c5817fa2184154a1698757d48 (diff) |
crypto: chcr - Move tfm ctx variable to request context
Move request specific data in request context.
Signed-off-by: Harsh Jain <harsh@chelsio.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/chelsio/chcr_algo.c | 26 | ||||
-rw-r--r-- | drivers/crypto/chelsio/chcr_crypto.h | 9 |
2 files changed, 17 insertions, 18 deletions
diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c index e19f7f40bd75..8d677c7e3d61 100644 --- a/drivers/crypto/chelsio/chcr_algo.c +++ b/drivers/crypto/chelsio/chcr_algo.c | |||
@@ -119,7 +119,7 @@ int chcr_handle_resp(struct crypto_async_request *req, unsigned char *input, | |||
119 | AES_BLOCK_SIZE); | 119 | AES_BLOCK_SIZE); |
120 | } | 120 | } |
121 | dma_unmap_sg(&u_ctx->lldi.pdev->dev, ctx_req.req.ablk_req->dst, | 121 | dma_unmap_sg(&u_ctx->lldi.pdev->dev, ctx_req.req.ablk_req->dst, |
122 | ABLK_CTX(ctx)->dst_nents, DMA_FROM_DEVICE); | 122 | ctx_req.ctx.ablk_ctx->dst_nents, DMA_FROM_DEVICE); |
123 | if (ctx_req.ctx.ablk_ctx->skb) { | 123 | if (ctx_req.ctx.ablk_ctx->skb) { |
124 | kfree_skb(ctx_req.ctx.ablk_ctx->skb); | 124 | kfree_skb(ctx_req.ctx.ablk_ctx->skb); |
125 | ctx_req.ctx.ablk_ctx->skb = NULL; | 125 | ctx_req.ctx.ablk_ctx->skb = NULL; |
@@ -138,8 +138,10 @@ int chcr_handle_resp(struct crypto_async_request *req, unsigned char *input, | |||
138 | updated_digestsize = SHA256_DIGEST_SIZE; | 138 | updated_digestsize = SHA256_DIGEST_SIZE; |
139 | else if (digestsize == SHA384_DIGEST_SIZE) | 139 | else if (digestsize == SHA384_DIGEST_SIZE) |
140 | updated_digestsize = SHA512_DIGEST_SIZE; | 140 | updated_digestsize = SHA512_DIGEST_SIZE; |
141 | if (ctx_req.ctx.ahash_ctx->skb) | 141 | if (ctx_req.ctx.ahash_ctx->skb) { |
142 | kfree_skb(ctx_req.ctx.ahash_ctx->skb); | ||
142 | ctx_req.ctx.ahash_ctx->skb = NULL; | 143 | ctx_req.ctx.ahash_ctx->skb = NULL; |
144 | } | ||
143 | if (ctx_req.ctx.ahash_ctx->result == 1) { | 145 | if (ctx_req.ctx.ahash_ctx->result == 1) { |
144 | ctx_req.ctx.ahash_ctx->result = 0; | 146 | ctx_req.ctx.ahash_ctx->result = 0; |
145 | memcpy(ctx_req.req.ahash_req->result, input + | 147 | memcpy(ctx_req.req.ahash_req->result, input + |
@@ -318,8 +320,7 @@ static inline int is_hmac(struct crypto_tfm *tfm) | |||
318 | struct chcr_alg_template *chcr_crypto_alg = | 320 | struct chcr_alg_template *chcr_crypto_alg = |
319 | container_of(__crypto_ahash_alg(alg), struct chcr_alg_template, | 321 | container_of(__crypto_ahash_alg(alg), struct chcr_alg_template, |
320 | alg.hash); | 322 | alg.hash); |
321 | if ((chcr_crypto_alg->type & CRYPTO_ALG_SUB_TYPE_MASK) == | 323 | if (chcr_crypto_alg->type == CRYPTO_ALG_TYPE_HMAC) |
322 | CRYPTO_ALG_SUB_TYPE_HASH_HMAC) | ||
323 | return 1; | 324 | return 1; |
324 | return 0; | 325 | return 0; |
325 | } | 326 | } |
@@ -505,7 +506,7 @@ static struct sk_buff | |||
505 | struct sk_buff *skb = NULL; | 506 | struct sk_buff *skb = NULL; |
506 | struct chcr_wr *chcr_req; | 507 | struct chcr_wr *chcr_req; |
507 | struct cpl_rx_phys_dsgl *phys_cpl; | 508 | struct cpl_rx_phys_dsgl *phys_cpl; |
508 | struct chcr_blkcipher_req_ctx *req_ctx = ablkcipher_request_ctx(req); | 509 | struct chcr_blkcipher_req_ctx *reqctx = ablkcipher_request_ctx(req); |
509 | struct phys_sge_parm sg_param; | 510 | struct phys_sge_parm sg_param; |
510 | unsigned int frags = 0, transhdr_len, phys_dsgl; | 511 | unsigned int frags = 0, transhdr_len, phys_dsgl; |
511 | unsigned int ivsize = crypto_ablkcipher_ivsize(tfm), kctx_len; | 512 | unsigned int ivsize = crypto_ablkcipher_ivsize(tfm), kctx_len; |
@@ -514,12 +515,11 @@ static struct sk_buff | |||
514 | 515 | ||
515 | if (!req->info) | 516 | if (!req->info) |
516 | return ERR_PTR(-EINVAL); | 517 | return ERR_PTR(-EINVAL); |
517 | ablkctx->dst_nents = sg_nents_for_len(req->dst, req->nbytes); | 518 | reqctx->dst_nents = sg_nents_for_len(req->dst, req->nbytes); |
518 | if (ablkctx->dst_nents <= 0) { | 519 | if (reqctx->dst_nents <= 0) { |
519 | pr_err("AES:Invalid Destination sg lists\n"); | 520 | pr_err("AES:Invalid Destination sg lists\n"); |
520 | return ERR_PTR(-EINVAL); | 521 | return ERR_PTR(-EINVAL); |
521 | } | 522 | } |
522 | ablkctx->enc = op_type; | ||
523 | if ((ablkctx->enckey_len == 0) || (ivsize > AES_BLOCK_SIZE) || | 523 | if ((ablkctx->enckey_len == 0) || (ivsize > AES_BLOCK_SIZE) || |
524 | (req->nbytes <= 0) || (req->nbytes % AES_BLOCK_SIZE)) { | 524 | (req->nbytes <= 0) || (req->nbytes % AES_BLOCK_SIZE)) { |
525 | pr_err("AES: Invalid value of Key Len %d nbytes %d IV Len %d\n", | 525 | pr_err("AES: Invalid value of Key Len %d nbytes %d IV Len %d\n", |
@@ -527,7 +527,7 @@ static struct sk_buff | |||
527 | return ERR_PTR(-EINVAL); | 527 | return ERR_PTR(-EINVAL); |
528 | } | 528 | } |
529 | 529 | ||
530 | phys_dsgl = get_space_for_phys_dsgl(ablkctx->dst_nents); | 530 | phys_dsgl = get_space_for_phys_dsgl(reqctx->dst_nents); |
531 | 531 | ||
532 | kctx_len = (DIV_ROUND_UP(ablkctx->enckey_len, 16) * 16); | 532 | kctx_len = (DIV_ROUND_UP(ablkctx->enckey_len, 16) * 16); |
533 | transhdr_len = CIPHER_TRANSHDR_SIZE(kctx_len, phys_dsgl); | 533 | transhdr_len = CIPHER_TRANSHDR_SIZE(kctx_len, phys_dsgl); |
@@ -570,7 +570,7 @@ static struct sk_buff | |||
570 | } | 570 | } |
571 | } | 571 | } |
572 | phys_cpl = (struct cpl_rx_phys_dsgl *)((u8 *)(chcr_req + 1) + kctx_len); | 572 | phys_cpl = (struct cpl_rx_phys_dsgl *)((u8 *)(chcr_req + 1) + kctx_len); |
573 | sg_param.nents = ablkctx->dst_nents; | 573 | sg_param.nents = reqctx->dst_nents; |
574 | sg_param.obsize = req->nbytes; | 574 | sg_param.obsize = req->nbytes; |
575 | sg_param.qid = qid; | 575 | sg_param.qid = qid; |
576 | sg_param.align = 1; | 576 | sg_param.align = 1; |
@@ -579,11 +579,11 @@ static struct sk_buff | |||
579 | goto map_fail1; | 579 | goto map_fail1; |
580 | 580 | ||
581 | skb_set_transport_header(skb, transhdr_len); | 581 | skb_set_transport_header(skb, transhdr_len); |
582 | memcpy(ablkctx->iv, req->info, ivsize); | 582 | memcpy(reqctx->iv, req->info, ivsize); |
583 | write_buffer_to_skb(skb, &frags, ablkctx->iv, ivsize); | 583 | write_buffer_to_skb(skb, &frags, reqctx->iv, ivsize); |
584 | write_sg_to_skb(skb, &frags, req->src, req->nbytes); | 584 | write_sg_to_skb(skb, &frags, req->src, req->nbytes); |
585 | create_wreq(ctx, chcr_req, req, skb, kctx_len, 0, phys_dsgl); | 585 | create_wreq(ctx, chcr_req, req, skb, kctx_len, 0, phys_dsgl); |
586 | req_ctx->skb = skb; | 586 | reqctx->skb = skb; |
587 | skb_get(skb); | 587 | skb_get(skb); |
588 | return skb; | 588 | return skb; |
589 | map_fail1: | 589 | map_fail1: |
diff --git a/drivers/crypto/chelsio/chcr_crypto.h b/drivers/crypto/chelsio/chcr_crypto.h index 977d20520f53..40a5182fac90 100644 --- a/drivers/crypto/chelsio/chcr_crypto.h +++ b/drivers/crypto/chelsio/chcr_crypto.h | |||
@@ -120,17 +120,14 @@ | |||
120 | /* Aligned to 128 bit boundary */ | 120 | /* Aligned to 128 bit boundary */ |
121 | 121 | ||
122 | struct ablk_ctx { | 122 | struct ablk_ctx { |
123 | u8 enc; | ||
124 | unsigned int processed_len; | ||
125 | __be32 key_ctx_hdr; | 123 | __be32 key_ctx_hdr; |
126 | unsigned int enckey_len; | 124 | unsigned int enckey_len; |
127 | unsigned int dst_nents; | ||
128 | u8 key[CHCR_AES_MAX_KEY_LEN]; | 125 | u8 key[CHCR_AES_MAX_KEY_LEN]; |
129 | u8 rrkey[AES_MAX_KEY_SIZE]; | ||
130 | u8 iv[CHCR_MAX_CRYPTO_IV_LEN]; | ||
131 | unsigned char ciph_mode; | 126 | unsigned char ciph_mode; |
127 | u8 rrkey[AES_MAX_KEY_SIZE]; | ||
132 | }; | 128 | }; |
133 | 129 | ||
130 | |||
134 | struct hmac_ctx { | 131 | struct hmac_ctx { |
135 | struct crypto_shash *base_hash; | 132 | struct crypto_shash *base_hash; |
136 | u8 ipad[CHCR_HASH_MAX_BLOCK_SIZE_128]; | 133 | u8 ipad[CHCR_HASH_MAX_BLOCK_SIZE_128]; |
@@ -164,6 +161,8 @@ struct chcr_ahash_req_ctx { | |||
164 | 161 | ||
165 | struct chcr_blkcipher_req_ctx { | 162 | struct chcr_blkcipher_req_ctx { |
166 | struct sk_buff *skb; | 163 | struct sk_buff *skb; |
164 | unsigned int dst_nents; | ||
165 | u8 iv[CHCR_MAX_CRYPTO_IV_LEN]; | ||
167 | }; | 166 | }; |
168 | 167 | ||
169 | struct chcr_alg_template { | 168 | struct chcr_alg_template { |