From patchwork Fri Sep 11 15:08:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 77432 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 AFD0EA04BB; Fri, 11 Sep 2020 17:09:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1D37C1C10C; Fri, 11 Sep 2020 17:08:27 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by dpdk.org (Postfix) with ESMTP id 8A3891C10C for ; Fri, 11 Sep 2020 17:08:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599836905; 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=42xg75LdvwfB4xp3yjZImXeStmWYsVaahWrv7Sa1M+M=; b=NWh5cGak7clIMFMEm6SCGrxDCmxr4yjF4e4d4O/jdYo61jmC67QRNewov6VJZN+jjnKWcJ /0Y9OhM6b3RnO84PdIL9oirL4+xFwZ4pZtrx+rPtd8IphjnlbrLqToGM2vdcYXlKIuaGkm pMuWz6R12kmA3TKFlgM+bhMLQmpoNtQ= 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-421-tEm9sx08NLG7VvjH2g6HCQ-1; Fri, 11 Sep 2020 11:08:21 -0400 X-MC-Unique: tEm9sx08NLG7VvjH2g6HCQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C66A8018AB; Fri, 11 Sep 2020 15:08:20 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA9BA1A887; Fri, 11 Sep 2020 15:08:18 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, patrick.fu@intel.com, amorenoz@redhat.com Cc: Maxime Coquelin Date: Fri, 11 Sep 2020 17:08:02 +0200 Message-Id: <20200911150805.79901-5-maxime.coquelin@redhat.com> In-Reply-To: <20200911150805.79901-1-maxime.coquelin@redhat.com> References: <20200911150805.79901-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 4/7] net/virtio: adapt Virtio-user status size 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" Set proper payload size for set/get status message. The payload size varies according to backend types. Signed-off-by: Maxime Coquelin Signed-off-by: Patrick Fu --- .../net/virtio/virtio_user/virtio_user_dev.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 93274b2a94..753611ef42 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -838,14 +838,18 @@ virtio_user_send_status_update(struct virtio_user_dev *dev, uint8_t status) enum virtio_user_backend_type backend_type = virtio_user_backend_type(dev->path); - /* Vhost-user only for now */ - if (backend_type != VIRTIO_USER_BACKEND_VHOST_USER) + if (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_STATUS))) return 0; - if (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_STATUS))) + if (backend_type == VIRTIO_USER_BACKEND_VHOST_USER) + ret = dev->ops->send_request(dev, + VHOST_USER_SET_STATUS, &arg); + else if (backend_type == VIRTIO_USER_BACKEND_VHOST_VDPA) + ret = dev->ops->send_request(dev, + VHOST_USER_SET_STATUS, &status); + else return 0; - ret = dev->ops->send_request(dev, VHOST_USER_SET_STATUS, &arg); if (ret) { PMD_INIT_LOG(ERR, "VHOST_USER_SET_STATUS failed (%d): %s", ret, strerror(errno)); @@ -858,7 +862,7 @@ virtio_user_send_status_update(struct virtio_user_dev *dev, uint8_t status) int virtio_user_update_status(struct virtio_user_dev *dev) { - uint64_t ret; + uint8_t ret; int err; enum virtio_user_backend_type backend_type = virtio_user_backend_type(dev->path); @@ -876,11 +880,6 @@ virtio_user_update_status(struct virtio_user_dev *dev) strerror(errno)); return -1; } - if (ret > UINT8_MAX) { - PMD_INIT_LOG(ERR, "Invalid VHOST_USER_GET_STATUS " - "response 0x%" PRIx64 "\n", ret); - return -1; - } dev->status = ret; PMD_INIT_LOG(DEBUG, "Updated Device Status(0x%08x):\n"