From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id B119E5A6F for ; Mon, 9 Feb 2015 02:15:26 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 08 Feb 2015 17:15:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,540,1418112000"; d="scan'208";a="682851239" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 08 Feb 2015 17:15:24 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t191FL7p019455; Mon, 9 Feb 2015 09:15:21 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t191FIsG011581; Mon, 9 Feb 2015 09:15:21 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t191FIUl011577; Mon, 9 Feb 2015 09:15:18 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Mon, 9 Feb 2015 09:14:15 +0800 Message-Id: <1423444455-11330-27-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1423444455-11330-1-git-send-email-changchun.ouyang@intel.com> References: <1422516249-14596-1-git-send-email-changchun.ouyang@intel.com> <1423444455-11330-1-git-send-email-changchun.ouyang@intel.com> Subject: [dpdk-dev] [PATCH v4 26/26] virtio: Fix updating vring descriptor index issue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2015 01:15:27 -0000 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 --- lib/librte_pmd_virtio/virtio_rxtx.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/librte_pmd_virtio/virtio_rxtx.c b/lib/librte_pmd_virtio/virtio_rxtx.c index 0225cc9..1d74b34 100644 --- a/lib/librte_pmd_virtio/virtio_rxtx.c +++ b/lib/librte_pmd_virtio/virtio_rxtx.c @@ -555,15 +555,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; } @@ -719,14 +718,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; } @@ -800,14 +799,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; -- 1.8.4.2