DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tal Shnaiderman <talshn@nvidia.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, matan@nvidia.com, rasland@nvidia.com,
	ophirmu@nvidia.com
Subject: [dpdk-dev] [PATCH 25/35] net/mlx5/windows: create flow matcher object
Date: Thu, 17 Dec 2020 19:30:27 +0200	[thread overview]
Message-ID: <20201217173037.11396-26-talshn@nvidia.com> (raw)
In-Reply-To: <20201217173037.11396-1-talshn@nvidia.com>

From: Ophir Munk <ophirmu@nvidia.com>

This commit implements the mlx5_flow_os_create_flow_matcher() API. It is
the Linux rdma-core equivalent implementation. Missing rdma-core
parameters (e.g. struct mlx5dv_flow_match_parameters) are added to file
mlx5_win_defs.h. The API allocates space to hold the PRM bits in PRM
fte_match_param format and copy the DV translated PRM bits into the
matcher struct. This matcher struct will be used later by the flow
creation API.

Signed-off-by: Ophir Munk <ophirmu@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/common/mlx5/windows/mlx5_win_defs.h | 57 +++++++++++++++++++++++++++++
 drivers/net/mlx5/windows/mlx5_flow_os.c     | 32 ++++++++++++----
 drivers/net/mlx5/windows/mlx5_flow_os.h     |  1 +
 3 files changed, 83 insertions(+), 7 deletions(-)

