From patchwork Thu May 19 16:26:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 68149 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp3277477qge; Thu, 19 May 2016 08:47:29 -0700 (PDT) X-Received: by 10.51.14.137 with SMTP id fg9mr3509378igd.29.1463672849390; Thu, 19 May 2016 08:47:29 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j29si13781286ioi.2.2016.05.19.08.47.27; Thu, 19 May 2016 08:47:29 -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 AE48C617F1; Thu, 19 May 2016 15:47:27 +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 E92BB6180D; Thu, 19 May 2016 15:32:02 +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 3EA05618C5; Thu, 19 May 2016 15:31:56 +0000 (UTC) Received: from mail-lf0-f41.google.com (mail-lf0-f41.google.com [209.85.215.41]) by lists.linaro.org (Postfix) with ESMTPS id 2F868617EA for ; Thu, 19 May 2016 15:28:49 +0000 (UTC) Received: by mail-lf0-f41.google.com with SMTP id y84so38872157lfc.0 for ; Thu, 19 May 2016 08:28:49 -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=2ZicArtInpLR+/2ldor5iBc8j0qpu/+GYK/ceYwsriA=; b=Pjvp7SiS5HmcUTnhznLHLYPweOzb0N5wH+Dr4yusfVc3nIuJTO7h3SHQ0Tfo1+D6ev 2os2hHWPQFTlE45JqApoYVi0twzTJSyaYN6r3Tid/P1K3RCO0wTu8euTlyPk9sAsaUMe UXWzVjp8N+IHW4cNmSMC1tyWYOhEaZfwPNgJj8Ksv+yNIlis/39ULF+asnOsSMd6h4Q7 HAtfQcIqYOfSkfd6RWMJ4yPp0ynAuRLQbqwTqMz0NlHOuFsdlXvb7e88kTUsMlop9u/u oNf4SD7Pxyl2D0CrKw/qb4zCAjNhxIG5oyQ7MGxcvxtX4Oqrl/9S9nfGuyRMIOP6UW+D WFiw== X-Gm-Message-State: AOPr4FVMwQM5QciGpLNqbMyghs4be9m/2Qukc5T1krRRnUIRfdpQCVlfxeB90/cdz/oDwRzAfsE= X-Received: by 10.25.21.96 with SMTP id l93mr2535580lfi.41.1463671728031; Thu, 19 May 2016 08:28:48 -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.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 May 2016 08:28:47 -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:26:58 +0200 Message-Id: <1463675234-6739-20-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 19/35] example: generator: using agnostic function for ODP threads 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" odp_generator is changed to use the implementation agnostic ODP thread create and join functions, from helpers. odp_generator is hence no longer aware on how the odpthread is implemented. Signed-off-by: Christophe Milard --- example/generator/odp_generator.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index fd1141a..dd3e023 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -352,7 +352,7 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool) * @param arg thread arguments of type 'thread_args_t *' */ -static void *gen_send_thread(void *arg) +static int gen_send_thread(void *arg) { int thr; int ret; @@ -368,12 +368,12 @@ static void *gen_send_thread(void *arg) if (pktio == ODP_PKTIO_INVALID) { EXAMPLE_ERR(" [%02i] Error: lookup of pktio %s failed\n", thr, thr_args->pktio_dev); - return NULL; + return -1; } if (odp_pktout_queue(pktio, &pktout, 1) != 1) { EXAMPLE_ERR(" [%02i] Error: no output queue\n", thr); - return NULL; + return -1; } printf(" [%02i] created mode: SEND\n", thr); @@ -441,7 +441,7 @@ static void *gen_send_thread(void *arg) } } - return arg; + return 0; } /** @@ -515,7 +515,7 @@ static void print_pkts(int thr, odp_packet_t pkt_tbl[], unsigned len) * * @param arg thread arguments of type 'thread_args_t *' */ -static void *gen_recv_thread(void *arg) +static int gen_recv_thread(void *arg) { int thr; odp_pktio_t pktio; @@ -530,7 +530,7 @@ static void *gen_recv_thread(void *arg) if (pktio == ODP_PKTIO_INVALID) { EXAMPLE_ERR(" [%02i] Error: lookup of pktio %s failed\n", thr, thr_args->pktio_dev); - return NULL; + return -1; } printf(" [%02i] created mode: RECEIVE\n", thr); @@ -558,7 +558,7 @@ static void *gen_recv_thread(void *arg) odp_packet_free(pkt); } - return arg; + return 0; } /** @@ -621,7 +621,7 @@ static void print_global_stats(int num_workers) */ int main(int argc, char *argv[]) { - odph_linux_pthread_t thread_tbl[MAX_WORKERS]; + odph_odpthread_t thread_tbl[MAX_WORKERS]; odp_pool_t pool; int num_workers; int i; @@ -636,7 +636,7 @@ int main(int argc, char *argv[]) odp_event_t ev; odp_pktio_t *pktio; odp_instance_t instance; - odph_linux_thr_params_t thr_params; + odph_odpthread_params_t thr_params; /* Init ODP before calling anything else */ if (odp_init_global(&instance, NULL, NULL)) { @@ -786,8 +786,7 @@ int main(int argc, char *argv[]) thr_params.thr_type = ODP_THREAD_WORKER; thr_params.instance = instance; - odph_linux_pthread_create(&thread_tbl[1], &cpu_mask, - &thr_params); + odph_odpthreads_create(&thread_tbl[1], &cpu_mask, &thr_params); tq = odp_queue_create("", NULL); if (tq == ODP_QUEUE_INVALID) @@ -810,14 +809,13 @@ int main(int argc, char *argv[]) thr_params.start = gen_send_thread; thr_params.arg = &args->thread[0]; - odph_linux_pthread_create(&thread_tbl[0], &cpu_mask, - &thr_params); + odph_odpthreads_create(&thread_tbl[0], &cpu_mask, &thr_params); } else { int cpu = odp_cpumask_first(&cpumask); for (i = 0; i < num_workers; ++i) { odp_cpumask_t thd_mask; - void *(*thr_run_func) (void *); + int (*thr_run_func)(void *); int if_idx; if_idx = i % args->appl.if_count; @@ -856,8 +854,8 @@ int main(int argc, char *argv[]) thr_params.start = thr_run_func; thr_params.arg = &args->thread[i]; - odph_linux_pthread_create(&thread_tbl[i], - &thd_mask, &thr_params); + odph_odpthreads_create(&thread_tbl[i], + &thd_mask, &thr_params); cpu = odp_cpumask_next(&cpumask, cpu); } @@ -866,7 +864,8 @@ int main(int argc, char *argv[]) print_global_stats(num_workers); /* Master thread waits for other threads to exit */ - odph_linux_pthread_join(thread_tbl, num_workers); + for (i = 0; i < num_workers; ++i) + odph_odpthreads_join(&thread_tbl[i]); for (i = 0; i < args->appl.if_count; ++i) odp_pktio_stop(pktio[i]);