regex/mlx5: pmd improvements
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
PATCH 1/4 regex/mlx5: fix memory rule alignment
Due to Kernel requirement the memory allocated must be aligned to 2M.
--- drivers/regex/mlx5/mlx5_rxp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regex/mlx5/mlx5_rxp.c +1 -1
@@ -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
PATCH 2/4 regex/mlx5: add support for combined rule file
In reply to Ori KamThe 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
@@ -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
@@ -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
@@ -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
PATCH 3/4 regex/mlx5: fix support for group id
In reply to Ori KamIn 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.
--- drivers/regex/mlx5/mlx5_regex_fastpath.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/regex/mlx5/mlx5_regex_fastpath.c +17 -4
@@ -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
PATCH 4/4 regex/mlx5: add support for priority match
In reply to Ori KamThe 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
@@ -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
v2 cover regex/mlx5: pmd improvements
In reply to Ori KamThis 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
PATCH v2 1/5 regex/mlx5: fix memory rule alignment
Due to Kernel requirement the memory allocated must be aligned to 2M.
--- drivers/regex/mlx5/mlx5_rxp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regex/mlx5/mlx5_rxp.c +1 -1
@@ -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
PATCH v2 2/5 regex/mlx5: add support for combined rule file
In reply to Ori KamThe 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
@@ -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
@@ -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
@@ -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
PATCH v2 3/5 regex/mlx5: fix support for group id
In reply to Ori KamIn 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.
--- drivers/regex/mlx5/mlx5_regex_fastpath.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/regex/mlx5/mlx5_regex_fastpath.c +17 -4
@@ -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
PATCH v2 4/5 regex/mlx5: add support for priority match
In reply to Ori KamThe 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
@@ -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
PATCH v2 5/5 regex/mlx5: fix num of supported queues
In reply to Ori KamThe RegEx engine as no limitation on number of queues.
This commits modifies the max supported queues reported to the application.
--- drivers/regex/mlx5/mlx5_rxp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/regex/mlx5/mlx5_rxp.c +1 -2
@@ -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
Thomas Monjalon
AppliedQuoted 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