From patchwork Fri May 20 16:30:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 68275 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp3858842qge; Fri, 20 May 2016 08:54:15 -0700 (PDT) X-Received: by 10.55.4.210 with SMTP id 201mr4332353qke.103.1463759655171; Fri, 20 May 2016 08:54:15 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id t79si18730784qki.14.2016.05.20.08.54.14; Fri, 20 May 2016 08:54:15 -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 C650B61701; Fri, 20 May 2016 15:54:14 +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 ED48F618D0; Fri, 20 May 2016 15:35:47 +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 01ECC6180E; Fri, 20 May 2016 15:35:41 +0000 (UTC) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) by lists.linaro.org (Postfix) with ESMTPS id A5A8A6180F for ; Fri, 20 May 2016 15:32:27 +0000 (UTC) Received: by mail-lb0-f181.google.com with SMTP id k7so15787035lbm.0 for ; Fri, 20 May 2016 08:32: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=m2dGUIp1RrjuLFtiD50c53T0FcgzHbMCN1FxgX9UJdY=; b=KJzEopVfpEWWUsq9dY0ADNoTCb9ci/1vldkNnIzgx6IyMVZHbGTU/N24DkCNi8vMCk 8IWBmTb168Vj2+7FgoeRtUPD8Cs8yhdQnxU+NA3rIWfKQ43KZ0l07dSHz8K7EFPVwjbK +1MC61nu7UA7qAXs7Dt2uQsCm9CcUqnL00GQ0Mek1wpGgPzDzDoVhnnfYdSJgje//uvI vTibmzDCQNZ5y+tcpTF2uc4HjzRNuJVVhOdQ10BTU1nv4d3BwK7rqTB9TYvaPHdyWx5B cjC610mjxXNMvaf+TT7B4xqzZvKto+3b8sSRhhu1zW+0Hujcs9Jc842VIprP68keCXnh HXiQ== X-Gm-Message-State: AOPr4FUAaXUFv0CiZ2KJEWs2YQ75Mmjmld/XzIVX+tyOI8XFX1Z+RJYrjS+ElFtHkcC28i/Gpqw= X-Received: by 10.112.16.6 with SMTP id b6mr1331607lbd.13.1463758346533; Fri, 20 May 2016 08:32: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 tg1sm3348847lbb.7.2016.05.20.08.32.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 May 2016 08:32:25 -0700 (PDT) From: Christophe Milard To: maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Fri, 20 May 2016 18:30:41 +0200 Message-Id: <1463761851-37121-26-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 25/35] example: pktio: 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" pktio is changed to use the implementation agnostic ODP thread create and join functions, from helpers. pktio is hence no longer aware on how the odpthread is implemented. Signed-off-by: Christophe Milard --- example/packet/odp_pktio.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index dce9447..f500cf0 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -169,7 +169,7 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool, int mode) * * @param arg thread arguments of type 'thread_args_t *' */ -static void *pktio_queue_thread(void *arg) +static int pktio_queue_thread(void *arg) { int thr; odp_pktio_t pktio; @@ -189,7 +189,7 @@ static void *pktio_queue_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] looked up pktio:%02" PRIu64 @@ -203,7 +203,7 @@ static void *pktio_queue_thread(void *arg) (odp_pktin_event_queue(pktio, &inq, 1) != 1)) { EXAMPLE_ERR(" [%02i] Error: no input queue for %s\n", thr, thr_args->pktio_dev); - return NULL; + return -1; } /* Loop packets */ @@ -232,7 +232,7 @@ static void *pktio_queue_thread(void *arg) if (odp_pktout_queue(pktio_tmp, &pktout, 1) != 1) { EXAMPLE_ERR(" [%02i] Error: no pktout queue\n", thr); - return NULL; + return -1; } /* Swap Eth MACs and possibly IP-addrs before sending back */ @@ -252,7 +252,7 @@ static void *pktio_queue_thread(void *arg) } } - return NULL; + return 0; } /** @@ -260,7 +260,7 @@ static void *pktio_queue_thread(void *arg) * * @param arg thread arguments of type 'thread_args_t *' */ -static void *pktio_ifburst_thread(void *arg) +static int pktio_ifburst_thread(void *arg) { int thr; odp_pktio_t pktio; @@ -280,7 +280,7 @@ static void *pktio_ifburst_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] looked up pktio:%02" PRIu64 ", burst mode\n", @@ -288,12 +288,12 @@ static void *pktio_ifburst_thread(void *arg) if (odp_pktin_queue(pktio, &pktin, 1) != 1) { EXAMPLE_ERR(" [%02i] Error: no pktin queue\n", thr); - return NULL; + return -1; } if (odp_pktout_queue(pktio, &pktout, 1) != 1) { EXAMPLE_ERR(" [%02i] Error: no pktout queue\n", thr); - return NULL; + return -1; } /* Loop packets */ @@ -334,7 +334,7 @@ static void *pktio_ifburst_thread(void *arg) } } - return NULL; + return 0; } /** @@ -342,7 +342,7 @@ static void *pktio_ifburst_thread(void *arg) */ 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; @@ -351,7 +351,7 @@ int main(int argc, char *argv[]) char cpumaskstr[ODP_CPUMASK_STR_SIZE]; odp_pool_param_t params; odp_instance_t instance; - odph_linux_thr_params_t thr_params; + odph_odpthread_params_t thr_params; args = calloc(1, sizeof(args_t)); if (args == NULL) { @@ -419,7 +419,7 @@ int main(int argc, char *argv[]) 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; @@ -442,8 +442,7 @@ 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); } @@ -462,7 +461,8 @@ int main(int argc, char *argv[]) } /* 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_close(odp_pktio_lookup(args->thread[i].pktio_dev));