From patchwork Wed May 11 16:42:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 67577 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp302380qge; Wed, 11 May 2016 09:03:58 -0700 (PDT) X-Received: by 10.140.109.132 with SMTP id l4mr4472617qgf.9.1462982638295; Wed, 11 May 2016 09:03:58 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id y11si5628218qhy.79.2016.05.11.09.03.57; Wed, 11 May 2016 09:03:58 -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 B688761693; Wed, 11 May 2016 16:03:57 +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 308F0616F0; Wed, 11 May 2016 15:47:00 +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 4664B616DE; Wed, 11 May 2016 15:46:52 +0000 (UTC) Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com [209.85.215.50]) by lists.linaro.org (Postfix) with ESMTPS id DD55B6167A for ; Wed, 11 May 2016 15:44:27 +0000 (UTC) Received: by mail-lf0-f50.google.com with SMTP id m64so53862829lfd.1 for ; Wed, 11 May 2016 08:44:27 -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=A0dwH4cHDF8j5W76awf2JpiuSJk1qWzlph5P13PHp/D19OMALiG4PraZrikCVDe5cc WrT+4RJ7oOuVyb7XQ/FYDuU3t2dLcXh0STefpsH5REf3HS+dK0q3BE03rYmPKaH7kjk1 TwVv62OyoLj2UaZX54DSXmax3Z03QFB9jbvzAUH5x4Q2h/rHXIYLKi071Aur5wsodGlQ m/3ufIpC17/54dXZ5sG/7nh9Zdayzf60mPbeIE/thr72wKM5Jpj6MrcQVlCjr/6dKRI6 8Zzdr8Bpmif4sTqvAjeZ435Ay+kLooqjTEeqgDwQfy6sSY3G2VmahBJDVJPT6N6nwk9v 3sKg== X-Gm-Message-State: AOPr4FVJdiUg2DAAF75Z204mU9vfU03q1bde0NF533g5txuBUXsL+kAWJnPpr6nnOkd4saJgYSQ= X-Received: by 10.25.212.6 with SMTP id l6mr1928383lfg.163.1462981466820; Wed, 11 May 2016 08:44:26 -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.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 May 2016 08:44:26 -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:04 +0200 Message-Id: <1462984942-53326-21-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 20/38] 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) &&