DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] common/mlx5: add glue function for duplicate rule ability
@ 2021-05-28 13:25 Jiawei Wang
  2021-05-28 13:25 ` [dpdk-dev] [PATCH 2/2] net/mlx5: control rules with identical pattern behavior Jiawei Wang
  2021-07-06  8:12 ` [dpdk-dev] [PATCH v2 0/2] " Jiawei Wang
  0 siblings, 2 replies; 6+ messages in thread
From: Jiawei Wang @ 2021-05-28 13:25 UTC (permalink / raw)
  To: matan, viacheslavo, orika, thomas, Shahaf Shuler; +Cc: dev, rasland

Add glue function to update the duplicate rule allow/disallow
through rdma-core DV API.

Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
---
 drivers/common/mlx5/linux/meson.build |  2 ++
 drivers/common/mlx5/linux/mlx5_glue.c | 12 ++++++++++++
 drivers/common/mlx5/linux/mlx5_glue.h |  1 +
 3 files changed, 15 insertions(+)

diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index 007834a49b..c0bfab1f33 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build
@@ -191,6 +191,8 @@ has_sym_args = [
             'mlx5dv_dump_dr_rule' ],
         [ 'HAVE_MLX5_DR_ACTION_ASO_CT', 'infiniband/mlx5dv.h',
             'MLX5DV_DR_ACTION_FLAGS_ASO_CT_DIRECTION_INITIATOR' ],
+    	[ 'HAVE_MLX5_DR_ALLOW_DUPLICATE', 'infiniband/mlx5dv.h',
+    	'mlx5dv_dr_domain_allow_duplicate_rules' ],
 ]
 config = configuration_data()
 foreach arg:has_sym_args
diff --git a/drivers/common/mlx5/linux/mlx5_glue.c b/drivers/common/mlx5/linux/mlx5_glue.c
index d3bd645a5b..145cf83fd9 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.c
+++ b/drivers/common/mlx5/linux/mlx5_glue.c
@@ -1321,6 +1321,17 @@ mlx5_glue_dv_alloc_pp(struct ibv_context *context,
 #endif
 }
 
+static void
+mlx5_glue_dr_allow_duplicate_rules(void *domain, uint32_t allow)
+{
+#ifdef HAVE_MLX5_DR_ALLOW_DUPLICATE
+	mlx5dv_dr_domain_allow_duplicate_rules(domain, allow);
+#else
+	(void)(allow);
+	(void)(domain);
+#endif
+}
+
 static void
 mlx5_glue_dv_free_pp(struct mlx5dv_pp *pp)
 {
@@ -1441,6 +1452,7 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
 		mlx5_glue_dr_create_flow_action_sampler,
 	.dr_create_flow_action_dest_array =
 		mlx5_glue_dr_action_create_dest_array,
+	.dr_allow_duplicate_rules = mlx5_glue_dr_allow_duplicate_rules,
 	.devx_query_eqn = mlx5_glue_devx_query_eqn,
 	.devx_create_event_channel = mlx5_glue_devx_create_event_channel,
 	.devx_destroy_event_channel = mlx5_glue_devx_destroy_event_channel,
diff --git a/drivers/common/mlx5/linux/mlx5_glue.h b/drivers/common/mlx5/linux/mlx5_glue.h
index 97462e9ab8..56246bca18 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.h
+++ b/drivers/common/mlx5/linux/mlx5_glue.h
@@ -336,6 +336,7 @@ struct mlx5_glue {
 			 struct mlx5dv_devx_async_event_hdr *event_data,
 			 size_t event_resp_len);
 	void (*dr_reclaim_domain_memory)(void *domain, uint32_t enable);
+	void (*dr_allow_duplicate_rules)(void *domain, uint32_t allow);
 	struct mlx5dv_pp *(*dv_alloc_pp)(struct ibv_context *context,
 					 size_t pp_context_sz,
 					 const void *pp_context,
-- 
2.18.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH 2/2] net/mlx5: control rules with identical pattern behavior
  2021-05-28 13:25 [dpdk-dev] [PATCH 1/2] common/mlx5: add glue function for duplicate rule ability Jiawei Wang
@ 2021-05-28 13:25 ` Jiawei Wang
  2021-07-06  8:12 ` [dpdk-dev] [PATCH v2 0/2] " Jiawei Wang
  1 sibling, 0 replies; 6+ messages in thread
From: Jiawei Wang @ 2021-05-28 13:25 UTC (permalink / raw)
  To: matan, viacheslavo, orika, thomas, Shahaf Shuler; +Cc: dev, rasland

In order to allow\disallow configuring rules with identical
patterns, the new device argument 'allow_duplicate_pattern'
is introduced.
If allow, these rules be inserted successfully and only the
first rule take affect.
If disallow, the first rule will be inserted and other rules
be rejected.

The default is to allow.
Set it to 0 if disallow, for example:
	-a <PCI_BDF>,allow_duplicate_pattern=0

Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
---
 doc/guides/nics/mlx5.rst               | 10 ++++++++++
 doc/guides/rel_notes/release_21_08.rst |  6 ++++++
 drivers/net/mlx5/linux/mlx5_os.c       |  7 +++++++
 drivers/net/mlx5/mlx5.c                |  6 ++++++
 drivers/net/mlx5/mlx5.h                |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c        |  3 +++
 6 files changed, 34 insertions(+)

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index 83299646dd..26f4a25441 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -1058,6 +1058,16 @@ Driver options
 
   By default, the PMD will set this value to 1.
 
+- ``allow_duplicate_pattern`` parameter [int]
+
+  There are two options to choose:
+
+  - 0. Prevent insertion of rules with the same pattern items on non-root table.
+
+  - 1. Allow insertion of rules with the same pattern items.
+
+  By default, the PMD will set this value to 1.
+
 .. _mlx5_firmware_config:
 
 Firmware configuration
diff --git a/doc/guides/rel_notes/release_21_08.rst b/doc/guides/rel_notes/release_21_08.rst
index a6ecfdf3ce..e6f696a71d 100644
--- a/doc/guides/rel_notes/release_21_08.rst
+++ b/doc/guides/rel_notes/release_21_08.rst
@@ -55,6 +55,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Mellanox mlx5 net driver and common layer.**
+
+  Updated Mellanox mlx5 driver with new features and improvements, including:
+
+  * Added devargs options ``allow_duplicate_pattern``.
+
 
 Removed Items
 -------------
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 534a56a555..7c4384ca77 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -355,6 +355,12 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
 			mlx5_glue->dr_reclaim_domain_memory(sh->fdb_domain, 1);
 	}
 	sh->pop_vlan_action = mlx5_glue->dr_create_flow_action_pop_vlan();
