From patchwork Tue Aug 22 13:04:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavan Nikhilesh Bhagavatula X-Patchwork-Id: 130634 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C0536430D0; Tue, 22 Aug 2023 15:04:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 60E284021D; Tue, 22 Aug 2023 15:04:11 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 291B240041 for ; Tue, 22 Aug 2023 15:04:08 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37M8ZhhK015741 for ; Tue, 22 Aug 2023 06:04:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=6CmfcfPsTtJnScvbn3NYgjQr8TG6TmA11/lzB/iO8B4=; b=jjBo4Md6OkKZjC6FcXaWeUesMWYm5WYz9+zqjGmVXiFe59BIbu419qEsypwK4ajKhNRq QryF7yQN8neSr4dclQ/RBNFSoyqByykrO39RpGkHOp9HdQoMt8sMRvKo6lw78oh1gRKA ckZGB8pWRW6PBqoet+2HSqtLvpLHKsAWhHayF7+JBa80FwqKmU5u/Ghej26h6WFXctF5 UBFJQA3eVoJ8Yb05gmYx4Lwl2Ck2YtRkQXBzGf4BNygFK0/y7Wkp7qMHFwKt580WlJmw Wf56otESICD0drxnO6+TnCaQByZcvqoqdomnhVyErHxNh+uwrBDu2dTDbHwGdFWYhBlB eQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3smdthas1k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 22 Aug 2023 06:04:07 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 22 Aug 2023 06:04:06 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Tue, 22 Aug 2023 06:04:06 -0700 Received: from MININT-80QBFE8.corp.innovium.com (MININT-80QBFE8.marvell.com [10.28.164.106]) by maili.marvell.com (Postfix) with ESMTP id 80B0A3F70AE; Tue, 22 Aug 2023 06:04:04 -0700 (PDT) From: To: , Pavan Nikhilesh , "Shijith Thotton" CC: Subject: [PATCH v2] event/cnxk: add get remaining ticks routine Date: Tue, 22 Aug 2023 18:34:01 +0530 Message-ID: <20230822130402.1286-1-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230516144824.6732-1-pbhagavatula@marvell.com> References: <20230516144824.6732-1-pbhagavatula@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: mIQNGHtBvV-lkLe8O6OBe21i_ga0uivb X-Proofpoint-ORIG-GUID: mIQNGHtBvV-lkLe8O6OBe21i_ga0uivb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-22_12,2023-08-22_01,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Pavan Nikhilesh Add support to get the remaining ticks to expire for a given event timer. Signed-off-by: Pavan Nikhilesh --- doc/guides/rel_notes/release_23_11.rst | 5 ++++ drivers/event/cnxk/cnxk_tim_evdev.c | 1 + drivers/event/cnxk/cnxk_tim_evdev.h | 3 +++ drivers/event/cnxk/cnxk_tim_worker.c | 35 ++++++++++++++++++++++++++ 4 files changed, 44 insertions(+) diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst index 4411bb32c1..072f7f6959 100644 --- a/doc/guides/rel_notes/release_23_11.rst +++ b/doc/guides/rel_notes/release_23_11.rst @@ -41,6 +41,11 @@ DPDK Release 23.11 New Features ------------ +* **Updated Marvell cnxk eventdev driver.** + + Added support to get the remaining ticks to expire for a + given event timer. + .. This section should contain new features added in this release. Sample format: diff --git a/drivers/event/cnxk/cnxk_tim_evdev.c b/drivers/event/cnxk/cnxk_tim_evdev.c index 121480df15..6d59fdf909 100644 --- a/drivers/event/cnxk/cnxk_tim_evdev.c +++ b/drivers/event/cnxk/cnxk_tim_evdev.c @@ -392,6 +392,7 @@ cnxk_tim_caps_get(const struct rte_eventdev *evdev, uint64_t flags, cnxk_tim_ops.start = cnxk_tim_ring_start; cnxk_tim_ops.stop = cnxk_tim_ring_stop; cnxk_tim_ops.get_info = cnxk_tim_ring_info_get; + cnxk_tim_ops.remaining_ticks_get = cnxk_tim_remaining_ticks_get; sso_set_priv_mem_fn = priv_mem_fn; if (dev->enable_stats) { diff --git a/drivers/event/cnxk/cnxk_tim_evdev.h b/drivers/event/cnxk/cnxk_tim_evdev.h index 3a0b036cb4..b91fcb3aca 100644 --- a/drivers/event/cnxk/cnxk_tim_evdev.h +++ b/drivers/event/cnxk/cnxk_tim_evdev.h @@ -320,6 +320,9 @@ cnxk_tim_timer_cancel_burst(const struct rte_event_timer_adapter *adptr, struct rte_event_timer **tim, const uint16_t nb_timers); +int cnxk_tim_remaining_ticks_get(const struct rte_event_timer_adapter *adapter, + const struct rte_event_timer *evtim, uint64_t *ticks_remaining); + int cnxk_tim_caps_get(const struct rte_eventdev *dev, uint64_t flags, uint32_t *caps, const struct event_timer_adapter_ops **ops, diff --git a/drivers/event/cnxk/cnxk_tim_worker.c b/drivers/event/cnxk/cnxk_tim_worker.c index 923a72093b..d1dab0552f 100644 --- a/drivers/event/cnxk/cnxk_tim_worker.c +++ b/drivers/event/cnxk/cnxk_tim_worker.c @@ -171,3 +171,38 @@ cnxk_tim_timer_cancel_burst(const struct rte_event_timer_adapter *adptr, return index; } + +int +cnxk_tim_remaining_ticks_get(const struct rte_event_timer_adapter *adapter, + const struct rte_event_timer *evtim, uint64_t *ticks_remaining) +{ + struct cnxk_tim_ring *tim_ring = adapter->data->adapter_priv; + struct cnxk_tim_bkt *bkt, *current_bkt; + struct cnxk_tim_ent *entry; + uint64_t bkt_cyc, bucket; + uint64_t sema; + + if (evtim->impl_opaque[1] == 0 || evtim->impl_opaque[0] == 0) + return -ENOENT; + + entry = (struct cnxk_tim_ent *)(uintptr_t)evtim->impl_opaque[0]; + if (entry->wqe != evtim->ev.u64) + return -ENOENT; + + if (evtim->state != RTE_EVENT_TIMER_ARMED) + return -ENOENT; + + bkt = (struct cnxk_tim_bkt *)evtim->impl_opaque[1]; + sema = __atomic_load_n(&bkt->w1, __ATOMIC_ACQUIRE); + if (cnxk_tim_bkt_get_hbt(sema) || !cnxk_tim_bkt_get_nent(sema)) + return -ENOENT; + + bkt_cyc = tim_ring->tick_fn(tim_ring->tbase) - tim_ring->ring_start_cyc; + bucket = rte_reciprocal_divide_u64(bkt_cyc, &tim_ring->fast_div); + current_bkt = &tim_ring->bkt[bucket]; + + *ticks_remaining = RTE_MAX(bkt, current_bkt) - RTE_MIN(bkt, current_bkt); + /* Assume that the current bucket is yet to expire */ + *ticks_remaining += 1; + return 0; +}