From patchwork Wed May 11 16:42:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 67584 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp305150qge; Wed, 11 May 2016 09:08:47 -0700 (PDT) X-Received: by 10.55.15.76 with SMTP id z73mr4519380qkg.209.1462982927179; Wed, 11 May 2016 09:08:47 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p4si5639024qki.191.2016.05.11.09.08.46; Wed, 11 May 2016 09:08:47 -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 C3AC0616BC; Wed, 11 May 2016 16:08:46 +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 7B79D6167D; Wed, 11 May 2016 15:48:22 +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 CF4126170C; Wed, 11 May 2016 15:48:19 +0000 (UTC) Received: from mail-lf0-f45.google.com (mail-lf0-f45.google.com [209.85.215.45]) by lists.linaro.org (Postfix) with ESMTPS id C3A476168C for ; Wed, 11 May 2016 15:44:34 +0000 (UTC) Received: by mail-lf0-f45.google.com with SMTP id j8so53751470lfd.2 for ; Wed, 11 May 2016 08:44:34 -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=m+0u7ZlFufMao959NTjhj+tLTaMQ1diwXjDi569dFDNbVy6whs5THTMpXeeNy9Nm8U PtbwjuKnZDK/oX6b4Ov7UQmoHQtARNwI7LwXJUER8JUhPZ8Mo3Yl/zE8xTThlQACQhpn eAcniWD5ZNG8Uvc92+lrWBxenGja68emHyjZp962RfCCgCV72620ySm2RDMbosllsMYX mUA+3087dOTV0uEZR1mHLI5fv855e5wcXbdsdR1+wNRL+3bbchQ5ChuGlUN/VW2ftidu Y4C7eibKPgX47NTQSxkTF+roonpn1+S7dS4GphMnVY+nWU/XvqE74WYtJWXFXNiYyZGo Zkrg== X-Gm-Message-State: AOPr4FUd/xlfzFOtR4rtZbje9IeMvGh5oHXi7hpUgBoTn+5sVAjKYB1j2xAuTWOc8btn/WQaN1M= X-Received: by 10.25.30.70 with SMTP id e67mr1935598lfe.144.1462981473720; Wed, 11 May 2016 08:44:33 -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 n37sm1421164lfg.46.2016.05.11.08.44.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 May 2016 08:44:33 -0700 (PDT) From: Christophe Milard To: brian.brooks@linaro.org, mike.holmes@linaro.org, lng-odp@lists.linaro.org Date: Wed, 11 May 2016 18:42:11 +0200 Message-Id: <1462984942-53326-28-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1462984942-53326-1-git-send-email-christophe.milard@linaro.org> References: <1462984942-53326-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv6 27/38] 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);