+	if (!priv->config.allow_duplicate_pattern) {
+		mlx5_glue->dr_allow_duplicate_rules(sh->rx_domain, 0);
+		mlx5_glue->dr_allow_duplicate_rules(sh->tx_domain, 0);
+		if (sh->fdb_domain)
+			mlx5_glue->dr_allow_duplicate_rules(sh->fdb_domain, 0);
+	}
 #endif /* HAVE_MLX5DV_DR */
 	sh->default_miss_action =
 			mlx5_glue->dr_create_flow_action_default_miss();
@@ -2359,6 +2365,7 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev,
 		dev_config.dv_flow_en = 1;
 		dev_config.decap_en = 1;
 		dev_config.log_hp_size = MLX5_ARG_UNSET;
+		dev_config.allow_duplicate_pattern = 1;
 		list[i].eth_dev = mlx5_dev_spawn(&pci_dev->device,
 						 &list[i],
 						 &dev_config,
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index cf1815cb74..ef15b115d8 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -175,6 +175,9 @@
 /* Decap will be used or not. */
 #define MLX5_DECAP_EN "decap_en"
 
+/* Device parameter to configure allow or prevent duplicate rules pattern. */
+#define MLX5_ALLOW_DUPLICATE_PATTERN "allow_duplicate_pattern"
+
 /* Shared memory between primary and secondary processes. */
 struct mlx5_shared_data *mlx5_shared_data;
 
@@ -1948,6 +1951,8 @@ mlx5_args_check(const char *key, const char *val, void *opaque)
 		config->sys_mem_en = !!tmp;
 	} else if (strcmp(MLX5_DECAP_EN, key) == 0) {
 		config->decap_en = !!tmp;
+	} else if (strcmp(MLX5_ALLOW_DUPLICATE_PATTERN, key) == 0) {
+		config->allow_duplicate_pattern = !!tmp;
 	} else {
 		DRV_LOG(WARNING, "%s: unknown parameter", key);
 		rte_errno = EINVAL;
@@ -2007,6 +2012,7 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs)
 		MLX5_RECLAIM_MEM,
 		MLX5_SYS_MEM_EN,
 		MLX5_DECAP_EN,
