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 4498CC32E for ; Wed, 10 Jun 2015 07:52:51 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 09 Jun 2015 22:52:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,586,1427785200"; d="scan'208";a="708366828" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 09 Jun 2015 22:52:49 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t5A5qk5F004880; Wed, 10 Jun 2015 13:52:46 +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 t5A5qirg018648; Wed, 10 Jun 2015 13:52:46 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t5A5qiWw018644; Wed, 10 Jun 2015 13:52:44 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Wed, 10 Jun 2015 13:52:28 +0800 Message-Id: <1433915549-18571-7-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1433915549-18571-1-git-send-email-changchun.ouyang@intel.com> References: <1432194581-15301-1-git-send-email-changchun.ouyang@intel.com> <1433915549-18571-1-git-send-email-changchun.ouyang@intel.com> Subject: [dpdk-dev] [PATCH v2 6/7] virtio: Resolve for control queue 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: Wed, 10 Jun 2015 05:52:51 -0000 Control queue can't work for vhost-user mulitple queue mode, so introduce a counter to void the dead loop when polling the control queue. Changes in v2: - fix checkpatch errors Signed-off-by: Changchun Ouyang --- drivers/net/virtio/virtio_ethdev.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index f74e413..9618f4f 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -61,6 +61,7 @@ #include "virtio_logs.h" #include "virtqueue.h" +#define CQ_POLL_COUNTER 500 /* Avoid dead loop when polling control queue */ static int eth_virtio_dev_init(struct rte_eth_dev *eth_dev); static int virtio_dev_configure(struct rte_eth_dev *dev); @@ -118,6 +119,7 @@ virtio_send_command(struct virtqueue *vq, struct virtio_pmd_ctrl *ctrl, int k, sum = 0; virtio_net_ctrl_ack status = ~0; struct virtio_pmd_ctrl result; + uint32_t cq_poll = CQ_POLL_COUNTER; ctrl->status = status; @@ -177,9 +179,15 @@ virtio_send_command(struct virtqueue *vq, struct virtio_pmd_ctrl *ctrl, virtqueue_notify(vq); rte_rmb(); - while (vq->vq_used_cons_idx == vq->vq_ring.used->idx) { + + /** + * FIXME: The control queue doesn't work for vhost-user + * multiple queue, introduce poll_ms to avoid the deadloop. + */ + while ((vq->vq_used_cons_idx == vq->vq_ring.used->idx) && (cq_poll != 0)) { rte_rmb(); usleep(100); + cq_poll--; } while (vq->vq_used_cons_idx != vq->vq_ring.used->idx) { @@ -207,7 +215,10 @@ virtio_send_command(struct virtqueue *vq, struct virtio_pmd_ctrl *ctrl, PMD_INIT_LOG(DEBUG, "vq->vq_free_cnt=%d\nvq->vq_desc_head_idx=%d", vq->vq_free_cnt, vq->vq_desc_head_idx); - memcpy(&result, vq->virtio_net_hdr_mz->addr, + if (cq_poll == 0) + result.status = 0; + else + memcpy(&result, vq->virtio_net_hdr_mz->addr, sizeof(struct virtio_pmd_ctrl)); return result.status; -- 1.8.4.2