i40evf: support reporting PF reset
[dpdk.git] / lib / librte_vhost / vhost_rxtx.c
index b0d0dff..b4da665 100644 (file)
@@ -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: