DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bing Zhao <bingz@mellanox.com>
To: orika@mellanox.com, viacheslavo@mellanox.com
Cc: rasland@mellanox.com, matan@mellanox.com, dev@dpdk.org
Subject: [dpdk-dev] [PATCH 1/5] net/mlx5: add flow validation of eCPRI header
Date: Wed,  8 Jul 2020 22:43:03 +0800	[thread overview]
Message-ID: <1594219387-240274-2-git-send-email-bingz@mellanox.com> (raw)
In-Reply-To: <1594219387-240274-1-git-send-email-bingz@mellanox.com>

When creating a flow with eCPRI header item, the validation of it is
mandatory. The detailed limitations are listed below:
  1. Over Ether / VLAN, ethertype must be 0xAEFE.
  2. No tunnel support is described in the specification now.
  3. L3 layer is only supported when L4 is UDP, see #4.
  4. Over TCP is not supported from the specification, and over UDP
     is not supported right now.
  5. Concatenation indicator matching is not supported now.
  6. No need to check the revision.
  7. Only type field in the common header is mandatory, and one byte
     should be matched integrally.
  8. Fields in the message payload header are optional.
  9. Only messages with type #0, #2 and #5 are supported now.

Some limitations are only from software right now, because there is
no need to support all the message types and variants of protocol
stack listed in the specification.

Signed-off-by: Bing Zhao <bingz@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c    | 106 +++++++++++++++++++++++++++++++++++++++-
 drivers/net/mlx5/mlx5_flow.h    |   9 ++++
 drivers/net/mlx5/mlx5_flow_dv.c |  22 +++++++++
 3 files changed, 136 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index ae5ccc2..9309603 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -1227,11 +1227,17 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 					  RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
 					  "rss action not supported for "
 					  "egress");
-	if (rss->level > 1 &&  !tunnel)
+	if (rss->level > 1 && !tunnel)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL,
 					  "inner RSS is not supported for "
 					  "non-tunnel flows");
+	if ((item_flags & MLX5_FLOW_LAYER_ECPRI) &&
+	    !(item_flags & MLX5_FLOW_LAYER_INNER_L4_UDP)) {
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL,
+					  "RSS on eCPRI is not supported now");
+	}
 	return 0;
 }
 
@@ -1597,6 +1603,10 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
  *   Item specification.
  * @param[in] item_flags
  *   Bit-fields that holds the items detected until now.
+ * @param[in] last_item
+ *   Previous validated item in the pattern items.
+ * @param[in] ether_type
+ *   Type in the ethernet layer header (including dot1q).
  * @param[in] acc_mask
  *   Acceptable mask, if NULL default internal default mask
  *   will be used to check whether item fields are supported.
@@ -1695,6 +1705,10 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
  *   Item specification.
  * @param[in] item_flags
  *   Bit-fields that holds the items detected until now.
+ * @param[in] last_item
+ *   Previous validated item in the pattern items.
+ * @param[in] ether_type
+ *   Type in the ethernet layer header (including dot1q).
  * @param[in] acc_mask
  *   Acceptable mask, if NULL default internal default mask
  *   will be used to check whether item fields are supported.
@@ -2357,6 +2371,96 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 	return 0;
 }
 
