src/dpdk/drivers/net/mlx5/linux/mlx5_verbs.c
static int
mlx5_ibv_drop_action_create(struct rte_eth_dev *dev)
{
	struct mlx5_priv *priv = dev->data->dev_private;
	struct mlx5_hrxq *hrxq = priv->drop_queue.hrxq;
	struct ibv_rwq_ind_table *ind_tbl = NULL;
	struct mlx5_rxq_obj *rxq;
	int ret;

	MLX5_ASSERT(hrxq && hrxq->ind_table);
	ret = mlx5_rxq_ibv_obj_drop_create(dev);
	if (ret < 0)
		goto error;
	rxq = priv->drop_queue.rxq;
	ind_tbl = mlx5_glue->create_rwq_ind_table
				(priv->sh->ctx,
				 &(struct ibv_rwq_ind_table_init_attr){
					.log_ind_tbl_size = 0,
					.ind_tbl = (struct ibv_wq **)&rxq->wq,
					.comp_mask = 0,
				 });
	if (!ind_tbl) {
		DEBUG("Port %u cannot allocate indirection table for drop"
		      " queue.", dev->data->port_id);
		rte_errno = errno;
		goto error;
	}
	hrxq->qp = mlx5_glue->create_qp_ex(priv->sh->ctx,
		 &(struct ibv_qp_init_attr_ex){
			.qp_type = IBV_QPT_RAW_PACKET,
			.comp_mask = IBV_QP_INIT_ATTR_PD |
				     IBV_QP_INIT_ATTR_IND_TABLE |
				     IBV_QP_INIT_ATTR_RX_HASH,
			.rx_hash_conf = (struct ibv_rx_hash_conf){
				.rx_hash_function = IBV_RX_HASH_FUNC_TOEPLITZ,
				.rx_hash_key_len = MLX5_RSS_HASH_KEY_LEN,
				.rx_hash_key = rss_hash_default_key,
				.rx_hash_fields_mask = 0,
				},
			.rwq_ind_tbl = ind_tbl,
			.pd = priv->sh->pd
		 });
	if (!hrxq->qp) {
		DEBUG("Port %u cannot allocate QP for drop queue.",
		      dev->data->port_id);
		rte_errno = errno;
		goto error;
	}
#ifdef HAVE_IBV_FLOW_DV_SUPPORT
	hrxq->action = mlx5_glue->dv_create_flow_action_dest_ibv_qp(hrxq->qp);
	if (!hrxq->action) {
		rte_errno = errno;
		goto error;
	}
#endif
	hrxq->ind_table->ind_table = ind_tbl;
	return 0;
error:
	if (hrxq->qp)
		claim_zero(mlx5_glue->destroy_qp(hrxq->qp));
	if (ind_tbl)
		claim_zero(mlx5_glue->destroy_rwq_ind_table(ind_tbl));
	if (priv->drop_queue.rxq)
		mlx5_rxq_ibv_obj_drop_release(dev);
	return -rte_errno;
}
/**
 * Create a Verbs drop action for Rx Hash queue.
 *
 * @param dev
 *   Pointer to Ethernet device.
 *
 * @return
 *   0 on success, a negative errno value otherwise and rte_errno is set.
 */
Create a Verbs drop action for Rx Hash queue.
@param dev
Pointer to Ethernet device.

