MCPcopy Create free account
hub / github.com/F-Stack/f-stack / prepare_sym_cipher_op

Function prepare_sym_cipher_op

dpdk/lib/vhost/vhost_crypto.c:788–917  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

786}
787
788static __rte_always_inline uint8_t
789prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op,
790 struct vhost_crypto_data_req *vc_req,
791 struct virtio_crypto_cipher_data_req *cipher,
792 struct vhost_crypto_desc *head,
793 uint32_t max_n_descs)
794 __rte_shared_locks_required(&vc_req->vq->iotlb_lock)
795{
796 struct vhost_crypto_desc *desc = head;
797 struct vhost_crypto_writeback_data *ewb = NULL;
798 struct rte_mbuf *m_src = op->sym->m_src, *m_dst = op->sym->m_dst;
799 uint8_t *iv_data = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET);
800 uint8_t ret = vhost_crypto_check_cipher_request(cipher);
801
802 if (unlikely(ret != VIRTIO_CRYPTO_OK))
803 goto error_exit;
804
805 /* prepare */
806 /* iv */
807 if (unlikely(copy_data(iv_data, vc_req, head, &desc,
808 cipher->para.iv_len, max_n_descs))) {
809 VC_LOG_ERR("Incorrect virtio descriptor");
810 ret = VIRTIO_CRYPTO_BADMSG;
811 goto error_exit;
812 }
813
814 switch (vcrypto->option) {
815 case RTE_VHOST_CRYPTO_ZERO_COPY_ENABLE:
816 m_src->data_len = cipher->para.src_data_len;
817 rte_mbuf_iova_set(m_src,
818 gpa_to_hpa(vcrypto->dev, desc->addr, cipher->para.src_data_len));
819 m_src->buf_addr = get_data_ptr(vc_req, desc, VHOST_ACCESS_RO);
820 if (unlikely(rte_mbuf_iova_get(m_src) == 0 || m_src->buf_addr == NULL)) {
821 VC_LOG_ERR("zero_copy may fail due to cross page data");
822 ret = VIRTIO_CRYPTO_ERR;
823 goto error_exit;
824 }
825
826 if (unlikely(move_desc(head, &desc, cipher->para.src_data_len,
827 max_n_descs) < 0)) {
828 VC_LOG_ERR("Incorrect descriptor");
829 ret = VIRTIO_CRYPTO_ERR;
830 goto error_exit;
831 }
832
833 break;
834 case RTE_VHOST_CRYPTO_ZERO_COPY_DISABLE:
835 vc_req->wb_pool = vcrypto->wb_pool;
836 m_src->data_len = cipher->para.src_data_len;
837 if (unlikely(copy_data(rte_pktmbuf_mtod(m_src, uint8_t *),
838 vc_req, head, &desc, cipher->para.src_data_len,
839 max_n_descs) < 0)) {
840 VC_LOG_ERR("Incorrect virtio descriptor");
841 ret = VIRTIO_CRYPTO_BADMSG;
842 goto error_exit;
843 }
844 break;
845 default:

Callers 1

Calls 9

copy_dataFunction · 0.85
rte_mbuf_iova_setFunction · 0.85
get_data_ptrFunction · 0.85
rte_mbuf_iova_getFunction · 0.85
move_descFunction · 0.85
find_write_descFunction · 0.85
prepare_write_back_dataFunction · 0.85
free_wb_dataFunction · 0.85

Tested by

no test coverage detected