From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0F3C2A04DD; Mon, 26 Oct 2020 17:42:50 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 50AB74C94; Mon, 26 Oct 2020 17:40:12 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by dpdk.org (Postfix) with ESMTP id A36E937AF for ; Mon, 26 Oct 2020 17:40:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603730402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OeUuGepVoCBebD+MkNGvbkMiuskRc3grFgPjhWvaBEk=; b=Pudrno02kxuyZf9k1UBq7bf9GB7Kng+RvB23m0sCqhuu1FDQXdwmSW1Hti6tG1tHE0M9fB OV/zMb4nQaNvN0Ha3lCIeR5CjcsAl2RXna6aNNR1c09o7pBgdoJpDpLgr8gJ+x/f2gvQTf UCt6DxuMte9Tp4ikR9t1VxjJnBT/xeo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-346-Y9xz2C5IMmG9NVhRjOHamg-1; Mon, 26 Oct 2020 12:39:58 -0400 X-MC-Unique: Y9xz2C5IMmG9NVhRjOHamg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F2FA218C9F46; Mon, 26 Oct 2020 16:39:56 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (ovpn-114-135.ams2.redhat.com [10.36.114.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F7CF55762; Mon, 26 Oct 2020 16:39:55 +0000 (UTC) From: Adrian Moreno To: dev@dpdk.org Cc: yinan.wang@intel.com, patrick.fu@intel.com, chenbo.xia@intel.com, zhihong.wang@intel.com, maxime.coquelin@redhat.com, Adrian Moreno , stable@dpdk.org Date: Mon, 26 Oct 2020 17:39:29 +0100 Message-Id: <20201026163930.94032-6-amorenoz@redhat.com> In-Reply-To: <20201026163930.94032-1-amorenoz@redhat.com> References: <20201026163930.94032-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=amorenoz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH v3 5/6] net/virtio-user: don't assume vhost status feature 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" There are some status reads and updates that need to happen before the protocol features are negotiated. Therefore, assuming the backend does support this feature can lead to failures. On server mode, do not assume the backend supports VHOST_USER_PROTOCOL_F_STATUS. Activate it back on reconnection and cleare it on disconnection. Fixes: 57912824615f ("net/virtio-user: support vhost status setting") Cc: maxime.coquelin@redhat.com Cc: stable@dpdk.org Signed-off-by: Adrian Moreno --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 6 ++++++ drivers/net/virtio/virtio_user_ethdev.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 36e5619df..053f0267c 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -523,6 +523,12 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, * later. */ dev->device_features = VIRTIO_USER_SUPPORTED_FEATURES; + + /* We cannot assume VHOST_USER_PROTOCOL_F_STATUS is supported + * until it's negotiated + */ + dev->protocol_features &= + ~(1ULL << VHOST_USER_PROTOCOL_F_STATUS); } diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 97ddc5651..142bdc0bd 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -92,6 +92,9 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev) &protocol_features)) return -1; + /* Offer VHOST_USER_PROTOCOL_F_STATUS */ + dev->protocol_features |= + (1ULL << VHOST_USER_PROTOCOL_F_STATUS); dev->protocol_features &= protocol_features; if (dev->ops->send_request(dev, @@ -168,6 +171,11 @@ virtio_user_delayed_handler(void *param) if (dev->vhostfd >= 0) { close(dev->vhostfd); dev->vhostfd = -1; + /* Until the featuers are negotiated again, don't assume + * the backend supports VHOST_USER_PROTOCOL_F_STATUS + */ + dev->protocol_features &= + ~(1ULL << VHOST_USER_PROTOCOL_F_STATUS); } eth_dev->intr_handle->fd = dev->listenfd; rte_intr_callback_register(eth_dev->intr_handle, -- 2.26.2