src/dpdk/drivers/net/nfp/nfp_net.c
static int32_t
nfp_cpp_bridge_service_func(void *args)
{
	struct sockaddr address;
	struct nfp_cpp *cpp = args;
	int sockfd, datafd, op, ret;

	unlink("/tmp/nfp_cpp");
	sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
	if (sockfd < 0) {
		RTE_LOG(ERR, PMD, "%s: socket creation error. Service failed\n",
			__func__);
		return -EIO;
	}

	memset(&address, 0, sizeof(struct sockaddr));

	address.sa_family = AF_UNIX;
	strcpy(address.sa_data, "/tmp/nfp_cpp");

	ret = bind(sockfd, (const struct sockaddr *)&address,
		   sizeof(struct sockaddr));
	if (ret < 0) {
		RTE_LOG(ERR, PMD, "%s: bind error (%d). Service failed\n",
				  __func__, errno);
		close(sockfd);
		return ret;
	}

	ret = listen(sockfd, 20);
	if (ret < 0) {
		RTE_LOG(ERR, PMD, "%s: listen error(%d). Service failed\n",
				  __func__, errno);
		close(sockfd);
		return ret;
	}

	for (;;) {
		datafd = accept(sockfd, NULL, NULL);
		if (datafd < 0) {
			RTE_LOG(ERR, PMD, "%s: accept call error (%d)\n",
					  __func__, errno);
			RTE_LOG(ERR, PMD, "%s: service failed\n", __func__);
			close(sockfd);
			return -EIO;
		}

		while (1) {
			ret = recv(datafd, &op, 4, 0);
			if (ret <= 0) {
				PMD_CPP_LOG(DEBUG, "%s: socket close\n",
						   __func__);
				break;
			}

			PMD_CPP_LOG(DEBUG, "%s: getting op %u\n", __func__, op);

			if (op == NFP_BRIDGE_OP_READ)
				nfp_cpp_bridge_serve_read(datafd, cpp);

			if (op == NFP_BRIDGE_OP_WRITE)
				nfp_cpp_bridge_serve_write(datafd, cpp);

			if (op == NFP_BRIDGE_OP_IOCTL)
				nfp_cpp_bridge_serve_ioctl(datafd, cpp);

			if (op == 0)
				break;
		}
		close(datafd);
	}
	close(sockfd);

	return 0;
}
/*
 * This is the code to be executed by a service core. The CPP bridge interface
 * is based on a unix socket and requests usually received by a kernel char
 * driver, read, write and ioctl, are handled by the CPP bridge. NFP host tools
 * can be executed with a wrapper library and LD_LIBRARY being completely
 * unaware of the CPP bridge performing the NFP kernel char driver for CPP
 * accesses.
 */
