From patchwork Fri May 20 16:30:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 68274 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp3858551qge; Fri, 20 May 2016 08:53:44 -0700 (PDT) X-Received: by 10.55.170.200 with SMTP id t191mr4255231qke.100.1463759624326; Fri, 20 May 2016 08:53:44 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p64si18640686qha.129.2016.05.20.08.53.44; Fri, 20 May 2016 08:53:44 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 09728616DD; Fri, 20 May 2016 15:53:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id AB59E618CB; Fri, 20 May 2016 15:35:45 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 45B96618C9; Fri, 20 May 2016 15:35:40 +0000 (UTC) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) by lists.linaro.org (Postfix) with ESMTPS id 9F8466180E for ; Fri, 20 May 2016 15:32:26 +0000 (UTC) Received: by mail-lb0-f181.google.com with SMTP id k7so15786892lbm.0 for ; Fri, 20 May 2016 08:32:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RuklwXgErXpTh59D+r3CT2dfnRA4B2/w17N9HkVsXbM=; b=BO7xelK/fpakSc/vfo/YukyH7a0403cFM8B5yl/fO196e1EFM9EVdBYFJ11CTlZXjU fB9mBjKiJn/mG3q+yzBOWgxcg9Wz57wGJ3jthE1sWm5ZlwWYPAGIi6OagZ8JSwvUoJBJ +Wq/hyDsKlPZq7P1JHik4Z97qBUhL+eVXT+0PXslOTd8vLqAM6fV0iyj0+8zYCezAVAU 86VQZ12Eo1ghWVyQ0LrjjVtZkibM/RolekGoYGEoi9Iu1EEmOgTrT2fonHJZcKHuNgxd jb60Sm+gi+U9wCSGhGd3AA2KQh8iz8r7QHK7SxqLYoX1sHpzrc6Ga+VPoM4zfr0fTXV2 /RVQ== X-Gm-Message-State: AOPr4FVp6nKOkwFrWPP6FV+Oh8XgElZiFGhOi7F06pscMT9KOsR/vLm6km5n8pWr4RZTBOnapak= X-Received: by 10.112.141.71 with SMTP id rm7mr1422256lbb.56.1463758345540; Fri, 20 May 2016 08:32:25 -0700 (PDT) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-90-46.cust.bredband2.com. [83.233.90.46]) by smtp.gmail.com with ESMTPSA id tg1sm3348847lbb.7.2016.05.20.08.32.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 May 2016 08:32:24 -0700 (PDT) From: Christophe Milard To: maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Fri, 20 May 2016 18:30:40 +0200 Message-Id: <1463761851-37121-25-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1463761851-37121-1-git-send-email-christophe.milard@linaro.org> References: <1463761851-37121-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv9 24/35] example: l2fwd_simple: adding helper cmd line parsing X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" 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 --- 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 #include +#include #include #include @@ -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);