Skip to contentSkip to conversation

regex/mlx5: pmd improvements

PATCH Superseded Ori Kam 2 participants 12 messages Dec 17, 2020 – Jan 19, 2021

lore
Share & tools
lore

Ori Kam

author
#0 lore raw

cover regex/mlx5: pmd improvements

This series adds a few fixes and improvements to the Nvidia RegEx PMD.

Ori Kam (4):
regex/mlx5: fix memory rule alignment
regex/mlx5: add support for combined rule file
regex/mlx5: fix support for group id
regex/mlx5: add support for priority match

 drivers/regex/mlx5/mlx5_regex.c          |   9 +
 drivers/regex/mlx5/mlx5_regex.h          |   1 +
 drivers/regex/mlx5/mlx5_regex_fastpath.c |  23 +-
 drivers/regex/mlx5/mlx5_rxp.c            | 827 ++++++++++-------------
 drivers/regex/mlx5/mlx5_rxp_csrs.h       |   3 +
 5 files changed, 372 insertions(+), 491 deletions(-)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/4 regex/mlx5: fix memory rule alignment

Due to Kernel requirement the memory allocated must be aligned to 2M.

Fixes b34d816363b5 ("regex/mlx5: support rules import")
---
 drivers/regex/mlx5/mlx5_rxp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regex/mlx5/mlx5_rxp.c +1 -1
