DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dariusz Sosnowski <dsosnowski@nvidia.com>
To: Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Ori Kam <orika@nvidia.com>,  Suanming Mou <suanmingm@nvidia.com>,
	Matan Azrad <matan@nvidia.com>
Cc: <dev@dpdk.org>
Subject: [PATCH 4/9] net/mlx5: store pattern template items
Date: Wed, 5 Jun 2024 20:34:14 +0200	[thread overview]
Message-ID: <20240605183419.489323-5-dsosnowski@nvidia.com> (raw)
In-Reply-To: <20240605183419.489323-1-dsosnowski@nvidia.com>

Store items which define the pattern template on creation.
This allows validation of items, provided by the user during flow rule
creation, against pattern template.

Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow.h    |  2 ++
 drivers/net/mlx5/mlx5_flow_hw.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 7be95a7d18..5997ffb5e0 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -1489,6 +1489,8 @@ struct rte_flow_pattern_template {
 	/* Manages all GENEVE TLV options used by this pattern template. */
 	struct mlx5_geneve_tlv_options_mng geneve_opt_mng;
 	uint8_t flex_item; /* flex item index. */
+	/* Items on which this pattern template is based on. */
+	struct rte_flow_item *items;
 };
 
 /* Flow action template struct. */
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 24b86535b1..132f6ca264 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -8401,6 +8401,7 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 		.mask = &tag_m,
 		.last = NULL
 	};
+	int it_items_size;
 	unsigned int i = 0;
 	int rc;
 
@@ -8444,6 +8445,31 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 	it->attr = *attr;
 	it->item_flags = item_flags;
 	it->orig_item_nb = orig_item_nb;
