regex/mlx5: add dynamic memroy registration to datapath
PATCH 1/1 regex/mlx5: add dynamic memroy registration to datapath
From: Yuval Avnery <[email protected]>
Currently job data is being copied to pre-registered buffer. To avoid memcpy on the datapath, use dynamic memory registration.
This change will reduce latency when sending regex jobs. The first few jobs may have high latency due to registration, but assuming all following mbufs will arrive from the same mempool/hugepage, there will be no further memory registration.
Signed-off-by Yuval Avnery <[email protected]>
Acked-by Ori Kam <[email protected]>
--- drivers/regex/mlx5/mlx5_regex.c | 13 ++++++++ drivers/regex/mlx5/mlx5_regex.h | 4 ++- drivers/regex/mlx5/mlx5_regex_control.c | 16 ++++++++-- drivers/regex/mlx5/mlx5_regex_fastpath.c | 55 +++++++++----------------------- 4 files changed, 44 insertions(+), 44 deletions(-)
drivers/regex/mlx5/mlx5_regex.c +13 -0
@@ -109,6 +109,9 @@ pci_dev->addr.devid, pci_dev->addr.function); } +void mlx5_os_set_reg_mr_cb (mlx5_reg_mr_t *reg_mr_cb, +mlx5_dereg_mr_t *dereg_mr_cb); +static int mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev)
@@ -194,6 +197,16 @@ priv->regexdev->device = (struct rte_device *)pci_dev; priv->regexdev->data->dev_private = priv; priv->regexdev->state =RTE_REGEXDEV_READY ; +mlx5_os_set_reg_mr_cb (&priv->mr_scache.reg_mr_cb, + &priv->mr_scache.dereg_mr_cb); + ret =mlx5_mr_btree_init (&priv->mr_scache.cache, +MLX5_MR_BTREE_CACHE_N *2 , +rte_socket_id ()); +if (ret) { +DRV_LOG (ERR ,"MR init tree failed." ); + rte_errno =ENOMEM ; + goto error; + }return 0 ; error:
drivers/regex/mlx5/mlx5_regex.h +3 -1
@@ -11,6 +11,7 @@#include <infiniband/mlx5dv.h> #include <mlx5_common.h> +#include <mlx5_common_mr.h> #include "mlx5_rxp.h"
@@ -47,9 +48,9 @@ struct mlx5_regex_qp {uint32_t free_sqs;struct mlx5_regex_job *jobs;struct ibv_mr *metadata; -struct ibv_mr *inputs;struct ibv_mr *outputs;size_t ci, pi; +struct mlx5_mr_ctrl mr_ctrl; };struct mlx5_regex_db {
@@ -78,6 +79,7 @@ struct mlx5_regex_priv {struct mlx5dv_devx_uar *uar;/* UAR object. */ struct ibv_pd *pd;struct mlx5_dbr_page_list dbrpgs;/* Door-bell pages. */ +struct mlx5_mr_share_cache mr_scache;/* Global shared MR cache. */ };/* mlx5_regex.c */
drivers/regex/mlx5/mlx5_regex_control.c +13 -3
@@ -10,6 +10,7 @@#include <rte_regexdev.h> #include <rte_regexdev_core.h> #include <rte_regexdev_driver.h> +#include <rte_dev.h> #include <mlx5_common.h> #include <mlx5_glue.h>
@@ -350,7 +351,7 @@ qp->nb_obj * sizeof(struct mlx5_regex_sq), 64);if (!qp->sqs) {DRV_LOG (ERR ,"Can't allocate sq array memory." ); - rte_errno =ENOMEM ; + rte_errno =ENOMEM ;return -rte_errno; } log_desc =rte_log2_u32 (qp->nb_desc / qp->nb_obj);
@@ -367,16 +368,25 @@ } } + ret =mlx5_mr_btree_init (&qp->mr_ctrl.cache_bh,MLX5_MR_BTREE_CACHE_N , +rte_socket_id ()); +if (ret) { +DRV_LOG (ERR ,"Error setting up mr btree" ); + goto err_btree; + } + ret =mlx5_regexdev_setup_fastpath (priv, qp_ind);if (ret) { -DRV_LOG (ERR ,"Fail to setup fastpath." ); +DRV_LOG (ERR ,"Error setting up fastpath" ); goto err_fp; }return 0 ; err_fp: +mlx5_mr_btree_free (&qp->mr_ctrl.cache_bh); +err_btree:for (i =0 ; i < qp->nb_obj; i++) - ret =regex_ctrl_destroy_sq (priv, qp, i); +regex_ctrl_destroy_sq (priv, qp, i); err_sq:regex_ctrl_destroy_cq (priv, &qp->cq); err_cq:
drivers/regex/mlx5/mlx5_regex_fastpath.c +15 -40
136 lines not on this page · raw message
Signature · 1 line
1.8.3.1