mlx5_queue_state_modify_primary(struct rte_eth_dev *dev,
			const struct mlx5_mp_arg_queue_state_modify *sm)
{
	int ret;
	struct mlx5_priv *priv = dev->data->dev_private;

	if (sm->is_wq) {
		struct mlx5_rxq_data *rxq = (*priv->rxqs)[sm->queue_id];
		struct mlx5_rxq_ctrl *rxq_ctrl =
			container_of(rxq, struct mlx5_rxq_ctrl, rxq);

		if (rxq_ctrl->obj->type == MLX5_RXQ_OBJ_TYPE_IBV) {
			struct ibv_wq_attr mod = {
				.attr_mask = IBV_WQ_ATTR_STATE,
				.wq_state = sm->state,
			};

			ret = mlx5_glue->modify_wq(rxq_ctrl->obj->wq, &mod);
		} else { /* rxq_ctrl->obj->type == MLX5_RXQ_OBJ_TYPE_DEVX_RQ. */
			struct mlx5_devx_modify_rq_attr rq_attr;

			memset(&rq_attr, 0, sizeof(rq_attr));
			if (sm->state == IBV_WQS_RESET) {
				rq_attr.rq_state = MLX5_RQC_STATE_ERR;
				rq_attr.state = MLX5_RQC_STATE_RST;
			} else if (sm->state == IBV_WQS_RDY) {
				rq_attr.rq_state = MLX5_RQC_STATE_RST;
				rq_attr.state = MLX5_RQC_STATE_RDY;
			} else if (sm->state == IBV_WQS_ERR) {
				rq_attr.rq_state = MLX5_RQC_STATE_RDY;
				rq_attr.state = MLX5_RQC_STATE_ERR;
			}
			ret = mlx5_devx_cmd_modify_rq(rxq_ctrl->obj->rq,
						      &rq_attr);
		}
		if (ret) {
			DRV_LOG(ERR, "Cannot change Rx WQ state to %u  - %s",
					sm->state, strerror(errno));
			rte_errno = errno;
			return ret;
		}
	} else {
		struct mlx5_txq_data *txq = (*priv->txqs)[sm->queue_id];
		struct mlx5_txq_ctrl *txq_ctrl =
			container_of(txq, struct mlx5_txq_ctrl, txq);
		struct ibv_qp_attr mod = {
			.qp_state = IBV_QPS_RESET,
			.port_num = (uint8_t)priv->ibv_port,
		};
		struct ibv_qp *qp = txq_ctrl->obj->qp;

		ret = mlx5_glue->modify_qp(qp, &mod, IBV_QP_STATE);
		if (ret) {
			DRV_LOG(ERR, "Cannot change the Tx QP state to RESET "
				"%s", strerror(errno));
			rte_errno = errno;
			return ret;
		}
		mod.qp_state = IBV_QPS_INIT;
		ret = mlx5_glue->modify_qp(qp, &mod,
					   (IBV_QP_STATE | IBV_QP_PORT));
		if (ret) {
			DRV_LOG(ERR, "Cannot change Tx QP state to INIT %s",
				strerror(errno));
			rte_errno = errno;
			return ret;
		}
		mod.qp_state = IBV_QPS_RTR;
		ret = mlx5_glue->modify_qp(qp, &mod, IBV_QP_STATE);
		if (ret) {
			DRV_LOG(ERR, "Cannot change Tx QP state to RTR %s",
				strerror(errno));
			rte_errno = errno;
			return ret;
		}
		mod.qp_state = IBV_QPS_RTS;
		ret = mlx5_glue->modify_qp(qp, &mod, IBV_QP_STATE);
		if (ret) {
			DRV_LOG(ERR, "Cannot change Tx QP state to RTS %s",
				strerror(errno));
			rte_errno = errno;
			return ret;
		}
	}
	return 0;
}
mlx5_queue_state_modify_primary(struct rte_eth_dev *dev,
			const struct mlx5_mp_arg_queue_state_modify *sm)
{
	int ret;
	struct mlx5_priv *priv = dev->data->dev_private;

	if (sm->is_wq) {
		struct mlx5_rxq_data *rxq = (*priv->rxqs)[sm->queue_id];
		struct mlx5_rxq_ctrl *rxq_ctrl =
			container_of(rxq, struct mlx5_rxq_ctrl, rxq);

		if (rxq_ctrl->obj->type == MLX5_RXQ_OBJ_TYPE_IBV) {
			struct ibv_wq_attr mod = {
				.attr_mask = IBV_WQ_ATTR_STATE,
				.wq_state = sm->state,
			};

			ret = mlx5_glue->modify_wq(rxq_ctrl->obj->wq, &mod);
		} else {  
			struct mlx5_devx_modify_rq_attr rq_attr;

			memset(&rq_attr, 0, sizeof(rq_attr));
			if (sm->state == IBV_WQS_RESET) {
				rq_attr.rq_state = MLX5_RQC_STATE_ERR;
				rq_attr.state = MLX5_RQC_STATE_RST;
			} else if (sm->state == IBV_WQS_RDY) {
				rq_attr.rq_state = MLX5_RQC_STATE_RST;
				rq_attr.state = MLX5_RQC_STATE_RDY;
			} else if (sm->state == IBV_WQS_ERR) {
				rq_attr.rq_state = MLX5_RQC_STATE_RDY;
				rq_attr.state = MLX5_RQC_STATE_ERR;
			}
			ret = mlx5_devx_cmd_modify_rq(rxq_ctrl->obj->rq,
						      &rq_attr);
		}
		if (ret) {
			DRV_LOG(ERR, "Cannot change Rx WQ state to %u  - %s",
					sm->state, strerror(errno));
			rte_errno = errno;
			return ret;
		}
	} else {
		struct mlx5_txq_data *txq = (*priv->txqs)[sm->queue_id];
		struct mlx5_txq_ctrl *txq_ctrl =
			container_of(txq, struct mlx5_txq_ctrl, txq);
		struct ibv_qp_attr mod = {
			.qp_state = IBV_QPS_RESET,
			.port_num = (uint8_t)priv->ibv_port,
		};
		struct ibv_qp *qp = txq_ctrl->obj->qp;

		ret = mlx5_glue->modify_qp(qp, &mod, IBV_QP_STATE);
		if (ret) {
			DRV_LOG(ERR, "Cannot change the Tx QP state to RESET "
				"%s", strerror(errno));
			rte_errno = errno;
			return ret;
		}
		mod.qp_state = IBV_QPS_INIT;
		ret = mlx5_glue->modify_qp(qp, &mod,
					   (IBV_QP_STATE | IBV_QP_PORT));
		if (ret) {
			DRV_LOG(ERR, "Cannot change Tx QP state to INIT %s",
				strerror(errno));
			rte_errno = errno;
			return ret;
		}
		mod.qp_state = IBV_QPS_RTR;
		ret = mlx5_glue->modify_qp(qp, &mod, IBV_QP_STATE);
		if (ret) {
			DRV_LOG(ERR, "Cannot change Tx QP state to RTR %s",
				strerror(errno));
			rte_errno = errno;
			return ret;
		}
		mod.qp_state = IBV_QPS_RTS;
		ret = mlx5_glue->modify_qp(qp, &mod, IBV_QP_STATE);
		if (ret) {
			DRV_LOG(ERR, "Cannot change Tx QP state to RTS %s",
				strerror(errno));
			rte_errno = errno;
			return ret;
		}
	}
	return 0;
}