[PATCH v2 2/4] net/i40e: implement flow dump
Anatoly Burakov
anatoly.burakov at intel.com
Thu Apr 30 13:00:45 CEST 2026
Implement flow dumping API.
Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
drivers/net/intel/i40e/i40e_flow.c | 103 +++++++++++++++++++++++++++++
1 file changed, 103 insertions(+)
diff --git a/drivers/net/intel/i40e/i40e_flow.c b/drivers/net/intel/i40e/i40e_flow.c
index 967af052ff..cb246da780 100644
--- a/drivers/net/intel/i40e/i40e_flow.c
+++ b/drivers/net/intel/i40e/i40e_flow.c
@@ -17,6 +17,7 @@
#include <rte_log.h>
#include <rte_malloc.h>
#include <rte_tailq.h>
+#include <rte_hexdump.h>
#include <rte_flow_driver.h>
#include <rte_bitmap.h>
@@ -50,6 +51,10 @@ static int i40e_flow_query(struct rte_eth_dev *dev,
struct rte_flow *flow,
const struct rte_flow_action *actions,
void *data, struct rte_flow_error *error);
+static int i40e_flow_dev_dump(struct rte_eth_dev *dev,
+ struct rte_flow *flow,
+ FILE *file,
+ struct rte_flow_error *error);
static int
i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev,
const struct rte_flow_item *pattern,
@@ -141,6 +146,7 @@ const struct rte_flow_ops i40e_flow_ops = {
.destroy = i40e_flow_destroy,
.flush = i40e_flow_flush,
.query = i40e_flow_query,
+ .dev_dump = i40e_flow_dev_dump,
};
/* Pattern matched ethertype filter */
@@ -1256,6 +1262,103 @@ i40e_flow_parse_attr(const struct rte_flow_attr *attr,
return 0;
}
+#define I40E_FLOW_DUMP_CHUNK_BYTES 32
+
+static const char *
+i40e_flow_rule_name(enum rte_filter_type filter_type)
+{
+ switch (filter_type) {
+ case RTE_ETH_FILTER_ETHERTYPE:
+ return "ethertype";
+ case RTE_ETH_FILTER_FDIR:
+ return "fdir";
+ case RTE_ETH_FILTER_TUNNEL:
+ return "tunnel";
+ case RTE_ETH_FILTER_HASH:
+ return "hash";
+ default:
+ return "unknown";
+ }
+}
+
+static size_t
+i40e_flow_rule_size(enum rte_filter_type filter_type)
+{
+ switch (filter_type) {
+ case RTE_ETH_FILTER_ETHERTYPE:
+ return sizeof(struct i40e_ethertype_filter);
+ case RTE_ETH_FILTER_FDIR:
+ return sizeof(struct i40e_fdir_filter);
+ case RTE_ETH_FILTER_TUNNEL:
+ return sizeof(struct i40e_tunnel_filter);
+ case RTE_ETH_FILTER_HASH:
+ return sizeof(struct i40e_rss_filter);
+ default:
+ return 0;
+ }
+}
+
+static void
+i40e_flow_dump_blob(FILE *file, const char *engine,
+ const void *data, size_t data_len)
+{
+ const uint8_t *raw = (const uint8_t *)data;
+ const size_t nchunks =
+ (data_len + I40E_FLOW_DUMP_CHUNK_BYTES - 1) /
+ I40E_FLOW_DUMP_CHUNK_BYTES;
+ char title[64];
+ size_t ci;
+
+ fprintf(file, "FLOW DUMP: driver=i40e engine=%s\n", engine);
+ fprintf(file, "FLOW DUMP: DATA size=%zu chunks=%zu chunk_bytes=%d\n",
+ data_len, nchunks, I40E_FLOW_DUMP_CHUNK_BYTES);
+
+ for (ci = 0; ci < nchunks; ci++) {
+ const size_t off = ci * I40E_FLOW_DUMP_CHUNK_BYTES;
+ const size_t clen =
+ RTE_MIN((size_t)I40E_FLOW_DUMP_CHUNK_BYTES, data_len - off);
+
+ snprintf(title, sizeof(title), "FLOW DUMP: chunk %03zu/%03zu",
+ ci + 1, nchunks);
+ rte_memdump(file, title, raw + off, clen);
+ }
+}
+
+static int
+i40e_flow_dev_dump(struct rte_eth_dev *dev,
+ struct rte_flow *flow,
+ FILE *file,
+ struct rte_flow_error *error)
+{
+ struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+ struct rte_flow *p_flow;
+ bool found = false;
+
+ TAILQ_FOREACH(p_flow, &pf->flow_list, node) {
+ size_t rule_size = 0;
+ const void *rule_data = NULL;
+
+ if (flow != NULL && p_flow != flow)
+ continue;
+
+ found = true;
+ if (p_flow->rule != NULL) {
+ rule_size = i40e_flow_rule_size(p_flow->filter_type);
+ rule_data = p_flow->rule;
+ }
+ i40e_flow_dump_blob(file,
+ i40e_flow_rule_name(p_flow->filter_type),
+ rule_data, rule_size);
+ }
+
+ if (flow != NULL && !found)
+ return rte_flow_error_set(error, ENOENT,
+ RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+ "Flow not found");
+
+ return 0;
+}
+
static int
i40e_get_outer_vlan(struct rte_eth_dev *dev, uint16_t *tpid)
{
--
2.47.3
More information about the dev
mailing list