summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/virtio/node.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-01-18 14:54:04 +0100
committerFlorin Coras <florin.coras@gmail.com>2018-01-18 17:03:22 +0000
commitc58408c0f2db122c5185413ef35fe330551afc2d (patch)
tree594ac30237187346864c7e5e97c0d3f748d58ceb /src/vnet/devices/virtio/node.c
parent7866c4595b65f54f491ffc4e92b1f8cf94d6f142 (diff)
vlib: add vlib_buffer_alloc_to_ring API
Change-Id: I4e2804754b443f5f41fb25eed8334908c4a70f84 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/devices/virtio/node.c')
-rw-r--r--src/vnet/devices/virtio/node.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/vnet/devices/virtio/node.c b/src/vnet/devices/virtio/node.c
index 5ca06366cad..9477a1cfc58 100644
--- a/src/vnet/devices/virtio/node.c
+++ b/src/vnet/devices/virtio/node.c
@@ -83,10 +83,9 @@ static_always_inline void
virtio_refill_vring (vlib_main_t * vm, virtio_vring_t * vring)
{
const int hdr_sz = sizeof (struct virtio_net_hdr_v1);
- u16 used, next, avail, n_slots, n_alloc;
+ u16 used, next, avail, n_slots;
u16 sz = vring->size;
u16 mask = sz - 1;
- int i;
used = vring->desc_in_use;
@@ -96,14 +95,8 @@ virtio_refill_vring (vlib_main_t * vm, virtio_vring_t * vring)
n_slots = sz - used;
next = vring->desc_next;
avail = vring->avail->idx;
- n_alloc = vlib_buffer_alloc (vm, &vring->buffers[next], n_slots);
-
- if (PREDICT_FALSE (n_alloc < n_slots))
- n_slots = n_alloc;
-
- i = next + n_slots - sz;
- if (PREDICT_FALSE (i > 0))
- clib_memcpy (vring->buffers, &vring->buffers[sz], i * sizeof (u32));
+ n_slots = vlib_buffer_alloc_to_ring (vm, vring->buffers, next, vring->size,
+ n_slots);
while (n_slots)
{