static void netmap_send(void *opaque)

{

    NetmapState *s = opaque;

    struct netmap_ring *ring = s->me.rx;



    /* Keep sending while there are available packets into the netmap

       RX ring and the forwarding path towards the peer is open. */

    while (!nm_ring_empty(ring) && qemu_can_send_packet(&s->nc)) {

        uint32_t i;

        uint32_t idx;

        bool morefrag;

        int iovcnt = 0;

        int iovsize;



        do {

            i = ring->cur;

            idx = ring->slot[i].buf_idx;

            morefrag = (ring->slot[i].flags & NS_MOREFRAG);

            s->iov[iovcnt].iov_base = (u_char *)NETMAP_BUF(ring, idx);

            s->iov[iovcnt].iov_len = ring->slot[i].len;

            iovcnt++;



            ring->cur = ring->head = nm_ring_next(ring, i);

        } while (!nm_ring_empty(ring) && morefrag);



        if (unlikely(nm_ring_empty(ring) && morefrag)) {

            RD(5, "[netmap_send] ran out of slots, with a pending"

                   "incomplete packet\n");

        }



        iovsize = qemu_sendv_packet_async(&s->nc, s->iov, iovcnt,

                                            netmap_send_completed);



        if (iovsize == 0) {

            /* The peer does not receive anymore. Packet is queued, stop

             * reading from the backend until netmap_send_completed()

             */

            netmap_read_poll(s, false);

            break;

        }

    }

}

static void netmap_send(void *opaque)

{

    NetmapState *s = opaque;

    struct netmap_ring *ring = s->me.rx;



    



    while (!nm_ring_empty(ring) && qemu_can_send_packet(&s->nc)) {

        uint32_t i;

        uint32_t idx;

        bool morefrag;

        int iovcnt = 0;

        int iovsize;



        do {

            i = ring->cur;

            idx = ring->slot[i].buf_idx;

            morefrag = (ring->slot[i].flags & NS_MOREFRAG);

            s->iov[iovcnt].iov_base = (u_char *)NETMAP_BUF(ring, idx);

            s->iov[iovcnt].iov_len = ring->slot[i].len;

            iovcnt++;



            ring->cur = ring->head = nm_ring_next(ring, i);

        } while (!nm_ring_empty(ring) && morefrag);



        if (unlikely(nm_ring_empty(ring) && morefrag)) {

            RD(5, "[netmap_send] ran out of slots, with a pending"

                   "incomplete packet\n");

        }



        iovsize = qemu_sendv_packet_async(&s->nc, s->iov, iovcnt,

                                            netmap_send_completed);



        if (iovsize == 0) {

            





            netmap_read_poll(s, false);

            break;

        }

    }

}

static void FUNC_0(void *VAR_0)

{

    NetmapState *s = VAR_0;

    struct netmap_ring *VAR_1 = s->me.rx;



    



    while (!nm_ring_empty(VAR_1) && qemu_can_send_packet(&s->nc)) {

        uint32_t i;

        uint32_t idx;

        bool morefrag;

        int VAR_2 = 0;

        int VAR_3;



        do {

            i = VAR_1->cur;

            idx = VAR_1->slot[i].buf_idx;

            morefrag = (VAR_1->slot[i].flags & NS_MOREFRAG);

            s->iov[VAR_2].iov_base = (u_char *)NETMAP_BUF(VAR_1, idx);

            s->iov[VAR_2].iov_len = VAR_1->slot[i].len;

            VAR_2++;



            VAR_1->cur = VAR_1->head = nm_ring_next(VAR_1, i);

        } while (!nm_ring_empty(VAR_1) && morefrag);



        if (unlikely(nm_ring_empty(VAR_1) && morefrag)) {

            RD(5, "[FUNC_0] ran out of slots, with a pending"

                   "incomplete packet\n");

        }



        VAR_3 = qemu_sendv_packet_async(&s->nc, s->iov, VAR_2,

                                            netmap_send_completed);



        if (VAR_3 == 0) {

            





            netmap_read_poll(s, false);

            break;

        }

    }

}

static void FUNC_0(void *VAR_0)
{ NetmapState *s = VAR_0; struct netmap_ring *VAR_1 = s->me.rx; while (!nm_ring_empty(VAR_1) && qemu_can_send_packet(&s->nc)) { uint32_t i; uint32_t idx; bool morefrag; int VAR_2 = 0; int VAR_3; do { i = VAR_1->cur; idx = VAR_1->slot[i].buf_idx; morefrag = (VAR_1->slot[i].flags & NS_MOREFRAG); s->iov[VAR_2].iov_base = (u_char *)NETMAP_BUF(VAR_1, idx); s->iov[VAR_2].iov_len = VAR_1->slot[i].len; VAR_2++; VAR_1->cur = VAR_1->head = nm_ring_next(VAR_1, i); } while (!nm_ring_empty(VAR_1) && morefrag); if (unlikely(nm_ring_empty(VAR_1) && morefrag)) { RD(5, "[FUNC_0] ran out of slots, with a pending"
"incomplete packet\n"); } VAR_3 = qemu_sendv_packet_async(&s->nc, s->iov, VAR_2,
netmap_send_completed); if (VAR_3 == 0) { netmap_read_poll(s, false); break; } } }