xref: /dpdk/doc/guides/prog_guide/multi_proc_support.rst (revision 41dd9a6bc2d9c6e20e139ad713cc9d172572dd43)
15630257fSFerruh Yigit..  SPDX-License-Identifier: BSD-3-Clause
25630257fSFerruh Yigit    Copyright(c) 2010-2014 Intel Corporation.
3fc1f2750SBernard Iremonger
4fc1f2750SBernard IremongerMulti-process Support
5fc1f2750SBernard Iremonger=====================
6fc1f2750SBernard Iremonger
748624fd9SSiobhan ButlerIn the DPDK, multi-process support is designed to allow a group of DPDK processes
8fc1f2750SBernard Iremongerto work together in a simple transparent manner to perform packet processing,
9dab1d475SJerin Jacobor other workloads.
10fc1f2750SBernard IremongerTo support this functionality,
1148624fd9SSiobhan Butlera number of additions have been made to the core DPDK Environment Abstraction Layer (EAL).
12fc1f2750SBernard Iremonger
1348624fd9SSiobhan ButlerThe EAL has been modified to allow different types of DPDK processes to be spawned,
14fc1f2750SBernard Iremongereach with different permissions on the hugepage memory used by the applications.
15fc1f2750SBernard IremongerFor now, there are two types of process specified:
16fc1f2750SBernard Iremonger
17fc1f2750SBernard Iremonger*   primary processes, which can initialize and which have full permissions on shared memory
18fc1f2750SBernard Iremonger
19fc1f2750SBernard Iremonger*   secondary processes, which cannot initialize shared memory,
20fc1f2750SBernard Iremonger    but can attach to pre- initialized shared memory and create objects in it.
21fc1f2750SBernard Iremonger
2248624fd9SSiobhan ButlerStandalone DPDK processes are primary processes,
23fc1f2750SBernard Iremongerwhile secondary processes can only run alongside a primary process or
24fc1f2750SBernard Iremongerafter a primary process has already configured the hugepage shared memory for them.
25fc1f2750SBernard Iremonger
26deedc8d9SJunjie Chen.. note::
27deedc8d9SJunjie Chen
28deedc8d9SJunjie Chen    Secondary processes should run alongside primary process with same DPDK version.
29deedc8d9SJunjie Chen
307e323feaSVipin Varghese    Secondary processes which requires access to physical devices in Primary process, must
31db27370bSStephen Hemminger    be passed with the same allow and block options.
327e323feaSVipin Varghese
33fc1f2750SBernard IremongerTo support these two process types, and other multi-process setups described later,
34fc1f2750SBernard Iremongertwo additional command-line parameters are available to the EAL:
35fc1f2750SBernard Iremonger
36f02730abSFerruh Yigit*   ``--proc-type:`` for specifying a given process instance as the primary or secondary DPDK instance
37fc1f2750SBernard Iremonger
38f02730abSFerruh Yigit*   ``--file-prefix:`` to allow processes that do not want to co-operate to have different memory regions
39fc1f2750SBernard Iremonger
4048624fd9SSiobhan ButlerA number of example applications are provided that demonstrate how multiple DPDK processes can be used together.
41fc1f2750SBernard IremongerThese are more fully documented in the "Multi- process Sample Application" chapter
4248624fd9SSiobhan Butlerin the *DPDK Sample Application's User Guide*.
43fc1f2750SBernard Iremonger
44fc1f2750SBernard IremongerMemory Sharing
45fc1f2750SBernard Iremonger--------------
46fc1f2750SBernard Iremonger
4748624fd9SSiobhan ButlerThe key element in getting a multi-process application working using the DPDK is to ensure that
48fc1f2750SBernard Iremongermemory resources are properly shared among the processes making up the multi-process application.
49fc1f2750SBernard IremongerOnce there are blocks of shared memory available that can be accessed by multiple processes,
50fc1f2750SBernard Iremongerthen issues such as inter-process communication (IPC) becomes much simpler.
51fc1f2750SBernard Iremonger
52fc1f2750SBernard IremongerOn application start-up in a primary or standalone process,
5348624fd9SSiobhan Butlerthe DPDK records to memory-mapped files the details of the memory configuration it is using - hugepages in use,
54fc1f2750SBernard Iremongerthe virtual addresses they are mapped at, the number of memory channels present, etc.
55fc1f2750SBernard IremongerWhen a secondary process is started, these files are read and the EAL recreates the same memory configuration
56fc1f2750SBernard Iremongerin the secondary process so that all memory zones are shared between processes and all pointers to that memory are valid,
57fc1f2750SBernard Iremongerand point to the same objects, in both processes.
58fc1f2750SBernard Iremonger
59fc1f2750SBernard Iremonger.. note::
60fc1f2750SBernard Iremonger
6129e30cbcSThomas Monjalon    Refer to `Multi-process Limitations`_ for details of
62fc1f2750SBernard Iremonger    how Linux kernel Address-Space Layout Randomization (ASLR) can affect memory sharing.
63fc1f2750SBernard Iremonger
64b3173932SAnatoly Burakov    If the primary process was run with ``--legacy-mem`` or
65b3173932SAnatoly Burakov    ``--single-file-segments`` switch, secondary processes must be run with the
66b3173932SAnatoly Burakov    same switch specified. Otherwise, memory corruption may occur.
67b3173932SAnatoly Burakov
684a22e6eeSJohn McNamara.. _figure_multi_process_memory:
69fc1f2750SBernard Iremonger
704a22e6eeSJohn McNamara.. figure:: img/multi_process_memory.*
71fc1f2750SBernard Iremonger
724a22e6eeSJohn McNamara   Memory Sharing in the DPDK Multi-process Sample Application
73fc1f2750SBernard Iremonger
74fc1f2750SBernard Iremonger
75f02730abSFerruh YigitThe EAL also supports an auto-detection mode (set by EAL ``--proc-type=auto`` flag ),
76c053d9e9SSarosh Arifwhereby a DPDK process is started as a secondary instance if a primary instance is already running.
77fc1f2750SBernard Iremonger
78fc1f2750SBernard IremongerDeployment Models
79fc1f2750SBernard Iremonger-----------------
80fc1f2750SBernard Iremonger
81fc1f2750SBernard IremongerSymmetric/Peer Processes
82fc1f2750SBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~
83fc1f2750SBernard Iremonger
8448624fd9SSiobhan ButlerDPDK multi-process support can be used to create a set of peer processes where each process performs the same workload.
85fc1f2750SBernard IremongerThis model is equivalent to having multiple threads each running the same main-loop function,
8648624fd9SSiobhan Butleras is done in most of the supplied DPDK sample applications.
87f02730abSFerruh YigitIn this model, the first of the processes spawned should be spawned using the ``--proc-type=primary`` EAL flag,
88f02730abSFerruh Yigitwhile all subsequent instances should be spawned using the ``--proc-type=secondary`` flag.
89fc1f2750SBernard Iremonger
90fc1f2750SBernard IremongerThe simple_mp and symmetric_mp sample applications demonstrate this usage model.
9148624fd9SSiobhan ButlerThey are described in the "Multi-process Sample Application" chapter in the *DPDK Sample Application's User Guide*.
92fc1f2750SBernard Iremonger
93fc1f2750SBernard IremongerAsymmetric/Non-Peer Processes
94fc1f2750SBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95fc1f2750SBernard Iremonger
96fc1f2750SBernard IremongerAn alternative deployment model that can be used for multi-process applications
97fc1f2750SBernard Iremongeris to have a single primary process instance that acts as a load-balancer or
98fc1f2750SBernard Iremongerserver distributing received packets among worker or client threads, which are run as secondary processes.
99fc1f2750SBernard IremongerIn this case, extensive use of rte_ring objects is made, which are located in shared hugepage memory.
100fc1f2750SBernard Iremonger
101fc1f2750SBernard IremongerThe client_server_mp sample application shows this usage model.
10248624fd9SSiobhan ButlerIt is described in the "Multi-process Sample Application" chapter in the *DPDK Sample Application's User Guide*.
103fc1f2750SBernard Iremonger
10448624fd9SSiobhan ButlerRunning Multiple Independent DPDK Applications
10548624fd9SSiobhan Butler~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106fc1f2750SBernard Iremonger
10748624fd9SSiobhan ButlerIn addition to the above scenarios involving multiple DPDK processes working together,
108*b301f2d3SStephen Hemmingerit is possible to run multiple DPDK processes concurrently,
109fc1f2750SBernard Iremongerwhere those processes are all working independently.
110f02730abSFerruh YigitSupport for this usage scenario is provided using the ``--file-prefix`` parameter to the EAL.
111fc1f2750SBernard Iremonger
112*b301f2d3SStephen HemmingerThe EAL puts shared runtime files in a directory based on standard conventions.
113*b301f2d3SStephen HemmingerIf ``$RUNTIME_DIRECTORY`` is defined in the environment,
114*b301f2d3SStephen Hemmingerit is used (as ``$RUNTIME_DIRECTORY/dpdk``).
115*b301f2d3SStephen HemmingerOtherwise, if DPDK is run as root user, it uses ``/var/run/dpdk``
116*b301f2d3SStephen Hemmingeror if run as non-root user then the ``/tmp/dpdk`` (or ``$XDG_RUNTIME_DIRECTORY/dpdk``) is used.
117*b301f2d3SStephen HemmingerHugepage files on each hugetlbfs filesystem use the ``rtemap_X`` filename,
118fc1f2750SBernard Iremongerwhere X is in the range 0 to the maximum number of hugepages -1.
119*b301f2d3SStephen HemmingerSimilarly, it creates shared configuration files, memory mapped in each process,
120*b301f2d3SStephen Hemmingerusing the ``.rte_config`` filename.
121fc1f2750SBernard IremongerThe rte part of the filenames of each of the above is configurable using the file-prefix parameter.
122fc1f2750SBernard Iremonger
123fc1f2750SBernard IremongerIn addition to specifying the file-prefix parameter,
12448624fd9SSiobhan Butlerany DPDK applications that are to be run side-by-side must explicitly limit their memory use.
125b3173932SAnatoly BurakovThis is less of a problem on Linux, as by default, applications will not
126b3173932SAnatoly Burakovallocate more memory than they need. However if ``--legacy-mem`` is used, DPDK
127b3173932SAnatoly Burakovwill attempt to preallocate all memory it can get to, and memory use must be
128b3173932SAnatoly Burakovexplicitly limited. This is done by passing the ``-m`` flag to each process to
129b3173932SAnatoly Burakovspecify how much hugepage memory, in megabytes, each process can use (or passing
130b3173932SAnatoly Burakov``--socket-mem`` to specify how much hugepage memory on each socket each process
131b3173932SAnatoly Burakovcan use).
132fc1f2750SBernard Iremonger
133fc1f2750SBernard Iremonger.. note::
134fc1f2750SBernard Iremonger
13548624fd9SSiobhan Butler    Independent DPDK instances running side-by-side on a single machine cannot share any network ports.
136db27370bSStephen Hemminger    Any network ports being used by one process should be blocked by every other process.
137fc1f2750SBernard Iremonger
13848624fd9SSiobhan ButlerRunning Multiple Independent Groups of DPDK Applications
13948624fd9SSiobhan Butler~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
140fc1f2750SBernard Iremonger
14148624fd9SSiobhan ButlerIn the same way that it is possible to run independent DPDK applications side- by-side on a single system,
14248624fd9SSiobhan Butlerthis can be trivially extended to multi-process groups of DPDK applications running side-by-side.
143f02730abSFerruh YigitIn this case, the secondary processes must use the same ``--file-prefix`` parameter
144fc1f2750SBernard Iremongeras the primary process whose shared memory they are connecting to.
145fc1f2750SBernard Iremonger
146fc1f2750SBernard Iremonger.. note::
147fc1f2750SBernard Iremonger
14848624fd9SSiobhan Butler    All restrictions and issues with multiple independent DPDK processes running side-by-side
149fc1f2750SBernard Iremonger    apply in this usage scenario also.
150fc1f2750SBernard Iremonger
151fc1f2750SBernard IremongerMulti-process Limitations
152fc1f2750SBernard Iremonger-------------------------
153fc1f2750SBernard Iremonger
15448624fd9SSiobhan ButlerThere are a number of limitations to what can be done when running DPDK multi-process applications.
155fc1f2750SBernard IremongerSome of these are documented below:
156fc1f2750SBernard Iremonger
157fc1f2750SBernard Iremonger*   The multi-process feature requires that the exact same hugepage memory mappings be present in all applications.
158b3173932SAnatoly Burakov    This makes secondary process startup process generally unreliable. Disabling
159b3173932SAnatoly Burakov    Linux security feature - Address-Space Layout Randomization (ASLR) may
160b3173932SAnatoly Burakov    help getting more consistent mappings, but not necessarily more reliable -
161b3173932SAnatoly Burakov    if the mappings are wrong, they will be consistently wrong!
162fc1f2750SBernard Iremonger
163fc1f2750SBernard Iremonger.. warning::
164fc1f2750SBernard Iremonger
165fc1f2750SBernard Iremonger    Disabling Address-Space Layout Randomization (ASLR) may have security implications,
166fc1f2750SBernard Iremonger    so it is recommended that it be disabled only when absolutely necessary,
167fc1f2750SBernard Iremonger    and only when the implications of this change have been understood.
168fc1f2750SBernard Iremonger
16935b09d76SKeith Wiles*   All DPDK processes running as a single application and using shared memory must have distinct coremask/corelist arguments.
170fc1f2750SBernard Iremonger    It is not possible to have a primary and secondary instance, or two secondary instances,
171fc1f2750SBernard Iremonger    using any of the same logical cores.
172fc1f2750SBernard Iremonger    Attempting to do so can cause corruption of memory pool caches, among other issues.
173fc1f2750SBernard Iremonger
174fc1f2750SBernard Iremonger*   The delivery of interrupts, such as Ethernet* device link status interrupts, do not work in secondary processes.
175fc1f2750SBernard Iremonger    All interrupts are triggered inside the primary process only.
176fc1f2750SBernard Iremonger    Any application needing interrupt notification in multiple processes should provide its own mechanism
177fc1f2750SBernard Iremonger    to transfer the interrupt information from the primary process to any secondary process that needs the information.
178fc1f2750SBernard Iremonger
179fc1f2750SBernard Iremonger*   The use of function pointers between multiple processes running based of different compiled binaries is not supported,
180fc1f2750SBernard Iremonger    since the location of a given function in one process may be different to its location in a second.
181c96b55dfSYipeng Wang    This prevents the librte_hash library from behaving properly as in a multi-process instance,
182fc1f2750SBernard Iremonger    since it uses a pointer to the hash function internally.
183fc1f2750SBernard Iremonger
184fc1f2750SBernard IremongerTo work around this issue, it is recommended that multi-process applications perform the hash calculations by directly calling
185fc1f2750SBernard Iremongerthe hashing function from the code and then using the rte_hash_add_with_hash()/rte_hash_lookup_with_hash() functions
186fc1f2750SBernard Iremongerinstead of the functions which do the hashing internally, such as rte_hash_add()/rte_hash_lookup().
187fc1f2750SBernard Iremonger
18848624fd9SSiobhan Butler*   Depending upon the hardware in use, and the number of DPDK processes used,
18948624fd9SSiobhan Butler    it may not be possible to have HPET timers available in each DPDK instance.
190fc1f2750SBernard Iremonger    The minimum number of HPET comparators available to Linux* userspace can be just a single comparator,
19148624fd9SSiobhan Butler    which means that only the first, primary DPDK process instance can open and mmap  /dev/hpet.
19248624fd9SSiobhan Butler    If the number of required DPDK processes exceeds that of the number of available HPET comparators,
193fc1f2750SBernard Iremonger    the TSC (which is the default timer in this release) must be used as a time source across all processes instead of the HPET.
194e2226666SAnatoly Burakov
195e2226666SAnatoly BurakovCommunication between multiple processes
196e2226666SAnatoly Burakov----------------------------------------
197e2226666SAnatoly Burakov
198e2226666SAnatoly BurakovWhile there are multiple ways one can approach inter-process communication in
199e2226666SAnatoly BurakovDPDK, there is also a native DPDK IPC API available. It is not intended to be
200e2226666SAnatoly Burakovperformance-critical, but rather is intended to be a convenient, general
201e2226666SAnatoly Burakovpurpose API to exchange short messages between primary and secondary processes.
202e2226666SAnatoly Burakov
203e2226666SAnatoly BurakovDPDK IPC API supports the following communication modes:
204e2226666SAnatoly Burakov
205e2226666SAnatoly Burakov* Unicast message from secondary to primary
206e2226666SAnatoly Burakov* Broadcast message from primary to all secondaries
207e2226666SAnatoly Burakov
208e2226666SAnatoly BurakovIn other words, any IPC message sent in a primary process will be delivered to
209e2226666SAnatoly Burakovall secondaries, while any IPC message sent in a secondary process will only be
210e2226666SAnatoly Burakovdelivered to primary process. Unicast from primary to secondary or from
211e2226666SAnatoly Burakovsecondary to secondary is not supported.
212e2226666SAnatoly Burakov
213e2226666SAnatoly BurakovThere are three types of communications that are available within DPDK IPC API:
214e2226666SAnatoly Burakov
215e2226666SAnatoly Burakov* Message
216e2226666SAnatoly Burakov* Synchronous request
217e2226666SAnatoly Burakov* Asynchronous request
218e2226666SAnatoly Burakov
219e2226666SAnatoly BurakovA "message" type does not expect a response and is meant to be a best-effort
220e2226666SAnatoly Burakovnotification mechanism, while the two types of "requests" are meant to be a two
221e2226666SAnatoly Burakovway communication mechanism, with the requester expecting a response from the
222e2226666SAnatoly Burakovother side.
223e2226666SAnatoly Burakov
224e2226666SAnatoly BurakovBoth messages and requests will trigger a named callback on the receiver side.
2253456b5eaSAnatoly BurakovThese callbacks will be called from within a dedicated IPC or interrupt thread
2263456b5eaSAnatoly Burakovthat are not part of EAL lcore threads.
227e2226666SAnatoly Burakov
228e2226666SAnatoly BurakovRegistering for incoming messages
229e2226666SAnatoly Burakov~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
230e2226666SAnatoly Burakov
231e2226666SAnatoly BurakovBefore any messages can be received, a callback will need to be registered.
232e2226666SAnatoly BurakovThis is accomplished by calling ``rte_mp_action_register()`` function. This
233e2226666SAnatoly Burakovfunction accepts a unique callback name, and a function pointer to a callback
234e2226666SAnatoly Burakovthat will be called when a message or a request matching this callback name
235e2226666SAnatoly Burakovarrives.
236e2226666SAnatoly Burakov
237e2226666SAnatoly BurakovIf the application is no longer willing to receive messages intended for a
238e2226666SAnatoly Burakovspecific callback function, ``rte_mp_action_unregister()`` function can be
239e2226666SAnatoly Burakovcalled to ensure that callback will not be triggered again.
240e2226666SAnatoly Burakov
241e2226666SAnatoly BurakovSending messages
242e2226666SAnatoly Burakov~~~~~~~~~~~~~~~~
243e2226666SAnatoly Burakov
244e2226666SAnatoly BurakovTo send a message, a ``rte_mp_msg`` descriptor must be populated first. The list
245e2226666SAnatoly Burakovof fields to be populated are as follows:
246e2226666SAnatoly Burakov
247e2226666SAnatoly Burakov* ``name`` - message name. This name must match receivers' callback name.
248e2226666SAnatoly Burakov* ``param`` - message data (up to 256 bytes).
249e2226666SAnatoly Burakov* ``len_param`` - length of message data.
250e2226666SAnatoly Burakov* ``fds`` - file descriptors to pass long with the data (up to 8 fd's).
251e2226666SAnatoly Burakov* ``num_fds`` - number of file descriptors to send.
252e2226666SAnatoly Burakov
253e2226666SAnatoly BurakovOnce the structure is populated, calling ``rte_mp_sendmsg()`` will send the
254e2226666SAnatoly Burakovdescriptor either to all secondary processes (if sent from primary process), or
255e2226666SAnatoly Burakovto primary process (if sent from secondary process). The function will return
256e2226666SAnatoly Burakova value indicating whether sending the message succeeded or not.
257e2226666SAnatoly Burakov
258e2226666SAnatoly BurakovSending requests
259e2226666SAnatoly Burakov~~~~~~~~~~~~~~~~
260e2226666SAnatoly Burakov
261e2226666SAnatoly BurakovSending requests involves waiting for the other side to reply, so they can block
262e2226666SAnatoly Burakovfor a relatively long time.
263e2226666SAnatoly Burakov
264e2226666SAnatoly BurakovTo send a request, a message descriptor ``rte_mp_msg`` must be populated.
265e2226666SAnatoly BurakovAdditionally, a ``timespec`` value must be specified as a timeout, after which
266e2226666SAnatoly BurakovIPC will stop waiting and return.
267e2226666SAnatoly Burakov
268ab96056dSAnatoly BurakovFor synchronous requests, the ``rte_mp_reply`` descriptor must also be created.
269ab96056dSAnatoly BurakovThis is where the responses will be stored.
270ab96056dSAnatoly BurakovThe list of fields that will be populated by IPC are as follows:
271e2226666SAnatoly Burakov
272e2226666SAnatoly Burakov* ``nb_sent`` - number indicating how many requests were sent (i.e. how many
273e2226666SAnatoly Burakov  peer processes were active at the time of the request).
274e2226666SAnatoly Burakov* ``nb_received`` - number indicating how many responses were received (i.e. of
275e2226666SAnatoly Burakov  those peer processes that were active at the time of request, how many have
276e2226666SAnatoly Burakov  replied)
277e2226666SAnatoly Burakov* ``msgs`` - pointer to where all of the responses are stored. The order in
278d629b7b5SJohn McNamara  which responses appear is undefined. When doing synchronous requests, this
279e2226666SAnatoly Burakov  memory must be freed by the requestor after request completes!
280e2226666SAnatoly Burakov
281e2226666SAnatoly BurakovFor asynchronous requests, a function pointer to the callback function must be
282e2226666SAnatoly Burakovprovided instead. This callback will be called when the request either has timed
283e2226666SAnatoly Burakovout, or will have received a response to all the messages that were sent.
284e2226666SAnatoly Burakov
2853456b5eaSAnatoly Burakov.. warning::
2863456b5eaSAnatoly Burakov
2873456b5eaSAnatoly Burakov    When an asynchronous request times out, the callback will be called not by
2883456b5eaSAnatoly Burakov    a dedicated IPC thread, but rather from EAL interrupt thread. Because of
2893456b5eaSAnatoly Burakov    this, it may not be possible for DPDK to trigger another interrupt-based
2903456b5eaSAnatoly Burakov    event (such as an alarm) while handling asynchronous IPC callback.
2913456b5eaSAnatoly Burakov
292e2226666SAnatoly BurakovWhen the callback is called, the original request descriptor will be provided
293e2226666SAnatoly Burakov(so that it would be possible to determine for which sent message this is a
294e2226666SAnatoly Burakovcallback to), along with a response descriptor like the one described above.
295e2226666SAnatoly BurakovWhen doing asynchronous requests, there is no need to free the resulting
296e2226666SAnatoly Burakov``rte_mp_reply`` descriptor.
297e2226666SAnatoly Burakov
298e2226666SAnatoly BurakovReceiving and responding to messages
299e2226666SAnatoly Burakov~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
300e2226666SAnatoly Burakov
301e2226666SAnatoly BurakovTo receive a message, a name callback must be registered using the
302e2226666SAnatoly Burakov``rte_mp_action_register()`` function. The name of the callback must match the
303e2226666SAnatoly Burakov``name`` field in sender's ``rte_mp_msg`` message descriptor in order for this
304e2226666SAnatoly Burakovmessage to be delivered and for the callback to be trigger.
305e2226666SAnatoly Burakov
306e2226666SAnatoly BurakovThe callback's definition is ``rte_mp_t``, and consists of the incoming message
307e2226666SAnatoly Burakovpointer ``msg``, and an opaque pointer ``peer``. Contents of ``msg`` will be
308e2226666SAnatoly Burakovidentical to ones sent by the sender.
309e2226666SAnatoly Burakov
310e2226666SAnatoly BurakovIf a response is required, a new ``rte_mp_msg`` message descriptor must be
311e2226666SAnatoly Burakovconstructed and sent via ``rte_mp_reply()`` function, along with ``peer``
312e2226666SAnatoly Burakovpointer. The resulting response will then be delivered to the correct requestor.
313e2226666SAnatoly Burakov
314bfbc3a50SAnatoly Burakov.. warning::
315bfbc3a50SAnatoly Burakov    Simply returning a value when processing a request callback will not send a
316bfbc3a50SAnatoly Burakov    response to the request - it must always be explicitly sent even in case
317bfbc3a50SAnatoly Burakov    of errors. Implementation of error signalling rests with the application,
318bfbc3a50SAnatoly Burakov    there is no built-in way to indicate success or error for a request. Failing
319bfbc3a50SAnatoly Burakov    to do so will cause the requestor to time out while waiting on a response.
320bfbc3a50SAnatoly Burakov
321e2226666SAnatoly BurakovMisc considerations
322e2226666SAnatoly Burakov~~~~~~~~~~~~~~~~~~~~~~~~
323e2226666SAnatoly Burakov
324e2226666SAnatoly BurakovDue to the underlying IPC implementation being single-threaded, recursive
325e2226666SAnatoly Burakovrequests (i.e. sending a request while responding to another request) is not
326e2226666SAnatoly Burakovsupported. However, since sending messages (not requests) does not involve an
327e2226666SAnatoly BurakovIPC thread, sending messages while processing another message or request is
328e2226666SAnatoly Burakovsupported.
329e2226666SAnatoly Burakov
3309c30a6f3SHenry NadeauSince the memory subsystem uses IPC internally, memory allocations and IPC must
3313855b415SAnatoly Burakovnot be mixed: it is not safe to use IPC inside a memory-related callback, nor is
3323855b415SAnatoly Burakovit safe to allocate/free memory inside IPC callbacks. Attempting to do so may
3333855b415SAnatoly Burakovlead to a deadlock.
3343855b415SAnatoly Burakov
3353456b5eaSAnatoly BurakovAsynchronous request callbacks may be triggered either from IPC thread or from
3363456b5eaSAnatoly Burakovinterrupt thread, depending on whether the request has timed out. It is
3373456b5eaSAnatoly Burakovtherefore suggested to avoid waiting for interrupt-based events (such as alarms)
3383456b5eaSAnatoly Burakovinside asynchronous IPC request callbacks. This limitation does not apply to
3393456b5eaSAnatoly Burakovmessages or synchronous requests.
3403456b5eaSAnatoly Burakov
341e2226666SAnatoly BurakovIf callbacks spend a long time processing the incoming requests, the requestor
342e2226666SAnatoly Burakovmight time out, so setting the right timeout value on the requestor side is
343e2226666SAnatoly Burakovimperative.
344e2226666SAnatoly Burakov
345e2226666SAnatoly BurakovIf some of the messages timed out, ``nb_sent`` and ``nb_received`` fields in the
346e2226666SAnatoly Burakov``rte_mp_reply`` descriptor will not have matching values. This is not treated
347e2226666SAnatoly Burakovas error by the IPC API, and it is expected that the user will be responsible
348e2226666SAnatoly Burakovfor deciding how to handle such cases.
349e2226666SAnatoly Burakov
350e2226666SAnatoly BurakovIf a callback has been registered, IPC will assume that it is safe to call it.
351e2226666SAnatoly BurakovThis is important when registering callbacks during DPDK initialization.
352e2226666SAnatoly BurakovDuring initialization, IPC will consider the receiving side as non-existing if
353e2226666SAnatoly Burakovthe callback has not been registered yet. However, once the callback has been
354e2226666SAnatoly Burakovregistered, it is expected that IPC should be safe to trigger it, even if the
355e2226666SAnatoly Burakovrest of the DPDK initialization hasn't finished yet.
356