RTE_LOG_REGISTER_SUFFIX(evtim_buffer_logtype, adapter.timer, NOTICE);
RTE_LOG_REGISTER_SUFFIX(evtim_svc_logtype, adapter.timer.svc, NOTICE);
-static struct rte_event_timer_adapter adapters[RTE_EVENT_TIMER_ADAPTER_NUM_MAX];
+static struct rte_event_timer_adapter *adapters;
static const struct event_timer_adapter_ops swtim_ops;
int n, ret;
struct rte_eventdev *dev;
+ if (adapters == NULL) {
+ adapters = rte_zmalloc("Eventdev",
+ sizeof(struct rte_event_timer_adapter) *
+ RTE_EVENT_TIMER_ADAPTER_NUM_MAX,
+ RTE_CACHE_LINE_SIZE);
+ if (adapters == NULL) {
+ rte_errno = ENOMEM;
+ return NULL;
+ }
+ }
+
if (conf == NULL) {
rte_errno = EINVAL;
return NULL;
int ret;
struct rte_eventdev *dev;
+ if (adapters == NULL) {
+ adapters = rte_zmalloc("Eventdev",
+ sizeof(struct rte_event_timer_adapter) *
+ RTE_EVENT_TIMER_ADAPTER_NUM_MAX,
+ RTE_CACHE_LINE_SIZE);
+ if (adapters == NULL) {
+ rte_errno = ENOMEM;
+ return NULL;
+ }
+ }
+
if (adapters[adapter_id].allocated)
return &adapters[adapter_id]; /* Adapter is already loaded */
int
rte_event_timer_adapter_free(struct rte_event_timer_adapter *adapter)
{
- int ret;
+ int i, ret;
ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
FUNC_PTR_OR_ERR_RET(adapter->ops->uninit, -EINVAL);
adapter->data = NULL;
adapter->allocated = 0;
+ ret = 0;
+ for (i = 0; i < RTE_EVENT_TIMER_ADAPTER_NUM_MAX; i++)
+ if (adapters[i].allocated)
+ ret = adapters[i].allocated;
+
+ if (!ret) {
+ rte_free(adapters);
+ adapters = NULL;
+ }
+
rte_eventdev_trace_timer_adapter_free(adapter);
return 0;
}