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 B248F106B for ; Mon, 15 Jun 2015 09:57:12 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 15 Jun 2015 00:57:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,617,1427785200"; d="scan'208";a="746791519" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 15 Jun 2015 00:57:11 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t5F7v8QN005693; Mon, 15 Jun 2015 15:57:08 +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 t5F7v4UB030667; Mon, 15 Jun 2015 15:57:06 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t5F7v4Z4030663; Mon, 15 Jun 2015 15:57:04 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Mon, 15 Jun 2015 15:56:44 +0800 Message-Id: <1434355006-30583-8-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1434355006-30583-1-git-send-email-changchun.ouyang@intel.com> References: <1433915549-18571-1-git-send-email-changchun.ouyang@intel.com> <1434355006-30583-1-git-send-email-changchun.ouyang@intel.com> Subject: [dpdk-dev] [PATCH v3 7/9] 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: Mon, 15 Jun 2015 07:57:13 -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 fe5f9a1..e4bedbd 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; @@ -178,9 +180,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) { @@ -208,7 +216,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