DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
To: Shijith Thotton <sthotton@marvell.com>,
	Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
Cc: Shijith Thotton <sthotton@marvell.com>,
	Jerin Jacob Kollanukkaran <jerinj@marvell.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [RFC PATCH] eventdev: use shared memory to store timer adapter
Date: Fri, 12 Feb 2021 11:03:59 +0000	[thread overview]
Message-ID: <CO6PR18MB38284CF1C8E5A8860DF36BAFDE8B9@CO6PR18MB3828.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20210212101343.689792-1-sthotton@marvell.com>



>-----Original Message-----
>From: Shijith Thotton <sthotton@marvell.com>
>Sent: Friday, February 12, 2021 3:44 PM
>To: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
>Cc: Shijith Thotton <sthotton@marvell.com>; Pavan Nikhilesh
>Bhagavatula <pbhagavatula@marvell.com>; Jerin Jacob Kollanukkaran
><jerinj@marvell.com>; dev@dpdk.org
>Subject: [RFC PATCH] eventdev: use shared memory to store timer
>adapter
>
>It is not possible for secondary process to arm timer as timer adapter
>is not stored in shared memory. Using shared memory allows the
>secondary
>to lookup adapters and arm them.
>
>Signed-off-by: Shijith Thotton <sthotton@marvell.com>
>---
> drivers/event/octeontx/timvf_evdev.c          |  20 +-
> drivers/event/octeontx/timvf_worker.c         |  12 +-
> drivers/event/octeontx2/otx2_tim_evdev.c      |  28 +--
> drivers/event/octeontx2/otx2_tim_worker.c     |   4 +-
> lib/librte_eventdev/rte_event_timer_adapter.c | 193 ++++++++++------
>--
> lib/librte_eventdev/rte_event_timer_adapter.h |  58 ++++--
> .../rte_event_timer_adapter_pmd.h             |  31 ---
> 7 files changed, 186 insertions(+), 160 deletions(-)
>

<snip>

