[v2,10/20] regex/mlx5: add engine status check
diff mbox series

Message ID 1594587541-110442-11-git-send-email-orika@mellanox.com
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • add Mellanox RegEx PMD
Related show

Checks

Context Check Description
ci/Intel-compilation fail apply issues
ci/checkpatch warning coding style issues

Commit Message

Ori Kam July 12, 2020, 8:58 p.m. UTC
This commit checks the engine status.

Signed-off-by: Ori Kam <orika@mellanox.com>
---
 drivers/regex/mlx5/mlx5_regex.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Patch
diff mbox series

diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c
index d264ecd..c469a10 100644
--- a/drivers/regex/mlx5/mlx5_regex.c
+++ b/drivers/regex/mlx5/mlx5_regex.c
@@ -17,6 +17,7 @@ 
 
 #include "mlx5_regex.h"
 #include "mlx5_regex_utils.h"
+#include "mlx5_rxp_csrs.h"
 
 int mlx5_regex_logtype;
 
@@ -49,6 +50,28 @@ 
 	mlx5_glue->free_device_list(ibv_list);
 	return ibv_match;
 }
+static int
+mlx5_regex_engines_status(struct ibv_context *ctx, int num_engines)
+{
+	uint32_t fpga_ident = 0;
+	int err;
+	int i;
+
+	for (i = 0; i < num_engines; i++) {
+		err = mlx5_devx_regex_register_read(ctx, i,
+						    MLX5_RXP_CSR_IDENTIFIER,
+						    &fpga_ident);
+		fpga_ident = (fpga_ident & (0x0000FFFF));
+		if (err || fpga_ident != MLX5_RXP_IDENTIFER) {
+			DRV_LOG(ERR, "Failed setup RXP %d err %d database "
+				"memory 0x%x", i, err, fpga_ident);
+			if (!err)
+				err = EINVAL;
+			return err;
+		}
+	}
+	return 0;
+}
 
 static void
 mlx5_regex_get_name(char *name, struct rte_pci_device *pci_dev __rte_unused)
@@ -109,6 +132,11 @@ 
 		rte_errno = ENOTSUP;
 		goto error;
 	}
+	if (mlx5_regex_engines_status(ctx, 2)) {
+		DRV_LOG(ERR, "RegEx engine error.");
+		rte_errno = ENOMEM;
+		goto error;
+	}
 	priv = rte_zmalloc("mlx5 regex device private", sizeof(*priv),
 			   RTE_CACHE_LINE_SIZE);
 	if (!priv) {