From: <pbhagavatula@marvell.com>
To: <jerinj@marvell.com>, Pavan Nikhilesh <pbhagavatula@marvell.com>,
"Shijith Thotton" <sthotton@marvell.com>
Cc: <dev@dpdk.org>
Subject: [PATCH v2] event/cnxk: add get remaining ticks routine
Date: Tue, 22 Aug 2023 18:34:01 +0530 [thread overview]
Message-ID: <20230822130402.1286-1-pbhagavatula@marvell.com> (raw)
In-Reply-To: <20230516144824.6732-1-pbhagavatula@marvell.com>
From: Pavan Nikhilesh <pbhagavatula@marvell.com>
Add support to get the remaining ticks to expire for a
given event timer.
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
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;
+}
--
2.25.1
next prev parent reply other threads:[~2023-08-22 13:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 14:48 [PATCH] " pbhagavatula
2023-08-08 10:28 ` Jerin Jacob
2023-08-22 13:04 ` pbhagavatula [this message]
2023-08-24 5:29 ` [PATCH v2] " Jerin Jacob
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230822130402.1286-1-pbhagavatula@marvell.com \
--to=pbhagavatula@marvell.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=sthotton@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).