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

Function prepare_sym_chain_op

dpdk/lib/vhost/vhost_crypto.c:942–1123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

940}
941
942static __rte_always_inline uint8_t
943prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op,
944 struct vhost_crypto_data_req *vc_req,
945 struct virtio_crypto_alg_chain_data_req *chain,
946 struct vhost_crypto_desc *head,
947 uint32_t max_n_descs)
948 __rte_shared_locks_required(&vc_req->vq->iotlb_lock)
949{
950 struct vhost_crypto_desc *desc = head, *digest_desc;
951 struct vhost_crypto_writeback_data *ewb = NULL, *ewb2 = NULL;
952 struct rte_mbuf *m_src = op->sym->m_src, *m_dst = op->sym->m_dst;
953 uint8_t *iv_data = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET);
954 uint32_t digest_offset;
955 void *digest_addr;
956 uint8_t ret = vhost_crypto_check_chain_request(chain);
957
958 if (unlikely(ret != VIRTIO_CRYPTO_OK))
959 goto error_exit;
960
961 /* prepare */
962 /* iv */
963 if (unlikely(copy_data(iv_data, vc_req, head, &desc,
964 chain->para.iv_len, max_n_descs) < 0)) {
965 VC_LOG_ERR("Incorrect virtio descriptor");
966 ret = VIRTIO_CRYPTO_BADMSG;
967 goto error_exit;
968 }
969
970 switch (vcrypto->option) {
971 case RTE_VHOST_CRYPTO_ZERO_COPY_ENABLE:
972 m_src->data_len = chain->para.src_data_len;
973 m_dst->data_len = chain->para.dst_data_len;
974
975 rte_mbuf_iova_set(m_src,
976 gpa_to_hpa(vcrypto->dev, desc->addr, chain->para.src_data_len));
977 m_src->buf_addr = get_data_ptr(vc_req, desc, VHOST_ACCESS_RO);
978 if (unlikely(rte_mbuf_iova_get(m_src) == 0 || m_src->buf_addr == NULL)) {
979 VC_LOG_ERR("zero_copy may fail due to cross page data");
980 ret = VIRTIO_CRYPTO_ERR;
981 goto error_exit;
982 }
983
984 if (unlikely(move_desc(head, &desc, chain->para.src_data_len,
985 max_n_descs) < 0)) {
986 VC_LOG_ERR("Incorrect descriptor");
987 ret = VIRTIO_CRYPTO_ERR;
988 goto error_exit;
989 }
990 break;
991 case RTE_VHOST_CRYPTO_ZERO_COPY_DISABLE:
992 vc_req->wb_pool = vcrypto->wb_pool;
993 m_src->data_len = chain->para.src_data_len;
994 if (unlikely(copy_data(rte_pktmbuf_mtod(m_src, uint8_t *),
995 vc_req, head, &desc, chain->para.src_data_len,
996 max_n_descs) < 0)) {
997 VC_LOG_ERR("Incorrect virtio descriptor");
998 ret = VIRTIO_CRYPTO_BADMSG;
999 goto error_exit;

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