src/dpdk/drivers/net/mlx5/mlx5_trigger.c
int
mlx5_hairpin_queue_peer_unbind(struct rte_eth_dev *dev, uint16_t cur_queue,
			       uint32_t direction)
{
	int ret = 0;

	if (direction != 0) {
		struct mlx5_txq_ctrl *txq_ctrl;
		struct mlx5_devx_modify_sq_attr sq_attr = { 0 };

		txq_ctrl = mlx5_txq_get(dev, cur_queue);
		if (txq_ctrl == NULL) {
			rte_errno = EINVAL;
			DRV_LOG(ERR, "Failed to get port %u Tx queue %d",
				dev->data->port_id, cur_queue);
			return -rte_errno;
		}
		if (txq_ctrl->type != MLX5_TXQ_TYPE_HAIRPIN) {
			rte_errno = EINVAL;
			DRV_LOG(ERR, "port %u queue %d not a hairpin Txq",
				dev->data->port_id, cur_queue);
			mlx5_txq_release(dev, cur_queue);
			return -rte_errno;
		}
		/* Already unbound, return success before obj checking. */
		if (txq_ctrl->hairpin_status == 0) {
			DRV_LOG(DEBUG, "port %u Tx queue %d is already unbound",
				dev->data->port_id, cur_queue);
			mlx5_txq_release(dev, cur_queue);
			return 0;
		}
		if (!txq_ctrl->obj || !txq_ctrl->obj->sq) {
			rte_errno = ENOMEM;
			DRV_LOG(ERR, "port %u no Txq object found: %d",
				dev->data->port_id, cur_queue);
			mlx5_txq_release(dev, cur_queue);
			return -rte_errno;
		}
		sq_attr.state = MLX5_SQC_STATE_RST;
		sq_attr.sq_state = MLX5_SQC_STATE_RST;
		ret = mlx5_devx_cmd_modify_sq(txq_ctrl->obj->sq, &sq_attr);
		if (ret == 0)
			txq_ctrl->hairpin_status = 0;
		mlx5_txq_release(dev, cur_queue);
	} else {
		struct mlx5_rxq_ctrl *rxq_ctrl;
		struct mlx5_devx_modify_rq_attr rq_attr = { 0 };

		rxq_ctrl = mlx5_rxq_get(dev, cur_queue);
		if (rxq_ctrl == NULL) {
			rte_errno = EINVAL;
			DRV_LOG(ERR, "Failed to get port %u Rx queue %d",
				dev->data->port_id, cur_queue);
			return -rte_errno;
		}
		if (rxq_ctrl->type != MLX5_RXQ_TYPE_HAIRPIN) {
			rte_errno = EINVAL;
			DRV_LOG(ERR, "port %u queue %d not a hairpin Rxq",
				dev->data->port_id, cur_queue);
			mlx5_rxq_release(dev, cur_queue);
			return -rte_errno;
		}
		if (rxq_ctrl->hairpin_status == 0) {
			DRV_LOG(DEBUG, "port %u Rx queue %d is already unbound",
				dev->data->port_id, cur_queue);
			mlx5_rxq_release(dev, cur_queue);
			return 0;
		}
		if (rxq_ctrl->obj == NULL || rxq_ctrl->obj->rq == NULL) {
			rte_errno = ENOMEM;
			DRV_LOG(ERR, "port %u no Rxq object found: %d",
				dev->data->port_id, cur_queue);
			mlx5_rxq_release(dev, cur_queue);
			return -rte_errno;
		}
		rq_attr.state = MLX5_SQC_STATE_RST;
		rq_attr.rq_state = MLX5_SQC_STATE_RST;
		ret = mlx5_devx_cmd_modify_rq(rxq_ctrl->obj->rq, &rq_attr);
		if (ret == 0)
			rxq_ctrl->hairpin_status = 0;
		mlx5_rxq_release(dev, cur_queue);
	}
	return ret;
}
/*
 * Unbind the hairpin queue and reset its HW configuration.
 * This needs to be called twice both for Tx and Rx queues of a pair.
 * If the queue is already unbound, it is considered successful.
 *
 * @param dev
 *   Pointer to Ethernet device structure.
 * @param cur_queue
 *   Index of the queue to change the HW configuration to unbind.
 * @param direction
 *   Positive to reset the TxQ, zero to reset the RxQ.
 *
 * @return
 *   0 on success, a negative errno value otherwise and rte_errno is set.
 */
