[dpdk-dev,07/10] event/octeontx: optimize timer adapter resolution parameters
Checks
Commit Message
When application sets `RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES` flag
while creating adapter underlying driver is free to optimize the
resolution for best possible configuration.
Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
---
drivers/event/octeontx/timvf_evdev.c | 51 +++++++++++++++++++++++++++++++++++-
drivers/event/octeontx/timvf_evdev.h | 6 +++++
2 files changed, 56 insertions(+), 1 deletion(-)
Comments
-----Original Message-----
> Date: Sat, 17 Feb 2018 03:06:57 +0530
> From: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> To: jerin.jacob@caviumnetworks.com, santosh.shukla@caviumnetworks.com,
> erik.g.carrillo@intel.com
> Cc: dev@dpdk.org, Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> Subject: [dpdk-dev] [PATCH 07/10] event/octeontx: optimize timer adapter
> resolution parameters
> X-Mailer: git-send-email 2.16.1
>
> When application sets `RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES` flag
> while creating adapter underlying driver is free to optimize the
> resolution for best possible configuration.
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> ---
> drivers/event/octeontx/timvf_evdev.c | 51 +++++++++++++++++++++++++++++++++++-
> drivers/event/octeontx/timvf_evdev.h | 6 +++++
> 2 files changed, 56 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c
> index 6cf5d4846..ffdfbb387 100644
> --- a/drivers/event/octeontx/timvf_evdev.c
> +++ b/drivers/event/octeontx/timvf_evdev.c
> @@ -82,6 +82,48 @@ timvf_get_start_cyc(uint64_t *now, uint8_t ring_id)
> return octeontx_ssovf_mbox_send(&hdr, NULL, 0, now, sizeof(uint64_t));
> }
>
> +#define ALIGN_CEIL(a, b) \
> + (((a + (typeof(a)) b - 1) / ((typeof(a)) b)) * (typeof(a))b)
> +
Can this moved to common code if this not already available?
On Sat, Feb 17, 2018 at 10:36:24AM +0530, Jerin Jacob wrote:
> -----Original Message-----
> > Date: Sat, 17 Feb 2018 03:06:57 +0530
> > From: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> > To: jerin.jacob@caviumnetworks.com, santosh.shukla@caviumnetworks.com,
> > erik.g.carrillo@intel.com
> > Cc: dev@dpdk.org, Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> > Subject: [dpdk-dev] [PATCH 07/10] event/octeontx: optimize timer adapter
> > resolution parameters
> > X-Mailer: git-send-email 2.16.1
> >
> > When application sets `RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES` flag
> > while creating adapter underlying driver is free to optimize the
> > resolution for best possible configuration.
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> > ---
> > drivers/event/octeontx/timvf_evdev.c | 51 +++++++++++++++++++++++++++++++++++-
> > drivers/event/octeontx/timvf_evdev.h | 6 +++++
> > 2 files changed, 56 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c
> > index 6cf5d4846..ffdfbb387 100644
> > --- a/drivers/event/octeontx/timvf_evdev.c
> > +++ b/drivers/event/octeontx/timvf_evdev.c
> > @@ -82,6 +82,48 @@ timvf_get_start_cyc(uint64_t *now, uint8_t ring_id)
> > return octeontx_ssovf_mbox_send(&hdr, NULL, 0, now, sizeof(uint64_t));
> > }
> >
> > +#define ALIGN_CEIL(a, b) \
> > + (((a + (typeof(a)) b - 1) / ((typeof(a)) b)) * (typeof(a))b)
> > +
>
> Can this moved to common code if this not already available?
>
Currently, align macros support aligning given value to a power of 2 and not
to a given multiple.
Will move this to common code and send a seperate patch.
@@ -82,6 +82,48 @@ timvf_get_start_cyc(uint64_t *now, uint8_t ring_id)
return octeontx_ssovf_mbox_send(&hdr, NULL, 0, now, sizeof(uint64_t));
}
+#define ALIGN_CEIL(a, b) \
+ (((a + (typeof(a)) b - 1) / ((typeof(a)) b)) * (typeof(a))b)
+
+static int
+optimize_bucket_parameters(struct timvf_ring *timr)
+{
+ uint32_t hbkts;
+ uint32_t lbkts;
+ uint64_t tck_nsec;
+
+ hbkts = rte_align32pow2(timr->meta.nb_bkts);
+ tck_nsec = ALIGN_CEIL(timr->max_tout / (hbkts - 1), 10);
+
+ if ((tck_nsec < 1000 || hbkts > TIM_MAX_BUCKETS))
+ hbkts = 0;
+
+ lbkts = rte_align32lowpow2(timr->meta.nb_bkts);
+ tck_nsec = ALIGN_CEIL((timr->max_tout / (lbkts - 1)), 10);
+
+ if ((tck_nsec < 1000 || hbkts > TIM_MAX_BUCKETS))
+ lbkts = 0;
+
+ if (!hbkts && !lbkts)
+ return 0;
+
+ if (!hbkts) {
+ timr->meta.nb_bkts = lbkts;
+ goto end;
+ } else if (!lbkts) {
+ timr->meta.nb_bkts = hbkts;
+ goto end;
+ }
+
+ timr->meta.nb_bkts = (hbkts - timr->meta.nb_bkts) <
+ (timr->meta.nb_bkts - lbkts) ? hbkts : lbkts;
+end:
+ timr->meta.get_target_bkt = bkt_and;
+ timr->tck_nsec = ALIGN_CEIL((timr->max_tout /
+ (timr->meta.nb_bkts - 1)), 10);
+ return 1;
+}
+
static int
timvf_ring_start(const struct rte_event_timer_adapter *adptr)
{
@@ -215,7 +257,7 @@ timvf_ring_create(struct rte_event_timer_adapter *adptr)
}
timr->tim_ring_id = adptr->data->id;
- timr->tck_nsec = rcfg->timer_tick_ns;
+ timr->tck_nsec = ALIGN_CEIL(rcfg->timer_tick_ns, 10);
timr->max_tout = rcfg->max_tmo_ns;
timr->meta.nb_bkts = (timr->max_tout / timr->tck_nsec) + 1;
timr->vbar0 = octeontx_timvf_bar(timr->tim_ring_id, 0);
@@ -225,6 +267,13 @@ timvf_ring_create(struct rte_event_timer_adapter *adptr)
timr->nb_chunks = nb_timers / nb_chunk_slots;
+ /* Try to optimize the bucket parameters. */
+ if ((rcfg->flags & RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES)
+ && !rte_is_power_of_2(timr->meta.nb_bkts)) {
+ optimize_bucket_parameters(timr);
+ timvf_log_info("Optimizing configured values");
+ }
+
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");
@@ -184,6 +184,12 @@ bkt_mod(uint32_t rel_bkt, uint32_t nb_bkts)
return rel_bkt % nb_bkts;
}
+static __rte_always_inline uint32_t __hot
+bkt_and(uint32_t rel_bkt, uint32_t nb_bkts)
+{
+ return rel_bkt & (nb_bkts - 1);
+}
+
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_reg_brst(const struct rte_event_timer_adapter *adptr,