src/dpdk/drivers/net/mlx5/mlx5_rxq.c
int
mlx5_rx_intr_vec_enable(struct rte_eth_dev *dev)
{
	struct mlx5_priv *priv = dev->data->dev_private;
	unsigned int i;
	unsigned int rxqs_n = priv->rxqs_n;
	unsigned int n = RTE_MIN(rxqs_n, (uint32_t)RTE_MAX_RXTX_INTR_VEC_ID);
	unsigned int count = 0;
	struct rte_intr_handle *intr_handle = dev->intr_handle;

	/* Representor shares dev->intr_handle with PF. */
	if (priv->representor)
		return 0;
	if (!dev->data->dev_conf.intr_conf.rxq)
		return 0;
	mlx5_rx_intr_vec_disable(dev);
	intr_handle->intr_vec = mlx5_malloc(0,
				n * sizeof(intr_handle->intr_vec[0]),
				0, SOCKET_ID_ANY);
	if (intr_handle->intr_vec == NULL) {
		DRV_LOG(ERR,
			"port %u failed to allocate memory for interrupt"
			" vector, Rx interrupts will not be supported",
			dev->data->port_id);
		rte_errno = ENOMEM;
		return -rte_errno;
	}
	intr_handle->type = RTE_INTR_HANDLE_EXT;
	for (i = 0; i != n; ++i) {
		/* This rxq obj must not be released in this function. */
		struct mlx5_rxq_ctrl *rxq_ctrl = mlx5_rxq_get(dev, i);
		struct mlx5_rxq_obj *rxq_obj = rxq_ctrl ? rxq_ctrl->obj : NULL;
		int rc;

		/* Skip queues that cannot request interrupts. */
		if (!rxq_obj || (!rxq_obj->ibv_channel &&
				 !rxq_obj->devx_channel)) {
			/* Use invalid intr_vec[] index to disable entry. */
			intr_handle->intr_vec[i] =
				RTE_INTR_VEC_RXTX_OFFSET +
				RTE_MAX_RXTX_INTR_VEC_ID;
			/* Decrease the rxq_ctrl's refcnt */
			if (rxq_ctrl)
				mlx5_rxq_release(dev, i);
			continue;
		}
		if (count >= RTE_MAX_RXTX_INTR_VEC_ID) {
			DRV_LOG(ERR,
				"port %u too many Rx queues for interrupt"
				" vector size (%d), Rx interrupts cannot be"
				" enabled",
				dev->data->port_id, RTE_MAX_RXTX_INTR_VEC_ID);
			mlx5_rx_intr_vec_disable(dev);
			rte_errno = ENOMEM;
			return -rte_errno;
		}
		rc = mlx5_os_set_nonblock_channel_fd(rxq_obj->fd);
		if (rc < 0) {
			rte_errno = errno;
			DRV_LOG(ERR,
				"port %u failed to make Rx interrupt file"
				" descriptor %d non-blocking for queue index"
				" %d",
				dev->data->port_id, rxq_obj->fd, i);
			mlx5_rx_intr_vec_disable(dev);
			return -rte_errno;
		}
		intr_handle->intr_vec[i] = RTE_INTR_VEC_RXTX_OFFSET + count;
		intr_handle->efds[count] = rxq_obj->fd;
		count++;
	}
	if (!count)
		mlx5_rx_intr_vec_disable(dev);
	else
		intr_handle->nb_efd = count;
	return 0;
}
/**
 * Allocate queue vector and fill epoll fd list for Rx interrupts.
 *
 * @param dev
 *   Pointer to Ethernet device.
 *
 * @return
 *   0 on success, a negative errno value otherwise and rte_errno is set.
 */
Allocate queue vector and fill epoll fd list for Rx interrupts.
@param dev
Pointer to Ethernet device.