@return
0 on success, a negative errno value otherwise and rte_errno is set.
Create a Verbs drop action for Rx Hash queue . @param dev Pointer to Ethernet device . @return 0 on success a negative errno value otherwise and rte_errno is set .
static int
mlx5_ibv_drop_action_create(struct rte_eth_dev *dev)
{
	struct mlx5_priv *priv = dev->data->dev_private;
	struct mlx5_hrxq *hrxq = priv->drop_queue.hrxq;
	struct ibv_rwq_ind_table *ind_tbl = NULL;
	struct mlx5_rxq_obj *rxq;
	int ret;
	MLX5_ASSERT(hrxq && hrxq->ind_table);
	ret = mlx5_rxq_ibv_obj_drop_create(dev);
	if (ret < 0)
		goto error;
	rxq = priv->drop_queue.rxq;
	ind_tbl = mlx5_glue->create_rwq_ind_table
				(priv->sh->ctx,
				 &(struct ibv_rwq_ind_table_init_attr){
					.log_ind_tbl_size = 0,
					.ind_tbl = (struct ibv_wq **)&rxq->wq,
					.comp_mask = 0,
				 });
	if (!ind_tbl) {
		DEBUG("Port %u cannot allocate indirection table for drop"
		      " queue.", dev->data->port_id);
		rte_errno = errno;
		goto error;
	}
	hrxq->qp = mlx5_glue->create_qp_ex(priv->sh->ctx,
		 &(struct ibv_qp_init_attr_ex){
			.qp_type = IBV_QPT_RAW_PACKET,
			.comp_mask = IBV_QP_INIT_ATTR_PD |
				     IBV_QP_INIT_ATTR_IND_TABLE |
				     IBV_QP_INIT_ATTR_RX_HASH,
			.rx_hash_conf = (struct ibv_rx_hash_conf){
				.rx_hash_function = IBV_RX_HASH_FUNC_TOEPLITZ,
				.rx_hash_key_len = MLX5_RSS_HASH_KEY_LEN,
				.rx_hash_key = rss_hash_default_key,
				.rx_hash_fields_mask = 0,
				},
			.rwq_ind_tbl = ind_tbl,
			.pd = priv->sh->pd
		 });
	if (!hrxq->qp) {
		DEBUG("Port %u cannot allocate QP for drop queue.",
		      dev->data->port_id);
		rte_errno = errno;
		goto error;
	}
#ifdef HAVE_IBV_FLOW_DV_SUPPORT
	hrxq->action = mlx5_glue->dv_create_flow_action_dest_ibv_qp(hrxq->qp);
	if (!hrxq->action) {
		rte_errno = errno;
		goto error;
	}
#endif
	hrxq->ind_table->ind_table = ind_tbl;
	return 0;
error:
	if (hrxq->qp)
		claim_zero(mlx5_glue->destroy_qp(hrxq->qp));
	if (ind_tbl)
		claim_zero(mlx5_glue->destroy_rwq_ind_table(ind_tbl));
	if (priv->drop_queue.rxq)
		mlx5_rxq_ibv_obj_drop_release(dev);
	return -rte_errno;
}
static int mlx5_ibv_drop_action_create ( struct rte_eth_dev * dev ) { struct mlx5_priv * priv = dev -> data -> dev_private ; struct mlx5_hrxq * hrxq = priv -> drop_queue . hrxq ; struct ibv_rwq_ind_table * ind_tbl = NULL ; struct mlx5_rxq_obj * rxq ; int ret ; MLX5_ASSERT ( hrxq && hrxq -> ind_table ) ; ret = mlx5_rxq_ibv_obj_drop_create ( dev ) ; if ( ret < 0 ) goto error ; rxq = priv -> drop_queue . rxq ; ind_tbl = mlx5_glue -> create_rwq_ind_table ( priv -> sh -> ctx , & ( struct ibv_rwq_ind_table_init_attr ) { . log_ind_tbl_size = 0 , . ind_tbl = ( struct ibv_wq * * ) & rxq -> wq , . comp_mask = 0 , } ) ; if ( ! ind_tbl ) { DEBUG ( " " " " , dev -> data -> port_id ) ; rte_errno = errno ; goto error ; } hrxq -> qp = mlx5_glue -> create_qp_ex ( priv -> sh -> ctx , & ( struct ibv_qp_init_attr_ex ) { . qp_type = IBV_QPT_RAW_PACKET , . comp_mask = IBV_QP_INIT_ATTR_PD | IBV_QP_INIT_ATTR_IND_TABLE | IBV_QP_INIT_ATTR_RX_HASH , . rx_hash_conf = ( struct ibv_rx_hash_conf ) { . rx_hash_function = IBV_RX_HASH_FUNC_TOEPLITZ , . rx_hash_key_len = MLX5_RSS_HASH_KEY_LEN , . rx_hash_key = rss_hash_default_key , . rx_hash_fields_mask = 0 , } , . rwq_ind_tbl = ind_tbl , . pd = priv -> sh -> pd } ) ; if ( ! hrxq -> qp ) { DEBUG ( " " , dev -> data -> port_id ) ; rte_errno = errno ; goto error ; } #ifdef HAVE_IBV_FLOW_DV_SUPPORT hrxq -> action = mlx5_glue -> dv_create_flow_action_dest_ibv_qp ( hrxq -> qp ) ; if ( ! hrxq -> action ) { rte_errno = errno ; goto error ; } #endif hrxq -> ind_table -> ind_table = ind_tbl ; return 0 ; error : if ( hrxq -> qp ) claim_zero ( mlx5_glue -> destroy_qp ( hrxq -> qp ) ) ; if ( ind_tbl ) claim_zero ( mlx5_glue -> destroy_rwq_ind_table ( ind_tbl ) ) ; if ( priv -> drop_queue . rxq ) mlx5_rxq_ibv_obj_drop_release ( dev ) ; return - rte_errno ; }
Create a Verbs drop action for Rx Hash queue.
Create a Verbs drop action for Rx Hash queue .