Skip to content

[PWCI] "flow_parser: add shared parser library"#598

Open
ovsrobot wants to merge 7 commits intomainfrom
series_36972
Open

[PWCI] "flow_parser: add shared parser library"#598
ovsrobot wants to merge 7 commits intomainfrom
series_36972

Conversation

@ovsrobot
Copy link
Owner

@ovsrobot ovsrobot commented Jan 6, 2026

Auto-submission for "http://patchwork.dpdk.org/project/dpdk/list/?series=36972"

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced Flow Parser Library: a reusable component that parses DPDK flow rules from command strings, enabling applications to programmatically create flow rules
    • Added lightweight helpers for parsing flow attributes, patterns, and actions independently
    • Added flow parsing example code demonstrating practical usage
  • Documentation

    • Added comprehensive guide for the Flow Parser Library
  • Improvements

    • Enhanced RSS type handling with new string conversion APIs

✏️ Tip: You can customize this high-level summary in your review settings.

Lukas Sismis added 7 commits January 6, 2026 10:48
Introduce librte_flow_parser as an optional, experimental library
exposing the testpmd flow CLI parser as a reusable component.

The library provides:
- rte_flow_parser_init(): Initialize parser with operation callbacks
- rte_flow_parser_parse(): Parse flow command strings into output
- rte_flow_parser_run(): Parse and execute via registered callbacks
- Helper functions for parsing pattern/action/attribute strings

The parser uses a single global instance design for simplicity.
All parsing state is internal to the library. Callbacks are invoked
for flow create, destroy, validate, query and other flow operations.

This enables applications to reuse testpmd's well-tested flow syntax
without duplicating the parser implementation.

Signed-off-by: Lukas Sismis <sismis@dyna-nic.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
Switch testpmd to use the shared librte_flow_parser library instead
of the embedded cmdline_flow.c implementation.

Changes:
- Remove app/test-pmd/cmdline_flow.c (moved to library)
- Add flow_parser.c: Implements flow operation callbacks that bridge
  the parser library to testpmd's port/flow management functions
- Add flow_parser_cli.c: Hosts cmdline integration for 'flow' and
  'set raw_encap/decap' commands
- Update cmdline.c to register flow commands with the parser
- Update meson.build to link against flow_parser library

The testpmd flow command syntax remains unchanged. All existing
flow commands continue to work identically.

Signed-off-by: Lukas Sismis <sismis@dyna-nic.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
Add example application demonstrating the flow parser library API.

The example shows:
- Using parse_attr_str() to parse flow attributes from strings
- Using parse_pattern_str() to parse match patterns
- Using parse_actions_str() to parse flow actions
- Printing parsed results with RTE_FLOW_LOG macros
- Integration without EAL initialization (library is standalone)

Build with: meson configure -Dexamples=flow_parsing

Signed-off-by: Lukas Sismis <sismis@dyna-nic.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
Add comprehensive unit tests for the flow parser library.

Tests cover:
- flow_parser_autotest: Tests rte_flow_parser_parse() with various
  flow command strings including create, destroy, validate, query,
  list, and isolate commands. Verifies parsed patterns, actions,
  and attributes match expected values.

- flow_parser_helpers_autotest: Tests the standalone helper functions
  parse_attr_str(), parse_pattern_str(), and parse_actions_str().
  Verifies parsing of attributes, patterns with various item types,
  and action sequences.

Run with: dpdk-test flow_parser_autotest
          dpdk-test flow_parser_helpers_autotest

Signed-off-by: Lukas Sismis <sismis@dyna-nic.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
Add maintainer entries for the new flow parser library.
Update .mailmap with new contributor email.

Signed-off-by: Lukas Sismis <sismis@dyna-nic.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
Fix Python syntax errors in f-strings that used nested quotes
incorrectly. The pattern f'{foo['bar']}' is invalid Python 3.11
syntax and breaks Sphinx autodoc during documentation builds.

Use f"{foo['bar']}" with outer double quotes instead.

Signed-off-by: Lukas Sismis <sismis@dyna-nic.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
Include <stddef.h> at the top of cmdline_parse.h before the
fallback offsetof macro definition. This prevents macro
redefinition warnings when building with MSVC which uses /WX
(warnings as errors).

The standard header provides offsetof on all platforms, and
including it first ensures the fallback is only used when truly
needed.

Signed-off-by: Lukas Sismis <sismis@dyna-nic.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @ovsrobot, your pull request is larger than the review limit of 150000 diff characters

@coderabbitai
Copy link

coderabbitai bot commented Jan 6, 2026

📝 Walkthrough

Walkthrough

Introduces a new experimental librte_flow_parser library that exposes testpmd's flow CLI parser as a reusable component for parsing DPDK flow rules. Integrates the parser into test-pmd, adds new ethdev APIs for RSS type information, and removes legacy flow parsing infrastructure. Includes example code, documentation, and test coverage.

Changes

