Skip to content

Commit

Permalink
eal: add channel for multi-process communication
Browse files Browse the repository at this point in the history
Previouly, there are three channels for multi-process
(i.e., primary/secondary) communication.
  1. Config-file based channel, in which, the primary process writes
     info into a pre-defined config file, and the secondary process
     reads the info out.
  2. vfio submodule has its own channel based on unix socket for the
     secondary process to get container fd and group fd from the
     primary process.
  3. pdump submodule also has its own channel based on unix socket for
     packet dump.

It'd be good to have a generic communication channel for multi-process
communication to accommodate the requirements including:
  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.
  d. A send message request needs the other side to response immediately.

This patch proposes to create a communication channel, based on datagram
unix socket, for above requirements. Each process will block on a unix
socket waiting for messages from the peers.

Three new APIs are added:

  1. rte_eal_mp_action_register() is used to register an action,
     indexed by a string, when a component at receiver side would like
     to response the messages from the peer processe.
  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, and returns
     immediately. If there are n secondary processes, the primary
     process will send n messages.

Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
  • Loading branch information
Jianfeng Tan authored and tmonjalo committed Jan 30, 2018
1 parent 367bc2a commit bacaa27
Show file tree
Hide file tree
Showing 8 changed files with 575 additions and 7 deletions.
9 changes: 9 additions & 0 deletions doc/guides/rel_notes/release_18_02.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ New Features
renamed the application from SW PMD specific ``eventdev_pipeline_sw_pmd``
to PMD agnostic ``eventdev_pipeline``.

* **Added new multi-process communication channel**

Added a generic channel in EAL for multi-process (primary/secondary) communication.
Consumers of this channel need to register an action with an action name to response
a message received; the actions will be identified by the action name and executed
in the context of a new dedicated thread for this channel. The list of new APIs:

* ``rte_mp_register`` and ``rte_mp_unregister`` are for action (un)registration.
* ``rte_mp_sendmsg`` is for sending a message without blocking for a response.

API Changes
-----------
Expand Down
10 changes: 9 additions & 1 deletion lib/librte_eal/bsdapp/eal/eal.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*-
* BSD LICENSE
*
* Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
* Copyright(c) 2010-2018 Intel Corporation. All rights reserved.
* Copyright(c) 2014 6WIND S.A.
* All rights reserved.
*
Expand Down Expand Up @@ -604,6 +604,14 @@ rte_eal_init(int argc, char **argv)

rte_config_init();

if (rte_mp_channel_init() < 0) {
rte_eal_init_alert("failed to init mp channel\n");
if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
rte_errno = EFAULT;
return -1;
}
}

if (rte_eal_memory_init() < 0) {
rte_eal_init_alert("Cannot init memory\n");
rte_errno = ENOMEM;
Expand Down

0 comments on commit bacaa27

Please sign in to comment.