diff mbox

Add-global_init-paramiters

Message ID 1408636886-14474-1-git-send-email-mike.holmes@linaro.org
State Rejected
Headers show

Commit Message

Mike Holmes Aug. 21, 2014, 4:01 p.m. UTC
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 example/generator/odp_generator.c   |  2 +-
 example/l2fwd/odp_l2fwd.c           |  2 +-
 example/odp_example/odp_example.c   |  2 +-
 example/packet/odp_pktio.c          |  2 +-
 example/timer/odp_timer_test.c      |  2 +-
 include/odp_init.h                  | 22 +++++++++++++++++++---
 platform/linux-dpdk/odp_init.c      |  3 ++-
 platform/linux-generic/odp_init.c   |  3 ++-
 platform/linux-keystone2/odp_init.c |  3 ++-
 test/api_test/odp_common.c          |  2 +-
 10 files changed, 31 insertions(+), 12 deletions(-)

Comments

Bill Fischofer Aug. 21, 2014, 4:05 p.m. UTC | #1
Should odp_init_local() be similarly expanded to include these parameters?
 If yes, then perhaps changing the types from odp_global_init_t and
odp_global_platform_init_t to odp_init_t and odp_platform_init_t,
respectively, should be done.

Bill


On Thu, Aug 21, 2014 at 11:01 AM, Mike Holmes <mike.holmes@linaro.org>
wrote:

> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> ---
>  example/generator/odp_generator.c   |  2 +-
>  example/l2fwd/odp_l2fwd.c           |  2 +-
>  example/odp_example/odp_example.c   |  2 +-
>  example/packet/odp_pktio.c          |  2 +-
>  example/timer/odp_timer_test.c      |  2 +-
>  include/odp_init.h                  | 22 +++++++++++++++++++---
>  platform/linux-dpdk/odp_init.c      |  3 ++-
>  platform/linux-generic/odp_init.c   |  3 ++-
>  platform/linux-keystone2/odp_init.c |  3 ++-
>  test/api_test/odp_common.c          |  2 +-
>  10 files changed, 31 insertions(+), 12 deletions(-)
>
> diff --git a/example/generator/odp_generator.c
> b/example/generator/odp_generator.c
> index 9fa9b37..ba7aa68 100644
> --- a/example/generator/odp_generator.c
> +++ b/example/generator/odp_generator.c
> @@ -525,7 +525,7 @@ int main(int argc, char *argv[])
>         int core_count;
>
>         /* Init ODP before calling anything else */
> -       if (odp_init_global()) {
> +       if (odp_init_global(NULL, NULL)) {
>                 ODP_ERR("Error: ODP global init failed.\n");
>                 exit(EXIT_FAILURE);
>         }
> diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c
> index d74449a..f8d6729 100644
> --- a/example/l2fwd/odp_l2fwd.c
> +++ b/example/l2fwd/odp_l2fwd.c
> @@ -323,7 +323,7 @@ int main(int argc, char *argv[])
>         odp_pktio_t pktio;
>
>         /* Init ODP before calling anything else */
> -       if (odp_init_global()) {
> +       if (odp_init_global(NULL, NULL)) {
>                 ODP_ERR("Error: ODP global init failed.\n");
>                 exit(EXIT_FAILURE);
>         }
> diff --git a/example/odp_example/odp_example.c
> b/example/odp_example/odp_example.c
> index f0bdf29..3d38ac7 100644
> --- a/example/odp_example/odp_example.c
> +++ b/example/odp_example/odp_example.c
> @@ -951,7 +951,7 @@ int main(int argc, char *argv[])
>
>         memset(thread_tbl, 0, sizeof(thread_tbl));
>
> -       if (odp_init_global()) {
> +       if (odp_init_global(NULL, NULL)) {
>                 printf("ODP global init failed.\n");
>                 return -1;
>         }
> diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
> index f247bd0..f3543a0 100644
> --- a/example/packet/odp_pktio.c
> +++ b/example/packet/odp_pktio.c
> @@ -311,7 +311,7 @@ int main(int argc, char *argv[])
>         int core_count;
>
>         /* Init ODP before calling anything else */
> -       if (odp_init_global()) {
> +       if (odp_init_global(NULL, NULL)) {
>                 ODP_ERR("Error: ODP global init failed.\n");
>                 exit(EXIT_FAILURE);
>         }
> diff --git a/example/timer/odp_timer_test.c
> b/example/timer/odp_timer_test.c
> index dbe0e5b..1af8c2b 100644
> --- a/example/timer/odp_timer_test.c
> +++ b/example/timer/odp_timer_test.c
> @@ -210,7 +210,7 @@ int main(int argc, char *argv[])
>
>         memset(thread_tbl, 0, sizeof(thread_tbl));
>
> -       if (odp_init_global()) {
> +       if (odp_init_global(NULL, NULL)) {
>                 printf("ODP global init failed.\n");
>                 return -1;
>         }
> diff --git a/include/odp_init.h b/include/odp_init.h
> index 490324a..45db5f5 100644
> --- a/include/odp_init.h
> +++ b/include/odp_init.h
> @@ -23,23 +23,39 @@ extern "C" {
>  #include <odp_std_types.h>
>
>
> +/**
> + * ODP  initialisation
> + * Data that is required to initialize the ODP
> + * application, such as specifying a logging callback, the log level etc.
> + */
> +typedef struct odp_global_init {
> +} odp_global_init_t;
>
> +/**
> + * ODP  platform initialization
> + * Platform specific data. ODP does nothing with
> + * this data.
> + */
> +typedef struct odp_global_platform_init {
> +} odp_global_platform_init_t;
>
>  /**
> - * Perform global ODP initalisation.
> + * Perform global ODP initialisation.
>   *
>   * This function must be called once before calling
>   * any other ODP API functions.
>   *
>   * @return 0 if successful
>   */
> -int odp_init_global(void);
> +int odp_init_global(odp_global_init_t *params,
> +                   odp_global_platform_init_t *platform_params);
>
>
>  /**
> - * Perform thread local ODP initalisation.
> + * Perform thread local ODP initialisation.
>   *
>   * All threads must call this function before calling
> + *
>   * any other ODP API functions.
>   * @param thr_id Thread id
>   * @return 0 if successful
> diff --git a/platform/linux-dpdk/odp_init.c
> b/platform/linux-dpdk/odp_init.c
> index ecc2066..c3f937d 100644
> --- a/platform/linux-dpdk/odp_init.c
> +++ b/platform/linux-dpdk/odp_init.c
> @@ -50,7 +50,8 @@ int odp_init_dpdk(void)
>         return 0;
>  }
>
> -int odp_init_global(void)
> +int odp_init_global(odp_global_init_t *params  ODP_UNUSED,
> +                   odp_global_platform_init_t *platform_params ODP_UNUSED)
>  {
>         odp_thread_init_global();
>
> diff --git a/platform/linux-generic/odp_init.c
> b/platform/linux-generic/odp_init.c
> index 5b7e192..8b339e4 100644
> --- a/platform/linux-generic/odp_init.c
> +++ b/platform/linux-generic/odp_init.c
> @@ -9,7 +9,8 @@
>  #include <odp_debug.h>
>
>
> -int odp_init_global(void)
> +int odp_init_global(odp_global_init_t *params  ODP_UNUSED,
> +                   odp_global_platform_init_t *platform_params ODP_UNUSED)
>  {
>         odp_thread_init_global();
>
> diff --git a/platform/linux-keystone2/odp_init.c
> b/platform/linux-keystone2/odp_init.c
> index f832551..3111b51 100644
> --- a/platform/linux-keystone2/odp_init.c
> +++ b/platform/linux-keystone2/odp_init.c
> @@ -90,7 +90,8 @@ static int ti_init_hw_config(void)
>  }
>
>
> -int odp_init_global(void)
> +int odp_init_global(odp_global_init_t *init_data ODP_UNUSED,
> +                   odp_global_platform_init_t *platform_params ODP_UNUSED)
>  {
>         odp_thread_init_global();
>
> diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
> index 89ebd2d..fc583c0 100644
> --- a/test/api_test/odp_common.c
> +++ b/test/api_test/odp_common.c
> @@ -56,7 +56,7 @@ int odp_test_global_init(void)
>  {
>         memset(thread_tbl, 0, sizeof(thread_tbl));
>
> -       if (odp_init_global()) {
> +       if (odp_init_global(NULL, NULL)) {
>                 ODP_ERR("ODP global init failed.\n");
>                 return -1;
>         }
> --
> 1.9.1
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Wiles, Roger Keith Aug. 21, 2014, 5:39 p.m. UTC | #2
Comment inline.
On Aug 21, 2014, at 11:01 AM, Mike Holmes <mike.holmes@linaro.org> wrote:

> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> ---
> example/generator/odp_generator.c   |  2 +-
> example/l2fwd/odp_l2fwd.c           |  2 +-
> example/odp_example/odp_example.c   |  2 +-
> example/packet/odp_pktio.c          |  2 +-
> example/timer/odp_timer_test.c      |  2 +-
> include/odp_init.h                  | 22 +++++++++++++++++++---
> platform/linux-dpdk/odp_init.c      |  3 ++-
> platform/linux-generic/odp_init.c   |  3 ++-
> platform/linux-keystone2/odp_init.c |  3 ++-
> test/api_test/odp_common.c          |  2 +-
> 10 files changed, 31 insertions(+), 12 deletions(-)
> 
> diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
> index 9fa9b37..ba7aa68 100644
> --- a/example/generator/odp_generator.c
> +++ b/example/generator/odp_generator.c
> @@ -525,7 +525,7 @@ int main(int argc, char *argv[])
> 	int core_count;
> 
> 	/* Init ODP before calling anything else */
> -	if (odp_init_global()) {
> +	if (odp_init_global(NULL, NULL)) {
> 		ODP_ERR("Error: ODP global init failed.\n");
> 		exit(EXIT_FAILURE);
> 	}
> diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c
> index d74449a..f8d6729 100644
> --- a/example/l2fwd/odp_l2fwd.c
> +++ b/example/l2fwd/odp_l2fwd.c
> @@ -323,7 +323,7 @@ int main(int argc, char *argv[])
> 	odp_pktio_t pktio;
> 
> 	/* Init ODP before calling anything else */
> -	if (odp_init_global()) {
> +	if (odp_init_global(NULL, NULL)) {
> 		ODP_ERR("Error: ODP global init failed.\n");
> 		exit(EXIT_FAILURE);
> 	}
> diff --git a/example/odp_example/odp_example.c b/example/odp_example/odp_example.c
> index f0bdf29..3d38ac7 100644
> --- a/example/odp_example/odp_example.c
> +++ b/example/odp_example/odp_example.c
> @@ -951,7 +951,7 @@ int main(int argc, char *argv[])
> 
> 	memset(thread_tbl, 0, sizeof(thread_tbl));
> 
> -	if (odp_init_global()) {
> +	if (odp_init_global(NULL, NULL)) {
> 		printf("ODP global init failed.\n");
> 		return -1;
> 	}
> diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
> index f247bd0..f3543a0 100644
> --- a/example/packet/odp_pktio.c
> +++ b/example/packet/odp_pktio.c
> @@ -311,7 +311,7 @@ int main(int argc, char *argv[])
> 	int core_count;
> 
> 	/* Init ODP before calling anything else */
> -	if (odp_init_global()) {
> +	if (odp_init_global(NULL, NULL)) {
> 		ODP_ERR("Error: ODP global init failed.\n");
> 		exit(EXIT_FAILURE);
> 	}
> diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
> index dbe0e5b..1af8c2b 100644
> --- a/example/timer/odp_timer_test.c
> +++ b/example/timer/odp_timer_test.c
> @@ -210,7 +210,7 @@ int main(int argc, char *argv[])
> 
> 	memset(thread_tbl, 0, sizeof(thread_tbl));
> 
> -	if (odp_init_global()) {
> +	if (odp_init_global(NULL, NULL)) {
> 		printf("ODP global init failed.\n");
> 		return -1;
> 	}
> diff --git a/include/odp_init.h b/include/odp_init.h
> index 490324a..45db5f5 100644
> --- a/include/odp_init.h
> +++ b/include/odp_init.h
> @@ -23,23 +23,39 @@ extern "C" {
> #include <odp_std_types.h>
> 
> 
> +/**
> + * ODP  initialisation
> + * Data that is required to initialize the ODP
> + * application, such as specifying a logging callback, the log level etc.
> + */
> +typedef struct odp_global_init {
> +} odp_global_init_t;
> 
> +/**
> + * ODP  platform initialization
> + * Platform specific data. ODP does nothing with
> + * this data.
> + */
> +typedef struct odp_global_platform_init {
> +} odp_global_platform_init_t;
> 
> /**
> - * Perform global ODP initalisation.
> + * Perform global ODP initialisation.
>  *
>  * This function must be called once before calling
>  * any other ODP API functions.
>  *
>  * @return 0 if successful
>  */
> -int odp_init_global(void);
> +int odp_init_global(odp_global_init_t *params,
> +		    odp_global_platform_init_t *platform_params);
> 
> 
> /**
> - * Perform thread local ODP initalisation.
> + * Perform thread local ODP initialisation.
>  *
>  * All threads must call this function before calling
> + *
>  * any other ODP API functions.
>  * @param thr_id Thread id
>  * @return 0 if successful
> diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c
> index ecc2066..c3f937d 100644
> --- a/platform/linux-dpdk/odp_init.c
> +++ b/platform/linux-dpdk/odp_init.c
> @@ -50,7 +50,8 @@ int odp_init_dpdk(void)
> 	return 0;
> }
> 
> -int odp_init_global(void)
> +int odp_init_global(odp_global_init_t *params  ODP_UNUSED,
> +		    odp_global_platform_init_t *platform_params ODP_UNUSED)
> {
> 	odp_thread_init_global();

For the code to init DPDK I would suggest:

	if ( odp_init_platform(platform_params) ) {

To pass the platform_params down and change the odp_init_dpdk() to odp_init_platform() to make it generic. This means the odp_init_dpdk() routine needs to change to odp_init_platform() and get moved to its own platform specific file.
> 
> diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
> index 5b7e192..8b339e4 100644
> --- a/platform/linux-generic/odp_init.c
> +++ b/platform/linux-generic/odp_init.c
> @@ -9,7 +9,8 @@
> #include <odp_debug.h>
> 
> 
> -int odp_init_global(void)
> +int odp_init_global(odp_global_init_t *params  ODP_UNUSED,
> +		    odp_global_platform_init_t *platform_params ODP_UNUSED)
> {
> 	odp_thread_init_global();
> 
Add the same odp_init_platform() call here as well, plus add the routine in a platform specific file. I know the routine is empty for this case, but it does make it so the code does not have to be altered.

> diff --git a/platform/linux-keystone2/odp_init.c b/platform/linux-keystone2/odp_init.c
> index f832551..3111b51 100644
> --- a/platform/linux-keystone2/odp_init.c
> +++ b/platform/linux-keystone2/odp_init.c
> @@ -90,7 +90,8 @@ static int ti_init_hw_config(void)
> }
> 
> 
> -int odp_init_global(void)
> +int odp_init_global(odp_global_init_t *init_data ODP_UNUSED,
> +		    odp_global_platform_init_t *platform_params ODP_UNUSED)
> {
> 	odp_thread_init_global();

Add the same odp_init_platform() call here as well, plus add the routine in a platform specific file.
> 
> diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
> index 89ebd2d..fc583c0 100644
> --- a/test/api_test/odp_common.c
> +++ b/test/api_test/odp_common.c
> @@ -56,7 +56,7 @@ int odp_test_global_init(void)
> {
> 	memset(thread_tbl, 0, sizeof(thread_tbl));
> 
> -	if (odp_init_global()) {
> +	if (odp_init_global(NULL, NULL)) {
> 		ODP_ERR("ODP global init failed.\n");
> 		return -1;
> 	}
> -- 
> 1.9.1
> 
> 
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp

Let me know what you think?
++Keith

Keith Wiles, Principal Technologist with CTO office, Wind River mobile 972-213-5533
Maxim Uvarov Aug. 21, 2014, 6:24 p.m. UTC | #3
What do you about leaving original odp_init_global() without parameters?

Something like:

int odp_init_global_param(odp_global_init_t *params,
         odp_global_platform_init_t *platform_params);

int odp_init_global() {
          /* init defaults */
          odp_init_global_param(NULL, NULL);
}

So if some advance init is needed then app should call 
odp_init_global_param, on other way just
fall back to default.

Maxim.

On 08/21/2014 08:01 PM, Mike Holmes wrote:
> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> ---
>   example/generator/odp_generator.c   |  2 +-
>   example/l2fwd/odp_l2fwd.c           |  2 +-
>   example/odp_example/odp_example.c   |  2 +-
>   example/packet/odp_pktio.c          |  2 +-
>   example/timer/odp_timer_test.c      |  2 +-
>   include/odp_init.h                  | 22 +++++++++++++++++++---
>   platform/linux-dpdk/odp_init.c      |  3 ++-
>   platform/linux-generic/odp_init.c   |  3 ++-
>   platform/linux-keystone2/odp_init.c |  3 ++-
>   test/api_test/odp_common.c          |  2 +-
>   10 files changed, 31 insertions(+), 12 deletions(-)
>
> diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
> index 9fa9b37..ba7aa68 100644
> --- a/example/generator/odp_generator.c
> +++ b/example/generator/odp_generator.c
> @@ -525,7 +525,7 @@ int main(int argc, char *argv[])
>   	int core_count;
>   
>   	/* Init ODP before calling anything else */
> -	if (odp_init_global()) {
> +	if (odp_init_global(NULL, NULL)) {
>   		ODP_ERR("Error: ODP global init failed.\n");
>   		exit(EXIT_FAILURE);
>   	}
> diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c
> index d74449a..f8d6729 100644
> --- a/example/l2fwd/odp_l2fwd.c
> +++ b/example/l2fwd/odp_l2fwd.c
> @@ -323,7 +323,7 @@ int main(int argc, char *argv[])
>   	odp_pktio_t pktio;
>   
>   	/* Init ODP before calling anything else */
> -	if (odp_init_global()) {
> +	if (odp_init_global(NULL, NULL)) {
>   		ODP_ERR("Error: ODP global init failed.\n");
>   		exit(EXIT_FAILURE);
>   	}
> diff --git a/example/odp_example/odp_example.c b/example/odp_example/odp_example.c
> index f0bdf29..3d38ac7 100644
> --- a/example/odp_example/odp_example.c
> +++ b/example/odp_example/odp_example.c
> @@ -951,7 +951,7 @@ int main(int argc, char *argv[])
>   
>   	memset(thread_tbl, 0, sizeof(thread_tbl));
>   
> -	if (odp_init_global()) {
> +	if (odp_init_global(NULL, NULL)) {
>   		printf("ODP global init failed.\n");
>   		return -1;
>   	}
> diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
> index f247bd0..f3543a0 100644
> --- a/example/packet/odp_pktio.c
> +++ b/example/packet/odp_pktio.c
> @@ -311,7 +311,7 @@ int main(int argc, char *argv[])
>   	int core_count;
>   
>   	/* Init ODP before calling anything else */
> -	if (odp_init_global()) {
> +	if (odp_init_global(NULL, NULL)) {
>   		ODP_ERR("Error: ODP global init failed.\n");
>   		exit(EXIT_FAILURE);
>   	}
> diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
> index dbe0e5b..1af8c2b 100644
> --- a/example/timer/odp_timer_test.c
> +++ b/example/timer/odp_timer_test.c
> @@ -210,7 +210,7 @@ int main(int argc, char *argv[])
>   
>   	memset(thread_tbl, 0, sizeof(thread_tbl));
>   
> -	if (odp_init_global()) {
> +	if (odp_init_global(NULL, NULL)) {
>   		printf("ODP global init failed.\n");
>   		return -1;
>   	}
> diff --git a/include/odp_init.h b/include/odp_init.h
> index 490324a..45db5f5 100644
> --- a/include/odp_init.h
> +++ b/include/odp_init.h
> @@ -23,23 +23,39 @@ extern "C" {
>   #include <odp_std_types.h>
>   
>   
> +/**
> + * ODP  initialisation
> + * Data that is required to initialize the ODP
> + * application, such as specifying a logging callback, the log level etc.
> + */
> +typedef struct odp_global_init {
> +} odp_global_init_t;
>   
> +/**
> + * ODP  platform initialization
> + * Platform specific data. ODP does nothing with
> + * this data.
> + */
> +typedef struct odp_global_platform_init {
> +} odp_global_platform_init_t;
>   
>   /**
> - * Perform global ODP initalisation.
> + * Perform global ODP initialisation.
>    *
>    * This function must be called once before calling
>    * any other ODP API functions.
>    *
>    * @return 0 if successful
>    */
> -int odp_init_global(void);
> +int odp_init_global(odp_global_init_t *params,
> +		    odp_global_platform_init_t *platform_params);
>   
>   
>   /**
> - * Perform thread local ODP initalisation.
> + * Perform thread local ODP initialisation.
>    *
>    * All threads must call this function before calling
> + *
>    * any other ODP API functions.
>    * @param thr_id Thread id
>    * @return 0 if successful
> diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c
> index ecc2066..c3f937d 100644
> --- a/platform/linux-dpdk/odp_init.c
> +++ b/platform/linux-dpdk/odp_init.c
> @@ -50,7 +50,8 @@ int odp_init_dpdk(void)
>   	return 0;
>   }
>   
> -int odp_init_global(void)
> +int odp_init_global(odp_global_init_t *params  ODP_UNUSED,
> +		    odp_global_platform_init_t *platform_params ODP_UNUSED)
>   {
>   	odp_thread_init_global();
>   
> diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
> index 5b7e192..8b339e4 100644
> --- a/platform/linux-generic/odp_init.c
> +++ b/platform/linux-generic/odp_init.c
> @@ -9,7 +9,8 @@
>   #include <odp_debug.h>
>   
>   
> -int odp_init_global(void)
> +int odp_init_global(odp_global_init_t *params  ODP_UNUSED,
> +		    odp_global_platform_init_t *platform_params ODP_UNUSED)
>   {
>   	odp_thread_init_global();
>   
> diff --git a/platform/linux-keystone2/odp_init.c b/platform/linux-keystone2/odp_init.c
> index f832551..3111b51 100644
> --- a/platform/linux-keystone2/odp_init.c
> +++ b/platform/linux-keystone2/odp_init.c
> @@ -90,7 +90,8 @@ static int ti_init_hw_config(void)
>   }
>   
>   
> -int odp_init_global(void)
> +int odp_init_global(odp_global_init_t *init_data ODP_UNUSED,
> +		    odp_global_platform_init_t *platform_params ODP_UNUSED)
>   {
>   	odp_thread_init_global();
>   
> diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
> index 89ebd2d..fc583c0 100644
> --- a/test/api_test/odp_common.c
> +++ b/test/api_test/odp_common.c
> @@ -56,7 +56,7 @@ int odp_test_global_init(void)
>   {
>   	memset(thread_tbl, 0, sizeof(thread_tbl));
>   
> -	if (odp_init_global()) {
> +	if (odp_init_global(NULL, NULL)) {
>   		ODP_ERR("ODP global init failed.\n");
>   		return -1;
>   	}
Maxim Uvarov Aug. 21, 2014, 6:25 p.m. UTC | #4
On 08/21/2014 10:24 PM, Maxim Uvarov wrote:
> What do you 
think
> about leaving original odp_init_global() without parameters?
>
> Something like:
>
> int odp_init_global_param(odp_global_init_t *params,
>         odp_global_platform_init_t *platform_params);
>
> int odp_init_global() {
>          /* init defaults */
>          odp_init_global_param(NULL, NULL);
> }
>
> So if some advance init is needed then app should call 
> odp_init_global_param, on other way just
> fall back to default.
>
> Maxim.
>
> On 08/21/2014 08:01 PM, Mike Holmes wrote:
>> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
>> ---
>>   example/generator/odp_generator.c   |  2 +-
>>   example/l2fwd/odp_l2fwd.c           |  2 +-
>>   example/odp_example/odp_example.c   |  2 +-
>>   example/packet/odp_pktio.c          |  2 +-
>>   example/timer/odp_timer_test.c      |  2 +-
>>   include/odp_init.h                  | 22 +++++++++++++++++++---
>>   platform/linux-dpdk/odp_init.c      |  3 ++-
>>   platform/linux-generic/odp_init.c   |  3 ++-
>>   platform/linux-keystone2/odp_init.c |  3 ++-
>>   test/api_test/odp_common.c          |  2 +-
>>   10 files changed, 31 insertions(+), 12 deletions(-)
>>
>> diff --git a/example/generator/odp_generator.c 
>> b/example/generator/odp_generator.c
>> index 9fa9b37..ba7aa68 100644
>> --- a/example/generator/odp_generator.c
>> +++ b/example/generator/odp_generator.c
>> @@ -525,7 +525,7 @@ int main(int argc, char *argv[])
>>       int core_count;
>>         /* Init ODP before calling anything else */
>> -    if (odp_init_global()) {
>> +    if (odp_init_global(NULL, NULL)) {
>>           ODP_ERR("Error: ODP global init failed.\n");
>>           exit(EXIT_FAILURE);
>>       }
>> diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c
>> index d74449a..f8d6729 100644
>> --- a/example/l2fwd/odp_l2fwd.c
>> +++ b/example/l2fwd/odp_l2fwd.c
>> @@ -323,7 +323,7 @@ int main(int argc, char *argv[])
>>       odp_pktio_t pktio;
>>         /* Init ODP before calling anything else */
>> -    if (odp_init_global()) {
>> +    if (odp_init_global(NULL, NULL)) {
>>           ODP_ERR("Error: ODP global init failed.\n");
>>           exit(EXIT_FAILURE);
>>       }
>> diff --git a/example/odp_example/odp_example.c 
>> b/example/odp_example/odp_example.c
>> index f0bdf29..3d38ac7 100644
>> --- a/example/odp_example/odp_example.c
>> +++ b/example/odp_example/odp_example.c
>> @@ -951,7 +951,7 @@ int main(int argc, char *argv[])
>>         memset(thread_tbl, 0, sizeof(thread_tbl));
>>   -    if (odp_init_global()) {
>> +    if (odp_init_global(NULL, NULL)) {
>>           printf("ODP global init failed.\n");
>>           return -1;
>>       }
>> diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
>> index f247bd0..f3543a0 100644
>> --- a/example/packet/odp_pktio.c
>> +++ b/example/packet/odp_pktio.c
>> @@ -311,7 +311,7 @@ int main(int argc, char *argv[])
>>       int core_count;
>>         /* Init ODP before calling anything else */
>> -    if (odp_init_global()) {
>> +    if (odp_init_global(NULL, NULL)) {
>>           ODP_ERR("Error: ODP global init failed.\n");
>>           exit(EXIT_FAILURE);
>>       }
>> diff --git a/example/timer/odp_timer_test.c 
>> b/example/timer/odp_timer_test.c
>> index dbe0e5b..1af8c2b 100644
>> --- a/example/timer/odp_timer_test.c
>> +++ b/example/timer/odp_timer_test.c
>> @@ -210,7 +210,7 @@ int main(int argc, char *argv[])
>>         memset(thread_tbl, 0, sizeof(thread_tbl));
>>   -    if (odp_init_global()) {
>> +    if (odp_init_global(NULL, NULL)) {
>>           printf("ODP global init failed.\n");
>>           return -1;
>>       }
>> diff --git a/include/odp_init.h b/include/odp_init.h
>> index 490324a..45db5f5 100644
>> --- a/include/odp_init.h
>> +++ b/include/odp_init.h
>> @@ -23,23 +23,39 @@ extern "C" {
>>   #include <odp_std_types.h>
>>     +/**
>> + * ODP  initialisation
>> + * Data that is required to initialize the ODP
>> + * application, such as specifying a logging callback, the log level 
>> etc.
>> + */
>> +typedef struct odp_global_init {
>> +} odp_global_init_t;
>>   +/**
>> + * ODP  platform initialization
>> + * Platform specific data. ODP does nothing with
>> + * this data.
>> + */
>> +typedef struct odp_global_platform_init {
>> +} odp_global_platform_init_t;
>>     /**
>> - * Perform global ODP initalisation.
>> + * Perform global ODP initialisation.
>>    *
>>    * This function must be called once before calling
>>    * any other ODP API functions.
>>    *
>>    * @return 0 if successful
>>    */
>> -int odp_init_global(void);
>> +int odp_init_global(odp_global_init_t *params,
>> +            odp_global_platform_init_t *platform_params);
>>       /**
>> - * Perform thread local ODP initalisation.
>> + * Perform thread local ODP initialisation.
>>    *
>>    * All threads must call this function before calling
>> + *
>>    * any other ODP API functions.
>>    * @param thr_id Thread id
>>    * @return 0 if successful
>> diff --git a/platform/linux-dpdk/odp_init.c 
>> b/platform/linux-dpdk/odp_init.c
>> index ecc2066..c3f937d 100644
>> --- a/platform/linux-dpdk/odp_init.c
>> +++ b/platform/linux-dpdk/odp_init.c
>> @@ -50,7 +50,8 @@ int odp_init_dpdk(void)
>>       return 0;
>>   }
>>   -int odp_init_global(void)
>> +int odp_init_global(odp_global_init_t *params  ODP_UNUSED,
>> +            odp_global_platform_init_t *platform_params ODP_UNUSED)
>>   {
>>       odp_thread_init_global();
>>   diff --git a/platform/linux-generic/odp_init.c 
>> b/platform/linux-generic/odp_init.c
>> index 5b7e192..8b339e4 100644
>> --- a/platform/linux-generic/odp_init.c
>> +++ b/platform/linux-generic/odp_init.c
>> @@ -9,7 +9,8 @@
>>   #include <odp_debug.h>
>>     -int odp_init_global(void)
>> +int odp_init_global(odp_global_init_t *params  ODP_UNUSED,
>> +            odp_global_platform_init_t *platform_params ODP_UNUSED)
>>   {
>>       odp_thread_init_global();
>>   diff --git a/platform/linux-keystone2/odp_init.c 
>> b/platform/linux-keystone2/odp_init.c
>> index f832551..3111b51 100644
>> --- a/platform/linux-keystone2/odp_init.c
>> +++ b/platform/linux-keystone2/odp_init.c
>> @@ -90,7 +90,8 @@ static int ti_init_hw_config(void)
>>   }
>>     -int odp_init_global(void)
>> +int odp_init_global(odp_global_init_t *init_data ODP_UNUSED,
>> +            odp_global_platform_init_t *platform_params ODP_UNUSED)
>>   {
>>       odp_thread_init_global();
>>   diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
>> index 89ebd2d..fc583c0 100644
>> --- a/test/api_test/odp_common.c
>> +++ b/test/api_test/odp_common.c
>> @@ -56,7 +56,7 @@ int odp_test_global_init(void)
>>   {
>>       memset(thread_tbl, 0, sizeof(thread_tbl));
>>   -    if (odp_init_global()) {
>> +    if (odp_init_global(NULL, NULL)) {
>>           ODP_ERR("ODP global init failed.\n");
>>           return -1;
>>       }
>
Wiles, Roger Keith Aug. 21, 2014, 6:28 p.m. UTC | #5
On Aug 21, 2014, at 1:24 PM, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> What do you about leaving original odp_init_global() without parameters?
> 
> Something like:
> 
> int odp_init_global_param(odp_global_init_t *params,
>        odp_global_platform_init_t *platform_params);
> 
> int odp_init_global() {
>         /* init defaults */
>         odp_init_global_param(NULL, NULL);
> }

I think I understand your reason, but I feel it is not required. Adding two NULL parameters is not a big concern IMO.
> 
> So if some advance init is needed then app should call odp_init_global_param, on other way just
> fall back to default.
> 
> Maxim.
> 
> On 08/21/2014 08:01 PM, Mike Holmes wrote:
>> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
>> ---
>>  example/generator/odp_generator.c   |  2 +-
>>  example/l2fwd/odp_l2fwd.c           |  2 +-
>>  example/odp_example/odp_example.c   |  2 +-
>>  example/packet/odp_pktio.c          |  2 +-
>>  example/timer/odp_timer_test.c      |  2 +-
>>  include/odp_init.h                  | 22 +++++++++++++++++++---
>>  platform/linux-dpdk/odp_init.c      |  3 ++-
>>  platform/linux-generic/odp_init.c   |  3 ++-
>>  platform/linux-keystone2/odp_init.c |  3 ++-
>>  test/api_test/odp_common.c          |  2 +-
>>  10 files changed, 31 insertions(+), 12 deletions(-)
>> 
>> diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
>> index 9fa9b37..ba7aa68 100644
>> --- a/example/generator/odp_generator.c
>> +++ b/example/generator/odp_generator.c
>> @@ -525,7 +525,7 @@ int main(int argc, char *argv[])
>>  	int core_count;
>>    	/* Init ODP before calling anything else */
>> -	if (odp_init_global()) {
>> +	if (odp_init_global(NULL, NULL)) {
>>  		ODP_ERR("Error: ODP global init failed.\n");
>>  		exit(EXIT_FAILURE);
>>  	}
>> diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c
>> index d74449a..f8d6729 100644
>> --- a/example/l2fwd/odp_l2fwd.c
>> +++ b/example/l2fwd/odp_l2fwd.c
>> @@ -323,7 +323,7 @@ int main(int argc, char *argv[])
>>  	odp_pktio_t pktio;
>>    	/* Init ODP before calling anything else */
>> -	if (odp_init_global()) {
>> +	if (odp_init_global(NULL, NULL)) {
>>  		ODP_ERR("Error: ODP global init failed.\n");
>>  		exit(EXIT_FAILURE);
>>  	}
>> diff --git a/example/odp_example/odp_example.c b/example/odp_example/odp_example.c
>> index f0bdf29..3d38ac7 100644
>> --- a/example/odp_example/odp_example.c
>> +++ b/example/odp_example/odp_example.c
>> @@ -951,7 +951,7 @@ int main(int argc, char *argv[])
>>    	memset(thread_tbl, 0, sizeof(thread_tbl));
>>  -	if (odp_init_global()) {
>> +	if (odp_init_global(NULL, NULL)) {
>>  		printf("ODP global init failed.\n");
>>  		return -1;
>>  	}
>> diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
>> index f247bd0..f3543a0 100644
>> --- a/example/packet/odp_pktio.c
>> +++ b/example/packet/odp_pktio.c
>> @@ -311,7 +311,7 @@ int main(int argc, char *argv[])
>>  	int core_count;
>>    	/* Init ODP before calling anything else */
>> -	if (odp_init_global()) {
>> +	if (odp_init_global(NULL, NULL)) {
>>  		ODP_ERR("Error: ODP global init failed.\n");
>>  		exit(EXIT_FAILURE);
>>  	}
>> diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
>> index dbe0e5b..1af8c2b 100644
>> --- a/example/timer/odp_timer_test.c
>> +++ b/example/timer/odp_timer_test.c
>> @@ -210,7 +210,7 @@ int main(int argc, char *argv[])
>>    	memset(thread_tbl, 0, sizeof(thread_tbl));
>>  -	if (odp_init_global()) {
>> +	if (odp_init_global(NULL, NULL)) {
>>  		printf("ODP global init failed.\n");
>>  		return -1;
>>  	}
>> diff --git a/include/odp_init.h b/include/odp_init.h
>> index 490324a..45db5f5 100644
>> --- a/include/odp_init.h
>> +++ b/include/odp_init.h
>> @@ -23,23 +23,39 @@ extern "C" {
>>  #include <odp_std_types.h>
>>    +/**
>> + * ODP  initialisation
>> + * Data that is required to initialize the ODP
>> + * application, such as specifying a logging callback, the log level etc.
>> + */
>> +typedef struct odp_global_init {
>> +} odp_global_init_t;
>>  +/**
>> + * ODP  platform initialization
>> + * Platform specific data. ODP does nothing with
>> + * this data.
>> + */
>> +typedef struct odp_global_platform_init {
>> +} odp_global_platform_init_t;
>>    /**
>> - * Perform global ODP initalisation.
>> + * Perform global ODP initialisation.
>>   *
>>   * This function must be called once before calling
>>   * any other ODP API functions.
>>   *
>>   * @return 0 if successful
>>   */
>> -int odp_init_global(void);
>> +int odp_init_global(odp_global_init_t *params,
>> +		    odp_global_platform_init_t *platform_params);
>>      /**
>> - * Perform thread local ODP initalisation.
>> + * Perform thread local ODP initialisation.
>>   *
>>   * All threads must call this function before calling
>> + *
>>   * any other ODP API functions.
>>   * @param thr_id Thread id
>>   * @return 0 if successful
>> diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c
>> index ecc2066..c3f937d 100644
>> --- a/platform/linux-dpdk/odp_init.c
>> +++ b/platform/linux-dpdk/odp_init.c
>> @@ -50,7 +50,8 @@ int odp_init_dpdk(void)
>>  	return 0;
>>  }
>>  -int odp_init_global(void)
>> +int odp_init_global(odp_global_init_t *params  ODP_UNUSED,
>> +		    odp_global_platform_init_t *platform_params ODP_UNUSED)
>>  {
>>  	odp_thread_init_global();
>>  diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
>> index 5b7e192..8b339e4 100644
>> --- a/platform/linux-generic/odp_init.c
>> +++ b/platform/linux-generic/odp_init.c
>> @@ -9,7 +9,8 @@
>>  #include <odp_debug.h>
>>    -int odp_init_global(void)
>> +int odp_init_global(odp_global_init_t *params  ODP_UNUSED,
>> +		    odp_global_platform_init_t *platform_params ODP_UNUSED)
>>  {
>>  	odp_thread_init_global();
>>  diff --git a/platform/linux-keystone2/odp_init.c b/platform/linux-keystone2/odp_init.c
>> index f832551..3111b51 100644
>> --- a/platform/linux-keystone2/odp_init.c
>> +++ b/platform/linux-keystone2/odp_init.c
>> @@ -90,7 +90,8 @@ static int ti_init_hw_config(void)
>>  }
>>    -int odp_init_global(void)
>> +int odp_init_global(odp_global_init_t *init_data ODP_UNUSED,
>> +		    odp_global_platform_init_t *platform_params ODP_UNUSED)
>>  {
>>  	odp_thread_init_global();
>>  diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
>> index 89ebd2d..fc583c0 100644
>> --- a/test/api_test/odp_common.c
>> +++ b/test/api_test/odp_common.c
>> @@ -56,7 +56,7 @@ int odp_test_global_init(void)
>>  {
>>  	memset(thread_tbl, 0, sizeof(thread_tbl));
>>  -	if (odp_init_global()) {
>> +	if (odp_init_global(NULL, NULL)) {
>>  		ODP_ERR("ODP global init failed.\n");
>>  		return -1;
>>  	}
> 
> 
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp

Keith Wiles, Principal Technologist with CTO office, Wind River mobile 972-213-5533
diff mbox

Patch

diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index 9fa9b37..ba7aa68 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -525,7 +525,7 @@  int main(int argc, char *argv[])
 	int core_count;
 
 	/* Init ODP before calling anything else */
-	if (odp_init_global()) {
+	if (odp_init_global(NULL, NULL)) {
 		ODP_ERR("Error: ODP global init failed.\n");
 		exit(EXIT_FAILURE);
 	}
diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c
index d74449a..f8d6729 100644
--- a/example/l2fwd/odp_l2fwd.c
+++ b/example/l2fwd/odp_l2fwd.c
@@ -323,7 +323,7 @@  int main(int argc, char *argv[])
 	odp_pktio_t pktio;
 
 	/* Init ODP before calling anything else */
-	if (odp_init_global()) {
+	if (odp_init_global(NULL, NULL)) {
 		ODP_ERR("Error: ODP global init failed.\n");
 		exit(EXIT_FAILURE);
 	}
diff --git a/example/odp_example/odp_example.c b/example/odp_example/odp_example.c
index f0bdf29..3d38ac7 100644
--- a/example/odp_example/odp_example.c
+++ b/example/odp_example/odp_example.c
@@ -951,7 +951,7 @@  int main(int argc, char *argv[])
 
 	memset(thread_tbl, 0, sizeof(thread_tbl));
 
-	if (odp_init_global()) {
+	if (odp_init_global(NULL, NULL)) {
 		printf("ODP global init failed.\n");
 		return -1;
 	}
diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
index f247bd0..f3543a0 100644
--- a/example/packet/odp_pktio.c
+++ b/example/packet/odp_pktio.c
@@ -311,7 +311,7 @@  int main(int argc, char *argv[])
 	int core_count;
 
 	/* Init ODP before calling anything else */
-	if (odp_init_global()) {
+	if (odp_init_global(NULL, NULL)) {
 		ODP_ERR("Error: ODP global init failed.\n");
 		exit(EXIT_FAILURE);
 	}
diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index dbe0e5b..1af8c2b 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -210,7 +210,7 @@  int main(int argc, char *argv[])
 
 	memset(thread_tbl, 0, sizeof(thread_tbl));
 
-	if (odp_init_global()) {
+	if (odp_init_global(NULL, NULL)) {
 		printf("ODP global init failed.\n");
 		return -1;
 	}
diff --git a/include/odp_init.h b/include/odp_init.h
index 490324a..45db5f5 100644
--- a/include/odp_init.h
+++ b/include/odp_init.h
@@ -23,23 +23,39 @@  extern "C" {
 #include <odp_std_types.h>
 
 
+/**
+ * ODP  initialisation
+ * Data that is required to initialize the ODP
+ * application, such as specifying a logging callback, the log level etc.
+ */
+typedef struct odp_global_init {
+} odp_global_init_t;
 
+/**
+ * ODP  platform initialization
+ * Platform specific data. ODP does nothing with
+ * this data.
+ */
+typedef struct odp_global_platform_init {
+} odp_global_platform_init_t;
 
 /**
- * Perform global ODP initalisation.
+ * Perform global ODP initialisation.
  *
  * This function must be called once before calling
  * any other ODP API functions.
  *
  * @return 0 if successful
  */
-int odp_init_global(void);
+int odp_init_global(odp_global_init_t *params,
+		    odp_global_platform_init_t *platform_params);
 
 
 /**
- * Perform thread local ODP initalisation.
+ * Perform thread local ODP initialisation.
  *
  * All threads must call this function before calling
+ *
  * any other ODP API functions.
  * @param thr_id Thread id
  * @return 0 if successful
diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c
index ecc2066..c3f937d 100644
--- a/platform/linux-dpdk/odp_init.c
+++ b/platform/linux-dpdk/odp_init.c
@@ -50,7 +50,8 @@  int odp_init_dpdk(void)
 	return 0;
 }
 
-int odp_init_global(void)
+int odp_init_global(odp_global_init_t *params  ODP_UNUSED,
+		    odp_global_platform_init_t *platform_params ODP_UNUSED)
 {
 	odp_thread_init_global();
 
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index 5b7e192..8b339e4 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -9,7 +9,8 @@ 
 #include <odp_debug.h>
 
 
-int odp_init_global(void)
+int odp_init_global(odp_global_init_t *params  ODP_UNUSED,
+		    odp_global_platform_init_t *platform_params ODP_UNUSED)
 {
 	odp_thread_init_global();
 
diff --git a/platform/linux-keystone2/odp_init.c b/platform/linux-keystone2/odp_init.c
index f832551..3111b51 100644
--- a/platform/linux-keystone2/odp_init.c
+++ b/platform/linux-keystone2/odp_init.c
@@ -90,7 +90,8 @@  static int ti_init_hw_config(void)
 }
 
 
-int odp_init_global(void)
+int odp_init_global(odp_global_init_t *init_data ODP_UNUSED,
+		    odp_global_platform_init_t *platform_params ODP_UNUSED)
 {
 	odp_thread_init_global();
 
diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
index 89ebd2d..fc583c0 100644
--- a/test/api_test/odp_common.c
+++ b/test/api_test/odp_common.c
@@ -56,7 +56,7 @@  int odp_test_global_init(void)
 {
 	memset(thread_tbl, 0, sizeof(thread_tbl));
 
-	if (odp_init_global()) {
+	if (odp_init_global(NULL, NULL)) {
 		ODP_ERR("ODP global init failed.\n");
 		return -1;
 	}