net/virtio: add Rx descriptor check
[dpdk.git] / drivers / net / virtio / virtio_rxtx.c
index 22d97a4..b29565e 100644 (file)
 #define VIRTIO_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \
        ETH_TXQ_FLAGS_NOOFFLOADS)
 
+int
+virtio_dev_rx_queue_done(void *rxq, uint16_t offset)
+{
+       struct virtnet_rx *rxvq = rxq;
+       struct virtqueue *vq = rxvq->vq;
+
+       return VIRTQUEUE_NUSED(vq) >= offset;
+}
+
 static void
 vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx)
 {
@@ -1015,7 +1024,8 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
                }
 
                /* optimize ring usage */
-               if (vtpci_with_feature(hw, VIRTIO_F_ANY_LAYOUT) &&
+               if ((vtpci_with_feature(hw, VIRTIO_F_ANY_LAYOUT) ||
+                     vtpci_with_feature(hw, VIRTIO_F_VERSION_1)) &&
                    rte_mbuf_refcnt_read(txm) == 1 &&
                    RTE_MBUF_DIRECT(txm) &&
                    txm->nb_segs == 1 &&