From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 39CE91B6B8 for ; Fri, 3 Nov 2017 16:53:07 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73B1961D22; Fri, 3 Nov 2017 15:53:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 73B1961D22 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=maxime.coquelin@redhat.com Received: from localhost.localdomain (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2181E5C54A; Fri, 3 Nov 2017 15:52:50 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, yliu@fridaylinux.org, lei.a.yao@intel.com Cc: mst@redhat.com, Maxime Coquelin Date: Fri, 3 Nov 2017 16:52:35 +0100 Message-Id: <20171103155235.29869-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 03 Nov 2017 15:53:06 +0000 (UTC) Subject: [dpdk-dev] [PATCH] vhost: postpone ring addresses translations at kick time only X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Nov 2017 15:53:07 -0000 If multiple queue pairs are created but all are not used, the device is never started, as unused queues aren't enabled and their ring addresses aren't translated. The device is changed to running state when all rings addresses are translated. This patch fixes this by postponning rings addresses translation at kick time unconditionnaly, VHOST_USER_F_PROTOCOL_FEATURES being negotiated or not. Reported-by: Lei Yao Signed-off-by: Maxime Coquelin --- lib/librte_vhost/vhost_user.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 1f6cba4b9..849755093 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -755,15 +755,12 @@ vhost_user_set_vring_kick(struct virtio_net **pdev, struct VhostUserMsg *pmsg) RTE_LOG(INFO, VHOST_CONFIG, "vring kick idx:%d file:%d\n", file.index, file.fd); - /* - * Interpret ring addresses only when ring is started and enabled. - * This is now if protocol features aren't supported. - */ - if (!(dev->features & (1ULL << VHOST_USER_F_PROTOCOL_FEATURES))) { - *pdev = dev = translate_ring_addresses(dev, file.index); - if (!dev) - return; - } + /* Interpret ring addresses only when ring is started. */ + dev = translate_ring_addresses(dev, file.index); + if (!dev) + return; + + *pdev = dev; vq = dev->virtqueue[file.index]; @@ -845,29 +842,15 @@ vhost_user_get_vring_base(struct virtio_net *dev, * enable the virtio queue pair. */ static int -vhost_user_set_vring_enable(struct virtio_net **pdev, +vhost_user_set_vring_enable(struct virtio_net *dev, VhostUserMsg *msg) { - struct virtio_net *dev = *pdev; int enable = (int)msg->payload.state.num; RTE_LOG(INFO, VHOST_CONFIG, "set queue enable: %d to qp idx: %d\n", enable, msg->payload.state.index); - /* - * Interpret ring addresses only when ring is started and enabled. - * This is now if protocol features are supported. - */ - if (enable && (dev->features & - (1ULL << VHOST_USER_F_PROTOCOL_FEATURES))) { - dev = translate_ring_addresses(dev, msg->payload.state.index); - if (!dev) - return -1; - - *pdev = dev; - } - if (dev->notify_ops->vring_state_changed) dev->notify_ops->vring_state_changed(dev->vid, msg->payload.state.index, enable); @@ -1315,7 +1298,7 @@ vhost_user_msg_handler(int vid, int fd) break; case VHOST_USER_SET_VRING_ENABLE: - vhost_user_set_vring_enable(&dev, &msg); + vhost_user_set_vring_enable(dev, &msg); break; case VHOST_USER_SEND_RARP: vhost_user_send_rarp(dev, &msg); -- 2.13.6