+	it_items_size = rte_flow_conv(RTE_FLOW_CONV_OP_PATTERN, NULL, 0, tmpl_items, error);
+	if (it_items_size <= 0) {
+		rte_flow_error_set(error, ENOMEM,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				   NULL,
+				   "Failed to determine buffer size for pattern");
+		goto error;
+	}
+	it_items_size = RTE_ALIGN(it_items_size, 16);
+	it->items = mlx5_malloc(MLX5_MEM_ZERO, it_items_size, 0, rte_dev_numa_node(dev->device));
+	if (it->items == NULL) {
+		rte_flow_error_set(error, ENOMEM,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				   NULL,
+				   "Cannot allocate memory for pattern");
+		goto error;
+	}
+	rc = rte_flow_conv(RTE_FLOW_CONV_OP_PATTERN, it->items, it_items_size, tmpl_items, error);
+	if (rc <= 0) {
+		rte_flow_error_set(error, ENOMEM,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				   NULL,
+				   "Failed to store pattern");
+		goto error;
+	}
 	it->mt = mlx5dr_match_template_create(tmpl_items, attr->relaxed_matching);
 	if (!it->mt) {
 		rte_flow_error_set(error, rte_errno,
@@ -8458,6 +8484,7 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 		else if (attr->egress)
 			it->implicit_tag = true;
 		mlx5_free(copied_items);
+		copied_items = NULL;
 	}
 	/* Either inner or outer, can't both. */
 	if (it->item_flags & (MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT |
@@ -8518,6 +8545,7 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 			mlx5_geneve_tlv_options_unregister(priv, &it->geneve_opt_mng);
 		if (it->mt)
 			claim_zero(mlx5dr_match_template_destroy(it->mt));
+		mlx5_free(it->items);
 		mlx5_free(it);
 	}
 	if (copied_items)
@@ -8560,6 +8588,7 @@ flow_hw_pattern_template_destroy(struct rte_eth_dev *dev,
 	flow_hw_flex_item_release(dev, &template->flex_item);
 	mlx5_geneve_tlv_options_unregister(priv, &template->geneve_opt_mng);
 	claim_zero(mlx5dr_match_template_destroy(template->mt));
+	mlx5_free(template->items);
 	mlx5_free(template);
 	return 0;
 }
-- 
2.39.2


  parent reply	other threads:[~2024-06-05 18:35 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05 18:34 [PATCH 0/9] net/mlx5: flow fast path validation Dariusz Sosnowski
2024-06-05 18:34 ` [PATCH 1/9] ethdev: support duplicating only item mask Dariusz Sosnowski
2024-06-05 18:34 ` [PATCH 2/9] net/mlx5: extract target port validation Dariusz Sosnowski
2024-06-05 18:34 ` [PATCH 3/9] net/mlx5: extract queue index validation Dariusz Sosnowski
2024-06-05 18:34 ` Dariusz Sosnowski [this message]
2024-06-05 18:34 ` [PATCH 5/9] net/mlx5: store original actions in template Dariusz Sosnowski
2024-06-05 18:34 ` [PATCH 6/9] net/mlx5: store expected type on indirect action Dariusz Sosnowski
2024-06-05 18:34 ` [PATCH 7/9] net/mlx5: store modify field action Dariusz Sosnowski
2024-06-05 18:34 ` [PATCH 8/9] common/mlx5: add debug mode indicator Dariusz Sosnowski
2024-06-05 18:34 ` [PATCH 9/9] net/mlx5: add async flow operation validation Dariusz Sosnowski
2024-06-06  8:50 ` [PATCH 0/9] net/mlx5: flow fast path validation Dariusz Sosnowski
2024-06-12 16:18 ` [PATCH v2] ethdev: support duplicating only item mask Dariusz Sosnowski
2024-06-12 22:28   ` Ferruh Yigit
2024-06-12 16:24 ` [PATCH v2 0/8] net/mlx5: flow fast path validation Dariusz Sosnowski
2024-06-12 16:24   ` [PATCH v2 1/8] net/mlx5: extract target port validation Dariusz Sosnowski
2024-06-12 16:24   ` [PATCH v2 2/8] net/mlx5: extract queue index validation Dariusz Sosnowski
2024-06-12 16:24   ` [PATCH v2 3/8] net/mlx5: store pattern template items Dariusz Sosnowski
2024-06-12 16:24   ` [PATCH v2 4/8] net/mlx5: store original actions in template Dariusz Sosnowski
2024-06-12 16:24   ` [PATCH v2 5/8] net/mlx5: store expected type on indirect action Dariusz Sosnowski
2024-06-12 16:24   ` [PATCH v2 6/8] net/mlx5: store modify field action Dariusz Sosnowski
2024-06-12 16:24   ` [PATCH v2 7/8] common/mlx5: add debug mode indicator Dariusz Sosnowski
2024-06-12 16:24   ` [PATCH v2 8/8] net/mlx5: add async flow operation validation Dariusz Sosnowski
2024-06-26 18:14   ` [PATCH v3 0/8] net/mlx5: flow fast path validation Dariusz Sosnowski
2024-06-26 18:14     ` [PATCH v3 1/8] net/mlx5: extract target port validation Dariusz Sosnowski
2024-06-26 18:14     ` [PATCH v3 2/8] net/mlx5: extract queue index validation Dariusz Sosnowski
2024-06-26 18:14     ` [PATCH v3 3/8] net/mlx5: store pattern template items Dariusz Sosnowski
2024-06-26 18:14     ` [PATCH v3 4/8] net/mlx5: store original actions in template Dariusz Sosnowski
2024-06-26 18:14     ` [PATCH v3 5/8] net/mlx5: store expected type on indirect action Dariusz Sosnowski
2024-06-26 18:14     ` [PATCH v3 6/8] net/mlx5: store modify field action Dariusz Sosnowski
2024-06-26 18:14     ` [PATCH v3 7/8] common/mlx5: add debug mode indicator Dariusz Sosnowski
2024-06-26 18:14     ` [PATCH v3 8/8] net/mlx5: add async flow operation validation Dariusz Sosnowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240605183419.489323-5-dsosnowski@nvidia.com \
    --to=dsosnowski@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=suanmingm@nvidia.com \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).