From patchwork Thu Jul 30 11:24:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balakrishna Garapati X-Patchwork-Id: 51693 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id D2D0722DB5 for ; Thu, 30 Jul 2015 11:24:22 +0000 (UTC) Received: by lafd3 with SMTP id d3sf13022159laf.1 for ; Thu, 30 Jul 2015 04:24:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list; bh=sVt5wcIOcLOvqMAr0P05R/F1t5tv0Y1ekYJLG7651YY=; b=Id4mlVm4aQ+LhEPRI2bq2Oed8DdtX/urRCu6RgHQPkL9UzgOlkqH2MweNATg9uqjDF eBfN/YLWQZN/Fn+epe6wCdCmNwfixXFFWr3UGb027ECnEprOEdDMQ/ByqEm1xtZGkeA+ 4uXsjj+lKxpnJIPXdSOgwWWaB2VIX0o5TKEbzXMcTjQKJ4lzNeARrka0aWmxectAZD1W tokZlI4JjEzx0Iu8gK7m9J6mabzwN3qX+dYyKwtayLzZLbYnVRMc33WYms2Z18oCWXcQ HH9ldy5BZn1+xozrNeskbvrWqR39bsasUfhBhafAmMKxMo839yyY4+SWFc3P64H1ZTn1 +osw== X-Gm-Message-State: ALoCoQnDo03b0i+f5AtquqhvR/R/7COOKVesxAoW5clcoblCum5/D0hyFRnNufEUnO/9TC5IX6zn X-Received: by 10.194.60.73 with SMTP id f9mr17638214wjr.6.1438255461787; Thu, 30 Jul 2015 04:24:21 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.196 with SMTP id a4ls138796lak.27.gmail; Thu, 30 Jul 2015 04:24:21 -0700 (PDT) X-Received: by 10.112.163.129 with SMTP id yi1mr44600439lbb.77.1438255461413; Thu, 30 Jul 2015 04:24:21 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id ap4si597201lac.21.2015.07.30.04.24.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jul 2015 04:24:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbbud7 with SMTP id ud7so21011410lbb.3 for ; Thu, 30 Jul 2015 04:24:21 -0700 (PDT) X-Received: by 10.152.18.162 with SMTP id x2mr44084026lad.73.1438255461254; Thu, 30 Jul 2015 04:24:21 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp528065lba; Thu, 30 Jul 2015 04:24:20 -0700 (PDT) X-Received: by 10.140.82.180 with SMTP id h49mr68270930qgd.29.1438255459749; Thu, 30 Jul 2015 04:24:19 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d76si747376qkh.116.2015.07.30.04.24.18; Thu, 30 Jul 2015 04:24:19 -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; Received: by lists.linaro.org (Postfix, from userid 109) id A575361D95; Thu, 30 Jul 2015 11:24:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 8B33C61D60; Thu, 30 Jul 2015 11:24:12 +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 B2C7D61D67; Thu, 30 Jul 2015 11:24:10 +0000 (UTC) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com [209.85.217.176]) by lists.linaro.org (Postfix) with ESMTPS id 7A99261C8C for ; Thu, 30 Jul 2015 11:24:09 +0000 (UTC) Received: by lbbyj8 with SMTP id yj8so24964925lbb.0 for ; Thu, 30 Jul 2015 04:24:08 -0700 (PDT) X-Received: by 10.152.8.130 with SMTP id r2mr39310380laa.17.1438255448076; Thu, 30 Jul 2015 04:24:08 -0700 (PDT) Received: from elxahtkds32.localdomain (host-95-192-53-28.mobileonline.telia.com. [95.192.53.28]) by smtp.gmail.com with ESMTPSA id bn2sm172259lbc.47.2015.07.30.04.24.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Jul 2015 04:24:07 -0700 (PDT) From: "Balakrishna.Garapati" To: stuart.haslam@linaro.org, maxim.uvarov@linaro.org Date: Thu, 30 Jul 2015 13:24:01 +0200 Message-Id: <1438255441-5150-1-git-send-email-balakrishna.garapati@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Cc: lng-odp@lists.linaro.org Subject: [lng-odp] [PATCHv3] example:generator:option to supply core mask X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: balakrishna.garapati@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Balakrishna.Garapati --- changed the command line argument conventions. example/generator/odp_generator.c | 57 ++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index d6ec758..19ad7b4 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -42,6 +42,7 @@ */ typedef struct { int cpu_count; /**< system CPU count */ + const char *mask; /**< core mask */ int if_count; /**< Number of interfaces to be used */ char **if_names; /**< Array of pointers to interface names */ char *if_str; /**< Storage for interface names */ @@ -633,18 +634,27 @@ int main(int argc, char *argv[]) if (args->appl.cpu_count) num_workers = args->appl.cpu_count; - /* ping mode need two worker */ - if (args->appl.mode == APPL_MODE_PING) - num_workers = 2; + if (args->appl.mask) { + (void)odp_cpumask_from_str(&cpumask, args->appl.mask); + num_workers = odp_cpumask_count(&cpumask); + } else { + num_workers = odp_cpumask_def_worker(&cpumask, num_workers); + } - /* Get default worker cpumask */ - num_workers = odp_cpumask_def_worker(&cpumask, num_workers); (void)odp_cpumask_to_str(&cpumask, cpumaskstr, sizeof(cpumaskstr)); printf("num worker threads: %i\n", num_workers); printf("first CPU: %i\n", odp_cpumask_first(&cpumask)); printf("cpu mask: %s\n", cpumaskstr); + /* ping mode need two workers */ + if (args->appl.mode == APPL_MODE_PING) { + if (num_workers < 2) { + EXAMPLE_ERR("Need at least two worker threads\n"); + exit(EXIT_FAILURE); + } + } + /* Create packet pool */ memset(¶ms, 0, sizeof(params)); params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE; @@ -692,12 +702,13 @@ int main(int argc, char *argv[]) memset(thread_tbl, 0, sizeof(thread_tbl)); if (args->appl.mode == APPL_MODE_PING) { - odp_cpumask_t cpu0_mask; + odp_cpumask_t cpu_mask; odp_queue_t tq; + int cpu_first, cpu_next; - /* Previous code forced both threads to CPU 0 */ - odp_cpumask_zero(&cpu0_mask); - odp_cpumask_set(&cpu0_mask, 0); + odp_cpumask_zero(&cpu_mask); + cpu_first = odp_cpumask_first(&cpumask); + odp_cpumask_set(&cpu_mask, cpu_first); tq = odp_queue_create("", ODP_QUEUE_TYPE_POLL, NULL); if (tq == ODP_QUEUE_INVALID) @@ -713,7 +724,7 @@ int main(int argc, char *argv[]) if (args->thread[1].tmo_ev == ODP_TIMEOUT_INVALID) abort(); args->thread[1].mode = args->appl.mode; - odph_linux_pthread_create(&thread_tbl[1], &cpu0_mask, + odph_linux_pthread_create(&thread_tbl[1], &cpu_mask, gen_recv_thread, &args->thread[1]); tq = odp_queue_create("", ODP_QUEUE_TYPE_POLL, NULL); @@ -730,7 +741,10 @@ int main(int argc, char *argv[]) if (args->thread[0].tmo_ev == ODP_TIMEOUT_INVALID) abort(); args->thread[0].mode = args->appl.mode; - odph_linux_pthread_create(&thread_tbl[0], &cpu0_mask, + cpu_next = odp_cpumask_next(&cpumask, cpu_first); + odp_cpumask_zero(&cpu_mask); + odp_cpumask_set(&cpu_mask, cpu_next); + odph_linux_pthread_create(&thread_tbl[0], &cpu_mask, gen_send_thread, &args->thread[0]); /* only wait send thread to join */ @@ -812,11 +826,12 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) static struct option longopts[] = { {"interface", required_argument, NULL, 'I'}, {"workers", required_argument, NULL, 'w'}, + {"coremask", required_argument, NULL, 'c'}, {"srcmac", required_argument, NULL, 'a'}, {"dstmac", required_argument, NULL, 'b'}, - {"srcip", required_argument, NULL, 'c'}, + {"srcip", required_argument, NULL, 's'}, {"dstip", required_argument, NULL, 'd'}, - {"packetsize", required_argument, NULL, 's'}, + {"packetsize", required_argument, NULL, 'p'}, {"mode", required_argument, NULL, 'm'}, {"count", required_argument, NULL, 'n'}, {"timeout", required_argument, NULL, 't'}, @@ -831,7 +846,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) appl_args->timeout = -1; while (1) { - opt = getopt_long(argc, argv, "+I:a:b:c:d:s:i:m:n:t:w:h", + opt = getopt_long(argc, argv, "+I:a:b:s:d:p:i:m:n:t:w:c:h", longopts, &long_index); if (opt == -1) break; /* No more options */ @@ -840,6 +855,9 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) case 'w': appl_args->cpu_count = atoi(optarg); break; + case 'c': + appl_args->mask = optarg; + break; /* parse packet-io interface names */ case 'I': len = strlen(optarg); @@ -908,7 +926,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) } break; - case 'c': + case 's': if (scan_ip(optarg, &appl_args->srcip) != 1) { EXAMPLE_ERR("wrong src ip:%s\n", optarg); exit(EXIT_FAILURE); @@ -922,7 +940,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) } break; - case 's': + case 'p': appl_args->payload = atoi(optarg); break; @@ -1021,14 +1039,17 @@ static void usage(char *progname) " -I, --interface Eth interfaces (comma-separated, no spaces)\n" " -a, --srcmac src mac address\n" " -b, --dstmac dst mac address\n" - " -c, --srcip src ip address\n" + " -s, --srcip src ip address\n" " -d, --dstip dst ip address\n" - " -s, --packetsize payload length of the packets\n" + " -p, --packetsize payload length of the packets\n" " -m, --mode work mode: send udp(u), receive(r), send icmp(p)\n" " -n, --count the number of packets to be send\n" " -t, --timeout only for ping mode, wait ICMP reply timeout seconds\n" " -i, --interval wait interval ms between sending each packet\n" " default is 1000ms. 0 for flood mode\n" + " -w, --workers specify number of workers need to be assigned to application\n" + " default is to assign all\n" + " -c, --coremask to set on cores\n" "\n" "Optional OPTIONS\n" " -h, --help Display help and exit.\n"