[v5,1/7] net/mlx5: support for an action search in a list
diff mbox series

Message ID 722c53ed070c19d562e75eb76c6d1ab873597ea8.1567951422.git.motih@mellanox.com
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers show
Series
  • net/mlx5: support for flow action on VLAN header
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-dpdk_compile_ovs success Compile Testing PASS
ci/iol-dpdk_compile success Compile Testing PASS
ci/iol-dpdk_compile_spdk success Compile Testing PASS
ci/intel-Performance success Performance Testing PASS
ci/mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Moti Haimovsky Sept. 9, 2019, 3:56 p.m. UTC
This commit adds a helper routine that supports searching for a
specific action in a list of actions.

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c | 23 +++++++++++++++++++++++
 drivers/net/mlx5/mlx5_flow.h |  3 +++
 2 files changed, 26 insertions(+)

Comments

Slava Ovsiienko Sept. 10, 2019, 8:12 a.m. UTC | #1
> -----Original Message-----
> From: Moti Haimovsky <motih@mellanox.com>
> Sent: Monday, September 9, 2019 18:57
> To: Slava Ovsiienko <viacheslavo@mellanox.com>; Raslan Darawsheh
> <rasland@mellanox.com>
> Cc: dev@dpdk.org
> Subject: [PATCH v5 1/7] net/mlx5: support for an action search in a list
> 
> This commit adds a helper routine that supports searching for a specific
> action in a list of actions.
> 
> Signed-off-by: Moti Haimovsky <motih@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>

> ---
>  drivers/net/mlx5/mlx5_flow.c | 23 +++++++++++++++++++++++
> drivers/net/mlx5/mlx5_flow.h |  3 +++
>  2 files changed, 26 insertions(+)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index 78cc06f..eb36052 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -697,6 +697,29 @@ uint32_t mlx5_flow_adjust_priority(struct
> rte_eth_dev *dev, int32_t priority,  }
> 
>  /*
> + * return a pointer to the desired action in the list of actions.
> + *
> + * @param[in] actions
> + *   The list of actions to search the action in.
> + * @param[in] action
> + *   The action to find.
> + *
> + * @return
> + *   Pointer to the action in the list, if found. NULL otherwise.
> + */
> +const struct rte_flow_action *
> +mlx5_flow_find_action(const struct rte_flow_action *actions,
> +		      enum rte_flow_action_type action) {
> +	if (actions == NULL)
> +		return NULL;
> +	for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++)
> +		if (actions->type == action)
> +			return actions;
> +	return NULL;
> +}
> +
> +/*
>   * Validate the flag action.
>   *
>   * @param[in] action_flags
> diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
> index 822ff36..8d193b6 100644
> --- a/drivers/net/mlx5/mlx5_flow.h
> +++ b/drivers/net/mlx5/mlx5_flow.h
> @@ -442,6 +442,9 @@ uint64_t mlx5_flow_hashfields_adjust(struct
> mlx5_flow *dev_flow, int tunnel,
>  				     uint64_t hash_fields);
>  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
>  				   uint32_t subpriority);
> +const struct rte_flow_action *mlx5_flow_find_action
> +					(const struct rte_flow_action
> *actions,
> +					 enum rte_flow_action_type action);
>  int mlx5_flow_validate_action_count(struct rte_eth_dev *dev,
>  				    const struct rte_flow_attr *attr,
>  				    struct rte_flow_error *error);
> --
> 1.8.3.1

Patch
diff mbox series

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 78cc06f..eb36052 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -697,6 +697,29 @@  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 }
 
 /*
+ * return a pointer to the desired action in the list of actions.
+ *
+ * @param[in] actions
+ *   The list of actions to search the action in.
+ * @param[in] action
+ *   The action to find.
+ *
+ * @return
+ *   Pointer to the action in the list, if found. NULL otherwise.
+ */
+const struct rte_flow_action *
+mlx5_flow_find_action(const struct rte_flow_action *actions,
+		      enum rte_flow_action_type action)
+{
+	if (actions == NULL)
+		return NULL;
+	for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++)
+		if (actions->type == action)
+			return actions;
+	return NULL;
+}
+
+/*
  * Validate the flag action.
  *
  * @param[in] action_flags
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 822ff36..8d193b6 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -442,6 +442,9 @@  uint64_t mlx5_flow_hashfields_adjust(struct mlx5_flow *dev_flow, int tunnel,
 				     uint64_t hash_fields);
 uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 				   uint32_t subpriority);
+const struct rte_flow_action *mlx5_flow_find_action
+					(const struct rte_flow_action *actions,
+					 enum rte_flow_action_type action);
 int mlx5_flow_validate_action_count(struct rte_eth_dev *dev,
 				    const struct rte_flow_attr *attr,
 				    struct rte_flow_error *error);