[v6,04/13] regex/mlx5: add get info function
diff mbox series

Message ID 1595226378-81144-5-git-send-email-orika@mellanox.com
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • add Mellanox RegEx PMD
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Ori Kam July 20, 2020, 6:26 a.m. UTC
This commit adds the get info function.

Signed-off-by: Ori Kam <orika@mellanox.com>
---
 drivers/regex/mlx5/Makefile     |  1 +
 drivers/regex/mlx5/meson.build  |  1 +
 drivers/regex/mlx5/mlx5_regex.c |  4 +++-
 drivers/regex/mlx5/mlx5_regex.h |  5 +++++
 drivers/regex/mlx5/mlx5_rxp.c   | 29 +++++++++++++++++++++++++++++
 5 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100644 drivers/regex/mlx5/mlx5_rxp.c

Patch
diff mbox series

diff --git a/drivers/regex/mlx5/Makefile b/drivers/regex/mlx5/Makefile
index 1bddf21..8fe61f8 100644
--- a/drivers/regex/mlx5/Makefile
+++ b/drivers/regex/mlx5/Makefile
@@ -8,6 +8,7 @@  LIB = librte_pmd_mlx5_regex.a
 
 # Sources.
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_REGEX_PMD) += mlx5_regex.c
+SRCS-$(CONFIG_RTE_LIBRTE_MLX5_REGEX_PMD) += mlx5_rxp.c
 
 # Basic CFLAGS.
 CFLAGS += -O3
diff --git a/drivers/regex/mlx5/meson.build b/drivers/regex/mlx5/meson.build
index 27bb0ad..bfb25e2 100644
--- a/drivers/regex/mlx5/meson.build
+++ b/drivers/regex/mlx5/meson.build
@@ -11,6 +11,7 @@  fmt_name = 'mlx5_regex'
 deps += ['common_mlx5', 'bus_pci', 'bus_mlx5_pci', 'eal', 'regexdev']
 sources = files(
 	'mlx5_regex.c',
+	'mlx5_rxp.c',
 )
 cflags_options = [
 	'-std=c11',
diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c
index fe44429..1f4d967 100644
--- a/drivers/regex/mlx5/mlx5_regex.c
+++ b/drivers/regex/mlx5/mlx5_regex.c
@@ -22,7 +22,9 @@ 
 
 int mlx5_regex_logtype;
 
-static const struct rte_regexdev_ops mlx5_regexdev_ops = {0};
+const struct rte_regexdev_ops mlx5_regexdev_ops = {
+	.dev_info_get = mlx5_regex_info_get,
+};
 
 static struct ibv_device *
 mlx5_regex_get_ib_device_match(struct rte_pci_addr *addr)
diff --git a/drivers/regex/mlx5/mlx5_regex.h b/drivers/regex/mlx5/mlx5_regex.h
index 0ce1e4d..9d0fc16 100644
--- a/drivers/regex/mlx5/mlx5_regex.h
+++ b/drivers/regex/mlx5/mlx5_regex.h
@@ -11,4 +11,9 @@  struct mlx5_regex_priv {
 	struct rte_pci_device *pci_dev;
 	struct rte_regexdev *regexdev; /* Pointer to the RegEx dev. */
 };
+
+/* mlx5_rxp.c */
+int mlx5_regex_info_get(struct rte_regexdev *dev,
+			struct rte_regexdev_info *info);
+
 #endif /* MLX5_REGEX_H */
diff --git a/drivers/regex/mlx5/mlx5_rxp.c b/drivers/regex/mlx5/mlx5_rxp.c
new file mode 100644
index 0000000..a5a6f15
--- /dev/null
+++ b/drivers/regex/mlx5/mlx5_rxp.c
@@ -0,0 +1,29 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd
+ */
+
+#include <rte_log.h>
+#include <rte_errno.h>
+#include <rte_regexdev.h>
+#include <rte_regexdev_core.h>
+#include <rte_regexdev_driver.h>
+
+#include "mlx5_regex.h"
+
+#define MLX5_REGEX_MAX_MATCHES 255
+#define MLX5_REGEX_MAX_PAYLOAD_SIZE UINT16_MAX
+#define MLX5_REGEX_MAX_RULES_PER_GROUP UINT16_MAX
+#define MLX5_REGEX_MAX_GROUPS UINT16_MAX
+
+int
+mlx5_regex_info_get(struct rte_regexdev *dev __rte_unused,
+		  struct rte_regexdev_info *info)
+{
+	info->max_matches = MLX5_REGEX_MAX_MATCHES;
+	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->regexdev_capa = RTE_REGEXDEV_SUPP_PCRE_GREEDY_F;
+	info->rule_flags = 0;
+	return 0;
+}