index fcbc766441..bd721f0b11 100644
@@ -892,7 +892,7 @@ rxp_db_setup(struct mlx5_regex_priv *priv)
 
 	/* Setup database memories for both RXP engines + reprogram memory. */
 	for (i = 0; i < (priv->nb_engines + MLX5_RXP_EM_COUNT); i++) {
-		priv->db[i].ptr = rte_malloc("", MLX5_MAX_DB_SIZE, 0);
+		priv->db[i].ptr = rte_malloc("", MLX5_MAX_DB_SIZE, 1 << 21);
 		if (!priv->db[i].ptr) {
 			DRV_LOG(ERR, "Failed to alloc db memory!");
 			ret = ENODEV;
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH 2/4 regex/mlx5: add support for combined rule file

In reply to Ori Kam

The rof file holds programming instructions for a given HW version.
In order to support future generation of HW it was decided that the rof file will hold number of rule configurations, and the driver will use the one that matches the HW version.

In current code we force sync after each write block. This has impact on performance.

The solution is to move the sync to the end of the entire programming sequence.

---
 drivers/regex/mlx5/mlx5_regex.c    |   9 +
 drivers/regex/mlx5/mlx5_regex.h    |   1 +
 drivers/regex/mlx5/mlx5_rxp.c      | 825 ++++++++++++-----------------
 drivers/regex/mlx5/mlx5_rxp_csrs.h |   3 +
 4 files changed, 352 insertions(+), 486 deletions(-)
drivers/regex/mlx5/mlx5_regex.c +9 -0
index c91c444dda..25eaec5802 100644
@@ -119,6 +119,7 @@ mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct mlx5_hca_attr attr;
 	char name[RTE_REGEXDEV_NAME_MAX_LEN];
 	int ret;
+	uint32_t val;
 
 	ibv = mlx5_regex_get_ib_device_match(&pci_dev->addr);
 	if (!ibv) {
@@ -161,6 +162,14 @@ mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	}
 	priv->ctx = ctx;
 	priv->nb_engines = 2; /* attr.regexp_num_of_engines */
+	ret = mlx5_devx_regex_register_read(priv->ctx, 0,
+					    MLX5_RXP_CSR_IDENTIFIER, &val);
+	if (ret) {
+		DRV_LOG(ERR, "CSR read failed!");
+		return -1;
+	}
+	if (val == MLX5_RXP_BF2_IDENTIFIER)
+		priv->is_bf2 = 1;
 	/* Default RXP programming mode to Shared. */
 	priv->prog_mode = MLX5_RXP_SHARED_PROG_MODE;
 	mlx5_regex_get_name(name, pci_dev);
drivers/regex/mlx5/mlx5_regex.h +1 -0
index 2c4877c37d..60f29a84d2 100644
@@ -80,6 +80,7 @@ struct mlx5_regex_priv {
 	struct ibv_pd *pd;
 	struct mlx5_dbr_page_list dbrpgs; /* Door-bell pages. */
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
+	uint8_t is_bf2; /* The device is BF2 device. */
 };
 
 /* mlx5_regex.c */
drivers/regex/mlx5/mlx5_rxp.c +339 -486

953 lines not on this page · raw message

drivers/regex/mlx5/mlx5_rxp_csrs.h +3 -0
index d92b3fff53..f3ffdfdef2 100644
@@ -5,6 +5,9 @@
 #ifndef _MLX5_RXP_CSRS_H_
 #define _MLX5_RXP_CSRS_H_
 
+/* BF types */
+#define MLX5_RXP_BF2_IDENTIFIER 0x07055254ul
+
 /*
  * Common to all RXP implementations
  */
Signature · 1 line
2.25.1
author
#3 lore raw

PATCH 3/4 regex/mlx5: fix support for group id

In reply to Ori Kam

In order to know which groups in the RegEx engine should be used there is a need to check the req_flags.

This commit adds the missing check.

Fixes 4d4e245ad637 ("regex/mlx5: support enqueue")
---
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/regex/mlx5/mlx5_regex_fastpath.c +17 -4
index 5857617282..8d134ac98e 100644
@@ -105,7 +105,21 @@ prep_one(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp,
 {
 	size_t wqe_offset = (sq->pi & (sq_size_get(sq) - 1)) * MLX5_SEND_WQE_BB;
 	uint32_t lkey;
-
+	uint16_t group0 = op->req_flags & RTE_REGEX_OPS_REQ_GROUP_ID0_VALID_F ?
+				op->group_id0 : 0;
+	uint16_t group1 = op->req_flags & RTE_REGEX_OPS_REQ_GROUP_ID1_VALID_F ?
+				op->group_id1 : 0;
+	uint16_t group2 = op->req_flags & RTE_REGEX_OPS_REQ_GROUP_ID2_VALID_F ?
+				op->group_id2 : 0;
+	uint16_t group3 = op->req_flags & RTE_REGEX_OPS_REQ_GROUP_ID3_VALID_F ?
+				op->group_id3 : 0;
+
+	/* For backward compatibility. */
+	if (!(op->req_flags & (RTE_REGEX_OPS_REQ_GROUP_ID0_VALID_F |
+			       RTE_REGEX_OPS_REQ_GROUP_ID1_VALID_F |
+			       RTE_REGEX_OPS_REQ_GROUP_ID2_VALID_F |
+			       RTE_REGEX_OPS_REQ_GROUP_ID3_VALID_F)))
+		group0 = op->group_id0;
 	lkey = mlx5_mr_addr2mr_bh(priv->pd, 0,
 				  &priv->mr_scache, &qp->mr_ctrl,
 				  rte_pktmbuf_mtod(op->mbuf, uintptr_t),
@@ -116,9 +130,8 @@ prep_one(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp,
 	set_wqe_ctrl_seg((struct mlx5_wqe_ctrl_seg *)wqe, sq->pi,
 			 MLX5_OPCODE_MMO, MLX5_OPC_MOD_MMO_REGEX, sq->obj->id,
 			 0, ds, 0, 0);
-	set_regex_ctrl_seg(wqe + 12, 0, op->group_id0, op->group_id1,
-			   op->group_id2,
-			   op->group_id3, 0);
+	set_regex_ctrl_seg(wqe + 12, 0, group0, group1, group2, group3,
+			   0);
 	struct mlx5_wqe_data_seg *input_seg =
 		(struct mlx5_wqe_data_seg *)(wqe +
 					     MLX5_REGEX_WQE_GATHER_OFFSET);
Signature · 1 line
2.25.1
author
#4 lore raw

PATCH 4/4 regex/mlx5: add support for priority match

In reply to Ori Kam

The high priority match request flags means that the RegEx engine should stop on the first match.

This commit add this flag check to the RegEx engine.

---
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/regex/mlx5/mlx5_regex_fastpath.c +3 -1
index 8d134ac98e..ee72f89c99 100644
@@ -113,6 +113,8 @@ prep_one(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp,
 				op->group_id2 : 0;
 	uint16_t group3 = op->req_flags & RTE_REGEX_OPS_REQ_GROUP_ID3_VALID_F ?
 				op->group_id3 : 0;
+	uint8_t control = op->req_flags &
+				RTE_REGEX_OPS_REQ_MATCH_HIGH_PRIORITY_F ? 1 : 0;
 
 	/* For backward compatibility. */
 	if (!(op->req_flags & (RTE_REGEX_OPS_REQ_GROUP_ID0_VALID_F |
@@ -131,7 +133,7 @@ prep_one(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp,
 			 MLX5_OPCODE_MMO, MLX5_OPC_MOD_MMO_REGEX, sq->obj->id,
 			 0, ds, 0, 0);
 	set_regex_ctrl_seg(wqe + 12, 0, group0, group1, group2, group3,
-			   0);
+			   control);
 	struct mlx5_wqe_data_seg *input_seg =
 		(struct mlx5_wqe_data_seg *)(wqe +
 					     MLX5_REGEX_WQE_GATHER_OFFSET);
Signature · 1 line
2.25.1
author
#5 lore raw

v2 cover regex/mlx5: pmd improvements

In reply to Ori Kam

This series adds a few fixes and improvements to the Nvidia RegEx PMD.

V2:
* Fix small issue in combined rule patch.
* Add new patch for number of queues.

Ori Kam (5):
regex/mlx5: fix memory rule alignment
regex/mlx5: add support for combined rule file
regex/mlx5: fix support for group id
regex/mlx5: add support for priority match
regex/mlx5: fix num of supported queues

 drivers/regex/mlx5/mlx5_regex.c          |   9 +
 drivers/regex/mlx5/mlx5_regex.h          |   1 +
 drivers/regex/mlx5/mlx5_regex_fastpath.c |  23 +-
 drivers/regex/mlx5/mlx5_rxp.c            | 846 ++++++++++-------------
 drivers/regex/mlx5/mlx5_rxp_csrs.h       |   3 +
 5 files changed, 385 insertions(+), 497 deletions(-)
Signature · 1 line
2.25.1
author
#6 lore raw

PATCH v2 1/5 regex/mlx5: fix memory rule alignment

Due to Kernel requirement the memory allocated must be aligned to 2M.

Fixes b34d816363b5 ("regex/mlx5: support rules import")
---
 drivers/regex/mlx5/mlx5_rxp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regex/mlx5/mlx5_rxp.c +1 -1
index fcbc766441..bd721f0b11 100644
@@ -892,7 +892,7 @@ rxp_db_setup(struct mlx5_regex_priv *priv)
 
 	/* Setup database memories for both RXP engines + reprogram memory. */
 	for (i = 0; i < (priv->nb_engines + MLX5_RXP_EM_COUNT); i++) {
-		priv->db[i].ptr = rte_malloc("", MLX5_MAX_DB_SIZE, 0);
+		priv->db[i].ptr = rte_malloc("", MLX5_MAX_DB_SIZE, 1 << 21);
 		if (!priv->db[i].ptr) {
 			DRV_LOG(ERR, "Failed to alloc db memory!");
 			ret = ENODEV;
Signature · 1 line
2.25.1
author
#7 lore raw

PATCH v2 2/5 regex/mlx5: add support for combined rule file

In reply to Ori Kam

The rof file holds programming instructions for a given HW version.
In order to support future generation of HW it was decided that the rof file will hold number of rule configurations, and the driver will use the one that matches the HW version.

In current code we force sync after each write block. This has impact on performance.

The solution is to move the sync to the end of the entire programming sequence.

---
V2:
* fix issue with external rules.

---
 drivers/regex/mlx5/mlx5_regex.c    |   9 +
 drivers/regex/mlx5/mlx5_regex.h    |   1 +
 drivers/regex/mlx5/mlx5_rxp.c      | 841 ++++++++++++-----------------
 drivers/regex/mlx5/mlx5_rxp_csrs.h |   3 +
 4 files changed, 364 insertions(+), 490 deletions(-)
drivers/regex/mlx5/mlx5_regex.c +9 -0
index c91c444dda..25eaec5802 100644
@@ -119,6 +119,7 @@ mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct mlx5_hca_attr attr;
 	char name[RTE_REGEXDEV_NAME_MAX_LEN];
 	int ret;
+	uint32_t val;
 
 	ibv = mlx5_regex_get_ib_device_match(&pci_dev->addr);
 	if (!ibv) {
@@ -161,6 +162,14 @@ mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	}
 	priv->ctx = ctx;
 	priv->nb_engines = 2; /* attr.regexp_num_of_engines */
+	ret = mlx5_devx_regex_register_read(priv->ctx, 0,
+					    MLX5_RXP_CSR_IDENTIFIER, &val);
+	if (ret) {
+		DRV_LOG(ERR, "CSR read failed!");
+		return -1;
+	}
+	if (val == MLX5_RXP_BF2_IDENTIFIER)
+		priv->is_bf2 = 1;
 	/* Default RXP programming mode to Shared. */
 	priv->prog_mode = MLX5_RXP_SHARED_PROG_MODE;
 	mlx5_regex_get_name(name, pci_dev);
drivers/regex/mlx5/mlx5_regex.h +1 -0
index 2c4877c37d..60f29a84d2 100644
@@ -80,6 +80,7 @@ struct mlx5_regex_priv {
 	struct ibv_pd *pd;
 	struct mlx5_dbr_page_list dbrpgs; /* Door-bell pages. */
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
+	uint8_t is_bf2; /* The device is BF2 device. */
 };
 
 /* mlx5_regex.c */
drivers/regex/mlx5/mlx5_rxp.c +351 -490

965 lines not on this page · raw message

drivers/regex/mlx5/mlx5_rxp_csrs.h +3 -0
index d92b3fff53..f3ffdfdef2 100644
@@ -5,6 +5,9 @@
 #ifndef _MLX5_RXP_CSRS_H_
 #define _MLX5_RXP_CSRS_H_
 
+/* BF types */
+#define MLX5_RXP_BF2_IDENTIFIER 0x07055254ul
+
 /*
  * Common to all RXP implementations
  */
Signature · 1 line
2.25.1
author
#8 lore raw

PATCH v2 3/5 regex/mlx5: fix support for group id

In reply to Ori Kam

In order to know which groups in the RegEx engine should be used there is a need to check the req_flags.

This commit adds the missing check.

Fixes 4d4e245ad637 ("regex/mlx5: support enqueue")
---
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/regex/mlx5/mlx5_regex_fastpath.c +17 -4
index 5857617282..8d134ac98e 100644
@@ -105,7 +105,21 @@ prep_one(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp,
 {
 	size_t wqe_offset = (sq->pi & (sq_size_get(sq) - 1)) * MLX5_SEND_WQE_BB;
 	uint32_t lkey;
-
+	uint16_t group0 = op->req_flags & RTE_REGEX_OPS_REQ_GROUP_ID0_VALID_F ?
+				op->group_id0 : 0;
+	uint16_t group1 = op->req_flags & RTE_REGEX_OPS_REQ_GROUP_ID1_VALID_F ?
+				op->group_id1 : 0;
+	uint16_t group2 = op->req_flags & RTE_REGEX_OPS_REQ_GROUP_ID2_VALID_F ?
+				op->group_id2 : 0;
+	uint16_t group3 = op->req_flags & RTE_REGEX_OPS_REQ_GROUP_ID3_VALID_F ?
+				op->group_id3 : 0;
+
+	/* For backward compatibility. */
+	if (!(op->req_flags & (RTE_REGEX_OPS_REQ_GROUP_ID0_VALID_F |
+			       RTE_REGEX_OPS_REQ_GROUP_ID1_VALID_F |
+			       RTE_REGEX_OPS_REQ_GROUP_ID2_VALID_F |
+			       RTE_REGEX_OPS_REQ_GROUP_ID3_VALID_F)))
+		group0 = op->group_id0;
 	lkey = mlx5_mr_addr2mr_bh(priv->pd, 0,
 				  &priv->mr_scache, &qp->mr_ctrl,
 				  rte_pktmbuf_mtod(op->mbuf, uintptr_t),
@@ -116,9 +130,8 @@ prep_one(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp,
 	set_wqe_ctrl_seg((struct mlx5_wqe_ctrl_seg *)wqe, sq->pi,
 			 MLX5_OPCODE_MMO, MLX5_OPC_MOD_MMO_REGEX, sq->obj->id,
 			 0, ds, 0, 0);
-	set_regex_ctrl_seg(wqe + 12, 0, op->group_id0, op->group_id1,
-			   op->group_id2,
-			   op->group_id3, 0);
+	set_regex_ctrl_seg(wqe + 12, 0, group0, group1, group2, group3,
+			   0);
 	struct mlx5_wqe_data_seg *input_seg =
 		(struct mlx5_wqe_data_seg *)(wqe +
 					     MLX5_REGEX_WQE_GATHER_OFFSET);
Signature · 1 line
2.25.1
author
#9 lore raw

PATCH v2 4/5 regex/mlx5: add support for priority match

In reply to Ori Kam

The high priority match request flags means that the RegEx engine should stop on the first match.

This commit add this flag check to the RegEx engine.

---
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/regex/mlx5/mlx5_regex_fastpath.c +3 -1
index 8d134ac98e..ee72f89c99 100644
@@ -113,6 +113,8 @@ prep_one(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp,
 				op->group_id2 : 0;
 	uint16_t group3 = op->req_flags & RTE_REGEX_OPS_REQ_GROUP_ID3_VALID_F ?
 				op->group_id3 : 0;
+	uint8_t control = op->req_flags &
+				RTE_REGEX_OPS_REQ_MATCH_HIGH_PRIORITY_F ? 1 : 0;
 
 	/* For backward compatibility. */
 	if (!(op->req_flags & (RTE_REGEX_OPS_REQ_GROUP_ID0_VALID_F |
@@ -131,7 +133,7 @@ prep_one(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp,
 			 MLX5_OPCODE_MMO, MLX5_OPC_MOD_MMO_REGEX, sq->obj->id,
 			 0, ds, 0, 0);
 	set_regex_ctrl_seg(wqe + 12, 0, group0, group1, group2, group3,
-			   0);
+			   control);
 	struct mlx5_wqe_data_seg *input_seg =
 		(struct mlx5_wqe_data_seg *)(wqe +
 					     MLX5_REGEX_WQE_GATHER_OFFSET);
Signature · 1 line
2.25.1
author
#10 lore raw

PATCH v2 5/5 regex/mlx5: fix num of supported queues

In reply to Ori Kam

The RegEx engine as no limitation on number of queues.
This commits modifies the max supported queues reported to the application.

Fixes fbc8c7003b93 ("regex/mlx5: add completion queue creation")
---
 drivers/regex/mlx5/mlx5_rxp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/regex/mlx5/mlx5_rxp.c +1 -2
index 66cbc1f481..e5d9b9245a 100644
@@ -103,11 +103,10 @@ mlx5_regex_info_get(struct rte_regexdev *dev __rte_unused,
 	info->max_payload_size = MLX5_REGEX_MAX_PAYLOAD_SIZE;
 	info->max_rules_per_group = MLX5_REGEX_MAX_RULES_PER_GROUP;
 	info->max_groups = MLX5_REGEX_MAX_GROUPS;
-	info->max_queue_pairs = 1;
 	info->regexdev_capa = RTE_REGEXDEV_SUPP_PCRE_GREEDY_F |
 			      RTE_REGEXDEV_CAPA_QUEUE_PAIR_OOS_F;
 	info->rule_flags = 0;
-	info->max_queue_pairs = 10;
+	info->max_queue_pairs = UINT16_MAX;
 	return 0;
 }
 
Signature · 1 line
2.25.1
#11 lore raw
In reply to Ori Kam
Quoted 6 lines

Ori Kam (5):
regex/mlx5: fix memory rule alignment
regex/mlx5: add support for combined rule file
regex/mlx5: fix support for group id
regex/mlx5: add support for priority match
regex/mlx5: fix num of supported queues

Applied, thanks