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 AB1CE8DAF for ; Fri, 20 Nov 2015 14:45:04 +0100 (CET) Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 003F28F500; Fri, 20 Nov 2015 13:45:03 +0000 (UTC) Received: from redhat.com (vpn-200-159.tlv.redhat.com [10.35.200.159]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id tAKDj0pN014877; Fri, 20 Nov 2015 08:45:01 -0500 Date: Fri, 20 Nov 2015 15:45:00 +0200 From: Victor Kaplansky To: dev@dpdk.org Message-ID: <1448026465-27460-1-git-send-email-victork@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Cc: "Michael S. Tsirkin" , Marcel Apfelbaum , Marc-Andre Lureau Subject: [dpdk-dev] [PATCH] vhost-user: fix enabling of queue pair 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: Fri, 20 Nov 2015 13:45:04 -0000 The VHOST_USER_SET_VRING_ENABLE request is sent for each queue in queue-pair separately. So, a queue-pair should be considered enabled only when both RX and TX queues are enabled. The old code caused segfault when last TX queue was enabled. Signed-off-by: Victor Kaplansky --- lib/librte_vhost/vhost_user/virtio-net-user.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c index d07452a..c06e53e 100644 --- a/lib/librte_vhost/vhost_user/virtio-net-user.c +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c @@ -317,21 +317,25 @@ user_set_vring_enable(struct vhost_device_ctx ctx, struct vhost_vring_state *state) { struct virtio_net *dev = get_device(ctx); - uint16_t base_idx = state->index; + uint16_t idx = state->index; + uint16_t base_idx = (idx / VIRTIO_QNUM) * VIRTIO_QNUM; int enable = (int)state->num; + int qpair_enabled; RTE_LOG(INFO, VHOST_CONFIG, "set queue enable: %d to qp idx: %d\n", enable, state->index); + dev->virtqueue[idx]->enabled = enable; + qpair_enabled = + dev->virtqueue[base_idx + VIRTIO_RXQ]->enabled && + dev->virtqueue[base_idx + VIRTIO_TXQ]->enabled; + if (notify_ops->vring_state_changed) { notify_ops->vring_state_changed(dev, base_idx / VIRTIO_QNUM, - enable); + qpair_enabled); } - dev->virtqueue[base_idx + VIRTIO_RXQ]->enabled = enable; - dev->virtqueue[base_idx + VIRTIO_TXQ]->enabled = enable; - return 0; } -- --Victor