Skip to content

Commit 9039878

Browse files
yekai123123herbertx
authored andcommitted
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>
1 parent 668f1ab commit 9039878

2 files changed

Lines changed: 22 additions & 19 deletions

File tree

‎drivers/crypto/hisilicon/sec2/sec.h‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ struct sec_alg_res {
2121

2222
/* Cipher request of SEC private */
2323
struct sec_cipher_req {
24-
struct hisi_acc_hw_sgl *c_in;
25-
dma_addr_t c_in_dma;
2624
struct hisi_acc_hw_sgl *c_out;
2725
dma_addr_t c_out_dma;
2826
u8 *c_ivin;
@@ -49,6 +47,11 @@ struct sec_req {
4947
struct sec_ctx *ctx;
5048
struct sec_qp_ctx *qp_ctx;
5149

50+
/**
51+
* Common parameter of the SEC request.
52+
*/
53+
struct hisi_acc_hw_sgl *in;
54+
dma_addr_t in_dma;
5255
struct sec_cipher_req c_req;
5356
struct sec_aead_req aead_req;
5457
struct list_head backlog_head;

‎drivers/crypto/hisilicon/sec2/sec_crypto.c‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -871,8 +871,8 @@ static int sec_cipher_pbuf_map(struct sec_ctx *ctx, struct sec_req *req,
871871
memcpy(a_req->out_mac, mac_offset, authsize);
872872
}
873873

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;
876876

877877
return 0;
878878
}
@@ -950,14 +950,13 @@ static int sec_cipher_map(struct sec_ctx *ctx, struct sec_req *req,
950950
a_req->out_mac_dma = res->out_mac_dma;
951951
}
952952

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)) {
959958
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);
961960
}
962961

963962
if (!c_req->encrypt && ctx->alg_type == SEC_AEAD) {
@@ -967,9 +966,10 @@ static int sec_cipher_map(struct sec_ctx *ctx, struct sec_req *req,
967966
return ret;
968967
}
969968
}
969+
970970
if (dst == src) {
971-
c_req->c_out = c_req->c_in;
972-
c_req->c_out_dma = c_req->c_in_dma;
971+
c_req->c_out = req->in;
972+
c_req->c_out_dma = req->in_dma;
973973
} else {
974974
c_req->c_out = hisi_acc_sg_buf_map_to_hw_sgl(dev, dst,
975975
qp_ctx->c_out_pool,
@@ -978,7 +978,7 @@ static int sec_cipher_map(struct sec_ctx *ctx, struct sec_req *req,
978978

979979
if (IS_ERR(c_req->c_out)) {
980980
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);
982982
return PTR_ERR(c_req->c_out);
983983
}
984984
}
@@ -996,7 +996,7 @@ static void sec_cipher_unmap(struct sec_ctx *ctx, struct sec_req *req,
996996
sec_cipher_pbuf_unmap(ctx, req, dst);
997997
} else {
998998
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);
10001000

10011001
hisi_acc_sg_buf_unmap(dev, dst, c_req->c_out);
10021002
}
@@ -1236,7 +1236,7 @@ static int sec_skcipher_bd_fill(struct sec_ctx *ctx, struct sec_req *req)
12361236

12371237
sec_sqe->type2.c_key_addr = cpu_to_le64(c_ctx->c_key_dma);
12381238
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);
12401240
sec_sqe->type2.data_dst_addr = cpu_to_le64(c_req->c_out_dma);
12411241

12421242
sec_sqe->type2.icvw_kmode |= cpu_to_le16(((u16)c_ctx->c_mode) <<
@@ -1263,7 +1263,7 @@ static int sec_skcipher_bd_fill(struct sec_ctx *ctx, struct sec_req *req)
12631263

12641264
sec_sqe->sdm_addr_type |= da_type;
12651265
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)
12671267
de = 0x1 << SEC_DE_OFFSET;
12681268

12691269
sec_sqe->sds_sa_type = (de | scene | sa_type);
@@ -1286,7 +1286,7 @@ static int sec_skcipher_bd_fill_v3(struct sec_ctx *ctx, struct sec_req *req)
12861286

12871287
sec_sqe3->c_key_addr = cpu_to_le64(c_ctx->c_key_dma);
12881288
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);
12901290
sec_sqe3->data_dst_addr = cpu_to_le64(c_req->c_out_dma);
12911291

12921292
sec_sqe3->c_mode_alg = ((u8)c_ctx->c_alg << SEC_CALG_OFFSET_V3) |
@@ -1309,7 +1309,7 @@ static int sec_skcipher_bd_fill_v3(struct sec_ctx *ctx, struct sec_req *req)
13091309
}
13101310

13111311
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)
13131313
bd_param |= 0x1 << SEC_DE_OFFSET_V3;
13141314

13151315
bd_param |= SEC_BD_TYPE3;

0 commit comments

Comments
 (0)