Cohort / File(s) Summary
Flow Parser Library
lib/flow_parser/meson.build, lib/flow_parser/rte_flow_parser.h
New experimental library with comprehensive public API for parsing flow commands, attributes, patterns, and actions. Defines encapsulation config structures (VXLAN, NVGRE, L2, MPLS), command callbacks, parser operations, and CLI registration hooks.
Ethdev RSS Type APIs
lib/ethdev/rte_ethdev.h, lib/ethdev/rte_ethdev.c
Added three new runtime APIs for RSS type conversion: rte_eth_rss_type_info_get(), rte_eth_rss_type_from_str(), rte_eth_rss_type_to_str(). Added new typedefs rte_port_id_t and rte_queue_id_t.
Test-PMD Core Integration
app/test-pmd/testpmd.h, app/test-pmd/testpmd.c
Updated port/queue typedefs to use new ethdev types; added flow parser initialization call in main; removed legacy flow parsing API and encapsulation structure externs; added flow parser header inclusion.
Test-PMD Flow Parsing Implementation
app/test-pmd/flow_parser.h, app/test-pmd/flow_parser.c
New adapter layer for test-pmd integrating with flow parser library; provides port/flow traversal helpers, tunnel ops conversion, validation/creation entry points, and parser operation tables.
Test-PMD CLI Integration
app/test-pmd/flow_parser_cli.c
New command-line handlers for flow and raw encap/decap commands; defines public cmdline parse instances (cmd_flow, cmd_set_raw, cmd_show_set_raw, cmd_show_set_raw_all) with token parsing and hexdump display utilities.
Test-PMD Command Infrastructure
app/test-pmd/cmdline.c
Integrated flow parser with dynamic token registration; replaced legacy RSS type handling with new ethdev APIs; replaced direct encapsulation config references with parser-provided accessors guarded by NULL checks.
Test-PMD Configuration
app/test-pmd/config.c
Removed legacy static RSS type table and helper functions; refactored RSS display logic to use new ethdev runtime APIs; replaced direct conntrack context usage with parser accessor.
Test-PMD Flex Item
app/test-pmd/cmd_flex_item.c
Integrated new flow parser API for flex item flow parsing; uses rte_flow_parser_parse() with dedicated output buffer and validates CREATE command requirement.
Test-PMD Build
app/test-pmd/meson.build
Replaced cmdline_flow.c with flow_parser.c and flow_parser_cli.c; added flow_parser dependency.
Test Suite
app/test/test_flow_parser.c, app/test/meson.build
Added two new test suites validating flow parser command mapping and lightweight attribute/pattern/actions parsing with various configurations.
Example Application
examples/flow_parsing/main.c, examples/flow_parsing/meson.build, examples/meson.build
New example demonstrating flow parser usage with helper functions for printing attributes, patterns, and actions; includes initialization, parsing, and output demonstrations.
Documentation
doc/guides/prog_guide/flow_parser_lib.rst, doc/guides/prog_guide/index.rst, doc/guides/rel_notes/release_26_03.rst
Added comprehensive flow parser library guide covering initialization, parsing APIs, lightweight helpers, thread-safety caveats, and integration patterns. Added library to release notes and utility libraries index.
Build System
lib/meson.build
Added flow_parser to libraries and always\_enable lists.
Metadata
.mailmap, MAINTAINERS
Updated Lukas Sismis email mapping in .mailmap; referenced new lib/flow_parser/ and related files in MAINTAINERS.
Python DTS
dts/api/testpmd/__init__.py
Minor string literal adjustments in three command formatting functions (quote normalization).
Cmdline Headers
lib/cmdline/cmdline_parse.h
Added #include <stddef.h> for standard definitions.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant testpmd as testpmd<br/>CLI
    participant parser as rte_flow_parser<br/>(Library)
    participant adapter as testpmd<br/>Adapter<br/>(flow_parser.c)
    participant handlers as Port<br/>Handlers
    participant ethdev as DPDK<br/>Core

    User->>testpmd: "flow create 0 pattern eth / actions drop"
    testpmd->>parser: rte_flow_parser_parse(cmd_str)
    parser->>parser: Tokenize & validate
    parser-->>testpmd: rte_flow_parser_output
    testpmd->>adapter: Query ops (validate_flow, create_flow)
    adapter->>handlers: port_flow_validate() / port_flow_create()
    handlers->>ethdev: rte_flow_create()
    ethdev-->>handlers: flow_handle
    handlers-->>adapter: result
    adapter-->>testpmd: status
    testpmd-->>User: Success/Error message

    Note over parser,adapter: New architecture:<br/>Parsing decoupled from<br/>execution via callbacks
Loading
sequenceDiagram
    actor App as External App
    participant init as Initialization
    participant parser as rte_flow_parser
    participant parse_fn as Parse Functions
    participant helpers as Lightweight<br/>Helpers

    App->>init: testpmd_flow_parser_init()
    init->>parser: rte_flow_parser_init(ops_table)
    parser->>parser: Register callback ops
    parser-->>init: Success

    App->>parse_fn: rte_flow_parser_parse(pattern_str)
    parse_fn->>parse_fn: Full parse + execute
    parse_fn-->>App: rte_flow_parser_output

    alt Lightweight (no execution)
        App->>helpers: rte_flow_parser_parse_attr_str()
        helpers->>helpers: Parse only
        helpers-->>App: rte_flow_attr
    end

    Note over parser,helpers: Two modes:<br/>Full (with dispatch)<br/>Lightweight (parse-only)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 Whiskers twitching with glee,
