From patchwork Tue Oct 20 15:20:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Moreno X-Patchwork-Id: 81600 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A90CDA04DC; Tue, 20 Oct 2020 17:21:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 705ABBCD0; Tue, 20 Oct 2020 17:21:09 +0200 (CEST) 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 1C205BCCC for ; Tue, 20 Oct 2020 17:21:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603207265; 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=Mwp/NI8XtIfLCMWztDOo/iA2zVSldzcEhzQa4vHUF1E=; b=XCHgmoE40f4ADqtxx8WPXhktQSzr/Go3rRSlS9kjAXwFlApmLtWdC7ioZK83cTmcC+/N/+ EeuSytPQVzJoSwW7sdil6d4EfKT33u2yMuUKGuDzBHHJ37kwXHhdkXueZ1EnNNx6Ny03JS DpiSNlnm+wKuQiTxR4S3F4RD92r2c4w= 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-502-TC0CpIB2M-6mD-JyX1m0Pg-1; Tue, 20 Oct 2020 11:21:02 -0400 X-MC-Unique: TC0CpIB2M-6mD-JyX1m0Pg-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 86EAB18BE16B; Tue, 20 Oct 2020 15:21:01 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (ovpn-112-202.ams2.redhat.com [10.36.112.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8DCA6266E; Tue, 20 Oct 2020 15:20:56 +0000 (UTC) From: Adrian Moreno To: dev@dpdk.org Cc: yinan.wang@intel.com, patrick.fu@intel.com, amorenoz@redhat.com, stable@dpdk.org, Maxime Coquelin , Chenbo Xia , Zhihong Wang Date: Tue, 20 Oct 2020 17:20:50 +0200 Message-Id: <20201020152052.389446-2-amorenoz@redhat.com> In-Reply-To: <20201020152052.389446-1-amorenoz@redhat.com> References: <20201020152052.389446-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 Subject: [dpdk-dev] [PATCH v2 1/3] virtio-user: fix backend selection if stat fails 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" If stat fails because the file does not exist, it means that the backend must be vhost-user in server mode. Also, log the detected backend type. Bugzilla ID: 559 Fixes: f908b22ea47a ("net/virtio: move backend type selection to ethdev") Cc: stable@dpdk.org Signed-off-by: Adrian Moreno Reviewed-by: Maxime Coquelin Acked-by: Kevin Traynor --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 7 +++++++ drivers/net/virtio/virtio_user/virtio_user_dev.h | 1 + drivers/net/virtio/virtio_user_ethdev.c | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 3681758ef..27814eadb 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -22,6 +22,13 @@ #define VIRTIO_USER_MEM_EVENT_CLB_NAME "virtio_user_mem_event_clb" +const char * const virtio_user_backend_strings[] = { + [VIRTIO_USER_BACKEND_UNKNOWN] = "VIRTIO_USER_BACKEND_UNKNOWN", + [VIRTIO_USER_BACKEND_VHOST_USER] = "VHOST_USER", + [VIRTIO_USER_BACKEND_VHOST_KERNEL] = "VHOST_NET", + [VIRTIO_USER_BACKEND_VHOST_VDPA] = "VHOST_VDPA", +}; + static int virtio_user_create_queue(struct virtio_user_dev *dev, uint32_t queue_sel) { diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h index 3e9d1a1eb..998986875 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h @@ -83,4 +83,5 @@ void virtio_user_handle_cq_packed(struct virtio_user_dev *dev, uint8_t virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs); int virtio_user_send_status_update(struct virtio_user_dev *dev, uint8_t status); int virtio_user_update_status(struct virtio_user_dev *dev); +extern const char * const virtio_user_backend_strings[]; #endif diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 042665bc0..e870fb2ff 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -560,6 +560,9 @@ virtio_user_backend_type(const char *path) struct stat sb; if (stat(path, &sb) == -1) { + if (errno == ENOENT) + return VIRTIO_USER_BACKEND_VHOST_USER; + PMD_INIT_LOG(ERR, "Stat fails: %s (%s)\n", path, strerror(errno)); return VIRTIO_USER_BACKEND_UNKNOWN; @@ -697,7 +700,8 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev) path); goto end; } - + PMD_INIT_LOG(INFO, "Backend type detected: %s", + virtio_user_backend_strings[backend_type]); if (rte_kvargs_count(kvlist, VIRTIO_USER_ARG_INTERFACE_NAME) == 1) { if (backend_type != VIRTIO_USER_BACKEND_VHOST_KERNEL) { From patchwork Tue Oct 20 15:20:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Moreno X-Patchwork-Id: 81601 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 13ACAA04DC; Tue, 20 Oct 2020 17:21:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E2CB7BCF9; Tue, 20 Oct 2020 17:21:12 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by dpdk.org (Postfix) with ESMTP id 7A6B5BCF1 for ; Tue, 20 Oct 2020 17:21:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603207268; 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=ixGc/T2lTLUgB9FGSpAtW3F+2uLWJHEaX8805BcvInY=; b=UUoLgpJnXlnpNOK4xBavSgr18cC7eHrtEVk9gH0cDy6v7IT+8dCdQj2NVFrbCdlqfPQiAQ nywAya2Z8oSKnklRyPotllUNtn18pNB3Rc5TWmmex4HsfHF2I+JK8qMBy6yaTTeK1+XfRG wLFy3ZgtMxNPk8I1ObtmN5MFBGuYKWI= 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-69-1esTdA2lNmizRNSFfqkKdA-1; Tue, 20 Oct 2020 11:21:05 -0400 X-MC-Unique: 1esTdA2lNmizRNSFfqkKdA-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 BBF3B18BE163; Tue, 20 Oct 2020 15:21:03 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (ovpn-112-202.ams2.redhat.com [10.36.112.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAE6B55763; Tue, 20 Oct 2020 15:21:01 +0000 (UTC) From: Adrian Moreno To: dev@dpdk.org Cc: yinan.wang@intel.com, patrick.fu@intel.com, amorenoz@redhat.com, maxime.coquelin@redhat.com, stable@dpdk.org, Chenbo Xia , Zhihong Wang Date: Tue, 20 Oct 2020 17:20:51 +0200 Message-Id: <20201020152052.389446-3-amorenoz@redhat.com> In-Reply-To: <20201020152052.389446-1-amorenoz@redhat.com> References: <20201020152052.389446-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 Subject: [dpdk-dev] [PATCH v2 2/3] virtio_user: don't set/get_status until FEATURES_OK 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" According to the virtio spec, ACK and DRIVER status bits should be set before feature negotiation. However, until the protocol features are negotiated, the driver does not know if the device actually supports the those vhost-user messages. Therefore, until FEATURES_OK is set, the GET/SET_STATUS messages should not be sent. Fixes: 57912824615f ("net/virtio-user: support vhost status setting") Cc: maxime.coquelin@redhat.com Cc: stable@dpdk.org Signed-off-by: Adrian Moreno Reviewed-by: Maxime Coquelin --- drivers/net/virtio/virtio_user/vhost_user.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c index ef290c357..450d77e92 100644 --- a/drivers/net/virtio/virtio_user/vhost_user.c +++ b/drivers/net/virtio/virtio_user/vhost_user.c @@ -278,8 +278,9 @@ vhost_user_sock(struct virtio_user_dev *dev, switch (req) { case VHOST_USER_GET_STATUS: - if (!(dev->protocol_features & - (1ULL << VHOST_USER_PROTOCOL_F_STATUS))) + if (!(dev->status & VIRTIO_CONFIG_STATUS_FEATURES_OK) || + (!(dev->protocol_features & + (1ULL << VHOST_USER_PROTOCOL_F_STATUS)))) return 0; /* Fallthrough */ case VHOST_USER_GET_FEATURES: @@ -288,8 +289,9 @@ vhost_user_sock(struct virtio_user_dev *dev, break; case VHOST_USER_SET_STATUS: - if (!(dev->protocol_features & - (1ULL << VHOST_USER_PROTOCOL_F_STATUS))) + if (!(dev->status & VIRTIO_CONFIG_STATUS_FEATURES_OK) || + (!(dev->protocol_features & + (1ULL << VHOST_USER_PROTOCOL_F_STATUS)))) return 0; if (has_reply_ack) From patchwork Tue Oct 20 15:20:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Moreno X-Patchwork-Id: 81602 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2E8F1A04DC; Tue, 20 Oct 2020 17:22:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 62926BE27; Tue, 20 Oct 2020 17:21:14 +0200 (CEST) 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 527EABCEB for ; Tue, 20 Oct 2020 17:21:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603207269; 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=mECSGPlM/k1rwIVi8bx1p8Gw94CkLMjqpMAflz15RbM=; b=JULmIgEr0TnoTxbjkpj2zqPpA1lQ8OQulo5TAlAm14IPxKUShEDNW2WryLDZzXzhhl+tC7 qJDN5w3G8z1kX2ybWwYspI19rH6R5Q4kGyh/KL26FTf0Z4bjS6YwAQExfosA68i1K+4Spl tNmrF1txO71jyE2f4DJiblXRUP44hpI= 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-130-T0yG9FFjNC-76CwBy5UHNQ-1; Tue, 20 Oct 2020 11:21:07 -0400 X-MC-Unique: T0yG9FFjNC-76CwBy5UHNQ-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 E3721879515; Tue, 20 Oct 2020 15:21:05 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (ovpn-112-202.ams2.redhat.com [10.36.112.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id 303625577A; Tue, 20 Oct 2020 15:21:04 +0000 (UTC) From: Adrian Moreno To: dev@dpdk.org Cc: yinan.wang@intel.com, patrick.fu@intel.com, amorenoz@redhat.com, maxime.coquelin@redhat.com, stable@dpdk.org, Chenbo Xia , Zhihong Wang Date: Tue, 20 Oct 2020 17:20:52 +0200 Message-Id: <20201020152052.389446-4-amorenoz@redhat.com> In-Reply-To: <20201020152052.389446-1-amorenoz@redhat.com> References: <20201020152052.389446-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 Subject: [dpdk-dev] [PATCH v2 3/3] virtio-user: set status on virtio-user reconnect 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" Newer vhost-user backends will rely on SET_STATUS to start the device so this required to support them. Fixes: 57912824615f ("net/virtio-user: support vhost status setting") Cc: maxime.coquelin@redhat.com Cc: stable@dpdk.org Signed-off-by: Adrian Moreno Reviewed-by: Maxime Coquelin Tested-by: JiangYuX --- drivers/net/virtio/virtio_user_ethdev.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index e870fb2ff..d8bea4537 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -78,6 +78,13 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev) return -1; dev->vhostfd = connectfd; + + vtpci_reset(hw); + + vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_ACK); + + vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER); + if (dev->ops->send_request(dev, VHOST_USER_GET_FEATURES, &dev->device_features) < 0) { PMD_INIT_LOG(ERR, "get_features failed: %s", @@ -111,6 +118,8 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev) dev->features &= dev->device_features; + vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_FEATURES_OK); + /* For packed ring, resetting queues is required in reconnection. */ if (vtpci_packed_queue(hw) && (vtpci_get_status(hw) & VIRTIO_CONFIG_STATUS_DRIVER_OK)) { @@ -119,8 +128,9 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev) virtio_user_reset_queues_packed(eth_dev); } - ret = virtio_user_start_device(dev); - if (ret < 0) + /* Start the device */ + vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER_OK); + if (!dev->started) return -1; if (dev->queue_pairs > 1) {