Unbind the hairpin queue and reset its HW configuration.
This needs to be called twice both for Tx and Rx queues of a pair.
If the queue is already unbound, it is considered successful.

@param dev
Pointer to Ethernet device structure.
@param cur_queue
Index of the queue to change the HW configuration to unbind.
@param direction
Positive to reset the TxQ, zero to reset the RxQ.

@return
0 on success, a negative errno value otherwise and rte_errno is set.
Unbind the hairpin queue and reset its HW configuration . This needs to be called twice both for Tx and Rx queues of a pair . If the queue is already unbound it is considered successful . @param dev Pointer to Ethernet device structure . @param cur_queue Index of the queue to change the HW configuration to unbind . @param direction Positive to reset the TxQ zero to reset the RxQ . @return 0 on success a negative errno value otherwise and rte_errno is set .
int
mlx5_hairpin_queue_peer_unbind(struct rte_eth_dev *dev, uint16_t cur_queue,
			       uint32_t direction)
{
	int ret = 0;
	if (direction != 0) {
		struct mlx5_txq_ctrl *txq_ctrl;
		struct mlx5_devx_modify_sq_attr sq_attr = { 0 };
		txq_ctrl = mlx5_txq_get(dev, cur_queue);
		if (txq_ctrl == NULL) {
			rte_errno = EINVAL;
			DRV_LOG(ERR, "Failed to get port %u Tx queue %d",
				dev->data->port_id, cur_queue);
			return -rte_errno;
		}
		if (txq_ctrl->type != MLX5_TXQ_TYPE_HAIRPIN) {
			rte_errno = EINVAL;
			DRV_LOG(ERR, "port %u queue %d not a hairpin Txq",
				dev->data->port_id, cur_queue);
			mlx5_txq_release(dev, cur_queue);
			return -rte_errno;
		}
		if (txq_ctrl->hairpin_status == 0) {
			DRV_LOG(DEBUG, "port %u Tx queue %d is already unbound",
				dev->data->port_id, cur_queue);
			mlx5_txq_release(dev, cur_queue);
			return 0;
		}
		if (!txq_ctrl->obj || !txq_ctrl->obj->sq) {
			rte_errno = ENOMEM;
			DRV_LOG(ERR, "port %u no Txq object found: %d",
				dev->data->port_id, cur_queue);
			mlx5_txq_release(dev, cur_queue);
			return -rte_errno;
		}
		sq_attr.state = MLX5_SQC_STATE_RST;
		sq_attr.sq_state = MLX5_SQC_STATE_RST;
		ret = mlx5_devx_cmd_modify_sq(txq_ctrl->obj->sq, &sq_attr);
		if (ret == 0)
			txq_ctrl->hairpin_status = 0;
		mlx5_txq_release(dev, cur_queue);
	} else {
		struct mlx5_rxq_ctrl *rxq_ctrl;
		struct mlx5_devx_modify_rq_attr rq_attr = { 0 };
		rxq_ctrl = mlx5_rxq_get(dev, cur_queue);
		if (rxq_ctrl == NULL) {
			rte_errno = EINVAL;
			DRV_LOG(ERR, "Failed to get port %u Rx queue %d",
				dev->data->port_id, cur_queue);
			return -rte_errno;
		}
		if (rxq_ctrl->type != MLX5_RXQ_TYPE_HAIRPIN) {
			rte_errno = EINVAL;
			DRV_LOG(ERR, "port %u queue %d not a hairpin Rxq",
				dev->data->port_id, cur_queue);
			mlx5_rxq_release(dev, cur_queue);
			return -rte_errno;
		}
		if (rxq_ctrl->hairpin_status == 0) {
			DRV_LOG(DEBUG, "port %u Rx queue %d is already unbound",
				dev->data->port_id, cur_queue);
			mlx5_rxq_release(dev, cur_queue);
			return 0;
		}
		if (rxq_ctrl->obj == NULL || rxq_ctrl->obj->rq == NULL) {
			rte_errno = ENOMEM;
			DRV_LOG(ERR, "port %u no Rxq object found: %d",
				dev->data->port_id, cur_queue);
			mlx5_rxq_release(dev, cur_queue);
			return -rte_errno;
		}
		rq_attr.state = MLX5_SQC_STATE_RST;
		rq_attr.rq_state = MLX5_SQC_STATE_RST;
		ret = mlx5_devx_cmd_modify_rq(rxq_ctrl->obj->rq, &rq_attr);
		if (ret == 0)
			rxq_ctrl->hairpin_status = 0;
		mlx5_rxq_release(dev, cur_queue);
	}
	return ret;
}
int mlx5_hairpin_queue_peer_unbind ( struct rte_eth_dev * dev , uint16_t cur_queue , uint32_t direction ) { int ret = 0 ; if ( direction != 0 ) { struct mlx5_txq_ctrl * txq_ctrl ; struct mlx5_devx_modify_sq_attr sq_attr = { 0 } ; txq_ctrl = mlx5_txq_get ( dev , cur_queue ) ; if ( txq_ctrl == NULL ) { rte_errno = EINVAL ; DRV_LOG ( ERR , " " , dev -> data -> port_id , cur_queue ) ; return - rte_errno ; } if ( txq_ctrl -> type != MLX5_TXQ_TYPE_HAIRPIN ) { rte_errno = EINVAL ; DRV_LOG ( ERR , " " , dev -> data -> port_id , cur_queue ) ; mlx5_txq_release ( dev , cur_queue ) ; return - rte_errno ; } if ( txq_ctrl -> hairpin_status == 0 ) { DRV_LOG ( DEBUG , " " , dev -> data -> port_id , cur_queue ) ; mlx5_txq_release ( dev , cur_queue ) ; return 0 ; } if ( ! txq_ctrl -> obj || ! txq_ctrl -> obj -> sq ) { rte_errno = ENOMEM ; DRV_LOG ( ERR , " " , dev -> data -> port_id , cur_queue ) ; mlx5_txq_release ( dev , cur_queue ) ; return - rte_errno ; } sq_attr . state = MLX5_SQC_STATE_RST ; sq_attr . sq_state = MLX5_SQC_STATE_RST ; ret = mlx5_devx_cmd_modify_sq ( txq_ctrl -> obj -> sq , & sq_attr ) ; if ( ret == 0 ) txq_ctrl -> hairpin_status = 0 ; mlx5_txq_release ( dev , cur_queue ) ; } else { struct mlx5_rxq_ctrl * rxq_ctrl ; struct mlx5_devx_modify_rq_attr rq_attr = { 0 } ; rxq_ctrl = mlx5_rxq_get ( dev , cur_queue ) ; if ( rxq_ctrl == NULL ) { rte_errno = EINVAL ; DRV_LOG ( ERR , " " , dev -> data -> port_id , cur_queue ) ; return - rte_errno ; } if ( rxq_ctrl -> type != MLX5_RXQ_TYPE_HAIRPIN ) { rte_errno = EINVAL ; DRV_LOG ( ERR , " " , dev -> data -> port_id , cur_queue ) ; mlx5_rxq_release ( dev , cur_queue ) ; return - rte_errno ; } if ( rxq_ctrl -> hairpin_status == 0 ) { DRV_LOG ( DEBUG , " " , dev -> data -> port_id , cur_queue ) ; mlx5_rxq_release ( dev , cur_queue ) ; return 0 ; } if ( rxq_ctrl -> obj == NULL || rxq_ctrl -> obj -> rq == NULL ) { rte_errno = ENOMEM ; DRV_LOG ( ERR , " " , dev -> data -> port_id , cur_queue ) ; mlx5_rxq_release ( dev , cur_queue ) ; return - rte_errno ; } rq_attr . state = MLX5_SQC_STATE_RST ; rq_attr . rq_state = MLX5_SQC_STATE_RST ; ret = mlx5_devx_cmd_modify_rq ( rxq_ctrl -> obj -> rq , & rq_attr ) ; if ( ret == 0 ) rxq_ctrl -> hairpin_status = 0 ; mlx5_rxq_release ( dev , cur_queue ) ; } return ret ; }
Unbind the hairpin queue and reset its HW configuration.
Unbind the hairpin queue and reset its HW configuration .
/* Already unbound, return success before obj checking. */