>diff --git a/lib/librte_eventdev/rte_event_timer_adapter.c
>b/lib/librte_eventdev/rte_event_timer_adapter.c
>index dd7b83087..682b1c3c2 100644
>--- a/lib/librte_eventdev/rte_event_timer_adapter.c
>+++ b/lib/librte_eventdev/rte_event_timer_adapter.c
>@@ -26,14 +26,14 @@
> #include "rte_event_timer_adapter.h"
> #include "rte_event_timer_adapter_pmd.h"
>
>-#define DATA_MZ_NAME_MAX_LEN 64
>-#define DATA_MZ_NAME_FORMAT
>"rte_event_timer_adapter_data_%d"
>+#define EVTIM_MZ_NAME_MAX_LEN 64
>+#define EVTIM_MZ_NAME_FORMAT "rte_event_timer_adapter_%d"
>
> RTE_LOG_REGISTER(evtim_logtype, lib.eventdev.adapter.timer,
>NOTICE);
> RTE_LOG_REGISTER(evtim_buffer_logtype, lib.eventdev.adapter.timer,
>NOTICE);
> RTE_LOG_REGISTER(evtim_svc_logtype,
>lib.eventdev.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 rte_event_timer_adapter_ops swtim_ops;
>
>@@ -72,8 +72,8 @@ default_port_conf_cb(uint16_t id, uint8_t
>event_dev_id, uint8_t *event_port_id,
>
> 	RTE_SET_USED(event_dev_id);
>
>-	adapter = &adapters[id];
>-	dev = &rte_eventdevs[adapter->data->event_dev_id];
>+	adapter = adapters[id];
>+	dev = &rte_eventdevs[adapter->data.event_dev_id];
> 	dev_id = dev->data->dev_id;
> 	dev_conf = dev->data->dev_conf;
>
>@@ -118,6 +118,31 @@ default_port_conf_cb(uint16_t id, uint8_t
>event_dev_id, uint8_t *event_port_id,
> 	return ret;
> }
>
>+static int
>+rte_event_timer_adapter_init(void)
>+{
>+	const char *name = "rte_event_timer_adapter_array";
>+	const struct rte_memzone *mz;
>+	unsigned int sz;
>+
>+	sz = sizeof(*adapters) *
>RTE_EVENT_TIMER_ADAPTER_NUM_MAX;
>+	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
>+
>+	mz = rte_memzone_lookup(name);
>+	if (mz == NULL) {
>+		mz = rte_memzone_reserve_aligned(name, sz,
>rte_socket_id(), 0,
>+
>RTE_CACHE_LINE_SIZE);
>+		if (mz == NULL) {
>+			EVTIM_LOG_ERR("failed to reserve memzone
>err = %"
>+					PRId32, rte_errno);
>+			return -rte_errno;
>+		}
>+	}
>+
>+	adapters = mz->addr;

Moving adapter array to shared memory wouldn't work as adapter->ops would also be on shared mem 
and secondary processes would just replace the ops function pointers to its text section resulting in 
undefined behavior on primary and other secondaries.

The Programming model should be one process should create the timer adapter and other primary/secondaries
Should do a rte_event_timer_adapter_lookup before using the adapter_id to arm/cancel timers.

The fixup/sync between primary and secondary is done in `rte_event_timer_adapter_lookup`.
Maybe we should update the documentation regarding this.

Regards,
Pavan.

>+	return 0;
>+}
>+
> struct rte_event_timer_adapter *
> rte_event_timer_adapter_create(const struct
>rte_event_timer_adapter_conf *conf)
> {
>@@ -134,7 +159,7 @@ rte_event_timer_adapter_create_ext(
> 	uint16_t adapter_id;
> 	struct rte_event_timer_adapter *adapter;
> 	const struct rte_memzone *mz;
>-	char mz_name[DATA_MZ_NAME_MAX_LEN];
>+	char mz_name[EVTIM_MZ_NAME_MAX_LEN];
> 	int n, ret;
> 	struct rte_eventdev *dev;
>
>@@ -143,6 +168,11 @@ rte_event_timer_adapter_create_ext(
> 		return NULL;
> 	}
>
>+	if (adapters == NULL) {
>+		if (rte_event_timer_adapter_init())
>+			return NULL;
>+	}
>+
> 	/* Check eventdev ID */
> 	if (!rte_event_pmd_is_valid_dev(conf->event_dev_id)) {
> 		rte_errno = EINVAL;
>@@ -159,49 +189,51 @@ rte_event_timer_adapter_create_ext(
> 	}
>
> 	/* Check adapter ID not already allocated */
>-	adapter = &adapters[adapter_id];
>-	if (adapter->allocated) {
>+	adapter = adapters[adapter_id];
>+	if (adapter) {
>+		EVTIM_LOG_ERR("Timer adapter id %u already exists",
>adapter_id);
> 		rte_errno = EEXIST;
> 		return NULL;
> 	}
>
>-	/* Create shared data area. */
>-	n = snprintf(mz_name, sizeof(mz_name),
>DATA_MZ_NAME_FORMAT, adapter_id);
>+	/* Reserve timer adapter memory. */
>+	n = snprintf(mz_name, sizeof(mz_name),
>EVTIM_MZ_NAME_FORMAT,
>+		     adapter_id);
> 	if (n >= (int)sizeof(mz_name)) {
> 		rte_errno = EINVAL;
> 		return NULL;
> 	}
> 	mz = rte_memzone_reserve(mz_name,
>-				 sizeof(struct
>rte_event_timer_adapter_data),
>+				 sizeof(struct rte_event_timer_adapter),
> 				 conf->socket_id, 0);
> 	if (mz == NULL)
> 		/* rte_errno set by rte_memzone_reserve */
> 		return NULL;
>
>-	adapter->data = mz->addr;
>-	memset(adapter->data, 0, sizeof(struct
>rte_event_timer_adapter_data));
>+	adapter = mz->addr;
>+	memset(adapter, 0, sizeof(struct rte_event_timer_adapter));
>
>-	adapter->data->mz = mz;
>-	adapter->data->event_dev_id = conf->event_dev_id;
>-	adapter->data->id = adapter_id;
>-	adapter->data->socket_id = conf->socket_id;
>-	adapter->data->conf = *conf;  /* copy conf structure */
>+	adapter->mz = mz;
>+	adapter->data.event_dev_id = conf->event_dev_id;
>+	adapter->data.id = adapter_id;
>+	adapter->data.socket_id = conf->socket_id;
>+	adapter->data.conf = *conf;  /* copy conf structure */
>
> 	/* Query eventdev PMD for timer adapter capabilities and ops
>*/
> 	ret = dev->dev_ops->timer_adapter_caps_get(dev,
>-						   adapter->data-
>>conf.flags,
>-						   &adapter->data-
>>caps,
>+						   adapter-
>>data.conf.flags,
>+						   &adapter->data.caps,
> 						   &adapter->ops);
> 	if (ret < 0) {
> 		rte_errno = -ret;
> 		goto free_memzone;
> 	}
>
>-	if (!(adapter->data->caps &
>+	if (!(adapter->data.caps &
> 	      RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT)) {
> 		FUNC_PTR_OR_NULL_RET_WITH_ERRNO(conf_cb,
>EINVAL);
>-		ret = conf_cb(adapter->data->id, adapter->data-
>>event_dev_id,
>-			      &adapter->data->event_port_id, conf_arg);
>+		ret = conf_cb(adapter->data.id, adapter-
>>data.event_dev_id,
>+			      &adapter->data.event_port_id, conf_arg);
> 		if (ret < 0) {
> 			rte_errno = -ret;
> 			goto free_memzone;
>@@ -227,14 +259,14 @@ rte_event_timer_adapter_create_ext(
> 	adapter->arm_tmo_tick_burst = adapter->ops-
>>arm_tmo_tick_burst;
> 	adapter->cancel_burst = adapter->ops->cancel_burst;
>
>-	adapter->allocated = 1;
>+	adapters[adapter_id] = adapter;
>
> 	rte_eventdev_trace_timer_adapter_create(adapter_id,
>adapter, conf,
> 		conf_cb);
> 	return adapter;
>
> free_memzone:
>-	rte_memzone_free(adapter->data->mz);
>+	rte_memzone_free(adapter->mz);
> 	return NULL;
> }
>
>@@ -249,24 +281,24 @@ rte_event_timer_adapter_get_info(const
>struct rte_event_timer_adapter *adapter,
> 		adapter->ops->get_info(adapter, adapter_info);
>
> 	/* Set common values */
>-	adapter_info->conf = adapter->data->conf;
>-	adapter_info->event_dev_port_id = adapter->data-
>>event_port_id;
>-	adapter_info->caps = adapter->data->caps;
>+	adapter_info->conf = adapter->data.conf;
>+	adapter_info->event_dev_port_id = adapter-
>>data.event_port_id;
>+	adapter_info->caps = adapter->data.caps;
>
> 	return 0;
> }
>
> int
>-rte_event_timer_adapter_start(const struct rte_event_timer_adapter
>*adapter)
>+rte_event_timer_adapter_start(struct rte_event_timer_adapter
>*adapter)
> {
> 	int ret;
>
> 	ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
> 	FUNC_PTR_OR_ERR_RET(adapter->ops->start, -EINVAL);
>
>-	if (adapter->data->started) {
>+	if (adapter->data.started) {
> 		EVTIM_LOG_ERR("event timer adapter %"PRIu8"
>already started",
>-			      adapter->data->id);
>+			      adapter->data.id);
> 		return -EALREADY;
> 	}
>
>@@ -274,22 +306,22 @@ rte_event_timer_adapter_start(const struct
>rte_event_timer_adapter *adapter)
> 	if (ret < 0)
> 		return ret;
>
>-	adapter->data->started = 1;
>+	adapter->data.started = 1;
> 	rte_eventdev_trace_timer_adapter_start(adapter);
> 	return 0;
> }
>
> int
>-rte_event_timer_adapter_stop(const struct rte_event_timer_adapter
>*adapter)
>+rte_event_timer_adapter_stop(struct rte_event_timer_adapter
>*adapter)
> {
> 	int ret;
>
> 	ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
> 	FUNC_PTR_OR_ERR_RET(adapter->ops->stop, -EINVAL);
>
>-	if (adapter->data->started == 0) {
>+	if (adapter->data.started == 0) {
> 		EVTIM_LOG_ERR("event timer adapter %"PRIu8"
>already stopped",
>-			      adapter->data->id);
>+			      adapter->data.id);
> 		return 0;
> 	}
>
>@@ -297,7 +329,7 @@ rte_event_timer_adapter_stop(const struct
>rte_event_timer_adapter *adapter)
> 	if (ret < 0)
> 		return ret;
>
>-	adapter->data->started = 0;
>+	adapter->data.started = 0;
> 	rte_eventdev_trace_timer_adapter_stop(adapter);
> 	return 0;
> }
>@@ -305,34 +337,26 @@ rte_event_timer_adapter_stop(const struct
>rte_event_timer_adapter *adapter)
> struct rte_event_timer_adapter *
> rte_event_timer_adapter_lookup(uint16_t adapter_id)
> {
>-	char name[DATA_MZ_NAME_MAX_LEN];
>-	const struct rte_memzone *mz;
>-	struct rte_event_timer_adapter_data *data;
> 	struct rte_event_timer_adapter *adapter;
>-	int ret;
>+	char name[EVTIM_MZ_NAME_MAX_LEN];
>+	const struct rte_memzone *mz;
> 	struct rte_eventdev *dev;
>+	int ret;
>
>-	if (adapters[adapter_id].allocated)
>-		return &adapters[adapter_id]; /* Adapter is already
>loaded */
>-
>-	snprintf(name, DATA_MZ_NAME_MAX_LEN,
>DATA_MZ_NAME_FORMAT, adapter_id);
>+	snprintf(name, EVTIM_MZ_NAME_MAX_LEN,
>EVTIM_MZ_NAME_FORMAT, adapter_id);
> 	mz = rte_memzone_lookup(name);
> 	if (mz == NULL) {
> 		rte_errno = ENOENT;
> 		return NULL;
> 	}
>
>-	data = mz->addr;
>-
>-	adapter = &adapters[data->id];
>-	adapter->data = data;
>-
>-	dev = &rte_eventdevs[adapter->data->event_dev_id];
>+	adapter = mz->addr;
>+	dev = &rte_eventdevs[adapter->data.event_dev_id];
>
> 	/* Query eventdev PMD for timer adapter capabilities and ops
>*/
> 	ret = dev->dev_ops->timer_adapter_caps_get(dev,
>-						   adapter->data-
>>conf.flags,
>-						   &adapter->data-
>>caps,
>+						   adapter-
>>data.conf.flags,
>+						   &adapter->data.caps,
> 						   &adapter->ops);
> 	if (ret < 0) {
> 		rte_errno = EINVAL;
>@@ -350,37 +374,36 @@ rte_event_timer_adapter_lookup(uint16_t
>adapter_id)
> 	adapter->arm_tmo_tick_burst = adapter->ops-
>>arm_tmo_tick_burst;
> 	adapter->cancel_burst = adapter->ops->cancel_burst;
>
>-	adapter->allocated = 1;
>-
> 	return adapter;
> }
>
> int
> rte_event_timer_adapter_free(struct rte_event_timer_adapter
>*adapter)
> {
>+	uint8_t adapter_id;
> 	int ret;
>
> 	ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
> 	FUNC_PTR_OR_ERR_RET(adapter->ops->uninit, -EINVAL);
>
>-	if (adapter->data->started == 1) {
>+	if (adapter->data.started == 1) {
> 		EVTIM_LOG_ERR("event timer adapter %"PRIu8" must
>be stopped "
>-			      "before freeing", adapter->data->id);
>+			      "before freeing", adapter->data.id);
> 		return -EBUSY;
> 	}
>
>+	adapter_id = adapter->data.id;
> 	/* free impl priv data */
> 	ret = adapter->ops->uninit(adapter);
> 	if (ret < 0)
> 		return ret;
>
>-	/* free shared data area */
>-	ret = rte_memzone_free(adapter->data->mz);
>+	/* free shared adapter memory */
>+	ret = rte_memzone_free(adapter->mz);
> 	if (ret < 0)
> 		return ret;
>
>-	adapter->data = NULL;
>-	adapter->allocated = 0;
>+	adapters[adapter_id] = NULL;
>
> 	rte_eventdev_trace_timer_adapter_free(adapter);
> 	return 0;
>@@ -392,10 +415,10 @@
>rte_event_timer_adapter_service_id_get(struct
>rte_event_timer_adapter *adapter,
> {
> 	ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
>
>-	if (adapter->data->service_inited && service_id != NULL)
>-		*service_id = adapter->data->service_id;
>+	if (adapter->data.service_inited && service_id != NULL)
>+		*service_id = adapter->data.service_id;
>
>-	return adapter->data->service_inited ? 0 : -ESRCH;
>+	return adapter->data.service_inited ? 0 : -ESRCH;
> }
>
> int
>@@ -569,7 +592,7 @@ struct swtim {
> static inline struct swtim *
> swtim_pmd_priv(const struct rte_event_timer_adapter *adapter)
> {
>-	return adapter->data->adapter_priv;
>+	return adapter->data.adapter_priv;
> }
>
> static void
>@@ -635,8 +658,8 @@ swtim_callback(struct rte_timer *tim)
>
> 	if (event_buffer_batch_ready(&sw->buffer)) {
> 		event_buffer_flush(&sw->buffer,
>-				   adapter->data->event_dev_id,
>-				   adapter->data->event_port_id,
>+				   adapter->data.event_dev_id,
>+				   adapter->data.event_port_id,
> 				   &nb_evs_flushed,
> 				   &nb_evs_invalid);
>
>@@ -712,7 +735,7 @@ check_destination_event_queue(struct
>rte_event_timer *evtim,
> 	int ret;
> 	uint32_t sched_type;
>
>-	ret = rte_event_queue_attr_get(adapter->data->event_dev_id,
>+	ret = rte_event_queue_attr_get(adapter->data.event_dev_id,
> 				       evtim->ev.queue_id,
>
>RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE,
> 				       &sched_type);
>@@ -744,8 +767,8 @@ swtim_service_func(void *arg)
> 		sw->n_expired_timers = 0;
>
> 		event_buffer_flush(&sw->buffer,
>-				   adapter->data->event_dev_id,
>-				   adapter->data->event_port_id,
>+				   adapter->data.event_dev_id,
>+				   adapter->data.event_port_id,
> 				   &nb_evs_flushed,
> 				   &nb_evs_invalid);
>
>@@ -799,9 +822,9 @@ swtim_init(struct rte_event_timer_adapter
>*adapter)
> #define SWTIM_NAMESIZE 32
> 	char swtim_name[SWTIM_NAMESIZE];
> 	snprintf(swtim_name, SWTIM_NAMESIZE, "swtim_%"PRIu8,
>-			adapter->data->id);
>+			adapter->data.id);
> 	sw = rte_zmalloc_socket(swtim_name, sizeof(*sw),
>RTE_CACHE_LINE_SIZE,
>-			adapter->data->socket_id);
>+			adapter->data.socket_id);
> 	if (sw == NULL) {
> 		EVTIM_LOG_ERR("failed to allocate space for private
>data");
> 		rte_errno = ENOMEM;
>@@ -809,25 +832,25 @@ swtim_init(struct rte_event_timer_adapter
>*adapter)
> 	}
>
> 	/* Connect storage to adapter instance */
>-	adapter->data->adapter_priv = sw;
>+	adapter->data.adapter_priv = sw;
> 	sw->adapter = adapter;
>
>-	sw->timer_tick_ns = adapter->data->conf.timer_tick_ns;
>-	sw->max_tmo_ns = adapter->data->conf.max_tmo_ns;
>+	sw->timer_tick_ns = adapter->data.conf.timer_tick_ns;
>+	sw->max_tmo_ns = adapter->data.conf.max_tmo_ns;
>
> 	/* Create a timer pool */
> 	char pool_name[SWTIM_NAMESIZE];
> 	snprintf(pool_name, SWTIM_NAMESIZE,
>"swtim_pool_%"PRIu8,
>-		 adapter->data->id);
>+		 adapter->data.id);
> 	/* Optimal mempool size is a power of 2 minus one */
>-	uint64_t nb_timers = rte_align64pow2(adapter->data-
>>conf.nb_timers);
>+	uint64_t nb_timers = rte_align64pow2(adapter-
>>data.conf.nb_timers);
> 	int pool_size = nb_timers - 1;
> 	int cache_size = compute_msg_mempool_cache_size(
>-				adapter->data->conf.nb_timers,
>nb_timers);
>+				adapter->data.conf.nb_timers,
>nb_timers);
> 	flags = 0; /* pool is multi-producer, multi-consumer */
> 	sw->tim_pool = rte_mempool_create(pool_name, pool_size,
> 			sizeof(struct rte_timer), cache_size, 0, NULL,
>NULL,
>-			NULL, NULL, adapter->data->socket_id, flags);
>+			NULL, NULL, adapter->data.socket_id, flags);
> 	if (sw->tim_pool == NULL) {
> 		EVTIM_LOG_ERR("failed to create timer object
>mempool");
> 		rte_errno = ENOMEM;
>@@ -863,8 +886,8 @@ swtim_init(struct rte_event_timer_adapter
>*adapter)
> 	/* Register a service component to run adapter logic */
> 	memset(&service, 0, sizeof(service));
> 	snprintf(service.name, RTE_SERVICE_NAME_MAX,
>-		 "swtim_svc_%"PRIu8, adapter->data->id);
>-	service.socket_id = adapter->data->socket_id;
>+		 "swtim_svc_%"PRIu8, adapter->data.id);
>+	service.socket_id = adapter->data.socket_id;
> 	service.callback = swtim_service_func;
> 	service.callback_userdata = adapter;
> 	service.capabilities &= ~(RTE_SERVICE_CAP_MT_SAFE);
>@@ -881,8 +904,8 @@ swtim_init(struct rte_event_timer_adapter
>*adapter)
> 	EVTIM_LOG_DBG("registered service %s with id %"PRIu32,
>service.name,
> 		      sw->service_id);
>
>-	adapter->data->service_id = sw->service_id;
>-	adapter->data->service_inited = 1;
>+	adapter->data.service_id = sw->service_id;
>+	adapter->data.service_inited = 1;
>
> 	return 0;
> free_mempool:
>@@ -924,7 +947,7 @@ swtim_uninit(struct rte_event_timer_adapter
>*adapter)
>
> 	rte_mempool_free(sw->tim_pool);
> 	rte_free(sw);
>-	adapter->data->adapter_priv = NULL;
>+	adapter->data.adapter_priv = NULL;
>
> 	return 0;
> }
>@@ -1025,7 +1048,7 @@ __swtim_arm_burst(const struct
>rte_event_timer_adapter *adapter,
>
> #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
> 	/* Check that the service is running. */
>-	if (rte_service_runstate_get(adapter->data->service_id) != 1) {
>+	if (rte_service_runstate_get(adapter->data.service_id) != 1) {
> 		rte_errno = EINVAL;
> 		return 0;
> 	}
>@@ -1149,7 +1172,7 @@ swtim_cancel_burst(const struct
>rte_event_timer_adapter *adapter,
>
> #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
> 	/* Check that the service is running. */
>-	if (rte_service_runstate_get(adapter->data->service_id) != 1) {
>+	if (rte_service_runstate_get(adapter->data.service_id) != 1) {
> 		rte_errno = EINVAL;
> 		return 0;
> 	}
>diff --git a/lib/librte_eventdev/rte_event_timer_adapter.h
>b/lib/librte_eventdev/rte_event_timer_adapter.h
>index d2ebcb090..af9541736 100644
>--- a/lib/librte_eventdev/rte_event_timer_adapter.h
>+++ b/lib/librte_eventdev/rte_event_timer_adapter.h
>@@ -320,8 +320,7 @@ rte_event_timer_adapter_get_info(
>  *  be started before calling rte_event_timer_adapter_start().
>  */
> int
>-rte_event_timer_adapter_start(
>-		const struct rte_event_timer_adapter *adapter);
>+rte_event_timer_adapter_start(struct rte_event_timer_adapter
>*adapter);
>
> /**
>  * Stop an event timer adapter.
>@@ -338,7 +337,7 @@ rte_event_timer_adapter_start(
>  *   - -EINVAL if adapter identifier invalid
>  */
> int
>-rte_event_timer_adapter_stop(const struct rte_event_timer_adapter
>*adapter);
>+rte_event_timer_adapter_stop(struct rte_event_timer_adapter
>*adapter);
>
> /**
>  * Lookup an event timer adapter using its identifier.
>@@ -503,6 +502,34 @@ typedef uint16_t
>(*rte_event_timer_cancel_burst_t)(
> 		uint16_t nb_tims);
> /**< @internal Prevent event timers from enqueuing timer events */
>
>+/**
>+ * @internal Adapter data.
>+ */
>+struct rte_event_timer_adapter_data {
>+	uint8_t id;
>+	/**< Event timer adapter ID */
>+	uint8_t event_dev_id;
>+	/**< Event device ID */
>+	uint32_t socket_id;
>+	/**< Socket ID where memory is allocated */
>+	uint8_t event_port_id;
>+	/**< Optional: event port ID used when the inbuilt port is
>absent */
>+	struct rte_event_timer_adapter_conf conf;
>+	/**< Configuration used to configure the adapter. */
>+	uint32_t caps;
>+	/**< Adapter capabilities */
>+	void *adapter_priv;
>+	/**< Timer adapter private data*/
>+	uint8_t service_inited;
>+	/**< Service initialization state */
>+	uint32_t service_id;
>+	/**< Service ID*/
>+
>+	RTE_STD_C11
>+	uint8_t started : 1;
>+	/**< Flag to indicate adapter started. */
>+} __rte_cache_aligned;
>+
> /**
>  * @internal Data structure associated with each event timer adapter.
>  */
>@@ -513,19 +540,26 @@ struct rte_event_timer_adapter {
> 	/**< Pointer to driver arm_tmo_tick_burst function. */
> 	rte_event_timer_cancel_burst_t cancel_burst;
> 	/**< Pointer to driver cancel function. */
>-	struct rte_event_timer_adapter_data *data;
>-	/**< Pointer to shared adapter data */
>+	struct rte_event_timer_adapter_data data;
>+	/**< Event timer adapter data. */
> 	const struct rte_event_timer_adapter_ops *ops;
> 	/**< Functions exported by adapter driver */
>-
>-	RTE_STD_C11
>-	uint8_t allocated : 1;
>-	/**< Flag to indicate that this adapter has been allocated */
>+	const struct rte_memzone *mz;
>+	/**< Event timer adapter memzone pointer */
> } __rte_cache_aligned;
>
>-#define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do {
>	\
>-	if (adapter == NULL || !adapter->allocated)		\
>-		return retval;					\
>+#define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do {
>	\
>+	if (adapter == NULL) {
>	\
>+		return retval;
>	\
>+	} else {							\
>+		int i;
>	\
>+		for (i = 0; i < RTE_EVENT_TIMER_ADAPTER_NUM_MAX;
>i++) {	\
>+			if (adapters[i] == adapter)
>	\
>+				break;
>	\
>+		}
>	\
>+		if (i == RTE_EVENT_TIMER_ADAPTER_NUM_MAX)
>	\
>+			return retval;
>	\
>+	}
>	\
> } while (0)
>
> #define FUNC_PTR_OR_ERR_RET(func, errval) do {
>	\
>diff --git a/lib/librte_eventdev/rte_event_timer_adapter_pmd.h
>b/lib/librte_eventdev/rte_event_timer_adapter_pmd.h
>index cf3509dc6..0766b336e 100644
>--- a/lib/librte_eventdev/rte_event_timer_adapter_pmd.h
>+++ b/lib/librte_eventdev/rte_event_timer_adapter_pmd.h
>@@ -76,37 +76,6 @@ struct rte_event_timer_adapter_ops {
> 	/**< Cancel one or more event timers */
> };
>
>-/**
>- * @internal Adapter data; structure to be placed in shared memory to
>be
>- * accessible by various processes in a multi-process configuration.
>- */
>-struct rte_event_timer_adapter_data {
>-	uint8_t id;
>-	/**< Event timer adapter ID */
>-	uint8_t event_dev_id;
>-	/**< Event device ID */
>-	uint32_t socket_id;
>-	/**< Socket ID where memory is allocated */
>-	uint8_t event_port_id;
>-	/**< Optional: event port ID used when the inbuilt port is
>absent */
>-	const struct rte_memzone *mz;
>-	/**< Event timer adapter memzone pointer */
>-	struct rte_event_timer_adapter_conf conf;
>-	/**< Configuration used to configure the adapter. */
>-	uint32_t caps;
>-	/**< Adapter capabilities */
>-	void *adapter_priv;
>-	/**< Timer adapter private data*/
>-	uint8_t service_inited;
>-	/**< Service initialization state */
>-	uint32_t service_id;
>-	/**< Service ID*/
>-
>-	RTE_STD_C11
>-	uint8_t started : 1;
>-	/**< Flag to indicate adapter started. */
>-} __rte_cache_aligned;
>-
> #ifdef __cplusplus
> }
> #endif
>--
>2.25.1


      reply	other threads:[~2021-02-12 11:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-12 10:13 Shijith Thotton
2021-02-12 11:03 ` Pavan Nikhilesh Bhagavatula [this message]

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=CO6PR18MB38284CF1C8E5A8860DF36BAFDE8B9@CO6PR18MB3828.namprd18.prod.outlook.com \
    --to=pbhagavatula@marvell.com \
    --cc=dev@dpdk.org \
    --cc=erik.g.carrillo@intel.com \
    --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).