l2fwd_simple now calls the helper command line parsing so that helper
can collect its options. Hence enabling process mode run.

Signed-off-by: Christophe Milard <christophe.mil...@linaro.org>
---
 example/l2fwd_simple/odp_l2fwd_simple.c | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/example/l2fwd_simple/odp_l2fwd_simple.c 
b/example/l2fwd_simple/odp_l2fwd_simple.c
index c075744..daae038 100644
--- a/example/l2fwd_simple/odp_l2fwd_simple.c
+++ b/example/l2fwd_simple/odp_l2fwd_simple.c
@@ -6,6 +6,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <getopt.h>
 
 #include <odp_api.h>
 #include <odp/helper/linux.h>
@@ -121,10 +122,29 @@ int main(int argc, char **argv)
        odph_odpthread_t thd;
        odp_instance_t instance;
        odph_odpthread_params_t thr_params;
+       int opt;
+       int long_index;
+
+       static const struct option longopts[] = { {NULL, 0, NULL, 0} };
+       static const char *shortopts = "";
+
+       /* let helper collect its own arguments (e.g. --odph_proc) */
+       odph_parse_options(argc, argv, shortopts, longopts);
+
+       /*
+        * parse own options: currentely none, but this will move optind
+        * to the first non-option argument. (in case there where helprt args)
+        */
+       opterr = 0; /* do not issue errors on helper options */
+       while (1) {
+               opt = getopt_long(argc, argv, shortopts, longopts, &long_index);
+               if (-1 == opt)
+                       break;  /* No more options */
+       }
 
-       if (argc != 5 ||
-           odph_eth_addr_parse(&global.dst, argv[3]) != 0 ||
-           odph_eth_addr_parse(&global.src, argv[4]) != 0) {
+       if (argc != optind + 4 ||
+           odph_eth_addr_parse(&global.dst, argv[optind + 2]) != 0 ||
+           odph_eth_addr_parse(&global.src, argv[optind + 3]) != 0) {
                printf("Usage: odp_l2fwd_simple eth0 eth1 01:02:03:04:05:06"
                       " 07:08:09:0a:0b:0c\n");
                printf("Where eth0 and eth1 are the used interfaces"
@@ -158,8 +178,10 @@ int main(int argc, char **argv)
                exit(1);
        }
 
-       global.if0 = create_pktio(argv[1], pool, &global.if0in, &global.if0out);
-       global.if1 = create_pktio(argv[2], pool, &global.if1in, &global.if1out);
+       global.if0 = create_pktio(argv[optind], pool, &global.if0in,
+                                                               &global.if0out);
+       global.if1 = create_pktio(argv[optind + 1], pool, &global.if1in,
+                                                               &global.if1out);
 
        odp_cpumask_default_worker(&cpumask, 1);
 
-- 
2.5.0

_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to