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 06661A00BE; Thu, 11 Jun 2020 23:39:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 15F534C99; Thu, 11 Jun 2020 23:38:53 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 5975137B0 for ; Thu, 11 Jun 2020 23:38:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591911530; 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=HNvVAtXvZ7zGQAUxsiwuuX3fjyRwMi8qkRZ6BXENVQs=; b=hMccstTadFGp7IQCmm7vHFpwn/8xOb/qNWgHPgQNMtqgo5Scl+8F3/7obzteW2mQMSvhVo cbXsRthKWSb254G+K7uNLQHTvdzSf+3/7kaPPThjIsh9QQFVx9G1np/cm3VAl9Ehtyaeqj 8ttWLdOHPZgm7C6OkXrHIXqBuvJmTtk= 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-24-Ncs25AVUPze1ugvF9kgk_g-1; Thu, 11 Jun 2020 17:38:49 -0400 X-MC-Unique: Ncs25AVUPze1ugvF9kgk_g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A6E5E107ACCA; Thu, 11 Jun 2020 21:38:47 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47357100238D; Thu, 11 Jun 2020 21:38:44 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, matan@mellanox.com, xiao.w.wang@intel.com, zhihong.wang@intel.com, xiaolong.ye@intel.com, chenbo.xia@intel.com, david.marchand@redhat.com, amorenoz@redhat.com, shreyansh.jain@nxp.com, viacheslavo@mellanox.com, hemant.agrawal@nxp.com, sachin.saxena@nxp.com Cc: Maxime Coquelin Date: Thu, 11 Jun 2020 23:37:44 +0200 Message-Id: <20200611213748.1967029-11-maxime.coquelin@redhat.com> In-Reply-To: <20200611213748.1967029-1-maxime.coquelin@redhat.com> References: <20200611213748.1967029-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 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. Signed-off-by: Maxime Coquelin --- lib/librte_vhost/rte_vdpa.h | 52 ++++++++++++++++++++++++++ lib/librte_vhost/rte_vhost_version.map | 3 ++ lib/librte_vhost/vdpa.c | 28 ++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/lib/librte_vhost/rte_vdpa.h b/lib/librte_vhost/rte_vdpa.h index 011befdc71..e830014d5a 100644 --- a/lib/librte_vhost/rte_vdpa.h +++ b/lib/librte_vhost/rte_vdpa.h @@ -185,4 +185,56 @@ rte_vhost_host_notifier_ctrl(int vid, bool enable); __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); + #endif /* _RTE_VDPA_H_ */ diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map index 27d63ce6fe..6c74a3ec4f 100644 --- a/lib/librte_vhost/rte_vhost_version.map +++ b/lib/librte_vhost/rte_vhost_version.map @@ -67,4 +67,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 8f4778e2fa..f00544b3ea 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); +} + static int vdpa_dev_match(struct rte_vdpa_device *dev, const struct rte_device *rte_dev) -- 2.26.2