From patchwork Thu Apr 2 07:29:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Badicioiu X-Patchwork-Id: 46705 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CC5CE216D1 for ; Thu, 2 Apr 2015 07:30:12 +0000 (UTC) Received: by widjs5 with SMTP id js5sf2305361wid.3 for ; Thu, 02 Apr 2015 00:30:12 -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=G1SJh6tZwOzzEPDuB8L3wCJQHQMPvkt/8e10uchOROtDBGVNBx96TvYi+QQJwcpINN D6MU/hqxpoNXgyPjLTQMR/cwmJHiXYd4wCSsNMezCoZUFH3ZLYYMI5txDBvOzOaNKcaW WJliaoFTT7fVQv8sUExR1SHKpnLb5tjKDEf3ipo5xrL/P7b4pu0hjo+nQwDV/crk5Xvz XRJVTKBsO+FLF/2pOw7Uwx3wKo8NX0Ov3UVkl5AkTuPa6DZSFB/5/3kKalAGfr6Zdozt KukMEgenLKTL1E50Fgw8lLcfgLMe+VKYFuh/LEO7sFIFJOYPEPwYK7yBuOt+A0Ekh8If vDCQ== X-Gm-Message-State: ALoCoQkqVKl5Ef0jKIuMYUiSugHqxf3MuaFNBc7Sbyq//x0wkg5fCK7AWn48dcbn97df6K3rbncC X-Received: by 10.112.125.67 with SMTP id mo3mr10292731lbb.6.1427959812104; Thu, 02 Apr 2015 00:30:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.110 with SMTP id bf14ls142454lab.48.gmail; Thu, 02 Apr 2015 00:30:11 -0700 (PDT) X-Received: by 10.112.17.36 with SMTP id l4mr34693911lbd.123.1427959811953; Thu, 02 Apr 2015 00:30:11 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id ww6si3555659lbb.20.2015.04.02.00.30.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Apr 2015 00:30:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by lagg8 with SMTP id g8so53969146lag.1 for ; Thu, 02 Apr 2015 00:30:11 -0700 (PDT) X-Received: by 10.112.46.74 with SMTP id t10mr12653192lbm.73.1427959811808; Thu, 02 Apr 2015 00:30:11 -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.57.201 with SMTP id k9csp1156318lbq; Thu, 2 Apr 2015 00:30:10 -0700 (PDT) X-Received: by 10.55.26.29 with SMTP id a29mr14177090qka.0.1427959810173; Thu, 02 Apr 2015 00:30:10 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id e69si4269784qhc.18.2015.04.02.00.30.08; Thu, 02 Apr 2015 00:30:10 -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 B936565079; Thu, 2 Apr 2015 07:30:08 +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=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable 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 1B2A665073; Thu, 2 Apr 2015 07:30:04 +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 0993165075; Thu, 2 Apr 2015 07:30:02 +0000 (UTC) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0083.outbound.protection.outlook.com [157.56.111.83]) by lists.linaro.org (Postfix) with ESMTPS id 9BE9D65073 for ; Thu, 2 Apr 2015 07:30:00 +0000 (UTC) Received: from DM2PR03CA0051.namprd03.prod.outlook.com (10.141.96.50) by DM2PR0301MB0607.namprd03.prod.outlook.com (25.160.95.23) with Microsoft SMTP Server (TLS) id 15.1.125.19; Thu, 2 Apr 2015 07:29:59 +0000 Received: from BY2FFO11FD035.protection.gbl (2a01:111:f400:7c0c::121) by DM2PR03CA0051.outlook.office365.com (2a01:111:e400:2428::50) with Microsoft SMTP Server (TLS) id 15.1.125.19 via Frontend Transport; Thu, 2 Apr 2015 07:29:59 +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 BY2FFO11FD035.mail.protection.outlook.com (10.1.14.220) with Microsoft SMTP Server (TLS) id 15.1.136.16 via Frontend Transport; Thu, 2 Apr 2015 07:29:58 +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 t327TvPm001358; Thu, 2 Apr 2015 00:29:57 -0700 From: To: Date: Thu, 2 Apr 2015 10:29:39 +0300 Message-ID: <1427959779-11307-1-git-send-email-alexandru.badicioiu@linaro.org> X-Mailer: git-send-email 1.7.3.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 130724333990769121; (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)(189002)(199003)(229853001)(110136001)(104016003)(15975445007)(77096005)(36756003)(92566002)(2351001)(46102003)(106466001)(105596002)(33646002)(87936001)(50466002)(86152002)(50226001)(19580395003)(19580405001)(6806004)(48376002)(50986999)(86362001)(77156002)(62966003)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0301MB0607; H:az84smr01.freescale.net; FPR:; SPF:SoftFail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0607; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5002010)(5005006); SRVR:DM2PR0301MB0607; BCL:0; PCL:0; RULEID:(401004)(400005); SRVR:DM2PR0301MB0607; X-Forefront-PRVS: 0534947130 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2015 07:29:58.8429 (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: DM2PR0301MB0607 X-Topics: patch Subject: [lng-odp] [PATCH 1/1] 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.215.48 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) ); }