From: Michael Baum <michaelba@nvidia.com>
To: <dev@dpdk.org>
Cc: Ori Kam <orika@nvidia.com>,
Aman Singh <aman.deep.singh@intel.com>,
"Yuying Zhang" <yuying.zhang@intel.com>,
Ferruh Yigit <ferruh.yigit@amd.com>,
"Thomas Monjalon" <thomas@monjalon.net>
Subject: [PATCH v1 7/7] net/mlx5: add MPLS modify field support
Date: Tue, 16 May 2023 09:37:47 +0300 [thread overview]
Message-ID: <20230516063747.3047758-8-michaelba@nvidia.com> (raw)
In-Reply-To: <20230516063747.3047758-1-michaelba@nvidia.com>
Add support for modify field in tunnel MPLS header.
For now it is supported only to copy from.
Signed-off-by: Michael Baum <michaelba@nvidia.com>
---
drivers/common/mlx5/mlx5_prm.h | 5 +++++
drivers/net/mlx5/mlx5_flow_dv.c | 23 +++++++++++++++++++++++
drivers/net/mlx5/mlx5_flow_hw.c | 16 +++++++++-------
3 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index ed3d5efbb7..04c1400a1e 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -787,6 +787,11 @@ enum mlx5_modification_field {
MLX5_MODI_TUNNEL_HDR_DW_1 = 0x75,
MLX5_MODI_GTPU_FIRST_EXT_DW_0 = 0x76,
MLX5_MODI_HASH_RESULT = 0x81,
+ MLX5_MODI_IN_MPLS_LABEL_0 = 0x8a,
+ MLX5_MODI_IN_MPLS_LABEL_1,
+ MLX5_MODI_IN_MPLS_LABEL_2,
+ MLX5_MODI_IN_MPLS_LABEL_3,
+ MLX5_MODI_IN_MPLS_LABEL_4,
MLX5_MODI_OUT_IPV6_NEXT_HDR = 0x4A,
MLX5_MODI_INVALID = INT_MAX,
};
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index f136f43b0a..93cce16a1e 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -1388,6 +1388,7 @@ mlx5_flow_item_field_width(struct rte_eth_dev *dev,
case RTE_FLOW_FIELD_GENEVE_VNI:
return 24;
case RTE_FLOW_FIELD_GTP_TEID:
+ case RTE_FLOW_FIELD_MPLS:
case RTE_FLOW_FIELD_TAG:
return 32;
case RTE_FLOW_FIELD_MARK:
@@ -1435,6 +1436,12 @@ flow_modify_info_mask_32_masked(uint32_t length, uint32_t off, uint32_t post_mas
return rte_cpu_to_be_32(mask & post_mask);
}
+static __rte_always_inline enum mlx5_modification_field
+mlx5_mpls_modi_field_get(const struct rte_flow_action_modify_data *data)
+{
+ return MLX5_MODI_IN_MPLS_LABEL_0 + data->sub_level;
+}
+
static void
mlx5_modify_flex_item(const struct rte_eth_dev *dev,
const struct mlx5_flex_item *flex,
@@ -1893,6 +1900,16 @@ mlx5_flow_field_id_to_modify_info
else
info[idx].offset = off_be;
break;
+ case RTE_FLOW_FIELD_MPLS:
+ MLX5_ASSERT(data->offset + width <= 32);
+ off_be = 32 - (data->offset + width);
+ info[idx] = (struct field_modify_info){4, 0,
+ mlx5_mpls_modi_field_get(data)};
+ if (mask)
+ mask[idx] = flow_modify_info_mask_32(width, off_be);
+ else
+ info[idx].offset = off_be;
+ break;
case RTE_FLOW_FIELD_TAG:
{
MLX5_ASSERT(data->offset + width <= 32);
@@ -5344,6 +5361,12 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,
RTE_FLOW_ERROR_TYPE_ACTION, action,
"modifications of the GENEVE Network"
" Identifier is not supported");
+ if (action_modify_field->dst.field == RTE_FLOW_FIELD_MPLS ||
+ action_modify_field->src.field == RTE_FLOW_FIELD_MPLS)
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ACTION, action,
+ "modifications of the MPLS header "
+ "is not supported");
if (action_modify_field->dst.field == RTE_FLOW_FIELD_MARK ||
action_modify_field->src.field == RTE_FLOW_FIELD_MARK)
if (config->dv_xmeta_en == MLX5_XMETA_MODE_LEGACY ||
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 1b68a19900..80e6398992 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -3546,10 +3546,8 @@ flow_hw_validate_action_modify_field(const struct rte_flow_action *action,
const struct rte_flow_action *mask,
struct rte_flow_error *error)
{
- const struct rte_flow_action_modify_field *action_conf =
- action->conf;
- const struct rte_flow_action_modify_field *mask_conf =
- mask->conf;
+ const struct rte_flow_action_modify_field *action_conf = action->conf;
+ const struct rte_flow_action_modify_field *mask_conf = mask->conf;
if (action_conf->operation != mask_conf->operation)
return rte_flow_error_set(error, EINVAL,
@@ -3604,6 +3602,11 @@ flow_hw_validate_action_modify_field(const struct rte_flow_action *action,
return rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_ACTION, action,
"modifying Geneve VNI is not supported");
+ /* Due to HW bug, tunnel MPLS header is read only. */
+ if (action_conf->dst.field == RTE_FLOW_FIELD_MPLS)
+ return rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ACTION, action,
+ "MPLS cannot be used as destination");
return 0;
}
@@ -4134,9 +4137,8 @@ mlx5_flow_hw_actions_validate(struct rte_eth_dev *dev,
action_flags |= MLX5_FLOW_ACTION_METER;
break;
case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD:
- ret = flow_hw_validate_action_modify_field(action,
- mask,
- error);
+ ret = flow_hw_validate_action_modify_field(action, mask,
+ error);
if (ret < 0)
return ret;
action_flags |= MLX5_FLOW_ACTION_MODIFY_FIELD;
--
2.25.1
next prev parent reply other threads:[~2023-05-16 6:38 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 6:37 [PATCH v1 0/7] ethdev: modify field API for multiple headers Michael Baum
2023-05-16 6:37 ` [PATCH v1 1/7] doc: fix blank lines in modify field action description Michael Baum
2023-05-16 6:37 ` [PATCH v1 2/7] doc: fix blank line in asynchronous operations description Michael Baum
2023-05-17 17:13 ` Ori Kam
2023-05-16 6:37 ` [PATCH v1 3/7] doc: fix wrong indentation in RSS action description Michael Baum
2023-05-18 6:18 ` Ori Kam
2023-05-16 6:37 ` [PATCH v1 4/7] net/mlx5: reduce modify field encapsulation level size Michael Baum
2023-05-16 6:37 ` [PATCH v1 5/7] ethdev: add GENEVE TLV option modification support Michael Baum
2023-05-16 6:37 ` [PATCH v1 6/7] ethdev: add MPLS header " Michael Baum
2023-05-16 6:37 ` Michael Baum [this message]
2023-05-18 17:40 ` [PATCH v2 0/5] ethdev: modify field API for multiple headers Michael Baum
2023-05-18 17:40 ` [PATCH v2 1/5] doc: fix blank lines in modify field action description Michael Baum
2023-05-21 10:07 ` Ori Kam
2023-05-18 17:40 ` [PATCH v2 2/5] doc: fix blank line in asynchronous operations description Michael Baum
2023-05-21 10:07 ` Ori Kam
2023-05-18 17:40 ` [PATCH v2 3/5] doc: fix wrong indentation in RSS action description Michael Baum
2023-05-21 10:08 ` Ori Kam
2023-05-18 17:40 ` [PATCH v2 4/5] ethdev: add GENEVE TLV option modification support Michael Baum
2023-05-21 18:52 ` Ori Kam
2023-05-18 17:40 ` [PATCH v2 5/5] ethdev: add MPLS header " Michael Baum
2023-05-21 19:03 ` Ori Kam
2023-05-22 12:04 ` Michael Baum
2023-05-22 19:27 ` [PATCH v3 0/5] ethdev: modify field API for multiple headers Michael Baum
2023-05-22 19:28 ` [PATCH v3 1/5] doc: fix blank lines in modify field action description Michael Baum
2023-05-22 19:28 ` [PATCH v3 2/5] doc: fix blank line in asynchronous operations description Michael Baum
2023-05-22 19:28 ` [PATCH v3 3/5] doc: fix wrong indentation in RSS action description Michael Baum
2023-05-22 19:28 ` [PATCH v3 4/5] ethdev: add GENEVE TLV option modification support Michael Baum
2023-05-22 19:28 ` [PATCH v3 5/5] ethdev: add MPLS header " Michael Baum
2023-05-23 10:40 ` [PATCH v3 0/5] ethdev: modify field API for multiple headers Ori Kam
2023-05-23 12:48 ` [PATCH v4 " Michael Baum
2023-05-23 12:48 ` [PATCH v4 1/5] doc: fix blank lines in modify field action description Michael Baum
2023-05-23 12:48 ` [PATCH v4 2/5] doc: fix blank line in asynchronous operations description Michael Baum
2023-05-23 12:48 ` [PATCH v4 3/5] doc: fix wrong indentation in RSS action description Michael Baum
2023-05-23 12:48 ` [PATCH v4 4/5] ethdev: add GENEVE TLV option modification support Michael Baum
2023-05-23 12:48 ` [PATCH v4 5/5] ethdev: add MPLS header " Michael Baum
2023-05-23 21:31 ` [PATCH v5 0/5] ethdev: modify field API for multiple headers Michael Baum
2023-05-23 21:31 ` [PATCH v5 1/5] doc: fix blank lines in modify field action description Michael Baum
2023-05-23 21:31 ` [PATCH v5 2/5] doc: fix blank line in asynchronous operations description Michael Baum
2023-05-23 21:31 ` [PATCH v5 3/5] doc: fix wrong indentation in RSS action description Michael Baum
2023-05-23 21:31 ` [PATCH v5 4/5] ethdev: add GENEVE TLV option modification support Michael Baum
2023-05-23 21:31 ` [PATCH v5 5/5] ethdev: add MPLS header " Michael Baum
2023-06-01 11:54 ` Ferruh Yigit
2023-06-01 11:54 ` [PATCH v5 0/5] ethdev: modify field API for multiple headers Ferruh Yigit
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=20230516063747.3047758-8-michaelba@nvidia.com \
--to=michaelba@nvidia.com \
--cc=aman.deep.singh@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=orika@nvidia.com \
--cc=thomas@monjalon.net \
--cc=yuying.zhang@intel.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).