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

Function vhost_enqueue_single_packed

dpdk/lib/vhost/virtio_net.c:1339–1402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1337}
1338
1339static __rte_always_inline int
1340vhost_enqueue_single_packed(struct virtio_net *dev,
1341 struct vhost_virtqueue *vq,
1342 struct rte_mbuf *pkt,
1343 struct buf_vector *buf_vec,
1344 uint16_t *nr_descs)
1345 __rte_shared_locks_required(&vq->access_lock)
1346 __rte_shared_locks_required(&vq->iotlb_lock)
1347{
1348 uint16_t nr_vec = 0;
1349 uint16_t avail_idx = vq->last_avail_idx;
1350 uint16_t max_tries, tries = 0;
1351 uint16_t buf_id = 0;
1352 uint32_t len = 0;
1353 uint16_t desc_count;
1354 uint64_t size = pkt->pkt_len + sizeof(struct virtio_net_hdr_mrg_rxbuf);
1355 uint16_t num_buffers = 0;
1356 uint32_t buffer_len[vq->size];
1357 uint16_t buffer_buf_id[vq->size];
1358 uint16_t buffer_desc_count[vq->size];
1359
1360 if (rxvq_is_mergeable(dev))
1361 max_tries = vq->size - 1;
1362 else
1363 max_tries = 1;
1364
1365 while (size > 0) {
1366 /*
1367 * if we tried all available ring items, and still
1368 * can't get enough buf, it means something abnormal
1369 * happened.
1370 */
1371 if (unlikely(++tries > max_tries))
1372 return -1;
1373
1374 if (unlikely(fill_vec_buf_packed(dev, vq,
1375 avail_idx, &desc_count,
1376 buf_vec, &nr_vec,
1377 &buf_id, &len,
1378 VHOST_ACCESS_RW) < 0))
1379 return -1;
1380
1381 len = RTE_MIN(len, size);
1382 size -= len;
1383
1384 buffer_len[num_buffers] = len;
1385 buffer_buf_id[num_buffers] = buf_id;
1386 buffer_desc_count[num_buffers] = desc_count;
1387 num_buffers += 1;
1388
1389 *nr_descs += desc_count;
1390 avail_idx += desc_count;
1391 if (avail_idx >= vq->size)
1392 avail_idx -= vq->size;
1393 }
1394
1395 if (mbuf_to_desc(dev, vq, pkt, buf_vec, nr_vec, num_buffers, false) < 0)
1396 return -1;

Callers 1

Calls 4

rxvq_is_mergeableFunction · 0.85
fill_vec_buf_packedFunction · 0.85
mbuf_to_descFunction · 0.85

Tested by

no test coverage detected