From: Ouyang Changchun Date: Mon, 9 Feb 2015 01:14:15 +0000 (+0800) Subject: virtio: fix update of vring descriptor index X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=8c09c20fb4cde76e53d87bd50acf2b441ecf6eb8;p=dpdk.git virtio: fix update of vring descriptor index Updating the vring descriptor index should be done before notifying host; Remove 2 duplicated store memory barriers in both Rx and Tx path because there is store memory barrier in vq_update_avail_idx function; Notify the host only if packets actually transmitted(nb_tx > 0). Signed-off-by: Changchun Ouyang Acked-by: Huawei Xie --- diff --git a/lib/librte_pmd_virtio/virtio_rxtx.c b/lib/librte_pmd_virtio/virtio_rxtx.c index 78af3347bf..1db1dd8d95 100644 --- a/lib/librte_pmd_virtio/virtio_rxtx.c +++ b/lib/librte_pmd_virtio/virtio_rxtx.c @@ -516,15 +516,14 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) } if (likely(nb_enqueued)) { - virtio_wmb(); + vq_update_avail_idx(rxvq); + if (unlikely(virtqueue_kick_prepare(rxvq))) { virtqueue_notify(rxvq); PMD_RX_LOG(DEBUG, "Notified\n"); } } - vq_update_avail_idx(rxvq); - return nb_rx; } @@ -668,14 +667,14 @@ virtio_recv_mergeable_pkts(void *rx_queue, } if (likely(nb_enqueued)) { + vq_update_avail_idx(rxvq); + if (unlikely(virtqueue_kick_prepare(rxvq))) { virtqueue_notify(rxvq); PMD_RX_LOG(DEBUG, "Notified"); } } - vq_update_avail_idx(rxvq); - return nb_rx; } @@ -735,14 +734,16 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) break; } } - vq_update_avail_idx(txvq); - virtio_wmb(); txvq->packets += nb_tx; - if (unlikely(virtqueue_kick_prepare(txvq))) { - virtqueue_notify(txvq); - PMD_TX_LOG(DEBUG, "Notified backend after xmit"); + if (likely(nb_tx)) { + vq_update_avail_idx(txvq); + + if (unlikely(virtqueue_kick_prepare(txvq))) { + virtqueue_notify(txvq); + PMD_TX_LOG(DEBUG, "Notified backend after xmit"); + } } return nb_tx;