A parser born wild and free,
From testpmd's embrace, it hops away,
To parse all flows in a brilliant way!
With callbacks dancing and tokens bright,
Flow creation takes graceful flight! 🌸

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.57% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly summarizes the main change: introducing a new shared flow_parser library. It is specific and relates directly to the primary objective.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI Agents
In @lib/flow_parser/rte_flow_parser.h:
- Line 208: Fix the spelling typo in the comment that reads "Sub-leve commands."
by updating it to "Sub-level commands." so the descriptive comment for the
sub-level command section is correct; locate the comment string in
lib/flow_parser/rte_flow_parser.h (the line containing "Sub-leve commands.") and
replace it accordingly.
🧹 Nitpick comments (12)
lib/ethdev/rte_ethdev.c (1)

5171-5276: RSS type mapping API is sound; clarify 0/NULL semantics and intended usage

The static rte_eth_rss_type_table and the three helpers are straightforward and match typical DPDK patterns; no correctness issues jump out. Two behavioral points worth calling out:

  • rte_eth_rss_type_from_str() returns 0 both for "none" and for NULL/unknown input. That’s fine if call‑sites either special‑case "none" or treat “unknown” as “no bits”, but it does make error vs “none” indistinguishable from the return value alone.
  • rte_eth_rss_type_to_str() only returns a name for exact entries in the table; combined bitmasks will correctly yield NULL. It might be useful to explicitly document that it’s for single/group constants, not arbitrary OR’d masks.

If these semantics are what the higher‑level CLI/parser already expects, I’d just ensure they’re documented in rte_ethdev.h so users don’t misinterpret 0/NULL as hard errors.

app/test-pmd/cmd_flex_item.c (1)

132-133: Consider heap allocation for large parser output buffer.

The 4096-byte stack allocation for outbuf may be excessive for environments with limited stack space. Consider using heap allocation if this function is called in contexts where stack space is constrained.

💡 Alternative approach using heap allocation
-	uint8_t outbuf[4096];
+	uint8_t *outbuf = malloc(4096);
 	struct rte_flow_parser_output *out = (void *)outbuf;
 	int ret;
+
+	if (!outbuf)
+		return -ENOMEM;
 
 	sprintf(flow_rule,
 		"flow create 0 pattern %s / end actions drop / end", src);
 	memset(outbuf, 0, sizeof(outbuf));
 	ret = rte_flow_parser_parse(flow_rule, out, sizeof(outbuf));
-	if (ret)
+	if (ret) {
+		free(outbuf);
 		return ret;
+	}
 	if (out->command != RTE_FLOW_PARSER_CMD_CREATE)
+	{
+		free(outbuf);
 		return -EINVAL;
+	}
+	// ... rest of the function ...
+	free(outbuf);
lib/ethdev/rte_ethdev.h (1)

171-174: RSS helper APIs and new typedefs look consistent; consider clarifying “not found” semantics

The rte_port_id_t/rte_queue_id_t typedefs are straightforward aliases and align with existing usage of 16‑bit IDs, and the RSS type helper trio (_info_get, _from_str, _to_str) cleanly exposes the static table from rte_ethdev.c.

One small design point: rte_eth_rss_type_from_str() returns 0 both for “not found/NULL” and for a legitimate value if 0 were ever introduced as a valid RSS type. Today all RTE_ETH_RSS_* bits are non‑zero, so it’s safe, but you may want to document this explicitly or consider a future bool/int return plus an out‑param if an actual 0-valued type is ever added.

Also applies to: 4897-4950

app/test-pmd/flow_parser.c (3)

21-38: Index-based helpers are simple but give O(n²) traversal when enumerating many flows

parser_flow_rule_count() walks port->flow_list once, and parser_flow_rule_id_get() walks from the head again for each index via parser_flow_by_index(). If the parser library iterates index=0..count-1, total cost is O(n²) in the number of rules.

Given this is testpmd/CLI-oriented it’s probably fine, but if you expect very large rule lists it might be worth either:

  • Storing a count in struct rte_port and returning it directly, and/or
  • Adding a direct “nth element” helper that caches traversal state when called repeatedly.

Also applies to: 81-92


40-58: Template/table enumeration uses the same O(n²) pattern as flows

parser_pattern_template_count / _id_get, parser_actions_template_count / _id_get, and parser_table_count / _id_get mirror the flow helpers and re-traverse the linked lists from the head for every index.

As with flows, this is acceptable for small lists and CLI usage, but will degrade quadratically if the library walks all indices. If these lists can grow large, consider either caching counts on struct rte_port and/or adopting an iterator pattern rather than “count + indexed get”.

Also applies to: 110-154, 172-199


201-220: RSS queue count fallback logic: clarify assumptions on dev_info.max_rx_queues

