From patchwork Wed Feb 8 12:19:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 93633 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2704334obz; Wed, 8 Feb 2017 04:29:30 -0800 (PST) X-Received: by 10.107.56.194 with SMTP id f185mr8136175ioa.137.1486556970683; Wed, 08 Feb 2017 04:29:30 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 198si1522774itj.113.2017.02.08.04.29.30; Wed, 08 Feb 2017 04:29:30 -0800 (PST) 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 sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 09AEA634CB; Wed, 8 Feb 2017 12:29:30 +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=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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 0B368634DB; Wed, 8 Feb 2017 12:23:48 +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 8CE7C634E0; Wed, 8 Feb 2017 12:23:42 +0000 (UTC) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40091.outbound.protection.outlook.com [40.107.4.91]) by lists.linaro.org (Postfix) with ESMTPS id B99BD634C4 for ; Wed, 8 Feb 2017 12:19:52 +0000 (UTC) Received: from AM5PR0701CA0052.eurprd07.prod.outlook.com (10.169.145.142) by AMSPR07MB277.eurprd07.prod.outlook.com (10.242.227.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.5; Wed, 8 Feb 2017 12:19:51 +0000 Received: from DB3FFO11FD040.protection.gbl (2a01:111:f400:7e04::106) by AM5PR0701CA0052.outlook.office365.com (2603:10a6:203:2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.5 via Frontend Transport; Wed, 8 Feb 2017 12:19:50 +0000 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning linaro.org discourages use of 131.228.2.36 as permitted sender) Received: from hybrid2.ext.net.nokia.com (131.228.2.36) by DB3FFO11FD040.mail.protection.outlook.com (10.47.217.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.7 via Frontend Transport; Wed, 8 Feb 2017 12:19:50 +0000 Received: from fihe3nok1348.nsn-intra.net (10.158.36.136) by fihe3nok1347.nsn-intra.net (10.158.36.135) with Microsoft SMTP Server (TLS) id 15.1.466.34; Wed, 8 Feb 2017 14:19:49 +0200 Received: from mailrelay.int.nokia.com (10.130.128.21) by fihe3nok1348.nsn-intra.net (10.158.36.136) with Microsoft SMTP Server (TLS) id 15.1.466.34 via Frontend Transport; Wed, 8 Feb 2017 14:19:48 +0200 Received: from fihe3nok0734.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0734.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v18CJgxB027384 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 8 Feb 2017 14:19:42 +0200 Received: from 10.144.19.15 ([10.144.104.219]) by fihe3nok0734.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v18CJf6J027358 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Wed, 8 Feb 2017 14:19:41 +0200 X-HPESVCS-Source-Ip: 10.144.104.219 From: Petri Savolainen To: Date: Wed, 8 Feb 2017 14:19:39 +0200 Message-ID: <1486556381-22233-4-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1486556381-22233-1-git-send-email-petri.savolainen@linaro.org> References: <1486556381-22233-1-git-send-email-petri.savolainen@linaro.org> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.36; IPV:NLI; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(39450400003)(39410400002)(39840400002)(39860400002)(39850400002)(2980300002)(199003)(189002)(5660300001)(626004)(305945005)(2950100002)(47776003)(50986999)(6916009)(76176999)(48376002)(356003)(5003940100001)(110136004)(53936002)(38730400002)(189998001)(50226002)(50466002)(97736004)(36756003)(22756006)(92566002)(77096006)(68736007)(450100001)(2351001)(106466001)(105596002)(8936002)(81156014)(81166006)(86362001)(2906002)(8676002)(33646002); DIR:OUT; SFP:1102; SCL:1; SRVR:AMSPR07MB277; H:hybrid2.ext.net.nokia.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD040; 1:L708g0poEXQOfuEbf4On2Coc0q3uUGd/OJZgYeRCOKZSc+LCXK9HgCEwOl1xbsBmku8PxwfKXNxXIsCHkD48g5ugrKw0pBCQMKT89TddOwAPaoYx2baApPNObDUJADC8ecnfBFdgTZUPltVA9PhMfG0PREbgdmYv5rfZqnAkq/gOZ2TeRCfGhzv0DFjAdPn1Ycnk+EdYtvAZ8fdMd8bE7kh4pBCqnvQPSHMtr/VCXUWDHayl1kf6ykwHEOUbdhsQZl/SAFgVKOWShO8vnvbntJxViUZW/AcjOTpEHwpWYYLTKj1wDRAA5jKEJEESloL+knxYsVw9obhZOHdn7J4cAOq1IV/54LfEZg3aT9+mxgurWlfC71XfOS4ur4GUJB9cnN1oNdAB9xCjmVR95gWq5brtupV8PFI/8zgw0Lzucj3UZjJoqlLLpxe9QgTfXKCY1j/bal+4ypuopESJK9DT6RsD1sgq71Yp58eFXLxClHHr8mu3Qc1V3O9VFC0YIMlgZ6MQIZGvGphXs0RFsjVnXg== X-MS-Office365-Filtering-Correlation-Id: 56d36da6-0af8-4ff3-628e-08d4501cc794 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:AMSPR07MB277; X-Microsoft-Exchange-Diagnostics: 1; AMSPR07MB277; 3:CdNjdaxL981CLc7zrT8x+FG3N1oFrAvfzow+3lmkea0ucI6JAlBjfWojHwVPYr/R5ti4JEDw02eaVaTohvdyyyblWM5ckNx/bxnwg0NqOLmNtW+hfvemvLD7Uu0JQmgG19Arw7S0OWzp+TzlTaHZB2UGJilDjQQ5+EuBnGRXkQ8dW5XEyLxF9r38iqdSgQ4QKaQrfl2S5UQAoXsouiU738yWssksqp6TRPg4UqyKfpX4iBS8hDNM80lkCaFe05D9Bivv7AgXfLivZElpGzinmcVt/Fb+w3O1bnKL9yEKXCBla1vCL8zQ4wD0Ejf6YgRxUS6AkwCLdWQKVE2mQoOYcoLCexGC3tnJoEvtJ1dELrGhyiWO9Eh13EYtAQP49N2L; 25:1DG9wSIyAt/SKlIlrm7v+xp68RbPMu0bHumu8mBSEMUhQx0s4vl7GXO9O+E1ZMAE1IelQWTqugUWr/+ZEzohivmXcXLVZdHd+d2BEKQzt2rYg/umRjCbwoJXxLlsR0YAYpFB8YhLTEF1v7V+5JASqynJ0wgq4RQx3bH7DV8rALqnwzQNydkxk0SpjFOLEya5EDTadV6KKa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l2n3B2nfju15YbVMgqVccu6loyfWAOVIPSLY7RErB0Rmhr6xQ47LCZSAJGHZHCoLswuFgbVqNPVulUY6SqspuoNzVlZtwMHxHtfbZ+nnleCb35UUSD0uVSycVTK6KDQyCBPzgGt+yh9a6sCfM16y3WssPCtHmk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13016025)(20170203043)(8121501046)(5005006)(2017020702029)(13018025)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123555025)(20161123558025)(20161123564025)(20161123562025)(6072148); SRVR:AMSPR07MB277; BCL:0; PCL:0; RULEID:; SRVR:AMSPR07MB277; X-Microsoft-Exchange-Diagnostics: 1; AMSPR07MB277; 4:C5EegKJM387aY/i2ODNaytIEKuFzd/jb9wS9zsnasIEfRixmymr6fJtLV9iQ6Vn/GxCJ2BI6ZJsdEA3CvGzRtGbuC/nkMPR0+bVtgu5gDhZCtto2z784g0q8feTIC9vnwJkuCu4P376febdY3XD0PLT7O5Rr9zWKTMDjUw7x8ttZv9O3WGTkB6FMNjkBDL7+NbOd2r/SyqVLnOaUqlE6Ws3TvfmwaXgtfH+JpsoAiEJKx6riRIQKWmuD1d48XOkr+Ted7zRLLgFPGy2SGTEc0UU3Uv/VU0SP47nGgKF2h47VCegiOk8YD2KqswptvOHD5+fXzAb0OQptc5q3ErZ0jDe3SI032W5lOunyC2cT520QSGGPwvM8OfPQIeDlEHryn56EOScJXzi9k+7WVpVUSd8AllmMvVJukDCSPeM3aBMMnkwLBARvOPUDyrEc0uoUyxDshCHDarrkJqyF1OdoA4pL1g6ot02AvnSL2+3OmxTGxl8ScFF0XuLAeq8MD9Pk54fJoaSr0qBR0GIjNXrRgOQ3l1mg1kgT585c5NGp8SMerBFO7ji//f0hoHACMTM1ghj19EHJ2fvpMM9yroZfh8o80562cUMGL07W4OkRgC7nYpfZ2Avrey0ddXMIawXizp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VKfjgjs2WPoEYeRpTPUWXXW0EgeOV/soIc7eM1jlWAPjHqGakY+Nr6Jxz1bxpIPkJHm2ZnNF04vrH3BzvX5QfAPh/VC3P5OfyHoQ4wW6UemInIsQbJyRaaIKAB+JvHwz3BjaH8cKpR4JU8TKdlUfgPG9bvBbxU9GMd/DndoVeQNEWbgKiwhaCkKLcVsW6BoRIec9CA== X-Microsoft-Exchange-Diagnostics: 1; AMSPR07MB277; 6:5SmP5eH2cbG6SDJatLqwNsc72PN0A6g1eUjEFF0CtxjNpf0bhltCFwiqRTYTTELK6ZLqJaOHxDOAjbdXnv/liKBqSj7wszauDf1xussUS24lL+VyfJZ4OxLy5OqhreeZrvm4VniQX/5J6tQQzVL8+CX8egKrMHd0AkUZPAtMBfRzbnmJYBhXbjw6wWXqMVy8WZMVxdJiXtjDaKRUrgCEIdvxPHW72jU+Kvgut4ciqJSxsqNdM5W0KTfCmiQTBx4bxDxQRO3sEAICccbtPE9qPengF9SmLxLuNFxknwjljKAAvJg1087PTGkCC3On9R0e0JtwunUIz1ovHOLwF687WY9NWvT/s4aeHi3YjRpmNrWUHgP3jCfhpUmse3tHcvwwn6/SXhc7mdRxmHwRihFX5w==; 5:oCbVTNbCPPb89cXhzAglD65BDv4jMyu3d6nWDKROqfGf465+X8EusVFrLZI6ibKm3PkPFXKzrD7GGOUKG3a6qvQUGlvmgFDuTstABaqjwbCOcWxbvbYb/JicdBJFtASxmNS6pATc8M6nOi0NdbL02A==; 24:fOMMI4Aw8Ar3ieaDukYqQr2NqB11iKkjN110IQFE0KHaQn8hR2/6u/ltvLWukQydlIOoii2J0CEJeOhwTvMCMMSc88WyUm64hpnsD/gxnXs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AMSPR07MB277; 7:JppEIxka1drIq6+o0lKs1VTlcp/40KTOqVd9kttDyJKcLgOI0kJgMsFpNz0+2pk6PJRBamKZbeCgTdYM0xS9T22nRv1Eay0LlVlZEFJ22grjeSTKgtBYo7PIrofVWxDk/X2IqEU4jKgJNyFHcEqKO4QUbioHNHiNqFUbGq6dPnvyjVm0PgG1EHKMGW5JlJRA+fDvCUqU93rVe/5X0upxMTwHHYNPuUohzA4to9K4m1LFp+IlaykxZLUqu4hTEp6DcY83b9oJ7Ng/x2n+dEm9HnmnmsF1E6EzOCUJ3Lz7SYxJr78DMT5keXIONbaWpqZN0Flq54EoSsoaFpsAb7vaF4SDz/X87enusOPUaz9QQvgTxQOQ9x9TKQTNY2Nde+d+4K02Ys/tMZtNRVsaJIo3gwWBjeqgYPV6ef7RK1OFqsHSuq+ShaGcVMN2aFmlrrhgHbkTr94j9TzdcIeMGUBFYCNJscdZcBMvm/Ak+k/2duyEe2fYnxfs5B4sIpY5Asp9y45bq/PnmSJcQnOHGzffCw== X-OriginatorOrg: nokia.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2017 12:19:50.2687 (UTC) X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.36]; Helo=[hybrid2.ext.net.nokia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMSPR07MB277 Subject: [lng-odp] [PATCH 3/5] test: generator: various improvements 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" User may select number of worker threads (-w) or cpumask (-c) (but not both) to limit number of worker thread. Increased pool size since many threads empty the pool easily and result some threads to give up (on the first time those see pool empty). Added EXAMPLE_ERR() before abort() to make debugging easier. Signed-off-by: Petri Savolainen --- example/generator/odp_generator.c | 77 ++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 26 deletions(-) -- 2.8.1 diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 6ac8f2d..8062d87 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -22,10 +22,10 @@ #include -#define MAX_WORKERS 32 /**< max number of works */ -#define SHM_PKT_POOL_SIZE (512*2048) /**< pkt pool size */ -#define SHM_PKT_POOL_BUF_SIZE 1856 /**< pkt pool buf size */ -#define DEFAULT_PKT_INTERVAL 1000 /**< interval btw each pkt */ +#define MAX_WORKERS 32 /* Max number of workers */ +#define POOL_NUM_PKT 2048 /* Number of packets in packet pool */ +#define POOL_PKT_LEN 1856 /* Max packet length */ +#define DEFAULT_PKT_INTERVAL 1000 /* Interval between each packet */ #define APPL_MODE_UDP 0 /**< UDP mode */ #define APPL_MODE_PING 1 /**< ping mode */ @@ -41,7 +41,7 @@ * Parsed command line application arguments */ typedef struct { - int cpu_count; /**< system CPU count */ + int num_workers; /**< Number of worker thread */ const char *mask; /**< CPU mask */ int if_count; /**< Number of interfaces to be used */ char **if_names; /**< Array of pointers to interface names */ @@ -383,14 +383,17 @@ static int gen_send_thread(void *arg) (unsigned int)args->appl.number) break; + pkt = ODP_PACKET_INVALID; + if (args->appl.mode == APPL_MODE_UDP) pkt = pack_udp_pkt(thr_args->pool); else if (args->appl.mode == APPL_MODE_PING) pkt = pack_icmp_pkt(thr_args->pool); - else - pkt = ODP_PACKET_INVALID; - if (!odp_packet_is_valid(pkt)) { + if (pkt == ODP_PACKET_INVALID) { + /* Thread gives up as soon as it sees the pool empty. + * Depending on pool size and transmit latency, it may + * be normal that pool gets empty sometimes. */ EXAMPLE_ERR(" [%2i] alloc_single failed\n", thr); break; } @@ -671,13 +674,17 @@ int main(int argc, char *argv[]) /* Print both system and application information */ print_info(NO_PATH(argv[0]), &args->appl); - /* Default to system CPU count unless user specified */ + /* Default to max number of workers, unless user specified number of + * workers or cpumask */ num_workers = MAX_WORKERS; - if (args->appl.cpu_count) - num_workers = args->appl.cpu_count; - num_workers = odp_cpumask_default_worker(&cpumask, num_workers); - if (args->appl.mask) { + + if (args->appl.num_workers) { + /* -w option: number of workers */ + num_workers = args->appl.num_workers; + num_workers = odp_cpumask_default_worker(&cpumask, num_workers); + } else if (args->appl.mask) { + /* -c option: cpumask */ odp_cpumask_from_str(&cpumask, args->appl.mask); num_workers = odp_cpumask_count(&cpumask); } @@ -700,9 +707,9 @@ int main(int argc, char *argv[]) /* Create packet pool */ odp_pool_param_init(¶ms); - params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE; - params.pkt.len = SHM_PKT_POOL_BUF_SIZE; - params.pkt.num = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE; + params.pkt.seg_len = POOL_PKT_LEN; + params.pkt.len = POOL_PKT_LEN; + params.pkt.num = POOL_NUM_PKT; params.type = ODP_POOL_PACKET; pool = odp_pool_create("packet_pool", ¶ms); @@ -763,18 +770,24 @@ int main(int argc, char *argv[]) odp_cpumask_set(&cpu_mask, cpu_first); tq = odp_queue_create("", NULL); - if (tq == ODP_QUEUE_INVALID) + if (tq == ODP_QUEUE_INVALID) { + EXAMPLE_ERR("queue_create failed\n"); abort(); + } args->thread[1].pktio_dev = args->appl.if_names[0]; args->thread[1].pool = pool; args->thread[1].tp = tp; args->thread[1].tq = tq; args->thread[1].tim = odp_timer_alloc(tp, tq, NULL); - if (args->thread[1].tim == ODP_TIMER_INVALID) + if (args->thread[1].tim == ODP_TIMER_INVALID) { + EXAMPLE_ERR("timer_alloc failed\n"); abort(); + } args->thread[1].tmo_ev = odp_timeout_alloc(tmop); - if (args->thread[1].tmo_ev == ODP_TIMEOUT_INVALID) + if (args->thread[1].tmo_ev == ODP_TIMEOUT_INVALID) { + EXAMPLE_ERR("timeout_alloc failed\n"); abort(); + } args->thread[1].mode = args->appl.mode; memset(&thr_params, 0, sizeof(thr_params)); @@ -786,18 +799,24 @@ int main(int argc, char *argv[]) odph_odpthreads_create(&thread_tbl[1], &cpu_mask, &thr_params); tq = odp_queue_create("", NULL); - if (tq == ODP_QUEUE_INVALID) + if (tq == ODP_QUEUE_INVALID) { + EXAMPLE_ERR("queue_create failed\n"); abort(); + } args->thread[0].pktio_dev = args->appl.if_names[0]; args->thread[0].pool = pool; args->thread[0].tp = tp; args->thread[0].tq = tq; args->thread[0].tim = odp_timer_alloc(tp, tq, NULL); - if (args->thread[0].tim == ODP_TIMER_INVALID) + if (args->thread[0].tim == ODP_TIMER_INVALID) { + EXAMPLE_ERR("timer_alloc failed\n"); abort(); + } args->thread[0].tmo_ev = odp_timeout_alloc(tmop); - if (args->thread[0].tmo_ev == ODP_TIMEOUT_INVALID) + if (args->thread[0].tmo_ev == ODP_TIMEOUT_INVALID) { + EXAMPLE_ERR("timeout_alloc failed\n"); abort(); + } args->thread[0].mode = args->appl.mode; cpu_next = odp_cpumask_next(&cpumask, cpu_first); odp_cpumask_zero(&cpu_mask); @@ -819,17 +838,23 @@ int main(int argc, char *argv[]) args->thread[i].pktio_dev = args->appl.if_names[if_idx]; tq = odp_queue_create("", NULL); - if (tq == ODP_QUEUE_INVALID) + if (tq == ODP_QUEUE_INVALID) { + EXAMPLE_ERR("queue_create failed\n"); abort(); + } args->thread[i].pool = pool; args->thread[i].tp = tp; args->thread[i].tq = tq; args->thread[i].tim = odp_timer_alloc(tp, tq, NULL); - if (args->thread[i].tim == ODP_TIMER_INVALID) + if (args->thread[i].tim == ODP_TIMER_INVALID) { + EXAMPLE_ERR("timer_alloc failed\n"); abort(); + } args->thread[i].tmo_ev = odp_timeout_alloc(tmop); - if (args->thread[i].tmo_ev == ODP_TIMEOUT_INVALID) + if (args->thread[i].tmo_ev == ODP_TIMEOUT_INVALID) { + EXAMPLE_ERR("timeout_alloc failed\n"); abort(); + } args->thread[i].mode = args->appl.mode; if (args->appl.mode == APPL_MODE_UDP) { @@ -955,7 +980,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) switch (opt) { case 'w': - appl_args->cpu_count = atoi(optarg); + appl_args->num_workers = atoi(optarg); break; case 'c': appl_args->mask = optarg;