X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_vhost%2Fvhost_rxtx.c;h=b4da66563cf80f543da34bf6b3c543a7e4e82c48;hb=ae19955e7c86;hp=b0d0dff288bce0ac781f8c614c9e58262402a25a;hpb=c687b0b635e29c99f4dc7c91d84849130aeb89ac;p=dpdk.git diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c index b0d0dff288..b4da66563c 100644 --- a/lib/librte_vhost/vhost_rxtx.c +++ b/lib/librte_vhost/vhost_rxtx.c @@ -94,8 +94,6 @@ is_valid_virt_queue_idx(uint32_t idx, int is_tx, uint32_t qp_nb) static void virtio_enqueue_offload(struct rte_mbuf *m_buf, struct virtio_net_hdr *net_hdr) { - memset(net_hdr, 0, sizeof(struct virtio_net_hdr)); - if (m_buf->ol_flags & PKT_TX_L4_MASK) { net_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM; net_hdr->csum_start = m_buf->l2_len + m_buf->l3_len; @@ -333,7 +331,8 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, rte_mb(); /* Kick the guest if necessary. */ - if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) + if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT) + && (vq->callfd >= 0)) eventfd_write(vq->callfd, (eventfd_t)1); return count; } @@ -586,7 +585,8 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id, rte_mb(); /* Kick the guest if necessary. */ - if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) + if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT) + && (vq->callfd >= 0)) eventfd_write(vq->callfd, (eventfd_t)1); } @@ -745,6 +745,8 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq, uint32_t cpy_len; struct rte_mbuf *cur = m, *prev = m; struct virtio_net_hdr *hdr; + /* A counter to avoid desc dead loop chain */ + uint32_t nr_desc = 1; desc = &vq->desc[desc_idx]; if (unlikely(desc->len < vq->vhost_hlen)) @@ -763,7 +765,8 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq, while (desc_avail != 0 || (desc->flags & VRING_DESC_F_NEXT) != 0) { /* This desc reaches to its end, get the next one */ if (desc_avail == 0) { - if (unlikely(desc->next >= vq->size)) + if (unlikely(desc->next >= vq->size || + ++nr_desc >= vq->size)) return -1; desc = &vq->desc[desc->next]; @@ -926,7 +929,8 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, sizeof(vq->used->idx)); /* Kick guest if required. */ - if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) + if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT) + && (vq->callfd >= 0)) eventfd_write(vq->callfd, (eventfd_t)1); out: