From patchwork Fri Jun 26 14:04:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 72256 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 1AABDA051C; Fri, 26 Jun 2020 16:07:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 231AB1C012; Fri, 26 Jun 2020 16:06:15 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 9BD061BFC8 for ; Fri, 26 Jun 2020 16:06:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593180373; 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=rttQfusn8y+xGsbGYmyauBK8b2vPiV2DUSYOD66iOvc=; b=TV0kUChLzlAXG+ghEjpqRKR2xyNISj7BM3TdA+zvfQb0Kmr2Z9ksUZHJwX8UsUKsZT56LO KHUdCk0QGiVNmjkVa+Qd9PErnO4q65VkP36sByPR5WJ0tp5agn7OmymO2ixvFIjlzpR7i3 QZWs83R+sZdJZC1zCDfbXx7h1T0uqaM= 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-484-UcTTBxETN--GLwhw95R_iw-1; Fri, 26 Jun 2020 10:06:10 -0400 X-MC-Unique: UcTTBxETN--GLwhw95R_iw-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 8F5A6804003; Fri, 26 Jun 2020 14:06:08 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id F23D45BAE1; Fri, 26 Jun 2020 14:05:57 +0000 (UTC) From: Maxime Coquelin To: matan@mellanox.com, xiao.w.wang@intel.com, zhihong.wang@intel.com, chenbo.xia@intel.com, david.marchand@redhat.com, amorenoz@redhat.com, viacheslavo@mellanox.com, hemant.agrawal@nxp.com, sachin.saxena@nxp.com, grive@u256.net, dev@dpdk.org Cc: Maxime Coquelin Date: Fri, 26 Jun 2020 16:04:37 +0200 Message-Id: <20200626140441.1441763-11-maxime.coquelin@redhat.com> In-Reply-To: <20200626140441.1441763-1-maxime.coquelin@redhat.com> References: <20200626140441.1441763-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH v3 10/14] vhost: introduce wrappers for some vDPA ops 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" This patch is preliminary work to make the vDPA device structure opaque to the user application. Some callbacks of the vDPA devices are used to query capabilities before attaching to a Vhost port. This patch introduces wrappers for these ops. Acked-by: Adrián Moreno Signed-off-by: Maxime Coquelin --- lib/librte_vhost/rte_vdpa.h | 72 ++++++++++++++++++++++++++ lib/librte_vhost/rte_vhost_version.map | 3 ++ lib/librte_vhost/vdpa.c | 28 ++++++++++ 3 files changed, 103 insertions(+) diff --git a/lib/librte_vhost/rte_vdpa.h b/lib/librte_vhost/rte_vdpa.h index dbdc273702..eda56dd556 100644 --- a/lib/librte_vhost/rte_vdpa.h +++ b/lib/librte_vhost/rte_vdpa.h @@ -226,6 +226,78 @@ __rte_experimental int rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Get number of queue pairs supported by the vDPA device + * + * @param dev + * vDP device pointer + * @param queue_num + * pointer on where the number of queue is stored + * @return + * 0 on success, -1 on failure + */ +__rte_experimental +int +rte_vdpa_get_queue_num(struct rte_vdpa_device *dev, uint32_t *queue_num); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Get the Virtio features supported by the vDPA device + * + * @param dev + * vDP device pointer + * @param features + * pointer on where the supported features are stored + * @return + * 0 on success, -1 on failure + */ +__rte_experimental +int +rte_vdpa_get_features(struct rte_vdpa_device *dev, uint64_t *features); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Get the Vhost-user protocol features supported by the vDPA device + * + * @param dev + * vDP device pointer + * @param features + * pointer on where the supported protocol features are stored + * @return + * 0 on success, -1 on failure + */ +__rte_experimental +int +rte_vdpa_get_protocol_features(struct rte_vdpa_device *dev, uint64_t *features); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Synchronize the used ring from mediated ring to guest, log dirty + * page for each writeable buffer, caller should handle the used + * ring logging before device stop. + * + * @param vid + * vhost device id + * @param qid + * vhost queue id + * @param vring_m + * mediated virtio ring pointer + * @return + * number of synced used entries on success, -1 on failure + */ +__rte_experimental +int +rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m); + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map index d9124d0462..7a919102cf 100644 --- a/lib/librte_vhost/rte_vhost_version.map +++ b/lib/librte_vhost/rte_vhost_version.map @@ -70,4 +70,7 @@ EXPERIMENTAL { rte_vhost_slave_config_change; rte_vdpa_find_device_by_name; rte_vdpa_get_rte_device; + rte_vdpa_get_queue_num; + rte_vdpa_get_features; + rte_vdpa_get_protocol_features; }; diff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c index 72561552c3..8810bf3b36 100644 --- a/lib/librte_vhost/vdpa.c +++ b/lib/librte_vhost/vdpa.c @@ -229,6 +229,34 @@ rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m) return -1; } +int +rte_vdpa_get_queue_num(struct rte_vdpa_device *dev, uint32_t *queue_num) +{ + if (dev == NULL || dev->ops == NULL || dev->ops->get_queue_num == NULL) + return -1; + + return dev->ops->get_queue_num(dev, queue_num); +} + +int +rte_vdpa_get_features(struct rte_vdpa_device *dev, uint64_t *features) +{ + if (dev == NULL || dev->ops == NULL || dev->ops->get_features == NULL) + return -1; + + return dev->ops->get_features(dev, features); +} + +int +rte_vdpa_get_protocol_features(struct rte_vdpa_device *dev, uint64_t *features) +{ + if (dev == NULL || dev->ops == NULL || + dev->ops->get_protocol_features == NULL) + return -1; + + return dev->ops->get_protocol_features(dev, features); +} + int rte_vdpa_get_stats_names(struct rte_vdpa_device *dev, struct rte_vdpa_stat_name *stats_names,