From patchwork Fri May 20 16:30:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 68266 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp3855778qge; Fri, 20 May 2016 08:49:09 -0700 (PDT) X-Received: by 10.55.192.209 with SMTP id v78mr4290991qkv.122.1463759349723; Fri, 20 May 2016 08:49:09 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id s52si18714262qge.53.2016.05.20.08.49.09; Fri, 20 May 2016 08:49:09 -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 55C5F6164C; Fri, 20 May 2016 15:49:09 +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 54CBC617F8; Fri, 20 May 2016 15:34:53 +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 3A32B6186F; Fri, 20 May 2016 15:34:50 +0000 (UTC) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com [209.85.215.43]) by lists.linaro.org (Postfix) with ESMTPS id 5A8B7617F8 for ; Fri, 20 May 2016 15:32:19 +0000 (UTC) Received: by mail-lf0-f43.google.com with SMTP id e126so25589634lfg.2 for ; Fri, 20 May 2016 08:32:19 -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=DAg1QuYVb+etIFh4gpuEAOeiu5Y/l1WesKZs286ajTQ=; b=dwWWm8D+7b7rjr7baev8V+z//qPuNu006ZvtqnwJVi2CTUbgAmFBCti7mI3rDcGK1h b+jQn7Bw1FIqReOSIAnsOy0AJSI+aNOb1RBu98eaUlCkc+pV78DRnoqccfHEBccJRRku u4+q8ccjDxIG7YZxntl9zJol1t1+5U3Dm2WuZ6yj3/7eE33AZU7gx7za7DhD22sNkA8L vdB8beXAftlnRkjU5lcRQyEBBf3bjq4AHMIVBRSpMhYwYys876eT//FEHZfr0muuEi8t 1UmBmM8pUGj6F7Qk3Ouf3D8QOKpOG9O2uEDrlHNIhQNVbs+csrSLQvStB4YcMio9WI2K hDfg== X-Gm-Message-State: AOPr4FVHDEPVAh0bNreZLo2UmI65FtLSkk9U7HEE61N7l8axNGRZwYV8K63Sino21w2OnMdX2oE= X-Received: by 10.25.21.68 with SMTP id l65mr1185894lfi.44.1463758338232; Fri, 20 May 2016 08:32:18 -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 tg1sm3348847lbb.7.2016.05.20.08.32.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 May 2016 08:32:17 -0700 (PDT) From: Christophe Milard To: maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Fri, 20 May 2016 18:30:33 +0200 Message-Id: <1463761851-37121-18-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1463761851-37121-1-git-send-email-christophe.milard@linaro.org> References: <1463761851-37121-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv9 17/35] example: classifier: 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_classifier is changed to use the implementation agnostic ODP thread create and join functions, from helpers. odp_classifier is hence no longer aware on how the odpthread is implemented. Signed-off-by: Christophe Milard --- example/classifier/odp_classifier.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c index 071788d..5982446 100644 --- a/example/classifier/odp_classifier.c +++ b/example/classifier/odp_classifier.c @@ -254,7 +254,7 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool) * Worker threads to receive the packet * */ -static void *pktio_receive_thread(void *arg) +static int pktio_receive_thread(void *arg) { int thr; odp_pktout_queue_t pktout; @@ -298,7 +298,7 @@ static void *pktio_receive_thread(void *arg) if (odp_pktout_queue(pktio_tmp, &pktout, 1) != 1) { EXAMPLE_ERR(" [%02i] Error: no output queue\n", thr); - return NULL; + return -1; } pool = odp_packet_pool(pkt); @@ -324,7 +324,7 @@ static void *pktio_receive_thread(void *arg) } } - return NULL; + return 0; } static odp_cos_t configure_default_cos(odp_pktio_t pktio, appl_args_t *args) @@ -469,11 +469,10 @@ static void configure_cos(odp_cos_t default_cos, appl_args_t *args) */ 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; - int cpu; odp_cpumask_t cpumask; char cpumaskstr[ODP_CPUMASK_STR_SIZE]; odp_pool_param_t params; @@ -483,7 +482,7 @@ int main(int argc, char *argv[]) odp_shm_t shm; int ret; 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)) { @@ -571,25 +570,13 @@ int main(int argc, char *argv[]) thr_params.arg = args; thr_params.thr_type = ODP_THREAD_WORKER; thr_params.instance = instance; - - cpu = odp_cpumask_first(&cpumask); - for (i = 0; i < num_workers; ++i) { - odp_cpumask_t thd_mask; - /* - * Calls odp_thread_create(cpu) for each thread - */ - odp_cpumask_zero(&thd_mask); - odp_cpumask_set(&thd_mask, cpu); - odph_linux_pthread_create(&thread_tbl[i], &thd_mask, - &thr_params); - cpu = odp_cpumask_next(&cpumask, cpu); - } + odph_odpthreads_create(thread_tbl, &cpumask, &thr_params); print_cls_statistics(args); odp_pktio_stop(pktio); shutdown = 1; - odph_linux_pthread_join(thread_tbl, num_workers); + odph_odpthreads_join(thread_tbl); for (i = 0; i < args->policy_count; i++) { if ((i != args->policy_count - 1) &&