* [PATCH 1/4] net/mlx5: add TCP/IP length modify field
2023-12-14 3:04 [PATCH 0/4] net/mlx5: add modify field ADD fields support Suanming Mou
@ 2023-12-14 3:04 ` 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
` (3 subsequent siblings)
4 siblings, 2 replies; 11+ messages in thread
From: Suanming Mou @ 2023-12-14 3:04 UTC (permalink / raw)
To: Dariusz Sosnowski, Viacheslav Ovsiienko, Ori Kam, Matan Azrad
Cc: dev, rasland
This commit adds TCP data offset, IPv4 total length, IPv4 IHL,
IPv6 payload length in modify field operation.
Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
---
drivers/common/mlx5/mlx5_prm.h | 4 ++++
drivers/net/mlx5/mlx5_flow_dv.c | 40 +++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index 9e22dce6da..0d46ba9c40 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -848,6 +848,10 @@ enum mlx5_modification_field {
MLX5_MODI_META_REG_C_13 = 0x94,
MLX5_MODI_META_REG_C_14 = 0x95,
MLX5_MODI_META_REG_C_15 = 0x96,
+ MLX5_MODI_OUT_IPV4_TOTAL_LEN = 0x11D,
+ MLX5_MODI_OUT_IPV6_PAYLOAD_LEN = 0x11E,
+ MLX5_MODI_OUT_IPV4_IHL = 0x11F,
+ MLX5_MODI_OUT_TCP_DATA_OFFSET = 0x120,
MLX5_MODI_INVALID = INT_MAX,
};
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 115d730317..4e2095dcfe 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -1664,6 +1664,16 @@ mlx5_flow_field_id_to_modify_info
else
info[idx].offset = off_be;
break;
+ case RTE_FLOW_FIELD_IPV4_IHL:
+ MLX5_ASSERT(data->offset + width <= 4);
+ off_be = 4 - (data->offset + width);
+ info[idx] = (struct field_modify_info){1, 0,
+ MLX5_MODI_OUT_IPV4_IHL};
+ if (mask)
+ mask[idx] = flow_modify_info_mask_8(width, off_be);
+ else
+ info[idx].offset = off_be;
+ break;
case RTE_FLOW_FIELD_IPV4_DSCP:
MLX5_ASSERT(data->offset + width <= 6);
off_be = 6 - (data->offset + width);
@@ -1674,6 +1684,16 @@ mlx5_flow_field_id_to_modify_info
else
info[idx].offset = off_be;
break;
+ case RTE_FLOW_FIELD_IPV4_TOTAL_LEN:
+ MLX5_ASSERT(data->offset + width <= 16);
+ off_be = 16 - (data->offset + width);
+ info[idx] = (struct field_modify_info){2, 0,
+ MLX5_MODI_OUT_IPV4_TOTAL_LEN};
+ if (mask)
+ mask[idx] = flow_modify_info_mask_16(width, off_be);
+ else
+ info[idx].offset = off_be;
+ break;
case RTE_FLOW_FIELD_IPV4_TTL:
MLX5_ASSERT(data->offset + width <= 8);
off_be = 8 - (data->offset + width);
@@ -1714,6 +1734,16 @@ mlx5_flow_field_id_to_modify_info
else
info[idx].offset = off_be;
break;
+ case RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN:
+ MLX5_ASSERT(data->offset + width <= 16);
+ off_be = 16 - (data->offset + width);
+ info[idx] = (struct field_modify_info){2, 0,
+ MLX5_MODI_OUT_IPV6_PAYLOAD_LEN};
+ if (mask)
+ mask[idx] = flow_modify_info_mask_16(width, off_be);
+ else
+ info[idx].offset = off_be;
+ break;
case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
MLX5_ASSERT(data->offset + width <= 8);
off_be = 8 - (data->offset + width);
@@ -1860,6 +1890,16 @@ mlx5_flow_field_id_to_modify_info
else
info[idx].offset = off_be;
break;
+ case RTE_FLOW_FIELD_TCP_DATA_OFFSET:
+ MLX5_ASSERT(data->offset + width <= 4);
+ off_be = 4 - (data->offset + width);
+ info[idx] = (struct field_modify_info){1, 0,
+ MLX5_MODI_OUT_TCP_DATA_OFFSET};
+ if (mask)
+ mask[idx] = flow_modify_info_mask_8(width, off_be);
+ else
+ info[idx].offset = off_be;
+ break;
case RTE_FLOW_FIELD_UDP_PORT_SRC:
MLX5_ASSERT(data->offset + width <= 16);
off_be = 16 - (data->offset + width);
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH 1/4] net/mlx5: add TCP/IP length modify field
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
1 sibling, 0 replies; 11+ messages in thread
From: Ori Kam @ 2023-12-14 11:35 UTC (permalink / raw)
To: Suanming Mou, Dariusz Sosnowski, Slava Ovsiienko, Matan Azrad
Cc: dev, Raslan Darawsheh
Hi Suanming
> -----Original Message-----
> From: Suanming Mou <suanmingm@nvidia.com>
> Sent: Thursday, December 14, 2023 5:04 AM
IHL,
> IPv6 payload length in modify field operation.
>
> Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
> ---
Acked-by: Ori Kam <orika@nvidia.com>
Best,
Ori
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH 1/4] net/mlx5: add TCP/IP length modify field
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
1 sibling, 0 replies; 11+ messages in thread
From: Ori Kam @ 2023-12-14 11:36 UTC (permalink / raw)
To: Suanming Mou, Dariusz Sosnowski, Slava Ovsiienko, Matan Azrad
Cc: dev, Raslan Darawsheh
Hi Suanming
> -----Original Message-----
> From: Suanming Mou <suanmingm@nvidia.com>
> Sent: Thursday, December 14, 2023 5:04 AM
> To: Dariusz Sosnowski <dsosnowski@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Matan Azrad
> <matan@nvidia.com>
> Cc: dev@dpdk.org; Raslan Darawsheh <rasland@nvidia.com>
> Subject: [PATCH 1/4] net/mlx5: add TCP/IP length modify field
>
> This commit adds TCP data offset, IPv4 total length, IPv4 IHL,
> IPv6 payload length in modify field operation.
>
> Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
> ---
Acked-by: Ori Kam <orika@nvidia.com>
Best,
Ori
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/4] net/mlx5: rename modify copy destination to destination
2023-12-14 3:04 [PATCH 0/4] net/mlx5: add modify field ADD fields support Suanming Mou
2023-12-14 3:04 ` [PATCH 1/4] net/mlx5: add TCP/IP length modify field Suanming Mou
@ 2023-12-14 3:04 ` Suanming Mou
2023-12-14 11:37 ` Ori Kam
2023-12-14 3:04 ` [PATCH 3/4] net/mlx5: add modify field action ADD fields support Suanming Mou
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Suanming Mou @ 2023-12-14 3:04 UTC (permalink / raw)
To: Dariusz Sosnowski, Viacheslav Ovsiienko, Ori Kam, Matan Azrad
Cc: dev, rasland
In the mlx5_flow_field_id_to_modify_info() function, for the coming
new ADD_FILED operation will also use that dcopy as ADD_FIELD's
destination.
This commit renames the dcopy to dest which makes things much clearer.
Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
---
drivers/net/mlx5/mlx5_flow.h | 2 +-
drivers/net/mlx5/mlx5_flow_dv.c | 34 +++++++++++++++++----------------
2 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 6dde9de688..120609c595 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -2834,7 +2834,7 @@ void mlx5_flow_field_id_to_modify_info
const struct rte_flow_attr *attr, struct rte_flow_error *error);
int flow_dv_convert_modify_action(struct rte_flow_item *item,
struct field_modify_info *field,
- struct field_modify_info *dcopy,
+ struct field_modify_info *dest,
struct mlx5_flow_dv_modify_hdr_resource *resource,
uint32_t type, struct rte_flow_error *error);
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 4e2095dcfe..272dbca00f 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -363,8 +363,10 @@ mlx5_update_vlan_vid_pcp(const struct rte_flow_action *action,
* For MLX5_MODIFICATION_TYPE_SET specifies destination field.
* For MLX5_MODIFICATION_TYPE_ADD specifies destination field.
* For MLX5_MODIFICATION_TYPE_COPY specifies source field.
- * @param[in] dcopy
- * Destination field info for MLX5_MODIFICATION_TYPE_COPY in @type.
+ * For MLX5_MODIFICATION_TYPE_ADD_FIELD specifies source field.
+ * @param[in] dest
+ * Destination field info for MLX5_MODIFICATION_TYPE_COPY and
+ * MLX5_MODIFICATION_TYPE_ADD_FIELD in @type.
* Negative offset value sets the same offset as source offset.
* size field is ignored, value is taken from source field.
* @param[in,out] resource
@@ -380,7 +382,7 @@ mlx5_update_vlan_vid_pcp(const struct rte_flow_action *action,
int
flow_dv_convert_modify_action(struct rte_flow_item *item,
struct field_modify_info *field,
- struct field_modify_info *dcopy,
+ struct field_modify_info *dest,
struct mlx5_flow_dv_modify_hdr_resource *resource,
uint32_t type, struct rte_flow_error *error)
{
@@ -401,7 +403,7 @@ flow_dv_convert_modify_action(struct rte_flow_item *item,
uint32_t mask;
uint32_t data;
bool next_field = true;
- bool next_dcopy = true;
+ bool next_dest = true;
if (i >= MLX5_MAX_MODIFY_NUM)
return rte_flow_error_set(error, EINVAL,
@@ -432,20 +434,20 @@ flow_dv_convert_modify_action(struct rte_flow_item *item,
0 : size_b,
};
if (type == MLX5_MODIFICATION_TYPE_COPY) {
- MLX5_ASSERT(dcopy);
- actions[i].dst_field = dcopy->id;
+ MLX5_ASSERT(dest);
+ actions[i].dst_field = dest->id;
actions[i].dst_offset =
- (int)dcopy->offset < 0 ? off_b : dcopy->offset;
+ (int)dest->offset < 0 ? off_b : dest->offset;
/* Convert entire record to big-endian format. */
actions[i].data1 = rte_cpu_to_be_32(actions[i].data1);
/*
* Destination field overflow. Copy leftovers of
* a source field to the next destination field.
*/
- if ((size_b > dcopy->size * CHAR_BIT - dcopy->offset) &&
- dcopy->size != 0) {
+ if ((size_b > dest->size * CHAR_BIT - dest->offset) &&
+ dest->size != 0) {
actions[i].length =
- dcopy->size * CHAR_BIT - dcopy->offset;
+ dest->size * CHAR_BIT - dest->offset;
carry_b += actions[i].length;
next_field = false;
} else {
@@ -455,12 +457,12 @@ flow_dv_convert_modify_action(struct rte_flow_item *item,
* Not enough bits in a source filed to fill a
* destination field. Switch to the next source.
*/
- if ((size_b < dcopy->size * CHAR_BIT - dcopy->offset) &&
+ if ((size_b < dest->size * CHAR_BIT - dest->offset) &&
((size_b == field->size * CHAR_BIT - off_b) ||
field->is_flex)) {
actions[i].length = size_b;
- dcopy->offset += actions[i].length;
- next_dcopy = false;
+ dest->offset += actions[i].length;
+ next_dest = false;
}
} else {
MLX5_ASSERT(item->spec);
@@ -475,11 +477,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 ||
- dcopy->id != (enum mlx5_modification_field)UINT32_MAX) &&
+ dest->id != (enum mlx5_modification_field)UINT32_MAX) &&
field->id != (enum mlx5_modification_field)UINT32_MAX)
++i;
- if (next_dcopy && type == MLX5_MODIFICATION_TYPE_COPY)
- ++dcopy;
+ if (next_dest && type == MLX5_MODIFICATION_TYPE_COPY)
+ ++dest;
if (next_field)
++field;
} while (field->size);
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH 2/4] net/mlx5: rename modify copy destination to destination
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
0 siblings, 0 replies; 11+ messages in thread
From: Ori Kam @ 2023-12-14 11:37 UTC (permalink / raw)
To: Suanming Mou, Dariusz Sosnowski, Slava Ovsiienko, Matan Azrad
Cc: dev, Raslan Darawsheh
Hi Suanming
> -----Original Message-----
> From: Suanming Mou <suanmingm@nvidia.com>
> Sent: Thursday, December 14, 2023 5:04 AM
> Subject: [PATCH 2/4] net/mlx5: rename modify copy destination to destination
>
> In the mlx5_flow_field_id_to_modify_info() function, for the coming
> new ADD_FILED operation will also use that dcopy as ADD_FIELD's
> destination.
>
> This commit renames the dcopy to dest which makes things much clearer.
>
> Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
> ---
Acked-by: Ori Kam <orika@nvidia.com>
Best,
Ori
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/4] net/mlx5: add modify field action ADD fields support
2023-12-14 3:04 [PATCH 0/4] net/mlx5: add modify field ADD fields support Suanming Mou
2023-12-14 3:04 ` [PATCH 1/4] net/mlx5: add TCP/IP length modify field Suanming Mou
2023-12-14 3:04 ` [PATCH 2/4] net/mlx5: rename modify copy destination to destination Suanming Mou
@ 2023-12-14 3:04 ` Suanming Mou
2023-12-14 11:38 ` Ori Kam
2023-12-14 3:04 ` [PATCH 4/4] net/mlx5: add modify field action ADD fields validation Suanming Mou
2024-01-07 12:37 ` [PATCH 0/4] net/mlx5: add modify field ADD fields support Raslan Darawsheh
4 siblings, 1 reply; 11+ messages in thread
From: Suanming Mou @ 2023-12-14 3:04 UTC (permalink / raw)
To: Dariusz Sosnowski, Viacheslav Ovsiienko, Ori Kam, Matan Azrad
Cc: dev, rasland
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH 3/4] net/mlx5: add modify field action ADD fields support
2023-12-14 3:04 ` [PATCH 3/4] net/mlx5: add modify field action ADD fields support Suanming Mou
@ 2023-12-14 11:38 ` Ori Kam
0 siblings, 0 replies; 11+ messages in thread
From: Ori Kam @ 2023-12-14 11:38 UTC (permalink / raw)
To: Suanming Mou, Dariusz Sosnowski, Slava Ovsiienko, Matan Azrad
Cc: dev, Raslan Darawsheh
Hi Suanming,
> -----Original Message-----
> From: Suanming Mou <suanmingm@nvidia.com>
> Sent: Thursday, December 14, 2023 5:04 AM
> Subject: [PATCH 3/4] net/mlx5: add modify field action ADD fields support
>
> 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>
> ---
Acked-by: Ori Kam <orika@nvidia.com>
Best,
Ori
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 4/4] net/mlx5: add modify field action ADD fields validation
2023-12-14 3:04 [PATCH 0/4] net/mlx5: add modify field ADD fields support Suanming Mou
` (2 preceding siblings ...)
2023-12-14 3:04 ` [PATCH 3/4] net/mlx5: add modify field action ADD fields support Suanming Mou
@ 2023-12-14 3:04 ` 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
4 siblings, 1 reply; 11+ messages in thread
From: Suanming Mou @ 2023-12-14 3:04 UTC (permalink / raw)
To: Dariusz Sosnowski, Viacheslav Ovsiienko, Ori Kam, Matan Azrad
Cc: dev, rasland
Due to HW limitation, not all the fields are available as ADD_FIELD
destination.
This commit adds the validation to the destinations.
Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
---
doc/guides/rel_notes/release_24_03.rst | 4 ++++
drivers/net/mlx5/mlx5_flow_hw.c | 32 ++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst
index e9c9717706..2c0e2930cc 100644
--- a/doc/guides/rel_notes/release_24_03.rst
+++ b/doc/guides/rel_notes/release_24_03.rst
@@ -55,6 +55,10 @@ New Features
Also, make sure to start the actual text at the margin.
=======================================================
+* **Updated NVIDIA mlx5 driver.**
+
+ * Added support for accumulating from src field to dst field.
+
Removed Items
-------------
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index d224979ee8..c4a90a3690 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -4948,6 +4948,33 @@ flow_hw_modify_field_is_used(const struct rte_flow_action_modify_field *action,
return action->src.field == field || action->dst.field == field;
}
+static bool
+flow_hw_modify_field_is_add_dst_valid(const struct rte_flow_action_modify_field *conf)
+{
+ if (conf->operation != RTE_FLOW_MODIFY_ADD)
+ return true;
+ if (conf->src.field == RTE_FLOW_FIELD_POINTER ||
+ conf->src.field == RTE_FLOW_FIELD_VALUE)
+ return true;
+ switch (conf->dst.field) {
+ case RTE_FLOW_FIELD_IPV4_TTL:
+ case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
+ case RTE_FLOW_FIELD_TCP_SEQ_NUM:
+ case RTE_FLOW_FIELD_TCP_ACK_NUM:
+ case RTE_FLOW_FIELD_TAG:
+ case RTE_FLOW_FIELD_META:
+ case RTE_FLOW_FIELD_FLEX_ITEM:
+ case RTE_FLOW_FIELD_TCP_DATA_OFFSET:
+ case RTE_FLOW_FIELD_IPV4_IHL:
+ case RTE_FLOW_FIELD_IPV4_TOTAL_LEN:
+ case RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
static int
flow_hw_validate_action_modify_field(struct rte_eth_dev *dev,
const struct rte_flow_action *action,
@@ -5060,6 +5087,11 @@ flow_hw_validate_action_modify_field(struct rte_eth_dev *dev,
return rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_ACTION, action,
"MPLS cannot be used as destination");
+ /* ADD_FIELD is not supported for all the fields. */
+ if (!flow_hw_modify_field_is_add_dst_valid(action_conf))
+ return rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ACTION, action,
+ "invalid add_field destination");
return 0;
}
static int
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH 4/4] net/mlx5: add modify field action ADD fields validation
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
0 siblings, 0 replies; 11+ messages in thread
From: Ori Kam @ 2023-12-14 11:39 UTC (permalink / raw)
To: Suanming Mou, Dariusz Sosnowski, Slava Ovsiienko, Matan Azrad
Cc: dev, Raslan Darawsheh
Hi Suanming,
> -----Original Message-----
> From: Suanming Mou <suanmingm@nvidia.com>
> Sent: Thursday, December 14, 2023 5:04 AM
>
> Due to HW limitation, not all the fields are available as ADD_FIELD
> destination.
>
> This commit adds the validation to the destinations.
>
> Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
> ---
Acked-by: Ori Kam <orika@nvidia.com>
Best,
Ori
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH 0/4] net/mlx5: add modify field ADD fields support
2023-12-14 3:04 [PATCH 0/4] net/mlx5: add modify field ADD fields support Suanming Mou
` (3 preceding siblings ...)
2023-12-14 3:04 ` [PATCH 4/4] net/mlx5: add modify field action ADD fields validation Suanming Mou
@ 2024-01-07 12:37 ` Raslan Darawsheh
4 siblings, 0 replies; 11+ messages in thread
From: Raslan Darawsheh @ 2024-01-07 12:37 UTC (permalink / raw)
To: Suanming Mou; +Cc: dev
Hi,
> -----Original Message-----
> From: Suanming Mou <suanmingm@nvidia.com>
> Sent: Thursday, December 14, 2023 5:04 AM
> Cc: dev@dpdk.org; Raslan Darawsheh <rasland@nvidia.com>
> Subject: [PATCH 0/4] net/mlx5: add modify field ADD fields support
>
> Before this series, the modify_field ADD operation in mlx5 PMD only allowed
> sum of immediate value to field.
>
> 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.
>
>
> Suanming Mou (4):
> net/mlx5: add TCP/IP length modify field
> net/mlx5: rename modify copy destination to destination
> net/mlx5: add modify field action ADD fields support
> net/mlx5: add modify field action ADD fields validation
>
> doc/guides/rel_notes/release_24_03.rst | 4 ++
> drivers/common/mlx5/mlx5_prm.h | 4 ++
> drivers/net/mlx5/mlx5_flow.h | 2 +-
> drivers/net/mlx5/mlx5_flow_dv.c | 83 ++++++++++++++++++++------
> drivers/net/mlx5/mlx5_flow_hw.c | 42 ++++++++++++-
> 5 files changed, 112 insertions(+), 23 deletions(-)
>
> --
> 2.34.1
Series applied to next-net-mlx,
Kindest regards
Raslan Darawsheh
^ permalink raw reply [flat|nested] 11+ messages in thread