From patchwork Thu May 19 16:27:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 68155 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp3278607qge; Thu, 19 May 2016 08:49:54 -0700 (PDT) X-Received: by 10.55.217.3 with SMTP id u3mr15604446qki.109.1463672994811; Thu, 19 May 2016 08:49:54 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d124si13110752qka.244.2016.05.19.08.49.54; Thu, 19 May 2016 08:49:54 -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 6DB6E617EA; Thu, 19 May 2016 15:49:54 +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 92740618D2; Thu, 19 May 2016 15:32:28 +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 4E32A6182C; Thu, 19 May 2016 15:32:21 +0000 (UTC) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com [209.85.217.170]) by lists.linaro.org (Postfix) with ESMTPS id 0B44A61813 for ; Thu, 19 May 2016 15:28:54 +0000 (UTC) Received: by mail-lb0-f170.google.com with SMTP id ww9so25924032lbc.2 for ; Thu, 19 May 2016 08:28:53 -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=mJ1Aqf4VVSeM3c3uLMo6OCX71cO48ycqstQckc/x6uLV0FIk2UsrixPoSXU01QQhgw eL1wuQiRJEGmPPsnw7+K93kLoeaDCGyAwCpRv/U+iS1s9bUu9ClgtHedt3UZtBy1olJL w1AlfPBL/1YlbCKw0hw4f7m4JBqcLyn2Pxr+m4QbxCe8VHLjuq2cloN0FcMuXz1DKoeA fED1k3K2ku5gH5Da85k3rjzFic/9jlymQxejUoOgViNuf/siwKsA9PhQ9ayI0xm7RG6R fsdpEyJe6a66W6/2/2By0B8ZJ+xMWgvMKNqDEtd0aKxGinENQB84WgqXiWeODYhyDhGh eVVw== X-Gm-Message-State: AOPr4FXrXYHQCVoDs/+OQVhzRNuz3Lo38wX54Jas9bFmnb7e3/O2+1whrpdecQt+mIVxpf0H3CI= X-Received: by 10.112.133.1 with SMTP id oy1mr4288827lbb.79.1463671732969; Thu, 19 May 2016 08:28:52 -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 cv11sm2366290lbb.49.2016.05.19.08.28.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 May 2016 08:28:52 -0700 (PDT) From: Christophe Milard To: brian.brooks@linaro.org, maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Thu, 19 May 2016 18:27:03 +0200 Message-Id: <1463675234-6739-25-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1463675234-6739-1-git-send-email-christophe.milard@linaro.org> References: <1463675234-6739-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv8 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);