Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: hisilicon/sec - modify the SEC request structure

Modify the SEC request structure, combines two common parameters of the
SEC request into one parameter.

Signed-off-by: Kai Ye <yekai13@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Kai Ye and committed by
Herbert Xu
9039878a 668f1ab7

+22 -19
+5 -2
drivers/crypto/hisilicon/sec2/sec.h
··· 21 21 22 22 /* Cipher request of SEC private */ 23 23 struct sec_cipher_req { 24 - struct hisi_acc_hw_sgl *c_in; 25 - dma_addr_t c_in_dma; 26 24 struct hisi_acc_hw_sgl *c_out; 27 25 dma_addr_t c_out_dma; 28 26 u8 *c_ivin; ··· 47 49 struct sec_ctx *ctx; 48 50 struct sec_qp_ctx *qp_ctx; 49 51 52 + /** 53 + * Common parameter of the SEC request. 54 + */ 55 + struct hisi_acc_hw_sgl *in; 56 + dma_addr_t in_dma; 50 57 struct sec_cipher_req c_req; 51 58 struct sec_aead_req aead_req; 52 59 struct list_head backlog_head;
+17 -17
drivers/crypto/hisilicon/sec2/sec_crypto.c
··· 871 871 memcpy(a_req->out_mac, mac_offset, authsize); 872 872 } 873 873 874 - c_req->c_in_dma = qp_ctx->res[req_id].pbuf_dma; 875 - c_req->c_out_dma = c_req->c_in_dma; 874 + req->in_dma = qp_ctx->res[req_id].pbuf_dma; 875 + c_req->c_out_dma = req->in_dma; 876 876 877 877 return 0; 878 878 } ··· 950 950 a_req->out_mac_dma = res->out_mac_dma; 951 951 } 952 952 953 - c_req->c_in = hisi_acc_sg_buf_map_to_hw_sgl(dev, src, 954 - qp_ctx->c_in_pool, 955 - req->req_id, 956 - &c_req->c_in_dma); 957 - 958 - if (IS_ERR(c_req->c_in)) { 953 + req->in = hisi_acc_sg_buf_map_to_hw_sgl(dev, src, 954 + qp_ctx->c_in_pool, 955 + req->req_id, 956 + &req->in_dma); 957 + if (IS_ERR(req->in)) { 959 958 dev_err(dev, "fail to dma map input sgl buffers!\n"); 960 - return PTR_ERR(c_req->c_in); 959 + return PTR_ERR(req->in); 961 960 } 962 961 963 962 if (!c_req->encrypt && ctx->alg_type == SEC_AEAD) { ··· 966 967 return ret; 967 968 } 968 969 } 970 + 969 971 if (dst == src) { 970 - c_req->c_out = c_req->c_in; 971 - c_req->c_out_dma = c_req->c_in_dma; 972 + c_req->c_out = req->in; 973 + c_req->c_out_dma = req->in_dma; 972 974 } else { 973 975 c_req->c_out = hisi_acc_sg_buf_map_to_hw_sgl(dev, dst, 974 976 qp_ctx->c_out_pool, ··· 978 978 979 979 if (IS_ERR(c_req->c_out)) { 980 980 dev_err(dev, "fail to dma map output sgl buffers!\n"); 981 - hisi_acc_sg_buf_unmap(dev, src, c_req->c_in); 981 + hisi_acc_sg_buf_unmap(dev, src, req->in); 982 982 return PTR_ERR(c_req->c_out); 983 983 } 984 984 } ··· 996 996 sec_cipher_pbuf_unmap(ctx, req, dst); 997 997 } else { 998 998 if (dst != src) 999 - hisi_acc_sg_buf_unmap(dev, src, c_req->c_in); 999 + hisi_acc_sg_buf_unmap(dev, src, req->in); 1000 1000 1001 1001 hisi_acc_sg_buf_unmap(dev, dst, c_req->c_out); 1002 1002 } ··· 1236 1236 1237 1237 sec_sqe->type2.c_key_addr = cpu_to_le64(c_ctx->c_key_dma); 1238 1238 sec_sqe->type2.c_ivin_addr = cpu_to_le64(c_req->c_ivin_dma); 1239 - sec_sqe->type2.data_src_addr = cpu_to_le64(c_req->c_in_dma); 1239 + sec_sqe->type2.data_src_addr = cpu_to_le64(req->in_dma); 1240 1240 sec_sqe->type2.data_dst_addr = cpu_to_le64(c_req->c_out_dma); 1241 1241 1242 1242 sec_sqe->type2.icvw_kmode |= cpu_to_le16(((u16)c_ctx->c_mode) << ··· 1263 1263 1264 1264 sec_sqe->sdm_addr_type |= da_type; 1265 1265 scene = SEC_COMM_SCENE << SEC_SCENE_OFFSET; 1266 - if (c_req->c_in_dma != c_req->c_out_dma) 1266 + if (req->in_dma != c_req->c_out_dma) 1267 1267 de = 0x1 << SEC_DE_OFFSET; 1268 1268 1269 1269 sec_sqe->sds_sa_type = (de | scene | sa_type); ··· 1286 1286 1287 1287 sec_sqe3->c_key_addr = cpu_to_le64(c_ctx->c_key_dma); 1288 1288 sec_sqe3->no_scene.c_ivin_addr = cpu_to_le64(c_req->c_ivin_dma); 1289 - sec_sqe3->data_src_addr = cpu_to_le64(c_req->c_in_dma); 1289 + sec_sqe3->data_src_addr = cpu_to_le64(req->in_dma); 1290 1290 sec_sqe3->data_dst_addr = cpu_to_le64(c_req->c_out_dma); 1291 1291 1292 1292 sec_sqe3->c_mode_alg = ((u8)c_ctx->c_alg << SEC_CALG_OFFSET_V3) | ··· 1309 1309 } 1310 1310 1311 1311 bd_param |= SEC_COMM_SCENE << SEC_SCENE_OFFSET_V3; 1312 - if (c_req->c_in_dma != c_req->c_out_dma) 1312 + if (req->in_dma != c_req->c_out_dma) 1313 1313 bd_param |= 0x1 << SEC_DE_OFFSET_V3; 1314 1314 1315 1315 bd_param |= SEC_BD_TYPE3;