From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0068.outbound.protection.outlook.com [104.47.40.68]) by dpdk.org (Postfix) with ESMTP id 9BB402C57 for ; Thu, 11 Jan 2018 13:03:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ClnNdWI76yfA51uPSnPaNXlcTCBcCQB3+03r5qToLMs=; b=Px05uOLWD56+9Qoh02prJK6xmmoCyBorw3xYOCHizm4gageeJSozZeYPDYKZ8F33aYhLb0BBFH9LcPbCgEfApX7UUuqPJlp5QXtQXQYak6Xeh4BTcs9cWd9vDiwmJWdrQW/QAJZQRIpCqNIvwzjhMmwLoOCrfqQRuaPG4oxuNPw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from Pavan-LT (111.93.218.67) by MWHPR07MB3470.namprd07.prod.outlook.com (10.164.192.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Thu, 11 Jan 2018 12:03:15 +0000 Date: Thu, 11 Jan 2018 17:33:09 +0530 From: Pavan Nikhilesh To: Erik Gabriel Carrillo , jerin.jacob@caviumnetworks.com, nipun.gupta@nxp.com, hemant.agrawal@nxp.com Cc: dev@dpdk.org Message-ID: <20180111120308.eaveovovjh3q7ip7@Pavan-LT> References: <1512158458-22661-1-git-send-email-erik.g.carrillo@intel.com> <1515630074-29020-1-git-send-email-erik.g.carrillo@intel.com> <1515630074-29020-14-git-send-email-erik.g.carrillo@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1515630074-29020-14-git-send-email-erik.g.carrillo@intel.com> User-Agent: NeoMutt/20170609 (1.8.3) X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: CO2PR05CA0077.namprd05.prod.outlook.com (10.166.88.173) To MWHPR07MB3470.namprd07.prod.outlook.com (10.164.192.21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9e934560-e371-4893-bcfa-08d558eb4d1e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:MWHPR07MB3470; X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 3:J4cW7UQ71fTjhBQEyk80Ap73aouH1w9WOWfd/hkHxPFZ3QHCfSXKW2sfbsXm+KhHoN1+/62pNGrBWI4UW1WgB4HC7GprkAtdVysh5SgRz8hpX7Uk7WI+cFC0ZXPODXqf0PekJG4AmPChzE/oM3Xs6V/yTZDCk1MGuKF4OAwxPpfpUy8rLy15e/Lpd+HruvqgbAKcmSoIU0+mqnyAmyub+W0/YAtyZEoKDsqDEIIfMHP7HBS9HuoTANLBIX7g6APN; 25:uBW2iZRSDNqMZsIwDi1G5tVxmFbaiGdW+rbzdT2J9UKjsIBPKH5hHIktJFZKcJPX4oMQSeBOO++SJZ0QBJFZuB4POz128LfNF80JfBtSAkd4AtXUkjDhDNe0x9CfYEQIXwZCGrQTAjU6TWqbRQNi/+fQuCDVmLfcj4jl4wJQY0EvubqbHVhBBG7cShg4QN/Z4Qbwe0jATRHl3K7cGIfCe1Y+Cn/pXh4mIv0Wr7pzp8AQO/KCVEdG/vHUkSzmW3ivMzIzDUSeYAReydLOZWy3FfZDULMyyIsmsgXxCqPPGscNNeQEcRjQ+zVFNMb+dTiGdn+XaSR2KFa24p9/lRtVmQ==; 31:KLVHD7ziKCz/KkBzjQ5YSS8YNOqomgTvFLo2PgMRP5XT6D848hy5AMkVq3zQVpjYtNTSPBf8dGru4Nl9S0dYAhnjX1OloqgxGGNRR4vr4qsx5VZh/FkaaTatG5i3Cek4DIgLlVB/n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BjHnHK0vMa//qSig2oXjgkuD22T2E3iCHXxEJhhCf+ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(3231023)(944501075)(93006095)(10201501046)(6041268)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:MWHPR07MB3470; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:MWHPR07MB3470; X-Forefront-PRVS: 0549E6FD50 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(39380400002)(346002)(376002)(396003)(366004)(24454002)(189003)(199004)(81166006)(81156014)(8676002)(478600001)(8656006)(6246003)(53936002)(316002)(50466002)(72206003)(2906002)(386003)(59450400001)(105586002)(33896004)(52116002)(23726003)(76176011)(6116002)(3846002)(1076002)(106356001)(6496006)(47776003)(33716001)(66066001)(7736002)(305945005)(25786009)(8936002)(83506002)(97736004)(5009440100003)(16526018)(4326008)(5660300001)(58126008)(55016002)(229853002)(6666003)(16586007)(9686003)(42882006)(2950100002)(68736007)(107986001)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB3470; H:Pavan-LT; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR07MB3470; 23:fKupgkMGyYZRuc+5VSTI+px84uY9g3mi8Dl/1bbSB?= =?us-ascii?Q?fdgbAsEluSpDJ2qH6jz2Iqx0y9Qni/fBdunTwZhZq/JW328c+q8tXNlMWwYF?= =?us-ascii?Q?X7M96KTtJRjWci9MZt/Y7TY9vmMTX+4K5pu7EVFy2WhWDbIGr/sUt7s4v8ti?= =?us-ascii?Q?nDSGt4ruvKC4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VEh2v16mXQHLFIpfkJeiYDgZizzFZDvZ5+STbBZ4qVoY6ypsautcrUYIrKrMIv7C3PtTLlS6N93vjB8Q2qMNJ6X2mgRprXMZGMr/qEIMYPoQxo51x7zN2Sga6becNAWJdpKWmdWgrKo2SX8dsrZlk4cs6EbJrg5rTU4N5Vtxoxkt3mjC0QFFuESjQmXn/7l5QjU2RTqNOWKcYk SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2018 12:03:15.9711 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9e934560-e371-4893-bcfa-08d558eb4d1e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3470 Subject: Re: [dpdk-dev] [PATCH v6 13/23] eventtimer: add adapter service definition X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jan 2018 12:03:20 -0000 On Wed, Jan 10, 2018 at 06:21:04PM -0600, Erik Gabriel Carrillo wrote: > Define the callback function for the service that corresponds to an > adapter instance, as well as the callback for expired timers that the > service manages. > > Signed-off-by: Erik Gabriel Carrillo > --- > lib/librte_eventdev/rte_event_timer_adapter.c | 198 +++++++++++++++++++++++++- > lib/librte_eventdev/rte_event_timer_adapter.h | 2 +- > 2 files changed, 198 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_eventdev/rte_event_timer_adapter.c b/lib/librte_eventdev/rte_event_timer_adapter.c > index 38e52cb..0266ad5 100644 > --- a/lib/librte_eventdev/rte_event_timer_adapter.c > +++ b/lib/librte_eventdev/rte_event_timer_adapter.c > @@ -40,8 +40,10 @@ > #include > #include > #include > +#include > #include > #include > +#include > > #include "rte_eventdev.h" > #include "rte_eventdev_pmd.h" > @@ -460,10 +462,198 @@ struct msg { > struct rte_event_timer *evtim; > }; > + if (n != 1 && rte_errno == -ENOSPC) { > + /* If we couldn't enqueue because the event port was > + * backpressured, put the timer back in the skiplist with an > + * immediate expiry value so we can process it again on the > + * next iteration. > + */ > + rte_timer_reset_sync(tim, SINGLE, 0, rte_lcore_id(), > + sw_event_timer_cb, evtim); > + } else { > + sw_data->nb_armed_evtims--; > + rte_wmb(); Any reason for using barrier here?. IMO smp_wmb() would be more than sufficient or use atomics. > + evtim->state = RTE_EVENT_TIMER_NOT_ARMED; > + rte_mempool_put(sw_data->tim_pool, (void **)&tim); > + } > +} > + > +static __rte_always_inline uint64_t > +get_timeout_cycles(struct rte_event_timer *evtim, > + struct rte_event_timer_adapter *adapter) > +{ > + uint64_t timeout_ns; > + > + timeout_ns = evtim->timeout_ticks * adapter->data->conf.timer_tick_ns; > +#define NSECPERSEC 1E9 > + return timeout_ns * rte_get_timer_hz() / NSECPERSEC; > + > +} > + > +/* Check that event timer timeout value is in range */ > +static __rte_always_inline int > +check_timeout(struct rte_event_timer *evtim, > + const struct rte_event_timer_adapter *adapter) > +{ > + uint64_t tmo_nsec = evtim->timeout_ticks * > + adapter->data->conf.timer_tick_ns; > + > + return (tmo_nsec > adapter->data->conf.max_tmo_ns) ? -1 > + : (tmo_nsec < adapter->data->conf.timer_tick_ns) ? -2 > + : 0; Consider simplifying this for readability. > +} > + > +/* Check that event timer event queue sched type matches destination event queue > + * sched type > + */ > +static __rte_always_inline int > +check_destination_event_queue(struct rte_event_timer *evtim, > + const struct rte_event_timer_adapter *adapter) > + > +#define NB_OBJS 32 > static int > sw_event_timer_adapter_service_func(void *arg) > { > - RTE_SET_USED(arg); > + int i, num_msgs, ret; > + uint64_t cycles; > + uint16_t nb_events; > + struct rte_event_timer_adapter *adapter; > + struct rte_event_timer_adapter_sw_data *sw_data; > + struct rte_event_timer *evtim = NULL; > + struct rte_timer *tim = NULL; > + struct msg *msg, *msgs[NB_OBJS]; > + > + adapter = arg; > + sw_data = adapter->data->adapter_priv; > + > + while (!rte_ring_empty(sw_data->msg_ring)) { > + num_msgs = rte_ring_dequeue_burst(sw_data->msg_ring, > + (void **)msgs, NB_OBJS, NULL); > + > + for (i = 0; i < num_msgs; i++) { > + msg = msgs[i]; > + evtim = msg->evtim; > + > + tim = (struct rte_timer *)evtim->impl_opaque[0]; > + RTE_ASSERT(tim != NULL); > + > + switch (msg->type) { > + case MSG_TYPE_ARM: > + if (validate_event_timer(evtim, adapter) < 0) { > + rte_mempool_put(sw_data->tim_pool, > + (void **)&tim); > + continue; > + } > + > + /* Checks passed; set an rte_timer */ > + cycles = get_timeout_cycles(msg->evtim, > + adapter); > + rte_timer_reset_sync(tim, cycles, SINGLE, > + rte_lcore_id(), > + sw_event_timer_cb, > + msg->evtim); > + > + sw_data->nb_armed_evtims++; > + rte_wmb(); Same as above comment. > + evtim->state = RTE_EVENT_TIMER_ARMED; > + break; > + case MSG_TYPE_CANCEL: > + /* The event timer was either not armed or it > + * fired after this cancel request was queued > + * and before the request was processed. > + */ > + if (evtim->state != RTE_EVENT_TIMER_ARMED) > + continue; > + > + rte_timer_stop_sync(tim); > + rte_mempool_put(sw_data->tim_pool, > + (void **)&tim); > + sw_data->nb_armed_evtims--; > + rte_wmb(); Same as above comment. > + msg->evtim->state = RTE_EVENT_TIMER_CANCELED; > + break; > + } > + } > + > + rte_mempool_put_bulk(sw_data->msg_pool, (void **)msgs, > + num_msgs); > + } > + > + rte_timer_manage(); Consider calling rte_timer_manage() before ARM new set of timers also, poll it based on the timeout interval configured. > + > + /* Could use for stats */ > + RTE_SET_USED(nb_events); > + RTE_SET_USED(ret); > + > return 0; > } >