[25/39] eventdev: add routine to validate conf

Message ID 1559580584-5728-26-git-send-email-anoobj@marvell.com (mailing list archive)
State Superseded, archived
Headers
Series None |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Anoob Joseph June 3, 2019, 4:49 p.m. UTC
  Adding routine to validate event mode conf. This function will verify
the conf requested by the user and would populate other fields with
default values. Presently, the function acts as placeholder for the
above mentioned actions.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Signed-off-by: Lukasz Bartosik <lbartosik@marvell.com>
---
 lib/librte_eventdev/rte_eventmode_helper.c | 33 ++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
  

Patch

diff --git a/lib/librte_eventdev/rte_eventmode_helper.c b/lib/librte_eventdev/rte_eventmode_helper.c
index a57f837..4dbb94a 100644
--- a/lib/librte_eventdev/rte_eventmode_helper.c
+++ b/lib/librte_eventdev/rte_eventmode_helper.c
@@ -165,6 +165,32 @@  rte_eventmode_helper_parse_args(int argc, char **argv)
 	return NULL;
 }
 
+/* Pre-process conf before using for init*/
+
+static int
+rte_eventmode_validate_user_params(struct eventmode_conf *em_conf)
+{
+	/* TODO */
+	/* Check sanity of the conf requested by user */
+
+	RTE_SET_USED(em_conf);
+
+	return 0;
+}
+
+static int
+rte_eventmode_helper_validate_conf(struct eventmode_conf *em_conf)
+{
+	int ret;
+
+	/* After parsing all args, verify that the conf can be allowed */
+	ret = rte_eventmode_validate_user_params(em_conf);
+	if (ret != 0)
+		return ret;
+
+	return 0;
+}
+
 /* Setup eventmode devs */
 
 static int
@@ -468,6 +494,13 @@  rte_eventmode_helper_initialize_devs(
 	/* Get eventmode conf */
 	em_conf = (struct eventmode_conf *)(mode_conf->mode_params);
 
+	/* Validate the conf requested */
+	if (rte_eventmode_helper_validate_conf(em_conf) != 0) {
+		RTE_EM_HLPR_LOG_ERR(
+			"Failed while validating the conf requested");
+		return -1;
+	}
+
 	/* Stop eth devices before setting up adapter */
 	RTE_ETH_FOREACH_DEV(portid) {