DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: "Tan, Jianfeng" <jianfeng.tan@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "Richardson, Bruce" <bruce.richardson@intel.com>,
	"De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>,
	"thomas@monjalon.net" <thomas@monjalon.net>,
	"yliu@fridaylinux.org" <yliu@fridaylinux.org>,
	"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>,
	"mtetsuyah@gmail.com" <mtetsuyah@gmail.com>,
	"Yigit, Ferruh" <ferruh.yigit@intel.com>
Subject: Re: [dpdk-dev] [PATCH v2 07/12] eal: add channel for primary/secondary communication
Date: Thu, 28 Sep 2017 15:01:41 +0000	[thread overview]
Message-ID: <2601191342CEEE43887BDE71AB9772584F24FF69@irsmsx105.ger.corp.intel.com> (raw)
In-Reply-To: <1506606959-76230-8-git-send-email-jianfeng.tan@intel.com>

Hi Jianfeng,


> -----Original Message-----
> From: Tan, Jianfeng
> Sent: Thursday, September 28, 2017 2:56 PM
> To: dev@dpdk.org
> Cc: Richardson, Bruce <bruce.richardson@intel.com>; Ananyev, Konstantin <konstantin.ananyev@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>; thomas@monjalon.net; yliu@fridaylinux.org; maxime.coquelin@redhat.com; mtetsuyah@gmail.com;
> Yigit, Ferruh <ferruh.yigit@intel.com>; Tan, Jianfeng <jianfeng.tan@intel.com>
> Subject: [PATCH v2 07/12] eal: add channel for primary/secondary communication
> 
> Previouly, there is only one way for primary/secondary to exchange
> messages, that is, primary process writes info into some predefind
> file, and secondary process reads info out. That cannot address
> the requirements:
>   a. Secondary wants to send info to primary, for example, secondary
>      would like to send request (about some specific vdev to primary).
>   b. Sending info at any time, instead of just initialization time.
>   c. Share FDs with the other side, for vdev like vhost, related FDs
>      (memory region, kick) should be shared.
> 
> This patch proposes to create a communication channel, as an unix
> socket connection, for above requirements. Primary will listen on
> the unix socket; secondary will connect this socket to talk.
> 
> Three new APIs are added:
> 
>   1. rte_eal_mp_action_register is used to register an action,
>      indexed by a string; if the calling component wants to
>      response the messages from the corresponding component in
>      its primary process or secondary processes.
>   2. rte_eal_mp_action_unregister is used to unregister the action
>      if the calling component does not want to response the messages.
>   3. rte_eal_mp_sendmsg is used to send a message.

I think we already have similar channel in librte_pdump().
Also it seems like eal_vfio also has it's own socket to communicate between mp/sp.
Could we probably make it generic - so same code (and socket) be used by all such  places.
Konstantin