This is the code to be executed by a service core. The CPP bridge interface
is based on a unix socket and requests usually received by a kernel char
driver, read, write and ioctl, are handled by the CPP bridge. NFP host tools
can be executed with a wrapper library and LD_LIBRARY being completely
unaware of the CPP bridge performing the NFP kernel char driver for CPP
accesses.
This is the code to be executed by a service core . The CPP bridge interface is based on a unix socket and requests usually received by a kernel char driver read write and ioctl are handled by the CPP bridge . NFP host tools can be executed with a wrapper library and LD_LIBRARY being completely unaware of the CPP bridge performing the NFP kernel char driver for CPP accesses .
static int32_t
nfp_cpp_bridge_service_func(void *args)
{
	struct sockaddr address;
	struct nfp_cpp *cpp = args;
	int sockfd, datafd, op, ret;
	unlink("/tmp/nfp_cpp");
	sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
	if (sockfd < 0) {
		RTE_LOG(ERR, PMD, "%s: socket creation error. Service failed\n",
			__func__);
		return -EIO;
	}
	memset(&address, 0, sizeof(struct sockaddr));
	address.sa_family = AF_UNIX;
	strcpy(address.sa_data, "/tmp/nfp_cpp");
	ret = bind(sockfd, (const struct sockaddr *)&address,
		   sizeof(struct sockaddr));
	if (ret < 0) {
		RTE_LOG(ERR, PMD, "%s: bind error (%d). Service failed\n",
				  __func__, errno);
		close(sockfd);
		return ret;
	}
	ret = listen(sockfd, 20);
	if (ret < 0) {
		RTE_LOG(ERR, PMD, "%s: listen error(%d). Service failed\n",
				  __func__, errno);
		close(sockfd);
		return ret;
	}
	for (;;) {
		datafd = accept(sockfd, NULL, NULL);
		if (datafd < 0) {
			RTE_LOG(ERR, PMD, "%s: accept call error (%d)\n",
					  __func__, errno);
			RTE_LOG(ERR, PMD, "%s: service failed\n", __func__);
			close(sockfd);
			return -EIO;
		}
		while (1) {
			ret = recv(datafd, &op, 4, 0);
			if (ret <= 0) {
				PMD_CPP_LOG(DEBUG, "%s: socket close\n",
						   __func__);
				break;
			}
			PMD_CPP_LOG(DEBUG, "%s: getting op %u\n", __func__, op);
			if (op == NFP_BRIDGE_OP_READ)
				nfp_cpp_bridge_serve_read(datafd, cpp);
			if (op == NFP_BRIDGE_OP_WRITE)
				nfp_cpp_bridge_serve_write(datafd, cpp);
			if (op == NFP_BRIDGE_OP_IOCTL)
				nfp_cpp_bridge_serve_ioctl(datafd, cpp);
			if (op == 0)
				break;
		}
		close(datafd);
	}
	close(sockfd);
	return 0;
}
static int32_t nfp_cpp_bridge_service_func ( void * args ) { struct sockaddr address ; struct nfp_cpp * cpp = args ; int sockfd , datafd , op , ret ; unlink ( " " ) ; sockfd = socket ( AF_UNIX , SOCK_STREAM , 0 ) ; if ( sockfd < 0 ) { RTE_LOG ( ERR , PMD , " \n " , __func__ ) ; return - EIO ; } memset ( & address , 0 , sizeof ( struct sockaddr ) ) ; address . sa_family = AF_UNIX ; strcpy ( address . sa_data , " " ) ; ret = bind ( sockfd , ( const struct sockaddr * ) & address , sizeof ( struct sockaddr ) ) ; if ( ret < 0 ) { RTE_LOG ( ERR , PMD , " \n " , __func__ , errno ) ; close ( sockfd ) ; return ret ; } ret = listen ( sockfd , 20 ) ; if ( ret < 0 ) { RTE_LOG ( ERR , PMD , " \n " , __func__ , errno ) ; close ( sockfd ) ; return ret ; } for ( ; ; ) { datafd = accept ( sockfd , NULL , NULL ) ; if ( datafd < 0 ) { RTE_LOG ( ERR , PMD , " \n " , __func__ , errno ) ; RTE_LOG ( ERR , PMD , " \n " , __func__ ) ; close ( sockfd ) ; return - EIO ; } while ( 1 ) { ret = recv ( datafd , & op , 4 , 0 ) ; if ( ret <= 0 ) { PMD_CPP_LOG ( DEBUG , " \n " , __func__ ) ; break ; } PMD_CPP_LOG ( DEBUG , " \n " , __func__ , op ) ; if ( op == NFP_BRIDGE_OP_READ ) nfp_cpp_bridge_serve_read ( datafd , cpp ) ; if ( op == NFP_BRIDGE_OP_WRITE ) nfp_cpp_bridge_serve_write ( datafd , cpp ) ; if ( op == NFP_BRIDGE_OP_IOCTL ) nfp_cpp_bridge_serve_ioctl ( datafd , cpp ) ; if ( op == 0 ) break ; } close ( datafd ) ; } close ( sockfd ) ; return 0 ; }
This is the code to be executed by a service core.
This is the code to be executed by a service core .