From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0069.outbound.protection.outlook.com [104.47.34.69]) by dpdk.org (Postfix) with ESMTP id 665B07272 for ; Tue, 3 Apr 2018 17:06:00 +0200 (CEST) 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=/sh1uQUVSnSpAR4t8izgjdCe0vzslix4i9nJ0a0lNSM=; b=AMpFaTLI0IHQoMMxs7xQ2SVrgwtqpm2ul/oc0ZdpNVbYMH960oNVF98eV/INMK2LMGR6JLlxNjD3FW0CCHr7u9hd9zvRF9xQYXUm8y5Vjl1BjJrzgXe2rGx/BVnqIypHtfYk3EOi9UQ645Ax6FqmY6UsuZJtq/RtmbQUxIOxvHE= 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.631.10; Tue, 3 Apr 2018 15:05:57 +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: Tue, 3 Apr 2018 20:35:09 +0530 Message-Id: <20180403150514.24201-8-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180403150514.24201-1-pbhagavatula@caviumnetworks.com> References: <20180216213700.3415-1-pbhagavatula@caviumnetworks.com> <20180403150514.24201-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BM1PR0101CA0070.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::32) To MWHPR07MB3470.namprd07.prod.outlook.com (2603:10b6:301:63::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0e83672d-391d-40e2-3677-08d599746896 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:ht0qokmfsNP9vrhwBHYz5vvnvKt5ol+fdY7KQERVX80oY0iNF7zveyuXSwFQdA5qaPdJNP5tuGlfSqxVr7NrvS8h6XqYdzG0DrCvMqH14No/lngZcdzhdcbYcGj88ar4JtAXO1eEjTzcrGpiPO7VNagbAIkxCzP9tSVc3DO+0pRn8ws0s3lyqknMXKR7SWujjeBMQA+V8aDpk4L3fRvrdJYVXxtXeRZBirHWC7buBPh2UxA8IfQGQD5D3M64MaAn; 25:4ULPPVMVF05ZbRwCFqJsaNd9FXeyk1kGPwrkNyzJhdU5iI2EfBpbiYA6xB+kgQMg8ggXMsOIBQHRgnZpZI43e/9jJ/Oy6GHmXuYz3OQ/yVrVuG5/mUCyoJkYQXnH1ksr3Vi2N7soqRn4O/UiU9D0qOua+FwNqI5BPJuRT0KTHOq7xIKOZ9U51nZHnaYfRhyD5ffS+pRjc/Ox2vTFIJyfaB7woZCHk0v58N8WT3wC0tvtyHfqjUxyu10yLASBj9QZsaDWlKr6EnGWs1mfGPCJhKqzsAmQ6kI67iIResPjcWMM2kWNdkdorEWmaYY36CPYzBxZHFZGPlj+hX/JmGTxww==; 31:zaFFPTy09Sac476DiIdiUDborBLiSknwIj0X6mbxACQRXp42ms0MK2etknKM0gFS4pbNLei9eLIavIlaJSvvn247m2YiBuqGeIlI0xTR/SiMmW/pZHNi19SavfEriSGuRlBDk7iHBRXGzJLz1m5nDAmB3mDp3m9pQIgxda26YkWdFVTBfVGApLEK6iNKLcCQl7XEJQ6n6f0xQJ6cwpwGcd6N1ybobyjf37CNaPs8xGU= X-MS-TrafficTypeDiagnostic: MWHPR07MB3470: X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 20:D4st1EO5b0WaK9HOg1/eNNOWra1OyI3goQUTAcR7Iwsw9bKon8QfZ+AuOqpL0uuLTgHXgaS5Ubj7a2iIsrdX8Zvg0kSpKMcmTuUjenLL8BPrju5cddv9fSNDtSuJQky4DZjXpZfQ74+ECWJnEAgx9gvbvFlyE/8NWoOofIHeLiHChFc2FLLkk1eZY4fO12d4vrD4W4x2uHBICWjProNlGduZRguYKIDF9YxlPWwi691eXNvHFVtl7PfpDH4qq58QLqHY1n7GuXy7jtqr1ykk76tfSuBKE/E67bikdnaMKyhugaWK76vr+beKo+ZsaPS9NlHSex56O+ISzdl12AuZbtQIqefMLQFsNhtaly7D8SghTJlJ06WBt89fRXr3H2qQpmLAJQvYMK3qbY1FqgqbXH/jVMozUTBD+XLAE4V9S/TNOyNk/zK7RCBJKNIyJU9JjkK8RkPkYH19IUi3bi6JycWeeVIVLczBQ1PamqLbu3xG51erE7tSc6x2IDUvmVCZdew+g+aRNQP3AAt/30k/RNvfP9gosaAlZcriuO+iZIxlOC6NKDddjgl4RcTKdBt3YtMbzWVNlmx3vv0aovxbMRyEaD7Bxg9MCrz/Pyfj8IY=; 4:oPP433SkzI41X8PzqesCYjHv7pluAJDHP0VSLnujEe72x+pPDqa8uORO7ALFutQ4p8WQtwRMQ+caUHm+LdV1Ildh4XU6kEDi1ChmtzUqIBO6uzLjVZcR99mw1v+0Eq9doaC9LQLdKsEmAsugolH1CqqeyEVvB2bIUAgcaz4fxKEjI2s9+TMzdoconSfM/jb6J4qwuJpwsVpYl0GNBTDc0Max7HlPqPz89pbFuUtFX6l0uKFh1O9o86A9XfZ35/hGf3Jp6qUGtJiabTmOFMjpfw== 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)(944501327)(52105095)(10201501046)(3002001)(93006095)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123564045)(6072148)(201708071742011); SRVR:MWHPR07MB3470; BCL:0; PCL:0; RULEID:; SRVR:MWHPR07MB3470; X-Forefront-PRVS: 0631F0BC3D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39380400002)(346002)(39850400004)(376002)(366004)(189003)(199004)(47776003)(305945005)(66066001)(72206003)(386003)(6506007)(16586007)(478600001)(316002)(48376002)(7736002)(76176011)(59450400001)(36756003)(52116002)(51416003)(5009440100003)(50466002)(68736007)(106356001)(4326008)(25786009)(486005)(476003)(2906002)(107886003)(6512007)(11346002)(6116002)(2616005)(53416004)(26005)(16526019)(5660300001)(6486002)(3846002)(1076002)(81166006)(81156014)(446003)(956004)(486005)(69596002)(8676002)(6666003)(97736004)(42882007)(50226002)(105586002)(8936002)(1857600001)(53936002)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB3470; H:ltp-pvn.caveonetworks.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR07MB3470; 23:g8jknk4p5s5jJ5vaGPWuPR+HjbjGV9t8yUFnxVDkq?= =?us-ascii?Q?iN0aGLtrdGx/MzO8RlyGz5+3VxzEHhops6iLezYUNTktra8C5vXvuI9QMOJP?= =?us-ascii?Q?25MQ1GrtTSquomRK2KUKzieDki2mIZkJzTdWl6a1AMvYTmB/yi3W0LwWD3jX?= =?us-ascii?Q?zNhwbslWDyJWXQE+4aeA33DwY/7EQQGrU5hE9sHUv5ShEfLR6LS2Pt7bcPAg?= =?us-ascii?Q?Jw2ZybEAKIItHqDppmagKk5JNirCujQe0I4U96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MGakW3XfddVwjgn3gG+BAKwfU9C/ljvcZagJWpz9Y8BxofLewdP3MLI1Vj3WORB+yubIBNedUELQxDby4AbwMIcUazvLIl2B0ya0Yw8eDSBDRSbuXnUXO7DYokFF2nA/EgNj0MXEXLhlPAJTrcWxxWXTrWNhg=; 24:IGWYnlOwZLSXn6erhCUFD6Vp+OuKEXxHwxFU1JvP3bg+13LTnt5hexzEwaZpb29yKhoFuXBMz+4UdLkwAD6Ytq4A1aQ+Np8+4eTFe+7awnw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 7:KYCBr/IKBKkR5ByDvk368w2beFXjf2XWqrs4hCDCOpL1q7AnpaAAgBc8C5rjG+bWOq+48g7rcu1aodVvkU0IvN65WKgHqmSO64n4IETyQuVeFlCI+DeCIceyLZe/fGf5MJ08YTg+zMOGyPpDX8rhkVqySKpZpoJ/XP7mJrftgaW4glHKI6zLExuph0dsfkR7EK/OFBmckm7GQwTUUyCwBM1U4tSBS0Rj7OP4iwaa7fwHKfVF1nidtrHp8heJqkhS X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2018 15:05:57.4911 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e83672d-391d-40e2-3677-08d599746896 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 v3 07/12] 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: Tue, 03 Apr 2018 15:06:01 -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 | 25 +++++++++++++++++++ drivers/event/octeontx/timvf_worker.h | 47 +++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 3 deletions(-) diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c index c8865e33c..a32892107 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); @@ -321,9 +327,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 ddf50643f..ab2de678f 100644 --- a/drivers/event/octeontx/timvf_evdev.h +++ b/drivers/event/octeontx/timvf_evdev.h @@ -196,6 +196,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); uint16_t timvf_timer_unreg_burst(const struct rte_event_timer_adapter *adptr, struct rte_event_timer **tim, const uint16_t nb_timers); +uint16_t timvf_timer_reg_burst_sp(const struct rte_event_timer_adapter *adptr, + struct rte_event_timer **tim, const uint16_t nb_timers); uint16_t 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 50794d37b..139dfdc07 100644 --- a/drivers/event/octeontx/timvf_worker.c +++ b/drivers/event/octeontx/timvf_worker.c @@ -64,6 +64,31 @@ timvf_timer_unreg_burst(const struct rte_event_timer_adapter *adptr, return index; } +uint16_t +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 (timvf_timer_reg_checks(timr, tim[index])) + break; + + timvf_format_event(tim[index], &entry); + ret = timvf_add_entry_sp(timr, tim[index]->timeout_ticks, + tim[index], &entry); + if (unlikely(ret)) { + rte_errno = -ret; + break; + } + } + timr->meta.tim_arm_cnt += index; + + return index; +} + uint16_t 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.3