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

Function vhost_crypto_process_one_req

dpdk/lib/vhost/vhost_crypto.c:1128–1290  ·  view source on GitHub ↗

* Process on descriptor */

Source from the content-addressed store, hash-verified

1126 * Process on descriptor
1127 */
1128static __rte_always_inline int
1129vhost_crypto_process_one_req(struct vhost_crypto *vcrypto,
1130 struct vhost_virtqueue *vq, struct rte_crypto_op *op,
1131 struct vring_desc *head, struct vhost_crypto_desc *descs,
1132 uint16_t desc_idx)
1133 __rte_no_thread_safety_analysis /* FIXME: requires iotlb_lock? */
1134{
1135 struct vhost_crypto_data_req *vc_req = rte_mbuf_to_priv(op->sym->m_src);
1136 struct rte_cryptodev_sym_session *session;
1137 struct virtio_crypto_op_data_req req;
1138 struct virtio_crypto_inhdr *inhdr;
1139 struct vhost_crypto_desc *desc = descs;
1140 struct vring_desc *src_desc;
1141 uint64_t session_id;
1142 uint64_t dlen;
1143 uint32_t nb_descs = 0, max_n_descs, i;
1144 int err;
1145
1146 vc_req->desc_idx = desc_idx;
1147 vc_req->dev = vcrypto->dev;
1148 vc_req->vq = vq;
1149
1150 if (unlikely((head->flags & VRING_DESC_F_INDIRECT) == 0)) {
1151 VC_LOG_ERR("Invalid descriptor");
1152 return -1;
1153 }
1154
1155 dlen = head->len;
1156 src_desc = IOVA_TO_VVA(struct vring_desc *, vc_req, head->addr,
1157 &dlen, VHOST_ACCESS_RO);
1158 if (unlikely(!src_desc || dlen != head->len)) {
1159 VC_LOG_ERR("Invalid descriptor");
1160 return -1;
1161 }
1162 head = src_desc;
1163
1164 nb_descs = max_n_descs = dlen / sizeof(struct vring_desc);
1165 if (unlikely(nb_descs > VHOST_CRYPTO_MAX_N_DESC || nb_descs == 0)) {
1166 err = VIRTIO_CRYPTO_ERR;
1167 VC_LOG_ERR("Cannot process num of descriptors %u", nb_descs);
1168 if (nb_descs > 0) {
1169 struct vring_desc *inhdr_desc = head;
1170 while (inhdr_desc->flags & VRING_DESC_F_NEXT) {
1171 if (inhdr_desc->next >= max_n_descs)
1172 return -1;
1173 inhdr_desc = &head[inhdr_desc->next];
1174 }
1175 if (inhdr_desc->len != sizeof(*inhdr))
1176 return -1;
1177 inhdr = IOVA_TO_VVA(struct virtio_crypto_inhdr *,
1178 vc_req, inhdr_desc->addr, &dlen,
1179 VHOST_ACCESS_WO);
1180 if (unlikely(!inhdr || dlen != inhdr_desc->len))
1181 return -1;
1182 inhdr->status = VIRTIO_CRYPTO_ERR;
1183 return -1;
1184 }
1185 }

Callers 1

Calls 7

rte_mbuf_to_privFunction · 0.85
copy_dataFunction · 0.85
rte_hash_lookup_dataFunction · 0.85
prepare_sym_cipher_opFunction · 0.85
prepare_sym_chain_opFunction · 0.85
reach_inhdrFunction · 0.85

Tested by

no test coverage detected