eal: add synchronous multi-process communication
authorJianfeng Tan <jianfeng.tan@intel.com>
Tue, 30 Jan 2018 06:58:09 +0000 (06:58 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 30 Jan 2018 14:17:23 +0000 (15:17 +0100)
commit783b6e54971d63f795e3ef71ced89f699bc01f81
tree769e19f1079f8065e67a71b856c0b0271b28c323
parentbacaa2754017e7d7baf27b8bcef8cdc909b30a26
eal: add synchronous multi-process communication

We need the synchronous way for multi-process communication,
i.e., blockingly waiting for reply message when we send a request
to the peer process.

We add two APIs rte_eal_mp_request() and rte_eal_mp_reply() for
such use case. By invoking rte_eal_mp_request(), a request message
is sent out, and then it waits there for a reply message. The caller
can specify the timeout. And the response messages will be collected
and returned so that the caller can decide how to translate them.

The API rte_eal_mp_reply() is always called by an mp action handler.
Here we add another parameter for rte_eal_mp_t so that the action
handler knows which peer address to reply.

       sender-process                receiver-process
   ----------------------            ----------------

    thread-n
     |_rte_eal_mp_request() ----------> mp-thread
        |_timedwait()                    |_process_msg()
                                           |_action()
                                               |_rte_eal_mp_reply()
        mp_thread  <---------------------|
                  |_process_msg()
                     |_signal(send_thread)
    thread-m <----------|
     |_collect-reply

 * A secondary process is only allowed to talk to the primary process.
 * If there are multiple secondary processes for the primary process,
   it will send request to peer1, collect response from peer1; then
   send request to peer2, collect response from peer2, and so on.
 * When thread-n is sending request, thread-m of that process can send
   request at the same time.
 * For pair <action_name, peer>, we guarantee that only one such request
   is on the fly.

Suggested-by: Anatoly Burakov <anatoly.burakov@intel.com>
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>
doc/guides/rel_notes/release_18_02.rst
lib/librte_eal/common/eal_common_proc.c
lib/librte_eal/common/include/rte_eal.h
lib/librte_eal/rte_eal_version.map