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

Message ID 1559583160-13944-26-git-send-email-anoobj@marvell.com (mailing list archive)
State Changes Requested, archived
Delegated to: Jerin Jacob
Headers
Series adding eventmode helper library |

Checks

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

Commit Message

Anoob Joseph June 3, 2019, 5:32 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(+)
  

Comments

Jerin Jacob Kollanukkaran June 10, 2019, 10:25 a.m. UTC | #1
> -----Original Message-----
> From: Anoob Joseph <anoobj@marvell.com>
> Sent: Monday, June 3, 2019 11:02 PM
> To: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Nikhil Rao
> <nikhil.rao@intel.com>; Erik Gabriel Carrillo <erik.g.carrillo@intel.com>;
> Abhinandan Gujjar <abhinandan.gujjar@intel.com>; Bruce Richardson
> <bruce.richardson@intel.com>; Pablo de Lara
> <pablo.de.lara.guarch@intel.com>
> Cc: Anoob Joseph <anoobj@marvell.com>; Narayana Prasad Raju Athreya
> <pathreya@marvell.com>; dev@dpdk.org; Lukas Bartosik
> <lbartosik@marvell.com>; Pavan Nikhilesh Bhagavatula
> <pbhagavatula@marvell.com>; Hemant Agrawal
> <hemant.agrawal@nxp.com>; Nipun Gupta <nipun.gupta@nxp.com>; Harry
> van Haaren <harry.van.haaren@intel.com>; Mattias Rönnblom
> <mattias.ronnblom@ericsson.com>; Liang Ma <liang.j.ma@intel.com>
> Subject: [PATCH 25/39] eventdev: add routine to validate conf
> 
> 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(+)
> 
> 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) {

No need to start with rte_eventmode_... for internal functions
  
Anoob Joseph June 17, 2019, 10:23 a.m. UTC | #2
Hi Jerin,

Please see inline.

Thanks,
Anoob

> -----Original Message-----
> From: Jerin Jacob Kollanukkaran
> Sent: Monday, June 10, 2019 3:55 PM
> To: Anoob Joseph <anoobj@marvell.com>; Nikhil Rao
> <nikhil.rao@intel.com>; Erik Gabriel Carrillo <erik.g.carrillo@intel.com>;
> Abhinandan Gujjar <abhinandan.gujjar@intel.com>; Bruce Richardson
> <bruce.richardson@intel.com>; Pablo de Lara
> <pablo.de.lara.guarch@intel.com>
> Cc: Anoob Joseph <anoobj@marvell.com>; Narayana Prasad Raju Athreya
> <pathreya@marvell.com>; dev@dpdk.org; Lukas Bartosik
> <lbartosik@marvell.com>; Pavan Nikhilesh Bhagavatula
> <pbhagavatula@marvell.com>; Hemant Agrawal
> <hemant.agrawal@nxp.com>; Nipun Gupta <nipun.gupta@nxp.com>; Harry
> van Haaren <harry.van.haaren@intel.com>; Mattias Rönnblom
> <mattias.ronnblom@ericsson.com>; Liang Ma <liang.j.ma@intel.com>
> Subject: RE: [PATCH 25/39] eventdev: add routine to validate conf
> 
> > -----Original Message-----
> > From: Anoob Joseph <anoobj@marvell.com>
> > Sent: Monday, June 3, 2019 11:02 PM
> > To: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Nikhil Rao
> > <nikhil.rao@intel.com>; Erik Gabriel Carrillo
> > <erik.g.carrillo@intel.com>; Abhinandan Gujjar
> > <abhinandan.gujjar@intel.com>; Bruce Richardson
> > <bruce.richardson@intel.com>; Pablo de Lara
> > <pablo.de.lara.guarch@intel.com>
> > Cc: Anoob Joseph <anoobj@marvell.com>; Narayana Prasad Raju Athreya
> > <pathreya@marvell.com>; dev@dpdk.org; Lukas Bartosik
> > <lbartosik@marvell.com>; Pavan Nikhilesh Bhagavatula
> > <pbhagavatula@marvell.com>; Hemant Agrawal
> <hemant.agrawal@nxp.com>;
> > Nipun Gupta <nipun.gupta@nxp.com>; Harry van Haaren
> > <harry.van.haaren@intel.com>; Mattias Rönnblom
> > <mattias.ronnblom@ericsson.com>; Liang Ma <liang.j.ma@intel.com>
> > Subject: [PATCH 25/39] eventdev: add routine to validate conf
> >
> > 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(+)
> >
> > 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) {
> 
> No need to start with rte_eventmode_... for internal functions

[Anoob] Will fix in v2.
  

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) {