[dpdk-dev,v5,11/20] event/sw: add start stop and close functions

Message ID 1490374395-149320-12-git-send-email-harry.van.haaren@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Van Haaren, Harry March 24, 2017, 4:53 p.m. UTC
  From: Bruce Richardson <bruce.richardson@intel.com>

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 drivers/event/sw/sw_evdev.c | 74 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
  

Comments

Jerin Jacob March 27, 2017, 4:02 p.m. UTC | #1
On Fri, Mar 24, 2017 at 04:53:06PM +0000, Harry van Haaren wrote:
> From: Bruce Richardson <bruce.richardson@intel.com>
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> ---
>  drivers/event/sw/sw_evdev.c | 74 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 74 insertions(+)
> 
> diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
> index b1ae2b6..d4d6d7f 100644
> --- a/drivers/event/sw/sw_evdev.c
> +++ b/drivers/event/sw/sw_evdev.c
> @@ -440,6 +440,77 @@ sw_info_get(struct rte_eventdev *dev, struct rte_event_dev_info *info)
>  }
>  
>  static int
> +sw_start(struct rte_eventdev *dev)
> +{
> +	unsigned int i, j;
> +	struct sw_evdev *sw = sw_pmd_priv(dev);
> +	/* check all ports are set up */
> +	for (i = 0; i < sw->port_count; i++)
> +		if (sw->ports[i].rx_worker_ring == NULL) {
> +			printf("%s %d: port %d not configured\n",
> +			       __func__, __LINE__, i);

s/printf/SW_LOG_ERR

> +			return -1;

Is it possible to have better error code than -1?

> +		}
> +
> +	/* check all queues are configured and mapped to ports*/
> +	for (i = 0; i < sw->qid_count; i++)
> +		if (sw->qids[i].iq[0] == NULL ||
> +				sw->qids[i].cq_num_mapped_cqs == 0) {
> +			printf("%s %d: queue %d not configured\n",
> +			       __func__, __LINE__, i);
> +			return -1;

ditto

> +		}
> +
> +	/* build up our prioritized array of qids */
> +	/* We don't use qsort here, as if all/multiple entries have the same
> +	 * priority, the result is non-deterministic. From "man 3 qsort":
> +	 * "If two members compare as equal, their order in the sorted
> +	 * array is undefined."
> +	 */
> +	uint32_t qidx = 0;
> +	for (j = 0; j <= RTE_EVENT_DEV_PRIORITY_LOWEST; j++) {
> +		for (i = 0; i < sw->qid_count; i++) {
> +			if (sw->qids[i].priority == j) {
> +				sw->qids_prioritized[qidx] = &sw->qids[i];
> +				qidx++;
> +			}
> +		}
> +	}
> +	sw->started = 1;

Do we need rte_smp_wmb() here to update correct sw->started status on other core,
as sw_event_schedule() uses sw->started?

> +	return 0;
> +}
> +
> +static void
> +sw_stop(struct rte_eventdev *dev)
> +{
> +	struct sw_evdev *sw = sw_pmd_priv(dev);
> +	sw->started = 0;

Same as above?

> +}
> +
> +static int
> +sw_close(struct rte_eventdev *dev)
> +{
> +	struct sw_evdev *sw = sw_pmd_priv(dev);
> +	uint32_t i;
> +
> +	for (i = 0; i < sw->qid_count; i++)
> +		sw_queue_release(dev, i);
> +	sw->qid_count = 0;
> +
> +	for (i = 0; i < sw->port_count; i++)
> +		sw_port_release(&sw->ports[i]);
> +	sw->port_count = 0;
> +
> +	memset(&sw->stats, 0, sizeof(sw->stats));
> +	sw->sched_called = 0;
> +	sw->sched_no_iq_enqueues = 0;
> +	sw->sched_no_cq_enqueues = 0;
> +	sw->sched_cq_qid_called = 0;
> +
> +	return 0;
> +}
> +
> +static int
>  assign_numa_node(const char *key __rte_unused, const char *value, void *opaque)
>  {
>  	int *socket_id = opaque;
> @@ -475,6 +546,9 @@ sw_probe(const char *name, const char *params)
>  	static const struct rte_eventdev_ops evdev_sw_ops = {
>  			.dev_configure = sw_dev_configure,
>  			.dev_infos_get = sw_info_get,
> +			.dev_close = sw_close,
> +			.dev_start = sw_start,
> +			.dev_stop = sw_stop,
>  
>  			.queue_def_conf = sw_queue_def_conf,
>  			.queue_setup = sw_queue_setup,
> -- 
> 2.7.4
>

With suggested changes,
Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
  

Patch

diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index b1ae2b6..d4d6d7f 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -440,6 +440,77 @@  sw_info_get(struct rte_eventdev *dev, struct rte_event_dev_info *info)
 }
 
 static int
+sw_start(struct rte_eventdev *dev)
+{
+	unsigned int i, j;
+	struct sw_evdev *sw = sw_pmd_priv(dev);
+	/* check all ports are set up */
+	for (i = 0; i < sw->port_count; i++)
+		if (sw->ports[i].rx_worker_ring == NULL) {
+			printf("%s %d: port %d not configured\n",
+			       __func__, __LINE__, i);
+			return -1;
+		}
+
+	/* check all queues are configured and mapped to ports*/
+	for (i = 0; i < sw->qid_count; i++)
+		if (sw->qids[i].iq[0] == NULL ||
+				sw->qids[i].cq_num_mapped_cqs == 0) {
+			printf("%s %d: queue %d not configured\n",
+			       __func__, __LINE__, i);
+			return -1;
+		}
+
+	/* build up our prioritized array of qids */
+	/* We don't use qsort here, as if all/multiple entries have the same
+	 * priority, the result is non-deterministic. From "man 3 qsort":
+	 * "If two members compare as equal, their order in the sorted
+	 * array is undefined."
+	 */
+	uint32_t qidx = 0;
+	for (j = 0; j <= RTE_EVENT_DEV_PRIORITY_LOWEST; j++) {
+		for (i = 0; i < sw->qid_count; i++) {
+			if (sw->qids[i].priority == j) {
+				sw->qids_prioritized[qidx] = &sw->qids[i];
+				qidx++;
+			}
+		}
+	}
+	sw->started = 1;
+	return 0;
+}
+
+static void
+sw_stop(struct rte_eventdev *dev)
+{
+	struct sw_evdev *sw = sw_pmd_priv(dev);
+	sw->started = 0;
+}
+
+static int
+sw_close(struct rte_eventdev *dev)
+{
+	struct sw_evdev *sw = sw_pmd_priv(dev);
+	uint32_t i;
+
+	for (i = 0; i < sw->qid_count; i++)
+		sw_queue_release(dev, i);
+	sw->qid_count = 0;
+
+	for (i = 0; i < sw->port_count; i++)
+		sw_port_release(&sw->ports[i]);
+	sw->port_count = 0;
+
+	memset(&sw->stats, 0, sizeof(sw->stats));
+	sw->sched_called = 0;
+	sw->sched_no_iq_enqueues = 0;
+	sw->sched_no_cq_enqueues = 0;
+	sw->sched_cq_qid_called = 0;
+
+	return 0;
+}
+
+static int
 assign_numa_node(const char *key __rte_unused, const char *value, void *opaque)
 {
 	int *socket_id = opaque;
@@ -475,6 +546,9 @@  sw_probe(const char *name, const char *params)
 	static const struct rte_eventdev_ops evdev_sw_ops = {
 			.dev_configure = sw_dev_configure,
 			.dev_infos_get = sw_info_get,
+			.dev_close = sw_close,
+			.dev_start = sw_start,
+			.dev_stop = sw_stop,
 
 			.queue_def_conf = sw_queue_def_conf,
 			.queue_setup = sw_queue_setup,