+		MLX5_ALLOW_DUPLICATE_PATTERN,
 		NULL,
 	};
 	struct rte_kvargs *kvlist;
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 32b2817bf2..63e7779d6f 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -244,6 +244,8 @@ struct mlx5_dev_config {
 	unsigned int sys_mem_en:1; /* The default memory allocator. */
 	unsigned int decap_en:1; /* Whether decap will be used or not. */
 	unsigned int dv_miss_info:1; /* restore packet after partial hw miss */
+	unsigned int allow_duplicate_pattern:1;
+	/* Allow/Prevent the duplicate rules pattern. */
 	struct {
 		unsigned int enabled:1; /* Whether MPRQ is enabled. */
 		unsigned int stride_num_n; /* Number of strides. */
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index c50649a107..17d5a942d8 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -13299,6 +13299,9 @@ flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow,
 					   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
 					   NULL,
 					   "hardware refuses to create flow");
+			if (!priv->config.allow_duplicate_pattern &&
+			     errno == EEXIST)
+				DRV_LOG(INFO, "duplicate rules not supported");
 			goto error;
 		}
 		if (priv->vmwa_context &&
-- 
2.18.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v2 0/2] control rules with identical pattern behavior
  2021-05-28 13:25 [dpdk-dev] [PATCH 1/2] common/mlx5: add glue function for duplicate rule ability Jiawei Wang
  2021-05-28 13:25 ` [dpdk-dev] [PATCH 2/2] net/mlx5: control rules with identical pattern behavior Jiawei Wang
@ 2021-07-06  8:12 ` Jiawei Wang
  2021-07-06  8:12   ` [dpdk-dev] [PATCH v2 1/2] common/mlx5: add glue function for duplicate rule ability Jiawei Wang
                     ` (2 more replies)
  1 sibling, 3 replies; 6+ messages in thread
From: Jiawei Wang @ 2021-07-06  8:12 UTC (permalink / raw)
  To: matan, orika, viacheslavo, thomas; +Cc: dev, rasland

In order to allow\disallow configuring rules with identical
patterns, the new device argument 'allow_duplicate_pattern'
is introduced.
If allow, these rules be inserted successfully and only the
first rule take affect.
If disallow, the first rule will be inserted and other rules
be rejected.

The default is to allow.
Set it to 0 if disallow, for example:
	-a <PCI_BDF>,allow_duplicate_pattern=0

Jiawei Wang (2):
  common/mlx5: add glue function for duplicate rule ability
  net/mlx5: control rules with identical pattern behavior

 doc/guides/nics/mlx5.rst               | 14 ++++++++++++++
 doc/guides/rel_notes/release_21_08.rst |  6 ++++++
 drivers/common/mlx5/linux/meson.build  |  2 ++
 drivers/common/mlx5/linux/mlx5_glue.c  | 12 ++++++++++++
 drivers/common/mlx5/linux/mlx5_glue.h  |  1 +
 drivers/net/mlx5/linux/mlx5_os.c       | 10 ++++++++++
 drivers/net/mlx5/mlx5.c                |  6 ++++++
 drivers/net/mlx5/mlx5.h                |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c        | 12 ++++++++----
 9 files changed, 61 insertions(+), 4 deletions(-)

-- 
2.18.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v2 1/2] common/mlx5: add glue function for duplicate rule ability
  2021-07-06  8:12 ` [dpdk-dev] [PATCH v2 0/2] " Jiawei Wang
@ 2021-07-06  8:12   ` Jiawei Wang
  2021-07-06  8:12   ` [dpdk-dev] [PATCH v2 2/2] net/mlx5: control rules with identical pattern behavior Jiawei Wang
  2021-07-07 16:55   ` [dpdk-dev] [PATCH v2 0/2] " Raslan Darawsheh
  2 siblings, 0 replies; 6+ messages in thread
From: Jiawei Wang @ 2021-07-06  8:12 UTC (permalink / raw)
  To: matan, orika, viacheslavo, thomas, Shahaf Shuler; +Cc: dev, rasland

Add glue function to update the duplicate rule allow/disallow
through rdma-core DV API.

Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/common/mlx5/linux/meson.build |  2 ++
 drivers/common/mlx5/linux/mlx5_glue.c | 12 ++++++++++++
 drivers/common/mlx5/linux/mlx5_glue.h |  1 +
 3 files changed, 15 insertions(+)

diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index 5cea1b44d7..d3e95f83bb 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build
@@ -195,6 +195,8 @@ has_sym_args = [
             'mlx5dv_dump_dr_rule' ],
         [ 'HAVE_MLX5_DR_ACTION_ASO_CT', 'infiniband/mlx5dv.h',
             'MLX5DV_DR_ACTION_FLAGS_ASO_CT_DIRECTION_INITIATOR' ],
+        [ 'HAVE_MLX5_DR_ALLOW_DUPLICATE', 'infiniband/mlx5dv.h',
+        'mlx5dv_dr_domain_allow_duplicate_rules' ],
 ]
 config = configuration_data()
 foreach arg:has_sym_args
diff --git a/drivers/common/mlx5/linux/mlx5_glue.c b/drivers/common/mlx5/linux/mlx5_glue.c
index 00be8114be..037ca961a0 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.c
+++ b/drivers/common/mlx5/linux/mlx5_glue.c
@@ -1358,6 +1358,17 @@ mlx5_glue_dv_alloc_pp(struct ibv_context *context,
 #endif
 }
 
+static void
+mlx5_glue_dr_allow_duplicate_rules(void *domain, uint32_t allow)
+{
+#ifdef HAVE_MLX5_DR_ALLOW_DUPLICATE
+	mlx5dv_dr_domain_allow_duplicate_rules(domain, allow);
+#else
+	(void)(allow);
+	(void)(domain);
+#endif
+}
+
 static void
 mlx5_glue_dv_free_pp(struct mlx5dv_pp *pp)
 {
@@ -1478,6 +1489,7 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
 		mlx5_glue_dr_create_flow_action_sampler,
 	.dr_create_flow_action_dest_array =
 		mlx5_glue_dr_action_create_dest_array,
+	.dr_allow_duplicate_rules = mlx5_glue_dr_allow_duplicate_rules,
 	.devx_query_eqn = mlx5_glue_devx_query_eqn,
 	.devx_create_event_channel = mlx5_glue_devx_create_event_channel,
 	.devx_destroy_event_channel = mlx5_glue_devx_destroy_event_channel,
diff --git a/drivers/common/mlx5/linux/mlx5_glue.h b/drivers/common/mlx5/linux/mlx5_glue.h
index 840d8cf57f..61f40d5478 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.h
+++ b/drivers/common/mlx5/linux/mlx5_glue.h
@@ -350,6 +350,7 @@ struct mlx5_glue {
 			 struct mlx5dv_devx_async_event_hdr *event_data,
 			 size_t event_resp_len);
 	void (*dr_reclaim_domain_memory)(void *domain, uint32_t enable);
+	void (*dr_allow_duplicate_rules)(void *domain, uint32_t allow);
 	struct mlx5dv_pp *(*dv_alloc_pp)(struct ibv_context *context,
 					 size_t pp_context_sz,
 					 const void *pp_context,
-- 
2.18.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v2 2/2] net/mlx5: control rules with identical pattern behavior
  2021-07-06  8:12 ` [dpdk-dev] [PATCH v2 0/2] " Jiawei Wang
  2021-07-06  8:12   ` [dpdk-dev] [PATCH v2 1/2] common/mlx5: add glue function for duplicate rule ability Jiawei Wang
@ 2021-07-06  8:12   ` Jiawei Wang
  2021-07-07 16:55   ` [dpdk-dev] [PATCH v2 0/2] " Raslan Darawsheh
  2 siblings, 0 replies; 6+ messages in thread
From: Jiawei Wang @ 2021-07-06  8:12 UTC (permalink / raw)
  To: matan, orika, viacheslavo, thomas, Shahaf Shuler; +Cc: dev, rasland

In order to allow\disallow configuring rules with identical
patterns, the new device argument 'allow_duplicate_pattern'
is introduced.
If allow, these rules be inserted successfully and only the
first rule take affect.
If disallow, the first rule will be inserted and other rules
be rejected.

The default is to allow.
Set it to 0 if disallow, for example:
	-a <PCI_BDF>,allow_duplicate_pattern=0

Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 doc/guides/nics/mlx5.rst               | 14 ++++++++++++++
 doc/guides/rel_notes/release_21_08.rst |  6 ++++++
 drivers/net/mlx5/linux/mlx5_os.c       | 10 ++++++++++
 drivers/net/mlx5/mlx5.c                |  6 ++++++
 drivers/net/mlx5/mlx5.h                |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c        | 12 ++++++++----
 6 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index eb44a070b1..233834958b 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -1061,6 +1061,20 @@ Driver options
 
   By default, the PMD will set this value to 1.
 
+- ``allow_duplicate_pattern`` parameter [int]
+
+  There are two options to choose:
+
+  - 0. Prevent insertion of rules with the same pattern items on non-root table.
+    In this case, only the first rule be inserted and the following rules be
+    rejected and error code EEXIST be returned.
+
+  - 1. Allow insertion of rules with the same pattern items.
+    In this case, all rules be inserted but only the first rule will take
+    affect, this rule will take affect only if the previous rules be deleted.
+
+  By default, the PMD will set this value to 1.
+
 .. _mlx5_firmware_config:
 
 Firmware configuration
diff --git a/doc/guides/rel_notes/release_21_08.rst b/doc/guides/rel_notes/release_21_08.rst
index a6ecfdf3ce..299fdbbe93 100644
--- a/doc/guides/rel_notes/release_21_08.rst
+++ b/doc/guides/rel_notes/release_21_08.rst
@@ -55,6 +55,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Mellanox mlx5 driver.**
+
+  Updated the Mellanox mlx5 driver with new features and improvements, including:
+
+  * Added devargs options ``allow_duplicate_pattern``.
+
 
 Removed Items
 -------------
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 92b3009786..06f5233da1 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -355,6 +355,15 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
 			mlx5_glue->dr_reclaim_domain_memory(sh->fdb_domain, 1);
 	}
 	sh->pop_vlan_action = mlx5_glue->dr_create_flow_action_pop_vlan();
