vhost: support host notifier queue configuration
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 <matan@mellanox.com> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
This commit is contained in:
parent
edc6391e45
commit
0329868d6a
@ -140,6 +140,9 @@ API Changes
|
|||||||
|
|
||||||
* ``rte_page_sizes`` enumeration is replaced with ``RTE_PGSIZE_xxx`` defines.
|
* ``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
|
ABI Changes
|
||||||
-----------
|
-----------
|
||||||
|
@ -840,7 +840,7 @@ ifcvf_sw_fallback_switchover(struct ifcvf_internal *internal)
|
|||||||
vdpa_ifcvf_stop(internal);
|
vdpa_ifcvf_stop(internal);
|
||||||
vdpa_disable_vfio_intr(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)
|
if (ret && ret != -ENOTSUP)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -859,7 +859,7 @@ ifcvf_sw_fallback_switchover(struct ifcvf_internal *internal)
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto stop_vf;
|
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;
|
internal->sw_fallback_running = true;
|
||||||
|
|
||||||
@ -894,7 +894,7 @@ ifcvf_dev_config(int vid)
|
|||||||
rte_atomic32_set(&internal->dev_attached, 1);
|
rte_atomic32_set(&internal->dev_attached, 1);
|
||||||
update_datapath(internal);
|
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 (%s): software relay is used.",
|
DRV_LOG(NOTICE, "vDPA (%s): software relay is used.",
|
||||||
vdev->device->name);
|
vdev->device->name);
|
||||||
|
|
||||||
|
@ -151,7 +151,8 @@ mlx5_vdpa_direct_db_prepare(struct mlx5_vdpa_priv *priv)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (priv->direct_notifier) {
|
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) {
|
if (ret != 0) {
|
||||||
DRV_LOG(INFO, "Direct HW notifier FD cannot be "
|
DRV_LOG(INFO, "Direct HW notifier FD cannot be "
|
||||||
"destroyed for device %d: %d.", priv->vid, ret);
|
"destroyed for device %d: %d.", priv->vid, ret);
|
||||||
@ -159,7 +160,8 @@ mlx5_vdpa_direct_db_prepare(struct mlx5_vdpa_priv *priv)
|
|||||||
}
|
}
|
||||||
priv->direct_notifier = 0;
|
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)
|
if (ret != 0)
|
||||||
DRV_LOG(INFO, "Direct HW notifier FD cannot be configured for"
|
DRV_LOG(INFO, "Direct HW notifier FD cannot be configured for"
|
||||||
" device %d: %d.", priv->vid, ret);
|
" device %d: %d.", priv->vid, ret);
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#include "rte_vhost.h"
|
#include "rte_vhost.h"
|
||||||
|
|
||||||
|
#define RTE_VHOST_QUEUE_ALL UINT16_MAX
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vdpa device operations
|
* vdpa device operations
|
||||||
*/
|
*/
|
||||||
@ -116,12 +118,14 @@ rte_vdpa_unregister_device(struct rte_vdpa_device *dev);
|
|||||||
* vhost device id
|
* vhost device id
|
||||||
* @param enable
|
* @param enable
|
||||||
* true for host notifier map, false for host notifier unmap
|
* 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
|
* @return
|
||||||
* 0 on success, -1 on failure
|
* 0 on success, -1 on failure
|
||||||
*/
|
*/
|
||||||
__rte_experimental
|
__rte_experimental
|
||||||
int
|
int
|
||||||
rte_vhost_host_notifier_ctrl(int vid, bool enable);
|
rte_vhost_host_notifier_ctrl(int vid, uint16_t qid, bool enable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @warning
|
* @warning
|
||||||
|
@ -2943,13 +2943,13 @@ static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
|
|||||||
return process_slave_message_reply(dev, &msg);
|
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 virtio_net *dev;
|
||||||
struct rte_vdpa_device *vdpa_dev;
|
struct rte_vdpa_device *vdpa_dev;
|
||||||
int vfio_device_fd, ret = 0;
|
int vfio_device_fd, ret = 0;
|
||||||
uint64_t offset, size;
|
uint64_t offset, size;
|
||||||
unsigned int i;
|
unsigned int i, q_start, q_last;
|
||||||
|
|
||||||
dev = get_device(vid);
|
dev = get_device(vid);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
@ -2969,6 +2969,16 @@ int rte_vhost_host_notifier_ctrl(int vid, bool enable)
|
|||||||
(1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER)))
|
(1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER)))
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
|
||||||
|
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_vfio_device_fd, -ENOTSUP);
|
||||||
RTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->get_notify_area, -ENOTSUP);
|
RTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->get_notify_area, -ENOTSUP);
|
||||||
|
|
||||||
@ -2977,7 +2987,7 @@ int rte_vhost_host_notifier_ctrl(int vid, bool enable)
|
|||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
|
||||||
if (enable) {
|
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,
|
if (vdpa_dev->ops->get_notify_area(vid, i, &offset,
|
||||||
&size) < 0) {
|
&size) < 0) {
|
||||||
ret = -ENOTSUP;
|
ret = -ENOTSUP;
|
||||||
@ -2992,7 +3002,7 @@ int rte_vhost_host_notifier_ctrl(int vid, bool enable)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
disable:
|
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,
|
vhost_user_slave_set_vring_host_notifier(dev, i, -1,
|
||||||
0, 0);
|
0, 0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user