Lines Matching refs:req
69 static inline int sec_alloc_queue_id(struct sec_ctx *ctx, struct sec_req *req)
71 if (req->c_req.encrypt)
79 static inline void sec_free_queue_id(struct sec_ctx *ctx, struct sec_req *req)
81 if (req->c_req.encrypt)
87 static int sec_alloc_req_id(struct sec_req *req, struct sec_qp_ctx *qp_ctx)
97 dev_err(req->ctx->dev, "alloc req id fail!\n");
101 req->qp_ctx = qp_ctx;
102 qp_ctx->req_list[req_id] = req;
106 static void sec_free_req_id(struct sec_req *req)
108 struct sec_qp_ctx *qp_ctx = req->qp_ctx;
109 int req_id = req->req_id;
112 dev_err(req->ctx->dev, "free request id invalid!\n");
117 req->qp_ctx = NULL;
124 static int sec_aead_verify(struct sec_req *req)
126 struct aead_request *aead_req = req->aead_req.aead_req;
129 u8 *mac_out = req->aead_req.out_mac;
138 dev_err(req->ctx->dev, "aead verify failure!\n");
151 struct sec_req *req;
163 req = qp_ctx->req_list[le16_to_cpu(bd->type2.tag)];
164 if (unlikely(!req)) {
169 req->err_type = bd->type2.error_type;
170 ctx = req->ctx;
174 if (unlikely(req->err_type || done != SEC_SQE_DONE ||
179 req->err_type, done, flag);
184 if (ctx->alg_type == SEC_AEAD && !req->c_req.encrypt)
185 err = sec_aead_verify(req);
189 ctx->req_op->buf_unmap(ctx, req);
191 ctx->req_op->callback(ctx, req, err);
194 static int sec_bd_send(struct sec_ctx *ctx, struct sec_req *req)
196 struct sec_qp_ctx *qp_ctx = req->qp_ctx;
201 !(req->flag & CRYPTO_TFM_REQ_MAY_BACKLOG))
205 ret = hisi_qp_send(qp_ctx->qp, &req->sec_sqe);
209 list_add_tail(&req->backlog_head, &qp_ctx->backlog);
685 static int sec_cipher_pbuf_map(struct sec_ctx *ctx, struct sec_req *req,
688 struct aead_request *aead_req = req->aead_req.aead_req;
689 struct sec_cipher_req *c_req = &req->c_req;
690 struct sec_qp_ctx *qp_ctx = req->qp_ctx;
693 int req_id = req->req_id;
720 static void sec_cipher_pbuf_unmap(struct sec_ctx *ctx, struct sec_req *req,
723 struct aead_request *aead_req = req->aead_req.aead_req;
724 struct sec_cipher_req *c_req = &req->c_req;
725 struct sec_qp_ctx *qp_ctx = req->qp_ctx;
728 int req_id = req->req_id;
743 static int sec_cipher_map(struct sec_ctx *ctx, struct sec_req *req,
746 struct sec_cipher_req *c_req = &req->c_req;
747 struct sec_aead_req *a_req = &req->aead_req;
748 struct sec_qp_ctx *qp_ctx = req->qp_ctx;
749 struct sec_alg_res *res = &qp_ctx->res[req->req_id];
753 if (req->use_pbuf) {
754 ret = sec_cipher_pbuf_map(ctx, req, src);
774 req->req_id,
788 req->req_id,
801 static void sec_cipher_unmap(struct sec_ctx *ctx, struct sec_req *req,
804 struct sec_cipher_req *c_req = &req->c_req;
807 if (req->use_pbuf) {
808 sec_cipher_pbuf_unmap(ctx, req, dst);
817 static int sec_skcipher_sgl_map(struct sec_ctx *ctx, struct sec_req *req)
819 struct skcipher_request *sq = req->c_req.sk_req;
821 return sec_cipher_map(ctx, req, sq->src, sq->dst);
824 static void sec_skcipher_sgl_unmap(struct sec_ctx *ctx, struct sec_req *req)
826 struct skcipher_request *sq = req->c_req.sk_req;
828 sec_cipher_unmap(ctx, req, sq->src, sq->dst);
935 static int sec_aead_sgl_map(struct sec_ctx *ctx, struct sec_req *req)
937 struct aead_request *aq = req->aead_req.aead_req;
939 return sec_cipher_map(ctx, req, aq->src, aq->dst);
942 static void sec_aead_sgl_unmap(struct sec_ctx *ctx, struct sec_req *req)
944 struct aead_request *aq = req->aead_req.aead_req;
946 sec_cipher_unmap(ctx, req, aq->src, aq->dst);
949 static int sec_request_transfer(struct sec_ctx *ctx, struct sec_req *req)
953 ret = ctx->req_op->buf_map(ctx, req);
957 ctx->req_op->do_transfer(ctx, req);
959 ret = ctx->req_op->bd_fill(ctx, req);
966 ctx->req_op->buf_unmap(ctx, req);
971 static void sec_request_untransfer(struct sec_ctx *ctx, struct sec_req *req)
973 ctx->req_op->buf_unmap(ctx, req);
976 static void sec_skcipher_copy_iv(struct sec_ctx *ctx, struct sec_req *req)
978 struct skcipher_request *sk_req = req->c_req.sk_req;
979 struct sec_cipher_req *c_req = &req->c_req;
984 static int sec_skcipher_bd_fill(struct sec_ctx *ctx, struct sec_req *req)
987 struct sec_cipher_req *c_req = &req->c_req;
988 struct sec_sqe *sec_sqe = &req->sec_sqe;
1013 if (req->use_pbuf)
1024 if (req->use_pbuf)
1031 sec_sqe->type2.tag = cpu_to_le16((u16)req->req_id);
1036 static void sec_update_iv(struct sec_req *req, enum sec_alg_type alg_type)
1038 struct aead_request *aead_req = req->aead_req.aead_req;
1039 struct skcipher_request *sk_req = req->c_req.sk_req;
1040 u32 iv_size = req->ctx->c_ctx.ivsize;
1046 if (req->c_req.encrypt)
1062 dev_err(req->ctx->dev, "copy output iv error!\n");
1083 static void sec_skcipher_callback(struct sec_ctx *ctx, struct sec_req *req,
1086 struct skcipher_request *sk_req = req->c_req.sk_req;
1087 struct sec_qp_ctx *qp_ctx = req->qp_ctx;
1091 sec_free_req_id(req);
1094 if (!err && ctx->c_ctx.c_mode == SEC_CMODE_CBC && req->c_req.encrypt)
1095 sec_update_iv(req, SEC_SKCIPHER);
1112 static void sec_aead_copy_iv(struct sec_ctx *ctx, struct sec_req *req)
1114 struct aead_request *aead_req = req->aead_req.aead_req;
1115 struct sec_cipher_req *c_req = &req->c_req;
1121 struct sec_req *req, struct sec_sqe *sec_sqe)
1123 struct sec_aead_req *a_req = &req->aead_req;
1124 struct sec_cipher_req *c_req = &req->c_req;
1153 static int sec_aead_bd_fill(struct sec_ctx *ctx, struct sec_req *req)
1156 struct sec_sqe *sec_sqe = &req->sec_sqe;
1159 ret = sec_skcipher_bd_fill(ctx, req);
1165 sec_auth_bd_fill_ex(auth_ctx, req->c_req.encrypt, req, sec_sqe);
1170 static void sec_aead_callback(struct sec_ctx *c, struct sec_req *req, int err)
1172 struct aead_request *a_req = req->aead_req.aead_req;
1174 struct sec_aead_req *aead_req = &req->aead_req;
1175 struct sec_cipher_req *c_req = &req->c_req;
1177 struct sec_qp_ctx *qp_ctx = req->qp_ctx;
1183 sec_update_iv(req, SEC_AEAD);
1200 sec_free_req_id(req);
1216 static void sec_request_uninit(struct sec_ctx *ctx, struct sec_req *req)
1218 sec_free_req_id(req);
1219 sec_free_queue_id(ctx, req);
1222 static int sec_request_init(struct sec_ctx *ctx, struct sec_req *req)
1228 queue_id = sec_alloc_queue_id(ctx, req);
1231 req->req_id = sec_alloc_req_id(req, qp_ctx);
1232 if (unlikely(req->req_id < 0)) {
1233 sec_free_queue_id(ctx, req);
1234 return req->req_id;
1240 static int sec_process(struct sec_ctx *ctx, struct sec_req *req)
1242 struct sec_cipher_req *c_req = &req->c_req;
1245 ret = sec_request_init(ctx, req);
1249 ret = sec_request_transfer(ctx, req);
1254 if (ctx->c_ctx.c_mode == SEC_CMODE_CBC && !req->c_req.encrypt)
1255 sec_update_iv(req, ctx->alg_type);
1257 ret = ctx->req_op->bd_send(ctx, req);
1259 (ret == -EBUSY && !(req->flag & CRYPTO_TFM_REQ_MAY_BACKLOG)))) {
1268 if (ctx->c_ctx.c_mode == SEC_CMODE_CBC && !req->c_req.encrypt) {
1270 memcpy(req->c_req.sk_req->iv, c_req->c_ivin,
1273 memcpy(req->aead_req.aead_req->iv, c_req->c_ivin,
1277 sec_request_untransfer(ctx, req);
1279 sec_request_uninit(ctx, req);
1446 struct sec_req *req = skcipher_request_ctx(sk_req);
1453 req->flag = sk_req->base.flags;
1454 req->c_req.sk_req = sk_req;
1455 req->c_req.encrypt = encrypt;
1456 req->ctx = ctx;
1458 ret = sec_skcipher_param_check(ctx, req);
1462 return ctx->req_op->process(ctx, req);
1534 struct aead_request *req = sreq->aead_req.aead_req;
1535 struct crypto_aead *tfm = crypto_aead_reqtfm(req);
1540 if (unlikely(!req->src || !req->dst || !req->cryptlen ||
1541 req->assoclen > SEC_MAX_AAD_LEN)) {
1546 if (ctx->pbuf_supported && (req->cryptlen + req->assoclen) <=
1559 sreq->c_req.c_len = req->cryptlen;
1561 sreq->c_req.c_len = req->cryptlen - authsize;
1574 struct sec_req *req = aead_request_ctx(a_req);
1578 req->flag = a_req->base.flags;
1579 req->aead_req.aead_req = a_req;
1580 req->c_req.encrypt = encrypt;
1581 req->ctx = ctx;
1583 ret = sec_aead_param_check(ctx, req);
1587 return ctx->req_op->process(ctx, req);