X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fevent%2Focteontx%2Ftimvf_evdev.c;h=688e9daa66afaa99b1ca0ddb7fb0884f8baa0006;hb=fdab8f2e17493192d555cd88cf28b06269174326;hp=d6a8bb355ec54a05c82278ef6faa37f89e7f4da3;hpb=4cec5aae58d1573c7208159c191d2a6529c20628;p=dpdk.git diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c index d6a8bb355e..688e9daa66 100644 --- a/drivers/event/octeontx/timvf_evdev.c +++ b/drivers/event/octeontx/timvf_evdev.c @@ -1,20 +1,13 @@ -/* - * SPDX-License-Identifier: BSD-3-Clause +/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2017 Cavium, Inc */ +#include "ssovf_evdev.h" #include "timvf_evdev.h" -int otx_logtype_timvf; +RTE_LOG_REGISTER_SUFFIX(otx_logtype_timvf, timer, NOTICE); -RTE_INIT(otx_timvf_init_log); -static void -otx_timvf_init_log(void) -{ - otx_logtype_timvf = rte_log_register("pmd.event.octeontx.timer"); - if (otx_logtype_timvf >= 0) - rte_log_set_level(otx_logtype_timvf, RTE_LOG_NOTICE); -} +static struct rte_eventdev *event_dev; struct __rte_packed timvf_mbox_dev_info { uint64_t ring_active[4]; @@ -125,7 +118,9 @@ static int timvf_ring_start(const struct rte_event_timer_adapter *adptr) { int ret; + uint8_t use_fpa = 0; uint64_t interval; + uintptr_t pool; struct timvf_ctrl_reg rctrl; struct timvf_mbox_dev_info dinfo; struct timvf_ring *timr = adptr->data->adapter_priv; @@ -155,6 +150,9 @@ timvf_ring_start(const struct rte_event_timer_adapter *adptr) return -EINVAL; } + if (!strcmp(rte_mbuf_best_mempool_ops(), "octeontx_fpavf")) + use_fpa = 1; + /*CTRL0 register.*/ rctrl.rctrl0 = interval; @@ -167,9 +165,24 @@ timvf_ring_start(const struct rte_event_timer_adapter *adptr) rctrl.rctrl2 = (uint64_t)(TIM_CHUNK_SIZE / 16) << 40; + if (use_fpa) { + pool = (uintptr_t)((struct rte_mempool *) + timr->chunk_pool)->pool_id; + ret = octeontx_fpa_bufpool_gaura(pool); + if (ret < 0) { + timvf_log_dbg("Unable to get gaura id"); + ret = -ENOMEM; + goto error; + } + timvf_write64((uint64_t)ret, + (uint8_t *)timr->vbar0 + TIM_VRING_AURA); + } else { + rctrl.rctrl1 |= 1ull << 43 /* ENA_DFB (Enable don't free) */; + } + timvf_write64((uintptr_t)timr->bkt, (uint8_t *)timr->vbar0 + TIM_VRING_BASE); - timvf_set_chunk_refill(timr); + timvf_set_chunk_refill(timr, use_fpa); if (timvf_ring_conf_set(&rctrl, timr->tim_ring_id)) { ret = -EACCES; goto error; @@ -212,21 +225,21 @@ timvf_ring_stop(const struct rte_event_timer_adapter *adptr) static int timvf_ring_create(struct rte_event_timer_adapter *adptr) { - char pool_name[25]; - int ret; - uint64_t nb_timers; struct rte_event_timer_adapter_conf *rcfg = &adptr->data->conf; + uint16_t free_idx = UINT16_MAX; + unsigned int mp_flags = 0; + struct ssovf_evdev *edev; struct timvf_ring *timr; - struct timvf_info tinfo; const char *mempool_ops; - unsigned int mp_flags = 0; - - if (timvf_info(&tinfo) < 0) - return -ENODEV; + uint8_t tim_ring_id; + char pool_name[25]; + int i, ret; - if (adptr->data->id >= tinfo.total_timvfs) + tim_ring_id = timvf_get_ring(); + if (tim_ring_id == UINT8_MAX) return -ENODEV; + edev = ssovf_pmd_priv(event_dev); timr = rte_zmalloc("octeontx_timvf_priv", sizeof(struct timvf_ring), 0); if (timr == NULL) @@ -242,16 +255,48 @@ timvf_ring_create(struct rte_event_timer_adapter *adptr) } timr->clk_src = (int) rcfg->clk_src; - timr->tim_ring_id = adptr->data->id; + timr->tim_ring_id = tim_ring_id; timr->tck_nsec = RTE_ALIGN_MUL_CEIL(rcfg->timer_tick_ns, 10); timr->max_tout = rcfg->max_tmo_ns; timr->nb_bkts = (timr->max_tout / timr->tck_nsec); timr->vbar0 = timvf_bar(timr->tim_ring_id, 0); timr->bkt_pos = (uint8_t *)timr->vbar0 + TIM_VRING_REL; - nb_timers = rcfg->nb_timers; + timr->nb_timers = rcfg->nb_timers; timr->get_target_bkt = bkt_mod; - timr->nb_chunks = nb_timers / nb_chunk_slots; + if (edev->available_events < timr->nb_timers) { + timvf_log_err( + "Max available events %"PRIu32" requested timer events %"PRIu64"", + edev->available_events, timr->nb_timers); + return -ENOMEM; + } + + for (i = 0; i < edev->tim_ring_cnt; i++) { + if (edev->tim_ring_ids[i] == UINT16_MAX) + free_idx = i; + } + + if (free_idx == UINT16_MAX) { + void *old_ptr; + + edev->tim_ring_cnt++; + old_ptr = edev->tim_ring_ids; + edev->tim_ring_ids = + rte_realloc(edev->tim_ring_ids, + sizeof(uint16_t) * edev->tim_ring_cnt, 0); + if (edev->tim_ring_ids == NULL) { + edev->tim_ring_ids = old_ptr; + edev->tim_ring_cnt--; + return -ENOMEM; + } + + edev->available_events -= timr->nb_timers; + } else { + edev->tim_ring_ids[free_idx] = tim_ring_id; + edev->available_events -= timr->nb_timers; + } + + timr->nb_chunks = timr->nb_timers / nb_chunk_slots; /* Try to optimize the bucket parameters. */ if ((rcfg->flags & RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES) @@ -275,7 +320,8 @@ timvf_ring_create(struct rte_event_timer_adapter *adptr) if (timr->bkt == NULL) goto mem_err; - snprintf(pool_name, 30, "timvf_chunk_pool%d", timr->tim_ring_id); + snprintf(pool_name, sizeof(pool_name), "timvf_chunk_pool%d", + timr->tim_ring_id); timr->chunk_pool = (void *)rte_mempool_create_empty(pool_name, timr->nb_chunks, TIM_CHUNK_SIZE, 0, 0, rte_socket_id(), mp_flags); @@ -319,8 +365,21 @@ static int timvf_ring_free(struct rte_event_timer_adapter *adptr) { struct timvf_ring *timr = adptr->data->adapter_priv; + struct ssovf_evdev *edev; + int i; + + edev = ssovf_pmd_priv(event_dev); + for (i = 0; i < edev->tim_ring_cnt; i++) { + if (edev->tim_ring_ids[i] == timr->tim_ring_id) { + edev->available_events += timr->nb_timers; + edev->tim_ring_ids[i] = UINT16_MAX; + break; + } + } + rte_mempool_free(timr->chunk_pool); rte_free(timr->bkt); + timvf_release_ring(timr->tim_ring_id); rte_free(adptr->data->adapter_priv); return 0; } @@ -385,3 +444,9 @@ timvf_timer_adapter_caps_get(const struct rte_eventdev *dev, uint64_t flags, *ops = &timvf_ops; return 0; } + +void +timvf_set_eventdevice(struct rte_eventdev *dev) +{ + event_dev = dev; +}