DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dekel Peled <dekelp@mellanox.com>
To: matan@mellanox.com, viacheslavo@mellanox.com, rasland@mellanox.com
Cc: dev@dpdk.org, Eli Britstein <elibr@mellanox.com>
Subject: [dpdk-dev] [PATCH] net/mlx5: support match on IPv4 TTL and IPv6 HLIM
Date: Tue,  3 Mar 2020 14:37:31 +0200
Message-ID: <b819452e0d90fff4cc75bf0be667d9a13ba1754b.1583238749.git.dekelp@mellanox.com> (raw)

This patch adds to MLX5 PMD the support of matching on IPv4 TTL and
IPv6 hoplimit.
Support is valid when using DV flow engine (Verbs flow engine doesn't
support matching on this field).

Signed-off-by: Eli Britstein <elibr@mellanox.com>
Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 doc/guides/rel_notes/release_20_05.rst |  6 +++++
 drivers/common/mlx5/mlx5_prm.h         |  3 ++-
 drivers/net/mlx5/mlx5_flow_dv.c        | 40 +++++++++++++++++++++++++++++++---
 3 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/doc/guides/rel_notes/release_20_05.rst b/doc/guides/rel_notes/release_20_05.rst
index 2190eaf..000bbf5 100644
--- a/doc/guides/rel_notes/release_20_05.rst
+++ b/doc/guides/rel_notes/release_20_05.rst
@@ -56,6 +56,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Updated Mellanox mlx5 driver.**
+
+  Updated Mellanox mlx5 driver with new features and improvements, including:
+
+  * Added support for matching on IPv4 Time To Live and IPv6 Hop Limit.
+
 
 Removed Items
 -------------
diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index 4ac3d4b..eee3a4b 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -651,7 +651,8 @@ struct mlx5_ifc_fte_match_set_lyr_2_4_bits {
 	u8 tcp_flags[0x9];
 	u8 tcp_sport[0x10];
 	u8 tcp_dport[0x10];
-	u8 reserved_at_c0[0x20];
+	u8 reserved_at_c0[0x18];
+	u8 ip_ttl_hoplimit[0x8];
 	u8 udp_sport[0x10];
 	u8 udp_dport[0x10];
 	union mlx5_ifc_ipv6_layout_ipv4_layout_auto_bits src_ipv4_src_ipv6;
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 2414a97..e7278f0 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -4490,13 +4490,35 @@ struct field_modify_info modify_tcp[] = {
 	const struct rte_flow_action_raw_decap *decap;
 	const struct rte_flow_action_raw_encap *encap;
 	const struct rte_flow_action_rss *rss;
-	struct rte_flow_item_tcp nic_tcp_mask = {
+	const struct rte_flow_item_tcp nic_tcp_mask = {
 		.hdr = {
 			.tcp_flags = 0xFF,
 			.src_port = RTE_BE16(UINT16_MAX),
 			.dst_port = RTE_BE16(UINT16_MAX),
 		}
 	};
+	const struct rte_flow_item_ipv4 nic_ipv4_mask = {
+		.hdr = {
+			.src_addr = RTE_BE32(0xffffffff),
+			.dst_addr = RTE_BE32(0xffffffff),
+			.type_of_service = 0xff,
+			.next_proto_id = 0xff,
+			.time_to_live = 0xff,
+		},
+	};
+	const struct rte_flow_item_ipv6 nic_ipv6_mask = {
+		.hdr = {
+			.src_addr =
+			"\xff\xff\xff\xff\xff\xff\xff\xff"
+			"\xff\xff\xff\xff\xff\xff\xff\xff",
+			.dst_addr =
+			"\xff\xff\xff\xff\xff\xff\xff\xff"
+			"\xff\xff\xff\xff\xff\xff\xff\xff",
+			.vtc_flow = RTE_BE32(0xffffffff),
+			.proto = 0xff,
+			.hop_limits = 0xff,
+		},
+	};
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_dev_config *dev_conf = &priv->config;
 	uint16_t queue_index = 0xFFFF;
@@ -4563,7 +4585,8 @@ struct field_modify_info modify_tcp[] = {
 						  &item_flags, &tunnel);
 			ret = mlx5_flow_validate_item_ipv4(items, item_flags,
 							   last_item,
-							   ether_type, NULL,
+							   ether_type,
+							   &nic_ipv4_mask,
 							   error);
 			if (ret < 0)
 				return ret;
@@ -4588,7 +4611,8 @@ struct field_modify_info modify_tcp[] = {
 						  &item_flags, &tunnel);
 			ret = mlx5_flow_validate_item_ipv6(items, item_flags,
 							   last_item,
-							   ether_type, NULL,
+							   ether_type,
+							   &nic_ipv6_mask,
 							   error);
 			if (ret < 0)
 				return ret;
@@ -5421,6 +5445,7 @@ struct field_modify_info modify_tcp[] = {
 			.dst_addr = RTE_BE32(0xffffffff),
 			.type_of_service = 0xff,
 			.next_proto_id = 0xff,
+			.time_to_live = 0xff,
 		},
 	};
 	void *headers_m;
@@ -5470,6 +5495,10 @@ struct field_modify_info modify_tcp[] = {
 		 ipv4_m->hdr.next_proto_id);
 	MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol,
 		 ipv4_v->hdr.next_proto_id & ipv4_m->hdr.next_proto_id);
+	MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_ttl_hoplimit,
+		 ipv4_m->hdr.time_to_live);
+	MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ttl_hoplimit,
+		 ipv4_v->hdr.time_to_live & ipv4_m->hdr.time_to_live);
 	/*
 	 * On outer header (which must contains L2), or inner header with L2,
 	 * set cvlan_tag mask bit to mark this packet as untagged.
@@ -5583,6 +5612,11 @@ struct field_modify_info modify_tcp[] = {
 		 ipv6_m->hdr.proto);
 	MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol,
 		 ipv6_v->hdr.proto & ipv6_m->hdr.proto);
+	/* Hop limit. */
+	MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_ttl_hoplimit,
+		 ipv6_m->hdr.hop_limits);
+	MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ttl_hoplimit,
+		 ipv6_v->hdr.hop_limits & ipv6_m->hdr.hop_limits);
 	/*
 	 * On outer header (which must contains L2), or inner header with L2,
 	 * set cvlan_tag mask bit to mark this packet as untagged.
-- 
1.8.3.1


             reply	other threads:[~2020-03-03 12:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-03 12:37 Dekel Peled [this message]
2020-03-08 11:33 ` 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=b819452e0d90fff4cc75bf0be667d9a13ba1754b.1583238749.git.dekelp@mellanox.com \
    --to=dekelp@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=elibr@mellanox.com \
    --cc=matan@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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git