<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">út 5. 5. 2026 v 20:39 odesílatel Lukas Sismis <<a href="mailto:sismis@dyna-nic.com">sismis@dyna-nic.com</a>> napsal:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This series extracts the testpmd flow CLI parser into a reusable library,<br>
enabling external applications to parse rte_flow rules using testpmd syntax.<br>
<br>
Motivation<br>
----------<br>
External applications like Suricata IDS [1] need to express hardware filtering<br>
rules in a consistent, human-readable format. Rather than inventing custom<br>
syntax, reusing testpmd's well-tested flow grammar provides immediate<br>
compatibility with existing documentation and user knowledge.<br>
<br>
Note: This library provides only one way to create rte_flow structures.<br>
Applications can also construct rte_flow_attr, rte_flow_item[], and<br>
rte_flow_action[] directly in C code.<br>
<br>
Design<br>
------<br>
The library (librte_flow_parser) exposes the following APIs:<br>
- rte_flow_parser_parse_attr_str(): Parse attributes only<br>
- rte_flow_parser_parse_pattern_str(): Parse patterns only<br>
- rte_flow_parser_parse_actions_str(): Parse actions only<br>
<br>
Testpmd is updated to use the library, ensuring a single<br>
maintained parser implementation.<br>
<br>
Testing and Demo<br>
-------<br>
- Functional tests in dpdk-test<br>
- Example application: examples/flow_parsing<br>
<br>
Changes<br>
-------<br>
v12:<br>
- flipped the ethdev dependency on cmdline, now cmdline depends on ethdev<br>
- added Bruce's ACK from v11 to the MSVC commit<br>
<br>
v11:<br>
- targetting 26.07 now<br>
- MAJOR overhaul of the patch set to make every part of the library API public<br>
and reusable, while only parsing flow testpmd commands.<br>
- library splitted into a "simple" part and "cmdline" part<br>
- testpmd changed to use the "cmdline" part of the library, and also to handle<br>
most of the "set" commands itself, while still using the library to parse <br>
the parameters of the "set" commands. Previous "operation callbacks" are now<br>
replaced by command-codes (enum) and the caller is expected to handle <br>
the command execution itself. Likewise, the ownership of helper structures,<br>
e.g. for vxlan/raw/sample etc. is in the hands of the caller, and the library<br>
only uses/fills them in with the parsed parameters.<br>
<br>
v10:<br>
- rebased to avoid Github Actions CI build failure<br>
- merge conflict solved in rel_notes/release_26_03.rst<br>
- release notes shortened<br>
<br>
v9:<br>
- removed extra new line from the flow parser docs file<br>
<br>
v8:<br>
- rte_port/queue_id_t typedefs removal to be included in a separate patch series<br>
- move of accidental changes of rte_flow parser library from the testpmd commit<br>
- DynaNIC copyright name update<br>
<br>
v7:<br>
- Fixed implicit integer comparison (while (left) -> while (left != 0))<br>
- NULL checks fixed<br>
- arpa header removed for Windows compatibility<br>
- minor comments from the last review addressed<br>
<br>
v6:<br>
- Inconsistent Experimental API Version adjusted<br>
- Fixes Tag added to MSVC build commit<br>
- Non-Standard Header Guards updated<br>
- Implicit Pointer Comparison and Return Type issues addressed in many places<br>
- commit message in patch 6 updated<br>
<br>
v5:<br>
- removed/replaced (f)printf code from the library <br>
- reverted back to exporting the internal/private API as it is needed by<br>
testpmd and cannot be easily split further.<br>
- adjusted length of certain lines<br>
- marking port/queue id typedef as experimental<br>
- updated release rel_notes<br>
- copyeright adjustments<br>
<br>
v4:<br>
- ethdev changes in separate commit<br>
- library's public API only exposes attribute, pattern and action parsing,<br>
while the full command parsing is kept internal for testpmd usage only.<br>
- Addressed Stephen's comments from V3<br>
- dpdk-test now have tests focused on public and internal library functions<br>
<br>
v3:<br>
- Add more functional tests<br>
- More concise MAINTAINERS updates<br>
- Updated license headers<br>
- A thing to note: When playing with flow commands, I figured, some may use<br>
non-flow commands, such as raw decap/encap, policy meter and others.<br>
Flow parser library itself now supports `set` command to set e.g. the decap/<br>
encap parameters, as the flow syntax only supports defining the index of the<br>
encap/decap configs. The library, however, does not support e.g. `create`<br>
command to create policy meters, as that is just an ID and it can be created<br>
separately using rte_meter APIs.<br>
<br>
[1] <a href="https://github.com/OISF/suricata/pull/13950" rel="noreferrer" target="_blank">https://github.com/OISF/suricata/pull/13950</a><br>
<br>
Lukas Sismis (6):<br>
cmdline: include stddef.h for MSVC compatibility<br>
ethdev: add RSS type helper APIs<br>
ethdev: add flow parser library<br>
app/testpmd: use flow parser from ethdev<br>
examples/flow_parsing: add flow parser demo<br>
test: add flow parser functional tests<br>
<br>
MAINTAINERS | 6 +-<br>
app/test-pmd/cmd_flex_item.c | 47 +-<br>
app/test-pmd/cmdline.c | 249 +-<br>
app/test-pmd/config.c | 115 +-<br>
app/test-pmd/flow_parser.c | 288 +<br>
app/test-pmd/flow_parser_cli.c | 478 +<br>
app/test-pmd/meson.build | 3 +-<br>
app/test-pmd/testpmd.h | 135 +-<br>
app/test/meson.build | 2 +<br>
app/test/test_ethdev_api.c | 56 +<br>
app/test/test_flow_parser.c | 790 +<br>
app/test/test_flow_parser_simple.c | 445 +<br>
doc/api/doxy-api-index.md | 2 +<br>
doc/guides/prog_guide/flow_parser_lib.rst | 99 +<br>
doc/guides/prog_guide/index.rst | 1 +<br>
doc/guides/rel_notes/release_26_07.rst | 11 +<br>
doc/guides/sample_app_ug/flow_parsing.rst | 60 +<br>
doc/guides/sample_app_ug/index.rst | 1 +<br>
examples/flow_parsing/main.c | 409 +<br>
examples/flow_parsing/meson.build | 8 +<br>
examples/meson.build | 1 +<br>
lib/cmdline/cmdline_parse.h | 2 +<br>
lib/cmdline/meson.build | 8 +-<br>
lib/cmdline/rte_flow_parser_cmdline.c | 138 +<br>
lib/cmdline/rte_flow_parser_cmdline.h | 82 +<br>
lib/ethdev/meson.build | 3 +<br>
lib/ethdev/rte_ethdev.c | 109 +<br>
lib/ethdev/rte_ethdev.h | 60 +<br>
.../ethdev/rte_flow_parser.c | 12350 ++++++++--------<br>
lib/ethdev/rte_flow_parser.h | 130 +<br>
lib/ethdev/rte_flow_parser_config.h | 583 +<br>
lib/ethdev/rte_flow_parser_internal.h | 124 +<br>
lib/meson.build | 4 +-<br>
33 files changed, 10157 insertions(+), 6642 deletions(-)<br>
create mode 100644 app/test-pmd/flow_parser.c<br>
create mode 100644 app/test-pmd/flow_parser_cli.c<br>
create mode 100644 app/test/test_flow_parser.c<br>
create mode 100644 app/test/test_flow_parser_simple.c<br>
create mode 100644 doc/guides/prog_guide/flow_parser_lib.rst<br>
create mode 100644 doc/guides/sample_app_ug/flow_parsing.rst<br>
create mode 100644 examples/flow_parsing/main.c<br>
create mode 100644 examples/flow_parsing/meson.build<br>
create mode 100644 lib/cmdline/rte_flow_parser_cmdline.c<br>
create mode 100644 lib/cmdline/rte_flow_parser_cmdline.h<br>
rename app/test-pmd/cmdline_flow.c => lib/ethdev/rte_flow_parser.c (59%)<br>
create mode 100644 lib/ethdev/rte_flow_parser.h<br>
create mode 100644 lib/ethdev/rte_flow_parser_config.h<br>
create mode 100644 lib/ethdev/rte_flow_parser_internal.h<br>
<br>
-- <br>
2.43.7<br>
<br></blockquote><div><br></div><div>Apparently, I missed documenting one field, so GH Actions will fail. But Stephen, can you please check and decide if this direction is viable? I didn't make the full parser part of the cmdline part, but now the cmdline has a dependency on ethdev.</div><div>I generally think, no matter the way you look at it, some added dependency will be present (and likely <span aria-invalid="grammar" class="Lm ng" style="border-style:none;background:none">of cmdline</span> on ethdev).</div><div>Thank you.</div></div></div>