src/dpdk/drivers/net/mlx5/linux/mlx5_socket.c
int
mlx5_pmd_socket_init(void)
{
	struct sockaddr_un sun = {
		.sun_family = AF_UNIX,
	};
	int ret;
	int flags;

	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
	if (server_socket)
		return 0;
	/*
	 * Initialize the socket to communicate with the secondary
	 * process.
	 */
	ret = socket(AF_UNIX, SOCK_STREAM, 0);
	if (ret < 0) {
		DRV_LOG(WARNING, "Failed to open mlx5 socket: %s",
			strerror(errno));
		goto error;
	}
	server_socket = ret;
	flags = fcntl(server_socket, F_GETFL, 0);
	if (flags == -1)
		goto error;
	ret = fcntl(server_socket, F_SETFL, flags | O_NONBLOCK);
	if (ret < 0)
		goto error;
	snprintf(sun.sun_path, sizeof(sun.sun_path), MLX5_SOCKET_PATH,
		 getpid());
	remove(sun.sun_path);
	ret = bind(server_socket, (const struct sockaddr *)&sun, sizeof(sun));
	if (ret < 0) {
		DRV_LOG(WARNING,
			"cannot bind mlx5 socket: %s", strerror(errno));
		goto close;
	}
	ret = listen(server_socket, 0);
	if (ret < 0) {
		DRV_LOG(WARNING, "cannot listen on mlx5 socket: %s",
			strerror(errno));
		goto close;
	}
	if (mlx5_pmd_interrupt_handler_install()) {
		DRV_LOG(WARNING, "cannot register interrupt handler for mlx5 socket: %s",
			strerror(errno));
		goto close;
	}
	return 0;
close:
	remove(sun.sun_path);
error:
	claim_zero(close(server_socket));
	server_socket = 0;
	DRV_LOG(ERR, "Cannot initialize socket: %s", strerror(errno));
	return -errno;
}
/**
 * Initialise the socket to communicate with the secondary process
 *
 * @param[in] dev
 *   Pointer to Ethernet device.
 *
 * @return
 *   0 on success, a negative value otherwise.
 */
Initialise the socket to communicate with the secondary process
@param[in] dev
Pointer to Ethernet device.

@return
0 on success, a negative value otherwise.
Initialise the socket to communicate with the secondary process @param [ in ] dev Pointer to Ethernet device . @return 0 on success a negative value otherwise .
int
mlx5_pmd_socket_init(void)
{
	struct sockaddr_un sun = {
		.sun_family = AF_UNIX,
	};
	int ret;
	int flags;
	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
	if (server_socket)
		return 0;
	ret = socket(AF_UNIX, SOCK_STREAM, 0);
	if (ret < 0) {
		DRV_LOG(WARNING, "Failed to open mlx5 socket: %s",
			strerror(errno));
		goto error;
	}
	server_socket = ret;
	flags = fcntl(server_socket, F_GETFL, 0);
	if (flags == -1)
		goto error;
	ret = fcntl(server_socket, F_SETFL, flags | O_NONBLOCK);
	if (ret < 0)
		goto error;
	snprintf(sun.sun_path, sizeof(sun.sun_path), MLX5_SOCKET_PATH,
		 getpid());
	remove(sun.sun_path);
	ret = bind(server_socket, (const struct sockaddr *)&sun, sizeof(sun));
	if (ret < 0) {
		DRV_LOG(WARNING,
			"cannot bind mlx5 socket: %s", strerror(errno));
		goto close;
	}
	ret = listen(server_socket, 0);
	if (ret < 0) {
		DRV_LOG(WARNING, "cannot listen on mlx5 socket: %s",
			strerror(errno));
		goto close;
	}
	if (mlx5_pmd_interrupt_handler_install()) {
		DRV_LOG(WARNING, "cannot register interrupt handler for mlx5 socket: %s",
			strerror(errno));
		goto close;
	}
	return 0;
close:
	remove(sun.sun_path);
error:
	claim_zero(close(server_socket));
	server_socket = 0;
	DRV_LOG(ERR, "Cannot initialize socket: %s", strerror(errno));
	return -errno;
}
int mlx5_pmd_socket_init ( void ) { struct sockaddr_un sun = { . sun_family = AF_UNIX , } ; int ret ; int flags ; MLX5_ASSERT ( rte_eal_process_type ( ) == RTE_PROC_PRIMARY ) ; if ( server_socket ) return 0 ; ret = socket ( AF_UNIX , SOCK_STREAM , 0 ) ; if ( ret < 0 ) { DRV_LOG ( WARNING , " " , strerror ( errno ) ) ; goto error ; } server_socket = ret ; flags = fcntl ( server_socket , F_GETFL , 0 ) ; if ( flags == -1 ) goto error ; ret = fcntl ( server_socket , F_SETFL , flags | O_NONBLOCK ) ; if ( ret < 0 ) goto error ; snprintf ( sun . sun_path , sizeof ( sun . sun_path ) , MLX5_SOCKET_PATH , getpid ( ) ) ; remove ( sun . sun_path ) ; ret = bind ( server_socket , ( const struct sockaddr * ) & sun , sizeof ( sun ) ) ; if ( ret < 0 ) { DRV_LOG ( WARNING , " " , strerror ( errno ) ) ; goto close ; } ret = listen ( server_socket , 0 ) ; if ( ret < 0 ) { DRV_LOG ( WARNING , " " , strerror ( errno ) ) ; goto close ; } if ( mlx5_pmd_interrupt_handler_install ( ) ) { DRV_LOG ( WARNING , " " , strerror ( errno ) ) ; goto close ; } return 0 ; close : remove ( sun . sun_path ) ; error : claim_zero ( close ( server_socket ) ) ; server_socket = 0 ; DRV_LOG ( ERR , " " , strerror ( errno ) ) ; return - errno ; }
Initialise the socket to communicate with the secondary process
 @param[in] dev
   Pointer to Ethernet device.
Initialise the socket to communicate with the secondary process @param [ in ] dev Pointer to Ethernet device .
/*
	 * Initialize the socket to communicate with the secondary
	 * process.
	 */