src/dpdk/drivers/net/mlx4/mlx4.c
static int
mlx4_init_once(void)
{
	struct mlx4_shared_data *sd;
	struct mlx4_local_data *ld = &mlx4_local_data;
	int ret = 0;

	if (mlx4_init_shared_data())
		return -rte_errno;
	sd = mlx4_shared_data;
	MLX4_ASSERT(sd);
	rte_spinlock_lock(&sd->lock);
	switch (rte_eal_process_type()) {
	case RTE_PROC_PRIMARY:
		if (sd->init_done)
			break;
		LIST_INIT(&sd->mem_event_cb_list);
		rte_rwlock_init(&sd->mem_event_rwlock);
		rte_mem_event_callback_register("MLX4_MEM_EVENT_CB",
						mlx4_mr_mem_event_cb, NULL);
		ret = mlx4_mp_init_primary();
		if (ret)
			goto out;
		sd->init_done = 1;
		break;
	case RTE_PROC_SECONDARY:
		if (ld->init_done)
			break;
		ret = mlx4_mp_init_secondary();
		if (ret)
			goto out;
		++sd->secondary_cnt;
		ld->init_done = 1;
		break;
	default:
		break;
	}
out:
	rte_spinlock_unlock(&sd->lock);
	return ret;
}
/**
 * PMD global initialization.
 *
 * Independent from individual device, this function initializes global
 * per-PMD data structures distinguishing primary and secondary processes.
 * Hence, each initialization is called once per a process.
 *
 * @return
 *   0 on success, a negative errno value otherwise and rte_errno is set.
 */
PMD global initialization.
Independent from individual device, this function initializes global
per-PMD data structures distinguishing primary and secondary processes.
Hence, each initialization is called once per a process.

@return
0 on success, a negative errno value otherwise and rte_errno is set.
PMD global initialization . Independent from individual device this function initializes global per - PMD data structures distinguishing primary and secondary processes . Hence each initialization is called once per a process . @return 0 on success a negative errno value otherwise and rte_errno is set .
static int
mlx4_init_once(void)
{
	struct mlx4_shared_data *sd;
	struct mlx4_local_data *ld = &mlx4_local_data;
	int ret = 0;
	if (mlx4_init_shared_data())
		return -rte_errno;
	sd = mlx4_shared_data;
	MLX4_ASSERT(sd);
	rte_spinlock_lock(&sd->lock);
	switch (rte_eal_process_type()) {
	case RTE_PROC_PRIMARY:
		if (sd->init_done)
			break;
		LIST_INIT(&sd->mem_event_cb_list);
		rte_rwlock_init(&sd->mem_event_rwlock);
		rte_mem_event_callback_register("MLX4_MEM_EVENT_CB",
						mlx4_mr_mem_event_cb, NULL);
		ret = mlx4_mp_init_primary();
		if (ret)
			goto out;
		sd->init_done = 1;
		break;
	case RTE_PROC_SECONDARY:
		if (ld->init_done)
			break;
		ret = mlx4_mp_init_secondary();
		if (ret)
			goto out;
		++sd->secondary_cnt;
		ld->init_done = 1;
		break;
	default:
		break;
	}
out:
	rte_spinlock_unlock(&sd->lock);
	return ret;
}
static int mlx4_init_once ( void ) { struct mlx4_shared_data * sd ; struct mlx4_local_data * ld = & mlx4_local_data ; int ret = 0 ; if ( mlx4_init_shared_data ( ) ) return - rte_errno ; sd = mlx4_shared_data ; MLX4_ASSERT ( sd ) ; rte_spinlock_lock ( & sd -> lock ) ; switch ( rte_eal_process_type ( ) ) { case RTE_PROC_PRIMARY : if ( sd -> init_done ) break ; LIST_INIT ( & sd -> mem_event_cb_list ) ; rte_rwlock_init ( & sd -> mem_event_rwlock ) ; rte_mem_event_callback_register ( " " , mlx4_mr_mem_event_cb , NULL ) ; ret = mlx4_mp_init_primary ( ) ; if ( ret ) goto out ; sd -> init_done = 1 ; break ; case RTE_PROC_SECONDARY : if ( ld -> init_done ) break ; ret = mlx4_mp_init_secondary ( ) ; if ( ret ) goto out ; ++ sd -> secondary_cnt ; ld -> init_done = 1 ; break ; default : break ; } out : rte_spinlock_unlock ( & sd -> lock ) ; return ret ; }
PMD global initialization.
PMD global initialization .