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 A32B7A0350; Mon, 29 Jun 2020 16:08:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 799F81BF6F; Mon, 29 Jun 2020 16:08:38 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id ED6FF1BF6C for ; Mon, 29 Jun 2020 16:08:36 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from matan@mellanox.com) with SMTP; 29 Jun 2020 17:08:34 +0300 Received: from pegasus25.mtr.labs.mlnx. (pegasus25.mtr.labs.mlnx [10.210.16.10]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 05TE8RgO029797; Mon, 29 Jun 2020 17:08:34 +0300 From: Matan Azrad To: Maxime Coquelin Cc: dev@dpdk.org, Xiao Wang Date: Mon, 29 Jun 2020 14:08:16 +0000 Message-Id: <1593439701-136089-2-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1593439701-136089-1-git-send-email-matan@mellanox.com> References: <1593092298-52257-1-git-send-email-matan@mellanox.com> <1593439701-136089-1-git-send-email-matan@mellanox.com> Subject: [dpdk-dev] [PATCH v3 1/6] vhost: support host notifier queue configuration 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" As an arrangement to per queue operations in the vDPA device it is needed to change the next experimental API: The API ``rte_vhost_host_notifier_ctrl`` was changed to be per queue instead of per device. A `qid` parameter was added to the API arguments list. Setting the parameter to the value RTE_VHOST_QUEUE_ALL configures the host notifier to all the device queues as done before this patch. Signed-off-by: Matan Azrad Reviewed-by: Maxime Coquelin --- doc/guides/rel_notes/release_20_08.rst | 3 +++ drivers/vdpa/ifc/ifcvf_vdpa.c | 6 +++--- drivers/vdpa/mlx5/mlx5_vdpa.c | 6 ++++-- lib/librte_vhost/rte_vdpa.h | 8 ++++++-- lib/librte_vhost/rte_vhost.h | 1 - lib/librte_vhost/vhost_user.c | 18 ++++++++++++++---- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/doc/guides/rel_notes/release_20_08.rst b/doc/guides/rel_notes/release_20_08.rst index 44383b8..2d5a3f7 100644 --- a/doc/guides/rel_notes/release_20_08.rst +++ b/doc/guides/rel_notes/release_20_08.rst @@ -125,6 +125,9 @@ API Changes * ``rte_page_sizes`` enumeration is replaced with ``RTE_PGSIZE_xxx`` defines. +* vhost: The API of ``rte_vhost_host_notifier_ctrl`` was changed to be per + queue and not per device, a qid parameter was added to the arguments list. + ABI Changes ----------- diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c index ec97178..6a2fed3 100644 --- a/drivers/vdpa/ifc/ifcvf_vdpa.c +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c @@ -839,7 +839,7 @@ struct internal_list { vdpa_ifcvf_stop(internal); vdpa_disable_vfio_intr(internal); - ret = rte_vhost_host_notifier_ctrl(vid, false); + ret = rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, false); if (ret && ret != -ENOTSUP) goto error; @@ -858,7 +858,7 @@ struct internal_list { if (ret) goto stop_vf; - rte_vhost_host_notifier_ctrl(vid, true); + rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, true); internal->sw_fallback_running = true; @@ -893,7 +893,7 @@ struct internal_list { rte_atomic32_set(&internal->dev_attached, 1); update_datapath(internal); - if (rte_vhost_host_notifier_ctrl(vid, true) != 0) + if (rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, true) != 0) DRV_LOG(NOTICE, "vDPA (%d): software relay is used.", did); return 0; diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index 159653f..97f87c5 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -146,7 +146,8 @@ int ret; if (priv->direct_notifier) { - ret = rte_vhost_host_notifier_ctrl(priv->vid, false); + ret = rte_vhost_host_notifier_ctrl(priv->vid, + RTE_VHOST_QUEUE_ALL, false); if (ret != 0) { DRV_LOG(INFO, "Direct HW notifier FD cannot be " "destroyed for device %d: %d.", priv->vid, ret); @@ -154,7 +155,8 @@ } priv->direct_notifier = 0; } - ret = rte_vhost_host_notifier_ctrl(priv->vid, true); + ret = rte_vhost_host_notifier_ctrl(priv->vid, RTE_VHOST_QUEUE_ALL, + true); if (ret != 0) DRV_LOG(INFO, "Direct HW notifier FD cannot be configured for" " device %d: %d.", priv->vid, ret); diff --git a/lib/librte_vhost/rte_vdpa.h b/lib/librte_vhost/rte_vdpa.h index ecb3d91..fd42085 100644 --- a/lib/librte_vhost/rte_vdpa.h +++ b/lib/librte_vhost/rte_vdpa.h @@ -202,22 +202,26 @@ struct rte_vdpa_device * int rte_vdpa_get_device_num(void); +#define RTE_VHOST_QUEUE_ALL UINT16_MAX + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice * - * Enable/Disable host notifier mapping for a vdpa port. + * Enable/Disable host notifier mapping for a vdpa queue. * * @param vid * vhost device id * @param enable * true for host notifier map, false for host notifier unmap + * @param qid + * vhost queue id, RTE_VHOST_QUEUE_ALL to configure all the device queues * @return * 0 on success, -1 on failure */ __rte_experimental int -rte_vhost_host_notifier_ctrl(int vid, bool enable); +rte_vhost_host_notifier_ctrl(int vid, uint16_t qid, bool enable); /** * @warning diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h index 329ed8a..1ac7eaf 100644 --- a/lib/librte_vhost/rte_vhost.h +++ b/lib/librte_vhost/rte_vhost.h @@ -107,7 +107,6 @@ #define VHOST_USER_F_PROTOCOL_FEATURES 30 #endif - /** * Information relating to memory regions including offsets to * addresses in QEMUs memory file. diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index ea9cd10..4e1af91 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -2951,13 +2951,13 @@ static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev, return process_slave_message_reply(dev, &msg); } -int rte_vhost_host_notifier_ctrl(int vid, bool enable) +int rte_vhost_host_notifier_ctrl(int vid, uint16_t qid, bool enable) { struct virtio_net *dev; struct rte_vdpa_device *vdpa_dev; int vfio_device_fd, did, ret = 0; uint64_t offset, size; - unsigned int i; + unsigned int i, q_start, q_last; dev = get_device(vid); if (!dev) @@ -2981,6 +2981,16 @@ int rte_vhost_host_notifier_ctrl(int vid, bool enable) if (!vdpa_dev) return -ENODEV; + if (qid == RTE_VHOST_QUEUE_ALL) { + q_start = 0; + q_last = dev->nr_vring - 1; + } else { + if (qid >= dev->nr_vring) + return -EINVAL; + q_start = qid; + q_last = qid; + } + RTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->get_vfio_device_fd, -ENOTSUP); RTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->get_notify_area, -ENOTSUP); @@ -2989,7 +2999,7 @@ int rte_vhost_host_notifier_ctrl(int vid, bool enable) return -ENOTSUP; if (enable) { - for (i = 0; i < dev->nr_vring; i++) { + for (i = q_start; i <= q_last; i++) { if (vdpa_dev->ops->get_notify_area(vid, i, &offset, &size) < 0) { ret = -ENOTSUP; @@ -3004,7 +3014,7 @@ int rte_vhost_host_notifier_ctrl(int vid, bool enable) } } else { disable: - for (i = 0; i < dev->nr_vring; i++) { + for (i = q_start; i <= q_last; i++) { vhost_user_slave_set_vring_host_notifier(dev, i, -1, 0, 0); } -- 1.8.3.1