From patchwork Wed Apr 8 06:28:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Badicioiu X-Patchwork-Id: 46864 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F141E20553 for ; Wed, 8 Apr 2015 06:29:13 +0000 (UTC) Received: by wgin8 with SMTP id n8sf7178654wgi.0 for ; Tue, 07 Apr 2015 23:29:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:mime-version:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=EDet2GL9RYtOE3tG+l3Zso6s73F/II7SGkvhn217Lms=; b=Mpffdrj+Z2azv0zmXQfxRSS2ouKBItI9uNTqGVfJv+xaROUZ/VkRHwhHQg6+cLlRvA COL/Ua0CfYEPTxRAg4bywsQdIlnkRqzQ3aMfTC9QDUvK/s3MbXOFGpzZO5TBk5P671Ja EMv44FSD7CpZqzd4jg8uTFSjdSTLEBv0LHCzKVtskK1QBhB/kXLiWMIjOl5WOyrYWSCY NzaJAJgOT1tsTGpbU6OKxgg5/sBd/GrmedaC3gZqY1O7NI46+Q8XOBCD2YqunvZecL1K svkfBbL0x3Ti5dsX9Cc2lVlGrcgxRgvyDScfwF9xnEZOoQ9ZTjkUl7/+lipJdGQkCgD5 dLhA== X-Gm-Message-State: ALoCoQmdDJqTy7GpFbbkFGAxjDPSj9WM2mdan7glbfHLRQASj6XJhaHAEKgQq6NFhGkmE9USdC1N X-Received: by 10.180.11.101 with SMTP id p5mr1039729wib.3.1428474553307; Tue, 07 Apr 2015 23:29:13 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.98 with SMTP id l2ls122022lam.28.gmail; Tue, 07 Apr 2015 23:29:13 -0700 (PDT) X-Received: by 10.153.4.43 with SMTP id cb11mr13546085lad.122.1428474553044; Tue, 07 Apr 2015 23:29:13 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id wv10si7368474lac.79.2015.04.07.23.29.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Apr 2015 23:29:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbbuc2 with SMTP id uc2so55967628lbb.2 for ; Tue, 07 Apr 2015 23:29:12 -0700 (PDT) X-Received: by 10.112.16.196 with SMTP id i4mr10824769lbd.72.1428474552649; Tue, 07 Apr 2015 23:29:12 -0700 (PDT) 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.67.65 with SMTP id l1csp861651lbt; Tue, 7 Apr 2015 23:29:11 -0700 (PDT) X-Received: by 10.140.195.7 with SMTP id q7mr28195413qha.35.1428474551244; Tue, 07 Apr 2015 23:29:11 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f190si9976650qka.36.2015.04.07.23.29.09; Tue, 07 Apr 2015 23:29:11 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id A484264F72; Wed, 8 Apr 2015 06:29:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: *** X-Spam-Status: No, score=3.4 required=5.0 tests=RCVD_ILLEGAL_IP, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 9B78F64E5F; Wed, 8 Apr 2015 06:29:05 +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 0F87264F69; Wed, 8 Apr 2015 06:29:03 +0000 (UTC) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0073.outbound.protection.outlook.com [157.56.111.73]) by lists.linaro.org (Postfix) with ESMTPS id 80DD264E5F for ; Wed, 8 Apr 2015 06:29:02 +0000 (UTC) Received: from BN1PR0301MB0595.namprd03.prod.outlook.com (0.160.170.22) by BN1PR0301MB0641.namprd03.prod.outlook.com (0.160.171.14) with Microsoft SMTP Server (TLS) id 15.1.130.23; Wed, 8 Apr 2015 06:29:01 +0000 Received: from DM2PR03CA0003.namprd03.prod.outlook.com (10.141.96.13) by BN1PR0301MB0595.namprd03.prod.outlook.com (0.160.170.22) with Microsoft SMTP Server (TLS) id 15.1.130.23; Wed, 8 Apr 2015 06:29:00 +0000 Received: from BL2FFO11OLC009.protection.gbl (2a01:111:f400:7c09::163) by DM2PR03CA0003.outlook.office365.com (2a01:111:e400:2428::13) with Microsoft SMTP Server (TLS) id 15.1.130.23 via Frontend Transport; Wed, 8 Apr 2015 06:29:00 +0000 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning linaro.org discourages use of 192.88.158.2 as permitted sender) Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11OLC009.mail.protection.outlook.com (10.173.160.145) with Microsoft SMTP Server (TLS) id 15.1.136.16 via Frontend Transport; Wed, 8 Apr 2015 06:28:59 +0000 Received: from fsr-fed1364-15.ea.freescale.net (fsr-fed1364-15.ea.freescale.net [10.171.81.144]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t386SvPQ019537; Tue, 7 Apr 2015 23:28:58 -0700 From: To: Date: Wed, 8 Apr 2015 09:28:16 +0300 Message-ID: <1428474496-30434-1-git-send-email-alexandru.badicioiu@linaro.org> X-Mailer: git-send-email 1.7.3.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 130729481399038886; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; BMV:1; SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(229853001)(2351001)(110136001)(105596002)(106466001)(19580395003)(19580405001)(6806004)(86152002)(47776003)(87936001)(104016003)(36756003)(48376002)(50466002)(86362001)(50986999)(46102003)(50226001)(77156002)(15975445007)(62966003)(77096005)(33646002)(92566002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0301MB0595; H:az84smr01.freescale.net; FPR:; SPF:SoftFail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BN1PR0301MB0595; UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BN1PR0301MB0641; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(5002010); SRVR:BN1PR0301MB0595; BCL:0; PCL:0; RULEID:(401004)(400005); SRVR:BN1PR0301MB0595; X-Forefront-PRVS: 0540846A1D X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2015 06:28:59.6542 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR0301MB0595 X-Topics: patch Subject: [lng-odp] [PATCH 1/1 v1] examples: odp_ipsec: runtime select scheduled vs poll queues X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alexandru.badicioiu@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.217.176 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 From: Alexandru Badicioiu Signed-off-by: Alexandru Badicioiu --- example/ipsec/odp_ipsec.c | 64 +++++++++++++++++++++++--------------------- 1 files changed, 33 insertions(+), 31 deletions(-) diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 0cbf5b4..9fb048a 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -211,14 +211,14 @@ void free_pkt_ctx(pkt_ctx_t *ctx) /** * Example supports either polling queues or using odp_schedule - * - * Specify "CFLAGS=-DIPSEC_POLL_QUEUES" during configure to enable polling - * versus calling odp_schedule - * - * @todo Make this command line driven versus compile time - * (see https://bugs.linaro.org/show_bug.cgi?id=625) */ -#ifdef IPSEC_POLL_QUEUES +typedef odp_queue_t (*queue_create_func_t) + (const char *, odp_queue_type_t, odp_queue_param_t *); +typedef odp_event_t (*schedule_func_t) + (odp_queue_t *, uint64_t); + +static queue_create_func_t queue_create; +static schedule_func_t schedule; #define MAX_POLL_QUEUES 256 @@ -245,7 +245,8 @@ odp_queue_t polled_odp_queue_create(const char *name, if ((ODP_QUEUE_TYPE_SCHED == type) || (ODP_QUEUE_TYPE_PKTIN == type)) { poll_queues[num_polled_queues++] = my_queue; - printf("%s: adding %d\n", __func__, my_queue); + printf("%s: adding %"PRIu64"\n", __func__, + odp_queue_to_u64(my_queue)); } return my_queue; @@ -255,7 +256,7 @@ odp_queue_t polled_odp_queue_create(const char *name, * odp_schedule replacement to poll queues versus using ODP scheduler */ static -odp_buffer_t polled_odp_schedule(odp_queue_t *from, uint64_t wait) +odp_event_t polled_odp_schedule(odp_queue_t *from, uint64_t wait) { uint64_t start_cycle; uint64_t cycle; @@ -268,11 +269,11 @@ odp_buffer_t polled_odp_schedule(odp_queue_t *from, uint64_t wait) for (idx = 0; idx < num_polled_queues; idx++) { odp_queue_t queue = poll_queues[idx]; - odp_buffer_t buf; + odp_event_t buf; buf = odp_queue_deq(queue); - if (ODP_BUFFER_INVALID != buf) { + if (ODP_EVENT_INVALID != buf) { *from = queue; return buf; } @@ -285,11 +286,11 @@ odp_buffer_t polled_odp_schedule(odp_queue_t *from, uint64_t wait) break; if (0 == start_cycle) { - start_cycle = odp_time_get_cycles(); + start_cycle = odp_time_cycles(); continue; } - cycle = odp_time_get_cycles(); + cycle = odp_time_cycles(); diff = odp_time_diff_cycles(start_cycle, cycle); if (wait < diff) @@ -297,20 +298,9 @@ odp_buffer_t polled_odp_schedule(odp_queue_t *from, uint64_t wait) } *from = ODP_QUEUE_INVALID; - return ODP_BUFFER_INVALID; + return ODP_EVENT_INVALID; } - -#define QUEUE_CREATE(n, t, p) polled_odp_queue_create(n, t, p) -#define SCHEDULE(q, w) polled_odp_schedule(q, w) - -#else - -#define QUEUE_CREATE(n, t, p) odp_queue_create(n, t, p) -#define SCHEDULE(q, w) odp_schedule(q, w) - -#endif - /** * IPsec pre argument processing intialization */ @@ -330,7 +320,7 @@ void ipsec_init_pre(void) qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; - completionq = QUEUE_CREATE("completion", + completionq = queue_create("completion", ODP_QUEUE_TYPE_SCHED, &qparam); if (ODP_QUEUE_INVALID == completionq) { @@ -342,7 +332,7 @@ void ipsec_init_pre(void) qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; - seqnumq = QUEUE_CREATE("seqnum", + seqnumq = queue_create("seqnum", ODP_QUEUE_TYPE_SCHED, &qparam); if (ODP_QUEUE_INVALID == seqnumq) { @@ -448,7 +438,7 @@ void initialize_loop(char *intf) snprintf(queue_name, sizeof(queue_name), "%i-loop_inq_def", idx); queue_name[ODP_QUEUE_NAME_LEN - 1] = '\0'; - inq_def = QUEUE_CREATE(queue_name, ODP_QUEUE_TYPE_SCHED, &qparam); + inq_def = queue_create(queue_name, ODP_QUEUE_TYPE_SCHED, &qparam); if (ODP_QUEUE_INVALID == inq_def) { EXAMPLE_ERR("Error: input queue creation failed for %s\n", intf); @@ -461,7 +451,7 @@ void initialize_loop(char *intf) snprintf(queue_name, sizeof(queue_name), "%i-loop_outq_def", idx); queue_name[ODP_QUEUE_NAME_LEN - 1] = '\0'; - outq_def = QUEUE_CREATE(queue_name, ODP_QUEUE_TYPE_POLL, &qparam); + outq_def = queue_create(queue_name, ODP_QUEUE_TYPE_POLL, &qparam); if (ODP_QUEUE_INVALID == outq_def) { EXAMPLE_ERR("Error: output queue creation failed for %s\n", intf); @@ -525,7 +515,7 @@ void initialize_intf(char *intf) odp_pktio_to_u64(pktio)); inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0'; - inq_def = QUEUE_CREATE(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam); + inq_def = queue_create(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam); if (ODP_QUEUE_INVALID == inq_def) { EXAMPLE_ERR("Error: pktio queue creation failed for %s\n", intf); @@ -1007,7 +997,7 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED) odp_crypto_op_result_t result; /* Use schedule to get event from any input queue */ - ev = SCHEDULE(&dispatchq, ODP_SCHED_WAIT); + ev = schedule(&dispatchq, ODP_SCHED_WAIT); /* Determine new work versus completion or sequence number */ if (ODP_EVENT_PACKET == odp_event_type(ev)) { @@ -1153,6 +1143,16 @@ main(int argc, char *argv[]) char cpumaskstr[ODP_CPUMASK_STR_SIZE]; odp_pool_param_t params; + /* create by default scheduled queues */ + queue_create = odp_queue_create; + schedule = odp_schedule; + + /* check for using poll queues */ + if (getenv("ODP_IPSEC_USE_POLL_QUEUES")) { + queue_create = polled_odp_queue_create; + schedule = polled_odp_schedule; + } + /* Init ODP before calling anything else */ if (odp_init_global(NULL, NULL)) { EXAMPLE_ERR("Error: ODP global init failed.\n"); @@ -1496,6 +1496,8 @@ static void usage(char *progname) " ODP_PKTIO_DISABLE_SOCKET_MMSG\n" " ODP_PKTIO_DISABLE_SOCKET_BASIC\n" " can be used to advanced pkt I/O selection for linux-generic\n" + " ODP_IPSEC_USE_POLL_QUEUES\n" + " to enable use of poll queues instead of scheduled (default)\n" "\n", NO_PATH(progname), NO_PATH(progname) ); }