From patchwork Mon Feb 16 17:56:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 44724 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 232B121544 for ; Mon, 16 Feb 2015 17:56:41 +0000 (UTC) Received: by lbiz11 with SMTP id z11sf20496lbi.2 for ; Mon, 16 Feb 2015 09:56:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=lvmgHpxHG5QtE0DpAE9lK4P86TgIOGL+MgndHBDOa6s=; b=AeqQ8jQWJlF2u+O5aGSNd/qZRPotqWpYhHQ5CvOidWHlg4crYHTtjF2tgzxo7qCJaa zvK03YKynHJLcwjCSwqhKxn6EEUmF/mm56Ul2HGEKV2MDx791mKSReEGi6OoXkoEggfF jzu5JpGccd0t3DEAxIDXePYZ4Ik1PxoJFJ7Vs4FtSL1cVngscFbCyZINuzVucXBg+a4g wyOUa0qXhr25e/Pf+sSvrCle5BVJwLTObMvxh9W+eQlg5oC3gK7JLNpo7HXBc6RhE3jd kbVt49QX0iruMJkYbiXrW4eI+4pbscRVWgISUkk4+45h+PkgjNxJw0KSNhcIhT5a6svn EBgg== X-Gm-Message-State: ALoCoQkS6vLPImW/UDs2KRk1qldka9VJNdxdxQNXcFDwaMdvdvOF+eLrFVVATNYSlJJGPdsrjKvi X-Received: by 10.180.101.101 with SMTP id ff5mr2901694wib.5.1424109400055; Mon, 16 Feb 2015 09:56:40 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.169 with SMTP id x9ls599712lad.72.gmail; Mon, 16 Feb 2015 09:56:39 -0800 (PST) X-Received: by 10.112.161.34 with SMTP id xp2mr24116623lbb.73.1424109399818; Mon, 16 Feb 2015 09:56:39 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id aw3si10461094lbc.151.2015.02.16.09.56.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Feb 2015 09:56:39 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by lams18 with SMTP id s18so31311019lam.13 for ; Mon, 16 Feb 2015 09:56:39 -0800 (PST) X-Received: by 10.112.37.197 with SMTP id a5mr24520880lbk.19.1424109399606; Mon, 16 Feb 2015 09:56:39 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1733079lbj; Mon, 16 Feb 2015 09:56:38 -0800 (PST) X-Received: by 10.140.218.202 with SMTP id o193mr526521qhb.13.1424109398121; Mon, 16 Feb 2015 09:56:38 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id b90si14941954qgb.50.2015.02.16.09.56.36 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 16 Feb 2015 09:56:38 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YNPuL-0003I7-48; Mon, 16 Feb 2015 17:56:33 +0000 Received: from mail-la0-f51.google.com ([209.85.215.51]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YNPuE-0003HF-QG for lng-odp@lists.linaro.org; Mon, 16 Feb 2015 17:56:26 +0000 Received: by labhz20 with SMTP id hz20so31158358lab.0 for ; Mon, 16 Feb 2015 09:56:20 -0800 (PST) X-Received: by 10.112.12.134 with SMTP id y6mr24892948lbb.34.1424109380723; Mon, 16 Feb 2015 09:56:20 -0800 (PST) Received: from localhost.localdomain (broadband-46-188-125-106.2com.net. [46.188.125.106]) by mx.google.com with ESMTPSA id uf3sm3068568lbc.44.2015.02.16.09.56.19 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Feb 2015 09:56:19 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 16 Feb 2015 20:56:13 +0300 Message-Id: <1424109373-29629-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 X-Topics: patch Subject: [lng-odp] [PATCH] example: odp_packet uncomment polling queues X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 odp_packet examples has polling queues commented out with if 1. Input queue (ODP_QUEUE_TYPE_PKTIN) is not attached to scheduler but it make sense in example show that packets can be accessed with polling queues also. https://bugs.linaro.org/show_bug.cgi?id=301 Signed-off-by: Maxim Uvarov --- example/packet/odp_pktio.c | 75 +++++++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index 5eec796..537bb8a 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -52,6 +52,11 @@ */ #define APPL_MODE_PKT_QUEUE 1 +/** @def APPL_MODE_PKT_SHED + * @brief The application will handle packets with sheduler + */ +#define APPL_MODE_PKT_SCHED 2 + /** @def PRINT_APPL_MODE(x) * @brief Macro to print the current status of how the application handles * packets. @@ -113,13 +118,22 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool, int mode) if (pktio == ODP_PKTIO_INVALID) EXAMPLE_ABORT("Error: pktio create failed for %s\n", dev); - /* no further setup needed for burst mode */ - if (mode == APPL_MODE_PKT_BURST) + switch (mode) { + case APPL_MODE_PKT_BURST: + /* no further setup needed for burst mode */ return pktio; + case APPL_MODE_PKT_QUEUE: + qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; + qparam.sched.sync = ODP_SCHED_SYNC_NONE; + qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; + break; + case APPL_MODE_PKT_SCHED: + qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; + qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; + qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; + break; + } - qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; - qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; - qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; snprintf(inq_name, sizeof(inq_name), "%" PRIu64 "-pktio_inq_def", odp_pktio_to_u64(pktio)); inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0'; @@ -177,17 +191,20 @@ static void *pktio_queue_thread(void *arg) for (;;) { odp_pktio_t pktio_tmp; -#if 1 - /* Use schedule to get buf from any input queue */ - ev = odp_schedule(NULL, ODP_SCHED_WAIT); -#else - /* Always dequeue from the same input queue */ - buf = odp_queue_deq(inq_def); - if (!odp_buffer_is_valid(buf)) - continue; -#endif - - pkt = odp_packet_from_event(ev); + switch (thr_args->mode) { + case APPL_MODE_PKT_QUEUE: + /* Always dequeue from the same input queue */ + ev = odp_queue_deq(odp_pktio_inq_getdef(pktio)); + pkt = odp_packet_from_event(ev); + if (!odp_packet_is_valid(pkt)) + continue; + break; + case APPL_MODE_PKT_SCHED: + /* Use schedule to get buf from any input queue */ + ev = odp_schedule(NULL, ODP_SCHED_WAIT); + pkt = odp_packet_from_event(ev); + break; + } /* Drop packets with errors */ if (odp_unlikely(drop_err_pkts(&pkt, 1) == 0)) { @@ -544,10 +561,20 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) case 'm': i = atoi(optarg); - if (i == 0) + switch (i) { + case 0: appl_args->mode = APPL_MODE_PKT_BURST; - else + break; + case 1: appl_args->mode = APPL_MODE_PKT_QUEUE; + break; + case 2: + appl_args->mode = APPL_MODE_PKT_SCHED; + break; + default: + usage(argv[0]); + exit(EXIT_SUCCESS); + } break; case 'h': usage(argv[0]); @@ -595,10 +622,17 @@ static void print_info(char *progname, appl_args_t *appl_args) printf(" %s", appl_args->if_names[i]); printf("\n" "Mode: "); - if (appl_args->mode == APPL_MODE_PKT_BURST) + switch (appl_args->mode) { + case APPL_MODE_PKT_BURST: PRINT_APPL_MODE(APPL_MODE_PKT_BURST); - else + break; + case APPL_MODE_PKT_QUEUE: PRINT_APPL_MODE(APPL_MODE_PKT_QUEUE); + break; + case APPL_MODE_PKT_SCHED: + PRINT_APPL_MODE(APPL_MODE_PKT_SCHED); + break; + } printf("\n\n"); fflush(NULL); } @@ -618,6 +652,7 @@ static void usage(char *progname) " -i, --interface Eth interfaces (comma-separated, no spaces)\n" " -m, --mode 0: Burst send&receive packets (no queues)\n" " 1: Send&receive packets through ODP queues.\n" + " 2: Send&receive packets with odp_scheduler.\n" "\n" "Optional OPTIONS\n" " -c, --count CPU count.\n"