aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoltan Kiss <zoltan.kiss@linaro.org>2015-11-20 16:30:38 +0000
committerZoltan Kiss <zoltan.kiss@linaro.org>2015-11-20 16:30:38 +0000
commit14ae91fae0a1293aa079e4fec5cd50db2ffb34ef (patch)
tree97735570de65a25f2614a795e363e0e177324036
parentf5a441303606b2f0ad06a657af2bbd958c648197 (diff)
linux-dpdk: init: allow passing DPDK cmd line through odp_global_init()
The platform_params parameter will convey that through. Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org>
-rw-r--r--platform/linux-dpdk/README9
-rw-r--r--platform/linux-dpdk/include/odp_packet_dpdk.h2
-rw-r--r--platform/linux-dpdk/odp_init.c36
3 files changed, 28 insertions, 19 deletions
diff --git a/platform/linux-dpdk/README b/platform/linux-dpdk/README
index 33d3f33b0..f35124092 100644
--- a/platform/linux-dpdk/README
+++ b/platform/linux-dpdk/README
@@ -222,8 +222,13 @@ To restore the NIC's back to kernel use something like this:
5. Running ODP apps
=================================================
-You need to supply the DPDK command line parameters in the ODP_PLATFORM_PARAMS
-environment variable:
+You need to supply the DPDK command line parameters either as a null-terminated
+array of char's to odp_global_init()'s platform_params parameter:
+
+ odp_global_init([params], "-n 4");
+
+Or, if it's NULL the platform tries to read the ODP_PLATFORM_PARAMS environment
+variable:
export ODP_PLATFORM_PARAMS="-n 4"
diff --git a/platform/linux-dpdk/include/odp_packet_dpdk.h b/platform/linux-dpdk/include/odp_packet_dpdk.h
index 8a16fd4ba..49a0fc817 100644
--- a/platform/linux-dpdk/include/odp_packet_dpdk.h
+++ b/platform/linux-dpdk/include/odp_packet_dpdk.h
@@ -84,5 +84,5 @@ int close_pkt_dpdk(pkt_dpdk_t * const pkt_dpdk);
int recv_pkt_dpdk(pkt_dpdk_t * const pkt_dpdk, odp_packet_t pkt_table[],
unsigned len);
-int odp_init_dpdk(void);
+int odp_init_dpdk(const char *cmdline);
#endif
diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c
index 186bd291f..e8eab7ae7 100644
--- a/platform/linux-dpdk/odp_init.c
+++ b/platform/linux-dpdk/odp_init.c
@@ -147,7 +147,11 @@ static void print_dpdk_env_help(void)
int dpdk_argc, save_optind;
parse_dpdk_args("--help", &dpdk_argc, &dpdk_argv);
- ODP_ERR("Missing: export ODP_PLATFORM_PARAMS=\"EAL options\"\n");
+ ODP_ERR("Neither (char *)platform_params were provided to "
+ "odp_init_global(),\n");
+ ODP_ERR("nor ODP_PLATFORM_PARAMS environment variable were "
+ "specified.\n");
+ ODP_ERR("A string of DPDK command line arguments should be provided");
ODP_ERR("Example: export ODP_PLATFORM_PARAMS=\"-n 4 --no-huge\"\n");
ODP_ERR("Note: -c argument substitutes automatically from odp coremask\n");
save_optind = optind;
@@ -159,35 +163,35 @@ static void print_dpdk_env_help(void)
}
-int odp_init_dpdk(void)
+int odp_init_dpdk(const char *cmdline)
{
char **dpdk_argv;
int dpdk_argc;
- char *env;
- char *new_env;
+ char *full_cmdline;
int core_mask, i, save_optind;
- env = getenv("ODP_PLATFORM_PARAMS");
- if (env == NULL) {
- print_dpdk_env_help();
- ODP_ERR("ODP_PLATFORM_PARAMS has to be exported\n");
- return -1;
+ if (cmdline == NULL) {
+ cmdline = getenv("ODP_PLATFORM_PARAMS");
+ if (cmdline == NULL) {
+ print_dpdk_env_help();
+ return -1;
+ }
}
for (i = 0, core_mask = 0; i < odp_cpu_count(); i++)
core_mask += (0x1 << i);
- new_env = calloc(1, strlen(env) + strlen("odpdpdk -c ") +
- sizeof(core_mask) + 1);
+ full_cmdline = calloc(1, strlen(cmdline) + strlen("odpdpdk -c ") +
+ sizeof(core_mask) + 1);
/* first argument is facility log, simply bind it to odpdpdk for now.*/
- sprintf(new_env, "odpdpdk -c 0x%x %s", core_mask, env);
+ sprintf(full_cmdline, "odpdpdk -c 0x%x %s", core_mask, cmdline);
- parse_dpdk_args(new_env, &dpdk_argc, &dpdk_argv);
+ parse_dpdk_args(full_cmdline, &dpdk_argc, &dpdk_argv);
for (i = 0; i < dpdk_argc; ++i)
ODP_DBG("arg[%d]: %s\n", i, dpdk_argv[i]);
fflush(stdout);
- free(new_env);
+ free(full_cmdline);
/* reset optind, the caller application might have used it */
save_optind = optind;
@@ -211,7 +215,7 @@ int odp_init_dpdk(void)
struct odp_global_data_s odp_global_data;
int odp_init_global(const odp_init_t *params,
- const odp_platform_init_t *platform_params ODP_UNUSED)
+ const odp_platform_init_t *platform_params)
{
odp_global_data.log_fn = odp_override_log;
odp_global_data.abort_fn = odp_override_abort;
@@ -225,7 +229,7 @@ int odp_init_global(const odp_init_t *params,
odp_system_info_init();
- if (odp_init_dpdk()) {
+ if (odp_init_dpdk((const char *)platform_params)) {
ODP_ERR("ODP dpdk init failed.\n");
return -1;
}