DPDK patches and discussions
 help / color / mirror / Atom feed
From: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
To: shahafs@mellanox.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 3/4] net/mlx5: add tos and ttl validation on E-Switch
Date: Sat, 29 Dec 2018 18:51:40 +0000	[thread overview]
Message-ID: <1546109501-24865-4-git-send-email-viacheslavo@mellanox.com> (raw)
In-Reply-To: <1546109501-24865-1-git-send-email-viacheslavo@mellanox.com>

This patch adds the type-of-service and time-to-live IP header
fields validation on E-Switch, both for match pattern and
VXLAN encapsulation action IP header itesm. The E-Switch flows
will use the common mlx5_flow_validate_item_ipv4/6 routines
with added extra parameter, specifying the supported fields
mask.

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c       | 14 ++++++++++++--
 drivers/net/mlx5/mlx5_flow.h       |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c    |  4 ++--
 drivers/net/mlx5/mlx5_flow_tcf.c   | 24 ++++++++++++++++--------
 drivers/net/mlx5/mlx5_flow_verbs.c |  4 ++--
 5 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index ee129b9..0fd6ed5 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -1141,6 +1141,9 @@ 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] 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.
  *
@@ -1150,6 +1153,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 int
 mlx5_flow_validate_item_ipv4(const struct rte_flow_item *item,
 			     uint64_t item_flags,
+			     const struct rte_flow_item_ipv4 *acc_mask,
 			     struct rte_flow_error *error)
 {
 	const struct rte_flow_item_ipv4 *mask = item->mask;
@@ -1185,7 +1189,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 					  "partial mask is not supported"
 					  " for protocol");
 	ret = mlx5_flow_item_acceptable(item, (const uint8_t *)mask,
-					(const uint8_t *)&nic_mask,
+					acc_mask ? (const uint8_t *)acc_mask
+						 : (const uint8_t *)&nic_mask,
 					sizeof(struct rte_flow_item_ipv4),
 					error);
 	if (ret < 0)
@@ -1200,6 +1205,9 @@ 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] 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.
  *
@@ -1209,6 +1217,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 int
 mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,
 			     uint64_t item_flags,
+			     const struct rte_flow_item_ipv6 *acc_mask,
 			     struct rte_flow_error *error)
 {
 	const struct rte_flow_item_ipv6 *mask = item->mask;
@@ -1243,7 +1252,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 	if (!mask)
 		mask = &rte_flow_item_ipv6_mask;
 	ret = mlx5_flow_item_acceptable(item, (const uint8_t *)mask,
-					(const uint8_t *)&nic_mask,
+					acc_mask ? (const uint8_t *)acc_mask
+						 : (const uint8_t *)&nic_mask,
 					sizeof(struct rte_flow_item_ipv6),
 					error);
 	if (ret < 0)
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 4a7c052..8e4eacb 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -381,9 +381,11 @@ int mlx5_flow_validate_item_gre(const struct rte_flow_item *item,
 				struct rte_flow_error *error);
 int mlx5_flow_validate_item_ipv4(const struct rte_flow_item *item,
 				 uint64_t item_flags,
+				 const struct rte_flow_item_ipv4 *acc_mask,
 				 struct rte_flow_error *error);
 int mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,
 				 uint64_t item_flags,
+				 const struct rte_flow_item_ipv6 *acc_mask,
 				 struct rte_flow_error *error);
 int mlx5_flow_validate_item_mpls(struct rte_eth_dev *dev,
 				 const struct rte_flow_item *item,
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 1f31874..ab87165 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -808,7 +808,7 @@
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV4:
 			ret = mlx5_flow_validate_item_ipv4(items, item_flags,
-							   error);
+							   NULL, error);
 			if (ret < 0)
 				return ret;
 			last_item = tunnel ? MLX5_FLOW_LAYER_INNER_L3_IPV4 :
@@ -829,7 +829,7 @@
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			ret = mlx5_flow_validate_item_ipv6(items, item_flags,
-							   error);
+							   NULL, error);
 			if (ret < 0)
 				return ret;
 			last_item = tunnel ? MLX5_FLOW_LAYER_INNER_L3_IPV6 :
diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c
index ca8ea0b..16fc936 100644
--- a/drivers/net/mlx5/mlx5_flow_tcf.c
+++ b/drivers/net/mlx5/mlx5_flow_tcf.c
@@ -532,11 +532,15 @@ struct flow_tcf_stats_basic {
 	},
 	.ipv4.hdr = {
 		.next_proto_id = 0xff,
+		.time_to_live = 0xff,
+		.type_of_service = 0xff,
 		.src_addr = RTE_BE32(0xffffffff),
 		.dst_addr = RTE_BE32(0xffffffff),
 	},
 	.ipv6.hdr = {
 		.proto = 0xff,
+		.vtc_flow = RTE_BE32(0xfful << IPV6_HDR_FL_SHIFT),
+		.hop_limits = 0xff,
 		.src_addr =
 			"\xff\xff\xff\xff\xff\xff\xff\xff"
 			"\xff\xff\xff\xff\xff\xff\xff\xff",
@@ -1589,8 +1593,9 @@ struct pedit_parser {
 			break;
 		break;
 		case RTE_FLOW_ITEM_TYPE_IPV4:
-			ret = mlx5_flow_validate_item_ipv4(items, item_flags,
-							   error);
+			ret = mlx5_flow_validate_item_ipv4
+					(items, item_flags,
+					 &flow_tcf_mask_supported.ipv4, error);
 			if (ret < 0)
 				return ret;
 			ret = flow_tcf_validate_vxlan_encap_ipv4(items, error);
@@ -1599,8 +1604,9 @@ struct pedit_parser {
 			item_flags |= MLX5_FLOW_LAYER_OUTER_L3_IPV4;
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
-			ret = mlx5_flow_validate_item_ipv6(items, item_flags,
-							   error);
+			ret = mlx5_flow_validate_item_ipv6
+					(items, item_flags,
+					 &flow_tcf_mask_supported.ipv6, error);
 			if (ret < 0)
 				return ret;
 			ret = flow_tcf_validate_vxlan_encap_ipv6(items, error);
@@ -2119,8 +2125,9 @@ struct pedit_parser {
 				vlan_etype = spec.vlan->inner_type;
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV4:
-			ret = mlx5_flow_validate_item_ipv4(items, item_flags,
-							   error);
+			ret = mlx5_flow_validate_item_ipv4
+					(items, item_flags,
+					 &flow_tcf_mask_supported.ipv4, error);
 			if (ret < 0)
 				return ret;
 			item_flags |= (item_flags & MLX5_FLOW_LAYER_TUNNEL) ?
@@ -2179,8 +2186,9 @@ struct pedit_parser {
 			}
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
-			ret = mlx5_flow_validate_item_ipv6(items, item_flags,
-							   error);
+			ret = mlx5_flow_validate_item_ipv6
+					(items, item_flags,
+					 &flow_tcf_mask_supported.ipv6, error);
 			if (ret < 0)
 				return ret;
 			item_flags |= (item_flags & MLX5_FLOW_LAYER_TUNNEL) ?
diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index 81ec59d..130cf68 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -1053,7 +1053,7 @@
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV4:
 			ret = mlx5_flow_validate_item_ipv4(items, item_flags,
-							   error);
+							   NULL, error);
 			if (ret < 0)
 				return ret;
 			last_item = tunnel ? MLX5_FLOW_LAYER_INNER_L3_IPV4 :
@@ -1074,7 +1074,7 @@
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			ret = mlx5_flow_validate_item_ipv6(items, item_flags,
-							   error);
+							   NULL, error);
 			if (ret < 0)
 				return ret;
 			last_item = tunnel ? MLX5_FLOW_LAYER_INNER_L3_IPV6 :
-- 
1.8.3.1

  parent reply	other threads:[~2018-12-29 18:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-29 18:51 [dpdk-dev] [PATCH 0/4] net/mlx5: add tos and ttl flower match and tunnel keys Viacheslav Ovsiienko
2018-12-29 18:51 ` [dpdk-dev] [PATCH 1/4] " Viacheslav Ovsiienko
2018-12-29 18:51 ` [dpdk-dev] [PATCH 2/4] net/mlx5: add tos and ttl fields support on E-Switch Viacheslav Ovsiienko
2018-12-29 18:51 ` Viacheslav Ovsiienko [this message]
2018-12-29 18:51 ` [dpdk-dev] [PATCH 4/4] app/testpmd: add tos and ttl field to vxlan encapsulation Viacheslav Ovsiienko
2019-01-13 14:15 ` [dpdk-dev] [PATCH v2 0/3] net/mlx5: add tos and ttl flower match and tunnel keys Viacheslav Ovsiienko
2019-01-13 14:15   ` [dpdk-dev] [PATCH v2 1/3] " Viacheslav Ovsiienko
2019-01-13 14:15   ` [dpdk-dev] [PATCH v2 2/3] net/mlx5: add tos and ttl fields support on E-Switch Viacheslav Ovsiienko
2019-01-13 14:15   ` [dpdk-dev] [PATCH v2 3/3] net/mlx5: add tos and ttl validation " Viacheslav Ovsiienko
2019-01-14  6:14   ` [dpdk-dev] [PATCH v2 0/3] net/mlx5: add tos and ttl flower match and tunnel keys Shahaf Shuler
2019-01-13 14:40 ` [dpdk-dev] [PATCH v2] app/testpmd: add tos and ttl field to vxlan encapsulation Viacheslav Ovsiienko
2019-01-14  6:04   ` Shahaf Shuler
2019-01-14 10:08     ` Iremonger, Bernard
2019-01-16  6:59       ` Ori Kam
2019-01-22 10:57   ` [dpdk-dev] [PATCH v3] " Viacheslav Ovsiienko
2019-01-23 19:45     ` Ori Kam
2019-02-07 12:08       ` 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=1546109501-24865-4-git-send-email-viacheslavo@mellanox.com \
    --to=viacheslavo@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=shahafs@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).