DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maayan Kashani <mkashani@nvidia.com>
To: <dev@dpdk.org>
Cc: <mkashani@nvidia.com>, <dsosnowski@nvidia.com>,
	<rasland@nvidia.com>, Gregory Etelson <getelson@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Ori Kam <orika@nvidia.com>, Suanming Mou <suanmingm@nvidia.com>,
	Matan Azrad <matan@nvidia.com>
Subject: [PATCH v4 1/6] net/mlx5: update NTA rule pattern and actions flags
Date: Thu, 6 Jun 2024 13:12:09 +0300	[thread overview]
Message-ID: <20240606101214.172057-2-mkashani@nvidia.com> (raw)
In-Reply-To: <20240606101214.172057-1-mkashani@nvidia.com>

From: Gregory Etelson <getelson@nvidia.com>

Move pattern flags bitmap to flow_hw_list_create.
Create actions flags bitmap in flow_hw_list_create.

PMD uses pattern and actions bitmaps for direct queries instead of
iterating arrays.

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 147 +++++++++++++++++++++++++++-----
 1 file changed, 126 insertions(+), 21 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index d938b5976a..696f675f63 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -568,6 +568,111 @@ flow_hw_matching_item_flags_get(const struct rte_flow_item items[])
 	return item_flags;
 }
 
+static uint64_t
+flow_hw_action_flags_get(const struct rte_flow_action actions[],
+			 struct rte_flow_error *error)
+{
+	uint64_t action_flags = 0;
+	const struct rte_flow_action *action;
+
+	for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; action++) {
+		int type = (int)action->type;
+		switch (type) {
+		case RTE_FLOW_ACTION_TYPE_INDIRECT:
+			switch (MLX5_INDIRECT_ACTION_TYPE_GET(action->conf)) {
+			case MLX5_INDIRECT_ACTION_TYPE_RSS:
+				goto rss;
+			case MLX5_INDIRECT_ACTION_TYPE_AGE:
+				goto age;
+			case MLX5_INDIRECT_ACTION_TYPE_COUNT:
+				goto count;
+			case MLX5_INDIRECT_ACTION_TYPE_CT:
+				goto ct;
+			case MLX5_INDIRECT_ACTION_TYPE_METER_MARK:
+				goto meter;
+			default:
+				goto error;
+			}
+			break;
+		case RTE_FLOW_ACTION_TYPE_DROP:
+			action_flags |= MLX5_FLOW_ACTION_DROP;
+			break;
+		case RTE_FLOW_ACTION_TYPE_MARK:
+			action_flags |= MLX5_FLOW_ACTION_MARK;
+			break;
+		case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN:
+			action_flags |= MLX5_FLOW_ACTION_OF_PUSH_VLAN;
+			break;
+		case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN:
+			action_flags |= MLX5_FLOW_ACTION_OF_POP_VLAN;
+			break;
+		case RTE_FLOW_ACTION_TYPE_JUMP:
+			action_flags |= MLX5_FLOW_ACTION_JUMP;
+			break;
+		case RTE_FLOW_ACTION_TYPE_QUEUE:
+			action_flags |= MLX5_FLOW_ACTION_QUEUE;
+			break;
+		case RTE_FLOW_ACTION_TYPE_RSS:
+rss:
+			action_flags |= MLX5_FLOW_ACTION_RSS;
+			break;
+		case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
+		case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
+			action_flags |= MLX5_FLOW_ACTION_ENCAP;
+			break;
+		case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
+			action_flags |= MLX5_FLOW_ACTION_ENCAP;
+			break;
+		case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP:
+		case RTE_FLOW_ACTION_TYPE_NVGRE_DECAP:
+			action_flags |= MLX5_FLOW_ACTION_DECAP;
+			break;
+		case RTE_FLOW_ACTION_TYPE_RAW_DECAP:
+			action_flags |= MLX5_FLOW_ACTION_DECAP;
+			break;
+		case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL:
+			action_flags |= MLX5_FLOW_ACTION_SEND_TO_KERNEL;
+			break;
+		case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD:
+			action_flags |= MLX5_FLOW_ACTION_MODIFY_FIELD;
+			break;
+		case RTE_FLOW_ACTION_TYPE_PORT_ID:
+		case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
+			action_flags |= MLX5_FLOW_ACTION_PORT_ID;
+			break;
+		case RTE_FLOW_ACTION_TYPE_AGE:
+age:
+			action_flags |= MLX5_FLOW_ACTION_AGE;
+			break;
+		case RTE_FLOW_ACTION_TYPE_COUNT:
+count:
+			action_flags |= MLX5_FLOW_ACTION_COUNT;
+			break;
+		case RTE_FLOW_ACTION_TYPE_CONNTRACK:
+ct:
+			action_flags |= MLX5_FLOW_ACTION_CT;
+			break;
+		case RTE_FLOW_ACTION_TYPE_METER_MARK:
+meter:
+			action_flags |= MLX5_FLOW_ACTION_METER;
+			break;
+		case MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS:
+			action_flags |= MLX5_FLOW_ACTION_DEFAULT_MISS;
+			break;
+		case RTE_FLOW_ACTION_TYPE_VOID:
+		case RTE_FLOW_ACTION_TYPE_END:
+			break;
+		default:
+			goto error;
+		}
+	}
+	return action_flags;
+error:
+	rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
+			   action, "invalid flow action");
+	return 0;
+}
+
 /**
  * Register destination table DR jump action.
  *
@@ -12339,21 +12444,20 @@ flow_hw_encap_decap_resource_register
 
 static int
 flow_hw_translate_flow_actions(struct rte_eth_dev *dev,
-			       const struct rte_flow_attr *attr,
-			       const struct rte_flow_action actions[],
-			       struct rte_flow_hw *flow,
-			       struct mlx5_flow_hw_action_params *ap,
-			       struct mlx5_hw_actions *hw_acts,
-			       uint64_t item_flags,
-			       bool external,
-			       struct rte_flow_error *error)
+			  const struct rte_flow_attr *attr,
+			  const struct rte_flow_action actions[],
+			  struct rte_flow_hw *flow,
+			  struct mlx5_flow_hw_action_params *ap,
+			  struct mlx5_hw_actions *hw_acts,
+			  uint64_t item_flags, uint64_t action_flags,
+			  bool external,
+			  struct rte_flow_error *error)
 {
 	int ret = 0;
 	uint32_t src_group = 0;
 	enum mlx5dr_table_type table_type;
 	struct rte_flow_template_table *table = NULL;
 	struct mlx5_flow_group grp;
-	uint64_t action_flags = 0;
 	struct rte_flow_actions_template *at = NULL;
 	struct rte_flow_actions_template_attr template_attr = {
 		.egress = attr->egress,
@@ -12631,14 +12735,13 @@ static int flow_hw_apply(struct rte_eth_dev *dev __rte_unused,
  * @return
  *   0 on success, negative errno value otherwise and rte_errno set.
  */