@return
0 on success, a negative errno value otherwise and rte_errno is set.
Allocate queue vector and fill epoll fd list for Rx interrupts . @param dev Pointer to Ethernet device . @return 0 on success a negative errno value otherwise and rte_errno is set .
int
mlx5_rx_intr_vec_enable(struct rte_eth_dev *dev)
{
	struct mlx5_priv *priv = dev->data->dev_private;
	unsigned int i;
	unsigned int rxqs_n = priv->rxqs_n;
	unsigned int n = RTE_MIN(rxqs_n, (uint32_t)RTE_MAX_RXTX_INTR_VEC_ID);
	unsigned int count = 0;
	struct rte_intr_handle *intr_handle = dev->intr_handle;
	if (priv->representor)
		return 0;
	if (!dev->data->dev_conf.intr_conf.rxq)
		return 0;
	mlx5_rx_intr_vec_disable(dev);
	intr_handle->intr_vec = mlx5_malloc(0,
				n * sizeof(intr_handle->intr_vec[0]),
				0, SOCKET_ID_ANY);
	if (intr_handle->intr_vec == NULL) {
		DRV_LOG(ERR,
			"port %u failed to allocate memory for interrupt"
			" vector, Rx interrupts will not be supported",
			dev->data->port_id);
		rte_errno = ENOMEM;
		return -rte_errno;
	}
	intr_handle->type = RTE_INTR_HANDLE_EXT;
	for (i = 0; i != n; ++i) {
		struct mlx5_rxq_ctrl *rxq_ctrl = mlx5_rxq_get(dev, i);
		struct mlx5_rxq_obj *rxq_obj = rxq_ctrl ? rxq_ctrl->obj : NULL;
		int rc;
		if (!rxq_obj || (!rxq_obj->ibv_channel &&
				 !rxq_obj->devx_channel)) {
			intr_handle->intr_vec[i] =
				RTE_INTR_VEC_RXTX_OFFSET +
				RTE_MAX_RXTX_INTR_VEC_ID;
			if (rxq_ctrl)
				mlx5_rxq_release(dev, i);
			continue;
		}
		if (count >= RTE_MAX_RXTX_INTR_VEC_ID) {
			DRV_LOG(ERR,
				"port %u too many Rx queues for interrupt"
				" vector size (%d), Rx interrupts cannot be"
				" enabled",
				dev->data->port_id, RTE_MAX_RXTX_INTR_VEC_ID);
			mlx5_rx_intr_vec_disable(dev);
			rte_errno = ENOMEM;
			return -rte_errno;
		}
		rc = mlx5_os_set_nonblock_channel_fd(rxq_obj->fd);
		if (rc < 0) {
			rte_errno = errno;
			DRV_LOG(ERR,
				"port %u failed to make Rx interrupt file"
				" descriptor %d non-blocking for queue index"
				" %d",
				dev->data->port_id, rxq_obj->fd, i);
			mlx5_rx_intr_vec_disable(dev);
			return -rte_errno;
		}
		intr_handle->intr_vec[i] = RTE_INTR_VEC_RXTX_OFFSET + count;
		intr_handle->efds[count] = rxq_obj->fd;
		count++;
	}
	if (!count)
		mlx5_rx_intr_vec_disable(dev);
	else
		intr_handle->nb_efd = count;
	return 0;
}
int mlx5_rx_intr_vec_enable ( struct rte_eth_dev * dev ) { struct mlx5_priv * priv = dev -> data -> dev_private ; unsigned int i ; unsigned int rxqs_n = priv -> rxqs_n ; unsigned int n = RTE_MIN ( rxqs_n , ( uint32_t ) RTE_MAX_RXTX_INTR_VEC_ID ) ; unsigned int count = 0 ; struct rte_intr_handle * intr_handle = dev -> intr_handle ; if ( priv -> representor ) return 0 ; if ( ! dev -> data -> dev_conf . intr_conf . rxq ) return 0 ; mlx5_rx_intr_vec_disable ( dev ) ; intr_handle -> intr_vec = mlx5_malloc ( 0 , n * sizeof ( intr_handle -> intr_vec [ 0 ] ) , 0 , SOCKET_ID_ANY ) ; if ( intr_handle -> intr_vec == NULL ) { DRV_LOG ( ERR , " " " " , dev -> data -> port_id ) ; rte_errno = ENOMEM ; return - rte_errno ; } intr_handle -> type = RTE_INTR_HANDLE_EXT ; for ( i = 0 ; i != n ; ++ i ) { struct mlx5_rxq_ctrl * rxq_ctrl = mlx5_rxq_get ( dev , i ) ; struct mlx5_rxq_obj * rxq_obj = rxq_ctrl ? rxq_ctrl -> obj : NULL ; int rc ; if ( ! rxq_obj || ( ! rxq_obj -> ibv_channel && ! rxq_obj -> devx_channel ) ) { intr_handle -> intr_vec [ i ] = RTE_INTR_VEC_RXTX_OFFSET + RTE_MAX_RXTX_INTR_VEC_ID ; if ( rxq_ctrl ) mlx5_rxq_release ( dev , i ) ; continue ; } if ( count >= RTE_MAX_RXTX_INTR_VEC_ID ) { DRV_LOG ( ERR , " " " " " " , dev -> data -> port_id , RTE_MAX_RXTX_INTR_VEC_ID ) ; mlx5_rx_intr_vec_disable ( dev ) ; rte_errno = ENOMEM ; return - rte_errno ; } rc = mlx5_os_set_nonblock_channel_fd ( rxq_obj -> fd ) ; if ( rc < 0 ) { rte_errno = errno ; DRV_LOG ( ERR , " " " " " " , dev -> data -> port_id , rxq_obj -> fd , i ) ; mlx5_rx_intr_vec_disable ( dev ) ; return - rte_errno ; } intr_handle -> intr_vec [ i ] = RTE_INTR_VEC_RXTX_OFFSET + count ; intr_handle -> efds [ count ] = rxq_obj -> fd ; count ++ ; } if ( ! count ) mlx5_rx_intr_vec_disable ( dev ) ; else intr_handle -> nb_efd = count ; return 0 ; }
Allocate queue vector and fill epoll fd list for Rx interrupts.
Allocate queue vector and fill epoll fd list for Rx interrupts .
/* Representor shares dev->intr_handle with PF. */ /* This rxq obj must not be released in this function. */ /* Skip queues that cannot request interrupts. */ /* Use invalid intr_vec[] index to disable entry. */ /* Decrease the rxq_ctrl's refcnt */