+	if (!priv->config.allow_duplicate_pattern) {
+#ifndef HAVE_MLX5_DR_ALLOW_DUPLICATE
+		DRV_LOG(WARNING, "Disallow duplicate pattern is not supported - maybe old rdma-core version?");
+#endif
+		mlx5_glue->dr_allow_duplicate_rules(sh->rx_domain, 0);
+		mlx5_glue->dr_allow_duplicate_rules(sh->tx_domain, 0);
+		if (sh->fdb_domain)
+			mlx5_glue->dr_allow_duplicate_rules(sh->fdb_domain, 0);
+	}
 #endif /* HAVE_MLX5DV_DR */
 	sh->default_miss_action =
 			mlx5_glue->dr_create_flow_action_default_miss();
@@ -2363,6 +2372,7 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev,
 		dev_config.dv_flow_en = 1;
 		dev_config.decap_en = 1;
 		dev_config.log_hp_size = MLX5_ARG_UNSET;
+		dev_config.allow_duplicate_pattern = 1;
 		list[i].eth_dev = mlx5_dev_spawn(&pci_dev->device,
 						 &list[i],
 						 &dev_config,
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index cf1815cb74..ef15b115d8 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -175,6 +175,9 @@
 /* Decap will be used or not. */
 #define MLX5_DECAP_EN "decap_en"
 
+/* Device parameter to configure allow or prevent duplicate rules pattern. */
+#define MLX5_ALLOW_DUPLICATE_PATTERN "allow_duplicate_pattern"
+
 /* Shared memory between primary and secondary processes. */
 struct mlx5_shared_data *mlx5_shared_data;
 
@@ -1948,6 +1951,8 @@ mlx5_args_check(const char *key, const char *val, void *opaque)
 		config->sys_mem_en = !!tmp;
 	} else if (strcmp(MLX5_DECAP_EN, key) == 0) {
 		config->decap_en = !!tmp;
+	} else if (strcmp(MLX5_ALLOW_DUPLICATE_PATTERN, key) == 0) {
+		config->allow_duplicate_pattern = !!tmp;
 	} else {
 		DRV_LOG(WARNING, "%s: unknown parameter", key);
 		rte_errno = EINVAL;
@@ -2007,6 +2012,7 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs)
 		MLX5_RECLAIM_MEM,
 		MLX5_SYS_MEM_EN,
 		MLX5_DECAP_EN,