-static int flow_hw_create_flow(struct rte_eth_dev *dev,
-			       enum mlx5_flow_type type,
-			       const struct rte_flow_attr *attr,
-			       const struct rte_flow_item items[],
-			       const struct rte_flow_action actions[],
-			       bool external,
-			       struct rte_flow_hw **flow,
-			       struct rte_flow_error *error)
+static int
+flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,
+		    const struct rte_flow_attr *attr,
+		    const struct rte_flow_item items[],
+		    const struct rte_flow_action actions[],
+		    uint64_t item_flags, uint64_t action_flags, bool external,
+		    struct rte_flow_hw **flow, struct rte_flow_error *error)
 {
 	int ret;
 	struct mlx5_hw_actions hw_act;
@@ -12668,8 +12771,6 @@ static int flow_hw_create_flow(struct rte_eth_dev *dev,
 		.tbl_type = 0,
 		};
 
-	uint64_t item_flags = 0;
-
 	memset(&hw_act, 0, sizeof(hw_act));
 	if (attr->transfer)
 		tbl_type = MLX5DR_TABLE_TYPE_FDB;
@@ -12710,7 +12811,7 @@ static int flow_hw_create_flow(struct rte_eth_dev *dev,
 
 	/* Note: the actions should be saved in the sub-flow rule itself for reference. */
 	ret = flow_hw_translate_flow_actions(dev, attr, actions, *flow, &ap, &hw_act,
-					item_flags, external, error);
+					item_flags, action_flags, external, error);
 	if (ret)
 		goto error;
 
@@ -12848,11 +12949,15 @@ static uintptr_t flow_hw_list_create(struct rte_eth_dev *dev,
 {
 	int ret;
 	struct rte_flow_hw *flow = NULL;
+	uint64_t item_flags = flow_hw_matching_item_flags_get(items);
+	uint64_t action_flags = flow_hw_action_flags_get(actions, error);
 
 	/*TODO: Handle split/expand to num_flows. */
 
 	/* Create single flow. */
-	ret = flow_hw_create_flow(dev, type, attr, items, actions, external, &flow, error);
+	ret = flow_hw_create_flow(dev, type, attr, items, actions,
+				  item_flags, action_flags,
+				  external, &flow, error);
 	if (ret)
 		goto free;
 	if (flow)
-- 
2.21.0


  reply	other threads:[~2024-06-06 10:12 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-02 10:28 [PATCH " Maayan Kashani
2024-06-03  8:10 ` [PATCH v2 16/34] " Maayan Kashani
2024-06-03  8:10   ` [PATCH v2 17/34] net/mlx5: support RSS expansion in non-template HWS setup Maayan Kashani
2024-06-03  8:10   ` [PATCH v2 18/34] net/mlx5: support indirect actions in non-template setup Maayan Kashani
2024-06-03  8:10   ` [PATCH v2 19/34] net/mlx5: update ASO resources " Maayan Kashani
2024-06-03  8:10   ` [PATCH v2 20/34] net/mlx5: update HWS ASO actions validation Maayan Kashani
2024-06-03  8:10   ` [PATCH v2 21/34] net/mlx5: support FDB in non-template mode Maayan Kashani
2024-06-03 10:52 ` [PATCH v3 1/6] net/mlx5: update NTA rule pattern and actions flags Maayan Kashani
2024-06-03 10:52   ` [PATCH v3 2/6] net/mlx5: support RSS expansion in non-template HWS setup Maayan Kashani
2024-06-03 10:52   ` [PATCH v3 3/6] net/mlx5: support indirect actions in non-template setup Maayan Kashani
2024-06-03 10:52   ` [PATCH v3 4/6] net/mlx5: update ASO resources " Maayan Kashani
2024-06-03 10:52   ` [PATCH v3 5/6] net/mlx5: update HWS ASO actions validation Maayan Kashani
2024-06-03 10:52   ` [PATCH v3 6/6] net/mlx5: support FDB in non-template mode Maayan Kashani
2024-06-06 10:12   ` [PATCH v4 0/6] non-template pmd advanced Maayan Kashani
2024-06-06 10:12     ` Maayan Kashani [this message]
2024-06-06 10:12     ` [PATCH v4 2/6] net/mlx5: support RSS expansion in non-template HWS setup Maayan Kashani
2024-06-06 10:12     ` [PATCH v4 3/6] net/mlx5: support indirect actions in non-template setup Maayan Kashani
2024-06-06 10:12     ` [PATCH v4 4/6] net/mlx5: update ASO resources " Maayan Kashani
2024-06-06 10:12     ` [PATCH v4 5/6] net/mlx5: update HWS ASO actions validation Maayan Kashani
2024-06-06 10:12     ` [PATCH v4 6/6] net/mlx5: support FDB in non-template mode Maayan Kashani
2024-06-10  8:50     ` [PATCH v5 1/6] net/mlx5: update NTA rule pattern and actions flags Maayan Kashani
2024-06-10  8:50       ` [PATCH v5 2/6] net/mlx5: support RSS expansion in non-template HWS setup Maayan Kashani
2024-06-10  8:50       ` [PATCH v5 3/6] net/mlx5: support indirect actions in non-template setup Maayan Kashani
2024-06-10  8:50       ` [PATCH v5 4/6] net/mlx5: update ASO resources " Maayan Kashani
2024-06-10  8:50       ` [PATCH v5 5/6] net/mlx5: update HWS ASO actions validation Maayan Kashani
2024-06-10  8:50       ` [PATCH v5 6/6] net/mlx5: support FDB in non-template mode Maayan Kashani
2024-06-11 11:20       ` [PATCH v5 1/6] net/mlx5: update NTA rule pattern and actions flags Raslan Darawsheh

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=20240606101214.172057-2-mkashani@nvidia.com \
    --to=mkashani@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=getelson@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@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).