+/**
+ * Validate eCPRI item.
+ *
+ * @param[in] item
+ *   Item specification.
+ * @param[in] item_flags
+ *   Bit-fields that holds the items detected until now.
+ * @param[in] last_item
+ *   Previous validated item in the pattern items.
+ * @param[in] ether_type
+ *   Type in the ethernet layer header (including dot1q).
+ * @param[in] acc_mask
+ *   Acceptable mask, if NULL default internal default mask
+ *   will be used to check whether item fields are supported.
+ * @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_ecpri(const struct rte_flow_item *item,
+			      uint64_t item_flags,
+			      uint64_t last_item,
+			      uint16_t ether_type,
+			      const struct rte_flow_item_ecpri *acc_mask,
+			      struct rte_flow_error *error)
+{
+	const struct rte_flow_item_ecpri *mask = item->mask;
+	const struct rte_flow_item_ecpri nic_mask = {
+		.hdr = {
+			.dw0 = RTE_BE32(((const struct rte_ecpri_msg_hdr) {
+						.common = {
+							.type = 0xFF,
+						},
+					}).dw0),
+			.dummy[0] = 0xFFFFFFFF,
+		},
+	};
+	const uint64_t outer_l2_vlan = (MLX5_FLOW_LAYER_OUTER_L2 |
+					MLX5_FLOW_LAYER_OUTER_VLAN);
+	struct rte_flow_item_ecpri mask_lo;
+
+	if ((last_item & outer_l2_vlan) && ether_type &&
+	    ether_type != RTE_ETHER_TYPE_ECPRI)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM, item,
+					  "eCPRI cannot follow L2/VLAN layer "
+					  "which ether type is not 0xAEFE.");
+	if (item_flags & MLX5_FLOW_LAYER_TUNNEL)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM, item,
+					  "eCPRI with tunnel is not supported "
+					  "right now.");
+	if (item_flags & MLX5_FLOW_LAYER_OUTER_L3)
+		return rte_flow_error_set(error, ENOTSUP,
+					  RTE_FLOW_ERROR_TYPE_ITEM, item,
+					  "multiple L3 layers not supported");
+	else if (item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM, item,
+					  "eCPRI cannot follow a TCP layer.");
+	/* In specification, eCPRI could be over UDP layer. */
+	else if (item_flags & MLX5_FLOW_LAYER_OUTER_L4_UDP)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM, item,
+					  "eCPRI over UDP layer is not yet"
+					  "supported right now.");
+	/* Mask for type field in common header could be zero. */
+	if (!mask)
+		mask = &rte_flow_item_ecpri_mask;
+	mask_lo.hdr.dw0 = rte_be_to_cpu_32(mask->hdr.dw0);
+	/* Input mask is in big-endian format. */
+	if (mask_lo.hdr.common.type != 0 && mask_lo.hdr.common.type != 0xff)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM_MASK, mask,
+					  "partial mask is not supported "
+					  "for protocol");
+	else if (mask_lo.hdr.common.type == 0 && mask->hdr.dummy[0] != 0)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM_MASK, mask,
+					  "message header mask must be after "
+					  "a type mask");
+	return mlx5_flow_item_acceptable(item, (const uint8_t *)mask,
+					 acc_mask ? (const uint8_t *)acc_mask
+						  : (const uint8_t *)&nic_mask,
+					 sizeof(struct rte_flow_item_ecpri),
+					 error);
+}
+
 /* Allocate unique ID for the split Q/RSS subflows. */
 static uint32_t
 flow_qrss_get_id(struct rte_eth_dev *dev)
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 43cbda8..6dfeef3 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -128,6 +128,9 @@ enum mlx5_feature_name {
 /* Pattern tunnel Layer bits (continued). */
 #define MLX5_FLOW_LAYER_GTP (1u << 28)
 
+/* Pattern eCPRI Layer bit. */
+#define MLX5_FLOW_LAYER_ECPRI (UINT64_C(1) << 29)
+
 /* Outer Masks. */
 #define MLX5_FLOW_LAYER_OUTER_L3 \
 	(MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
@@ -1027,6 +1030,12 @@ int mlx5_flow_validate_item_geneve(const struct rte_flow_item *item,
 				   uint64_t item_flags,
 				   struct rte_eth_dev *dev,
 				   struct rte_flow_error *error);
+int mlx5_flow_validate_item_ecpri(const struct rte_flow_item *item,
+				  uint64_t item_flags,
+				  uint64_t last_item,
+				  uint16_t ether_type,
+				  const struct rte_flow_item_ecpri *acc_mask,
+				  struct rte_flow_error *error);
 struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls
 					(struct rte_eth_dev *dev,
 					 const struct mlx5_flow_meter *fm);
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 8b5b683..6711c79 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -4923,6 +4923,16 @@ struct field_modify_info modify_tcp[] = {
 			.hop_limits = 0xff,
 		},
 	};
+	const struct rte_flow_item_ecpri nic_ecpri_mask = {
+		.hdr = {
+			.dw0 = RTE_BE32(((const struct rte_ecpri_msg_hdr) {
+						.common = {
+							.type = 0xFF,
+						},
+					}).dw0),
+			.dummy[0] = 0xffffffff,
+		},
+	};
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_dev_config *dev_conf = &priv->config;
 	uint16_t queue_index = 0xFFFF;
@@ -5173,6 +5183,17 @@ struct field_modify_info modify_tcp[] = {
 				return ret;
 			last_item = MLX5_FLOW_LAYER_GTP;
 			break;
+		case RTE_FLOW_ITEM_TYPE_ECPRI:
+			/* Capacity will be checked in the translate stage. */
+			ret = mlx5_flow_validate_item_ecpri(items, item_flags,
+							    last_item,
+							    ether_type,
+							    &nic_ecpri_mask,
+							    error);
+			if (ret < 0)
+				return ret;
+			last_item = MLX5_FLOW_LAYER_ECPRI;
+			break;
 		default:
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ITEM,
@@ -5882,6 +5903,7 @@ struct field_modify_info modify_tcp[] = {
 	 * Set match on ethertype only if ETH header is not followed by VLAN.
 	 * HW is optimized for IPv4/IPv6. In such cases, avoid setting
 	 * ethertype, and use ip_version field instead.
+	 * eCPRI over Ether layer will use type value 0xAEFE.
 	 */
 	if (eth_v->type == RTE_BE16(RTE_ETHER_TYPE_IPV4) &&
 	    eth_m->type == 0xFFFF) {
-- 
1.8.3.1


  reply	other threads:[~2020-07-08 14:43 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08 14:43 [dpdk-dev] [PATCH 0/5] add eCPRI support in mlx5 driver Bing Zhao
2020-07-08 14:43 ` Bing Zhao [this message]
2020-07-08 14:43 ` [dpdk-dev] [PATCH 2/5] net/mlx5: add flow translation of eCPRI header Bing Zhao
2020-07-09 12:22   ` Thomas Monjalon
2020-07-09 14:47     ` Bing Zhao
2020-07-08 14:43 ` [dpdk-dev] [PATCH 3/5] net/mlx5: add flex parser devx structures Bing Zhao
2020-07-08 14:43 ` [dpdk-dev] [PATCH 4/5] net/mlx5: adding Devx command for flex parsers Bing Zhao
2020-07-08 14:43 ` [dpdk-dev] [PATCH 5/5] net/mlx5: create and destroy eCPRI flex parser Bing Zhao
2020-07-16 13:49 ` [dpdk-dev] [PATCH v2 0/7] add eCPRI support in mlx5 driver Bing Zhao
2020-07-16 13:49   ` [dpdk-dev] [PATCH v2 1/7] net/mlx5: add flow validation of eCPRI header Bing Zhao
2020-07-16 13:49   ` [dpdk-dev] [PATCH v2 2/7] net/mlx5: add flow translation " Bing Zhao
2020-07-16 13:49   ` [dpdk-dev] [PATCH v2 3/7] common/mlx5: add flex parser DevX structures Bing Zhao
2020-07-16 13:49   ` [dpdk-dev] [PATCH v2 4/7] common/mlx5: adding DevX command for flex parsers Bing Zhao
2020-07-16 13:49   ` [dpdk-dev] [PATCH v2 5/7] net/mlx5: create and destroy eCPRI flex parser Bing Zhao
2020-07-16 13:49   ` [dpdk-dev] [PATCH v2 6/7] net/mlx5: add eCPRI flex parser capacity check Bing Zhao
2020-07-16 13:49   ` [dpdk-dev] [PATCH v2 7/7] doc: update release notes and guides for eCPRI Bing Zhao
2020-07-16 14:23   ` [dpdk-dev] [PATCH v3 0/7] add eCPRI support in mlx5 driver Bing Zhao
2020-07-16 14:23     ` [dpdk-dev] [PATCH v3 1/7] net/mlx5: add flow validation of eCPRI header Bing Zhao
2020-07-16 15:04       ` Slava Ovsiienko
2020-07-16 14:23     ` [dpdk-dev] [PATCH v3 2/7] net/mlx5: add flow translation " Bing Zhao
2020-07-16 15:04       ` Slava Ovsiienko
2020-07-16 14:23     ` [dpdk-dev] [PATCH v3 3/7] common/mlx5: add flex parser DevX structures Bing Zhao
2020-07-16 15:04       ` Slava Ovsiienko
2020-07-16 14:23     ` [dpdk-dev] [PATCH v3 4/7] common/mlx5: adding DevX command for flex parsers Bing Zhao
2020-07-16 15:05       ` Slava Ovsiienko
2020-07-16 14:23     ` [dpdk-dev] [PATCH v3 5/7] net/mlx5: create and destroy eCPRI flex parser Bing Zhao
2020-07-16 15:05       ` Slava Ovsiienko
2020-07-16 14:23     ` [dpdk-dev] [PATCH v3 6/7] net/mlx5: add eCPRI flex parser capacity check Bing Zhao
2020-07-16 15:05       ` Slava Ovsiienko
2020-07-16 14:23     ` [dpdk-dev] [PATCH v3 7/7] doc: update release notes and guides for eCPRI Bing Zhao
2020-07-16 15:05       ` Slava Ovsiienko
2020-07-17  7:11     ` [dpdk-dev] [PATCH v4 0/7] add eCPRI support in mlx5 driver Bing Zhao
2020-07-17  7:11       ` [dpdk-dev] [PATCH v4 1/7] net/mlx5: add flow validation of eCPRI header Bing Zhao
2020-07-17  7:11       ` [dpdk-dev] [PATCH v4 2/7] net/mlx5: add flow translation " Bing Zhao
2020-07-17  7:11       ` [dpdk-dev] [PATCH v4 3/7] common/mlx5: add flex parser DevX structures Bing Zhao
2020-07-17  7:11       ` [dpdk-dev] [PATCH v4 4/7] common/mlx5: adding DevX command for flex parsers Bing Zhao
2020-07-17  7:11       ` [dpdk-dev] [PATCH v4 5/7] net/mlx5: create and destroy eCPRI flex parser Bing Zhao
2020-07-17  7:11       ` [dpdk-dev] [PATCH v4 6/7] net/mlx5: add eCPRI flex parser capacity check Bing Zhao
2020-07-17  7:11       ` [dpdk-dev] [PATCH v4 7/7] doc: update release notes and guides for eCPRI Bing Zhao
2020-07-17 12:55       ` [dpdk-dev] [PATCH v4 0/7] add eCPRI support in mlx5 driver 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=1594219387-240274-2-git-send-email-bingz@mellanox.com \
    --to=bingz@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=matan@mellanox.com \
    --cc=orika@mellanox.com \
    --cc=rasland@mellanox.com \
    --cc=viacheslavo@mellanox.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).