From: Suanming Mou <suanmingm@nvidia.com>
To: Dariusz Sosnowski <dsosnowski@nvidia.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
Ori Kam <orika@nvidia.com>, Matan Azrad <matan@nvidia.com>
Cc: <dev@dpdk.org>, <rasland@nvidia.com>
Subject: [PATCH 3/4] net/mlx5: add modify field action ADD fields support
Date: Thu, 14 Dec 2023 11:04:26 +0800 [thread overview]
Message-ID: <20231214030428.363471-4-suanmingm@nvidia.com> (raw)
In-Reply-To: <20231214030428.363471-1-suanmingm@nvidia.com>
ADD_FIELD operation allows user to add the src field value to the
dest field. Dest field has the sum of src field value and original
dst field value.
Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_dv.c | 11 +++++++----
drivers/net/mlx5/mlx5_flow_hw.c | 10 +++++++---
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 272dbca00f..1c3d557d4a 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -389,6 +389,7 @@ flow_dv_convert_modify_action(struct rte_flow_item *item,
uint32_t i = resource->actions_num;
struct mlx5_modification_cmd *actions = resource->actions;
uint32_t carry_b = 0;
+ bool to_dest;
/*
* The item and mask are provided in big-endian format.
@@ -397,6 +398,8 @@ flow_dv_convert_modify_action(struct rte_flow_item *item,
*/
MLX5_ASSERT(item->mask);
MLX5_ASSERT(field->size);
+ to_dest = type == MLX5_MODIFICATION_TYPE_COPY ||
+ type == MLX5_MODIFICATION_TYPE_ADD_FIELD;
do {
uint32_t size_b;
uint32_t off_b;
@@ -416,7 +419,7 @@ flow_dv_convert_modify_action(struct rte_flow_item *item,
++field;
continue;
}
- if (type == MLX5_MODIFICATION_TYPE_COPY && field->is_flex) {
+ if (to_dest && field->is_flex) {
off_b = 32 - field->shift + carry_b - field->size * CHAR_BIT;
size_b = field->size * CHAR_BIT - carry_b;
} else {
@@ -433,7 +436,7 @@ flow_dv_convert_modify_action(struct rte_flow_item *item,
.length = (size_b == sizeof(uint32_t) * CHAR_BIT) ?
0 : size_b,
};
- if (type == MLX5_MODIFICATION_TYPE_COPY) {
+ if (to_dest) {
MLX5_ASSERT(dest);
actions[i].dst_field = dest->id;
actions[i].dst_offset =
@@ -476,11 +479,11 @@ flow_dv_convert_modify_action(struct rte_flow_item *item,
}
/* Convert entire record to expected big-endian format. */
actions[i].data0 = rte_cpu_to_be_32(actions[i].data0);
- if ((type != MLX5_MODIFICATION_TYPE_COPY ||
+ if ((!to_dest ||
dest->id != (enum mlx5_modification_field)UINT32_MAX) &&
field->id != (enum mlx5_modification_field)UINT32_MAX)
++i;
- if (next_dest && type == MLX5_MODIFICATION_TYPE_COPY)
+ if (next_dest && to_dest)
++dest;
if (next_field)
++field;
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index da873ae2e2..d224979ee8 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -1102,7 +1102,8 @@ flow_hw_should_insert_nop(const struct mlx5_hw_modify_header_action *mhdr,
if (last_type == MLX5_MODIFICATION_TYPE_SET ||
last_type == MLX5_MODIFICATION_TYPE_ADD)
should_insert = new_cmd.field == last_cmd.field;
- else if (last_type == MLX5_MODIFICATION_TYPE_COPY)
+ else if (last_type == MLX5_MODIFICATION_TYPE_COPY ||
+ last_type == MLX5_MODIFICATION_TYPE_ADD_FIELD)
should_insert = new_cmd.field == last_cmd.dst_field;
else if (last_type == MLX5_MODIFICATION_TYPE_NOP)
should_insert = false;
@@ -1110,11 +1111,13 @@ flow_hw_should_insert_nop(const struct mlx5_hw_modify_header_action *mhdr,
MLX5_ASSERT(false); /* Other types are not supported. */
break;
case MLX5_MODIFICATION_TYPE_COPY:
+ case MLX5_MODIFICATION_TYPE_ADD_FIELD:
if (last_type == MLX5_MODIFICATION_TYPE_SET ||
last_type == MLX5_MODIFICATION_TYPE_ADD)
should_insert = (new_cmd.field == last_cmd.field ||
new_cmd.dst_field == last_cmd.field);
- else if (last_type == MLX5_MODIFICATION_TYPE_COPY)
+ else if (last_type == MLX5_MODIFICATION_TYPE_COPY ||
+ last_type == MLX5_MODIFICATION_TYPE_ADD_FIELD)
should_insert = (new_cmd.field == last_cmd.dst_field ||
new_cmd.dst_field == last_cmd.dst_field);
else if (last_type == MLX5_MODIFICATION_TYPE_NOP)
@@ -1264,7 +1267,8 @@ flow_hw_modify_field_compile(struct rte_eth_dev *dev,
item.spec = &value;
}
} else {
- type = MLX5_MODIFICATION_TYPE_COPY;
+ type = conf->operation == RTE_FLOW_MODIFY_SET ?
+ MLX5_MODIFICATION_TYPE_COPY : MLX5_MODIFICATION_TYPE_ADD_FIELD;
/* For COPY fill the destination field (dcopy) without mask. */
mlx5_flow_field_id_to_modify_info(&conf->dst, dcopy, NULL,
conf->width, dev,
--
2.34.1
next prev parent reply other threads:[~2023-12-14 3:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-14 3:04 [PATCH 0/4] net/mlx5: add modify field " Suanming Mou
2023-12-14 3:04 ` [PATCH 1/4] net/mlx5: add TCP/IP length modify field Suanming Mou
2023-12-14 11:35 ` Ori Kam
2023-12-14 11:36 ` Ori Kam
2023-12-14 3:04 ` [PATCH 2/4] net/mlx5: rename modify copy destination to destination Suanming Mou
2023-12-14 11:37 ` Ori Kam
2023-12-14 3:04 ` Suanming Mou [this message]
2023-12-14 11:38 ` [PATCH 3/4] net/mlx5: add modify field action ADD fields support Ori Kam
2023-12-14 3:04 ` [PATCH 4/4] net/mlx5: add modify field action ADD fields validation Suanming Mou
2023-12-14 11:39 ` Ori Kam
2024-01-07 12:37 ` [PATCH 0/4] net/mlx5: add modify field ADD fields support 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=20231214030428.363471-4-suanmingm@nvidia.com \
--to=suanmingm@nvidia.com \
--cc=dev@dpdk.org \
--cc=dsosnowski@nvidia.com \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=rasland@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).