xref: /dpdk/doc/guides/sample_app_ug/multi_process.rst (revision cb056611a8ed9ab9024f3b91bf26e97255194514)
15630257fSFerruh Yigit..  SPDX-License-Identifier: BSD-3-Clause
25630257fSFerruh Yigit    Copyright(c) 2010-2014 Intel Corporation.
3d0dff9baSBernard Iremonger
4f9d7ffecSJohn McNamara.. _multi_process_app:
5f9d7ffecSJohn McNamara
6d0dff9baSBernard IremongerMulti-process Sample Application
7d0dff9baSBernard Iremonger================================
8d0dff9baSBernard Iremonger
9e0c7c473SSiobhan ButlerThis chapter describes the example applications for multi-processing that are included in the DPDK.
10d0dff9baSBernard Iremonger
11d0dff9baSBernard IremongerExample Applications
12d0dff9baSBernard Iremonger--------------------
13d0dff9baSBernard Iremonger
14d0dff9baSBernard IremongerBuilding the Sample Applications
15d0dff9baSBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16d0dff9baSBernard IremongerThe multi-process example applications are built in the same way as other sample applications,
17e0c7c473SSiobhan Butlerand as documented in the *DPDK Getting Started Guide*.
18d0dff9baSBernard Iremonger
19d0dff9baSBernard Iremonger
207cacb056SHerakliusz LipiecTo compile the sample application see :doc:`compiling`.
21d0dff9baSBernard Iremonger
227cacb056SHerakliusz LipiecThe applications are located in the ``multi_process`` sub-directory.
23d0dff9baSBernard Iremonger
24d0dff9baSBernard Iremonger.. note::
25d0dff9baSBernard Iremonger
26d0dff9baSBernard Iremonger    If just a specific multi-process application needs to be built,
27d0dff9baSBernard Iremonger    the final make command can be run just in that application's directory,
28d0dff9baSBernard Iremonger    rather than at the top-level multi-process directory.
29d0dff9baSBernard Iremonger
30d0dff9baSBernard IremongerBasic Multi-process Example
31d0dff9baSBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~~~~
32d0dff9baSBernard Iremonger
33e0c7c473SSiobhan ButlerThe examples/simple_mp folder in the DPDK release contains a basic example application to demonstrate how
34e0c7c473SSiobhan Butlertwo DPDK processes can work together using queues and memory pools to share information.
35d0dff9baSBernard Iremonger
36d0dff9baSBernard IremongerRunning the Application
37d0dff9baSBernard Iremonger^^^^^^^^^^^^^^^^^^^^^^^
38d0dff9baSBernard Iremonger
39d0dff9baSBernard IremongerTo run the application, start one copy of the simple_mp binary in one terminal,
4035b09d76SKeith Wilespassing at least two cores in the coremask/corelist, as follows:
41d0dff9baSBernard Iremonger
42d0dff9baSBernard Iremonger.. code-block:: console
43d0dff9baSBernard Iremonger
4435b09d76SKeith Wiles    ./build/simple_mp -l 0-1 -n 4 --proc-type=primary
45d0dff9baSBernard Iremonger
46e0c7c473SSiobhan ButlerFor the first DPDK process run, the proc-type flag can be omitted or set to auto,
47e0c7c473SSiobhan Butlersince all DPDK processes will default to being a primary instance,
48d0dff9baSBernard Iremongermeaning they have control over the hugepage shared memory regions.
49d0dff9baSBernard IremongerThe process should start successfully and display a command prompt as follows:
50d0dff9baSBernard Iremonger
51d0dff9baSBernard Iremonger.. code-block:: console
52d0dff9baSBernard Iremonger
5335b09d76SKeith Wiles    $ ./build/simple_mp -l 0-1 -n 4 --proc-type=primary
54d0dff9baSBernard Iremonger    EAL: coremask set to 3
55d0dff9baSBernard Iremonger    EAL: Detected lcore 0 on socket 0
56d0dff9baSBernard Iremonger    EAL: Detected lcore 1 on socket 0
57d0dff9baSBernard Iremonger    EAL: Detected lcore 2 on socket 0
58d0dff9baSBernard Iremonger    EAL: Detected lcore 3 on socket 0
59d0dff9baSBernard Iremonger    ...
60d0dff9baSBernard Iremonger
61d0dff9baSBernard Iremonger    EAL: Requesting 2 pages of size 1073741824
62d0dff9baSBernard Iremonger    EAL: Requesting 768 pages of size 2097152
63d0dff9baSBernard Iremonger    EAL: Ask a virtual area of 0x40000000 bytes
64d0dff9baSBernard Iremonger    EAL: Virtual area found at 0x7ff200000000 (size = 0x40000000)
65d0dff9baSBernard Iremonger    ...
66d0dff9baSBernard Iremonger
67*cb056611SStephen Hemminger    EAL: check module finished
68*cb056611SStephen Hemminger    EAL: Main core 0 is ready (tid=54e41820)
69d0dff9baSBernard Iremonger    EAL: Core 1 is ready (tid=53b32700)
70d0dff9baSBernard Iremonger
71d0dff9baSBernard Iremonger    Starting core 1
72d0dff9baSBernard Iremonger
73d0dff9baSBernard Iremonger    simple_mp >
74d0dff9baSBernard Iremonger
75d0dff9baSBernard IremongerTo run the secondary process to communicate with the primary process,
7635b09d76SKeith Wilesagain run the same binary setting at least two cores in the coremask/corelist:
77d0dff9baSBernard Iremonger
78d0dff9baSBernard Iremonger.. code-block:: console
79d0dff9baSBernard Iremonger
8035b09d76SKeith Wiles    ./build/simple_mp -l 2-3 -n 4 --proc-type=secondary
81d0dff9baSBernard Iremonger
82d0dff9baSBernard IremongerWhen running a secondary process such as that shown above, the proc-type parameter can again be specified as auto.
83d0dff9baSBernard IremongerHowever, omitting the parameter altogether will cause the process to try and start as a primary rather than secondary process.
84d0dff9baSBernard Iremonger
85d0dff9baSBernard IremongerOnce the process type is specified correctly,
86d0dff9baSBernard Iremongerthe process starts up, displaying largely similar status messages to the primary instance as it initializes.
87d0dff9baSBernard IremongerOnce again, you will be presented with a command prompt.
88d0dff9baSBernard Iremonger
89d0dff9baSBernard IremongerOnce both processes are running, messages can be sent between them using the send command.
90d0dff9baSBernard IremongerAt any stage, either process can be terminated using the quit command.
91d0dff9baSBernard Iremonger
92d0dff9baSBernard Iremonger.. code-block:: console
93d0dff9baSBernard Iremonger
94*cb056611SStephen Hemminger   EAL: Main core 10 is ready (tid=b5f89820)             EAL: Main core 8 is ready (tid=864a3820)
95d0dff9baSBernard Iremonger   EAL: Core 11 is ready (tid=84ffe700)                  EAL: Core 9 is ready (tid=85995700)
96d0dff9baSBernard Iremonger   Starting core 11                                      Starting core 9
97d0dff9baSBernard Iremonger   simple_mp > send hello_secondary                      simple_mp > core 9: Received 'hello_secondary'
98d0dff9baSBernard Iremonger   simple_mp > core 11: Received 'hello_primary'         simple_mp > send hello_primary
99d0dff9baSBernard Iremonger   simple_mp > quit                                      simple_mp > quit
100d0dff9baSBernard Iremonger
101d0dff9baSBernard Iremonger.. note::
102d0dff9baSBernard Iremonger
103d0dff9baSBernard Iremonger    If the primary instance is terminated, the secondary instance must also be shut-down and restarted after the primary.
104d0dff9baSBernard Iremonger    This is necessary because the primary instance will clear and reset the shared memory regions on startup,
105d0dff9baSBernard Iremonger    invalidating the secondary process's pointers.
106d0dff9baSBernard Iremonger    The secondary process can be stopped and restarted without affecting the primary process.
107d0dff9baSBernard Iremonger
108d0dff9baSBernard IremongerHow the Application Works
109d0dff9baSBernard Iremonger^^^^^^^^^^^^^^^^^^^^^^^^^
110d0dff9baSBernard Iremonger
111d0dff9baSBernard IremongerThe core of this example application is based on using two queues and a single memory pool in shared memory.
112d0dff9baSBernard IremongerThese three objects are created at startup by the primary process,
113d0dff9baSBernard Iremongersince the secondary process cannot create objects in memory as it cannot reserve memory zones,
114d0dff9baSBernard Iremongerand the secondary process then uses lookup functions to attach to these objects as it starts up.
115d0dff9baSBernard Iremonger
116d0dff9baSBernard Iremonger.. code-block:: c
117d0dff9baSBernard Iremonger
118d0dff9baSBernard Iremonger    if (rte_eal_process_type() == RTE_PROC_PRIMARY){
119d0dff9baSBernard Iremonger        send_ring = rte_ring_create(_PRI_2_SEC, ring_size, SOCKET0, flags);
120d0dff9baSBernard Iremonger        recv_ring = rte_ring_create(_SEC_2_PRI, ring_size, SOCKET0, flags);
121d0dff9baSBernard Iremonger        message_pool = rte_mempool_create(_MSG_POOL, pool_size, string_size, pool_cache, priv_data_sz, NULL, NULL, NULL, NULL, SOCKET0, flags);
122d0dff9baSBernard Iremonger    } else {
123d0dff9baSBernard Iremonger        recv_ring = rte_ring_lookup(_PRI_2_SEC);
124d0dff9baSBernard Iremonger        send_ring = rte_ring_lookup(_SEC_2_PRI);
125d0dff9baSBernard Iremonger        message_pool = rte_mempool_lookup(_MSG_POOL);
126d0dff9baSBernard Iremonger    }
127d0dff9baSBernard Iremonger
128d0dff9baSBernard IremongerNote, however, that the named ring structure used as send_ring in the primary process is the recv_ring in the secondary process.
129d0dff9baSBernard Iremonger
130d0dff9baSBernard IremongerOnce the rings and memory pools are all available in both the primary and secondary processes,
131d0dff9baSBernard Iremongerthe application simply dedicates two threads to sending and receiving messages respectively.
132d0dff9baSBernard IremongerThe receive thread simply dequeues any messages on the receive ring, prints them,
133d0dff9baSBernard Iremongerand frees the buffer space used by the messages back to the memory pool.
134d0dff9baSBernard IremongerThe send thread makes use of the command-prompt library to interactively request user input for messages to send.
135d0dff9baSBernard IremongerOnce a send command is issued by the user, a buffer is allocated from the memory pool, filled in with the message contents,
136d0dff9baSBernard Iremongerthen enqueued on the appropriate rte_ring.
137d0dff9baSBernard Iremonger
138d0dff9baSBernard IremongerSymmetric Multi-process Example
139d0dff9baSBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
140d0dff9baSBernard Iremonger
141e0c7c473SSiobhan ButlerThe second example of DPDK multi-process support demonstrates how a set of processes can run in parallel,
142d0dff9baSBernard Iremongerwith each process performing the same set of packet- processing operations.
143d0dff9baSBernard Iremonger(Since each process is identical in functionality to the others,
144d0dff9baSBernard Iremongerwe refer to this as symmetric multi-processing, to differentiate it from asymmetric multi- processing -
145d0dff9baSBernard Iremongersuch as a client-server mode of operation seen in the next example,
146d0dff9baSBernard Iremongerwhere different processes perform different tasks, yet co-operate to form a packet-processing system.)
147d0dff9baSBernard IremongerThe following diagram shows the data-flow through the application, using two processes.
148d0dff9baSBernard Iremonger
1494a22e6eeSJohn McNamara.. _figure_sym_multi_proc_app:
150d0dff9baSBernard Iremonger
1514a22e6eeSJohn McNamara.. figure:: img/sym_multi_proc_app.*
152d0dff9baSBernard Iremonger
1534a22e6eeSJohn McNamara   Example Data Flow in a Symmetric Multi-process Application
154d0dff9baSBernard Iremonger
155d0dff9baSBernard Iremonger
156d0dff9baSBernard IremongerAs the diagram shows, each process reads packets from each of the network ports in use.
157d0dff9baSBernard IremongerRSS is used to distribute incoming packets on each port to different hardware RX queues.
158d0dff9baSBernard IremongerEach process reads a different RX queue on each port and so does not contend with any other process for that queue access.
159d0dff9baSBernard IremongerSimilarly, each process writes outgoing packets to a different TX queue on each port.
160d0dff9baSBernard Iremonger
161d0dff9baSBernard IremongerRunning the Application
162d0dff9baSBernard Iremonger^^^^^^^^^^^^^^^^^^^^^^^
163d0dff9baSBernard Iremonger
164d0dff9baSBernard IremongerAs with the simple_mp example, the first instance of the symmetric_mp process must be run as the primary instance,
165d0dff9baSBernard Iremongerthough with a number of other application- specific parameters also provided after the EAL arguments.
166d0dff9baSBernard IremongerThese additional parameters are:
167d0dff9baSBernard Iremonger
168d0dff9baSBernard Iremonger*   -p <portmask>, where portmask is a hexadecimal bitmask of what ports on the system are to be used.
169d0dff9baSBernard Iremonger    For example: -p 3 to use ports 0 and 1 only.
170d0dff9baSBernard Iremonger
171d0dff9baSBernard Iremonger*   --num-procs <N>, where N is the total number of symmetric_mp instances that will be run side-by-side to perform packet processing.
172d0dff9baSBernard Iremonger    This parameter is used to configure the appropriate number of receive queues on each network port.
173d0dff9baSBernard Iremonger
174d0dff9baSBernard Iremonger*   --proc-id <n>, where n is a numeric value in the range 0 <= n < N (number of processes, specified above).
175d0dff9baSBernard Iremonger    This identifies which symmetric_mp instance is being run, so that each process can read a unique receive queue on each network port.
176d0dff9baSBernard Iremonger
177d0dff9baSBernard IremongerThe secondary symmetric_mp instances must also have these parameters specified,
178d0dff9baSBernard Iremongerand the first two must be the same as those passed to the primary instance, or errors result.
179d0dff9baSBernard Iremonger
180d0dff9baSBernard IremongerFor example, to run a set of four symmetric_mp instances, running on lcores 1-4,
181d0dff9baSBernard Iremongerall performing level-2 forwarding of packets between ports 0 and 1,
182d0dff9baSBernard Iremongerthe following commands can be used (assuming run as root):
183d0dff9baSBernard Iremonger
184d0dff9baSBernard Iremonger.. code-block:: console
185d0dff9baSBernard Iremonger
18635b09d76SKeith Wiles    # ./build/symmetric_mp -l 1 -n 4 --proc-type=auto -- -p 3 --num-procs=4 --proc-id=0
18735b09d76SKeith Wiles    # ./build/symmetric_mp -l 2 -n 4 --proc-type=auto -- -p 3 --num-procs=4 --proc-id=1
18835b09d76SKeith Wiles    # ./build/symmetric_mp -l 3 -n 4 --proc-type=auto -- -p 3 --num-procs=4 --proc-id=2
18935b09d76SKeith Wiles    # ./build/symmetric_mp -l 4 -n 4 --proc-type=auto -- -p 3 --num-procs=4 --proc-id=3
190d0dff9baSBernard Iremonger
191d0dff9baSBernard Iremonger.. note::
192d0dff9baSBernard Iremonger
193d0dff9baSBernard Iremonger    In the above example, the process type can be explicitly specified as primary or secondary, rather than auto.
194d0dff9baSBernard Iremonger    When using auto, the first process run creates all the memory structures needed for all processes -
195d0dff9baSBernard Iremonger    irrespective of whether it has a proc-id of 0, 1, 2 or 3.
196d0dff9baSBernard Iremonger
197d0dff9baSBernard Iremonger.. note::
198d0dff9baSBernard Iremonger
199d0dff9baSBernard Iremonger    For the symmetric multi-process example, since all processes work in the same manner,
200d0dff9baSBernard Iremonger    once the hugepage shared memory and the network ports are initialized,
201d0dff9baSBernard Iremonger    it is not necessary to restart all processes if the primary instance dies.
202d0dff9baSBernard Iremonger    Instead, that process can be restarted as a secondary,
203d0dff9baSBernard Iremonger    by explicitly setting the proc-type to secondary on the command line.
204d0dff9baSBernard Iremonger    (All subsequent instances launched will also need this explicitly specified,
205d0dff9baSBernard Iremonger    as auto-detection will detect no primary processes running and therefore attempt to re-initialize shared memory.)
206d0dff9baSBernard Iremonger
207d0dff9baSBernard IremongerHow the Application Works
208d0dff9baSBernard Iremonger^^^^^^^^^^^^^^^^^^^^^^^^^
209d0dff9baSBernard Iremonger
210d0dff9baSBernard IremongerThe initialization calls in both the primary and secondary instances are the same for the most part,
21187db93e0SDavid Marchandcalling the rte_eal_init(), 1 G and 10 G driver initialization and then probing devices.
212d0dff9baSBernard IremongerThereafter, the initialization done depends on whether the process is configured as a primary or secondary instance.
213d0dff9baSBernard Iremonger
214d0dff9baSBernard IremongerIn the primary instance, a memory pool is created for the packet mbufs and the network ports to be used are initialized -
215d0dff9baSBernard Iremongerthe number of RX and TX queues per port being determined by the num-procs parameter passed on the command-line.
216d0dff9baSBernard IremongerThe structures for the initialized network ports are stored in shared memory and
217d0dff9baSBernard Iremongertherefore will be accessible by the secondary process as it initializes.
218d0dff9baSBernard Iremonger
219d0dff9baSBernard Iremonger.. code-block:: c
220d0dff9baSBernard Iremonger
221d0dff9baSBernard Iremonger    if (num_ports & 1)
222d0dff9baSBernard Iremonger       rte_exit(EXIT_FAILURE, "Application must use an even number of ports\n");
223d0dff9baSBernard Iremonger
224d0dff9baSBernard Iremonger    for(i = 0; i < num_ports; i++){
225d0dff9baSBernard Iremonger        if(proc_type == RTE_PROC_PRIMARY)
226d0dff9baSBernard Iremonger            if (smp_port_init(ports[i], mp, (uint16_t)num_procs) < 0)
227fea1d908SJohn McNamara                rte_exit(EXIT_FAILURE, "Error initializing ports\n");
228d0dff9baSBernard Iremonger    }
229d0dff9baSBernard Iremonger
230d0dff9baSBernard IremongerIn the secondary instance, rather than initializing the network ports, the port information exported by the primary process is used,
231d0dff9baSBernard Iremongergiving the secondary process access to the hardware and software rings for each network port.
232d0dff9baSBernard IremongerSimilarly, the memory pool of mbufs is accessed by doing a lookup for it by name:
233d0dff9baSBernard Iremonger
234d0dff9baSBernard Iremonger.. code-block:: c
235d0dff9baSBernard Iremonger
236d0dff9baSBernard Iremonger    mp = (proc_type == RTE_PROC_SECONDARY) ? rte_mempool_lookup(_SMP_MBUF_POOL) : rte_mempool_create(_SMP_MBUF_POOL, NB_MBUFS, MBUF_SIZE, ... )
237d0dff9baSBernard Iremonger
238d0dff9baSBernard IremongerOnce this initialization is complete, the main loop of each process, both primary and secondary,
239d0dff9baSBernard Iremongeris exactly the same - each process reads from each port using the queue corresponding to its proc-id parameter,
240d0dff9baSBernard Iremongerand writes to the corresponding transmit queue on the output port.
241d0dff9baSBernard Iremonger
242d0dff9baSBernard IremongerClient-Server Multi-process Example
243d0dff9baSBernard Iremonger~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
244d0dff9baSBernard Iremonger
245e0c7c473SSiobhan ButlerThe third example multi-process application included with the DPDK shows how one can
246d0dff9baSBernard Iremongeruse a client-server type multi-process design to do packet processing.
247d0dff9baSBernard IremongerIn this example, a single server process performs the packet reception from the ports being used and
248d0dff9baSBernard Iremongerdistributes these packets using round-robin ordering among a set of client  processes,
249d0dff9baSBernard Iremongerwhich perform the actual packet processing.
250d0dff9baSBernard IremongerIn this case, the client applications just perform level-2 forwarding of packets by sending each packet out on a different network port.
251d0dff9baSBernard Iremonger
252d0dff9baSBernard IremongerThe following diagram shows the data-flow through the application, using two client processes.
253d0dff9baSBernard Iremonger
2544a22e6eeSJohn McNamara.. _figure_client_svr_sym_multi_proc_app:
255d0dff9baSBernard Iremonger
2564a22e6eeSJohn McNamara.. figure:: img/client_svr_sym_multi_proc_app.*
257d0dff9baSBernard Iremonger
2584a22e6eeSJohn McNamara   Example Data Flow in a Client-Server Symmetric Multi-process Application
259d0dff9baSBernard Iremonger
260d0dff9baSBernard Iremonger
261d0dff9baSBernard IremongerRunning the Application
262d0dff9baSBernard Iremonger^^^^^^^^^^^^^^^^^^^^^^^
263d0dff9baSBernard Iremonger
264d0dff9baSBernard IremongerThe server process must be run initially as the primary process to set up all memory structures for use by the clients.
265d0dff9baSBernard IremongerIn addition to the EAL parameters, the application- specific parameters are:
266d0dff9baSBernard Iremonger
267d0dff9baSBernard Iremonger*   -p <portmask >, where portmask is a hexadecimal bitmask of what ports on the system are to be used.
268d0dff9baSBernard Iremonger    For example: -p 3 to use ports 0 and 1 only.
269d0dff9baSBernard Iremonger
270d0dff9baSBernard Iremonger*   -n <num-clients>, where the num-clients parameter is the number of client processes that will process the packets received
271d0dff9baSBernard Iremonger    by the server application.
272d0dff9baSBernard Iremonger
273d0dff9baSBernard Iremonger.. note::
274d0dff9baSBernard Iremonger
275*cb056611SStephen Hemminger    In the server process, a single thread, the main thread, that is, the lowest numbered lcore in the coremask/corelist, performs all packet I/O.
27635b09d76SKeith Wiles    If a coremask/corelist is specified with more than a single lcore bit set in it,
277d0dff9baSBernard Iremonger    an additional lcore will be used for a thread to periodically print packet count statistics.
278d0dff9baSBernard Iremonger
279d0dff9baSBernard IremongerSince the server application stores configuration data in shared memory, including the network ports to be used,
280d0dff9baSBernard Iremongerthe only application parameter needed by a client process is its client instance ID.
281d0dff9baSBernard IremongerTherefore, to run a server application on lcore 1 (with lcore 2 printing statistics) along with two client processes running on lcores 3 and 4,
282d0dff9baSBernard Iremongerthe following commands could be used:
283d0dff9baSBernard Iremonger
284d0dff9baSBernard Iremonger.. code-block:: console
285d0dff9baSBernard Iremonger
28635b09d76SKeith Wiles    # ./mp_server/build/mp_server -l 1-2 -n 4 -- -p 3 -n 2
28735b09d76SKeith Wiles    # ./mp_client/build/mp_client -l 3 -n 4 --proc-type=auto -- -n 0
28835b09d76SKeith Wiles    # ./mp_client/build/mp_client -l 4 -n 4 --proc-type=auto -- -n 1
289d0dff9baSBernard Iremonger
290d0dff9baSBernard Iremonger.. note::
291d0dff9baSBernard Iremonger
292d0dff9baSBernard Iremonger    If the server application dies and needs to be restarted, all client applications also need to be restarted,
293d0dff9baSBernard Iremonger    as there is no support in the server application for it to run as a secondary process.
294d0dff9baSBernard Iremonger    Any client processes that need restarting can be restarted without affecting the server process.
295d0dff9baSBernard Iremonger
296d0dff9baSBernard IremongerHow the Application Works
297d0dff9baSBernard Iremonger^^^^^^^^^^^^^^^^^^^^^^^^^
298d0dff9baSBernard Iremonger
299d0dff9baSBernard IremongerThe server process performs the network port and data structure initialization much as the symmetric multi-process application does when run as primary.
300d0dff9baSBernard IremongerOne additional enhancement in this sample application is that the server process stores its port configuration data in a memory zone in hugepage shared memory.
301d0dff9baSBernard IremongerThis eliminates the need for the client processes to have the portmask parameter passed into them on the command line,
302d0dff9baSBernard Iremongeras is done for the symmetric multi-process application, and therefore eliminates mismatched parameters as a potential source of errors.
303d0dff9baSBernard Iremonger
304d0dff9baSBernard IremongerIn the same way that the server process is designed to be run as a primary process instance only,
305d0dff9baSBernard Iremongerthe client processes are designed to be run as secondary instances only.
306d0dff9baSBernard IremongerThey have no code to attempt to create shared memory objects.
307d0dff9baSBernard IremongerInstead, handles to all needed rings and memory pools are obtained via calls to rte_ring_lookup() and rte_mempool_lookup().
308d0dff9baSBernard IremongerThe network ports for use by the processes are obtained by loading the network port drivers and probing the PCI bus,
309d0dff9baSBernard Iremongerwhich will, as in the symmetric multi-process example,
310d0dff9baSBernard Iremongerautomatically get access to the network ports using the settings already configured by the primary/server process.
311d0dff9baSBernard Iremonger
312d0dff9baSBernard IremongerOnce all applications are initialized, the server operates by reading packets from each network port in turn and
313d0dff9baSBernard Iremongerdistributing those packets to the client queues (software rings, one for each client process) in round-robin order.
314d0dff9baSBernard IremongerOn the client side, the packets are read from the rings in as big of bursts as possible, then routed out to a different network port.
315d0dff9baSBernard IremongerThe routing used is very simple. All packets received on the first NIC port are transmitted back out on the second port and vice versa.
316d0dff9baSBernard IremongerSimilarly, packets are routed between the 3rd and 4th network ports and so on.
317d0dff9baSBernard IremongerThe sending of packets is done by writing the packets directly to the network ports; they are not transferred back via the server process.
318d0dff9baSBernard Iremonger
319d0dff9baSBernard IremongerIn both the server and the client processes, outgoing packets are buffered before being sent,
320d0dff9baSBernard Iremongerso as to allow the sending of multiple packets in a single burst to improve efficiency.
321d0dff9baSBernard IremongerFor example, the client process will buffer packets to send,
322d0dff9baSBernard Iremongeruntil either the buffer is full or until we receive no further packets from the server.
323