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

Function virtqueue_detach_unused

dpdk/drivers/net/virtio/virtqueue.c:22–60  ·  view source on GitHub ↗

* Two types of mbuf to be cleaned: * 1) mbuf that has been consumed by backend but not used by virtio. * 2) mbuf that hasn't been consumed by backend. */

Source from the content-addressed store, hash-verified

20 * 2) mbuf that hasn't been consumed by backend.
21 */
22struct rte_mbuf *
23virtqueue_detach_unused(struct virtqueue *vq)
24{
25 struct rte_mbuf *cookie;
26 struct virtio_hw *hw;
27 uint16_t start, end;
28 int type, idx;
29
30 if (vq == NULL)
31 return NULL;
32
33 hw = vq->hw;
34 type = virtio_get_queue_type(hw, vq->vq_queue_index);
35 start = vq->vq_avail_idx & (vq->vq_nentries - 1);
36 end = (vq->vq_avail_idx + vq->vq_free_cnt) & (vq->vq_nentries - 1);
37
38 for (idx = 0; idx < vq->vq_nentries; idx++) {
39 if (hw->use_vec_rx && !virtio_with_packed_queue(hw) &&
40 type == VTNET_RQ) {
41 if (start <= end && idx >= start && idx < end)
42 continue;
43 if (start > end && (idx >= start || idx < end))
44 continue;
45 cookie = vq->rxq.sw_ring[idx];
46 if (cookie != NULL) {
47 vq->rxq.sw_ring[idx] = NULL;
48 return cookie;
49 }
50 } else {
51 cookie = vq->vq_descx[idx].cookie;
52 if (cookie != NULL) {
53 vq->vq_descx[idx].cookie = NULL;
54 return cookie;
55 }
56 }
57 }
58
59 return NULL;
60}
61
62/* Flush used descs */
63static void

Callers 1

virtio_dev_free_mbufsFunction · 0.85

Calls 2

virtio_get_queue_typeFunction · 0.85
virtio_with_packed_queueFunction · 0.85

Tested by

no test coverage detected