parser_rss_queue_count() returns port->queue_nb when queues are configured, otherwise falls back to port->dev_info.max_rx_queues. That makes sense for pre‑configuration introspection, but relies on dev_info having been populated and max_rx_queues being non‑zero.

If there is any path where parser_rss_queue_count() can be called before dev_info is valid, you may want a defensive fallback (e.g., return 0) or a brief comment stating the assumption that dev_info has already been filled.

app/test-pmd/flow_parser_cli.c (2)

13-33: Dynamic token wiring via cl == NULL is unconventional; ensure call sites match the contract

cmd_flow_cb / cmd_set_raw_cb treat cl == NULL as “token registration” (delegating to rte_flow_parser_cmd_*_tok) and cl != NULL as “dispatch” (delegating to rte_flow_parser_cmd_*_dispatch). The associated cmdline_parse_inst_t instances (cmd_flow, cmd_set_raw) start with .tokens = { NULL }, so some initialization path must be explicitly invoking these callbacks with cl == NULL to fill in the token arrays.

This is a clever reuse of the f callback, but it’s also non‑standard for cmdline. Please double‑check that your initialization code actually calls cmd_flow_cb(NULL, …) / cmd_set_raw_cb(NULL, …) with appropriate arguments so that the tokens get populated before the CLI starts parsing commands.

Also applies to: 109-125


34-94: show raw_encap/raw_decap helper is robust; minor robustness nits only

The cmd_show_set_raw_parsed() logic correctly:

  • Distinguishes all vs single index using cmd_all,
  • Validates cmd_index against RAW_ENCAP_CONFS_MAX_NUM,
  • Checks conf/data/size before dumping, and
  • Iterates over all configured entries when requested.

A couple of small, optional refinements:

  • Since cmd_show_set_raw_parsed is shared between the <index> and all variants, it relies on the parser zero‑initializing struct cmd_show_set_raw_result, so cmd_all is an empty string for the <index> form. That’s how cmdline works today, but adding an explicit if (res->cmd_all[0] == '\0') comment or check would make the dependency clearer.
  • title[16] is tight but safe for current index ranges; bumping to something like 32 bytes would leave more headroom if RAW_ENCAP_CONFS_MAX_NUM ever grows significantly.

None of this blocks the change; the current implementation is functionally sound.

Also applies to: 96-149

app/test-pmd/cmdline.c (2)

10559-11279: Encap/decap “set” commands correctly write into librte_flow_parser config structs

The refactor of set vxlan/nvgre/l2_encap/l2_decap/mplsogre_encap/mplsogre_decap/mplsoudp_encap/mplsoudp_decap to:

  • fetch struct rte_flow_parser_*_conf * via the corresponding rte_flow_parser_*_encap_conf() / *_decap_conf() helpers,
  • NULL‑check those pointers before touching them, and
  • populate fields (VNI/TNI/labels, UDP ports, IPs, VLAN TCI, MACs, selector bits)

matches the previous per‑feature CLI behavior while moving state into the shared parser library. The use of IPV4_ADDR_TO_UINT / IPV6_ADDR_TO_ARRAY and rte_cpu_to_be_16/32 keeps the expected endianness. The only small polish you might consider is logging a brief error instead of silently return when a *_conf() helper returns NULL, to aid debugging if the parser isn’t initialized.


11457-11624: Defensively NULL‑check rte_flow_parser_conntrack_context() before use

In cmd_set_conntrack_common_parsed and cmd_set_conntrack_dir_parsed you now obtain the conntrack context via rte_flow_parser_conntrack_context() but don’t NULL‑check it before dereferencing, unlike the other rte_flow_parser_*_conf() helpers above. If this ever failed (e.g., parser not initialized), the CLI would segfault.

Consider aligning with the other helpers and returning early on NULL, e.g.:

