From: Haifei Luo <haifeil@nvidia.com>
To: <dev@dpdk.org>
Cc: <orika@nvidia.com>, <viacheslavo@nvidia.com>,
<rasland@nvidia.com>, <xuemingl@nvidia.com>, <haifeil@nvidia.com>,
Dariusz Sosnowski <dsosnowski@nvidia.com>,
Suanming Mou <suanmingm@nvidia.com>,
Matan Azrad <matan@nvidia.com>
Subject: [PATCH v4 5/5] net/mlx5: add support for item NSH
Date: Sun, 8 Oct 2023 06:10:29 +0300 [thread overview]
Message-ID: <20231008031029.30850-6-haifeil@nvidia.com> (raw)
In-Reply-To: <20231008031029.30850-1-haifeil@nvidia.com>
1. Add validation for item NSH.
It will fail if HCA cap for NSH is false.
2. Add item_flags for NSH.
3. For vxlan-gpe if next header is NSH, set next_protocol as NSH.
Signed-off-by: Haifei Luo <haifeil@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Acked-by: Suanming Mou <suanmingm@nvidia.com>
---
drivers/net/mlx5/mlx5_flow.c | 39 +++++++++++++++++++++++++++++++++
drivers/net/mlx5/mlx5_flow.h | 6 +++++
drivers/net/mlx5/mlx5_flow_dv.c | 13 ++++++++++-
3 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 202e878ddf..8ad85e6027 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -3905,6 +3905,45 @@ mlx5_flow_validate_item_ecpri(const struct rte_flow_item *item,
MLX5_ITEM_RANGE_NOT_ACCEPTED, error);
}
+/**
+ * Validate the NSH item.
+ *
+ * @param[in] dev
+ * Pointer to Ethernet device on which flow rule is being created on.
+ * @param[out] error
+ * Pointer to error structure.
+ *
+ * @return
+ * 0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_flow_validate_item_nsh(struct rte_eth_dev *dev,
+ const struct rte_flow_item *item,
+ struct rte_flow_error *error)
+{
+ struct mlx5_priv *priv = dev->data->dev_private;
+
+ if (item->mask) {
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ITEM, item,
+ "NSH fields matching is not supported");
+ }
+
+ if (!priv->sh->config.dv_flow_en) {
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "NSH support requires DV flow interface");
+ }
+
+ if (!priv->sh->cdev->config.hca_attr.tunnel_stateless_vxlan_gpe_nsh) {
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ITEM, item,
+ "Current FW does not support matching on NSH");
+ }
+
+ return 0;
+}
+
static int
flow_null_validate(struct rte_eth_dev *dev __rte_unused,
const struct rte_flow_attr *attr __rte_unused,
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 3a97975d69..ccb416e497 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -233,6 +233,9 @@ enum mlx5_feature_name {
/* IB BTH ITEM. */
#define MLX5_FLOW_ITEM_IB_BTH (1ull << 51)
+/* NSH ITEM */
+#define MLX5_FLOW_ITEM_NSH (1ull << 53)
+
/* Outer Masks. */
#define MLX5_FLOW_LAYER_OUTER_L3 \
(MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
@@ -2453,6 +2456,9 @@ int mlx5_flow_validate_item_ecpri(const struct rte_flow_item *item,
uint16_t ether_type,
const struct rte_flow_item_ecpri *acc_mask,
struct rte_flow_error *error);
+int mlx5_flow_validate_item_nsh(struct rte_eth_dev *dev,
+ const struct rte_flow_item *item,
+ struct rte_flow_error *error);
int mlx5_flow_create_mtr_tbls(struct rte_eth_dev *dev,
struct mlx5_flow_meter_info *fm,
uint32_t mtr_idx,
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 3f4325c5c8..5cd04b1d93 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -7815,6 +7815,12 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
last_item = MLX5_FLOW_ITEM_IB_BTH;
break;
+ case RTE_FLOW_ITEM_TYPE_NSH:
+ ret = mlx5_flow_validate_item_nsh(dev, items, error);
+ if (ret < 0)
+ return ret;
+ last_item = MLX5_FLOW_ITEM_NSH;
+ break;
default:
return rte_flow_error_set(error, ENOTSUP,
RTE_FLOW_ERROR_TYPE_ITEM,
@@ -9720,7 +9726,9 @@ flow_dv_translate_item_vxlan_gpe(void *key, const struct rte_flow_item *item,
v_protocol = vxlan_v->hdr.protocol;
if (!m_protocol) {
/* Force next protocol to ensure next headers parsing. */
- if (pattern_flags & MLX5_FLOW_LAYER_INNER_L2)
+ if (pattern_flags & MLX5_FLOW_ITEM_NSH)
+ v_protocol = RTE_VXLAN_GPE_TYPE_NSH;
+ else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L2)
v_protocol = RTE_VXLAN_GPE_TYPE_ETH;
else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV4)
v_protocol = RTE_VXLAN_GPE_TYPE_IPV4;
@@ -13910,6 +13918,9 @@ flow_dv_translate_items(struct rte_eth_dev *dev,
flow_dv_translate_item_ib_bth(key, items, tunnel, key_type);
last_item = MLX5_FLOW_ITEM_IB_BTH;
break;
+ case RTE_FLOW_ITEM_TYPE_NSH:
+ last_item = MLX5_FLOW_ITEM_NSH;
+ break;
default:
break;
}
--
2.27.0
next prev parent reply other threads:[~2023-10-08 3:11 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 7:40 [PATCH 0/5] support item NSH matching Haifei Luo
2023-08-09 7:40 ` [PATCH 1/5] app/testpmd: support for VXLAN-GPE's next protocol Haifei Luo
2023-08-09 7:40 ` [PATCH 2/5] common/mlx5: extend HCA attribute query for NSH Haifei Luo
2023-08-09 7:40 ` [PATCH 3/5] net/mlx5: enhance the validation for item VXLAN-GPE Haifei Luo
2023-08-09 7:40 ` [PATCH 4/5] app/testpmd: support for NSH flow item Haifei Luo
2023-08-09 7:40 ` [PATCH 5/5] net/mlx5: add support for item NSH Haifei Luo
2023-09-25 2:09 ` [PATCH v2 0/5] support item NSH matching Haifei Luo
2023-09-25 2:09 ` [PATCH v2 1/5] app/testpmd: support for VXLAN-GPE's next protocol Haifei Luo
2023-09-25 2:09 ` [PATCH v2 2/5] common/mlx5: extend HCA attribute query for NSH Haifei Luo
2023-09-25 2:09 ` [PATCH v2 3/5] net/mlx5: enhance the validation for item VXLAN-GPE Haifei Luo
2023-09-25 2:09 ` [PATCH v2 4/5] app/testpmd: support for NSH flow item Haifei Luo
2023-09-25 2:09 ` [PATCH v2 5/5] net/mlx5: add support for item NSH Haifei Luo
2023-09-25 8:07 ` [PATCH v3 0/5] support item NSH matching Haifei Luo
2023-09-25 8:07 ` [PATCH v3 1/5] app/testpmd: support for VXLAN-GPE's next protocol Haifei Luo
2023-09-25 8:07 ` [PATCH v3 2/5] common/mlx5: extend HCA attribute query for NSH Haifei Luo
2023-09-25 8:07 ` [PATCH v3 3/5] net/mlx5: enhance the validation for item VXLAN-GPE Haifei Luo
2023-09-25 8:07 ` [PATCH v3 4/5] app/testpmd: support for NSH flow item Haifei Luo
2023-09-25 8:07 ` [PATCH v3 5/5] net/mlx5: add support for item NSH Haifei Luo
2023-10-08 3:10 ` [PATCH v4 0/5] support item NSH matching Haifei Luo
2023-10-08 3:10 ` [PATCH v4 1/5] app/testpmd: support for VXLAN-GPE's next protocol Haifei Luo
2023-10-08 3:10 ` [PATCH v4 2/5] common/mlx5: extend HCA attribute query for NSH Haifei Luo
2023-10-08 3:10 ` [PATCH v4 3/5] net/mlx5: enhance the validation for item VXLAN-GPE Haifei Luo
2023-10-08 3:10 ` [PATCH v4 4/5] app/testpmd: support for NSH flow item Haifei Luo
2023-10-08 3:10 ` Haifei Luo [this message]
2023-10-09 11:15 ` [PATCH v4 0/5] support item NSH matching Raslan Darawsheh
2023-10-16 9:27 ` Thomas Monjalon
2023-10-08 10:34 ` [PATCH v2 " 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=20231008031029.30850-6-haifeil@nvidia.com \
--to=haifeil@nvidia.com \
--cc=dev@dpdk.org \
--cc=dsosnowski@nvidia.com \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=rasland@nvidia.com \
--cc=suanmingm@nvidia.com \
--cc=viacheslavo@nvidia.com \
--cc=xuemingl@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).