Lines Matching refs:sr
55 static void softreq_unmap_sgbufs(struct nitrox_softreq *sr) in softreq_unmap_sgbufs() argument
57 struct nitrox_device *ndev = sr->ndev; in softreq_unmap_sgbufs()
61 dma_unmap_sg(dev, sr->in.sg, sg_nents(sr->in.sg), in softreq_unmap_sgbufs()
63 dma_unmap_single(dev, sr->in.sgcomp_dma, sr->in.sgcomp_len, in softreq_unmap_sgbufs()
65 kfree(sr->in.sgcomp); in softreq_unmap_sgbufs()
66 sr->in.sg = NULL; in softreq_unmap_sgbufs()
67 sr->in.sgmap_cnt = 0; in softreq_unmap_sgbufs()
69 dma_unmap_sg(dev, sr->out.sg, sg_nents(sr->out.sg), in softreq_unmap_sgbufs()
71 dma_unmap_single(dev, sr->out.sgcomp_dma, sr->out.sgcomp_len, in softreq_unmap_sgbufs()
73 kfree(sr->out.sgcomp); in softreq_unmap_sgbufs()
74 sr->out.sg = NULL; in softreq_unmap_sgbufs()
75 sr->out.sgmap_cnt = 0; in softreq_unmap_sgbufs()
78 static void softreq_destroy(struct nitrox_softreq *sr) in softreq_destroy() argument
80 softreq_unmap_sgbufs(sr); in softreq_destroy()
81 kfree(sr); in softreq_destroy()
107 static int create_sg_component(struct nitrox_softreq *sr, in create_sg_component() argument
110 struct nitrox_device *ndev = sr->ndev; in create_sg_component()
121 sgcomp = kzalloc(sz_comp, sr->gfp); in create_sg_component()
158 static int dma_map_inbufs(struct nitrox_softreq *sr, in dma_map_inbufs() argument
161 struct device *dev = DEV(sr->ndev); in dma_map_inbufs()
171 sr->in.total_bytes += sg_dma_len(sg); in dma_map_inbufs()
173 sr->in.sg = req->src; in dma_map_inbufs()
174 sr->in.sgmap_cnt = nents; in dma_map_inbufs()
175 ret = create_sg_component(sr, &sr->in, sr->in.sgmap_cnt); in dma_map_inbufs()
183 sr->in.sgmap_cnt = 0; in dma_map_inbufs()
187 static int dma_map_outbufs(struct nitrox_softreq *sr, in dma_map_outbufs() argument
190 struct device *dev = DEV(sr->ndev); in dma_map_outbufs()
198 sr->out.sg = req->dst; in dma_map_outbufs()
199 sr->out.sgmap_cnt = nents; in dma_map_outbufs()
200 ret = create_sg_component(sr, &sr->out, sr->out.sgmap_cnt); in dma_map_outbufs()
208 sr->out.sgmap_cnt = 0; in dma_map_outbufs()
209 sr->out.sg = NULL; in dma_map_outbufs()
213 static inline int softreq_map_iobuf(struct nitrox_softreq *sr, in softreq_map_iobuf() argument
218 ret = dma_map_inbufs(sr, creq); in softreq_map_iobuf()
222 ret = dma_map_outbufs(sr, creq); in softreq_map_iobuf()
224 softreq_unmap_sgbufs(sr); in softreq_map_iobuf()
229 static inline void backlog_list_add(struct nitrox_softreq *sr, in backlog_list_add() argument
232 INIT_LIST_HEAD(&sr->backlog); in backlog_list_add()
235 list_add_tail(&sr->backlog, &cmdq->backlog_head); in backlog_list_add()
237 atomic_set(&sr->status, REQ_BACKLOG); in backlog_list_add()
241 static inline void response_list_add(struct nitrox_softreq *sr, in response_list_add() argument
244 INIT_LIST_HEAD(&sr->response); in response_list_add()
247 list_add_tail(&sr->response, &cmdq->response_head); in response_list_add()
251 static inline void response_list_del(struct nitrox_softreq *sr, in response_list_del() argument
255 list_del(&sr->response); in response_list_del()
287 static void post_se_instr(struct nitrox_softreq *sr, in post_se_instr() argument
290 struct nitrox_device *ndev = sr->ndev; in post_se_instr()
299 memcpy(ent, &sr->instr, cmdq->instr_size); in post_se_instr()
301 atomic_set(&sr->status, REQ_POSTED); in post_se_instr()
302 response_list_add(sr, cmdq); in post_se_instr()
303 sr->tstamp = jiffies; in post_se_instr()
321 struct nitrox_softreq *sr, *tmp; in post_backlog_cmds() local
329 list_for_each_entry_safe(sr, tmp, &cmdq->backlog_head, backlog) { in post_backlog_cmds()
336 list_del(&sr->backlog); in post_backlog_cmds()
342 post_se_instr(sr, cmdq); in post_backlog_cmds()
349 static int nitrox_enqueue_request(struct nitrox_softreq *sr) in nitrox_enqueue_request() argument
351 struct nitrox_cmdq *cmdq = sr->cmdq; in nitrox_enqueue_request()
352 struct nitrox_device *ndev = sr->ndev; in nitrox_enqueue_request()
358 if (!(sr->flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) { in nitrox_enqueue_request()
364 backlog_list_add(sr, cmdq); in nitrox_enqueue_request()
367 post_se_instr(sr, cmdq); in nitrox_enqueue_request()
386 struct nitrox_softreq *sr; in nitrox_process_se_request() local
393 sr = kzalloc(sizeof(*sr), req->gfp); in nitrox_process_se_request()
394 if (!sr) in nitrox_process_se_request()
397 sr->ndev = ndev; in nitrox_process_se_request()
398 sr->flags = req->flags; in nitrox_process_se_request()
399 sr->gfp = req->gfp; in nitrox_process_se_request()
400 sr->callback = callback; in nitrox_process_se_request()
401 sr->cb_arg = cb_arg; in nitrox_process_se_request()
403 atomic_set(&sr->status, REQ_NOT_POSTED); in nitrox_process_se_request()
405 sr->resp.orh = req->orh; in nitrox_process_se_request()
406 sr->resp.completion = req->comp; in nitrox_process_se_request()
408 ret = softreq_map_iobuf(sr, req); in nitrox_process_se_request()
410 kfree(sr); in nitrox_process_se_request()
427 sr->cmdq = &ndev->pkt_inq[qno]; in nitrox_process_se_request()
447 sr->instr.dptr0 = cpu_to_be64(sr->in.sgcomp_dma); in nitrox_process_se_request()
450 sr->instr.ih.value = 0; in nitrox_process_se_request()
451 sr->instr.ih.s.g = 1; in nitrox_process_se_request()
452 sr->instr.ih.s.gsz = sr->in.sgmap_cnt; in nitrox_process_se_request()
453 sr->instr.ih.s.ssz = sr->out.sgmap_cnt; in nitrox_process_se_request()
454 sr->instr.ih.s.fsz = FDATA_SIZE + sizeof(struct gphdr); in nitrox_process_se_request()
455 sr->instr.ih.s.tlen = sr->instr.ih.s.fsz + sr->in.total_bytes; in nitrox_process_se_request()
456 sr->instr.ih.bev = cpu_to_be64(sr->instr.ih.value); in nitrox_process_se_request()
459 sr->instr.irh.value[0] = 0; in nitrox_process_se_request()
460 sr->instr.irh.s.uddl = MIN_UDD_LEN; in nitrox_process_se_request()
462 sr->instr.irh.s.ctxl = (req->ctrl.s.ctxl / 8); in nitrox_process_se_request()
464 sr->instr.irh.s.destport = SOLICIT_BASE_DPORT + qno; in nitrox_process_se_request()
465 sr->instr.irh.s.ctxc = req->ctrl.s.ctxc; in nitrox_process_se_request()
466 sr->instr.irh.s.arg = req->ctrl.s.arg; in nitrox_process_se_request()
467 sr->instr.irh.s.opcode = req->opcode; in nitrox_process_se_request()
468 sr->instr.irh.bev[0] = cpu_to_be64(sr->instr.irh.value[0]); in nitrox_process_se_request()
471 sr->instr.irh.s.ctxp = cpu_to_be64(ctx_handle); in nitrox_process_se_request()
474 sr->instr.slc.value[0] = 0; in nitrox_process_se_request()
475 sr->instr.slc.s.ssz = sr->out.sgmap_cnt; in nitrox_process_se_request()
476 sr->instr.slc.bev[0] = cpu_to_be64(sr->instr.slc.value[0]); in nitrox_process_se_request()
479 sr->instr.slc.s.rptr = cpu_to_be64(sr->out.sgcomp_dma); in nitrox_process_se_request()
486 sr->instr.fdata[0] = *((u64 *)&req->gph); in nitrox_process_se_request()
487 sr->instr.fdata[1] = 0; in nitrox_process_se_request()
489 ret = nitrox_enqueue_request(sr); in nitrox_process_se_request()
496 softreq_destroy(sr); in nitrox_process_se_request()
513 static bool sr_completed(struct nitrox_softreq *sr) in sr_completed() argument
515 u64 orh = READ_ONCE(*sr->resp.orh); in sr_completed()
521 while (READ_ONCE(*sr->resp.completion) == PENDING_SIG) { in sr_completed()
540 struct nitrox_softreq *sr; in process_response_list() local
549 sr = get_first_response_entry(cmdq); in process_response_list()
550 if (!sr) in process_response_list()
553 if (atomic_read(&sr->status) != REQ_POSTED) in process_response_list()
557 if (!sr_completed(sr)) { in process_response_list()
559 if (!cmd_timeout(sr->tstamp, ndev->timeout)) in process_response_list()
563 READ_ONCE(*sr->resp.orh)); in process_response_list()
570 response_list_del(sr, cmdq); in process_response_list()
572 err = READ_ONCE(*sr->resp.orh) & 0xff; in process_response_list()
573 callback = sr->callback; in process_response_list()
574 cb_arg = sr->cb_arg; in process_response_list()
575 softreq_destroy(sr); in process_response_list()