From: Gregory Etelson <getelson@nvidia.com>
To: <dev@dpdk.org>
Cc: <getelson@nvidia.com>, <mkashani@nvidia.com>,
<rasland@nvidia.com>, <stable@dpdk.org>,
Suanming Mou <suanmingm@nvidia.com>,
Dariusz Sosnowski <dsosnowski@nvidia.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
"Ori Kam" <orika@nvidia.com>, Matan Azrad <matan@nvidia.com>
Subject: [PATCH] net/mlx5: fix action template expansion: support indirect actions list
Date: Thu, 29 Feb 2024 12:19:55 +0200 [thread overview]
Message-ID: <20240229101955.586947-1-getelson@nvidia.com> (raw)
MLX5 PMD actions template compilation may implicitly add MODIFY_HEADER
to actions list provided by application.
MLX5 actions in a template list must be arranged according to the HW
supported order.
The PMD must place new MODIFY_HEADER in the correct location relative
to existing actions.
The patch adds indirect actions list to calculation of the new
MODIFY_HEADER location.
Fixes: e26f50adbf38 ("net/mlx5: support indirect list meter mark action")
Cc: stable@dpdk.org
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Suanming Mou <suanmingm@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_hw.c | 80 +++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index f778fd0698..585f1ba925 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -88,6 +88,9 @@ mlx5_tbl_multi_pattern_process(struct rte_eth_dev *dev,
static void
mlx5_destroy_multi_pattern_segment(struct mlx5_multi_pattern_segment *segment);
+static __rte_always_inline enum mlx5_indirect_list_type
+flow_hw_inlist_type_get(const struct rte_flow_action *actions);
+
static __rte_always_inline int
mlx5_multi_pattern_reformat_to_index(enum mlx5dr_action_type type)
{
@@ -5803,6 +5806,69 @@ mlx5_decap_encap_reformat_type(const struct rte_flow_action *actions,
MLX5_FLOW_ACTION_ENCAP : MLX5_FLOW_ACTION_DECAP;
}
+enum mlx5_hw_indirect_list_relative_position {
+ MLX5_INDIRECT_LIST_POSITION_UNKNOWN = -1,
+ MLX5_INDIRECT_LIST_POSITION_BEFORE_MH = 0,
+ MLX5_INDIRECT_LIST_POSITION_AFTER_MH,
+};
+
+static enum mlx5_hw_indirect_list_relative_position
+mlx5_hw_indirect_list_mh_position(const struct rte_flow_action *action)
+{
+ const struct rte_flow_action_indirect_list *conf = action->conf;
+ enum mlx5_indirect_list_type list_type = mlx5_get_indirect_list_type(conf->handle);
+ enum mlx5_hw_indirect_list_relative_position pos = MLX5_INDIRECT_LIST_POSITION_UNKNOWN;
+ const union {
+ struct mlx5_indlst_legacy *legacy;
+ struct mlx5_hw_encap_decap_action *reformat;
+ struct rte_flow_action_list_handle *handle;
+ } h = { .handle = conf->handle};
+
+ switch (list_type) {
+ case MLX5_INDIRECT_ACTION_LIST_TYPE_LEGACY:
+ switch (h.legacy->legacy_type) {
+ case RTE_FLOW_ACTION_TYPE_AGE:
+ case RTE_FLOW_ACTION_TYPE_COUNT:
+ case RTE_FLOW_ACTION_TYPE_CONNTRACK:
+ case RTE_FLOW_ACTION_TYPE_METER_MARK:
+ case RTE_FLOW_ACTION_TYPE_QUOTA:
+ pos = MLX5_INDIRECT_LIST_POSITION_BEFORE_MH;
+ break;
+ case RTE_FLOW_ACTION_TYPE_RSS:
+ pos = MLX5_INDIRECT_LIST_POSITION_AFTER_MH;
+ break;
+ default:
+ pos = MLX5_INDIRECT_LIST_POSITION_UNKNOWN;
+ break;
+ }
+ break;
+ case MLX5_INDIRECT_ACTION_LIST_TYPE_MIRROR:
+ pos = MLX5_INDIRECT_LIST_POSITION_AFTER_MH;
+ break;
+ case MLX5_INDIRECT_ACTION_LIST_TYPE_REFORMAT:
+ switch (h.reformat->action_type) {
+ case MLX5DR_ACTION_TYP_REFORMAT_TNL_L2_TO_L2:
+ case MLX5DR_ACTION_TYP_REFORMAT_TNL_L3_TO_L2:
+ pos = MLX5_INDIRECT_LIST_POSITION_BEFORE_MH;
+ break;
+ case MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L2:
+ case MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L3:
+ pos = MLX5_INDIRECT_LIST_POSITION_AFTER_MH;
+ break;
+ default:
+ pos = MLX5_INDIRECT_LIST_POSITION_UNKNOWN;
+ break;
+ }
+ break;
+ default:
+ pos = MLX5_INDIRECT_LIST_POSITION_UNKNOWN;
+ break;
+ }
+ return pos;
+}
+
+#define MLX5_HW_EXPAND_MH_FAILED 0xffff
+
static inline uint16_t
flow_hw_template_expand_modify_field(struct rte_flow_action actions[],
struct rte_flow_action masks[],
@@ -5839,6 +5905,7 @@ flow_hw_template_expand_modify_field(struct rte_flow_action actions[],
* @see action_order_arr[]
*/
for (i = act_num - 2; (int)i >= 0; i--) {
+ enum mlx5_hw_indirect_list_relative_position pos;
enum rte_flow_action_type type = actions[i].type;
uint64_t reformat_type;
@@ -5869,6 +5936,13 @@ flow_hw_template_expand_modify_field(struct rte_flow_action actions[],
if (actions[i - 1].type == RTE_FLOW_ACTION_TYPE_RAW_DECAP)
i--;
break;
+ case RTE_FLOW_ACTION_TYPE_INDIRECT_LIST:
+ pos = mlx5_hw_indirect_list_mh_position(&actions[i]);
+ if (pos == MLX5_INDIRECT_LIST_POSITION_UNKNOWN)
+ return MLX5_HW_EXPAND_MH_FAILED;
+ if (pos == MLX5_INDIRECT_LIST_POSITION_BEFORE_MH)
+ goto insert;
+ break;
default:
i++; /* new MF inserted AFTER actions[i] */
goto insert;
@@ -6822,6 +6896,12 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev,
action_flags,
act_num,
expand_mf_num);
+ if (pos == MLX5_HW_EXPAND_MH_FAILED) {
+ rte_flow_error_set(error, ENOMEM,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "modify header expansion failed");
+ return NULL;
+ }
act_num += expand_mf_num;
for (i = pos + expand_mf_num; i < act_num; i++)
src_off[i] += expand_mf_num;
--
2.39.2
next reply other threads:[~2024-02-29 10:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-29 10:19 Gregory Etelson [this message]
2024-02-29 13:37 ` 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=20240229101955.586947-1-getelson@nvidia.com \
--to=getelson@nvidia.com \
--cc=dev@dpdk.org \
--cc=dsosnowski@nvidia.com \
--cc=matan@nvidia.com \
--cc=mkashani@nvidia.com \
--cc=orika@nvidia.com \
--cc=rasland@nvidia.com \
--cc=stable@dpdk.org \
--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).