src/dpdk/drivers/net/mlx4/mlx4.c
static int
mlx4_init_shared_data(void)
{
	const struct rte_memzone *mz;
	int ret = 0;

	rte_spinlock_lock(&mlx4_shared_data_lock);
	if (mlx4_shared_data == NULL) {
		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
			/* Allocate shared memory. */
			mz = rte_memzone_reserve(MZ_MLX4_PMD_SHARED_DATA,
						 sizeof(*mlx4_shared_data),
						 SOCKET_ID_ANY, 0);
			if (mz == NULL) {
				ERROR("Cannot allocate mlx4 shared data\n");
				ret = -rte_errno;
				goto error;
			}
			mlx4_shared_data = mz->addr;
			memset(mlx4_shared_data, 0, sizeof(*mlx4_shared_data));
			rte_spinlock_init(&mlx4_shared_data->lock);
		} else {
			/* Lookup allocated shared memory. */
			mz = rte_memzone_lookup(MZ_MLX4_PMD_SHARED_DATA);
			if (mz == NULL) {
				ERROR("Cannot attach mlx4 shared data\n");
				ret = -rte_errno;
				goto error;
			}
			mlx4_shared_data = mz->addr;
			memset(&mlx4_local_data, 0, sizeof(mlx4_local_data));
		}
	}
error:
	rte_spinlock_unlock(&mlx4_shared_data_lock);
	return ret;
}
/**
 * Initialize shared data between primary and secondary process.
 *
 * A memzone is reserved by primary process and secondary processes attach to
 * the memzone.
 *
 * @return
 *   0 on success, a negative errno value otherwise and rte_errno is set.
 */
Initialize shared data between primary and secondary process.
A memzone is reserved by primary process and secondary processes attach to
the memzone.

@return
0 on success, a negative errno value otherwise and rte_errno is set.
Initialize shared data between primary and secondary process . A memzone is reserved by primary process and secondary processes attach to the memzone . @return 0 on success a negative errno value otherwise and rte_errno is set .
static int
mlx4_init_shared_data(void)
{
	const struct rte_memzone *mz;
	int ret = 0;
	rte_spinlock_lock(&mlx4_shared_data_lock);
	if (mlx4_shared_data == NULL) {
		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
			mz = rte_memzone_reserve(MZ_MLX4_PMD_SHARED_DATA,
						 sizeof(*mlx4_shared_data),
						 SOCKET_ID_ANY, 0);
			if (mz == NULL) {
				ERROR("Cannot allocate mlx4 shared data\n");
				ret = -rte_errno;
				goto error;
			}
			mlx4_shared_data = mz->addr;
			memset(mlx4_shared_data, 0, sizeof(*mlx4_shared_data));
			rte_spinlock_init(&mlx4_shared_data->lock);
		} else {
			mz = rte_memzone_lookup(MZ_MLX4_PMD_SHARED_DATA);
			if (mz == NULL) {
				ERROR("Cannot attach mlx4 shared data\n");
				ret = -rte_errno;
				goto error;
			}
			mlx4_shared_data = mz->addr;
			memset(&mlx4_local_data, 0, sizeof(mlx4_local_data));
		}
	}
error:
	rte_spinlock_unlock(&mlx4_shared_data_lock);
	return ret;
}
static int mlx4_init_shared_data ( void ) { const struct rte_memzone * mz ; int ret = 0 ; rte_spinlock_lock ( & mlx4_shared_data_lock ) ; if ( mlx4_shared_data == NULL ) { if ( rte_eal_process_type ( ) == RTE_PROC_PRIMARY ) { mz = rte_memzone_reserve ( MZ_MLX4_PMD_SHARED_DATA , sizeof ( * mlx4_shared_data ) , SOCKET_ID_ANY , 0 ) ; if ( mz == NULL ) { ERROR ( " \n " ) ; ret = - rte_errno ; goto error ; } mlx4_shared_data = mz -> addr ; memset ( mlx4_shared_data , 0 , sizeof ( * mlx4_shared_data ) ) ; rte_spinlock_init ( & mlx4_shared_data -> lock ) ; } else { mz = rte_memzone_lookup ( MZ_MLX4_PMD_SHARED_DATA ) ; if ( mz == NULL ) { ERROR ( " \n " ) ; ret = - rte_errno ; goto error ; } mlx4_shared_data = mz -> addr ; memset ( & mlx4_local_data , 0 , sizeof ( mlx4_local_data ) ) ; } } error : rte_spinlock_unlock ( & mlx4_shared_data_lock ) ; return ret ; }
Initialize shared data between primary and secondary process.
Initialize shared data between primary and secondary process .
/* Allocate shared memory. */ /* Lookup allocated shared memory. */