> 
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> ---
>  lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   8 +
>  lib/librte_eal/common/eal_common_proc.c         | 498 ++++++++++++++++++++++++
>  lib/librte_eal/common/eal_filesystem.h          |  18 +
>  lib/librte_eal/common/eal_private.h             |  10 +
>  lib/librte_eal/common/include/rte_eal.h         |  68 ++++
>  lib/librte_eal/linuxapp/eal/eal.c               |   6 +
>  lib/librte_eal/linuxapp/eal/rte_eal_version.map |   8 +
>  7 files changed, 616 insertions(+)
> 
> diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> index 47a09ea..f895916 100644
> --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> @@ -238,3 +238,11 @@ EXPERIMENTAL {
>  	rte_service_start_with_defaults;
> 
>  } DPDK_17.08;
> +
> +EXPERIMENTAL {
> +	global:
> +
> +	rte_eal_primary_secondary_add_action;
> +	rte_eal_primary_secondary_del_action;
> +	rte_eal_primary_secondary_sendmsg;
> +} DPDK_17.11;
> diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c
> index 60526ca..eb5a502 100644
> --- a/lib/librte_eal/common/eal_common_proc.c
> +++ b/lib/librte_eal/common/eal_common_proc.c
> @@ -33,8 +33,21 @@
>  #include <stdio.h>
>  #include <fcntl.h>
>  #include <stdlib.h>
> +#include <sys/types.h>
> +#include <sys/socket.h>
> +#include <sys/epoll.h>
> +#include <limits.h>
> +#include <unistd.h>
> +#include <sys/un.h>
> +#include <errno.h>
> +#include <pthread.h>
> +
> +#include <rte_log.h>
>  #include <rte_eal.h>
> +#include <rte_lcore.h>
> +#include <rte_common.h>
> 
> +#include "eal_private.h"
>  #include "eal_filesystem.h"
>  #include "eal_internal_cfg.h"
> 
> @@ -59,3 +72,488 @@ rte_eal_primary_proc_alive(const char *config_file_path)
> 
>  	return !!ret;
>  }
> +
> +struct action_entry {
> +	TAILQ_ENTRY(action_entry) next;      /**< Next attached action entry */
> +
> +#define MAX_ACTION_NAME_LEN	64
> +	char action_name[MAX_ACTION_NAME_LEN];
> +	rte_eal_mp_t action;
> +};
> +
> +/** Double linked list of actions. */
> +TAILQ_HEAD(action_entry_list, action_entry);
> +
> +static struct action_entry_list action_entry_list =
> +	TAILQ_HEAD_INITIALIZER(action_entry_list);
> +
> +static struct action_entry *
> +find_action_entry_by_name(const char *name)
> +{
> +	int len = strlen(name);
> +	struct action_entry *entry;
> +
> +	TAILQ_FOREACH(entry, &action_entry_list, next) {
> +		if (strncmp(entry->action_name, name, len) == 0)
> +			break;
> +	}
> +
> +	return entry;
> +}
> +
> +int
> +rte_eal_mp_action_register(const char *action_name, rte_eal_mp_t action)
> +{
> +	struct action_entry *entry = malloc(sizeof(struct action_entry));
> +
> +	if (entry == NULL)
> +		return -ENOMEM;
> +
> +	if (find_action_entry_by_name(action_name) != NULL)
> +		return -EEXIST;
> +
> +	strncpy(entry->action_name, action_name, MAX_ACTION_NAME_LEN);
> +	entry->action = action;
> +	TAILQ_INSERT_TAIL(&action_entry_list, entry, next);
> +	return 0;
> +}
> +
> +void
> +rte_eal_mp_action_unregister(const char *name)
> +{
> +	struct action_entry *entry = find_action_entry_by_name(name);
> +
> +	TAILQ_REMOVE(&action_entry_list, entry, next);
> +	free(entry);
> +}
> +
> +/* The maximum amount of fd for one recvmsg/sendmsg */
> +#define SCM_MAX_FD		253
> +#define MAX_SECONDARY_PROCS	8
> +#define MAX_MESSAGE_LENGTH	1024
> +
> +struct mp_fds {
> +	int efd;
> +
> +	union {
> +		/* fds for primary process */
> +		struct {
> +			int listen;
> +			/* fds used to send msg to secondary process(es) */
> +			int secondaries[MAX_SECONDARY_PROCS];
> +		};
> +
> +		/* fds for secondary process */
> +		struct {
> +			/* fds used to send msg to the primary process */
> +			int primary;
> +		};
> +	};
> +};
> +
> +static struct mp_fds mp_fds;
> +
> +struct msg_hdr {
> +	char action_name[MAX_ACTION_NAME_LEN];
> +	int fds_num;
> +	int len_params;
> +	char params[0];
> +} __rte_packed;
> +
> +static int
> +add_sec_proc(int fd)
> +{
> +	int i;
> +
> +	for (i = 0; i < MAX_SECONDARY_PROCS; ++i)
> +		if (mp_fds.secondaries[i] == -1)
> +			break;
> +
> +	if (i >= MAX_SECONDARY_PROCS)
> +		return -1;
> +
> +	mp_fds.secondaries[i] = fd;
> +
> +	return i;
> +}
> +
> +static void
> +del_sec_proc(int fd)
> +{
> +	int i;
> +
> +	for (i = 0; i < MAX_SECONDARY_PROCS; ++i) {
> +		if (mp_fds.secondaries[i] == fd) {
> +			mp_fds.secondaries[i] = -1;
> +			break;
> +		}
> +	}
> +}
> +
> +static int
> +read_msg(int sockfd, char *buf, int buflen, int *fds, int fds_num)
> +{
> +	struct iovec iov;
> +	struct msghdr msgh;
> +	size_t fdsize = fds_num * sizeof(int);
> +	char control[CMSG_SPACE(fdsize)];
> +	struct cmsghdr *cmsg;
> +	struct msg_hdr *hdr = (struct msg_hdr *)buf;
> +	int ret, total;
> +
> +	/* read msg_hdr */
> +	memset(&msgh, 0, sizeof(msgh));
> +	iov.iov_base = hdr;
> +	iov.iov_len  = sizeof(*hdr);
> +
> +	msgh.msg_iov = &iov;
> +	msgh.msg_iovlen = 1;
> +	msgh.msg_control = control;
> +	msgh.msg_controllen = sizeof(control);
> +
> +	ret = recvmsg(sockfd, &msgh, 0);
> +	if (ret != sizeof(struct msg_hdr)) {
> +		RTE_LOG(ERR, EAL, "recvmsg failed\n");
> +		return ret;
> +	}
> +
> +	if (msgh.msg_flags & (MSG_TRUNC | MSG_CTRUNC)) {
> +		RTE_LOG(ERR, EAL, "truncted msg\n");
> +		return -1;
> +	}
> +	total = ret;
> +
> +	/* read auxiliary FDs if any */
> +	for (cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL;
> +		cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
> +		if ((cmsg->cmsg_level == SOL_SOCKET) &&
> +			(cmsg->cmsg_type == SCM_RIGHTS)) {
> +			memcpy(fds, CMSG_DATA(cmsg), fdsize);
> +			break;
> +		}
> +	}
> +
> +	/* read params */
> +	if (hdr->len_params) {
> +		if (hdr->len_params > buflen - (int)sizeof(*hdr))
> +			rte_exit(EXIT_FAILURE, "params too long\n");
> +
> +		ret = read(sockfd, &hdr->params, hdr->len_params);
> +		if (ret != hdr->len_params)
> +			rte_exit(EXIT_FAILURE, "failed to recv params\n");
> +
> +		total += ret;
> +	}
> +
> +	RTE_LOG(INFO, EAL, "read msg: %s, %d\n", hdr->action_name,
> +		(int)sizeof(*hdr) + hdr->len_params);
> +	return total;
> +}
> +
> +static int
> +process_msg(int fd)
> +{
> +	int len;
> +	int params_len;
> +	char buf[MAX_MESSAGE_LENGTH];
> +	int fds[SCM_MAX_FD];
> +	struct msg_hdr *hdr;
> +	struct action_entry *entry;
> +
> +	len = read_msg(fd, buf, MAX_MESSAGE_LENGTH, fds, SCM_MAX_FD);
> +	if (len <= 0) {
> +		RTE_LOG(ERR, EAL, "failed to read message: %s\n",
> +			strerror(errno));
> +		return -1;
> +	}
> +
> +	hdr = (struct msg_hdr *) buf;
> +
> +	entry = find_action_entry_by_name(hdr->action_name);
> +	if (entry == NULL) {
> +		RTE_LOG(ERR, EAL, "cannot find action by: %s\n",
> +			hdr->action_name);
> +		return -1;
> +	}
> +
> +	params_len = len - sizeof(struct msg_hdr);
> +	entry->action(hdr->params, params_len, fds, hdr->fds_num);
> +
> +	return 0;
> +}
> +
> +static int
> +add_secondary(void)
> +{
> +	int fd;
> +	struct epoll_event ev;
> +
> +	while (1) {
> +		fd = accept(mp_fds.listen, NULL, NULL);
> +		if (fd < 0 && errno == EAGAIN)
> +			break;
> +		else if (fd < 0) {
> +			RTE_LOG(ERR, EAL, "primary failed to accept: %s\n",
> +				strerror(errno));
> +			return -1;
> +		}
> +
> +		ev.events = EPOLLIN | EPOLLRDHUP;
> +		ev.data.fd = fd;
> +		if (epoll_ctl(mp_fds.efd, EPOLL_CTL_ADD, fd, &ev) < 0) {
> +			RTE_LOG(ERR, EAL, "failed to add secondary: %s\n",
> +				strerror(errno));
> +			break;
> +		}
> +		if (add_sec_proc(fd) < 0) {
> +			RTE_LOG(ERR, EAL, "too many secondary processes\n");
> +			close(fd);
> +			break;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +static void *
> +mp_handler(void *arg __rte_unused)
> +{
> +	int fd;
> +	int i, n;
> +	struct epoll_event ev;
> +	struct epoll_event *events;
> +	int is_primary = rte_eal_process_type() == RTE_PROC_PRIMARY;
> +
> +	ev.events = EPOLLIN | EPOLLRDHUP;
> +	ev.data.fd = (is_primary) ? mp_fds.listen : mp_fds.primary;
> +	if (epoll_ctl(mp_fds.efd, EPOLL_CTL_ADD, ev.data.fd, &ev) < 0) {
> +		RTE_LOG(ERR, EAL, "failed to epoll_ctl: %s\n",
> +			strerror(errno));
> +		exit(EXIT_FAILURE);
> +	}
> +
> +	events = calloc(20, sizeof ev);
> +
> +	while (1) {
> +		n = epoll_wait(mp_fds.efd, events, 20, -1);
> +		for (i = 0; i < n; i++) {
> +			if (is_primary && events[i].data.fd == mp_fds.listen) {
> +				if (events[i].events != EPOLLIN) {
> +					RTE_LOG(ERR, EAL, "what happens?\n");
> +					exit(EXIT_FAILURE);
> +				}
> +
> +				if (add_secondary() < 0)
> +					break;
> +
> +				continue;
> +			}
> +
> +			fd = events[i].data.fd;
> +
> +			if ((events[i].events & EPOLLIN)) {
> +				if (process_msg(fd) < 0) {
> +					RTE_LOG(ERR, EAL,
> +						"failed to process msg\n");
> +					if (!is_primary)
> +						exit(EXIT_FAILURE);
> +				}
> +				continue;
> +			}
> +
> +			/* EPOLLERR, EPOLLHUP, etc */
> +			if (is_primary) {
> +				RTE_LOG(ERR, EAL, "secondary exit: %d\n", fd);
> +				epoll_ctl(mp_fds.efd, EPOLL_CTL_DEL, fd, NULL);
> +				del_sec_proc(fd);
> +				close(fd);
> +			} else {
> +				RTE_LOG(ERR, EAL, "primary exits, so do I\n");
> +				/* Exit secondary when primary exits? */
> +				exit(EXIT_FAILURE);
> +			}
> +		}
> +	}
> +
> +	return NULL;
> +}
> +
> +int
> +rte_eal_mp_channel_init(void)
> +{
> +	int i, fd, ret;
> +	const char *path;
> +	struct sockaddr_un un;
> +	pthread_t tid;
> +	char thread_name[RTE_MAX_THREAD_NAME_LEN];
> +
> +	mp_fds.efd = epoll_create1(0);
> +	if (mp_fds.efd < 0) {
> +		RTE_LOG(ERR, EAL, "epoll_create1 failed\n");
> +		return -1;
> +	}
> +
> +	fd = socket(AF_UNIX, SOCK_STREAM, 0);
> +	if (fd < 0) {
> +		RTE_LOG(ERR, EAL, "Failed to create unix socket\n");
> +		return -1;
> +	}
> +
> +	memset(&un, 0, sizeof(un));
> +	un.sun_family = AF_UNIX;
> +	path = eal_mp_unix_path();
> +	strncpy(un.sun_path, path, sizeof(un.sun_path));
> +	un.sun_path[sizeof(un.sun_path) - 1] = '\0';
> +
> +	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> +		for (i = 0; i < MAX_SECONDARY_PROCS; ++i)
> +			mp_fds.secondaries[i] = -1;
> +
> +		if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
> +			RTE_LOG(ERR, EAL, "cannot set nonblocking mode\n");
> +			close(fd);
> +			return -1;
> +		}
> +
> +		/* The file still exists since last run */
> +		unlink(path);
> +
> +		ret = bind(fd, (struct sockaddr *)&un, sizeof(un));
> +		if (ret < 0) {
> +			RTE_LOG(ERR, EAL, "failed to bind to %s: %s\n",
> +				path, strerror(errno));
> +			close(fd);
> +			return -1;
> +		}
> +		RTE_LOG(INFO, EAL, "primary bind to %s\n", path);
> +
> +		ret = listen(fd, 1024);
> +		if (ret < 0) {
> +			RTE_LOG(ERR, EAL, "failed to listen: %s\n",
> +				strerror(errno));
> +			close(fd);
> +			return -1;
> +		}
> +		mp_fds.listen = fd;
> +	} else {
> +		ret = connect(fd, (struct sockaddr *)&un, sizeof(un));
> +		if (ret < 0) {
> +			RTE_LOG(ERR, EAL, "failed to connect primary\n");
> +			return -1;
> +		}
> +		mp_fds.primary = fd;
> +	}
> +
> +	ret = pthread_create(&tid, NULL, mp_handler, NULL);
> +	if (ret < 0) {
> +		RTE_LOG(ERR, EAL, "failed to create thead: %s\n",
> +			strerror(errno));
> +		close(fd);
> +		close(mp_fds.efd);
> +		return -1;
> +	}
> +
> +	snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
> +		 "rte_mp_handle");
> +	ret = rte_thread_setname(tid, thread_name);
> +	if (ret < 0) {
> +		RTE_LOG(ERR, EAL, "failed to set thead name\n");
> +		close(fd);
> +		close(mp_fds.efd);
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +send_msg(int fd, struct msghdr *p_msgh)
> +{
> +	int ret;
> +
> +	do {
> +		ret = sendmsg(fd, p_msgh, 0);
> +	} while (ret < 0 && errno == EINTR);
> +
> +	if (ret < 0)
> +		RTE_LOG(ERR, EAL, "failed to send msg: %s\n", strerror(errno));
> +
> +	return ret;
> +}
> +
> +int
> +rte_eal_mp_sendmsg(const char *action_name,
> +				  const void *params,
> +				  int len_params,
> +				  int fds[],
> +				  int fds_num)
> +{
> +	int i;
> +	int ret = 0;
> +	struct msghdr msgh;
> +	struct iovec iov;
> +	size_t fd_size = fds_num * sizeof(int);
> +	char control[CMSG_SPACE(fd_size)];
> +	struct cmsghdr *cmsg;
> +	struct msg_hdr *msg;
> +	int len_msg;
> +
> +	if (fds_num > SCM_MAX_FD) {
> +		RTE_LOG(ERR, EAL,
> +			"Cannot send more than %d FDs\n", SCM_MAX_FD);
> +		return -E2BIG;
> +	}
> +
> +	len_msg = sizeof(struct msg_hdr) + len_params;
> +	if (len_msg > MAX_MESSAGE_LENGTH) {
> +		RTE_LOG(ERR, EAL, "Message is too long\n");
> +		return -ENOMEM;
> +	}
> +
> +	RTE_LOG(INFO, EAL, "send msg: %s, %d\n", action_name, len_msg);
> +
> +	msg = malloc(len_msg);
> +	if (!msg) {
> +		RTE_LOG(ERR, EAL, "Cannot alloc memory for msg\n");
> +		return -ENOMEM;
> +	}
> +	memset(msg, 0, len_msg);
> +	strcpy(msg->action_name, action_name);
> +	msg->fds_num = fds_num;
> +	msg->len_params = len_params;
> +	memcpy(msg->params, params, len_params);
> +
> +	memset(&msgh, 0, sizeof(msgh));
> +	memset(control, 0, sizeof(control));
> +
> +	iov.iov_base = (uint8_t *)msg;
> +	iov.iov_len = len_msg;
> +
> +	msgh.msg_iov = &iov;
> +	msgh.msg_iovlen = 1;
> +	msgh.msg_control = control;
> +	msgh.msg_controllen = sizeof(control);
> +
> +	cmsg = CMSG_FIRSTHDR(&msgh);
> +	cmsg->cmsg_len = CMSG_LEN(fd_size);
> +	cmsg->cmsg_level = SOL_SOCKET;
> +	cmsg->cmsg_type = SCM_RIGHTS;
> +	memcpy(CMSG_DATA(cmsg), fds, fd_size);
> +
> +	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> +		for (i = 0; i < MAX_SECONDARY_PROCS; ++i) {
> +			if (mp_fds.secondaries[i] == -1)
> +				continue;
> +
> +			ret = send_msg(mp_fds.secondaries[i], &msgh);
> +			if (ret < 0)
> +				break;
> +		}
> +	} else {
> +		ret = send_msg(mp_fds.primary, &msgh);
> +	}
> +
> +	free(msg);
> +
> +	return ret;
> +}
> diff --git a/lib/librte_eal/common/eal_filesystem.h b/lib/librte_eal/common/eal_filesystem.h
> index 8acbd99..3d9514f 100644
> --- a/lib/librte_eal/common/eal_filesystem.h
> +++ b/lib/librte_eal/common/eal_filesystem.h
> @@ -67,6 +67,24 @@ eal_runtime_config_path(void)
>  	return buffer;
>  }
> 
> +/** Path of primary/secondary communication unix socket file. */
> +#define MP_UNIX_PATH_FMT "%s/.%s_unix"
> +static inline const char *
> +eal_mp_unix_path(void)
> +{
> +	static char buffer[PATH_MAX]; /* static so auto-zeroed */
> +	const char *directory = default_config_dir;
> +	const char *home_dir = getenv("HOME");
> +
> +	if (getuid() != 0 && home_dir != NULL)
> +		directory = home_dir;
> +	snprintf(buffer, sizeof(buffer) - 1, MP_UNIX_PATH_FMT,
> +		 directory, internal_config.hugefile_prefix);
> +
> +	return buffer;
> +
> +}
> +
>  /** Path of hugepage info file. */
>  #define HUGEPAGE_INFO_FMT "%s/.%s_hugepage_info"
> 
> diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
> index 597d82e..7fbfbdf 100644
> --- a/lib/librte_eal/common/eal_private.h
> +++ b/lib/librte_eal/common/eal_private.h
> @@ -355,4 +355,14 @@ bool rte_eal_using_phys_addrs(void);
>   */
>  struct rte_bus *rte_bus_find_by_device_name(const char *str);
> 
> +/**
> + * Create the unix channel for primary/secondary communication.
> + *
> + * @return
> + *   0 on success;
> + *   (<0) on failure.
> + */
> +
> +int rte_eal_mp_channel_init(void);
> +
>  #endif /* _EAL_PRIVATE_H_ */
> diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
> index 0e7363d..4e3d4d2 100644
> --- a/lib/librte_eal/common/include/rte_eal.h
> +++ b/lib/librte_eal/common/include/rte_eal.h
> @@ -210,6 +210,74 @@ int rte_eal_init(int argc, char **argv);
>  int rte_eal_primary_proc_alive(const char *config_file_path);
> 
>  /**
> + * Action function typedef used by other components.
> + *
> + * As we create unix socket channel for primary/secondary communication, use
> + * this function typedef to register action for coming messages.
> + */
> +typedef int (*rte_eal_mp_t)(const void *params, int len,
> +			    int fds[], int fds_num);
> +/**
> + * Register an action function for primary/secondary communication.
> + *
> + * Call this function to register an action, if the calling component wants
> + * to response the messages from the corresponding component in its primary
> + * process or secondary processes.
> + *
> + * @param action_name
> + *   The action_name argument plays as the nonredundant key to find the action.
> + *
> + * @param action
> + *   The action argument is the function pointer to the action function.
> + *
> + * @return
> + *  - 0 on success.
> + *  - (<0) on failure.
> + */
> +int rte_eal_mp_action_register(const char *action_name, rte_eal_mp_t action);
> +/**
> + * Unregister an action function for primary/secondary communication.
> + *
> + * Call this function to unregister an action  if the calling component does
> + * not want to response the messages from the corresponding component in its
> + * primary process or secondary processes.
> + *
> + * @param action_name
> + *   The action_name argument plays as the nonredundant key to find the action.
> + *
> + */
> +void rte_eal_mp_action_unregister(const char *name);
> +
> +/**
> + * Send a message to the primary process or the secondary processes.
> + *
> + * This function will send a message which will be responsed by the action
> + * identified by action_name of the process on the other side.
> + *
> + * @param action_name
> + *   The action_name argument is used to identify which action will be used.
> + *
> + * @param params
> + *   The params argument contains the customized message.
> + *
> + * @param len_params
> + *   The len_params argument is the length of the customized message.
> + *
> + * @param fds
> + *   The fds argument is an array of fds sent with sendmsg.
> + *
> + * @param fds_num
> + *   The fds_num argument is number of fds to be sent with sendmsg.
> + *
> + * @return
> + *  - (>=0) on success.
> + *  - (<0) on failure.
> + */
> +int
> +rte_eal_mp_sendmsg(const char *action_name, const void *params,
> +		   int len_params, int fds[], int fds_num);
> +
> +/**
>   * Usage function typedef used by the application usage function.
>   *
>   * Use this function typedef to define and call rte_set_applcation_usage_hook()
> diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
> index 48f12f4..4b491b9 100644
> --- a/lib/librte_eal/linuxapp/eal/eal.c
> +++ b/lib/librte_eal/linuxapp/eal/eal.c
> @@ -873,6 +873,12 @@ rte_eal_init(int argc, char **argv)
> 
>  	eal_check_mem_on_local_socket();
> 
> +	if (rte_eal_mp_channel_init() < 0) {
> +		rte_eal_init_alert("failed to init mp channel\n");
> +		rte_errno = EFAULT;
> +		return -1;
> +	}
> +
>  	if (eal_plugins_init() < 0)
>  		rte_eal_init_alert("Cannot init plugins\n");
> 
> diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> index 8c08b8d..2e1d0e5 100644
> --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> @@ -243,3 +243,11 @@ EXPERIMENTAL {
>  	rte_service_start_with_defaults;
> 
>  } DPDK_17.08;
> +
> +EXPERIMENTAL {
> +	global:
> +
> +	rte_eal_primary_secondary_add_action;
> +	rte_eal_primary_secondary_del_action;
> +	rte_eal_primary_secondary_sendmsg;
> +} DPDK_17.11;
> --
> 2.7.4

  reply	other threads:[~2017-09-28 15:01 UTC|newest]

Thread overview: 158+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-25  9:40 [dpdk-dev] [PATCH 00/12] support to run vdev in the secondary process Jianfeng Tan
2017-08-25  9:40 ` [dpdk-dev] [PATCH 01/12] cryptodev: remove crypto vdev init Jianfeng Tan
2017-09-18 11:48   ` De Lara Guarch, Pablo
2017-08-25  9:40 ` [dpdk-dev] [PATCH 02/12] eal: avoid calling rte_vdev_init() Jianfeng Tan
2017-08-29 12:50   ` Gaëtan Rivet
2017-08-29 22:25     ` Tan, Jianfeng
2017-08-25  9:40 ` [dpdk-dev] [PATCH 03/12] crypto: move vdev helper functions into dedicated file Jianfeng Tan
2017-09-18 11:51   ` De Lara Guarch, Pablo
2017-08-25  9:40 ` [dpdk-dev] [PATCH 04/12] vdev: move to drivers/bus Jianfeng Tan
2017-08-29 13:04   ` Gaëtan Rivet
2017-08-29 22:47     ` Tan, Jianfeng
2017-09-18 11:47       ` De Lara Guarch, Pablo
2017-09-19  6:01         ` Tan, Jianfeng
2017-08-25  9:40 ` [dpdk-dev] [PATCH 05/12] bus/vdev: change log type from EAL to PMD Jianfeng Tan
2017-08-29 12:54   ` Gaëtan Rivet
2017-08-29 22:27     ` Tan, Jianfeng
2017-08-25  9:40 ` [dpdk-dev] [PATCH 06/12] eal: add channel for primary/secondary communication Jianfeng Tan
2017-09-18 13:49   ` Jiayu Hu
2017-09-21  6:11     ` Tan, Jianfeng
2017-09-20  3:00   ` Jiayu Hu
2017-09-21  6:53     ` Tan, Jianfeng
2017-09-27 12:19   ` Yuanhan Liu
2017-09-28 13:50     ` Tan, Jianfeng
2017-09-29  1:24       ` Yuanhan Liu
2017-09-29 10:09         ` Burakov, Anatoly
2017-09-29 10:25           ` Yuanhan Liu
2017-08-25  9:40 ` [dpdk-dev] [PATCH 07/12] bus/vdev: scan and probe vdev in secondary processes Jianfeng Tan
2017-08-25  9:40 ` [dpdk-dev] [PATCH 08/12] ethdev: support attach vdev in secondary process Jianfeng Tan
2017-08-25  9:40 ` [dpdk-dev] [PATCH 09/12] vhost: allocate virtio_net in memzone Jianfeng Tan
2017-08-25  9:40 ` [dpdk-dev] [PATCH 10/12] vhost: support to kick in secondary process Jianfeng Tan
2017-09-21  3:33   ` Yuanhan Liu
2017-09-21  7:04     ` Tan, Jianfeng
2017-09-21  9:17       ` Yuanhan Liu
2017-09-22  2:30         ` Tan, Jianfeng
2017-09-27  9:36           ` Yuanhan Liu
2017-09-28  5:10             ` Tan, Jianfeng
2017-09-28  8:09             ` Tan, Jianfeng
2017-09-30  8:18               ` Yuanhan Liu
2017-09-30 10:50                 ` Tan, Jianfeng
2017-08-25  9:40 ` [dpdk-dev] [PATCH 11/12] net/vhost: support to run in the " Jianfeng Tan
2017-09-21  4:29   ` Yuanhan Liu
2017-08-25  9:40 ` [dpdk-dev] [PATCH 12/12] examples/helloworld: do not exit automatically Jianfeng Tan
2017-09-18 11:44   ` De Lara Guarch, Pablo
2017-09-19  5:07     ` Tan, Jianfeng
2017-09-28 13:55 ` [dpdk-dev] [PATCH v2 00/12] support to run vdev in the secondary process Jianfeng Tan
2017-09-28 13:55   ` [dpdk-dev] [PATCH v2 01/12] cryptodev: remove crypto vdev init API Jianfeng Tan
2017-09-28 13:55   ` [dpdk-dev] [PATCH v2 02/12] eal: avoid calling rte_vdev_init() Jianfeng Tan
2017-09-28 13:55   ` [dpdk-dev] [PATCH v2 03/12] cryptodev: avoid dependency on rte_vdev.h Jianfeng Tan
2017-10-05 13:13     ` Jan Blunck
2017-10-09  1:04       ` Tan, Jianfeng
2017-09-28 13:55   ` [dpdk-dev] [PATCH v2 04/12] bus/fslmc: introduce RTE_LOGTYPE_BUS for bus drivers Jianfeng Tan
2017-09-28 13:55   ` [dpdk-dev] [PATCH v2 05/12] bus/vdev: move to vdev bus to drivers/bus Jianfeng Tan
2017-09-28 13:55   ` [dpdk-dev] [PATCH v2 06/12] bus/vdev: normalize log type Jianfeng Tan
2017-09-28 13:55   ` [dpdk-dev] [PATCH v2 07/12] eal: add channel for primary/secondary communication Jianfeng Tan
2017-09-28 15:01     ` Ananyev, Konstantin [this message]
2017-09-28 15:29       ` Burakov, Anatoly
2017-09-29  1:03         ` Tan, Jianfeng
2017-09-29 10:00           ` Burakov, Anatoly
2017-09-30  4:07             ` Tan, Jianfeng
2017-10-02 10:08               ` Burakov, Anatoly
2017-10-05 12:01     ` Jan Blunck
2017-10-09  1:27       ` Tan, Jianfeng
2017-09-28 13:55   ` [dpdk-dev] [PATCH v2 08/12] bus/vdev: scan and probe vdev in secondary processes Jianfeng Tan
2017-10-05 13:04     ` Jan Blunck
2017-10-09  1:08       ` Tan, Jianfeng
2017-09-28 13:55   ` [dpdk-dev] [PATCH v2 09/12] ethdev: support attach vdev in secondary process Jianfeng Tan
2017-10-05 14:26     ` Jan Blunck
2017-10-09  0:56       ` Tan, Jianfeng
2017-09-28 13:55   ` [dpdk-dev] [PATCH v2 10/12] vhost: allocate virtio_net in memzone Jianfeng Tan
2017-09-28 13:55   ` [dpdk-dev] [PATCH v2 11/12] vhost: support to kick in secondary process Jianfeng Tan
2017-09-28 13:55   ` [dpdk-dev] [PATCH v2 12/12] net/vhost: support to run in the " Jianfeng Tan
2017-09-29  8:28     ` Yuanhan Liu
2017-09-30  4:03       ` Tan, Jianfeng
2017-09-30  8:16         ` Yuanhan Liu
2017-09-30 10:06           ` Tan, Jianfeng
2017-09-30 11:49           ` Yuanhan Liu
2017-10-01 23:48             ` Tan, Jianfeng
2017-09-30  8:23     ` Yuanhan Liu
2017-09-30 10:53       ` Tan, Jianfeng
2017-09-30 11:34       ` Yuanhan Liu
2017-10-01 23:46         ` Tan, Jianfeng
2017-10-09  3:20 ` [dpdk-dev] [PATCH v3 0/5] move vdev into drivers/bus Jianfeng Tan
2017-10-09  3:20   ` [dpdk-dev] [PATCH v3 1/5] cryptodev: remove crypto vdev init API Jianfeng Tan
2017-10-09  3:20   ` [dpdk-dev] [PATCH v3 2/5] eal: avoid calling rte_vdev_init() Jianfeng Tan
2017-10-09  3:20   ` [dpdk-dev] [PATCH v3 3/5] bus: introduce RTE_LOGTYPE_BUS for bus drivers Jianfeng Tan
2017-10-09  3:20   ` [dpdk-dev] [PATCH v3 4/5] bus/vdev: move to vdev bus to drivers/bus Jianfeng Tan
2017-10-09  3:20   ` [dpdk-dev] [PATCH v3 5/5] bus/vdev: normalize log type Jianfeng Tan
2017-10-09 10:55   ` [dpdk-dev] [PATCH v4 0/5] move vdev into drivers/bus Jianfeng Tan
2017-10-09 10:55     ` [dpdk-dev] [PATCH v4 1/5] bus/vdev: scan and probe vdev in secondary processes Jianfeng Tan
2017-10-09 10:55     ` [dpdk-dev] [PATCH v4 2/5] ethdev: support attach vdev in secondary process Jianfeng Tan
2017-10-09 10:55     ` [dpdk-dev] [PATCH v4 3/5] vhost: allocate virtio_net in memzone Jianfeng Tan
2017-10-09 10:55     ` [dpdk-dev] [PATCH v4 4/5] vhost: support to kick in secondary process Jianfeng Tan
2017-10-09 10:55     ` [dpdk-dev] [PATCH v4 5/5] net/vhost: support to run in the " Jianfeng Tan
2017-10-09 11:08     ` [dpdk-dev] [PATCH v4 0/5] move vdev into drivers/bus Tan, Jianfeng
2017-10-09 11:27   ` [dpdk-dev] [PATCH v5 " Jianfeng Tan
2017-10-09 11:27     ` [dpdk-dev] [PATCH v5 1/5] cryptodev: remove crypto vdev init API Jianfeng Tan
2017-10-09 11:27     ` [dpdk-dev] [PATCH v5 2/5] eal: remove dependency on vdev Jianfeng Tan
2017-10-09 11:27     ` [dpdk-dev] [PATCH v5 3/5] bus: introduce new log type for bus drivers Jianfeng Tan
2017-10-11  6:54       ` Shreyansh Jain
2017-10-11 10:42         ` Tan, Jianfeng
2017-10-11 11:20           ` Shreyansh Jain
2017-10-12  2:14             ` Tan, Jianfeng
2017-10-09 11:27     ` [dpdk-dev] [PATCH v5 4/5] bus/vdev: move to vdev bus to drivers/bus Jianfeng Tan
2017-10-09 11:27     ` [dpdk-dev] [PATCH v5 5/5] bus/vdev: normalize log type Jianfeng Tan
2017-10-12  8:46   ` [dpdk-dev] [PATCH v6 0/4] move vdev into drivers/bus Jianfeng Tan
2017-10-12  8:46     ` [dpdk-dev] [PATCH v6 1/4] cryptodev: remove crypto vdev init API Jianfeng Tan
2017-10-12 10:06       ` Thomas Monjalon
2017-10-12  8:46     ` [dpdk-dev] [PATCH v6 2/4] eal: remove dependency on vdev Jianfeng Tan
2017-10-12  8:46     ` [dpdk-dev] [PATCH v6 3/4] bus/vdev: move to vdev bus to drivers/bus Jianfeng Tan
2017-10-12  8:46     ` [dpdk-dev] [PATCH v6 4/4] bus/vdev: change log type Jianfeng Tan
2017-10-13  2:04   ` [dpdk-dev] [PATCH v7 0/4] move vdev into drivers/bus Jianfeng Tan
2017-10-13  2:04     ` [dpdk-dev] [PATCH v7 1/4] ethdev: support attach vdev in secondary process Jianfeng Tan
2017-10-13  2:04     ` [dpdk-dev] [PATCH v7 2/4] vhost: allocate virtio_net in memzone Jianfeng Tan
2017-10-13  2:04     ` [dpdk-dev] [PATCH v7 3/4] vhost: support to kick in secondary process Jianfeng Tan
2017-10-13  2:04     ` [dpdk-dev] [PATCH v7 4/4] net/vhost: support to run in the " Jianfeng Tan
2017-10-13  8:26     ` [dpdk-dev] [PATCH v7 0/4] move vdev into drivers/bus Thomas Monjalon
2017-10-13 11:49       ` Tan, Jianfeng
2017-10-13 11:51   ` Jianfeng Tan
2017-10-13 11:51     ` [dpdk-dev] [PATCH v7 1/4] cryptodev: remove crypto vdev init API Jianfeng Tan
2017-10-23 10:06       ` De Lara Guarch, Pablo
2017-10-13 11:51     ` [dpdk-dev] [PATCH v7 2/4] eal: remove dependency on vdev Jianfeng Tan
2017-10-13 11:52     ` [dpdk-dev] [PATCH v7 3/4] bus/vdev: move to vdev bus to drivers/bus Jianfeng Tan
2017-10-23 14:34       ` De Lara Guarch, Pablo
2017-10-13 11:52     ` [dpdk-dev] [PATCH v7 4/4] bus/vdev: change log type Jianfeng Tan
2017-10-25 17:10   ` [dpdk-dev] [PATCH v8 0/4] move vdev into drivers/bus Jianfeng Tan
2017-10-25 17:10     ` [dpdk-dev] [PATCH v8 1/4] cryptodev: remove crypto vdev init API Jianfeng Tan
2017-10-25 17:10     ` [dpdk-dev] [PATCH v8 2/4] eal: remove dependency on vdev Jianfeng Tan
2017-10-25 17:10     ` [dpdk-dev] [PATCH v8 3/4] bus/vdev: move to vdev bus to drivers/bus Jianfeng Tan
2017-10-25 21:32       ` De Lara Guarch, Pablo
2017-10-25 23:03       ` Gaëtan Rivet
2017-10-25 17:10     ` [dpdk-dev] [PATCH v8 4/4] bus/vdev: change log type Jianfeng Tan
2017-10-27  1:06   ` [dpdk-dev] [PATCH v0 0/4] move vdev into drivers/bus Jianfeng Tan
2017-10-27  1:06     ` [dpdk-dev] [PATCH v9 1/4] cryptodev: remove crypto vdev init API Jianfeng Tan
2017-10-27  1:06     ` [dpdk-dev] [PATCH v9 2/4] eal: remove dependency on vdev Jianfeng Tan
2017-10-27  1:06     ` [dpdk-dev] [PATCH v9 3/4] bus/vdev: move to vdev bus to drivers/bus Jianfeng Tan
2017-10-27  7:56       ` Thomas Monjalon
2017-10-27  8:19         ` Tan, Jianfeng
2017-10-27  8:53           ` Thomas Monjalon
2017-10-27 16:57             ` Gaëtan Rivet
2017-10-27  1:06     ` [dpdk-dev] [PATCH v9 4/4] bus/vdev: change log type Jianfeng Tan
2017-10-27  3:23   ` [dpdk-dev] [PATCH v10 0/4] move vdev into drivers/bus Jianfeng Tan
2017-10-27  3:23     ` [dpdk-dev] [PATCH v10 1/4] cryptodev: remove crypto vdev init API Jianfeng Tan
2017-10-27  3:23     ` [dpdk-dev] [PATCH v10 2/4] eal: remove dependency on vdev Jianfeng Tan
2017-10-27  3:23     ` [dpdk-dev] [PATCH v10 3/4] bus/vdev: move to vdev bus to drivers/bus Jianfeng Tan
2017-10-27  3:23     ` [dpdk-dev] [PATCH v10 4/4] bus/vdev: change log type Jianfeng Tan
2017-10-30  8:28   ` [dpdk-dev] [PATCH v11 0/4] move vdev into drivers/bus Jianfeng Tan
2017-10-30  8:28     ` [dpdk-dev] [PATCH v11 1/4] cryptodev: remove crypto vdev init API Jianfeng Tan
2017-10-30  8:28     ` [dpdk-dev] [PATCH v11 2/4] eal: remove dependency on vdev Jianfeng Tan
2017-10-30  8:28     ` [dpdk-dev] [PATCH v11 3/4] bus/vdev: move to vdev bus to drivers/bus Jianfeng Tan
2017-11-07  2:43       ` Thomas Monjalon
2017-11-07  6:21         ` Tan, Jianfeng
2017-10-30  8:28     ` [dpdk-dev] [PATCH v11 4/4] bus/vdev: change log type Jianfeng Tan
2017-11-07  6:54   ` [dpdk-dev] [PATCH v12 0/4] move vdev into drivers/bus Jianfeng Tan
2017-11-07  6:54     ` [dpdk-dev] [PATCH v12 1/4] cryptodev: remove crypto vdev init API Jianfeng Tan
2017-11-07  6:54     ` [dpdk-dev] [PATCH v12 2/4] eal: remove dependency on vdev Jianfeng Tan
2017-11-07  6:54     ` [dpdk-dev] [PATCH v12 3/4] bus/vdev: move to vdev bus to drivers/bus Jianfeng Tan
2017-11-07  6:54     ` [dpdk-dev] [PATCH v12 4/4] bus/vdev: change log type Jianfeng Tan
2017-11-07 15:43     ` [dpdk-dev] [PATCH v12 0/4] move vdev into drivers/bus Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2601191342CEEE43887BDE71AB9772584F24FF69@irsmsx105.ger.corp.intel.com \
    --to=konstantin.ananyev@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=jianfeng.tan@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=mtetsuyah@gmail.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=thomas@monjalon.net \
    --cc=yliu@fridaylinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).