rte_flow API unit testing via null PMD
Subsystems (2)
cover rte_flow API unit testing via null PMD
The rte_flow API is an important DPDK interface but has no dedicated unit tests. This series adds stub flow ops to the null PMD and a test suite that exercises the public API without requiring hardware.
Patch 1 adds flow_ops to net_null that validate input structure and reject all rules with specific error types and cause pointers.
Patch 2 adds flow_api_autotest with 31 test cases covering basic operations and error handling.
Limitations:
- Only negative-path behaviour is tested since the null PMD rejects all rules. Positive-path coverage requires a PMD that installs flows.
- The async template API, meters, and indirect actions can be covered with additional stubs in a follow-up series.
- Aged flow testing requires a PMD that creates real rules and is outside the scope of the null PMD stub approach.
The test code and null PMD stub were generated with AI assistance (Claude) and reviewed/edited by the author.
Stephen Hemminger (2):
net/null: add stub flow ops for rte_flow API testing app/test: add rte_flow API unit tests
app/test/meson.build | 1 + app/test/test_flow_api.c | 1015 +++++++++++++++++++++++++++++++ drivers/net/null/meson.build | 6 +- drivers/net/null/null_flow.c | 237 ++++++++ drivers/net/null/null_flow.h | 12 + drivers/net/null/rte_eth_null.c | 12 + 6 files changed, 1282 insertions(+), 1 deletion(-) create mode 100644 app/test/test_flow_api.c create mode 100644 drivers/net/null/null_flow.c create mode 100644 drivers/net/null/null_flow.h
Signature · 1 line
2.51.0
RFC 1/2 net/null: add stub flow ops for rte_flow API testing
Add flow_ops to the null PMD that validate input structure and reject all rules with properly typed rte_flow_error responses. Pattern items and actions are walked individually, with cause pointers set to the offending element. flush() succeeds as a no-op; all other operations return appropriate error codes.
This enables testing the full rte_flow code path without hardware.
--- drivers/net/null/meson.build | 6 +- drivers/net/null/null_flow.c | 237 ++++++++++++++++++++++++++++++++ drivers/net/null/null_flow.h | 12 ++ drivers/net/null/rte_eth_null.c | 12 ++ 4 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 drivers/net/null/null_flow.c create mode 100644 drivers/net/null/null_flow.h
drivers/net/null/meson.build +5 -1
@@ -1,5 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -sources = files('rte_eth_null.c') +sources = files( + 'rte_eth_null.c', + 'null_flow.c', +) + require_iova_in_mbuf = false
drivers/net/null/null_flow.c new file +237 -0
237 lines not on this page · raw message
drivers/net/null/null_flow.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2026 Stephen Hemminger +*/ + +#ifndef NULL_FLOW_H +#define NULL_FLOW_H + +#include <rte_flow_driver.h> + +extern const struct rte_flow_ops null_flow_ops; + +#endif /* NULL_FLOW_H */
drivers/net/null/rte_eth_null.c +12 -0
@@ -8,12 +8,15 @@#include <rte_mbuf.h> #include <ethdev_driver.h> #include <ethdev_vdev.h> +#include <rte_flow.h> #include <rte_malloc.h> #include <rte_memcpy.h> #include <bus_vdev_driver.h> #include <rte_kvargs.h> #include <rte_spinlock.h> +#include "null_flow.h" +#define ETH_NULL_PACKET_SIZE_ARG "size"#define ETH_NULL_PACKET_COPY_ARG "copy"#define ETH_NULL_PACKET_NO_RX_ARG "no-rx"
@@ -511,12 +514,21 @@ eth_dev_close(struct rte_eth_dev *dev)return 0 ; } +static int +null_dev_flow_ops_get(struct rte_eth_dev *dev __rte_unused, +const struct rte_flow_ops **ops) +{ + *ops = &null_flow_ops; +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_close = eth_dev_close, .dev_start = eth_dev_start, .dev_stop = eth_dev_stop, .dev_configure = eth_dev_configure, .dev_infos_get = eth_dev_info, + .flow_ops_get = null_dev_flow_ops_get, .rx_queue_setup = eth_rx_queue_setup, .tx_queue_setup = eth_tx_queue_setup, .rx_queue_release = eth_rx_queue_release,
Signature · 1 line
2.51.0
RFC 2/2 app/test: add rte_flow API unit tests
In reply to Stephen HemmingerAdd flow_api_autotest to exercise the rte_flow API through the null PMD stub flow ops. Covers basic operations and error handling, verifying that error types, cause pointers, and messages are correctly propagated.
--- app/test/meson.build | 1 + app/test/test_flow_api.c | 1015 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 1016 insertions(+) create mode 100644 app/test/test_flow_api.c
app/test/meson.build +1 -0
@@ -87,6 +87,7 @@ source_file_deps = { 'test_fib6.c': ['rib', 'fib'], 'test_fib6_perf.c': ['fib'], 'test_fib_perf.c': ['net', 'fib'], + 'test_flow_api.c': ['net_null', 'ethdev', 'bus_vdev'], 'test_flow_classify.c': ['net', 'acl', 'table', 'ethdev', 'flow_classify'], 'test_func_reentrancy.c': ['hash', 'lpm'], 'test_graph.c': ['graph'],
app/test/test_flow_api.c new file +1015 -0
1,015 lines not on this page · raw message
Signature · 1 line
2.51.0