Proposed defensive checks
 static void cmd_set_conntrack_common_parsed(void *parsed_result,
                                             __rte_unused struct cmdline *cl,
                                             __rte_unused void *data)
 {
     struct cmd_set_conntrack_common_result *res = parsed_result;
-    struct rte_flow_action_conntrack *ct = rte_flow_parser_conntrack_context();
+    struct rte_flow_action_conntrack *ct = rte_flow_parser_conntrack_context();
+
+    if (ct == NULL)
+        return;
@@
 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
                                          __rte_unused struct cmdline *cl,
                                          __rte_unused void *data)
 {
     struct cmd_set_conntrack_dir_result *res = parsed_result;
-    struct rte_flow_action_conntrack *ct = rte_flow_parser_conntrack_context();
+    struct rte_flow_action_conntrack *ct = rte_flow_parser_conntrack_context();
     struct rte_flow_tcp_dir_param *dir = NULL;
+
+    if (ct == NULL)
+        return;

This keeps the CLI robust even if the global parser context isn’t available for some reason.

lib/flow_parser/rte_flow_parser.h (2)

934-936: Inconsistent comment style for struct members.

Lines 935-936 use /** but end with just */ without proper Doxygen format. Consider using consistent /**< ... */ style for trailing member comments.

🔎 Proposed fix
 	enum rte_flow_parser_command_index command; /**< Flow command. */
 	uint16_t port; /**< Affected port ID. */
-	uint16_t queue; /** Async queue ID. */
-	bool postpone; /** Postpone async operation */
+	uint16_t queue; /**< Async queue ID. */
+	bool postpone; /**< Postpone async operation. */
 	union {

1244-1298: Document thread-safety constraints more prominently.

The helper functions (rte_flow_parser_parse_attr_str, rte_flow_parser_parse_pattern_str, rte_flow_parser_parse_actions_str) return pointers to internal storage that is invalidated by the next call. While this is documented per-function, consider adding a prominent note at the top of the API section about the parser using global/thread-local state, which has implications for concurrent usage.

Based on the external context showing a single global parser instance with parser.ctx, concurrent calls from multiple threads could lead to data races. If thread-safety is required, consider documenting this limitation explicitly or using thread-local storage.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd60dcd and a308542.

📒 Files selected for processing (27)
  • .mailmap
  • MAINTAINERS
  • app/test-pmd/cmd_flex_item.c
  • app/test-pmd/cmdline.c
  • app/test-pmd/config.c
  • app/test-pmd/flow_parser.c
  • app/test-pmd/flow_parser.h
  • app/test-pmd/flow_parser_cli.c
  • app/test-pmd/meson.build
  • app/test-pmd/testpmd.c
  • app/test-pmd/testpmd.h
  • app/test/meson.build
  • app/test/test_flow_parser.c
  • doc/guides/prog_guide/flow_parser_lib.rst
  • doc/guides/prog_guide/index.rst
  • doc/guides/rel_notes/release_26_03.rst
  • dts/api/testpmd/__init__.py
  • examples/flow_parsing/main.c
  • examples/flow_parsing/meson.build
  • examples/meson.build
  • lib/cmdline/cmdline_parse.h
  • lib/ethdev/rte_ethdev.c
  • lib/ethdev/rte_ethdev.h
  • lib/flow_parser/meson.build
  • lib/flow_parser/rte_flow_parser.c
  • lib/flow_parser/rte_flow_parser.h
  • lib/meson.build
🧰 Additional context used
🧬 Code graph analysis (10)
dts/api/testpmd/__init__.py (2)
dts/framework/testbed_model/os_session.py (1)
  • send_command (134-163)
dts/framework/exception.py (1)
  • InteractiveCommandExecutionError (180-184)
app/test-pmd/testpmd.c (1)
app/test-pmd/flow_parser.c (1)
  • testpmd_flow_parser_init (402-406)
lib/ethdev/rte_ethdev.h (1)
lib/ethdev/rte_ethdev.c (3)
  • rte_eth_rss_type_info_get (5241-5245)
  • rte_eth_rss_type_from_str (5248-5262)
  • rte_eth_rss_type_to_str (5265-5276)
app/test-pmd/cmd_flex_item.c (1)
lib/flow_parser/rte_flow_parser.c (1)
  • rte_flow_parser_parse (14690-14718)
examples/flow_parsing/main.c (1)
lib/flow_parser/rte_flow_parser.c (4)
  • rte_flow_parser_parse_attr_str (14803-14822)
  • rte_flow_parser_parse_pattern_str (14824-14846)
  • rte_flow_parser_parse_actions_str (14848-14872)
  • rte_flow_parser_init (1070-1076)
app/test-pmd/config.c (2)
lib/flow_parser/rte_flow_parser.c (2)
  • p (13612-13616)
  • rte_flow_parser_conntrack_context (1126-1130)
lib/ethdev/rte_ethdev.c (3)
  • rte_eth_rss_type_to_str (5265-5276)
  • rte_eth_rss_type_info_get (5241-5245)
  • rte_eth_rss_type_from_str (5248-5262)
app/test-pmd/testpmd.h (1)
app/test-pmd/flow_parser.c (1)
  • testpmd_flow_parser_init (402-406)
app/test/test_flow_parser.c (1)
lib/flow_parser/rte_flow_parser.c (5)
  • rte_flow_parser_init (1070-1076)
  • rte_flow_parser_parse (14690-14718)
  • rte_flow_parser_parse_attr_str (14803-14822)
  • rte_flow_parser_parse_pattern_str (14824-14846)
  • rte_flow_parser_parse_actions_str (14848-14872)
app/test-pmd/flow_parser_cli.c (1)
lib/flow_parser/rte_flow_parser.c (6)
  • rte_flow_parser_cmd_flow_tok (14660-14665)
  • rte_flow_parser_cmd_flow_dispatch (14674-14680)
  • rte_flow_parser_cmd_set_raw_tok (14667-14672)
  • rte_flow_parser_cmd_set_raw_dispatch (14682-14688)
  • rte_flow_parser_raw_encap_conf_get (821-832)
  • rte_flow_parser_raw_decap_conf_get (834-844)
lib/flow_parser/rte_flow_parser.h (1)
lib/flow_parser/rte_flow_parser.c (19)
  • rte_flow_parser_reset_defaults (1056-1068)
  • rte_flow_parser_vxlan_encap_conf (1078-1082)
  • rte_flow_parser_nvgre_encap_conf (1084-1088)
  • rte_flow_parser_l2_encap_conf (1090-1094)
  • rte_flow_parser_l2_decap_conf (1096-1100)
  • rte_flow_parser_mplsogre_encap_conf (1102-1106)
  • rte_flow_parser_mplsogre_decap_conf (1108-1112)
  • rte_flow_parser_mplsoudp_encap_conf (1114-1118)
  • rte_flow_parser_mplsoudp_decap_conf (1120-1124)
  • rte_flow_parser_conntrack_context (1126-1130)
  • rte_flow_parser_raw_encap_conf_get (821-832)
  • rte_flow_parser_raw_decap_conf_get (834-844)
  • rte_flow_parser_init (1070-1076)
  • rte_flow_parser_cmdline_register (14652-14658)
  • rte_flow_parser_parse (14690-14718)
  • rte_flow_parser_run (14720-14745)
  • rte_flow_parser_parse_attr_str (14803-14822)
  • rte_flow_parser_parse_pattern_str (14824-14846)
  • rte_flow_parser_parse_actions_str (14848-14872)
🪛 Cppcheck (2.19.0)
app/test-pmd/flow_parser.c

[error] 361-361: syntax error

(syntaxError)

🔇 Additional comments (46)
.mailmap (1)

936-936: Correctly consolidated contributor identity mapping.

The mailmap entry properly consolidates both email addresses for Lukas Sismis, with the newer affiliation (sismis@dyna-nic.com) as the canonical identity while preserving the legacy alias. The entry is correctly positioned alphabetically and follows the standard .mailmap format used elsewhere in the file.

dts/api/testpmd/__init__.py (3)

230-230: LGTM - Style consistency improvement.

The change from "" to '' is purely cosmetic and improves quote style consistency within the f-string. No functional impact.


901-905: LGTM - Style consistency improvement.

The changes standardize quote usage within f-string conditional expressions (double quotes → single quotes). These are purely stylistic with no functional impact on the error logging or exception messages.


1538-1538: LGTM - Style consistency improvement.

The change standardizes quote usage within the f-string conditional expression (double quotes → single quotes). The testpmd command string remains functionally identical.

MAINTAINERS (1)

445-452: Flow API ownership for new flow parser bits looks consistent

Listing lib/flow_parser/, app/test-pmd/flow_parser.c, and the new flow_parser_lib doc under the Flow API section matches the new library and its integration; nothing else to flag here.

lib/cmdline/cmdline_parse.h (1)

10-18: Including <stddef.h> before the fallback offsetof macro is correct

Pulling in <stddef.h> and only defining offsetof under #ifndef offsetof is the right way to avoid compiler warnings while preserving the existing fallback; no further changes needed.

app/test/meson.build (1)

90-92: test_flow_parser meson wiring matches new library dependencies

Hooking test_flow_parser.c into source_file_deps with ['flow_parser', 'cmdline', 'ethdev'] aligns with the new library’s usage and integrates cleanly with the existing per‑file dependency logic; looks good.

doc/guides/prog_guide/index.rst (1)

120-124: Prog guide index correctly lists the new Flow Parser library

Adding flow_parser_lib to the Utility Libraries toctree is consistent with the new documentation file and keeps ordering sensible; no issues here.

app/test-pmd/meson.build (1)

16-17: LGTM: Flow parser integration into testpmd build.

The addition of flow_parser.c and flow_parser_cli.c source files along with the flow_parser library dependency correctly integrates the new flow parser functionality into the testpmd build system.

Also applies to: 38-38

examples/flow_parsing/meson.build (1)

9-11: LGTM: Standard example build configuration.

The build configuration correctly enables experimental APIs and declares the dependency on the flow_parser library, following standard DPDK example patterns.

app/test-pmd/testpmd.c (1)

4619-4621: LGTM: Flow parser initialization with appropriate error handling.

The flow parser initialization is correctly placed in the startup sequence (after init_config() but before device operations) and includes proper error handling with rte_exit() on failure. The initialization ensures the parser is ready before any flow operations can be performed.

app/test-pmd/flow_parser.h (1)

1-8: LGTM: Minimal header exposing flow parser API.

The header correctly includes the flow parser public API and follows standard DPDK header conventions with appropriate include guards.

examples/meson.build (1)

20-20: LGTM: Example correctly added to build list.

The flow_parsing example is correctly added to the alphabetically sorted all_examples list.

lib/flow_parser/meson.build (1)

1-6: LGTM! Build configuration is correct.

The Meson build file properly defines the flow parser library with appropriate dependencies on cmdline and ethdev.

lib/meson.build (2)

71-71: LGTM! Library registration is correct.

The flow_parser library is properly added to the libraries list. The placement at the end is appropriate for a new library that depends on existing core libraries.


79-79: LGTM! Always-enable configuration is appropriate.

Adding flow_parser to the always_enable list ensures it's always built and available, which is appropriate for a library that provides essential flow parsing functionality.

doc/guides/rel_notes/release_26_03.rst (1)

58-65: LGTM! Release notes are clear and comprehensive.

The release notes accurately describe the new experimental flow parser library, its purpose, and key features. The documentation properly emphasizes the experimental and optional nature of the library.

doc/guides/prog_guide/flow_parser_lib.rst (1)

1-140: LGTM! Excellent comprehensive documentation.

The documentation thoroughly covers the flow parser library with:

  • Clear explanation of purpose and alternatives
  • Important thread-safety and buffer management caveats
  • Comprehensive API coverage
  • Usage examples and build instructions
  • Callback model explanation

The documentation properly warns users about thread-safety limitations and buffer size requirements, which are critical for correct usage.

examples/flow_parsing/main.c (4)

37-163: LGTM! Helper functions are well-implemented.

The helper functions properly:

  • Check for null specs/configs before dereferencing
  • Use appropriate buffer sizes for inet_ntop
  • Apply correct byte-order conversions with ntohs
  • Handle multiple pattern and action types

272-320: Good documentation of buffer limitations.

The demo_combine function excellently documents the static buffer limitation (lines 266-269 and 283), warning users that returned pointers are only valid until the next parse call. The comments at lines 316-319 appropriately suggest copying data in real applications.

This is a clear and helpful demonstration of proper usage patterns.


322-345: LGTM! Main function structure is clean and correct.

The main function properly:

  • Initializes the flow parser with appropriate error checking
  • Runs all demonstration functions in logical order
  • Returns correct exit codes

5-25: Excellent header documentation.

The file header provides outstanding context by:

  • Clearly stating this is ONE WAY to create rte_flow structures
  • Documenting alternative approaches (direct C construction)
  • Explaining appropriate use cases
  • Listing the key functions demonstrated

This helps users understand when to use the flow parser vs. other approaches.

app/test/test_flow_parser.c (2)

11-88: Good test coverage for command parsing.

The test thoroughly validates the flow parser's ability to parse different command types and extract the correct information from the parsed output. The validation checks are comprehensive.


90-220: Excellent coverage of helper APIs.

The test thoroughly exercises the attribute, pattern, and action parsing helpers with various configurations. The validation of queue configurations and mark IDs demonstrates proper testing of parsed action parameters.

app/test-pmd/config.c (4)

667-697: Good migration to ethdev RSS type API.

The refactor to use rte_eth_rss_type_to_str() instead of a local static mapping improves maintainability and ensures consistency with the ethdev library's RSS type naming.


1447-1473: Well-refactored RSS types display using runtime API.

The migration from a static table to using rte_eth_rss_type_info_get() improves maintainability. The iteration logic correctly filters out invalid entries and matches enabled types.


4718-4748: Appropriate migration to ethdev RSS type conversion API.

The change from str_to_rsstypes() to rte_eth_rss_type_from_str() correctly adopts the ethdev library's standard API for RSS type string conversion, improving code consistency.


1768-1778: No issues found. The conntrack context initialization is handled correctly at application startup via testpmd_flow_parser_init() called in testpmd.c before any code in config.c executes. The rte_flow_parser_conntrack_context() function is the official API for accessing the parser-maintained conntrack context, and its usage is consistent throughout the codebase (cmdline.c uses the same pattern). The design aligns with the flow parser library's intent to maintain global state for conntrack and other configuration contexts.

app/test-pmd/cmd_flex_item.c (1)

149-169: Use pattern length field to avoid unnecessary copying of zero-padded buffer.

The memcpy operations at lines 151-152, 158-159, and 165-166 copy a fixed FLEX_MAX_FLOW_PATTERN_LENGTH bytes, but the source pattern buffers have a length field that indicates the actual valid data size (populated at cmd_flex_item.c:505). While the source buffers are zero-initialized, copying 64 bytes when the pattern may be only 10-20 bytes is inefficient and masks the intent of the code.

Update the memcpy calls to respect the actual pattern length:

if (out->args.vc.pattern[0].spec) {
	ptr = (void *)(uintptr_t)item->spec;
	memcpy(ptr, out->args.vc.pattern[0].spec,
	       out->args.vc.pattern[0].spec->length);
}

Or ensure the contract is documented: if buffers are guaranteed to be exactly FLEX_MAX_FLOW_PATTERN_LENGTH bytes with appropriate padding, document that assumption clearly.

app/test-pmd/flow_parser.c (3)

60-73: Stack-based tunnel_ops conversion relies on callees not retaining the pointer

parser_tunnel_convert() fills a caller-provided struct tunnel_ops on the stack and returns dst. Callers like parser_flow_validate, parser_flow_create, and parser_flow_tunnel_create immediately pass that pointer into port_flow_* functions.

This is fine as long as the port_flow_* implementations only read tunnel_ops during the call and do not store the pointer for later asynchronous use. If any of those functions cache the pointer inside a long-lived object, this would become a use‑after‑return bug.

Please double-check that port_flow_validate(), port_flow_create(), and port_flow_tunnel_create() treat tunnel_ops as strictly call-local data.

Also applies to: 282-307, 316-324


253-274: Flex handle / pattern getters are defensively implemented

parser_flex_handle_get() and parser_flex_pattern_get() both guard against out-of-range IDs and NULLs, and cleanly return NULL / -ENOENT without dereferencing invalid pointers. The pattern getter also returns pointers into the static flex_patterns storage, so the caller need not manage lifetime.

This looks solid and matches expected semantics for optional resources.


326-345: Ops tables wiring looks correct; Cppcheck “syntax error” is likely a false positive

The parser_query_ops, parser_command_ops, and parser_ops initializers consistently map to the corresponding rte_flow_parser_ops_* fields, and the function signatures match what the names suggest.

The line split around .flow_template_table_resize_complete = followed on the next line by port_flow_template_table_resize_complete, is valid C and should not be a real syntax issue. The reported Cppcheck “syntax error” around this region is almost certainly a parser limitation on designated initializers or macros rather than a true problem.

No change needed functionally; if you want to quiet that specific tool you could place the initializer on one line, but it’s not required.

Also applies to: 347-400, 402-405

app/test-pmd/cmdline.c (3)

39-40: Flow parser headers and local integration look consistent

Including <rte_flow_parser.h> and the new "flow_parser.h" here is the right place, and ordering with other rte headers is consistent with the rest of testpmd. This should give you the needed prototypes and local helpers without introducing layering issues, assuming the build links librte_flow_parser on all relevant targets.

Also applies to: 69-70


2362-2367: RSS configuration now uses rte_eth_rss_type_from_str – semantics look correct

Switching to rte_eth_rss_type_from_str(res->value) centralizes the string→RSS-hf mapping and will automatically pick up new types defined by ethdev. The 0‑return check with “Unknown parameter” is a clear error path, and none/numeric ids are still handled earlier in the function, so behavior for existing CLI values should be preserved. Please just double‑check against the ethdev API docs that no valid RSS type ever maps to 0 in your target DPDK version.


9457-9460: Dynamic flow/“set raw” CLI integration with librte_flow_parser is wired correctly

Declaring the new extern cmd_set_raw, cmd_show_set_raw, and cmd_show_set_raw_all, adding them to builtin_ctx, and registering dynamic flow/set tokens via rte_flow_parser_cmdline_register(&cmd_flow, &cmd_set_raw); in init_cmdline() ties the shared parser library cleanly into the existing CLI. The registration happens before main_ctx is built and before any CLI interaction, which is the right place.

Just ensure that:

  • cmd_set_raw / cmd_show_set_raw* are always linked in when testpmd is built with flow parser support, and
  • rte_flow_parser_cmdline_register() is safe to call exactly once from this init path (and is a no‑op or clearly documented if the library is disabled at build time).

Functionally this layout looks sound.

Also applies to: 14359-14361, 14390-14392

app/test-pmd/testpmd.h (3)

19-19: LGTM!

The new include adds the flow parser library header, enabling access to the parser API and types.


837-837: LGTM!

The function prototype correctly declares testpmd_flow_parser_init which, per the external context, wraps rte_flow_parser_init(&parser_ops) in app/test-pmd/flow_parser.c.


98-99: No action needed. Both rte_port_id_t and rte_queue_id_t are properly defined in rte_ethdev.h (at lines 172 and 174 respectively), which is already included at line 17 of testpmd.h. The typedefs are correct and have all necessary dependencies.

lib/flow_parser/rte_flow_parser.h (8)

1-17: LGTM!

The header has proper SPDX license, include guards, necessary standard headers, and C++ extern "C" linkage for compatibility.


19-29: LGTM!

The shared limit constants define reasonable bounds for buffer sizes and array limits.


35-51: LGTM!

The VXLAN encap configuration structure includes all necessary fields with appropriate types and bit-fields for optional features.


116-157: LGTM!

The accessor functions provide consistent access to mutable encap/decap configurations and raw encap/decap data. The const return type for rte_flow_parser_raw_encap_conf_get and rte_flow_parser_raw_decap_conf_get correctly indicates that the returned action configs should not be modified.


161-167: LGTM!

The tunnel ops structure captures the necessary tunnel steering/match flags with appropriate bit-fields.


1026-1056: LGTM!

The query ops structure provides comprehensive hooks for the parser to validate IDs and fetch cached objects. The callbacks allow applications to customize ID resolution and object lookup.


1062-1173: LGTM!

The command ops structure provides comprehensive hooks for all flow CLI operations. The callbacks are appropriately optional as documented.


1180-1189: LGTM!

The rte_flow_parser_init function is well-documented, clearly stating the ops parameter may be NULL and returns 0 on success or negative errno on error.


/* Top-level command. */
RTE_FLOW_PARSER_CMD_SET,
/* Sub-leve commands. */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Typo: "Sub-leve" should be "Sub-level".

🔎 Proposed fix
-	/* Sub-leve commands. */
+	/* Sub-level commands. */
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/* Sub-leve commands. */
/* Sub-level commands. */
🤖 Prompt for AI Agents
In @lib/flow_parser/rte_flow_parser.h at line 208, Fix the spelling typo in the
comment that reads "Sub-leve commands." by updating it to "Sub-level commands."
so the descriptive comment for the sub-level command section is correct; locate
the comment string in lib/flow_parser/rte_flow_parser.h (the line containing
"Sub-leve commands.") and replace it accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant