From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0082.outbound.protection.outlook.com [104.47.38.82]) by dpdk.org (Postfix) with ESMTP id CF431A49B for ; Wed, 14 Mar 2018 14:53:25 +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=3QFrvN7uHq31GJMYff3T7Gh6khzSqS3LebLyJCTbofw=; b=LivO9Ygx2VHdk3h+KUlvo1f3oO2no1vmO5ZcskYe381dO54BtN+BWGcW70zLfO0F8YV5NX6L/uTln4FYA4QmwCgTpoi0EqUYvdMp5C5MTznn/OGrRezeQe5CtaWczpWRrFLNuUPY332PqlnpzgOXvfpJLJWcA5jQBXsa683f7PQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from ltp-pvn.caveonetworks.com (111.93.218.67) by MWHPR07MB3470.namprd07.prod.outlook.com (2603:10b6:301:63::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.567.14; Wed, 14 Mar 2018 13:53:22 +0000 From: Pavan Nikhilesh To: jerin.jacob@caviumnetworks.com, santosh.shukla@caviumnetworks.com, erik.g.carrillo@intel.com Cc: dev@dpdk.org, Pavan Nikhilesh Date: Wed, 14 Mar 2018 19:22:28 +0530 Message-Id: <20180314135233.31282-7-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180314135233.31282-1-pbhagavatula@caviumnetworks.com> References: <20180216213700.3415-1-pbhagavatula@caviumnetworks.com> <20180314135233.31282-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: DM5PR20CA0005.namprd20.prod.outlook.com (2603:10b6:3:93::15) To MWHPR07MB3470.namprd07.prod.outlook.com (2603:10b6:301:63::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f42d50d1-9190-4c83-e2a4-08d589b2f4c5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(2017052603328)(7153060)(7193020); SRVR:MWHPR07MB3470; X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 3:bE8KNB530UZQpI45bK9GzopcWefZNV6fYLv7vUecwNkSoLu7ZFbIOeewt/c8LruDplSTeEGjcOtGG9MqOmUdMLU1vNDf2n3b3dy3jgz/ejjEwe/b0Li4OZkNJIw+rmmoRtCc4wAc65OP/RAvQbeHGawJzRH6J3FkGImojqzr9LKMqZwZ69biNUbIgSK/nriXpQwblT1fmjHbzJaL8MNX+f3aJuwh/3ZXUi9/+OasGgMFMpDxIrCI0NHUrcl8XLt6; 25:bQ2i8wxdm+J7rALj3onPD1hV32BN+h3LBejmrSNvZlh4X9WXg2ann7BESnwqtmE0vZolonegDmHvEVxDY6xKo5giCC9o+22RG5tFjFAya4CsYklW92pMdFvqMVzaVSO04bFR1D7DZDmdSu94GewaB1RmipcsAAF+B5fGzkirDWvCx8LVF5BU+DKatnDbU3PNrp+1TXHBvf9anx7FXp3aBBUOjo3UTT2BnkzyVlKZRIJ7/3Oo9+2BsroUQFjBMFmGtqy1EhMLLWdynAW99iwkkt6ufCI57XqtcDgOqj1r/smoopYEMRWzenkf660nMXkJp+MRrrK6/o7N527nxgwqCw==; 31:kQipMHMj1jUkC6gNT+uQNcaEZJ3VTfvp4W7+y/L6jZQPSgjlpCz7ZMsK/UHoWRy0zilf2GBIv/MNrApCvpPG0c6qdn9ypF8LshWvRoCmVVqxl8QMPbomtUkuJki7zCJqCAxAkt0mZuI8SFm12ppM3rgxuStyqsCX4UdIbLI2NamGnT9dR97LlqSEzO6gqM+2AvoM410bsp+MtiGTvFAv6E1JnC0z3L0k+dBNkEVA9Nw= X-MS-TrafficTypeDiagnostic: MWHPR07MB3470: X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 20:X2LBwJUqLILyUQT8FKD7NlZIf3DAysVhdBi+IoYQrDWQZHvBRjBkFSYJXt0fyZCFG7fy1NhCPFBshAh/xzdMIc9WiIbEztHOFKdehwpqyW3L5H3ePOYsS5Q0dkH/g0z23VsNA51nfTLtYviXvQ0O47hqjIxoy36xoas09s+RxHInE+piPLLhZAWnMptHnoCcwNGXXXksh7K9dqBZT4s9DZIQtmzM5MvqbV9mI8OeTRlf+WRr8BdE2nfAsv5Sf98SEymhe0o9zs3bhLql9WozKIO0T9s1M16cMzjWWWAndF7QNU19kuVDaEuBTHxqv3JoyjHsQqrvnH3lCspH1N+3NtnHFQxlWJKgvNRngZmZpL+eJvy9yTz51T125rCqmf/9m9wdWvhrtbWHY7t5xcwm+O46rsAKLfvIH0fCbFeHxONFUU2iO4taJ4/vQWaDERIWEVk5tcxjLtbWTwMvuFFnf0dXZBHDCWfxQ2/Ltm/8bRiDj7sHk7s/87MFmWdf6+DC6NqYaojdUdeeq1WSbyBaaFHTO8b759xPYzsax1dEJ+eSmBDRLKwcj7st3iGBwy//Zx9NIMepNupN2Rz1AdzxVWmzrtWV8NyiqwJT1/ffqkw=; 4:dDfrWJmG0fM55DrW3a2nWn2viKzcDhwuGh4EW8z8TzG9V6beS9UCfUhsJpTd7QP02zCIifq1dfY5TOjnkma0ZE5vUWD23Bxy33zL1xI0I32hLE8Hy3H1mbyExEl6QPSK3V67eoS+EPdXkjJtx7BWNGDu0fUL/LzCwzq6GWrHaPmVbUTi1lag2kbn/ji254se3mVByt79PkKRQxjn/Qo8fRP4Pt/GJZZpavOAt3eFX0gCK0lbKmGMfuSg3O1BVpRkBS4NsRVj87AZISrb4dH2DA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501244)(52105095)(3002001)(93006095)(10201501046)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:MWHPR07MB3470; BCL:0; PCL:0; RULEID:; SRVR:MWHPR07MB3470; X-Forefront-PRVS: 0611A21987 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(39380400002)(366004)(346002)(396003)(189003)(199004)(53936002)(6512007)(3846002)(4326008)(6506007)(48376002)(26005)(105586002)(68736007)(97736004)(47776003)(2950100002)(386003)(1076002)(6486002)(106356001)(52116002)(305945005)(107886003)(7736002)(69596002)(76176011)(66066001)(5660300001)(59450400001)(51416003)(25786009)(36756003)(50466002)(316002)(16586007)(72206003)(53416004)(1857600001)(6116002)(478600001)(575784001)(8676002)(81156014)(81166006)(42882007)(2906002)(5009440100003)(50226002)(16526019)(8936002)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB3470; H:ltp-pvn.caveonetworks.com; 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:wMoP7Ahi3L2ev5WLFVUnllXDiaG0PKTMAiAWmoLaA?= =?us-ascii?Q?IjLvLXhr17O60pYnynD2AVnjxIryS+DDOQd4s8TJJmJffBeOZ/AEszRiOYHq?= =?us-ascii?Q?OdqihHMkNgndcoqpjLou9+6jico5/IvjDZq8ka4NoCj2SX4tWDNVBe7t+Bie?= =?us-ascii?Q?53PxxuPqfKedOlfZ+QBOvr8jYygb0AJBhffg2Vx7MHNPUMEvkI8bcpbxGuIZ?= =?us-ascii?Q?g+BvW/X9BNEGdjA9SwcJYw4uA+ly0ej1aovW/i38fkqpPPsxuTCSUqUwfUOk?= =?us-ascii?Q?MYMLSfxgc1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jB+wfknlBzRWeuwJSKG3ZJ5D+bNXbfGIjbbRJTnOop7DYEeaP6D+XV2hfdS27uOK1rOF/vhwiKeNLn/zXZMLv4ZhutqIm6Vi7LiIoW4DBQlaYFFwUCICJAItcEbza2nVFrFrB2g350Q+NiRtxbTtFURvYAN+eKcZrCzUwDUzV/Qa/IcwDxngaKIwlJCZXaTmVeVHVfpM4mhz7z01kCAK+pIMPhT8LgzC5x3 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2018 13:53:22.6742 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f42d50d1-9190-4c83-e2a4-08d589b2f4c5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3470 Subject: [dpdk-dev] [PATCH v2 06/11] event/octeontx: add single producer timer arm variant 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: Wed, 14 Mar 2018 13:53:26 -0000 When application creates the timer adapter by passing `RTE_EVENT_TIMER_ADAPTER_F_SP_PUT` flag, we can optimize the arm sequence by removing the locking overhead. Signed-off-by: Pavan Nikhilesh --- drivers/event/octeontx/timvf_evdev.c | 15 ++++++++--- drivers/event/octeontx/timvf_evdev.h | 2 ++ drivers/event/octeontx/timvf_worker.c | 29 +++++++++++++++++++++ drivers/event/octeontx/timvf_worker.h | 47 +++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 3 deletions(-) diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c index 852e8811c..3d0e43229 100644 --- a/drivers/event/octeontx/timvf_evdev.c +++ b/drivers/event/octeontx/timvf_evdev.c @@ -176,6 +176,7 @@ timvf_ring_create(struct rte_event_timer_adapter *adptr) struct timvf_ring *timr; struct octeontx_timvf_info tinfo; const char *mempool_ops; + unsigned int mp_flags = 0; if (octeontx_timvf_info(&tinfo) < 0) return -ENODEV; @@ -226,6 +227,11 @@ timvf_ring_create(struct rte_event_timer_adapter *adptr) timr->nb_chunks = nb_timers / nb_chunk_slots; + if (rcfg->flags & RTE_EVENT_TIMER_ADAPTER_F_SP_PUT) { + mp_flags = MEMPOOL_F_SP_PUT | MEMPOOL_F_SC_GET; + timvf_log_info("Using single producer mode"); + } + timr->meta.bkt = rte_zmalloc("octeontx_timvf_bucket", (timr->meta.nb_bkts) * sizeof(struct tim_mem_bucket), 0); @@ -235,7 +241,7 @@ timvf_ring_create(struct rte_event_timer_adapter *adptr) snprintf(pool_name, 30, "timvf_meta.chunk_pool%d", timr->tim_ring_id); timr->meta.chunk_pool = (void *)rte_mempool_create_empty(pool_name, timr->nb_chunks, TIM_CHUNK_SIZE, 0, 0, rte_socket_id(), - 0); + mp_flags); if (!timr->meta.chunk_pool) { rte_free(timr->meta.bkt); @@ -295,9 +301,12 @@ timvf_timer_adapter_caps_get(const struct rte_eventdev *dev, uint64_t flags, uint32_t *caps, const struct rte_event_timer_adapter_ops **ops) { RTE_SET_USED(dev); - RTE_SET_USED(flags); - timvf_ops.arm_burst = timvf_timer_reg_burst_mp; + if (flags & RTE_EVENT_TIMER_ADAPTER_F_SP_PUT) + timvf_ops.arm_burst = timvf_timer_reg_burst_sp; + else + timvf_ops.arm_burst = timvf_timer_reg_burst_mp; + timvf_ops.cancel_burst = timvf_timer_unreg_burst; *caps = RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT; diff --git a/drivers/event/octeontx/timvf_evdev.h b/drivers/event/octeontx/timvf_evdev.h index c717c19bc..232657776 100644 --- a/drivers/event/octeontx/timvf_evdev.h +++ b/drivers/event/octeontx/timvf_evdev.h @@ -195,6 +195,8 @@ int timvf_timer_adapter_caps_get(const struct rte_eventdev *dev, uint64_t flags, uint32_t *caps, const struct rte_event_timer_adapter_ops **ops); int timvf_timer_unreg_burst(const struct rte_event_timer_adapter *adptr, struct rte_event_timer **tim, const uint16_t nb_timers); +int timvf_timer_reg_burst_sp(const struct rte_event_timer_adapter *adptr, + struct rte_event_timer **tim, const uint16_t nb_timers); int timvf_timer_reg_burst_mp(const struct rte_event_timer_adapter *adptr, struct rte_event_timer **tim, const uint16_t nb_timers); void timvf_set_chunk_refill(struct timvf_ring * const timr); diff --git a/drivers/event/octeontx/timvf_worker.c b/drivers/event/octeontx/timvf_worker.c index 113603616..93fd050c0 100644 --- a/drivers/event/octeontx/timvf_worker.c +++ b/drivers/event/octeontx/timvf_worker.c @@ -23,6 +23,35 @@ timvf_timer_unreg_burst(const struct rte_event_timer_adapter *adptr, return index; } +int +timvf_timer_reg_burst_sp(const struct rte_event_timer_adapter *adptr, + struct rte_event_timer **tim, const uint16_t nb_timers) +{ + int ret; + uint16_t index; + struct tim_mem_entry entry; + struct timvf_ring *timr = adptr->data->adapter_priv; + for (index = 0; index < nb_timers; index++) { + if (unlikely(tim[index]->timeout_ticks > timr->meta.nb_bkts)) { + tim[index]->state = RTE_EVENT_TIMER_ERROR_TOOLATE; + rte_errno = EINVAL; + break; + } + + entry.w0 = (tim[index]->ev.event & 0xFFC000000000) >> 6 | + (tim[index]->ev.event & 0xFFFFFFFF); + entry.wqe = tim[index]->ev.u64; + ret = timvf_add_entry_sp(timr, tim[index]->timeout_ticks, + tim[index], &entry); + if (unlikely(ret)) { + rte_errno = -ret; + break; + } + } + + return index; +} + int timvf_timer_reg_burst_mp(const struct rte_event_timer_adapter *adptr, struct rte_event_timer **tim, const uint16_t nb_timers) diff --git a/drivers/event/octeontx/timvf_worker.h b/drivers/event/octeontx/timvf_worker.h index bba4985ab..7e197f5cd 100644 --- a/drivers/event/octeontx/timvf_worker.h +++ b/drivers/event/octeontx/timvf_worker.h @@ -223,6 +223,53 @@ timvf_get_target_bucket(struct timvf_ring * const timr, const uint32_t rel_bkt) return &timr->meta.bkt[tbkt_id]; } +/* Single producer functions. */ +static inline int +timvf_add_entry_sp(struct timvf_ring * const timr, const uint32_t rel_bkt, + struct rte_event_timer * const tim, + const struct tim_mem_entry * const pent) +{ + int16_t rem; + uint64_t lock_sema; + struct tim_mem_bucket *bkt; + struct tim_mem_entry *chunk; + + + bkt = timvf_get_target_bucket(timr, rel_bkt); +__retry: + /*Get Bucket sema*/ + lock_sema = timr_bkt_fetch_sema(bkt); + /* Bucket related checks. */ + if (unlikely(timr_bkt_get_hbt(lock_sema))) + goto __retry; + + /* Insert the work. */ + rem = timr_bkt_fetch_rem(lock_sema); + + if (!rem) { + chunk = timr->meta.refill_chunk(bkt, timr); + if (unlikely(chunk == NULL)) { + timr_bkt_set_rem(bkt, 0); + tim->impl_opaque[0] = tim->impl_opaque[1] = 0; + tim->state = RTE_EVENT_TIMER_ERROR; + return -ENOMEM; + } + bkt->current_chunk = (uint64_t) chunk; + timr_bkt_set_rem(bkt, nb_chunk_slots - 1); + } else { + chunk = (struct tim_mem_entry *)bkt->current_chunk; + chunk += nb_chunk_slots - rem; + } + /* Copy work entry. */ + *chunk = *pent; + timr_bkt_inc_nent(bkt); + + tim->impl_opaque[0] = (uint64_t)chunk; + tim->impl_opaque[1] = (uint64_t)bkt; + tim->state = RTE_EVENT_TIMER_ARMED; + return 0; +} + /* Multi producer functions. */ static inline int timvf_add_entry_mp(struct timvf_ring * const timr, const uint32_t rel_bkt, -- 2.16.2