| 662 | * The pointer to the start of the write back data linked list. |
| 663 | */ |
| 664 | static __rte_always_inline struct vhost_crypto_writeback_data * |
| 665 | prepare_write_back_data(struct vhost_crypto_data_req *vc_req, |
| 666 | struct vhost_crypto_desc *head_desc, |
| 667 | struct vhost_crypto_desc **cur_desc, |
| 668 | struct vhost_crypto_writeback_data **end_wb_data, |
| 669 | uint8_t *src, |
| 670 | uint32_t offset, |
| 671 | uint64_t write_back_len, |
| 672 | uint32_t max_n_descs) |
| 673 | __rte_shared_locks_required(&vc_req->vq->iotlb_lock) |
| 674 | { |
| 675 | struct vhost_crypto_writeback_data *wb_data, *head; |
| 676 | struct vhost_crypto_desc *desc = *cur_desc; |
| 677 | uint64_t dlen; |
| 678 | uint8_t *dst; |
| 679 | int ret; |
| 680 | |
| 681 | ret = rte_mempool_get(vc_req->wb_pool, (void **)&head); |
| 682 | if (unlikely(ret < 0)) { |
| 683 | VC_LOG_ERR("no memory"); |
| 684 | goto error_exit; |
| 685 | } |
| 686 | |
| 687 | wb_data = head; |
| 688 | |
| 689 | if (likely(desc->len > offset)) { |
| 690 | wb_data->src = src + offset; |
| 691 | dlen = desc->len; |
| 692 | dst = IOVA_TO_VVA(uint8_t *, vc_req, desc->addr, |
| 693 | &dlen, VHOST_ACCESS_RW); |
| 694 | if (unlikely(!dst || dlen != desc->len)) { |
| 695 | VC_LOG_ERR("Failed to map descriptor"); |
| 696 | goto error_exit; |
| 697 | } |
| 698 | |
| 699 | wb_data->dst = dst + offset; |
| 700 | wb_data->len = RTE_MIN(dlen - offset, write_back_len); |
| 701 | write_back_len -= wb_data->len; |
| 702 | src += offset + wb_data->len; |
| 703 | offset = 0; |
| 704 | |
| 705 | if (unlikely(write_back_len)) { |
| 706 | ret = rte_mempool_get(vc_req->wb_pool, |
| 707 | (void **)&(wb_data->next)); |
| 708 | if (unlikely(ret < 0)) { |
| 709 | VC_LOG_ERR("no memory"); |
| 710 | goto error_exit; |
| 711 | } |
| 712 | |
| 713 | wb_data = wb_data->next; |
| 714 | } else |
| 715 | wb_data->next = NULL; |
| 716 | } else |
| 717 | offset -= desc->len; |
| 718 | |
| 719 | while (write_back_len && |
| 720 | desc >= head_desc && |
| 721 | desc - head_desc < (int)max_n_descs) { |
no test coverage detected