diff --git a/drivers/common/mlx5/windows/mlx5_win_defs.h b/drivers/common/mlx5/windows/mlx5_win_defs.h
index 27dcf40819..231c3220a3 100644
--- a/drivers/common/mlx5/windows/mlx5_win_defs.h
+++ b/drivers/common/mlx5/windows/mlx5_win_defs.h
@@ -132,6 +132,63 @@ enum {
 #define MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL	0x3
 #endif
 
+enum ibv_flow_flags {
+	IBV_FLOW_ATTR_FLAGS_ALLOW_LOOP_BACK = 1 << 0,
+	IBV_FLOW_ATTR_FLAGS_DONT_TRAP = 1 << 1,
+	IBV_FLOW_ATTR_FLAGS_EGRESS = 1 << 2,
+};
+
+enum ibv_flow_attr_type {
+	/* Steering according to rule specifications. */
+	IBV_FLOW_ATTR_NORMAL		= 0x0,
+	/*
+	 * Default unicast and multicast rule -
+	 * receive all Eth traffic which isn't steered to any QP.
+	 */
+	IBV_FLOW_ATTR_ALL_DEFAULT	= 0x1,
+	/*
+	 * Default multicast rule -
+	 * receive all Eth multicast traffic which isn't steered to any QP.
+	 */
+	IBV_FLOW_ATTR_MC_DEFAULT	= 0x2,
+	/* Sniffer rule - receive all port traffic. */
+	IBV_FLOW_ATTR_SNIFFER		= 0x3,
+};
+
+enum mlx5dv_flow_table_type {
+	MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_RX     = 0x0,
+	MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_TX	= 0x1,
+	MLX5_IB_UAPI_FLOW_TABLE_TYPE_FDB	= 0x2,
+	MLX5_IB_UAPI_FLOW_TABLE_TYPE_RDMA_RX	= 0x3,
+};
+
+#define MLX5DV_FLOW_TABLE_TYPE_NIC_RX	MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_RX
+#define MLX5DV_FLOW_TABLE_TYPE_NIC_TX	MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_TX
+#define MLX5DV_FLOW_TABLE_TYPE_FDB	MLX5_IB_UAPI_FLOW_TABLE_TYPE_FDB
+#define MLX5DV_FLOW_TABLE_TYPE_RDMA_RX	MLX5_IB_UAPI_FLOW_TABLE_TYPE_RDMA_RX
+
+struct mlx5dv_flow_match_parameters {
+	size_t match_sz;
+	uint64_t match_buf[]; /* Device spec format */
+};
+
+struct mlx5dv_flow_matcher_attr {
+	enum ibv_flow_attr_type type;
+	uint32_t flags; /* From enum ibv_flow_flags. */
+	uint16_t priority;
+	uint8_t match_criteria_enable; /* Device spec format. */
+	struct mlx5dv_flow_match_parameters *match_mask;
+	uint64_t comp_mask; /* Use mlx5dv_flow_matcher_attr_mask. */
+	enum mlx5dv_flow_table_type ft_type;
+};
+
+/* Windows specific mlx5_matcher. */
+struct mlx5_matcher {
+	void *ctx;
+	struct mlx5dv_flow_matcher_attr attr;
+	uint64_t match_buf[];
+};
+
 struct mlx5_err_cqe {
 	uint8_t		rsvd0[32];
 	uint32_t	srqn;
diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c b/drivers/net/mlx5/windows/mlx5_flow_os.c
index 8c504fc69c..0ade518910 100644
--- a/drivers/net/mlx5/windows/mlx5_flow_os.c
+++ b/drivers/net/mlx5/windows/mlx5_flow_os.c
@@ -76,12 +76,31 @@ mlx5_flow_os_create_flow_matcher(void *ctx,
 				 void *table,
 				 void **matcher)
 {
-	RTE_SET_USED(ctx);
-	RTE_SET_USED(attr);
+	struct mlx5dv_flow_matcher_attr *mattr;
+
 	RTE_SET_USED(table);
 	*matcher = NULL;
-	rte_errno = ENOTSUP;
-	return -rte_errno;
+	mattr = attr;
+	if (mattr->type != IBV_FLOW_ATTR_NORMAL) {
+		rte_errno = ENOTSUP;
+		return -rte_errno;
+	}
+	struct mlx5_matcher *mlx5_matcher =
+		mlx5_malloc(MLX5_MEM_ZERO,
+		       sizeof(struct mlx5_matcher) +
+		       MLX5_ST_SZ_BYTES(fte_match_param),
+		       0, SOCKET_ID_ANY);
+	if (!mlx5_matcher) {
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
+	mlx5_matcher->ctx = ctx;
+	memcpy(&mlx5_matcher->attr, attr, sizeof(mlx5_matcher->attr));
+	memcpy(&mlx5_matcher->match_buf,
+	       mattr->match_mask->match_buf,
+	       MLX5_ST_SZ_BYTES(fte_match_param));
+	*matcher = mlx5_matcher;
+	return 0;
 }
 
 /**
@@ -96,9 +115,8 @@ mlx5_flow_os_create_flow_matcher(void *ctx,
 int
 mlx5_flow_os_destroy_flow_matcher(void *matcher)
 {
-	RTE_SET_USED(matcher);
-	rte_errno = ENOTSUP;
-	return -rte_errno;
+	mlx5_free(matcher);
+	return 0;
 }
 
 /**
diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.h b/drivers/net/mlx5/windows/mlx5_flow_os.h
index 1e762c17dc..50185669cf 100644
--- a/drivers/net/mlx5/windows/mlx5_flow_os.h
+++ b/drivers/net/mlx5/windows/mlx5_flow_os.h
@@ -6,6 +6,7 @@
 #define RTE_PMD_MLX5_FLOW_OS_H_
 
 #include "mlx5_flow.h"
+#include "mlx5_malloc.h"
 
 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
 extern const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops;
-- 
2.16.1.windows.4


  parent reply	other threads:[~2020-12-17 17:41 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17 17:30 [dpdk-dev] [PATCH 00/35] mlx5 Windows support - part #6 Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 01/35] common/mlx5/windows: add missing DV and IBV definitions Tal Shnaiderman
2020-12-28 12:32   ` [dpdk-dev] [PATCH v2 00/35] mlx5 Windows support - part #6 Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 01/35] common/mlx5/windows: add missing DV and IBV definitions Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 02/35] mlx5/windows: add mlx5 macros for fs name and path Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 03/35] common/mlx5: add rte compatibility header file Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 04/35] common/mlx5/windows: add DevX UAR getters Tal Shnaiderman
2021-01-08 12:08       ` Ferruh Yigit
2021-01-08 16:08         ` Ophir Munk
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 05/35] common/mlx5/windows: wrap event channel APIs with OS calls Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 06/35] net/mlx5/windows: add memory region callbacks Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 07/35] net/mlx5/windows: add stubs for MP requests Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 08/35] net/mlx5/windows: support get mac Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 09/35] net/mlx5/windows: add ethdev stub operations Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 10/35] net/mlx5/windows: support link update Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 11/35] net/mlx5/windows: support read clock Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 12/35] net/mlx5/windows: support get mtu Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 13/35] net/mlx5/windows: support get interface name Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 14/35] net/mlx5/windows: support device removed query Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 15/35] net/mlx5/windws: add VLAN stubs Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 16/35] net/mlx5/windows: support get pdn Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 17/35] net/mlx5/windows: support open device Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 18/35] net/mlx5/windows: initial probing implementation Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 19/35] net/mlx5/windws: spawn eth devices Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 20/35] net/mlx5/windows: support VF PCI address Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 21/35] net/mlx5/linux: wrap adjust flow priority with OS calls Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 22/35] net/mlx5/linux: add OS default miss flow action Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 23/35] net/mlx5/linux: fix add OS dest_devx_tir action Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 24/35] net/mlx5/windows: introduce flow support Tal Shnaiderman
2021-01-08 14:38       ` Ferruh Yigit
2021-01-08 14:55         ` Thomas Monjalon
2021-01-08 16:15           ` Ophir Munk
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 25/35] net/mlx5/windows: create flow matcher object Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 26/35] net/mlx5/windows: create flow action dest TIR object Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 27/35] net/mlx5/windows: create flow rule Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 28/35] net/mlx5: use HAVE_INFINIBAND_VERBS_H in shared code Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 29/35] net/mlx5: fix separating eth_dev_ops per OS Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 30/35] net/mlx5: define MLX5_NAMESIZE for device interface size Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 31/35] net/mlx5: use OS independent code in ASO feature Tal Shnaiderman
2020-12-28 12:32     ` [dpdk-dev] [PATCH v2 32/35] mlx5: use init function for ctx list mutex Tal Shnaiderman
2020-12-28 12:33     ` [dpdk-dev] [PATCH v2 33/35] mlx5: use OS function for dr_sync_domain Tal Shnaiderman
2020-12-28 12:33     ` [dpdk-dev] [PATCH v2 34/35] mlx5: do not fail on IPv6 broadcast flow creation failure Tal Shnaiderman
2020-12-28 12:33     ` [dpdk-dev] [PATCH v2 35/35] net/mlx5: fix warnings on comparison sign mismatch Tal Shnaiderman
2021-01-03  2:05     ` [dpdk-dev] [PATCH v2 00/35] mlx5 Windows support - part #6 Raslan Darawsheh
2020-12-17 17:30 ` [dpdk-dev] [PATCH 02/35] mlx5/windows: add mlx5 macros for fs name and path Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 03/35] common/mlx5: add rte compatibility header file Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 04/35] common/mlx5/windows: add DevX UAR getters Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 05/35] common/mlx5/windows: wrap event channel APIs with OS calls Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 06/35] net/mlx5/windows: add memory region callbacks Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 07/35] net/mlx5/windows: add stubs for MP requests Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 08/35] net/mlx5/windows: support get mac Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 09/35] net/mlx5/windows: add ethdev stub operations Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 10/35] net/mlx5/windows: support link update Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 11/35] net/mlx5/windows: support read clock Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 12/35] net/mlx5/windows: support get mtu Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 13/35] net/mlx5/windows: support get interface name Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 14/35] net/mlx5/windows: support device removed query Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 15/35] net/mlx5/windws: add VLAN stubs Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 16/35] net/mlx5/windows: support get pdn Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 17/35] net/mlx5/windows: support open device Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 18/35] net/mlx5/windows: initial probing implementation Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 19/35] net/mlx5/windws: spawn eth devices Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 20/35] net/mlx5/windows: support VF PCI address Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 21/35] net/mlx5/linux: wrap adjust flow priority with OS calls Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 22/35] net/mlx5/linux: add OS default miss flow action Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 23/35] net/mlx5/linux: fix add OS dest_devx_tir action Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 24/35] net/mlx5/windows: introduce flow support Tal Shnaiderman
2020-12-17 17:30 ` Tal Shnaiderman [this message]
2020-12-17 17:30 ` [dpdk-dev] [PATCH 26/35] net/mlx5/windows: create flow action dest TIR object Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 27/35] net/mlx5/windows: create flow rule Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 28/35] net/mlx5: use HAVE_INFINIBAND_VERBS_H in shared code Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 29/35] net/mlx5: fix separating eth_dev_ops per OS Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 30/35] net/mlx5: define MLX5_NAMESIZE for device interface size Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 31/35] net/mlx5: use OS independent code in ASO feature Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 32/35] mlx5: use init function for ctx list mutex Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 33/35] mlx5: use OS function for dr_sync_domain Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 34/35] mlx5: do not fail on IPv6 broadcast flow creation failure Tal Shnaiderman
2020-12-17 17:30 ` [dpdk-dev] [PATCH 35/35] net/mlx5: fix warnings on comparison sign mismatch Tal Shnaiderman

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=20201217173037.11396-26-talshn@nvidia.com \
    --to=talshn@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=ophirmu@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=thomas@monjalon.net \
    /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).