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

Function mbuf_to_desc

dpdk/lib/vhost/virtio_net.c:1211–1337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1209}
1210
1211static __rte_always_inline int
1212mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
1213 struct rte_mbuf *m, struct buf_vector *buf_vec,
1214 uint16_t nr_vec, uint16_t num_buffers, bool is_async)
1215 __rte_shared_locks_required(&vq->access_lock)
1216 __rte_shared_locks_required(&vq->iotlb_lock)
1217{
1218 uint32_t vec_idx = 0;
1219 uint32_t mbuf_offset, mbuf_avail;
1220 uint32_t buf_offset, buf_avail;
1221 uint64_t buf_addr, buf_iova, buf_len;
1222 uint32_t cpy_len;
1223 uint64_t hdr_addr;
1224 struct rte_mbuf *hdr_mbuf;
1225 struct virtio_net_hdr_mrg_rxbuf tmp_hdr, *hdr = NULL;
1226 struct vhost_async *async = vq->async;
1227
1228 if (unlikely(m == NULL))
1229 return -1;
1230
1231 buf_addr = buf_vec[vec_idx].buf_addr;
1232 buf_iova = buf_vec[vec_idx].buf_iova;
1233 buf_len = buf_vec[vec_idx].buf_len;
1234
1235 if (unlikely(buf_len < dev->vhost_hlen && nr_vec <= 1))
1236 return -1;
1237
1238 hdr_mbuf = m;
1239 hdr_addr = buf_addr;
1240 if (unlikely(buf_len < dev->vhost_hlen)) {
1241 memset(&tmp_hdr, 0, sizeof(struct virtio_net_hdr_mrg_rxbuf));
1242 hdr = &tmp_hdr;
1243 } else
1244 hdr = (struct virtio_net_hdr_mrg_rxbuf *)(uintptr_t)hdr_addr;
1245
1246 VHOST_LOG_DATA(dev->ifname, DEBUG, "RX: num merge buffers %d\n", num_buffers);
1247
1248 if (unlikely(buf_len < dev->vhost_hlen)) {
1249 buf_offset = dev->vhost_hlen - buf_len;
1250 vec_idx++;
1251 buf_addr = buf_vec[vec_idx].buf_addr;
1252 buf_iova = buf_vec[vec_idx].buf_iova;
1253 buf_len = buf_vec[vec_idx].buf_len;
1254 buf_avail = buf_len - buf_offset;
1255 } else {
1256 buf_offset = dev->vhost_hlen;
1257 buf_avail = buf_len - dev->vhost_hlen;
1258 }
1259
1260 mbuf_avail = rte_pktmbuf_data_len(m);
1261 mbuf_offset = 0;
1262
1263 if (is_async) {
1264 if (async_iter_initialize(dev, async))
1265 return -1;
1266 }
1267
1268 while (mbuf_avail != 0 || m->next != NULL) {

Callers 4

virtio_dev_rx_splitFunction · 0.85

Calls 9

memsetFunction · 0.85
async_iter_initializeFunction · 0.85
virtio_enqueue_offloadFunction · 0.85
rxvq_is_mergeableFunction · 0.85
copy_vnet_hdr_to_descFunction · 0.85
async_fill_segFunction · 0.85
sync_fill_segFunction · 0.85
async_iter_finalizeFunction · 0.85
async_iter_cancelFunction · 0.85

Tested by

no test coverage detected