event/octeontx2: update start timestamp periodically
Update start timestamp periodically to prevent drift. Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
This commit is contained in:
parent
7be7d02fad
commit
79b9f3d7f8
@ -389,6 +389,31 @@ rng_mem_err:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
otx2_tim_calibrate_start_tsc(struct otx2_tim_ring *tim_ring)
|
||||||
|
{
|
||||||
|
#define OTX2_TIM_CALIB_ITER 1E6
|
||||||
|
uint32_t real_bkt, bucket;
|
||||||
|
int icount, ecount = 0;
|
||||||
|
uint64_t bkt_cyc;
|
||||||
|
|
||||||
|
for (icount = 0; icount < OTX2_TIM_CALIB_ITER; icount++) {
|
||||||
|
real_bkt = otx2_read64(tim_ring->base + TIM_LF_RING_REL) >> 44;
|
||||||
|
bkt_cyc = rte_rdtsc();
|
||||||
|
bucket = (bkt_cyc - tim_ring->ring_start_cyc) /
|
||||||
|
tim_ring->tck_int;
|
||||||
|
bucket = bucket % (tim_ring->nb_bkts);
|
||||||
|
tim_ring->ring_start_cyc = bkt_cyc - (real_bkt *
|
||||||
|
tim_ring->tck_int);
|
||||||
|
if (bucket != real_bkt)
|
||||||
|
ecount++;
|
||||||
|
}
|
||||||
|
tim_ring->last_updt_cyc = bkt_cyc;
|
||||||
|
otx2_tim_dbg("Bucket mispredict %3.2f distance %d\n",
|
||||||
|
100 - (((double)(icount - ecount) / (double)icount) * 100),
|
||||||
|
bucket - real_bkt);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
otx2_tim_ring_start(const struct rte_event_timer_adapter *adptr)
|
otx2_tim_ring_start(const struct rte_event_timer_adapter *adptr)
|
||||||
{
|
{
|
||||||
@ -423,8 +448,11 @@ otx2_tim_ring_start(const struct rte_event_timer_adapter *adptr)
|
|||||||
tim_ring->ring_start_cyc = rsp->timestarted;
|
tim_ring->ring_start_cyc = rsp->timestarted;
|
||||||
#endif
|
#endif
|
||||||
tim_ring->tck_int = NSEC2TICK(tim_ring->tck_nsec, rte_get_timer_hz());
|
tim_ring->tck_int = NSEC2TICK(tim_ring->tck_nsec, rte_get_timer_hz());
|
||||||
|
tim_ring->tot_int = tim_ring->tck_int * tim_ring->nb_bkts;
|
||||||
tim_ring->fast_div = rte_reciprocal_value_u64(tim_ring->tck_int);
|
tim_ring->fast_div = rte_reciprocal_value_u64(tim_ring->tck_int);
|
||||||
|
|
||||||
|
otx2_tim_calibrate_start_tsc(tim_ring);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#define TIM_LF_RAS_INT_W1S (0x308)
|
#define TIM_LF_RAS_INT_W1S (0x308)
|
||||||
#define TIM_LF_RAS_INT_ENA_W1S (0x310)
|
#define TIM_LF_RAS_INT_ENA_W1S (0x310)
|
||||||
#define TIM_LF_RAS_INT_ENA_W1C (0x318)
|
#define TIM_LF_RAS_INT_ENA_W1C (0x318)
|
||||||
|
#define TIM_LF_RING_REL (0x400)
|
||||||
|
|
||||||
#define TIM_BUCKET_W1_S_CHUNK_REMAINDER (48)
|
#define TIM_BUCKET_W1_S_CHUNK_REMAINDER (48)
|
||||||
#define TIM_BUCKET_W1_M_CHUNK_REMAINDER ((1ULL << (64 - \
|
#define TIM_BUCKET_W1_M_CHUNK_REMAINDER ((1ULL << (64 - \
|
||||||
@ -139,13 +140,15 @@ struct otx2_tim_evdev {
|
|||||||
|
|
||||||
struct otx2_tim_ring {
|
struct otx2_tim_ring {
|
||||||
uintptr_t base;
|
uintptr_t base;
|
||||||
struct rte_reciprocal_u64 fast_div;
|
|
||||||
uint16_t nb_chunk_slots;
|
uint16_t nb_chunk_slots;
|
||||||
uint32_t nb_bkts;
|
uint32_t nb_bkts;
|
||||||
|
uint64_t last_updt_cyc;
|
||||||
uint64_t ring_start_cyc;
|
uint64_t ring_start_cyc;
|
||||||
|
uint64_t tck_int;
|
||||||
|
uint64_t tot_int;
|
||||||
struct otx2_tim_bkt *bkt;
|
struct otx2_tim_bkt *bkt;
|
||||||
struct rte_mempool *chunk_pool;
|
struct rte_mempool *chunk_pool;
|
||||||
uint64_t tck_int;
|
struct rte_reciprocal_u64 fast_div;
|
||||||
rte_atomic64_t arm_cnt;
|
rte_atomic64_t arm_cnt;
|
||||||
uint8_t prod_type_sp;
|
uint8_t prod_type_sp;
|
||||||
uint8_t enable_stats;
|
uint8_t enable_stats;
|
||||||
|
@ -38,6 +38,23 @@ tim_format_event(const struct rte_event_timer * const tim,
|
|||||||
entry->wqe = tim->ev.u64;
|
entry->wqe = tim->ev.u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
tim_sync_start_cyc(struct otx2_tim_ring *tim_ring)
|
||||||
|
{
|
||||||
|
uint64_t cur_cyc = rte_rdtsc();
|
||||||
|
uint32_t real_bkt;
|
||||||
|
|
||||||
|
if (cur_cyc - tim_ring->last_updt_cyc > tim_ring->tot_int) {
|
||||||
|
real_bkt = otx2_read64(tim_ring->base + TIM_LF_RING_REL) >> 44;
|
||||||
|
cur_cyc = rte_rdtsc();
|
||||||
|
|
||||||
|
tim_ring->ring_start_cyc = cur_cyc -
|
||||||
|
(real_bkt * tim_ring->tck_int);
|
||||||
|
tim_ring->last_updt_cyc = cur_cyc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static __rte_always_inline uint16_t
|
static __rte_always_inline uint16_t
|
||||||
tim_timer_arm_burst(const struct rte_event_timer_adapter *adptr,
|
tim_timer_arm_burst(const struct rte_event_timer_adapter *adptr,
|
||||||
struct rte_event_timer **tim,
|
struct rte_event_timer **tim,
|
||||||
@ -49,6 +66,7 @@ tim_timer_arm_burst(const struct rte_event_timer_adapter *adptr,
|
|||||||
uint16_t index;
|
uint16_t index;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
tim_sync_start_cyc(tim_ring);
|
||||||
for (index = 0; index < nb_timers; index++) {
|
for (index = 0; index < nb_timers; index++) {
|
||||||
if (tim_arm_checks(tim_ring, tim[index]))
|
if (tim_arm_checks(tim_ring, tim[index]))
|
||||||
break;
|
break;
|
||||||
@ -99,6 +117,7 @@ tim_timer_arm_tmo_brst(const struct rte_event_timer_adapter *adptr,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tim_sync_start_cyc(tim_ring);
|
||||||
while (arr_idx < nb_timers) {
|
while (arr_idx < nb_timers) {
|
||||||
for (idx = 0; idx < OTX2_TIM_MAX_BURST && (arr_idx < nb_timers);
|
for (idx = 0; idx < OTX2_TIM_MAX_BURST && (arr_idx < nb_timers);
|
||||||
idx++, arr_idx++) {
|
idx++, arr_idx++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user