xref: /dpdk/doc/guides/tools/graph.rst (revision fe42375ac6f4af5f97017091baada7fc38cc1874)
1.. SPDX-License-Identifier: BSD-3-Clause
2   Copyright(c) 2023 Marvell.
3
4dpdk-graph Application
5======================
6
7The ``dpdk-graph`` tool is a Data Plane Development Kit (DPDK)
8application that allows exercising various graph use cases.
9This application has a generic framework to add new graph based use cases
10to verify functionality.
11Each use case is defined as a ``<usecase>.cli`` file.
12Based on the input file, application creates a graph to cater the use case.
13
14Also this application framework can be used by other graph-based applications.
15
16
17Running the Application
18-----------------------
19
20The application has a number of command line options
21which can be provided in following syntax:
22
23.. code-block:: console
24
25   dpdk-graph [EAL Options] -- [application options]
26
27EAL Options
28~~~~~~~~~~~
29
30Following are the EAL command-line options that can be used in conjunction
31with the ``dpdk-graph`` application.
32See the DPDK Getting Started Guides for more information on these options.
33
34``-c <COREMASK>`` or ``-l <CORELIST>``
35
36   Set the hexadecimal bit mask of the cores to run on.
37   The CORELIST is a list of cores to be used.
38
39Application Options
40~~~~~~~~~~~~~~~~~~~
41
42Following are the application command-line options:
43
44``-h``
45
46   Set the host IPv4 address over which telnet session can be opened.
47   It is an optional parameter. Default host address is ``0.0.0.0``.
48
49``-p``
50
51   Set the L4 port number over which telnet session can be opened.
52	It is an optional parameter. Default port is ``8086``.
53
54``-s``
55
56   Script name with absolute path which specifies the use case.
57   It is a mandatory parameter which will be used
58   to create desired graph for a given use case.
59
60``--enable-graph-stats``
61
62   Enable graph statistics printing on console.
63   By default, graph statistics are disabled.
64
65``--help``
66
67   Dumps application usage.
68
69
70Supported Use cases
71-------------------
72
73l3fwd
74~~~~~
75
76This use case is supported for both H/W and PCAP vdev network devices.
77To demonstrate, corresponding ``.cli`` files are available at ``app/graph/examples/``
78named as ``l3fwd.cli`` and ``l3fwd_pcap.cli`` respectively.
79
80l2fwd
81~~~~~
82
83This use case is supported for both H/W and PCAP vdev network devices.
84To demonstrate, corresponding ``.cli`` files are available at ``app/graph/examples/``
85named as ``l2fwd.cli`` and ``l2fwd_pcap.cli`` respectively.
86
87Example Commands
88^^^^^^^^^^^^^^^^
89For H/W devices
90
91.. code-block:: console
92
93   ./dpdk-graph -c 0xff -a 0002:02:00.0 -a 0002:03:00.0 --
94                -s <dpdk_root_dir>/app/graph/examples/l3fwd.cli
95
96   ./dpdk-graph -c 0xff -a 0002:02:00.0 -a 0002:03:00.0 --
97                -s <dpdk_root_dir>/app/graph/examples/l2fwd.cli
98
99For net_pcapX devices
100
101.. code-block:: console
102
103   ./dpdk-graph -c 0xff --vdev=net_pcap0,rx_pcap=in_net_pcap0.pcap,tx_pcap=out_net_pcap1.pcap
104                        --vdev=net_pcap1,rx_pcap=in_net_pcap1.pcap,tx_pcap=out_net_pcap0.pcap
105                        -- -s <dpdk_root_dir>/app/graph/examples/l3fwd_pcap.cli
106
107   ./dpdk-graph -c 0xff --vdev=net_pcap0,rx_pcap=in_net_pcap0.pcap,tx_pcap=out_net_pcap1.pcap
108                        --vdev=net_pcap1,rx_pcap=in_net_pcap1.pcap,tx_pcap=out_net_pcap0.pcap
109                        -- -s <dpdk_root_dir>/app/graph/examples/l2fwd_pcap.cli
110
111Verifying traffic
112^^^^^^^^^^^^^^^^^
113
114``l3fwd.cli`` and ``l3fwd_pcap.cli`` creates setup with two network ports.
115Routing between these ports are done by lookup node routing information.
116For current use case, following routing table is used:
117
118.. code-block:: console
119
120   DIP        port
121   10.0.2.2    1
122   20.0.2.2    0
123
124On the successful execution of ``l3fwd.cli`` or ``l3fwd_pcap.cli``,
125user needs to send traffic with mentioned DIP.
126
127For net_pcapX devices, required pcap file should be created and passed to application.
128These pcap files can be created in several ways.
129Scapy is one of the method to get the same:
130
131.. code-block:: console
132
133   # scapy
134   >>> pkts=[Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="28.0.0.1", dst="10.0.2.2"),
135             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="28.0.0.1", dst="10.0.2.2"),
136             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="28.0.0.1", dst="10.0.2.2"),
137             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="28.0.0.1", dst="10.0.2.2"),
138             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="28.0.0.1", dst="10.0.2.2"),
139             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="28.0.0.1", dst="10.0.2.2"),
140             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="28.0.0.1", dst="10.0.2.2"),
141             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="28.0.0.1", dst="10.0.2.2"),
142             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="28.0.0.1", dst="10.0.2.2"),
143             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="28.0.0.1", dst="10.0.2.2")]
144   >>>
145   >>> wrpcap("in_net_pcap1.pcap",pkts)
146   >>>
147   >>> pkts=[Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="29.0.0.1", dst="20.0.2.2"),
148             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="29.0.0.1", dst="20.0.2.2"),
149             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="29.0.0.1", dst="20.0.2.2"),
150             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="29.0.0.1", dst="20.0.2.2"),
151             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="29.0.0.1", dst="20.0.2.2"),
152             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="29.0.0.1", dst="20.0.2.2"),
153             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="29.0.0.1", dst="20.0.2.2"),
154             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="29.0.0.1", dst="20.0.2.2"),
155             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="29.0.0.1", dst="20.0.2.2"),
156             Ether(dst="FA:09:F9:D7:E0:9D", src="10:70:1d:2f:42:2d")/IP(src="28.0.0.1", dst="20.0.2.2")]
157   >>>
158   >>> wrpcap("in_net_pcap0.pcap",pkts)
159   >>> quit
160
161
162Supported CLI commands
163----------------------
164
165This section provides details on commands which can be used in ``<usecase>.cli``
166file to express the requested use case configuration.
167
168.. table:: Exposed CLIs
169   :widths: auto
170
171   +--------------------------------------+-----------------------------------+-------------------+----------+
172   |               Command                |             Description           |     Scope         | Optional |
173   +======================================+===================================+===================+==========+
174   | | graph <usecases> [bsz <size>]      | | Command to express the desired  | :ref:`1 <scopes>` |    No    |
175   | | [tmo <ns>] [coremask <bitmask>]    | | use case. Also enables/disable  |                   |          |
176   | | model <rtc/mcd/default> pcap_enable| | pcap capturing.                 |                   |          |
177   | | <0/1> num_pcap_pkts <num> pcap_file|                                   |                   |          |
178   | | <output_capture_file>              |                                   |                   |          |
179   +--------------------------------------+-----------------------------------+-------------------+----------+
180   | graph start                          | | Command to start the graph.     | :ref:`1 <scopes>` |    No    |
181   |                                      | | This command triggers that no   |                   |          |
182   |                                      | | more commands are left to be    |                   |          |
183   |                                      | | parsed and graph initialization |                   |          |
184   |                                      | | can be started now. It must be  |                   |          |
185   |                                      | | the last command in usecase.cli |                   |          |
186   +--------------------------------------+-----------------------------------+-------------------+----------+
187   | graph stats show                     | | Command to dump current graph   | :ref:`2 <scopes>` |    Yes   |
188   |                                      | | statistics.                     |                   |          |
189   +--------------------------------------+-----------------------------------+-------------------+----------+
190   | help graph                           | | Command to dump graph help      | :ref:`2 <scopes>` |    Yes   |
191   |                                      | | message.                        |                   |          |
192   +--------------------------------------+-----------------------------------+-------------------+----------+
193   | | mempool <mempool_name> size        | | Command to create mempool which | :ref:`1 <scopes>` |    No    |
194   | | <mbuf_size> buffers                | | will be further associated to   |                   |          |
195   | | <number_of_buffers>                | | RxQ to dequeue the packets.     |                   |          |
196   | | cache <cache_size> numa <numa_id>  |                                   |                   |          |
197   +--------------------------------------+-----------------------------------+-------------------+----------+
198   | help mempool                         | | Command to dump mempool help    | :ref:`2 <scopes>` |    Yes   |
199   |                                      | | message.                        |                   |          |
200   +--------------------------------------+-----------------------------------+-------------------+----------+
201   | | ethdev <ethdev_name> rxq <n_queues>| | Command to create DPDK port with| :ref:`1 <scopes>` |    No    |
202   | | txq <n_queues> <mempool_name>      | | given number of Rx and Tx queues|                   |          |
203   |                                      | | . Also attach RxQ with given    |                   |          |
204   |                                      | | mempool. Each port can have     |                   |          |
205   |                                      | | single mempool only i.e. all    |                   |          |
206   |                                      | | RxQs will share the same mempool|                   |          |
207   |                                      | | .                               |                   |          |
208   +--------------------------------------+-----------------------------------+-------------------+----------+
209   | ethdev <ethdev_name> mtu <mtu_sz>    | | Command to configure MTU of DPDK| :ref:`3 <scopes>` |    Yes   |
210   |                                      | | port.                           |                   |          |
211   +--------------------------------------+-----------------------------------+-------------------+----------+
212   | | ethdev forward <tx_dev_name>       | | Command to configure port       | :ref:`1 <scopes>` |    Yes   |
213   | | <rx_dev_name>                      | | forwarding of DPDK              |                   |          |
214   +--------------------------------------+-----------------------------------+-------------------+----------+
215   | | ethdev <ethdev_name> promiscuous   | | Command to enable/disable       | :ref:`3 <scopes>` |    Yes   |
216   | | <on/off>                           | | promiscuous mode on DPDK port.  |                   |          |
217   +--------------------------------------+-----------------------------------+-------------------+----------+
218   | ethdev <ethdev_name> show            | | Command to dump current ethdev  | :ref:`2 <scopes>` |    Yes   |
219   |                                      | | configuration.                  |                   |          |
220   +--------------------------------------+-----------------------------------+-------------------+----------+
221   | ethdev <ethdev_name> stats           | | Command to dump current ethdev  | :ref:`2 <scopes>` |    Yes   |
222   |                                      | | statistics.                     |                   |          |
223   +--------------------------------------+-----------------------------------+-------------------+----------+
224   | | ethdev <ethdev_name> ip4 addr add  | | Command to configure IPv4       | :ref:`3 <scopes>` |    Yes   |
225   | | <ip> netmask <mask>                | | address on given PCI device. It |                   |          |
226   |                                      | | is needed if user wishes to use |                   |          |
227   |                                      | | ``ipv4_lookup`` node.           |                   |          |
228   +--------------------------------------+-----------------------------------+-------------------+----------+
229   | | ethdev <ethdev_name> ip6 addr add  | | Command to configure IPv6       | :ref:`3 <scopes>` |    Yes   |
230   | | <ip> netmask <mask>                | | address on given PCI device. It |                   |          |
231   |                                      | | is needed if user wishes to use |                   |          |
232   |                                      | | ``ipv6_lookup`` node.           |                   |          |
233   +--------------------------------------+-----------------------------------+-------------------+----------+
234   | help ethdev                          | | Command to dump ethdev help     | :ref:`2 <scopes>` |    Yes   |
235   |                                      | | message.                        |                   |          |
236   +--------------------------------------+-----------------------------------+-------------------+----------+
237   | | ipv4_lookup route add ipv4 <ip>    | | Command to add a route into     | :ref:`3 <scopes>` |    Yes   |
238   | |  netmask <mask> via <ip>           | | ``ipv4_lookup`` LPM table. It is|                   |          |
239   |                                      | | needed if user wishes to route  |                   |          |
240   |                                      | | the packets based on LPM lookup |                   |          |
241   |                                      | | table.                          |                   |          |
242   +--------------------------------------+-----------------------------------+-------------------+----------+
243   | help ipv4_lookup                     | | Command to dump ``ipv4_lookup`` | :ref:`2 <scopes>` |    Yes   |
244   |                                      | | help message.                   |                   |          |
245   +--------------------------------------+-----------------------------------+-------------------+----------+
246   | | ipv6_lookup route add ipv6 <ip>    | | Command to add a route into     | :ref:`3 <scopes>` |    Yes   |
247   | |  netmask <mask> via <ip>           | | ``ipv6_lookup`` LPM table. It is|                   |          |
248   |                                      | | needed if user wishes to route  |                   |          |
249   |                                      | | the packets based on LPM6 lookup|                   |          |
250   |                                      | | table.                          |                   |          |
251   +--------------------------------------+-----------------------------------+-------------------+----------+
252   | help ipv6_lookup                     | | Command to dump ``ipv6_lookup`` | :ref:`2 <scopes>` |    Yes   |
253   |                                      | | help message.                   |                   |          |
254   +--------------------------------------+-----------------------------------+-------------------+----------+
255   | neigh add ipv4 <ip> <mac>            | | Command to add a neighbour      | :ref:`3 <scopes>` |    Yes   |
256   |                                      | | information into                |                   |          |
257   |                                      | | ``ipv4_rewrite`` node.          |                   |          |
258   +--------------------------------------+-----------------------------------+-------------------+----------+
259   | neigh add ipv6 <ip> <mac>            | | Command to add a neighbour      | :ref:`3 <scopes>` |    Yes   |
260   |                                      | | information into                |                   |          |
261   |                                      | | ``ipv6_rewrite`` node.          |                   |          |
262   +--------------------------------------+-----------------------------------+-------------------+----------+
263   | help neigh                           | | Command to dump neigh help      | :ref:`2 <scopes>` |    Yes   |
264   |                                      | | message.                        |                   |          |
265   +--------------------------------------+-----------------------------------+-------------------+----------+
266   | | ethdev_rx map port <ethdev_name>   | | Command to add port-queue-core  | :ref:`1 <scopes>` |    No    |
267   | | queue <q_num> core <core_id>       | | mapping to ``ethdev_rx`` node.  |                   |          |
268   |                                      | | ``ethdev_rx`` node instance will|                   |          |
269   |                                      | | be pinned on given core and will|                   |          |
270   |                                      | | poll on requested port/queue    |                   |          |
271   |                                      | | pair.                           |                   |          |
272   +--------------------------------------+-----------------------------------+-------------------+----------+
273   | help ethdev_rx                       | | Command to dump ethdev_rx help  | :ref:`2 <scopes>` |    Yes   |
274   |                                      | | message.                        |                   |          |
275   +--------------------------------------+-----------------------------------+-------------------+----------+
276
277.. _scopes:
278
2791. Script only
2802. Telnet only
2813. Script and telnet both
282
283Runtime configuration
284---------------------
285
286Application allows some configuration to be modified at runtime using a telnet session.
287Application initiates a telnet server with host address ``0.0.0.0`` and port number ``8086``
288by default.
289
290If user passes ``-h`` and ``-p`` options while running application,
291then corresponding IP address and port number will be used for telnet session.
292
293After successful launch of application,
294client can connect to application using given host & port
295and console will be accessed with prompt ``graph>``.
296
297Command to access a telnet session:
298
299.. code-block:: console
300
301   telnet <host> <port>
302
303Example: ``dpdk-graph`` is started with ``-h 10.28.35.207`` and ``-p 50000`` then
304
305.. code-block:: console
306
307   $ telnet 10.28.35.207 50000
308   Trying 10.28.35.207...
309   Connected to 10.28.35.207.
310   Escape character is '^]'.
311
312   Welcome!
313
314   graph>
315   graph>
316   graph> help ethdev
317
318   ----------------------------- ethdev command help -----------------------------
319   ethdev <ethdev_name> rxq <n_queues> txq <n_queues> <mempool_name>
320   ethdev <ethdev_name> ip4 addr add <ip> netmask <mask>
321   ethdev <ethdev_name> ip6 addr add <ip> netmask <mask>
322   ethdev forward <tx_dev_name> <rx_dev_name>
323   ethdev <ethdev_name> promiscuous <on/off>
324   ethdev <ethdev_name> mtu <mtu_sz>
325   ethdev <ethdev_name> stats
326   ethdev <ethdev_name> show
327   graph>
328
329To exit the telnet session, type ``Ctrl + ]``.
330This changes the ``graph>`` command prompt to ``telnet>`` command prompt.
331Now running ``close`` or ``quit`` command on ``telnet>`` prompt
332will terminate the telnet session.
333
334
335Created graph for use case
336--------------------------
337
338On the successful execution of ``<usecase>.cli`` file, corresponding graph will be created.
339This section mentions the created graph for each use case.
340
341l3fwd
342~~~~~
343
344.. _figure_l3fwd_graph:
345
346.. figure:: img/graph-usecase-l3fwd.*
347
348l2fwd
349~~~~~
350
351.. _figure_l2fwd_graph:
352
353.. figure:: img/graph-usecase-l2fwd.*
354