+		MLX5_ALLOW_DUPLICATE_PATTERN,
 		NULL,
 	};
 	struct rte_kvargs *kvlist;
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 1b2dc8f815..b0f36eb668 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -244,6 +244,8 @@ struct mlx5_dev_config {
 	unsigned int sys_mem_en:1; /* The default memory allocator. */
 	unsigned int decap_en:1; /* Whether decap will be used or not. */
 	unsigned int dv_miss_info:1; /* restore packet after partial hw miss */
+	unsigned int allow_duplicate_pattern:1;
+	/* Allow/Prevent the duplicate rules pattern. */
 	struct {
 		unsigned int enabled:1; /* Whether MPRQ is enabled. */
 		unsigned int stride_num_n; /* Number of strides. */
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index a04a3c2bb8..30b347c671 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -13309,10 +13309,14 @@ flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow,
 					       (void *)&dv->value, n,
 					       dv->actions, &dh->drv_flow);
 		if (err) {
-			rte_flow_error_set(error, errno,
-					   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-					   NULL,
-					   "hardware refuses to create flow");
+			rte_flow_error_set
+				(error, errno,
+				RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				NULL,
+				(!priv->config.allow_duplicate_pattern &&
+				errno == EEXIST) ?
+				"duplicating pattern is not allowed" :
+				"hardware refuses to create flow");
 			goto error;
 		}
 		if (priv->vmwa_context &&
-- 
2.18.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/2] control rules with identical pattern behavior
  2021-07-06  8:12 ` [dpdk-dev] [PATCH v2 0/2] " Jiawei Wang
  2021-07-06  8:12   ` [dpdk-dev] [PATCH v2 1/2] common/mlx5: add glue function for duplicate rule ability Jiawei Wang
  2021-07-06  8:12   ` [dpdk-dev] [PATCH v2 2/2] net/mlx5: control rules with identical pattern behavior Jiawei Wang
@ 2021-07-07 16:55   ` Raslan Darawsheh
  2 siblings, 0 replies; 6+ messages in thread
From: Raslan Darawsheh @ 2021-07-07 16:55 UTC (permalink / raw)
  To: Jiawei(Jonny) Wang, Matan Azrad, Ori Kam, Slava Ovsiienko,
	NBU-Contact-Thomas Monjalon
  Cc: dev

Hi,

> -----Original Message-----
> From: Jiawei(Jonny) Wang <jiaweiw@nvidia.com>
> Sent: Tuesday, July 6, 2021 11:12 AM
> To: Matan Azrad <matan@nvidia.com>; Ori Kam <orika@nvidia.com>; Slava
> Ovsiienko <viacheslavo@nvidia.com>; NBU-Contact-Thomas Monjalon
> <thomas@monjalon.net>
> Cc: dev@dpdk.org; Raslan Darawsheh <rasland@nvidia.com>
> Subject: [PATCH v2 0/2] control rules with identical pattern behavior
> 
> In order to allow\disallow configuring rules with identical
> patterns, the new device argument 'allow_duplicate_pattern'
> is introduced.
> If allow, these rules be inserted successfully and only the
> first rule take affect.
> If disallow, the first rule will be inserted and other rules
> be rejected.
> 
> The default is to allow.
> Set it to 0 if disallow, for example:
> 	-a <PCI_BDF>,allow_duplicate_pattern=0
> 
> Jiawei Wang (2):
>   common/mlx5: add glue function for duplicate rule ability
>   net/mlx5: control rules with identical pattern behavior
> 
>  doc/guides/nics/mlx5.rst               | 14 ++++++++++++++
>  doc/guides/rel_notes/release_21_08.rst |  6 ++++++
>  drivers/common/mlx5/linux/meson.build  |  2 ++
>  drivers/common/mlx5/linux/mlx5_glue.c  | 12 ++++++++++++
>  drivers/common/mlx5/linux/mlx5_glue.h  |  1 +
>  drivers/net/mlx5/linux/mlx5_os.c       | 10 ++++++++++
>  drivers/net/mlx5/mlx5.c                |  6 ++++++
>  drivers/net/mlx5/mlx5.h                |  2 ++
>  drivers/net/mlx5/mlx5_flow_dv.c        | 12 ++++++++----
>  9 files changed, 61 insertions(+), 4 deletions(-)
> 
> --
> 2.18.1

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-07 16:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28 13:25 [dpdk-dev] [PATCH 1/2] common/mlx5: add glue function for duplicate rule ability Jiawei Wang
2021-05-28 13:25 ` [dpdk-dev] [PATCH 2/2] net/mlx5: control rules with identical pattern behavior Jiawei Wang
2021-07-06  8:12 ` [dpdk-dev] [PATCH v2 0/2] " Jiawei Wang
2021-07-06  8:12   ` [dpdk-dev] [PATCH v2 1/2] common/mlx5: add glue function for duplicate rule ability Jiawei Wang
2021-07-06  8:12   ` [dpdk-dev] [PATCH v2 2/2] net/mlx5: control rules with identical pattern behavior Jiawei Wang
2021-07-07 16:55   ` [dpdk-dev] [PATCH v2 0/2] " Raslan Darawsheh

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).