DPDK patches and discussions
 help / color / mirror / Atom feed
From: Eli Britstein <elibr@mellanox.com>
To: dev@dpdk.org
Cc: matan@mellanox.com, rasland@mellanox.com, orika@mellanox.com,
	viacheslavo@mellanox.com, Eli Britstein <elibr@mellanox.com>
Subject: [dpdk-dev] [PATCH 1/2] net/mlx5: introduce a helper to set IP version match
Date: Sun,  3 May 2020 10:04:46 +0000
Message-ID: <20200503100447.9869-2-elibr@mellanox.com> (raw)
In-Reply-To: <20200503100447.9869-1-elibr@mellanox.com>

Introduce a heler function to set the ip_version match.

Signed-off-by: Eli Britstein <elibr@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 38 ++++++++++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 18d9d302e3..174d86103b 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -5449,6 +5449,32 @@ flow_dv_check_valid_spec(void *match_mask, void *match_value)
 }
 #endif
 
+/**
+ * Add match of ip_version.
+ *
+ * @param[in] group
+ *   Flow group.
+ * @param[in] headers_v
+ *   Values header pointer.
+ * @param[in] headers_m
+ *   Masks header pointer.
+ * @param[in] ip_version
+ *   The IP version to set.
+ */
+static inline void
+flow_dv_set_match_ip_version(uint32_t group,
+			     void *headers_v,
+			     void *headers_m,
+			     uint8_t ip_version)
+{
+	if (group == 0)
+		MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_version, 0xf);
+	else
+		MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_version,
+			 ip_version);
+	MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_version, ip_version);
+}
+
 /**
  * Add Ethernet item to matcher and to the value.
  *
@@ -5635,11 +5661,7 @@ flow_dv_translate_item_ipv4(void *matcher, void *key,
 					 outer_headers);
 		headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers);
 	}
-	if (group == 0)
-		MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_version, 0xf);
-	else
-		MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_version, 0x4);
-	MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_version, 4);
+	flow_dv_set_match_ip_version(group, headers_v, headers_m, 4);
 	/*
 	 * On outer header (which must contains L2), or inner header with L2,
 	 * set cvlan_tag mask bit to mark this packet as untagged.
@@ -5737,11 +5759,7 @@ flow_dv_translate_item_ipv6(void *matcher, void *key,
 					 outer_headers);
 		headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers);
 	}
-	if (group == 0)
-		MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_version, 0xf);
-	else
-		MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_version, 0x6);
-	MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_version, 6);
+	flow_dv_set_match_ip_version(group, headers_v, headers_m, 6);
 	/*
 	 * On outer header (which must contains L2), or inner header with L2,
 	 * set cvlan_tag mask bit to mark this packet as untagged.
-- 
2.14.5


  reply	other threads:[~2020-05-03 10:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-03 10:04 [dpdk-dev] [PATCH 0/2] net/mlx5: optimize performance for IPv4/IPv6 Eli Britstein
2020-05-03 10:04 ` Eli Britstein [this message]
2020-05-03 10:04 ` [dpdk-dev] [PATCH 2/2] net/mlx5: optimize performance for IPv4/IPv6 ethertype Eli Britstein
2020-05-03 10:31   ` Matan Azrad

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=20200503100447.9869-2-elibr@mellanox.com \
    --to=elibr@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

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