#include <unistd.h>
#include <stdint.h>
#include <fcntl.h>
+#include <sys/eventfd.h>
#include <rte_malloc.h>
#include <rte_errno.h>
rte_errno = errno;
goto error;
}
- /* Subscribe CQ event to the guest FD only if it is not in poll mode. */
- if (callfd != -1) {
- ret = mlx5_glue->devx_subscribe_devx_event_fd(priv->eventc,
- callfd,
- cq->cq->obj, 0);
- if (ret) {
- DRV_LOG(ERR, "Failed to subscribe CQE event fd.");
- rte_errno = errno;
- goto error;
- }
- }
+ cq->callfd = callfd;
+ /* Init CQ to ones to be in HW owner in the start. */
+ memset((void *)(uintptr_t)cq->umem_buf, 0xFF, attr.db_umem_offset);
/* First arming. */
mlx5_vdpa_cq_arm(priv, cq);
return 0;
rte_spinlock_lock(&cq->sl);
mlx5_vdpa_cq_poll(priv, cq);
mlx5_vdpa_cq_arm(priv, cq);
+ if (cq->callfd != -1)
+ /* Notify guest for descriptors consuming. */
+ eventfd_write(cq->callfd, (eventfd_t)1);
rte_spinlock_unlock(&cq->sl);
DRV_LOG(DEBUG, "CQ %d event: new cq_ci = %u.", cq->cq->id,
cq->cq_ci);
int
mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
{
- int flags = fcntl(priv->eventc->fd, F_GETFL);
- int ret = fcntl(priv->eventc->fd, F_SETFL, flags | O_NONBLOCK);
+ int flags;
+ int ret;
+
+ if (!priv->eventc)
+ /* All virtqs are in poll mode. */
+ return 0;
+ flags = fcntl(priv->eventc->fd, F_GETFL);
+ ret = fcntl(priv->eventc->fd, F_SETFL, flags | O_NONBLOCK);
if (ret) {
DRV_LOG(ERR, "Failed to change event channel FD.");
rte_errno = errno;